|
1 // Copyright (c) 2007-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". |
|
7 // |
|
8 // Initial Contributors: |
|
9 // Nokia Corporation - initial contribution. |
|
10 // |
|
11 // Contributors: |
|
12 // |
|
13 // Description: |
|
14 // The declaration of the CTSY integration test suite base class. |
|
15 // |
|
16 // |
|
17 |
|
18 /** |
|
19 @internalTechnology |
|
20 */ |
|
21 |
|
22 #ifndef __CCTSYINTEGRATIONTESTSUITEBASE_H__ |
|
23 #define __CCTSYINTEGRATIONTESTSUITEBASE_H__ |
|
24 |
|
25 #include <test/testexecutestepbase.h> |
|
26 |
|
27 #include <etelmm.h> |
|
28 #include <etelpckt.h> |
|
29 |
|
30 #include "tetelrequeststatus.h" |
|
31 #include "rpsownnumbers.h" |
|
32 #include "townnumbersmanager.h" |
|
33 #include "rpsasciirqstdefs.h" |
|
34 |
|
35 class CEtelSessionMgr; |
|
36 |
|
37 /** |
|
38 Test result allocation: |
|
39 |
|
40 EInconclusive: (INCONCLUSIVE) |
|
41 - The test can't be run because the HW, LTSY, SIM or Network |
|
42 doesn't support a require functionality or capability. |
|
43 Example: Call waiting indicator test and the SIM doesn't |
|
44 support call waiting. |
|
45 - The test setup can't be completed due to an expected error. |
|
46 Example: the test setup requires to have a active call but |
|
47 this call can't be connected because the network is too busy. |
|
48 No actions require, the test is correct and may pass on others |
|
49 condition/configuration. |
|
50 |
|
51 ETestSuiteError: (UNKNOWN) |
|
52 - The test setup can't be completed due to an unexpected error |
|
53 or leave. Example: the test setup requires to have a line |
|
54 status change notification active but the call to activate |
|
55 this notification returned an error. |
|
56 There is a problem with the test setup that must be investigated. |
|
57 |
|
58 EIgnore: (UNEXECUTED) |
|
59 - The test fails for a known reason, but it cannot be fixed in |
|
60 the near future. Example: there is a known problem with the |
|
61 baseband that makes the test fail. |
|
62 |
|
63 EAbort: (ABORT) |
|
64 - Generated by TEF when a test timeout |
|
65 */ |
|
66 |
|
67 /************************************************************************************* |
|
68 INSTRUCTIONS on good use of MACROS! |
|
69 |
|
70 1) Only use CHECK_XXX macros between SET UP and SET UP END sections of doTestStepL. |
|
71 2) Only use ASSERT_XXXX macros in procedure section of doTestStepL I.e. Between TEST START and TEST END. |
|
72 3) Use ASSERT_EQUALS_XX where possible as this will automatically log out actual and expected values on failure. |
|
73 4) Do not use ASSERT_TRUE for testing equality of simple types. This is because on failure it will not data. Prefer ASSERT_EQUALS_XX instead. |
|
74 5) Comparison of complex types (e.g. TMobileCallInfoV1) can either be compared on each field (so would use ASSERT_EQUALS_XX) or a comparator obect can be created |
|
75 and ASSERT_TRUE used. E.g ASSERT_TRUE(cmpObj.IsEqual(ELogError), _L("Failed kkk")); |
|
76 6) If comparator object is used the IsEquals() should be passed ELogError to ensure data is logged on failure. |
|
77 *************************************************************************************/ |
|
78 |
|
79 |
|
80 |
|
81 /** |
|
82 description: ASSERT_EQUALS may be used to test equality of two values. <result> argument may also be an expression returning a simple type. |
|
83 usage: For testing equality of simple types, e.g. TInt, TBool, TReal, caps, enums. |
|
84 exceptions: Not for use for testing equality of complex types e.g TMobileCallInfoV1. Use ASSERT_TRUE with a TCmpBase derived comparator class |
|
85 exceptions: Not for use for testing equality of descriptors. See ASSERT_EQUALS_DES8 and ASSERT_EQUALS_DES16. |
|
86 logging: when comparison fails macro will log out the actual and expected values that have been compared. |
|
87 E.g. "FAILURE: Got 0, Expected 3 : my error22." |
|
88 example: ASSERT_EQUALS(RMobileCall::EMulticallNotSupported, RMobileCall::EMulticallNotSupported, _L("my error4.")); |
|
89 example: ASSERT_EQUALS(DoSomething(), 3, _L("my error22.")); |
|
90 example: ASSERT_EQUALS(-5, KErrNotSupported, _L("my error4.")); |
|
91 |
|
92 @param result. simple value to compare |
|
93 @param expected. expected value to test against |
|
94 @param msg. string to print out if comaprison fails. |
|
95 */ |
|
96 #define ASSERT_EQUALS(result, expected, msg) \ |
|
97 { \ |
|
98 if(!assert_equals(Logger(),((TText8*)__FILE__), __LINE__, ESevrErr, result, expected, msg)) \ |
|
99 { \ |
|
100 SetAssertResult(); \ |
|
101 } \ |
|
102 } |
|
103 |
|
104 |
|
105 /** |
|
106 description: ASSERT_EQUALS_DES8 may be used to test equality of two 8-bit descriptors. <result> argument may also be an expression returning a 8-bit descriptor. |
|
107 usage: For testing equality of 8-bit descriptors e.g. TDes8, TDesC8, TBuf8. |
|
108 exception: Not for use for testing equality of complex types e.g TMobileCallInfoV1. Use ASSERT_TRUE with a TCmpBase derived comparator class |
|
109 exception: Not for use for testing equality simple types. See ASSERT_EQUALS. |
|
110 exception: Not for use for testing equality of 16-bit descriptors. See ASSERT_EQUALS_DES16. |
|
111 logging: when comparison fails macro will log out the actual and expected values that have been compared. |
|
112 E.g. "FAILURE: Got bbbbbbbbbbbbbbbbbbbb, Expected cccccccccccccccccccc : my error44." |
|
113 Logging will truncate logged strings to length KMaxLogCharLength. |
|
114 example: ASSERT_EQUALS_DES8(buf1, buf2, _L("my error4.")); |
|
115 |
|
116 @param result. TDes8 value to compare |
|
117 @param expected. expected value to test against |
|
118 @param msg. string to print out if comaprison fails. |
|
119 */ |
|
120 #define ASSERT_EQUALS_DES8(result, expected, msg) \ |
|
121 { \ |
|
122 if(!assert_equals_des8(Logger(),((TText8*)__FILE__), __LINE__, ESevrErr, result, expected, msg)) \ |
|
123 { \ |
|
124 SetAssertResult(); \ |
|
125 } \ |
|
126 } |
|
127 |
|
128 |
|
129 /** |
|
130 description: ASSERT_EQUALS_DES16 may be used to test equality of two 16-bit descriptors. <result> argument may also be an expression returning a 16-bit descriptor. |
|
131 usage: For testing equality of 16-bit descriptors e.g. TDes16, TDesC16, TBuf16. |
|
132 exception: Not for use for testing equality of complex types e.g TMobileCallInfoV1. Use ASSERT_TRUE with a TCmpBase derived comparator class |
|
133 exception: Not for use for testing equality simple types. See ASSERT_EQUALS. |
|
134 exception: Not for use for testing equality of 8-bit descriptors. See ASSERT_EQUALS_DES8. |
|
135 logging: when comparison fails macro will log out the actual and expected values that have been compared. |
|
136 E.g. "FAILURE: Got bbbbbbbbbbbbbbbbbbbb, Expected cccccccccccccccccccc : my error44." |
|
137 Logging will truncate logged strings to length KMaxLogCharLength. |
|
138 example: ASSERT_EQUALS_DES16(buf1, buf2, _L("my error4.")); |
|
139 |
|
140 @param result. TDes16 value to compare |
|
141 @param expected. expected value to test against |
|
142 @param msg. string to print out if comaprison fails. |
|
143 */ |
|
144 #define ASSERT_EQUALS_DES16(result, expected, msg) \ |
|
145 { \ |
|
146 if(!assert_equals_des16(Logger(),((TText8*)__FILE__), __LINE__, ESevrErr, result, expected, msg)) \ |
|
147 { \ |
|
148 SetAssertResult(); \ |
|
149 } \ |
|
150 } |
|
151 |
|
152 /** |
|
153 description: ASSERT_TRUE may be used to test for true statements. <value> argument may also be an expression returning a bool. |
|
154 This macro should be used for testing inequality statements holding true e.g. >,<,>=, <= |
|
155 usage: For testing boolean true. This macro should be used when checking for equality in TCmpBase and TCapsCmpBase derived classes for complex types. |
|
156 exception: Not for use for testing equality of simple types or descriptor types. Use one of ASSERT_EQUALS_XXX macros. |
|
157 logging: Does not log input values. Will only log message below concatonated with <msg> |
|
158 E.g. "FAILURE: Expected true : <msg>." |
|
159 example: ASSERT_TRUE(5>3, _L("my error4.")); |
|
160 example: ASSERT_TRUE(cmpObj.IsEqual(ELogError), _L("Failed kkk")); |
|
161 |
|
162 @param value. to check for boolean true. |
|
163 @param msg. string to print out if check fails. |
|
164 */ |
|
165 _LIT(KAssertTrueText, "FAILURE: Expected true : %S"); |
|
166 |
|
167 #define ASSERT_TRUE(value, msg) \ |
|
168 { \ |
|
169 TBool result = value; \ |
|
170 if (!result) \ |
|
171 { \ |
|
172 TPtrC m = (msg); \ |
|
173 ERR_PRINTF2(KAssertTrueText, &m); \ |
|
174 SetAssertResult(); \ |
|
175 } \ |
|
176 } |
|
177 |
|
178 |
|
179 /** |
|
180 description: ASSERT_BITS_SET may be used to test correct capbilities set in a bitmask. |
|
181 usage: For comparison of actual bitmask with expected bitmask. Comparison is based on matching wanted and unwanted bits. All other bits are ignored. |
|
182 logging: when check fails macro will logs out actual bit mask and wanted and unwanted bitmasks. |
|
183 E.g. "FAILURE: Wrong bits set : Got 0x19 , required 0x10, unwanted 0x2 : <msg>" |
|
184 example: ASSERT_BITS_SET(dynCaps, expectedCaps, unwantedCaps, _L("Wrong dynamic caps")) |
|
185 |
|
186 @param value. bitmaks to check. |
|
187 @param wantedBits. wanted bits in value mask |
|
188 @param unwantedBits. Unwanted bits in value mask. |
|
189 @param msg. string to print out if check fails. |
|
190 */ |
|
191 |
|
192 /** |
|
193 * Use this in the ASSERT_BITS_SET macro setting wantedBits to this value if |
|
194 * there are no wanted bits. |
|
195 */ |
|
196 const TUint KNoWantedBits = 0; |
|
197 /** |
|
198 * Use this in the ASSERT_BITS_SET macro setting wantedBits to this value if |
|
199 * there are no unwanted bits. |
|
200 */ |
|
201 const TUint KNoUnwantedBits = 0; |
|
202 |
|
203 _LIT(KAssertBitsSet, "FAILURE: Wrong bits set : Got 0x%x , required 0x%x, unwanted 0x%x : %S"); |
|
204 |
|
205 #define ASSERT_BITS_SET(value, wantedBits, unwantedBits, msg) \ |
|
206 { \ |
|
207 if( (((value) & (wantedBits)) != (wantedBits)) || \ |
|
208 (((value) & (unwantedBits)) != 0) ) \ |
|
209 { \ |
|
210 TPtrC m = (msg); \ |
|
211 ERR_PRINTF5(KAssertBitsSet, value, wantedBits, unwantedBits, &m); \ |
|
212 SetAssertResult(); \ |
|
213 } \ |
|
214 } |
|
215 |
|
216 /** |
|
217 * Causes the test to leave if it has failed at this point. |
|
218 * When the test leaves, message msg is logged to the log file. |
|
219 * |
|
220 * This macro should be used at a point in the test to cause |
|
221 * it to leave if there is no point in proceeding with the |
|
222 * test if it has already failed. Use sparingly! |
|
223 * |
|
224 * Example: TEST_CHECK_POINT_L(_L("Could not dial a call.")); |
|
225 */ |
|
226 _LIT(KTestCheckPointText, "TEST CHECK POINT FAILURE: %S"); |
|
227 #define TEST_CHECK_POINT_L(msg) \ |
|
228 { \ |
|
229 if (TestStepResult() != EPass) \ |
|
230 { \ |
|
231 TPtrC m = (msg); \ |
|
232 ERR_PRINTF2(KTestCheckPointText, &m); \ |
|
233 User::Leave(KErrGeneral); \ |
|
234 } \ |
|
235 }; |
|
236 |
|
237 |
|
238 // NOTE: These CHECK_XXX macros for test setup only, |
|
239 // to check a test pre-condidion. |
|
240 // To be used between SET UP and SET UP END in test step. |
|
241 |
|
242 _LIT(KCheckText, "SET UP FAILURE: %S"); |
|
243 |
|
244 #define CHECK_TRUE_L(cond, msg) \ |
|
245 if(!(cond)) \ |
|
246 { \ |
|
247 TPtrC m = (msg); \ |
|
248 WARN_PRINTF2(KCheckText, &m); \ |
|
249 SetCheckResultL(); \ |
|
250 } |
|
251 |
|
252 |
|
253 #define CHECK_EQUALS_L(result, expected, msg) \ |
|
254 { \ |
|
255 if(!assert_equals(Logger(),((TText8*)__FILE__), __LINE__, ESevrErr, result, expected, msg)) \ |
|
256 { \ |
|
257 SetCheckResultL(); \ |
|
258 } \ |
|
259 } |
|
260 |
|
261 |
|
262 _LIT(KCheckBitsSetText, "SET UP FAILURE: Got 0x%x , required 0x%x, unwanted 0x%x : %S"); |
|
263 |
|
264 #define CHECK_BITS_SET_L(value, wantedBits, unwantedBits, msg) \ |
|
265 { \ |
|
266 if ((((value) & wantedBits) != wantedBits) || \ |
|
267 (((value) & unwantedBits) != 0)) \ |
|
268 { \ |
|
269 TPtrC m = (msg); \ |
|
270 WARN_PRINTF5(KCheckBitsSetText, value, wantedBits, unwantedBits, &m); \ |
|
271 SetCheckResultL(); \ |
|
272 } \ |
|
273 } |
|
274 |
|
275 |
|
276 /* |
|
277 * Debug logging macros. |
|
278 * |
|
279 * These macros wrap around the regular INFO_PRINTFX macros defined in TestExecute |
|
280 * but allow logging to be turned on or off depending on whether |
|
281 * the ENABLE_DEBUG_LOGGING macro is defined in the mmp file. |
|
282 */ |
|
283 #ifdef ENABLE_DEBUG_LOGGING |
|
284 |
|
285 #ifndef ENABLE_COMMS_DEBUG_UTIL_LOGGING // Route logging to TEF script |
|
286 #define DEBUG_PRINTF1(p1) INFO_PRINTF1(p1) |
|
287 #define DEBUG_PRINTF2(p1, p2) INFO_PRINTF2(p1, p2) |
|
288 #define DEBUG_PRINTF3(p1, p2, p3) INFO_PRINTF3(p1, p2, p3) |
|
289 #define DEBUG_PRINTF4(p1, p2, p3, p4) INFO_PRINTF4(p1, p2, p3, p4) |
|
290 #else // Route logging to CommsDebugUtil and to TEF log file |
|
291 |
|
292 #include <comms-infras/commsdebugutility.h> |
|
293 |
|
294 _LIT8(KTSYSubSystem, "tsy"); |
|
295 _LIT8(KTSYCompnt, "ctsytest"); |
|
296 |
|
297 #define DEBUG_PRINTF1(AAA) { __FLOG_STATIC0(KTSYSubSystem, KTSYCompnt, (AAA)); INFO_PRINTF1(AAA); } |
|
298 #define DEBUG_PRINTF2(AAA,BBB) { __FLOG_STATIC1(KTSYSubSystem, KTSYCompnt, (AAA), (BBB)); INFO_PRINTF2(AAA, BBB); } |
|
299 #define DEBUG_PRINTF3(AAA,BBB,CCC) { __FLOG_STATIC2(KTSYSubSystem, KTSYCompnt, (AAA), (BBB), (CCC)); INFO_PRINTF3(AAA, BBB, CCC); } |
|
300 #define DEBUG_PRINTF4(AAA,BBB,CCC,DDD) { __FLOG_STATIC3(KTSYSubSystem, KTSYCompnt, (AAA), (BBB), (CCC), (DDD)); INFO_PRINTF4(AAA, BBB, CCC, DDD); } |
|
301 |
|
302 #define DEBUG_HEX_PRINTF2(AAA) {RFileLogger::HexDump(KTSYSubSystem, KTSYCompnt, (AAA)); } |
|
303 |
|
304 #endif // ENABLE_COMMS_DEBUG_UTIL_LOGGING |
|
305 |
|
306 #else |
|
307 #define DEBUG_PRINTF1(p1) |
|
308 #define DEBUG_PRINTF2(p1, p2) |
|
309 #define DEBUG_PRINTF3(p1, p2, p3) |
|
310 #define DEBUG_PRINTF4(p1, p2, p3, p4) |
|
311 #endif // ENABLE_DEBUG_LOGGING |
|
312 |
|
313 |
|
314 /** |
|
315 test helper functions |
|
316 */ |
|
317 |
|
318 _LIT(KAssertErrorEqualsText,"FAILURE: Got %d, Expected %d : %S"); |
|
319 _LIT(KAssertErrorEqualsTextDes,"FAILURE: Got %S, Expected %S : %S"); |
|
320 const TInt KMaxLogCharLength = 20; |
|
321 |
|
322 template<class T> |
|
323 inline TBool assert_equals(CTestExecuteLogger& aLogger, const TText8* aFile, TInt aLine, TInt aSeverity, T aRes, T aExp, TPtrC aMsg) |
|
324 { |
|
325 if(aRes != aExp) |
|
326 { |
|
327 aLogger.LogExtra(aFile, aLine, aSeverity, KAssertErrorEqualsText, aRes, aExp, &aMsg); |
|
328 return EFalse; |
|
329 } |
|
330 return ETrue; |
|
331 } |
|
332 |
|
333 |
|
334 TBool assert_equals_des16(CTestExecuteLogger& aLogger, const TText8* aFile, TInt aLine, |
|
335 TInt aSeverity, const TDesC& aRes, const TDesC& aExp, const TDesC& aMsg); |
|
336 |
|
337 TBool assert_equals_des8(CTestExecuteLogger& aLogger, const TText8* aFile, |
|
338 TInt aLine, TInt aSeverity, const TDesC8& aRes, const TDesC8& aExp, const TDesC& aMsg); |
|
339 |
|
340 |
|
341 // Time constants |
|
342 const TInt KOneSecond = 1000000; |
|
343 |
|
344 /** |
|
345 * Timeouts |
|
346 */ |
|
347 enum TTimeDuration |
|
348 { |
|
349 ETimeShort = 5*KOneSecond, // Simple LTSY transaction |
|
350 ETimeMedium = 20*KOneSecond, // Simple SIM access |
|
351 ETimeLong = 60*KOneSecond, // When sending something to the network |
|
352 ETimeVeryLong = 120*KOneSecond // Multiple network transactions or SIM access |
|
353 }; |
|
354 |
|
355 const TInt KTwentySeconds = 20*1000000;//deliberately not using KOneSecond in case it gets reduced to speed up tests. Do not want to reduce time for user interaction. |
|
356 class CRPSMaster; |
|
357 class MRpsFunctorBase; |
|
358 class CCTSYIntegrationTestSuiteStepBase : public CTestStep |
|
359 /** |
|
360 * Base test step class from which all test steps inherit. |
|
361 */ |
|
362 { |
|
363 public: |
|
364 |
|
365 virtual ~CCTSYIntegrationTestSuiteStepBase(); |
|
366 CCTSYIntegrationTestSuiteStepBase(CEtelSessionMgr& aEtelSessionMgr); |
|
367 |
|
368 virtual TVerdict doTestStepPreambleL(); |
|
369 virtual TVerdict doTestStepPostambleL(); |
|
370 |
|
371 void SetAssertResult(); |
|
372 void SetCheckResultL(); |
|
373 TInt WaitForRequestWithTimeOut(TEtelRequestBase& aRequestStatus, TTimeDuration aTimeOut); |
|
374 |
|
375 void ConsolePrintL(const TDesC& aText ); |
|
376 |
|
377 void DisplayUserInteractionPromptL(const TDesC& aText, TTimeDuration aTimeOut = ETimeMedium); |
|
378 |
|
379 inline void SetRpsHandle(CRPSMaster* aRPS) |
|
380 { |
|
381 iRPS = aRPS; |
|
382 }; |
|
383 |
|
384 inline void SetOwnNumbersManager(TOwnNumbersManager* aOwnNumbers) |
|
385 { |
|
386 iOwnNumbersCache.SetOwnNumbersManager(aOwnNumbers); |
|
387 }; |
|
388 |
|
389 inline TBool UsingRps() const |
|
390 { |
|
391 // if the pointer to RPS is null, return false, else return true |
|
392 return ((iRPS==NULL)?EFalse:ETrue); |
|
393 } |
|
394 void GetRPSNumber(TEtelLine aLine, TPtrC& aNumber); |
|
395 |
|
396 //RPS dispatch requests |
|
397 TInt RPSDialNumberL(const TDesC& aNumToDial, TEtelLine aLine); |
|
398 TInt RPSRequestIncomingCallL(TEtelLine aLine); |
|
399 TInt RPSRequestIncomingCancelBeforeConnectL(TEtelLine aLine, TInt aDelay); |
|
400 TInt RPSRequestIncomingHangupAfterConnectL(TEtelLine aLine, TInt aDelay); |
|
401 TInt RPSAnswerNextCallThenHangupL(TEtelLine aLine, TInt aDelay); |
|
402 TInt RPSAnswerNextCallL(TEtelLine aLine); |
|
403 TInt RPSAnswerNextCallThenHoldL(TEtelLine aLine, TInt aDelay); |
|
404 TInt RPSIgnoreNextCallL(TEtelLine aLine); |
|
405 TInt RPSHoldL(TEtelLine aLine, TInt aDelay); |
|
406 TInt RPSResumeL(TEtelLine aLine, TInt aDelay); |
|
407 TInt RPSHangupL(TEtelLine aLine, TInt aDelay); |
|
408 TInt RPSHangUpNextCallBeforeConnectL(TEtelLine aLine); |
|
409 TInt RPSEchoDataL(const TDesC& aDataToSend); |
|
410 TInt RPSRejectNextCallL(TEtelLine aLine); |
|
411 |
|
412 void AsyncExec(CThreadExec::MFunctor* aFunction); |
|
413 void SyncExec(CThreadExec::MFunctor* aFunction); |
|
414 protected: |
|
415 void StartSetup(); |
|
416 void StartTest(); |
|
417 void StartCleanup(); |
|
418 void RPSCleanupL(); |
|
419 TInt ExecuteRemoteRequestL(MRpsFunctorBase& aRpsFunctor, const TDesC& aRpsCallMsg); |
|
420 TInt DoPauseL(const TDesC& aText, TTimeDuration aTimeout = ETimeMedium ); |
|
421 TPtrC Number(TEtelLine aLine); |
|
422 |
|
423 protected: |
|
424 CEtelSessionMgr& iEtelSessionMgr; |
|
425 |
|
426 TVerdict iAssertResult; |
|
427 TVerdict iCheckResult; |
|
428 CRPSMaster* iRPS; |
|
429 |
|
430 // Own Number Info |
|
431 TOwnNumbersCache iOwnNumbersCache; |
|
432 |
|
433 }; // class CCTSYIntegrationTestSuiteStepBase |
|
434 |
|
435 #endif // __CCTSYINTEGRATIONTESTSUITEBASE_H__ |