|
1 /* |
|
2 * Copyright (c) 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: STIF hardcoded module declaration |
|
15 * |
|
16 */ |
|
17 |
|
18 #ifndef HARDCODEDTESTMODULEXXX_H |
|
19 #define HARDCODEDTESTMODULEXXX_H |
|
20 |
|
21 // INCLUDES |
|
22 #include "StifTestModule.h" |
|
23 #include <StifLogger.h> |
|
24 #include <NormalHardcodedAssert.h> |
|
25 |
|
26 // CONSTANTS |
|
27 //const ?type ?constant_var = ?constant; |
|
28 |
|
29 // MACROS |
|
30 //#define ?macro ?macro_def |
|
31 #define TEST_MODULE_VERSION_MAJOR 0 |
|
32 #define TEST_MODULE_VERSION_MINOR 0 |
|
33 #define TEST_MODULE_VERSION_BUILD 0 |
|
34 |
|
35 // Logging path |
|
36 _LIT( KHardCodedTestModuleXXXLogPath, "\\logs\\testframework\\HardCodedTestModuleXXX\\" ); |
|
37 // Log file |
|
38 _LIT( KHardCodedTestModuleXXXLogFile, "HardCodedTestModuleXXX.txt" ); |
|
39 _LIT( KHardCodedTestModuleXXXLogFileWithTitle, "HardCodedTestModuleXXX_[%S].txt" ); |
|
40 |
|
41 #define GETPTR & |
|
42 #define ENTRY(str,func) {_S(str), GETPTR func,0,0,0} |
|
43 #define FUNCENTRY(func) {_S(#func), GETPTR func,0,0,0} |
|
44 #define OOM_ENTRY(str,func,a,b,c) {_S(str), GETPTR func,a,b,c} |
|
45 #define OOM_FUNCENTRY(func,a,b,c) {_S(#func), GETPTR func,a,b,c} |
|
46 |
|
47 // FUNCTION PROTOTYPES |
|
48 //?type ?function_name(?arg_list); |
|
49 |
|
50 // FORWARD DECLARATIONS |
|
51 //class ?FORWARD_CLASSNAME; |
|
52 class CHardCodedTestModuleXXX; |
|
53 |
|
54 // DATA TYPES |
|
55 //enum ?declaration |
|
56 //typedef ?declaration |
|
57 //extern ?data_type; |
|
58 // A typedef for function that does the actual testing, |
|
59 // function is a type |
|
60 // TInt CHardCodedTestModuleXXX::<NameOfFunction> ( TTestResult& aResult ) |
|
61 typedef TInt (CHardCodedTestModuleXXX::* TestFunction)(TTestResult&); |
|
62 |
|
63 // CLASS DECLARATION |
|
64 |
|
65 /** |
|
66 * An internal structure containing a test case name and |
|
67 * the pointer to function doing the test |
|
68 * |
|
69 * @lib ?library |
|
70 * @since ?Series60_version |
|
71 */ |
|
72 class TCaseInfoInternal |
|
73 { |
|
74 public: |
|
75 const TText* iCaseName; |
|
76 TestFunction iMethod; |
|
77 TBool iIsOOMTest; |
|
78 TInt iFirstMemoryAllocation; |
|
79 TInt iLastMemoryAllocation; |
|
80 }; |
|
81 |
|
82 // CLASS DECLARATION |
|
83 |
|
84 /** |
|
85 * A structure containing a test case name and |
|
86 * the pointer to function doing the test |
|
87 * |
|
88 * @lib ?library |
|
89 * @since ?Series60_version |
|
90 */ |
|
91 class TCaseInfo |
|
92 { |
|
93 public: |
|
94 TPtrC iCaseName; |
|
95 TestFunction iMethod; |
|
96 TBool iIsOOMTest; |
|
97 TInt iFirstMemoryAllocation; |
|
98 TInt iLastMemoryAllocation; |
|
99 |
|
100 TCaseInfo( const TText* a ) : iCaseName( (TText*) a ) |
|
101 { |
|
102 }; |
|
103 |
|
104 }; |
|
105 |
|
106 |
|
107 // CLASS DECLARATION |
|
108 |
|
109 /** |
|
110 * This a HardCodedTestModuleXXX class. |
|
111 * ?other_description_lines |
|
112 * |
|
113 * @lib ?library |
|
114 * @since ?Series60_version |
|
115 */ |
|
116 NONSHARABLE_CLASS(CHardCodedTestModuleXXX) : public CTestModuleBase |
|
117 { |
|
118 public: // Constructors and destructor |
|
119 |
|
120 |
|
121 /** |
|
122 * Two-phased constructor. |
|
123 */ |
|
124 static CHardCodedTestModuleXXX* NewL(); |
|
125 |
|
126 /** |
|
127 * Destructor. |
|
128 */ |
|
129 virtual ~CHardCodedTestModuleXXX(); |
|
130 |
|
131 public: // New functions |
|
132 |
|
133 /** |
|
134 * ?member_description. |
|
135 * @since ?Series60_version |
|
136 * @param ?arg1 ?description |
|
137 * @return ?description |
|
138 */ |
|
139 //?type ?member_function( ?type ?arg1 ); |
|
140 |
|
141 public: // Functions from base classes |
|
142 |
|
143 /** |
|
144 * From CTestModuleBase InitL is used to initialize the |
|
145 * HardCodedTestModuleXXX. It is called once for every instance of |
|
146 * TestModuleXXX after its creation. |
|
147 * @since ?Series60_version |
|
148 * @param aIniFile Initialization file for the test module (optional) |
|
149 * @param aFirstTime Flag is true when InitL is executed for first |
|
150 * created instance of HardCodedTestModuleXXX. |
|
151 * @return Symbian OS error code |
|
152 */ |
|
153 TInt InitL( TFileName& aIniFile, TBool aFirstTime ); |
|
154 |
|
155 /** |
|
156 * From CTestModuleBase GetTestCasesL is used to inquiry test cases |
|
157 * from HardCodedTestModuleXXX. |
|
158 * @since ?Series60_version |
|
159 * @param aTestCaseFile Test case file (optional) |
|
160 * @param aTestCases Array of TestCases returned to test framework |
|
161 * @return Symbian OS error code |
|
162 */ |
|
163 TInt GetTestCasesL( const TFileName& aTestCaseFile, |
|
164 RPointerArray<TTestCaseInfo>& aTestCases ); |
|
165 |
|
166 /** |
|
167 * From CTestModuleBase RunTestCaseL is used to run an individual |
|
168 * test case. |
|
169 * @since ?Series60_version |
|
170 * @param aCaseNumber Test case number |
|
171 * @param aTestCaseFile Test case file (optional) |
|
172 * @param aResult Test case result returned to test framework (PASS/FAIL) |
|
173 * @return Symbian OS error code (test case execution error, which is |
|
174 * not reported in aResult parameter as test case failure). |
|
175 */ |
|
176 TInt RunTestCaseL( const TInt aCaseNumber, |
|
177 const TFileName& aTestCaseFile, |
|
178 TTestResult& aResult ); |
|
179 |
|
180 /** |
|
181 * From CTestModuleBase; OOMTestQueryL is used to specify is particular |
|
182 * test case going to be executed using OOM conditions |
|
183 * @param aTestCaseFile Test case file (optional) |
|
184 * @param aCaseNumber Test case number (optional) |
|
185 * @param aFailureType OOM failure type (optional) |
|
186 * @param aFirstMemFailure The first heap memory allocation failure value (optional) |
|
187 * @param aLastMemFailure The last heap memory allocation failure value (optional) |
|
188 * @return TBool |
|
189 */ |
|
190 virtual TBool OOMTestQueryL( const TFileName& /* aTestCaseFile */, |
|
191 const TInt /* aCaseNumber */, |
|
192 TOOMFailureType& aFailureType, |
|
193 TInt& /* aFirstMemFailure */, |
|
194 TInt& /* aLastMemFailure */ ); |
|
195 |
|
196 /** |
|
197 * From CTestModuleBase; OOMTestInitializeL may be used to initialize OOM |
|
198 * test environment |
|
199 * @param aTestCaseFile Test case file (optional) |
|
200 * @param aCaseNumber Test case number (optional) |
|
201 * @return None |
|
202 */ |
|
203 virtual void OOMTestInitializeL( const TFileName& /* aTestCaseFile */, |
|
204 const TInt /* aCaseNumber */ ); |
|
205 |
|
206 /** |
|
207 * From CTestModuleBase; OOMHandleWarningL |
|
208 * @param aTestCaseFile Test case file (optional) |
|
209 * @param aCaseNumber Test case number (optional) |
|
210 * @param aFailNextValue FailNextValue for OOM test execution (optional) |
|
211 * @return None |
|
212 * |
|
213 * User may add implementation for OOM test warning handling. Usually no |
|
214 * implementation is required. |
|
215 */ |
|
216 virtual void OOMHandleWarningL( const TFileName& /* aTestCaseFile */, |
|
217 const TInt /* aCaseNumber */, |
|
218 TInt& /* aFailNextValue */); |
|
219 |
|
220 /** |
|
221 * From CTestModuleBase; OOMTestFinalizeL may be used to finalize OOM |
|
222 * test environment |
|
223 * @param aTestCaseFile Test case file (optional) |
|
224 * @param aCaseNumber Test case number (optional) |
|
225 * @return None |
|
226 * |
|
227 */ |
|
228 virtual void OOMTestFinalizeL( const TFileName& /* aTestCaseFile */, |
|
229 const TInt /* aCaseNumber */ ); |
|
230 |
|
231 /** |
|
232 * Method used to log version of test module |
|
233 */ |
|
234 void SendTestModuleVersion(); |
|
235 |
|
236 protected: // New functions |
|
237 |
|
238 /** |
|
239 * ?member_description. |
|
240 * @since ?Series60_version |
|
241 * @param ?arg1 ?description |
|
242 * @return ?description |
|
243 */ |
|
244 //?type ?member_function( ?type ?arg1 ); |
|
245 |
|
246 protected: // Functions from base classes |
|
247 |
|
248 /** |
|
249 * From ?base_class ?member_description |
|
250 */ |
|
251 //?type ?member_function(); |
|
252 |
|
253 private: |
|
254 |
|
255 /** |
|
256 * C++ default constructor. |
|
257 */ |
|
258 CHardCodedTestModuleXXX(); |
|
259 |
|
260 /** |
|
261 * By default Symbian 2nd phase constructor is private. |
|
262 */ |
|
263 void ConstructL(); |
|
264 |
|
265 // Prohibit copy constructor if not deriving from CBase. |
|
266 // ?classname( const ?classname& ); |
|
267 // Prohibit assigment operator if not deriving from CBase. |
|
268 // ?classname& operator=( const ?classname& ); |
|
269 |
|
270 /** |
|
271 * Function returning test case name and pointer to test case function. |
|
272 * @since ?Series60_version |
|
273 * @param aCaseNumber test case number |
|
274 * @return TCaseInfo |
|
275 */ |
|
276 const TCaseInfo Case ( const TInt aCaseNumber ) const; |
|
277 |
|
278 /** |
|
279 * [test case declarations] - do not remove |
|
280 */ |
|
281 //ADD NEW METHOD DEC HERE" |
|
282 |
|
283 /** |
|
284 * Printing test case. |
|
285 * @since ?Series60_version |
|
286 * @param aResult Test case result (PASS/FAIL) |
|
287 * @return Symbian OS error code (test case execution error |
|
288 * that is not returned as test case result in aResult) |
|
289 */ |
|
290 TInt PrintTest( TTestResult& aResult ); |
|
291 |
|
292 /** |
|
293 * Printing loop test case. |
|
294 * @since ?Series60_version |
|
295 * @param aResult Test case result (PASS/FAIL) |
|
296 * @return Symbian OS error code (test case execution error |
|
297 * that is not returned as test case result in aResult) |
|
298 */ |
|
299 TInt LoopTest( TTestResult& aResult ); |
|
300 |
|
301 public: // Data |
|
302 // ?one_line_short_description_of_data |
|
303 //?data_declaration; |
|
304 |
|
305 protected: // Data |
|
306 // ?one_line_short_description_of_data |
|
307 //?data_declaration; |
|
308 |
|
309 private: // Data |
|
310 // Pointer to test (function) to be executed |
|
311 TestFunction iMethod; |
|
312 |
|
313 // Pointer to logger |
|
314 CStifLogger * iLog; |
|
315 |
|
316 // Normal logger |
|
317 CStifLogger* iStdLog; |
|
318 |
|
319 // Test case logger |
|
320 CStifLogger* iTCLog; |
|
321 |
|
322 // Flag saying if test case title should be added to log file name |
|
323 TBool iAddTestCaseTitleToLogName; |
|
324 |
|
325 // Flag saying if version of test module was already sent |
|
326 TBool iVersionLogged; |
|
327 |
|
328 // ?one_line_short_description_of_data |
|
329 //?data_declaration; |
|
330 |
|
331 // Reserved pointer for future extension |
|
332 //TAny* iReserved; |
|
333 |
|
334 public: // Friend classes |
|
335 //?friend_class_declaration; |
|
336 protected: // Friend classes |
|
337 //?friend_class_declaration; |
|
338 private: // Friend classes |
|
339 //?friend_class_declaration; |
|
340 |
|
341 }; |
|
342 |
|
343 #endif // HARDCODEDTESTMODULEXXX_H |
|
344 |
|
345 // End of File |