os/persistentdata/traceservices/commsdebugutility/TE_commsdebugutility/src/step_008_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 008.xx
19 // Test system includes
20 #include <comms-infras/commsdebugutility.h>
25 #include "teststepcomsdbg.h"
26 #include "step_008_xx.h"
30 * Function Name : CFloggerTest008_01
31 * Input parameters : None
32 * Output parameters : None
33 * Description : This is the constructor
37 CFloggerTest008_01::CFloggerTest008_01()
39 // store the name of this test case
40 SetTestStepName(_L("step_008_01"));
47 * Function Name :~ CFloggerTest008_01
48 * Input parameters : None
49 * Output parameters : None
50 * Description : This is the Destructor
54 CFloggerTest008_01::~CFloggerTest008_01()
61 * Function Name : doTestStepL
62 * Input parameters : None
63 * Output parameters : TVerdict
64 * Description : This function returns weather the test case 008_01 has
70 TVerdict CFloggerTest008_01::doTestStepL( )
72 INFO_PRINTF1(_L("Step 008.01 called "));
74 if ( executeStepL(EFalse) == KErrNone )
75 SetTestStepResult(EPass);
78 SetTestStepResult(EFail);
81 User::After(KTimeForDisplay);
82 return TestStepResult();
87 * Function Name : executeStepL
88 * Input parameters : None
89 * Output parameters : TInt
90 * Description : This function writes the test data in to the log file
91 * This function check the test message is present in the
97 TInt CFloggerTest008_01::executeStepL(TBool heapTest)
100 ret = DoTestConnect();
104 if ( ret == KErrNone)
106 TRAPD(r, ret = DoTestCheckWriteL());
107 if ((heapTest) && ((ret == KErrNotFound) || (r != KErrNone)))
111 else if (r != KErrNone)
118 // if (ret == KErrNone)
124 * Function Name : executeStepL
125 * Input parameters : None
126 * Output parameters : TInt
127 * Description : This function writes the test data in to the log file
128 * This function check the test message is present in the
134 TInt CFloggerTest008_01::executeStepL()
140 * Function Name : DoTestWrite
141 * Input parameters : None
142 * Output parameters : TInt
143 * Description : This function writes the data to the file logger
148 TInt CFloggerTest008_01::DoTestWrite()
150 _LIT8(KTestMessageOne,"TC 8_01: The value of test integer variable :%d");
151 iFlogger.WriteFormat(KTestMessageOne, 100); //Write 8 bit test descriptor
153 ForceLogFlush(iFlogger);
160 * Function Name : DoTestCheckWriteL
161 * Input parameters : None
162 * Output parameters : TInt
163 * Description : This function checks the weather test data was written
164 in to the log file by DoTestWriteL() or not.
169 TInt CFloggerTest008_01::DoTestCheckWriteL()
171 User::After(1000*1000);
176 RFs fileSystem; //For file operation create a file system
177 _LIT(KLogFile,"c:\\logs\\log.txt"); // the log file path
179 TBuf8<256> testData; //To hold the test descriptor
181 _LIT8(KTestMessageOne,"TC 8_01: The value of test integer variable :%d");
182 testData.Format(KTestMessageOne,100);
184 _LIT8(KOOMError, "#Logs may be lost out of memory!!"); //Error message
186 User::LeaveIfError(fileSystem.Connect());
188 //Open the file in the read mode
189 User::LeaveIfError(theFile.Open(fileSystem,KLogFile,EFileRead));
191 CleanupClosePushL(theFile);
193 User::LeaveIfError(returnCode = theFile.Size(listfilesize)); //Size of the file
194 hBuffer = HBufC8::New(listfilesize); //Allocate the buffer
195 CleanupStack::PushL(hBuffer);
196 TPtr8 ptrString = hBuffer->Des(); ; //To hold the buffer
198 // Read from position 0: start of file
199 returnCode = theFile.Read(ptrString);
201 returnCode = ptrString.Find(testData); //find the test descriptor in the buffer read
204 if (returnCode == KErrNotFound) //Find the error message
206 returnCode = ptrString.Find(KOOMError);
208 User::Leave(KErrNoMemory);
211 CleanupStack::PopAndDestroy(hBuffer);
212 CleanupStack::PopAndDestroy(); // For theFile object
222 * Function Name : DoTestConnect
223 * Input parameters : None
224 * Output parameters : TInt
225 * Description : This function establishes a connection to file logger
226 * and sets the system and component name in file logger.
231 TInt CFloggerTest008_01::DoTestConnect()
236 ptrSubSystem.Set(_L8("SubSystem"));
237 ptrComponent.Set(_L8("Component"));
239 ret = iFlogger.Connect(); //Call connect() of Flogger
241 ret = iFlogger.SetLogTags(ptrSubSystem, ptrComponent); //SetLogTags() of Flogger called
244 ret = iFlogger.ClearLog(); //clear the contents from the log
254 * Function Name : CFloggerTest008_02
255 * Input parameters : None
256 * Output parameters : None
257 * Description : This is the constructor
261 CFloggerTest008_02::CFloggerTest008_02()
263 // store the name of this test case
264 SetTestStepName(_L("step_008_02"));
269 * Function Name :~ CFloggerTest008_02
270 * Input parameters : None
271 * Output parameters : None
272 * Description : This is the Destructor
276 CFloggerTest008_02::~CFloggerTest008_02()
283 * Function Name : doTestStepL
284 * Input parameters : None
285 * Output parameters : TVerdict
286 * Description : This function returns weather the test case 008_02 has
292 TVerdict CFloggerTest008_02::doTestStepL( )
294 INFO_PRINTF1(_L("Step 008.02 called "));
296 if ( executeStepL() == KErrNone )
297 SetTestStepResult(EPass);
300 SetTestStepResult(EFail);
303 User::After(KTimeForDisplay);
304 return TestStepResult();
309 * Function Name : executeStepL
310 * Input parameters : None
311 * Output parameters : TInt
312 * Description : This function writes the test data in to the log file
313 * This function check the test message is present in the
319 TInt CFloggerTest008_02::executeStepL()
321 TInt ret = KErrGeneral;
322 ret = DoTestConnect();
323 CleanupClosePushL(iFlogger);
326 ret = DoTestWrite() ;
327 if ( ret == KErrNone)
330 TRAPD(r, ret = DoTestCheckWriteL() );
335 CleanupStack::PopAndDestroy(); //logger
340 * Function Name : executeStepL
341 * Input parameters : None
342 * Output parameters : TInt
343 * Description : This function writes the test data in to the log file
344 * This function check the test message is present in the
350 TInt CFloggerTest008_02::executeStepL(TBool)
356 * Function Name : DoTestConnect
357 * Input parameters : None
358 * Output parameters : TInt
359 * Description : This function establishes a connection to file logger
360 * and sets the system and component name in file logger.
365 TInt CFloggerTest008_02::DoTestConnect()
368 TPtrC8 ptrSubSystem, ptrComponent;
369 ptrSubSystem.Set(_L8("SubSystem"));
370 ptrComponent.Set(_L8("Component"));
372 ret = iFlogger.Connect(); //Call connect() of Flogger
374 ret = iFlogger.SetLogTags(ptrSubSystem, ptrComponent); //SetLogTags() of Flogger called
377 ret = iFlogger.ClearLog(); //clear the contents from the log
385 * Function Name : DoTestWrite
386 * Input parameters : None
387 * Output parameters : TInt
388 * Description : This function writes the data to the file logger
393 TInt CFloggerTest008_02::DoTestWrite()
395 _LIT8(KTestMessageTwo,"TC 8_02: The value of first test integer variable :%d The value of second test integer variable : %d");
396 iFlogger.WriteFormat(KTestMessageTwo, 100, 200); //Writes a 8 bit test descriptor
398 ForceLogFlush(iFlogger);
404 //Function Name : DoTestCheckWriteL
405 //Input parameters : None
406 //Output parameters : TInt
407 //Description : This function checks the weather test data was written
408 // in to the log file by DoTestWriteL() or not.
413 TInt CFloggerTest008_02::DoTestCheckWriteL()
415 User::After(1000*1000);
421 RFs fileSystem; //For file operation create a file system
422 _LIT(KLogFile,"c:\\logs\\log.txt"); // the log file path
424 TBuf8<256> testData; //To hold the test descriptor
425 _LIT8(KTestMessageTwo,"TC 8_02: The value of first test integer variable :%d The value of second test integer variable : %d");
426 testData.Format(KTestMessageTwo,100, 200);
428 _LIT8(KOOMError, "#Logs may be lost out of memory!!"); // Error message
430 User::LeaveIfError(fileSystem.Connect());//Connect to the file server
432 //Open the file in the read mode
433 User::LeaveIfError(theFile.Open(fileSystem,KLogFile,EFileRead));
435 CleanupClosePushL(theFile);
438 User::LeaveIfError(returnCode = theFile.Size(listfilesize)); //Size of the file
439 hBuffer = HBufC8::New(listfilesize); //Allocate the buffer
440 CleanupStack::PushL(hBuffer);
441 TPtr8 ptrString = hBuffer->Des(); ; //To hold the buffer
443 // Read from position 0: start of file
444 returnCode = theFile.Read(ptrString);
446 returnCode = ptrString.Find(testData); //find the test descriptor in the buffer read
449 if (returnCode == KErrNotFound) // Check for the error message in the log
451 returnCode = ptrString.Find(KOOMError);
453 User::Leave(KErrNoMemory);
457 CleanupStack::PopAndDestroy(hBuffer);
458 CleanupStack::PopAndDestroy(); //theFile
470 * Function Name : CFloggerTest008_03
471 * Input parameters : None
472 * Output parameters : None
473 * Description : This is the constructor
477 CFloggerTest008_03::CFloggerTest008_03()
479 // store the name of this test case
480 SetTestStepName(_L("step_008_03"));
487 * Function Name :~ CFloggerTest008_03
488 * Input parameters : None
489 * Output parameters : None
490 * Description : This is the Destructor
494 CFloggerTest008_03::~CFloggerTest008_03()
501 * Function Name : doTestStepL
502 * Input parameters : None
503 * Output parameters : TVerdict
504 * Description : This function returns weather the test case 004_01 has
510 TVerdict CFloggerTest008_03::doTestStepL( )
512 if ( executeStepL() == KErrNone )
513 SetTestStepResult(EPass);
516 SetTestStepResult(EFail);
518 User::After(KTimeForDisplay);
519 return TestStepResult();
524 * Function Name : executeStepL
525 * Input parameters : None
526 * Output parameters : TInt
527 * Description : This function writes the test data in to the log file
528 * This function check the test message is present in the
534 TInt CFloggerTest008_03::executeStepL()
536 TInt ret = KErrGeneral;
538 ret = DoTestConnect();
539 CleanupClosePushL(iFlogger);
543 ret = DoTestCheckWriteL();
545 CleanupStack::PopAndDestroy(); //logger
547 User::After(1000000);
552 * Function Name : executeStepL
553 * Input parameters : None
554 * Output parameters : TInt
555 * Description : This function writes the test data in to the log file
556 * This function check the test message is present in the
562 TInt CFloggerTest008_03::executeStepL(TBool)
568 * Function Name : DoTestConnect
569 * Input parameters : None
570 * Output parameters : TInt
571 * Description : This function establishes a connection to file logger
572 * and sets the system and component name in file logger.
577 TInt CFloggerTest008_03::DoTestConnect()
582 ptrSubSystem.Set(_L8("SubSystem"));
583 ptrComponent.Set(_L8("Component"));
585 ret = iFlogger.Connect(); //Call connect() of Flogger
588 ret = iFlogger.SetLogTags(ptrSubSystem, ptrComponent); //SetLogTags() of Flogger called
595 Function Name : DoTestWrite
596 * Input parameters : None
597 * Output parameters : TInt
598 * Description : This function writes the data to the file logger
603 TInt CFloggerTest008_03::DoTestWrite()
605 //KTestLongMessage contains a very long test message
606 _LIT(KTestLongMessage,"TC 8_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 ");
608 iFlogger.Write(KTestLongMessage); //this causes a PANIC
609 ForceLogFlush(iFlogger);
615 * Function Name : DoTestCheckWriteL
616 * Input parameters : None
617 * Output parameters : TInt
618 * Description : This function checks the weather test data was written
619 * in to the log file by DoTestWriteL() or not.
624 TInt CFloggerTest008_03::DoTestCheckWriteL()
626 User::After(KTimeToLog);
629 TInt listfilesize,returnCode;
630 RFs fileSystem; //For file operation create a file system
631 TBuf8<256> testData; //To hold the test descriptor
632 _LIT(KLogFile,"c:\\logs\\log.txt"); // log file name and path
634 //The following contains the string of length 200(max)
635 //which is written to the log file
636 //_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");
637 _LIT(KTestLongMessage, "TC 8_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");
639 //_LIT8(KOOMError, "#Logs may be lost out of memory!!");
641 User::LeaveIfError(fileSystem.Connect());
643 //Open the file in the read mode
644 User::LeaveIfError(theFile.Open(fileSystem,KLogFile,EFileRead));
646 CleanupClosePushL(theFile);
648 User::LeaveIfError(theFile.Size(listfilesize)); //Size of the file
650 hBuffer = HBufC8::New(listfilesize); //Allocate the buffer
651 CleanupStack::PushL(hBuffer);
653 TPtr8 ptrString = hBuffer->Des(); ; //To hold the buffer
655 // Read from position 0: start of file
656 User::LeaveIfError(returnCode = theFile.Read(ptrString));
658 testData.Copy(KTestLongMessage); //Copy the test descriptor
659 returnCode = ptrString.Find(testData); //find the test descriptor in the buffer read
663 CleanupStack::PopAndDestroy(hBuffer);
664 CleanupStack::PopAndDestroy(); //theFile
676 * Function Name : CFloggerTest008_04
677 * Input parameters : None
678 * Output parameters : None
679 * Description : This is the constructor
683 CFloggerTest008_04::CFloggerTest008_04()
685 // store the name of this test case
686 SetTestStepName(_L("step_008_04"));
692 * Function Name :~ CFloggerTest008_04
693 * Input parameters : None
694 * Output parameters : None
695 * Description : This is the Destructor
699 CFloggerTest008_04::~CFloggerTest008_04()
707 *Function Name : doTestStepL
708 * Input parameters : None
709 * Output parameters : TVerdict
710 * Description : This function is responsible for doing the heap test analysis
714 TVerdict CFloggerTest008_04::doTestStepL( )
716 INFO_PRINTF1(_L("Step 008.04 called "));
718 CFloggerTest008_01* step008_01 = new CFloggerTest008_01;
719 CleanupStack::PushL(step008_01);
720 doTestStepWithHeapFailureL( *step008_01, 1, 20, KErrNone, ETrue);
722 CleanupStack::PopAndDestroy(step008_01);
724 User::After(KTimeForDisplay);
725 return TestStepResult();