os/persistentdata/traceservices/commsdebugutility/TE_commsdebugutility/src/step_012_xx.cpp
First public contribution.
1 // Copyright (c) 2003-2009 Nokia Corporation and/or its subsidiary(-ies).
2 // All rights reserved.
3 // This component and the accompanying materials are made available
4 // under the terms of "Eclipse Public License v1.0"
5 // which accompanies this distribution, and is available
6 // at the URL "http://www.eclipse.org/legal/epl-v10.html".
8 // Initial Contributors:
9 // Nokia Corporation - initial contribution.
14 // This contains Flogger Unit Test Case 012.xx
19 // Test system includes
20 #include "teststepcomsdbg.h"
21 #include "TestMessage.h"
22 #include "step_012_xx.h"
24 #include <comms-infras/commsdebugutility.h>
28 * Function Name : CFloggerTest012_01
29 * Input parameters : None
30 * Output parameters : None
31 * Description : This is the constructor
35 CFloggerTest012_01::CFloggerTest012_01()
37 // store the name of this test case
38 SetTestStepName(_L("step_012_01"));
43 * Function Name :~ CFloggerTest012_01
44 * Input parameters : None
45 * Output parameters : None
46 * Description : This is the Destructor
50 CFloggerTest012_01::~CFloggerTest012_01()
56 * Function Name : doTestStepL
57 * Input parameters : None
58 * Output parameters : TVerdict
59 * Description : This function returns weather the test case 012_01 has
65 TVerdict CFloggerTest012_01::doTestStepL( )
68 INFO_PRINTF1(_L("Step 012.01 called "));
70 if ( executeStepL(EFalse) == KErrNone )
71 SetTestStepResult(EPass);
74 SetTestStepResult(EFail);
77 User::After(KTimeForDisplay1);
78 return TestStepResult();
83 * Function Name : executeStepL
84 * Input parameters : None
85 * Output parameters : TInt
86 * Description : This function writes the test data in to the log file
87 * This function check the test message is present in the
93 TInt CFloggerTest012_01::executeStepL(TBool heapTest)
95 TInt ret = KErrGeneral;
100 User::After(KTimeToLog);
101 TRAPD(r, ret = DoTestCheckWriteL() );
102 if ((heapTest) && ((ret == KErrNotFound) || (r != KErrNone)))
106 else if (r != KErrNone)
114 * Function Name : executeStepL
115 * Input parameters : None
116 * Output parameters : TInt
117 * Description : This function writes the test data in to the log file
118 * This function check the test message is present in the
124 TInt CFloggerTest012_01::executeStepL()
131 * Function Name : DoTestWrite
132 * Function Name : DoTestWrite
133 * Input parameters : None
134 * Output parameters : TInt
135 * Description : This function writes the data to the file logger
140 TInt CFloggerTest012_01::DoTestWrite()
142 _LIT16(KTestMessageOne,"TEST 12.01: The value of test integer variable :%d"); //unicode test decriptor
143 RFileLogger::WriteFormat(KStdSubsysTag8, KStdCompTag8, KTestMessageOne, 100);
145 // connect so we can flush file buffer for heap check
146 RFileLogger theFlogger;
147 theFlogger.Connect();
148 theFlogger.SetLogTags(KStdSubsysTag8, KStdCompTag8);
149 ForceLogFlush(theFlogger);
157 * Function Name : DoTestCheckWriteL
158 * Input parameters : None
159 * Output parameters : TInt
160 * Description : This function checks the weather test data was written
161 * in to the log file by DoTestWriteL() or not.
166 TInt CFloggerTest012_01::DoTestCheckWriteL()
172 RFs fileSystem; //For file operation create a file system
173 TBuf8<256> testData; //To hold the test descriptor
174 _LIT(KLogFile, "c:\\logs\\log.txt"); // log file name and path
176 _LIT8(KTestMessageOne,"TEST 12.01: The value of test integer variable :%d"); //unicode test decriptor
177 testData.Format(KTestMessageOne,100);
179 User::LeaveIfError(fileSystem.Connect());
181 //Open the file in the read mode
182 User::LeaveIfError(theFile.Open(fileSystem,KLogFile,EFileRead));
185 returnCode = theFile.Size(listfilesize); //Size of the file
186 hBuffer = HBufC8::New(listfilesize); //Allocate the buffer
187 CleanupStack::PushL(hBuffer);
188 TPtr8 ptrString = hBuffer->Des(); ; //To hold the buffer read from file
190 // Read from position 0: starting of file
191 returnCode = theFile.Read(ptrString);
193 returnCode = ptrString.Find(testData); //find the test descriptor in the buffer read
198 CleanupStack::PopAndDestroy(hBuffer);
206 TInt CFloggerTest012_01::DoHeapTestWrite()
209 _LIT16(KTestMessageOne,"TEST 12.04: Heap Test: The value of test integer variable :%d"); //unicode test decriptor
210 RFileLogger::WriteFormat(KStdSubsysTag8, KStdCompTag8, KTestMessageOne, 100);
216 * Function Name : CFloggerTest012_02
217 * Input parameters : None
218 * Output parameters : None
219 * Description : This is the constructor
223 CFloggerTest012_02::CFloggerTest012_02()
225 // store the name of this test case
226 SetTestStepName(_L("step_012_02"));
231 * Function Name :~ CFloggerTest012_02
232 * Input parameters : None
233 * Output parameters : None
234 * Description : This is the Destructor
238 CFloggerTest012_02::~CFloggerTest012_02()
246 * Function Name : doTestStepL
247 * Input parameters : None
248 * Output parameters : TVerdict
249 * Description : This function returns weather the test case 012_02 has
255 TVerdict CFloggerTest012_02::doTestStepL( )
257 INFO_PRINTF1(_L("Step 011.02 called "));
259 if ( executeStepL() == KErrNone )
260 SetTestStepResult(EPass);
263 SetTestStepResult(EFail);
266 User::After(KTimeForDisplay1);
267 return TestStepResult();
271 * Function Name : executeStepL
272 * Input parameters : None
273 * Output parameters : TInt
274 * Description : This function writes the test data in to the log file
275 * This function check the test message is present in the
281 TInt CFloggerTest012_02::executeStepL(TBool)
287 * Function Name : executeStepL
288 * Input parameters : None
289 * Output parameters : TInt
290 * Description : This function writes the test data in to the log file
291 * This function check the test message is present in the
297 TInt CFloggerTest012_02::executeStepL()
299 TInt ret = KErrGeneral;
302 if (ret == KErrNone )
304 TRAPD(r, ret = DoTestCheckWriteL());
312 * Function Name : DoTestWrite
313 * Input parameters : None
314 * Output parameters : TInt
315 * Description : This function writes the data to the file logger
320 TInt CFloggerTest012_02::DoTestWrite()
323 //unicode test decriptor
324 _LIT16(KTestMessageTwo,"TEST 12.02: The value of first test integer variable :%d The value of second test integer variable : %d");
326 RFileLogger ::WriteFormat(KStdSubsysTag8, KStdCompTag8, KTestMessageTwo, 100, 200);
334 * Function Name : DoTestCheckWriteL
335 * Input parameters : None
336 * Output parameters : TInt
337 * Description : This function checks the weather test data was written
338 * in to the log file by DoTestWriteL() or not.
343 TInt CFloggerTest012_02::DoTestCheckWriteL()
347 User::After(KTimeToLog);
353 RFs fileSystem; //For file operation create a file system
354 TBuf8<256> testData; //To hold the test descriptor
355 _LIT(KLogFile, "c:\\logs\\log.txt"); // log file name and path
357 _LIT8(KTestMessageTwo,"TEST 12.02: The value of first test integer variable :%d The value of second test integer variable : %d");
358 testData.Format(KTestMessageTwo,100, 200);
360 User::LeaveIfError(fileSystem.Connect());
362 //Open the file in the read mode
363 User::LeaveIfError(theFile.Open(fileSystem,KLogFile,EFileRead));
366 returnCode = theFile.Size(listfilesize); //Size of the file
367 hBuffer = HBufC8::New(listfilesize); //Allocate the buffer
368 CleanupStack::PushL(hBuffer);
369 TPtr8 ptrString = hBuffer->Des(); ; //To hold the buffer
371 // Read from position 0: start of file
372 returnCode = theFile.Read(ptrString);
374 returnCode = ptrString.Find(testData); //find the test descriptor in the buffer read
378 CleanupStack::PopAndDestroy(hBuffer);
387 * Function Name : CFloggerTest012_03
388 * Input parameters : None
389 * Output parameters : None
390 * Description : This is the constructor
394 CFloggerTest012_03::CFloggerTest012_03()
396 // store the name of this test case
397 SetTestStepName(_L("step_012_03"));
401 * Function Name :~ CFloggerTest012_03
402 * Input parameters : None
403 * Output parameters : None
404 * Description : This is the Destructor
408 CFloggerTest012_03::~CFloggerTest012_03()
414 * Function Name : doTestStepL
415 * Input parameters : None
416 * Output parameters : TVerdict
417 * Description : This function returns weather the test case 012_03 has
423 TVerdict CFloggerTest012_03::doTestStepL( )
425 INFO_PRINTF1(_L("Step 012.03 called "));
427 if ( executeStepL() == KErrNone )
428 SetTestStepResult(EPass);
431 SetTestStepResult(EFail);
434 User::After(KTimeForDisplay1);
435 return TestStepResult();
439 * Function Name : executeStepL
440 * Input parameters : None
441 * Output parameters : TInt
442 * Description : This function writes the test data in to the log file
443 * This function check the test message is present in the
449 TInt CFloggerTest012_03::executeStepL(TBool)
455 * Function Name : executeStepL
456 * Input parameters : None
457 * Output parameters : TInt
458 * Description : This function writes the test data in to the log file
459 * This function check the test message is present in the
465 TInt CFloggerTest012_03::executeStepL()
467 TInt ret = KErrGeneral;
468 User::After(1000*100); //Need this or connect will return KErrServerTerminated
470 if (ret == KErrNone )
472 TRAPD(r, ret = DoTestCheckWriteL());
482 * Function Name : DoTestWrite
483 * Input parameters : None
484 * Output parameters : TInt
485 * Description : This function writes the data to the file logger
490 TInt CFloggerTest012_03::DoTestWrite()
492 _LIT(KTestLongMessage,"TEST 12.03: This is the long message This is the long message This is the long message This is the long message This is the long message This is the long message This is the long message This is the long message This is the long message This is the long message This is the long message ");
494 RFileLogger ::WriteFormat(KStdSubsysTag8, KStdCompTag8, KTestLongMessage);
501 * Function Name : DoTestCheckWriteL
502 * Input parameters : None
503 * Output parameters : TInt
504 * Description : This function checks the weather test data was written
505 * in to the log file by DoTestWriteL() or not.
510 TInt CFloggerTest012_03::DoTestCheckWriteL()
512 User::After(KTimeToLog);
516 TInt listfilesize,returnCode;
517 RFs fileSystem; //For file operation create a file system
518 TBuf8<256> testData; //To hold the test descriptor
519 _LIT(KLogFile,"c:\\logs\\log.txt"); // log file name and path
521 //The following contains the string of length 200(max)
522 //which is written to the log file
523 //_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");
524 _LIT(KTestLongMessage, "TEST 12.03: This is the long message This is the long message This is the long message This is the long message This is the long message This is the long message This is the long message This");
526 //_LIT8(KOOMError, "#Logs may be lost out of memory!!");
528 User::LeaveIfError(fileSystem.Connect());
530 //Open the file in the read mode
531 User::LeaveIfError(theFile.Open(fileSystem,KLogFile,EFileRead));
533 CleanupClosePushL(theFile);
535 User::LeaveIfError(theFile.Size(listfilesize)); //Size of the file
537 hBuffer = HBufC8::New(listfilesize); //Allocate the buffer
538 CleanupStack::PushL(hBuffer);
540 TPtr8 ptrString = hBuffer->Des(); ; //To hold the buffer
542 // Read from position 0: start of file
543 User::LeaveIfError(returnCode = theFile.Read(ptrString));
545 testData.Copy(KTestLongMessage); //Copy the test descriptor
546 returnCode = ptrString.Find(testData); //find the test descriptor in the buffer read
549 CleanupStack::PopAndDestroy(hBuffer);
550 CleanupStack::PopAndDestroy(); //theFile
560 * Function Name : CFloggerTest005_02
561 * Input parameters : None
562 * Output parameters : None
563 * Description : This is the constructor
567 CFloggerTest012_04::CFloggerTest012_04()
569 // store the name of this test case
570 SetTestStepName(_L("step_012_04"));
575 * Function Name :~ CFloggerTest005_02
576 * Input parameters : None
577 * Output parameters : None
578 * Description : This is the Destructor
582 CFloggerTest012_04::~CFloggerTest012_04()
587 * Function Name : doTestStepL
588 * Input parameters : None
589 * Output parameters : TVerdict
590 * Description : This function is responsible for doing the heap test analysis
593 TVerdict CFloggerTest012_04::doTestStepL( )
595 INFO_PRINTF1(_L("Step 012.04 called "));
597 CFloggerTest012_01* step012_01 = new CFloggerTest012_01;
598 CleanupStack::PushL(step012_01);
599 doTestStepWithHeapFailureL( *step012_01, 1,20, KErrNone, ETrue);
601 CleanupStack::PopAndDestroy(step012_01);
602 User::After(KTimeForDisplay);
603 return TestStepResult();