Update contrib.
1 // Copyright (c) 1997-2009 Nokia Corporation and/or its subsidiary(-ies).
2 // All rights reserved.
3 // This component and the accompanying materials are made available
4 // under the terms of "Eclipse Public License v1.0"
5 // which accompanies this distribution, and is available
6 // at the URL "http://www.eclipse.org/legal/epl-v10.html".
8 // Initial Contributors:
9 // Nokia Corporation - initial contribution.
22 #include "TestUtils.h"
25 RTest TheTest(_L("TC_TSCH_SCHEDULING1"));
26 static RScheduler TheScheduler;
27 static RFs TheFsSession;
29 typedef CArrayFixFlat<TScheduleEntryInfo> CScheduleEntryInfoArray;
30 typedef CArrayFixFlat<TTaskInfo> CTaskInfoArray;
31 typedef CArrayFixFlat<TSchedulerItemRef> CSchItemRefArray;
33 _LIT(KMinimalTaskHandler, "MinimalTaskHandler");
35 _LIT(KTimeFormatString, "%-B%:0%J%:1%T%:2%S%.%*C4%:3%+B");
36 _LIT(KCurrentDateTimeChanged, "Date & Time changed to: [%S]\n");
38 const TInt KTimeToWait = 4*1000*1000;
41 //***********************************************************************************
43 // Sets time to before specified time by aTimeBeforeInSeconds
44 static void SetTimeBeforeL(RTest& aTest, TTime& aTime, TInt aTimeBeforeInSeconds)
46 TTimeIntervalSeconds secs(aTimeBeforeInSeconds);
47 TTime time = aTime-secs;
48 SchSvrHelpers::SetHomeTimeL(time);
50 time.FormatL(dateString, KTimeFormatString);
51 aTest.Printf(KCurrentDateTimeChanged, &dateString);
54 // gets the due time for this schedule
55 static TTime GetDueTimeL(TInt aScheduleId)
57 TTime nextTimeScheduleIsDue;
59 CScheduleEntryInfoArray* entries
60 = new (ELeave) CScheduleEntryInfoArray(3);
61 CleanupStack::PushL(entries);
62 CTaskInfoArray* tasks = new (ELeave) CTaskInfoArray(3);
63 CleanupStack::PushL(tasks);
65 TInt res = TheScheduler.GetScheduleL(aScheduleId, state, *entries, *tasks, nextTimeScheduleIsDue);
68 CleanupStack::PopAndDestroy(2); // entries, tasks
69 return state.iDueTime;
72 // Forces the task to be exectued aCount times.
73 static void ForceTaskExecutionForSpecifiedIdL(TInt aId, TInt aCount)
75 TheTest.Printf(_L("Executing %d times\n"), aCount);
77 for (TInt i=0; i<aCount; ++i)
79 TheTest.Printf(_L("Execution %d\n"), i+1);
80 time = GetDueTimeL(aId);
82 SetTimeBeforeL(TheTest, time, 5 /*seconds*/);
84 // Wait for notification that schedule has executed.
85 TEST2(STaskSemaphore::WaitL(KDefaultTimeout), KErrNone);
86 CleanupHelpers::KillProcess(KMinimalTaskHandler);
90 //creates a daily schedule with StartTime of aStartTime
91 static TInt CreateScheduleL(TSchedulerItemRef& aRef,
92 RScheduler& aScheduler,
93 const TTime& aStartTime)
95 CScheduleEntryInfoArray* entryList
96 = new (ELeave) CScheduleEntryInfoArray(1);
97 CleanupStack::PushL(entryList);
99 TScheduleEntryInfo entry1;
100 entry1.iStartTime = aStartTime;
101 entry1.iInterval = 1; // TTimeIntervalDays
102 entry1.iIntervalType = EDaily;
103 entry1.iValidityPeriod = 30; // minutes
104 entryList->AppendL(entry1);
105 TInt res = aScheduler.CreatePersistentSchedule(aRef, *entryList);
106 CleanupStack::PopAndDestroy(); // entryList
110 // counts the number of scheduled items based on the supplied filter.
111 static TInt CountScheduledItemsL(TScheduleFilter aFilter,
112 RScheduler& aScheduler)
113 // Extract schedule references from the schedule server based on a filter. If
115 CSchItemRefArray* refs = new (ELeave) CSchItemRefArray(3);
116 CleanupStack::PushL(refs);
118 TInt res = aScheduler.GetScheduleRefsL(*refs, aFilter);
119 TEST2(res, KErrNone);
121 TInt count = refs->Count();
122 CleanupStack::PopAndDestroy(); // refs
126 // Extract task references from the schedule server based on a ID
127 static void GetTaskInfoL(CTaskInfoArray& aTaskInfoArray,
130 aTaskInfoArray.Reset();
131 TTime nextTimeScheduleIsDue;
132 TScheduleState state;
133 CScheduleEntryInfoArray* entries
134 = new (ELeave) CScheduleEntryInfoArray(3);
135 CleanupStack::PushL(entries);
136 TInt res = TheScheduler.GetScheduleL(aScheduleId,
140 nextTimeScheduleIsDue);
141 TEST2(res, KErrNone);
142 CleanupStack::PopAndDestroy(entries);
148 // schedules a transient task
149 static TInt ScheduleTransientTaskL(TInt& aTaskId,
150 TSchedulerItemRef& aRef,
152 RScheduler& aScheduler)
154 CScheduleEntryInfoArray* entryList = new(ELeave) CScheduleEntryInfoArray(3);
155 CleanupStack::PushL(entryList);
157 aRef.iName = _L("transient one");
160 TScheduleEntryInfo entry1;
161 entry1.iStartTime = SchSvrHelpers::TimeBasedOnOffset(0, 1); // 1 min in the future
162 entry1.iInterval = 1;
163 entry1.iIntervalType = EDaily;
164 entry1.iValidityPeriod = 20;
165 entryList->AppendL(entry1);
167 TScheduleEntryInfo entry2;
168 entry2.iStartTime = SchSvrHelpers::TimeBasedOnOffset(0, 2); // 2 mins in the future
169 entry2.iInterval = 1;
170 entry2.iIntervalType = EDaily;
171 entry2.iValidityPeriod = 500;
172 entryList->AppendL(entry2);
174 TScheduleEntryInfo entry3;
175 entry3.iStartTime = SchSvrHelpers::TimeBasedOnOffset(0, 3); // 3 mins in the future
176 entry3.iInterval = 1;
177 entry3.iIntervalType = EDaily;
178 entry3.iValidityPeriod = 5;
179 entryList->AppendL(entry3);
183 taskInfo.iName = _L("mail");
184 taskInfo.iTaskId = aTaskId;
185 taskInfo.iRepeat = aRepeat;
186 taskInfo.iPriority = 2;
187 HBufC* data = _L("the data, some strange new name ").AllocLC();
190 TInt res = aScheduler.ScheduleTask(taskInfo, *data, aRef, *entryList);
191 CleanupStack::PopAndDestroy(2); // data, entryList
193 aTaskId = taskInfo.iTaskId;
198 * Add Persistent and long term schedules to SchedulessBackup.dat files. this function
199 * is part of the DEF108026 defect testing called by DEF108026()
200 * It is part of the manual test SYSLIB-SCHSVR-CT-4003
201 * should be commented and will run as manual test only.
205 static void DEF108026_AddPersistentSchedulesL( TBool aImmediate )
208 _LIT(KTaskData1, "This is some really exciting task data (number 1)");
209 _LIT(KTaskData2, "This is some really exciting task data (number 2)");
210 _LIT(KTestName, "Def108026_test");
212 TheTest.Next(_L("Def108026_test: Adding schedules"));
214 RDebug::Print(_L("DEF108026_AddPersistentSchedulesL"));
216 TheTest.Next(_L("Connect to Scheduler"));
217 TInt res = TheScheduler.Connect();
218 TEST2(res, KErrNone);
220 TheTest.Next(_L("Registering Client"));
221 TEST2(SchSvrHelpers::RegisterClientL(TheScheduler), KErrNone);
225 TTime startTimeForSchedule;
228 // This is the time when we want the schedule to fire
229 startTimeForSchedule = TTime( (TDateTime(2007, EJune, 20, 10, 00, 0, 0)) );
230 RDebug::Print( _L("Added immediate schedule"));
234 startTimeForSchedule = TTime( (TDateTime(2037, EJune, 20, 10, 00, 0, 0)) ); // These schedules are due in the future.
235 RDebug::Print( _L("Added long-term schedule"));
239 // Prepare a schedule describing when we want the tasks to run (10:00 am)
240 TSchedulerItemRef ref;
241 User::LeaveIfError(CreateScheduleL(ref, TheScheduler, startTimeForSchedule));
243 // Disable the schedule whilst we set it up
244 User::LeaveIfError(TheScheduler.DisableSchedule(ref.iHandle));
246 // Associate a task with the schedule
248 taskInfo1.iRepeat = 0;
249 taskInfo1.iName = KTestName;
250 taskInfo1.iPriority = 2;
252 // Create some data associated with this task
253 HBufC* taskData1 = KTaskData1().AllocLC();
254 User::LeaveIfError(TheScheduler.ScheduleTask(taskInfo1, *taskData1, ref.iHandle));
255 CleanupStack::PopAndDestroy(); // taskData1
257 // Associate a task (2) with the schedule
259 taskInfo2.iRepeat = 0;
260 taskInfo2.iName = KTestName;
261 taskInfo2.iPriority = 2;
263 // Create some data associated with this task
264 HBufC* taskData2 = KTaskData2().AllocLC();
265 User::LeaveIfError(TheScheduler.ScheduleTask(taskInfo2, *taskData2, ref.iHandle));
266 CleanupStack::PopAndDestroy(); // taskData2
268 // We should now have two tasks scheduled at exactly the same time...
269 User::LeaveIfError(TheScheduler.EnableSchedule(ref.iHandle));
271 CleanupHelpers::KillProcess(KMinimalTaskHandler);
275 ** end of DEF108026_AddPersistentSchedulesL() **/
279 @SYMTestCaseID SYSLIB-SCHSVR-CT-1031
280 @SYMTestCaseDesc Test code for defect "Sending SMS to multiple recipients
281 sends message to only one recipient" (EDNEMHE-4Q69BG)
282 @SYMTestPriority High
283 @SYMTestActions Schedule two tasks to run at same time
284 @SYMTestExpectedResults Test must not fail
289 _LIT(KTaskData1, "This is some really exciting task data (number 1)");
290 _LIT(KTaskData2, "This is some really exciting task data (number 2)");
291 _LIT(KTestName, "SmsTest");
293 TheTest.Next(_L(" @SYMTestCaseID:SYSLIB-SCHSVR-CT-1031 TheTest3: SMS:Sending to multiple recipients"));
295 TheTest.Next(_L("Connect to Scheduler"));
296 TInt res = TheScheduler.Connect();
297 TEST2(res, KErrNone);
299 TheTest.Next(_L("Registering Client"));
300 TEST2(SchSvrHelpers::RegisterClientL(TheScheduler), KErrNone);
302 // Set the time to a known value, since this makes testing much easier (and more
304 SchSvrHelpers::SetHomeTimeL(TTime(TDateTime(2000, EJanuary, 1, 9, 55, 0, 0))); // 9:55 am
306 // This is the time when we want the schedule to fire
307 TTime startTimeForSchedule(TDateTime(2000, EJanuary, 1, 10, 0, 0, 0)); // 10:00 am
309 // Prepare a schedule describing when we want the tasks to run (10:00 am)
310 TSchedulerItemRef ref;
311 User::LeaveIfError(CreateScheduleL(ref, TheScheduler, startTimeForSchedule));
313 // Disable the schedule whilst we set it up
314 User::LeaveIfError(TheScheduler.DisableSchedule(ref.iHandle));
316 // Associate a task with the schedule
318 taskInfo1.iRepeat = 0;
319 taskInfo1.iName = KTestName;
320 taskInfo1.iPriority = 2;
322 // Create some data associated with this task
323 HBufC* taskData1 = KTaskData1().AllocLC();
324 User::LeaveIfError(TheScheduler.ScheduleTask(taskInfo1, *taskData1, ref.iHandle));
325 CleanupStack::PopAndDestroy(); // taskData1
327 // Associate a task (2) with the schedule
329 taskInfo2.iRepeat = 0;
330 taskInfo2.iName = KTestName;
331 taskInfo2.iPriority = 2;
333 // Create some data associated with this task
334 HBufC* taskData2 = KTaskData2().AllocLC();
335 User::LeaveIfError(TheScheduler.ScheduleTask(taskInfo2, *taskData2, ref.iHandle));
336 CleanupStack::PopAndDestroy(); // taskData2
338 // We should now have two tasks scheduled at exactly the same time...
339 User::LeaveIfError(TheScheduler.EnableSchedule(ref.iHandle));
341 // Set the time to 5 minutes *AFTER* the schedule was due to run (10:05am). In this instance,
342 // based on the new fixed Schedule Server, the schedule should still execute since
343 // it falls within the validity period (30 mins), however, in the old scheme of things,
344 // the schedule would not be valid again until tomorrow (2/1/2000) at 10:00am and hence
345 // would not execute until then.
346 SchSvrHelpers::SetHomeTimeL(TTime(TDateTime(2000, EJanuary, 1, 10, 5, 0, 0))); // 10:05 am
348 // Now wait for something to happen...
349 TEST2(STaskSemaphore::WaitL(KDefaultTimeout), KErrNone);
350 CleanupHelpers::KillProcess(KMinimalTaskHandler);
354 @SYMTestCaseID SYSLIB-SCHSVR-CT-1032
355 @SYMTestCaseDesc Tests for creation of transient schedule with task repeating 5 times
356 @SYMTestPriority High
357 @SYMTestActions There should be no schedules as its a transient one and last schedule
358 should have deleted by itself.
359 @SYMTestExpectedResults Test must not fail
364 TheTest.Next(_L(" @SYMTestCaseID:SYSLIB-SCHSVR-CT-1032 Testing creation of transient schedule with task repeating 5 times "));
367 TSchedulerItemRef ref;
368 // schedule has 3 entries - +1min, +2min and +3min
369 TInt res = ScheduleTransientTaskL(tTask, ref, 5, TheScheduler);//5 repeats
370 TEST2(res, KErrNone);
372 TheTest.Printf(_L("Get Task count and repeat count\n"));
374 CTaskInfoArray* tasks = new (ELeave) CTaskInfoArray(3);
375 CleanupStack::PushL(tasks);
376 GetTaskInfoL(*tasks, ref.iHandle);
377 TEST(tasks->Count() == 1);
378 TTaskInfo info = tasks->At(0);
379 TEST(info.iRepeat == 5);
380 ForceTaskExecutionForSpecifiedIdL(ref.iHandle, 3);
381 GetTaskInfoL(*tasks, ref.iHandle);
382 TEST(tasks->Count() == 1);
384 TEST(info.iRepeat == 2); // still 2 repeats to go.
385 ForceTaskExecutionForSpecifiedIdL(ref.iHandle, 2);
387 CleanupStack::PopAndDestroy(tasks);
389 TInt scheduleCount = CountScheduledItemsL(EPendingSchedules, TheScheduler);
390 // There should be no schedules as its a transient one and last schedule
391 // should have deleted itself.
392 TEST(scheduleCount == 0);
393 SchSvrHelpers::Pause(TheTest);
397 @SYMTestCaseID SYSLIB-SCHSVR-CT-1341
398 @SYMTestCaseDesc Tests for defect number DEF055586L
399 @SYMTestPriority High
400 @SYMTestActions Check to ensure that last element in schedule entries
401 array not skipped by schedule checking functions
402 @SYMTestExpectedResults Test must not fail
405 static void DEF055586L()
407 TheTest.Next(_L(" @SYMTestCaseID:SYSLIB-SCHSVR-CT-1041 DEF055586 - Last element in array missed by loop"));
409 TheTest.Next(_L("Connect to Scheduler"));
410 TInt res = TheScheduler.Connect();
411 TEST2(res, KErrNone);
413 TheTest.Next(_L("Registering Client"));
414 TEST2(SchSvrHelpers::RegisterClientL(TheScheduler), KErrNone);
416 // Set the time to a known value, since this makes testing much easier (and more
418 SchSvrHelpers::SetHomeTimeL(TTime(TDateTime(2000, EJanuary, 1, 9, 55, 0, 0))); // 9:55 am
420 // This is the time when we want the schedule to fire
421 TTime startTimeForSchedule(TDateTime(2000, EJanuary, 1, 10, 0, 0, 0)); // 10:00 am
423 // Prepare a schedule describing when we want the tasks to run (10:00 am)
424 TSchedulerItemRef ref;
426 CScheduleEntryInfoArray* entryList = new (ELeave) CScheduleEntryInfoArray(1);
427 CleanupStack::PushL(entryList);
429 TScheduleEntryInfo entry1;
430 entry1.iStartTime = startTimeForSchedule;
431 entry1.iInterval = 0; // TTimeIntervalDays: set to 0 to induce an error
432 entry1.iIntervalType = EDaily;
433 entry1.iValidityPeriod = 30; // minutes
434 entryList->AppendL(entry1);
435 TInt err = TheScheduler.CreatePersistentSchedule(ref, *entryList);
437 TEST2(err, KErrArgument);
439 TheTest.Next(_L("DEF055586 - Now checking 0 entries in schedule"));
442 err = TheScheduler.CreatePersistentSchedule(ref, *entryList);
444 TEST2(err, KErrArgument);
446 CleanupStack::PopAndDestroy(); // entryList
450 @SYMTestCaseID SYSLIB-SCHSVR-CT-3159
451 @SYMTestCaseDesc Tests for defect number DEF094149
452 @SYMTestPriority Normal
453 @SYMTestActions Create one Schedule and two task in it, then delete one task
454 check whether Task Scheduler execute disabled Schedule
455 @SYMTestExpectedResults Test must not fail
460 // Create scheduling entries
461 TheTest.Next(_L(" @SYMTestCaseID:SYSLIB-SCHSVR-CT-3159 DEF094149: RF Task Scheduler execute deleted tasks (in stress conditions) "));
464 time += TTimeIntervalSeconds(2); // Scheduler will run task in 2 seconds
466 TScheduleEntryInfo entry;
467 entry.iIntervalType = EHourly;
468 entry.iStartTime = time;
470 entry.iValidityPeriod = 20;
472 CArrayFixFlat<TScheduleEntryInfo>* entries = new(ELeave) CArrayFixFlat<TScheduleEntryInfo>(10);
473 CleanupStack::PushL(entries);
475 entries->AppendL(entry);
476 TSchedulerItemRef ref;
477 // Create the schedule for the task... and disable it
478 TheScheduler.Connect();
479 TheScheduler.CreatePersistentSchedule(ref, *entries);
480 TheScheduler.DisableSchedule(ref.iHandle);
484 task.iRepeat = 1; // repeat once
485 task.iName = _L("Test Task For Defect Verification");
486 task.iPriority = 100;
489 TBuf<255>fileName = _L("Some task");
490 TheScheduler.Register( fileName, 1 );
491 HBufC* taskData = HBufC::NewLC(1);
494 TheScheduler.ScheduleTask(task, *taskData,ref.iHandle);
496 taskid1 = task.iTaskId;
499 TheScheduler.ScheduleTask(task, *taskData,ref.iHandle);
501 taskid2 = task.iTaskId;
503 TInt err = TheScheduler.DeleteTask(taskid1);
505 User::After(KTimeToWait);
506 err = TheScheduler.DeleteTask(taskid2);
508 //check whether Task Scheduler execute the second task after deleting first tasks
509 //If the Schedule executed then err == KErrNotFound
510 TEST2(err, KErrNone);
511 CleanupStack::PopAndDestroy(taskData);
512 CleanupStack::PopAndDestroy(entries);
517 @SYMTestCaseID SYSLIB-SCHSVR-CT-3358
518 @SYMTestCaseDesc Tests for defect number INC098909
519 @SYMTestPriority High
520 @SYMTestActions Mark heap of Scheduler then create a schedule & task wait for its
521 execution then check heap again for memory leaks
522 @SYMTestExpectedResults Test must not fail
523 @SYMDEF INC098909: Process !TaskScheluder leaks memory in mail polls.
525 static void INC098909()
527 const TInt KTimeToWait = 5*1000*1000;
528 //SchSvrHelpers::DeleteScheduleFilesL();
530 TheTest.Next(_L(" @SYMTestCaseID:SYSLIB-SCHSVR-CT-3358 INC098909: Process !TaskScheluder leaks memory in mail polls "));
531 TheTest.Next(_L("Connect to Scheduler"));
532 TEST2(TheScheduler.Connect(),KErrNone);
534 TheTest.Next(_L("Registering Client"));
535 TEST2(SchSvrHelpers::RegisterClientL(TheScheduler), KErrNone);
537 User::LeaveIfError(TheScheduler.__DbgMarkHeap());
540 CArrayFixFlat<TScheduleEntryInfo>* entryList = new(ELeave) CArrayFixFlat<TScheduleEntryInfo>(1);
541 CleanupStack::PushL(entryList);
542 TSchedulerItemRef ref;
546 time += TTimeIntervalSeconds(0); // Scheduler will run task in 5 sec
548 TScheduleEntryInfo entry1;
549 entry1.iIntervalType = EHourly;
550 entry1.iStartTime = time;
551 entry1.iInterval = 1;
552 entry1.iValidityPeriod = 20;
553 entryList->AppendL(entry1);
555 // Create the schedule for the task...
556 TEST2(TheScheduler.CreatePersistentSchedule(ref, *entryList),KErrNone);
560 task.iRepeat = 1; // repeat once
561 task.iName = _L("Test ");
562 task.iPriority = 100;
564 HBufC* taskData = HBufC::NewLC(1);
565 TEST2(TheScheduler.ScheduleTask(task, *taskData,ref.iHandle), KErrNone);
567 CleanupStack::PopAndDestroy(taskData);
568 CleanupStack::PopAndDestroy(entryList);
570 //Wait schedule to complete
571 User::After(KTimeToWait);
573 User::LeaveIfError(TheScheduler.__DbgMarkEnd(0));
575 SchSvrHelpers::DeleteAllSchedulesL(TheScheduler);
577 // really clean out the scheduler (get rid of all the files and process)
578 TheScheduler.Close();
579 SchSvrHelpers::DeleteScheduleFilesL();
580 CleanupHelpers::KillProcess(KMinimalTaskHandler);
581 // Now wait for something to happen...
582 TEST2(STaskSemaphore::WaitL(KDefaultTimeout), KErrNone);
588 @SYMTestCaseID SYSLIB-SCHSVR-CT-4003
589 @SYMTestCaseDesc Test for DEF108026:
590 The aim of this test is to create enough persistent schedules. This reproduce the defect, when
591 SysStart startup. task scheduler will see that these schedules are due. It will then add them
592 immediately to the timer during SSA phase. As this operation consumes a long time and CSchStartupStateMgr::RunL()
593 is blocking, the domain manager fails to be ackowleged about the state transition, therefore certain processes like
594 Esock workers does not complete. These schedules are due immediately (at the time we run this test), we need then to
595 set the time of the device at the time where the schedules are due. We set the home time of the device in CSchServer::ConstructL().
596 I add in comment the modified CSchServer::ConstructL().
597 ssch_svr.dll must be rebuilt.
598 I could reproduces this defect only on Uiq. I could not reproduce it on techview!
599 @SYMTestPriority Normal
600 @SYMTestActions Create persistent and long-term schedules.
601 @SYMTestExpectedResults Test must create a
602 @SYMDEF DEF108026:SCHSVR performs SSA-driven actions before acknowledging transition.
604 /*********************** constructL() modified.Needed to explain the manual test DEF108026() ********************************
607 void CSchServer::ConstructL()
609 #ifdef __SCHLOGGING__
610 iTheLog = CSheduleServerLog::NewL(_L("SchSvr"));
611 Dll::SetTls(iTheLog);
614 // Create server storage path
616 User::LeaveIfError(fs.Connect());
618 #ifdef __SECURE_DATA__
619 TInt err = fs.CreatePrivatePath(EDriveC);
621 _LIT(KDirPath, "C:\\System\\Schedules\\");
622 TInt err = fs.MkDirAll(KDirPath);
625 if(err != KErrNone && err != KErrAlreadyExists)
633 // The process that we need to add to set the time of the device.
634 // We need to set it to the same time that the schedules added are due.
635 TTime newTime ( (TDateTime(2007, EJune, 20, 10, 00, 00, 00)) ); // 10:00 am
638 _LIT(KSetHomeTime, "TSetHomeTime");
639 _LIT(KTimeFormat, "%F%Y%M%D:%H%T%S.%*C6");
643 TBuf<128> bufLocalTime;
645 newTime.FormatL(bufLocalTime, KTimeFormat);
647 User::LeaveIfError(p.Create(KSetHomeTime, bufLocalTime));
649 // Asynchronous logon: completes when process terminates with process exit code
653 User::WaitForRequest(stat);
654 TInt exitReason = p.ExitReason();
656 //return (exitReason);
662 iTaskScheduler = CTaskScheduler::NewL();
664 iSSAMgr = new(ELeave) CSchStartupStateMgr(KDmHierarchyIdStartup, KBaseServicesDomain3);
665 iSSAMgr->RegisterObserverL(iTaskScheduler);
666 iSSAMgr->InitialiseL();
671 ** end of the changes we need to do in ssch_svr.cpp **/
674 * This should be called by DoTheTestsL () . It is part of the manual test SYSLIB-SCHSVR-CT-4003
675 * should be commented and will run as manual test only.
678 static void DEF108026()
680 TheTest.Next(_L("DEF108026: Creating enough persistent and long-term schedules to make task scheduler slower while adding them to the timer"));
682 for ( TInt i = 0; i < 500; i++ )
684 DEF108026_AddPersistentSchedulesL( ETrue );
685 HBufC* debugTxt = HBufC::NewLC( 256 );
686 debugTxt->Des().Append( _L( "Added Test... " ) );
687 debugTxt->Des().AppendNum( i++ );
688 RDebug::Print( *debugTxt );
689 CleanupStack::PopAndDestroy( debugTxt );
693 for ( TInt i = 0; i < 1000; i++ )
695 DEF108026_AddPersistentSchedulesL( EFalse );
696 HBufC* debugTxt = HBufC::NewLC( 256 );
697 debugTxt->Des().Append( _L( "Added Test... " ) );
698 debugTxt->Des().AppendNum( i++ );
699 RDebug::Print( *debugTxt );
700 CleanupStack::PopAndDestroy( debugTxt );
704 ** end of DEF108026 () **/
706 GLDEF_C TInt DoTheTestsL()
710 SchSvrHelpers::DeleteScheduleFilesL();
715 TheTest.Next(_L("Start tests"));
718 //DEF108026(); //This is a manual test. This test runs only under certain condition,
719 //Read the condition required to run this test in the implementation of the DEF108026() comments.
721 INC098909(); // Should be commented while running def108026
722 DEF094149L(); // Should be commented while running def108026
723 Test1L(); //Should be commented while running def108026
724 Test2L(); //Should be commented while running def108026
725 DEF055586L(); //Should be commented while running def108026
729 //Tidying up so next test will be clear.
730 TheTest.Next(_L("Delete all schedules"));
731 SchSvrHelpers::DeleteAllSchedulesL(TheScheduler); // While running def108026() manual test, this should be commented. We
732 // want keep the persistent schedules.
733 SchSvrHelpers::Pause(TheTest, 2);
734 TheTest.Next(_L("Delete old files\n"));
735 SchSvrHelpers::DeleteScheduleFilesL(); // While running def108026() manual test, this should be commented. We
736 // want keep the persistent schedules.
737 TheScheduler.Close();
743 //***********************************************************************************
744 GLDEF_C TInt E32Main()
748 TheTest.Start(_L("TC_TSCH_SCHEDULING1"));
750 TInt error = KErrNone;
751 CTrapCleanup* cleanup = CTrapCleanup::New();
754 //If the previous test fails, SCHSVR.exe may stay in memory.
755 TRAP(error,CleanupHelpers::TestCleanupL());
756 TEST2(error, KErrNone);
758 TEST2(TheFsSession.Connect(), KErrNone);
759 TheTest.Next(_L("Do the tests"));
760 TRAP(error, DoTheTestsL());
761 TEST2(error,KErrNone); // While running DEF108026 this line should be commented. If not, error = -4 (no memory) and this leaves.
762 //The reason is that our generated schedules take a lot of space. But this is the aim of this manual test:
763 // The SchedulesBackup.dat must be bigger as possible to reproduce the defect
764 TheFsSession.Close();
765 TRAP(error,CleanupHelpers::TestCleanupL());
766 TEST2(error, KErrNone);