32
|
1 |
/*
|
|
2 |
* ============================================================================
|
|
3 |
* Name : testflexperiodic.h
|
|
4 |
* Part of : src / testflextimer
|
|
5 |
* Description : STIF test cases for CFlexPeriodic timer.
|
|
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 TESTFLEXPERIODIC_H
|
|
25 |
#define TESTFLEXPERIODIC_H
|
|
26 |
|
|
27 |
#include <e32base.h>
|
|
28 |
|
|
29 |
// FORWARD DECLARATIONS
|
|
30 |
class CFlexPeriodic;
|
|
31 |
|
|
32 |
/**
|
|
33 |
* STIF test cases for CFlexPeriodic class.
|
|
34 |
* This class is only a container for STIF test cases - it should NOT be
|
|
35 |
* instantiated, just call the static functions.
|
|
36 |
*
|
|
37 |
* @lib testflextimer.lib
|
|
38 |
* @since TB10.1
|
|
39 |
*/
|
|
40 |
NONSHARABLE_CLASS( CTestFlexPeriodic ) : public CBase
|
|
41 |
{
|
|
42 |
|
|
43 |
/**
|
|
44 |
* Data for restarting timer in callback function.
|
|
45 |
*/
|
|
46 |
struct TRestartInfo
|
|
47 |
{
|
|
48 |
CFlexPeriodic* iTimer; ///< Pointer to the timer
|
|
49 |
TInt iFirstTicksLeft; ///< Number of times the 1st timer settings are run
|
|
50 |
RArray<TTime>* iFirstTimestamps; ///< Timestamps for the 1st timer settings
|
|
51 |
RArray<TTime>* iSecondTimestamps; ///< Timestamps for the 2nd timer settings
|
|
52 |
TTimeIntervalMicroSeconds iSecondInterval; ///< Interval for the 2nd timer settings
|
|
53 |
};
|
|
54 |
|
|
55 |
/**
|
|
56 |
* Data for CFlexPeriodic::Configure() tests
|
|
57 |
*/
|
|
58 |
struct TConfigureInfo
|
|
59 |
{
|
|
60 |
CFlexPeriodic* iTimer; ///< Pointer to the timer under testing
|
|
61 |
TInt iDelayWindow; ///< value for delay window to be set
|
|
62 |
TInt iIntervalWindow; ///< value for interval window to be set
|
|
63 |
TInt iConfigResult32; ///< Result of configure(32 bit)
|
|
64 |
TInt iConfigResult64; ///< Result of configure(64 bit)
|
|
65 |
};
|
|
66 |
|
|
67 |
/**
|
|
68 |
* Data for running a test case in own thread
|
|
69 |
*/
|
|
70 |
struct TTestCaseArguments
|
|
71 |
{
|
|
72 |
TInt (*iTestFunction)( TTestResult&, CTestFlexTimer* ); ///< Function pointer to the test case to be run
|
|
73 |
TTestResult& iResult; ///< The result of the test (argument for the test case)
|
|
74 |
CTestFlexTimer* iCallback; ///< Pointer to the STIF test class (argument for the test case)
|
|
75 |
};
|
|
76 |
|
|
77 |
public:
|
|
78 |
|
|
79 |
/**
|
|
80 |
* Destructor.
|
|
81 |
*/
|
|
82 |
virtual ~CTestFlexPeriodic();
|
|
83 |
|
|
84 |
/**
|
|
85 |
* @brief Create and expire CFlexPeriodic timer.
|
|
86 |
*
|
|
87 |
* Create and start one CFlexPeriodic timer with 1 sec delay and interval
|
|
88 |
* wait for 5 secs. Check that the timer has been expired at correct times.
|
|
89 |
*
|
|
90 |
* Timer expiration times (sec):
|
|
91 |
* 1, 2, 3, 4, ...
|
|
92 |
*
|
|
93 |
* Tests:
|
|
94 |
* - CFlexPeriodic::NewL()
|
|
95 |
* - CFlexPeriodic::Start() 32-bit
|
|
96 |
* - CFlexPeriodic::Cancel()
|
|
97 |
* - CFlexPeriodic::~CFlexPeriodic()
|
|
98 |
* - Expiration of CFlexPeriodic timers
|
|
99 |
*
|
|
100 |
* @param aResult The result of the test.
|
|
101 |
* @param aCallback Pointer to the STIF test class
|
|
102 |
* @return The status of execution of the test. KErrNone if the test
|
|
103 |
* was executed ok, any system wide errorcode otherwise.
|
|
104 |
*/
|
|
105 |
static TInt StartOneTimerL( TTestResult& aResult,
|
|
106 |
CTestFlexTimer* aCallback );
|
|
107 |
|
|
108 |
/**
|
|
109 |
* @brief Create and expire CFlexPeriodic timer with Error CB.
|
|
110 |
*
|
|
111 |
* Create and start one CFlexPeriodic timer with 1 sec delay and interval
|
|
112 |
* wait for 5 secs. Give timer also Error CB argument.
|
|
113 |
* Check that the timer has been expired at correct times.
|
|
114 |
* If callback gets called case panics.
|
|
115 |
*
|
|
116 |
* Timer expiration times (sec):
|
|
117 |
* 1, 2, 3, 4, ...
|
|
118 |
*
|
|
119 |
* Tests:
|
|
120 |
* - CFlexPeriodic::NewL()
|
|
121 |
* - CFlexPeriodic::Start() 32-bit
|
|
122 |
* - CFlexPeriodic::Cancel()
|
|
123 |
* - CFlexPeriodic::~CFlexPeriodic()
|
|
124 |
* - Expiration of CFlexPeriodic timers
|
|
125 |
*
|
|
126 |
* @param aResult The result of the test.
|
|
127 |
* @param aCallback Pointer to the STIF test class
|
|
128 |
* @return The status of execution of the test. KErrNone if the test
|
|
129 |
* was executed ok, any system wide errorcode otherwise.
|
|
130 |
*/
|
|
131 |
static TInt StartOneTimerWithErrorCbL( TTestResult& aResult,
|
|
132 |
CTestFlexTimer* aCallback );
|
|
133 |
|
|
134 |
/**
|
|
135 |
* @brief Restart CFlexPeriodic in callback function.
|
|
136 |
*
|
|
137 |
* Start a periodic timer with 1 sec delay and interval.
|
|
138 |
*
|
|
139 |
* After 2 expiration cancel and start the timer in its callback function
|
|
140 |
* with 2 secs delay and interval.
|
|
141 |
*
|
|
142 |
* Timer expiration times (sec):
|
|
143 |
* 1, 2, 4, 6, 8, ...
|
|
144 |
*
|
|
145 |
* Tests:
|
|
146 |
* - CFlexPeriodic::NewL()
|
|
147 |
* - CFlexPeriodic::Start() 64-bit
|
|
148 |
* - CFlexPeriodic::Cancel()
|
|
149 |
* - CFlexPeriodic::~CFlexPeriodic()
|
|
150 |
* - Expiration of CFlexPeriodic timers
|
|
151 |
* - Cancelling and starting timer in callback function
|
|
152 |
*
|
|
153 |
* @param aResult The result of the test.
|
|
154 |
* @param aCallback Pointer to the STIF test class
|
|
155 |
* @return The status of execution of the test. KErrNone if the test
|
|
156 |
* was executed ok, any system wide errorcode otherwise.
|
|
157 |
*/
|
|
158 |
static TInt CallbackRestartL( TTestResult& aResult,
|
|
159 |
CTestFlexTimer* aCallback );
|
|
160 |
|
|
161 |
/**
|
|
162 |
* @brief Configure window sizes, 32 bit
|
|
163 |
*
|
|
164 |
* Start 2 timers:
|
|
165 |
* T1:
|
|
166 |
* - delay 3.0 sec, window 0.0 sec
|
|
167 |
* - interval 2.0 sec, window 1.5 sec
|
|
168 |
* T2:
|
|
169 |
* - delay 3.5 sec, window 1.5 sec
|
|
170 |
* - interval 1.0 sec, window 0.0 sec
|
|
171 |
*
|
|
172 |
* Both timers shoud expire at (sec)
|
|
173 |
* 3.0, 4.0, 5.0, 6.0, ...
|
|
174 |
*
|
|
175 |
* Functionality of delay window is tested in sec 3.0 expiration and
|
|
176 |
* functionality of interval window is tested in other expirations.
|
|
177 |
*
|
|
178 |
* Tests:
|
|
179 |
* - CFlexPeriodic::NewL()
|
|
180 |
* - CFlexPeriodic::Configure() 32-bit
|
|
181 |
* - CFlexPeriodic::Start() 32-bit
|
|
182 |
* - CFlexPeriodic::Cancel()
|
|
183 |
* - CFlexPeriodic::~CFlexPeriodic()
|
|
184 |
* - Expiration of CFlexPeriodic timers
|
|
185 |
* - Delay
|
|
186 |
* - Interval
|
|
187 |
* - Delay window
|
|
188 |
* - Interval window
|
|
189 |
*
|
|
190 |
* @param aResult The result of the test.
|
|
191 |
* @param aCallback Pointer to the STIF test class
|
|
192 |
* @return The status of execution of the test. KErrNone if the test
|
|
193 |
* was executed ok, any system wide errorcode otherwise.
|
|
194 |
*/
|
|
195 |
static TInt ConfigureWindow32L( TTestResult& aResult,
|
|
196 |
CTestFlexTimer* aCallback );
|
|
197 |
|
|
198 |
/**
|
|
199 |
* @brief Configure window sizes, 64 bit
|
|
200 |
*
|
|
201 |
* @see ConfigureWindow32L for test setup.
|
|
202 |
*
|
|
203 |
* Tests:
|
|
204 |
* - CFlexPeriodic::NewL()
|
|
205 |
* - CFlexPeriodic::Configure() 64-bit
|
|
206 |
* - CFlexPeriodic::Start() 64-bit
|
|
207 |
* - CFlexPeriodic::Cancel()
|
|
208 |
* - CFlexPeriodic::~CFlexPeriodic()
|
|
209 |
* - Expiration of CFlexPeriodic timers
|
|
210 |
* - Delay
|
|
211 |
* - Interval
|
|
212 |
* - Delay window
|
|
213 |
* - Interval window
|
|
214 |
*
|
|
215 |
* @param aResult The result of the test.
|
|
216 |
* @param aCallback Pointer to the STIF test class
|
|
217 |
* @return The status of execution of the test. KErrNone if the test
|
|
218 |
* was executed ok, any system wide errorcode otherwise.
|
|
219 |
*/
|
|
220 |
static TInt ConfigureWindow64L( TTestResult& aResult,
|
|
221 |
CTestFlexTimer* aCallback );
|
|
222 |
|
|
223 |
/**
|
|
224 |
* @brief Configure window sizes, 32 bit and 64 bit
|
|
225 |
*
|
|
226 |
* @see ConfigureWindow32L for test setup.
|
|
227 |
*
|
|
228 |
* Tests:
|
|
229 |
* - CFlexPeriodic::NewL()
|
|
230 |
* - CFlexPeriodic::Configure() 32-bit
|
|
231 |
* - CFlexPeriodic::Configure() 64-bit
|
|
232 |
* - CFlexPeriodic::Start() 32-bit
|
|
233 |
* - CFlexPeriodic::Start() 64-bit
|
|
234 |
* - CFlexPeriodic::Cancel()
|
|
235 |
* - CFlexPeriodic::~CFlexPeriodic()
|
|
236 |
* - Expiration of CFlexPeriodic timers
|
|
237 |
* - Delay
|
|
238 |
* - Interval
|
|
239 |
* - Delay window
|
|
240 |
* - Interval window
|
|
241 |
*
|
|
242 |
* @param aResult The result of the test.
|
|
243 |
* @param aCallback Pointer to the STIF test class
|
|
244 |
* @return The status of execution of the test. KErrNone if the test
|
|
245 |
* was executed ok, any system wide errorcode otherwise.
|
|
246 |
*/
|
|
247 |
static TInt ConfigureWindowMixL( TTestResult& aResult,
|
|
248 |
CTestFlexTimer* aCallback );
|
|
249 |
|
|
250 |
/**
|
|
251 |
* @brief Configure timer after it has been started.
|
|
252 |
*
|
|
253 |
* Start two timers:
|
|
254 |
* T1:
|
|
255 |
* - delay 1 microsecond, window 0
|
|
256 |
* - interval 1 sec, window 0
|
|
257 |
*
|
|
258 |
* T2:
|
|
259 |
* - delay 2 sec, default window
|
|
260 |
* - interval 2 sec, default window
|
|
261 |
*
|
|
262 |
* Try to configure T2 with 1.5 sec delay and interval windows by both
|
|
263 |
* 32 bit and 64 bit Configure(). Check that configure returns KErrInUse
|
|
264 |
* and it has not changed the window sizes. The timer expirations should be
|
|
265 |
* T1: 1, 2, 3, 4, 5, 6, 7, 8, ...
|
|
266 |
* T2: 2, 4, 6, 8, ...
|
|
267 |
*
|
|
268 |
* Cancel the timer T2 and set its callback function to call Configure()
|
|
269 |
* (32 bit and 64 bit versions) while the timer is running. Check that both
|
|
270 |
* configurations return KErrInUse
|
|
271 |
*
|
|
272 |
* Cancel timer T2 and configure its delay and interval windows to 1.5 sec.
|
|
273 |
* Let the timer(s) run a while and check that the timer expirations are:
|
|
274 |
* T1: ..., 10, 11, 12, 13, ...
|
|
275 |
* T2: ..., 10, 11, 12, 13, ...
|
|
276 |
*
|
|
277 |
* @param aResult The result of the test.
|
|
278 |
* @param aCallback Pointer to the STIF test class
|
|
279 |
* @return The status of execution of the test. KErrNone if the test
|
|
280 |
* was executed ok, any system wide errorcode otherwise.
|
|
281 |
*/
|
|
282 |
static TInt ConfigureAfterStartL( TTestResult& aResult,
|
|
283 |
CTestFlexTimer* aCallback );
|
|
284 |
|
|
285 |
/**
|
|
286 |
* @brief Start a running timer.
|
|
287 |
*
|
|
288 |
* Test should panic with E32USER-CBase 42 (attempt to active CActive when
|
|
289 |
* a request is still outstanding).
|
|
290 |
*
|
|
291 |
* @param aResult The result of the test.
|
|
292 |
* @param aCallback Pointer to the STIF test class
|
|
293 |
* @return The status of execution of the test. KErrNone if the test
|
|
294 |
* was executed ok, any system wide errorcode otherwise.
|
|
295 |
*/
|
|
296 |
static TInt StartAfterStartL( TTestResult& aResult,
|
|
297 |
CTestFlexTimer* aCallback );
|
|
298 |
|
|
299 |
/**
|
|
300 |
* @brief Start a running timer in its callback function.
|
|
301 |
*
|
|
302 |
* Test should panic with E32USER-CBase 42 (attempt to active CActive when
|
|
303 |
* a request is still outstanding).
|
|
304 |
*
|
|
305 |
* @param aResult The result of the test.
|
|
306 |
* @param aCallback Pointer to the STIF test class
|
|
307 |
* @return The status of execution of the test. KErrNone if the test
|
|
308 |
* was executed ok, any system wide errorcode otherwise.
|
|
309 |
*/
|
|
310 |
static TInt StartInCallbackL( TTestResult& aResult,
|
|
311 |
CTestFlexTimer* aCallback );
|
|
312 |
|
|
313 |
/**
|
|
314 |
* Start timer with negative delay (32 bit).
|
|
315 |
*
|
|
316 |
* Start should panic with CFlexPeriodic 6 (EFlexPeriodicDelayLessThanZero)
|
|
317 |
*
|
|
318 |
* @param aResult The result of the test.
|
|
319 |
* @param aCallback Pointer to the STIF test class
|
|
320 |
* @return The status of execution of the test. KErrNone if the test
|
|
321 |
* was executed ok, any system wide errorcode otherwise.
|
|
322 |
*/
|
|
323 |
static TInt StartWithNegativeDelay32L( TTestResult& aResult,
|
|
324 |
CTestFlexTimer* aCallback );
|
|
325 |
|
|
326 |
/**
|
|
327 |
* @brief Start timer with zero interval (32 bit).
|
|
328 |
*
|
|
329 |
* Start should panic with CFlexPeriodic 7 (EFlexPeriodicIntervalTooSmall)
|
|
330 |
*
|
|
331 |
* @param aResult The result of the test.
|
|
332 |
* @param aCallback Pointer to the STIF test class
|
|
333 |
* @return The status of execution of the test. KErrNone if the test
|
|
334 |
* was executed ok, any system wide errorcode otherwise.
|
|
335 |
*/
|
|
336 |
static TInt StartWithZeroInterval32L( TTestResult& aResult,
|
|
337 |
CTestFlexTimer* aCallback );
|
|
338 |
|
|
339 |
/**
|
|
340 |
* @brief Start timer with negative interval (32 bit).
|
|
341 |
*
|
|
342 |
* Start should panic with CFlexPeriodic 7 (EFlexPeriodicIntervalTooSmall)
|
|
343 |
*
|
|
344 |
* @param aResult The result of the test.
|
|
345 |
* @param aCallback Pointer to the STIF test class
|
|
346 |
* @return The status of execution of the test. KErrNone if the test
|
|
347 |
* was executed ok, any system wide errorcode otherwise.
|
|
348 |
*/
|
|
349 |
static TInt StartWithNegativeInterval32L( TTestResult& aResult,
|
|
350 |
CTestFlexTimer* aCallback );
|
|
351 |
|
|
352 |
/**
|
|
353 |
* @brief Start timer with negative delay (64 bit).
|
|
354 |
*
|
|
355 |
* Start should panic with CFlexPeriodic 6 (EFlexPeriodicDelayLessThanZero)
|
|
356 |
*
|
|
357 |
* @param aResult The result of the test.
|
|
358 |
* @param aCallback Pointer to the STIF test class
|
|
359 |
* @return The status of execution of the test. KErrNone if the test
|
|
360 |
* was executed ok, any system wide errorcode otherwise.
|
|
361 |
*/
|
|
362 |
static TInt StartWithNegativeDelay64L( TTestResult& aResult,
|
|
363 |
CTestFlexTimer* aCallback );
|
|
364 |
|
|
365 |
/**
|
|
366 |
* @brief Start timer with zero interval (64 bit).
|
|
367 |
*
|
|
368 |
* Start should panic with CFlexPeriodic 7 (EFlexPeriodicIntervalTooSmall)
|
|
369 |
*
|
|
370 |
* @param aResult The result of the test.
|
|
371 |
* @param aCallback Pointer to the STIF test class
|
|
372 |
* @return The status of execution of the test. KErrNone if the test
|
|
373 |
* was executed ok, any system wide errorcode otherwise.
|
|
374 |
*/
|
|
375 |
static TInt StartWithZeroInterval64L( TTestResult& aResult,
|
|
376 |
CTestFlexTimer* aCallback );
|
|
377 |
|
|
378 |
/**
|
|
379 |
* @brief Start timer with negative interval (64 bit).
|
|
380 |
*
|
|
381 |
* Start should panic with CFlexPeriodic 7 (EFlexPeriodicIntervalTooSmall)
|
|
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 StartWithNegativeInterval64L( TTestResult& aResult,
|
|
389 |
CTestFlexTimer* aCallback );
|
|
390 |
|
|
391 |
/**
|
|
392 |
* @brief Configure timer with negative delay window (32 bit).
|
|
393 |
*
|
|
394 |
* Configure should panic with CFlexPeriodic 9
|
|
395 |
* (EFlexPeriodicIntervalWindowLessThanZero)
|
|
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 ConfigureWithNegativeDelayWindow32L(
|
|
403 |
TTestResult& aResult,
|
|
404 |
CTestFlexTimer* aCallback );
|
|
405 |
|
|
406 |
/**
|
|
407 |
* @brief Configure timer with negative interval window (32 bit).
|
|
408 |
*
|
|
409 |
* Configure should panic with CFlexPeriodic 8
|
|
410 |
* (EFlexPeriodicDelayWindowLessThanZero)
|
|
411 |
*
|
|
412 |
* @param aResult The result of the test.
|
|
413 |
* @param aCallback Pointer to the STIF test class
|
|
414 |
* @return The status of execution of the test. KErrNone if the test
|
|
415 |
* was executed ok, any system wide errorcode otherwise.
|
|
416 |
*/
|
|
417 |
static TInt ConfigureWithNegativeIntervalWindow32L(
|
|
418 |
TTestResult& aResult,
|
|
419 |
CTestFlexTimer* aCallback );
|
|
420 |
|
|
421 |
/**
|
|
422 |
* @brief Configure timer with negative delay window (64 bit).
|
|
423 |
*
|
|
424 |
* Configure should panic with CFlexPeriodic 9
|
|
425 |
* (EFlexPeriodicIntervalWindowLessThanZero)
|
|
426 |
*
|
|
427 |
* @param aResult The result of the test.
|
|
428 |
* @param aCallback Pointer to the STIF test class
|
|
429 |
* @return The status of execution of the test. KErrNone if the test
|
|
430 |
* was executed ok, any system wide errorcode otherwise.
|
|
431 |
*/
|
|
432 |
static TInt ConfigureWithNegativeDelayWindow64L(
|
|
433 |
TTestResult& aResult,
|
|
434 |
CTestFlexTimer* aCallback );
|
|
435 |
|
|
436 |
/**
|
|
437 |
* @brief Configure timer with negative interval window (64 bit).
|
|
438 |
*
|
|
439 |
* Configure should panic with CFlexPeriodic 8
|
|
440 |
* (EFlexPeriodicDelayWindowLessThanZero)
|
|
441 |
*
|
|
442 |
* @param aResult The result of the test.
|
|
443 |
* @param aCallback Pointer to the STIF test class
|
|
444 |
* @return The status of execution of the test. KErrNone if the test
|
|
445 |
* was executed ok, any system wide errorcode otherwise.
|
|
446 |
*/
|
|
447 |
static TInt ConfigureWithNegativeIntervalWindow64L(
|
|
448 |
TTestResult& aResult,
|
|
449 |
CTestFlexTimer* aCallback );
|
|
450 |
|
|
451 |
|
|
452 |
/**
|
|
453 |
* @brief Test timer start allowed value range.
|
|
454 |
*
|
|
455 |
* Start timers with following parameters:
|
|
456 |
*
|
|
457 |
* T1:
|
|
458 |
* - Configure (32 bit): delay window 1 sec, interval window 1 sec
|
|
459 |
* - Start (32 bit): delay 0 microseconds, interval 1 sec
|
|
460 |
*
|
|
461 |
* T2:
|
|
462 |
* - Configure (32 bit): delay window 1 sec, interval window 1 sec
|
|
463 |
* - Start (32 bit): delay 0x7FFFFF microseconds, interval 1 sec
|
|
464 |
*
|
|
465 |
* T3:
|
|
466 |
* - Configure (32 bit): delay window 1 sec, interval window 1 sec
|
|
467 |
* - Start (32 bit): delay 1 sec, interval 0 microseconds
|
|
468 |
*
|
|
469 |
* T4:
|
|
470 |
* - Configure (32 bit): delay window 1 sec, interval window 1 sec
|
|
471 |
* - Start (32 bit): delay 1 sec, interval 0x7FFFFF microseconds
|
|
472 |
*
|
|
473 |
* T5:
|
|
474 |
* - Configure (64 bit): delay window 1 sec, interval window 1 sec
|
|
475 |
* - Start (64 bit): delay 0 microseconds, interval 1 sec
|
|
476 |
*
|
|
477 |
* T6:
|
|
478 |
* - Configure (64 bit): delay window 1 sec, interval window 1 sec
|
|
479 |
* - Start (64 bit): delay 1 year, interval 1 sec
|
|
480 |
*
|
|
481 |
* T7:
|
|
482 |
* - Configure (64 bit): delay window 1 sec, interval window 1 sec
|
|
483 |
* - Start (64 bit): delay 1 sec, interval 0 microseconds
|
|
484 |
*
|
|
485 |
* T8:
|
|
486 |
* - Configure (64 bit): delay window 1 sec, interval window 1 sec
|
|
487 |
* - Start (64 bit): delay 1 sec, interval 1 year
|
|
488 |
*
|
|
489 |
* @param aResult The result of the test.
|
|
490 |
* @param aCallback Pointer to the STIF test class
|
|
491 |
* @return The status of execution of the test. KErrNone if the test
|
|
492 |
* was executed ok, any system wide errorcode otherwise.
|
|
493 |
*/
|
|
494 |
static TInt StartWithMinAndMaxL(
|
|
495 |
TTestResult& aResult,
|
|
496 |
CTestFlexTimer* aCallback );
|
|
497 |
|
|
498 |
|
|
499 |
/**
|
|
500 |
* @brief Start timer with maximum delay (64 bit), 0x7FFFFFFFFFFFFFFF.
|
|
501 |
*
|
|
502 |
* Start should panic with CFlexPeriodic 24
|
|
503 |
* (EFlexTimerServerIllegalTimerValue)
|
|
504 |
*
|
|
505 |
* @param aResult The result of the test.
|
|
506 |
* @param aCallback Pointer to the STIF test class
|
|
507 |
* @return The status of execution of the test. KErrNone if the test
|
|
508 |
* was executed ok, any system wide errorcode otherwise.
|
|
509 |
*/
|
|
510 |
static TInt StartWithMaximumDelay64L(
|
|
511 |
TTestResult& aResult,
|
|
512 |
CTestFlexTimer* aCallback );
|
|
513 |
|
|
514 |
/**
|
|
515 |
* @brief Start timer with maximum interval (64 bit), 0x7FFFFFFFFFFFFFFF.
|
|
516 |
*
|
|
517 |
* Start should panic with CFlexPeriodic 24
|
|
518 |
* (EFlexTimerServerIllegalTimerValue)
|
|
519 |
*
|
|
520 |
* @param aResult The result of the test.
|
|
521 |
* @param aCallback Pointer to the STIF test class
|
|
522 |
* @return The status of execution of the test. KErrNone if the test
|
|
523 |
* was executed ok, any system wide errorcode otherwise.
|
|
524 |
*/
|
|
525 |
static TInt StartWithMaximumInterval64L(
|
|
526 |
TTestResult& aResult,
|
|
527 |
CTestFlexTimer* aCallback );
|
|
528 |
|
|
529 |
/**
|
|
530 |
* @brief Start timer with NULL callback function (32 bit)
|
|
531 |
*
|
|
532 |
* @param aResult The result of the test.
|
|
533 |
* @param aCallback Pointer to the STIF test class
|
|
534 |
* @return The status of execution of the test. KErrNone if the test
|
|
535 |
* was executed ok, any system wide errorcode otherwise.
|
|
536 |
*/
|
|
537 |
static TInt StartWithNullCallBack32L(
|
|
538 |
TTestResult& aResult,
|
|
539 |
CTestFlexTimer* aCallback );
|
|
540 |
|
|
541 |
/**
|
|
542 |
* @brief Start timer with NULL callback function (64 bit)
|
|
543 |
*
|
|
544 |
* @param aResult The result of the test.
|
|
545 |
* @param aCallback Pointer to the STIF test class
|
|
546 |
* @return The status of execution of the test. KErrNone if the test
|
|
547 |
* was executed ok, any system wide errorcode otherwise.
|
|
548 |
*/
|
|
549 |
static TInt StartWithNullCallBack64L(
|
|
550 |
TTestResult& aResult,
|
|
551 |
CTestFlexTimer* aCallback );
|
|
552 |
|
|
553 |
|
|
554 |
/**
|
|
555 |
* @brief Crash client with active periodic flexible timer.
|
|
556 |
*
|
|
557 |
* Start two timers in separate threads:
|
|
558 |
* T1: delay 1 sec, interval 1 sec with default windows
|
|
559 |
* T2: delay 1 sec, interval 1 sec with default windows
|
|
560 |
*
|
|
561 |
* Panic timer T1's thread after 3 sec.
|
|
562 |
*
|
|
563 |
* Cancel T2 after 5 sec and check that it had worked correctly.
|
|
564 |
* Implementation of T2 uses test case StartOneTimerL().
|
|
565 |
*
|
|
566 |
* @param aResult The result of the test.
|
|
567 |
* @param aCallback Pointer to the STIF test class
|
|
568 |
* @return The status of execution of the test. KErrNone if the test
|
|
569 |
* was executed ok, any system wide errorcode otherwise.
|
|
570 |
*/
|
|
571 |
static TInt ClientCrashL(
|
|
572 |
TTestResult& aResult,
|
|
573 |
CTestFlexTimer* aCallback );
|
|
574 |
|
|
575 |
private:
|
|
576 |
|
|
577 |
/**
|
|
578 |
* Constructor is private to prevent instantiation of the class.
|
|
579 |
*/
|
|
580 |
CTestFlexPeriodic();
|
|
581 |
|
|
582 |
/**
|
|
583 |
* Run active scheduler for given time.
|
|
584 |
* @param aPeriod Time to run active scheduler.
|
|
585 |
*/
|
|
586 |
static void WaitL( TTimeIntervalMicroSeconds32 aPeriod );
|
|
587 |
|
|
588 |
/**
|
|
589 |
* Stop the active scheduler. A function for TCallBack.
|
|
590 |
* @param aArgument Not used.
|
|
591 |
* @return KErrNone. Always.
|
|
592 |
*/
|
|
593 |
static TInt StopScheduler( TAny* aArgument );
|
|
594 |
|
|
595 |
|
|
596 |
/**
|
|
597 |
* Do nothing. A function for TCallBack.
|
|
598 |
* @param aArgument Not used.
|
|
599 |
* @return KErrNone.
|
|
600 |
*/
|
|
601 |
static TInt DoNothing( TAny* aArgument );
|
|
602 |
|
|
603 |
/**
|
|
604 |
* Panics testcase if get called. A function for TCallBack.
|
|
605 |
* @param aArgument Not used.
|
|
606 |
* @return KErrNone.
|
|
607 |
*/
|
|
608 |
static TInt PanicClient( TAny* aArgument );
|
|
609 |
|
|
610 |
/**
|
|
611 |
* Add current time to given array. A function for TCallBack.
|
|
612 |
* @param aArgument Timestamp storage, type: RArray<TTime>*
|
|
613 |
* @return KErrNone.
|
|
614 |
*/
|
|
615 |
static TInt AddTimestamp( TAny* aArgument );
|
|
616 |
|
|
617 |
/**
|
|
618 |
* Restart the given timer. A function for TCallBack.
|
|
619 |
* @param aArgument The restart data, type: TRestartInfo*
|
|
620 |
* @return KErrNone.
|
|
621 |
*/
|
|
622 |
static TInt RestartTimer( TAny* aArgument );
|
|
623 |
|
|
624 |
/**
|
|
625 |
* Configure timer without cancellation in callback. A function for
|
|
626 |
* TCallBack.
|
|
627 |
* @param aArgument The conficure data, type: TConfigureInfo*
|
|
628 |
* @return KErrNone.
|
|
629 |
*/
|
|
630 |
static TInt ConfigureTimer( TAny* aArgument );
|
|
631 |
|
|
632 |
/**
|
|
633 |
* Start timer without cancellation in callback. A function for TCallBack.
|
|
634 |
* @param aArgument The timer, type: CFlexPeriodic*
|
|
635 |
* @return KErrNone.
|
|
636 |
*/
|
|
637 |
static TInt StartTimer( TAny* aArgument );
|
|
638 |
|
|
639 |
/**
|
|
640 |
* Verify that the timestamps are expired at maximum window
|
|
641 |
* @param aTimestamps An array of times
|
|
642 |
* @param aDelay Requested delay of the 1st time
|
|
643 |
* @param aInterval Requested delay from the 2nd time
|
|
644 |
* @param aDelayWindow Time how much 1st time can be early
|
|
645 |
* @param aIntervalWindow Time how much times can be early from the 2nd time
|
|
646 |
* @return ETrue if all timestamps are in given delay
|
|
647 |
*/
|
|
648 |
static TBool AreTimestampsAtWindow(
|
|
649 |
const RArray<TTime>& aTimestamps,
|
|
650 |
const TTimeIntervalMicroSeconds32& aDelay,
|
|
651 |
const TTimeIntervalMicroSeconds32& aInterval,
|
|
652 |
const TTimeIntervalMicroSeconds32& aDelayWindow,
|
|
653 |
const TTimeIntervalMicroSeconds32& aIntervalWindow );
|
|
654 |
|
|
655 |
/**
|
|
656 |
* Verify that the timestamps are expired at maximum window
|
|
657 |
* @param aTimestamps An array of times
|
|
658 |
* @param aDelay Requested delay of the 1st time
|
|
659 |
* @param aInterval Requested delay from the 2nd time
|
|
660 |
* @param aDelayWindow Time how much 1st time can be early
|
|
661 |
* @param aIntervalWindow Time how much times can be early from the 2nd time
|
|
662 |
* @return ETrue if all timestamps are in given delay
|
|
663 |
*/
|
|
664 |
static TBool AreTimestampsAtWindow(
|
|
665 |
const RArray<TTime>& aTimestamps,
|
|
666 |
const TTimeIntervalMicroSeconds& aDelay,
|
|
667 |
const TTimeIntervalMicroSeconds& aInterval,
|
|
668 |
const TTimeIntervalMicroSeconds& aDelayWindow,
|
|
669 |
const TTimeIntervalMicroSeconds& aIntervalWindow );
|
|
670 |
|
|
671 |
/**
|
|
672 |
* Compare two arrays of timestamps.
|
|
673 |
* @param aLeft Array of timestamps to be compared
|
|
674 |
* @param aRight Array of timestamps to be compared
|
|
675 |
* @return ETrue if the arrays has the same timestamps, EFalse otherwise
|
|
676 |
*/
|
|
677 |
static TBool AreTimestampsSame(
|
|
678 |
const RArray<TTime>& aLeft,
|
|
679 |
const RArray<TTime>& aRight );
|
|
680 |
|
|
681 |
/**
|
|
682 |
* Parameter types of two timers are templated, so, 32 bit and 64 bit
|
|
683 |
* interfaces can be tested without duplicated source code.
|
|
684 |
*
|
|
685 |
* Possible values for template are:
|
|
686 |
* - TTimeIntervalMicroSeconds
|
|
687 |
* - TTimeIntervalMicroSeconds32
|
|
688 |
*/
|
|
689 |
template <class firstType, class secondType>
|
|
690 |
static TInt ConfigureWindowL( TTestResult& aResult );
|
|
691 |
|
|
692 |
/**
|
|
693 |
* Template function for NOK API test cases.
|
|
694 |
*
|
|
695 |
* Types for CFlexPeriodic::Start() and CFlexPeriodic::Configure() are
|
|
696 |
* templated, so, 32 bit and 64 bin interfaces can be tested without
|
|
697 |
* duplicated code.
|
|
698 |
*
|
|
699 |
* Function creates a flexible periodic timer, configures is, starts it.
|
|
700 |
* After one second the timer will be cancelled and destroyed.
|
|
701 |
*
|
|
702 |
* Possible values for configureType and startType are:
|
|
703 |
* - TTimeIntervalMicroSeconds
|
|
704 |
* - TTimeIntervalMicroSeconds32
|
|
705 |
*
|
|
706 |
* @param aDelay Value for timer's delay in start
|
|
707 |
* @param aInterval Value for timer's interval in start
|
|
708 |
* @param aDelayWindow Value for timer's delay window in configure
|
|
709 |
* @param aIntervalWindow Value for timer's interval window in configure
|
|
710 |
*/
|
|
711 |
template <class configureType, class startType>
|
|
712 |
static void ConfigureAndStartTimerL(
|
|
713 |
RArray<TTime>& aTimestamps,
|
|
714 |
TInt64 aDelay,
|
|
715 |
TInt64 aInterval,
|
|
716 |
TInt64 aDelayWindow,
|
|
717 |
TInt64 aIntervalWindow );
|
|
718 |
|
|
719 |
/**
|
|
720 |
* Start timer with NULL callback function
|
|
721 |
*
|
|
722 |
* Possible values for startType are:
|
|
723 |
* - TTimeIntervalMicroSeconds
|
|
724 |
* - TTimeIntervalMicroSeconds32
|
|
725 |
*
|
|
726 |
* @param aResult The result of the test.
|
|
727 |
* @param aCallback Pointer to the STIF test class
|
|
728 |
* @return The status of execution of the test. KErrNone if the test
|
|
729 |
* was executed ok, any system wide errorcode otherwise.
|
|
730 |
*/
|
|
731 |
template <class startType>
|
|
732 |
static TInt StartWithNullCallBackL(
|
|
733 |
TTestResult& aResult,
|
|
734 |
CTestFlexTimer* aCallback );
|
|
735 |
|
|
736 |
/**
|
|
737 |
* Run test case in own thread
|
|
738 |
*
|
|
739 |
* @param aThread The thread in which the test case is run
|
|
740 |
* @param aArguments Arguments for running a test case
|
|
741 |
* @return The status of execution of the test
|
|
742 |
*/
|
|
743 |
static TInt RunInThread(
|
|
744 |
RThread& aThread,
|
|
745 |
TTestCaseArguments& aArguments );
|
|
746 |
|
|
747 |
/**
|
|
748 |
* Start running a thread. A function of format TThreadFunction.
|
|
749 |
* Create trap harness for the thread and call RunTestCaseL()
|
|
750 |
*
|
|
751 |
* @param aArgument Test case data, type: TTestCaseArguments
|
|
752 |
* @return The status of running the thread
|
|
753 |
*/
|
|
754 |
static TInt RunTestCase( TAny* aArgument );
|
|
755 |
|
|
756 |
/**
|
|
757 |
* The second phase of start running a thread.
|
|
758 |
* Initialize scheduler and start the test case.
|
|
759 |
*
|
|
760 |
* @param aArgument Test case data, type: TTestCaseArguments
|
|
761 |
*/
|
|
762 |
static void RunTestCaseL( TAny* aArgument );
|
|
763 |
|
|
764 |
/**
|
|
765 |
* Panic thread after a while.
|
|
766 |
* @param aResult The result of the test.
|
|
767 |
* @param aCallback Pointer to the STIF test class
|
|
768 |
* @return The status of execution of the test. KErrNone if the test
|
|
769 |
* was executed ok, any system wide errorcode otherwise.
|
|
770 |
*/
|
|
771 |
static TInt DoPanicL( TTestResult& aResult, CTestFlexTimer* aCallback );
|
|
772 |
|
|
773 |
};
|
|
774 |
|
|
775 |
#endif // TESTFLEXPERIODIC_H
|