sl@0
|
1 |
// Copyright (c) 1997-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 |
|
sl@0
|
22 |
#include "TestUtils.h"
|
sl@0
|
23 |
|
sl@0
|
24 |
// Globals
|
sl@0
|
25 |
RTest TheTest(_L("TC_TSCH_SCHEDULING1 - UTC"));
|
sl@0
|
26 |
static RScheduler TheScheduler;
|
sl@0
|
27 |
static RFs TheFsSession;
|
sl@0
|
28 |
|
sl@0
|
29 |
typedef CArrayFixFlat<TScheduleEntryInfo2> CScheduleEntryInfoArray;
|
sl@0
|
30 |
typedef CArrayFixFlat<TTaskInfo> CTaskInfoArray;
|
sl@0
|
31 |
typedef CArrayFixFlat<TSchedulerItemRef> CSchItemRefArray;
|
sl@0
|
32 |
|
sl@0
|
33 |
_LIT(KMinimalTaskHandler, "MinimalTaskHandler");
|
sl@0
|
34 |
|
sl@0
|
35 |
_LIT(KTimeFormatString, "%-B%:0%J%:1%T%:2%S%.%*C4%:3%+B");
|
sl@0
|
36 |
_LIT(KCurrentDateTimeChanged, "Date & Time changed to: [%S]\n");
|
sl@0
|
37 |
|
sl@0
|
38 |
//***********************************************************************************
|
sl@0
|
39 |
|
sl@0
|
40 |
// Sets time to before specified time by aTimeBeforeInSeconds
|
sl@0
|
41 |
static void SetTimeBeforeL(RTest& aTest, TTsTime& aTime, TInt aTimeBeforeInSeconds)
|
sl@0
|
42 |
{
|
sl@0
|
43 |
TTimeIntervalSeconds secs(aTimeBeforeInSeconds);
|
sl@0
|
44 |
TTime time = aTime.GetLocalTime()-secs;
|
sl@0
|
45 |
SchSvrHelpers::SetHomeTimeL(time);
|
sl@0
|
46 |
TBuf<30> dateString;
|
sl@0
|
47 |
time.FormatL(dateString, KTimeFormatString);
|
sl@0
|
48 |
aTest.Printf(KCurrentDateTimeChanged, &dateString);
|
sl@0
|
49 |
}
|
sl@0
|
50 |
|
sl@0
|
51 |
// gets the due time for this schedule
|
sl@0
|
52 |
static TTsTime GetDueTimeL(TInt aScheduleId)
|
sl@0
|
53 |
{
|
sl@0
|
54 |
TTsTime nextTimeScheduleIsDue;
|
sl@0
|
55 |
TScheduleState2 state;
|
sl@0
|
56 |
CScheduleEntryInfoArray* entries
|
sl@0
|
57 |
= new (ELeave) CScheduleEntryInfoArray(3);
|
sl@0
|
58 |
CleanupStack::PushL(entries);
|
sl@0
|
59 |
CTaskInfoArray* tasks = new (ELeave) CTaskInfoArray(3);
|
sl@0
|
60 |
CleanupStack::PushL(tasks);
|
sl@0
|
61 |
|
sl@0
|
62 |
TInt res = TheScheduler.GetScheduleL(aScheduleId, state, *entries, *tasks, nextTimeScheduleIsDue);
|
sl@0
|
63 |
TEST2(res, KErrNone);
|
sl@0
|
64 |
|
sl@0
|
65 |
CleanupStack::PopAndDestroy(2); // entries, tasks
|
sl@0
|
66 |
|
sl@0
|
67 |
return state.DueTime();
|
sl@0
|
68 |
}
|
sl@0
|
69 |
|
sl@0
|
70 |
// Forces the task to be exectued aCount times.
|
sl@0
|
71 |
static void ForceTaskExecutionForSpecifiedIdL(TInt aId, TInt aCount)
|
sl@0
|
72 |
{
|
sl@0
|
73 |
TheTest.Printf(_L("Executing %d times\n"), aCount);
|
sl@0
|
74 |
TTsTime time;
|
sl@0
|
75 |
for (TInt i=0; i<aCount; ++i)
|
sl@0
|
76 |
{
|
sl@0
|
77 |
TheTest.Printf(_L("Execution %d\n"), i+1);
|
sl@0
|
78 |
time = GetDueTimeL(aId);
|
sl@0
|
79 |
|
sl@0
|
80 |
SetTimeBeforeL(TheTest, time, 5 /*seconds*/);
|
sl@0
|
81 |
|
sl@0
|
82 |
// Wait for notification that schedule has executed.
|
sl@0
|
83 |
TEST2(STaskSemaphore::WaitL(KDefaultTimeout), KErrNone);
|
sl@0
|
84 |
CleanupHelpers::KillProcess(KMinimalTaskHandler);
|
sl@0
|
85 |
}
|
sl@0
|
86 |
}
|
sl@0
|
87 |
|
sl@0
|
88 |
//creates a daily schedule with StartTime of aStartTime
|
sl@0
|
89 |
static TInt CreateScheduleL(TSchedulerItemRef& aRef,
|
sl@0
|
90 |
RScheduler& aScheduler,
|
sl@0
|
91 |
const TTsTime& aStartTime)
|
sl@0
|
92 |
{
|
sl@0
|
93 |
CScheduleEntryInfoArray* entryList
|
sl@0
|
94 |
= new (ELeave) CScheduleEntryInfoArray(1);
|
sl@0
|
95 |
CleanupStack::PushL(entryList);
|
sl@0
|
96 |
|
sl@0
|
97 |
TScheduleEntryInfo2 entry1 (aStartTime, EDaily, 1, 30);
|
sl@0
|
98 |
entryList->AppendL(entry1);
|
sl@0
|
99 |
TInt res = aScheduler.CreatePersistentSchedule(aRef, *entryList);
|
sl@0
|
100 |
CleanupStack::PopAndDestroy(); // entryList
|
sl@0
|
101 |
return res;
|
sl@0
|
102 |
}
|
sl@0
|
103 |
|
sl@0
|
104 |
// counts the number of scheduled items based on the supplied filter.
|
sl@0
|
105 |
static TInt CountScheduledItemsL(TScheduleFilter aFilter,
|
sl@0
|
106 |
RScheduler& aScheduler)
|
sl@0
|
107 |
// Extract schedule references from the schedule server based on a filter. If
|
sl@0
|
108 |
{
|
sl@0
|
109 |
CSchItemRefArray* refs = new (ELeave) CSchItemRefArray(3);
|
sl@0
|
110 |
CleanupStack::PushL(refs);
|
sl@0
|
111 |
|
sl@0
|
112 |
TInt res = aScheduler.GetScheduleRefsL(*refs, aFilter);
|
sl@0
|
113 |
TEST2(res, KErrNone);
|
sl@0
|
114 |
|
sl@0
|
115 |
TInt count = refs->Count();
|
sl@0
|
116 |
CleanupStack::PopAndDestroy(); // refs
|
sl@0
|
117 |
return count;
|
sl@0
|
118 |
}
|
sl@0
|
119 |
|
sl@0
|
120 |
// Extract task references from the schedule server based on a ID
|
sl@0
|
121 |
static void GetTaskInfoL(CTaskInfoArray& aTaskInfoArray,
|
sl@0
|
122 |
TInt aScheduleId)
|
sl@0
|
123 |
{
|
sl@0
|
124 |
aTaskInfoArray.Reset();
|
sl@0
|
125 |
TTsTime nextTimeScheduleIsDue;
|
sl@0
|
126 |
TScheduleState2 state;
|
sl@0
|
127 |
CScheduleEntryInfoArray* entries
|
sl@0
|
128 |
= new (ELeave) CScheduleEntryInfoArray(3);
|
sl@0
|
129 |
CleanupStack::PushL(entries);
|
sl@0
|
130 |
TInt res = TheScheduler.GetScheduleL(aScheduleId,
|
sl@0
|
131 |
state,
|
sl@0
|
132 |
*entries,
|
sl@0
|
133 |
aTaskInfoArray,
|
sl@0
|
134 |
nextTimeScheduleIsDue);
|
sl@0
|
135 |
TEST2(res, KErrNone);
|
sl@0
|
136 |
CleanupStack::PopAndDestroy(entries);
|
sl@0
|
137 |
}
|
sl@0
|
138 |
|
sl@0
|
139 |
// schedules a transient task
|
sl@0
|
140 |
static TInt ScheduleTransientTaskL(TInt& aTaskId,
|
sl@0
|
141 |
TSchedulerItemRef& aRef,
|
sl@0
|
142 |
TInt aRepeat,
|
sl@0
|
143 |
RScheduler& aScheduler)
|
sl@0
|
144 |
{
|
sl@0
|
145 |
CScheduleEntryInfoArray* entryList = new(ELeave) CScheduleEntryInfoArray(3);
|
sl@0
|
146 |
CleanupStack::PushL(entryList);
|
sl@0
|
147 |
|
sl@0
|
148 |
aRef.iName = _L("transient one");
|
sl@0
|
149 |
|
sl@0
|
150 |
// SCHEDULES
|
sl@0
|
151 |
TTime ttime1(SchSvrHelpers::UtcTimeBasedOnOffset(0, 1));
|
sl@0
|
152 |
TTsTime startTime1 (ttime1,ETrue); // 1 min in the future
|
sl@0
|
153 |
TScheduleEntryInfo2 entry1 (startTime1, EDaily, 1, 20);
|
sl@0
|
154 |
entryList->AppendL(entry1);
|
sl@0
|
155 |
TTime ttime2(SchSvrHelpers::UtcTimeBasedOnOffset(0, 2));
|
sl@0
|
156 |
TTsTime startTime2 (ttime2,ETrue); // 2 min in the future
|
sl@0
|
157 |
TScheduleEntryInfo2 entry2 (startTime2, EDaily, 1, 500);
|
sl@0
|
158 |
entryList->AppendL(entry2);
|
sl@0
|
159 |
|
sl@0
|
160 |
TTime ttime3(SchSvrHelpers::UtcTimeBasedOnOffset(0, 3));
|
sl@0
|
161 |
TTsTime startTime3 (ttime3,ETrue); // 3 min in the future
|
sl@0
|
162 |
TScheduleEntryInfo2 entry3 (startTime3, EDaily, 1, 5);
|
sl@0
|
163 |
entryList->AppendL(entry3);
|
sl@0
|
164 |
|
sl@0
|
165 |
// TASK
|
sl@0
|
166 |
TTaskInfo taskInfo;
|
sl@0
|
167 |
taskInfo.iName = _L("mail");
|
sl@0
|
168 |
taskInfo.iTaskId = aTaskId;
|
sl@0
|
169 |
taskInfo.iRepeat = aRepeat;
|
sl@0
|
170 |
taskInfo.iPriority = 2;
|
sl@0
|
171 |
HBufC* data = _L("the data, some strange new name ").AllocLC();
|
sl@0
|
172 |
|
sl@0
|
173 |
// Schedule the item
|
sl@0
|
174 |
TInt res = aScheduler.ScheduleTask(taskInfo, *data, aRef, *entryList);
|
sl@0
|
175 |
CleanupStack::PopAndDestroy(2); // data, entryList
|
sl@0
|
176 |
|
sl@0
|
177 |
aTaskId = taskInfo.iTaskId;
|
sl@0
|
178 |
return res;
|
sl@0
|
179 |
}
|
sl@0
|
180 |
|
sl@0
|
181 |
|
sl@0
|
182 |
//***********************************************************************************
|
sl@0
|
183 |
|
sl@0
|
184 |
/**
|
sl@0
|
185 |
@file
|
sl@0
|
186 |
@SYMTestCaseID SYSLIB-SCHSVR-CT-0254
|
sl@0
|
187 |
@SYMTestCaseDesc Replicated test for for defect (EDNEMHE-4Q69BG) - UTC
|
sl@0
|
188 |
@SYMTestPriority High
|
sl@0
|
189 |
@SYMTestActions Create time based schedules and then jump to a time after the due time but within the validity period and check it schedule still fires
|
sl@0
|
190 |
@SYMTestExpectedResults The test must not fail.
|
sl@0
|
191 |
@SYMPREQ PREQ234
|
sl@0
|
192 |
*/
|
sl@0
|
193 |
static void Test1L()
|
sl@0
|
194 |
{
|
sl@0
|
195 |
_LIT(KTaskData1, "This is some really exciting task data (number 1)");
|
sl@0
|
196 |
_LIT(KTaskData2, "This is some really exciting task data (number 2)");
|
sl@0
|
197 |
_LIT(KTestName, "SmsTest");
|
sl@0
|
198 |
|
sl@0
|
199 |
TheTest.Next(_L(" @SYMTestCaseID:SYSLIB-SCHSVR-CT-0254 TheTest3: SMS:Sending to multiple recipients "));
|
sl@0
|
200 |
|
sl@0
|
201 |
TheTest.Next(_L("Connect to Scheduler"));
|
sl@0
|
202 |
TInt res = TheScheduler.Connect();
|
sl@0
|
203 |
TEST2(res, KErrNone);
|
sl@0
|
204 |
|
sl@0
|
205 |
TheTest.Next(_L("Registering Client"));
|
sl@0
|
206 |
TEST2(SchSvrHelpers::RegisterClientL(TheScheduler), KErrNone);
|
sl@0
|
207 |
|
sl@0
|
208 |
// Set the time to a known value, since this makes testing much easier (and more
|
sl@0
|
209 |
// repeatable).
|
sl@0
|
210 |
SchSvrHelpers::SetHomeTimeL(TTime(TDateTime(2000, EJanuary, 1, 9, 55, 0, 0))); // 9:55 am
|
sl@0
|
211 |
|
sl@0
|
212 |
// This is the time when we want the schedule to fire
|
sl@0
|
213 |
TDateTime datetime(2000, EJanuary, 1, 10, 0, 0, 0);
|
sl@0
|
214 |
TTsTime startTimeForSchedule(datetime, ETrue); // 10:00 am
|
sl@0
|
215 |
|
sl@0
|
216 |
|
sl@0
|
217 |
// Prepare a schedule describing when we want the tasks to run (10:00 am)
|
sl@0
|
218 |
TSchedulerItemRef ref;
|
sl@0
|
219 |
User::LeaveIfError(CreateScheduleL(ref, TheScheduler, startTimeForSchedule));
|
sl@0
|
220 |
|
sl@0
|
221 |
// Disable the schedule whilst we set it up
|
sl@0
|
222 |
User::LeaveIfError(TheScheduler.DisableSchedule(ref.iHandle));
|
sl@0
|
223 |
|
sl@0
|
224 |
// Associate a task with the schedule
|
sl@0
|
225 |
TTaskInfo taskInfo1;
|
sl@0
|
226 |
taskInfo1.iRepeat = 0;
|
sl@0
|
227 |
taskInfo1.iName = KTestName;
|
sl@0
|
228 |
taskInfo1.iPriority = 2;
|
sl@0
|
229 |
|
sl@0
|
230 |
// Create some data associated with this task
|
sl@0
|
231 |
HBufC* taskData1 = KTaskData1().AllocLC();
|
sl@0
|
232 |
User::LeaveIfError(TheScheduler.ScheduleTask(taskInfo1, *taskData1, ref.iHandle));
|
sl@0
|
233 |
CleanupStack::PopAndDestroy(); // taskData1
|
sl@0
|
234 |
|
sl@0
|
235 |
// Associate a task (2) with the schedule
|
sl@0
|
236 |
TTaskInfo taskInfo2;
|
sl@0
|
237 |
taskInfo2.iRepeat = 0;
|
sl@0
|
238 |
taskInfo2.iName = KTestName;
|
sl@0
|
239 |
taskInfo2.iPriority = 2;
|
sl@0
|
240 |
|
sl@0
|
241 |
// Create some data associated with this task
|
sl@0
|
242 |
HBufC* taskData2 = KTaskData2().AllocLC();
|
sl@0
|
243 |
User::LeaveIfError(TheScheduler.ScheduleTask(taskInfo2, *taskData2, ref.iHandle));
|
sl@0
|
244 |
CleanupStack::PopAndDestroy(); // taskData2
|
sl@0
|
245 |
|
sl@0
|
246 |
// We should now have two tasks scheduled at exactly the same time...
|
sl@0
|
247 |
User::LeaveIfError(TheScheduler.EnableSchedule(ref.iHandle));
|
sl@0
|
248 |
|
sl@0
|
249 |
// Set the time to 5 minutes *AFTER* the schedule was due to run (10:05am). In this instance,
|
sl@0
|
250 |
// based on the new fixed Schedule Server, the schedule should still execute since
|
sl@0
|
251 |
// it falls within the validity period (30 mins), however, in the old scheme of things,
|
sl@0
|
252 |
// the schedule would not be valid again until tomorrow (2/1/2000) at 10:00am and hence
|
sl@0
|
253 |
// would not execute until then.
|
sl@0
|
254 |
SchSvrHelpers::SetHomeTimeL(TTime(TDateTime(2000, EJanuary, 1, 10, 5, 0, 0))); // 10:05 am
|
sl@0
|
255 |
|
sl@0
|
256 |
// Now wait for something to happen...
|
sl@0
|
257 |
TEST2(STaskSemaphore::WaitL(KDefaultTimeout), KErrNone);
|
sl@0
|
258 |
CleanupHelpers::KillProcess(KMinimalTaskHandler);
|
sl@0
|
259 |
}
|
sl@0
|
260 |
|
sl@0
|
261 |
//***********************************************************************************
|
sl@0
|
262 |
|
sl@0
|
263 |
/**
|
sl@0
|
264 |
@file
|
sl@0
|
265 |
@SYMTestCaseID SYSLIB-SCHSVR-CT-0255
|
sl@0
|
266 |
@SYMTestCaseDesc Replicated test for for defect (EDNEMHE-4Q69BG) - UTC
|
sl@0
|
267 |
@SYMTestPriority High
|
sl@0
|
268 |
@SYMTestActions Create time based schedules and then jump to a time after the due time but within the validity period and check it schedule still fires
|
sl@0
|
269 |
@SYMTestExpectedResults The test must not fail.
|
sl@0
|
270 |
@SYMPREQ PREQ234
|
sl@0
|
271 |
*/
|
sl@0
|
272 |
static void Test2L()
|
sl@0
|
273 |
{
|
sl@0
|
274 |
TheTest.Next(_L(" @SYMTestCaseID:SYSLIB-SCHSVR-CT-0255 Testing creation of transient schedule with task repeating 5 times "));
|
sl@0
|
275 |
TInt tTask = 0;
|
sl@0
|
276 |
TSchedulerItemRef ref;
|
sl@0
|
277 |
// schedule has 3 entries - +1min, +2min and +3min
|
sl@0
|
278 |
TInt res = ScheduleTransientTaskL(tTask, ref, 5, TheScheduler);//5 repeats
|
sl@0
|
279 |
TEST2(res, KErrNone);
|
sl@0
|
280 |
|
sl@0
|
281 |
TheTest.Printf(_L("Get Task count and repeat count\n"));
|
sl@0
|
282 |
|
sl@0
|
283 |
CTaskInfoArray* tasks = new (ELeave) CTaskInfoArray(3);
|
sl@0
|
284 |
CleanupStack::PushL(tasks);
|
sl@0
|
285 |
GetTaskInfoL(*tasks, ref.iHandle);
|
sl@0
|
286 |
TEST(tasks->Count() == 1);
|
sl@0
|
287 |
TTaskInfo info = tasks->At(0);
|
sl@0
|
288 |
TEST(info.iRepeat == 5);
|
sl@0
|
289 |
ForceTaskExecutionForSpecifiedIdL(ref.iHandle, 3);
|
sl@0
|
290 |
GetTaskInfoL(*tasks, ref.iHandle);
|
sl@0
|
291 |
TEST(tasks->Count() == 1);
|
sl@0
|
292 |
info = tasks->At(0);
|
sl@0
|
293 |
TEST(info.iRepeat == 2); // still 2 repeats to go.
|
sl@0
|
294 |
ForceTaskExecutionForSpecifiedIdL(ref.iHandle, 2);
|
sl@0
|
295 |
|
sl@0
|
296 |
CleanupStack::PopAndDestroy(tasks);
|
sl@0
|
297 |
|
sl@0
|
298 |
TInt scheduleCount = CountScheduledItemsL(EPendingSchedules, TheScheduler);
|
sl@0
|
299 |
// There should be no schedules as its a transient one and last schedule
|
sl@0
|
300 |
// should have deleted itself.
|
sl@0
|
301 |
TEST(scheduleCount == 0);
|
sl@0
|
302 |
SchSvrHelpers::Pause(TheTest);
|
sl@0
|
303 |
}
|
sl@0
|
304 |
|
sl@0
|
305 |
//***********************************************************************************
|
sl@0
|
306 |
|
sl@0
|
307 |
/**
|
sl@0
|
308 |
@file
|
sl@0
|
309 |
@SYMTestCaseID SYSLIB-SCHSVR-CT-0256
|
sl@0
|
310 |
@SYMTestCaseDesc Replicated test for for defect (DEF055586L) - UTC
|
sl@0
|
311 |
@SYMTestPriority High
|
sl@0
|
312 |
@SYMTestActions Create a time-based schedule check that there are 0 entries in the scehule after it fires
|
sl@0
|
313 |
@SYMTestExpectedResults The test must not fail.
|
sl@0
|
314 |
@SYMPREQ PREQ234
|
sl@0
|
315 |
*/
|
sl@0
|
316 |
static void DEF055586L()
|
sl@0
|
317 |
{
|
sl@0
|
318 |
TheTest.Next(_L(" @SYMTestCaseID:SYSLIB-SCHSVR-CT-0256 DEF055586 - Last element in array missed by loop "));
|
sl@0
|
319 |
TheTest.Next(_L("Connect to Scheduler"));
|
sl@0
|
320 |
TInt res = TheScheduler.Connect();
|
sl@0
|
321 |
TEST2(res, KErrNone);
|
sl@0
|
322 |
|
sl@0
|
323 |
TheTest.Next(_L("Registering Client"));
|
sl@0
|
324 |
TEST2(SchSvrHelpers::RegisterClientL(TheScheduler), KErrNone);
|
sl@0
|
325 |
|
sl@0
|
326 |
// Set the time to a known value, since this makes testing much easier (and more
|
sl@0
|
327 |
// repeatable).
|
sl@0
|
328 |
SchSvrHelpers::SetHomeTimeL(TTime(TDateTime(2000, EJanuary, 1, 9, 55, 0, 0))); // 9:55 am
|
sl@0
|
329 |
|
sl@0
|
330 |
// This is the time when we want the schedule to fire
|
sl@0
|
331 |
TDateTime datetime(2000, EJanuary, 1, 10, 0, 0, 0);
|
sl@0
|
332 |
TTsTime startTimeForSchedule(datetime, ETrue); // 10:00 am
|
sl@0
|
333 |
|
sl@0
|
334 |
// Prepare a schedule describing when we want the tasks to run (10:00 am)
|
sl@0
|
335 |
TSchedulerItemRef ref;
|
sl@0
|
336 |
|
sl@0
|
337 |
CScheduleEntryInfoArray* entryList = new (ELeave) CScheduleEntryInfoArray(1);
|
sl@0
|
338 |
CleanupStack::PushL(entryList);
|
sl@0
|
339 |
|
sl@0
|
340 |
TScheduleEntryInfo2 entry1 (startTimeForSchedule, EDaily, 0, 30); // TTimeIntervalDays: set to 0 to induce an error
|
sl@0
|
341 |
entryList->AppendL(entry1);
|
sl@0
|
342 |
TInt err = TheScheduler.CreatePersistentSchedule(ref, *entryList);
|
sl@0
|
343 |
|
sl@0
|
344 |
TEST2(err, KErrArgument);
|
sl@0
|
345 |
|
sl@0
|
346 |
TheTest.Next(_L("DEF055586 - Now checking 0 entries in schedule"));
|
sl@0
|
347 |
entryList->Reset();
|
sl@0
|
348 |
|
sl@0
|
349 |
err = TheScheduler.CreatePersistentSchedule(ref, *entryList);
|
sl@0
|
350 |
|
sl@0
|
351 |
TEST2(err, KErrArgument);
|
sl@0
|
352 |
|
sl@0
|
353 |
CleanupStack::PopAndDestroy(); // entryList
|
sl@0
|
354 |
}
|
sl@0
|
355 |
|
sl@0
|
356 |
//DEF061595 Schedule timers incorrectly expire when system time is changed
|
sl@0
|
357 |
//The test will create and submit one schedule which execution time is one year later.
|
sl@0
|
358 |
//Then the test will change the system time to be current time + 1 day.
|
sl@0
|
359 |
//Although the schedule time is set to be current time + 1 year, the schedule task(s) will
|
sl@0
|
360 |
//be executed immediately because the schedule timer expires when the system time changes.
|
sl@0
|
361 |
void DEF061595L()
|
sl@0
|
362 |
{
|
sl@0
|
363 |
TheTest.Next(_L("DEF061595 Schedule timers incorrectly expire when system time is changed"));
|
sl@0
|
364 |
//Get current time in currTime variable
|
sl@0
|
365 |
TTime currTime;
|
sl@0
|
366 |
currTime.HomeTime();
|
sl@0
|
367 |
//Prepare the task time (in taskTime variable) to be currTime + 1 year.
|
sl@0
|
368 |
TTime taskTime(currTime + TTimeIntervalYears(1));
|
sl@0
|
369 |
TInt taskYear = taskTime.DateTime().Year();
|
sl@0
|
370 |
//Connect to the Task Scheduler Server
|
sl@0
|
371 |
RScheduler scheduler;
|
sl@0
|
372 |
CleanupClosePushL(scheduler);
|
sl@0
|
373 |
TInt res = scheduler.Connect();
|
sl@0
|
374 |
TEST2(res, KErrNone);
|
sl@0
|
375 |
TEST2(SchSvrHelpers::RegisterClientL(scheduler), KErrNone);
|
sl@0
|
376 |
//Create new schedule. The new schedule task will run 1 year later.
|
sl@0
|
377 |
TTsTime taskTsTime(taskTime, EFalse);
|
sl@0
|
378 |
TSchedulerItemRef ref;
|
sl@0
|
379 |
TEST2(::CreateScheduleL(ref, scheduler, taskTsTime), KErrNone);
|
sl@0
|
380 |
// Disable the schedule whilst we set it up
|
sl@0
|
381 |
TEST2(scheduler.DisableSchedule(ref.iHandle), KErrNone);
|
sl@0
|
382 |
// Associate a task with the schedule
|
sl@0
|
383 |
_LIT(KTaskInfo, "DEF061595");
|
sl@0
|
384 |
TTaskInfo taskInfo;
|
sl@0
|
385 |
taskInfo.iRepeat = 0;
|
sl@0
|
386 |
taskInfo.iName = KTaskInfo;
|
sl@0
|
387 |
taskInfo.iPriority = 2;
|
sl@0
|
388 |
const TInt KTaskDataLen = 1;
|
sl@0
|
389 |
HBufC* taskData = HBufC::NewLC(KTaskDataLen);
|
sl@0
|
390 |
TEST2(scheduler.ScheduleTask(taskInfo, *taskData, ref.iHandle), KErrNone);
|
sl@0
|
391 |
//We should now have one tasks scheduled to be executed after 1 year.
|
sl@0
|
392 |
//Enable schedule.
|
sl@0
|
393 |
TEST2(scheduler.EnableSchedule(ref.iHandle), KErrNone);
|
sl@0
|
394 |
//Get the scheduled task info. The task year should be the same as it was set in the schedule.
|
sl@0
|
395 |
TTime nextTime;
|
sl@0
|
396 |
TPtr pTaskData = taskData->Des();
|
sl@0
|
397 |
TEST2(scheduler.GetTaskInfoL(taskInfo.iTaskId, taskInfo, pTaskData, ref, nextTime), KErrNone);
|
sl@0
|
398 |
TInt nextTaskYear = nextTime.DateTime().Year();
|
sl@0
|
399 |
TEST(nextTaskYear == taskYear);
|
sl@0
|
400 |
//Change the system time to be current time + 1 day
|
sl@0
|
401 |
TEST2(SchSvrHelpers::SetUTCTimeL(currTime + TTimeIntervalDays(1)), KErrNone);
|
sl@0
|
402 |
//Get the scheduled task info again. If the defect is not fixed, the call will fail
|
sl@0
|
403 |
//with KErrNotFound (because SchSvrHelpers::SetUTCTimeL() call will make the schedule timer to expire)
|
sl@0
|
404 |
TInt err = scheduler.GetTaskInfoL(taskInfo.iTaskId, taskInfo, pTaskData, ref, nextTime);
|
sl@0
|
405 |
//TODO TEST2(err, KErrNone);
|
sl@0
|
406 |
//TODO nextTaskYear = nextTime.DateTime().Year();
|
sl@0
|
407 |
//TODO TEST(nextTaskYear == taskYear);
|
sl@0
|
408 |
|
sl@0
|
409 |
CleanupStack::PopAndDestroy(taskData);
|
sl@0
|
410 |
CleanupStack::PopAndDestroy(&scheduler);
|
sl@0
|
411 |
CleanupHelpers::KillProcess(KMinimalTaskHandler);
|
sl@0
|
412 |
}
|
sl@0
|
413 |
|
sl@0
|
414 |
/**
|
sl@0
|
415 |
@SYMTestCaseID SYSLIB-SCHSVR-CT-1655
|
sl@0
|
416 |
@SYMTestCaseDesc Tests for defect number DEF079983
|
sl@0
|
417 |
@SYMTestPriority High
|
sl@0
|
418 |
@SYMTestActions Check to ensure all task files have been cleaned up
|
sl@0
|
419 |
after scheduled tasks completed
|
sl@0
|
420 |
@SYMTestExpectedResults Test must not fail
|
sl@0
|
421 |
@SYMDEF DEF079983
|
sl@0
|
422 |
*/
|
sl@0
|
423 |
static void DEF079983L()
|
sl@0
|
424 |
{
|
sl@0
|
425 |
TheTest.Next(_L(" @SYMTestCaseID:SYSLIB-SCHSVR-CT-1655 DEF079983: Private directory of schsvr flooded with files "));
|
sl@0
|
426 |
// A dummy scheduled task:
|
sl@0
|
427 |
// Create some transient schedule task and repeat 5 times
|
sl@0
|
428 |
TheTest.Printf(_L("DEF079983: Create a dummy scheduled task"));
|
sl@0
|
429 |
TInt tTask = 0;
|
sl@0
|
430 |
TSchedulerItemRef ref;
|
sl@0
|
431 |
// 5 repeats
|
sl@0
|
432 |
TInt res = ScheduleTransientTaskL(tTask, ref, 5, TheScheduler);
|
sl@0
|
433 |
TEST2(res, KErrNone);
|
sl@0
|
434 |
ForceTaskExecutionForSpecifiedIdL(ref.iHandle, 5);
|
sl@0
|
435 |
|
sl@0
|
436 |
// Check for left task files after scheduled tasks completed
|
sl@0
|
437 |
// To access private data cage, uses SchSvrHelplers::CheckTaskFilesL()
|
sl@0
|
438 |
TheTest.Next(_L("DEF079983: Now checking no files left when tasks completed"));
|
sl@0
|
439 |
TInt err = SchSvrHelpers::CheckTaskFilesL();
|
sl@0
|
440 |
// If there's any task files left, test fails with error code KErrGeneral
|
sl@0
|
441 |
TEST(err == KErrNone);
|
sl@0
|
442 |
}
|
sl@0
|
443 |
|
sl@0
|
444 |
/**
|
sl@0
|
445 |
@SYMTestCaseID SYSLIB-SCHSVR-CT-3362
|
sl@0
|
446 |
@SYMTestCaseDesc Replicated test for for defect (INC098909) - UTC
|
sl@0
|
447 |
@SYMTestPriority High
|
sl@0
|
448 |
@SYMTestActions Mark heap of Scheduler then create a schedule & task wait for its
|
sl@0
|
449 |
execution then check heap again for memory leaks
|
sl@0
|
450 |
@SYMTestExpectedResults Test must not fail (i.e. No memory leaks)
|
sl@0
|
451 |
@SYMDEF INC098909: Process !TaskScheluder leaks memory in mail polls.
|
sl@0
|
452 |
*/
|
sl@0
|
453 |
static void INC098909()
|
sl@0
|
454 |
{
|
sl@0
|
455 |
const TInt KTimeToWait = 10*1000*1000;
|
sl@0
|
456 |
SchSvrHelpers::DeleteScheduleFilesL();
|
sl@0
|
457 |
|
sl@0
|
458 |
TheTest.Next(_L(" @SYMTestCaseID:SYSLIB-SCHSVR-CT-3362 INC098909: Process !TaskScheluder leaks memory in mail polls "));
|
sl@0
|
459 |
TheTest.Next(_L("Connect to Scheduler"));
|
sl@0
|
460 |
TEST2(TheScheduler.Connect(),KErrNone);
|
sl@0
|
461 |
|
sl@0
|
462 |
TheTest.Next(_L("Registering Client"));
|
sl@0
|
463 |
TEST2(SchSvrHelpers::RegisterClientL(TheScheduler), KErrNone);
|
sl@0
|
464 |
|
sl@0
|
465 |
User::LeaveIfError(TheScheduler.__DbgMarkHeap());
|
sl@0
|
466 |
|
sl@0
|
467 |
//Create Schedule
|
sl@0
|
468 |
CArrayFixFlat<TScheduleEntryInfo2>* entryList = new(ELeave) CArrayFixFlat<TScheduleEntryInfo2>(1);
|
sl@0
|
469 |
CleanupStack::PushL(entryList);
|
sl@0
|
470 |
TSchedulerItemRef ref;
|
sl@0
|
471 |
|
sl@0
|
472 |
TTsTime startTime1(SchSvrHelpers::UtcTimeBasedOnOffset(0, 0), ETrue); // 0m:0s from "now"
|
sl@0
|
473 |
|
sl@0
|
474 |
TScheduleEntryInfo2 entry1 (startTime1, EDaily, 1, 20);
|
sl@0
|
475 |
entryList->AppendL(entry1);
|
sl@0
|
476 |
|
sl@0
|
477 |
// Create the schedule for the task...
|
sl@0
|
478 |
TEST2(TheScheduler.CreatePersistentSchedule(ref, *entryList),KErrNone);
|
sl@0
|
479 |
|
sl@0
|
480 |
//Create Task
|
sl@0
|
481 |
TTaskInfo task;
|
sl@0
|
482 |
task.iRepeat = 1; // repeat once
|
sl@0
|
483 |
task.iName = _L("Test ");
|
sl@0
|
484 |
task.iPriority = 100;
|
sl@0
|
485 |
|
sl@0
|
486 |
HBufC* taskData = HBufC::NewLC(1);
|
sl@0
|
487 |
TEST2(TheScheduler.ScheduleTask(task, *taskData,ref.iHandle), KErrNone);
|
sl@0
|
488 |
|
sl@0
|
489 |
CleanupStack::PopAndDestroy(taskData);
|
sl@0
|
490 |
CleanupStack::PopAndDestroy(entryList);
|
sl@0
|
491 |
|
sl@0
|
492 |
//Wait schedule to complete
|
sl@0
|
493 |
User::After(KTimeToWait);
|
sl@0
|
494 |
|
sl@0
|
495 |
User::LeaveIfError(TheScheduler.__DbgMarkEnd(0));
|
sl@0
|
496 |
|
sl@0
|
497 |
TheScheduler.Close();
|
sl@0
|
498 |
// really clean out the scheduler (get rid of all the files and process)
|
sl@0
|
499 |
SchSvrHelpers::DeleteScheduleFilesL();
|
sl@0
|
500 |
CleanupHelpers::KillProcess(KMinimalTaskHandler);
|
sl@0
|
501 |
// Now wait for something to happen...
|
sl@0
|
502 |
TEST2(STaskSemaphore::WaitL(KDefaultTimeout), KErrNone);
|
sl@0
|
503 |
}
|
sl@0
|
504 |
|
sl@0
|
505 |
GLDEF_C TInt DoTheTestsL()
|
sl@0
|
506 |
{
|
sl@0
|
507 |
//Delete old files.
|
sl@0
|
508 |
SchSvrHelpers::DeleteScheduleFilesL();
|
sl@0
|
509 |
|
sl@0
|
510 |
STaskSemaphore sem;
|
sl@0
|
511 |
sem.CreateL();
|
sl@0
|
512 |
|
sl@0
|
513 |
TheTest.Next(_L("Start tests"));
|
sl@0
|
514 |
// Add tests here:-
|
sl@0
|
515 |
Test1L();
|
sl@0
|
516 |
Test2L();
|
sl@0
|
517 |
INC098909();
|
sl@0
|
518 |
DEF055586L();
|
sl@0
|
519 |
DEF061595L();
|
sl@0
|
520 |
DEF079983L(); // task file check test
|
sl@0
|
521 |
|
sl@0
|
522 |
sem.Close();
|
sl@0
|
523 |
|
sl@0
|
524 |
//Tidying up so next test will be clear.
|
sl@0
|
525 |
TheTest.Next(_L("Delete all schedules"));
|
sl@0
|
526 |
SchSvrHelpers::DeleteAllSchedulesL(TheScheduler);
|
sl@0
|
527 |
SchSvrHelpers::Pause(TheTest, 2);
|
sl@0
|
528 |
TheTest.Next(_L("Delete old files\n"));
|
sl@0
|
529 |
SchSvrHelpers::DeleteScheduleFilesL();
|
sl@0
|
530 |
|
sl@0
|
531 |
TheScheduler.Close();
|
sl@0
|
532 |
|
sl@0
|
533 |
return KErrNone;
|
sl@0
|
534 |
}
|
sl@0
|
535 |
|
sl@0
|
536 |
//***********************************************************************************
|
sl@0
|
537 |
GLDEF_C TInt E32Main()
|
sl@0
|
538 |
{
|
sl@0
|
539 |
__UHEAP_MARK;
|
sl@0
|
540 |
TheTest.Title();
|
sl@0
|
541 |
TheTest.Start(_L("TC_TSCH_SCHEDULING1 - UTC"));
|
sl@0
|
542 |
|
sl@0
|
543 |
TInt error = KErrNone;
|
sl@0
|
544 |
CTrapCleanup* cleanup = CTrapCleanup::New();
|
sl@0
|
545 |
if (!cleanup)
|
sl@0
|
546 |
return KErrNoMemory;
|
sl@0
|
547 |
//If the previous test fails, SCHSVR.exe may stay in memory.
|
sl@0
|
548 |
TRAP(error,CleanupHelpers::TestCleanupL());
|
sl@0
|
549 |
TEST2(error, KErrNone);
|
sl@0
|
550 |
|
sl@0
|
551 |
TTime now;
|
sl@0
|
552 |
now.HomeTime();
|
sl@0
|
553 |
// Used to Set the system UTC time and UTC offset
|
sl@0
|
554 |
// so that correct UTC Time values are returned while using time based APIs.
|
sl@0
|
555 |
SchSvrHelpers::SetHomeTimeL(now);
|
sl@0
|
556 |
|
sl@0
|
557 |
TEST2(TheFsSession.Connect(), KErrNone);
|
sl@0
|
558 |
TheTest.Next(_L("Do the tests"));
|
sl@0
|
559 |
TRAP(error, DoTheTestsL());
|
sl@0
|
560 |
TEST2(error,KErrNone);
|
sl@0
|
561 |
TheFsSession.Close();
|
sl@0
|
562 |
TRAP(error,CleanupHelpers::TestCleanupL());
|
sl@0
|
563 |
TEST2(error, KErrNone);
|
sl@0
|
564 |
delete cleanup;
|
sl@0
|
565 |
|
sl@0
|
566 |
TheTest.End();
|
sl@0
|
567 |
TheTest.Close();
|
sl@0
|
568 |
__UHEAP_MARKEND;
|
sl@0
|
569 |
return KErrNone;
|
sl@0
|
570 |
}
|