testexecmdw/tef/tef/utils/test/src/testexecuteloggingtest.cpp
branchRCL_3
changeset 3 9397a16b6eb8
parent 1 6edeef394eb7
equal deleted inserted replaced
1:6edeef394eb7 3:9397a16b6eb8
     1 /*
       
     2 * Copyright (c) 2005-2009 Nokia Corporation and/or its subsidiary(-ies).
       
     3 * All rights reserved.
       
     4 * This component and the accompanying materials are made available
       
     5 * under the terms of "Eclipse Public License v1.0"
       
     6 * which accompanies this distribution, and is available
       
     7 * at the URL "http://www.eclipse.org/legal/epl-v10.html".
       
     8 *
       
     9 * Initial Contributors:
       
    10 * Nokia Corporation - initial contribution.
       
    11 *
       
    12 * Contributors:
       
    13 *
       
    14 * Description:  
       
    15 * Unit test for TestExecuteUtils , CTestExecuteLogger
       
    16 * Code for logging over serial connection
       
    17 * please make sure the logging channel is set to 'Serial' or Both 
       
    18 * in the testexecute.ini file for this code to be able to cover the 
       
    19 * serial logging code...
       
    20 *
       
    21 */
       
    22 
       
    23 
       
    24 
       
    25 /**
       
    26  @file TestExecuteLoggingTest.cpp
       
    27 */
       
    28 #include <test/testexecutelogger.h>
       
    29 #include <e32cons.h>
       
    30 
       
    31 _LIT(K16BitText,"This is a short line of 16 Bit Text");
       
    32 _LIT8(K8BitText,"This is a short line of  8 Bit Text");
       
    33 _LIT(K16BitFormatText,"This is a short line of 16 Bit Format Text int = %d string = %S");
       
    34 _LIT8(K8BitFormatText,"This is a short line of  8 Bit Format Text int = %d string = %S");
       
    35 _LIT(K16BitString,"The String16");
       
    36 _LIT8(K8BitString,"The String8");
       
    37 
       
    38 
       
    39 LOCAL_C void TestWorkAPIsL(CTestExecuteLogger& aLogger,CConsoleBase*& aConsole)
       
    40 {
       
    41 
       
    42 	aConsole->Write(_L("Testing logger.Write(16BitText) \r\n"));
       
    43 	aLogger.Write(K16BitText);
       
    44 	
       
    45 	aConsole->Write(_L("Testing logger.Write(8BitText) \r\n"));
       
    46 	aLogger.Write(K8BitText);
       
    47 
       
    48 	aConsole->Write(_L("Testing logger.WriteFormat(16BitText) \r\n"));
       
    49 	TBuf<20> buf16(K16BitString);
       
    50 	aLogger.WriteFormat(K16BitFormatText,16,&buf16);
       
    51 
       
    52 	aConsole->Write(_L("Testing logger.WriteFormat(8BitText) \r\n"));
       
    53 	TBuf8<20> buf8(K8BitString);
       
    54 	aLogger.WriteFormat(K8BitFormatText,8,&buf8);
       
    55 
       
    56 	aConsole->Write(_L("Testing logger.LogExtra() \r\n"));
       
    57 	aLogger.LogExtra(((TText8*)__FILE__), __LINE__,ESevrInfo,K16BitFormatText,1,&buf16);
       
    58 
       
    59 	aConsole->Write(_L("Testing logger.PrintCurrentScriptLine() \r\n"));
       
    60 	TBuf<30> output(_L("Testing PrintCurrentScriptLine")) ; 
       
    61 	aLogger.PrintCurrentScriptLine(output) ; 
       
    62 	
       
    63 	aConsole->Write(_L("Testing logger.LogTestCaseResult() \r\n"));
       
    64 	TBuf<30> file(_L("TestExcuteLoggingTest.cpp"));
       
    65 	TInt lineNo(68) ; 
       
    66 	TBuf<20> testCsNm(_L("TestCaseSomething"));
       
    67 	aLogger.LogTestCaseResult(file, lineNo, ESevrInfo, KTEFEndTestCaseCommand, testCsNm);
       
    68 
       
    69 	aConsole->Write(_L("Testing logger.LogResult() \r\n"));
       
    70 	TBuf<30> panicStringbuf(_L("Panic string")) ; 
       
    71 	TBuf<30> fileRes(_L("TestExcuteLoggingTest.cpp"));
       
    72 	TInt lineNum(70) ; 
       
    73 	TInt severity(RFileFlogger::ESevrHigh) ; 
       
    74 
       
    75 	aLogger.LogResult(EPass,panicStringbuf,lineNum,KTEFRunTestStepCommand,fileRes,RFileFlogger::ESevrHigh);
       
    76 }
       
    77 
       
    78 
       
    79 LOCAL_C void MainL()
       
    80 	{
       
    81 	_LIT(KTitle,"TestExecuteLogger Test Code for serial logging");
       
    82 	CConsoleBase* console = Console::NewL(KTitle,TSize(KConsFullScreen,KConsFullScreen));
       
    83 	CleanupStack::PushL(console);
       
    84 	CTestExecuteLogger logger;
       
    85 
       
    86 	TInt logLevel =1  ;
       
    87 	TBool separateLogFiles(EFalse); 
       
    88 	_LIT(KScriptPath,"E:\\plattest\\Selective.script");
       
    89 	TPtrC scriptFilePath(KScriptPath);
       
    90 
       
    91 	console->Write(_L("logger.InitialiseLoggingL next2 \n")) ; 
       
    92 	logger.InitialiseLoggingL(scriptFilePath, separateLogFiles, logLevel);
       
    93 	
       
    94 	console->Write(_L("post logger.InitialiseLoggingL next \n"));
       
    95 	TestWorkAPIsL(logger, console)	;
       
    96 	
       
    97 	console->Write(_L("attempting TerminateLoggingL \n")) ; 
       
    98 	logger.TerminateLoggingL(3, 4, 3); //suggested by todays fortune cookie...
       
    99 
       
   100 	console->Write(_L("Done testing, press a key to finish \n")) ; 
       
   101 	console->Getch() ; 
       
   102 	CleanupStack::PopAndDestroy(console);	
       
   103 	}
       
   104 
       
   105 // Entry point for all Epoc32 executables
       
   106 // See PSP Chapter 2 Getting Started
       
   107 GLDEF_C TInt E32Main()
       
   108 	{
       
   109 	// Heap balance checking
       
   110 	// See PSP Chapter 6 Error Handling
       
   111 	__UHEAP_MARK;
       
   112 	CTrapCleanup* cleanup = CTrapCleanup::New();
       
   113 	if(cleanup == NULL)
       
   114 		{
       
   115 		return KErrNoMemory;
       
   116 		}
       
   117 	TRAPD(err,MainL());
       
   118 	_LIT(KPanic,"LoggingTest");
       
   119 	__ASSERT_ALWAYS(!err, User::Panic(KPanic,err));
       
   120 	delete cleanup;
       
   121 	__UHEAP_MARKEND;
       
   122 	return KErrNone;
       
   123     }