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