traceservices/commsdebugutility/TE_commsdebugutility/src/step_024_xx.cpp
changeset 0 08ec8eefde2f
child 23 26645d81f48d
equal deleted inserted replaced
-1:000000000000 0:08ec8eefde2f
       
     1 // Copyright (c) 2003-2009 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".
       
     7 //
       
     8 // Initial Contributors:
       
     9 // Nokia Corporation - initial contribution.
       
    10 //
       
    11 // Contributors:
       
    12 //
       
    13 // Description:
       
    14 // This contains Flogger Unit Test Case 024.xx
       
    15 
       
    16 // EPOC includes
       
    17 #include <e32base.h>
       
    18 
       
    19 
       
    20 // Test system includes
       
    21 #include "teststepcomsdbg.h"
       
    22 #include "TestMessage.h"
       
    23 #include "step_024_xx.h"
       
    24 
       
    25 #include <comms-infras/commsdebugutility.h>
       
    26 
       
    27 
       
    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.
       
    32 
       
    33 
       
    34 /**
       
    35 * Function  Name : CFloggerTest024_01
       
    36 * Input parameters : None
       
    37 * Output parameters : None
       
    38 * Description : This is the constructor
       
    39 */
       
    40 
       
    41 
       
    42 CFloggerTest024_01::CFloggerTest024_01()
       
    43 	{
       
    44 	// Store the name of this test case
       
    45 	SetTestStepName(_L("step_024_01"));
       
    46 	}
       
    47 
       
    48 
       
    49 /**
       
    50 * Function  Name :~ CFloggerTest024_01
       
    51 * Input parameters : None
       
    52 * Output parameters : None
       
    53 * Description : This is the Destructor
       
    54 */
       
    55 
       
    56 
       
    57 CFloggerTest024_01::~CFloggerTest024_01()
       
    58 	{
       
    59 	}
       
    60 
       
    61 
       
    62 /**
       
    63 * Function  Name	: doTestStepL
       
    64 * Input parameters	: None
       
    65 * Output parameters : TVerdict 
       
    66 * Description		: This function returns weather the test case 024_01 has 
       
    67 * 					  passed or failed
       
    68 
       
    69 */
       
    70 
       
    71 
       
    72 TVerdict CFloggerTest024_01::doTestStepL( )
       
    73 	{
       
    74 
       
    75 	INFO_PRINTF1(_L("Step 024.01 called "));
       
    76 	if ( executeStepL() == KErrNone  )
       
    77 		SetTestStepResult(EPass);
       
    78 	else
       
    79 		SetTestStepResult(EFail);
       
    80 	
       
    81 	return TestStepResult();
       
    82 	}
       
    83 
       
    84 
       
    85 /**
       
    86 * Function  Name		: executeStepL
       
    87 * Input parameters		: None
       
    88 * Output parameters		: TInt 
       
    89 * Description 			: This function sets the subsystem and component name
       
    90 * 						  checks weather they are set in the log file correctly
       
    91 
       
    92 					  
       
    93 */
       
    94 
       
    95 
       
    96 TInt CFloggerTest024_01::executeStepL()
       
    97 	{
       
    98 	return DoTestWrite();
       
    99 	}
       
   100 	
       
   101 /**
       
   102 * Function  Name		: executeStepL
       
   103 * Input parameters		: None
       
   104 * Output parameters		: TInt 
       
   105 * Description 			: This function sets the subsystem and component name
       
   106 * 						  checks weather they are set in the log file correctly
       
   107 
       
   108 					  
       
   109 */
       
   110 
       
   111 
       
   112 TInt CFloggerTest024_01::executeStepL(TBool)
       
   113 	{
       
   114 	return KErrGeneral;
       
   115 	}
       
   116 /**
       
   117 * Function  Name		: DoTestWriteL
       
   118 * Input parameters		: None
       
   119 * Output parameters		: TInt 
       
   120 * Description 			: This function checks the weather test data was written
       
   121 * 						  in to the log file by DoTestWriteL() or not.
       
   122 					  
       
   123 */
       
   124 
       
   125 
       
   126 TInt CFloggerTest024_01::DoTestWrite()
       
   127 	{
       
   128 	TPtrC8 ptrSubSystem;
       
   129 	TPtrC8 ptrComponent;
       
   130 	ptrSubSystem.Set(_L8("SubSystem"));
       
   131 	ptrComponent.Set(_L8("Component"));
       
   132 
       
   133 	_LIT8(KTestMessage1 ,"TC NO 24: This is test message before sleep");
       
   134 	_LIT8(KTestMessage2 ,"TC NO 24: This is test message After sleep");
       
   135 
       
   136 	TInt ret = KErrGeneral;
       
   137 	RFileLogger theFlogger;
       
   138 
       
   139 	ret = theFlogger.Connect();
       
   140 	if (ret == KErrNone)
       
   141 		{
       
   142 		ret = theFlogger.SetLogTags(ptrSubSystem, ptrComponent);
       
   143 		if (ret == KErrNone)
       
   144 			{
       
   145 			ret = theFlogger.ClearLog();
       
   146 			if (ret == KErrNone)
       
   147 				{
       
   148 				theFlogger.Write(KTestMessage1); //Write the test descriptor before sleep
       
   149 				User::After(KFiveSeconds); // Call After() function
       
   150 				theFlogger.Write(KTestMessage2); //Write the test descriptor after sleep
       
   151 				User::After(KFiveSeconds);
       
   152 
       
   153 				TRAPD(r, ret = DoTestCheckWriteL()); // Check whether the message is present in log
       
   154 			
       
   155 				
       
   156 				if (r != KErrNone)
       
   157 					ret = r;
       
   158 				}
       
   159 			}
       
   160 		}
       
   161 	if (ret == KErrNone)
       
   162 		theFlogger.__DbgShutDownServer();
       
   163 	theFlogger.Close();
       
   164 	return ret;
       
   165 	}
       
   166 
       
   167 
       
   168 /**
       
   169 * Function  Name		: DoTestCheckWriteL
       
   170 * Input parameters		: None
       
   171 * Output parameters		: TInt 
       
   172 * Description 			: This function checks the weather test data was written
       
   173 * 						  in to the log file by DoTestWriteL() or not.
       
   174 					  
       
   175 */
       
   176 
       
   177 
       
   178 TInt CFloggerTest024_01::DoTestCheckWriteL()
       
   179 	{
       
   180 	RFile theFile;
       
   181 
       
   182 	_LIT(KTestString,"Time");
       
   183 
       
   184 	HBufC8 * hBuffer;
       
   185 	TInt listfilesize;
       
   186 	RFs iFileSystem; //For file operation create a file system
       
   187 	TBuf8<256> testData; //To hold the test descriptor
       
   188 
       
   189 	User::LeaveIfError(iFileSystem.Connect());
       
   190 	
       
   191 	//Open the file in the read mode
       
   192 	User::LeaveIfError(theFile.Open(iFileSystem, KFloggerOutputFile, EFileWrite|EFileShareAny)); 
       
   193 	CleanupClosePushL(theFile);
       
   194 	
       
   195 	User::LeaveIfError(theFile.Size(listfilesize)); //Size of the file
       
   196 	
       
   197 	hBuffer = HBufC8::New(listfilesize); //Allocate the buffer
       
   198 	CleanupStack::PushL(hBuffer);
       
   199 	TPtr8 ptrString = hBuffer->Des();  ; //To hold the buffer
       
   200 
       
   201 	// Read from position 0: start of file
       
   202 	User::LeaveIfError(theFile.Read(ptrString));
       
   203 	
       
   204 	testData.Copy(KTestString); //Copy the test string to be tested
       
   205 
       
   206 	TPtrC8 ptrTmpBuffer = ptrString.Right(listfilesize); //Copy of the orginal buffer read from the file
       
   207 	TInt charCount1 = 0;
       
   208 	TInt charCount2 = 0;
       
   209 	TInt lineCount = 0;
       
   210 	TInt tmpCount = 0;
       
   211 	
       
   212 	charCount1 = ptrString.Find(testData);
       
   213 	while(charCount1 != KErrNotFound)
       
   214 		{
       
   215 		lineCount++; //Increment the line count since we just found another one
       
   216 		charCount2 = charCount2 + charCount1 + KSampleTimeLine().Length(); //the the number of char's present in the line which
       
   217 										// is constant for the line starting with "#Time" in the log file
       
   218 
       
   219 		tmpCount = listfilesize - charCount2; // Remaining string after the "Time" is read
       
   220 		TPtrC8 strTmp = ptrString.Right(tmpCount);
       
   221 		charCount1 = strTmp.Find(testData);
       
   222 		if (charCount1 == 0) //Since the Time is found at the zeroth position count1 will contain 0
       
   223 			charCount1 = charCount1 + 4; // Charecter count of Time is 4
       
   224 		ptrString = ptrTmpBuffer.Right(listfilesize); // Get back the orginal buffer 
       
   225 		}
       
   226 
       
   227 	CleanupStack::PopAndDestroy(hBuffer);
       
   228 	CleanupStack::PopAndDestroy();	//theFile
       
   229 
       
   230 	// we expect to find the word "TIME" 10 times (or more) - 5 during each delay.
       
   231 	if ((lineCount >= 10) && (lineCount <= 12))
       
   232 		return KErrNone;
       
   233 	else
       
   234 		return KErrGeneral;
       
   235 
       
   236 
       
   237 
       
   238 	}
       
   239 
       
   240 
       
   241 
       
   242 
       
   243 
       
   244 
       
   245 _LIT8(KTestStringWithPunctuation1,"                                                 /===-_---~~~~~~~~~------____"); _LIT8(KTestStringWithPunctuation26,"    `~/  )` ) ,/|                 ~-_~>--<_/-__       __-~ _/ ");
       
   246 _LIT8(KTestStringWithPunctuation2,"                 -==\\\\                         `//~\\\\   ~~~~`---.___.-~~"); _LIT8(KTestStringWithPunctuation27,"   ;'( ')/ ,)(                              ~~~~~~~~~~ ");
       
   247 _LIT8(KTestStringWithPunctuation3,"       __--~~~  ,-/-==\\\\                        | |   `\\        ,'"); _LIT8(KTestStringWithPunctuation19,"                  \\_|      /        _)   ;  ),   __--~~");
       
   248 _LIT8(KTestStringWithPunctuation4,"  .'        /       |   \\\\                   /' /        \\   /'");              _LIT8(KTestStringWithPunctuation21,"                  |0  0 _/) )-~     | |__>--<__|      |");
       
   249 _LIT8(KTestStringWithPunctuation5,"/-'~    ~~~~~---__  |     ~-/~         ( )   /'        _--~`");                    _LIT8(KTestStringWithPunctuation20,"                   {\\__--_/}    / \\\\_>- )<__\\      \\");
       
   250 _LIT8(KTestStringWithPunctuation6,"                    '~~--_/      _-~/-  / \\   '-~ \\");                           _LIT8(KTestStringWithPunctuation22,"                 o o _//        /-~_>---<__-~      /");
       
   251 _LIT8(KTestStringWithPunctuation15,"                                                |===-~___                _,-'");  _LIT8(KTestStringWithPunctuation24,"            ( ( '))          |__>--<__|    |                 /' _---_~\\");
       
   252 _LIT8(KTestStringWithPunctuation16,"             ______-==|                         | |  \\\\           _-~`");       _LIT8(KTestStringWithPunctuation23,"                ,/|           /__>--<__/     _-~");
       
   253 _LIT8(KTestStringWithPunctuation17,"    _-~       /'    |  \\\\                      / /      \\      /");           _LIT8(KTestStringWithPunctuation25,"        ,/,'//( (             \\__>--<__\\    \\            /'  //        ||");
       
   254 _LIT8(KTestStringWithPunctuation18," /  ____  /         |    \\`\\.__/-~~ ~ \\ _ _/'  /          \\/'");
       
   255 _LIT8(KTestStringWithPunctuationExpected1,"         `-)) )) (           |__>--<__|    |               /'  /     ~\\`\\");
       
   256 _LIT8(KTestStringWithPunctuationExpected2,"                 o o _//        /-~_>---<__-~      /");
       
   257 _LIT8(KTestStringWithPunctuationExpected3,"    `~/  )` ) ,/|                 ~-_~>--<_/-__       __-~ _/ ");
       
   258 
       
   259 
       
   260 
       
   261 /**
       
   262 * CFloggerTest024_02 - test static write with string with beeps, tabs, nulls, CR's, LFs in the tags
       
   263 * doTestStep returns whether test case passed or failed.
       
   264 */ 
       
   265 
       
   266 
       
   267 
       
   268 
       
   269 CFloggerTest024_02::CFloggerTest024_02()
       
   270 	{
       
   271 	// Store the name of this test case
       
   272 	SetTestStepName(_L("step_024_02"));
       
   273 	}
       
   274 
       
   275 
       
   276 
       
   277 
       
   278 CFloggerTest024_02::~CFloggerTest024_02()
       
   279 	{
       
   280 	}
       
   281 
       
   282 
       
   283 
       
   284 
       
   285 TVerdict CFloggerTest024_02::doTestStepL( )
       
   286 	{
       
   287 	if ( executeStepL() == KErrNone  )
       
   288 		SetTestStepResult(EPass);
       
   289 	else
       
   290 		SetTestStepResult(EFail);
       
   291 	
       
   292 	return TestStepResult();
       
   293 	}
       
   294 
       
   295 
       
   296 TInt CFloggerTest024_02::executeStepL(TBool)
       
   297 	{
       
   298 	return KErrGeneral;
       
   299 	}
       
   300 
       
   301 TInt CFloggerTest024_02::executeStepL()
       
   302 	{
       
   303 	TInt ret;
       
   304 	
       
   305 	// clear the old log messages
       
   306 	RFileLogger flogger;
       
   307 	ret = flogger.Connect();
       
   308 	
       
   309 	if ( ret == KErrNone )
       
   310 		{
       
   311 		flogger.SetLogTags(KStdSubsysTag8, KStdCompTag8);
       
   312 		flogger.ClearLog();
       
   313 		flogger.Close();
       
   314 		
       
   315 		RFileLogger::Write(KSubsysTagWithEscapeChars8, KCompTagWithEscapeChars8,KTestMessage8);
       
   316 		
       
   317 		User::After(KTimeToLog);
       
   318 		
       
   319 		TRAPD(r, ret = DoTestCheckWriteL());
       
   320 		if (r != KErrNone)
       
   321 			ret = r;
       
   322 		}
       
   323 		
       
   324 	
       
   325 	return ret;		
       
   326 
       
   327 	}
       
   328 
       
   329 
       
   330 TInt CFloggerTest024_02::DoTestCheckWriteL()
       
   331 	{
       
   332 	RFile logFile;
       
   333 	HBufC8* hBuffer;
       
   334 	TInt listfilesize,returnCode;
       
   335 	RFs fileSystem; //For file operation create a file system
       
   336 	TInt numSuccessful = 0;
       
   337 
       
   338 	User::LeaveIfError(fileSystem.Connect());
       
   339 	
       
   340 	//Open the file in the read mode
       
   341 	User::LeaveIfError(logFile.Open(fileSystem,KFloggerOutputFile,EFileRead));
       
   342 
       
   343 	CleanupClosePushL(logFile);
       
   344 
       
   345 	User::LeaveIfError(logFile.Size(listfilesize)); //Size of the file
       
   346 	
       
   347 	hBuffer = HBufC8::New(listfilesize); //Allocate the buffer
       
   348 	CleanupStack::PushL(hBuffer);
       
   349 
       
   350 	TPtr8 ptrString = hBuffer->Des();  ; //To access the buffer
       
   351 
       
   352 	// Read from position 0: start of file
       
   353 	User::LeaveIfError(returnCode = logFile.Read(ptrString));
       
   354 	
       
   355 	// flogger should not have logged
       
   356 	returnCode = ptrString.Find(KTestMessage8);
       
   357 	
       
   358 	if (returnCode == KErrNotFound)
       
   359 		{
       
   360 		numSuccessful++;
       
   361 		}
       
   362 
       
   363 
       
   364 	CleanupStack::PopAndDestroy(hBuffer);
       
   365 	CleanupStack::PopAndDestroy();	//logFile
       
   366 	if (numSuccessful == 1)
       
   367 		return KErrNone;
       
   368 	else
       
   369 		return KErrUnknown;
       
   370 	}
       
   371 
       
   372 
       
   373 
       
   374 
       
   375 /**
       
   376 * CFloggerTest024_03 - test static write with string with punctuation and spaces in the data
       
   377 * doTestStep returns whether test case passed or failed.
       
   378 */ 
       
   379 
       
   380 _LIT8(KTestStringWithPunctuation8,"                  / /~ ,_/       / /__>---<__/      |  ");
       
   381 _LIT8(KTestStringWithPunctuation14,"  ' ') '( (/");
       
   382 _LIT8(KTestStringWithPunctuation9,"                 (^(~          /~_>---<__-      _-~");
       
   383 _LIT8(KTestStringWithPunctuation7,"                   /'   (_/  _-~  | |__>--<__|      | ");
       
   384 _LIT8(KTestStringWithPunctuation11,"         `-)) )) (           |__>--<__|    |               /'  /     ~\\`\\");
       
   385 _LIT8(KTestStringWithPunctuation12,"      ,( ( ((, ))              ~-__>--<_~-_  ~--____---~' _/'/        /'");
       
   386 _LIT8(KTestStringWithPunctuation10,"             ,//('(          |__>--<__|     /                  .----_ ");
       
   387 _LIT8(KTestStringWithPunctuation13,"  ._-~//( )/ )) `                    ~~-'_/_/ /~~~~~~~__--~ ");
       
   388 
       
   389 
       
   390 CFloggerTest024_03::CFloggerTest024_03()
       
   391 	{
       
   392 	// Store the name of this test case
       
   393 	SetTestStepName(_L("step_024_03"));
       
   394 	}
       
   395 
       
   396 
       
   397 
       
   398 
       
   399 CFloggerTest024_03::~CFloggerTest024_03()
       
   400 	{
       
   401 	}
       
   402 
       
   403 
       
   404 
       
   405 
       
   406 TVerdict CFloggerTest024_03::doTestStepL( )
       
   407 	{
       
   408 	if ( executeStepL() == KErrNone  )
       
   409 		SetTestStepResult(EPass);
       
   410 	else
       
   411 		SetTestStepResult(EFail);
       
   412 	
       
   413 	return TestStepResult();
       
   414 	}
       
   415 
       
   416 
       
   417 TInt CFloggerTest024_03::executeStepL(TBool)
       
   418 	{
       
   419 	return KErrGeneral;
       
   420 	}
       
   421 
       
   422 TInt CFloggerTest024_03::executeStepL()
       
   423 	{
       
   424 	TInt ret;
       
   425 	
       
   426 	// clear the old log messages
       
   427 	RFileLogger flogger;
       
   428 	ret = flogger.Connect();
       
   429 	
       
   430 	if ( ret == KErrNone )
       
   431 		{
       
   432 		flogger.SetLogTags(KStdSubsysTag8, KStdCompTag8);
       
   433 		flogger.ClearLog();
       
   434 		flogger.Close();
       
   435 		
       
   436 		RFileLogger::Write(KStdSubsysTag8, KStdCompTag8,KTestStringWithPunctuation1);
       
   437 		RFileLogger::Write(KStdSubsysTag8, KStdCompTag8,KTestStringWithPunctuation15);
       
   438 		RFileLogger::Write(KStdSubsysTag8, KStdCompTag8,KTestStringWithPunctuation2);
       
   439 		RFileLogger::Write(KStdSubsysTag8, KStdCompTag8,KTestStringWithPunctuation16);
       
   440 		RFileLogger::Write(KStdSubsysTag8, KStdCompTag8,KTestStringWithPunctuation3);
       
   441 		RFileLogger::Write(KStdSubsysTag8, KStdCompTag8,KTestStringWithPunctuation17);
       
   442 		RFileLogger::Write(KStdSubsysTag8, KStdCompTag8,KTestStringWithPunctuation4);
       
   443 		RFileLogger::Write(KStdSubsysTag8, KStdCompTag8,KTestStringWithPunctuation18);
       
   444 		RFileLogger::Write(KStdSubsysTag8, KStdCompTag8,KTestStringWithPunctuation5);
       
   445 		RFileLogger::Write(KStdSubsysTag8, KStdCompTag8,KTestStringWithPunctuation19);
       
   446 		RFileLogger::Write(KStdSubsysTag8, KStdCompTag8,KTestStringWithPunctuation6);
       
   447 		RFileLogger::Write(KStdSubsysTag8, KStdCompTag8,KTestStringWithPunctuation20);
       
   448 		RFileLogger::Write(KStdSubsysTag8, KStdCompTag8,KTestStringWithPunctuation7);
       
   449 		RFileLogger::Write(KStdSubsysTag8, KStdCompTag8,KTestStringWithPunctuation21);
       
   450 		RFileLogger::Write(KStdSubsysTag8, KStdCompTag8,KTestStringWithPunctuation8);
       
   451 		RFileLogger::Write(KStdSubsysTag8, KStdCompTag8,KTestStringWithPunctuation22);
       
   452 		RFileLogger::Write(KStdSubsysTag8, KStdCompTag8,KTestStringWithPunctuation9);
       
   453 		RFileLogger::Write(KStdSubsysTag8, KStdCompTag8,KTestStringWithPunctuation23);
       
   454 		RFileLogger::Write(KStdSubsysTag8, KStdCompTag8,KTestStringWithPunctuation10);
       
   455 		RFileLogger::Write(KStdSubsysTag8, KStdCompTag8,KTestStringWithPunctuation24);
       
   456 		RFileLogger::Write(KStdSubsysTag8, KStdCompTag8,KTestStringWithPunctuation11);
       
   457 		RFileLogger::Write(KStdSubsysTag8, KStdCompTag8,KTestStringWithPunctuation25);
       
   458 		RFileLogger::Write(KStdSubsysTag8, KStdCompTag8,KTestStringWithPunctuation12);
       
   459 		RFileLogger::Write(KStdSubsysTag8, KStdCompTag8,KTestStringWithPunctuation26);
       
   460 		RFileLogger::Write(KStdSubsysTag8, KStdCompTag8,KTestStringWithPunctuation13);
       
   461 		RFileLogger::Write(KStdSubsysTag8, KStdCompTag8,KTestStringWithPunctuation27);
       
   462 		RFileLogger::Write(KStdSubsysTag8, KStdCompTag8,KTestStringWithPunctuation14);
       
   463 		
       
   464 		User::After(KTimeToLog);
       
   465 		
       
   466 		TRAPD(r, ret = DoTestCheckWriteL());
       
   467 		if (r != KErrNone)
       
   468 			ret = r;
       
   469 		}
       
   470 		
       
   471 	
       
   472 	return ret;		
       
   473 
       
   474 	}
       
   475 
       
   476 
       
   477 TInt CFloggerTest024_03::DoTestCheckWriteL()
       
   478 	{
       
   479 	RFile logFile;
       
   480 	HBufC8* hBuffer;
       
   481 	TInt listfilesize,returnCode;
       
   482 	RFs fileSystem; //For file operation create a file system
       
   483 	TInt numSuccessful = 0;
       
   484 
       
   485 	User::LeaveIfError(fileSystem.Connect());
       
   486 	
       
   487 	//Open the file in the read mode
       
   488 	User::LeaveIfError(logFile.Open(fileSystem,KFloggerOutputFile,EFileRead));
       
   489 
       
   490 	CleanupClosePushL(logFile);
       
   491 
       
   492 	User::LeaveIfError(logFile.Size(listfilesize)); //Size of the file
       
   493 	
       
   494 	hBuffer = HBufC8::New(listfilesize); //Allocate the buffer
       
   495 	CleanupStack::PushL(hBuffer);
       
   496 
       
   497 	TPtr8 ptrString = hBuffer->Des();  ; //To access the buffer
       
   498 
       
   499 	// Read from position 0: start of file
       
   500 	User::LeaveIfError(returnCode = logFile.Read(ptrString));
       
   501 	
       
   502 	// check that flogger logged the punctuation/spaces correctly by checking three samples
       
   503 	returnCode = ptrString.Find(KTestStringWithPunctuationExpected1);
       
   504 	
       
   505 	if (returnCode > 0)
       
   506 		{
       
   507 		numSuccessful++;
       
   508 		}
       
   509 		
       
   510 	returnCode = ptrString.Find(KTestStringWithPunctuationExpected2);
       
   511 	
       
   512 	if (returnCode > 0)
       
   513 		{
       
   514 		numSuccessful++;
       
   515 		}
       
   516 		
       
   517 	returnCode = ptrString.Find(KTestStringWithPunctuationExpected3);
       
   518 	
       
   519 	if (returnCode > 0)
       
   520 		{
       
   521 		numSuccessful++;
       
   522 		}
       
   523 
       
   524 
       
   525 	CleanupStack::PopAndDestroy(hBuffer);
       
   526 	CleanupStack::PopAndDestroy();	//logFile
       
   527 	if (numSuccessful == 3)
       
   528 		return KErrNone;
       
   529 	else
       
   530 		return KErrUnknown;
       
   531 	}
       
   532 
       
   533 
       
   534 
       
   535 
       
   536 /**
       
   537 * CFloggerTest024_04 - test static write with data string with beeps, tabs, nulls, CR's, LFs in it
       
   538 * doTestStep returns whether test case passed or failed.
       
   539 */ 
       
   540 
       
   541 CFloggerTest024_04::CFloggerTest024_04()
       
   542 	{
       
   543 	// Store the name of this test case
       
   544 	SetTestStepName(_L("step_024_04"));
       
   545 	}
       
   546 
       
   547 
       
   548 
       
   549 
       
   550 CFloggerTest024_04::~CFloggerTest024_04()
       
   551 	{
       
   552 	}
       
   553 
       
   554 
       
   555 
       
   556 
       
   557 TVerdict CFloggerTest024_04::doTestStepL( )
       
   558 	{
       
   559 	if ( executeStepL() == KErrNone  )
       
   560 		SetTestStepResult(EPass);
       
   561 	else
       
   562 		SetTestStepResult(EFail);
       
   563 	
       
   564 	return TestStepResult();
       
   565 	}
       
   566 
       
   567 
       
   568 TInt CFloggerTest024_04::executeStepL(TBool)
       
   569 	{
       
   570 	return KErrGeneral;
       
   571 	}
       
   572 
       
   573 TInt CFloggerTest024_04::executeStepL()
       
   574 	{
       
   575 	TInt ret;
       
   576 	
       
   577 	// clear the old log messages
       
   578 	RFileLogger flogger;
       
   579 	ret = flogger.Connect();
       
   580 	
       
   581 	if ( ret == KErrNone )
       
   582 		{
       
   583 		flogger.SetLogTags(KStdSubsysTag8, KStdCompTag8);
       
   584 		flogger.ClearLog();
       
   585 		flogger.Close();
       
   586 		
       
   587 		RFileLogger::Write(KStdSubsysTag8, KStdCompTag8,KTestMessageWithEscapeChars8);
       
   588 		
       
   589 		User::After(KTimeToLog);
       
   590 		
       
   591 		TRAPD(r, ret = DoTestCheckWriteL());
       
   592 		if (r != KErrNone)
       
   593 			ret = r;
       
   594 		}
       
   595 		
       
   596 	
       
   597 	return ret;		
       
   598 
       
   599 	}
       
   600 
       
   601 
       
   602 TInt CFloggerTest024_04::DoTestCheckWriteL()
       
   603 	{
       
   604 	RFile logFile;
       
   605 	HBufC8* hBuffer;
       
   606 	TInt listfilesize,returnCode;
       
   607 	RFs fileSystem; //For file operation create a file system
       
   608 	TInt numSuccessful = 0;
       
   609 
       
   610 	User::LeaveIfError(fileSystem.Connect());
       
   611 	
       
   612 	//Open the file in the read mode
       
   613 	User::LeaveIfError(logFile.Open(fileSystem,KFloggerOutputFile,EFileRead));
       
   614 
       
   615 	CleanupClosePushL(logFile);
       
   616 
       
   617 	User::LeaveIfError(logFile.Size(listfilesize)); //Size of the file
       
   618 	
       
   619 	hBuffer = HBufC8::New(listfilesize); //Allocate the buffer
       
   620 	CleanupStack::PushL(hBuffer);
       
   621 
       
   622 	TPtr8 ptrString = hBuffer->Des();  ; //To access the buffer
       
   623 
       
   624 	// Read from position 0: start of file
       
   625 	User::LeaveIfError(returnCode = logFile.Read(ptrString));
       
   626 	
       
   627 	// flogger will have logged the string exactly as it was sent. The CR/LF will not
       
   628 	// cause a line feed because they are not adjacent
       
   629 	returnCode = ptrString.Find(KTestMessageWithEscapeChars8);
       
   630 	
       
   631 	if (returnCode > 0)
       
   632 		{
       
   633 		numSuccessful++;
       
   634 		}
       
   635 
       
   636 
       
   637 	CleanupStack::PopAndDestroy(hBuffer);
       
   638 	CleanupStack::PopAndDestroy();	//logFile
       
   639 	if (numSuccessful == 1)
       
   640 		return KErrNone;
       
   641 	else
       
   642 		return KErrUnknown;
       
   643 	}
       
   644 
       
   645 
       
   646 
       
   647 
       
   648 
       
   649 /**
       
   650 * CFloggerTest024_05 - test static write with data string with char 255, nulls, and escapes in it
       
   651 * doTestStep returns whether test case passed or failed.
       
   652 */ 
       
   653 
       
   654 CFloggerTest024_05::CFloggerTest024_05()
       
   655 	{
       
   656 	// Store the name of this test case
       
   657 	SetTestStepName(_L("step_024_05"));
       
   658 	}
       
   659 
       
   660 
       
   661 
       
   662 
       
   663 CFloggerTest024_05::~CFloggerTest024_05()
       
   664 	{
       
   665 	}
       
   666 
       
   667 
       
   668 
       
   669 
       
   670 TVerdict CFloggerTest024_05::doTestStepL( )
       
   671 	{
       
   672 	if ( executeStepL() == KErrNone  )
       
   673 		SetTestStepResult(EPass);
       
   674 	else
       
   675 		SetTestStepResult(EFail);
       
   676 	
       
   677 	return TestStepResult();
       
   678 	}
       
   679 
       
   680 TInt CFloggerTest024_05::executeStepL(TBool)
       
   681 	{
       
   682 	return KErrGeneral;
       
   683 	}
       
   684 
       
   685 
       
   686 TInt CFloggerTest024_05::executeStepL()
       
   687 	{
       
   688 	TInt ret;
       
   689 	
       
   690 	// clear the old log messages
       
   691 	RFileLogger flogger;
       
   692 	ret = flogger.Connect();
       
   693 	
       
   694 	if ( ret == KErrNone )
       
   695 		{
       
   696 		flogger.SetLogTags(KStdSubsysTag8, KStdCompTag8);
       
   697 		flogger.ClearLog();
       
   698 		flogger.Close();
       
   699 		
       
   700 		RFileLogger::Write(KStdSubsysTag8, KStdCompTag8,K2ndTestMessageWithEscapeChars8);
       
   701 		
       
   702 		User::After(KTimeToLog);
       
   703 		
       
   704 		TRAPD(r, ret = DoTestCheckWriteL());
       
   705 		if (r != KErrNone)
       
   706 			ret = r;
       
   707 		}
       
   708 		
       
   709 	
       
   710 	return ret;		
       
   711 
       
   712 	}
       
   713 
       
   714 
       
   715 TInt CFloggerTest024_05::DoTestCheckWriteL()
       
   716 	{
       
   717 	RFile logFile;
       
   718 	HBufC8* hBuffer;
       
   719 	TInt listfilesize,returnCode;
       
   720 	RFs fileSystem; //For file operation create a file system
       
   721 	TInt numSuccessful = 0;
       
   722 
       
   723 	User::LeaveIfError(fileSystem.Connect());
       
   724 	
       
   725 	//Open the file in the read mode
       
   726 	User::LeaveIfError(logFile.Open(fileSystem,KFloggerOutputFile,EFileRead));
       
   727 
       
   728 	CleanupClosePushL(logFile);
       
   729 
       
   730 	User::LeaveIfError(logFile.Size(listfilesize)); //Size of the file
       
   731 	
       
   732 	hBuffer = HBufC8::New(listfilesize); //Allocate the buffer
       
   733 	CleanupStack::PushL(hBuffer);
       
   734 
       
   735 	TPtr8 ptrString = hBuffer->Des();  ; //To access the buffer
       
   736 
       
   737 	// Read from position 0: start of file
       
   738 	User::LeaveIfError(returnCode = logFile.Read(ptrString));
       
   739 	
       
   740 	// flogger will have logged the string exactly as it was sent. The CR/LF will not
       
   741 	// cause a line feed because they are not adjacent
       
   742 	returnCode = ptrString.Find(K2ndTestMessageWithEscapeChars8);
       
   743 	
       
   744 	if (returnCode > 0)
       
   745 		{
       
   746 		numSuccessful++;
       
   747 		}
       
   748 
       
   749 
       
   750 	CleanupStack::PopAndDestroy(hBuffer);
       
   751 	CleanupStack::PopAndDestroy();	//logFile
       
   752 	if (numSuccessful == 1)
       
   753 		return KErrNone;
       
   754 	else
       
   755 		return KErrUnknown;
       
   756 	}
       
   757 
       
   758 
       
   759 
       
   760 /**
       
   761 * CFloggerTest024_06 - test static write with empty data string
       
   762 * doTestStep returns whether test case passed or failed.
       
   763 */ 
       
   764 
       
   765 CFloggerTest024_06::CFloggerTest024_06()
       
   766 	{
       
   767 	// Store the name of this test case
       
   768 	SetTestStepName(_L("step_024_06"));
       
   769 	}
       
   770 
       
   771 
       
   772 
       
   773 
       
   774 CFloggerTest024_06::~CFloggerTest024_06()
       
   775 	{
       
   776 	}
       
   777 
       
   778 
       
   779 
       
   780 
       
   781 TVerdict CFloggerTest024_06::doTestStepL( )
       
   782 	{
       
   783 	if ( executeStepL() == KErrNone  )
       
   784 		SetTestStepResult(EPass);
       
   785 	else
       
   786 		SetTestStepResult(EFail);
       
   787 	
       
   788 	return TestStepResult();
       
   789 	}
       
   790 
       
   791 
       
   792 TInt CFloggerTest024_06::executeStepL(TBool)
       
   793 	{
       
   794 	return KErrGeneral;
       
   795 	}
       
   796 
       
   797 TInt CFloggerTest024_06::executeStepL()
       
   798 	{
       
   799 	TInt ret;
       
   800 	
       
   801 	// clear the old log messages
       
   802 	RFileLogger flogger;
       
   803 	ret = flogger.Connect();
       
   804 	
       
   805 	if ( ret == KErrNone )
       
   806 		{
       
   807 		flogger.SetLogTags(KStdSubsysTag8, KStdCompTag8);
       
   808 		flogger.ClearLog();
       
   809 		flogger.Close();
       
   810 		
       
   811 		RFileLogger::Write(KStdSubsysTag8, KStdCompTag8,KNullDesC8);
       
   812 		
       
   813 		User::After(KTimeToLog);
       
   814 		
       
   815 		TRAPD(r, ret = DoTestCheckWriteL());
       
   816 		if (r != KErrNone)
       
   817 			ret = r;
       
   818 		}
       
   819 		
       
   820 	
       
   821 	return ret;		
       
   822 
       
   823 	}
       
   824 
       
   825 
       
   826 TInt CFloggerTest024_06::DoTestCheckWriteL()
       
   827 	{
       
   828 	RFile logFile;
       
   829 	HBufC8* hBuffer;
       
   830 	TInt listfilesize,returnCode;
       
   831 	RFs fileSystem; //For file operation create a file system
       
   832 	TInt numSuccessful = 0;
       
   833 
       
   834 	User::LeaveIfError(fileSystem.Connect());
       
   835 	
       
   836 	//Open the file in the read mode
       
   837 	User::LeaveIfError(logFile.Open(fileSystem,KFloggerOutputFile,EFileRead));
       
   838 
       
   839 	CleanupClosePushL(logFile);
       
   840 
       
   841 	User::LeaveIfError(logFile.Size(listfilesize)); //Size of the file
       
   842 	
       
   843 	hBuffer = HBufC8::New(listfilesize); //Allocate the buffer
       
   844 	CleanupStack::PushL(hBuffer);
       
   845 
       
   846 	TPtr8 ptrString = hBuffer->Des();  ; //To access the buffer
       
   847 
       
   848 	// Read from position 0: start of file
       
   849 	User::LeaveIfError(returnCode = logFile.Read(ptrString));
       
   850 	
       
   851 	// not much to check since flogger won't have written much other than
       
   852 	// the tags
       
   853 	returnCode = ptrString.Find(KStdCompTag8);
       
   854 	
       
   855 	if (returnCode > 0)
       
   856 		{
       
   857 		numSuccessful++;
       
   858 		}
       
   859 
       
   860 
       
   861 	CleanupStack::PopAndDestroy(hBuffer);
       
   862 	CleanupStack::PopAndDestroy();	//logFile
       
   863 	if (numSuccessful == 1)
       
   864 		return KErrNone;
       
   865 	else
       
   866 		return KErrUnknown;
       
   867 	}
       
   868 
       
   869 
       
   870 CFloggerTest024_07::CFloggerTest024_07()
       
   871 	{
       
   872 	// Store the name of this test case
       
   873 	SetTestStepName(_L("step_024_07"));
       
   874 	}
       
   875 
       
   876 
       
   877 /**
       
   878 * Function  Name :~ CFloggerTest024_07
       
   879 * Input parameters : None
       
   880 * Output parameters : None
       
   881 * Description : This is the Destructor
       
   882 */ 
       
   883 
       
   884 
       
   885 CFloggerTest024_07::~CFloggerTest024_07()
       
   886 	{
       
   887 	}
       
   888 
       
   889 
       
   890 /**
       
   891 * Function  Name	: doTestStepL
       
   892 * Input parameters	: None
       
   893 * Output parameters : TVerdict 
       
   894 * Description		: This function returns whether the test case 024_07 has 
       
   895 * 					  passed or failed
       
   896 
       
   897 */
       
   898 
       
   899 
       
   900 TVerdict CFloggerTest024_07::doTestStepL( )
       
   901 	{
       
   902 	INFO_PRINTF1(_L("Step 027.13 called "));
       
   903 	if ( executeStepL() == KErrNone  )
       
   904 		SetTestStepResult(EPass);
       
   905 	else
       
   906 		SetTestStepResult(EFail);
       
   907 	INFO_PRINTF1(_L("leaving Step 027.13"));
       
   908 	User::After(KTimeForDisplay);
       
   909 
       
   910 	
       
   911 	return TestStepResult();
       
   912 	}
       
   913 
       
   914 /**
       
   915 * Function  Name		: executeStepL
       
   916 * Input parameters		: None
       
   917 * Output parameters		: TInt 
       
   918 * Description 			: This function checks for the flogger connection for 500 times
       
   919 
       
   920 */
       
   921 
       
   922 
       
   923 TInt CFloggerTest024_07::executeStepL(TBool)
       
   924 	{
       
   925 	return KErrGeneral;
       
   926 	}
       
   927 
       
   928 /**
       
   929 * Function  Name		: executeStepL
       
   930 * Input parameters		: None
       
   931 * Output parameters		: TInt 
       
   932 * Description 			: This function checks for the flogger connection for 500 times
       
   933 
       
   934 */
       
   935 
       
   936 
       
   937 TInt CFloggerTest024_07::executeStepL()
       
   938 	{
       
   939 	TInt ret = KErrNone;
       
   940 	ret = connectionTest();
       
   941 	if (ret == KErrNone)
       
   942 		{
       
   943 		TRAPD(r, ret = DoTestCheckWriteL());
       
   944 		if ( r != KErrNone)
       
   945 				ret = r;
       
   946 		}
       
   947 	return ret;
       
   948 	}
       
   949 
       
   950 
       
   951 TInt CFloggerTest024_07::connectionTest()
       
   952 	{
       
   953 	
       
   954 	_LIT8(KTestMessage,"TC 24_15: The flogger connection has been connected %d");
       
   955 	TPtrC8 ptrSubSystem;
       
   956 	TPtrC8 ptrComponent;
       
   957 	ptrSubSystem.Set(_L8("SubSystem"));
       
   958 	ptrComponent.Set(_L8("Component"));
       
   959 	TInt res = KErrNone;
       
   960 	RFileLogger flogger[KMaxConnection];
       
   961 
       
   962 	for(TInt i= 0; i<KMaxConnection; i++)
       
   963 		{
       
   964 		res = flogger[i].Connect();
       
   965 		if (res == KErrNone)
       
   966 			{
       
   967 			res = flogger[i].SetLogTags(ptrSubSystem, ptrComponent);
       
   968 			if (res == KErrNone)	
       
   969 				{
       
   970 				if (i == 0)
       
   971 					flogger[0].ClearLog();	// Clear previous test cases messages
       
   972 				flogger[i].WriteFormat(KTestMessage, i);
       
   973 				}
       
   974 			else
       
   975 				return KErrGeneral;
       
   976 			}
       
   977 		
       
   978 		else
       
   979 			{
       
   980 			INFO_PRINTF2(_L("Flogger connection failed for connection at -> %d "), i);
       
   981 			return KErrGeneral;
       
   982 			}
       
   983 	User::After(KTimeBetConnection);
       
   984 		}
       
   985 
       
   986 	for(TInt j= 0; j<KMaxConnection; j++)
       
   987 		flogger[j].Close();
       
   988 
       
   989 	User::After(KDelayToCheckWrite);
       
   990 	
       
   991 	return KErrNone;
       
   992 
       
   993 	}
       
   994 
       
   995 TInt CFloggerTest024_07::DoTestCheckWriteL()
       
   996 	{
       
   997 	User::After(KTimeToLog);
       
   998 	RFile theFile;
       
   999 	HBufC8 * hBuffer;
       
  1000 	TInt listfilesize;
       
  1001 	TInt returnCode;
       
  1002 	RFs fileSystem; //For file operation create a file system	
       
  1003 	_LIT(KLogFile,"c:\\logs\\log.txt"); // the log file path
       
  1004 
       
  1005 	TBuf8<256> testData; //To hold the test descriptor
       
  1006 
       
  1007 	_LIT8(KTestMessage,"TC 24_15: The flogger connection has been connected %d");
       
  1008 	
       
  1009 
       
  1010 	User::LeaveIfError(fileSystem.Connect());
       
  1011 	
       
  1012 	//Open the file in the read mode
       
  1013 	User::LeaveIfError(theFile.Open(fileSystem,KLogFile,EFileRead)); 
       
  1014 
       
  1015 	CleanupClosePushL(theFile);	
       
  1016 	
       
  1017 	User::LeaveIfError(returnCode = theFile.Size(listfilesize)); //Size of the file
       
  1018 	hBuffer = HBufC8::New(listfilesize); //Allocate the buffer
       
  1019 	CleanupStack::PushL(hBuffer);
       
  1020 	TPtr8 ptrString = hBuffer->Des();  ; //To hold the buffer
       
  1021 
       
  1022 	// Read from position 0: start of file
       
  1023 	returnCode = theFile.Read(ptrString);
       
  1024 	
       
  1025 	for(TInt i =0; i<KMaxConnection; i++)
       
  1026 	{
       
  1027 	testData.Format(KTestMessage, i);
       
  1028 	returnCode = ptrString.Find(testData); //find the test descriptor in the buffer read
       
  1029 												//from the file
       
  1030 	if (returnCode > 0)
       
  1031 		continue;
       
  1032 	else
       
  1033 		User::Leave(KErrGeneral);
       
  1034 	}
       
  1035 
       
  1036 	CleanupStack::PopAndDestroy(hBuffer);
       
  1037 	CleanupStack::PopAndDestroy(); // For theFile object
       
  1038 	if (returnCode > 0)
       
  1039 		return KErrNone;
       
  1040 	else 
       
  1041 		return KErrGeneral;
       
  1042 	}
       
  1043 
       
  1044 
       
  1045 /**
       
  1046 * 024_08: Test that flogger handles date changes
       
  1047 */ 
       
  1048 
       
  1049 
       
  1050 CFloggerTest024_08::CFloggerTest024_08()
       
  1051 	{
       
  1052 	// Store the name of this test case
       
  1053 	SetTestStepName(_L("step_024_08"));
       
  1054 	}
       
  1055 
       
  1056 
       
  1057 
       
  1058 
       
  1059 CFloggerTest024_08::~CFloggerTest024_08()
       
  1060 	{
       
  1061 	}
       
  1062 
       
  1063 
       
  1064 
       
  1065 
       
  1066 TVerdict CFloggerTest024_08::doTestStepL( )
       
  1067 	{
       
  1068 	if ( executeStepL() == KErrNone  )
       
  1069 		SetTestStepResult(EPass);
       
  1070 	else
       
  1071 		SetTestStepResult(EFail);
       
  1072 	User::After(KTimeForDisplay);
       
  1073 
       
  1074 	
       
  1075 	return TestStepResult();
       
  1076 	}
       
  1077 
       
  1078 
       
  1079 TInt CFloggerTest024_08::executeStepL(TBool)
       
  1080 	{
       
  1081 	return KErrGeneral;
       
  1082 	}
       
  1083 
       
  1084 TInt CFloggerTest024_08::executeStepL()
       
  1085 	{
       
  1086 	TInt ret ;
       
  1087 	RFileLogger theFlogger; 
       
  1088 	
       
  1089 	//Just to clear the old log message
       
  1090 	ret = theFlogger.Connect(); 
       
  1091 	if ( ret == KErrNone)
       
  1092 		ret = theFlogger.SetLogTags(KStdSubsysTag8, KStdCompTag8);
       
  1093 		if ( ret == KErrNone)
       
  1094 			ret = theFlogger.ClearLog();
       
  1095 			if ( ret == KErrNone)
       
  1096 				theFlogger.Close();
       
  1097 
       
  1098 	// perform test. write some data, roll the date to 0 the following day. write more data.
       
  1099 	if ( ret == KErrNone)
       
  1100 		{
       
  1101 		RFileLogger ::Write(KStdSubsysTag16, KStdCompTag16,EFileLoggingModeAppend, KTestMessage);
       
  1102 		
       
  1103 		TTime time;
       
  1104 		time.HomeTime();
       
  1105 		TInt item;
       
  1106 		TDateTime dateTime(time.DateTime());
       
  1107 		dateTime.SetHour(0);
       
  1108 		dateTime.SetMinute(0);
       
  1109 		dateTime.SetSecond(0);
       
  1110 		item = dateTime.Day();
       
  1111 		if ((dateTime.SetDay(++item) != KErrNone))
       
  1112 			{
       
  1113 			dateTime.SetDay(0);
       
  1114 			item = dateTime.Month();
       
  1115 			if (item == EDecember)
       
  1116 				{
       
  1117 				dateTime.SetMonth(EJanuary);
       
  1118 				item = dateTime.Year();
       
  1119 				dateTime.SetYear(item++);
       
  1120 				}
       
  1121 			else
       
  1122 				{
       
  1123 				dateTime.SetMonth(TMonth(item++));
       
  1124 				}
       
  1125 			}
       
  1126 		time = TTime(dateTime);
       
  1127 	
       
  1128 		User::SetHomeTime(time);
       
  1129 		TTime currentMicrosecs;
       
  1130 		TTimeIntervalDays newDate;
       
  1131 		currentMicrosecs.HomeTime();
       
  1132 		newDate = currentMicrosecs.DaysFrom(TTime(0));
       
  1133 
       
  1134 		RFileLogger ::Write(KStdSubsysTag16, KStdCompTag16,EFileLoggingModeAppend, KTestMessage);
       
  1135 		User::After(KTimeToLog);
       
  1136 		TRAPD(r, ret = DoTestCheckWriteL());
       
  1137 		if (r != KErrNone)
       
  1138 			ret = r;
       
  1139 
       
  1140 		}
       
  1141 	return ret;
       
  1142 
       
  1143 	}
       
  1144 
       
  1145 
       
  1146 
       
  1147 /**
       
  1148 * This function checks whether test data was written
       
  1149 * 						  in to the log file .				  
       
  1150 */
       
  1151 
       
  1152 
       
  1153 TInt CFloggerTest024_08::DoTestCheckWriteL()
       
  1154 	{
       
  1155 	RFile theFile;
       
  1156 	HBufC8 * hBuffer;
       
  1157 	TInt listfilesize,returnCode;
       
  1158 	RFs fileSystem; //For file operation create a file system
       
  1159 	TBuf8<256> testData; //To hold the test descriptor
       
  1160 	TInt numSuccessful = 0;
       
  1161 
       
  1162 
       
  1163 	_LIT8(KOOMError, "#Logs may be lost out of memory!!");
       
  1164 	
       
  1165 	User::LeaveIfError(fileSystem.Connect());
       
  1166 	
       
  1167 	//Open the file in the read mode
       
  1168 	User::LeaveIfError(theFile.Open(fileSystem,KFloggerOutputFile,EFileRead)); 
       
  1169 
       
  1170 	CleanupClosePushL(theFile);
       
  1171 
       
  1172 	User::LeaveIfError(theFile.Size(listfilesize)); //Size of the file
       
  1173 	
       
  1174 	hBuffer = HBufC8::New(listfilesize); //Allocate the buffer
       
  1175 	CleanupStack::PushL(hBuffer);
       
  1176 
       
  1177 	TPtr8 ptrString = hBuffer->Des();  ; //To hold the buffer
       
  1178 
       
  1179 	// Read from position 0: start of file
       
  1180 	User::LeaveIfError(returnCode = theFile.Read(ptrString));
       
  1181 	
       
  1182 	testData.Copy(KTestMessage); //Copy the test descriptor
       
  1183 	returnCode = ptrString.Find(testData); //find the test descriptor in the buffer read
       
  1184 											//from the file
       
  1185 	if (returnCode > 0)
       
  1186 		{
       
  1187 		numSuccessful++;
       
  1188 		}
       
  1189 											
       
  1190 	// We expect to see the string "date change"
       
  1191 	testData.Copy(KDateChangeMessage); //Copy the test descriptor
       
  1192 	returnCode = ptrString.Find(testData); //find the test descriptor in the buffer read
       
  1193 
       
  1194 	if (returnCode > 0)
       
  1195 		{
       
  1196 		numSuccessful++;
       
  1197 		}
       
  1198 
       
  1199 
       
  1200 	if (returnCode == KErrNotFound)
       
  1201 		{
       
  1202 		returnCode = ptrString.Find(KOOMError);
       
  1203 		if (returnCode > 0)
       
  1204 			User::Leave(KErrNoMemory);
       
  1205 		}
       
  1206 
       
  1207 
       
  1208 	
       
  1209 	CleanupStack::PopAndDestroy(hBuffer);
       
  1210 	CleanupStack::PopAndDestroy();	//theFile
       
  1211 	if (numSuccessful == 2)
       
  1212 		return KErrNone;
       
  1213 	else 
       
  1214 		return KErrNotFound;
       
  1215 	}
       
  1216 
       
  1217 
       
  1218 
       
  1219