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