os/persistentdata/traceservices/commsdebugutility/TE_commsdebugutility/src/step_017_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 017.xx
19 // Test system includes
20 #include <comms-infras/commsdebugutility.h>
21 #include "TestMessage.h"
26 #include "teststepcomsdbg.h"
27 #include "step_017_xx.h"
31 * Function Name : CFloggerTest017_01
32 * Input parameters : None
33 * Output parameters : None
34 * Description : This is the constructor
38 CFloggerTest017_01::CFloggerTest017_01()
40 // store the name of this test case
41 SetTestStepName(_L("step_017_01"));
46 * Function Name :~ CFloggerTest017_01
47 * Input parameters : None
48 * Output parameters : None
49 * Description : This is the Destructor
53 CFloggerTest017_01::~CFloggerTest017_01()
59 * Function Name : doTestStepL
60 * Input parameters : None
61 * Output parameters : TVerdict
62 * Description : This function returns weather the test case 017_01 has
68 TVerdict CFloggerTest017_01::doTestStepL( )
70 INFO_PRINTF1(_L("Step 017.01 called "));
72 if ( executeStepL(EFalse) == KErrNone )
73 SetTestStepResult(EPass);
76 SetTestStepResult(EFail);
79 User::After(KTimeForDisplay1);
80 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 CFloggerTest017_01::executeStepL()
99 * Function Name : executeStepL
100 * Input parameters : None
101 * Output parameters : TInt
102 * Description : This function writes the test data in to the log file
103 * This function check the test message is present in the
109 TInt CFloggerTest017_01::executeStepL(TBool heapTest)
111 TInt ret = KErrGeneral;
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 in hexa format
140 TInt CFloggerTest017_01::DoTestWrite()
142 _LIT8(KDescText, "TC 17_1:Test Msg----"); //Test body descriptor
144 //Write the test datas in the hexa format
145 RFileLogger::HexDump(KStdSubsysTag8,KStdCompTag8, KDescText, KHexTestHeader);
147 // connect so we can flush file buffer for heap check since timer is killed in heap checks
148 RFileLogger theFlogger;
149 theFlogger.Connect();
150 theFlogger.SetLogTags(KStdSubsysTag8, KStdCompTag8);
151 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 CFloggerTest017_01::DoTestCheckWriteL()
169 User::After(KTimeToLog);
175 RFs fileSystem; //For file operation create a file system
176 _LIT(KLogFile,"c:\\logs\\log.txt"); // the log file path
178 _LIT8(KBodyTxt,"TC 17_1:Test Msg");// First 16 chars of Test body descriptor
180 User::LeaveIfError(fileSystem.Connect());
182 //Open the file in the read mode
183 User::LeaveIfError(theFile.Open(fileSystem,KLogFile,EFileRead)) ;
186 User::LeaveIfError(returnCode = theFile.Size(listfilesize)); //Size of the file
187 hBuffer = HBufC8::New(listfilesize); //Allocate the buffer
188 CleanupStack::PushL(hBuffer);
190 TPtr8 ptrString = hBuffer->Des(); ; //To hold the buffer
192 // Read from position 0, i.e starting of file
193 returnCode = theFile.Read(ptrString);
195 returnCode = ptrString.Find(KHexTestHeader); //find the test header descriptor in
196 //the buffer read from the file
198 if (returnCode > 0) //The header is present
200 returnCode = ptrString.Find(KHexTestMargin); //find the test margin descriptor in
201 //the buffer read from the file
204 if (returnCode > 0) //The margin is present
206 returnCode = ptrString.Find(KBodyTxt); //find the test descriptor in the
207 //buffer read from the file
211 fileSystem.Close(); //Close the file server
212 CleanupStack::PopAndDestroy(hBuffer);
214 if (returnCode > 0) //The test body descriptor is present
225 * Function Name : CFloggerTest017_02
226 * Input parameters : None
227 * Output parameters : None
228 * Description : This is the constructor
232 CFloggerTest017_02::CFloggerTest017_02()
234 // store the name of this test case
235 SetTestStepName(_L("step_017_02"));
240 * Function Name :~ CFloggerTest017_02
241 * Input parameters : None
242 * Output parameters : None
243 * Description : This is the Destructor
247 CFloggerTest017_02::~CFloggerTest017_02()
253 * Function Name : doTestStepL
254 * Input parameters : None
255 * Output parameters : TVerdict
256 * Description : This function returns weather the test case 017_02 has
262 TVerdict CFloggerTest017_02::doTestStepL( )
264 INFO_PRINTF1(_L("Step 017.02 called "));
266 if ( executeStepL() == KErrNone )
267 SetTestStepResult(EPass);
270 SetTestStepResult(EFail);
273 User::After(KTimeForDisplay1);
274 return TestStepResult();
278 * Function Name : executeStepL
279 * Input parameters : None
280 * Output parameters : TInt
281 * Description : This function writes the test data in to the log file
282 * This function check the test message is present in the
289 TInt CFloggerTest017_02::executeStepL(TBool)
294 * Function Name : executeStepL
295 * Input parameters : None
296 * Output parameters : TInt
297 * Description : This function writes the test data in to the log file
298 * This function check the test message is present in the
305 TInt CFloggerTest017_02::executeStepL( )
307 User::After(1000*1000); //Need this or connect will return KErrServerTerminated
308 TInt ret = KErrGeneral;
311 if (ret == KErrNone )
313 TRAPD(r, ret = DoTestCheckWriteL());
323 * Function Name : DoTestWrite
324 * Input parameters : None
325 * Output parameters : TInt
326 * Description : This function writes the data to the file logger
331 TInt CFloggerTest017_02::DoTestWrite()
334 RFileLogger theFlogger;
337 ret = theFlogger.Connect(); //Just to clear the old log message
339 ret = theFlogger.SetLogTags(KStdSubsysTag8,KStdCompTag8);
341 ret = theFlogger.ClearLog();
347 _LIT8(KDescText,"TC 17_2:Test Msg");
349 //Write the test datas in the hexa format
350 RFileLogger::HexDump(KStdSubsysTag8,KStdCompTag8, KDescText, KEightSpaces8);
359 * Function Name : DoTestCheckWriteL
360 * Input parameters : None
361 * Output parameters : TInt
362 * Description : This function checks the weather test data was written
363 * in to the log file by DoTestWrite() or not.
368 TInt CFloggerTest017_02::DoTestCheckWriteL()
370 User::After(KTimeToLog);
375 RFs fileSystem; //For file operation create a file system
376 TBuf8<256> testData; //To hold the test descriptor
377 _LIT(KLogFile,"c:\\logs\\log.txt"); // the log file path
379 _LIT8(KOOMError, "#Logs may be lost out of memory!!"); // Error message
381 User::LeaveIfError(fileSystem.Connect());
383 //Open the file in the read mode
384 User::LeaveIfError(theFile.Open(fileSystem,KLogFile,EFileRead));
386 CleanupClosePushL(theFile);
388 User::LeaveIfError(returnCode = theFile.Size(listfilesize)); //Size of the file
389 hBuffer = HBufC8::New(listfilesize); //Allocate the buffer
390 CleanupStack::PushL(hBuffer);
391 TPtr8 ptrString = hBuffer->Des(); ; //To hold the buffer
393 // Read from position 0: start of file
394 returnCode = theFile.Read(ptrString);
397 testData.Copy(KEightSpaces8); //Copy the test descriptor
398 returnCode = ptrString.Find(testData); //find the test descriptor in the buffer read
401 if (returnCode == KErrNotFound) // Check for the error message in the log
403 returnCode = ptrString.Find(KOOMError);
405 User::Leave(KErrNoMemory);
408 CleanupStack::PopAndDestroy(hBuffer);
409 CleanupStack::PopAndDestroy(); //theFile
419 * Function Name : CFloggerTest017_03
420 * Input parameters : None
421 * Output parameters : None
422 * Description : This is the constructor
423 * Description : This is the constructor
427 CFloggerTest017_03::CFloggerTest017_03()
429 // store the name of this test case
430 SetTestStepName(_L("step_017_03"));
435 * Function Name :~ CFloggerTest017_03
436 * Input parameters : None
437 * Output parameters : None
438 * Description : This is the Destructor
442 CFloggerTest017_03::~CFloggerTest017_03()
448 * Function Name : doTestStepL
449 * Input parameters : None
450 * Output parameters : TVerdict
451 * Description : This function returns weather the test case 017_03 has
457 TVerdict CFloggerTest017_03::doTestStepL( )
459 INFO_PRINTF1(_L("Step 017.03 called "));
461 if ( executeStepL() == KErrNone )
462 SetTestStepResult(EPass);
465 SetTestStepResult(EFail);
468 User::After(KTimeForDisplay1);
469 return TestStepResult();
474 * Function Name : executeStepL
475 * Input parameters : None
476 * Output parameters : TInt
477 * Description : This function writes the test data in to the log file
478 * This function check the test message is present in the
484 TInt CFloggerTest017_03::executeStepL( )
486 User::After(1000*1000); //Need this or connect will return KErrServerTerminated
487 TInt ret = KErrGeneral;
490 if (ret == KErrNone )
492 TRAPD(r, ret = DoTestCheckWriteL());
501 * Function Name : executeStepL
502 * Input parameters : None
503 * Output parameters : TInt
504 * Description : This function writes the test data in to the log file
505 * This function check the test message is present in the
511 TInt CFloggerTest017_03::executeStepL(TBool)
517 /* Function Name : DoTestWrite
518 * Input parameters : None
519 * Output parameters : TInt
520 * Description : This function writes the data to the file logger
525 TInt CFloggerTest017_03::DoTestWrite()
528 RFileLogger theFlogger;
531 ret = theFlogger.Connect(); //Just to clear the old log message
533 ret = theFlogger.SetLogTags(KStdSubsysTag8,KStdCompTag8);
535 ret = theFlogger.ClearLog();
541 _LIT8(KDescText,"TC 17_3:Test Msg"); //8 bit test descriptor
543 //Write the test datas in the hexa format
544 RFileLogger::HexDump(KStdSubsysTag8,KStdCompTag8, KDescText);
554 * Function Name : DoTestCheckWriteL
555 * Input parameters : None
556 * Output parameters : TInt
557 * Description : This function checks the weather test data was written
558 * in to the log file by DoTestWrite() or not.
563 TInt CFloggerTest017_03::DoTestCheckWriteL()
566 User::After(KTimeToLog);
571 RFs fileSystem; //For file operation create a file system
572 TBuf8<256> testData; //To hold the test descriptor
573 _LIT(KLogFile,"c:\\logs\\log.txt"); // the log file path
575 _LIT8(KBodyTxt,"TC 17_3:Test Msg");// Test body descriptor
577 User::LeaveIfError(fileSystem.Connect());
579 //Open the file in the read mode
580 User::LeaveIfError(theFile.Open(fileSystem,KLogFile,EFileRead));
581 CleanupClosePushL(theFile);
583 User::LeaveIfError(returnCode = theFile.Size(listfilesize)); //Size of the file
584 hBuffer = HBufC8::New(listfilesize); //Allocate the buffer
585 CleanupStack::PushL(hBuffer);
586 TPtr8 ptrString = hBuffer->Des(); ; //To hold the buffer
588 // Read from position 0: start of file
589 returnCode=theFile.Read(ptrString);
591 testData.Copy(KBodyTxt); //Copy the test descriptor
592 returnCode=ptrString.Find(testData); //find the test descriptor in the buffer read
595 if (returnCode == KErrNotFound) //Find the error message
597 returnCode = ptrString.Find(KErrOOM);
599 User::Leave(KErrNoMemory);
602 CleanupStack::PopAndDestroy(hBuffer);
603 CleanupStack::PopAndDestroy(); //theFile object
613 * Function Name : CFloggerTest017_04
614 * Input parameters : None
615 * Output parameters : None
616 * Description : This is the constructor
620 CFloggerTest017_04::CFloggerTest017_04()
622 // store the name of this test case
623 SetTestStepName(_L("step_017_04"));
628 * Function Name :~ CFloggerTest017_04
629 * Input parameters : None
630 * Output parameters : None
631 * Description : This is the Destructor
635 CFloggerTest017_04::~CFloggerTest017_04()
640 * Function Name : doTestStepL
641 * Input parameters : None
642 * Output parameters : TVerdict
643 * Description : This function returns weather the test case 017_04 has
649 TVerdict CFloggerTest017_04::doTestStepL( )
651 INFO_PRINTF1(_L("Step 017.04 called "));
653 if ( executeStepL() == KErrNone )
654 SetTestStepResult(EPass);
657 SetTestStepResult(EFail);
660 User::After(KTimeForDisplay1);
661 return TestStepResult();
666 * Function Name : executeStepL
667 * Input parameters : None
668 * Output parameters : TInt
669 * Description : This function writes the test data in to the log file
670 * This function check the test message is present in the
676 TInt CFloggerTest017_04::executeStepL( )
678 User::After(1000*1000); //Need this or connect will return KErrServerTerminated
679 TInt ret = KErrGeneral;
682 if (ret == KErrNone )
684 TRAPD(r, ret = DoTestCheckWriteL());
692 * Function Name : executeStepL
693 * Input parameters : None
694 * Output parameters : TInt
695 * Description : This function writes the test data in to the log file
696 * This function check the test message is present in the
702 TInt CFloggerTest017_04::executeStepL(TBool)
708 * Function Name : DoTestWrite
709 * Input parameters : None
710 * Output parameters : TInt
711 * Description : This function writes the data to the file logger
716 TInt CFloggerTest017_04::DoTestWrite()
718 _LIT8(KDescText,"TC 17_4:Test Msg");
720 RFileLogger theFlogger;
722 ret = theFlogger.Connect(); //Just to clear the old log message
724 ret = theFlogger.SetLogTags(KStdSubsysTag8,KStdCompTag8);
726 ret = theFlogger.ClearLog();
731 //Write the test datas in the hexa format
732 RFileLogger::HexDump(KStdSubsysTag8,KStdCompTag8, KDescText, KNullDesC8);
741 * Function Name : DoTestCheckWriteL
742 * Input parameters : None
743 * Output parameters : TInt
744 * Description : This function checks the weather test data was written
745 * in to the log file by DoTestWrite() or not.
750 TInt CFloggerTest017_04::DoTestCheckWriteL()
752 User::After(KTimeToLog);
757 RFs fileSystem; //For file operation create a file system
758 TBuf8<256> testData; //To hold the test descriptor
759 _LIT(KLogFile,"c:\\logs\\log.txt"); // the log file path
761 _LIT(KBodyTxt,"TC 17_4:Test Msg");// Test body descriptor
762 TUint numSuccessful = 0;
764 User::LeaveIfError(fileSystem.Connect());
766 //Open the file in the read mode
767 User::LeaveIfError(theFile.Open(fileSystem,KLogFile,EFileRead));
768 CleanupClosePushL(theFile);
770 User::LeaveIfError(returnCode = theFile.Size(listfilesize)); //Size of the file
771 hBuffer = HBufC8::New(listfilesize); //Allocate the buffer
772 CleanupStack::PushL(hBuffer);
773 TPtr8 ptrString = hBuffer->Des(); ; //To hold the buffer
775 // Read from position 0: start of file
776 returnCode = theFile.Read(ptrString);
779 testData.Copy(KBodyTxt); //Copy the test descriptor
780 returnCode=ptrString.Find(testData); //find the test descriptor in the buffer read
786 returnCode=ptrString.Find(KHexTestHeader); //find the test descriptor in the buffer read
788 if (returnCode == KErrNotFound)
792 if (returnCode == KErrNotFound) //Find the error message
794 returnCode = ptrString.Find(KErrOOM);
796 User::Leave(KErrNoMemory);
799 CleanupStack::PopAndDestroy(hBuffer);
800 CleanupStack::PopAndDestroy(); //theFile object
802 if (numSuccessful == 2)
812 * Function Name : CFloggerTest017_05
813 * Input parameters : None
814 * Output parameters : None
815 * Description : This is the constructor
819 CFloggerTest017_05::CFloggerTest017_05()
821 // store the name of this test case
822 SetTestStepName(_L("step_017_05"));
827 * Function Name :~ CFloggerTest017_05
828 * Input parameters : None
829 * Output parameters : None
830 * Description : This is the Destructor
834 CFloggerTest017_05::~CFloggerTest017_05()
839 * Function Name : doTestStepL
840 * Input parameters : None
841 * Output parameters : TVerdict
842 * Description : This function returns weather the test case 017_05 has
848 TVerdict CFloggerTest017_05::doTestStepL( )
850 INFO_PRINTF1(_L("Step 017.05 called "));
852 if ( executeStepL() == KErrNone )
853 SetTestStepResult(EPass);
856 SetTestStepResult(EFail);
859 User::After(KTimeForDisplay1);
860 return TestStepResult();
864 * Function Name : executeStepL
865 * Input parameters : None
866 * Output parameters : TInt
867 * Description : This function writes the test data in to the log file
868 * This function check the test message is present in the
874 TInt CFloggerTest017_05::executeStepL(TBool)
879 * Function Name : executeStepL
880 * Input parameters : None
881 * Output parameters : TInt
882 * Description : This function writes the test data in to the log file
883 * This function check the test message is present in the
889 TInt CFloggerTest017_05::executeStepL( )
891 User::After(KTimeToLog); //Need this or connect will return KErrServerTerminated
892 TInt ret = KErrGeneral;
895 if (ret == KErrNone )
897 TRAPD(r, ret = DoTestCheckWriteL());
906 * Function Name : DoTestWrite
907 * Input parameters : None
908 * Output parameters : TInt
909 * Description : This function writes the data to the file logger
914 TInt CFloggerTest017_05::DoTestWrite()
916 RFileLogger theFlogger;
919 ret = theFlogger.Connect(); //Just to clear the old log message
921 ret = theFlogger.SetLogTags(KStdSubsysTag8,KStdCompTag8);
923 ret = theFlogger.ClearLog();
929 //Write the test datas in the hexa format
930 RFileLogger::HexDump(KStdSubsysTag8,KStdCompTag8, KNullDesC8);
938 * Function Name : DoTestCheckWriteL
939 * Input parameters : None
940 * Output parameters : TInt
941 * Description : This function checks the weather test data was written
942 * in to the log file by DoTestWrite() or not.
947 TInt CFloggerTest017_05::DoTestCheckWriteL()
949 User::After(KTimeToLog);
954 RFs fileSystem; //For file operation create a file system
955 _LIT(KLogFile,"c:\\logs\\log.txt"); // the log file path
956 _LIT8(KExpectedString,"0000 :");
958 _LIT8(KOOMError, "#Logs may be lost out of memory!!"); //Error message
960 User::LeaveIfError(fileSystem.Connect());
962 //Open the file in the read mode
963 User::LeaveIfError(theFile.Open(fileSystem,KLogFile,EFileRead));
964 CleanupClosePushL(theFile);
967 User::LeaveIfError(returnCode = theFile.Size(listfilesize)); //Size of the file
968 hBuffer = HBufC8::New(listfilesize); //Allocate the buffer
969 CleanupStack::PushL(hBuffer);
970 TPtr8 ptrString = hBuffer->Des(); ; //To hold the buffer
972 // Read from position 0: start of file
973 returnCode = theFile.Read(ptrString);
975 //check for no OOM msg
976 returnCode = ptrString.Find(KOOMError);
979 User::Leave(KErrNoMemory);
983 // we expect the output to be pretty blank, so not much to search for
984 // except make sure the standard "0000: " ins't even there
985 returnCode = ptrString.Find(KExpectedString); //find the test descriptor in the buffer read
988 CleanupStack::PopAndDestroy(hBuffer);
989 CleanupStack::PopAndDestroy(); //theFile object
990 if (returnCode == KErrNotFound)
999 * Function Name : CFloggerTest017_06
1000 * Input parameters : None
1001 * Output parameters : None
1002 * Description : This is the constructor
1006 CFloggerTest017_06::CFloggerTest017_06()
1008 // store the name of this test case
1009 SetTestStepName(_L("step_017_06"));
1014 * Function Name :~ CFloggerTest017_06
1015 * Input parameters : None
1016 * Output parameters : None
1017 * Description : This is the Destructor
1021 CFloggerTest017_06::~CFloggerTest017_06()
1027 * Function Name : doTestStepL
1028 * Input parameters : None
1029 * Output parameters : TVerdict
1030 * Description : This function is responsible for doing the heap test analysis
1036 TVerdict CFloggerTest017_06::doTestStepL( )
1038 INFO_PRINTF1(_L("Step 017.06 called "));
1040 CFloggerTest017_01* step017_01 = new CFloggerTest017_01;
1041 CleanupStack::PushL(step017_01);
1042 doTestStepWithHeapFailureL( *step017_01, 1, 20, KErrNone, ETrue);
1044 CleanupStack::PopAndDestroy(step017_01);
1045 User::After(KTimeForDisplay);
1046 return TestStepResult();