os/persistentdata/traceservices/commsdebugutility/TE_commsdebugutility/src/step_024_xx.cpp
changeset 0 bde4ae8d615e
     1.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     1.2 +++ b/os/persistentdata/traceservices/commsdebugutility/TE_commsdebugutility/src/step_024_xx.cpp	Fri Jun 15 03:10:57 2012 +0200
     1.3 @@ -0,0 +1,1233 @@
     1.4 +// Copyright (c) 2003-2010 Nokia Corporation and/or its subsidiary(-ies).
     1.5 +// All rights reserved.
     1.6 +// This component and the accompanying materials are made available
     1.7 +// under the terms of "Eclipse Public License v1.0"
     1.8 +// which accompanies this distribution, and is available
     1.9 +// at the URL "http://www.eclipse.org/legal/epl-v10.html".
    1.10 +//
    1.11 +// Initial Contributors:
    1.12 +// Nokia Corporation - initial contribution.
    1.13 +//
    1.14 +// Contributors:
    1.15 +//
    1.16 +// Description:
    1.17 +// This contains Flogger Unit Test Case 024.xx
    1.18 +
    1.19 +// EPOC includes
    1.20 +#include <e32base.h>
    1.21 +
    1.22 +
    1.23 +// Test system includes
    1.24 +#include "teststepcomsdbg.h"
    1.25 +#include "TestMessage.h"
    1.26 +#include "step_024_xx.h"
    1.27 +
    1.28 +#include <comms-infras/commsdebugutility.h>
    1.29 +
    1.30 +
    1.31 +const TInt KFiveSeconds = 5000000;
    1.32 +const TInt KMaxConnection = 500; ///< specify a lot of connections for the connection stress test 
    1.33 +const TInt KTimeBetConnection = 100000; //Some time between connection
    1.34 +const TInt KDelayToCheckWrite = 10000000; //Give some time for the flogger to write the message before checking. Replaces KTimeToLog which is normally used.
    1.35 +
    1.36 +
    1.37 +/**
    1.38 +* Function  Name : CFloggerTest024_01
    1.39 +* Input parameters : None
    1.40 +* Output parameters : None
    1.41 +* Description : This is the constructor
    1.42 +*/
    1.43 +
    1.44 +
    1.45 +CFloggerTest024_01::CFloggerTest024_01()
    1.46 +	{
    1.47 +	// Store the name of this test case
    1.48 +	SetTestStepName(_L("step_024_01"));
    1.49 +	}
    1.50 +
    1.51 +
    1.52 +/**
    1.53 +* Function  Name :~ CFloggerTest024_01
    1.54 +* Input parameters : None
    1.55 +* Output parameters : None
    1.56 +* Description : This is the Destructor
    1.57 +*/
    1.58 +
    1.59 +
    1.60 +CFloggerTest024_01::~CFloggerTest024_01()
    1.61 +	{
    1.62 +	}
    1.63 +
    1.64 +
    1.65 +/**
    1.66 +* Function  Name	: doTestStepL
    1.67 +* Input parameters	: None
    1.68 +* Output parameters : TVerdict 
    1.69 +* Description		: This function returns weather the test case 024_01 has 
    1.70 +* 					  passed or failed
    1.71 +
    1.72 +*/
    1.73 +
    1.74 +
    1.75 +TVerdict CFloggerTest024_01::doTestStepL( )
    1.76 +	{
    1.77 +
    1.78 +	INFO_PRINTF1(_L("Step 024.01 called "));
    1.79 +	if ( executeStepL() == KErrNone  )
    1.80 +		SetTestStepResult(EPass);
    1.81 +
    1.82 +	else
    1.83 +		SetTestStepResult(EFail);
    1.84 +
    1.85 +	
    1.86 +	return TestStepResult();
    1.87 +	}
    1.88 +
    1.89 +
    1.90 +/**
    1.91 +* Function  Name		: executeStepL
    1.92 +* Input parameters		: None
    1.93 +* Output parameters		: TInt 
    1.94 +* Description 			: This function sets the subsystem and component name
    1.95 +* 						  checks weather they are set in the log file correctly
    1.96 +
    1.97 +					  
    1.98 +*/
    1.99 +
   1.100 +
   1.101 +TInt CFloggerTest024_01::executeStepL()
   1.102 +	{
   1.103 +	return DoTestWrite();
   1.104 +	}
   1.105 +	
   1.106 +/**
   1.107 +* Function  Name		: executeStepL
   1.108 +* Input parameters		: None
   1.109 +* Output parameters		: TInt 
   1.110 +* Description 			: This function sets the subsystem and component name
   1.111 +* 						  checks weather they are set in the log file correctly
   1.112 +
   1.113 +					  
   1.114 +*/
   1.115 +
   1.116 +
   1.117 +TInt CFloggerTest024_01::executeStepL(TBool)
   1.118 +	{
   1.119 +	return KErrGeneral;
   1.120 +	}
   1.121 +/**
   1.122 +* Function  Name		: DoTestWriteL
   1.123 +* Input parameters		: None
   1.124 +* Output parameters		: TInt 
   1.125 +* Description 			: This function checks the weather test data was written
   1.126 +* 						  in to the log file by DoTestWriteL() or not.
   1.127 +					  
   1.128 +*/
   1.129 +
   1.130 +
   1.131 +TInt CFloggerTest024_01::DoTestWrite()
   1.132 +	{
   1.133 +	TPtrC8 ptrSubSystem;
   1.134 +	TPtrC8 ptrComponent;
   1.135 +	ptrSubSystem.Set(_L8("SubSystem"));
   1.136 +	ptrComponent.Set(_L8("Component"));
   1.137 +
   1.138 +	_LIT8(KTestMessage1 ,"TC NO 24: This is test message before sleep");
   1.139 +	_LIT8(KTestMessage2 ,"TC NO 24: This is test message After sleep");
   1.140 +
   1.141 +	TInt ret = KErrGeneral;
   1.142 +	RFileLogger theFlogger;
   1.143 +
   1.144 +	ret = theFlogger.Connect();
   1.145 +	if (ret == KErrNone)
   1.146 +		{
   1.147 +		ret = theFlogger.SetLogTags(ptrSubSystem, ptrComponent);
   1.148 +		if (ret == KErrNone)
   1.149 +			{
   1.150 +			ret = theFlogger.ClearLog();
   1.151 +			if (ret == KErrNone)
   1.152 +				{
   1.153 +				theFlogger.Write(KTestMessage1); //Write the test descriptor before sleep
   1.154 +				User::After(KFiveSeconds); // Call After() function
   1.155 +				theFlogger.Write(KTestMessage2); //Write the test descriptor after sleep
   1.156 +				User::After(KFiveSeconds);
   1.157 +
   1.158 +				TRAPD(r, ret = DoTestCheckWriteL()); // Check whether the message is present in log
   1.159 +			
   1.160 +				
   1.161 +				if (r != KErrNone)
   1.162 +					ret = r;
   1.163 +				}
   1.164 +			}
   1.165 +		}
   1.166 +	if (ret == KErrNone)
   1.167 +		theFlogger.__DbgShutDownServer();
   1.168 +	theFlogger.Close();
   1.169 +	return ret;
   1.170 +	}
   1.171 +
   1.172 +
   1.173 +/**
   1.174 +* Function  Name		: DoTestCheckWriteL
   1.175 +* Input parameters		: None
   1.176 +* Output parameters		: TInt 
   1.177 +* Description 			: This function checks the weather test data was written
   1.178 +* 						  in to the log file by DoTestWriteL() or not.
   1.179 +					  
   1.180 +*/
   1.181 +
   1.182 +
   1.183 +TInt CFloggerTest024_01::DoTestCheckWriteL()
   1.184 +	{
   1.185 +	RFile theFile;
   1.186 +
   1.187 +	_LIT(KTestString,"Time");
   1.188 +
   1.189 +	HBufC8 * hBuffer;
   1.190 +	TInt listfilesize;
   1.191 +	RFs iFileSystem; //For file operation create a file system
   1.192 +	TBuf8<256> testData; //To hold the test descriptor
   1.193 +
   1.194 +	User::LeaveIfError(iFileSystem.Connect());
   1.195 +	
   1.196 +	//Open the file in the read mode
   1.197 +	User::LeaveIfError(theFile.Open(iFileSystem, KFloggerOutputFile, EFileWrite|EFileShareAny)); 
   1.198 +	CleanupClosePushL(theFile);
   1.199 +	
   1.200 +	User::LeaveIfError(theFile.Size(listfilesize)); //Size of the file
   1.201 +	
   1.202 +	hBuffer = HBufC8::New(listfilesize); //Allocate the buffer
   1.203 +	CleanupStack::PushL(hBuffer);
   1.204 +	TPtr8 ptrString = hBuffer->Des();  ; //To hold the buffer
   1.205 +
   1.206 +	// Read from position 0: start of file
   1.207 +	User::LeaveIfError(theFile.Read(ptrString));
   1.208 +	
   1.209 +	testData.Copy(KTestString); //Copy the test string to be tested
   1.210 +
   1.211 +	TPtrC8 ptrTmpBuffer = ptrString.Right(listfilesize); //Copy of the orginal buffer read from the file
   1.212 +	TInt charCount1 = 0;
   1.213 +	TInt charCount2 = 0;
   1.214 +	TInt lineCount = 0;
   1.215 +	TInt tmpCount = 0;
   1.216 +	
   1.217 +	charCount1 = ptrString.Find(testData);
   1.218 +	while(charCount1 != KErrNotFound)
   1.219 +		{
   1.220 +		lineCount++; //Increment the line count since we just found another one
   1.221 +		charCount2 = charCount2 + charCount1 + KSampleTimeLine().Length(); //the the number of char's present in the line which
   1.222 +										// is constant for the line starting with "#Time" in the log file
   1.223 +
   1.224 +		tmpCount = listfilesize - charCount2; // Remaining string after the "Time" is read
   1.225 +		TPtrC8 strTmp = ptrString.Right(tmpCount);
   1.226 +		charCount1 = strTmp.Find(testData);
   1.227 +		if (charCount1 == 0) //Since the Time is found at the zeroth position count1 will contain 0
   1.228 +			charCount1 = charCount1 + 4; // Charecter count of Time is 4
   1.229 +		ptrString = ptrTmpBuffer.Right(listfilesize); // Get back the orginal buffer 
   1.230 +		}
   1.231 +
   1.232 +	CleanupStack::PopAndDestroy(hBuffer);
   1.233 +	CleanupStack::PopAndDestroy();	//theFile
   1.234 +
   1.235 +	// we expect to find the word "TIME" 10 times (or more) - 5 during each delay.
   1.236 +	if ((lineCount >= 10) && (lineCount <= 12))
   1.237 +		return KErrNone;
   1.238 +	else
   1.239 +		return KErrGeneral;
   1.240 +
   1.241 +
   1.242 +
   1.243 +	}
   1.244 +
   1.245 +
   1.246 +
   1.247 +
   1.248 +
   1.249 +
   1.250 +_LIT8(KTestStringWithPunctuation1,"                                                 /===-_---~~~~~~~~~------____"); _LIT8(KTestStringWithPunctuation26,"    `~/  )` ) ,/|                 ~-_~>--<_/-__       __-~ _/ ");
   1.251 +_LIT8(KTestStringWithPunctuation2,"                 -==\\\\                         `//~\\\\   ~~~~`---.___.-~~"); _LIT8(KTestStringWithPunctuation27,"   ;'( ')/ ,)(                              ~~~~~~~~~~ ");
   1.252 +_LIT8(KTestStringWithPunctuation3,"       __--~~~  ,-/-==\\\\                        | |   `\\        ,'"); _LIT8(KTestStringWithPunctuation19,"                  \\_|      /        _)   ;  ),   __--~~");
   1.253 +_LIT8(KTestStringWithPunctuation4,"  .'        /       |   \\\\                   /' /        \\   /'");              _LIT8(KTestStringWithPunctuation21,"                  |0  0 _/) )-~     | |__>--<__|      |");
   1.254 +_LIT8(KTestStringWithPunctuation5,"/-'~    ~~~~~---__  |     ~-/~         ( )   /'        _--~`");                    _LIT8(KTestStringWithPunctuation20,"                   {\\__--_/}    / \\\\_>- )<__\\      \\");
   1.255 +_LIT8(KTestStringWithPunctuation6,"                    '~~--_/      _-~/-  / \\   '-~ \\");                           _LIT8(KTestStringWithPunctuation22,"                 o o _//        /-~_>---<__-~      /");
   1.256 +_LIT8(KTestStringWithPunctuation15,"                                                |===-~___                _,-'");  _LIT8(KTestStringWithPunctuation24,"            ( ( '))          |__>--<__|    |                 /' _---_~\\");
   1.257 +_LIT8(KTestStringWithPunctuation16,"             ______-==|                         | |  \\\\           _-~`");       _LIT8(KTestStringWithPunctuation23,"                ,/|           /__>--<__/     _-~");
   1.258 +_LIT8(KTestStringWithPunctuation17,"    _-~       /'    |  \\\\                      / /      \\      /");           _LIT8(KTestStringWithPunctuation25,"        ,/,'//( (             \\__>--<__\\    \\            /'  //        ||");
   1.259 +_LIT8(KTestStringWithPunctuation18," /  ____  /         |    \\`\\.__/-~~ ~ \\ _ _/'  /          \\/'");
   1.260 +_LIT8(KTestStringWithPunctuationExpected1,"         `-)) )) (           |__>--<__|    |               /'  /     ~\\`\\");
   1.261 +_LIT8(KTestStringWithPunctuationExpected2,"                 o o _//        /-~_>---<__-~      /");
   1.262 +_LIT8(KTestStringWithPunctuationExpected3,"    `~/  )` ) ,/|                 ~-_~>--<_/-__       __-~ _/ ");
   1.263 +
   1.264 +
   1.265 +
   1.266 +/**
   1.267 +* CFloggerTest024_02 - test static write with string with beeps, tabs, nulls, CR's, LFs in the tags
   1.268 +* doTestStep returns whether test case passed or failed.
   1.269 +*/ 
   1.270 +
   1.271 +
   1.272 +
   1.273 +
   1.274 +CFloggerTest024_02::CFloggerTest024_02()
   1.275 +	{
   1.276 +	// Store the name of this test case
   1.277 +	SetTestStepName(_L("step_024_02"));
   1.278 +	}
   1.279 +
   1.280 +
   1.281 +
   1.282 +
   1.283 +CFloggerTest024_02::~CFloggerTest024_02()
   1.284 +	{
   1.285 +	}
   1.286 +
   1.287 +
   1.288 +
   1.289 +
   1.290 +TVerdict CFloggerTest024_02::doTestStepL( )
   1.291 +	{
   1.292 +	if ( executeStepL() == KErrNone  )
   1.293 +		SetTestStepResult(EPass);
   1.294 +
   1.295 +	else
   1.296 +		SetTestStepResult(EFail);
   1.297 +
   1.298 +	
   1.299 +	return TestStepResult();
   1.300 +	}
   1.301 +
   1.302 +
   1.303 +TInt CFloggerTest024_02::executeStepL(TBool)
   1.304 +	{
   1.305 +	return KErrGeneral;
   1.306 +	}
   1.307 +
   1.308 +TInt CFloggerTest024_02::executeStepL()
   1.309 +	{
   1.310 +	TInt ret;
   1.311 +	
   1.312 +	// clear the old log messages
   1.313 +	RFileLogger flogger;
   1.314 +	ret = flogger.Connect();
   1.315 +	
   1.316 +	if ( ret == KErrNone )
   1.317 +		{
   1.318 +		flogger.SetLogTags(KStdSubsysTag8, KStdCompTag8);
   1.319 +		flogger.ClearLog();
   1.320 +		flogger.Close();
   1.321 +		
   1.322 +		RFileLogger::Write(KSubsysTagWithEscapeChars8, KCompTagWithEscapeChars8,KTestMessage8);
   1.323 +		
   1.324 +		User::After(KTimeToLog);
   1.325 +		
   1.326 +		TRAPD(r, ret = DoTestCheckWriteL());
   1.327 +		if (r != KErrNone)
   1.328 +			ret = r;
   1.329 +		}
   1.330 +		
   1.331 +	
   1.332 +	return ret;		
   1.333 +
   1.334 +	}
   1.335 +
   1.336 +
   1.337 +TInt CFloggerTest024_02::DoTestCheckWriteL()
   1.338 +	{
   1.339 +	RFile logFile;
   1.340 +	HBufC8* hBuffer;
   1.341 +	TInt listfilesize,returnCode;
   1.342 +	RFs fileSystem; //For file operation create a file system
   1.343 +	TInt numSuccessful = 0;
   1.344 +
   1.345 +	User::LeaveIfError(fileSystem.Connect());
   1.346 +	
   1.347 +	//Open the file in the read mode
   1.348 +	User::LeaveIfError(logFile.Open(fileSystem,KFloggerOutputFile,EFileRead));
   1.349 +
   1.350 +	CleanupClosePushL(logFile);
   1.351 +
   1.352 +	User::LeaveIfError(logFile.Size(listfilesize)); //Size of the file
   1.353 +	
   1.354 +	hBuffer = HBufC8::New(listfilesize); //Allocate the buffer
   1.355 +	CleanupStack::PushL(hBuffer);
   1.356 +
   1.357 +	TPtr8 ptrString = hBuffer->Des();  ; //To access the buffer
   1.358 +
   1.359 +	// Read from position 0: start of file
   1.360 +	User::LeaveIfError(returnCode = logFile.Read(ptrString));
   1.361 +	
   1.362 +	// flogger should not have logged
   1.363 +	returnCode = ptrString.Find(KTestMessage8);
   1.364 +	
   1.365 +	if (returnCode == KErrNotFound)
   1.366 +		{
   1.367 +		numSuccessful++;
   1.368 +		}
   1.369 +
   1.370 +
   1.371 +	CleanupStack::PopAndDestroy(hBuffer);
   1.372 +	CleanupStack::PopAndDestroy();	//logFile
   1.373 +	if (numSuccessful == 1)
   1.374 +		return KErrNone;
   1.375 +	else
   1.376 +		return KErrUnknown;
   1.377 +	}
   1.378 +
   1.379 +
   1.380 +
   1.381 +
   1.382 +/**
   1.383 +* CFloggerTest024_03 - test static write with string with punctuation and spaces in the data
   1.384 +* doTestStep returns whether test case passed or failed.
   1.385 +*/ 
   1.386 +
   1.387 +_LIT8(KTestStringWithPunctuation8,"                  / /~ ,_/       / /__>---<__/      |  ");
   1.388 +_LIT8(KTestStringWithPunctuation14,"  ' ') '( (/");
   1.389 +_LIT8(KTestStringWithPunctuation9,"                 (^(~          /~_>---<__-      _-~");
   1.390 +_LIT8(KTestStringWithPunctuation7,"                   /'   (_/  _-~  | |__>--<__|      | ");
   1.391 +_LIT8(KTestStringWithPunctuation11,"         `-)) )) (           |__>--<__|    |               /'  /     ~\\`\\");
   1.392 +_LIT8(KTestStringWithPunctuation12,"      ,( ( ((, ))              ~-__>--<_~-_  ~--____---~' _/'/        /'");
   1.393 +_LIT8(KTestStringWithPunctuation10,"             ,//('(          |__>--<__|     /                  .----_ ");
   1.394 +_LIT8(KTestStringWithPunctuation13,"  ._-~//( )/ )) `                    ~~-'_/_/ /~~~~~~~__--~ ");
   1.395 +
   1.396 +
   1.397 +CFloggerTest024_03::CFloggerTest024_03()
   1.398 +	{
   1.399 +	// Store the name of this test case
   1.400 +	SetTestStepName(_L("step_024_03"));
   1.401 +	}
   1.402 +
   1.403 +
   1.404 +
   1.405 +
   1.406 +CFloggerTest024_03::~CFloggerTest024_03()
   1.407 +	{
   1.408 +	}
   1.409 +
   1.410 +
   1.411 +
   1.412 +
   1.413 +TVerdict CFloggerTest024_03::doTestStepL( )
   1.414 +	{
   1.415 +	if ( executeStepL() == KErrNone  )
   1.416 +		SetTestStepResult(EPass);
   1.417 +
   1.418 +	else
   1.419 +		SetTestStepResult(EFail);
   1.420 +
   1.421 +	
   1.422 +	return TestStepResult();
   1.423 +	}
   1.424 +
   1.425 +
   1.426 +TInt CFloggerTest024_03::executeStepL(TBool)
   1.427 +	{
   1.428 +	return KErrGeneral;
   1.429 +	}
   1.430 +
   1.431 +TInt CFloggerTest024_03::executeStepL()
   1.432 +	{
   1.433 +	TInt ret;
   1.434 +	
   1.435 +	// clear the old log messages
   1.436 +	RFileLogger flogger;
   1.437 +	ret = flogger.Connect();
   1.438 +	
   1.439 +	if ( ret == KErrNone )
   1.440 +		{
   1.441 +		flogger.SetLogTags(KStdSubsysTag8, KStdCompTag8);
   1.442 +		flogger.ClearLog();
   1.443 +		flogger.Close();
   1.444 +		
   1.445 +		RFileLogger::Write(KStdSubsysTag8, KStdCompTag8,KTestStringWithPunctuation1);
   1.446 +		RFileLogger::Write(KStdSubsysTag8, KStdCompTag8,KTestStringWithPunctuation15);
   1.447 +		RFileLogger::Write(KStdSubsysTag8, KStdCompTag8,KTestStringWithPunctuation2);
   1.448 +		RFileLogger::Write(KStdSubsysTag8, KStdCompTag8,KTestStringWithPunctuation16);
   1.449 +		RFileLogger::Write(KStdSubsysTag8, KStdCompTag8,KTestStringWithPunctuation3);
   1.450 +		RFileLogger::Write(KStdSubsysTag8, KStdCompTag8,KTestStringWithPunctuation17);
   1.451 +		RFileLogger::Write(KStdSubsysTag8, KStdCompTag8,KTestStringWithPunctuation4);
   1.452 +		RFileLogger::Write(KStdSubsysTag8, KStdCompTag8,KTestStringWithPunctuation18);
   1.453 +		RFileLogger::Write(KStdSubsysTag8, KStdCompTag8,KTestStringWithPunctuation5);
   1.454 +		RFileLogger::Write(KStdSubsysTag8, KStdCompTag8,KTestStringWithPunctuation19);
   1.455 +		RFileLogger::Write(KStdSubsysTag8, KStdCompTag8,KTestStringWithPunctuation6);
   1.456 +		RFileLogger::Write(KStdSubsysTag8, KStdCompTag8,KTestStringWithPunctuation20);
   1.457 +		RFileLogger::Write(KStdSubsysTag8, KStdCompTag8,KTestStringWithPunctuation7);
   1.458 +		RFileLogger::Write(KStdSubsysTag8, KStdCompTag8,KTestStringWithPunctuation21);
   1.459 +		RFileLogger::Write(KStdSubsysTag8, KStdCompTag8,KTestStringWithPunctuation8);
   1.460 +		RFileLogger::Write(KStdSubsysTag8, KStdCompTag8,KTestStringWithPunctuation22);
   1.461 +		RFileLogger::Write(KStdSubsysTag8, KStdCompTag8,KTestStringWithPunctuation9);
   1.462 +		RFileLogger::Write(KStdSubsysTag8, KStdCompTag8,KTestStringWithPunctuation23);
   1.463 +		RFileLogger::Write(KStdSubsysTag8, KStdCompTag8,KTestStringWithPunctuation10);
   1.464 +		RFileLogger::Write(KStdSubsysTag8, KStdCompTag8,KTestStringWithPunctuation24);
   1.465 +		RFileLogger::Write(KStdSubsysTag8, KStdCompTag8,KTestStringWithPunctuation11);
   1.466 +		RFileLogger::Write(KStdSubsysTag8, KStdCompTag8,KTestStringWithPunctuation25);
   1.467 +		RFileLogger::Write(KStdSubsysTag8, KStdCompTag8,KTestStringWithPunctuation12);
   1.468 +		RFileLogger::Write(KStdSubsysTag8, KStdCompTag8,KTestStringWithPunctuation26);
   1.469 +		RFileLogger::Write(KStdSubsysTag8, KStdCompTag8,KTestStringWithPunctuation13);
   1.470 +		RFileLogger::Write(KStdSubsysTag8, KStdCompTag8,KTestStringWithPunctuation27);
   1.471 +		RFileLogger::Write(KStdSubsysTag8, KStdCompTag8,KTestStringWithPunctuation14);
   1.472 +		
   1.473 +		User::After(KTimeToLog);
   1.474 +		
   1.475 +		TRAPD(r, ret = DoTestCheckWriteL());
   1.476 +		if (r != KErrNone)
   1.477 +			ret = r;
   1.478 +		}
   1.479 +		
   1.480 +	
   1.481 +	return ret;		
   1.482 +
   1.483 +	}
   1.484 +
   1.485 +
   1.486 +TInt CFloggerTest024_03::DoTestCheckWriteL()
   1.487 +	{
   1.488 +	RFile logFile;
   1.489 +	HBufC8* hBuffer;
   1.490 +	TInt listfilesize,returnCode;
   1.491 +	RFs fileSystem; //For file operation create a file system
   1.492 +	TInt numSuccessful = 0;
   1.493 +
   1.494 +	User::LeaveIfError(fileSystem.Connect());
   1.495 +	
   1.496 +	//Open the file in the read mode
   1.497 +	User::LeaveIfError(logFile.Open(fileSystem,KFloggerOutputFile,EFileRead));
   1.498 +
   1.499 +	CleanupClosePushL(logFile);
   1.500 +
   1.501 +	User::LeaveIfError(logFile.Size(listfilesize)); //Size of the file
   1.502 +	
   1.503 +	hBuffer = HBufC8::New(listfilesize); //Allocate the buffer
   1.504 +	CleanupStack::PushL(hBuffer);
   1.505 +
   1.506 +	TPtr8 ptrString = hBuffer->Des();  ; //To access the buffer
   1.507 +
   1.508 +	// Read from position 0: start of file
   1.509 +	User::LeaveIfError(returnCode = logFile.Read(ptrString));
   1.510 +	
   1.511 +	// check that flogger logged the punctuation/spaces correctly by checking three samples
   1.512 +	returnCode = ptrString.Find(KTestStringWithPunctuationExpected1);
   1.513 +	
   1.514 +	if (returnCode > 0)
   1.515 +		{
   1.516 +		numSuccessful++;
   1.517 +		}
   1.518 +		
   1.519 +	returnCode = ptrString.Find(KTestStringWithPunctuationExpected2);
   1.520 +	
   1.521 +	if (returnCode > 0)
   1.522 +		{
   1.523 +		numSuccessful++;
   1.524 +		}
   1.525 +		
   1.526 +	returnCode = ptrString.Find(KTestStringWithPunctuationExpected3);
   1.527 +	
   1.528 +	if (returnCode > 0)
   1.529 +		{
   1.530 +		numSuccessful++;
   1.531 +		}
   1.532 +
   1.533 +
   1.534 +	CleanupStack::PopAndDestroy(hBuffer);
   1.535 +	CleanupStack::PopAndDestroy();	//logFile
   1.536 +	if (numSuccessful == 3)
   1.537 +		return KErrNone;
   1.538 +	else
   1.539 +		return KErrUnknown;
   1.540 +	}
   1.541 +
   1.542 +
   1.543 +
   1.544 +
   1.545 +/**
   1.546 +* CFloggerTest024_04 - test static write with data string with beeps, tabs, nulls, CR's, LFs in it
   1.547 +* doTestStep returns whether test case passed or failed.
   1.548 +*/ 
   1.549 +
   1.550 +CFloggerTest024_04::CFloggerTest024_04()
   1.551 +	{
   1.552 +	// Store the name of this test case
   1.553 +	SetTestStepName(_L("step_024_04"));
   1.554 +	}
   1.555 +
   1.556 +
   1.557 +
   1.558 +
   1.559 +CFloggerTest024_04::~CFloggerTest024_04()
   1.560 +	{
   1.561 +	}
   1.562 +
   1.563 +
   1.564 +
   1.565 +
   1.566 +TVerdict CFloggerTest024_04::doTestStepL( )
   1.567 +	{
   1.568 +	if ( executeStepL() == KErrNone  )
   1.569 +		SetTestStepResult(EPass);
   1.570 +
   1.571 +	else
   1.572 +		SetTestStepResult(EFail);
   1.573 +
   1.574 +	
   1.575 +	return TestStepResult();
   1.576 +	}
   1.577 +
   1.578 +
   1.579 +TInt CFloggerTest024_04::executeStepL(TBool)
   1.580 +	{
   1.581 +	return KErrGeneral;
   1.582 +	}
   1.583 +
   1.584 +TInt CFloggerTest024_04::executeStepL()
   1.585 +	{
   1.586 +	TInt ret;
   1.587 +	
   1.588 +	// clear the old log messages
   1.589 +	RFileLogger flogger;
   1.590 +	ret = flogger.Connect();
   1.591 +	
   1.592 +	if ( ret == KErrNone )
   1.593 +		{
   1.594 +		flogger.SetLogTags(KStdSubsysTag8, KStdCompTag8);
   1.595 +		flogger.ClearLog();
   1.596 +		flogger.Close();
   1.597 +		
   1.598 +		RFileLogger::Write(KStdSubsysTag8, KStdCompTag8,KTestMessageWithEscapeChars8);
   1.599 +		
   1.600 +		User::After(KTimeToLog);
   1.601 +		
   1.602 +		TRAPD(r, ret = DoTestCheckWriteL());
   1.603 +		if (r != KErrNone)
   1.604 +			ret = r;
   1.605 +		}
   1.606 +		
   1.607 +	
   1.608 +	return ret;		
   1.609 +
   1.610 +	}
   1.611 +
   1.612 +
   1.613 +TInt CFloggerTest024_04::DoTestCheckWriteL()
   1.614 +	{
   1.615 +	RFile logFile;
   1.616 +	HBufC8* hBuffer;
   1.617 +	TInt listfilesize,returnCode;
   1.618 +	RFs fileSystem; //For file operation create a file system
   1.619 +	TInt numSuccessful = 0;
   1.620 +
   1.621 +	User::LeaveIfError(fileSystem.Connect());
   1.622 +	
   1.623 +	//Open the file in the read mode
   1.624 +	User::LeaveIfError(logFile.Open(fileSystem,KFloggerOutputFile,EFileRead));
   1.625 +
   1.626 +	CleanupClosePushL(logFile);
   1.627 +
   1.628 +	User::LeaveIfError(logFile.Size(listfilesize)); //Size of the file
   1.629 +	
   1.630 +	hBuffer = HBufC8::New(listfilesize); //Allocate the buffer
   1.631 +	CleanupStack::PushL(hBuffer);
   1.632 +
   1.633 +	TPtr8 ptrString = hBuffer->Des();  ; //To access the buffer
   1.634 +
   1.635 +	// Read from position 0: start of file
   1.636 +	User::LeaveIfError(returnCode = logFile.Read(ptrString));
   1.637 +	
   1.638 +	// flogger will have logged the string exactly as it was sent. The CR/LF will not
   1.639 +	// cause a line feed because they are not adjacent
   1.640 +	returnCode = ptrString.Find(KTestMessageWithEscapeChars8);
   1.641 +	
   1.642 +	if (returnCode > 0)
   1.643 +		{
   1.644 +		numSuccessful++;
   1.645 +		}
   1.646 +
   1.647 +
   1.648 +	CleanupStack::PopAndDestroy(hBuffer);
   1.649 +	CleanupStack::PopAndDestroy();	//logFile
   1.650 +	if (numSuccessful == 1)
   1.651 +		return KErrNone;
   1.652 +	else
   1.653 +		return KErrUnknown;
   1.654 +	}
   1.655 +
   1.656 +
   1.657 +
   1.658 +
   1.659 +
   1.660 +/**
   1.661 +* CFloggerTest024_05 - test static write with data string with char 255, nulls, and escapes in it
   1.662 +* doTestStep returns whether test case passed or failed.
   1.663 +*/ 
   1.664 +
   1.665 +CFloggerTest024_05::CFloggerTest024_05()
   1.666 +	{
   1.667 +	// Store the name of this test case
   1.668 +	SetTestStepName(_L("step_024_05"));
   1.669 +	}
   1.670 +
   1.671 +
   1.672 +
   1.673 +
   1.674 +CFloggerTest024_05::~CFloggerTest024_05()
   1.675 +	{
   1.676 +	}
   1.677 +
   1.678 +
   1.679 +
   1.680 +
   1.681 +TVerdict CFloggerTest024_05::doTestStepL( )
   1.682 +	{
   1.683 +	if ( executeStepL() == KErrNone  )
   1.684 +		SetTestStepResult(EPass);
   1.685 +
   1.686 +	else
   1.687 +		SetTestStepResult(EFail);
   1.688 +
   1.689 +	
   1.690 +	return TestStepResult();
   1.691 +	}
   1.692 +
   1.693 +TInt CFloggerTest024_05::executeStepL(TBool)
   1.694 +	{
   1.695 +	return KErrGeneral;
   1.696 +	}
   1.697 +
   1.698 +
   1.699 +TInt CFloggerTest024_05::executeStepL()
   1.700 +	{
   1.701 +	TInt ret;
   1.702 +	
   1.703 +	// clear the old log messages
   1.704 +	RFileLogger flogger;
   1.705 +	ret = flogger.Connect();
   1.706 +	
   1.707 +	if ( ret == KErrNone )
   1.708 +		{
   1.709 +		flogger.SetLogTags(KStdSubsysTag8, KStdCompTag8);
   1.710 +		flogger.ClearLog();
   1.711 +		flogger.Close();
   1.712 +		
   1.713 +		RFileLogger::Write(KStdSubsysTag8, KStdCompTag8,K2ndTestMessageWithEscapeChars8);
   1.714 +		
   1.715 +		User::After(KTimeToLog);
   1.716 +		
   1.717 +		TRAPD(r, ret = DoTestCheckWriteL());
   1.718 +		if (r != KErrNone)
   1.719 +			ret = r;
   1.720 +		}
   1.721 +		
   1.722 +	
   1.723 +	return ret;		
   1.724 +
   1.725 +	}
   1.726 +
   1.727 +
   1.728 +TInt CFloggerTest024_05::DoTestCheckWriteL()
   1.729 +	{
   1.730 +	RFile logFile;
   1.731 +	HBufC8* hBuffer;
   1.732 +	TInt listfilesize,returnCode;
   1.733 +	RFs fileSystem; //For file operation create a file system
   1.734 +	TInt numSuccessful = 0;
   1.735 +
   1.736 +	User::LeaveIfError(fileSystem.Connect());
   1.737 +	
   1.738 +	//Open the file in the read mode
   1.739 +	User::LeaveIfError(logFile.Open(fileSystem,KFloggerOutputFile,EFileRead));
   1.740 +
   1.741 +	CleanupClosePushL(logFile);
   1.742 +
   1.743 +	User::LeaveIfError(logFile.Size(listfilesize)); //Size of the file
   1.744 +	
   1.745 +	hBuffer = HBufC8::New(listfilesize); //Allocate the buffer
   1.746 +	CleanupStack::PushL(hBuffer);
   1.747 +
   1.748 +	TPtr8 ptrString = hBuffer->Des();  ; //To access the buffer
   1.749 +
   1.750 +	// Read from position 0: start of file
   1.751 +	User::LeaveIfError(returnCode = logFile.Read(ptrString));
   1.752 +	
   1.753 +	// flogger will have logged the string exactly as it was sent. The CR/LF will not
   1.754 +	// cause a line feed because they are not adjacent
   1.755 +	returnCode = ptrString.Find(K2ndTestMessageWithEscapeChars8);
   1.756 +	
   1.757 +	if (returnCode > 0)
   1.758 +		{
   1.759 +		numSuccessful++;
   1.760 +		}
   1.761 +
   1.762 +
   1.763 +	CleanupStack::PopAndDestroy(hBuffer);
   1.764 +	CleanupStack::PopAndDestroy();	//logFile
   1.765 +	if (numSuccessful == 1)
   1.766 +		return KErrNone;
   1.767 +	else
   1.768 +		return KErrUnknown;
   1.769 +	}
   1.770 +
   1.771 +
   1.772 +
   1.773 +/**
   1.774 +* CFloggerTest024_06 - test static write with empty data string
   1.775 +* doTestStep returns whether test case passed or failed.
   1.776 +*/ 
   1.777 +
   1.778 +CFloggerTest024_06::CFloggerTest024_06()
   1.779 +	{
   1.780 +	// Store the name of this test case
   1.781 +	SetTestStepName(_L("step_024_06"));
   1.782 +	}
   1.783 +
   1.784 +
   1.785 +
   1.786 +
   1.787 +CFloggerTest024_06::~CFloggerTest024_06()
   1.788 +	{
   1.789 +	}
   1.790 +
   1.791 +
   1.792 +
   1.793 +
   1.794 +TVerdict CFloggerTest024_06::doTestStepL( )
   1.795 +	{
   1.796 +	if ( executeStepL() == KErrNone  )
   1.797 +		SetTestStepResult(EPass);
   1.798 +
   1.799 +	else
   1.800 +		SetTestStepResult(EFail);
   1.801 +
   1.802 +	
   1.803 +	return TestStepResult();
   1.804 +	}
   1.805 +
   1.806 +
   1.807 +TInt CFloggerTest024_06::executeStepL(TBool)
   1.808 +	{
   1.809 +	return KErrGeneral;
   1.810 +	}
   1.811 +
   1.812 +TInt CFloggerTest024_06::executeStepL()
   1.813 +	{
   1.814 +	TInt ret;
   1.815 +	
   1.816 +	// clear the old log messages
   1.817 +	RFileLogger flogger;
   1.818 +	ret = flogger.Connect();
   1.819 +	
   1.820 +	if ( ret == KErrNone )
   1.821 +		{
   1.822 +		flogger.SetLogTags(KStdSubsysTag8, KStdCompTag8);
   1.823 +		flogger.ClearLog();
   1.824 +		flogger.Close();
   1.825 +		
   1.826 +		RFileLogger::Write(KStdSubsysTag8, KStdCompTag8,KNullDesC8);
   1.827 +		
   1.828 +		User::After(KTimeToLog);
   1.829 +		
   1.830 +		TRAPD(r, ret = DoTestCheckWriteL());
   1.831 +		if (r != KErrNone)
   1.832 +			ret = r;
   1.833 +		}
   1.834 +		
   1.835 +	
   1.836 +	return ret;		
   1.837 +
   1.838 +	}
   1.839 +
   1.840 +
   1.841 +TInt CFloggerTest024_06::DoTestCheckWriteL()
   1.842 +	{
   1.843 +	RFile logFile;
   1.844 +	HBufC8* hBuffer;
   1.845 +	TInt listfilesize,returnCode;
   1.846 +	RFs fileSystem; //For file operation create a file system
   1.847 +	TInt numSuccessful = 0;
   1.848 +
   1.849 +	User::LeaveIfError(fileSystem.Connect());
   1.850 +	
   1.851 +	//Open the file in the read mode
   1.852 +	User::LeaveIfError(logFile.Open(fileSystem,KFloggerOutputFile,EFileRead));
   1.853 +
   1.854 +	CleanupClosePushL(logFile);
   1.855 +
   1.856 +	User::LeaveIfError(logFile.Size(listfilesize)); //Size of the file
   1.857 +	
   1.858 +	hBuffer = HBufC8::New(listfilesize); //Allocate the buffer
   1.859 +	CleanupStack::PushL(hBuffer);
   1.860 +
   1.861 +	TPtr8 ptrString = hBuffer->Des();  ; //To access the buffer
   1.862 +
   1.863 +	// Read from position 0: start of file
   1.864 +	User::LeaveIfError(returnCode = logFile.Read(ptrString));
   1.865 +	
   1.866 +	// not much to check since flogger won't have written much other than
   1.867 +	// the tags
   1.868 +	returnCode = ptrString.Find(KStdCompTag8);
   1.869 +	
   1.870 +	if (returnCode > 0)
   1.871 +		{
   1.872 +		numSuccessful++;
   1.873 +		}
   1.874 +
   1.875 +
   1.876 +	CleanupStack::PopAndDestroy(hBuffer);
   1.877 +	CleanupStack::PopAndDestroy();	//logFile
   1.878 +	if (numSuccessful == 1)
   1.879 +		return KErrNone;
   1.880 +	else
   1.881 +		return KErrUnknown;
   1.882 +	}
   1.883 +
   1.884 +
   1.885 +CFloggerTest024_07::CFloggerTest024_07()
   1.886 +	{
   1.887 +	// Store the name of this test case
   1.888 +	SetTestStepName(_L("step_024_07"));
   1.889 +	}
   1.890 +
   1.891 +
   1.892 +/**
   1.893 +* Function  Name :~ CFloggerTest024_07
   1.894 +* Input parameters : None
   1.895 +* Output parameters : None
   1.896 +* Description : This is the Destructor
   1.897 +*/ 
   1.898 +
   1.899 +
   1.900 +CFloggerTest024_07::~CFloggerTest024_07()
   1.901 +	{
   1.902 +	}
   1.903 +
   1.904 +
   1.905 +/**
   1.906 +* Function  Name	: doTestStepL
   1.907 +* Input parameters	: None
   1.908 +* Output parameters : TVerdict 
   1.909 +* Description		: This function returns whether the test case 024_07 has 
   1.910 +* 					  passed or failed
   1.911 +
   1.912 +*/
   1.913 +
   1.914 +
   1.915 +TVerdict CFloggerTest024_07::doTestStepL( )
   1.916 +	{
   1.917 +	INFO_PRINTF1(_L("Step 027.13 called "));
   1.918 +	if ( executeStepL() == KErrNone  )
   1.919 +		SetTestStepResult(EPass);
   1.920 +
   1.921 +	else
   1.922 +		SetTestStepResult(EFail);
   1.923 +
   1.924 +	INFO_PRINTF1(_L("leaving Step 027.13"));
   1.925 +	User::After(KTimeForDisplay);
   1.926 +
   1.927 +	
   1.928 +	return TestStepResult();
   1.929 +	}
   1.930 +
   1.931 +/**
   1.932 +* Function  Name		: executeStepL
   1.933 +* Input parameters		: None
   1.934 +* Output parameters		: TInt 
   1.935 +* Description 			: This function checks for the flogger connection for 500 times
   1.936 +
   1.937 +*/
   1.938 +
   1.939 +
   1.940 +TInt CFloggerTest024_07::executeStepL(TBool)
   1.941 +	{
   1.942 +	return KErrGeneral;
   1.943 +	}
   1.944 +
   1.945 +/**
   1.946 +* Function  Name		: executeStepL
   1.947 +* Input parameters		: None
   1.948 +* Output parameters		: TInt 
   1.949 +* Description 			: This function checks for the flogger connection for 500 times
   1.950 +
   1.951 +*/
   1.952 +
   1.953 +
   1.954 +TInt CFloggerTest024_07::executeStepL()
   1.955 +	{
   1.956 +	TInt ret = KErrNone;
   1.957 +	ret = connectionTest();
   1.958 +	if (ret == KErrNone)
   1.959 +		{
   1.960 +		TRAPD(r, ret = DoTestCheckWriteL());
   1.961 +		if ( r != KErrNone)
   1.962 +				ret = r;
   1.963 +		}
   1.964 +	return ret;
   1.965 +	}
   1.966 +
   1.967 +
   1.968 +TInt CFloggerTest024_07::connectionTest()
   1.969 +	{
   1.970 +	
   1.971 +	_LIT8(KTestMessage,"TC 24_15: The flogger connection has been connected %d");
   1.972 +	TPtrC8 ptrSubSystem;
   1.973 +	TPtrC8 ptrComponent;
   1.974 +	ptrSubSystem.Set(_L8("SubSystem"));
   1.975 +	ptrComponent.Set(_L8("Component"));
   1.976 +	TInt res = KErrNone;
   1.977 +	RFileLogger flogger[KMaxConnection];
   1.978 +
   1.979 +	for(TInt i= 0; i<KMaxConnection; i++)
   1.980 +		{
   1.981 +		res = flogger[i].Connect();
   1.982 +		if (res == KErrNone)
   1.983 +			{
   1.984 +			res = flogger[i].SetLogTags(ptrSubSystem, ptrComponent);
   1.985 +			if (res == KErrNone)	
   1.986 +				{
   1.987 +				if (i == 0)
   1.988 +					flogger[0].ClearLog();	// Clear previous test cases messages
   1.989 +				flogger[i].WriteFormat(KTestMessage, i);
   1.990 +				}
   1.991 +			else
   1.992 +				return KErrGeneral;
   1.993 +			}
   1.994 +		
   1.995 +		else
   1.996 +			{
   1.997 +			INFO_PRINTF2(_L("Flogger connection failed for connection at -> %d "), i);
   1.998 +			return KErrGeneral;
   1.999 +			}
  1.1000 +	User::After(KTimeBetConnection);
  1.1001 +		}
  1.1002 +
  1.1003 +	for(TInt j= 0; j<KMaxConnection; j++)
  1.1004 +		flogger[j].Close();
  1.1005 +
  1.1006 +	User::After(KDelayToCheckWrite);
  1.1007 +	
  1.1008 +	return KErrNone;
  1.1009 +
  1.1010 +	}
  1.1011 +
  1.1012 +TInt CFloggerTest024_07::DoTestCheckWriteL()
  1.1013 +	{
  1.1014 +	User::After(KTimeToLog);
  1.1015 +	RFile theFile;
  1.1016 +	HBufC8 * hBuffer;
  1.1017 +	TInt listfilesize;
  1.1018 +	TInt returnCode;
  1.1019 +	RFs fileSystem; //For file operation create a file system	
  1.1020 +	_LIT(KLogFile,"c:\\logs\\log.txt"); // the log file path
  1.1021 +
  1.1022 +	TBuf8<256> testData; //To hold the test descriptor
  1.1023 +
  1.1024 +	_LIT8(KTestMessage,"TC 24_15: The flogger connection has been connected %d");
  1.1025 +	
  1.1026 +
  1.1027 +	User::LeaveIfError(fileSystem.Connect());
  1.1028 +	
  1.1029 +	//Open the file in the read mode
  1.1030 +	User::LeaveIfError(theFile.Open(fileSystem,KLogFile,EFileRead)); 
  1.1031 +
  1.1032 +	CleanupClosePushL(theFile);	
  1.1033 +	
  1.1034 +	User::LeaveIfError(returnCode = theFile.Size(listfilesize)); //Size of the file
  1.1035 +	hBuffer = HBufC8::New(listfilesize); //Allocate the buffer
  1.1036 +	CleanupStack::PushL(hBuffer);
  1.1037 +	TPtr8 ptrString = hBuffer->Des();  ; //To hold the buffer
  1.1038 +
  1.1039 +	// Read from position 0: start of file
  1.1040 +	returnCode = theFile.Read(ptrString);
  1.1041 +	
  1.1042 +	for(TInt i =0; i<KMaxConnection; i++)
  1.1043 +	{
  1.1044 +	testData.Format(KTestMessage, i);
  1.1045 +	returnCode = ptrString.Find(testData); //find the test descriptor in the buffer read
  1.1046 +												//from the file
  1.1047 +	if (returnCode > 0)
  1.1048 +		continue;
  1.1049 +	else
  1.1050 +		User::Leave(KErrGeneral);
  1.1051 +	}
  1.1052 +
  1.1053 +	CleanupStack::PopAndDestroy(hBuffer);
  1.1054 +	CleanupStack::PopAndDestroy(); // For theFile object
  1.1055 +	if (returnCode > 0)
  1.1056 +		return KErrNone;
  1.1057 +	else 
  1.1058 +		return KErrGeneral;
  1.1059 +	}
  1.1060 +
  1.1061 +
  1.1062 +/**
  1.1063 +* 024_08: Test that flogger handles date changes
  1.1064 +*/ 
  1.1065 +
  1.1066 +
  1.1067 +CFloggerTest024_08::CFloggerTest024_08()
  1.1068 +	{
  1.1069 +	// Store the name of this test case
  1.1070 +	SetTestStepName(_L("step_024_08"));
  1.1071 +	}
  1.1072 +
  1.1073 +
  1.1074 +
  1.1075 +
  1.1076 +CFloggerTest024_08::~CFloggerTest024_08()
  1.1077 +	{
  1.1078 +	}
  1.1079 +
  1.1080 +
  1.1081 +
  1.1082 +
  1.1083 +TVerdict CFloggerTest024_08::doTestStepL( )
  1.1084 +	{
  1.1085 +	if ( executeStepL() == KErrNone  )
  1.1086 +		SetTestStepResult(EPass);
  1.1087 +
  1.1088 +	else
  1.1089 +		SetTestStepResult(EFail);
  1.1090 +
  1.1091 +	User::After(KTimeForDisplay);
  1.1092 +
  1.1093 +	
  1.1094 +	return TestStepResult();
  1.1095 +	}
  1.1096 +
  1.1097 +
  1.1098 +TInt CFloggerTest024_08::executeStepL(TBool)
  1.1099 +	{
  1.1100 +	return KErrGeneral;
  1.1101 +	}
  1.1102 +
  1.1103 +TInt CFloggerTest024_08::executeStepL()
  1.1104 +	{
  1.1105 +	TInt ret ;
  1.1106 +	RFileLogger theFlogger; 
  1.1107 +	
  1.1108 +	//Just to clear the old log message
  1.1109 +	ret = theFlogger.Connect(); 
  1.1110 +	if ( ret == KErrNone)
  1.1111 +		ret = theFlogger.SetLogTags(KStdSubsysTag8, KStdCompTag8);
  1.1112 +		if ( ret == KErrNone)
  1.1113 +			ret = theFlogger.ClearLog();
  1.1114 +			if ( ret == KErrNone)
  1.1115 +				theFlogger.Close();
  1.1116 +
  1.1117 +	// perform test. write some data, roll the date to 0 the following day. write more data.
  1.1118 +	if ( ret == KErrNone)
  1.1119 +		{
  1.1120 +		RFileLogger ::Write(KStdSubsysTag16, KStdCompTag16,EFileLoggingModeAppend, KTestMessage);
  1.1121 +		
  1.1122 +		TTime time;
  1.1123 +		time.HomeTime();
  1.1124 +		TInt item;
  1.1125 +		TDateTime dateTime(time.DateTime());
  1.1126 +		dateTime.SetHour(0);
  1.1127 +		dateTime.SetMinute(0);
  1.1128 +		dateTime.SetSecond(0);
  1.1129 +		item = dateTime.Day();
  1.1130 +		if ((dateTime.SetDay(++item) != KErrNone))
  1.1131 +			{
  1.1132 +			dateTime.SetDay(0);
  1.1133 +			item = dateTime.Month();
  1.1134 +			if (item == EDecember)
  1.1135 +				{
  1.1136 +				dateTime.SetMonth(EJanuary);
  1.1137 +				item = dateTime.Year();
  1.1138 +				dateTime.SetYear(item++);
  1.1139 +				}
  1.1140 +			else
  1.1141 +				{
  1.1142 +				dateTime.SetMonth(TMonth(item++));
  1.1143 +				}
  1.1144 +			}
  1.1145 +		time = TTime(dateTime);
  1.1146 +	
  1.1147 +		User::SetHomeTime(time);
  1.1148 +		TTime currentMicrosecs;
  1.1149 +		currentMicrosecs.HomeTime();
  1.1150 +
  1.1151 +		RFileLogger ::Write(KStdSubsysTag16, KStdCompTag16,EFileLoggingModeAppend, KTestMessage);
  1.1152 +		User::After(KTimeToLog);
  1.1153 +		TRAPD(r, ret = DoTestCheckWriteL());
  1.1154 +		if (r != KErrNone)
  1.1155 +			ret = r;
  1.1156 +
  1.1157 +		}
  1.1158 +	return ret;
  1.1159 +
  1.1160 +	}
  1.1161 +
  1.1162 +
  1.1163 +
  1.1164 +/**
  1.1165 +* This function checks whether test data was written
  1.1166 +* 						  in to the log file .				  
  1.1167 +*/
  1.1168 +
  1.1169 +
  1.1170 +TInt CFloggerTest024_08::DoTestCheckWriteL()
  1.1171 +	{
  1.1172 +	RFile theFile;
  1.1173 +	HBufC8 * hBuffer;
  1.1174 +	TInt listfilesize,returnCode;
  1.1175 +	RFs fileSystem; //For file operation create a file system
  1.1176 +	TBuf8<256> testData; //To hold the test descriptor
  1.1177 +	TInt numSuccessful = 0;
  1.1178 +
  1.1179 +
  1.1180 +	_LIT8(KOOMError, "#Logs may be lost out of memory!!");
  1.1181 +	
  1.1182 +	User::LeaveIfError(fileSystem.Connect());
  1.1183 +	
  1.1184 +	//Open the file in the read mode
  1.1185 +	User::LeaveIfError(theFile.Open(fileSystem,KFloggerOutputFile,EFileRead)); 
  1.1186 +
  1.1187 +	CleanupClosePushL(theFile);
  1.1188 +
  1.1189 +	User::LeaveIfError(theFile.Size(listfilesize)); //Size of the file
  1.1190 +	
  1.1191 +	hBuffer = HBufC8::New(listfilesize); //Allocate the buffer
  1.1192 +	CleanupStack::PushL(hBuffer);
  1.1193 +
  1.1194 +	TPtr8 ptrString = hBuffer->Des();  ; //To hold the buffer
  1.1195 +
  1.1196 +	// Read from position 0: start of file
  1.1197 +	User::LeaveIfError(returnCode = theFile.Read(ptrString));
  1.1198 +	
  1.1199 +	testData.Copy(KTestMessage); //Copy the test descriptor
  1.1200 +	returnCode = ptrString.Find(testData); //find the test descriptor in the buffer read
  1.1201 +											//from the file
  1.1202 +	if (returnCode > 0)
  1.1203 +		{
  1.1204 +		numSuccessful++;
  1.1205 +		}
  1.1206 +											
  1.1207 +	// We expect to see the string "date change"
  1.1208 +	testData.Copy(KDateChangeMessage); //Copy the test descriptor
  1.1209 +	returnCode = ptrString.Find(testData); //find the test descriptor in the buffer read
  1.1210 +
  1.1211 +	if (returnCode > 0)
  1.1212 +		{
  1.1213 +		numSuccessful++;
  1.1214 +		}
  1.1215 +
  1.1216 +
  1.1217 +	if (returnCode == KErrNotFound)
  1.1218 +		{
  1.1219 +		returnCode = ptrString.Find(KOOMError);
  1.1220 +		if (returnCode > 0)
  1.1221 +			User::Leave(KErrNoMemory);
  1.1222 +		}
  1.1223 +
  1.1224 +
  1.1225 +	
  1.1226 +	CleanupStack::PopAndDestroy(hBuffer);
  1.1227 +	CleanupStack::PopAndDestroy();	//theFile
  1.1228 +	if (numSuccessful == 2)
  1.1229 +		return KErrNone;
  1.1230 +	else 
  1.1231 +		return KErrNotFound;
  1.1232 +	}
  1.1233 +
  1.1234 +
  1.1235 +
  1.1236 +