sl@0
|
1 |
// Copyright (c) 2005-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 |
// Example CTestStep derived implementation
|
sl@0
|
15 |
//
|
sl@0
|
16 |
//
|
sl@0
|
17 |
#include <schinfo.h>
|
sl@0
|
18 |
#include <schinfointernal.h>
|
sl@0
|
19 |
|
sl@0
|
20 |
#include "transient_hometimeStep.h"
|
sl@0
|
21 |
#include "Te_floating_scheduleSuiteDefs.h"
|
sl@0
|
22 |
|
sl@0
|
23 |
STaskSemaphore sem4;
|
sl@0
|
24 |
|
sl@0
|
25 |
Ctransient_hometimeStep::~Ctransient_hometimeStep()
|
sl@0
|
26 |
/**
|
sl@0
|
27 |
* Destructor
|
sl@0
|
28 |
*/
|
sl@0
|
29 |
{
|
sl@0
|
30 |
}
|
sl@0
|
31 |
|
sl@0
|
32 |
Ctransient_hometimeStep::Ctransient_hometimeStep()
|
sl@0
|
33 |
/**
|
sl@0
|
34 |
* Constructor
|
sl@0
|
35 |
*/
|
sl@0
|
36 |
{
|
sl@0
|
37 |
// **MUST** call SetTestStepName in the constructor as the controlling
|
sl@0
|
38 |
// framework uses the test step name immediately following construction to set
|
sl@0
|
39 |
// up the step's unique logging ID.
|
sl@0
|
40 |
SetTestStepName(Ktransient_hometimeStep);
|
sl@0
|
41 |
}
|
sl@0
|
42 |
|
sl@0
|
43 |
TVerdict Ctransient_hometimeStep::doTestStepPreambleL()
|
sl@0
|
44 |
/**
|
sl@0
|
45 |
* @return - TVerdict code
|
sl@0
|
46 |
* Override of base class virtual
|
sl@0
|
47 |
*/
|
sl@0
|
48 |
{
|
sl@0
|
49 |
SetTestStepResult(EFail);
|
sl@0
|
50 |
CTe_floating_scheduleSuiteStepBase::doTestStepPreambleL();
|
sl@0
|
51 |
|
sl@0
|
52 |
// Delete old files.
|
sl@0
|
53 |
SchSvrHelpers::DeleteScheduleFilesL();
|
sl@0
|
54 |
|
sl@0
|
55 |
sem4.CreateL();
|
sl@0
|
56 |
|
sl@0
|
57 |
TInt i = TheScheduler.Connect();
|
sl@0
|
58 |
TESTL (i==KErrNone);
|
sl@0
|
59 |
|
sl@0
|
60 |
// Registering Client
|
sl@0
|
61 |
i = SchSvrHelpers::RegisterClientL(TheScheduler);
|
sl@0
|
62 |
TESTL (i==KErrNone);
|
sl@0
|
63 |
|
sl@0
|
64 |
// create P&S variables for condition based tests
|
sl@0
|
65 |
User::LeaveIfError(RProperty::Define(KTestUid, KTestKey4, 0));
|
sl@0
|
66 |
|
sl@0
|
67 |
SetTestStepResult(EPass);
|
sl@0
|
68 |
return TestStepResult();
|
sl@0
|
69 |
}
|
sl@0
|
70 |
|
sl@0
|
71 |
/*
|
sl@0
|
72 |
@file
|
sl@0
|
73 |
@SYMTestCaseID SYSLIB-SCHSVR-CIT-0281
|
sl@0
|
74 |
@SYMTestCaseDesc Transient schedule - Hometime
|
sl@0
|
75 |
@SYMTestPriority High
|
sl@0
|
76 |
@SYMTestActions For time and condition based test schedule task and check it fires
|
sl@0
|
77 |
@SYMTestExpectedResults The test must not fail.
|
sl@0
|
78 |
@SYMPREQ PREQ234
|
sl@0
|
79 |
*/
|
sl@0
|
80 |
TVerdict Ctransient_hometimeStep::doTestStepL()
|
sl@0
|
81 |
/**
|
sl@0
|
82 |
* @return - TVerdict code
|
sl@0
|
83 |
* Override of base class pure virtual
|
sl@0
|
84 |
* Our implementation only gets called if the base class doTestStepPreambleL() did
|
sl@0
|
85 |
* not leave. That being the case, the current test result value will be EPass.
|
sl@0
|
86 |
*/
|
sl@0
|
87 |
{
|
sl@0
|
88 |
SetTestStepResult(EFail);
|
sl@0
|
89 |
|
sl@0
|
90 |
_LIT(KTestName1, "Transient Hometime - Time-Based");
|
sl@0
|
91 |
_LIT(KTaskData1, "This is some really exciting task data (number 1)");
|
sl@0
|
92 |
_LIT(KTestName2, "Transient Hometime - Condition-Based");
|
sl@0
|
93 |
_LIT(KTaskData2, "This is some really exciting task data (number 2)");
|
sl@0
|
94 |
|
sl@0
|
95 |
// Tests with timezone set to Europe, London
|
sl@0
|
96 |
RTz tz;
|
sl@0
|
97 |
tz.Connect();
|
sl@0
|
98 |
CTzId* tzId = CTzId::NewL(2592); //set the timezone to Europe/London
|
sl@0
|
99 |
CleanupStack::PushL(tzId);
|
sl@0
|
100 |
tz.SetTimeZoneL(*tzId);
|
sl@0
|
101 |
|
sl@0
|
102 |
// Set the time to a known value, since this makes testing much easier (and more
|
sl@0
|
103 |
// repeatable).
|
sl@0
|
104 |
SchSvrHelpers::SetHomeTimeL(TTime(TDateTime(2000, EJanuary, 1, 9, 55, 0, 0))); // 9:55 am
|
sl@0
|
105 |
|
sl@0
|
106 |
// Prepare schedules describing when we want the tasks to run (10:00 am & 10.01)
|
sl@0
|
107 |
|
sl@0
|
108 |
// Creates a time based daily transient schedule
|
sl@0
|
109 |
TSchedulerItemRef ref1;
|
sl@0
|
110 |
// This is the time when we want the time-based schedule to fire
|
sl@0
|
111 |
TDateTime datetime1(2000, EJanuary, 1, 10, 0, 0, 0);
|
sl@0
|
112 |
TTsTime startTimeForSchedule(datetime1, EFalse); // 10:00 am
|
sl@0
|
113 |
|
sl@0
|
114 |
{
|
sl@0
|
115 |
CScheduleEntryInfoArray* entryList = new (ELeave) CScheduleEntryInfoArray(1);
|
sl@0
|
116 |
CleanupStack::PushL(entryList);
|
sl@0
|
117 |
TScheduleEntryInfo2 entry1 (startTimeForSchedule, EDaily, 1, 30);
|
sl@0
|
118 |
entryList->AppendL(entry1);
|
sl@0
|
119 |
// Associate a task with the time-based schedule
|
sl@0
|
120 |
TTaskInfo taskInfo1;
|
sl@0
|
121 |
taskInfo1.iName = KTestName1;
|
sl@0
|
122 |
taskInfo1.iPriority = 2;
|
sl@0
|
123 |
taskInfo1.iRepeat = 0;
|
sl@0
|
124 |
// Create some data associated with this task
|
sl@0
|
125 |
HBufC* taskData1 = KTaskData1().AllocLC();
|
sl@0
|
126 |
User::LeaveIfError(TheScheduler.ScheduleTask(taskInfo1, *taskData1, ref1, *entryList));
|
sl@0
|
127 |
|
sl@0
|
128 |
CleanupStack::PopAndDestroy(2); // entryList, taskData1
|
sl@0
|
129 |
}
|
sl@0
|
130 |
|
sl@0
|
131 |
// Disable the schedule whilst we set it up
|
sl@0
|
132 |
User::LeaveIfError(TheScheduler.DisableSchedule(ref1.iHandle));
|
sl@0
|
133 |
|
sl@0
|
134 |
|
sl@0
|
135 |
// Creates a condition based transient schedule
|
sl@0
|
136 |
TSchedulerItemRef ref2;
|
sl@0
|
137 |
// This is the time when we want the condition-based schedule to fire
|
sl@0
|
138 |
TDateTime datetime2(2000, EJanuary, 1, 10, 1, 0, 0);
|
sl@0
|
139 |
TTsTime defaultRuntime(datetime2, EFalse); // 10:01 am
|
sl@0
|
140 |
|
sl@0
|
141 |
{
|
sl@0
|
142 |
CSchConditionArray* conditionList = new (ELeave) CSchConditionArray(1);
|
sl@0
|
143 |
CleanupStack::PushL(conditionList);
|
sl@0
|
144 |
TTaskSchedulerCondition condition1;
|
sl@0
|
145 |
condition1.iCategory = KTestUid;
|
sl@0
|
146 |
condition1.iKey = KTestKey1;
|
sl@0
|
147 |
condition1.iState = 10;
|
sl@0
|
148 |
condition1.iType = TTaskSchedulerCondition::EEquals;
|
sl@0
|
149 |
conditionList->AppendL(condition1);
|
sl@0
|
150 |
// Associate a task with the condition-based schedule
|
sl@0
|
151 |
TTaskInfo taskInfo2;
|
sl@0
|
152 |
taskInfo2.iName = KTestName2;
|
sl@0
|
153 |
taskInfo2.iPriority = 2;
|
sl@0
|
154 |
taskInfo2.iRepeat = 0;
|
sl@0
|
155 |
// Create some data associated with this task
|
sl@0
|
156 |
HBufC* taskData2 = KTaskData2().AllocLC();
|
sl@0
|
157 |
User::LeaveIfError(TheScheduler.ScheduleTask(taskInfo2, *taskData2, ref2, *conditionList, defaultRuntime));
|
sl@0
|
158 |
|
sl@0
|
159 |
CleanupStack::PopAndDestroy(2); // taskData2, conditionList
|
sl@0
|
160 |
}
|
sl@0
|
161 |
|
sl@0
|
162 |
// Disable the schedule whilst we set it up
|
sl@0
|
163 |
User::LeaveIfError(TheScheduler.DisableSchedule(ref2.iHandle));
|
sl@0
|
164 |
|
sl@0
|
165 |
SchSvrHelpers::SetHomeTimeL(TTime(TDateTime(2000, EJanuary, 1, 9, 59, 50, 0))); // 9:59.50 am
|
sl@0
|
166 |
|
sl@0
|
167 |
User::LeaveIfError(TheScheduler.EnableSchedule(ref1.iHandle));
|
sl@0
|
168 |
User::LeaveIfError(TheScheduler.EnableSchedule(ref2.iHandle));
|
sl@0
|
169 |
|
sl@0
|
170 |
// Now wait for the time-based schedule to fire
|
sl@0
|
171 |
TESTL(STaskSemaphore::WaitL(KDefaultTimeout) == KErrNone);
|
sl@0
|
172 |
|
sl@0
|
173 |
TTime timeNow;
|
sl@0
|
174 |
timeNow.HomeTime();
|
sl@0
|
175 |
TESTL(SchSvrHelpers::IsTimeTheSameNoSeconds(TTsTime(timeNow, EFalse), startTimeForSchedule));
|
sl@0
|
176 |
|
sl@0
|
177 |
// Now wait for the condition-based schedule to fire
|
sl@0
|
178 |
TESTL(STaskSemaphore::WaitL(KDefaultTimeout) == KErrNone);
|
sl@0
|
179 |
|
sl@0
|
180 |
timeNow.HomeTime();
|
sl@0
|
181 |
TESTL(SchSvrHelpers::IsTimeTheSameNoSeconds(TTsTime(timeNow, EFalse), defaultRuntime));
|
sl@0
|
182 |
|
sl@0
|
183 |
CleanupStack::PopAndDestroy(); // timezone ID
|
sl@0
|
184 |
CleanupHelpers::KillProcess(KMinimalTaskHandler);
|
sl@0
|
185 |
SetTestStepResult(EPass);
|
sl@0
|
186 |
return TestStepResult();
|
sl@0
|
187 |
}
|
sl@0
|
188 |
|
sl@0
|
189 |
|
sl@0
|
190 |
|
sl@0
|
191 |
TVerdict Ctransient_hometimeStep::doTestStepPostambleL()
|
sl@0
|
192 |
/**
|
sl@0
|
193 |
* @return - TVerdict code
|
sl@0
|
194 |
* Override of base class virtual
|
sl@0
|
195 |
*/
|
sl@0
|
196 |
{
|
sl@0
|
197 |
SetTestStepResult(EFail);
|
sl@0
|
198 |
CTe_floating_scheduleSuiteStepBase::doTestStepPostambleL();
|
sl@0
|
199 |
|
sl@0
|
200 |
sem4.Close();
|
sl@0
|
201 |
|
sl@0
|
202 |
// Delete all schedules
|
sl@0
|
203 |
SchSvrHelpers::DeleteAllSchedulesL(TheScheduler);
|
sl@0
|
204 |
SchSvrHelpers::Pause(2);
|
sl@0
|
205 |
|
sl@0
|
206 |
// Delete old files
|
sl@0
|
207 |
SchSvrHelpers::DeleteScheduleFilesL();
|
sl@0
|
208 |
|
sl@0
|
209 |
TheScheduler.Close();
|
sl@0
|
210 |
|
sl@0
|
211 |
SetTestStepResult(EPass);
|
sl@0
|
212 |
return TestStepResult();
|
sl@0
|
213 |
}
|