|
1 /* |
|
2 * ============================================================================ |
|
3 * Name : testrflextimer.h |
|
4 * Part of : src / testflextimer |
|
5 * Description : STIF test cases for RFlexTimer |
|
6 * Version : %version: 1 % |
|
7 * |
|
8 * Copyright © 2010 Nokia Corporation and/or its subsidiary(-ies). |
|
9 * All rights reserved. |
|
10 * This component and the accompanying materials are made available |
|
11 * under the terms of the License "Eclipse Public License v1.0" |
|
12 * which accompanies this distribution, and is available |
|
13 * at the URL "http://www.eclipse.org/legal/epl-v10.html". |
|
14 * |
|
15 * Initial Contributors: |
|
16 * Nokia Corporation - initial contribution. |
|
17 * |
|
18 * Contributors: |
|
19 * Nokia Corporation |
|
20 * ============================================================================ |
|
21 * Template version: 4.2 |
|
22 */ |
|
23 |
|
24 #ifndef TESTRFLEXTIMER_H |
|
25 #define TESTRFLEXTIMER_H |
|
26 |
|
27 |
|
28 #include <e32base.h> |
|
29 |
|
30 /** |
|
31 * STIF test cases for RFlexTimer class. |
|
32 * This class is only a container for STIF test cases - it should NOT be |
|
33 * instantiated, just call the static functions. |
|
34 * |
|
35 * @lib testflextimer.lib |
|
36 * @since TB10.1 |
|
37 */ |
|
38 class CTestRFlexTimer : public CBase |
|
39 { |
|
40 |
|
41 public: |
|
42 |
|
43 /** |
|
44 * Destructor. |
|
45 */ |
|
46 virtual ~CTestRFlexTimer(); |
|
47 |
|
48 /** |
|
49 * @brief Start a timer using After (32 bit) and wait it to expire |
|
50 * |
|
51 * Open RFlexTimer handle and connect to the server. Set timer to expire |
|
52 * after 3 secs. Close the handle and check that the expiration is done |
|
53 * at correct time. |
|
54 * |
|
55 * Tests: |
|
56 * - RFlexTimer::RFlexTimer() |
|
57 * - RFlexTimer::Connect() |
|
58 * - RFlexTimer::After() 32 bit |
|
59 * - RFlexTimer::Close() |
|
60 * - RFlexTimer::~RFlexTimer() |
|
61 * - Expiration of timer |
|
62 * |
|
63 * @param aResult The result of the test. |
|
64 * @param aCallback Pointer to the STIF test class |
|
65 * @return The status of execution of the test. KErrNone if the test |
|
66 * was executed ok, any system wide errorcode otherwise. |
|
67 */ |
|
68 static TInt ExpireAfter32L( TTestResult& aResult, |
|
69 CTestFlexTimer* aCallback ); |
|
70 |
|
71 |
|
72 /** |
|
73 * @brief Start a timer using After (64 bit) and wait it to expire |
|
74 * |
|
75 * Open RFlexTimer handle and connect to the server. Set timer to expire |
|
76 * after 3 secs. Close the handle and check that the expiration is done |
|
77 * at correct time. |
|
78 * |
|
79 * Tests: |
|
80 * - RFlexTimer::RFlexTimer() |
|
81 * - RFlexTimer::Connect() |
|
82 * - RFlexTimer::After() 64 bit |
|
83 * - RFlexTimer::Close() |
|
84 * - RFlexTimer::~RFlexTimer() |
|
85 * - Expiration of timer |
|
86 * |
|
87 * @param aResult The result of the test. |
|
88 * @param aCallback Pointer to the STIF test class |
|
89 * @return The status of execution of the test. KErrNone if the test |
|
90 * was executed ok, any system wide errorcode otherwise. |
|
91 */ |
|
92 static TInt ExpireAfter64L( TTestResult& aResult, |
|
93 CTestFlexTimer* aCallback ); |
|
94 |
|
95 |
|
96 /** |
|
97 * @brief Start a timer using AfterTicks and wait it to expire |
|
98 * |
|
99 * Open RFlexTimer handle and connect to the server. Set timer to expire |
|
100 * after 192 ticks (3 secs). Close the handle and check that the |
|
101 * expiration is done at correct time. |
|
102 * |
|
103 * Tests: |
|
104 * - RFlexTimer::RFlexTimer() |
|
105 * - RFlexTimer::Connect() |
|
106 * - RFlexTimer::AfterTicks() |
|
107 * - RFlexTimer::Close() |
|
108 * - RFlexTimer::~RFlexTimer() |
|
109 * - Expiration of timer |
|
110 * |
|
111 * @param aResult The result of the test. |
|
112 * @param aCallback Pointer to the STIF test class |
|
113 * @return The status of execution of the test. KErrNone if the test |
|
114 * was executed ok, any system wide errorcode otherwise. |
|
115 */ |
|
116 static TInt ExpireAfterTicksL( TTestResult& aResult, |
|
117 CTestFlexTimer* aCallback ); |
|
118 |
|
119 /** |
|
120 * @brief Start a timer using At and wait it to expire |
|
121 * |
|
122 * Open RFlexTimer handle and connect to the server. Set timer to expire |
|
123 * after 3 secs from now. Close the handle and check that the expiration is |
|
124 * done at correct time. |
|
125 * |
|
126 * Tests: |
|
127 * - RFlexTimer::RFlexTimer() |
|
128 * - RFlexTimer::Connect() |
|
129 * - RFlexTimer::At() |
|
130 * - RFlexTimer::Close() |
|
131 * - RFlexTimer::~RFlexTimer() |
|
132 * - Expiration of timer |
|
133 * |
|
134 * @param aResult The result of the test. |
|
135 * @param aCallback Pointer to the STIF test class |
|
136 * @return The status of execution of the test. KErrNone if the test |
|
137 * was executed ok, any system wide errorcode otherwise. |
|
138 */ |
|
139 static TInt ExpireAtL( TTestResult& aResult, |
|
140 CTestFlexTimer* aCallback ); |
|
141 |
|
142 /** |
|
143 * @brief Start a timer using AtUTC and wait it to expire |
|
144 * |
|
145 * Open RFlexTimer handle and connect to the server. Set timer to expire |
|
146 * after 3 secs from now. Close the handle and check that the expiration is |
|
147 * done at correct time. |
|
148 * |
|
149 * Tests: |
|
150 * - RFlexTimer::RFlexTimer() |
|
151 * - RFlexTimer::Connect() |
|
152 * - RFlexTimer::AtUTC() |
|
153 * - RFlexTimer::Close() |
|
154 * - RFlexTimer::~RFlexTimer() |
|
155 * - Expiration of timer |
|
156 * |
|
157 * @param aResult The result of the test. |
|
158 * @param aCallback Pointer to the STIF test class |
|
159 * @return The status of execution of the test. KErrNone if the test |
|
160 * was executed ok, any system wide errorcode otherwise. |
|
161 */ |
|
162 static TInt ExpireAtUtcL( TTestResult& aResult, |
|
163 CTestFlexTimer* aCallback ); |
|
164 |
|
165 /** |
|
166 * @brief Start timer using After (32 bit) without connecting to the server first. |
|
167 * |
|
168 * This tests illeagal usage of the interface and it'll panic with |
|
169 * KERN-EXEC 0. |
|
170 * |
|
171 * @param aResult The result of the test. |
|
172 * @param aCallback Pointer to the STIF test class |
|
173 * @return The status of execution of the test. KErrNone if the test |
|
174 * was executed ok, any system wide errorcode otherwise. |
|
175 */ |
|
176 static TInt After32WithoutConnect( TTestResult& aResult, |
|
177 CTestFlexTimer* aCallback ); |
|
178 |
|
179 /** |
|
180 * @brief Start timer using After (64 bit) without connecting to the server first. |
|
181 * |
|
182 * This tests illeagal usage of the interface and it'll panic with |
|
183 * KERN-EXEC 0. |
|
184 * |
|
185 * @param aResult The result of the test. |
|
186 * @param aCallback Pointer to the STIF test class |
|
187 * @return The status of execution of the test. KErrNone if the test |
|
188 * was executed ok, any system wide errorcode otherwise. |
|
189 */ |
|
190 static TInt After64WithoutConnect( TTestResult& aResult, |
|
191 CTestFlexTimer* aCallback ); |
|
192 |
|
193 /** |
|
194 * @brief Start timer using AfterTicks without connecting to the server first. |
|
195 * |
|
196 * This tests illeagal usage of the interface and it'll panic with |
|
197 * KERN-EXEC 0. |
|
198 * |
|
199 * @param aResult The result of the test. |
|
200 * @param aCallback Pointer to the STIF test class |
|
201 * @return The status of execution of the test. KErrNone if the test |
|
202 * was executed ok, any system wide errorcode otherwise. |
|
203 */ |
|
204 static TInt AfterTicksWithoutConnect( TTestResult& aResult, |
|
205 CTestFlexTimer* aCallback ); |
|
206 |
|
207 /** |
|
208 * @brief Start timer using At without connecting to the server first. |
|
209 * |
|
210 * This tests illeagal usage of the interface and it'll panic with |
|
211 * KERN-EXEC 0. |
|
212 * |
|
213 * @param aResult The result of the test. |
|
214 * @param aCallback Pointer to the STIF test class |
|
215 * @return The status of execution of the test. KErrNone if the test |
|
216 * was executed ok, any system wide errorcode otherwise. |
|
217 */ |
|
218 static TInt AtWithoutConnect( TTestResult& aResult, |
|
219 CTestFlexTimer* aCallback ); |
|
220 |
|
221 /** |
|
222 * @brief Start timer using AtUtc without connecting to the server first. |
|
223 * |
|
224 * This tests illeagal usage of the interface and it'll panic with |
|
225 * KERN-EXEC 0. |
|
226 * |
|
227 * @param aResult The result of the test. |
|
228 * @param aCallback Pointer to the STIF test class |
|
229 * @return The status of execution of the test. KErrNone if the test |
|
230 * was executed ok, any system wide errorcode otherwise. |
|
231 */ |
|
232 static TInt AtUtcWithoutConnect( TTestResult& aResult, |
|
233 CTestFlexTimer* aCallback ); |
|
234 |
|
235 /** |
|
236 * @brief Configure (32 bit) timer without connecting to the server first. |
|
237 * |
|
238 * This tests illeagal usage of the interface and it'll panic with |
|
239 * KERN-EXEC 0. |
|
240 * |
|
241 * @param aResult The result of the test. |
|
242 * @param aCallback Pointer to the STIF test class |
|
243 * @return The status of execution of the test. KErrNone if the test |
|
244 * was executed ok, any system wide errorcode otherwise. |
|
245 */ |
|
246 static TInt Configure32WithoutConnect( TTestResult& aResult, |
|
247 CTestFlexTimer* aCallback ); |
|
248 |
|
249 /** |
|
250 * @brief Configure (64 bit) timer without connecting to the server first. |
|
251 * |
|
252 * This tests illeagal usage of the interface and it'll panic with |
|
253 * KERN-EXEC 0. |
|
254 * |
|
255 * @param aResult The result of the test. |
|
256 * @param aCallback Pointer to the STIF test class |
|
257 * @return The status of execution of the test. KErrNone if the test |
|
258 * was executed ok, any system wide errorcode otherwise. |
|
259 */ |
|
260 static TInt Configure64WithoutConnect( TTestResult& aResult, |
|
261 CTestFlexTimer* aCallback ); |
|
262 |
|
263 /** |
|
264 * @brief Cancel timer using RFlexTimer without connecting to the server first. |
|
265 * |
|
266 * This tests illeagal usage of the interface and it'll panic with |
|
267 * KERN-EXEC 0. |
|
268 * |
|
269 * @param aResult The result of the test. |
|
270 * @param aCallback Pointer to the STIF test class |
|
271 * @return The status of execution of the test. KErrNone if the test |
|
272 * was executed ok, any system wide errorcode otherwise. |
|
273 */ |
|
274 static TInt CancelWithoutConnect( TTestResult& aResult, |
|
275 CTestFlexTimer* aCallback ); |
|
276 |
|
277 /** |
|
278 * @brief Set timer twice by After. |
|
279 * |
|
280 * This tests illeagal usage of the interface and it'll panic with |
|
281 * RFlexTimer 15 (EFlexTimerServerErrorPendingTimer). |
|
282 * |
|
283 * @param aResult The result of the test. |
|
284 * @param aCallback Pointer to the STIF test class |
|
285 * @return The status of execution of the test. KErrNone if the test |
|
286 * was executed ok, any system wide errorcode otherwise. |
|
287 */ |
|
288 static TInt CallAfterTwiceL( TTestResult& aResult, |
|
289 CTestFlexTimer* aCallback ); |
|
290 |
|
291 |
|
292 /** |
|
293 * @brief Set timer twice by AfterTicks. |
|
294 * |
|
295 * This tests illeagal usage of the interface and it'll panic with |
|
296 * RFlexTimer 15 (EFlexTimerServerErrorPendingTimer). |
|
297 * |
|
298 * @param aResult The result of the test. |
|
299 * @param aCallback Pointer to the STIF test class |
|
300 * @return The status of execution of the test. KErrNone if the test |
|
301 * was executed ok, any system wide errorcode otherwise. |
|
302 */ |
|
303 static TInt CallAfterTicksTwiceL( TTestResult& aResult, |
|
304 CTestFlexTimer* aCallback ); |
|
305 |
|
306 /** |
|
307 * @brief Set timer twice by At. |
|
308 * |
|
309 * This tests illeagal usage of the interface and it'll panic with |
|
310 * RFlexTimer 15 (EFlexTimerServerErrorPendingTimer). |
|
311 * |
|
312 * @param aResult The result of the test. |
|
313 * @param aCallback Pointer to the STIF test class |
|
314 * @return The status of execution of the test. KErrNone if the test |
|
315 * was executed ok, any system wide errorcode otherwise. |
|
316 */ |
|
317 static TInt CallAtTwiceL( TTestResult& aResult, |
|
318 CTestFlexTimer* aCallback ); |
|
319 |
|
320 /** |
|
321 * @brief Set timer twice by AtUTC. |
|
322 * |
|
323 * This tests illeagal usage of the interface and it'll panic with |
|
324 * RFlexTimer 15 (EFlexTimerServerErrorPendingTimer). |
|
325 * |
|
326 * @param aResult The result of the test. |
|
327 * @param aCallback Pointer to the STIF test class |
|
328 * @return The status of execution of the test. KErrNone if the test |
|
329 * was executed ok, any system wide errorcode otherwise. |
|
330 */ |
|
331 static TInt CallAtUtcTwiceL( TTestResult& aResult, |
|
332 CTestFlexTimer* aCallback ); |
|
333 |
|
334 /** |
|
335 * @brief Connect to timer server twice. |
|
336 * |
|
337 * This tests illeagal usage of the interface and it'll panic with |
|
338 * RFlexTimer 32 (EFlexTimerAlreadyConnected). |
|
339 * |
|
340 * @param aResult The result of the test. |
|
341 * @param aCallback Pointer to the STIF test class |
|
342 * @return The status of execution of the test. KErrNone if the test |
|
343 * was executed ok, any system wide errorcode otherwise. |
|
344 */ |
|
345 static TInt CallConnectTwiceL( TTestResult& aResult, |
|
346 CTestFlexTimer* aCallback ); |
|
347 |
|
348 |
|
349 /** |
|
350 * @brief Reconnect to timer server. |
|
351 * |
|
352 * Connect, close and connect again the handle. |
|
353 * |
|
354 * @param aResult The result of the test. |
|
355 * @param aCallback Pointer to the STIF test class |
|
356 * @return The status of execution of the test. KErrNone if the test |
|
357 * was executed ok, any system wide errorcode otherwise. |
|
358 */ |
|
359 static TInt ReconnectL( TTestResult& aResult, |
|
360 CTestFlexTimer* aCallback ); |
|
361 |
|
362 |
|
363 /** |
|
364 * @brief Cancel timer using RFlexTimer without starting it first. |
|
365 * |
|
366 * This tests a leagal uage of the interface. Timer can be cancelled |
|
367 * without setting it first. |
|
368 * |
|
369 * @param aResult The result of the test. |
|
370 * @param aCallback Pointer to the STIF test class |
|
371 * @return The status of execution of the test. KErrNone if the test |
|
372 * was executed ok, any system wide errorcode otherwise. |
|
373 */ |
|
374 static TInt CancelWithoutStart( TTestResult& aResult, |
|
375 CTestFlexTimer* aCallback ); |
|
376 |
|
377 /** |
|
378 * @brief Call AfterTicks() with negative value. |
|
379 * |
|
380 * This test illegal usage of the interface. There has to be zero or more |
|
381 * ticks. |
|
382 * |
|
383 * @param aResult The result of the test. |
|
384 * @param aCallback Pointer to the STIF test class |
|
385 * @return The status of execution of the test. KErrNone if the test |
|
386 * was executed ok, any system wide errorcode otherwise. |
|
387 */ |
|
388 static TInt NegativeTicksInAfterTicksL( |
|
389 TTestResult& aResult, |
|
390 CTestFlexTimer* aCallback ); |
|
391 |
|
392 /** |
|
393 * @brief Call AfterTicks() with zero. |
|
394 * |
|
395 * This tests leagal usage of the interface. |
|
396 * |
|
397 * @param aResult The result of the test. |
|
398 * @param aCallback Pointer to the STIF test class |
|
399 * @return The status of execution of the test. KErrNone if the test |
|
400 * was executed ok, any system wide errorcode otherwise. |
|
401 */ |
|
402 static TInt ZeroTicksInAfterTicksL( |
|
403 TTestResult& aResult, |
|
404 CTestFlexTimer* aCallback ); |
|
405 |
|
406 /** |
|
407 * @brief Change system time during AfterTicks timer is running. |
|
408 * |
|
409 * Set timer to be expired after 640 ticks (10 sec). After 1 sec from |
|
410 * starting the timer, add system time 3 seconds. Check that the timer |
|
411 * expires after 10 seconds from starting (13 secs by system time). |
|
412 * |
|
413 * @param aResult The result of the test. |
|
414 * @param aCallback Pointer to the STIF test class |
|
415 * @return The status of execution of the test. KErrNone if the test |
|
416 * was executed ok, any system wide errorcode otherwise. |
|
417 */ |
|
418 static TInt ChangeTimeWhileAfterTicksL( |
|
419 TTestResult& aResult, |
|
420 CTestFlexTimer* aCallback ); |
|
421 |
|
422 /** |
|
423 * @brief Test that timer window works correctly. |
|
424 * |
|
425 * Create three timers: |
|
426 * T1: expire after 4-8 secs |
|
427 * T2: expire after 7-8 secs |
|
428 * T3: expire after 5 secs |
|
429 * |
|
430 * T1 and T2 are AfterTicks -timers T3 is After timer. |
|
431 * |
|
432 * Check that T1 has expired after 5 secs and T2 after 8 secs of setting. |
|
433 * |
|
434 * @param aResult The result of the test. |
|
435 * @param aCallback Pointer to the STIF test class |
|
436 * @return The status of execution of the test. KErrNone if the test |
|
437 * was executed ok, any system wide errorcode otherwise. |
|
438 */ |
|
439 static TInt TestAfterTicksWindowL( |
|
440 TTestResult& aResult, |
|
441 CTestFlexTimer* aCallback ); |
|
442 |
|
443 private: |
|
444 |
|
445 /** |
|
446 * Constructor. |
|
447 * Keep it private to prevent instantiation of the class. |
|
448 */ |
|
449 CTestRFlexTimer(); |
|
450 |
|
451 /** |
|
452 * Check is the delay in the window. |
|
453 * @param aDelay Interval to be checked. |
|
454 * @param aInterval Interval of the timer. |
|
455 * @param aWindow Allowed window of the timer. |
|
456 * @return ETrue if the delay is correc, EFalse otherwise. |
|
457 */ |
|
458 static TBool IsDelayOk( |
|
459 const TTimeIntervalMicroSeconds aDelay, |
|
460 const TTimeIntervalMicroSeconds32 aInterval, |
|
461 const TTimeIntervalMicroSeconds32 aWindow ); |
|
462 |
|
463 /** |
|
464 * Check is the delay in the window. |
|
465 * @param aDelay Interval to be checked. |
|
466 * @param aInterval Interval of the timer. |
|
467 * @param aWindow Allowed window of the timer. |
|
468 * @return ETrue if the delay is correc, EFalse otherwise. |
|
469 */ |
|
470 static TBool IsDelayOk( |
|
471 const TTimeIntervalMicroSeconds aDelay, |
|
472 const TTimeIntervalMicroSeconds32 aInterval, |
|
473 const TTimeIntervalMicroSeconds aWindow ); |
|
474 |
|
475 /** |
|
476 * Check is the delay in the window. |
|
477 * @param aDelay Interval to be checked. |
|
478 * @param aInterval Interval of the timer. |
|
479 * @param aWindow Allowed window of the timer. |
|
480 * @return ETrue if the delay is correc, EFalse otherwise. |
|
481 */ |
|
482 static TBool IsDelayOk( |
|
483 const TTimeIntervalMicroSeconds aDelay, |
|
484 const TTimeIntervalMicroSeconds aInterval, |
|
485 const TTimeIntervalMicroSeconds32 aWindow ); |
|
486 |
|
487 /** |
|
488 * Check is the delay in the window. |
|
489 * @param aDelay Interval to be checked. |
|
490 * @param aInterval Interval of the timer. |
|
491 * @param aWindow Allowed window of the timer. |
|
492 * @return ETrue if the delay is correc, EFalse otherwise. |
|
493 */ |
|
494 static TBool IsDelayOk( |
|
495 const TTimeIntervalMicroSeconds aDelay, |
|
496 const TTimeIntervalMicroSeconds aInterval, |
|
497 const TTimeIntervalMicroSeconds aWindow ); |
|
498 |
|
499 /** |
|
500 * A helper function for AfterTicks() testing. |
|
501 * -# Creates RFlexTimer handle, |
|
502 * -# connects it to the server, |
|
503 * -# configures timer's window (default 0 microseconds), |
|
504 * -# set the timer to expire after given ticks, |
|
505 * -# wait timer to be expired |
|
506 * -# return the delay of the timer |
|
507 * |
|
508 * @param aTicks Timer's interval in number of ticks |
|
509 * @param aWindowSize Timer's window (default 0 microseconds) |
|
510 * @return The delay of the timer in microseconds |
|
511 */ |
|
512 static TTimeIntervalMicroSeconds ExecuteAfterTicksL( |
|
513 TInt aTicks, |
|
514 TTimeIntervalMicroSeconds aWindowSize = 0 ); |
|
515 |
|
516 private: // data |
|
517 |
|
518 }; |
|
519 |
|
520 #endif // TESTRFLEXTIMER_H |