os/persistentdata/traceservices/commsdebugutility/TE_commsdebugutility/src/step_011_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 011.01
19 // Test system includes
20 #include "teststepcomsdbg.h"
21 #include "TestMessage.h"
22 #include "step_011_xx.h"
24 #include <comms-infras/commsdebugutility.h>
27 //*****************************************************************
28 //Function Name : CFloggerTest011_01
29 //Input parameters : None
30 //Output parameters : None
31 //Description : This is the constructor
32 //*****************************************************************
34 CFloggerTest011_01::CFloggerTest011_01()
36 // store the name of this test case
37 SetTestStepName(_L("step_011_01"));
42 //*****************************************************************
43 //Function Name :~ CFloggerTest011_01
44 //Input parameters : None
45 //Output parameters : None
46 //Description : This is the Destructor
47 //*****************************************************************
49 CFloggerTest011_01::~CFloggerTest011_01()
55 //*****************************************************************
56 //Function Name : doTestStepL
57 //Input parameters : None
58 //Output parameters : TVerdict
59 //Description : This function returns weather the test case 011_01 has
62 //*****************************************************************
64 TVerdict CFloggerTest011_01::doTestStepL( )
67 INFO_PRINTF1(_L("Step 011.01 called "));
69 if ( executeStepL(EFalse) == KErrNone )
70 SetTestStepResult(EPass);
72 SetTestStepResult(EFail);
73 User::After(KTimeForDisplay);
74 return TestStepResult();
77 //*****************************************************************
78 //Function Name : executeStepL
79 //Input parameters : None
80 //Output parameters : TInt
81 //Description : This function writes the test data in to the log file
82 // This function check the test message is present in the
85 //*****************************************************************
88 TInt CFloggerTest011_01::executeStepL()
94 //*****************************************************************
95 //Function Name : executeStepL
96 //Input parameters : None
97 //Output parameters : TInt
98 //Description : This function writes the test data in to the log file
99 // This function check the test message is present in the
102 //*****************************************************************
105 TInt CFloggerTest011_01::executeStepL(TBool heapTest)
108 TInt ret = KErrGeneral;
111 if (ret == KErrNone )
113 User::After(KTimeToLog);
114 TRAPD(r, ret = DoTestCheckWriteL());
115 if ((heapTest) && ((ret == KErrNotFound) || (r != KErrNone)))
119 else if (r != KErrNone)
129 //*****************************************************************
130 //Function Name : DoTestWrite
131 //Input parameters : None
132 //Output parameters : TInt
133 //Description : This function writes the data to the file logger
135 //*****************************************************************
137 TInt CFloggerTest011_01::DoTestWrite()
140 _LIT(KTestMessage,"TC 11_01: This is test messsage"); //unicode test decriptor
142 RFileLogger theFlogger;
144 //Just to clear the old log message
145 ret = theFlogger.Connect();
146 if ( ret == KErrNone)
148 ret = theFlogger.SetLogTags(KStdSubsysTag8, KStdCompTag8);
149 if ( ret == KErrNone)
151 ret = theFlogger.ClearLog();
153 if ( ret == KErrNone)
160 if ( ret == KErrNone)
163 RFileLogger::Write(KStdSubsysTag8, KStdCompTag8,KTestMessage);
165 // reconnect so we can flush file buffer for heap check
166 ret = theFlogger.Connect();
169 theFlogger.SetLogTags(KStdSubsysTag8, KStdCompTag8);
170 ForceLogFlush(theFlogger);
179 //*****************************************************************
180 //Function Name : DoTestCheckWriteL
181 //Input parameters : None
182 //Output parameters : TInt
183 //Description : This function checks the weather test data was written
184 // in to the log file by DoTestWriteL() or not.
186 //*****************************************************************
188 TInt CFloggerTest011_01::DoTestCheckWriteL()
196 RFs fileSystem; //For file operation create a file system
197 TBuf8<256> testData; //To hold the test descriptor
198 _LIT(KLogFile, "c:\\logs\\log.txt"); // log file name and path
200 _LIT(KTestMessage,"TC 11_01: This is test messsage"); //unicode test decriptor
202 User::LeaveIfError(fileSystem.Connect());
204 //Open the file in the read mode
205 User::LeaveIfError(theFile.Open(fileSystem,KLogFile,EFileRead));
206 CleanupClosePushL(theFile);
208 User::LeaveIfError(returnCode=theFile.Size(listfilesize)); //Size of the file
209 hBuffer=HBufC8::New(listfilesize); //Allocate the buffer
210 CleanupStack::PushL(hBuffer);
211 TPtr8 ptrString = hBuffer->Des(); ; //To hold the buffer
213 // Read from position 0: start of file
214 returnCode = theFile.Read(ptrString);
216 testData.Copy(KTestMessage); //Copy the test descriptor
217 returnCode = ptrString.Find(testData); //find the test descriptor in the buffer read
221 CleanupStack::PopAndDestroy(hBuffer);
222 CleanupStack::PopAndDestroy(); //theFile
231 TInt CFloggerTest011_01::DoHeapTestWrite()
235 _LIT(KTestMessage,"TC 11_03: This is heap test messsage"); //unicode test decriptor
237 RFileLogger ::Write(KStdSubsysTag8, KStdCompTag8, KTestMessage);
242 /////////////////////////////////////////////////////////////////////
244 //*****************************************************************
245 //Function Name : CFloggerTest011_02
246 //Input parameters : None
247 //Output parameters : None
248 //Description : This is the constructor
249 //*****************************************************************
253 CFloggerTest011_02::CFloggerTest011_02()
255 // store the name of this test case
256 SetTestStepName(_L("step_011_02"));
261 //*****************************************************************
262 //Function Name :~ CFloggerTest011_02
263 //Input parameters : None
264 //Output parameters : None
265 //Description : This is the Destructor
266 //*****************************************************************
269 CFloggerTest011_02::~CFloggerTest011_02()
275 //*****************************************************************
276 //Function Name : doTestStepL
277 //Input parameters : None
278 //Output parameters : TVerdict
279 //Description : This function returns weather the test case 004_01 has
282 //*****************************************************************
284 TVerdict CFloggerTest011_02::doTestStepL( )
286 INFO_PRINTF1(_L("Step 011.02 called "));
288 if ( executeStepL() == KErrNone )
289 SetTestStepResult(EPass);
291 SetTestStepResult(EFail);
293 User::After(KTimeForDisplay);
294 return TestStepResult();
297 //*****************************************************************
298 //Function Name : executeStepL
299 //Input parameters : None
300 //Output parameters : TInt
301 //Description : This function writes the test data in to the log file
302 // This function check the test message is present in the
305 //*****************************************************************
307 TInt CFloggerTest011_02::executeStepL(TBool)
312 //*****************************************************************
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
320 //*****************************************************************
322 TInt CFloggerTest011_02::executeStepL()
324 TInt ret = KErrGeneral;
327 if (ret == KErrNone )
329 TRAPD(r, ret = DoTestCheckWriteL());
338 //*****************************************************************
339 //Function Name : DoTestWrite
340 //Input parameters : None
341 //Output parameters : TInt
342 //Description : This function writes the data to the file logger
344 //*****************************************************************
346 TInt CFloggerTest011_02::DoTestWrite()
352 _LIT(KTestLongMessage,"TC 11_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"); //unicode test decriptor
354 RFileLogger theFlogger;
356 ret = theFlogger.Connect(); //Just to clear the old log message
357 if ( ret == KErrNone)
358 ret = theFlogger.SetLogTags(KStdSubsysTag8, KStdCompTag8);
359 if ( ret == KErrNone)
360 ret = theFlogger.ClearLog();
361 if ( ret == KErrNone)
365 RFileLogger ::Write(KStdSubsysTag8, KStdCompTag8, KTestLongMessage);
373 TInt CFloggerTest011_02::DoTestCheckWriteL()
375 User::After(KTimeToLog);
378 TInt listfilesize,returnCode;
379 RFs fileSystem; //For file operation create a file system
380 TBuf8<256> testData; //To hold the test descriptor
381 _LIT(KLogFile,"c:\\logs\\log.txt"); // log file name and path
383 //The following contains the string of length 200(max)
384 //which is written to the log file
385 //_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");
386 _LIT(KTestLongMessage, "TC 11_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 lon");
388 //_LIT8(KOOMError, "#Logs may be lost out of memory!!");
390 User::LeaveIfError(fileSystem.Connect());
392 //Open the file in the read mode
393 User::LeaveIfError(theFile.Open(fileSystem,KLogFile,EFileRead));
395 CleanupClosePushL(theFile);
397 User::LeaveIfError(theFile.Size(listfilesize)); //Size of the file
399 hBuffer = HBufC8::New(listfilesize); //Allocate the buffer
400 CleanupStack::PushL(hBuffer);
402 TPtr8 ptrString = hBuffer->Des(); ; //To hold the buffer
404 // Read from position 0: start of file
405 User::LeaveIfError(returnCode = theFile.Read(ptrString));
407 testData.Copy(KTestLongMessage); //Copy the test descriptor
408 returnCode = ptrString.Find(testData); //find the test descriptor in the buffer read
412 CleanupStack::PopAndDestroy(hBuffer);
413 CleanupStack::PopAndDestroy(); //theFile
425 //////////////////////////////////////////////////////////////////////////////////
427 //*****************************************************************
428 //Function Name : CFloggerTest011_03
429 //Input parameters : None
430 //Output parameters : None
431 //Description : This is the constructor
432 //*****************************************************************
435 CFloggerTest011_03::CFloggerTest011_03()
437 // store the name of this test case
438 SetTestStepName(_L("step_011_03"));
443 //*****************************************************************
444 //Function Name :~ CFloggerTest011_03
445 //Input parameters : None
446 //Output parameters : None
447 //Description : This is the Destructor
448 //*****************************************************************
451 CFloggerTest011_03::~CFloggerTest011_03()
459 //*****************************************************************
460 //Function Name : doTestStepL
461 //Input parameters : None
462 //Output parameters : TVerdict
463 //Description : This function is responsible for doing the heap test analysis
465 //*****************************************************************
468 TVerdict CFloggerTest011_03::doTestStepL( )
470 INFO_PRINTF1(_L("Step 011.03 called "));
472 CFloggerTest011_01* step011_01 = new CFloggerTest011_01;
473 CleanupStack::PushL(step011_01);
474 doTestStepWithHeapFailureL( *step011_01, 1, 20, KErrNone, ETrue);
476 CleanupStack::PopAndDestroy(step011_01);
477 User::After(KTimeForDisplay);
478 return TestStepResult();
487 ///////////////////////////////////////////////////////////////////////