os/persistentdata/traceservices/commsdebugutility/TE_commsdebugutility/src/step_010_xx.cpp
author sl@SLION-WIN7.fritz.box
Fri, 15 Jun 2012 03:10:57 +0200
changeset 0 bde4ae8d615e
permissions -rw-r--r--
First public contribution.
     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 010.xx
    15 
    16 // EPOC includes
    17 #include <e32base.h>
    18 
    19 // Test system includes
    20 #include <comms-infras/commsdebugutility.h>
    21 #include "TestMessage.h"
    22 #include <f32file.h>
    23 
    24 
    25 //User includes
    26 #include "teststepcomsdbg.h"
    27 #include "step_010_xx.h"
    28 
    29 
    30 
    31 
    32 CFloggerTest010_01::CFloggerTest010_01()
    33 	{
    34 	// store the name of this test case
    35 	SetTestStepName(_L("step_010_01"));
    36 	}
    37 
    38 
    39 
    40 
    41 CFloggerTest010_01::~CFloggerTest010_01()
    42 	{
    43 	}
    44 
    45 
    46 
    47 
    48 TVerdict CFloggerTest010_01::doTestStepL( )
    49 	{
    50 	INFO_PRINTF1(_L("Step 010.01 called "));
    51 	
    52 	if ( executeStepL(EFalse) == KErrNone )
    53 		SetTestStepResult(EPass);
    54 
    55 	else
    56 		SetTestStepResult(EFail);
    57 
    58 	
    59 	User::After(KTimeForDisplay);
    60 	return TestStepResult();
    61 	}
    62 
    63 
    64 
    65 TInt CFloggerTest010_01::executeStepL(TBool heapTest)
    66 	{
    67 	User::After(100*1000);	//Need this or connect could return KErrServerTerminated
    68 	TInt ret = KErrGeneral;
    69 	
    70 	ret = DoTestConnect();
    71 	if (ret == KErrNone)
    72 		{
    73 		ret = DoTestWrite();
    74 			if (ret == KErrNone)
    75 			{
    76 			TRAPD(r, ret = DoTestCheckWriteL());
    77 			if ((heapTest) && ((ret == KErrNotFound) || (r != KErrNone)))
    78 				{
    79 				ret = KErrNoMemory;
    80 				}
    81 			else if (r != KErrNone)
    82 				{
    83 				ret = r;
    84 				}
    85 			}
    86 		}
    87 	iFlogger.Close();
    88 	return ret;
    89 	}
    90 
    91 TInt CFloggerTest010_01::executeStepL()
    92 	{
    93 	return KErrGeneral;
    94 	}
    95 
    96 
    97 TInt CFloggerTest010_01::DoTestWrite()
    98 	{
    99 	_LIT8(KDescTxt,"TC 10_1:Test Msg----"); //8 bit test descriptor
   100 
   101 	iFlogger.HexDump(KDescTxt,KHexTestHeader); 
   102 	
   103 	ForceLogFlush(iFlogger);
   104 	
   105 	iFlogger.__DbgShutDownServer();
   106 	iFlogger.Close();
   107 	return KErrNone; 
   108 	}
   109 
   110 
   111 
   112 
   113 TInt CFloggerTest010_01::DoTestCheckWriteL()
   114 	{
   115 	User::After(KTimeToLog);
   116 
   117 	RFile theFile;
   118 	HBufC8 * hBuffer;
   119 	TInt listfilesize;
   120 	TInt returnCode;
   121 	RFs fileSystem; //For file operation create a file system	
   122 	TBuf8<256> testData; //To hold the test descriptor
   123 	_LIT(KLogFile,"c:\\logs\\log.txt"); // the log file path
   124 
   125 	_LIT(KHeaderTxt,"Test Header");//  Test header
   126 	_LIT8(KBodyTxt1,"TC 10_1:Test Msg");  // first 16 chars
   127 
   128 	_LIT8(KOOMError, "#Logs may be lost out of memory!!"); //Error message
   129 
   130 	User::LeaveIfError(fileSystem.Connect());
   131 	
   132 	//Open the file in the read mode
   133 	User::LeaveIfError(theFile.Open(fileSystem,KLogFile,EFileRead)); 
   134 	CleanupClosePushL(theFile);
   135 	
   136 	User::LeaveIfError(returnCode = theFile.Size(listfilesize)); //Size of the file
   137 	hBuffer = HBufC8::New(listfilesize); //Allocate the buffer
   138 	CleanupStack::PushL(hBuffer);
   139 	TPtr8 ptrString = hBuffer->Des();  ; //To hold the buffer
   140 
   141 	// Read from position 0: start of file
   142 	returnCode = theFile.Read(ptrString);
   143 	
   144 	testData.Copy(KHeaderTxt); //Copy the test header descriptor 
   145 	returnCode = ptrString.Find(testData); //find the test header descriptor in the buffer read
   146 										 //from the file
   147 	if (returnCode > 0)
   148 		{
   149 		testData.Copy(KHexTestMargin); //Copy the test margin descriptor	
   150 		returnCode = ptrString.Find(testData); //find the test margin descriptor in the buffer read
   151 									 	 //from the file
   152 		}
   153 
   154 	if (returnCode > 0)
   155 		{
   156 		testData.Copy(KBodyTxt1); //Copy the test descriptor 
   157 		returnCode=ptrString.Find(testData); //find the test descriptor in the buffer read
   158 										 //from the file
   159 		}
   160 
   161 	if (returnCode == KErrNotFound)  //Find the error message
   162 		{
   163 		returnCode = ptrString.Find(KOOMError);
   164 		if (returnCode > 0)
   165 			User::Leave(KErrNoMemory);
   166 		}
   167 
   168 	CleanupStack::PopAndDestroy(hBuffer);
   169 	CleanupStack::PopAndDestroy();	//theFile object
   170 	if (returnCode > 0)
   171 		return KErrNone;
   172 	else 
   173 		return KErrNotFound;
   174 	}
   175 
   176 
   177 
   178 
   179 TInt CFloggerTest010_01::DoTestConnect()
   180 	{
   181 	
   182 	TInt ret;
   183 	TPtrC8 ptrSubSystem;
   184 	TPtrC8 ptrComponent;
   185 	ptrSubSystem.Set(_L8("SubSystem"));
   186 	ptrComponent.Set(_L8("Component"));
   187 	
   188 	ret = iFlogger.Connect(); //Call connect() of Flogger
   189 
   190 	if (ret == KErrNone)
   191 		ret = iFlogger.SetLogTags(ptrSubSystem, ptrComponent); //SetLogTags() of Flogger called
   192 
   193 	if (ret == KErrNone)
   194 		ret = iFlogger.ClearLog(); //clear the contents from the log
   195 
   196 	return ret;
   197 	}
   198 
   199 
   200 
   201 
   202 
   203 
   204 
   205 
   206 
   207 CFloggerTest010_02::CFloggerTest010_02()
   208 	{
   209 	// store the name of this test case
   210 	SetTestStepName(_L("step_010_02"));
   211 	}
   212 
   213 
   214 
   215 
   216 CFloggerTest010_02::~CFloggerTest010_02()
   217 	{
   218 	}
   219 
   220 
   221 
   222 TVerdict CFloggerTest010_02::doTestStepL( )
   223 	{
   224 	INFO_PRINTF1(_L("Step 010.02 called "));
   225 
   226 	if ( executeStepL() == KErrNone )
   227 		SetTestStepResult(EPass);
   228 
   229 	else
   230 		SetTestStepResult(EFail);
   231 
   232 	
   233 	User::After(KTimeForDisplay);
   234 	return TestStepResult();
   235 	}
   236 
   237 
   238 
   239 TInt CFloggerTest010_02::executeStepL( )
   240 	{
   241 	TInt ret = KErrGeneral;
   242 	ret = DoTestConnect();
   243 
   244 	if (ret == KErrNone)
   245 		{
   246 		ret = DoTestWrite();
   247 			if (ret == KErrNone)
   248 			{
   249 			TRAPD(r, ret = DoTestCheckWriteL());
   250 		
   251 			if (r != KErrNone)
   252 				ret = r;
   253 				
   254 			}
   255 			
   256 		}
   257 	iFlogger.Close();
   258 	return ret;
   259 	}
   260 
   261 TInt CFloggerTest010_02::executeStepL(TBool)
   262 	{
   263 	return KErrGeneral;
   264 	}
   265 
   266 
   267 TInt CFloggerTest010_02::DoTestWrite()
   268 	{
   269 	_LIT8(KDescText,"TC 10_2:Test Msg");
   270 
   271 	iFlogger.HexDump(KDescText, KEightSpaces8); 
   272 	ForceLogFlush(iFlogger);
   273 
   274 	iFlogger.__DbgShutDownServer();
   275 	iFlogger.Close();
   276 	return KErrNone; 
   277 	}
   278 
   279 
   280 
   281 
   282 TInt CFloggerTest010_02::DoTestCheckWriteL()
   283 	{
   284 	User::After(KTimeToLog);
   285 	RFile theFile;
   286 	HBufC8 * hBuffer;
   287 	TInt listfilesize;
   288 	TInt returnCode;
   289 	RFs fileSystem; //For file operation create a file system	
   290 	TBuf8<256> testData; //To hold the test descriptor
   291 	_LIT(KLogFile,"c:\\logs\\log.txt"); // the log file path
   292 
   293 	_LIT8(KOOMError, "#Logs may be lost out of memory!!"); // Error message 
   294 
   295 	User::LeaveIfError(fileSystem.Connect());
   296 	
   297 	//Open the file in the read mode
   298 	User::LeaveIfError(theFile.Open(fileSystem,KLogFile,EFileRead)); 
   299 
   300 	CleanupClosePushL(theFile);
   301 	
   302 	User::LeaveIfError(returnCode = theFile.Size(listfilesize)); //Size of the file
   303 	hBuffer = HBufC8::New(listfilesize); //Allocate the buffer
   304 	CleanupStack::PushL(hBuffer);
   305 	TPtr8 ptrString = hBuffer->Des();  ; //To hold the buffer
   306 
   307 	// Read from position 0: start of file
   308 	returnCode = theFile.Read(ptrString);
   309 	
   310 	testData.FillZ();
   311 	testData.Copy(KEightSpaces8); //Copy the test descriptor 
   312 	returnCode = ptrString.Find(testData); //find the test descriptor in the buffer read
   313 										 //from the file
   314 
   315 	if (returnCode == KErrNotFound) // Check for the error message in the log
   316 		{
   317 		returnCode = ptrString.Find(KOOMError);
   318 		if (returnCode > 0)
   319 			User::Leave(KErrNoMemory);
   320 		}
   321 	
   322 	CleanupStack::PopAndDestroy(hBuffer);
   323 	CleanupStack::PopAndDestroy();	//theFile
   324 	if (returnCode > 0)
   325 		return KErrNone;
   326 	else 
   327 		return KErrGeneral;
   328 	}
   329 
   330 
   331 
   332 TInt CFloggerTest010_02::DoTestConnect()
   333 	{
   334 	TInt ret = KErrGeneral;
   335 	TPtrC8 ptrSubSystem, ptrComponent;
   336 	ptrSubSystem.Set(_L8("SubSystem"));
   337 	ptrComponent.Set(_L8("Component"));
   338 	
   339 	ret = iFlogger.Connect(); //Call connect() of Flogger
   340 	if (ret == KErrNone)
   341 		ret = iFlogger.SetLogTags(ptrSubSystem, ptrComponent); //SetLogTags() of Flogger called
   342 
   343 	if (ret == KErrNone)
   344 		ret = iFlogger.ClearLog(); //clear the contents from the log
   345 
   346 	return ret;
   347 	}
   348 
   349 
   350 
   351 
   352 
   353 
   354 
   355 
   356 CFloggerTest010_03::CFloggerTest010_03()
   357 	{
   358 	// store the name of this test case
   359 	SetTestStepName(_L("step_010_03"));
   360 	}
   361 
   362 
   363 
   364 
   365 CFloggerTest010_03::~CFloggerTest010_03()
   366 	{
   367 	//iFlogger.Close(); //Close the flogger 
   368 	}
   369 
   370 
   371 
   372 
   373 TVerdict CFloggerTest010_03::doTestStepL( )
   374 	{
   375 	INFO_PRINTF1(_L("Step 010.03 called "));
   376 	
   377 	if ( executeStepL() == KErrNone )
   378 		SetTestStepResult(EPass);
   379 
   380 	else
   381 		SetTestStepResult(EFail);
   382 
   383 	
   384 	User::After(KTimeForDisplay);
   385 	return TestStepResult();
   386 	}	
   387 
   388 
   389 TInt CFloggerTest010_03::executeStepL(TBool)
   390 	{
   391 	return KErrGeneral;
   392 	}
   393 
   394 TInt CFloggerTest010_03::executeStepL( )
   395 	{
   396 	TInt ret = KErrGeneral;
   397 	ret = DoTestConnect();
   398 
   399 	if (ret == KErrNone)
   400 		{
   401 		ret = DoTestWrite();
   402 			if (ret == KErrNone)
   403 			{
   404 			TRAPD(r, ret = DoTestCheckWriteL());
   405 		
   406 			if (r != KErrNone)
   407 				ret = r;
   408 			}
   409 		}
   410 	iFlogger.Close();
   411 	return ret;
   412 	}
   413 
   414 
   415 
   416 
   417 TInt CFloggerTest010_03::DoTestWrite()
   418 	{
   419 	_LIT8(KDescTxt,"TC 10_3:Test Msg"); //8 bit test descriptor
   420 
   421 
   422 	iFlogger.HexDump(KDescTxt); 
   423 	ForceLogFlush(iFlogger);
   424 	
   425 	iFlogger.__DbgShutDownServer();
   426 	iFlogger.Close();
   427 	return KErrNone; 
   428 	}
   429 
   430 
   431 
   432 
   433 
   434 TInt CFloggerTest010_03::DoTestCheckWriteL()
   435 	{
   436 	User::After(KTimeToLog);
   437 	RFile theFile;
   438 	HBufC8 * hBuffer;
   439 	TInt listfilesize;
   440 	TInt returnCode;
   441 	RFs fileSystem; //For file operation create a file system	
   442 	TBuf8<256> testData; //To hold the test descriptor
   443 	_LIT(KLogFile,"c:\\logs\\log.txt"); // the log file path
   444 
   445 	_LIT8(KBodyTxt,"TC 10_3:Test Msg");//  Test body descriptor 
   446 	_LIT8(KOOMError, "#Logs may be lost out of memory!!"); //Error message
   447 
   448 	User::LeaveIfError(fileSystem.Connect());
   449 	
   450 	//Open the file in the read mode
   451 	User::LeaveIfError(theFile.Open(fileSystem,KLogFile,EFileRead)); 
   452 	CleanupClosePushL(theFile);
   453 	
   454 	User::LeaveIfError(returnCode = theFile.Size(listfilesize)); //Size of the file
   455 	hBuffer = HBufC8::New(listfilesize); //Allocate the buffer
   456 	CleanupStack::PushL(hBuffer);
   457 	TPtr8 ptrString = hBuffer->Des();  ; //To hold the buffer
   458 
   459 	// Read from position 0: start of file
   460 	returnCode=theFile.Read(ptrString);
   461 		
   462 	testData.Copy(KBodyTxt); //Copy the test descriptor 
   463 	returnCode=ptrString.Find(testData); //find the test descriptor in the buffer read
   464 										 //from the file
   465 										 
   466 	if (returnCode == KErrNotFound)  //Find the error message
   467 		{
   468 		returnCode = ptrString.Find(KOOMError);
   469 		if (returnCode > 0)
   470 			User::Leave(KErrNoMemory);
   471 		}
   472 	
   473 	CleanupStack::PopAndDestroy(hBuffer);
   474 	CleanupStack::PopAndDestroy();	//theFile object
   475 	if (returnCode > 0)
   476 		return KErrNone;
   477 	else 
   478 		return KErrGeneral;
   479 	}
   480 
   481 
   482 
   483 
   484 TInt CFloggerTest010_03::DoTestConnect()
   485 	{
   486 	TInt result;
   487 	TPtrC8 ptrSubSystem;
   488 	TPtrC8 ptrComponent;
   489 	ptrSubSystem.Set(_L8("SubSystem"));
   490 	ptrComponent.Set(_L8("Component"));
   491 	
   492 	result = iFlogger.Connect(); //Call connect() of Flogger
   493 	if (result == KErrNone)
   494 		{
   495 		result = iFlogger.SetLogTags(ptrSubSystem, ptrComponent); //SetLogTags() of Flogger called
   496 																//to set the tags
   497 		result = iFlogger.ClearLog(); //clear the contents in the log
   498 		
   499 		}
   500 	return result;
   501 
   502 	}
   503 
   504 
   505 
   506 
   507 
   508 
   509 
   510 
   511 CFloggerTest010_04::CFloggerTest010_04()
   512 	{
   513 	// store the name of this test case
   514 	SetTestStepName(_L("step_010_04"));
   515 	}
   516 
   517 
   518 
   519 
   520 CFloggerTest010_04::~CFloggerTest010_04()
   521 	{
   522 	}
   523 
   524 
   525 
   526 TVerdict CFloggerTest010_04::doTestStepL( )
   527 	{
   528 
   529 	INFO_PRINTF1(_L("Step 010.04 called "));
   530 	
   531 	if ( executeStepL() == KErrNone )
   532 		SetTestStepResult(EPass);
   533 
   534 	else
   535 		SetTestStepResult(EFail);
   536 
   537 	
   538 	User::After(KTimeForDisplay);
   539 	return TestStepResult();
   540 	}
   541 
   542 TInt CFloggerTest010_04::executeStepL(TBool)
   543 	{
   544 	return KErrGeneral;
   545 	}
   546 
   547 TInt CFloggerTest010_04::executeStepL( )
   548 	{
   549 	TInt ret = KErrGeneral;
   550 	ret = DoTestConnect();
   551 
   552 	if (ret == KErrNone)
   553 		{
   554 		ret = DoTestWrite();
   555 			if (ret == KErrNone)
   556 			{
   557 			TRAPD(r, ret = DoTestCheckWriteL());
   558 		
   559 			if (r != KErrNone)
   560 				ret = r;
   561 			}
   562 		}
   563 	iFlogger.Close();
   564 	return ret;
   565 	}
   566 
   567 
   568 
   569 
   570 TInt CFloggerTest010_04::DoTestWrite()
   571 	{
   572 	_LIT8(KTestDesc,"TC 10_4:Test Msg");
   573 
   574 	iFlogger.HexDump(KTestDesc, KNullDesC8);
   575 	ForceLogFlush(iFlogger);
   576 	iFlogger.__DbgShutDownServer();
   577 	iFlogger.Close();
   578 	return KErrNone; 
   579 	}
   580 
   581 
   582 
   583 
   584 TInt CFloggerTest010_04::DoTestCheckWriteL()
   585 	{
   586 	User::After(KTimeToLog);
   587 	RFile theFile;
   588 	HBufC8 * hBuffer;
   589 	TInt listfilesize;
   590 	TInt returnCode;
   591 	RFs fileSystem; //For file operation create a file system	
   592 	TBuf8<256> testData; //To hold the test descriptor
   593 	_LIT(KLogFile,"c:\\logs\\log.txt"); // the log file path
   594 
   595 	_LIT8(KBodyTxt,"TC 10_4:Test Msg");//  Test body descriptor 
   596 	_LIT8(KOOMError, "#Logs may be lost out of memory!!"); //Error message
   597 	TInt numSuccessful= 0;
   598 
   599 	User::LeaveIfError(fileSystem.Connect());
   600 	
   601 	//Open the file in the read mode
   602 	User::LeaveIfError(theFile.Open(fileSystem,KLogFile,EFileRead)); 
   603 	CleanupClosePushL(theFile);
   604 
   605 	User::LeaveIfError(returnCode = theFile.Size(listfilesize)); //Size of the file
   606 	hBuffer = HBufC8::New(listfilesize); //Allocate the buffer
   607 	CleanupStack::PushL(hBuffer);
   608 	TPtr8 ptrString = hBuffer->Des();  ; //To hold the buffer
   609 
   610 	// Read from position 0: start of file
   611 	returnCode = theFile.Read(ptrString);
   612 	
   613 
   614 	testData.Copy(KBodyTxt); //Copy the test descriptor 
   615 	returnCode=ptrString.Find(testData); //find the test descriptor in the buffer read
   616 									 //from the file
   617 									 
   618 	if (returnCode > 0)
   619 		numSuccessful++;
   620 		
   621 	returnCode=ptrString.Find(KHexTestHeader); //find the test descriptor in the buffer read
   622 		
   623 	if (returnCode == KErrNotFound)
   624 		numSuccessful++;
   625 
   626 
   627 	if (returnCode == KErrNotFound)  //Find the error message
   628 		{
   629 		returnCode = ptrString.Find(KOOMError);
   630 		if (returnCode > 0)
   631 			User::Leave(KErrNoMemory);
   632 		}
   633 
   634 	CleanupStack::PopAndDestroy(hBuffer);
   635 	CleanupStack::PopAndDestroy();	//theFile object
   636 
   637 	if (numSuccessful == 2)
   638 		return KErrNone;
   639 	else 
   640 		return KErrGeneral;
   641 	}
   642 
   643 
   644 
   645 
   646 TInt CFloggerTest010_04::DoTestConnect()
   647 	{
   648 	TInt ret = KErrGeneral;
   649 	TPtrC8 ptrSubSystem;
   650 	TPtrC8 ptrComponent;
   651 	ptrSubSystem.Set(_L8("SubSystem"));
   652 	ptrComponent.Set(_L8("Component"));
   653 	
   654 	ret = iFlogger.Connect(); //Call connect() of Flogger
   655 	if (ret == KErrNone)
   656 		ret = iFlogger.SetLogTags(ptrSubSystem, ptrComponent); //SetLogTags() of Flogger called
   657 
   658 	if (ret == KErrNone)
   659 		ret = iFlogger.ClearLog(); //clear the contents from the log
   660 
   661 	return ret;
   662 	}
   663 
   664 
   665 
   666 
   667 
   668 
   669 
   670 
   671 
   672 CFloggerTest010_05::CFloggerTest010_05()
   673 	{
   674 	// store the name of this test case
   675 	SetTestStepName(_L("step_010_05"));
   676 	}	
   677 
   678 
   679 
   680 CFloggerTest010_05::~CFloggerTest010_05()
   681 	{
   682 	}
   683 
   684 
   685 
   686 
   687 TVerdict CFloggerTest010_05::doTestStepL( )
   688 	{
   689 	INFO_PRINTF1(_L("Step 010.05 called "));
   690 	
   691 	if ( executeStepL() == KErrNone )
   692 		SetTestStepResult(EPass);
   693 
   694 	else
   695 		SetTestStepResult(EFail);
   696 
   697 	
   698 	User::After(KTimeForDisplay);
   699 	return TestStepResult();
   700 	}
   701 
   702 
   703 
   704 TInt CFloggerTest010_05::executeStepL(TBool)
   705 	{
   706 	return KErrGeneral;
   707 	}
   708 	
   709 TInt CFloggerTest010_05::executeStepL( )
   710 	{
   711 	User::After(100*1000);	//Need this or connect will return KErrServerTerminated
   712 	TInt ret = KErrGeneral;
   713 	ret = DoTestConnect();
   714 
   715 	if (ret == KErrNone)
   716 		{
   717 		ret = DoTestWrite();
   718 			if (ret == KErrNone)
   719 			{
   720 			TRAPD(r, ret = DoTestCheckWriteL());
   721 		
   722 			if (r != KErrNone)
   723 				ret = r;
   724 			}
   725 		}
   726 	if (ret == KErrNone)
   727 		iFlogger.__DbgShutDownServer();
   728 	iFlogger.Close();
   729 	return ret;
   730 	}	
   731 
   732 
   733 
   734 TInt CFloggerTest010_05::DoTestWrite()
   735 	{
   736 	ForceLogFlush(iFlogger);
   737 
   738 	iFlogger.HexDump(KNullDesC8);
   739 	return KErrNone; 
   740 	}
   741 
   742 
   743 
   744 TInt CFloggerTest010_05::DoTestCheckWriteL()
   745 	{
   746 	User::After(KTimeToLog);
   747 	RFile theFile;
   748 	HBufC8 * hBuffer;
   749 	TInt listfilesize;
   750 	TInt returnCode;
   751 	RFs fileSystem; //For file operation create a file system	
   752 	_LIT(KLogFile,"c:\\logs\\log.txt"); // the log file path
   753 	_LIT8(KExpectedString,"0000 :");
   754 
   755 	_LIT8(KOOMError, "#Logs may be lost out of memory!!"); //Error message
   756 
   757 	User::LeaveIfError(fileSystem.Connect());
   758 	
   759 	//Open the file in the read mode
   760 	User::LeaveIfError(theFile.Open(fileSystem,KLogFile,EFileRead)); 
   761 	CleanupClosePushL(theFile);
   762 
   763 	
   764 	User::LeaveIfError(returnCode = theFile.Size(listfilesize)); //Size of the file
   765 	hBuffer = HBufC8::New(listfilesize); //Allocate the buffer
   766 	CleanupStack::PushL(hBuffer);
   767 	TPtr8 ptrString = hBuffer->Des();  ; //To hold the buffer
   768 
   769 	// Read from position 0: start of file
   770 	returnCode = theFile.Read(ptrString);
   771 	
   772 	//check for no OOM msg
   773 	returnCode = ptrString.Find(KOOMError);
   774 	if (returnCode > 0)
   775 		{
   776 		User::Leave(KErrNoMemory);
   777 		}
   778 	
   779 	
   780 	// we expect the output to be pretty blank, so not much to search for
   781 	// except make sure the standard "0000: " ins't even there
   782 	returnCode = ptrString.Find(KExpectedString); //find the test descriptor in the buffer read
   783 										 //from the file
   784 	
   785 	CleanupStack::PopAndDestroy(hBuffer);
   786 	CleanupStack::PopAndDestroy();	//theFile object
   787 	if (returnCode == KErrNotFound)
   788 		return KErrNone;
   789 	else 
   790 		return KErrGeneral;
   791 	}
   792 
   793 
   794 
   795 
   796 
   797 TInt CFloggerTest010_05::DoTestConnect()
   798 	{
   799 	TInt ret = KErrGeneral;
   800 	TPtrC8 ptrSubSystem, ptrComponent;
   801 	ptrSubSystem.Set(_L8("SubSystem"));
   802 	ptrComponent.Set(_L8("Component"));
   803 	
   804 	ret = iFlogger.Connect(); //Call connect() of Flogger
   805 	if (ret == KErrNone)
   806 		ret = iFlogger.SetLogTags(ptrSubSystem, ptrComponent); //SetLogTags() of Flogger called
   807 
   808 	if (ret == KErrNone)
   809 		ret = iFlogger.ClearLog(); //clear the contents from the log
   810 
   811 	return ret;
   812 
   813 	}
   814 
   815 
   816 
   817 
   818 
   819 
   820 CFloggerTest010_06::CFloggerTest010_06()
   821 	{
   822 	// store the name of this test case
   823 	SetTestStepName(_L("step_010_06"));
   824 	}
   825 
   826 
   827 
   828 
   829 CFloggerTest010_06::~CFloggerTest010_06()
   830 	{
   831 	}
   832 
   833 
   834 
   835 TVerdict CFloggerTest010_06::doTestStepL( )
   836 	{
   837 	User::After(100*1000);	//Need this or connect will return KErrServerTerminated
   838 
   839 	INFO_PRINTF1(_L("Step 010.06 called "));
   840 
   841 	CFloggerTest010_01* step010_01 = new CFloggerTest010_01;
   842 	CleanupStack::PushL(step010_01);
   843 	doTestStepWithHeapFailureL( *step010_01, 1, 20, KErrNone, ETrue);
   844 
   845 	CleanupStack::PopAndDestroy(step010_01);
   846 
   847 	User::After(KTimeForDisplay);
   848 	return TestStepResult();
   849 	}
   850