sl@0
|
1 |
// Copyright (c) 2004-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 |
// This file contains the implementation of test classe for TScheduleState2.
|
sl@0
|
15 |
//
|
sl@0
|
16 |
//
|
sl@0
|
17 |
|
sl@0
|
18 |
#include <e32test.h>
|
sl@0
|
19 |
#include <f32file.h>
|
sl@0
|
20 |
|
sl@0
|
21 |
#include "SCHINFO.H"
|
sl@0
|
22 |
#include <schinfointernal.h>
|
sl@0
|
23 |
|
sl@0
|
24 |
_LIT(KTestName, "TScheduleState2 Tests");
|
sl@0
|
25 |
RTest TheTest(KTestName);
|
sl@0
|
26 |
|
sl@0
|
27 |
//
|
sl@0
|
28 |
//
|
sl@0
|
29 |
//Test macroses and functions
|
sl@0
|
30 |
|
sl@0
|
31 |
static void Check(TInt aValue, TInt aLine)
|
sl@0
|
32 |
{
|
sl@0
|
33 |
if(!aValue)
|
sl@0
|
34 |
{
|
sl@0
|
35 |
TheTest(EFalse, aLine);
|
sl@0
|
36 |
}
|
sl@0
|
37 |
}
|
sl@0
|
38 |
static void Check(TInt aValue, TInt aExpected, TInt aLine)
|
sl@0
|
39 |
{
|
sl@0
|
40 |
if(aValue != aExpected)
|
sl@0
|
41 |
{
|
sl@0
|
42 |
RDebug::Print(_L("*** Expected error: %d, got: %d\r\n"), aExpected, aValue);
|
sl@0
|
43 |
TheTest(EFalse, aLine);
|
sl@0
|
44 |
}
|
sl@0
|
45 |
}
|
sl@0
|
46 |
#define TEST(arg) ::Check((arg), __LINE__)
|
sl@0
|
47 |
#define TEST2(aValue, aExpected) ::Check(aValue, aExpected, __LINE__)
|
sl@0
|
48 |
|
sl@0
|
49 |
|
sl@0
|
50 |
|
sl@0
|
51 |
/**
|
sl@0
|
52 |
State accessor for the TScheduleState2 object under test.
|
sl@0
|
53 |
*/
|
sl@0
|
54 |
class TScheduleState2_StateAccessor
|
sl@0
|
55 |
{
|
sl@0
|
56 |
public :
|
sl@0
|
57 |
void TestDefaultConstructor();
|
sl@0
|
58 |
void TestCopyConstructorOverloadedConstructor();
|
sl@0
|
59 |
void TestNameSetName();
|
sl@0
|
60 |
void TestDueTimeSetDueTime();
|
sl@0
|
61 |
void TestPersistsSetPersists();
|
sl@0
|
62 |
void TestEnabledSetEnabled();
|
sl@0
|
63 |
void TestOperatorEqual();
|
sl@0
|
64 |
};
|
sl@0
|
65 |
|
sl@0
|
66 |
|
sl@0
|
67 |
|
sl@0
|
68 |
|
sl@0
|
69 |
/**
|
sl@0
|
70 |
@file
|
sl@0
|
71 |
@SYMTestCaseID SYSLIB-SCHSVR-CT-0224
|
sl@0
|
72 |
@SYMTestCaseDesc Check the default constructor works properly
|
sl@0
|
73 |
@SYMTestPriority low
|
sl@0
|
74 |
@SYMTestActions Creates an instance of TScheduleState2 and check its data has been
|
sl@0
|
75 |
set to default values.
|
sl@0
|
76 |
@SYMTestExpectedResults The test must not fail.
|
sl@0
|
77 |
@SYMPREQ PREQ234
|
sl@0
|
78 |
*/
|
sl@0
|
79 |
void TScheduleState2_StateAccessor::TestDefaultConstructor()
|
sl@0
|
80 |
{
|
sl@0
|
81 |
TheTest.Next(_L(" @SYMTestCaseID:SYSLIB-SCHSVR-CT-0224 "));
|
sl@0
|
82 |
TScheduleState2 state;
|
sl@0
|
83 |
|
sl@0
|
84 |
//name should be ""
|
sl@0
|
85 |
TEST(state.iName == _L(""));
|
sl@0
|
86 |
|
sl@0
|
87 |
//iDueTime UTC, O
|
sl@0
|
88 |
TEST(state.iDueTime.GetUtcTime() == TTime(0));
|
sl@0
|
89 |
|
sl@0
|
90 |
//iFlags should be 0
|
sl@0
|
91 |
TEST(state.iFlags == 0);
|
sl@0
|
92 |
|
sl@0
|
93 |
//iReserved 0
|
sl@0
|
94 |
TEST(state.iReserved == 0);
|
sl@0
|
95 |
}
|
sl@0
|
96 |
|
sl@0
|
97 |
|
sl@0
|
98 |
|
sl@0
|
99 |
/**
|
sl@0
|
100 |
@file
|
sl@0
|
101 |
@SYMTestCaseID SYSLIB-SCHSVR-CT-0225
|
sl@0
|
102 |
@SYMTestCaseDesc Checks the copy constructor and the overloaded constructor
|
sl@0
|
103 |
@SYMTestPriority low
|
sl@0
|
104 |
@SYMTestActions Creates an instance of TScheduleState2 using the overloaded constructor
|
sl@0
|
105 |
and another instance of TScheduleState2 using the copy constructor, then compares
|
sl@0
|
106 |
their data and makes sure they are equal.
|
sl@0
|
107 |
@SYMTestExpectedResults The test must not fail.
|
sl@0
|
108 |
@SYMPREQ PREQ234
|
sl@0
|
109 |
*/
|
sl@0
|
110 |
void TScheduleState2_StateAccessor::TestCopyConstructorOverloadedConstructor()
|
sl@0
|
111 |
{
|
sl@0
|
112 |
TheTest.Next(_L(" @SYMTestCaseID:SYSLIB-SCHSVR-CT-0225 Test constructors "));
|
sl@0
|
113 |
const TName name(_L("test_state"));
|
sl@0
|
114 |
TDateTime date(2005, EMay, 15, 8, 55, 0, 0);
|
sl@0
|
115 |
TTime time(date);
|
sl@0
|
116 |
TTsTime dueTime(time, EFalse); //TTsTime is Home time
|
sl@0
|
117 |
|
sl@0
|
118 |
TScheduleState2 state1(name, dueTime, ETrue, ETrue);
|
sl@0
|
119 |
TScheduleState2 state2(state1);
|
sl@0
|
120 |
|
sl@0
|
121 |
TEST(state1.iName == state2.iName);
|
sl@0
|
122 |
TEST(state1.iDueTime.GetLocalTime() == state2.iDueTime.GetLocalTime());
|
sl@0
|
123 |
TEST(state1.iFlags == state2.iFlags);
|
sl@0
|
124 |
TEST(state1.iReserved == state2.iReserved);
|
sl@0
|
125 |
|
sl@0
|
126 |
}
|
sl@0
|
127 |
|
sl@0
|
128 |
|
sl@0
|
129 |
|
sl@0
|
130 |
/**
|
sl@0
|
131 |
@file
|
sl@0
|
132 |
@SYMTestCaseID SYSLIB-SCHSVR-CT-0226
|
sl@0
|
133 |
@SYMTestCaseDesc Checks SetName() and Name() functions of TScheduleState2
|
sl@0
|
134 |
@SYMTestPriority low
|
sl@0
|
135 |
@SYMTestActions Creates an instance of TScheduleState2, calls SetName() and Name()
|
sl@0
|
136 |
and Name() returns the same value as the one set initially.
|
sl@0
|
137 |
@SYMTestExpectedResults The test must not fail.
|
sl@0
|
138 |
@SYMPREQ PREQ234
|
sl@0
|
139 |
*/
|
sl@0
|
140 |
void TScheduleState2_StateAccessor::TestNameSetName()
|
sl@0
|
141 |
{
|
sl@0
|
142 |
TheTest.Next(_L(" @SYMTestCaseID:SYSLIB-SCHSVR-CT-0226 "));
|
sl@0
|
143 |
TScheduleState2 state;
|
sl@0
|
144 |
const TName name(_L("name"));
|
sl@0
|
145 |
state.SetName(name);
|
sl@0
|
146 |
|
sl@0
|
147 |
TEST(state.Name() == name);
|
sl@0
|
148 |
|
sl@0
|
149 |
}
|
sl@0
|
150 |
|
sl@0
|
151 |
/**
|
sl@0
|
152 |
@file
|
sl@0
|
153 |
@SYMTestCaseID SYSLIB-SCHSVR-CT-0227
|
sl@0
|
154 |
@SYMTestCaseDesc Checks SetDueTime() and DueTime()
|
sl@0
|
155 |
@SYMTestPriority low
|
sl@0
|
156 |
@SYMTestActions Creates an instance of TScheduleState2, sets its due time and checks
|
sl@0
|
157 |
the returned time is equel to one set initially.
|
sl@0
|
158 |
@SYMTestExpectedResults The test must not fail.
|
sl@0
|
159 |
@SYMPREQ PREQ234
|
sl@0
|
160 |
*/
|
sl@0
|
161 |
void TScheduleState2_StateAccessor::TestDueTimeSetDueTime()
|
sl@0
|
162 |
{
|
sl@0
|
163 |
TheTest.Next(_L(" @SYMTestCaseID:SYSLIB-SCHSVR-CT-0227 Test set and get due time APIs "));
|
sl@0
|
164 |
|
sl@0
|
165 |
TScheduleState2 state;
|
sl@0
|
166 |
|
sl@0
|
167 |
TDateTime date(2005, EMay, 15, 8, 55, 0, 0);
|
sl@0
|
168 |
TTime time(date);
|
sl@0
|
169 |
TTsTime dueTime(time, EFalse); //TTsTime is Home time
|
sl@0
|
170 |
|
sl@0
|
171 |
state.SetDueTime(dueTime);
|
sl@0
|
172 |
TEST(time == state.DueTime().GetLocalTime());
|
sl@0
|
173 |
}
|
sl@0
|
174 |
|
sl@0
|
175 |
|
sl@0
|
176 |
|
sl@0
|
177 |
/**
|
sl@0
|
178 |
@file
|
sl@0
|
179 |
@SYMTestCaseID SYSLIB-SCHSVR-CT-0228
|
sl@0
|
180 |
@SYMTestCaseDesc Checks SetPersists() and Persists() functions
|
sl@0
|
181 |
@SYMTestPriority low
|
sl@0
|
182 |
@SYMTestActions Creates an instance of TScheduleState2, calls SetPersists then Persists
|
sl@0
|
183 |
and checks the returned value is equal to the one set initially.
|
sl@0
|
184 |
@SYMTestExpectedResults The test must not fail.
|
sl@0
|
185 |
@SYMPREQ PREQ234
|
sl@0
|
186 |
*/
|
sl@0
|
187 |
void TScheduleState2_StateAccessor::TestPersistsSetPersists()
|
sl@0
|
188 |
{
|
sl@0
|
189 |
TheTest.Next(_L(" @SYMTestCaseID:SYSLIB-SCHSVR-CT-0228 "));
|
sl@0
|
190 |
TScheduleState2 state;
|
sl@0
|
191 |
|
sl@0
|
192 |
//set Persists to Etrue
|
sl@0
|
193 |
state.SetPersists(ETrue);
|
sl@0
|
194 |
TEST(state.Persists());
|
sl@0
|
195 |
|
sl@0
|
196 |
//set Persists to EFalse
|
sl@0
|
197 |
state.SetPersists(EFalse);
|
sl@0
|
198 |
TEST(!state.Persists());
|
sl@0
|
199 |
}
|
sl@0
|
200 |
|
sl@0
|
201 |
|
sl@0
|
202 |
|
sl@0
|
203 |
/**
|
sl@0
|
204 |
@file
|
sl@0
|
205 |
@SYMTestCaseID SYSLIB-SCHSVR-CT-0229
|
sl@0
|
206 |
@SYMTestCaseDesc Checks Enabled() and SetEnabled() functions
|
sl@0
|
207 |
@SYMTestPriority low
|
sl@0
|
208 |
@SYMTestActions Creates an instance TScheduleState2, calls SetEnabled() then Enabled()
|
sl@0
|
209 |
and checks the returned value is equal to the one set initially.
|
sl@0
|
210 |
@SYMTestExpectedResults The test must not fail.
|
sl@0
|
211 |
@SYMPREQ PREQ234
|
sl@0
|
212 |
*/
|
sl@0
|
213 |
void TScheduleState2_StateAccessor::TestEnabledSetEnabled()
|
sl@0
|
214 |
{
|
sl@0
|
215 |
TheTest.Next(_L(" @SYMTestCaseID:SYSLIB-SCHSVR-CT-0229 "));
|
sl@0
|
216 |
TScheduleState2 state;
|
sl@0
|
217 |
|
sl@0
|
218 |
//ETrue
|
sl@0
|
219 |
state.SetEnabled(ETrue);
|
sl@0
|
220 |
TEST(state.Enabled());
|
sl@0
|
221 |
|
sl@0
|
222 |
//EFlase
|
sl@0
|
223 |
state.SetEnabled(EFalse);
|
sl@0
|
224 |
TEST(!state.Enabled());
|
sl@0
|
225 |
|
sl@0
|
226 |
}
|
sl@0
|
227 |
|
sl@0
|
228 |
|
sl@0
|
229 |
|
sl@0
|
230 |
/**
|
sl@0
|
231 |
@file
|
sl@0
|
232 |
@SYMTestCaseID SYSLIB-SCHSVR-CT-0230
|
sl@0
|
233 |
@SYMTestCaseDesc Check the operator = works properly
|
sl@0
|
234 |
@SYMTestPriority low
|
sl@0
|
235 |
@SYMTestActions Creates an instance of TScheduleState2 using the overloaded constructor,
|
sl@0
|
236 |
then creates another instance of TScheduleState2 and assigns it the first instance
|
sl@0
|
237 |
of TScheduleState2. The tests make sure both instances are equal.
|
sl@0
|
238 |
@SYMTestExpectedResults The test must not fail.
|
sl@0
|
239 |
@SYMPREQ PREQ234
|
sl@0
|
240 |
*/
|
sl@0
|
241 |
void TScheduleState2_StateAccessor::TestOperatorEqual()
|
sl@0
|
242 |
{
|
sl@0
|
243 |
TheTest.Next(_L(" @SYMTestCaseID:SYSLIB-SCHSVR-CT-0230 Test overloaded equals operator "));
|
sl@0
|
244 |
|
sl@0
|
245 |
const TName name(_L("name"));
|
sl@0
|
246 |
//set the current utc time to 8.55am, 15 May 2005 -Daylight savings apply on this date
|
sl@0
|
247 |
TDateTime date(2005, EMay, 15, 8, 55, 0, 0);
|
sl@0
|
248 |
TTime time(date);
|
sl@0
|
249 |
TTsTime dueTime(time, EFalse); //TTsTime is Home time
|
sl@0
|
250 |
|
sl@0
|
251 |
TScheduleState2 state1(name, dueTime, ETrue, ETrue);
|
sl@0
|
252 |
TScheduleState2 state2 = state1;
|
sl@0
|
253 |
|
sl@0
|
254 |
TEST(state1.iName == state2.iName);
|
sl@0
|
255 |
TEST(state1.iDueTime.GetLocalTime() == state2.iDueTime.GetLocalTime() );
|
sl@0
|
256 |
TEST(state1.iFlags == state2.iFlags);
|
sl@0
|
257 |
TEST(state1.iReserved == state2.iReserved);
|
sl@0
|
258 |
}
|
sl@0
|
259 |
|
sl@0
|
260 |
|
sl@0
|
261 |
/**
|
sl@0
|
262 |
Runs all the tests.
|
sl@0
|
263 |
*/
|
sl@0
|
264 |
static void RunTestsL()
|
sl@0
|
265 |
{
|
sl@0
|
266 |
TheTest.Start(_L("=== Start TScheduleState2 tests \n"));
|
sl@0
|
267 |
TScheduleState2_StateAccessor* entry = new (ELeave) TScheduleState2_StateAccessor;
|
sl@0
|
268 |
CleanupStack::PushL(entry);
|
sl@0
|
269 |
entry->TestDefaultConstructor();
|
sl@0
|
270 |
entry->TestCopyConstructorOverloadedConstructor();
|
sl@0
|
271 |
entry->TestNameSetName();
|
sl@0
|
272 |
entry->TestDueTimeSetDueTime();
|
sl@0
|
273 |
entry->TestPersistsSetPersists();
|
sl@0
|
274 |
entry->TestEnabledSetEnabled();
|
sl@0
|
275 |
entry->TestOperatorEqual();
|
sl@0
|
276 |
CleanupStack::PopAndDestroy();
|
sl@0
|
277 |
}
|
sl@0
|
278 |
|
sl@0
|
279 |
|
sl@0
|
280 |
|
sl@0
|
281 |
//***********************************************************************************
|
sl@0
|
282 |
GLDEF_C TInt E32Main()
|
sl@0
|
283 |
{
|
sl@0
|
284 |
CTrapCleanup* tc = CTrapCleanup::New();
|
sl@0
|
285 |
TEST(tc != NULL);
|
sl@0
|
286 |
|
sl@0
|
287 |
__UHEAP_MARK;
|
sl@0
|
288 |
|
sl@0
|
289 |
TInt err;
|
sl@0
|
290 |
TheTest.Title();
|
sl@0
|
291 |
|
sl@0
|
292 |
TRAP(err, ::RunTestsL())
|
sl@0
|
293 |
TEST2(err, KErrNone);
|
sl@0
|
294 |
|
sl@0
|
295 |
TheTest.End();
|
sl@0
|
296 |
TheTest.Close();
|
sl@0
|
297 |
|
sl@0
|
298 |
__UHEAP_MARKEND;
|
sl@0
|
299 |
|
sl@0
|
300 |
delete tc;
|
sl@0
|
301 |
|
sl@0
|
302 |
return(KErrNone);
|
sl@0
|
303 |
|
sl@0
|
304 |
}
|
sl@0
|
305 |
|
sl@0
|
306 |
|
sl@0
|
307 |
|