|
1 // Copyright (c) 2003-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 <e32base.h> |
|
17 #include <e32test.h> |
|
18 #include <csch_cli.h> |
|
19 #include <f32file.h> |
|
20 #include "Thelpers.h" |
|
21 #include "TestUtils.h" |
|
22 |
|
23 RTest TheTest(_L("TC_TSCH_YEAR2000")); |
|
24 LOCAL_D RFs TheFsSession; |
|
25 |
|
26 LOCAL_D RScheduler TheScheduler; |
|
27 |
|
28 _LIT(KMinimalTaskHandler, "MinimalTaskHandler"); |
|
29 |
|
30 LOCAL_D void SetTimeTo1SecBefore(TTime& aTime) |
|
31 { |
|
32 TTimeIntervalSeconds secs(1); |
|
33 TTime time = aTime-secs; |
|
34 SchSvrHelpers::SetHomeTimeL(time); |
|
35 TBuf<30> dateString; |
|
36 time.FormatL(dateString,(_L("%H%:1%T:%S %*E%*D %X%*N%Y %1 %2 %3"))); |
|
37 TheTest.Printf(_L("current time:%S\n"), &dateString); |
|
38 } |
|
39 |
|
40 LOCAL_D void SetTime(TDateTime& aDateTime) |
|
41 { |
|
42 TTime time(aDateTime); |
|
43 SchSvrHelpers::SetHomeTimeL(time); |
|
44 } |
|
45 |
|
46 LOCAL_D TTime ShowDueTime(TInt aScheduleId) |
|
47 { |
|
48 TScheduleState state; |
|
49 TTime dueTime; |
|
50 CArrayFixFlat<TScheduleEntryInfo>* entries = new CArrayFixFlat<TScheduleEntryInfo> (3); |
|
51 CArrayFixFlat<TTaskInfo>* tasks = new CArrayFixFlat<TTaskInfo> (3); |
|
52 TInt res = TheScheduler.GetScheduleL(aScheduleId, state, *entries, *tasks, dueTime); |
|
53 TEST2(res, KErrNone); |
|
54 |
|
55 delete tasks; |
|
56 delete entries; |
|
57 |
|
58 TBuf<30> dateString; |
|
59 state.iDueTime.FormatL(dateString,(_L("%H%:1%T%*E%*D%X%*N%Y %1 %2 %3"))); |
|
60 TheTest.Printf(_L("due at:%S\n"), &dateString); |
|
61 return state.iDueTime; |
|
62 } |
|
63 |
|
64 LOCAL_D void AppendHourlyEntry(CArrayFixFlat<TScheduleEntryInfo>& aEntries, TInt aInterval,TInt aYear, |
|
65 TMonth aMonth, TInt aDay, TInt aHour, TInt aMinute) |
|
66 { |
|
67 TScheduleEntryInfo entry1; |
|
68 TTime time; |
|
69 time.HomeTime(); |
|
70 TDateTime dateTime1 (aYear, aMonth, aDay, aHour, aMinute, 0,0); |
|
71 entry1.iStartTime = dateTime1; |
|
72 entry1.iInterval = aInterval; |
|
73 entry1.iIntervalType = EHourly; |
|
74 entry1.iValidityPeriod = 0; |
|
75 aEntries.AppendL(entry1); |
|
76 } |
|
77 |
|
78 LOCAL_D void AppendDailyEntry(CArrayFixFlat<TScheduleEntryInfo>& aEntries, TInt aInterval,TInt aYear, |
|
79 TMonth aMonth, TInt aDay, TInt aHour, TInt aMinute) |
|
80 { |
|
81 TScheduleEntryInfo entry1; |
|
82 TTime time; |
|
83 time.HomeTime(); |
|
84 TDateTime dateTime1 (aYear, aMonth, aDay, aHour, aMinute, 0,0); |
|
85 entry1.iStartTime = dateTime1; |
|
86 entry1.iInterval = aInterval; |
|
87 entry1.iIntervalType = EDaily; |
|
88 entry1.iValidityPeriod = 0; |
|
89 aEntries.AppendL(entry1); |
|
90 } |
|
91 |
|
92 LOCAL_D void AppendMonthlyEntry(CArrayFixFlat<TScheduleEntryInfo>& aEntries, TInt aInterval, |
|
93 TInt aYear, TMonth aMonth, TInt aDate, TInt aHour,TInt aMinute) |
|
94 { |
|
95 TScheduleEntryInfo entry1; |
|
96 TTime time; |
|
97 time.HomeTime(); |
|
98 TDateTime dateTime1 (aYear, aMonth, aDate, aHour, aMinute, 0,0); |
|
99 entry1.iStartTime = dateTime1; |
|
100 entry1.iInterval = aInterval; |
|
101 entry1.iIntervalType = EMonthly; |
|
102 entry1.iValidityPeriod = 0; |
|
103 aEntries.AppendL(entry1); |
|
104 } |
|
105 |
|
106 LOCAL_D void AppendYearlyEntry(CArrayFixFlat<TScheduleEntryInfo>& aEntries, TInt aInterval, |
|
107 TInt aYear, TMonth aMonth,TInt aDate, TInt aHour, TInt aMinute) |
|
108 { |
|
109 TScheduleEntryInfo entry1; |
|
110 TDateTime dateTime1 (aYear, aMonth, aDate, aHour, aMinute, 0,0); |
|
111 entry1.iStartTime = dateTime1; |
|
112 entry1.iInterval = aInterval; |
|
113 entry1.iIntervalType = EYearly; |
|
114 entry1.iValidityPeriod = 0; |
|
115 aEntries.AppendL(entry1); |
|
116 } |
|
117 |
|
118 |
|
119 LOCAL_D TInt testCreateBoundarySchedule1(TSchedulerItemRef& aRef) |
|
120 { |
|
121 CArrayFixFlat<TScheduleEntryInfo>* entryList; |
|
122 entryList = new (ELeave) CArrayFixFlat<TScheduleEntryInfo>(3); |
|
123 TName name(_L("and another off-peak")); |
|
124 aRef.iName = name; |
|
125 |
|
126 //times post-boundary (to show boundary crossed properly) |
|
127 AppendYearlyEntry(*entryList, 10, 1999, EJanuary, 0, 0, 0); |
|
128 AppendYearlyEntry(*entryList, 10, 1999, EFebruary, 27, 0, 0); |
|
129 AppendYearlyEntry(*entryList, 10, 1999, EMarch, 0, 0, 0); |
|
130 AppendYearlyEntry(*entryList, 10, 1999, ESeptember, 0, 0, 0); |
|
131 AppendYearlyEntry(*entryList, 10, 1999, ESeptember, 8, 0, 0); |
|
132 AppendYearlyEntry(*entryList, 10, 1999, ESeptember, 9, 0, 0); |
|
133 AppendYearlyEntry(*entryList, 10, 2000, EJanuary, 0, 0, 0); |
|
134 AppendYearlyEntry(*entryList, 10, 2000, EFebruary, 27, 0, 0); |
|
135 AppendYearlyEntry(*entryList, 10, 2000, EFebruary, 28, 0, 0); |
|
136 AppendYearlyEntry(*entryList, 10, 2000, EMarch, 0, 0, 0); |
|
137 AppendYearlyEntry(*entryList, 10, 2001, EJanuary, 0, 0, 0); |
|
138 AppendYearlyEntry(*entryList, 10, 2001, EMarch, 0, 0, 0); |
|
139 AppendYearlyEntry(*entryList, 10, 2004, EFebruary, 28, 0, 0); |
|
140 AppendYearlyEntry(*entryList, 10, 2004, EMarch, 0, 0, 0); |
|
141 |
|
142 TInt res = TheScheduler.CreatePersistentSchedule(aRef, *entryList); |
|
143 TEST2(res, KErrNone); |
|
144 TInt count = entryList->Count(); |
|
145 delete entryList; |
|
146 return count; |
|
147 } |
|
148 |
|
149 LOCAL_D TInt testCreateBoundarySchedule2(TSchedulerItemRef& aRef) |
|
150 { |
|
151 CArrayFixFlat<TScheduleEntryInfo>* entryList; |
|
152 entryList = new (ELeave) CArrayFixFlat<TScheduleEntryInfo>(3); |
|
153 TName name(_L("and another off-peak")); |
|
154 aRef.iName = name; |
|
155 |
|
156 //times on pre-boundary dates(to show they're recognized as valid) |
|
157 //commented-out lines are handled below |
|
158 AppendYearlyEntry(*entryList, 10, 1998, EDecember, 30, 0, 0); |
|
159 AppendYearlyEntry(*entryList, 10, 1999, EFebruary, 26, 0, 0); |
|
160 // AppendYearlyEntry(*entryList, 10, 1999, EFebruary, 27, 0, 0); |
|
161 AppendYearlyEntry(*entryList, 10, 1999, EAugust, 30, 0, 0); |
|
162 AppendYearlyEntry(*entryList, 10, 1999, ESeptember, 7, 0, 0); |
|
163 // AppendYearlyEntry(*entryList, 10, 1999, ESeptember, 8, 0, 0); |
|
164 AppendYearlyEntry(*entryList, 10, 1999, EDecember, 30, 0, 0); |
|
165 AppendYearlyEntry(*entryList, 10, 2000, EFebruary, 26, 0, 0); |
|
166 // AppendYearlyEntry(*entryList, 10, 2000, EFebruary, 27, 0, 0); |
|
167 // AppendYearlyEntry(*entryList, 10, 2000, EFebruary, 28, 0, 0); |
|
168 AppendYearlyEntry(*entryList, 10, 2000, EDecember, 30, 0, 0); |
|
169 AppendYearlyEntry(*entryList, 10, 2001, EFebruary, 27, 0, 0); |
|
170 AppendYearlyEntry(*entryList, 10, 2004, EFebruary, 27, 0, 0); |
|
171 //AppendYearlyEntry(*entryList, 10, 2004, EFebruary, 28, 0, 0); |
|
172 TInt res = TheScheduler.CreatePersistentSchedule(aRef, *entryList); |
|
173 TEST2(res, KErrNone); |
|
174 |
|
175 TInt count = entryList->Count(); |
|
176 delete entryList; |
|
177 return count; |
|
178 } |
|
179 |
|
180 LOCAL_D TInt testCreateHourlyTimeSpanSchedule1(TSchedulerItemRef& aRef) |
|
181 { |
|
182 CArrayFixFlat<TScheduleEntryInfo>* entryList; |
|
183 entryList = new (ELeave) CArrayFixFlat<TScheduleEntryInfo>(3); |
|
184 TName name(_L("and another off-peak")); |
|
185 aRef.iName = name; |
|
186 |
|
187 AppendHourlyEntry(*entryList, 213*24, 1999, EJune, 0, 0, 0); |
|
188 AppendHourlyEntry(*entryList, 214*24, 1999, EJune, 0, 0, 0); |
|
189 AppendHourlyEntry(*entryList, 273*24, 1999, EJune, 0, 0, 0); |
|
190 AppendHourlyEntry(*entryList, 274*24, 1999, EJune, 0, 0, 0); |
|
191 AppendHourlyEntry(*entryList, 305*24, 1999, EJune, 0, 0, 0); |
|
192 AppendHourlyEntry(*entryList, 366*24, 1999, EJuly, 0, 0, 0); |
|
193 |
|
194 TInt res = TheScheduler.CreatePersistentSchedule(aRef, *entryList); |
|
195 TEST2(res, KErrNone); |
|
196 |
|
197 TInt count = entryList->Count(); |
|
198 delete entryList; |
|
199 return count; |
|
200 } |
|
201 |
|
202 LOCAL_D TInt testCreateHourlyTimeSpanSchedule2(TSchedulerItemRef& aRef) |
|
203 { |
|
204 CArrayFixFlat<TScheduleEntryInfo>* entryList; |
|
205 entryList = new (ELeave) CArrayFixFlat<TScheduleEntryInfo>(3); |
|
206 TName name(_L("and another off-peak")); |
|
207 aRef.iName = name; |
|
208 |
|
209 AppendHourlyEntry(*entryList, 365*24, 2000, EAugust, 0, 0, 0); |
|
210 |
|
211 TInt res = TheScheduler.CreatePersistentSchedule(aRef, *entryList); |
|
212 TEST2(res, KErrNone); |
|
213 |
|
214 TInt count = entryList->Count(); |
|
215 delete entryList; |
|
216 return count; |
|
217 } |
|
218 |
|
219 LOCAL_D TInt testCreateDailyTimeSpanSchedule1(TSchedulerItemRef& aRef) |
|
220 { |
|
221 CArrayFixFlat<TScheduleEntryInfo>* entryList; |
|
222 entryList = new (ELeave) CArrayFixFlat<TScheduleEntryInfo>(3); |
|
223 TName name(_L("and another off-peak")); |
|
224 aRef.iName = name; |
|
225 |
|
226 AppendDailyEntry(*entryList, 213, 1999, EJune, 0, 0, 0); |
|
227 AppendDailyEntry(*entryList, 214, 1999, EJune, 0, 0, 0); |
|
228 AppendDailyEntry(*entryList, 273, 1999, EJune, 0, 0, 0); |
|
229 AppendDailyEntry(*entryList, 274, 1999, EJune, 0, 0, 0); |
|
230 AppendDailyEntry(*entryList, 305, 1999, EJune, 0, 0, 0); |
|
231 AppendDailyEntry(*entryList, 366, 1999, EJuly, 0, 0, 0); |
|
232 |
|
233 TInt res = TheScheduler.CreatePersistentSchedule(aRef, *entryList); |
|
234 TEST2(res, KErrNone); |
|
235 |
|
236 TInt count = entryList->Count(); |
|
237 delete entryList; |
|
238 return count; |
|
239 } |
|
240 |
|
241 LOCAL_D TInt testCreateDailyTimeSpanSchedule2(TSchedulerItemRef& aRef) |
|
242 { |
|
243 CArrayFixFlat<TScheduleEntryInfo>* entryList; |
|
244 entryList = new (ELeave) CArrayFixFlat<TScheduleEntryInfo>(3); |
|
245 TName name(_L("and another off-peak")); |
|
246 aRef.iName = name; |
|
247 |
|
248 AppendDailyEntry(*entryList, 365, 2000, EAugust, 0, 0, 0); |
|
249 |
|
250 TInt res = TheScheduler.CreatePersistentSchedule(aRef, *entryList); |
|
251 TEST2(res, KErrNone); |
|
252 |
|
253 TInt count = entryList->Count(); |
|
254 delete entryList; |
|
255 return count; |
|
256 } |
|
257 |
|
258 LOCAL_D TInt testCreateMonthlyTimeSpanSchedule1(TSchedulerItemRef& aRef) |
|
259 { |
|
260 CArrayFixFlat<TScheduleEntryInfo>* entryList; |
|
261 entryList = new (ELeave) CArrayFixFlat<TScheduleEntryInfo>(3); |
|
262 TName name(_L("and another off-peak")); |
|
263 aRef.iName = name; |
|
264 |
|
265 AppendMonthlyEntry(*entryList, 7, 1999, EMay, 30, 0, 0); |
|
266 AppendMonthlyEntry(*entryList, 7, 1999, EJune, 0, 0, 0); |
|
267 AppendMonthlyEntry(*entryList, 8, 1999, EJune, 29, 0, 0); |
|
268 AppendMonthlyEntry(*entryList, 8, 1999, EJuly, 0, 0, 0); |
|
269 AppendMonthlyEntry(*entryList, 9, 1999, EJuly, 0, 0, 0); |
|
270 AppendMonthlyEntry(*entryList, 12, 1999, EJuly, 0, 0, 0); |
|
271 |
|
272 TInt res = TheScheduler.CreatePersistentSchedule(aRef, *entryList); |
|
273 TEST2(res, KErrNone); |
|
274 |
|
275 TInt count = entryList->Count(); |
|
276 delete entryList; |
|
277 return count; |
|
278 } |
|
279 |
|
280 |
|
281 LOCAL_D TInt testCreateMonthlyTimeSpanSchedule2(TSchedulerItemRef& aRef) |
|
282 { |
|
283 CArrayFixFlat<TScheduleEntryInfo>* entryList; |
|
284 entryList = new (ELeave) CArrayFixFlat<TScheduleEntryInfo>(3); |
|
285 TName name(_L("and another off-peak")); |
|
286 aRef.iName = name; |
|
287 |
|
288 AppendMonthlyEntry(*entryList, 12, 2000, EAugust, 0, 0, 0); |
|
289 |
|
290 TInt res = TheScheduler.CreatePersistentSchedule(aRef, *entryList); |
|
291 TEST2(res, KErrNone); |
|
292 |
|
293 TInt count = entryList->Count(); |
|
294 delete entryList; |
|
295 return count; |
|
296 } |
|
297 |
|
298 LOCAL_D TInt testCreateYearlyTimeSpanSchedule1(TSchedulerItemRef& aRef) |
|
299 { |
|
300 CArrayFixFlat<TScheduleEntryInfo>* entryList; |
|
301 entryList = new (ELeave) CArrayFixFlat<TScheduleEntryInfo>(3); |
|
302 TName name(_L("and another off-peak")); |
|
303 aRef.iName = name; |
|
304 |
|
305 AppendYearlyEntry(*entryList, 1, 1998, EDecember, 30, 0, 0); |
|
306 AppendYearlyEntry(*entryList, 1, 1999, EJanuary, 0, 0, 0); |
|
307 AppendYearlyEntry(*entryList, 1, 1999, EFebruary, 27, 0, 0); |
|
308 AppendYearlyEntry(*entryList, 1, 1999, EMarch, 0, 0, 0); |
|
309 AppendYearlyEntry(*entryList, 1, 1999, EApril, 0, 0, 0); |
|
310 AppendYearlyEntry(*entryList, 1, 1999, EJuly, 0, 0, 0); |
|
311 |
|
312 TInt res = TheScheduler.CreatePersistentSchedule(aRef, *entryList); |
|
313 TEST2(res, KErrNone); |
|
314 |
|
315 TInt count = entryList->Count(); |
|
316 delete entryList; |
|
317 return count; |
|
318 } |
|
319 |
|
320 |
|
321 LOCAL_D TInt testCreateYearlyTimeSpanSchedule2(TSchedulerItemRef& aRef) |
|
322 { |
|
323 CArrayFixFlat<TScheduleEntryInfo>* entryList; |
|
324 entryList = new (ELeave) CArrayFixFlat<TScheduleEntryInfo>(3); |
|
325 TName name(_L("and another off-peak")); |
|
326 aRef.iName = name; |
|
327 |
|
328 AppendYearlyEntry(*entryList, 1, 2000, EAugust, 0, 0, 0); |
|
329 |
|
330 TInt res = TheScheduler.CreatePersistentSchedule(aRef, *entryList); |
|
331 TEST2(res, KErrNone); |
|
332 |
|
333 TInt count = entryList->Count(); |
|
334 delete entryList; |
|
335 return count; |
|
336 } |
|
337 |
|
338 |
|
339 LOCAL_D TInt testScheduleTask(TInt aScheduleId) |
|
340 { |
|
341 HBufC* data = HBufC::NewL(20); |
|
342 *data = _L("the data"); |
|
343 TTaskInfo taskInfo; |
|
344 taskInfo.iTaskId = 0; |
|
345 taskInfo.iName = (_L("Y2K testing")); |
|
346 taskInfo.iPriority = 2; |
|
347 taskInfo.iRepeat = -1; |
|
348 TInt res = TheScheduler.ScheduleTask(taskInfo, *data, aScheduleId); |
|
349 TEST2(res, KErrNone); |
|
350 delete data; |
|
351 return taskInfo.iTaskId; |
|
352 } |
|
353 |
|
354 LOCAL_D void doTestLoopL(TInt aId, TInt aCount) |
|
355 { |
|
356 TTime time = ShowDueTime(aId); |
|
357 for (TInt i=0;i<aCount;i++) |
|
358 { |
|
359 SetTimeTo1SecBefore(time); |
|
360 //wait for exe to launch |
|
361 TEST2(STaskSemaphore::WaitL(KDefaultTimeout), KErrNone); |
|
362 CleanupHelpers::KillProcess(KMinimalTaskHandler); |
|
363 // |
|
364 if (i<(aCount-1))//i.e. if it's going to execute |
|
365 time = ShowDueTime(aId); |
|
366 } |
|
367 } |
|
368 |
|
369 /** |
|
370 @SYMTestCaseID SYSLIB-SCHSVR-CT-1029 |
|
371 @SYMTestCaseDesc Tests for boundary/valid dates testing |
|
372 @SYMTestPriority High |
|
373 @SYMTestActions Create a schedules, with one entry for each boundary pair and with a task to execute |
|
374 immediately after boundary.Set time to 5 seconds before each boundary, task should be |
|
375 executed in 5 seconds.Ensure pre and post boundary times are valid. |
|
376 also reports the day on each of these dates |
|
377 Expected output: |
|
378 due at:Thu 31 Dec 1998 |
|
379 press any key to continue" |
|
380 -then task should execute in 2 seconds |
|
381 due at:Fri 1 Jan 1999 |
|
382 press any key to continue" |
|
383 -then task should execute in 2 seconds |
|
384 due at:Sat 27 Feb 1999 |
|
385 press any key to continue" |
|
386 -task in 2 seconds |
|
387 etc etc for all times listed in doc |
|
388 @SYMTestExpectedResults Test must not fail |
|
389 @SYMREQ REQ0000 |
|
390 */ |
|
391 LOCAL_D void doBoundaryTestL() |
|
392 //*3.4.1.1 -create a schedules, with one entry for each boundary pair, |
|
393 // & with a task to execute immediately after boundary |
|
394 // set time to 5 seconds before each boundary, task should be executed in 5 seconds |
|
395 //*3.4.2.1 -also ensures all (pre-and-)post boundary times are valid |
|
396 //*3.4.2.4.8-also reports the day on each of these dates |
|
397 |
|
398 //expected output: |
|
399 // |
|
400 //"due at:Thu 31 Dec 1998 |
|
401 //press any key to continue" |
|
402 // -then task should execute in 2 seconds |
|
403 //"due at:Fri 1 Jan 1999 |
|
404 //press any key to continue" |
|
405 // -then task should execute in 2 seconds |
|
406 //"due at:Sat 27 Feb 1999 |
|
407 //press any key to continue" |
|
408 // -task in 2 seconds |
|
409 //etc etc for all times listed in doc |
|
410 { |
|
411 |
|
412 TDateTime dateTime(1998, EAugust, 1, 17, 0, 0, 0); |
|
413 SetTime(dateTime); |
|
414 TSchedulerItemRef ref; |
|
415 TInt count = testCreateBoundarySchedule1(ref); |
|
416 TInt taskId; |
|
417 taskId = testScheduleTask(ref.iHandle); |
|
418 doTestLoopL(ref.iHandle, count); |
|
419 TInt res = TheScheduler.DeleteTask(taskId); |
|
420 TEST2(res, KErrNone); |
|
421 res = TheScheduler.DeleteSchedule(ref.iHandle); |
|
422 TEST2(res, KErrNone); |
|
423 |
|
424 SetTime(dateTime); |
|
425 count = testCreateBoundarySchedule2(ref); |
|
426 taskId = testScheduleTask(ref.iHandle); |
|
427 doTestLoopL(ref.iHandle, count); |
|
428 TheScheduler.DeleteTask(taskId); |
|
429 TheScheduler.DeleteSchedule(ref.iHandle); |
|
430 } |
|
431 /** |
|
432 @SYMTestCaseID SYSLIB-SCHSVR-CT-1030 |
|
433 @SYMTestCaseDesc Tests for hourly time span test |
|
434 @SYMTestPriority High |
|
435 @SYMTestActions Create a hourly time span schedule and execute the test |
|
436 @SYMTestExpectedResults Test must not fail |
|
437 @SYMREQ REQ0000 |
|
438 */ |
|
439 LOCAL_D void doHourlyTimeSpanTestL() |
|
440 { |
|
441 TheTest.Next(_L(" @SYMTestCaseID:SYSLIB-SCHSVR-CT-1030 ")); |
|
442 TDateTime dateTime(1999, EAugust, 1, 17, 0, 0, 0); |
|
443 SetTime(dateTime); |
|
444 TSchedulerItemRef ref; |
|
445 TInt count = testCreateHourlyTimeSpanSchedule1(ref); |
|
446 TInt taskId; |
|
447 taskId = testScheduleTask(ref.iHandle); |
|
448 doTestLoopL(ref.iHandle, count); |
|
449 TInt res = TheScheduler.DeleteTask(taskId); |
|
450 TEST2(res, KErrNone); |
|
451 res = TheScheduler.DeleteSchedule(ref.iHandle); |
|
452 TEST2(res, KErrNone); |
|
453 |
|
454 TDateTime dt2(2000, EAugust,1,17,0,0,0); |
|
455 SetTime(dt2); |
|
456 count = testCreateHourlyTimeSpanSchedule2(ref); |
|
457 taskId = testScheduleTask(ref.iHandle); |
|
458 doTestLoopL(ref.iHandle, count); |
|
459 TheScheduler.DeleteTask(taskId); |
|
460 TheScheduler.DeleteSchedule(ref.iHandle); |
|
461 } |
|
462 |
|
463 /** |
|
464 @SYMTestCaseID SYSLIB-SCHSVR-CT-1338 |
|
465 @SYMTestCaseDesc Tests for daily time span test |
|
466 @SYMTestPriority High |
|
467 @SYMTestActions Create a daily time span schedule and execute the test |
|
468 @SYMTestExpectedResults Test must not fail |
|
469 @SYMREQ REQ0000 |
|
470 */ |
|
471 LOCAL_D void doDailyTimeSpanTestL() |
|
472 { |
|
473 TheTest.Next(_L(" @SYMTestCaseID:SYSLIB-SCHSVR-CT-1338 ")); |
|
474 TDateTime dateTime(1999, EAugust, 1, 17, 0, 0, 0); |
|
475 SetTime(dateTime); |
|
476 TSchedulerItemRef ref; |
|
477 TInt count = testCreateDailyTimeSpanSchedule1(ref); |
|
478 TInt taskId; |
|
479 taskId = testScheduleTask(ref.iHandle); |
|
480 doTestLoopL(ref.iHandle, count); |
|
481 TInt res = TheScheduler.DeleteTask(taskId); |
|
482 TEST2(res, KErrNone); |
|
483 res = TheScheduler.DeleteSchedule(ref.iHandle); |
|
484 TEST2(res, KErrNone); |
|
485 |
|
486 TDateTime dt2(2000, EAugust,1,17,0,0,0); |
|
487 SetTime(dt2); |
|
488 count = testCreateDailyTimeSpanSchedule2(ref); |
|
489 taskId = testScheduleTask(ref.iHandle); |
|
490 doTestLoopL(ref.iHandle, count); |
|
491 TheScheduler.DeleteTask(taskId); |
|
492 TheScheduler.DeleteSchedule(ref.iHandle); |
|
493 } |
|
494 |
|
495 /** |
|
496 @SYMTestCaseID SYSLIB-SCHSVR-CT-1339 |
|
497 @SYMTestCaseDesc Tests for monthly time span test |
|
498 @SYMTestPriority High |
|
499 @SYMTestActions Create a monthly time span schedule and execute the test |
|
500 @SYMTestExpectedResults Test must not fail |
|
501 @SYMREQ REQ0000 |
|
502 */ |
|
503 LOCAL_D void doMonthlyTimeSpanTestL() |
|
504 { |
|
505 TheTest.Next(_L(" @SYMTestCaseID:SYSLIB-SCHSVR-CT-1339 ")); |
|
506 |
|
507 TDateTime dateTime(1999, EAugust, 1, 17, 0, 0, 0); |
|
508 SetTime(dateTime); |
|
509 TSchedulerItemRef ref; |
|
510 TInt count = testCreateMonthlyTimeSpanSchedule1(ref); |
|
511 TInt taskId; |
|
512 taskId = testScheduleTask(ref.iHandle); |
|
513 doTestLoopL(ref.iHandle, count); |
|
514 TInt res = TheScheduler.DeleteTask(taskId); |
|
515 TEST2(res, KErrNone); |
|
516 res = TheScheduler.DeleteSchedule(ref.iHandle); |
|
517 TEST2(res, KErrNone); |
|
518 |
|
519 TDateTime dt2(2000, EAugust,1,17,0,0,0); |
|
520 SetTime(dt2); |
|
521 count = testCreateMonthlyTimeSpanSchedule2(ref); |
|
522 taskId = testScheduleTask(ref.iHandle); |
|
523 doTestLoopL(ref.iHandle, count); |
|
524 TheScheduler.DeleteTask(taskId); |
|
525 TheScheduler.DeleteSchedule(ref.iHandle); |
|
526 } |
|
527 |
|
528 /** |
|
529 @SYMTestCaseID SYSLIB-SCHSVR-CT-1340 |
|
530 @SYMTestCaseDesc Tests for yearly time span test |
|
531 @SYMTestPriority High |
|
532 @SYMTestActions Create a yearly time span schedule and execute the test |
|
533 @SYMTestExpectedResults Test must not fail |
|
534 @SYMREQ REQ0000 |
|
535 */ |
|
536 LOCAL_D void doYearlyTimeSpanTestL() |
|
537 { |
|
538 TheTest.Next(_L(" @SYMTestCaseID:SYSLIB-SCHSVR-CT-1340 ")); |
|
539 |
|
540 TDateTime dateTime(1999, EAugust, 1, 17, 0, 0, 0); |
|
541 SetTime(dateTime); |
|
542 TSchedulerItemRef ref; |
|
543 TInt count = testCreateYearlyTimeSpanSchedule1(ref); |
|
544 TInt taskId; |
|
545 taskId = testScheduleTask(ref.iHandle); |
|
546 doTestLoopL(ref.iHandle, count); |
|
547 TInt res = TheScheduler.DeleteTask(taskId); |
|
548 TEST2(res, KErrNone); |
|
549 res = TheScheduler.DeleteSchedule(ref.iHandle); |
|
550 TEST2(res, KErrNone); |
|
551 |
|
552 TDateTime dt2(2000, EAugust,1,17,0,0,0); |
|
553 SetTime(dt2); |
|
554 count = testCreateYearlyTimeSpanSchedule2(ref); |
|
555 taskId = testScheduleTask(ref.iHandle); |
|
556 doTestLoopL(ref.iHandle, count); |
|
557 TheScheduler.DeleteTask(taskId); |
|
558 TheScheduler.DeleteSchedule(ref.iHandle); |
|
559 } |
|
560 |
|
561 LOCAL_D void doTimeSpanTestL() |
|
562 //*3.4.2.7 -for each time-span, a set of schedules with the interval defined in terms of |
|
563 // hours, days, weeks, months, whose interval=the time span: then set time to some |
|
564 // time in between start of span & end: schedules should be next due at end of each |
|
565 // respective time-span |
|
566 |
|
567 // -test time-spans measured in days & months. |
|
568 // -so, 1 schedule for each of these, including 1 entry for each span. |
|
569 // -each entry starts at start of span, repeats at end(defined in terms of x days/weeks/months.) |
|
570 // -for each entry, set time to just before end of span, check it goes off |
|
571 { |
|
572 TheTest.Printf(_L("\nTesting time-spans...\n")); |
|
573 TheTest.Printf(_L("Hourly time-spans...\n")); |
|
574 doHourlyTimeSpanTestL(); |
|
575 TheTest.Printf(_L("Daily time-spans...\n")); |
|
576 doDailyTimeSpanTestL(); |
|
577 TheTest.Printf(_L("Monthly time-spans...\n")); |
|
578 doMonthlyTimeSpanTestL(); |
|
579 TheTest.Printf(_L("Yearly time-spans...\n")); |
|
580 doYearlyTimeSpanTestL(); |
|
581 } |
|
582 |
|
583 static void DoTestsL() |
|
584 { |
|
585 TheTest.Next(_L("Delete old files")); |
|
586 SchSvrHelpers::DeleteScheduleFilesL(); |
|
587 |
|
588 TheTest.Next(_L("Connect to Scheduler")); |
|
589 TInt res=TheScheduler.Connect(); |
|
590 TEST2(res, KErrNone); |
|
591 |
|
592 TheTest.Next(_L("Registering Client")); |
|
593 res = SchSvrHelpers::RegisterClientL(TheScheduler); |
|
594 TEST2(res, KErrNone); |
|
595 |
|
596 // Create exe Semaphore |
|
597 STaskSemaphore sem; |
|
598 sem.CreateL(); |
|
599 |
|
600 TheTest.Next(_L(" @SYMTestCaseID:SYSLIB-SCHSVR-CT-1029 Boundary/valid dates testing")); |
|
601 doBoundaryTestL(); |
|
602 TheTest.Next(_L("Time span testing")); |
|
603 doTimeSpanTestL(); |
|
604 |
|
605 // close exe Semaphore |
|
606 sem.Close(); |
|
607 |
|
608 //Tidying up so next test will be clear. |
|
609 TheTest.Next(_L("Delete all schedules")); |
|
610 SchSvrHelpers::DeleteAllSchedulesL(TheScheduler); |
|
611 TheScheduler.Close(); |
|
612 } |
|
613 |
|
614 GLDEF_C TInt E32Main() |
|
615 { |
|
616 __UHEAP_MARK; |
|
617 |
|
618 CTrapCleanup* cleanup = CTrapCleanup::New(); |
|
619 TEST(cleanup != NULL); |
|
620 |
|
621 TEST2(TheFsSession.Connect(), KErrNone); |
|
622 |
|
623 TheTest.Title(); |
|
624 TheTest.Start(_L("Year 2000")); |
|
625 |
|
626 //If the previous test fails, SCHSVR.exe may stay in memory. |
|
627 TRAPD(err,CleanupHelpers::TestCleanupL()); |
|
628 TEST2(err, KErrNone); |
|
629 |
|
630 TRAP(err, DoTestsL()); |
|
631 TEST2(err,KErrNone); |
|
632 TRAP(err,CleanupHelpers::TestCleanupL()); |
|
633 TEST2(err, KErrNone); |
|
634 |
|
635 TheTest.End(); |
|
636 TheFsSession.Close(); |
|
637 TheTest.Close(); |
|
638 |
|
639 delete cleanup; |
|
640 |
|
641 __UHEAP_MARKEND; |
|
642 return KErrNone; |
|
643 } |