|
1 // Copyright (c) 2006-2009 Nokia Corporation and/or its subsidiary(-ies). |
|
2 // All rights reserved. |
|
3 // This component and the accompanying materials are made available |
|
4 // under the terms of "Eclipse Public License v1.0" |
|
5 // which accompanies this distribution, and is available |
|
6 // at the URL "http://www.eclipse.org/legal/epl-v10.html". |
|
7 // |
|
8 // Initial Contributors: |
|
9 // Nokia Corporation - initial contribution. |
|
10 // |
|
11 // Contributors: |
|
12 // |
|
13 // Description: |
|
14 // @file ctlbsclockstepmain.cpp |
|
15 // This is the class implementation for the Clock Tests |
|
16 // EPOC includes. |
|
17 // LBS includes. |
|
18 // |
|
19 // |
|
20 |
|
21 // LBS test includes. |
|
22 #include "ctlbsclockstepmain.h" |
|
23 |
|
24 const TTimeIntervalMicroSeconds32 KVerifyTimerInterval = 250000;//0.25s |
|
25 const TTimeIntervalMicroSeconds KDefaultAdjustClockTimeout = 3000000; |
|
26 const TTimeIntervalMicroSeconds KModuleTimeout = 50 * 1000* 1000; |
|
27 const TInt64 KMaxDiffForRoughCompare = 5000000; |
|
28 const TInt64 KMaxDiffForExactCompare = 2000000; |
|
29 const TInt64 KMaxDiffForTimeoutCompare = 500000; |
|
30 |
|
31 const TVersion verifyVer(1,0,0); |
|
32 |
|
33 _LIT(KTimeOffset, "time_offset"); |
|
34 _LIT(KClientTimeout, "client_timeout"); |
|
35 |
|
36 /** When adding new tests try to follow the test execute path currently taken by existing tests. |
|
37 |
|
38 A typical test case follows this logic flow though the code: |
|
39 |
|
40 doTestStepL() is called, where the required clock admin is set, which in turn causes the admin notification function |
|
41 OnSettingUpdateEvent() to be called, from which the test starts (some tests will end here also). |
|
42 |
|
43 Then from OnSettingUpdateEvent() a async operation is fired, which results in the RunL() being called, from here the test will |
|
44 come to a end or continue with a further cycle of RunL(). |
|
45 |
|
46 During the test CheckForTestHalt() will be called to determine is the test has finished, which done as a result of |
|
47 the correct test flags being set. |
|
48 */ |
|
49 |
|
50 |
|
51 /** |
|
52 Static Constructor |
|
53 */ |
|
54 CT_LbsClockStep_Main* CT_LbsClockStep_Main::New(CT_LbsClockServer& aParent) |
|
55 { |
|
56 // Note the lack of ELeave. |
|
57 // This means that having insufficient memory will return NULL; |
|
58 CT_LbsClockStep_Main* testStep = new CT_LbsClockStep_Main(aParent); |
|
59 if (testStep) |
|
60 { |
|
61 TInt err = KErrNone; |
|
62 |
|
63 TRAP(err, testStep->ConstructL()); |
|
64 if (err) |
|
65 { |
|
66 delete testStep; |
|
67 testStep = NULL; |
|
68 } |
|
69 } |
|
70 return testStep; |
|
71 } |
|
72 |
|
73 |
|
74 /** |
|
75 * Constructor |
|
76 */ |
|
77 CT_LbsClockStep_Main::CT_LbsClockStep_Main(CT_LbsClockServer& aParent) : CT_LbsClockStep(aParent), CActive(CActive::EPriorityStandard) |
|
78 { |
|
79 SetTestStepName(KLbsClockStep_Main); |
|
80 } |
|
81 |
|
82 |
|
83 void CT_LbsClockStep_Main::ConstructL() |
|
84 { |
|
85 // Create the base class objects. |
|
86 CT_LbsClockStep::ConstructL(); |
|
87 |
|
88 // Connect to the LBS self locate server. |
|
89 User::LeaveIfError(iServer.Connect()); |
|
90 CleanupClosePushL(iServer); |
|
91 |
|
92 // Open the positioner. |
|
93 User::LeaveIfError(iPositioner.Open(iServer)); |
|
94 CleanupClosePushL(iPositioner); |
|
95 |
|
96 // set requester will be removed... |
|
97 User::LeaveIfError(iPositioner.SetRequestor( CRequestor::ERequestorService, |
|
98 CRequestor::EFormatApplication, |
|
99 _L("Tom Tom"))); |
|
100 |
|
101 // Create the admin. |
|
102 iAdmin = CLbsAdmin::NewL(*this); |
|
103 |
|
104 // Create the verify timer. |
|
105 iVerifyTimer = CT_LbsTimerUtils::NewL(this, 0); |
|
106 |
|
107 // Create the plugin data bus monitor. |
|
108 iPluginDataBusMonitor = CT_LbsClockPluginDataBusMonitor::NewL(this); |
|
109 |
|
110 // Determine the A-GPS module's time to first fix. |
|
111 DetermineModuleTimeToFirstFixL(); |
|
112 |
|
113 CActiveScheduler::Add(this); |
|
114 |
|
115 CleanupStack::Pop(&iPositioner); |
|
116 CleanupStack::Pop(&iServer); |
|
117 } |
|
118 |
|
119 |
|
120 /** |
|
121 * Destructor |
|
122 */ |
|
123 CT_LbsClockStep_Main::~CT_LbsClockStep_Main() |
|
124 { |
|
125 Cancel(); |
|
126 iVerifyTimer->CancelTimer(); |
|
127 iPluginDataBusMonitor->CancelMonitor(); |
|
128 |
|
129 delete iPluginDataBusMonitor; |
|
130 delete iVerifyTimer; |
|
131 delete iAdmin; |
|
132 iPositioner.Close(); |
|
133 iServer.Close(); |
|
134 } |
|
135 |
|
136 |
|
137 /** Used to mark each callback that has fired. |
|
138 */ |
|
139 void CT_LbsClockStep_Main::SetCallbackFlag(TLbsClockCallbackFlags aCallbackFlag) |
|
140 { |
|
141 iCallbackFlags |= aCallbackFlag; |
|
142 } |
|
143 |
|
144 |
|
145 /** Determine the end of the test. |
|
146 |
|
147 Check the state machine to determine when to halt the test. Once all the callbacks |
|
148 have been received the test can end. |
|
149 */ |
|
150 void CT_LbsClockStep_Main::CheckForTestHalt() |
|
151 { |
|
152 // Check for test finish. |
|
153 |
|
154 // We stop test from here when in the correct state and, there should not be anything outstanding. |
|
155 if ((iState == EWaiting) && (iCallbackFlags == iFlagsToHaltOn)) |
|
156 { |
|
157 iState = EDone; |
|
158 |
|
159 iPluginDataBusMonitor->CancelMonitor(); |
|
160 |
|
161 CActiveScheduler::Stop(); |
|
162 } |
|
163 } |
|
164 |
|
165 /** |
|
166 * @return - TVerdict code |
|
167 * Override of base class pure virtual |
|
168 * Our implementation only gets called if the base class doTestStepPreambleL() did |
|
169 * not leave. That being the case, the current test result value will be EPass. |
|
170 */ |
|
171 TVerdict CT_LbsClockStep_Main::doTestStepL() |
|
172 { |
|
173 // Generic test step used to test the LBS Client Notify position update API. |
|
174 INFO_PRINTF1(_L(">> CT_LbsClockStep_Main::doTestStepL()")); |
|
175 RDebug::Printf(">> CT_LbsClockStep_Main::doTestStepL()"); |
|
176 if (TestStepResult() == EPass) |
|
177 { |
|
178 // Carry out common test actions (such as connecting to a server). |
|
179 |
|
180 // Ensure auto adjust is off. |
|
181 User::LeaveIfError(iAdmin->Set(KLbsSettingClockAdjust, CLbsAdmin::EClockAdjustOff)); |
|
182 |
|
183 // Only interested in clock related admin changes. |
|
184 iAdmin->SetNotificationMaskL(KLbsSettingClockAdjust | KLbsSettingAllowManualClockAdjust); |
|
185 |
|
186 iState = EWaitingAdminNotify; |
|
187 |
|
188 // Netsim setup is required if the AGPS module is in the EGpsPreferTerminalBased mode. |
|
189 TBool iNetSimUsed = EFalse; |
|
190 CLbsAdmin::TGpsMode modAgpsMode; |
|
191 User::LeaveIfError(iAdmin->Get(KLbsSettingHomeGpsMode, modAgpsMode)); |
|
192 if (modAgpsMode == CLbsAdmin::EGpsPreferTerminalBased) |
|
193 { |
|
194 iNetSimUsed = ETrue; |
|
195 |
|
196 OpenNetSim(); |
|
197 } |
|
198 |
|
199 // Carry out unique test actions. |
|
200 if (GetIntFromConfig(ConfigSection(), KTestCaseId, iTestCaseId)) |
|
201 { |
|
202 switch (iTestCaseId) |
|
203 { |
|
204 // test case LBS-SetTime-0002 - man |
|
205 case 2: |
|
206 { |
|
207 iFlagsToHaltOn = KLbsClockCallback_Got_AdjustClock_Stage1 | |
|
208 KLbsClockCallback_Got_AdminNotification; |
|
209 |
|
210 User::LeaveIfError(iAdmin->Set(KLbsSettingAllowManualClockAdjust, CLbsAdmin::EClockAdjustOff)); |
|
211 } |
|
212 break; |
|
213 |
|
214 |
|
215 // Test case LBS-Clock-0004 - man |
|
216 case 12: |
|
217 case 13: |
|
218 { |
|
219 iFlagsToHaltOn = KLbsClockCallback_Got_AdjustClock_Stage1 | |
|
220 KLbsClockCallback_Got_AdjustClock_Stage2 | |
|
221 KLbsClockCallback_Got_AdminNotification; |
|
222 |
|
223 // Set time stamp offset, how much to alter the clock by. |
|
224 SetTimeOffsetL(); // This will block if test module is in use. |
|
225 |
|
226 // Switch on auto adjust. |
|
227 if (iTestCaseId == 13) |
|
228 { |
|
229 SetAutoAdjustOnL(); |
|
230 } |
|
231 |
|
232 // Switch on the Clock API Kick off both the admin change |
|
233 User::LeaveIfError(iAdmin->Set(KLbsSettingAllowManualClockAdjust, CLbsAdmin::EClockAdjustOn)); |
|
234 } |
|
235 break; |
|
236 |
|
237 |
|
238 // will timeout |
|
239 case 18: |
|
240 case 19: |
|
241 { |
|
242 iFlagsToHaltOn = KLbsClockCallback_Got_AdjustClock_Stage1 | |
|
243 KLbsClockCallback_Got_AdminNotification; |
|
244 |
|
245 // Set time stamp offset, how much to alter the clock by. |
|
246 SetTimeOffsetL(); // This will block if test module is in use. |
|
247 |
|
248 // Set the module timeout to ensure the clock adjust does timeout. |
|
249 if ((iTestCaseId == 18) || (iTestCaseId == 19)) |
|
250 { |
|
251 SetModuleTimeoutL(KModuleTimeout); // This will block. |
|
252 } |
|
253 |
|
254 // Switch on the Clock APIKick off both the admin change |
|
255 User::LeaveIfError(iAdmin->Set(KLbsSettingAllowManualClockAdjust, CLbsAdmin::EClockAdjustOn)); |
|
256 } |
|
257 break; |
|
258 |
|
259 // Test case LBS-Clock-0020 - auto |
|
260 case 20: |
|
261 case 21: |
|
262 case 41: |
|
263 { |
|
264 StartAutoAdjustTesting(); |
|
265 } |
|
266 break; |
|
267 |
|
268 case 121: |
|
269 { |
|
270 // Soak up the network position info generated when assistance data is requested |
|
271 // by the AGPS module. |
|
272 iState = ESoakRefPos; |
|
273 |
|
274 iPositioner.NotifyPositionUpdate(iRefPosInfo, iStatus); |
|
275 SetActive(); |
|
276 } |
|
277 break; |
|
278 |
|
279 default: |
|
280 { |
|
281 User::Panic(KLbsClockStep_Main, KErrUnknown); |
|
282 } |
|
283 } |
|
284 } |
|
285 |
|
286 // Kick off test. |
|
287 CActiveScheduler::Start(); |
|
288 |
|
289 // Close Netsim if used by test. |
|
290 if (iNetSimUsed) |
|
291 { |
|
292 CloseNetSim(); |
|
293 } |
|
294 } |
|
295 |
|
296 INFO_PRINTF1(_L("<< CT_LbsClockStep_Main::doTestStepL()")); |
|
297 |
|
298 return TestStepResult(); |
|
299 } |
|
300 |
|
301 |
|
302 void CT_LbsClockStep_Main::DoCancel() |
|
303 { |
|
304 } |
|
305 |
|
306 |
|
307 void CT_LbsClockStep_Main::OnSettingUpdateEvent(TInt aError, const TLbsAdminSetting& aSetting) |
|
308 { |
|
309 |
|
310 // Only process the notifications we requested. |
|
311 if (iState == EWaitingAdminNotify) |
|
312 { |
|
313 // Only process the clock setting. |
|
314 if ((KLbsSettingClockAdjust == aSetting) || (KLbsSettingAllowManualClockAdjust == aSetting)) |
|
315 { |
|
316 SetCallbackFlag(KLbsClockCallback_Got_AdminNotification); |
|
317 |
|
318 if (aError) |
|
319 { |
|
320 // Test failed. |
|
321 INFO_PRINTF2(_L("Failed test, admin change failed with error %d."), aError); |
|
322 SetTestStepResult(EFail); |
|
323 } |
|
324 |
|
325 else |
|
326 { |
|
327 // next stage of the test here - first clock sync |
|
328 switch (iTestCaseId) |
|
329 { |
|
330 case 2: |
|
331 { |
|
332 SetActive(); |
|
333 iState = EClockAdjustPending_Stage1; |
|
334 } |
|
335 break; |
|
336 |
|
337 case 12: |
|
338 case 13: |
|
339 case 20: |
|
340 case 21: |
|
341 case 41: |
|
342 case 121: |
|
343 { |
|
344 AdjustClock(EFalse, 0); |
|
345 |
|
346 iState = EClockAdjustPending_Stage1; |
|
347 } |
|
348 break; |
|
349 |
|
350 case 18: |
|
351 case 19: |
|
352 { |
|
353 if (iTestCaseId == 19) |
|
354 { |
|
355 } |
|
356 |
|
357 else |
|
358 { |
|
359 // Read the client timeout value. |
|
360 SetClientTimeout(); |
|
361 |
|
362 INFO_PRINTF2(_L("AdjustClock(%d)"), iClientTimeout.Int64()); |
|
363 |
|
364 } |
|
365 SetActive(); |
|
366 |
|
367 iAdjustClockCallTime.UniversalTime(); |
|
368 |
|
369 iState = EClockAdjustPending_Stage1; |
|
370 } |
|
371 break; |
|
372 |
|
373 default: |
|
374 { |
|
375 |
|
376 } |
|
377 } |
|
378 } |
|
379 CheckForTestHalt(); |
|
380 } |
|
381 } |
|
382 } |
|
383 |
|
384 |
|
385 void CT_LbsClockStep_Main::RunL() |
|
386 { |
|
387 TBool errExpected = ETrue; // Some tests expect an error. |
|
388 TInt err = iStatus.Int(); |
|
389 TTime currentTime; |
|
390 INFO_PRINTF2(_L("CT_LbsClockStep_Main::RunL() iTestCaseId=%D"), iTestCaseId); |
|
391 |
|
392 // Cancel the verify timer. |
|
393 iVerifyTimer->CancelTimer(); |
|
394 |
|
395 // may not be able to put here - for pos it will be set twice that's all |
|
396 SetCallbackFlag(KLbsClockCallback_Got_AdjustClock_Stage1); |
|
397 |
|
398 |
|
399 switch (iTestCaseId) |
|
400 { |
|
401 case 2: |
|
402 { |
|
403 if (err != KErrLocked) |
|
404 { |
|
405 // Test failed. |
|
406 INFO_PRINTF2(_L("Failed test, expected KErrLocked got error %d."), err); |
|
407 SetTestStepResult(EFail); |
|
408 } |
|
409 |
|
410 iState = EWaiting; |
|
411 } |
|
412 break; |
|
413 |
|
414 |
|
415 case 18: |
|
416 case 19: |
|
417 { |
|
418 // Verify the call timed out after the correct interval. |
|
419 switch (iTestCaseId) |
|
420 { |
|
421 case 18: |
|
422 { |
|
423 ValidateTimeout(iClientTimeout); |
|
424 } |
|
425 break; |
|
426 case 19: |
|
427 { |
|
428 ValidateTimeout(iGpsTimeToFirstFix); |
|
429 } |
|
430 break; |
|
431 } |
|
432 |
|
433 |
|
434 // Verify error code. |
|
435 if (err != KErrTimedOut) |
|
436 { |
|
437 // Test failed. |
|
438 INFO_PRINTF2(_L("Failed test, expected KErrTimedOut got error %d."), err); |
|
439 SetTestStepResult(EFail); |
|
440 } |
|
441 |
|
442 iState = EWaiting; |
|
443 } |
|
444 break; |
|
445 |
|
446 case 13: |
|
447 case 20: |
|
448 case 21: |
|
449 case 41: |
|
450 case 121: |
|
451 { |
|
452 // Special case where the ref pos is soaked up. Only required for test cases 120 + 121. |
|
453 if (iState == ESoakRefPos) |
|
454 { |
|
455 // Verify reference position. |
|
456 TPositionInfo verifyRefPosInfo; |
|
457 T_LbsUtils utils; |
|
458 |
|
459 verifyRefPosInfo.SetPosition(iRefPos); |
|
460 |
|
461 // Only verify ref position when using test module. The reason for this |
|
462 // is the real module may or may not allways ref pos for new clients. |
|
463 if (!utils.Compare_PosInfo(verifyRefPosInfo, iRefPosInfo) && |
|
464 iParent.iSharedData->iTestModuleInUse) |
|
465 { |
|
466 INFO_PRINTF1(_L("Failed test, reference position incorrect.")); |
|
467 SetTestStepResult(EFail); |
|
468 } |
|
469 |
|
470 // Errors not expected. |
|
471 errExpected = EFalse; |
|
472 |
|
473 // Start test in normal way. |
|
474 StartAutoAdjustTesting(); |
|
475 |
|
476 break; |
|
477 } |
|
478 |
|
479 // Print expected time after AdjustClock. |
|
480 INFO_PRINTF1(_L("Expected time after AdjustClock: ")); |
|
481 INFO_PRINTF5(_L("at %d :%d :%d :%d\n"), iVerifyTime.DateTime().Hour(), iVerifyTime.DateTime().Minute(), iVerifyTime.DateTime().Second(), iVerifyTime.DateTime().MicroSecond()); |
|
482 |
|
483 // Print the current time after AdjustClock. |
|
484 TTime currentTime; |
|
485 currentTime.UniversalTime(); |
|
486 |
|
487 INFO_PRINTF1(_L("Actual time after AdjustClock: ")); |
|
488 INFO_PRINTF5(_L("at %d :%d :%d :%d\n\n"), currentTime.DateTime().Hour(), currentTime.DateTime().Minute(), currentTime.DateTime().Second(), currentTime.DateTime().MicroSecond()); |
|
489 |
|
490 // Errors not expected. |
|
491 errExpected = EFalse; |
|
492 |
|
493 // System clock updated, verify time was updated correctly. |
|
494 if (iState == EClockAdjustPending_Stage1) |
|
495 { |
|
496 SetCallbackFlag(KLbsClockCallback_Got_AdjustClock_Stage1); |
|
497 CompareTimes(T_LbsUtils::ERoughAccuracy); |
|
498 |
|
499 // Before next adjust wait a while. To ensure the target time for the second request is always different from the first request. |
|
500 // There is a very small chance that the target times for the update request are the same, this is due to the clock being adjusted to precily |
|
501 // the same time as it was before the first request. |
|
502 User::After(3000000); |
|
503 |
|
504 AdjustClock(EFalse, 0); |
|
505 |
|
506 iState = EClockAdjustPending_Stage2; |
|
507 } |
|
508 |
|
509 else if (iState == EClockAdjustPending_Stage2) |
|
510 { |
|
511 SetCallbackFlag(KLbsClockCallback_Got_AdjustClock_Stage2); |
|
512 CompareTimes(T_LbsUtils::EExactAccuracy); |
|
513 |
|
514 iState = EWaiting; |
|
515 } |
|
516 } |
|
517 break; |
|
518 } |
|
519 |
|
520 // Check if the test is over. |
|
521 CheckForTestHalt(); |
|
522 |
|
523 // Report any un-expected errors. |
|
524 if (!errExpected && err) |
|
525 { |
|
526 User::LeaveIfError(err); |
|
527 } |
|
528 } |
|
529 |
|
530 |
|
531 TInt CT_LbsClockStep_Main::RunError(TInt aError) |
|
532 { |
|
533 // Test failed. |
|
534 INFO_PRINTF2(_L("Failed test, AdjustClock completed with error %d."), aError); |
|
535 SetTestStepResult(EFail); |
|
536 |
|
537 return aError; |
|
538 } |
|
539 |
|
540 |
|
541 |
|
542 |
|
543 void CT_LbsClockStep_Main::HandleTimerL(TInt aTimerId, const TTime& aTargetTime) |
|
544 { |
|
545 (void)aTimerId; |
|
546 (void)aTargetTime; |
|
547 |
|
548 iVerifyTime += KVerifyTimerInterval; |
|
549 |
|
550 iVerifyTimer->SetTimer(KVerifyTimerInterval); |
|
551 } |
|
552 |
|
553 |
|
554 void CT_LbsClockStep_Main::HandleDataBusUpdateL(const TClockPluginDataOut& aClockPluginDataOut) |
|
555 { |
|
556 // Indicate that the plugin was used to carry out the clock adjust. |
|
557 if (aClockPluginDataOut.iResponse == TClockPluginDataOut::EClockPluginResponseOk) |
|
558 { |
|
559 SetCallbackFlag(KLbsClockCallback_Got_ClockPluginInUse); |
|
560 } |
|
561 |
|
562 else |
|
563 { |
|
564 INFO_PRINTF1(_L("Failed test, plugin returned bad response.")); |
|
565 SetTestStepResult(EFail); |
|
566 } |
|
567 } |
|
568 |
|
569 |
|
570 void CT_LbsClockStep_Main::StartAutoAdjustTesting() |
|
571 { |
|
572 iFlagsToHaltOn = KLbsClockCallback_Got_AdjustClock_Stage1 | |
|
573 KLbsClockCallback_Got_AdjustClock_Stage2 | |
|
574 KLbsClockCallback_Got_AdminNotification; |
|
575 |
|
576 // Set time stamp offset, how much to alter the clock by. |
|
577 SetTimeOffsetL(); // This will block if test module is in use. |
|
578 |
|
579 // Waiting for admin update. |
|
580 iState = EWaitingAdminNotify; |
|
581 |
|
582 // As we invoke the automatic adjust via NotifyPositionUpdate, |
|
583 // we need somewhere to store the returned posistion infos. |
|
584 |
|
585 // Clean the pos info array. |
|
586 RPointerArray<TAny>& posInfoArr = iParent.iSharedData->iCurrentPosInfoArr; |
|
587 |
|
588 T_LbsUtils utils; |
|
589 utils.ResetAndDestroy_PosInfoArr(posInfoArr); // Clear previous entries before new entry is appended. |
|
590 |
|
591 // Using a plugin. |
|
592 if (iTestCaseId == 41) |
|
593 { |
|
594 iFlagsToHaltOn |= KLbsClockCallback_Got_ClockPluginInUse; |
|
595 |
|
596 iPluginDataBusMonitor->StartMonitorL(); |
|
597 } |
|
598 |
|
599 SetAutoAdjustOnL(); |
|
600 } |
|
601 |
|
602 |
|
603 void CT_LbsClockStep_Main::AdjustClock(TBool /*aUseTimeout*/, TTimeIntervalMicroSeconds /*aTimeoutValue*/) |
|
604 { |
|
605 // Store the current time. |
|
606 iVerifyTime.UniversalTime(); |
|
607 iVerifyTimer->SetTimer(KVerifyTimerInterval); |
|
608 |
|
609 // Print the current time before AdjustClock. |
|
610 INFO_PRINTF1(_L("Time before AdjustClock: ")); |
|
611 INFO_PRINTF5(_L("at %d :%d :%d :%d\n"), iVerifyTime.DateTime().Hour(), iVerifyTime.DateTime().Minute(), iVerifyTime.DateTime().Second(), iVerifyTime.DateTime().MicroSecond()); |
|
612 |
|
613 // Move clock forward by the required offset. |
|
614 TTime currentTime; |
|
615 |
|
616 currentTime.UniversalTime(); |
|
617 currentTime += iTimeStampOffset; |
|
618 INFO_PRINTF5(_L("Putting UTCTime forward to %d :%d :%d :%d"), currentTime.DateTime().Hour(), currentTime.DateTime().Minute(), currentTime.DateTime().Second(), currentTime.DateTime().MicroSecond()); |
|
619 User::SetUTCTime(currentTime); |
|
620 INFO_PRINTF1(_L("After SetUTCTime")); |
|
621 |
|
622 // Adjust clock to GPS time invoke automatic clock adjust. |
|
623 // Create a posinfo and store in our shared array for later verification. |
|
624 RPointerArray<TAny>& posInfoArr = iParent.iSharedData->iCurrentPosInfoArr; |
|
625 TPositionInfo* posInfo = new(ELeave) TPositionInfo(); |
|
626 if (posInfo) |
|
627 { |
|
628 posInfoArr.Append(posInfo); |
|
629 |
|
630 iPositioner.NotifyPositionUpdate(*posInfo, iStatus); |
|
631 } |
|
632 |
|
633 else |
|
634 { |
|
635 // Test failed. |
|
636 INFO_PRINTF1(_L("Failed test, memory failure creating posInfo.")); |
|
637 SetTestStepResult(EFail); |
|
638 } |
|
639 |
|
640 SetActive(); |
|
641 } |
|
642 |
|
643 |
|
644 TBool CT_LbsClockStep_Main::CompareTimes(T_LbsUtils::TComparisonAccuracyType aCmpAccuracy) |
|
645 { |
|
646 TTime currentTime; |
|
647 TInt64 timeDiff, maxTime; |
|
648 |
|
649 // Get difference between the current + verify times. |
|
650 currentTime.UniversalTime(); |
|
651 timeDiff = Abs(currentTime.Int64() - iVerifyTime.Int64()); |
|
652 |
|
653 // Get the limit value to compare against. |
|
654 if (aCmpAccuracy == T_LbsUtils::ERoughAccuracy) |
|
655 { |
|
656 maxTime = KMaxDiffForRoughCompare; // Five secs. |
|
657 } |
|
658 |
|
659 else |
|
660 { |
|
661 maxTime = KMaxDiffForExactCompare; // Two secs. |
|
662 } |
|
663 |
|
664 if(timeDiff > maxTime) |
|
665 { |
|
666 // Test failed. |
|
667 INFO_PRINTF2(_L("Failed test, time values differ by more than %d micro seconds."), maxTime); |
|
668 SetTestStepResult(EFail); |
|
669 |
|
670 return EFalse; |
|
671 } |
|
672 |
|
673 return ETrue; |
|
674 } |
|
675 |
|
676 |
|
677 TBool CT_LbsClockStep_Main::ValidateTimeout(const TTimeIntervalMicroSeconds aExpectedTimeout) |
|
678 { |
|
679 TTime adjustClockRunLTime; |
|
680 TTimeIntervalMicroSeconds microSecs; |
|
681 TInt64 timeElapsed, timeDiff; |
|
682 |
|
683 adjustClockRunLTime.UniversalTime(); |
|
684 INFO_PRINTF5(_L("Universal Time %d :%d :%d :%d\n"), adjustClockRunLTime.DateTime().Hour(), adjustClockRunLTime.DateTime().Minute(), adjustClockRunLTime.DateTime().Second(), adjustClockRunLTime.DateTime().MicroSecond()); |
|
685 INFO_PRINTF5(_L("Time when Adjust Clock was called %d :%d :%d :%d\n"), iAdjustClockCallTime.DateTime().Hour(), iAdjustClockCallTime.DateTime().Minute(), iAdjustClockCallTime.DateTime().Second(), iAdjustClockCallTime.DateTime().MicroSecond()); |
|
686 microSecs = adjustClockRunLTime.MicroSecondsFrom(iAdjustClockCallTime); |
|
687 timeElapsed = microSecs.Int64(); |
|
688 |
|
689 INFO_PRINTF2(_L("Microseconds Elapsed since AdjustClock called = %d"), timeElapsed); |
|
690 |
|
691 // Ensure values are close... |
|
692 timeDiff = Abs(timeElapsed - aExpectedTimeout.Int64()); |
|
693 INFO_PRINTF2(_L("TimeDiff = %d microseconds"), timeDiff); |
|
694 if (timeDiff > KMaxDiffForTimeoutCompare) |
|
695 { |
|
696 // Test failed. |
|
697 INFO_PRINTF2(_L("Failed test, timeout values differ by more than %d micro seconds."), KMaxDiffForTimeoutCompare); |
|
698 SetTestStepResult(EFail); |
|
699 |
|
700 return EFalse; |
|
701 } |
|
702 |
|
703 return ETrue; |
|
704 } |
|
705 |
|
706 |
|
707 void CT_LbsClockStep_Main::SetTimeOffsetL() |
|
708 { |
|
709 // Read how much to alter the clock by. |
|
710 TInt value = 0; |
|
711 GetIntFromConfig(ConfigSection(), KTimeOffset, value); |
|
712 |
|
713 TInt64 offsetNum = (TInt64)1000000 * (TInt64)value; |
|
714 TTimeIntervalMicroSeconds offsetValue(offsetNum); |
|
715 |
|
716 iTimeStampOffset = offsetValue; |
|
717 |
|
718 // If the test module is in use, transfer the time offset to it. |
|
719 if (iParent.iSharedData->iTestModuleInUse) |
|
720 { |
|
721 T_LbsUtils utils; |
|
722 TModuleDataIn modDataIn; |
|
723 |
|
724 modDataIn.iRequestType = TModuleDataIn::EModuleRequestTimeStampOffset; |
|
725 modDataIn.iTimeStampOffset = iTimeStampOffset; |
|
726 |
|
727 utils.NotifyModuleOfConfigChangeL(modDataIn); // This will block. |
|
728 } |
|
729 } |
|
730 |
|
731 |
|
732 void CT_LbsClockStep_Main::SetClientTimeout() |
|
733 { |
|
734 TInt value = 0; |
|
735 GetIntFromConfig(ConfigSection(), KClientTimeout, value); |
|
736 |
|
737 TInt64 timeoutNum = (TInt64)1000000 * (TInt64)value; |
|
738 TTimeIntervalMicroSeconds timeoutValue(timeoutNum); |
|
739 |
|
740 iClientTimeout = timeoutValue; |
|
741 } |
|
742 |
|
743 |
|
744 void CT_LbsClockStep_Main::SetModuleTimeoutL(TTimeIntervalMicroSeconds aTimeout) |
|
745 { |
|
746 // If the test module is in use, transfer the timeout to it. |
|
747 if (iParent.iSharedData->iTestModuleInUse) |
|
748 { |
|
749 // Inform the module of the timeout. |
|
750 T_LbsUtils utils; |
|
751 TModuleDataIn modDataIn; |
|
752 |
|
753 modDataIn.iRequestType = TModuleDataIn::EModuleRequestTimeOut; |
|
754 modDataIn.iTimeOut = iGpsTimeToFirstFix.Int64() + aTimeout.Int64(); |
|
755 |
|
756 utils.NotifyModuleOfConfigChangeL(modDataIn); // This will block. |
|
757 } |
|
758 |
|
759 // Can't set a timeout for the real module. |
|
760 else |
|
761 { |
|
762 User::LeaveIfError(KErrNotSupported); |
|
763 } |
|
764 } |
|
765 |
|
766 |
|
767 void CT_LbsClockStep_Main::SetAutoAdjustOnL() |
|
768 { |
|
769 // Switch on the automatic clock adjust. |
|
770 TUint adjustInterval = 1; //100;//100000; // 10th of a sec. |
|
771 |
|
772 User::LeaveIfError(iAdmin->Set(KLbsSettingClockAdjustInterval, adjustInterval)); |
|
773 User::LeaveIfError(iAdmin->Set(KLbsSettingClockAdjustThreshold, adjustInterval)); |
|
774 User::LeaveIfError(iAdmin->Set(KLbsSettingClockAdjust, CLbsAdmin::EClockAdjustOn)); |
|
775 } |
|
776 |
|
777 |
|
778 void CT_LbsClockStep_Main::DetermineModuleTimeToFirstFixL() |
|
779 { |
|
780 T_LbsUtils utils; |
|
781 |
|
782 // Determine the max fix value of the A-GPS module. |
|
783 TPositionModuleId gpsModuleId; |
|
784 TPositionModuleInfo gpsModuleInfo; |
|
785 TPositionQuality gpsQuality; |
|
786 |
|
787 // Get module id first. |
|
788 gpsModuleId = utils.GetAGpsModuleIdL(iServer); |
|
789 |
|
790 // Get max fix from actual module info, now we have the correct id. |
|
791 User::LeaveIfError(iServer.GetModuleInfoById(gpsModuleId, gpsModuleInfo)); |
|
792 |
|
793 gpsModuleInfo.GetPositionQuality(gpsQuality); |
|
794 iGpsTimeToFirstFix = gpsQuality.TimeToFirstFix(); |
|
795 } |