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