sl@0: // Copyright (c) 2005-2009 Nokia Corporation and/or its subsidiary(-ies). sl@0: // All rights reserved. sl@0: // This component and the accompanying materials are made available sl@0: // under the terms of "Eclipse Public License v1.0" sl@0: // which accompanies this distribution, and is available sl@0: // at the URL "http://www.eclipse.org/legal/epl-v10.html". sl@0: // sl@0: // Initial Contributors: sl@0: // Nokia Corporation - initial contribution. sl@0: // sl@0: // Contributors: sl@0: // sl@0: // Description: sl@0: // Example CTestStep derived implementation sl@0: // sl@0: // sl@0: sl@0: #include sl@0: #include sl@0: sl@0: #include "DEF061595_Step.h" sl@0: #include "Te_floating_scheduleSuiteDefs.h" sl@0: #include "Thelpers.h" sl@0: sl@0: STaskSemaphore sem10; sl@0: sl@0: CDEF061595_Step::~CDEF061595_Step() sl@0: /** sl@0: * Destructor sl@0: */ sl@0: { sl@0: } sl@0: sl@0: CDEF061595_Step::CDEF061595_Step() sl@0: /** sl@0: * Constructor sl@0: */ sl@0: { sl@0: // **MUST** call SetTestStepName in the constructor as the controlling sl@0: // framework uses the test step name immediately following construction to set sl@0: // up the step's unique logging ID. sl@0: SetTestStepName(KDEF061595_Step); sl@0: } sl@0: sl@0: TVerdict CDEF061595_Step::doTestStepPreambleL() sl@0: /** sl@0: * @return - TVerdict code sl@0: * Override of base class virtual sl@0: */ sl@0: { sl@0: SetTestStepResult(EFail); sl@0: CTe_floating_scheduleSuiteStepBase::doTestStepPreambleL(); sl@0: sl@0: // Delete old files. sl@0: SchSvrHelpers::DeleteScheduleFilesL(); sl@0: sl@0: sem10.CreateL(); sl@0: sl@0: TInt i = TheScheduler.Connect(); sl@0: TESTL (i==KErrNone); sl@0: sl@0: // Registering Client sl@0: i = SchSvrHelpers::RegisterClientL(TheScheduler); sl@0: TESTL (i==KErrNone); sl@0: sl@0: // create P&S variables for condition based tests sl@0: User::LeaveIfError(RProperty::Define(KTestUid, KTestKey8, 0)); sl@0: sl@0: SetTestStepResult(EPass); sl@0: return TestStepResult(); sl@0: } sl@0: sl@0: /* sl@0: @file sl@0: @SYMTestCaseID SYSLIB-SCHSVR-CIT-1368 sl@0: @SYMTestCaseDesc DEF061595 - Schedule timers incorrectly expire when system time is changed sl@0: @SYMTestPriority High sl@0: @SYMTestActions For time and condition based test schedule task and check it floats when scheduled in a timezone that's not GMT, check also that the schedule fires correctly when it is enabled before the time and offset is changed sl@0: @SYMTestExpectedResults The test must not fail. sl@0: @SYMDEF DEF061595 sl@0: */ sl@0: TVerdict CDEF061595_Step::doTestStepL() sl@0: /** sl@0: * @return - TVerdict code sl@0: * Override of base class pure virtual sl@0: * Our implementation only gets called if the base class doTestStepPreambleL() did sl@0: * not leave. That being the case, the current test result value will be EPass. sl@0: */ sl@0: { sl@0: SetTestStepResult(EFail); sl@0: sl@0: _LIT(KTestName1, "DEF061595 - Time-Based"); sl@0: _LIT(KTaskData1, "This is some really exciting task data (number 1)"); sl@0: _LIT(KTestName2, "DEF061595 - Condition-Based"); sl@0: _LIT(KTaskData2, "This is some really exciting task data (number 2)"); sl@0: sl@0: // Tests with timezone set to Europe, London sl@0: RTz tz; sl@0: tz.Connect(); sl@0: CTzId* tzId = CTzId::NewL(2592); //set the timezone to Europe/London sl@0: CleanupStack::PushL(tzId); sl@0: tz.SetTimeZoneL(*tzId); sl@0: sl@0: // Set the time to a known value, since this makes testing much easier (and more sl@0: // repeatable). sl@0: SchSvrHelpers::SetUTCTimeL(TTime(TDateTime(2000, EJanuary, 1, 9, 0, 0, 0))); // 9:00 am sl@0: sl@0: // Prepare schedules describing when we want the tasks to run (3:00 pm & 3:01 pm) sl@0: sl@0: // Creates a time based daily transient schedule sl@0: TSchedulerItemRef ref1; sl@0: // This is the time when we want the time-based schedule to fire sl@0: TDateTime datetime1(2000, EJanuary, 1, 15, 0, 0, 0); sl@0: TTsTime startTimeForSchedule(datetime1, EFalse); // 3:00 pm sl@0: sl@0: { sl@0: CScheduleEntryInfoArray* entryList = new (ELeave) CScheduleEntryInfoArray(1); sl@0: CleanupStack::PushL(entryList); sl@0: TScheduleEntryInfo2 entry1 (startTimeForSchedule, EDaily, 1, 30); sl@0: entryList->AppendL(entry1); sl@0: // Associate a task with the time-based schedule sl@0: TTaskInfo taskInfo1; sl@0: taskInfo1.iName = KTestName1; sl@0: taskInfo1.iPriority = 2; sl@0: taskInfo1.iRepeat = 0; sl@0: // Create some data associated with this task sl@0: HBufC* taskData1 = KTaskData1().AllocLC(); sl@0: User::LeaveIfError(TheScheduler.ScheduleTask(taskInfo1, *taskData1, ref1, *entryList)); sl@0: sl@0: CleanupStack::PopAndDestroy(2); // entryList, taskData1 sl@0: } sl@0: sl@0: // Disable the schedule whilst we set it up sl@0: User::LeaveIfError(TheScheduler.DisableSchedule(ref1.iHandle)); sl@0: sl@0: sl@0: // Creates a condition based transient schedule sl@0: TSchedulerItemRef ref2; sl@0: // This is the time when we want the condition-based schedule to fire sl@0: TDateTime datetime2(2000, EJanuary, 1, 15, 1, 0, 0); sl@0: TTsTime defaultRuntime(datetime2, EFalse); // 3:01 pm sl@0: sl@0: { sl@0: CSchConditionArray* conditionList = new (ELeave) CSchConditionArray(1); sl@0: CleanupStack::PushL(conditionList); sl@0: TTaskSchedulerCondition condition1; sl@0: condition1.iCategory = KTestUid; sl@0: condition1.iKey = KTestKey1; sl@0: condition1.iState = 10; sl@0: condition1.iType = TTaskSchedulerCondition::EEquals; sl@0: conditionList->AppendL(condition1); sl@0: // Associate a task with the condition-based schedule sl@0: TTaskInfo taskInfo2; sl@0: taskInfo2.iName = KTestName2; sl@0: taskInfo2.iPriority = 2; sl@0: taskInfo2.iRepeat = 0; sl@0: // Create some data associated with this task sl@0: HBufC* taskData2 = KTaskData2().AllocLC(); sl@0: User::LeaveIfError(TheScheduler.ScheduleTask(taskInfo2, *taskData2, ref2, *conditionList, defaultRuntime)); sl@0: sl@0: CleanupStack::PopAndDestroy(2); // taskData2, conditionList sl@0: } sl@0: sl@0: // Disable the schedule whilst we set it up sl@0: User::LeaveIfError(TheScheduler.DisableSchedule(ref2.iHandle)); sl@0: sl@0: // This step is identical to the hometime_floatStep except for the schedules sl@0: // being enabled BEFORE the time is changed in this case. As would be normal behaviour sl@0: sl@0: User::LeaveIfError(TheScheduler.EnableSchedule(ref1.iHandle)); sl@0: User::LeaveIfError(TheScheduler.EnableSchedule(ref2.iHandle)); sl@0: sl@0: // Set UTC offset to +1Hr by moving to Europe, Paris sl@0: tzId = CTzId::NewL(2656); //set the timezone to Europe/Paris sl@0: tz.SetTimeZoneL(*tzId); sl@0: SchSvrHelpers::SetUTCTimeL(TTime(TDateTime(2000, EJanuary, 1, 13, 59, 50, 0))); // 1:59.50 pm sl@0: sl@0: // Now wait for the time-based schedule to fire sl@0: TESTL(STaskSemaphore::WaitL(KDefaultTimeout) == KErrNone); sl@0: sl@0: TTime timeNow; sl@0: timeNow.HomeTime(); sl@0: TESTL(SchSvrHelpers::IsTimeTheSameNoSeconds(TTsTime(timeNow, EFalse), startTimeForSchedule)); sl@0: sl@0: // Now wait for the condition-based schedule to fire sl@0: TESTL(STaskSemaphore::WaitL(KDefaultTimeout) == KErrNone); sl@0: sl@0: timeNow.HomeTime(); sl@0: TESTL(SchSvrHelpers::IsTimeTheSameNoSeconds(TTsTime(timeNow, EFalse), defaultRuntime)); sl@0: sl@0: CleanupStack::PopAndDestroy(); // timezone ID sl@0: CleanupHelpers::KillProcess(KMinimalTaskHandler); sl@0: SetTestStepResult(EPass); sl@0: return TestStepResult(); sl@0: } sl@0: sl@0: sl@0: TVerdict CDEF061595_Step::doTestStepPostambleL() sl@0: /** sl@0: * @return - TVerdict code sl@0: * Override of base class virtual sl@0: */ sl@0: { sl@0: SetTestStepResult(EFail); sl@0: CTe_floating_scheduleSuiteStepBase::doTestStepPostambleL(); sl@0: sl@0: sem10.Close(); sl@0: sl@0: // Delete all schedules sl@0: SchSvrHelpers::DeleteAllSchedulesL(TheScheduler); sl@0: SchSvrHelpers::Pause(2); sl@0: sl@0: // Delete old files sl@0: SchSvrHelpers::DeleteScheduleFilesL(); sl@0: sl@0: TheScheduler.Close(); sl@0: sl@0: SetTestStepResult(EPass); sl@0: return TestStepResult(); sl@0: }