os/persistentdata/traceservices/commsdebugutility/TE_commsdebugutility/src/step_014_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 014.xx
19 // Test system includes
20 #include "teststepcomsdbg.h"
21 #include "TestMessage.h"
22 #include "step_014_xx.h"
24 #include <comms-infras/commsdebugutility.h>
28 * Function Name : CFloggerTest005_02
29 * Input parameters : None
30 * Output parameters : None
31 * Description : This is the constructor
35 CFloggerTest014_01::CFloggerTest014_01()
37 // store the name of this test case
38 SetTestStepName(_L("step_014_01"));
43 * Function Name :~ CFloggerTest014_01
44 * Input parameters : None
45 * Output parameters : None
46 * Description : This is the Destructor
50 CFloggerTest014_01::~CFloggerTest014_01()
56 * Function Name : doTestStepL
57 * Input parameters : None
58 * Output parameters : TVerdict
59 * Description : This function returns weather the test case 014_01 has
65 TVerdict CFloggerTest014_01::doTestStepL( )
67 INFO_PRINTF1(_L("Step 011.01 called "));
69 if ( executeStepL(EFalse) == KErrNone )
70 SetTestStepResult(EPass);
73 SetTestStepResult(EFail);
76 User::After(KTimeForDisplay1);
77 return TestStepResult();
81 * Function Name : executeStepL
82 * Input parameters : None
83 * Output parameters : TInt
84 * Description : This function writes the test data in to the log file
85 * This function check the test message is present in the
91 TInt CFloggerTest014_01::executeStepL()
97 * Function Name : executeStepL
98 * Input parameters : None
99 * Output parameters : TInt
100 * Description : This function writes the test data in to the log file
101 * This function check the test message is present in the
107 TInt CFloggerTest014_01::executeStepL(TBool heapTest)
109 TInt ret = KErrGeneral;
112 if (ret == KErrNone )
114 User::After(KTimeToLog);
115 TRAPD(r, ret = DoTestCheckWriteL() );
116 if ((heapTest) && ((ret == KErrNotFound) || (r != KErrNone)))
120 else if (r != KErrNone)
130 * Function Name : DoTestWrite
131 * Input parameters : None
132 * Output parameters : TInt
133 * Description : This function writes the data to the file logger
138 TInt CFloggerTest014_01::DoTestWrite()
140 _LIT8(KTestMessage,"TC 14.01 :This is test msg"); //8 bit test decriptor
143 RFileLogger ::Write(KStdSubsysTag8, KStdCompTag8, KTestMessage);
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);
158 * Function Name : DoTestCheckWriteL
159 * Input parameters : None
160 * Output parameters : TInt
161 * Description : This function checks the weather test data was written
162 * in to the log file by DoTestWrite() or not.
167 TInt CFloggerTest014_01::DoTestCheckWriteL()
169 User::After(KTimeToLog);
175 RFs fileSystem; //For file operation create a file system
176 TBuf8<256> testData; //To hold the test descriptor
177 _LIT(KLogFile, "c:\\logs\\log.txt"); // log file name and path
180 _LIT8(KTestMessage,"TC 14.01 :This is test msg"); //8 bit test decriptor
182 User::LeaveIfError(fileSystem.Connect());
184 //Open the file in the read mode
185 User::LeaveIfError(theFile.Open(fileSystem,KLogFile,EFileRead));
188 returnCode = theFile.Size(listfilesize); //Size of the file
189 hBuffer = HBufC8::New(listfilesize); //Allocate the buffer
190 CleanupStack::PushL(hBuffer);
191 TPtr8 ptrString = hBuffer->Des(); ; //To hold the buffer
193 // Read from position 0: start of file
194 returnCode = theFile.Read(ptrString);
196 testData.Copy(KTestMessage); //Copy the test descriptor
197 returnCode = ptrString.Find(testData); //find the test descriptor in the buffer read
202 CleanupStack::PopAndDestroy(hBuffer);
215 * Function Name : CFloggerTest014_02
216 * Input parameters : None
217 * Output parameters : None
218 * Description : This is the constructor
222 CFloggerTest014_02::CFloggerTest014_02()
224 // store the name of this test case
225 SetTestStepName(_L("step_014_02"));
230 * Function Name :~ CFloggerTest014_02
231 * Input parameters : None
232 * Output parameters : None
233 * Description : This is the Destructor
237 CFloggerTest014_02::~CFloggerTest014_02()
243 * Function Name : doTestStepL
244 * Input parameters : None
245 * Output parameters : TVerdict
246 * Description : This function returns weather the test case 014_02 has
252 TVerdict CFloggerTest014_02::doTestStepL( )
254 INFO_PRINTF1(_L("Step 014.02 called "));
256 if ( executeStepL() == KErrNone )
257 SetTestStepResult(EPass);
260 SetTestStepResult(EFail);
263 User::After(KTimeForDisplay1);
264 return TestStepResult();
269 * Function Name : executeStepL
270 * Input parameters : None
271 * Output parameters : TInt
272 * Description : This function writes the test data in to the log file
273 * This function check the test message is present in the
279 TInt CFloggerTest014_02::executeStepL()
281 User::After(1000*1000);
283 TInt ret = KErrGeneral;
286 if (ret == KErrNone )
288 TRAPD(r, ret = DoTestCheckWriteL());
296 * Function Name : executeStepL
297 * Input parameters : None
298 * Output parameters : TInt
299 * Description : This function writes the test data in to the log file
300 * This function check the test message is present in the
306 TInt CFloggerTest014_02::executeStepL(TBool)
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 CFloggerTest014_02::DoTestWrite()
322 _LIT8(KTestLongMessage,"TEST 14.2: 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"); //8 bit test decriptor
326 RFileLogger theFlogger;
328 theFlogger.Connect(); //Just to clear the old log message
329 ret = theFlogger.SetLogTags(KStdSubsysTag8, KStdCompTag8);
330 theFlogger.ClearLog();
334 RFileLogger ::Write(KStdSubsysTag8, KStdCompTag8, KTestLongMessage);
340 * Function Name : DoTestCheckWriteL
341 * Input parameters : None
342 * Output parameters : TInt
343 * Description : This function checks the weather test data was written
344 * in to the log file by DoTestWrite() or not.
349 TInt CFloggerTest014_02::DoTestCheckWriteL()
351 User::After(KTimeToLog);
355 TInt listfilesize,returnCode;
356 RFs fileSystem; //For file operation create a file system
357 TBuf8<256> testData; //To hold the test descriptor
358 _LIT(KLogFile,"c:\\logs\\log.txt"); // log file name and path
360 //The following contains the string of length 200(max)
361 //which is written to the log file
362 //_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");
363 _LIT(KTestLongMessage, "TEST 14.2: 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 lo");
365 //_LIT8(KOOMError, "#Logs may be lost out of memory!!");
367 User::LeaveIfError(fileSystem.Connect());
369 //Open the file in the read mode
370 User::LeaveIfError(theFile.Open(fileSystem,KLogFile,EFileRead));
372 CleanupClosePushL(theFile);
374 User::LeaveIfError(theFile.Size(listfilesize)); //Size of the file
376 hBuffer = HBufC8::New(listfilesize); //Allocate the buffer
377 CleanupStack::PushL(hBuffer);
379 TPtr8 ptrString = hBuffer->Des(); ; //To hold the buffer
381 // Read from position 0: start of file
382 User::LeaveIfError(returnCode = theFile.Read(ptrString));
384 testData.Copy(KTestLongMessage); //Copy the test descriptor
385 returnCode = ptrString.Find(testData); //find the test descriptor in the buffer read
389 CleanupStack::PopAndDestroy(hBuffer);
390 CleanupStack::PopAndDestroy(); //theFile
400 * Function Name : CFloggerTest014_03
401 * Input parameters : None
402 * Output parameters : None
403 * Description : This is the constructor
407 CFloggerTest014_03::CFloggerTest014_03()
409 // store the name of this test case
410 SetTestStepName(_L("step_014_03"));
415 * Function Name :~ CFloggerTest014_03
416 * Input parameters : None
417 * Output parameters : None
418 * Description : This is the Destructor
422 CFloggerTest014_03::~CFloggerTest014_03()
428 * Function Name : doTestStepL
429 * Input parameters : None
430 * Output parameters : TVerdict
431 * Description : This function is responsible for doing the heap test analysis
436 TVerdict CFloggerTest014_03::doTestStepL( )
438 INFO_PRINTF1(_L("Step 014.03 called "));
440 CFloggerTest014_01* step014_01 = new CFloggerTest014_01;
441 CleanupStack::PushL(step014_01);
442 doTestStepWithHeapFailureL( *step014_01, 1, 20, KErrNone, ETrue);
444 CleanupStack::PopAndDestroy(step014_01);
445 User::After(KTimeForDisplay);
446 return TestStepResult();