|
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 the License "Symbian Foundation License v1.0" to Symbian Foundation members and "Symbian Foundation End User License Agreement v1.0" to non-members |
|
6 * which accompanies this distribution, and is available |
|
7 * at the URL "http://www.symbianfoundation.org/legal/licencesv10.html". |
|
8 * |
|
9 * Initial Contributors: |
|
10 * Nokia Corporation - initial contribution. |
|
11 * |
|
12 * Contributors: |
|
13 * |
|
14 * Description: |
|
15 * |
|
16 */ |
|
17 |
|
18 |
|
19 /** |
|
20 @file TestExecuteLogger.h |
|
21 */ |
|
22 |
|
23 #if !(defined __TESTEXECUTE_LOGGER_H__) |
|
24 #define __TESTEXECUTE_LOGGER_H__ |
|
25 |
|
26 #include <e32base.h> |
|
27 #include <e32cons.h> |
|
28 #include <f32file.h> |
|
29 #include <test/testexecutelogbase.h> |
|
30 #include <iniparser.h> |
|
31 #include <test/blockitems.h> |
|
32 #include <test/tefscriptutils.h> |
|
33 |
|
34 class CSerialWriter; |
|
35 /** |
|
36 * @internalComponent |
|
37 * @test |
|
38 */ |
|
39 class CTestExecuteIniData : public CBase |
|
40 { |
|
41 public: |
|
42 IMPORT_C CTestExecuteIniData(); |
|
43 IMPORT_C ~CTestExecuteIniData(); |
|
44 IMPORT_C static CTestExecuteIniData* NewL(); |
|
45 IMPORT_C static CTestExecuteIniData* NewLC(); |
|
46 IMPORT_C void ConstructL(); |
|
47 IMPORT_C void ExtractValuesFromIni(); |
|
48 IMPORT_C void GetKeyValueFromIni(const TDesC& aKeyName, TDes& aValue); |
|
49 IMPORT_C void GetKeyValueFromIni(const TDesC& aKeyName, TInt& aValue); |
|
50 IMPORT_C CTestExecuteIniData(TDriveName& aSysDrive); |
|
51 IMPORT_C static CTestExecuteIniData* NewL(TDriveName& aSysDrive); |
|
52 IMPORT_C static CTestExecuteIniData* NewLC(TDriveName& aSysDrive); |
|
53 private: |
|
54 CIniData* iConfigData; |
|
55 TPtrC iHtmlLogPath; |
|
56 TPtrC iXmlLogPath; |
|
57 TPtrC iDefaultScriptDirectory; |
|
58 TInt iLogSeverity; |
|
59 TInt iLoggerOptions; |
|
60 TInt iJustInTime; |
|
61 TInt iRemotePanicDetection; |
|
62 TInt iEnableIniAccessLog; |
|
63 TInt iEnableTestsCountLog; |
|
64 TInt iEnableSystemStarter; |
|
65 TInt iLoggerChannel; |
|
66 TInt iPortNumber; |
|
67 TDriveName iDefaultSysDrive; |
|
68 TPtrC iIniSysDriveName; |
|
69 TInt iWaitForLoggingTime; |
|
70 }; |
|
71 |
|
72 /** |
|
73 * Override of base class virtual for TEF logger implementation |
|
74 * @internalComponent |
|
75 * @test |
|
76 */ |
|
77 class CTestExecuteLogger : public MTestExecuteLogBase |
|
78 { |
|
79 public: |
|
80 IMPORT_C CTestExecuteLogger(TLoggerOptions aLogOptions=ELogHTMLOnly); |
|
81 IMPORT_C ~CTestExecuteLogger(); |
|
82 IMPORT_C void LogExtra(const TText8* aFile, TInt aLine, TInt aSeverity,TRefByValue<const TDesC> aFmt,...); |
|
83 IMPORT_C void LogToXml(const TText8* aFile, TInt aLine, TInt aSeverity,const TDesC& aCommandName, const TInt aNumberOfParams, TExtraLogField* aLogFields); |
|
84 IMPORT_C void LogToXml(const TText8* aFile, TInt aLine, TInt aSeverity,const TDesC& aCommandName); |
|
85 IMPORT_C void InitialiseLoggingL(const TDesC& aScriptFilePath, TBool aSeparateLogFileMode, TInt aLogLevel); |
|
86 |
|
87 IMPORT_C void TerminateLoggingL(const TInt aCommentedCommandsCount, const TInt aRemotePanicsCount, const TInt aRunScriptFailCount); |
|
88 IMPORT_C void LogTestCaseResult(const TDesC& aFile, TInt aLine, TInt aSeverity, const TDesC& aCommand, const TDesC& aTestCaseName, TVerdict aResult = EPass); |
|
89 IMPORT_C void PrintCurrentScriptLine(TDes& aCurrentScriptLine); |
|
90 IMPORT_C void LogResult(TVerdict aResult, const TDesC& aPanicString, TInt aScriptLineNumber,const TDesC& aCommand,const TDesC& aScriptFile,TInt aSeverity); |
|
91 IMPORT_C TVerdict LogBlock( TTEFItemArray* aItemArray, const TInt aScriptLineNumber ); |
|
92 IMPORT_C void SetLoggerOptions(TInt aLogMode); |
|
93 IMPORT_C TInt Connect(); |
|
94 IMPORT_C void Close(); |
|
95 inline RTestExecuteLogServ& HtmlLogger() { return iHtmlLogger; }; |
|
96 inline RTestExecutePIPSLogServ& PIPSLogger() { return iPIPSLogger; }; |
|
97 inline RFileFlogger& XmlLogger() { return iXmlLogger; }; |
|
98 IMPORT_C TInt ShareAuto(); |
|
99 |
|
100 // Legacy methods provided for backwards compatibility |
|
101 // These only log to the html log file |
|
102 IMPORT_C void Write(const TDesC& aLogBuffer); |
|
103 IMPORT_C void WriteFormat(TRefByValue<const TDesC> aFmt,...); |
|
104 IMPORT_C void Write(const TDesC8& aLogBuffer); |
|
105 IMPORT_C void WriteFormat(TRefByValue<const TDesC8> aFmt,...); |
|
106 IMPORT_C static CTestExecuteLogger* NewL(TLoggerOptions aLogOptions=ELogHTMLOnly); |
|
107 IMPORT_C static CTestExecuteLogger* NewLC(TLoggerOptions aLogOptions=ELogHTMLOnly); |
|
108 IMPORT_C void SetLoggerChannel(TInt aLogChannel); |
|
109 IMPORT_C void SetPipeName(TPtrC& aPipeName) ; |
|
110 void OpenSerialPortL(const TInt aPortNumber); |
|
111 protected: |
|
112 // parse the script string(!PanicString) |
|
113 TBool ParsePaincStringFromScriptCommandLine(const TDesC& aCommandStr,TLex& aScriptLineParamLex,TDes& aTEFPanicString); |
|
114 private: |
|
115 // Connects to the HTML log client session and creating the logs with initial tags for logging |
|
116 void InitialiseHTMLLoggingL(const TDesC& aLogFilePath, TInt aLogLevel, const TInt& aEnableCommandCount, CScriptPreProcess& aScriptPreProcess); |
|
117 void InitialisePIPSLoggingL(TInt aLogLevel, const TInt& aEnableCommandCount, CScriptPreProcess& aScriptPreProcess); |
|
118 // Connects to the XML log client session and creates the logs in the path passed in |
|
119 // Also sets in the default threshold for log level |
|
120 void InitialiseXMLLoggingL(const TDesC& aLogFilePath, TInt aLogLevel, const TInt& aEnableCommandCount, CScriptPreProcess& aScriptPreProcess); |
|
121 void TerminateHTMLLoggingL(RFile* aLogFile, const TInt aCommentedCommandsCount, const TInt aRemotePanicsCount, const TInt aRunScriptFailCount); |
|
122 void TerminateXMLLoggingL(const TInt aCommentedCommandsCount, const TInt aRemotePanicsCount, const TInt aRunScriptFailCount); |
|
123 TVerdict LogHTMLBlockL( const TTEFItemArray& aItemArray ); |
|
124 TVerdict LogXMLBlock( const TTEFItemArray& aItemArray, const TInt aScriptLineNumber ); |
|
125 void InitialiseSerialLoggingL(TInt aLogLevel, const TInt& aEnableCommandCount, CScriptPreProcess& aScriptPreProcess, TInt portNumber); |
|
126 void LogTestCaseResultSerialL(const TDesC& aFile, TInt aLine, TInt aSeverity, const TDesC& aCommand, const TDesC& aTestCaseName, TVerdict aResult = EPass); |
|
127 void LogResultSerialL(TVerdict aResult, const TDesC& aPanicString, TInt aScriptLineNumber,const TDesC& aCommand,const TDesC& aScriptFile); |
|
128 void LogResultFileL(TVerdict aResult, const TDesC& aPanicString, TInt aScriptLineNumber,const TDesC& aCommand,const TDesC& aScriptFile, TInt aSeverity); |
|
129 void LoggingTestCaseResultToSummaryResultL( const TDesC &aLogFileDir,const TDesC &aLogFileName,const TDesC8 &aResultBuf); |
|
130 |
|
131 private: |
|
132 // HTML Log client session |
|
133 RTestExecuteLogServ iHtmlLogger; |
|
134 RTestExecutePIPSLogServ iPIPSLogger; |
|
135 // XML Log client session |
|
136 RFileFlogger iXmlLogger; |
|
137 TInt iLoggerOptions; |
|
138 // Member variables to perform TerminateLogging |
|
139 // Set up some vars for the test step result types |
|
140 TInt iPassCount; |
|
141 TInt iFailCount; |
|
142 TInt iAbortCount; |
|
143 TInt iUnknownCount; |
|
144 TInt iInconclusiveCount; |
|
145 TInt iPanicCount; |
|
146 TInt iUnexecutedCount; |
|
147 |
|
148 // Set up some vars for the RUN_PROGRAM result types |
|
149 TBool iRunProgramUsed; |
|
150 TInt iRunProgramPassCount; |
|
151 TInt iRunProgramFailCount; |
|
152 TInt iRunProgramAbortCount; |
|
153 TInt iRunProgramUnknownCount; |
|
154 TInt iRunProgramInconclusiveCount; |
|
155 TInt iRunProgramPanicCount; |
|
156 TInt iRunProgramUnexecutedCount; |
|
157 |
|
158 // Set up some vars for the testcase result types |
|
159 TBool iTestCasesUsed; |
|
160 TInt iTestCasePassCount; |
|
161 TInt iTestCaseFailCount; |
|
162 TInt iTestCaseInconclusiveCount; |
|
163 |
|
164 // Log file paths for HTML & XML |
|
165 TBuf<KMaxTestExecuteNameLength> iHtmlLogPath; |
|
166 TBuf<KMaxTestExecuteNameLength> iXmlLogPath; |
|
167 TInt iRemotePanic; // Flag to retrieve status of Remote Panic Detection from testexecute.ini |
|
168 TInt iRunScriptCommandCount; // Count of number of RUN_SCRIPT commands in the main script executed |
|
169 CSerialWriter *iSerialWriter ; |
|
170 TInt iPortNumber ; |
|
171 TInt iLoggerChannel; |
|
172 TInt iTestCaseSkippedCount; |
|
173 TBool iPIPSExists ; |
|
174 }; |
|
175 |
|
176 #endif |