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 "transient_mixedStep.h" sl@0: #include "Te_floating_scheduleSuiteDefs.h" sl@0: sl@0: STaskSemaphore sem6; sl@0: sl@0: Ctransient_mixedStep::~Ctransient_mixedStep() sl@0: /** sl@0: * Destructor sl@0: */ sl@0: { sl@0: } sl@0: sl@0: Ctransient_mixedStep::Ctransient_mixedStep() 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(Ktransient_mixedStep); sl@0: } sl@0: sl@0: TVerdict Ctransient_mixedStep::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: sem6.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: SetTestStepResult(EPass); sl@0: return TestStepResult(); sl@0: } sl@0: sl@0: /* sl@0: @file sl@0: @SYMTestCaseID SYSLIB-SCHSVR-CIT-0283 sl@0: @SYMTestCaseDesc Transient schedule - Hometime & UTC sl@0: @SYMTestPriority High sl@0: @SYMTestActions For time and condition based test schedule task and check it fires sl@0: @SYMTestExpectedResults The test must not fail. sl@0: @SYMPREQ PREQ234 sl@0: */ sl@0: TVerdict Ctransient_mixedStep::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, "Transient Mixed - Hometime"); sl@0: _LIT(KTaskData1, "This is some really exciting task data (number 1)"); sl@0: _LIT(KTestName2, "Transient Mixed - UTC"); sl@0: _LIT(KTaskData2, "This is some really exciting task data (number 2)"); sl@0: sl@0: // Tests with timezone set to Europe, Paris sl@0: RTz tz; sl@0: tz.Connect(); sl@0: CTzId* tzId = CTzId::NewL(2656); //set the timezone to Europe/Paris 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, 55, 0, 0))); // 9:55 am sl@0: sl@0: // Prepare schedules describing when we want the tasks to run (10:00 am & 10.01) sl@0: sl@0: // Creates a hometime based daily transient schedule sl@0: TSchedulerItemRef ref1; sl@0: // This is the time when we want the Hometime time-based schedule to fire sl@0: TDateTime datetime1(2000, EJanuary, 1, 11, 0, 0, 0); sl@0: TTsTime startTimeForSchedule1(datetime1, EFalse); // 11:00 am sl@0: sl@0: { sl@0: CScheduleEntryInfoArray* entryList = new (ELeave) CScheduleEntryInfoArray(1); sl@0: CleanupStack::PushL(entryList); sl@0: TScheduleEntryInfo2 entry1 (startTimeForSchedule1, 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 UTC based daily transient schedule sl@0: TSchedulerItemRef ref2; sl@0: // This is the time when we want the UTC time-based schedule to fire sl@0: TDateTime datetime2(2000, EJanuary, 1, 10, 0, 0, 0); sl@0: TTsTime startTimeForSchedule2(datetime2, ETrue); // 10:00 am sl@0: sl@0: { sl@0: CScheduleEntryInfoArray* entryList = new (ELeave) CScheduleEntryInfoArray(1); sl@0: CleanupStack::PushL(entryList); sl@0: TScheduleEntryInfo2 entry1 (startTimeForSchedule2, 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 = KTestName2; sl@0: taskInfo1.iPriority = 2; sl@0: taskInfo1.iRepeat = 0; sl@0: // Create some data associated with this task sl@0: HBufC* taskData2 = KTaskData2().AllocLC(); sl@0: User::LeaveIfError(TheScheduler.ScheduleTask(taskInfo1, *taskData2, ref2, *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(ref2.iHandle)); sl@0: sl@0: // Set the UTC time such that both schedules fire at the same time sl@0: SchSvrHelpers::SetUTCTimeL(TTime(TDateTime(2000, EJanuary, 1, 9, 59, 50, 0))); // 9:59.50 am sl@0: sl@0: User::LeaveIfError(TheScheduler.EnableSchedule(ref1.iHandle)); sl@0: User::LeaveIfError(TheScheduler.EnableSchedule(ref2.iHandle)); 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), startTimeForSchedule1)); 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.UniversalTime(); sl@0: TESTL(SchSvrHelpers::IsTimeTheSameNoSeconds(TTsTime(timeNow, ETrue), startTimeForSchedule2)); 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: sl@0: TVerdict Ctransient_mixedStep::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: sem6.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: }