os/persistentdata/traceservices/commsdebugutility/TE_commsdebugutility/src/step_024_xx.cpp
Update contrib.
     1 // Copyright (c) 2003-2010 Nokia Corporation and/or its subsidiary(-ies).
 
     2 // All rights reserved.
 
     3 // This component and the accompanying materials are made available
 
     4 // under the terms of "Eclipse Public License v1.0"
 
     5 // which accompanies this distribution, and is available
 
     6 // at the URL "http://www.eclipse.org/legal/epl-v10.html".
 
     8 // Initial Contributors:
 
     9 // Nokia Corporation - initial contribution.
 
    14 // This contains Flogger Unit Test Case 024.xx
 
    20 // Test system includes
 
    21 #include "teststepcomsdbg.h"
 
    22 #include "TestMessage.h"
 
    23 #include "step_024_xx.h"
 
    25 #include <comms-infras/commsdebugutility.h>
 
    28 const TInt KFiveSeconds = 5000000;
 
    29 const TInt KMaxConnection = 500; ///< specify a lot of connections for the connection stress test 
 
    30 const TInt KTimeBetConnection = 100000; //Some time between connection
 
    31 const TInt KDelayToCheckWrite = 10000000; //Give some time for the flogger to write the message before checking. Replaces KTimeToLog which is normally used.
 
    35 * Function  Name : CFloggerTest024_01
 
    36 * Input parameters : None
 
    37 * Output parameters : None
 
    38 * Description : This is the constructor
 
    42 CFloggerTest024_01::CFloggerTest024_01()
 
    44 	// Store the name of this test case
 
    45 	SetTestStepName(_L("step_024_01"));
 
    50 * Function  Name :~ CFloggerTest024_01
 
    51 * Input parameters : None
 
    52 * Output parameters : None
 
    53 * Description : This is the Destructor
 
    57 CFloggerTest024_01::~CFloggerTest024_01()
 
    63 * Function  Name	: doTestStepL
 
    64 * Input parameters	: None
 
    65 * Output parameters : TVerdict 
 
    66 * Description		: This function returns weather the test case 024_01 has 
 
    72 TVerdict CFloggerTest024_01::doTestStepL( )
 
    75 	INFO_PRINTF1(_L("Step 024.01 called "));
 
    76 	if ( executeStepL() == KErrNone  )
 
    77 		SetTestStepResult(EPass);
 
    80 		SetTestStepResult(EFail);
 
    83 	return TestStepResult();
 
    88 * Function  Name		: executeStepL
 
    89 * Input parameters		: None
 
    90 * Output parameters		: TInt 
 
    91 * Description 			: This function sets the subsystem and component name
 
    92 * 						  checks weather they are set in the log file correctly
 
    98 TInt CFloggerTest024_01::executeStepL()
 
   100 	return DoTestWrite();
 
   104 * Function  Name		: executeStepL
 
   105 * Input parameters		: None
 
   106 * Output parameters		: TInt 
 
   107 * Description 			: This function sets the subsystem and component name
 
   108 * 						  checks weather they are set in the log file correctly
 
   114 TInt CFloggerTest024_01::executeStepL(TBool)
 
   119 * Function  Name		: DoTestWriteL
 
   120 * Input parameters		: None
 
   121 * Output parameters		: TInt 
 
   122 * Description 			: This function checks the weather test data was written
 
   123 * 						  in to the log file by DoTestWriteL() or not.
 
   128 TInt CFloggerTest024_01::DoTestWrite()
 
   132 	ptrSubSystem.Set(_L8("SubSystem"));
 
   133 	ptrComponent.Set(_L8("Component"));
 
   135 	_LIT8(KTestMessage1 ,"TC NO 24: This is test message before sleep");
 
   136 	_LIT8(KTestMessage2 ,"TC NO 24: This is test message After sleep");
 
   138 	TInt ret = KErrGeneral;
 
   139 	RFileLogger theFlogger;
 
   141 	ret = theFlogger.Connect();
 
   144 		ret = theFlogger.SetLogTags(ptrSubSystem, ptrComponent);
 
   147 			ret = theFlogger.ClearLog();
 
   150 				theFlogger.Write(KTestMessage1); //Write the test descriptor before sleep
 
   151 				User::After(KFiveSeconds); // Call After() function
 
   152 				theFlogger.Write(KTestMessage2); //Write the test descriptor after sleep
 
   153 				User::After(KFiveSeconds);
 
   155 				TRAPD(r, ret = DoTestCheckWriteL()); // Check whether the message is present in log
 
   164 		theFlogger.__DbgShutDownServer();
 
   171 * Function  Name		: DoTestCheckWriteL
 
   172 * Input parameters		: None
 
   173 * Output parameters		: TInt 
 
   174 * Description 			: This function checks the weather test data was written
 
   175 * 						  in to the log file by DoTestWriteL() or not.
 
   180 TInt CFloggerTest024_01::DoTestCheckWriteL()
 
   184 	_LIT(KTestString,"Time");
 
   188 	RFs iFileSystem; //For file operation create a file system
 
   189 	TBuf8<256> testData; //To hold the test descriptor
 
   191 	User::LeaveIfError(iFileSystem.Connect());
 
   193 	//Open the file in the read mode
 
   194 	User::LeaveIfError(theFile.Open(iFileSystem, KFloggerOutputFile, EFileWrite|EFileShareAny)); 
 
   195 	CleanupClosePushL(theFile);
 
   197 	User::LeaveIfError(theFile.Size(listfilesize)); //Size of the file
 
   199 	hBuffer = HBufC8::New(listfilesize); //Allocate the buffer
 
   200 	CleanupStack::PushL(hBuffer);
 
   201 	TPtr8 ptrString = hBuffer->Des();  ; //To hold the buffer
 
   203 	// Read from position 0: start of file
 
   204 	User::LeaveIfError(theFile.Read(ptrString));
 
   206 	testData.Copy(KTestString); //Copy the test string to be tested
 
   208 	TPtrC8 ptrTmpBuffer = ptrString.Right(listfilesize); //Copy of the orginal buffer read from the file
 
   214 	charCount1 = ptrString.Find(testData);
 
   215 	while(charCount1 != KErrNotFound)
 
   217 		lineCount++; //Increment the line count since we just found another one
 
   218 		charCount2 = charCount2 + charCount1 + KSampleTimeLine().Length(); //the the number of char's present in the line which
 
   219 										// is constant for the line starting with "#Time" in the log file
 
   221 		tmpCount = listfilesize - charCount2; // Remaining string after the "Time" is read
 
   222 		TPtrC8 strTmp = ptrString.Right(tmpCount);
 
   223 		charCount1 = strTmp.Find(testData);
 
   224 		if (charCount1 == 0) //Since the Time is found at the zeroth position count1 will contain 0
 
   225 			charCount1 = charCount1 + 4; // Charecter count of Time is 4
 
   226 		ptrString = ptrTmpBuffer.Right(listfilesize); // Get back the orginal buffer 
 
   229 	CleanupStack::PopAndDestroy(hBuffer);
 
   230 	CleanupStack::PopAndDestroy();	//theFile
 
   232 	// we expect to find the word "TIME" 10 times (or more) - 5 during each delay.
 
   233 	if ((lineCount >= 10) && (lineCount <= 12))
 
   247 _LIT8(KTestStringWithPunctuation1,"                                                 /===-_---~~~~~~~~~------____"); _LIT8(KTestStringWithPunctuation26,"    `~/  )` ) ,/|                 ~-_~>--<_/-__       __-~ _/ ");
 
   248 _LIT8(KTestStringWithPunctuation2,"                 -==\\\\                         `//~\\\\   ~~~~`---.___.-~~"); _LIT8(KTestStringWithPunctuation27,"   ;'( ')/ ,)(                              ~~~~~~~~~~ ");
 
   249 _LIT8(KTestStringWithPunctuation3,"       __--~~~  ,-/-==\\\\                        | |   `\\        ,'"); _LIT8(KTestStringWithPunctuation19,"                  \\_|      /        _)   ;  ),   __--~~");
 
   250 _LIT8(KTestStringWithPunctuation4,"  .'        /       |   \\\\                   /' /        \\   /'");              _LIT8(KTestStringWithPunctuation21,"                  |0  0 _/) )-~     | |__>--<__|      |");
 
   251 _LIT8(KTestStringWithPunctuation5,"/-'~    ~~~~~---__  |     ~-/~         ( )   /'        _--~`");                    _LIT8(KTestStringWithPunctuation20,"                   {\\__--_/}    / \\\\_>- )<__\\      \\");
 
   252 _LIT8(KTestStringWithPunctuation6,"                    '~~--_/      _-~/-  / \\   '-~ \\");                           _LIT8(KTestStringWithPunctuation22,"                 o o _//        /-~_>---<__-~      /");
 
   253 _LIT8(KTestStringWithPunctuation15,"                                                |===-~___                _,-'");  _LIT8(KTestStringWithPunctuation24,"            ( ( '))          |__>--<__|    |                 /' _---_~\\");
 
   254 _LIT8(KTestStringWithPunctuation16,"             ______-==|                         | |  \\\\           _-~`");       _LIT8(KTestStringWithPunctuation23,"                ,/|           /__>--<__/     _-~");
 
   255 _LIT8(KTestStringWithPunctuation17,"    _-~       /'    |  \\\\                      / /      \\      /");           _LIT8(KTestStringWithPunctuation25,"        ,/,'//( (             \\__>--<__\\    \\            /'  //        ||");
 
   256 _LIT8(KTestStringWithPunctuation18," /  ____  /         |    \\`\\.__/-~~ ~ \\ _ _/'  /          \\/'");
 
   257 _LIT8(KTestStringWithPunctuationExpected1,"         `-)) )) (           |__>--<__|    |               /'  /     ~\\`\\");
 
   258 _LIT8(KTestStringWithPunctuationExpected2,"                 o o _//        /-~_>---<__-~      /");
 
   259 _LIT8(KTestStringWithPunctuationExpected3,"    `~/  )` ) ,/|                 ~-_~>--<_/-__       __-~ _/ ");
 
   264 * CFloggerTest024_02 - test static write with string with beeps, tabs, nulls, CR's, LFs in the tags
 
   265 * doTestStep returns whether test case passed or failed.
 
   271 CFloggerTest024_02::CFloggerTest024_02()
 
   273 	// Store the name of this test case
 
   274 	SetTestStepName(_L("step_024_02"));
 
   280 CFloggerTest024_02::~CFloggerTest024_02()
 
   287 TVerdict CFloggerTest024_02::doTestStepL( )
 
   289 	if ( executeStepL() == KErrNone  )
 
   290 		SetTestStepResult(EPass);
 
   293 		SetTestStepResult(EFail);
 
   296 	return TestStepResult();
 
   300 TInt CFloggerTest024_02::executeStepL(TBool)
 
   305 TInt CFloggerTest024_02::executeStepL()
 
   309 	// clear the old log messages
 
   311 	ret = flogger.Connect();
 
   313 	if ( ret == KErrNone )
 
   315 		flogger.SetLogTags(KStdSubsysTag8, KStdCompTag8);
 
   319 		RFileLogger::Write(KSubsysTagWithEscapeChars8, KCompTagWithEscapeChars8,KTestMessage8);
 
   321 		User::After(KTimeToLog);
 
   323 		TRAPD(r, ret = DoTestCheckWriteL());
 
   334 TInt CFloggerTest024_02::DoTestCheckWriteL()
 
   338 	TInt listfilesize,returnCode;
 
   339 	RFs fileSystem; //For file operation create a file system
 
   340 	TInt numSuccessful = 0;
 
   342 	User::LeaveIfError(fileSystem.Connect());
 
   344 	//Open the file in the read mode
 
   345 	User::LeaveIfError(logFile.Open(fileSystem,KFloggerOutputFile,EFileRead));
 
   347 	CleanupClosePushL(logFile);
 
   349 	User::LeaveIfError(logFile.Size(listfilesize)); //Size of the file
 
   351 	hBuffer = HBufC8::New(listfilesize); //Allocate the buffer
 
   352 	CleanupStack::PushL(hBuffer);
 
   354 	TPtr8 ptrString = hBuffer->Des();  ; //To access the buffer
 
   356 	// Read from position 0: start of file
 
   357 	User::LeaveIfError(returnCode = logFile.Read(ptrString));
 
   359 	// flogger should not have logged
 
   360 	returnCode = ptrString.Find(KTestMessage8);
 
   362 	if (returnCode == KErrNotFound)
 
   368 	CleanupStack::PopAndDestroy(hBuffer);
 
   369 	CleanupStack::PopAndDestroy();	//logFile
 
   370 	if (numSuccessful == 1)
 
   380 * CFloggerTest024_03 - test static write with string with punctuation and spaces in the data
 
   381 * doTestStep returns whether test case passed or failed.
 
   384 _LIT8(KTestStringWithPunctuation8,"                  / /~ ,_/       / /__>---<__/      |  ");
 
   385 _LIT8(KTestStringWithPunctuation14,"  ' ') '( (/");
 
   386 _LIT8(KTestStringWithPunctuation9,"                 (^(~          /~_>---<__-      _-~");
 
   387 _LIT8(KTestStringWithPunctuation7,"                   /'   (_/  _-~  | |__>--<__|      | ");
 
   388 _LIT8(KTestStringWithPunctuation11,"         `-)) )) (           |__>--<__|    |               /'  /     ~\\`\\");
 
   389 _LIT8(KTestStringWithPunctuation12,"      ,( ( ((, ))              ~-__>--<_~-_  ~--____---~' _/'/        /'");
 
   390 _LIT8(KTestStringWithPunctuation10,"             ,//('(          |__>--<__|     /                  .----_ ");
 
   391 _LIT8(KTestStringWithPunctuation13,"  ._-~//( )/ )) `                    ~~-'_/_/ /~~~~~~~__--~ ");
 
   394 CFloggerTest024_03::CFloggerTest024_03()
 
   396 	// Store the name of this test case
 
   397 	SetTestStepName(_L("step_024_03"));
 
   403 CFloggerTest024_03::~CFloggerTest024_03()
 
   410 TVerdict CFloggerTest024_03::doTestStepL( )
 
   412 	if ( executeStepL() == KErrNone  )
 
   413 		SetTestStepResult(EPass);
 
   416 		SetTestStepResult(EFail);
 
   419 	return TestStepResult();
 
   423 TInt CFloggerTest024_03::executeStepL(TBool)
 
   428 TInt CFloggerTest024_03::executeStepL()
 
   432 	// clear the old log messages
 
   434 	ret = flogger.Connect();
 
   436 	if ( ret == KErrNone )
 
   438 		flogger.SetLogTags(KStdSubsysTag8, KStdCompTag8);
 
   442 		RFileLogger::Write(KStdSubsysTag8, KStdCompTag8,KTestStringWithPunctuation1);
 
   443 		RFileLogger::Write(KStdSubsysTag8, KStdCompTag8,KTestStringWithPunctuation15);
 
   444 		RFileLogger::Write(KStdSubsysTag8, KStdCompTag8,KTestStringWithPunctuation2);
 
   445 		RFileLogger::Write(KStdSubsysTag8, KStdCompTag8,KTestStringWithPunctuation16);
 
   446 		RFileLogger::Write(KStdSubsysTag8, KStdCompTag8,KTestStringWithPunctuation3);
 
   447 		RFileLogger::Write(KStdSubsysTag8, KStdCompTag8,KTestStringWithPunctuation17);
 
   448 		RFileLogger::Write(KStdSubsysTag8, KStdCompTag8,KTestStringWithPunctuation4);
 
   449 		RFileLogger::Write(KStdSubsysTag8, KStdCompTag8,KTestStringWithPunctuation18);
 
   450 		RFileLogger::Write(KStdSubsysTag8, KStdCompTag8,KTestStringWithPunctuation5);
 
   451 		RFileLogger::Write(KStdSubsysTag8, KStdCompTag8,KTestStringWithPunctuation19);
 
   452 		RFileLogger::Write(KStdSubsysTag8, KStdCompTag8,KTestStringWithPunctuation6);
 
   453 		RFileLogger::Write(KStdSubsysTag8, KStdCompTag8,KTestStringWithPunctuation20);
 
   454 		RFileLogger::Write(KStdSubsysTag8, KStdCompTag8,KTestStringWithPunctuation7);
 
   455 		RFileLogger::Write(KStdSubsysTag8, KStdCompTag8,KTestStringWithPunctuation21);
 
   456 		RFileLogger::Write(KStdSubsysTag8, KStdCompTag8,KTestStringWithPunctuation8);
 
   457 		RFileLogger::Write(KStdSubsysTag8, KStdCompTag8,KTestStringWithPunctuation22);
 
   458 		RFileLogger::Write(KStdSubsysTag8, KStdCompTag8,KTestStringWithPunctuation9);
 
   459 		RFileLogger::Write(KStdSubsysTag8, KStdCompTag8,KTestStringWithPunctuation23);
 
   460 		RFileLogger::Write(KStdSubsysTag8, KStdCompTag8,KTestStringWithPunctuation10);
 
   461 		RFileLogger::Write(KStdSubsysTag8, KStdCompTag8,KTestStringWithPunctuation24);
 
   462 		RFileLogger::Write(KStdSubsysTag8, KStdCompTag8,KTestStringWithPunctuation11);
 
   463 		RFileLogger::Write(KStdSubsysTag8, KStdCompTag8,KTestStringWithPunctuation25);
 
   464 		RFileLogger::Write(KStdSubsysTag8, KStdCompTag8,KTestStringWithPunctuation12);
 
   465 		RFileLogger::Write(KStdSubsysTag8, KStdCompTag8,KTestStringWithPunctuation26);
 
   466 		RFileLogger::Write(KStdSubsysTag8, KStdCompTag8,KTestStringWithPunctuation13);
 
   467 		RFileLogger::Write(KStdSubsysTag8, KStdCompTag8,KTestStringWithPunctuation27);
 
   468 		RFileLogger::Write(KStdSubsysTag8, KStdCompTag8,KTestStringWithPunctuation14);
 
   470 		User::After(KTimeToLog);
 
   472 		TRAPD(r, ret = DoTestCheckWriteL());
 
   483 TInt CFloggerTest024_03::DoTestCheckWriteL()
 
   487 	TInt listfilesize,returnCode;
 
   488 	RFs fileSystem; //For file operation create a file system
 
   489 	TInt numSuccessful = 0;
 
   491 	User::LeaveIfError(fileSystem.Connect());
 
   493 	//Open the file in the read mode
 
   494 	User::LeaveIfError(logFile.Open(fileSystem,KFloggerOutputFile,EFileRead));
 
   496 	CleanupClosePushL(logFile);
 
   498 	User::LeaveIfError(logFile.Size(listfilesize)); //Size of the file
 
   500 	hBuffer = HBufC8::New(listfilesize); //Allocate the buffer
 
   501 	CleanupStack::PushL(hBuffer);
 
   503 	TPtr8 ptrString = hBuffer->Des();  ; //To access the buffer
 
   505 	// Read from position 0: start of file
 
   506 	User::LeaveIfError(returnCode = logFile.Read(ptrString));
 
   508 	// check that flogger logged the punctuation/spaces correctly by checking three samples
 
   509 	returnCode = ptrString.Find(KTestStringWithPunctuationExpected1);
 
   516 	returnCode = ptrString.Find(KTestStringWithPunctuationExpected2);
 
   523 	returnCode = ptrString.Find(KTestStringWithPunctuationExpected3);
 
   531 	CleanupStack::PopAndDestroy(hBuffer);
 
   532 	CleanupStack::PopAndDestroy();	//logFile
 
   533 	if (numSuccessful == 3)
 
   543 * CFloggerTest024_04 - test static write with data string with beeps, tabs, nulls, CR's, LFs in it
 
   544 * doTestStep returns whether test case passed or failed.
 
   547 CFloggerTest024_04::CFloggerTest024_04()
 
   549 	// Store the name of this test case
 
   550 	SetTestStepName(_L("step_024_04"));
 
   556 CFloggerTest024_04::~CFloggerTest024_04()
 
   563 TVerdict CFloggerTest024_04::doTestStepL( )
 
   565 	if ( executeStepL() == KErrNone  )
 
   566 		SetTestStepResult(EPass);
 
   569 		SetTestStepResult(EFail);
 
   572 	return TestStepResult();
 
   576 TInt CFloggerTest024_04::executeStepL(TBool)
 
   581 TInt CFloggerTest024_04::executeStepL()
 
   585 	// clear the old log messages
 
   587 	ret = flogger.Connect();
 
   589 	if ( ret == KErrNone )
 
   591 		flogger.SetLogTags(KStdSubsysTag8, KStdCompTag8);
 
   595 		RFileLogger::Write(KStdSubsysTag8, KStdCompTag8,KTestMessageWithEscapeChars8);
 
   597 		User::After(KTimeToLog);
 
   599 		TRAPD(r, ret = DoTestCheckWriteL());
 
   610 TInt CFloggerTest024_04::DoTestCheckWriteL()
 
   614 	TInt listfilesize,returnCode;
 
   615 	RFs fileSystem; //For file operation create a file system
 
   616 	TInt numSuccessful = 0;
 
   618 	User::LeaveIfError(fileSystem.Connect());
 
   620 	//Open the file in the read mode
 
   621 	User::LeaveIfError(logFile.Open(fileSystem,KFloggerOutputFile,EFileRead));
 
   623 	CleanupClosePushL(logFile);
 
   625 	User::LeaveIfError(logFile.Size(listfilesize)); //Size of the file
 
   627 	hBuffer = HBufC8::New(listfilesize); //Allocate the buffer
 
   628 	CleanupStack::PushL(hBuffer);
 
   630 	TPtr8 ptrString = hBuffer->Des();  ; //To access the buffer
 
   632 	// Read from position 0: start of file
 
   633 	User::LeaveIfError(returnCode = logFile.Read(ptrString));
 
   635 	// flogger will have logged the string exactly as it was sent. The CR/LF will not
 
   636 	// cause a line feed because they are not adjacent
 
   637 	returnCode = ptrString.Find(KTestMessageWithEscapeChars8);
 
   645 	CleanupStack::PopAndDestroy(hBuffer);
 
   646 	CleanupStack::PopAndDestroy();	//logFile
 
   647 	if (numSuccessful == 1)
 
   658 * CFloggerTest024_05 - test static write with data string with char 255, nulls, and escapes in it
 
   659 * doTestStep returns whether test case passed or failed.
 
   662 CFloggerTest024_05::CFloggerTest024_05()
 
   664 	// Store the name of this test case
 
   665 	SetTestStepName(_L("step_024_05"));
 
   671 CFloggerTest024_05::~CFloggerTest024_05()
 
   678 TVerdict CFloggerTest024_05::doTestStepL( )
 
   680 	if ( executeStepL() == KErrNone  )
 
   681 		SetTestStepResult(EPass);
 
   684 		SetTestStepResult(EFail);
 
   687 	return TestStepResult();
 
   690 TInt CFloggerTest024_05::executeStepL(TBool)
 
   696 TInt CFloggerTest024_05::executeStepL()
 
   700 	// clear the old log messages
 
   702 	ret = flogger.Connect();
 
   704 	if ( ret == KErrNone )
 
   706 		flogger.SetLogTags(KStdSubsysTag8, KStdCompTag8);
 
   710 		RFileLogger::Write(KStdSubsysTag8, KStdCompTag8,K2ndTestMessageWithEscapeChars8);
 
   712 		User::After(KTimeToLog);
 
   714 		TRAPD(r, ret = DoTestCheckWriteL());
 
   725 TInt CFloggerTest024_05::DoTestCheckWriteL()
 
   729 	TInt listfilesize,returnCode;
 
   730 	RFs fileSystem; //For file operation create a file system
 
   731 	TInt numSuccessful = 0;
 
   733 	User::LeaveIfError(fileSystem.Connect());
 
   735 	//Open the file in the read mode
 
   736 	User::LeaveIfError(logFile.Open(fileSystem,KFloggerOutputFile,EFileRead));
 
   738 	CleanupClosePushL(logFile);
 
   740 	User::LeaveIfError(logFile.Size(listfilesize)); //Size of the file
 
   742 	hBuffer = HBufC8::New(listfilesize); //Allocate the buffer
 
   743 	CleanupStack::PushL(hBuffer);
 
   745 	TPtr8 ptrString = hBuffer->Des();  ; //To access the buffer
 
   747 	// Read from position 0: start of file
 
   748 	User::LeaveIfError(returnCode = logFile.Read(ptrString));
 
   750 	// flogger will have logged the string exactly as it was sent. The CR/LF will not
 
   751 	// cause a line feed because they are not adjacent
 
   752 	returnCode = ptrString.Find(K2ndTestMessageWithEscapeChars8);
 
   760 	CleanupStack::PopAndDestroy(hBuffer);
 
   761 	CleanupStack::PopAndDestroy();	//logFile
 
   762 	if (numSuccessful == 1)
 
   771 * CFloggerTest024_06 - test static write with empty data string
 
   772 * doTestStep returns whether test case passed or failed.
 
   775 CFloggerTest024_06::CFloggerTest024_06()
 
   777 	// Store the name of this test case
 
   778 	SetTestStepName(_L("step_024_06"));
 
   784 CFloggerTest024_06::~CFloggerTest024_06()
 
   791 TVerdict CFloggerTest024_06::doTestStepL( )
 
   793 	if ( executeStepL() == KErrNone  )
 
   794 		SetTestStepResult(EPass);
 
   797 		SetTestStepResult(EFail);
 
   800 	return TestStepResult();
 
   804 TInt CFloggerTest024_06::executeStepL(TBool)
 
   809 TInt CFloggerTest024_06::executeStepL()
 
   813 	// clear the old log messages
 
   815 	ret = flogger.Connect();
 
   817 	if ( ret == KErrNone )
 
   819 		flogger.SetLogTags(KStdSubsysTag8, KStdCompTag8);
 
   823 		RFileLogger::Write(KStdSubsysTag8, KStdCompTag8,KNullDesC8);
 
   825 		User::After(KTimeToLog);
 
   827 		TRAPD(r, ret = DoTestCheckWriteL());
 
   838 TInt CFloggerTest024_06::DoTestCheckWriteL()
 
   842 	TInt listfilesize,returnCode;
 
   843 	RFs fileSystem; //For file operation create a file system
 
   844 	TInt numSuccessful = 0;
 
   846 	User::LeaveIfError(fileSystem.Connect());
 
   848 	//Open the file in the read mode
 
   849 	User::LeaveIfError(logFile.Open(fileSystem,KFloggerOutputFile,EFileRead));
 
   851 	CleanupClosePushL(logFile);
 
   853 	User::LeaveIfError(logFile.Size(listfilesize)); //Size of the file
 
   855 	hBuffer = HBufC8::New(listfilesize); //Allocate the buffer
 
   856 	CleanupStack::PushL(hBuffer);
 
   858 	TPtr8 ptrString = hBuffer->Des();  ; //To access the buffer
 
   860 	// Read from position 0: start of file
 
   861 	User::LeaveIfError(returnCode = logFile.Read(ptrString));
 
   863 	// not much to check since flogger won't have written much other than
 
   865 	returnCode = ptrString.Find(KStdCompTag8);
 
   873 	CleanupStack::PopAndDestroy(hBuffer);
 
   874 	CleanupStack::PopAndDestroy();	//logFile
 
   875 	if (numSuccessful == 1)
 
   882 CFloggerTest024_07::CFloggerTest024_07()
 
   884 	// Store the name of this test case
 
   885 	SetTestStepName(_L("step_024_07"));
 
   890 * Function  Name :~ CFloggerTest024_07
 
   891 * Input parameters : None
 
   892 * Output parameters : None
 
   893 * Description : This is the Destructor
 
   897 CFloggerTest024_07::~CFloggerTest024_07()
 
   903 * Function  Name	: doTestStepL
 
   904 * Input parameters	: None
 
   905 * Output parameters : TVerdict 
 
   906 * Description		: This function returns whether the test case 024_07 has 
 
   912 TVerdict CFloggerTest024_07::doTestStepL( )
 
   914 	INFO_PRINTF1(_L("Step 027.13 called "));
 
   915 	if ( executeStepL() == KErrNone  )
 
   916 		SetTestStepResult(EPass);
 
   919 		SetTestStepResult(EFail);
 
   921 	INFO_PRINTF1(_L("leaving Step 027.13"));
 
   922 	User::After(KTimeForDisplay);
 
   925 	return TestStepResult();
 
   929 * Function  Name		: executeStepL
 
   930 * Input parameters		: None
 
   931 * Output parameters		: TInt 
 
   932 * Description 			: This function checks for the flogger connection for 500 times
 
   937 TInt CFloggerTest024_07::executeStepL(TBool)
 
   943 * Function  Name		: executeStepL
 
   944 * Input parameters		: None
 
   945 * Output parameters		: TInt 
 
   946 * Description 			: This function checks for the flogger connection for 500 times
 
   951 TInt CFloggerTest024_07::executeStepL()
 
   954 	ret = connectionTest();
 
   957 		TRAPD(r, ret = DoTestCheckWriteL());
 
   965 TInt CFloggerTest024_07::connectionTest()
 
   968 	_LIT8(KTestMessage,"TC 24_15: The flogger connection has been connected %d");
 
   971 	ptrSubSystem.Set(_L8("SubSystem"));
 
   972 	ptrComponent.Set(_L8("Component"));
 
   974 	RFileLogger flogger[KMaxConnection];
 
   976 	for(TInt i= 0; i<KMaxConnection; i++)
 
   978 		res = flogger[i].Connect();
 
   981 			res = flogger[i].SetLogTags(ptrSubSystem, ptrComponent);
 
   985 					flogger[0].ClearLog();	// Clear previous test cases messages
 
   986 				flogger[i].WriteFormat(KTestMessage, i);
 
   994 			INFO_PRINTF2(_L("Flogger connection failed for connection at -> %d "), i);
 
   997 	User::After(KTimeBetConnection);
 
  1000 	for(TInt j= 0; j<KMaxConnection; j++)
 
  1003 	User::After(KDelayToCheckWrite);
 
  1009 TInt CFloggerTest024_07::DoTestCheckWriteL()
 
  1011 	User::After(KTimeToLog);
 
  1016 	RFs fileSystem; //For file operation create a file system	
 
  1017 	_LIT(KLogFile,"c:\\logs\\log.txt"); // the log file path
 
  1019 	TBuf8<256> testData; //To hold the test descriptor
 
  1021 	_LIT8(KTestMessage,"TC 24_15: The flogger connection has been connected %d");
 
  1024 	User::LeaveIfError(fileSystem.Connect());
 
  1026 	//Open the file in the read mode
 
  1027 	User::LeaveIfError(theFile.Open(fileSystem,KLogFile,EFileRead)); 
 
  1029 	CleanupClosePushL(theFile);	
 
  1031 	User::LeaveIfError(returnCode = theFile.Size(listfilesize)); //Size of the file
 
  1032 	hBuffer = HBufC8::New(listfilesize); //Allocate the buffer
 
  1033 	CleanupStack::PushL(hBuffer);
 
  1034 	TPtr8 ptrString = hBuffer->Des();  ; //To hold the buffer
 
  1036 	// Read from position 0: start of file
 
  1037 	returnCode = theFile.Read(ptrString);
 
  1039 	for(TInt i =0; i<KMaxConnection; i++)
 
  1041 	testData.Format(KTestMessage, i);
 
  1042 	returnCode = ptrString.Find(testData); //find the test descriptor in the buffer read
 
  1047 		User::Leave(KErrGeneral);
 
  1050 	CleanupStack::PopAndDestroy(hBuffer);
 
  1051 	CleanupStack::PopAndDestroy(); // For theFile object
 
  1060 * 024_08: Test that flogger handles date changes
 
  1064 CFloggerTest024_08::CFloggerTest024_08()
 
  1066 	// Store the name of this test case
 
  1067 	SetTestStepName(_L("step_024_08"));
 
  1073 CFloggerTest024_08::~CFloggerTest024_08()
 
  1080 TVerdict CFloggerTest024_08::doTestStepL( )
 
  1082 	if ( executeStepL() == KErrNone  )
 
  1083 		SetTestStepResult(EPass);
 
  1086 		SetTestStepResult(EFail);
 
  1088 	User::After(KTimeForDisplay);
 
  1091 	return TestStepResult();
 
  1095 TInt CFloggerTest024_08::executeStepL(TBool)
 
  1100 TInt CFloggerTest024_08::executeStepL()
 
  1103 	RFileLogger theFlogger; 
 
  1105 	//Just to clear the old log message
 
  1106 	ret = theFlogger.Connect(); 
 
  1107 	if ( ret == KErrNone)
 
  1108 		ret = theFlogger.SetLogTags(KStdSubsysTag8, KStdCompTag8);
 
  1109 		if ( ret == KErrNone)
 
  1110 			ret = theFlogger.ClearLog();
 
  1111 			if ( ret == KErrNone)
 
  1114 	// perform test. write some data, roll the date to 0 the following day. write more data.
 
  1115 	if ( ret == KErrNone)
 
  1117 		RFileLogger ::Write(KStdSubsysTag16, KStdCompTag16,EFileLoggingModeAppend, KTestMessage);
 
  1122 		TDateTime dateTime(time.DateTime());
 
  1123 		dateTime.SetHour(0);
 
  1124 		dateTime.SetMinute(0);
 
  1125 		dateTime.SetSecond(0);
 
  1126 		item = dateTime.Day();
 
  1127 		if ((dateTime.SetDay(++item) != KErrNone))
 
  1130 			item = dateTime.Month();
 
  1131 			if (item == EDecember)
 
  1133 				dateTime.SetMonth(EJanuary);
 
  1134 				item = dateTime.Year();
 
  1135 				dateTime.SetYear(item++);
 
  1139 				dateTime.SetMonth(TMonth(item++));
 
  1142 		time = TTime(dateTime);
 
  1144 		User::SetHomeTime(time);
 
  1145 		TTime currentMicrosecs;
 
  1146 		currentMicrosecs.HomeTime();
 
  1148 		RFileLogger ::Write(KStdSubsysTag16, KStdCompTag16,EFileLoggingModeAppend, KTestMessage);
 
  1149 		User::After(KTimeToLog);
 
  1150 		TRAPD(r, ret = DoTestCheckWriteL());
 
  1162 * This function checks whether test data was written
 
  1163 * 						  in to the log file .				  
 
  1167 TInt CFloggerTest024_08::DoTestCheckWriteL()
 
  1171 	TInt listfilesize,returnCode;
 
  1172 	RFs fileSystem; //For file operation create a file system
 
  1173 	TBuf8<256> testData; //To hold the test descriptor
 
  1174 	TInt numSuccessful = 0;
 
  1177 	_LIT8(KOOMError, "#Logs may be lost out of memory!!");
 
  1179 	User::LeaveIfError(fileSystem.Connect());
 
  1181 	//Open the file in the read mode
 
  1182 	User::LeaveIfError(theFile.Open(fileSystem,KFloggerOutputFile,EFileRead)); 
 
  1184 	CleanupClosePushL(theFile);
 
  1186 	User::LeaveIfError(theFile.Size(listfilesize)); //Size of the file
 
  1188 	hBuffer = HBufC8::New(listfilesize); //Allocate the buffer
 
  1189 	CleanupStack::PushL(hBuffer);
 
  1191 	TPtr8 ptrString = hBuffer->Des();  ; //To hold the buffer
 
  1193 	// Read from position 0: start of file
 
  1194 	User::LeaveIfError(returnCode = theFile.Read(ptrString));
 
  1196 	testData.Copy(KTestMessage); //Copy the test descriptor
 
  1197 	returnCode = ptrString.Find(testData); //find the test descriptor in the buffer read
 
  1204 	// We expect to see the string "date change"
 
  1205 	testData.Copy(KDateChangeMessage); //Copy the test descriptor
 
  1206 	returnCode = ptrString.Find(testData); //find the test descriptor in the buffer read
 
  1214 	if (returnCode == KErrNotFound)
 
  1216 		returnCode = ptrString.Find(KOOMError);
 
  1218 			User::Leave(KErrNoMemory);
 
  1223 	CleanupStack::PopAndDestroy(hBuffer);
 
  1224 	CleanupStack::PopAndDestroy();	//theFile
 
  1225 	if (numSuccessful == 2)
 
  1228 		return KErrNotFound;