os/persistentdata/traceservices/commsdebugutility/TE_commsdebugutility/src/step_008_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.
sl@0
     1
// Copyright (c) 2003-2009 Nokia Corporation and/or its subsidiary(-ies).
sl@0
     2
// All rights reserved.
sl@0
     3
// This component and the accompanying materials are made available
sl@0
     4
// under the terms of "Eclipse Public License v1.0"
sl@0
     5
// which accompanies this distribution, and is available
sl@0
     6
// at the URL "http://www.eclipse.org/legal/epl-v10.html".
sl@0
     7
//
sl@0
     8
// Initial Contributors:
sl@0
     9
// Nokia Corporation - initial contribution.
sl@0
    10
//
sl@0
    11
// Contributors:
sl@0
    12
//
sl@0
    13
// Description:
sl@0
    14
// This contains Flogger Unit Test Case 008.xx
sl@0
    15
sl@0
    16
// EPOC includes
sl@0
    17
#include <e32base.h>
sl@0
    18
sl@0
    19
// Test system includes
sl@0
    20
#include <comms-infras/commsdebugutility.h>
sl@0
    21
#include <f32file.h>
sl@0
    22
sl@0
    23
sl@0
    24
//User includes
sl@0
    25
#include "teststepcomsdbg.h"
sl@0
    26
#include "step_008_xx.h"
sl@0
    27
sl@0
    28
sl@0
    29
/**
sl@0
    30
* Function  Name	: CFloggerTest008_01
sl@0
    31
* Input parameters	: None
sl@0
    32
* Output parameters : None
sl@0
    33
* Description		: This is the constructor
sl@0
    34
*/
sl@0
    35
sl@0
    36
sl@0
    37
CFloggerTest008_01::CFloggerTest008_01()
sl@0
    38
	{
sl@0
    39
	// store the name of this test case
sl@0
    40
	SetTestStepName(_L("step_008_01"));
sl@0
    41
sl@0
    42
	}
sl@0
    43
sl@0
    44
sl@0
    45
sl@0
    46
/**
sl@0
    47
* Function  Name	:~ CFloggerTest008_01
sl@0
    48
* Input parameters	: None
sl@0
    49
* Output parameters : None
sl@0
    50
* Description		: This is the Destructor
sl@0
    51
*/
sl@0
    52
sl@0
    53
sl@0
    54
CFloggerTest008_01::~CFloggerTest008_01()
sl@0
    55
	{
sl@0
    56
		
sl@0
    57
	}
sl@0
    58
sl@0
    59
sl@0
    60
/**
sl@0
    61
* Function  Name	: doTestStepL
sl@0
    62
* Input parameters	: None
sl@0
    63
* Output parameters : TVerdict 
sl@0
    64
* Description		: This function returns weather the test case 008_01 has 
sl@0
    65
* 					  passed or failed
sl@0
    66
sl@0
    67
*/
sl@0
    68
sl@0
    69
sl@0
    70
TVerdict CFloggerTest008_01::doTestStepL( )
sl@0
    71
	{	
sl@0
    72
	INFO_PRINTF1(_L("Step 008.01 called "));
sl@0
    73
	
sl@0
    74
	if ( executeStepL(EFalse) == KErrNone )
sl@0
    75
		SetTestStepResult(EPass);
sl@0
    76
sl@0
    77
	else
sl@0
    78
		SetTestStepResult(EFail);
sl@0
    79
sl@0
    80
	
sl@0
    81
	User::After(KTimeForDisplay);
sl@0
    82
	return TestStepResult();
sl@0
    83
	}
sl@0
    84
sl@0
    85
sl@0
    86
/**
sl@0
    87
* Function  Name		: executeStepL
sl@0
    88
* Input parameters		: None
sl@0
    89
* Output parameters		: TInt 
sl@0
    90
* Description 			: This function writes the test data in to the log file 
sl@0
    91
* 						  This function check the test message is present in the 
sl@0
    92
* 						  log file 
sl@0
    93
sl@0
    94
*/
sl@0
    95
sl@0
    96
sl@0
    97
TInt CFloggerTest008_01::executeStepL(TBool heapTest)
sl@0
    98
	{
sl@0
    99
	TInt ret = KErrNone;
sl@0
   100
	ret = DoTestConnect();
sl@0
   101
	if (ret == KErrNone)
sl@0
   102
		{
sl@0
   103
		ret = DoTestWrite();
sl@0
   104
		if ( ret == KErrNone)
sl@0
   105
			{
sl@0
   106
			TRAPD(r, ret = DoTestCheckWriteL());
sl@0
   107
			if ((heapTest) && ((ret == KErrNotFound) || (r != KErrNone)))
sl@0
   108
				{
sl@0
   109
				ret = KErrNoMemory;
sl@0
   110
				}
sl@0
   111
			else if (r != KErrNone)
sl@0
   112
				{
sl@0
   113
				ret = r;
sl@0
   114
				}
sl@0
   115
			}
sl@0
   116
		}
sl@0
   117
sl@0
   118
//	if (ret == KErrNone)
sl@0
   119
	iFlogger.Close();
sl@0
   120
	return ret;
sl@0
   121
	}
sl@0
   122
sl@0
   123
/**
sl@0
   124
* Function  Name		: executeStepL
sl@0
   125
* Input parameters		: None
sl@0
   126
* Output parameters		: TInt 
sl@0
   127
* Description 			: This function writes the test data in to the log file 
sl@0
   128
* 						  This function check the test message is present in the 
sl@0
   129
* 						  log file 
sl@0
   130
sl@0
   131
*/
sl@0
   132
sl@0
   133
sl@0
   134
TInt CFloggerTest008_01::executeStepL()
sl@0
   135
	{
sl@0
   136
	return KErrGeneral;
sl@0
   137
	}
sl@0
   138
sl@0
   139
/**
sl@0
   140
* Function  Name		: DoTestWrite
sl@0
   141
* Input parameters		: None
sl@0
   142
* Output parameters		: TInt 
sl@0
   143
* Description 			: This function writes the data to the file logger
sl@0
   144
 
sl@0
   145
*/
sl@0
   146
sl@0
   147
sl@0
   148
TInt CFloggerTest008_01::DoTestWrite()
sl@0
   149
	{
sl@0
   150
	_LIT8(KTestMessageOne,"TC 8_01: The value of test integer variable :%d");
sl@0
   151
	iFlogger.WriteFormat(KTestMessageOne, 100);  //Write 8 bit test descriptor
sl@0
   152
	
sl@0
   153
	ForceLogFlush(iFlogger);
sl@0
   154
sl@0
   155
	return KErrNone; 
sl@0
   156
	}
sl@0
   157
sl@0
   158
sl@0
   159
/**
sl@0
   160
* Function  Name		: DoTestCheckWriteL
sl@0
   161
* Input parameters		: None
sl@0
   162
* Output parameters		: TInt 
sl@0
   163
* Description 			: This function checks the weather test data was written
sl@0
   164
						  in to the log file by DoTestWriteL() or not.
sl@0
   165
					  
sl@0
   166
*/
sl@0
   167
sl@0
   168
sl@0
   169
TInt CFloggerTest008_01::DoTestCheckWriteL()
sl@0
   170
	{
sl@0
   171
	User::After(1000*1000);
sl@0
   172
	RFile theFile;
sl@0
   173
	HBufC8 * hBuffer;
sl@0
   174
	TInt listfilesize;
sl@0
   175
	TInt returnCode;
sl@0
   176
	RFs fileSystem; //For file operation create a file system	
sl@0
   177
	_LIT(KLogFile,"c:\\logs\\log.txt"); // the log file path
sl@0
   178
sl@0
   179
	TBuf8<256> testData; //To hold the test descriptor
sl@0
   180
sl@0
   181
	_LIT8(KTestMessageOne,"TC 8_01: The value of test integer variable :%d");
sl@0
   182
	testData.Format(KTestMessageOne,100);
sl@0
   183
sl@0
   184
	_LIT8(KOOMError, "#Logs may be lost out of memory!!"); //Error message
sl@0
   185
sl@0
   186
	User::LeaveIfError(fileSystem.Connect());
sl@0
   187
	
sl@0
   188
	//Open the file in the read mode
sl@0
   189
	User::LeaveIfError(theFile.Open(fileSystem,KLogFile,EFileRead)); 
sl@0
   190
sl@0
   191
	CleanupClosePushL(theFile);	
sl@0
   192
	
sl@0
   193
	User::LeaveIfError(returnCode = theFile.Size(listfilesize)); //Size of the file
sl@0
   194
	hBuffer = HBufC8::New(listfilesize); //Allocate the buffer
sl@0
   195
	CleanupStack::PushL(hBuffer);
sl@0
   196
	TPtr8 ptrString = hBuffer->Des();  ; //To hold the buffer
sl@0
   197
sl@0
   198
	// Read from position 0: start of file
sl@0
   199
	returnCode = theFile.Read(ptrString);
sl@0
   200
	
sl@0
   201
	returnCode = ptrString.Find(testData); //find the test descriptor in the buffer read
sl@0
   202
									//from the file
sl@0
   203
sl@0
   204
	if (returnCode == KErrNotFound)  //Find the error message
sl@0
   205
		{
sl@0
   206
		returnCode = ptrString.Find(KOOMError);
sl@0
   207
		if (returnCode > 0)
sl@0
   208
			User::Leave(KErrNoMemory);
sl@0
   209
		}
sl@0
   210
sl@0
   211
	CleanupStack::PopAndDestroy(hBuffer);
sl@0
   212
	CleanupStack::PopAndDestroy(); // For theFile object
sl@0
   213
	if (returnCode > 0)
sl@0
   214
		return KErrNone;
sl@0
   215
	else 
sl@0
   216
		return KErrNotFound;
sl@0
   217
	}
sl@0
   218
sl@0
   219
sl@0
   220
sl@0
   221
/**
sl@0
   222
* Function  Name		: DoTestConnect
sl@0
   223
* Input parameters		: None
sl@0
   224
* Output parameters		: TInt 
sl@0
   225
* Description 			: This function establishes a connection to file logger
sl@0
   226
* 						  and sets the system and component name in file logger.
sl@0
   227
					  
sl@0
   228
*/
sl@0
   229
sl@0
   230
sl@0
   231
TInt CFloggerTest008_01::DoTestConnect()
sl@0
   232
	{
sl@0
   233
	TInt ret = EFail;
sl@0
   234
	TPtrC8 ptrSubSystem;
sl@0
   235
	TPtrC8 ptrComponent;
sl@0
   236
	ptrSubSystem.Set(_L8("SubSystem"));
sl@0
   237
	ptrComponent.Set(_L8("Component"));
sl@0
   238
sl@0
   239
	ret = iFlogger.Connect(); //Call connect() of Flogger
sl@0
   240
	if (ret == KErrNone)
sl@0
   241
		ret = iFlogger.SetLogTags(ptrSubSystem, ptrComponent); //SetLogTags() of Flogger called
sl@0
   242
sl@0
   243
	if (ret == KErrNone)
sl@0
   244
		ret = iFlogger.ClearLog(); //clear the contents from the log
sl@0
   245
	
sl@0
   246
	return ret;
sl@0
   247
	}
sl@0
   248
sl@0
   249
sl@0
   250
sl@0
   251
sl@0
   252
sl@0
   253
/**
sl@0
   254
* Function  Name	: CFloggerTest008_02
sl@0
   255
* Input parameters	: None
sl@0
   256
* Output parameters : None
sl@0
   257
* Description		: This is the constructor
sl@0
   258
*/
sl@0
   259
sl@0
   260
sl@0
   261
CFloggerTest008_02::CFloggerTest008_02()
sl@0
   262
	{
sl@0
   263
	// store the name of this test case
sl@0
   264
	SetTestStepName(_L("step_008_02"));
sl@0
   265
	}
sl@0
   266
sl@0
   267
sl@0
   268
/**
sl@0
   269
* Function  Name	:~ CFloggerTest008_02
sl@0
   270
* Input parameters	: None
sl@0
   271
* Output parameters : None
sl@0
   272
* Description		: This is the Destructor
sl@0
   273
*/
sl@0
   274
sl@0
   275
sl@0
   276
CFloggerTest008_02::~CFloggerTest008_02()
sl@0
   277
	{
sl@0
   278
	
sl@0
   279
	}
sl@0
   280
sl@0
   281
sl@0
   282
/**
sl@0
   283
* Function  Name	: doTestStepL
sl@0
   284
* Input parameters	: None
sl@0
   285
* Output parameters : TVerdict 
sl@0
   286
* Description		: This function returns weather the test case 008_02 has 
sl@0
   287
* 					  passed or failed
sl@0
   288
sl@0
   289
*/
sl@0
   290
sl@0
   291
sl@0
   292
TVerdict CFloggerTest008_02::doTestStepL( )
sl@0
   293
	{
sl@0
   294
	INFO_PRINTF1(_L("Step 008.02 called "));
sl@0
   295
	
sl@0
   296
	if ( executeStepL() == KErrNone )
sl@0
   297
		SetTestStepResult(EPass);
sl@0
   298
sl@0
   299
	else
sl@0
   300
		SetTestStepResult(EFail);
sl@0
   301
sl@0
   302
	
sl@0
   303
	User::After(KTimeForDisplay);
sl@0
   304
	return TestStepResult();
sl@0
   305
	}
sl@0
   306
sl@0
   307
sl@0
   308
/**
sl@0
   309
* Function  Name		: executeStepL
sl@0
   310
* Input parameters		: None
sl@0
   311
* Output parameters		: TInt 
sl@0
   312
* Description 			: This function writes the test data in to the log file 
sl@0
   313
* 						  This function check the test message is present in the 
sl@0
   314
* 						  log file 
sl@0
   315
sl@0
   316
*/
sl@0
   317
sl@0
   318
sl@0
   319
TInt CFloggerTest008_02::executeStepL()
sl@0
   320
	{
sl@0
   321
	TInt ret = KErrGeneral;
sl@0
   322
	ret = DoTestConnect();
sl@0
   323
	 CleanupClosePushL(iFlogger);
sl@0
   324
	if (ret == KErrNone)
sl@0
   325
		{
sl@0
   326
		ret = DoTestWrite() ;
sl@0
   327
		if ( ret == KErrNone)
sl@0
   328
			{
sl@0
   329
			iFlogger.Close();
sl@0
   330
			TRAPD(r, ret = DoTestCheckWriteL() );
sl@0
   331
			if ( r != KErrNone)
sl@0
   332
				ret = r;
sl@0
   333
			}
sl@0
   334
		}
sl@0
   335
	CleanupStack::PopAndDestroy();	//logger
sl@0
   336
	return ret;
sl@0
   337
	}
sl@0
   338
sl@0
   339
/**
sl@0
   340
* Function  Name		: executeStepL
sl@0
   341
* Input parameters		: None
sl@0
   342
* Output parameters		: TInt 
sl@0
   343
* Description 			: This function writes the test data in to the log file 
sl@0
   344
* 						  This function check the test message is present in the 
sl@0
   345
* 						  log file 
sl@0
   346
sl@0
   347
*/
sl@0
   348
sl@0
   349
sl@0
   350
TInt CFloggerTest008_02::executeStepL(TBool)
sl@0
   351
	{
sl@0
   352
	return KErrGeneral;
sl@0
   353
	}
sl@0
   354
sl@0
   355
/**
sl@0
   356
* Function  Name		: DoTestConnect
sl@0
   357
* Input parameters		: None
sl@0
   358
* Output parameters		: TInt 
sl@0
   359
* Description 			: This function establishes a connection to file logger
sl@0
   360
* 						  and sets the system and component name in file logger.
sl@0
   361
					  
sl@0
   362
*/ 
sl@0
   363
sl@0
   364
sl@0
   365
TInt CFloggerTest008_02::DoTestConnect()
sl@0
   366
	{
sl@0
   367
	TInt ret;
sl@0
   368
	TPtrC8 ptrSubSystem, ptrComponent;
sl@0
   369
	ptrSubSystem.Set(_L8("SubSystem"));
sl@0
   370
	ptrComponent.Set(_L8("Component"));
sl@0
   371
sl@0
   372
	ret = iFlogger.Connect(); //Call connect() of Flogger
sl@0
   373
	if (ret == KErrNone)
sl@0
   374
		ret = iFlogger.SetLogTags(ptrSubSystem, ptrComponent); //SetLogTags() of Flogger called
sl@0
   375
sl@0
   376
	if (ret == KErrNone)
sl@0
   377
		ret = iFlogger.ClearLog(); //clear the contents from the log
sl@0
   378
sl@0
   379
	return ret;
sl@0
   380
sl@0
   381
	}
sl@0
   382
sl@0
   383
sl@0
   384
/**
sl@0
   385
* Function  Name		: DoTestWrite
sl@0
   386
* Input parameters		: None
sl@0
   387
* Output parameters		: TInt 
sl@0
   388
* Description 			: This function writes the data to the file logger
sl@0
   389
 
sl@0
   390
*/
sl@0
   391
sl@0
   392
sl@0
   393
TInt CFloggerTest008_02::DoTestWrite()
sl@0
   394
	{
sl@0
   395
	_LIT8(KTestMessageTwo,"TC 8_02: The value of first test integer variable :%d The value of second test integer variable : %d");
sl@0
   396
	iFlogger.WriteFormat(KTestMessageTwo, 100, 200); //Writes a 8 bit test descriptor
sl@0
   397
	
sl@0
   398
	ForceLogFlush(iFlogger);
sl@0
   399
	return KErrNone; 
sl@0
   400
	}
sl@0
   401
sl@0
   402
sl@0
   403
/**
sl@0
   404
//Function  Name		: DoTestCheckWriteL
sl@0
   405
//Input parameters		: None
sl@0
   406
//Output parameters		: TInt 
sl@0
   407
//Description 			: This function checks the weather test data was written
sl@0
   408
//						  in to the log file by DoTestWriteL() or not.
sl@0
   409
					  
sl@0
   410
*/
sl@0
   411
sl@0
   412
sl@0
   413
TInt CFloggerTest008_02::DoTestCheckWriteL()
sl@0
   414
	{
sl@0
   415
	User::After(1000*1000);
sl@0
   416
	RFile theFile;
sl@0
   417
	HBufC8 * hBuffer;
sl@0
   418
	TInt listfilesize;
sl@0
   419
	TInt returnCode;
sl@0
   420
sl@0
   421
	RFs fileSystem; //For file operation create a file system
sl@0
   422
	_LIT(KLogFile,"c:\\logs\\log.txt"); // the log file path
sl@0
   423
sl@0
   424
	TBuf8<256> testData; //To hold the test descriptor
sl@0
   425
	_LIT8(KTestMessageTwo,"TC 8_02: The value of first test integer variable :%d The value of second test integer variable : %d");
sl@0
   426
	testData.Format(KTestMessageTwo,100, 200);
sl@0
   427
sl@0
   428
	_LIT8(KOOMError, "#Logs may be lost out of memory!!"); // Error message 
sl@0
   429
sl@0
   430
	User::LeaveIfError(fileSystem.Connect());//Connect to the file server
sl@0
   431
	
sl@0
   432
	//Open the file in the read mode
sl@0
   433
	User::LeaveIfError(theFile.Open(fileSystem,KLogFile,EFileRead)); 
sl@0
   434
sl@0
   435
	CleanupClosePushL(theFile);
sl@0
   436
sl@0
   437
	
sl@0
   438
	User::LeaveIfError(returnCode = theFile.Size(listfilesize)); //Size of the file
sl@0
   439
	hBuffer = HBufC8::New(listfilesize); //Allocate the buffer
sl@0
   440
	CleanupStack::PushL(hBuffer);
sl@0
   441
	TPtr8 ptrString = hBuffer->Des();  ; //To hold the buffer
sl@0
   442
sl@0
   443
	// Read from position 0: start of file
sl@0
   444
	returnCode = theFile.Read(ptrString);
sl@0
   445
	
sl@0
   446
	returnCode = ptrString.Find(testData); //find the test descriptor in the buffer read
sl@0
   447
										 //from the file
sl@0
   448
sl@0
   449
	if (returnCode == KErrNotFound) // Check for the error message in the log
sl@0
   450
		{
sl@0
   451
		returnCode = ptrString.Find(KOOMError);
sl@0
   452
		if (returnCode > 0)
sl@0
   453
			User::Leave(KErrNoMemory);
sl@0
   454
		}
sl@0
   455
sl@0
   456
sl@0
   457
	CleanupStack::PopAndDestroy(hBuffer);
sl@0
   458
	CleanupStack::PopAndDestroy();	//theFile
sl@0
   459
	if (returnCode > 0)
sl@0
   460
		return KErrNone;
sl@0
   461
	else 
sl@0
   462
		return KErrGeneral;
sl@0
   463
	}
sl@0
   464
sl@0
   465
sl@0
   466
sl@0
   467
sl@0
   468
sl@0
   469
/**
sl@0
   470
* Function  Name	: CFloggerTest008_03
sl@0
   471
* Input parameters	: None
sl@0
   472
* Output parameters : None
sl@0
   473
* Description		: This is the constructor
sl@0
   474
*/
sl@0
   475
sl@0
   476
sl@0
   477
CFloggerTest008_03::CFloggerTest008_03()
sl@0
   478
	{
sl@0
   479
	// store the name of this test case
sl@0
   480
	SetTestStepName(_L("step_008_03"));
sl@0
   481
	
sl@0
   482
	}
sl@0
   483
sl@0
   484
sl@0
   485
sl@0
   486
/**
sl@0
   487
* Function  Name	:~ CFloggerTest008_03
sl@0
   488
* Input parameters	: None
sl@0
   489
* Output parameters : None
sl@0
   490
* Description		: This is the Destructor
sl@0
   491
*/
sl@0
   492
sl@0
   493
sl@0
   494
CFloggerTest008_03::~CFloggerTest008_03()
sl@0
   495
	{
sl@0
   496
	}
sl@0
   497
sl@0
   498
sl@0
   499
sl@0
   500
/**
sl@0
   501
* Function  Name	: doTestStepL
sl@0
   502
* Input parameters	: None
sl@0
   503
* Output parameters : TVerdict 
sl@0
   504
* Description		: This function returns weather the test case 004_01 has 
sl@0
   505
* 					  passed or failed
sl@0
   506
sl@0
   507
*/
sl@0
   508
sl@0
   509
sl@0
   510
TVerdict CFloggerTest008_03::doTestStepL( )
sl@0
   511
	{
sl@0
   512
	if ( executeStepL() == KErrNone )
sl@0
   513
		SetTestStepResult(EPass);
sl@0
   514
sl@0
   515
	else
sl@0
   516
		SetTestStepResult(EFail);
sl@0
   517
sl@0
   518
	User::After(KTimeForDisplay);
sl@0
   519
	return TestStepResult();
sl@0
   520
	}
sl@0
   521
sl@0
   522
sl@0
   523
/**
sl@0
   524
* Function  Name		: executeStepL
sl@0
   525
* Input parameters		: None
sl@0
   526
* Output parameters		: TInt 
sl@0
   527
* Description 			: This function writes the test data in to the log file 
sl@0
   528
* 						  This function check the test message is present in the 
sl@0
   529
*						  log file 
sl@0
   530
sl@0
   531
*/
sl@0
   532
sl@0
   533
sl@0
   534
TInt CFloggerTest008_03::executeStepL()
sl@0
   535
	{
sl@0
   536
	TInt ret = KErrGeneral;
sl@0
   537
	
sl@0
   538
	ret = DoTestConnect();
sl@0
   539
	CleanupClosePushL(iFlogger);
sl@0
   540
	if (ret == KErrNone)
sl@0
   541
		ret = DoTestWrite();
sl@0
   542
		if (ret == KErrNone)
sl@0
   543
			ret = DoTestCheckWriteL();
sl@0
   544
	
sl@0
   545
	CleanupStack::PopAndDestroy();	//logger
sl@0
   546
sl@0
   547
	User::After(1000000);
sl@0
   548
	return ret;
sl@0
   549
	}
sl@0
   550
sl@0
   551
/**
sl@0
   552
* Function  Name		: executeStepL
sl@0
   553
* Input parameters		: None
sl@0
   554
* Output parameters		: TInt 
sl@0
   555
* Description 			: This function writes the test data in to the log file 
sl@0
   556
* 						  This function check the test message is present in the 
sl@0
   557
*						  log file 
sl@0
   558
sl@0
   559
*/
sl@0
   560
sl@0
   561
sl@0
   562
TInt CFloggerTest008_03::executeStepL(TBool)
sl@0
   563
	{
sl@0
   564
	return KErrGeneral;
sl@0
   565
	}
sl@0
   566
sl@0
   567
/**
sl@0
   568
* Function  Name		: DoTestConnect
sl@0
   569
* Input parameters		: None
sl@0
   570
* Output parameters		: TInt 
sl@0
   571
* Description 			: This function establishes a connection to file logger
sl@0
   572
* 						  and sets the system and component name in file logger.
sl@0
   573
					  
sl@0
   574
*/
sl@0
   575
sl@0
   576
sl@0
   577
TInt CFloggerTest008_03::DoTestConnect()
sl@0
   578
	{	
sl@0
   579
	TInt ret;
sl@0
   580
	TPtrC8 ptrSubSystem;
sl@0
   581
	TPtrC8 ptrComponent;
sl@0
   582
	ptrSubSystem.Set(_L8("SubSystem"));
sl@0
   583
	ptrComponent.Set(_L8("Component"));
sl@0
   584
sl@0
   585
	ret = iFlogger.Connect(); //Call connect() of Flogger
sl@0
   586
	
sl@0
   587
	if (ret == KErrNone)
sl@0
   588
		ret = iFlogger.SetLogTags(ptrSubSystem, ptrComponent); //SetLogTags() of Flogger called
sl@0
   589
	
sl@0
   590
	return ret;
sl@0
   591
	}
sl@0
   592
sl@0
   593
sl@0
   594
/**
sl@0
   595
Function  Name		: DoTestWrite
sl@0
   596
* Input parameters		: None
sl@0
   597
* Output parameters		: TInt 
sl@0
   598
* Description 			: This function writes the data to the file logger
sl@0
   599
 
sl@0
   600
*/
sl@0
   601
sl@0
   602
sl@0
   603
TInt CFloggerTest008_03::DoTestWrite()
sl@0
   604
	{
sl@0
   605
	//KTestLongMessage contains a very long test message 
sl@0
   606
	_LIT(KTestLongMessage,"TC 8_03: This is the long message This is the long message This is the long message This is the long message This is the long message This is the long message This is the long message This is the long message This is the long message This is the long message This is the long message ");
sl@0
   607
sl@0
   608
	iFlogger.Write(KTestLongMessage); //this causes a PANIC
sl@0
   609
	ForceLogFlush(iFlogger);	
sl@0
   610
	return KErrNone; 
sl@0
   611
	}
sl@0
   612
sl@0
   613
sl@0
   614
/**
sl@0
   615
* Function  Name		: DoTestCheckWriteL
sl@0
   616
* Input parameters		: None
sl@0
   617
* Output parameters		: TInt 
sl@0
   618
* Description 			: This function checks the weather test data was written
sl@0
   619
*						  in to the log file by DoTestWriteL() or not.
sl@0
   620
					  
sl@0
   621
*/
sl@0
   622
sl@0
   623
sl@0
   624
TInt CFloggerTest008_03::DoTestCheckWriteL()
sl@0
   625
	{
sl@0
   626
	User::After(KTimeToLog);
sl@0
   627
	RFile theFile;
sl@0
   628
	HBufC8 * hBuffer;
sl@0
   629
	TInt listfilesize,returnCode;
sl@0
   630
	RFs fileSystem; //For file operation create a file system
sl@0
   631
	TBuf8<256> testData; //To hold the test descriptor
sl@0
   632
	_LIT(KLogFile,"c:\\logs\\log.txt"); // log file name and path
sl@0
   633
sl@0
   634
	//The following contains the string of length 200(max) 
sl@0
   635
	//which is  written to the log file
sl@0
   636
	//_LIT(KTestLongMessage, "This is the long message This is the long message This is the long message This is the long message This is the long message This is the long message This is the long message This is the long message");
sl@0
   637
	_LIT(KTestLongMessage, "TC 8_03: This is the long message This is the long message This is the long message This is the long message This is the long message This is the long message This is the long message This is the long");
sl@0
   638
	
sl@0
   639
	//_LIT8(KOOMError, "#Logs may be lost out of memory!!");
sl@0
   640
	
sl@0
   641
	User::LeaveIfError(fileSystem.Connect());
sl@0
   642
	
sl@0
   643
	//Open the file in the read mode
sl@0
   644
	User::LeaveIfError(theFile.Open(fileSystem,KLogFile,EFileRead)); 
sl@0
   645
sl@0
   646
	CleanupClosePushL(theFile);
sl@0
   647
sl@0
   648
	User::LeaveIfError(theFile.Size(listfilesize)); //Size of the file
sl@0
   649
	
sl@0
   650
	hBuffer = HBufC8::New(listfilesize); //Allocate the buffer
sl@0
   651
	CleanupStack::PushL(hBuffer);
sl@0
   652
sl@0
   653
	TPtr8 ptrString = hBuffer->Des();  ; //To hold the buffer
sl@0
   654
sl@0
   655
	// Read from position 0: start of file
sl@0
   656
	User::LeaveIfError(returnCode = theFile.Read(ptrString));
sl@0
   657
	
sl@0
   658
	testData.Copy(KTestLongMessage); //Copy the test descriptor
sl@0
   659
	returnCode = ptrString.Find(testData); //find the test descriptor in the buffer read
sl@0
   660
											//from the file
sl@0
   661
sl@0
   662
	
sl@0
   663
	CleanupStack::PopAndDestroy(hBuffer);
sl@0
   664
	CleanupStack::PopAndDestroy();	//theFile
sl@0
   665
	if (returnCode > 0)
sl@0
   666
		return KErrNone;
sl@0
   667
	else 
sl@0
   668
		return KErrGeneral;
sl@0
   669
	}
sl@0
   670
sl@0
   671
sl@0
   672
sl@0
   673
sl@0
   674
sl@0
   675
/**
sl@0
   676
* Function  Name	: CFloggerTest008_04
sl@0
   677
* Input parameters	: None
sl@0
   678
* Output parameters : None
sl@0
   679
* Description		: This is the constructor
sl@0
   680
*/
sl@0
   681
sl@0
   682
sl@0
   683
CFloggerTest008_04::CFloggerTest008_04()
sl@0
   684
	{
sl@0
   685
	// store the name of this test case
sl@0
   686
	SetTestStepName(_L("step_008_04"));
sl@0
   687
	}
sl@0
   688
sl@0
   689
sl@0
   690
sl@0
   691
/**
sl@0
   692
* Function  Name	:~ CFloggerTest008_04
sl@0
   693
* Input parameters	: None
sl@0
   694
* Output parameters : None
sl@0
   695
* Description		: This is the Destructor
sl@0
   696
*/
sl@0
   697
sl@0
   698
sl@0
   699
CFloggerTest008_04::~CFloggerTest008_04()
sl@0
   700
	{
sl@0
   701
	}
sl@0
   702
sl@0
   703
sl@0
   704
sl@0
   705
/**
sl@0
   706
sl@0
   707
*Function  Name : doTestStepL
sl@0
   708
* Input parameters : None
sl@0
   709
* Output parameters : TVerdict 
sl@0
   710
* Description : This function is responsible for doing the heap test analysis 
sl@0
   711
sl@0
   712
*/
sl@0
   713
sl@0
   714
TVerdict CFloggerTest008_04::doTestStepL( )
sl@0
   715
	{
sl@0
   716
	INFO_PRINTF1(_L("Step 008.04 called "));
sl@0
   717
sl@0
   718
	CFloggerTest008_01* step008_01 = new CFloggerTest008_01;
sl@0
   719
	CleanupStack::PushL(step008_01);
sl@0
   720
	doTestStepWithHeapFailureL( *step008_01, 1, 20, KErrNone, ETrue);
sl@0
   721
sl@0
   722
	CleanupStack::PopAndDestroy(step008_01);
sl@0
   723
	
sl@0
   724
	User::After(KTimeForDisplay);
sl@0
   725
	return TestStepResult();
sl@0
   726
	}
sl@0
   727