os/persistentdata/traceservices/commsdebugutility/TE_commsdebugutility/src/step_016_xx.cpp
Update contrib.
1 // Copyright (c) 2003-2009 Nokia Corporation and/or its subsidiary(-ies).
2 // All rights reserved.
3 // This component and the accompanying materials are made available
4 // under the terms of "Eclipse Public License v1.0"
5 // which accompanies this distribution, and is available
6 // at the URL "http://www.eclipse.org/legal/epl-v10.html".
8 // Initial Contributors:
9 // Nokia Corporation - initial contribution.
14 // This contains Flogger Unit Test Case 016.xx
19 // Test system includes
20 #include "TestMessage.h"
21 #include <comms-infras/commsdebugutility.h>
26 #include "teststepcomsdbg.h"
27 #include "step_016_xx.h"
31 * Function Name : CFloggerTest016_01
32 * Input parameters : None
33 * Output parameters : None
34 * Description : This is the constructor
38 CFloggerTest016_01::CFloggerTest016_01()
40 // store the name of this test case
41 SetTestStepName(_L("step_016_01"));
46 * Function Name :~ CFloggerTest016_01
47 * Input parameters : None
48 * Output parameters : None
49 * Description : This is the Destructor
53 CFloggerTest016_01::~CFloggerTest016_01()
58 * Function Name : doTestStepL
59 * Input parameters : None
60 * Output parameters : TVerdict
61 * Description : This function returns weather the test case 016_01 has
67 TVerdict CFloggerTest016_01::doTestStepL( )
69 INFO_PRINTF1(_L("Step 016.01 called "));
71 if ( executeStepL(EFalse) == KErrNone )
72 SetTestStepResult(EPass);
75 SetTestStepResult(EFail);
78 User::After(KTimeForDisplay1);
79 return TestStepResult();
84 * Function Name : executeStepL
85 * Input parameters : None
86 * Output parameters : TInt
87 * Description : This function writes the test data in to the log file
88 * This function check the test message is present in the
94 TInt CFloggerTest016_01::executeStepL(TBool heapTest)
96 TInt ret = KErrGeneral;
101 User::After(KTimeToLog);
102 TRAPD(r, ret = DoTestCheckWriteL() );
103 if ((heapTest) && ((ret == KErrNotFound) || (r != KErrNone)))
107 else if (r != KErrNone)
115 * Function Name : executeStepL
116 * Input parameters : None
117 * Output parameters : TInt
118 * Description : This function writes the test data in to the log file
119 * This function check the test message is present in the
125 TInt CFloggerTest016_01::executeStepL()
131 * Function Name : DoTestWrite
132 * Input parameters : None
133 * Output parameters : TInt
134 * Description : This function writes the data to the file logger
139 TInt CFloggerTest016_01::DoTestWrite()
141 _LIT8(KTestMessageOne,"TC 16_01: The value of test integer variable :%d");
142 DoTestWriteFormat(KTestMessageOne, 100); //Write 8 bit formatted test descriptor
144 // connect so we can flush file buffer for heap check since timer is killed in heap checks
145 RFileLogger theFlogger;
146 theFlogger.Connect();
147 theFlogger.SetLogTags(KStdSubsysTag8, KStdCompTag8);
148 ForceLogFlush(theFlogger);
155 * Function Name : DoTestWriteFormat
156 * Input parameters : TRefByValue<const TDesC8>
157 * Output parameters : TInt
158 * Description : This function writes formatted data to the file logger
162 TInt CFloggerTest016_01::DoTestWriteFormat(TRefByValue<const TDesC8> aFmt,...)
166 RFileLogger::WriteFormat(KStdSubsysTag8, KStdCompTag8, aFmt, list);
172 * Function Name : DoTestCheckWriteL
173 * Input parameters : None
174 * Output parameters : TInt
175 * Description : This function checks the weather test data was written
176 * in to the log file by DoTestWrite() or not.
181 TInt CFloggerTest016_01::DoTestCheckWriteL()
183 User::After(KTimeToLog);
189 RFs fileSystem; //For file operation create a file system
190 TBuf8<256> testData; //To hold the test descriptor
192 _LIT8(KTestMessageOne,"TC 16_01: The value of test integer variable :%d");
193 testData.Format(KTestMessageOne, 100);
195 _LIT(KLogFile,"c:\\logs\\log.txt"); // the log file path
197 User::LeaveIfError(fileSystem.Connect());
199 //Open the file in the read mode
200 User::LeaveIfError(theFile.Open(fileSystem,KLogFile,EFileRead));
203 User::LeaveIfError(returnCode = theFile.Size(listfilesize)); //Size of the file
204 hBuffer = HBufC8::New(listfilesize); //Allocate the buffer
205 CleanupStack::PushL(hBuffer);
206 TPtr8 ptrString = hBuffer->Des(); ; //To hold the buffer
208 // Read from position 0: start of file
209 returnCode = theFile.Read(ptrString);
211 returnCode = ptrString.Find(testData); //find the test descriptor in the buffer read
214 fileSystem.Close(); //Close the file server
215 CleanupStack::PopAndDestroy(hBuffer);
226 * Function Name : CFloggerTest016_02
227 * Input parameters : None
228 * Output parameters : None
229 * Description : This is the constructor
233 CFloggerTest016_02::CFloggerTest016_02()
235 // store the name of this test case
236 SetTestStepName(_L("step_016_02"));
241 * Function Name :~ CFloggerTest016_02
242 * Input parameters : None
243 * Output parameters : None
244 * Description : This is the Destructor
248 CFloggerTest016_02::~CFloggerTest016_02()
255 * Function Name : doTestStepL
256 * Input parameters : None
257 * Output parameters : TVerdict
258 * Description : This function returns weather the test case 016_01 has
264 TVerdict CFloggerTest016_02::doTestStepL( )
266 INFO_PRINTF1(_L("Step 016.02 called "));
267 if ( executeStepL() == KErrNone )
268 SetTestStepResult(EPass);
271 SetTestStepResult(EFail);
274 User::After(KTimeForDisplay1);
275 return TestStepResult();
279 * Function Name : executeStepL
280 * Input parameters : None
281 * Output parameters : TInt
282 * Description : This function writes the test data in to the log file
283 * This function check the test message is present in the
289 TInt CFloggerTest016_02::executeStepL(TBool)
294 * Function Name : executeStepL
295 * Input parameters : None
296 * Output parameters : TInt
297 * Description : This function writes the test data in to the log file
298 * This function check the test message is present in the
304 TInt CFloggerTest016_02::executeStepL()
306 User::After(1000*1000); //Need this or connect will return KErrServerTerminated
308 for(TInt i=0; i < 100000000; i++)
311 TInt ret = KErrGeneral;
313 if (ret == KErrNone )
315 TRAPD(r, ret = DoTestCheckWriteL());
323 TInt CFloggerTest016_02::DoTestWrite()
325 _LIT8(KTestLongMessage,"TEST 16.02: 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 %d"); //8 bit test decriptor
326 DoTestWriteFormat(KTestLongMessage, 100); //Write 8 bit formatted test descriptor
332 * Function Name : DoTestWriteFormat
333 * Input parameters : TRefByValue<const TDesC16>
334 * Output parameters : TInt
335 * Description : This function writes formatted data to the file logger
339 TInt CFloggerTest016_02::DoTestWriteFormat(TRefByValue<const TDesC8> aFmt,...)
342 RFileLogger theFlogger;
343 TInt ret = KErrGeneral;
344 ret = theFlogger.Connect(); //Just to clear the old log message
345 if ( ret == KErrNone)
346 ret = theFlogger.SetLogTags(KStdSubsysTag8, KStdCompTag8);
347 if ( ret == KErrNone)
348 ret = theFlogger.ClearLog();
349 if ( ret == KErrNone)
359 RFileLogger::WriteFormat(KStdSubsysTag8, KStdCompTag8, aFmt, list);
369 * Function Name : DoTestCheckWriteL
370 * Input parameters : None
371 * Output parameters : TInt
372 * Description : This function checks the weather test data was written
373 * in to the log file by DoTestWrite() or not.
378 TInt CFloggerTest016_02::DoTestCheckWriteL()
380 User::After(KTimeToLog);
384 TInt listfilesize,returnCode;
385 RFs fileSystem; //For file operation create a file system
386 TBuf8<256> testData; //To hold the test descriptor
387 _LIT(KLogFile,"c:\\logs\\log.txt"); // log file name and path
389 //The following contains the string of length 200(max)
390 //which is written to the log file
391 //_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");
392 _LIT(KTestLongMessage, "TEST 16.02: 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 l");
394 //_LIT8(KOOMError, "#Logs may be lost out of memory!!");
396 User::LeaveIfError(fileSystem.Connect());
398 //Open the file in the read mode
399 User::LeaveIfError(theFile.Open(fileSystem,KLogFile,EFileRead));
401 CleanupClosePushL(theFile);
403 User::LeaveIfError(theFile.Size(listfilesize)); //Size of the file
405 hBuffer = HBufC8::New(listfilesize); //Allocate the buffer
406 CleanupStack::PushL(hBuffer);
408 TPtr8 ptrString = hBuffer->Des(); ; //To hold the buffer
410 // Read from position 0: start of file
411 User::LeaveIfError(returnCode = theFile.Read(ptrString));
413 testData.Copy(KTestLongMessage); //Copy the test descriptor
414 returnCode = ptrString.Find(testData); //find the test descriptor in the buffer read
417 CleanupStack::PopAndDestroy(hBuffer);
418 CleanupStack::PopAndDestroy(); //theFile
427 * Function Name : CFloggerTest016_03
428 * Input parameters : None
429 * Output parameters : None
430 * Description : This is the constructor
434 CFloggerTest016_03::CFloggerTest016_03()
436 // store the name of this test case
437 SetTestStepName(_L("step_016_03"));
442 * Function Name :~ CFloggerTest016_03
443 * Input parameters : None
444 * Output parameters : None
445 * Description : This is the Destructor
449 CFloggerTest016_03::~CFloggerTest016_03()
455 * Function Name : doTestStepL
456 * Input parameters : None
457 * Output parameters : TVerdict
458 * Description : This function is responsible for doing the heap test analysis
463 TVerdict CFloggerTest016_03::doTestStepL( )
465 INFO_PRINTF1(_L("Step 016.03 called "));
467 CFloggerTest016_01* step016_01 = new CFloggerTest016_01;
468 CleanupStack::PushL(step016_01);
469 doTestStepWithHeapFailureL( *step016_01, 1, 20, KErrNone, ETrue);
471 CleanupStack::PopAndDestroy(step016_01);
472 User::After(KTimeForDisplay);
473 return TestStepResult();