sl@0
|
1 |
// Copyright (c) 2004-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 <csch_cli.h>
|
sl@0
|
17 |
#include "Thelpers.h"
|
sl@0
|
18 |
|
sl@0
|
19 |
#include <e32base.h>
|
sl@0
|
20 |
#include <e32test.h>
|
sl@0
|
21 |
#include <f32file.h>
|
sl@0
|
22 |
#include <s32file.h>
|
sl@0
|
23 |
|
sl@0
|
24 |
#include "TestUtils.h"
|
sl@0
|
25 |
|
sl@0
|
26 |
|
sl@0
|
27 |
//If suddenly all SCHSVR tests begin failing, the OOM conditions might be the reason.
|
sl@0
|
28 |
//TScheduling test tries to create KNumberOfSchedulesToCreate tasks, loading enormously
|
sl@0
|
29 |
//the task scheduling server. The task scheduling server fails and stays loaded in memory
|
sl@0
|
30 |
//with many scheduling tasks holding large amounts of allocated memory in this way.
|
sl@0
|
31 |
//The next SCHSVR tests may fail because of OOM.
|
sl@0
|
32 |
//KNumberOfSchedulesToCreate value was 100 originally. Now it is 20.
|
sl@0
|
33 |
|
sl@0
|
34 |
//
|
sl@0
|
35 |
// Literal constants
|
sl@0
|
36 |
//
|
sl@0
|
37 |
_LIT(KTestName, "TC_TSCH_SCHEDULING2 - UTC");
|
sl@0
|
38 |
|
sl@0
|
39 |
//
|
sl@0
|
40 |
// Type definitions
|
sl@0
|
41 |
//
|
sl@0
|
42 |
typedef CArrayFixFlat<TScheduleEntryInfo2> CSchEntryInfoArray;
|
sl@0
|
43 |
typedef CArrayFixFlat<TTaskInfo> CTaskInfoArray;
|
sl@0
|
44 |
typedef CArrayFixFlat<TSchedulerItemRef> CSchItemRefArray;
|
sl@0
|
45 |
|
sl@0
|
46 |
//
|
sl@0
|
47 |
// Global data
|
sl@0
|
48 |
//
|
sl@0
|
49 |
RTest TheTest(KTestName);
|
sl@0
|
50 |
static TInt64 TheSeed;
|
sl@0
|
51 |
static RScheduler TheScheduler;
|
sl@0
|
52 |
static CTrapCleanup* TheCleanup;
|
sl@0
|
53 |
static RFs TheFsSession;
|
sl@0
|
54 |
|
sl@0
|
55 |
_LIT(KMinimalTaskHandler, "MinimalTaskHandler");
|
sl@0
|
56 |
|
sl@0
|
57 |
|
sl@0
|
58 |
//***********************************************************************************
|
sl@0
|
59 |
// Extract task info from the schedule server based on a schedule ID
|
sl@0
|
60 |
static void GetTaskInfoL(CTaskInfoArray& aTaskInfoArray,
|
sl@0
|
61 |
TInt aScheduleId)
|
sl@0
|
62 |
{
|
sl@0
|
63 |
aTaskInfoArray.Reset();
|
sl@0
|
64 |
TTsTime nextTimeScheduleIsDue;
|
sl@0
|
65 |
TScheduleState2 state;
|
sl@0
|
66 |
CSchEntryInfoArray* entries
|
sl@0
|
67 |
= new (ELeave) CSchEntryInfoArray(3);
|
sl@0
|
68 |
CleanupStack::PushL(entries);
|
sl@0
|
69 |
TInt res = TheScheduler.GetScheduleL(aScheduleId,
|
sl@0
|
70 |
state,
|
sl@0
|
71 |
*entries,
|
sl@0
|
72 |
aTaskInfoArray,
|
sl@0
|
73 |
nextTimeScheduleIsDue);
|
sl@0
|
74 |
TEST2(res, KErrNone);
|
sl@0
|
75 |
CleanupStack::PopAndDestroy(entries);
|
sl@0
|
76 |
}
|
sl@0
|
77 |
|
sl@0
|
78 |
// count the number of tasks associated with this schedule
|
sl@0
|
79 |
static TInt CountTasksL(TInt aScheduleId)
|
sl@0
|
80 |
{
|
sl@0
|
81 |
CTaskInfoArray* tasks = new (ELeave) CTaskInfoArray(3);
|
sl@0
|
82 |
CleanupStack::PushL(tasks);
|
sl@0
|
83 |
GetTaskInfoL(*tasks, aScheduleId);
|
sl@0
|
84 |
TInt ret = tasks->Count();
|
sl@0
|
85 |
CleanupStack::PopAndDestroy(tasks);
|
sl@0
|
86 |
return ret;
|
sl@0
|
87 |
}
|
sl@0
|
88 |
|
sl@0
|
89 |
// count the number of schedules based on a filter.
|
sl@0
|
90 |
static TInt CountScheduledItemsL(TScheduleFilter aFilter,
|
sl@0
|
91 |
RScheduler& aScheduler)
|
sl@0
|
92 |
{
|
sl@0
|
93 |
CSchItemRefArray* refs = new (ELeave) CSchItemRefArray(3);
|
sl@0
|
94 |
CleanupStack::PushL(refs);
|
sl@0
|
95 |
|
sl@0
|
96 |
TInt res = aScheduler.GetScheduleRefsL(*refs, aFilter);
|
sl@0
|
97 |
TEST2(res, KErrNone);
|
sl@0
|
98 |
|
sl@0
|
99 |
TInt count = refs->Count();
|
sl@0
|
100 |
CleanupStack::PopAndDestroy(); // refs
|
sl@0
|
101 |
return count;
|
sl@0
|
102 |
}
|
sl@0
|
103 |
|
sl@0
|
104 |
//creates a daily schedule with StartTime of aStartTime
|
sl@0
|
105 |
static TInt CreateScheduleL(TSchedulerItemRef& aRef,
|
sl@0
|
106 |
RScheduler& aScheduler,
|
sl@0
|
107 |
const TTsTime& aStartTime)
|
sl@0
|
108 |
{
|
sl@0
|
109 |
CSchEntryInfoArray* entryList
|
sl@0
|
110 |
= new (ELeave) CSchEntryInfoArray(1);
|
sl@0
|
111 |
CleanupStack::PushL(entryList);
|
sl@0
|
112 |
|
sl@0
|
113 |
TScheduleEntryInfo2 entry1 (aStartTime, EDaily, 1, 30);
|
sl@0
|
114 |
entryList->AppendL(entry1);
|
sl@0
|
115 |
TInt res = aScheduler.CreatePersistentSchedule(aRef, *entryList);
|
sl@0
|
116 |
CleanupStack::PopAndDestroy(); // entryList
|
sl@0
|
117 |
return res;
|
sl@0
|
118 |
}
|
sl@0
|
119 |
|
sl@0
|
120 |
// creates a schedule with numerous entries
|
sl@0
|
121 |
static TInt CreateSchedule1L(TSchedulerItemRef& aRef, RScheduler& aScheduler)
|
sl@0
|
122 |
{
|
sl@0
|
123 |
aRef.iName = _L("Schedule created using \"CreateSchedule1L\"");
|
sl@0
|
124 |
|
sl@0
|
125 |
CSchEntryInfoArray* entryList = new (ELeave) CSchEntryInfoArray(3);
|
sl@0
|
126 |
CleanupStack::PushL(entryList);
|
sl@0
|
127 |
|
sl@0
|
128 |
{
|
sl@0
|
129 |
TTsTime startTime1(SchSvrHelpers::UtcTimeBasedOnOffset(10, 0), ETrue); // 0m:10s from "now"
|
sl@0
|
130 |
TScheduleEntryInfo2 entry1 (startTime1, EDaily, 1, 20);
|
sl@0
|
131 |
entryList->AppendL(entry1);
|
sl@0
|
132 |
}
|
sl@0
|
133 |
{
|
sl@0
|
134 |
TTsTime startTime2(SchSvrHelpers::UtcTimeBasedOnOffset(20, 1), ETrue); // 0m:20s from "now"
|
sl@0
|
135 |
TScheduleEntryInfo2 entry2 (startTime2, EDaily, 1, 20);
|
sl@0
|
136 |
entryList->AppendL(entry2);
|
sl@0
|
137 |
}
|
sl@0
|
138 |
{
|
sl@0
|
139 |
TTsTime startTime3(SchSvrHelpers::UtcTimeBasedOnOffset(0, 0, 0, 0, 0, -1), ETrue); // -1 year from "now"
|
sl@0
|
140 |
TScheduleEntryInfo2 entry3 (startTime3, EDaily, 1, 20);
|
sl@0
|
141 |
entryList->AppendL(entry3);
|
sl@0
|
142 |
}
|
sl@0
|
143 |
|
sl@0
|
144 |
TInt res = aScheduler.CreatePersistentSchedule(aRef, *entryList);
|
sl@0
|
145 |
CleanupStack::PopAndDestroy(); // entryList
|
sl@0
|
146 |
return res;
|
sl@0
|
147 |
}
|
sl@0
|
148 |
|
sl@0
|
149 |
// creates a schedule with numerous entries
|
sl@0
|
150 |
static TInt CreateSchedule2L(TSchedulerItemRef& aRef, RScheduler& aScheduler)
|
sl@0
|
151 |
{
|
sl@0
|
152 |
CSchEntryInfoArray* entryList = new (ELeave) CSchEntryInfoArray(3);
|
sl@0
|
153 |
CleanupStack::PushL(entryList);
|
sl@0
|
154 |
|
sl@0
|
155 |
aRef.iName = _L("Schedule created using \"CreateSchedule2L\"");
|
sl@0
|
156 |
|
sl@0
|
157 |
{
|
sl@0
|
158 |
TTsTime startTime1(SchSvrHelpers::UtcTimeBasedOnOffset(30, 2), ETrue); // 2m:30s from "now"
|
sl@0
|
159 |
TScheduleEntryInfo2 entry1 (startTime1, EDaily, 1, 20);
|
sl@0
|
160 |
entryList->AppendL(entry1);
|
sl@0
|
161 |
}
|
sl@0
|
162 |
{
|
sl@0
|
163 |
TTsTime startTime2(SchSvrHelpers::UtcTimeBasedOnOffset(0, 5), ETrue); // 5m:00s from "now"
|
sl@0
|
164 |
TScheduleEntryInfo2 entry2 (startTime2, EDaily, 1, 20);
|
sl@0
|
165 |
entryList->AppendL(entry2);
|
sl@0
|
166 |
}
|
sl@0
|
167 |
|
sl@0
|
168 |
TInt res = aScheduler.CreatePersistentSchedule(aRef, *entryList);
|
sl@0
|
169 |
CleanupStack::PopAndDestroy(); // entryList
|
sl@0
|
170 |
return res;
|
sl@0
|
171 |
}
|
sl@0
|
172 |
|
sl@0
|
173 |
// creates a schedule with numerous entries
|
sl@0
|
174 |
static TInt CreateSchedule3L(TSchedulerItemRef& aRef, RScheduler& aScheduler)
|
sl@0
|
175 |
{
|
sl@0
|
176 |
CSchEntryInfoArray* entryList = new (ELeave) CSchEntryInfoArray(3);
|
sl@0
|
177 |
CleanupStack::PushL(entryList);
|
sl@0
|
178 |
|
sl@0
|
179 |
aRef.iName = _L("Schedule created using \"CreateSchedule3L\"");
|
sl@0
|
180 |
|
sl@0
|
181 |
{
|
sl@0
|
182 |
TTsTime startTime1(SchSvrHelpers::TimeBasedOnOffset(0, 9, 0, 20), ETrue); // 9mins and 20days in the future
|
sl@0
|
183 |
TScheduleEntryInfo2 entry1 (startTime1, EDaily, 1, 5); // repeat every day and valid for only 5 minutes
|
sl@0
|
184 |
entryList->AppendL(entry1);
|
sl@0
|
185 |
}
|
sl@0
|
186 |
|
sl@0
|
187 |
{
|
sl@0
|
188 |
TTsTime startTime2(SchSvrHelpers::TimeBasedOnOffset(0, 11, 0, 20), ETrue); // 11mins and 20days in the future
|
sl@0
|
189 |
TScheduleEntryInfo2 entry2 (startTime2, EDaily, 1, 5);
|
sl@0
|
190 |
entryList->AppendL(entry2);
|
sl@0
|
191 |
}
|
sl@0
|
192 |
|
sl@0
|
193 |
TInt res = aScheduler.CreatePersistentSchedule(aRef, *entryList);
|
sl@0
|
194 |
CleanupStack::PopAndDestroy(); // entryList
|
sl@0
|
195 |
|
sl@0
|
196 |
return res;
|
sl@0
|
197 |
}
|
sl@0
|
198 |
|
sl@0
|
199 |
// schedules a persistent task associated with the supplied schedule ID
|
sl@0
|
200 |
static TInt SchedulePersistentTaskL(const TName& aName,
|
sl@0
|
201 |
TInt& aNewId,
|
sl@0
|
202 |
TInt aScheduleId,
|
sl@0
|
203 |
TInt aRepeat,
|
sl@0
|
204 |
RScheduler& aScheduler)
|
sl@0
|
205 |
{
|
sl@0
|
206 |
TTaskInfo taskInfo;
|
sl@0
|
207 |
taskInfo.iTaskId = aNewId;
|
sl@0
|
208 |
taskInfo.iName = aName;
|
sl@0
|
209 |
taskInfo.iPriority = 2;
|
sl@0
|
210 |
taskInfo.iRepeat = aRepeat;
|
sl@0
|
211 |
HBufC* data = _L("the data").AllocLC();
|
sl@0
|
212 |
TInt res = aScheduler.ScheduleTask(taskInfo, *data, aScheduleId);
|
sl@0
|
213 |
aNewId = taskInfo.iTaskId;
|
sl@0
|
214 |
|
sl@0
|
215 |
CleanupStack::PopAndDestroy(); // data
|
sl@0
|
216 |
return res;
|
sl@0
|
217 |
}
|
sl@0
|
218 |
|
sl@0
|
219 |
/**
|
sl@0
|
220 |
@file
|
sl@0
|
221 |
@SYMTestCaseID SYSLIB-SCHSVR-CT-0265
|
sl@0
|
222 |
@SYMTestCaseDesc Replicated test for for defect (EDNAWIR-4FQJ6A) - UTC
|
sl@0
|
223 |
@SYMTestPriority High
|
sl@0
|
224 |
@SYMTestActions Register twice with SchSvr and check that there are no memery leaks
|
sl@0
|
225 |
@SYMTestExpectedResults The test must not fail.
|
sl@0
|
226 |
@SYMPREQ PREQ234
|
sl@0
|
227 |
*/
|
sl@0
|
228 |
static void Test1L()
|
sl@0
|
229 |
{
|
sl@0
|
230 |
TheTest.Next(_L(" @SYMTestCaseID:SYSLIB-SCHSVR-CT-0265 TheTest1: Registering with the tasks scheduler without disconnecting "));
|
sl@0
|
231 |
|
sl@0
|
232 |
__UHEAP_MARK;
|
sl@0
|
233 |
TheTest.Next(_L("Connect to Scheduler"));
|
sl@0
|
234 |
TInt res = TheScheduler.Connect();
|
sl@0
|
235 |
TEST2(res, KErrNone);
|
sl@0
|
236 |
|
sl@0
|
237 |
TheTest.Next(_L("Registering Client"));
|
sl@0
|
238 |
TEST2(SchSvrHelpers::RegisterClientL(TheScheduler), KErrNone);
|
sl@0
|
239 |
|
sl@0
|
240 |
TheScheduler.Close();
|
sl@0
|
241 |
__UHEAP_MARKEND;
|
sl@0
|
242 |
|
sl@0
|
243 |
__UHEAP_MARK;
|
sl@0
|
244 |
TheTest.Next(_L("Connect to Scheduler again"));
|
sl@0
|
245 |
res = TheScheduler.Connect();
|
sl@0
|
246 |
TEST2(res, KErrNone);
|
sl@0
|
247 |
|
sl@0
|
248 |
TheTest.Next(_L("Registering client again"));
|
sl@0
|
249 |
TEST2(SchSvrHelpers::RegisterClientL(TheScheduler), KErrNone);
|
sl@0
|
250 |
TheScheduler.__DbgMarkHeap();
|
sl@0
|
251 |
|
sl@0
|
252 |
TheTest.Next(_L("Register when already registered"));
|
sl@0
|
253 |
TEST2(SchSvrHelpers::RegisterClientL(TheScheduler), KErrNone);
|
sl@0
|
254 |
|
sl@0
|
255 |
TheTest.Next(_L("Cancel registering client and check for memory leak"));
|
sl@0
|
256 |
TheScheduler.__DbgMarkEnd(0);
|
sl@0
|
257 |
TheScheduler.Close();
|
sl@0
|
258 |
__UHEAP_MARKEND;
|
sl@0
|
259 |
}
|
sl@0
|
260 |
|
sl@0
|
261 |
|
sl@0
|
262 |
//***********************************************************************************
|
sl@0
|
263 |
|
sl@0
|
264 |
/**
|
sl@0
|
265 |
@file
|
sl@0
|
266 |
@SYMTestCaseID SYSLIB-SCHSVR-CT-0266
|
sl@0
|
267 |
@SYMTestCaseDesc Replicated test for for defect (EDNHLJT-4TRAAE) - UTC
|
sl@0
|
268 |
@SYMTestPriority High
|
sl@0
|
269 |
@SYMTestActions Create schedule, kill server (simulate re-boot), and make sure task still completes
|
sl@0
|
270 |
@SYMTestExpectedResults The test must not fail.
|
sl@0
|
271 |
@SYMPREQ PREQ234
|
sl@0
|
272 |
*/
|
sl@0
|
273 |
static void Test2L()
|
sl@0
|
274 |
{
|
sl@0
|
275 |
TheTest.Next(_L(" @SYMTestCaseID:SYSLIB-SCHSVR-CT-0266 TheTest2: Resend after hard reset (simulation) "));
|
sl@0
|
276 |
TheTest.Next(_L("Connect to Scheduler"));
|
sl@0
|
277 |
TInt res = TheScheduler.Connect();
|
sl@0
|
278 |
TEST2(res, KErrNone);
|
sl@0
|
279 |
|
sl@0
|
280 |
TheTest.Next(_L("Registering Client"));
|
sl@0
|
281 |
TEST2(SchSvrHelpers::RegisterClientL(TheScheduler), KErrNone);
|
sl@0
|
282 |
|
sl@0
|
283 |
// Create a schedule
|
sl@0
|
284 |
TheTest.Next(_L("Creating schedule"));
|
sl@0
|
285 |
TSchedulerItemRef scheduleHandle;
|
sl@0
|
286 |
TTime time;
|
sl@0
|
287 |
time.UniversalTime();
|
sl@0
|
288 |
time += TTimeIntervalSeconds(5); //Task to go off five seconds from now
|
sl@0
|
289 |
TTsTime time2 (time, ETrue);
|
sl@0
|
290 |
User::LeaveIfError(CreateScheduleL(scheduleHandle, TheScheduler, time2));
|
sl@0
|
291 |
|
sl@0
|
292 |
// Add a task to the schedule
|
sl@0
|
293 |
TheTest.Next(_L("Creating task for schedule"));
|
sl@0
|
294 |
{
|
sl@0
|
295 |
TTaskInfo taskInfo;
|
sl@0
|
296 |
taskInfo.iName = _L("MyTaskName");
|
sl@0
|
297 |
taskInfo.iPriority = 2;
|
sl@0
|
298 |
taskInfo.iTaskId = 0;
|
sl@0
|
299 |
taskInfo.iRepeat = 1;
|
sl@0
|
300 |
HBufC* data = _L("Task Data").AllocLC();
|
sl@0
|
301 |
TInt res = TheScheduler.ScheduleTask(taskInfo, *data, scheduleHandle.iHandle);
|
sl@0
|
302 |
CleanupStack::PopAndDestroy(); // data
|
sl@0
|
303 |
TEST2(res, KErrNone);
|
sl@0
|
304 |
}
|
sl@0
|
305 |
|
sl@0
|
306 |
// Kill the server !!
|
sl@0
|
307 |
TheTest.Next(_L("Killing server"));
|
sl@0
|
308 |
// Need to turn off JIT dubugging as we are panicking server and we
|
sl@0
|
309 |
// want test to keep running.
|
sl@0
|
310 |
TBool jit = User::JustInTime();
|
sl@0
|
311 |
User::SetJustInTime(EFalse);
|
sl@0
|
312 |
|
sl@0
|
313 |
TheScheduler.__FaultServer();
|
sl@0
|
314 |
User::After(100000);
|
sl@0
|
315 |
|
sl@0
|
316 |
// Turn on JIT again.
|
sl@0
|
317 |
User::SetJustInTime(jit);
|
sl@0
|
318 |
|
sl@0
|
319 |
// Connect to the server again
|
sl@0
|
320 |
TheTest.Next(_L("Re-connect to Scheduler"));
|
sl@0
|
321 |
res = TheScheduler.Connect();
|
sl@0
|
322 |
TEST2(res, KErrNone);
|
sl@0
|
323 |
|
sl@0
|
324 |
// Re-register
|
sl@0
|
325 |
TheTest.Next(_L("Re-register Client"));
|
sl@0
|
326 |
TEST2(SchSvrHelpers::RegisterClientL(TheScheduler), KErrNone);
|
sl@0
|
327 |
|
sl@0
|
328 |
TheTest.Next(_L("Check schedule count and task count"));
|
sl@0
|
329 |
TInt scheduleCount = CountScheduledItemsL(EAllSchedules, TheScheduler);
|
sl@0
|
330 |
TEST(scheduleCount == 1);
|
sl@0
|
331 |
TInt taskCount = CountTasksL(scheduleHandle.iHandle);
|
sl@0
|
332 |
TEST(taskCount == 1);
|
sl@0
|
333 |
|
sl@0
|
334 |
// Wait for task to fire... It should happen in about 5 seconds
|
sl@0
|
335 |
TheTest.Next(_L("Waiting for task to complete"));
|
sl@0
|
336 |
TEST2(STaskSemaphore::WaitL(KDefaultTimeout), KErrNone);
|
sl@0
|
337 |
CleanupHelpers::KillProcess(KMinimalTaskHandler);
|
sl@0
|
338 |
}
|
sl@0
|
339 |
|
sl@0
|
340 |
//***********************************************************************************
|
sl@0
|
341 |
|
sl@0
|
342 |
/**
|
sl@0
|
343 |
@file
|
sl@0
|
344 |
@SYMTestCaseID SYSLIB-SCHSVR-CT-0267
|
sl@0
|
345 |
@SYMTestCaseDesc Replicated test for CR (AALR-4EDG75) - UTC
|
sl@0
|
346 |
@SYMTestPriority High
|
sl@0
|
347 |
@SYMTestActions Test changes to Schedule Server API
|
sl@0
|
348 |
@SYMTestExpectedResults The test must not fail.
|
sl@0
|
349 |
@SYMPREQ PREQ234
|
sl@0
|
350 |
*/
|
sl@0
|
351 |
static void Test3L()
|
sl@0
|
352 |
{
|
sl@0
|
353 |
//
|
sl@0
|
354 |
//
|
sl@0
|
355 |
// Test changes to Schedule Server API as of Change Request document AALR-4EDG75
|
sl@0
|
356 |
// (GT change requests database)
|
sl@0
|
357 |
//
|
sl@0
|
358 |
//
|
sl@0
|
359 |
//
|
sl@0
|
360 |
// This test establishes that the change to...
|
sl@0
|
361 |
//
|
sl@0
|
362 |
// RScheduler::GetScheduleL(const TInt aScheduleHandle,
|
sl@0
|
363 |
// TScheduleState& aState,
|
sl@0
|
364 |
// CArrayFixFlat<TScheduleEntryInfo>& aEntries,
|
sl@0
|
365 |
// CArrayFixFlat<TTaskInfo>& aTasks,
|
sl@0
|
366 |
// TTime& aNextDue)
|
sl@0
|
367 |
//
|
sl@0
|
368 |
// ...is functionally correct.
|
sl@0
|
369 |
//
|
sl@0
|
370 |
//
|
sl@0
|
371 |
|
sl@0
|
372 |
TheTest.Next(_L(" @SYMTestCaseID:SYSLIB-SCHSVR-CT-0267 Test change request AALR-4EDG75 implementation"));
|
sl@0
|
373 |
|
sl@0
|
374 |
TheTest.Next(_L("Connect to Scheduler"));
|
sl@0
|
375 |
TInt res = TheScheduler.Connect();
|
sl@0
|
376 |
TEST2(res, KErrNone);
|
sl@0
|
377 |
|
sl@0
|
378 |
TheTest.Next(_L("Registering Client"));
|
sl@0
|
379 |
TEST2(SchSvrHelpers::RegisterClientL(TheScheduler), KErrNone);
|
sl@0
|
380 |
|
sl@0
|
381 |
const TDateTime KTimeToStartTask(2000, EJanuary, 10, 15, 30, 0, 0);
|
sl@0
|
382 |
|
sl@0
|
383 |
TSchedulerItemRef schedulerItemReference;
|
sl@0
|
384 |
CSchEntryInfoArray* entryArray = new(ELeave) CSchEntryInfoArray(1);
|
sl@0
|
385 |
CleanupStack::PushL(entryArray);
|
sl@0
|
386 |
|
sl@0
|
387 |
HBufC* taskData = _L("This is some dummy task data created for testing").AllocL();
|
sl@0
|
388 |
CleanupStack::PushL(taskData);
|
sl@0
|
389 |
|
sl@0
|
390 |
// Prepare the task info - this describes the tasks that are contained within the task
|
sl@0
|
391 |
// entry array
|
sl@0
|
392 |
TTaskInfo taskInfo = SchSvrHelpers::TaskInfo(_L("A transient test task"), 100);
|
sl@0
|
393 |
|
sl@0
|
394 |
// Create a schedule entry and append it to the entry array
|
sl@0
|
395 |
{
|
sl@0
|
396 |
TScheduleEntryInfo2 scheduleEntry = SchSvrHelpers::ScheduleEntryInfo(EDaily, TTsTime(TTime(KTimeToStartTask), ETrue), 7, 2);
|
sl@0
|
397 |
entryArray->AppendL(scheduleEntry);
|
sl@0
|
398 |
}
|
sl@0
|
399 |
|
sl@0
|
400 |
// Create the transient task
|
sl@0
|
401 |
TInt ret = TheScheduler.ScheduleTask(taskInfo, *taskData, schedulerItemReference, *entryArray);
|
sl@0
|
402 |
TEST2(ret, KErrNone);
|
sl@0
|
403 |
|
sl@0
|
404 |
// Check that the task Id after scheduling the event is not
|
sl@0
|
405 |
// the same as it was prior to the requesting the service
|
sl@0
|
406 |
TEST(taskInfo.iTaskId != -1);
|
sl@0
|
407 |
|
sl@0
|
408 |
//
|
sl@0
|
409 |
// Now obtain info about the scheduled transient task...
|
sl@0
|
410 |
//
|
sl@0
|
411 |
TScheduleState2 scheduleState;
|
sl@0
|
412 |
TTsTime nextTaskDueTime;
|
sl@0
|
413 |
|
sl@0
|
414 |
// Reset the schedule entry info array as the server now has copies of this and it is
|
sl@0
|
415 |
// no longer required client-side
|
sl@0
|
416 |
entryArray->Reset();
|
sl@0
|
417 |
CTaskInfoArray* taskInfoArray = new(ELeave) CTaskInfoArray(4);
|
sl@0
|
418 |
CleanupStack::PushL(taskInfoArray);
|
sl@0
|
419 |
|
sl@0
|
420 |
// Request task schedule information from the server
|
sl@0
|
421 |
ret = TheScheduler.GetScheduleL(schedulerItemReference.iHandle, scheduleState, *entryArray, *taskInfoArray, nextTaskDueTime);
|
sl@0
|
422 |
TEST2(ret, KErrNone);
|
sl@0
|
423 |
|
sl@0
|
424 |
// Because this is a daily task which is scheduled to occur at a specific time (but the date
|
sl@0
|
425 |
// cannot necessarily be established, we can perform a simple check to ensure that the
|
sl@0
|
426 |
// time when the task is next scheduled to run falls within the 15:30 - 17:30 bracket.
|
sl@0
|
427 |
TEST(SchSvrHelpers::IsTimeTheSame(nextTaskDueTime, TTsTime(TTime(KTimeToStartTask), ETrue)) == (TInt) ETrue);
|
sl@0
|
428 |
|
sl@0
|
429 |
// Establish and test the size of the task data for the specified task object
|
sl@0
|
430 |
TInt sizeOfTaskData = 0;
|
sl@0
|
431 |
TEST2(TheScheduler.GetTaskDataSize(taskInfo.iTaskId, sizeOfTaskData), KErrNone);
|
sl@0
|
432 |
TEST(sizeOfTaskData == taskData->Length());
|
sl@0
|
433 |
|
sl@0
|
434 |
// Now check the information return from the server pertaining to a specific task...
|
sl@0
|
435 |
{
|
sl@0
|
436 |
TTaskInfo taskFromServer;
|
sl@0
|
437 |
HBufC* taskDataFromServer = HBufC::NewLC(sizeOfTaskData);
|
sl@0
|
438 |
TPtr pTaskDataFromServer = taskDataFromServer->Des();
|
sl@0
|
439 |
TTime nullTime = Time::NullTTime();
|
sl@0
|
440 |
TTsTime nextDueTimeFromServer (nullTime, ETrue);
|
sl@0
|
441 |
TSchedulerItemRef schedulerRefFromServer;
|
sl@0
|
442 |
TEST2(TheScheduler.GetTaskInfoL(taskInfo.iTaskId, taskFromServer, pTaskDataFromServer, schedulerRefFromServer, nextDueTimeFromServer), KErrNone);
|
sl@0
|
443 |
TEST(SchSvrHelpers::IsTimeTheSame(nextTaskDueTime, TTsTime(TTime(KTimeToStartTask), ETrue)) == (TInt) ETrue);
|
sl@0
|
444 |
|
sl@0
|
445 |
TEST(SchSvrHelpers::IsTaskInfoTheSame(taskFromServer, taskInfo) == (TInt) ETrue);
|
sl@0
|
446 |
TEST(SchSvrHelpers::IsItemRefTheSame(schedulerRefFromServer, schedulerItemReference) == (TInt) ETrue);
|
sl@0
|
447 |
CleanupStack::PopAndDestroy(); // taskDataFromServer
|
sl@0
|
448 |
}
|
sl@0
|
449 |
|
sl@0
|
450 |
// Disable the schedule and check when it is next schedule to run
|
sl@0
|
451 |
TEST2(TheScheduler.DisableSchedule(schedulerItemReference.iHandle), KErrNone);
|
sl@0
|
452 |
|
sl@0
|
453 |
// Get the new schedule info - check that the nextDueTime is still reported even
|
sl@0
|
454 |
// though the schedule has been disabled
|
sl@0
|
455 |
|
sl@0
|
456 |
nextTaskDueTime.SetUtcTime(Time::NullTTime());
|
sl@0
|
457 |
TEST2(TheScheduler.GetScheduleL(schedulerItemReference.iHandle, scheduleState, *entryArray, *taskInfoArray, nextTaskDueTime), KErrNone);
|
sl@0
|
458 |
TEST(SchSvrHelpers::IsTimeTheSame(nextTaskDueTime, TTsTime(TTime(KTimeToStartTask), ETrue)) == (TInt) ETrue);
|
sl@0
|
459 |
TEST(SchSvrHelpers::IsTaskInfoTheSame(taskInfoArray->At(0), taskInfo) == (TInt) ETrue);
|
sl@0
|
460 |
|
sl@0
|
461 |
// Re-enable the schedule
|
sl@0
|
462 |
TEST2(TheScheduler.EnableSchedule(schedulerItemReference.iHandle), KErrNone);
|
sl@0
|
463 |
|
sl@0
|
464 |
// Delete the only task (relating to this test) from the server
|
sl@0
|
465 |
TEST2(TheScheduler.DeleteTask(taskInfo.iTaskId), KErrNone);
|
sl@0
|
466 |
ret = TheScheduler.GetScheduleL(schedulerItemReference.iHandle, scheduleState, *entryArray, *taskInfoArray, nextTaskDueTime);
|
sl@0
|
467 |
TEST2(ret, KErrNotFound); // there is no longer any tasks associated with this schedule
|
sl@0
|
468 |
|
sl@0
|
469 |
CleanupStack::PopAndDestroy(3); // taskInfoArray, entryArray, taskData
|
sl@0
|
470 |
}
|
sl@0
|
471 |
|
sl@0
|
472 |
//***********************************************************************************
|
sl@0
|
473 |
|
sl@0
|
474 |
/**
|
sl@0
|
475 |
@file
|
sl@0
|
476 |
@SYMTestCaseID SYSLIB-SCHSVR-CT-0268
|
sl@0
|
477 |
@SYMTestCaseDesc Replicated test for defect (EDNAALR-4JKEFC) - UTC
|
sl@0
|
478 |
@SYMTestPriority High
|
sl@0
|
479 |
@SYMTestActions Create 2 schedules with repeating tasks, kill server and check that tasks complete
|
sl@0
|
480 |
@SYMTestExpectedResults The test must not fail.
|
sl@0
|
481 |
@SYMPREQ PREQ234
|
sl@0
|
482 |
*/
|
sl@0
|
483 |
static void Test4L()
|
sl@0
|
484 |
{
|
sl@0
|
485 |
// Test title
|
sl@0
|
486 |
TheTest.Next(_L(" @SYMTestCaseID:SYSLIB-SCHSVR-CT-0268 \nTest for defect EDNAALR-4JKEFC"));
|
sl@0
|
487 |
|
sl@0
|
488 |
TheTest.Next(_L("Connect to Scheduler"));
|
sl@0
|
489 |
TInt res = TheScheduler.Connect();
|
sl@0
|
490 |
TEST2(res, KErrNone);
|
sl@0
|
491 |
|
sl@0
|
492 |
TheTest.Next(_L("Registering Client"));
|
sl@0
|
493 |
TEST2(SchSvrHelpers::RegisterClientL(TheScheduler), KErrNone);
|
sl@0
|
494 |
|
sl@0
|
495 |
// Constants / vars used in this function
|
sl@0
|
496 |
TSchedulerItemRef itemRef;
|
sl@0
|
497 |
|
sl@0
|
498 |
// Create some scheduling entries
|
sl@0
|
499 |
CArrayFixFlat<TScheduleEntryInfo2>* entries = new(ELeave) CArrayFixFlat<TScheduleEntryInfo2>(10);
|
sl@0
|
500 |
CleanupStack::PushL(entries);
|
sl@0
|
501 |
|
sl@0
|
502 |
TTsTime startTime1 (SchSvrHelpers::TimeBasedOnOffset(1, 1), ETrue); // 1m:01s from "now"
|
sl@0
|
503 |
TScheduleEntryInfo2 entry1 (startTime1, EHourly, 1, 20);
|
sl@0
|
504 |
entries->AppendL(entry1);
|
sl@0
|
505 |
|
sl@0
|
506 |
TTsTime startTime2 (SchSvrHelpers::TimeBasedOnOffset(5, 5), ETrue); // 5m:05s from "now"
|
sl@0
|
507 |
TScheduleEntryInfo2 entry2 (startTime2, EHourly, 1, 20);
|
sl@0
|
508 |
entries->AppendL(entry2);
|
sl@0
|
509 |
|
sl@0
|
510 |
// Create the schedule for the task...
|
sl@0
|
511 |
res = TheScheduler.CreatePersistentSchedule(itemRef, *entries);
|
sl@0
|
512 |
TEST2(res, KErrNone);
|
sl@0
|
513 |
|
sl@0
|
514 |
// Create the tasks themselves..
|
sl@0
|
515 |
TTaskInfo task;
|
sl@0
|
516 |
task.iRepeat = 10; // repeat once
|
sl@0
|
517 |
task.iName = _L("Test Task For Defect Verification");
|
sl@0
|
518 |
task.iPriority = 100;
|
sl@0
|
519 |
HBufC* taskData = task.iName.AllocLC();
|
sl@0
|
520 |
res = TheScheduler.ScheduleTask(task, *taskData, itemRef.iHandle);
|
sl@0
|
521 |
CleanupStack::PopAndDestroy(); // taskData
|
sl@0
|
522 |
|
sl@0
|
523 |
{
|
sl@0
|
524 |
CArrayFixFlat<TSchedulerItemRef>* refs = new CArrayFixFlat<TSchedulerItemRef>(3);
|
sl@0
|
525 |
CleanupStack::PushL(refs);
|
sl@0
|
526 |
TInt res = TheScheduler.GetScheduleRefsL(*refs, EAllSchedules);
|
sl@0
|
527 |
TEST2(res, KErrNone);
|
sl@0
|
528 |
CleanupStack::PopAndDestroy(); // refs
|
sl@0
|
529 |
}
|
sl@0
|
530 |
|
sl@0
|
531 |
// Re-register theclient with the server
|
sl@0
|
532 |
for(TInt i=0; i<5; i++)
|
sl@0
|
533 |
{
|
sl@0
|
534 |
// Log off from the task scheduler
|
sl@0
|
535 |
TheScheduler.Close();
|
sl@0
|
536 |
res = TheScheduler.Connect();
|
sl@0
|
537 |
TEST2(res, KErrNone);
|
sl@0
|
538 |
|
sl@0
|
539 |
User::After(1000000);
|
sl@0
|
540 |
|
sl@0
|
541 |
TheTest.Next(_L("===== Re-registering Client (wait a second) ====="));
|
sl@0
|
542 |
res = SchSvrHelpers::RegisterClientL(TheScheduler);
|
sl@0
|
543 |
TEST2(res, KErrNone);
|
sl@0
|
544 |
{
|
sl@0
|
545 |
CArrayFixFlat<TSchedulerItemRef>* refs = new CArrayFixFlat<TSchedulerItemRef>(3);
|
sl@0
|
546 |
CleanupStack::PushL(refs);
|
sl@0
|
547 |
TInt res = TheScheduler.GetScheduleRefsL(*refs, EAllSchedules);
|
sl@0
|
548 |
TEST2(res, 0);
|
sl@0
|
549 |
CleanupStack::PopAndDestroy(); // refs
|
sl@0
|
550 |
}
|
sl@0
|
551 |
|
sl@0
|
552 |
// Check the information that the scheduler knows about...
|
sl@0
|
553 |
TInt taskDataSize = 0;
|
sl@0
|
554 |
res = TheScheduler.GetTaskDataSize(task.iTaskId, taskDataSize);
|
sl@0
|
555 |
TEST2(res, KErrNone);
|
sl@0
|
556 |
TEST(taskDataSize == task.iName.Length());
|
sl@0
|
557 |
TTaskInfo taskInfoFromServer;
|
sl@0
|
558 |
taskData = HBufC::NewLC(taskDataSize);
|
sl@0
|
559 |
TPtr pTaskData = taskData->Des();
|
sl@0
|
560 |
|
sl@0
|
561 |
TTsTime nextDueTime(Time::NullTTime(), ETrue);
|
sl@0
|
562 |
res = TheScheduler.GetTaskInfoL(task.iTaskId, taskInfoFromServer, pTaskData, itemRef, nextDueTime);
|
sl@0
|
563 |
TEST2(res, KErrNone);
|
sl@0
|
564 |
TEST(pTaskData == task.iName);
|
sl@0
|
565 |
CleanupStack::PopAndDestroy(); // taskData
|
sl@0
|
566 |
}
|
sl@0
|
567 |
|
sl@0
|
568 |
CleanupStack::PopAndDestroy(); // entries
|
sl@0
|
569 |
|
sl@0
|
570 |
}
|
sl@0
|
571 |
|
sl@0
|
572 |
//***********************************************************************************
|
sl@0
|
573 |
|
sl@0
|
574 |
/**
|
sl@0
|
575 |
@file
|
sl@0
|
576 |
@SYMTestCaseID SYSLIB-SCHSVR-CT-0269
|
sl@0
|
577 |
@SYMTestCaseDesc Persistant schedule test - UTC
|
sl@0
|
578 |
@SYMTestPriority High
|
sl@0
|
579 |
@SYMTestActions Mark heap, create persistent schedules, schedule tasks, transient schedules, delete tasks, delete remaing schedules, check heap
|
sl@0
|
580 |
@SYMTestExpectedResults The test must not fail.
|
sl@0
|
581 |
@SYMPREQ PREQ234
|
sl@0
|
582 |
*/
|
sl@0
|
583 |
static void Test5L()
|
sl@0
|
584 |
{
|
sl@0
|
585 |
TInt res = KErrNone;
|
sl@0
|
586 |
TheTest.Next(_L(" @SYMTestCaseID:SYSLIB-SCHSVR-CT-0269 ===== Starting test 1 ====="));
|
sl@0
|
587 |
|
sl@0
|
588 |
__UHEAP_MARK;
|
sl@0
|
589 |
|
sl@0
|
590 |
TSchedulerItemRef ref1;
|
sl@0
|
591 |
TSchedulerItemRef ref2;
|
sl@0
|
592 |
TSchedulerItemRef ref3;
|
sl@0
|
593 |
|
sl@0
|
594 |
// Remove all existing schedules before starting the test
|
sl@0
|
595 |
SchSvrHelpers::DeleteAllSchedulesL(TheScheduler);
|
sl@0
|
596 |
|
sl@0
|
597 |
TInt scheduleCount = CountScheduledItemsL(EAllSchedules, TheScheduler);
|
sl@0
|
598 |
TEST(scheduleCount == 0); // check that no schedules are present.
|
sl@0
|
599 |
|
sl@0
|
600 |
TheTest.Printf(_L("Create some schedules\n"));
|
sl@0
|
601 |
res = CreateSchedule1L(ref1, TheScheduler); // +10sec, +20sec, -1year
|
sl@0
|
602 |
TEST2(res, KErrNone);
|
sl@0
|
603 |
res = CreateSchedule2L(ref2, TheScheduler); // +2min 30sec, +5min
|
sl@0
|
604 |
TEST2(res, KErrNone);
|
sl@0
|
605 |
res = CreateSchedule3L(ref3, TheScheduler); // +20day 9min, +20day 11min
|
sl@0
|
606 |
TEST2(res, KErrNone);
|
sl@0
|
607 |
|
sl@0
|
608 |
TSchedulerItemRef ref4;
|
sl@0
|
609 |
TSchedulerItemRef ref5;
|
sl@0
|
610 |
res = CreateSchedule2L(ref4, TheScheduler); // +2min 30sec, 5min
|
sl@0
|
611 |
TEST2(res, KErrNone);
|
sl@0
|
612 |
res = CreateSchedule3L(ref5, TheScheduler); // +20day 9min, +20day 11min
|
sl@0
|
613 |
TEST2(res, KErrNone);
|
sl@0
|
614 |
|
sl@0
|
615 |
TInt task1 = 0;
|
sl@0
|
616 |
TInt task2 = 0;
|
sl@0
|
617 |
TInt task3 = 0;
|
sl@0
|
618 |
TInt task4 = 0;
|
sl@0
|
619 |
TName name1 = (_L("web subscription"));
|
sl@0
|
620 |
TName name2 = (_L("another web subscription"));
|
sl@0
|
621 |
TName name3 = (_L("third web subscription"));
|
sl@0
|
622 |
|
sl@0
|
623 |
TheTest.Printf(_L("Schedule some tasks\n"));
|
sl@0
|
624 |
|
sl@0
|
625 |
// NOTE: have to put repeats here of > 0 otherwise the task will run immediately
|
sl@0
|
626 |
// (because it's schedule specifies a date of 1 year in the past!) and be
|
sl@0
|
627 |
// removed (by the server) before we have a chance to delete it....
|
sl@0
|
628 |
res = SchedulePersistentTaskL(name1, task1, ref1.iHandle, 3, TheScheduler);
|
sl@0
|
629 |
TEST2(res, KErrNone);
|
sl@0
|
630 |
res = SchedulePersistentTaskL(name2, task2, ref2.iHandle, 3, TheScheduler);
|
sl@0
|
631 |
TEST2(res, KErrNone);
|
sl@0
|
632 |
res = SchedulePersistentTaskL(name3, task3, ref3.iHandle, 3, TheScheduler);
|
sl@0
|
633 |
TEST2(res, KErrNone);
|
sl@0
|
634 |
res = SchedulePersistentTaskL(name3, task4, ref3.iHandle, 3, TheScheduler);
|
sl@0
|
635 |
TEST2(res, KErrNone);
|
sl@0
|
636 |
|
sl@0
|
637 |
scheduleCount = CountScheduledItemsL(EAllSchedules, TheScheduler);
|
sl@0
|
638 |
TEST(scheduleCount == 5); // 5 persistant
|
sl@0
|
639 |
CleanupHelpers::KillProcess(KMinimalTaskHandler);
|
sl@0
|
640 |
|
sl@0
|
641 |
TheTest.Printf(_L("Deleting task with id %d\n"), task1);
|
sl@0
|
642 |
res = TheScheduler.DeleteTask(task1);
|
sl@0
|
643 |
TEST2(res, KErrNone);
|
sl@0
|
644 |
TheTest.Printf(_L("Deleting schedule with id %d\n"), ref1.iHandle);
|
sl@0
|
645 |
res = TheScheduler.DeleteSchedule(ref1.iHandle);
|
sl@0
|
646 |
TEST2(res, KErrNone);
|
sl@0
|
647 |
scheduleCount = CountScheduledItemsL(EAllSchedules, TheScheduler);
|
sl@0
|
648 |
// 4 persistant expected as we have deleted one
|
sl@0
|
649 |
TEST(scheduleCount == 4);
|
sl@0
|
650 |
|
sl@0
|
651 |
TheTest.Printf(_L("Deleting task with id %d\n"), task2);
|
sl@0
|
652 |
res = TheScheduler.DeleteTask(task2);
|
sl@0
|
653 |
TEST2(res, KErrNone);
|
sl@0
|
654 |
TheTest.Printf(_L("Deleting schedule with id %d\n"), ref2.iHandle);
|
sl@0
|
655 |
res = TheScheduler.DeleteSchedule(ref2.iHandle);
|
sl@0
|
656 |
TEST2(res, KErrNone);
|
sl@0
|
657 |
scheduleCount = CountScheduledItemsL(EAllSchedules, TheScheduler);
|
sl@0
|
658 |
// 3 persistant expected as we have deleted one
|
sl@0
|
659 |
TEST(scheduleCount == 3);
|
sl@0
|
660 |
|
sl@0
|
661 |
TheTest.Printf(_L("Deleting task with id %d\n"), task3);
|
sl@0
|
662 |
res = TheScheduler.DeleteTask(task3);
|
sl@0
|
663 |
TEST2(res, KErrNone);
|
sl@0
|
664 |
TheTest.Printf(_L("Deleting task with id %d\n"), task4);
|
sl@0
|
665 |
res = TheScheduler.DeleteTask(task4);
|
sl@0
|
666 |
TEST2(res, KErrNone);
|
sl@0
|
667 |
TheTest.Printf(_L("Deleting schedule with id %d\n"), ref3.iHandle);
|
sl@0
|
668 |
res = TheScheduler.DeleteSchedule(ref3.iHandle);
|
sl@0
|
669 |
TEST2(res, KErrNone);
|
sl@0
|
670 |
scheduleCount = CountScheduledItemsL(EAllSchedules, TheScheduler);
|
sl@0
|
671 |
// 2 persistant expected as we have deleted one
|
sl@0
|
672 |
TEST(scheduleCount == 2);
|
sl@0
|
673 |
|
sl@0
|
674 |
TheTest.Printf(_L("Deleting schedule with id %d\n"), ref4.iHandle);
|
sl@0
|
675 |
res = TheScheduler.DeleteSchedule(ref4.iHandle);
|
sl@0
|
676 |
TEST2(res, KErrNone);
|
sl@0
|
677 |
TheTest.Printf(_L("Deleting schedule with id %d\n"), ref5.iHandle);
|
sl@0
|
678 |
res = TheScheduler.DeleteSchedule(ref5.iHandle);
|
sl@0
|
679 |
TEST2(res, KErrNone);
|
sl@0
|
680 |
|
sl@0
|
681 |
scheduleCount = CountScheduledItemsL(EAllSchedules, TheScheduler);
|
sl@0
|
682 |
TEST(scheduleCount == 0);
|
sl@0
|
683 |
|
sl@0
|
684 |
SchSvrHelpers::Pause(TheTest,1);
|
sl@0
|
685 |
__UHEAP_MARKEND;
|
sl@0
|
686 |
}
|
sl@0
|
687 |
|
sl@0
|
688 |
|
sl@0
|
689 |
//***********************************************************************************
|
sl@0
|
690 |
|
sl@0
|
691 |
/**
|
sl@0
|
692 |
@file
|
sl@0
|
693 |
@SYMTestCaseID SYSLIB-SCHSVR-CT-0270
|
sl@0
|
694 |
@SYMTestCaseDesc Transient schedule test - UTC
|
sl@0
|
695 |
@SYMTestPriority High
|
sl@0
|
696 |
@SYMTestActions Create transient schedule with non-repeating task
|
sl@0
|
697 |
@SYMTestExpectedResults The test must not fail.
|
sl@0
|
698 |
@SYMPREQ PREQ234
|
sl@0
|
699 |
*/
|
sl@0
|
700 |
static void Test6L()
|
sl@0
|
701 |
{
|
sl@0
|
702 |
// Heap testing removed because this is a flakey bit of code.
|
sl@0
|
703 |
TheTest.Next(_L(" @SYMTestCaseID:SYSLIB-SCHSVR-CT-0270 Transient, non-repeating - waits for schedule to activate "));
|
sl@0
|
704 |
|
sl@0
|
705 |
// Remove all existing schedules before starting the test
|
sl@0
|
706 |
SchSvrHelpers::DeleteAllSchedulesL(TheScheduler);
|
sl@0
|
707 |
|
sl@0
|
708 |
// Create transient schedule
|
sl@0
|
709 |
TheTest.Printf(_L("Create transient schedule with non-repeating task\n"));
|
sl@0
|
710 |
TSchedulerItemRef ref;
|
sl@0
|
711 |
CSchEntryInfoArray* entryList = new(ELeave) CSchEntryInfoArray(1);
|
sl@0
|
712 |
CleanupStack::PushL(entryList);
|
sl@0
|
713 |
ref.iName = _L("A Transient Schedule");
|
sl@0
|
714 |
|
sl@0
|
715 |
// CREATE SCHEDULE ENTRY:
|
sl@0
|
716 |
// starttime 5 secs in the future, hometime based
|
sl@0
|
717 |
TTsTime startTime(SchSvrHelpers::TimeBasedOnOffset(5), EFalse);
|
sl@0
|
718 |
// constructor takes: starttime, interval type, interval, validity period
|
sl@0
|
719 |
TScheduleEntryInfo2 entry(startTime, EDaily, 1, 20);
|
sl@0
|
720 |
entryList->AppendL(entry);
|
sl@0
|
721 |
|
sl@0
|
722 |
// CREATE SCHEDULE TASK:
|
sl@0
|
723 |
TTaskInfo taskInfo;
|
sl@0
|
724 |
taskInfo.iName = _L("mail");
|
sl@0
|
725 |
taskInfo.iTaskId = 0;
|
sl@0
|
726 |
taskInfo.iRepeat = 1;
|
sl@0
|
727 |
taskInfo.iPriority = 2;
|
sl@0
|
728 |
HBufC* data = _L("This is the data for the task").AllocLC();
|
sl@0
|
729 |
|
sl@0
|
730 |
// Schedule the item
|
sl@0
|
731 |
TInt res = TheScheduler.ScheduleTask(taskInfo, *data, ref, *entryList);
|
sl@0
|
732 |
TEST2(res, KErrNone);
|
sl@0
|
733 |
|
sl@0
|
734 |
CleanupStack::PopAndDestroy(2, entryList); // data, entryList
|
sl@0
|
735 |
|
sl@0
|
736 |
// Should be one item
|
sl@0
|
737 |
TEST(CountScheduledItemsL(EAllSchedules, TheScheduler) == 1);
|
sl@0
|
738 |
|
sl@0
|
739 |
// Waiting for entry to complete
|
sl@0
|
740 |
TheTest.Next(_L("Waiting for task to complete"));
|
sl@0
|
741 |
TEST2(STaskSemaphore::WaitL(KDefaultTimeout), KErrNone);
|
sl@0
|
742 |
|
sl@0
|
743 |
CleanupHelpers::KillProcess(KMinimalTaskHandler);
|
sl@0
|
744 |
|
sl@0
|
745 |
// Should be no items as schedule deletes itself after task has completed
|
sl@0
|
746 |
TEST(CountScheduledItemsL(EAllSchedules, TheScheduler) == 0);
|
sl@0
|
747 |
|
sl@0
|
748 |
SchSvrHelpers::Pause(TheTest,1);
|
sl@0
|
749 |
}
|
sl@0
|
750 |
|
sl@0
|
751 |
|
sl@0
|
752 |
//***********************************************************************************
|
sl@0
|
753 |
|
sl@0
|
754 |
/**
|
sl@0
|
755 |
@file
|
sl@0
|
756 |
@SYMTestCaseID SYSLIB-SCHSVR-CT-0271
|
sl@0
|
757 |
@SYMTestCaseDesc Persistant schedule test with repeating task - UTC
|
sl@0
|
758 |
@SYMTestPriority High
|
sl@0
|
759 |
@SYMTestActions Persistent schedule, repeating task, non-repeating task, go off, check task's still there, go off again, check it's still there, delete task, delete schedule,
|
sl@0
|
760 |
@SYMTestExpectedResults The test must not fail.
|
sl@0
|
761 |
@SYMPREQ PREQ234
|
sl@0
|
762 |
*/
|
sl@0
|
763 |
static void Test7L()
|
sl@0
|
764 |
{
|
sl@0
|
765 |
TheTest.Next(_L(" @SYMTestCaseID:SYSLIB-SCHSVR-CT-0271 Test persistent scheduling, repeating and non-repeating task schedules"));
|
sl@0
|
766 |
SchSvrHelpers::DeleteAllSchedulesL(TheScheduler);
|
sl@0
|
767 |
|
sl@0
|
768 |
// Transient
|
sl@0
|
769 |
TSchedulerItemRef ref;
|
sl@0
|
770 |
|
sl@0
|
771 |
// We shouldn't have any outstanding schedules registered with the server
|
sl@0
|
772 |
TInt count = CountScheduledItemsL(EAllSchedules, TheScheduler);
|
sl@0
|
773 |
TEST(count == 0);
|
sl@0
|
774 |
|
sl@0
|
775 |
// This creates 3 schedule entries, each with a validity period of 20 minutes, and are
|
sl@0
|
776 |
// due to run in 10s, 20s, and over a year ago (a year in the past)
|
sl@0
|
777 |
TheTest.Printf(_L("Create Persistent schedule\n"));
|
sl@0
|
778 |
TInt res = CreateSchedule1L(ref, TheScheduler);
|
sl@0
|
779 |
TEST2(res, KErrNone);
|
sl@0
|
780 |
|
sl@0
|
781 |
// We should now have one registered schedule
|
sl@0
|
782 |
count = CountScheduledItemsL(EAllSchedules, TheScheduler);
|
sl@0
|
783 |
TEST(count == 1);
|
sl@0
|
784 |
|
sl@0
|
785 |
//
|
sl@0
|
786 |
TheTest.Printf(_L("\nSchedule two tasks: one repeating....\n"));
|
sl@0
|
787 |
//
|
sl@0
|
788 |
TInt task1 = 0;
|
sl@0
|
789 |
TName name1 = (_L("web subscription(rpts)"));
|
sl@0
|
790 |
// -1 indicates repeating schedule
|
sl@0
|
791 |
res = SchedulePersistentTaskL(name1, task1, ref.iHandle, -1, TheScheduler); // -1 indicates repeat until explicitly deleted
|
sl@0
|
792 |
TEST2(res, KErrNone);
|
sl@0
|
793 |
|
sl@0
|
794 |
// List those schedules that are pending
|
sl@0
|
795 |
count = CountScheduledItemsL(EPendingSchedules, TheScheduler);
|
sl@0
|
796 |
TEST(count == 1);
|
sl@0
|
797 |
|
sl@0
|
798 |
//
|
sl@0
|
799 |
TheTest.Printf(_L("\n... and one non-repeating\n"));
|
sl@0
|
800 |
//
|
sl@0
|
801 |
TInt task2 = 0;
|
sl@0
|
802 |
TName name2 = (_L("non-repeating"));
|
sl@0
|
803 |
res = SchedulePersistentTaskL(name2, task2, ref.iHandle, 1, TheScheduler); // only runs once
|
sl@0
|
804 |
TEST2(res, KErrNone);
|
sl@0
|
805 |
|
sl@0
|
806 |
TheTest.Printf(_L("Waiting for tasks to run\n"));
|
sl@0
|
807 |
// Wait for notification that schedule has executed.
|
sl@0
|
808 |
TEST2(STaskSemaphore::WaitL(KDefaultTimeout), KErrNone);
|
sl@0
|
809 |
|
sl@0
|
810 |
CleanupHelpers::KillProcess(KMinimalTaskHandler);
|
sl@0
|
811 |
|
sl@0
|
812 |
TheTest.Printf(_L("...and wait again for repeating one to execute again\n"));
|
sl@0
|
813 |
// Wait for notification that schedule has executed.
|
sl@0
|
814 |
TEST2(STaskSemaphore::WaitL(KDefaultTimeout), KErrNone);
|
sl@0
|
815 |
|
sl@0
|
816 |
CleanupHelpers::KillProcess
|
sl@0
|
817 |
(KMinimalTaskHandler);
|
sl@0
|
818 |
|
sl@0
|
819 |
TheTest.Printf(_L("Delete the repeating task, and the schedule \n"));
|
sl@0
|
820 |
res = TheScheduler.DeleteTask(task1);
|
sl@0
|
821 |
TEST2(res, KErrNone);
|
sl@0
|
822 |
res = TheScheduler.DeleteTask(task2);
|
sl@0
|
823 |
TEST2(res, KErrNotFound); //Should be not found since its only executed once.
|
sl@0
|
824 |
res = TheScheduler.DeleteSchedule(ref.iHandle);
|
sl@0
|
825 |
TEST2(res, KErrNone);
|
sl@0
|
826 |
|
sl@0
|
827 |
count = CountScheduledItemsL(EPendingSchedules, TheScheduler);
|
sl@0
|
828 |
TEST(count == 0);
|
sl@0
|
829 |
SchSvrHelpers::Pause(TheTest,1);
|
sl@0
|
830 |
}
|
sl@0
|
831 |
|
sl@0
|
832 |
|
sl@0
|
833 |
static CSchEntryInfoArray* CreateSchEntryInfoArrayLC(TInt aGranularity)
|
sl@0
|
834 |
{
|
sl@0
|
835 |
CSchEntryInfoArray* scheduleEntries = new (ELeave) CSchEntryInfoArray(aGranularity);
|
sl@0
|
836 |
CleanupStack::PushL(scheduleEntries);
|
sl@0
|
837 |
return scheduleEntries;
|
sl@0
|
838 |
}
|
sl@0
|
839 |
|
sl@0
|
840 |
static CArrayFixFlat<TTaskInfo>* CreateTaskInfoLC(TInt aGranularity)
|
sl@0
|
841 |
{
|
sl@0
|
842 |
CArrayFixFlat<TTaskInfo>* taskInfos = new (ELeave) CArrayFixFlat<TTaskInfo>(aGranularity);
|
sl@0
|
843 |
CleanupStack::PushL(taskInfos);
|
sl@0
|
844 |
return taskInfos;
|
sl@0
|
845 |
}
|
sl@0
|
846 |
|
sl@0
|
847 |
static CSchItemRefArray* CreateScheduleRefsLC(TInt aGranularity)
|
sl@0
|
848 |
{
|
sl@0
|
849 |
CSchItemRefArray* scheduleReferences = new (ELeave) CSchItemRefArray(aGranularity);
|
sl@0
|
850 |
CleanupStack::PushL(scheduleReferences);
|
sl@0
|
851 |
return scheduleReferences;
|
sl@0
|
852 |
}
|
sl@0
|
853 |
|
sl@0
|
854 |
static void CreateTransientScheduledTasksL(TInt aNumScheduleEntries,
|
sl@0
|
855 |
TInt aNumSchedules,
|
sl@0
|
856 |
CSchEntryInfoArray* aScheduleEntries,
|
sl@0
|
857 |
CArrayFixFlat<TTaskInfo>* aTaskInfos,
|
sl@0
|
858 |
CSchItemRefArray* aScheduleReferences)
|
sl@0
|
859 |
{
|
sl@0
|
860 |
const TTimeIntervalMicroSeconds timeToAdd = 10000000; //10 seconds
|
sl@0
|
861 |
const TTimeIntervalMicroSeconds timeLimit = 5000000; // 5 seconds
|
sl@0
|
862 |
_LIT(KTaskDataPrefix, "Task Data Entry: ");
|
sl@0
|
863 |
// Prepare keys required
|
sl@0
|
864 |
TKeyArrayFix KTaskInfoSortKey(_FOFF(TTaskInfo, iTaskId), ECmpTInt);
|
sl@0
|
865 |
|
sl@0
|
866 |
for(TInt i=0;i<aNumSchedules;i++)
|
sl@0
|
867 |
{
|
sl@0
|
868 |
// Remove any existing schedule entry info's
|
sl@0
|
869 |
aScheduleEntries->Reset();
|
sl@0
|
870 |
//
|
sl@0
|
871 |
// Populate the schedule entry array with a varying list of
|
sl@0
|
872 |
// start-times, intervals, etc for this particular task
|
sl@0
|
873 |
//
|
sl@0
|
874 |
for(TInt j=0; j<aNumScheduleEntries; ++j)
|
sl@0
|
875 |
{
|
sl@0
|
876 |
TScheduleEntryInfo2 scheduleEntry = SchSvrHelpers::RandomScheduleEntryInfoUtc(TheSeed);
|
sl@0
|
877 |
TTime now;
|
sl@0
|
878 |
now.HomeTime(); // sets now to home time
|
sl@0
|
879 |
TTime sTime = scheduleEntry.StartTime().GetUtcTime();
|
sl@0
|
880 |
//if scheduleEntry.StartTime() is set lower then 5 sec into the future, postpone StartTime 10 sec into the future
|
sl@0
|
881 |
if(sTime < now + timeLimit)
|
sl@0
|
882 |
{
|
sl@0
|
883 |
TTsTime newTime (now + timeToAdd, ETrue);
|
sl@0
|
884 |
scheduleEntry.SetStartTime(newTime);
|
sl@0
|
885 |
}
|
sl@0
|
886 |
aScheduleEntries->AppendL(scheduleEntry);
|
sl@0
|
887 |
}
|
sl@0
|
888 |
//
|
sl@0
|
889 |
// Create some dummy task data
|
sl@0
|
890 |
//
|
sl@0
|
891 |
HBufC* taskData = HBufC::NewLC(KTaskDataPrefix().Length()+4);
|
sl@0
|
892 |
taskData->Des().Copy(KTaskDataPrefix());
|
sl@0
|
893 |
taskData->Des().AppendNum(i);
|
sl@0
|
894 |
//
|
sl@0
|
895 |
// Munge the task name
|
sl@0
|
896 |
//
|
sl@0
|
897 |
TTaskInfo taskInfo;
|
sl@0
|
898 |
taskInfo.iName = *taskData;
|
sl@0
|
899 |
taskInfo.iRepeat = 1;
|
sl@0
|
900 |
taskInfo.iPriority = 1;
|
sl@0
|
901 |
// Schedule the transient task
|
sl@0
|
902 |
TSchedulerItemRef scheduleReference;
|
sl@0
|
903 |
TInt result = TheScheduler.ScheduleTask(taskInfo,
|
sl@0
|
904 |
*taskData,
|
sl@0
|
905 |
scheduleReference,
|
sl@0
|
906 |
*aScheduleEntries);
|
sl@0
|
907 |
TEST2(result, KErrNone);
|
sl@0
|
908 |
TheTest.Printf(_L("TaskId: %d => TaskName: %S\n"), taskInfo.iTaskId, &taskInfo.iName);
|
sl@0
|
909 |
CleanupStack::PopAndDestroy(taskData);
|
sl@0
|
910 |
//
|
sl@0
|
911 |
// Save the taskInfo so we can check it later - this inserts the taskinfo into
|
sl@0
|
912 |
// the array (preserves sorted order by TTaskInfo.iTaskId) but also has the
|
sl@0
|
913 |
// added bonus of preventing duplicate task ids...
|
sl@0
|
914 |
//
|
sl@0
|
915 |
aTaskInfos->InsertIsqL(taskInfo, KTaskInfoSortKey);
|
sl@0
|
916 |
// Disable all schedules once added, just to stop them going off
|
sl@0
|
917 |
// and therefore being deleted when we are trying to compare them
|
sl@0
|
918 |
result = TheScheduler.DisableSchedule(scheduleReference.iHandle);
|
sl@0
|
919 |
TEST2(result, KErrNone);
|
sl@0
|
920 |
// Save the sever generated schedule reference and taskId for checking later
|
sl@0
|
921 |
aScheduleReferences->AppendL(scheduleReference);
|
sl@0
|
922 |
}
|
sl@0
|
923 |
}
|
sl@0
|
924 |
|
sl@0
|
925 |
static void CheckScheduledRefs(TInt aNumSchedules)
|
sl@0
|
926 |
{
|
sl@0
|
927 |
CSchItemRefArray* refs = new (ELeave) CSchItemRefArray(3);
|
sl@0
|
928 |
CleanupStack::PushL(refs);
|
sl@0
|
929 |
TInt res = TheScheduler.GetScheduleRefsL(*refs, EAllSchedules);
|
sl@0
|
930 |
TEST2(res, KErrNone);
|
sl@0
|
931 |
TInt count = refs->Count();
|
sl@0
|
932 |
TEST(count == aNumSchedules);
|
sl@0
|
933 |
CleanupStack::PopAndDestroy(refs);
|
sl@0
|
934 |
}
|
sl@0
|
935 |
|
sl@0
|
936 |
static void TestScheduledTasksL(TInt aNumSchedules,
|
sl@0
|
937 |
CArrayFixFlat<TTaskInfo>* aTaskInfos)
|
sl@0
|
938 |
{
|
sl@0
|
939 |
for(TInt n=0; n<aNumSchedules; ++n)
|
sl@0
|
940 |
{
|
sl@0
|
941 |
const TTaskInfo& taskInfo = aTaskInfos->At(n);
|
sl@0
|
942 |
|
sl@0
|
943 |
// First retrieve the task size
|
sl@0
|
944 |
TInt taskSize;
|
sl@0
|
945 |
TInt result = TheScheduler.GetTaskDataSize(taskInfo.iTaskId, taskSize);
|
sl@0
|
946 |
TEST2(result, KErrNone);
|
sl@0
|
947 |
TEST(taskSize > 0);
|
sl@0
|
948 |
|
sl@0
|
949 |
// Next retrieve the task info associated with a particular task Id
|
sl@0
|
950 |
HBufC* taskData = HBufC::NewLC(taskSize);
|
sl@0
|
951 |
TPtr pTaskData = taskData->Des();
|
sl@0
|
952 |
|
sl@0
|
953 |
TTsTime scheduleNextDueTime;
|
sl@0
|
954 |
TTaskInfo taskFromServer;
|
sl@0
|
955 |
TSchedulerItemRef scheduleReference;
|
sl@0
|
956 |
|
sl@0
|
957 |
result = TheScheduler.GetTaskInfoL(taskInfo.iTaskId,
|
sl@0
|
958 |
taskFromServer,
|
sl@0
|
959 |
pTaskData,
|
sl@0
|
960 |
scheduleReference,
|
sl@0
|
961 |
scheduleNextDueTime);
|
sl@0
|
962 |
TEST2(result, KErrNone);
|
sl@0
|
963 |
TEST(taskData->Length() == taskSize);
|
sl@0
|
964 |
|
sl@0
|
965 |
// Now check that the task returned by the server matches that held locallly....
|
sl@0
|
966 |
TBool bbb = SchSvrHelpers::IsTaskInfoTheSame(taskFromServer, taskInfo);
|
sl@0
|
967 |
if(!bbb)
|
sl@0
|
968 |
{
|
sl@0
|
969 |
RDebug::Print(_L("TaskInfo1. repeat=%x, id=%d, name=%S, priority=%x\n"),
|
sl@0
|
970 |
taskFromServer.iRepeat, taskFromServer.iTaskId, &taskFromServer.iName, taskFromServer.iPriority);
|
sl@0
|
971 |
RDebug::Print(_L("TaskInfo2. repeat=%x, id=%d, name=%S, priority=%x\n"),
|
sl@0
|
972 |
taskInfo.iRepeat, taskInfo.iTaskId, &taskInfo.iName, taskInfo.iPriority);
|
sl@0
|
973 |
}
|
sl@0
|
974 |
TEST(bbb);
|
sl@0
|
975 |
|
sl@0
|
976 |
// Check taskData is the same (was originally held in the TTaskInfo.iName field)
|
sl@0
|
977 |
const TDesC& des1 = taskInfo.iName;
|
sl@0
|
978 |
TDes& des2 = pTaskData;
|
sl@0
|
979 |
TEST(des1 == des2);
|
sl@0
|
980 |
CleanupStack::PopAndDestroy(taskData);
|
sl@0
|
981 |
}
|
sl@0
|
982 |
}
|
sl@0
|
983 |
|
sl@0
|
984 |
//***********************************************************************************
|
sl@0
|
985 |
|
sl@0
|
986 |
/**
|
sl@0
|
987 |
@file
|
sl@0
|
988 |
@SYMTestCaseID SYSLIB-SCHSVR-CT-0272
|
sl@0
|
989 |
@SYMTestCaseDesc Large number of tasks test - UTC
|
sl@0
|
990 |
@SYMTestPriority High
|
sl@0
|
991 |
@SYMTestActions Create a large number of tasks, test retrieval of task data and task info
|
sl@0
|
992 |
@SYMTestExpectedResults The test must not fail.
|
sl@0
|
993 |
@SYMPREQ PREQ234
|
sl@0
|
994 |
*/
|
sl@0
|
995 |
static void Test8L()
|
sl@0
|
996 |
{
|
sl@0
|
997 |
// Test title
|
sl@0
|
998 |
TheTest.Next(_L(" @SYMTestCaseID:SYSLIB-SCHSVR-CT-0272 Create a large number of tasks, test retrieval of task data and task info"));
|
sl@0
|
999 |
|
sl@0
|
1000 |
SchSvrHelpers::DeleteAllSchedulesL(TheScheduler);
|
sl@0
|
1001 |
|
sl@0
|
1002 |
// Constants used in this function
|
sl@0
|
1003 |
const TInt KNumberOfSchedulesToCreate = 20;
|
sl@0
|
1004 |
const TInt KNumberOfScheduleEntriesToCreate = 5;
|
sl@0
|
1005 |
|
sl@0
|
1006 |
// Prepare arrays required for the tests below
|
sl@0
|
1007 |
CSchEntryInfoArray* scheduleEntries = ::CreateSchEntryInfoArrayLC(KNumberOfScheduleEntriesToCreate);
|
sl@0
|
1008 |
CArrayFixFlat<TTaskInfo>* taskInfos = ::CreateTaskInfoLC(KNumberOfSchedulesToCreate);
|
sl@0
|
1009 |
CSchItemRefArray* scheduleReferences = ::CreateScheduleRefsLC(KNumberOfSchedulesToCreate);
|
sl@0
|
1010 |
|
sl@0
|
1011 |
//
|
sl@0
|
1012 |
// Create a large number of transient scheduled tasks
|
sl@0
|
1013 |
// to test Id generation
|
sl@0
|
1014 |
//
|
sl@0
|
1015 |
::CreateTransientScheduledTasksL(KNumberOfScheduleEntriesToCreate,
|
sl@0
|
1016 |
KNumberOfSchedulesToCreate,
|
sl@0
|
1017 |
scheduleEntries,
|
sl@0
|
1018 |
taskInfos,
|
sl@0
|
1019 |
scheduleReferences);
|
sl@0
|
1020 |
|
sl@0
|
1021 |
|
sl@0
|
1022 |
::CheckScheduledRefs(KNumberOfSchedulesToCreate);
|
sl@0
|
1023 |
|
sl@0
|
1024 |
// Test tasks for a given taskid is the same
|
sl@0
|
1025 |
::TestScheduledTasksL(KNumberOfSchedulesToCreate, taskInfos);
|
sl@0
|
1026 |
|
sl@0
|
1027 |
// Test reference can be retrieved for a given handle.
|
sl@0
|
1028 |
CleanupStack::PopAndDestroy(scheduleReferences);
|
sl@0
|
1029 |
CleanupStack::PopAndDestroy(taskInfos);
|
sl@0
|
1030 |
CleanupStack::PopAndDestroy(scheduleEntries);
|
sl@0
|
1031 |
|
sl@0
|
1032 |
// now delete all schedules
|
sl@0
|
1033 |
SchSvrHelpers::DeleteAllSchedulesL(TheScheduler);
|
sl@0
|
1034 |
TInt ccc = CountScheduledItemsL(EAllSchedules, TheScheduler);
|
sl@0
|
1035 |
TEST(ccc == 0);
|
sl@0
|
1036 |
|
sl@0
|
1037 |
SchSvrHelpers::Pause(TheTest,1);
|
sl@0
|
1038 |
}
|
sl@0
|
1039 |
|
sl@0
|
1040 |
//***********************************************************************************
|
sl@0
|
1041 |
static TInt RunTestsL()
|
sl@0
|
1042 |
{
|
sl@0
|
1043 |
TheTest.Next(_L("Delete old files"));
|
sl@0
|
1044 |
SchSvrHelpers::DeleteScheduleFilesL();
|
sl@0
|
1045 |
|
sl@0
|
1046 |
TheTest.Next(_L("Create Task notification semaphore"));
|
sl@0
|
1047 |
//initialise task notification semaphore
|
sl@0
|
1048 |
STaskSemaphore sem;
|
sl@0
|
1049 |
sem.CreateL();
|
sl@0
|
1050 |
|
sl@0
|
1051 |
// Prepare random number seed
|
sl@0
|
1052 |
TheTest.Next(_L("Prepare random number"));
|
sl@0
|
1053 |
TTime now;
|
sl@0
|
1054 |
now.UniversalTime();
|
sl@0
|
1055 |
TheSeed = now.Int64();
|
sl@0
|
1056 |
|
sl@0
|
1057 |
// Connect to the server
|
sl@0
|
1058 |
TheTest.Next(_L("===== Connect to Scheduler ====="));
|
sl@0
|
1059 |
TInt res = TheScheduler.Connect();
|
sl@0
|
1060 |
TEST2(res, KErrNone);
|
sl@0
|
1061 |
|
sl@0
|
1062 |
// Register a client with the server
|
sl@0
|
1063 |
TheTest.Next(_L("===== Registering Client ====="));
|
sl@0
|
1064 |
res = SchSvrHelpers::RegisterClientL(TheScheduler);
|
sl@0
|
1065 |
TEST2(res, KErrNone);
|
sl@0
|
1066 |
|
sl@0
|
1067 |
TheTest.Next(_L("Start tests"));
|
sl@0
|
1068 |
Test1L();
|
sl@0
|
1069 |
Test2L();
|
sl@0
|
1070 |
Test3L();
|
sl@0
|
1071 |
Test4L();
|
sl@0
|
1072 |
Test5L();
|
sl@0
|
1073 |
Test6L();
|
sl@0
|
1074 |
Test7L();
|
sl@0
|
1075 |
Test8L();
|
sl@0
|
1076 |
|
sl@0
|
1077 |
TheTest.Next(_L("Tidying up"));
|
sl@0
|
1078 |
//Tidying up so next test will be clear.
|
sl@0
|
1079 |
TheTest.Next(_L("Delete all schedules"));
|
sl@0
|
1080 |
SchSvrHelpers::DeleteAllSchedulesL(TheScheduler);
|
sl@0
|
1081 |
SchSvrHelpers::Pause(TheTest, 2);
|
sl@0
|
1082 |
TheTest.Next(_L("Delete old files\n"));
|
sl@0
|
1083 |
SchSvrHelpers::DeleteScheduleFilesL();
|
sl@0
|
1084 |
|
sl@0
|
1085 |
TheScheduler.Close();
|
sl@0
|
1086 |
|
sl@0
|
1087 |
//close handle to semaphore
|
sl@0
|
1088 |
sem.Close();
|
sl@0
|
1089 |
|
sl@0
|
1090 |
return KErrNone;
|
sl@0
|
1091 |
}
|
sl@0
|
1092 |
|
sl@0
|
1093 |
//***********************************************************************************
|
sl@0
|
1094 |
GLDEF_C TInt E32Main()
|
sl@0
|
1095 |
//
|
sl@0
|
1096 |
// TheTest the scheduler
|
sl@0
|
1097 |
//
|
sl@0
|
1098 |
{
|
sl@0
|
1099 |
__UHEAP_MARK;
|
sl@0
|
1100 |
TheTest.Start(_L("TC_TSCH_SCHEDULING2 - UTC"));
|
sl@0
|
1101 |
TheTest.Title();
|
sl@0
|
1102 |
|
sl@0
|
1103 |
TheCleanup = CTrapCleanup::New();
|
sl@0
|
1104 |
//If the previous test fails, SCHSVR.exe may stay in memory.
|
sl@0
|
1105 |
TRAPD(error,CleanupHelpers::TestCleanupL());
|
sl@0
|
1106 |
TEST2(error, KErrNone);
|
sl@0
|
1107 |
|
sl@0
|
1108 |
TTime now;
|
sl@0
|
1109 |
now.HomeTime();
|
sl@0
|
1110 |
// Used to Set the system UTC time and UTC offset
|
sl@0
|
1111 |
// so that correct UTC Time values are returned while using time based APIs.
|
sl@0
|
1112 |
SchSvrHelpers::SetHomeTimeL(now);
|
sl@0
|
1113 |
|
sl@0
|
1114 |
TEST2(TheFsSession.Connect(), KErrNone);;
|
sl@0
|
1115 |
TRAP(error, RunTestsL());
|
sl@0
|
1116 |
TRAP(error,CleanupHelpers::TestCleanupL());
|
sl@0
|
1117 |
TEST2(error, KErrNone);
|
sl@0
|
1118 |
delete TheCleanup;
|
sl@0
|
1119 |
|
sl@0
|
1120 |
TheFsSession.Close();
|
sl@0
|
1121 |
TheTest.End();
|
sl@0
|
1122 |
TheTest.Close();
|
sl@0
|
1123 |
__UHEAP_MARKEND;
|
sl@0
|
1124 |
return(KErrNone);
|
sl@0
|
1125 |
}
|