os/persistentdata/traceservices/commsdebugutility/TE_commsdebugutility/src/step_013_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 013.xx
19 // Test system includes
20 #include <comms-infras/commsdebugutility.h>
21 #include "TestMessage.h"
26 #include "teststepcomsdbg.h"
27 #include "step_013_xx.h"
31 * Function Name : CFloggerTest013_01
32 * Input parameters : None
33 * Output parameters : None
34 * Description : This is the constructor
38 CFloggerTest013_01::CFloggerTest013_01()
40 // store the name of this test case
41 SetTestStepName(_L("step_013_01"));
46 * Function Name :~ CFloggerTest013_01
47 * Input parameters : None
48 * Output parameters : None
49 * Description : This is the Destructor
53 CFloggerTest013_01::~CFloggerTest013_01()
59 * Function Name : doTestStepL
60 * Input parameters : None
61 * Output parameters : TVerdict
62 * Description : This function returns weather the test case 013_01 has
68 TVerdict CFloggerTest013_01::doTestStepL( )
70 INFO_PRINTF1(_L("Step 013.01 called "));
72 if ( executeStepL(EFalse) == KErrNone )
73 SetTestStepResult(EPass);
76 SetTestStepResult(EFail);
79 User::After(KTimeForDisplay1);
80 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 CFloggerTest013_01::executeStepL()
100 * Function Name : executeStepL
101 * Input parameters : None
102 * Output parameters : TInt
103 * Description : This function writes the test data in to the log file
104 * This function check the test message is present in the
110 TInt CFloggerTest013_01::executeStepL(TBool heapTest)
112 TInt ret = KErrGeneral;
114 if (ret == KErrNone )
116 User::After(KTimeToLog);
117 TRAPD(r, ret = DoTestCheckWriteL() );
118 if ((heapTest) && ((ret == KErrNotFound) || (r != KErrNone)))
122 else if (r != KErrNone)
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 CFloggerTest013_01::DoTestWrite()
142 _LIT16(KTestMessageOne,"TC 13_01: The value of test integer variable :%d");
143 DoTestWriteFormat(KTestMessageOne, 100); //Write unicode formatted test descriptor
145 // connect so we can flush file buffer for heap check since timer is killed in heap checks
146 RFileLogger theFlogger;
147 theFlogger.Connect();
148 theFlogger.SetLogTags(KStdSubsysTag8, KStdCompTag8);
149 ForceLogFlush(theFlogger);
157 * Function Name : DoTestWriteFormat
158 * Input parameters : TRefByValue<const TDesC16>
159 * Output parameters : TInt
160 * Description : This function writes formatted data to the file logger
165 TInt CFloggerTest013_01::DoTestWriteFormat(TRefByValue<const TDesC16> aFmt,...)
169 TRAPD(res, RFileLogger::WriteFormat(KStdSubsysTag8, KStdCompTag8, aFmt, list));
175 * Function Name : DoTestCheckWriteL
176 * Input parameters : None
177 * Output parameters : TInt
178 * Description : This function checks the weather test data was written
179 * in to the log file by DoTestWrite() or not.
184 TInt CFloggerTest013_01::DoTestCheckWriteL()
190 RFs fileSystem; //For file operation create a file system
191 TBuf8<256> testData; //To hold the test descriptor
193 _LIT8(KTestMessageOne,"TC 13_01: The value of test integer variable :%d");
194 testData.Format(KTestMessageOne,100);
196 _LIT(KLogFile,"c:\\logs\\log.txt"); // the log file path
198 User::LeaveIfError(fileSystem.Connect());
200 //Open the file in the read mode
201 User::LeaveIfError(theFile.Open(fileSystem,KLogFile,EFileRead));
204 returnCode = theFile.Size(listfilesize); //Size of the file
205 hBuffer = HBufC8::New(listfilesize); //Allocate the buffer
206 CleanupStack::PushL(hBuffer);
207 TPtr8 ptrString = hBuffer->Des(); ; //To hold the buffer
209 // Read from position 0: start of file
210 returnCode = theFile.Read(ptrString);
213 returnCode = ptrString.Find(testData); //find the test descriptor in the buffer read
218 CleanupStack::PopAndDestroy(hBuffer);
230 * Function Name : CFloggerTest013_02
231 * Input parameters : None
232 * Output parameters : None
233 * Description : This is the constructor
237 CFloggerTest013_02::CFloggerTest013_02()
239 // store the name of this test case
240 SetTestStepName(_L("step_013_02"));
245 * Function Name :~ CFloggerTest013_02
246 * Input parameters : None
247 * Output parameters : None
248 * Description : This is the Destructor
252 CFloggerTest013_02::~CFloggerTest013_02()
259 * Function Name : doTestStepL
260 * Input parameters : None
261 * Output parameters : TVerdict
262 * Description : This function returns weather the test case 013_02 has
268 TVerdict CFloggerTest013_02::doTestStepL( )
270 INFO_PRINTF1(_L("Step 013.02 called "));
272 if ( executeStepL() == KErrNone )
273 SetTestStepResult(EPass);
276 SetTestStepResult(EFail);
279 User::After(KTimeForDisplay1);
280 return TestStepResult();
285 * Function Name : executeStepL
286 * Input parameters : None
287 * Output parameters : TInt
288 * Description : This function writes the test data in to the log file
289 * This function check the test message is present in the
295 TInt CFloggerTest013_02::executeStepL()
297 User::After(1000*1000); //Need this or connect will return KErrServerTerminated
299 TInt ret = KErrGeneral;
302 if (ret == KErrNone )
304 TRAPD(r, ret = DoTestCheckWriteL());
313 * Function Name : executeStepL
314 * Input parameters : None
315 * Output parameters : TInt
316 * Description : This function writes the test data in to the log file
317 * This function check the test message is present in the
323 TInt CFloggerTest013_02::executeStepL(TBool)
330 * Function Name : DoTestWrite
331 * Input parameters : None
332 * Output parameters : TInt
333 * Description : This function writes the data to the file logger
338 TInt CFloggerTest013_02::DoTestWrite()
340 _LIT(KTestLongMessage,"TEST 13: 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"); //Unicode long test decriptor
342 TRAPD(res, DoTestWriteFormat(KTestLongMessage, 100)); //Write unicode formatted test descriptor
348 * Function Name : DoTestWriteFormat
349 * Input parameters : TRefByValue<const TDesC16>
350 * Output parameters : TInt
351 * Description : This function writes formatted data to the file logger
356 TInt CFloggerTest013_02::DoTestWriteFormat(TRefByValue<const TDesC16> aFmt,...)
359 RFileLogger theFlogger;
361 ret = theFlogger.Connect(); //Just to clear the old log message
362 if ( ret == KErrNone)
363 ret = theFlogger.SetLogTags(KStdSubsysTag8, KStdCompTag8);
364 if ( ret == KErrNone)
365 ret = theFlogger.ClearLog();
366 if ( ret == KErrNone)
375 RFileLogger::WriteFormat(KStdSubsysTag8, KStdCompTag8, aFmt, list);
382 TInt CFloggerTest013_02::DoTestCheckWriteL()
384 User::After(KTimeToLog);
388 TInt listfilesize,returnCode;
389 RFs fileSystem; //For file operation create a file system
390 TBuf8<256> testData; //To hold the test descriptor
391 _LIT(KLogFile,"c:\\logs\\log.txt"); // log file name and path
393 //The following contains the string of length 200(max)
394 //which is written to the log file
395 //_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");
396 _LIT(KTestLongMessage, "TEST 13: 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");
398 //_LIT8(KOOMError, "#Logs may be lost out of memory!!");
400 User::LeaveIfError(fileSystem.Connect());
402 //Open the file in the read mode
403 User::LeaveIfError(theFile.Open(fileSystem,KLogFile,EFileRead));
405 CleanupClosePushL(theFile);
407 User::LeaveIfError(theFile.Size(listfilesize)); //Size of the file
409 hBuffer = HBufC8::New(listfilesize); //Allocate the buffer
410 CleanupStack::PushL(hBuffer);
412 TPtr8 ptrString = hBuffer->Des(); ; //To hold the buffer
414 // Read from position 0: start of file
415 User::LeaveIfError(returnCode = theFile.Read(ptrString));
417 testData.Copy(KTestLongMessage); //Copy the test descriptor
418 returnCode = ptrString.Find(testData); //find the test descriptor in the buffer read
422 CleanupStack::PopAndDestroy(hBuffer);
423 CleanupStack::PopAndDestroy(); //theFile
434 * Function Name : CFloggerTest013_03
435 * Input parameters : None
436 * Output parameters : None
437 * Description : This is the constructor
441 CFloggerTest013_03::CFloggerTest013_03()
443 // store the name of this test case
444 SetTestStepName(_L("step_013_03"));
448 * Function Name :~ CFloggerTest013_03
449 * Input parameters : None
450 * Output parameters : None
451 * Description : This is the Destructor
455 CFloggerTest013_03::~CFloggerTest013_03()
461 * Function Name : doTestStepL
462 * Input parameters : None
463 * Output parameters : TVerdict
464 * Description : This function is responsible for doing the heap test analysis
468 TVerdict CFloggerTest013_03::doTestStepL( )
470 INFO_PRINTF1(_L("Step 013.03 called "));
472 CFloggerTest013_01* step013_01 = new CFloggerTest013_01;
473 CleanupStack::PushL(step013_01);
474 doTestStepWithHeapFailureL( *step013_01, 1,20, KErrNone, ETrue);
476 CleanupStack::PopAndDestroy(step013_01);
477 User::After(KTimeForDisplay);
478 return TestStepResult();