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 - Hometime"));
|
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 |
TScheduleEntryInfo2 entry1 (aStartTime, EDaily, 1, 30);
|
sl@0
|
97 |
entryList->AppendL(entry1);
|
sl@0
|
98 |
TInt res = aScheduler.CreatePersistentSchedule(aRef, *entryList);
|
sl@0
|
99 |
CleanupStack::PopAndDestroy(); // entryList
|
sl@0
|
100 |
return res;
|
sl@0
|
101 |
}
|
sl@0
|
102 |
|
sl@0
|
103 |
// counts the number of scheduled items based on the supplied filter.
|
sl@0
|
104 |
static TInt CountScheduledItemsL(TScheduleFilter aFilter,
|
sl@0
|
105 |
RScheduler& aScheduler)
|
sl@0
|
106 |
// Extract schedule references from the schedule server based on a filter. If
|
sl@0
|
107 |
{
|
sl@0
|
108 |
CSchItemRefArray* refs = new (ELeave) CSchItemRefArray(3);
|
sl@0
|
109 |
CleanupStack::PushL(refs);
|
sl@0
|
110 |
|
sl@0
|
111 |
TInt res = aScheduler.GetScheduleRefsL(*refs, aFilter);
|
sl@0
|
112 |
TEST2(res, KErrNone);
|
sl@0
|
113 |
|
sl@0
|
114 |
TInt count = refs->Count();
|
sl@0
|
115 |
CleanupStack::PopAndDestroy(); // refs
|
sl@0
|
116 |
return count;
|
sl@0
|
117 |
}
|
sl@0
|
118 |
|
sl@0
|
119 |
// Extract task references from the schedule server based on a ID
|
sl@0
|
120 |
static void GetTaskInfoL(CTaskInfoArray& aTaskInfoArray,
|
sl@0
|
121 |
TInt aScheduleId)
|
sl@0
|
122 |
{
|
sl@0
|
123 |
aTaskInfoArray.Reset();
|
sl@0
|
124 |
TTsTime nextTimeScheduleIsDue;
|
sl@0
|
125 |
TScheduleState2 state;
|
sl@0
|
126 |
CScheduleEntryInfoArray* entries
|
sl@0
|
127 |
= new (ELeave) CScheduleEntryInfoArray(3);
|
sl@0
|
128 |
CleanupStack::PushL(entries);
|
sl@0
|
129 |
TInt res = TheScheduler.GetScheduleL(aScheduleId,
|
sl@0
|
130 |
state,
|
sl@0
|
131 |
*entries,
|
sl@0
|
132 |
aTaskInfoArray,
|
sl@0
|
133 |
nextTimeScheduleIsDue);
|
sl@0
|
134 |
TEST2(res, KErrNone);
|
sl@0
|
135 |
CleanupStack::PopAndDestroy(entries);
|
sl@0
|
136 |
}
|
sl@0
|
137 |
|
sl@0
|
138 |
// schedules a transient task
|
sl@0
|
139 |
static TInt ScheduleTransientTaskL(TInt& aTaskId,
|
sl@0
|
140 |
TSchedulerItemRef& aRef,
|
sl@0
|
141 |
TInt aRepeat,
|
sl@0
|
142 |
RScheduler& aScheduler)
|
sl@0
|
143 |
{
|
sl@0
|
144 |
CScheduleEntryInfoArray* entryList = new(ELeave) CScheduleEntryInfoArray(3);
|
sl@0
|
145 |
CleanupStack::PushL(entryList);
|
sl@0
|
146 |
|
sl@0
|
147 |
aRef.iName = _L("transient one");
|
sl@0
|
148 |
|
sl@0
|
149 |
// SCHEDULES
|
sl@0
|
150 |
TTime ttime1(SchSvrHelpers::TimeBasedOnOffset(0, 1));
|
sl@0
|
151 |
TTsTime startTime1 (ttime1,EFalse); // 1 min in the future
|
sl@0
|
152 |
TScheduleEntryInfo2 entry1 (startTime1, EDaily, 1, 20);
|
sl@0
|
153 |
entryList->AppendL(entry1);
|
sl@0
|
154 |
TTime ttime2(SchSvrHelpers::TimeBasedOnOffset(0, 2));
|
sl@0
|
155 |
TTsTime startTime2 (ttime2,EFalse); // 2 min in the future
|
sl@0
|
156 |
TScheduleEntryInfo2 entry2 (startTime2, EDaily, 1, 500);
|
sl@0
|
157 |
entryList->AppendL(entry2);
|
sl@0
|
158 |
|
sl@0
|
159 |
TTime ttime3(SchSvrHelpers::TimeBasedOnOffset(0, 3));
|
sl@0
|
160 |
TTsTime startTime3 (ttime3,EFalse); // 3 min in the future
|
sl@0
|
161 |
TScheduleEntryInfo2 entry3 (startTime3, EDaily, 1, 5);
|
sl@0
|
162 |
entryList->AppendL(entry3);
|
sl@0
|
163 |
|
sl@0
|
164 |
// TASK
|
sl@0
|
165 |
TTaskInfo taskInfo;
|
sl@0
|
166 |
taskInfo.iName = _L("mail");
|
sl@0
|
167 |
taskInfo.iTaskId = aTaskId;
|
sl@0
|
168 |
taskInfo.iRepeat = aRepeat;
|
sl@0
|
169 |
taskInfo.iPriority = 2;
|
sl@0
|
170 |
HBufC* data = _L("the data, some strange new name ").AllocLC();
|
sl@0
|
171 |
|
sl@0
|
172 |
// Schedule the item
|
sl@0
|
173 |
TInt res = aScheduler.ScheduleTask(taskInfo, *data, aRef, *entryList);
|
sl@0
|
174 |
CleanupStack::PopAndDestroy(2); // data, entryList
|
sl@0
|
175 |
|
sl@0
|
176 |
aTaskId = taskInfo.iTaskId;
|
sl@0
|
177 |
return res;
|
sl@0
|
178 |
}
|
sl@0
|
179 |
|
sl@0
|
180 |
|
sl@0
|
181 |
//***********************************************************************************
|
sl@0
|
182 |
|
sl@0
|
183 |
/**
|
sl@0
|
184 |
@file
|
sl@0
|
185 |
@SYMTestCaseID SYSLIB-SCHSVR-CT-0251
|
sl@0
|
186 |
@SYMTestCaseDesc Replicated test for for defect (EDNEMHE-4Q69BG) - Hometime
|
sl@0
|
187 |
@SYMTestPriority High
|
sl@0
|
188 |
@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
|
189 |
@SYMTestExpectedResults The test must not fail.
|
sl@0
|
190 |
@SYMPREQ PREQ234
|
sl@0
|
191 |
*/
|
sl@0
|
192 |
static void Test1L()
|
sl@0
|
193 |
{
|
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-0251 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, EFalse); // 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-0252
|
sl@0
|
266 |
@SYMTestCaseDesc Replicated test for for defect (EDNEMHE-4Q69BG) - Hometime
|
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-0252 Testing creation of transient schedule with task repeating 5 times "));
|
sl@0
|
275 |
|
sl@0
|
276 |
TInt tTask = 0;
|
sl@0
|
277 |
TSchedulerItemRef ref;
|
sl@0
|
278 |
// schedule has 3 entries - +1min, +2min and +3min
|
sl@0
|
279 |
TInt res = ScheduleTransientTaskL(tTask, ref, 5, TheScheduler);//5 repeats
|
sl@0
|
280 |
TEST2(res, KErrNone);
|
sl@0
|
281 |
|
sl@0
|
282 |
TheTest.Printf(_L("Get Task count and repeat count\n"));
|
sl@0
|
283 |
|
sl@0
|
284 |
CTaskInfoArray* tasks = new (ELeave) CTaskInfoArray(3);
|
sl@0
|
285 |
CleanupStack::PushL(tasks);
|
sl@0
|
286 |
GetTaskInfoL(*tasks, ref.iHandle);
|
sl@0
|
287 |
TEST(tasks->Count() == 1);
|
sl@0
|
288 |
TTaskInfo info = tasks->At(0);
|
sl@0
|
289 |
TEST(info.iRepeat == 5);
|
sl@0
|
290 |
ForceTaskExecutionForSpecifiedIdL(ref.iHandle, 3);
|
sl@0
|
291 |
GetTaskInfoL(*tasks, ref.iHandle);
|
sl@0
|
292 |
TEST(tasks->Count() == 1);
|
sl@0
|
293 |
info = tasks->At(0);
|
sl@0
|
294 |
TEST(info.iRepeat == 2); // still 2 repeats to go.
|
sl@0
|
295 |
ForceTaskExecutionForSpecifiedIdL(ref.iHandle, 2);
|
sl@0
|
296 |
|
sl@0
|
297 |
CleanupStack::PopAndDestroy(tasks);
|
sl@0
|
298 |
|
sl@0
|
299 |
TInt scheduleCount = CountScheduledItemsL(EPendingSchedules, TheScheduler);
|
sl@0
|
300 |
// There should be no schedules as its a transient one and last schedule
|
sl@0
|
301 |
// should have deleted itself.
|
sl@0
|
302 |
TEST(scheduleCount == 0);
|
sl@0
|
303 |
SchSvrHelpers::Pause(TheTest);
|
sl@0
|
304 |
}
|
sl@0
|
305 |
|
sl@0
|
306 |
//**********************************************************************************
|
sl@0
|
307 |
|
sl@0
|
308 |
/**
|
sl@0
|
309 |
@file
|
sl@0
|
310 |
@SYMTestCaseID SYSLIB-SCHSVR-CT-0253
|
sl@0
|
311 |
@SYMTestCaseDesc Replicated test for for defect (DEF055586L) - Hometime
|
sl@0
|
312 |
@SYMTestPriority High
|
sl@0
|
313 |
@SYMTestActions Create a time-based schedule check that there are 0 entries in the scehule after it fires
|
sl@0
|
314 |
@SYMTestExpectedResults The test must not fail.
|
sl@0
|
315 |
@SYMPREQ PREQ234
|
sl@0
|
316 |
*/
|
sl@0
|
317 |
static void DEF055586L()
|
sl@0
|
318 |
{
|
sl@0
|
319 |
TheTest.Next(_L(" @SYMTestCaseID:SYSLIB-SCHSVR-CT-0253 DEF055586 - Last element in array missed by loop "));
|
sl@0
|
320 |
|
sl@0
|
321 |
TheTest.Next(_L("Connect to Scheduler"));
|
sl@0
|
322 |
TInt res = TheScheduler.Connect();
|
sl@0
|
323 |
TEST2(res, KErrNone);
|
sl@0
|
324 |
|
sl@0
|
325 |
TheTest.Next(_L("Registering Client"));
|
sl@0
|
326 |
TEST2(SchSvrHelpers::RegisterClientL(TheScheduler), KErrNone);
|
sl@0
|
327 |
|
sl@0
|
328 |
// Set the time to a known value, since this makes testing much easier (and more
|
sl@0
|
329 |
// repeatable).
|
sl@0
|
330 |
SchSvrHelpers::SetHomeTimeL(TTime(TDateTime(2000, EJanuary, 1, 9, 55, 0, 0))); // 9:55 am
|
sl@0
|
331 |
|
sl@0
|
332 |
// This is the time when we want the schedule to fire
|
sl@0
|
333 |
TDateTime datetime(2000, EJanuary, 1, 10, 0, 0, 0);
|
sl@0
|
334 |
TTsTime startTimeForSchedule(datetime, EFalse); // 10:00 am
|
sl@0
|
335 |
|
sl@0
|
336 |
// Prepare a schedule describing when we want the tasks to run (10:00 am)
|
sl@0
|
337 |
TSchedulerItemRef ref;
|
sl@0
|
338 |
|
sl@0
|
339 |
CScheduleEntryInfoArray* entryList = new (ELeave) CScheduleEntryInfoArray(1);
|
sl@0
|
340 |
CleanupStack::PushL(entryList);
|
sl@0
|
341 |
|
sl@0
|
342 |
TScheduleEntryInfo2 entry1 (startTimeForSchedule, EDaily, 0, 30);
|
sl@0
|
343 |
entryList->AppendL(entry1);
|
sl@0
|
344 |
TInt err = TheScheduler.CreatePersistentSchedule(ref, *entryList);
|
sl@0
|
345 |
|
sl@0
|
346 |
TEST2(err, KErrArgument);
|
sl@0
|
347 |
|
sl@0
|
348 |
TheTest.Next(_L("DEF055586 - Now checking 0 entries in schedule"));
|
sl@0
|
349 |
entryList->Reset();
|
sl@0
|
350 |
|
sl@0
|
351 |
err = TheScheduler.CreatePersistentSchedule(ref, *entryList);
|
sl@0
|
352 |
|
sl@0
|
353 |
TEST2(err, KErrArgument);
|
sl@0
|
354 |
|
sl@0
|
355 |
CleanupStack::PopAndDestroy(); // entryList
|
sl@0
|
356 |
}
|
sl@0
|
357 |
|
sl@0
|
358 |
/**
|
sl@0
|
359 |
@SYMTestCaseID SYSLIB-SCHSVR-CT-3361
|
sl@0
|
360 |
@SYMTestCaseDesc Replicated test for for defect (INC098909) - Hometime
|
sl@0
|
361 |
@SYMTestPriority High
|
sl@0
|
362 |
@SYMTestActions Mark heap of Scheduler then create a schedule & task wait for its
|
sl@0
|
363 |
execution then check heap again for memory leaks
|
sl@0
|
364 |
@SYMTestExpectedResults Test must not fail (i.e. No memory leaks)
|
sl@0
|
365 |
@SYMDEF INC098909: Process !TaskScheluder leaks memory in mail polls.
|
sl@0
|
366 |
*/
|
sl@0
|
367 |
static void INC098909()
|
sl@0
|
368 |
{
|
sl@0
|
369 |
const TInt KTimeToWait = 10*1000*1000;
|
sl@0
|
370 |
SchSvrHelpers::DeleteScheduleFilesL();
|
sl@0
|
371 |
TheTest.Next(_L(" @SYMTestCaseID:SYSLIB-SCHSVR-CT-3361 INC098909: Process !TaskScheluder leaks memory in mail polls "));
|
sl@0
|
372 |
TheTest.Next(_L("Connect to Scheduler"));
|
sl@0
|
373 |
TEST2(TheScheduler.Connect(),KErrNone);
|
sl@0
|
374 |
|
sl@0
|
375 |
TheTest.Next(_L("Registering Client"));
|
sl@0
|
376 |
TEST2(SchSvrHelpers::RegisterClientL(TheScheduler), KErrNone);
|
sl@0
|
377 |
|
sl@0
|
378 |
User::LeaveIfError(TheScheduler.__DbgMarkHeap());
|
sl@0
|
379 |
|
sl@0
|
380 |
//Create Schedule
|
sl@0
|
381 |
CArrayFixFlat<TScheduleEntryInfo2>* entryList = new(ELeave) CArrayFixFlat<TScheduleEntryInfo2>(1);
|
sl@0
|
382 |
CleanupStack::PushL(entryList);
|
sl@0
|
383 |
TSchedulerItemRef ref;
|
sl@0
|
384 |
|
sl@0
|
385 |
TTime ttime(SchSvrHelpers::TimeBasedOnOffset(0));
|
sl@0
|
386 |
TTsTime startTime1(ttime, EFalse);
|
sl@0
|
387 |
|
sl@0
|
388 |
TScheduleEntryInfo2 entry1 (startTime1, EDaily, 1, 20);
|
sl@0
|
389 |
entryList->AppendL(entry1);
|
sl@0
|
390 |
|
sl@0
|
391 |
// Create the schedule for the task...
|
sl@0
|
392 |
TEST2(TheScheduler.CreatePersistentSchedule(ref, *entryList),KErrNone);
|
sl@0
|
393 |
|
sl@0
|
394 |
//Create Task
|
sl@0
|
395 |
TTaskInfo task;
|
sl@0
|
396 |
task.iRepeat = 1; // repeat once
|
sl@0
|
397 |
task.iName = _L("Test ");
|
sl@0
|
398 |
task.iPriority = 100;
|
sl@0
|
399 |
|
sl@0
|
400 |
HBufC* taskData = HBufC::NewLC(1);
|
sl@0
|
401 |
TEST2(TheScheduler.ScheduleTask(task, *taskData,ref.iHandle), KErrNone);
|
sl@0
|
402 |
|
sl@0
|
403 |
CleanupStack::PopAndDestroy(taskData);
|
sl@0
|
404 |
CleanupStack::PopAndDestroy(entryList);
|
sl@0
|
405 |
|
sl@0
|
406 |
//Wait schedule to complete
|
sl@0
|
407 |
User::After(KTimeToWait);
|
sl@0
|
408 |
|
sl@0
|
409 |
User::LeaveIfError(TheScheduler.__DbgMarkEnd(0));
|
sl@0
|
410 |
|
sl@0
|
411 |
// really clean out the scheduler (get rid of all the files and process)
|
sl@0
|
412 |
SchSvrHelpers::DeleteScheduleFilesL();
|
sl@0
|
413 |
CleanupHelpers::KillProcess(KMinimalTaskHandler);
|
sl@0
|
414 |
// Now wait for something to happen...
|
sl@0
|
415 |
TEST2(STaskSemaphore::WaitL(KDefaultTimeout), KErrNone);
|
sl@0
|
416 |
}
|
sl@0
|
417 |
|
sl@0
|
418 |
|
sl@0
|
419 |
GLDEF_C TInt DoTheTestsL()
|
sl@0
|
420 |
{
|
sl@0
|
421 |
//Delete old files.
|
sl@0
|
422 |
SchSvrHelpers::DeleteScheduleFilesL();
|
sl@0
|
423 |
|
sl@0
|
424 |
STaskSemaphore sem;
|
sl@0
|
425 |
sem.CreateL();
|
sl@0
|
426 |
|
sl@0
|
427 |
TheTest.Next(_L("Start tests"));
|
sl@0
|
428 |
// Add tests here:-
|
sl@0
|
429 |
Test1L();
|
sl@0
|
430 |
Test2L();
|
sl@0
|
431 |
DEF055586L();
|
sl@0
|
432 |
INC098909();
|
sl@0
|
433 |
|
sl@0
|
434 |
sem.Close();
|
sl@0
|
435 |
|
sl@0
|
436 |
//Tidying up so next test will be clear.
|
sl@0
|
437 |
TheTest.Next(_L("Delete all schedules"));
|
sl@0
|
438 |
SchSvrHelpers::DeleteAllSchedulesL(TheScheduler);
|
sl@0
|
439 |
SchSvrHelpers::Pause(TheTest, 2);
|
sl@0
|
440 |
TheTest.Next(_L("Delete old files\n"));
|
sl@0
|
441 |
SchSvrHelpers::DeleteScheduleFilesL();
|
sl@0
|
442 |
|
sl@0
|
443 |
TheScheduler.Close();
|
sl@0
|
444 |
|
sl@0
|
445 |
return KErrNone;
|
sl@0
|
446 |
}
|
sl@0
|
447 |
|
sl@0
|
448 |
//***********************************************************************************
|
sl@0
|
449 |
GLDEF_C TInt E32Main()
|
sl@0
|
450 |
{
|
sl@0
|
451 |
__UHEAP_MARK;
|
sl@0
|
452 |
TheTest.Title();
|
sl@0
|
453 |
TheTest.Start(_L("TC_TSCH_SCHEDULING1 - Hometime"));
|
sl@0
|
454 |
|
sl@0
|
455 |
TInt error = KErrNone;
|
sl@0
|
456 |
CTrapCleanup* cleanup = CTrapCleanup::New();
|
sl@0
|
457 |
if (!cleanup)
|
sl@0
|
458 |
return KErrNoMemory;
|
sl@0
|
459 |
//If the previous test fails, SCHSVR.exe may stay in memory.
|
sl@0
|
460 |
TRAP(error,CleanupHelpers::TestCleanupL());
|
sl@0
|
461 |
TEST2(error, KErrNone);
|
sl@0
|
462 |
|
sl@0
|
463 |
TEST2(TheFsSession.Connect(), KErrNone);
|
sl@0
|
464 |
TheTest.Next(_L("Do the tests"));
|
sl@0
|
465 |
TRAP(error, DoTheTestsL());
|
sl@0
|
466 |
TEST2(error,KErrNone);
|
sl@0
|
467 |
TheFsSession.Close();
|
sl@0
|
468 |
TRAP(error,CleanupHelpers::TestCleanupL());
|
sl@0
|
469 |
TEST2(error, KErrNone);
|
sl@0
|
470 |
delete cleanup;
|
sl@0
|
471 |
|
sl@0
|
472 |
TheTest.End();
|
sl@0
|
473 |
TheTest.Close();
|
sl@0
|
474 |
__UHEAP_MARKEND;
|
sl@0
|
475 |
return KErrNone;
|
sl@0
|
476 |
}
|