|
1 // Copyright (c) 1997-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 // |
|
15 |
|
16 #include "ASTstAlarmTest.h" |
|
17 |
|
18 // Constants |
|
19 const TInt KMaxClockAlarms = 8; |
|
20 |
|
21 |
|
22 static void testSetClockAlarms() |
|
23 // |
|
24 // Set all clock alarms |
|
25 // |
|
26 { |
|
27 TheAlarmTest.Test().Next(_L("Set Clock Alarms")); |
|
28 TInt n = TheAlarmTest.Session().NumberOfAlarmsActiveInQueue(); |
|
29 TheAlarmTest(n==0, __LINE__); |
|
30 // |
|
31 TASShdAlarm alarm; |
|
32 alarm.NextDueTime().HomeTime(); |
|
33 alarm.NextDueTime() += TTimeIntervalDays(3); |
|
34 alarm.RepeatDefinition() = EAlarmRepeatDefintionRepeatOnce; |
|
35 // |
|
36 for (TInt i=0; i<KMaxClockAlarms; i++) |
|
37 { |
|
38 alarm.Message().Num(i); |
|
39 TInt r = TheAlarmTest.Session().AlarmAdd(alarm); |
|
40 TheAlarmTest(r == KErrNone, __LINE__); |
|
41 } |
|
42 n = TheAlarmTest.Session().NumberOfAlarmsActiveInQueue(); |
|
43 TheAlarmTest(n==KMaxClockAlarms, __LINE__); |
|
44 } |
|
45 |
|
46 static TAlarmId SetAlarmLastMonday(TAlarmRepeatDefinition aRepeat, TTimeIntervalMinutes aMinuteOffset = 0) |
|
47 // |
|
48 // Set clock alarm 0 for monday |
|
49 // |
|
50 { |
|
51 TTime time; |
|
52 time.HomeTime(); |
|
53 time+=TTimeIntervalDays(-time.DayNoInWeek()); |
|
54 time+=aMinuteOffset; |
|
55 // |
|
56 TASShdAlarm alarm; |
|
57 alarm.NextDueTime() = time; |
|
58 alarm.Message() = _L("test alarm repeat"); |
|
59 alarm.RepeatDefinition() = aRepeat; |
|
60 // |
|
61 TInt r = TheAlarmTest.Session().AlarmAdd(alarm); |
|
62 TheAlarmTest(r == KErrNone, __LINE__); |
|
63 return alarm.Id(); |
|
64 } |
|
65 |
|
66 TAlarmId SetAlarmNextMonday(TAlarmRepeatDefinition aRepeat) |
|
67 // |
|
68 // Set clock alarm 0 for monday |
|
69 // |
|
70 { |
|
71 TTime time; |
|
72 time.HomeTime(); |
|
73 time+=TTimeIntervalDays(7-time.DayNoInWeek()); |
|
74 // |
|
75 TASShdAlarm alarm; |
|
76 alarm.NextDueTime() = time; |
|
77 alarm.Message() = _L("test alarm repeat"); |
|
78 alarm.RepeatDefinition() = aRepeat; |
|
79 // |
|
80 TInt r = TheAlarmTest.Session().AlarmAdd(alarm); |
|
81 TheAlarmTest(r == KErrNone, __LINE__); |
|
82 return alarm.Id(); |
|
83 } |
|
84 |
|
85 |
|
86 static void testSetClockUtcAlarms() |
|
87 // |
|
88 // Set all clock UTC alarms |
|
89 // |
|
90 { |
|
91 TheAlarmTest.Test().Next(_L("Set Clock Alarms")); |
|
92 TInt n = TheAlarmTest.Session().NumberOfAlarmsActiveInQueue(); |
|
93 TheAlarmTest(n==0, __LINE__); |
|
94 // |
|
95 TASShdAlarm alarm; |
|
96 TTime time; |
|
97 time.UniversalTime(); |
|
98 time += TTimeIntervalDays(3); |
|
99 alarm.SetUtcNextDueTime(time); |
|
100 alarm.RepeatDefinition()=EAlarmRepeatDefintionRepeatOnce; |
|
101 // |
|
102 for (TInt i=0; i<KMaxClockAlarms; i++) |
|
103 { |
|
104 TAlarmMessage m = alarm.Message(); |
|
105 m.Num(i); |
|
106 alarm.Message()=m; |
|
107 TInt r = TheAlarmTest.Session().AlarmAdd(alarm); |
|
108 TheAlarmTest(r == KErrNone, __LINE__); |
|
109 } |
|
110 n = TheAlarmTest.Session().NumberOfAlarmsActiveInQueue(); |
|
111 TheAlarmTest(n==KMaxClockAlarms, __LINE__); |
|
112 } |
|
113 |
|
114 static TAlarmId SetUtcAlarmLastMonday(TAlarmRepeatDefinition aRepeat, TTimeIntervalMinutes aMinuteOffset = 0) |
|
115 // |
|
116 // Set clock UTC alarm 0 for monday |
|
117 // |
|
118 { |
|
119 TTime time; |
|
120 time.UniversalTime(); |
|
121 time+=TTimeIntervalDays(-time.DayNoInWeek()); |
|
122 time+=aMinuteOffset; |
|
123 // |
|
124 TASShdAlarm alarm; |
|
125 alarm.SetUtcNextDueTime(time); |
|
126 alarm.Message()=(_L("test alarm repeat")); |
|
127 alarm.RepeatDefinition()=aRepeat; |
|
128 // |
|
129 TInt r = TheAlarmTest.Session().AlarmAdd(alarm); |
|
130 TheAlarmTest(r == KErrNone, __LINE__); |
|
131 return alarm.Id(); |
|
132 } |
|
133 |
|
134 TAlarmId SetUtcAlarmNextMonday(TAlarmRepeatDefinition aRepeat) |
|
135 // |
|
136 // Set clock UTC alarm 0 for monday |
|
137 // |
|
138 { |
|
139 TTime time; |
|
140 time.UniversalTime(); |
|
141 time+=TTimeIntervalDays(7-time.DayNoInWeek()); |
|
142 // |
|
143 TASShdAlarm alarm; |
|
144 alarm.SetUtcNextDueTime(time); |
|
145 alarm.Message()=(_L("test alarm repeat")); |
|
146 alarm.RepeatDefinition()=aRepeat; |
|
147 // |
|
148 TInt r = TheAlarmTest.Session().AlarmAdd(alarm); |
|
149 TheAlarmTest(r == KErrNone, __LINE__); |
|
150 return alarm.Id(); |
|
151 } |
|
152 |
|
153 |
|
154 #ifdef _DEBUG |
|
155 void ChangeDayToTuesday() |
|
156 // |
|
157 // Change the system time/date to Tuesday |
|
158 // |
|
159 { |
|
160 TTime time; |
|
161 time.UniversalTime(); |
|
162 time+=TTimeIntervalDays(7-time.DayNoInWeek()+ETuesday); |
|
163 |
|
164 User::SetUTCTime(time); |
|
165 User::After(KTimeToWait); |
|
166 } |
|
167 #endif |
|
168 |
|
169 |
|
170 static void testNextAlarm(TDay aDay, TInt aLineNum, TInt aAlarmNumber=1) |
|
171 // |
|
172 // Test the day of the next alarm |
|
173 // |
|
174 { |
|
175 // Wait for a fraction of a second before testing. The alarm |
|
176 // server takes some time to update the states of alarm objects |
|
177 // and if we request information from the server too quickly after |
|
178 // adding an alarm to its queue, it won't have had time to update |
|
179 // the state of the objects accordingly. |
|
180 User::After(KTimeToWait); |
|
181 // |
|
182 TInt n = TheAlarmTest.Session().NumberOfAlarmsActiveInQueue(); |
|
183 if (n != aAlarmNumber) |
|
184 { |
|
185 TheAlarmTest.Test().Printf(_L("testNextAlarm: aDay %i, aAlarmNumber %i, called from line %u"), |
|
186 aDay, aAlarmNumber, aLineNum); |
|
187 TheAlarmTest(EFalse, __LINE__); |
|
188 } |
|
189 // |
|
190 if (aAlarmNumber) |
|
191 { |
|
192 TInt r; |
|
193 TAlarmId nextDueAlarmId; |
|
194 // |
|
195 r = TheAlarmTest.Session().GetNextDueAlarmId(nextDueAlarmId); |
|
196 if (r == KErrNotFound) |
|
197 { |
|
198 TheAlarmTest.Test().Printf(_L("testNextAlarm: aDay %i, aAlarmNumber %i, called from line %u"), |
|
199 aDay, aAlarmNumber, aLineNum); |
|
200 TheAlarmTest(EFalse, __LINE__); |
|
201 } |
|
202 // |
|
203 TASShdAlarm alarm; |
|
204 r = TheAlarmTest.Session().GetAlarmDetails(nextDueAlarmId, alarm); |
|
205 if (r != KErrNone) |
|
206 { |
|
207 TheAlarmTest.Test().Printf(_L("testNextAlarm: aDay %i, aAlarmNumber %i, called from line %u"), |
|
208 aDay, aAlarmNumber, aLineNum); |
|
209 TheAlarmTest(EFalse, __LINE__); |
|
210 } |
|
211 // |
|
212 const TDay day = alarm.NextDueTime().DayNoInWeek(); |
|
213 if (day != aDay) |
|
214 { |
|
215 TheAlarmTest.Test().Printf(_L("testNextAlarm: aDay %i, aAlarmNumber %i, called from line %u"), |
|
216 aDay, aAlarmNumber, aLineNum); |
|
217 TheAlarmTest(EFalse, __LINE__); |
|
218 } |
|
219 } |
|
220 } |
|
221 |
|
222 |
|
223 static void testClockRepeats() |
|
224 // |
|
225 // Test clock alarm repeats |
|
226 // |
|
227 { |
|
228 TheAlarmTest.Test().Next(_L("Clock Alarm repeats")); |
|
229 #if !defined(_DEBUG) |
|
230 TheAlarmTest.Test().Printf(_L("This test can only be done in debug builds\n")); |
|
231 #else |
|
232 TAlarmId id; |
|
233 TInt n; |
|
234 TInt r; |
|
235 // |
|
236 n = TheAlarmTest.Session().NumberOfAlarmsActiveInQueue(); |
|
237 TheAlarmTest(n==0, __LINE__); |
|
238 // |
|
239 id = SetAlarmNextMonday(EAlarmRepeatDefintionRepeatOnce); |
|
240 ChangeDayToTuesday(); |
|
241 testNextAlarm(EMonday, __LINE__, 0); |
|
242 n = TheAlarmTest.Session().NumberOfAlarmsActiveInQueue(); |
|
243 TheAlarmTest(n==0, __LINE__); |
|
244 // Don't need to delete it - it shouldn't be there anyway |
|
245 // |
|
246 id = SetAlarmNextMonday(EAlarmRepeatDefintionRepeatDaily); |
|
247 ChangeDayToTuesday(); |
|
248 testNextAlarm(EWednesday, __LINE__); |
|
249 r = TheAlarmTest.Session().AlarmDelete(id); |
|
250 TheAlarmTest(r == KErrNone, __LINE__); |
|
251 // |
|
252 id = SetAlarmNextMonday(EAlarmRepeatDefintionRepeatWeekly); |
|
253 ChangeDayToTuesday(); |
|
254 testNextAlarm(EMonday, __LINE__); |
|
255 r = TheAlarmTest.Session().AlarmDelete(id); |
|
256 TheAlarmTest(r == KErrNone, __LINE__); |
|
257 // |
|
258 id = SetAlarmNextMonday(EAlarmRepeatDefintionRepeatWorkday); |
|
259 ChangeDayToTuesday(); |
|
260 testNextAlarm(EWednesday, __LINE__); |
|
261 r = TheAlarmTest.Session().AlarmDelete(id); |
|
262 TheAlarmTest(r == KErrNone, __LINE__); |
|
263 // |
|
264 n = TheAlarmTest.Session().NumberOfAlarmsActiveInQueue(); |
|
265 TheAlarmTest(n==0, __LINE__); |
|
266 #endif |
|
267 } |
|
268 |
|
269 |
|
270 static void testPastClockRepeats() |
|
271 // |
|
272 // Test past clock alarm repeats |
|
273 // |
|
274 { |
|
275 TheAlarmTest.Test().Next(_L("Past Clock Repeats")); |
|
276 // |
|
277 TAlarmId id; |
|
278 TInt n; |
|
279 TInt r; |
|
280 // |
|
281 n = TheAlarmTest.Session().NumberOfAlarmsActiveInQueue(); |
|
282 TheAlarmTest(n == 0, __LINE__); |
|
283 // |
|
284 id = SetAlarmLastMonday(EAlarmRepeatDefintionRepeatOnce); |
|
285 testNextAlarm(EMonday, __LINE__, 0); |
|
286 r = TheAlarmTest.Session().AlarmDelete(id); |
|
287 TheAlarmTest(r == KErrNone, __LINE__); |
|
288 // |
|
289 n = TheAlarmTest.Session().NumberOfAlarmsActiveInQueue(); |
|
290 TheAlarmTest(n == 0, __LINE__); |
|
291 // |
|
292 TTime time; |
|
293 time.HomeTime(); |
|
294 time+=TTimeIntervalDays(1); |
|
295 TDay day=time.DayNoInWeek(); |
|
296 // |
|
297 id = SetAlarmLastMonday(EAlarmRepeatDefintionRepeatDaily); |
|
298 testNextAlarm(day, __LINE__); |
|
299 r = TheAlarmTest.Session().AlarmDelete(id); |
|
300 TheAlarmTest(r == KErrNone, __LINE__); |
|
301 // |
|
302 id = SetAlarmLastMonday(EAlarmRepeatDefintionRepeatWeekly); |
|
303 testNextAlarm(EMonday, __LINE__); |
|
304 r = TheAlarmTest.Session().AlarmDelete(id); |
|
305 TheAlarmTest(r == KErrNone, __LINE__); |
|
306 |
|
307 // Assumes clock repeats use current locale |
|
308 TLocale locale; |
|
309 locale.SetWorkDays(2); // Tuesday |
|
310 locale.Set(); |
|
311 User::After(KTimeToWait); |
|
312 // |
|
313 id = SetAlarmLastMonday(EAlarmRepeatDefintionRepeatWorkday); |
|
314 testNextAlarm(ETuesday, __LINE__); |
|
315 r = TheAlarmTest.Session().AlarmDelete(id); |
|
316 TheAlarmTest(r == KErrNone, __LINE__); |
|
317 // |
|
318 locale.SetWorkDays(4); // Wednesday |
|
319 locale.Set(); |
|
320 User::After(KTimeToWait); |
|
321 // |
|
322 id = SetAlarmLastMonday(EAlarmRepeatDefintionRepeatWorkday); |
|
323 testNextAlarm(EWednesday, __LINE__); |
|
324 r = TheAlarmTest.Session().AlarmDelete(id); |
|
325 TheAlarmTest(r == KErrNone, __LINE__); |
|
326 // |
|
327 locale.SetWorkDays(0); // None |
|
328 locale.Set(); |
|
329 User::After(KTimeToWait); |
|
330 // |
|
331 id = SetAlarmLastMonday(EAlarmRepeatDefintionRepeatWorkday); |
|
332 r = TheAlarmTest.Session().AlarmDelete(id); |
|
333 TheAlarmTest(r == KErrNone, __LINE__); |
|
334 // |
|
335 n = TheAlarmTest.Session().NumberOfAlarmsActiveInQueue(); |
|
336 TheAlarmTest(n == 0, __LINE__); |
|
337 // |
|
338 locale.SetWorkDays(1|2|4|8|16); // Mon-Fri |
|
339 locale.Set(); |
|
340 User::After(KTimeToWait); |
|
341 // |
|
342 TTimeIntervalMinutes minuteOffSet = -10; |
|
343 id = SetAlarmLastMonday(EAlarmRepeatDefintionRepeatNext24Hours,minuteOffSet); |
|
344 time.HomeTime(); |
|
345 time+=minuteOffSet; |
|
346 time+=TTimeIntervalDays(1); |
|
347 day=time.DayNoInWeek(); |
|
348 testNextAlarm(day, __LINE__); |
|
349 r = TheAlarmTest.Session().AlarmDelete(id); |
|
350 TheAlarmTest(r == KErrNone, __LINE__); |
|
351 // |
|
352 minuteOffSet = 30; |
|
353 id = SetAlarmLastMonday(EAlarmRepeatDefintionRepeatNext24Hours,minuteOffSet); |
|
354 time.HomeTime(); |
|
355 //DEF062643 - Increase the time by the same number of minutes as the offset in |
|
356 //SetAlarmLastMonday which has the effect of going back 23.5 hrs in |
|
357 //the past so that we can be sure that the day does switch over just |
|
358 //incase the testcase runs between 23.30 and 24.00 hrs |
|
359 time+=minuteOffSet; |
|
360 day=time.DayNoInWeek(); |
|
361 testNextAlarm(day, __LINE__); |
|
362 r = TheAlarmTest.Session().AlarmDelete(id); |
|
363 TheAlarmTest(r == KErrNone, __LINE__); |
|
364 } |
|
365 |
|
366 static void testNextUtcAlarm(TDay aDay, TInt aLineNum, TInt aAlarmNumber=1) |
|
367 // |
|
368 // Test the day of the next UTC alarm |
|
369 // |
|
370 { |
|
371 // Wait for a fraction of a second before testing. The alarm |
|
372 // server takes some time to update the states of alarm objects |
|
373 // and if we request information from the server too quickly after |
|
374 // adding an alarm to its queue, it won't have had time to update |
|
375 // the state of the objects accordingly. |
|
376 User::After(KTimeToWait); |
|
377 // |
|
378 TInt n = TheAlarmTest.Session().NumberOfAlarmsActiveInQueue(); |
|
379 if (!n==aAlarmNumber) |
|
380 { |
|
381 TheAlarmTest.Test().Printf(_L("testNextUtcAlarm: aDay %i, aAlarmNumber %i, called from line %u"), |
|
382 aDay, aAlarmNumber, aLineNum); |
|
383 TheAlarmTest(EFalse, __LINE__); |
|
384 } |
|
385 // |
|
386 if (aAlarmNumber) |
|
387 { |
|
388 TInt r; |
|
389 TAlarmId nextDueAlarmId; |
|
390 // |
|
391 r = TheAlarmTest.Session().GetNextDueAlarmId(nextDueAlarmId); |
|
392 if (r == KErrNotFound) |
|
393 { |
|
394 TheAlarmTest.Test().Printf(_L("testNextUtcAlarm: aDay %i, aAlarmNumber %i, called from line %u"), |
|
395 aDay, aAlarmNumber, aLineNum); |
|
396 TheAlarmTest(EFalse, __LINE__); |
|
397 } |
|
398 // |
|
399 TASShdAlarm alarm; |
|
400 r = TheAlarmTest.Session().GetAlarmDetails(nextDueAlarmId, alarm); |
|
401 if (r != KErrNone) |
|
402 { |
|
403 TheAlarmTest.Test().Printf(_L("testNextUtcAlarm: aDay %i, aAlarmNumber %i, called from line %u"), |
|
404 aDay, aAlarmNumber, aLineNum); |
|
405 TheAlarmTest(EFalse, __LINE__); |
|
406 } |
|
407 // |
|
408 const TDay day = alarm.NextDueTime().DayNoInWeek(); |
|
409 if (day != aDay) |
|
410 { |
|
411 TheAlarmTest.Test().Printf(_L("testNextUtcAlarm: aDay %i, aAlarmNumber %i, called from line %u"), |
|
412 aDay, aAlarmNumber, aLineNum); |
|
413 TheAlarmTest(EFalse, __LINE__); |
|
414 } |
|
415 } |
|
416 } |
|
417 |
|
418 |
|
419 static void testClockRepeatsUtc() |
|
420 // |
|
421 // Test clock UTC alarm repeats |
|
422 // |
|
423 { |
|
424 TheAlarmTest.Test().Next(_L("Clock UTC Alarm repeats")); |
|
425 #if !defined(_DEBUG) |
|
426 TheAlarmTest.Test().Printf(_L("This test can only be done in debug builds\n")); |
|
427 #else |
|
428 TAlarmId id; |
|
429 TInt n; |
|
430 TInt r; |
|
431 // |
|
432 n = TheAlarmTest.Session().NumberOfAlarmsActiveInQueue(); |
|
433 TheAlarmTest(n==0, __LINE__); |
|
434 // |
|
435 id = SetUtcAlarmNextMonday(EAlarmRepeatDefintionRepeatOnce); |
|
436 ChangeDayToTuesday(); |
|
437 testNextUtcAlarm(EMonday, __LINE__, 0); |
|
438 n = TheAlarmTest.Session().NumberOfAlarmsActiveInQueue(); |
|
439 TheAlarmTest(n==0, __LINE__); |
|
440 // Don't need to delete it - it shouldn't be there anyway |
|
441 // |
|
442 id = SetUtcAlarmNextMonday(EAlarmRepeatDefintionRepeatDaily); |
|
443 ChangeDayToTuesday(); |
|
444 testNextUtcAlarm(EWednesday, __LINE__); |
|
445 r = TheAlarmTest.Session().AlarmDelete(id); |
|
446 TheAlarmTest(r == KErrNone, __LINE__); |
|
447 // |
|
448 id = SetUtcAlarmNextMonday(EAlarmRepeatDefintionRepeatWeekly); |
|
449 ChangeDayToTuesday(); |
|
450 testNextUtcAlarm(EMonday, __LINE__); |
|
451 r = TheAlarmTest.Session().AlarmDelete(id); |
|
452 TheAlarmTest(r == KErrNone, __LINE__); |
|
453 // |
|
454 id = SetUtcAlarmNextMonday(EAlarmRepeatDefintionRepeatWorkday); |
|
455 ChangeDayToTuesday(); |
|
456 testNextUtcAlarm(EWednesday, __LINE__); |
|
457 r = TheAlarmTest.Session().AlarmDelete(id); |
|
458 TheAlarmTest(r == KErrNone, __LINE__); |
|
459 // |
|
460 n = TheAlarmTest.Session().NumberOfAlarmsActiveInQueue(); |
|
461 TheAlarmTest(n==0, __LINE__); |
|
462 #endif |
|
463 } |
|
464 |
|
465 |
|
466 static void testPastClockRepeatsUtc() |
|
467 // |
|
468 // Test past clock UTC alarm repeats |
|
469 // |
|
470 { |
|
471 TheAlarmTest.Test().Next(_L("Past Clock Repeats for UTC alarms")); |
|
472 // |
|
473 TAlarmId id; |
|
474 TInt n; |
|
475 TInt r; |
|
476 // |
|
477 n = TheAlarmTest.Session().NumberOfAlarmsActiveInQueue(); |
|
478 TheAlarmTest(n == 0, __LINE__); |
|
479 // |
|
480 id = SetUtcAlarmLastMonday(EAlarmRepeatDefintionRepeatOnce); |
|
481 testNextUtcAlarm(EMonday, __LINE__, 0); |
|
482 r = TheAlarmTest.Session().AlarmDelete(id); |
|
483 TheAlarmTest(r == KErrNone, __LINE__); |
|
484 // |
|
485 n = TheAlarmTest.Session().NumberOfAlarmsActiveInQueue(); |
|
486 TheAlarmTest(n == 0, __LINE__); |
|
487 // |
|
488 TTime time; |
|
489 time.UniversalTime(); |
|
490 time+=TTimeIntervalDays(1); |
|
491 TDay day=time.DayNoInWeek(); |
|
492 // |
|
493 id = SetUtcAlarmLastMonday(EAlarmRepeatDefintionRepeatDaily); |
|
494 testNextUtcAlarm(day, __LINE__); |
|
495 r = TheAlarmTest.Session().AlarmDelete(id); |
|
496 TheAlarmTest(r == KErrNone, __LINE__); |
|
497 // |
|
498 id = SetUtcAlarmLastMonday(EAlarmRepeatDefintionRepeatWeekly); |
|
499 testNextUtcAlarm(EMonday, __LINE__); |
|
500 r = TheAlarmTest.Session().AlarmDelete(id); |
|
501 TheAlarmTest(r == KErrNone, __LINE__); |
|
502 |
|
503 // Assumes clock repeats use current locale |
|
504 TLocale locale; |
|
505 locale.SetWorkDays(2); // Tuesday |
|
506 locale.Set(); |
|
507 User::After(KTimeToWait); |
|
508 // |
|
509 id = SetUtcAlarmLastMonday(EAlarmRepeatDefintionRepeatWorkday); |
|
510 testNextUtcAlarm(ETuesday, __LINE__); |
|
511 r = TheAlarmTest.Session().AlarmDelete(id); |
|
512 TheAlarmTest(r == KErrNone, __LINE__); |
|
513 // |
|
514 locale.SetWorkDays(4); // Wednesday |
|
515 locale.Set(); |
|
516 User::After(KTimeToWait); |
|
517 // |
|
518 id = SetUtcAlarmLastMonday(EAlarmRepeatDefintionRepeatWorkday); |
|
519 testNextUtcAlarm(EWednesday, __LINE__); |
|
520 r = TheAlarmTest.Session().AlarmDelete(id); |
|
521 TheAlarmTest(r == KErrNone, __LINE__); |
|
522 // |
|
523 locale.SetWorkDays(0); // None |
|
524 locale.Set(); |
|
525 User::After(KTimeToWait); |
|
526 // |
|
527 id = SetUtcAlarmLastMonday(EAlarmRepeatDefintionRepeatWorkday); |
|
528 r = TheAlarmTest.Session().AlarmDelete(id); |
|
529 TheAlarmTest(r == KErrNone, __LINE__); |
|
530 // |
|
531 n = TheAlarmTest.Session().NumberOfAlarmsActiveInQueue(); |
|
532 TheAlarmTest(n == 0, __LINE__); |
|
533 // |
|
534 locale.SetWorkDays(1|2|4|8|16); // Mon-Fri |
|
535 locale.Set(); |
|
536 User::After(KTimeToWait); |
|
537 // |
|
538 TTimeIntervalMinutes minuteOffSet = -10; |
|
539 id = SetUtcAlarmLastMonday(EAlarmRepeatDefintionRepeatNext24Hours,minuteOffSet); |
|
540 time.UniversalTime(); |
|
541 time+=minuteOffSet; |
|
542 time+=TTimeIntervalDays(1); |
|
543 day=time.DayNoInWeek(); |
|
544 testNextUtcAlarm(day, __LINE__); |
|
545 r = TheAlarmTest.Session().AlarmDelete(id); |
|
546 TheAlarmTest(r == KErrNone, __LINE__); |
|
547 // |
|
548 |
|
549 minuteOffSet = 30; |
|
550 id = SetUtcAlarmLastMonday(EAlarmRepeatDefintionRepeatNext24Hours,minuteOffSet); |
|
551 time.UniversalTime(); |
|
552 //DEF062643 - Increase the time by the same number of minutes as the offset in |
|
553 //SetAlarmLastMonday which has the effect of going back 23.5 hrs in |
|
554 //the past so that we can be sure that the day does switch over just |
|
555 //incase the testcase runs between 23.30 and 24.00 hrs |
|
556 time+=minuteOffSet; |
|
557 day=time.DayNoInWeek(); |
|
558 testNextUtcAlarm(day, __LINE__); |
|
559 r = TheAlarmTest.Session().AlarmDelete(id); |
|
560 TheAlarmTest(r == KErrNone, __LINE__); |
|
561 } |
|
562 |
|
563 /** |
|
564 @SYMTestCaseID PIM-TPSEUDOCLOCKALARMS-0001 |
|
565 */ |
|
566 |
|
567 static void doTestsL() |
|
568 { |
|
569 CActiveScheduler* scheduler = new (ELeave) CActiveScheduler; |
|
570 CleanupStack::PushL(scheduler); |
|
571 CActiveScheduler::Install(scheduler); |
|
572 |
|
573 TheAlarmTest.Test().Start(_L("@SYMTestCaseID PIM-TPSEUDOCLOCKALARMS-0001 Connecting to server")); |
|
574 TInt r = TheAlarmTest.Session().Connect(); |
|
575 TheAlarmTest(r == KErrNone, __LINE__); |
|
576 |
|
577 TheAlarmTest.TestClearStoreL(); |
|
578 #if defined(_DEBUG) |
|
579 TheAlarmTest.Session().__DbgPreventUserNotify(ETrue); |
|
580 #endif |
|
581 |
|
582 testSetClockAlarms(); |
|
583 TheAlarmTest.TestClearStoreL(); |
|
584 testClockRepeats(); |
|
585 testPastClockRepeats(); |
|
586 TheAlarmTest.TestClearStoreL(); |
|
587 |
|
588 testSetClockUtcAlarms(); |
|
589 TheAlarmTest.TestClearStoreL(); |
|
590 testClockRepeatsUtc(); |
|
591 testPastClockRepeatsUtc(); |
|
592 TheAlarmTest.TestClearStoreL(); |
|
593 |
|
594 CleanupStack::PopAndDestroy(scheduler); |
|
595 } |
|
596 |
|
597 GLDEF_C TInt E32Main() |
|
598 // |
|
599 // Test the alarm server. |
|
600 // |
|
601 { |
|
602 __UHEAP_MARK; |
|
603 TInt ret = KErrNone; |
|
604 CTrapCleanup* cleanup = CTrapCleanup::New(); |
|
605 if (!cleanup) |
|
606 return KErrNoMemory; |
|
607 |
|
608 TheAlarmTest.Title(); |
|
609 TheAlarmTest.TestStartServers(); |
|
610 // |
|
611 TRAPD(error, doTestsL()); |
|
612 TheAlarmTest(error == KErrNone, __LINE__); |
|
613 // |
|
614 TRAP(ret,TheAlarmTest.EndL()); |
|
615 TheAlarmTest.Test().Close(); |
|
616 ASTstAlarmTest::Close(); |
|
617 |
|
618 delete cleanup; |
|
619 __UHEAP_MARKEND; |
|
620 return ret; |
|
621 } |
|
622 |