|
1 /* |
|
2 * Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies). |
|
3 * All rights reserved. |
|
4 * This component and the accompanying materials are made available |
|
5 * under the terms of the License "Symbian Foundation License v1.0" |
|
6 * which accompanies this distribution, and is available |
|
7 * at the URL "http://www.symbianfoundation.org/legal/sfl-v10.html". |
|
8 * |
|
9 * Initial Contributors: |
|
10 * Nokia Corporation - initial contribution. |
|
11 * |
|
12 * Contributors: |
|
13 * |
|
14 * Description: TimeZoneClient unit test class. |
|
15 * |
|
16 */ |
|
17 |
|
18 // System includes |
|
19 #include <QtTest/QtTest> |
|
20 #include <e32base.h> |
|
21 |
|
22 // User includes |
|
23 #include "clockserverclt.h" |
|
24 #include "clockserver.h" |
|
25 #include "clocktimesourceinterface.h" |
|
26 #include "clocktimesourceinterface.hrh" |
|
27 #include "clocktimezoneresolver.h" |
|
28 #include "clockdatatypes.h" |
|
29 #include "unittest_clockengines.h" |
|
30 |
|
31 // constants |
|
32 const int KNitzPluginId(0x200159A5); |
|
33 static const TUid KInvalidID = {0xA001234C}; |
|
34 const int KClockServerMajorVN(1); |
|
35 const int KClockServerMinorVN(0); |
|
36 const int KClockServerBuildVN(1); |
|
37 |
|
38 /*! |
|
39 This function will be called before each testfunction is executed. |
|
40 */ |
|
41 void TestClockEngines::init() |
|
42 { |
|
43 // Create a clockserver session. |
|
44 TRAPD(mError, mClockServerCltHandle = new RClkSrvInterface()); |
|
45 mClockServerCltHandle->Connect(); |
|
46 Q_UNUSED(mError) |
|
47 |
|
48 Q_ASSERT(!mError); |
|
49 Q_ASSERT(mClockServerCltHandle); |
|
50 } |
|
51 |
|
52 /*! |
|
53 This function will be called after every testfunction. |
|
54 */ |
|
55 void TestClockEngines::cleanup() |
|
56 { |
|
57 if (mClockServerCltHandle) { |
|
58 delete mClockServerCltHandle; |
|
59 mClockServerCltHandle = NULL; |
|
60 } |
|
61 } |
|
62 |
|
63 /*! |
|
64 Tests the api TestTimezoneClient::testConnectToServer. |
|
65 */ |
|
66 void TestClockEngines::testConnectToServer() |
|
67 { |
|
68 int result = mClockServerCltHandle->Connect(); |
|
69 QVERIFY(KErrNone == result); |
|
70 |
|
71 mClockServerCltHandle->Close(); |
|
72 } |
|
73 |
|
74 /*! |
|
75 Tests the api TestTimezoneClient::testActiveProtocol. |
|
76 */ |
|
77 void TestClockEngines::testActiveProtocol() |
|
78 { |
|
79 int errorCode(KErrNotFound); |
|
80 |
|
81 errorCode = mClockServerCltHandle->Connect(); |
|
82 if (errorCode == KErrNone) { |
|
83 // To activate nitz protocol |
|
84 errorCode = mClockServerCltHandle->ActivateProtocol(KNitzPluginId); |
|
85 mClockServerCltHandle->Close(); |
|
86 QVERIFY(KErrNone == errorCode); |
|
87 } |
|
88 else { |
|
89 QVERIFY(false); |
|
90 } |
|
91 } |
|
92 |
|
93 /*! |
|
94 Tests the api TestTimezoneClient::testActiveProtocol. |
|
95 */ |
|
96 void TestClockEngines::testActivateAllProtocols() |
|
97 { |
|
98 TInt errorCode(KErrNotFound); |
|
99 |
|
100 errorCode = mClockServerCltHandle->Connect(); |
|
101 if (errorCode == KErrNone) { |
|
102 // To activate nitz protocol |
|
103 errorCode = mClockServerCltHandle->ActivateAllProtocols();; |
|
104 mClockServerCltHandle->Close(); |
|
105 QVERIFY(KErrNone == errorCode); |
|
106 } |
|
107 else { |
|
108 QVERIFY(false); |
|
109 } |
|
110 } |
|
111 |
|
112 /*! |
|
113 Tests the api TestTimezoneClient::testIsProtocolActive. |
|
114 */ |
|
115 void TestClockEngines::testIsProtocolActive() |
|
116 { |
|
117 // First connect and test for it. |
|
118 int errorCode = mClockServerCltHandle->Connect(); |
|
119 if (KErrNone == errorCode) { |
|
120 int protocolActive(false); |
|
121 |
|
122 errorCode = mClockServerCltHandle->IsProtocolActive(KNitzPluginId, protocolActive); |
|
123 mClockServerCltHandle->Close(); |
|
124 QVERIFY(true == protocolActive); |
|
125 } |
|
126 else{ |
|
127 QVERIFY(false); |
|
128 } |
|
129 } |
|
130 |
|
131 /*! |
|
132 Tests the api TestTimezoneClient::testGetProtocolInfo. |
|
133 */ |
|
134 void TestClockEngines::testGetProtocolInfo() |
|
135 { |
|
136 // First connect and test for it. |
|
137 int errorCode = mClockServerCltHandle->Connect(); |
|
138 |
|
139 if (KErrNone == errorCode) { |
|
140 errorCode = mClockServerCltHandle->ActivateProtocol(KNitzPluginId); |
|
141 if (KErrNone == errorCode) { |
|
142 STimeAttributes timeAttributes; |
|
143 errorCode = mClockServerCltHandle->GetProtocolInfo(0x200159A5, timeAttributes); |
|
144 } |
|
145 QVERIFY(KErrNone == errorCode); |
|
146 mClockServerCltHandle->Close(); |
|
147 } |
|
148 } |
|
149 |
|
150 /*! |
|
151 Tests the api TestTimezoneClient::testGetCurrentMcc. |
|
152 */ |
|
153 void TestClockEngines::testGetCurrentMcc() |
|
154 { |
|
155 |
|
156 // First connect and test for it. |
|
157 int errorCode = mClockServerCltHandle->Connect(); |
|
158 |
|
159 if (KErrNone == errorCode) { |
|
160 int currentMcc; |
|
161 errorCode = mClockServerCltHandle->GetCurrentMcc(currentMcc); |
|
162 mClockServerCltHandle->Close(); |
|
163 QVERIFY(KErrNone == errorCode); |
|
164 } |
|
165 } |
|
166 |
|
167 /*! |
|
168 Tests the api TestTimezoneClient::testGetCurrentTimeZoneId. |
|
169 */ |
|
170 void TestClockEngines::testGetCurrentTimeZoneId() |
|
171 { |
|
172 // First connect and test for it. |
|
173 int errorCode = mClockServerCltHandle->Connect(); |
|
174 |
|
175 if (KErrNone == errorCode) { |
|
176 errorCode = mClockServerCltHandle->ActivateProtocol(KNitzPluginId); |
|
177 if (KErrNone == errorCode) { |
|
178 int currentTimeZoneId; |
|
179 errorCode = mClockServerCltHandle->GetCurrentTimeZondId(currentTimeZoneId); |
|
180 QVERIFY(KErrNone == errorCode); |
|
181 } |
|
182 mClockServerCltHandle->Close(); |
|
183 } |
|
184 } |
|
185 |
|
186 /*! |
|
187 Tests the api TestTimezoneClient::testDeActivateProtocol. |
|
188 */ |
|
189 void TestClockEngines::testDeActivateProtocol() |
|
190 { |
|
191 // First connect and test for it. |
|
192 int errorCode = mClockServerCltHandle->Connect(); |
|
193 |
|
194 if (KErrNone == errorCode) { |
|
195 errorCode = mClockServerCltHandle->DeActivateProtocol(KNitzPluginId); |
|
196 mClockServerCltHandle->Close(); |
|
197 QVERIFY(KErrNone == errorCode); |
|
198 } |
|
199 } |
|
200 |
|
201 /*! |
|
202 Tests the api TestTimezoneClient::testDeActivateProtocol. |
|
203 */ |
|
204 void TestClockEngines::testDeActivateAllProtocols() |
|
205 { |
|
206 // First connect and test for it. |
|
207 int errorCode = mClockServerCltHandle->Connect(); |
|
208 if (KErrNone == errorCode) { |
|
209 errorCode = mClockServerCltHandle->ActivateAllProtocols(); |
|
210 |
|
211 if (KErrNone == errorCode) { |
|
212 errorCode = mClockServerCltHandle->DeActivateAllProtocols(); |
|
213 mClockServerCltHandle->Close(); |
|
214 QVERIFY(KErrNone == errorCode); |
|
215 } |
|
216 } |
|
217 } |
|
218 |
|
219 /*! |
|
220 Tests the api TestTimezoneClient::tesTimeZoneResolverSingleZone1. |
|
221 */ |
|
222 void TestClockEngines::tesTimeZoneResolverSingleZone1() |
|
223 { |
|
224 int errorCode(KErrNotFound); |
|
225 mTzResolver = CClockTimeZoneResolver::NewL(); |
|
226 int actualTzId = 1944; |
|
227 |
|
228 if (NULL != mTzResolver) { |
|
229 mTimeInfo.iUtcDateTime = TDateTime(2008, TMonth( EJanuary ), 27, 10, 0, 0, 0); |
|
230 mTimeInfo.iTimeZoneOffset = 330; |
|
231 mTimeInfo.iDstOffset = 0; |
|
232 mMCC = _L("404"); |
|
233 |
|
234 errorCode = mTzResolver->GetTimeZoneL(mTimeInfo, mMCC, mTzId); |
|
235 QVERIFY(KErrNone == errorCode); |
|
236 QVERIFY(actualTzId == mTzId); |
|
237 delete mTzResolver; |
|
238 } |
|
239 } |
|
240 /*! |
|
241 Tests the api TestTimezoneClient::tesTimeZoneResolverSingleZone2. |
|
242 */ |
|
243 void TestClockEngines::tesTimeZoneResolverSingleZone2() |
|
244 { |
|
245 int errorCode(KErrNotFound); |
|
246 mTzResolver = CClockTimeZoneResolver::NewL(); |
|
247 |
|
248 if (NULL != mTzResolver) { |
|
249 mTimeInfo.iUtcDateTime = TDateTime(2008, TMonth(EJanuary), 27, 10, 0, 0, 0); |
|
250 mTimeInfo.iTimeZoneOffset = 300; |
|
251 mTimeInfo.iDstOffset = 0; |
|
252 |
|
253 mMCC = _L( "404" ); |
|
254 |
|
255 errorCode = mTzResolver->GetTimeZoneL(mTimeInfo, mMCC, mTzId); |
|
256 QVERIFY(KErrNotFound == errorCode); |
|
257 QVERIFY(KErrNotFound == mTzId); |
|
258 delete mTzResolver; |
|
259 } |
|
260 } |
|
261 |
|
262 /*! |
|
263 Tests the api TestTimezoneClient::tesTimeZoneResolverSingleZone3. |
|
264 */ |
|
265 void TestClockEngines::tesTimeZoneResolverSingleZone3() |
|
266 { |
|
267 int errorCode(KErrNotFound); |
|
268 mTzResolver = CClockTimeZoneResolver::NewL(); |
|
269 |
|
270 if (NULL != mTzResolver) { |
|
271 mTimeInfo.iUtcDateTime = TDateTime(2008, TMonth( EJanuary ), 27, 10, 0, 0, 0); |
|
272 mTimeInfo.iTimeZoneOffset = 330; |
|
273 mTimeInfo.iDstOffset = 0; |
|
274 mMCC = _L("310"); |
|
275 |
|
276 errorCode = mTzResolver->GetTimeZoneL(mTimeInfo, mMCC, mTzId); |
|
277 QVERIFY(KErrNotFound == errorCode); |
|
278 QVERIFY(KErrNotFound == mTzId); |
|
279 delete mTzResolver; |
|
280 } |
|
281 } |
|
282 |
|
283 /*! |
|
284 Tests the api TestTimezoneClient::tesTimeZoneResolverSingleZone4. |
|
285 */ |
|
286 void TestClockEngines::tesTimeZoneResolverSingleZone4() |
|
287 { |
|
288 int errorCode(KErrNotFound); |
|
289 mTzResolver = CClockTimeZoneResolver::NewL(); |
|
290 int actualTzId = 3048; |
|
291 if (NULL != mTzResolver) { |
|
292 mTimeInfo.iUtcDateTime = TDateTime(2008, TMonth(EJanuary), 27, 10, 0, 0, 0); |
|
293 mTimeInfo.iTimeZoneOffset = 300; |
|
294 mTimeInfo.iDstOffset = 0; |
|
295 mMCC = _L( "-1" ); |
|
296 |
|
297 errorCode = mTzResolver->GetTimeZoneL(mTimeInfo, mMCC, mTzId); |
|
298 QVERIFY(KErrNone == errorCode); |
|
299 QVERIFY(actualTzId == mTzId); |
|
300 delete mTzResolver; |
|
301 } |
|
302 } |
|
303 |
|
304 /*! |
|
305 Tests the api TestTimezoneClient::tesTimeZoneResolverSingleZone5. |
|
306 */ |
|
307 void TestClockEngines::tesTimeZoneResolverSingleZone5() |
|
308 { |
|
309 int errorCode(KErrNotFound); |
|
310 mTzResolver = CClockTimeZoneResolver::NewL(); |
|
311 int actualTzId = 1944; |
|
312 |
|
313 if(NULL != mTzResolver){ |
|
314 mTimeInfo.iUtcDateTime = TTime(KErrNotFound).DateTime();//TDateTime( 2008, TMonth( EJanuary ), 27, 10, 0, 0, 0 ); |
|
315 mTimeInfo.iTimeZoneOffset = KErrNotFound; |
|
316 mTimeInfo.iDstOffset = KErrNotFound; |
|
317 mMCC = _L( "404" ); |
|
318 |
|
319 errorCode = mTzResolver->GetTimeZoneL(mTimeInfo, mMCC, mTzId); |
|
320 QVERIFY(KErrNone == errorCode); |
|
321 QVERIFY(actualTzId == mTzId); |
|
322 delete mTzResolver; |
|
323 } |
|
324 } |
|
325 |
|
326 /*! |
|
327 Tests the api TestTimezoneClient::tesTimeZoneResolverSingleZone6. |
|
328 */ |
|
329 void TestClockEngines::tesTimeZoneResolverSingleZone6() |
|
330 { |
|
331 int errorCode(KErrNotFound); |
|
332 mTzResolver = CClockTimeZoneResolver::NewL(); |
|
333 |
|
334 if (NULL != mTzResolver) { |
|
335 mTimeInfo.iUtcDateTime = TTime(KErrNotFound).DateTime();//TDateTime( 2008, TMonth( EJanuary ), 27, 10, 0, 0, 0 ); |
|
336 mTimeInfo.iTimeZoneOffset = KErrNotFound; |
|
337 mTimeInfo.iDstOffset = KErrNotFound; |
|
338 |
|
339 mMCC = _L("-1"); |
|
340 |
|
341 errorCode = mTzResolver->GetTimeZoneL(mTimeInfo, mMCC, mTzId); |
|
342 QVERIFY(KErrNotFound == errorCode); |
|
343 QVERIFY(KErrNotFound == mTzId); |
|
344 delete mTzResolver; |
|
345 } |
|
346 } |
|
347 |
|
348 /*! |
|
349 Tests the api TestTimezoneClient::tesTimeZoneResolverSingleZone7. |
|
350 */ |
|
351 void TestClockEngines::tesTimeZoneResolverSingleZone7() |
|
352 { |
|
353 int errorCode(KErrNotFound); |
|
354 mTzResolver = CClockTimeZoneResolver::NewL(); |
|
355 int actualTzId = 2744; |
|
356 if (NULL != mTzResolver) { |
|
357 mTimeInfo.iUtcDateTime = TDateTime(2008, TMonth(EApril), 2, 10, 0, 0, 0); |
|
358 mTimeInfo.iTimeZoneOffset = 0; |
|
359 mTimeInfo.iDstOffset = 60; |
|
360 mMCC = _L( "235" ); |
|
361 |
|
362 errorCode = mTzResolver->GetTimeZoneL(mTimeInfo, mMCC, mTzId); |
|
363 QVERIFY(KErrNone == errorCode); |
|
364 QVERIFY(actualTzId == mTzId); |
|
365 delete mTzResolver; |
|
366 } |
|
367 } |
|
368 |
|
369 /*! |
|
370 Tests the api TestTimezoneClient::tesTimeZoneResolverMultiZone1. |
|
371 */ |
|
372 void TestClockEngines::tesTimeZoneResolverMultiZone1() |
|
373 { |
|
374 int errorCode(KErrNotFound); |
|
375 mTzResolver = CClockTimeZoneResolver::NewL(); |
|
376 int actualTzId = 2416; |
|
377 if (NULL != mTzResolver) { |
|
378 mTimeInfo.iUtcDateTime = TDateTime(2008, TMonth(EApril), 2, 10, 0, 0, 0); |
|
379 mTimeInfo.iTimeZoneOffset = 480; |
|
380 mTimeInfo.iDstOffset = 0; |
|
381 mMCC = _L( "505" ); |
|
382 |
|
383 errorCode = mTzResolver->GetTimeZoneL(mTimeInfo, mMCC, mTzId); |
|
384 QVERIFY(KErrNone == errorCode); |
|
385 QVERIFY(actualTzId == mTzId); |
|
386 delete mTzResolver; |
|
387 } |
|
388 |
|
389 } |
|
390 |
|
391 /*! |
|
392 Tests the api TestTimezoneClient::tesTimeZoneResolverSingleZone2. |
|
393 */ |
|
394 void TestClockEngines::tesTimeZoneResolverMultiZone2() |
|
395 { |
|
396 int errorCode(KErrNotFound); |
|
397 mTzResolver = CClockTimeZoneResolver::NewL(); |
|
398 |
|
399 if(NULL != mTzResolver) { |
|
400 mTimeInfo.iUtcDateTime = TDateTime(2008, TMonth( EApril ), 2, 10, 0, 0, 0); |
|
401 mTimeInfo.iTimeZoneOffset = 480; |
|
402 mTimeInfo.iDstOffset = 0; |
|
403 mMCC = _L("9999"); |
|
404 |
|
405 errorCode = mTzResolver->GetTimeZoneL(mTimeInfo, mMCC, mTzId); |
|
406 QVERIFY(KErrNotFound == errorCode); |
|
407 QVERIFY(KErrNotFound == mTzId); |
|
408 delete mTzResolver; |
|
409 } |
|
410 |
|
411 } |
|
412 |
|
413 /*! |
|
414 Tests the api TestTimezoneClient::tesTimeZoneResolverSingleZone3. |
|
415 */ |
|
416 void TestClockEngines::tesTimeZoneResolverMultiZone3() |
|
417 { |
|
418 int errorCode(KErrNotFound); |
|
419 mTzResolver = CClockTimeZoneResolver::NewL(); |
|
420 if (NULL != mTzResolver) { |
|
421 mTimeInfo.iUtcDateTime = TTime(KErrNotFound).DateTime(); |
|
422 mTimeInfo.iTimeZoneOffset = KErrNotFound; |
|
423 mTimeInfo.iDstOffset = KErrNotFound; |
|
424 mMCC = _L("505"); |
|
425 |
|
426 errorCode = mTzResolver->GetTimeZoneL(mTimeInfo, mMCC, mTzId); |
|
427 QVERIFY(KErrNotFound == errorCode); |
|
428 QVERIFY(KErrNotFound == mTzId); |
|
429 delete mTzResolver; |
|
430 } |
|
431 |
|
432 } |
|
433 |
|
434 /*! |
|
435 Tests the api TestTimezoneClient::tesTimeZoneResolverSingleZone4. |
|
436 */ |
|
437 void TestClockEngines::tesTimeZoneResolverMultiZone4() |
|
438 { |
|
439 int errorCode(KErrNotFound); |
|
440 mTzResolver = CClockTimeZoneResolver::NewL(); |
|
441 |
|
442 if (NULL != mTzResolver) { |
|
443 mTimeInfo.iUtcDateTime = TTime(KErrNotFound).DateTime(); |
|
444 mTimeInfo.iTimeZoneOffset = KErrNotFound; |
|
445 mTimeInfo.iDstOffset = KErrNotFound; |
|
446 mMCC = _L("9999"); |
|
447 |
|
448 errorCode = mTzResolver->GetTimeZoneL(mTimeInfo, mMCC, mTzId); |
|
449 QVERIFY(KErrNotFound == errorCode); |
|
450 QVERIFY(KErrNotFound == mTzId); |
|
451 delete mTzResolver; |
|
452 } |
|
453 } |
|
454 |
|
455 /*! |
|
456 Tests the api TestTimezoneClient::tesTimeZoneResolverSingleZone5. |
|
457 */ |
|
458 void TestClockEngines::tesTimeZoneResolverMultiZone5() |
|
459 { |
|
460 int errorCode(KErrNotFound); |
|
461 mTzResolver = CClockTimeZoneResolver::NewL(); |
|
462 |
|
463 if (NULL != mTzResolver) { |
|
464 mTimeInfo.iUtcDateTime = TDateTime(2010, TMonth(EApril), 2, 10, 0, 0, 0); |
|
465 mTimeInfo.iTimeZoneOffset = 600; |
|
466 mTimeInfo.iDstOffset = 1; |
|
467 mMCC = _L( "505" ); |
|
468 |
|
469 errorCode = mTzResolver->GetTimeZoneL(mTimeInfo, mMCC, mTzId); |
|
470 QVERIFY(KErrNotFound == errorCode); |
|
471 QVERIFY(KErrNotFound == mTzId); |
|
472 delete mTzResolver; |
|
473 } |
|
474 } |
|
475 |
|
476 /*! |
|
477 Tests the api TestTimezoneClient::tesTimeZoneResolverSingleZone5. |
|
478 */ |
|
479 void TestClockEngines::testTimeZoneResolverSingleZoneWrongMCC() |
|
480 { |
|
481 int errorCode(KErrNotFound); |
|
482 mTzResolver = CClockTimeZoneResolver::NewL(); |
|
483 int actualTzId = 1944; |
|
484 if (NULL != mTzResolver) { |
|
485 mTimeInfo.iUtcDateTime = TDateTime(2008, TMonth(EJanuary), 27, 10, 0, 0, 0);; |
|
486 mTimeInfo.iTimeZoneOffset = 330; |
|
487 mTimeInfo.iDstOffset = 0; |
|
488 mMCC = _L("9999"); |
|
489 |
|
490 errorCode = mTzResolver->GetTimeZoneL(mTimeInfo, mMCC, mTzId); |
|
491 QVERIFY(KErrNone == errorCode); |
|
492 QVERIFY(actualTzId == mTzId); |
|
493 delete mTzResolver; |
|
494 } |
|
495 } |
|
496 |
|
497 //********************** TIMESOURCE INTERFACE****************************// |
|
498 |
|
499 /*! |
|
500 Tests the api TestTimezoneClient::NotifyTimeChangeL. |
|
501 */ |
|
502 void TestClockEngines::NotifyTimeChangeL( CClockTimeSourceInterface& plugin ) |
|
503 { |
|
504 Q_UNUSED(plugin) |
|
505 } |
|
506 |
|
507 /*! |
|
508 Tests the api TestTimezoneClient::testVersion. |
|
509 */ |
|
510 void TestClockEngines::testVersion() |
|
511 { |
|
512 int errorCode = mClockServerCltHandle->Connect(); |
|
513 if (KErrNone == errorCode) { |
|
514 TVersion testVersion = mClockServerCltHandle->Version(); |
|
515 mClockServerCltHandle->Close(); |
|
516 |
|
517 QVERIFY(KClockServerBuildVN == testVersion.iBuild); |
|
518 QVERIFY(KClockServerMajorVN == testVersion.iMajor); |
|
519 QVERIFY(KClockServerMinorVN == testVersion.iMinor); |
|
520 } |
|
521 } |
|
522 |
|
523 /*! |
|
524 Tests the api TestTimezoneClient::testCreatePluginInstance. |
|
525 */ |
|
526 void TestClockEngines::testCreatePluginInstance() |
|
527 { |
|
528 mClkTimeUpdaterInterface = CClockTimeSourceInterface::NewL(TUid::Uid(KNitzPluginId), this); |
|
529 Q_ASSERT(mClkTimeUpdaterInterface); |
|
530 delete mClkTimeUpdaterInterface; |
|
531 } |
|
532 |
|
533 /*! |
|
534 Tests the api TestTimezoneClient::testGetNitzData. |
|
535 */ |
|
536 void TestClockEngines::testGetNitzData() |
|
537 { |
|
538 mNitzInfo.iUtcDateTime = TTime(KErrNotFound).DateTime(); |
|
539 mNitzInfo.iTimeZoneOffset = KErrNotFound; |
|
540 mNitzInfo.iDstOffset = KErrNotFound; |
|
541 |
|
542 mClkTimeUpdaterInterface = CClockTimeSourceInterface::NewL(TUid::Uid(KNitzPluginId), this); |
|
543 |
|
544 Q_ASSERT(mClkTimeUpdaterInterface); |
|
545 if (NULL != mClkTimeUpdaterInterface) { |
|
546 mClkTimeUpdaterInterface->GetTimeInformationL(EUTCTime, &mNitzInfo); |
|
547 mClkTimeUpdaterInterface->GetTimeInformationL(ETZOffset, &mNitzInfo); |
|
548 mClkTimeUpdaterInterface->GetTimeInformationL(EDSTOffset, &mNitzInfo); |
|
549 |
|
550 qDebug() << "UtcDate: " << QDate(mNitzInfo.iUtcDateTime.Year(),mNitzInfo.iUtcDateTime.Month(),mNitzInfo.iUtcDateTime.Day()); |
|
551 qDebug() << "UtcTime: " << QTime(mNitzInfo.iUtcDateTime.Hour(),mNitzInfo.iUtcDateTime.Minute(),mNitzInfo.iUtcDateTime.Second()); |
|
552 qDebug() << "Timzone Offset: " << mNitzInfo.iTimeZoneOffset.Int(); |
|
553 qDebug() << "DST Offset: " << mNitzInfo.iDstOffset.Int(); |
|
554 |
|
555 delete mClkTimeUpdaterInterface; |
|
556 } |
|
557 } |
|
558 |
|
559 /*! |
|
560 Tests the api TestTimezoneClient::testInvalidPlugin. |
|
561 */ |
|
562 void TestClockEngines::testInvalidPlugin() |
|
563 { |
|
564 mClkTimeUpdaterInterface = CClockTimeSourceInterface::NewL(KInvalidID, this); |
|
565 QVERIFY(NULL == mClkTimeUpdaterInterface); |
|
566 } |
|
567 |
|
568 /*! |
|
569 Tests the api TestTimezoneClient::testTimeUpdateOn. |
|
570 */ |
|
571 void TestClockEngines::testTimeUpdateOn() |
|
572 { |
|
573 // First connect and test for it. |
|
574 int errorCode = mClockServerCltHandle->Connect(); |
|
575 |
|
576 if (KErrNone == errorCode) { |
|
577 int timeUpdateOn( EFalse ); |
|
578 |
|
579 // Activate Nitz plugin. |
|
580 errorCode = mClockServerCltHandle->ActivateProtocol(KNitzPluginId); |
|
581 if (KErrNone == errorCode) { |
|
582 // Check if auto time update is on. |
|
583 errorCode = mClockServerCltHandle->IsAutoTimeUpdateOn(timeUpdateOn); |
|
584 QVERIFY(true == timeUpdateOn); |
|
585 } |
|
586 mClockServerCltHandle->Close(); |
|
587 } |
|
588 } |
|
589 |
|
590 /*! |
|
591 Tests the api TestTimezoneClient::testInvalidPlugin. |
|
592 */ |
|
593 void TestClockEngines::testTimeUpdateOff() |
|
594 { |
|
595 // First connect and test for it. |
|
596 int errorCode = mClockServerCltHandle->Connect(); |
|
597 |
|
598 if (KErrNone == errorCode) { |
|
599 int timeUpdateOn( ETrue ); |
|
600 |
|
601 // Activate Nitz plugin. |
|
602 errorCode = mClockServerCltHandle->DeActivateProtocol(KNitzPluginId); |
|
603 if (KErrNone == errorCode) { |
|
604 // Check if auto time update is on. |
|
605 errorCode = mClockServerCltHandle->IsAutoTimeUpdateOn(timeUpdateOn); |
|
606 QVERIFY(false == timeUpdateOn); |
|
607 } |
|
608 mClockServerCltHandle->Close(); |
|
609 } |
|
610 } |
|
611 |
|
612 QTEST_MAIN(TestClockEngines) |
|
613 |
|
614 // End of file --Don't remove this. |