|
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 the License "Symbian Foundation License v1.0" |
|
5 // which accompanies this distribution, and is available |
|
6 // at the URL "http://www.symbianfoundation.org/legal/sfl-v10.html". |
|
7 // |
|
8 // Initial Contributors: |
|
9 // Nokia Corporation - initial contribution. |
|
10 // |
|
11 // Contributors: |
|
12 // |
|
13 // Description: |
|
14 // @file ctlbsclientstep_UpdateOptions.cpp |
|
15 // This is the class implementation for the UpdateOptions Tests |
|
16 // |
|
17 // |
|
18 |
|
19 #include "ctlbsclientstepupdateoptions.h" |
|
20 |
|
21 #include <lbs.h> |
|
22 #include <lbssatellite.h> |
|
23 |
|
24 #include "tlbsutils.h" |
|
25 #include "ctlbsasyncwaiter.h" |
|
26 |
|
27 #define EXPECTED_GPS_ACCURACY_HORIZONTAL 100 |
|
28 #define EXPECTED_GPS_ACCURACY_VERTICAL 100 |
|
29 |
|
30 const TTimeIntervalMicroSeconds KTimestampMargin = 500000; //+/-0.5s |
|
31 |
|
32 /** |
|
33 |
|
34 */ |
|
35 TBool CT_LbsClientStep_UpdateOptions::VerifyFirstPosTime(const TTime& aTimeRequested, const TPositionInfo& aPosInfo, const TPositionUpdateOptions& aUpdateOpts) |
|
36 { |
|
37 TTime timeReceived, timeStamp; |
|
38 TPosition pos; |
|
39 |
|
40 TInt64 maxtime; |
|
41 maxtime = aUpdateOpts.UpdateTimeOut().Int64(); |
|
42 if(!maxtime) |
|
43 { |
|
44 #pragma message("TO DO: CT_LbsClientStep_UpdateOptions::VerifyFirstPosTime - Update when moduleinfo supported") |
|
45 const TTimeIntervalMicroSeconds ttff = 90*1000000; // TO DO - this should be retrieved from the module info (currently hardcoded in locserver too) |
|
46 maxtime = ttff.Int64(); |
|
47 } |
|
48 |
|
49 // get current time |
|
50 timeReceived.UniversalTime(); |
|
51 |
|
52 // get the position data: |
|
53 aPosInfo.GetPosition(pos); |
|
54 |
|
55 INFO_PRINTF1(_L("First position received at: ")); |
|
56 INFO_PRINTF4(_L("%d/%d/%d"), timeReceived.DateTime().Day() + 1, timeReceived.DateTime().Month() + 1, timeReceived.DateTime().Year()); |
|
57 INFO_PRINTF5(_L("at %d :%d :%d :%d"), timeReceived.DateTime().Hour(), timeReceived.DateTime().Minute(), timeReceived.DateTime().Second(), timeReceived.DateTime().MicroSecond()); |
|
58 |
|
59 timeStamp = pos.Time(); |
|
60 INFO_PRINTF1(_L("First position timeStamp: ")); |
|
61 INFO_PRINTF4(_L("%d/%d/%d"), timeStamp.DateTime().Day() + 1, timeStamp.DateTime().Month() + 1, timeStamp.DateTime().Year()); |
|
62 INFO_PRINTF5(_L("at %d :%d :%d :%d"), timeStamp.DateTime().Hour(), timeStamp.DateTime().Minute(), timeStamp.DateTime().Second(), timeStamp.DateTime().MicroSecond()); |
|
63 |
|
64 TInt64 timediff; |
|
65 timediff = timeReceived.Int64() - aTimeRequested.Int64(); |
|
66 |
|
67 // *first* position received can arrive 'immediately' and up to timeout, or maxtimetofirstfix if timeout not specified |
|
68 if(timediff > maxtime) |
|
69 { |
|
70 INFO_PRINTF1(_L("Failed: First Position received outside time range")); |
|
71 return FALSE; |
|
72 } |
|
73 else |
|
74 { |
|
75 return TRUE; |
|
76 } |
|
77 |
|
78 } |
|
79 |
|
80 |
|
81 /** |
|
82 aPosCount - which position in a set of periodic positions this is (first position = 0) |
|
83 */ |
|
84 TBool CT_LbsClientStep_UpdateOptions::VerifyPosTime(const TTime& aTimeFirstPosStamped, const TPositionUpdateOptions& aUpdateOpts, TPositionInfo& aPosInfo, TInt aPosCount) |
|
85 { |
|
86 TTime timeReceived, timeStamp; |
|
87 TPosition pos; |
|
88 TInt64 interval = aUpdateOpts.UpdateInterval().Int64(); |
|
89 TTimeIntervalMicroSeconds timeout; |
|
90 timeout = aUpdateOpts.UpdateTimeOut().Int64(); |
|
91 |
|
92 // should call different function for first position: |
|
93 __ASSERT_ALWAYS(aPosCount > 0, User::Panic(_L("Update options test"), KErrArgument)); |
|
94 |
|
95 // get current time |
|
96 timeReceived.UniversalTime(); |
|
97 |
|
98 // get the position data: |
|
99 aPosInfo.GetPosition(pos); |
|
100 |
|
101 INFO_PRINTF1(_L("Position received at: ")); |
|
102 INFO_PRINTF4(_L("%d/%d/%d"), timeReceived.DateTime().Day() + 1, timeReceived.DateTime().Month() + 1, timeReceived.DateTime().Year()); |
|
103 INFO_PRINTF5(_L("at %d :%d :%d :%d"), timeReceived.DateTime().Hour(), timeReceived.DateTime().Minute(), timeReceived.DateTime().Second(), timeReceived.DateTime().MicroSecond()); |
|
104 |
|
105 timeStamp = pos.Time(); |
|
106 INFO_PRINTF1(_L("Position timeStamp: ")); |
|
107 INFO_PRINTF4(_L("%d/%d/%d"), timeStamp.DateTime().Day() + 1, timeStamp.DateTime().Month() + 1, timeStamp.DateTime().Year()); |
|
108 INFO_PRINTF5(_L("at %d :%d :%d :%d"), timeStamp.DateTime().Hour(), timeStamp.DateTime().Minute(), timeStamp.DateTime().Second(), timeStamp.DateTime().MicroSecond()); |
|
109 |
|
110 TTime windowstart = aTimeFirstPosStamped + static_cast<TTimeIntervalMicroSeconds>(aPosCount * interval) - KTimestampMargin; |
|
111 TTime windowend = windowstart + timeout + KTimestampMargin; |
|
112 |
|
113 INFO_PRINTF1(_L("valid window start: ")); |
|
114 INFO_PRINTF4(_L("%d/%d/%d"), windowstart.DateTime().Day() + 1, windowstart.DateTime().Month() + 1, windowstart.DateTime().Year()); |
|
115 INFO_PRINTF5(_L("at %d :%d :%d :%d"), windowstart.DateTime().Hour(), windowstart.DateTime().Minute(), windowstart.DateTime().Second(), windowstart.DateTime().MicroSecond()); |
|
116 |
|
117 if(timeStamp < windowstart) |
|
118 { |
|
119 INFO_PRINTF1(_L("Failed: Position received outside time range")); |
|
120 return FALSE; |
|
121 } |
|
122 if(timeout.Int64() && (timeStamp > windowend)) |
|
123 { |
|
124 INFO_PRINTF1(_L("valid window end: ")); |
|
125 INFO_PRINTF4(_L("%d/%d/%d"), windowend.DateTime().Day() + 1, windowend.DateTime().Month() + 1, windowend.DateTime().Year()); |
|
126 INFO_PRINTF5(_L("at %d :%d :%d :%d"), windowend.DateTime().Hour(), windowend.DateTime().Minute(), windowend.DateTime().Second(), windowend.DateTime().MicroSecond()); |
|
127 |
|
128 return FALSE; |
|
129 } |
|
130 else |
|
131 { |
|
132 return TRUE; |
|
133 } |
|
134 } |
|
135 |
|
136 |
|
137 |
|
138 |
|
139 // constant definitions |
|
140 _LIT(KLbsClientStepUpdateOptions, "LbsClientStepUpdateOptions"); |
|
141 |
|
142 /** |
|
143 * Sets a Requestor for now - TO DO will be removed with new location server? |
|
144 */ |
|
145 void CT_LbsClientStep_UpdateOptions::TempSetRequestorL() |
|
146 { |
|
147 User::LeaveIfError(iPositioner.SetRequestor( CRequestor::ERequestorService, |
|
148 CRequestor::EFormatApplication, |
|
149 _L("Tom Tom"))); |
|
150 } |
|
151 |
|
152 |
|
153 /** |
|
154 * Destructor |
|
155 */ |
|
156 CT_LbsClientStep_UpdateOptions::~CT_LbsClientStep_UpdateOptions() |
|
157 { |
|
158 delete iLbsAdmin; |
|
159 } |
|
160 |
|
161 |
|
162 /** |
|
163 * Constructor |
|
164 */ |
|
165 CT_LbsClientStep_UpdateOptions::CT_LbsClientStep_UpdateOptions(CT_LbsClientServer& aParent) : CT_LbsClientStep(aParent), iLbsAdmin(NULL), iRequestedAssData(FALSE), iReceivedAssData(FALSE) |
|
166 { |
|
167 SetTestStepName(KLbsClientStep_UpdateOptions); |
|
168 } |
|
169 |
|
170 |
|
171 /** |
|
172 Static Constructor |
|
173 */ |
|
174 CT_LbsClientStep_UpdateOptions* CT_LbsClientStep_UpdateOptions::New(CT_LbsClientServer& aParent) |
|
175 { |
|
176 return new CT_LbsClientStep_UpdateOptions(aParent); |
|
177 // Note the lack of ELeave. |
|
178 // This means that having insufficient memory will return NULL; |
|
179 } |
|
180 |
|
181 |
|
182 /** |
|
183 Compare UpdateOptions |
|
184 */ |
|
185 TBool CT_LbsClientStep_UpdateOptions::CompareUpdateOptions(TPositionUpdateOptions aPosA, TPositionUpdateOptions aPosB) |
|
186 { |
|
187 TBool isEqual = ETrue; |
|
188 |
|
189 if(aPosA.AcceptPartialUpdates() != aPosB.AcceptPartialUpdates()) |
|
190 { |
|
191 return EFalse; |
|
192 } |
|
193 |
|
194 if(aPosA.MaxUpdateAge() != aPosB.MaxUpdateAge()) |
|
195 { |
|
196 return EFalse; |
|
197 } |
|
198 |
|
199 if(aPosA.PositionClassSize() != aPosB.PositionClassSize()) |
|
200 { |
|
201 return EFalse; |
|
202 } |
|
203 |
|
204 if(aPosA.PositionClassType() != aPosB.PositionClassType()) |
|
205 { |
|
206 return EFalse; |
|
207 } |
|
208 |
|
209 if(aPosA.UpdateInterval() != aPosB.UpdateInterval()) |
|
210 { |
|
211 return EFalse; |
|
212 } |
|
213 |
|
214 if(aPosA.UpdateTimeOut() != aPosB.UpdateTimeOut()) |
|
215 { |
|
216 return EFalse; |
|
217 } |
|
218 |
|
219 return isEqual; |
|
220 |
|
221 } |
|
222 |
|
223 /** |
|
224 * @return - TVerdict code |
|
225 * Override of base class pure virtual |
|
226 * Our implementation only gets called if the base class doTestStepPreambleL() did |
|
227 * not leave. That being the case, the current test result value will be EPass. |
|
228 */ |
|
229 TVerdict CT_LbsClientStep_UpdateOptions::doTestStepL() |
|
230 { |
|
231 // Generic test step used to test the LBS SetUpdateOptions API. |
|
232 INFO_PRINTF1(_L(">>CT_LbsClientStep_UpdateOptions::doTestStepL()")); |
|
233 |
|
234 if (TestStepResult()==EPass) |
|
235 { |
|
236 TInt err = KErrNone; |
|
237 |
|
238 // Connect to self locate server. |
|
239 User::LeaveIfError(iServer.Connect()); |
|
240 CleanupClosePushL(iServer); |
|
241 |
|
242 // Carryout unique test actions. |
|
243 TInt testCaseId; |
|
244 if (GetIntFromConfig(ConfigSection(), KTestCaseId, testCaseId)) |
|
245 { |
|
246 switch (testCaseId) |
|
247 { |
|
248 // Test case LBS-UpdateOptions-001 |
|
249 case 1: |
|
250 { |
|
251 // Open positioner. |
|
252 User::LeaveIfError(iPositioner.Open(iServer)); |
|
253 CleanupClosePushL(iPositioner); |
|
254 TPositionUpdateOptions optsA; |
|
255 |
|
256 TPositionUpdateOptions optsB; |
|
257 iPositioner.SetUpdateOptions(optsA); |
|
258 iPositioner.GetUpdateOptions(optsB); |
|
259 if (!CompareUpdateOptions(optsA, optsB)) |
|
260 { |
|
261 SetTestStepResult(EFail); |
|
262 } |
|
263 |
|
264 CleanupStack::PopAndDestroy(&iPositioner); |
|
265 |
|
266 break; |
|
267 } |
|
268 |
|
269 // Test case LBS-UpdateOptions-002 |
|
270 case 2: |
|
271 { |
|
272 // Open positioner. |
|
273 User::LeaveIfError(iPositioner.Open(iServer)); |
|
274 CleanupClosePushL(iPositioner); |
|
275 //(aInterval, aTimeOut, aMaxAge, TBool aAcceptPartialUpdates=EFalse) |
|
276 TPositionUpdateOptions optsA(-1, 0, 0, EFalse); |
|
277 |
|
278 CleanupStack::PopAndDestroy(&iPositioner); |
|
279 |
|
280 break; |
|
281 } |
|
282 |
|
283 // Test case LBS-UpdateOptions-003 |
|
284 case 3: |
|
285 { |
|
286 // Open positioner. |
|
287 User::LeaveIfError(iPositioner.Open(iServer)); |
|
288 CleanupClosePushL(iPositioner); |
|
289 |
|
290 TPositionUpdateOptions optsA(0, -1, 0, EFalse); |
|
291 |
|
292 CleanupStack::PopAndDestroy(&iPositioner); |
|
293 |
|
294 break; |
|
295 } |
|
296 |
|
297 // Test case LBS-UpdateOptions-004 |
|
298 case 4: |
|
299 { |
|
300 // Open positioner. |
|
301 User::LeaveIfError(iPositioner.Open(iServer)); |
|
302 CleanupClosePushL(iPositioner); |
|
303 |
|
304 TPositionUpdateOptions optsA(0, 0, -1, EFalse); |
|
305 |
|
306 CleanupStack::PopAndDestroy(&iPositioner); |
|
307 |
|
308 break; |
|
309 } |
|
310 |
|
311 |
|
312 // Test case LBS-UpdateOptions-005 |
|
313 case 5: |
|
314 { |
|
315 // Open positioner. |
|
316 User::LeaveIfError(iPositioner.Open(iServer)); |
|
317 CleanupClosePushL(iPositioner); |
|
318 |
|
319 TPositionUpdateOptions& updateOpts = iParent.iSharedData->iVerifyUpdateOpts; |
|
320 iPositioner.SetUpdateOptions(updateOpts); |
|
321 |
|
322 // Create a posinfo and store in our shared array for later verification. |
|
323 RPointerArray<TAny>& posInfoArr = iParent.iSharedData->iCurrentPosInfoArr; |
|
324 TPositionInfo* posInfo = new(ELeave) TPositionInfo(); |
|
325 |
|
326 T_LbsUtils utils; |
|
327 utils.ResetAndDestroy_PosInfoArr(posInfoArr); // Clear previous entries before new entry is appended. |
|
328 |
|
329 posInfoArr.Append(posInfo); |
|
330 |
|
331 TTime timeRequested; |
|
332 timeRequested.UniversalTime(); |
|
333 INFO_PRINTF1(_L("Position requested at: ")); |
|
334 INFO_PRINTF4(_L("%d/%d/%d"), timeRequested.DateTime().Day() + 1, timeRequested.DateTime().Month() + 1, timeRequested.DateTime().Year()); |
|
335 INFO_PRINTF5(_L("at %d :%d :%d :%d"), timeRequested.DateTime().Hour(), timeRequested.DateTime().Minute(), timeRequested.DateTime().Second(), timeRequested.DateTime().MicroSecond()); |
|
336 |
|
337 |
|
338 // Get the actual position |
|
339 err = DoNotifyUpdateL(*posInfo); |
|
340 if (KErrNone != err || !VerifyFirstPosTime(timeRequested, *posInfo, updateOpts)) |
|
341 { |
|
342 SetTestStepResult(EFail); |
|
343 } |
|
344 CleanupStack::PopAndDestroy(&iPositioner); |
|
345 |
|
346 break; |
|
347 } |
|
348 |
|
349 |
|
350 // Test case LBS-UpdateOptions-006 |
|
351 case 6: |
|
352 { |
|
353 // Open positioner. |
|
354 User::LeaveIfError(iPositioner.Open(iServer)); |
|
355 CleanupClosePushL(iPositioner); |
|
356 |
|
357 RPointerArray<TAny>& posInfoArr = iParent.iSharedData->iCurrentPosInfoArr; |
|
358 T_LbsUtils utils; |
|
359 utils.ResetAndDestroy_PosInfoArr(posInfoArr); // Clear previous entries before new entry is appended. |
|
360 |
|
361 // Create a posinfo and store in our shared array for later verification. |
|
362 TPositionInfo* posInfo = new(ELeave) TPositionInfo(); |
|
363 posInfoArr.Append(posInfo); |
|
364 |
|
365 TRequestStatus status; |
|
366 |
|
367 TPositionUpdateOptions tempOpts; |
|
368 // set a fairly long interval (1 minute) to ensure the 2nd request doesn't complete too quicky: |
|
369 tempOpts.SetUpdateInterval(60*1000000); |
|
370 tempOpts.SetUpdateTimeOut(300*1000000); |
|
371 iPositioner.SetUpdateOptions(tempOpts); |
|
372 iPositioner.GetUpdateOptions(tempOpts); |
|
373 |
|
374 TempSetRequestorL(); |
|
375 |
|
376 TTime timeRequested; |
|
377 TTime timeFirstStamped; |
|
378 |
|
379 INFO_PRINTF2(_L("Requesting position (current interval set to %d): "),tempOpts.UpdateInterval().Int64() ); |
|
380 timeRequested.UniversalTime(); |
|
381 err = DoNotifyUpdateL(*posInfo); |
|
382 if (KErrNone != err) |
|
383 { |
|
384 INFO_PRINTF2(_L("Failed: Position Update failed with %d"), err); |
|
385 SetTestStepResult(EFail); |
|
386 } |
|
387 else |
|
388 { |
|
389 TPosition pos; |
|
390 posInfo->GetPosition(pos); |
|
391 |
|
392 // need to remember the time we received this one: |
|
393 timeFirstStamped = pos.Time(); |
|
394 if(!VerifyFirstPosTime(timeRequested, *posInfo, tempOpts)) |
|
395 { |
|
396 SetTestStepResult(EFail); |
|
397 } |
|
398 } |
|
399 |
|
400 // Create another posinfo and store in our shared array for later verification. |
|
401 posInfo = new(ELeave) TPositionInfo(); |
|
402 posInfoArr.Append(posInfo); |
|
403 |
|
404 INFO_PRINTF2(_L("Requesting position (current interval set to %d): "), tempOpts.UpdateInterval().Int64()); |
|
405 |
|
406 // this should complete after original interval (1 min), despite setting a new interval while it's outstanding: |
|
407 iPositioner.NotifyPositionUpdate(*posInfo, status); |
|
408 |
|
409 // set configured update options while update still outstanding: |
|
410 TPositionUpdateOptions& updateOpts = iParent.iSharedData->iVerifyUpdateOpts; |
|
411 iPositioner.SetUpdateOptions(updateOpts); |
|
412 iPositioner.GetUpdateOptions(updateOpts); |
|
413 |
|
414 INFO_PRINTF2(_L("Interval now set to %d microseconds"), updateOpts.UpdateInterval().Int64()); |
|
415 |
|
416 User::WaitForRequest(status); |
|
417 |
|
418 // verify time for 'outstanding when interval changed' position |
|
419 if(!VerifyPosTime(timeFirstStamped, tempOpts, *posInfo, 1)) |
|
420 { |
|
421 INFO_PRINTF1(_L("CT_LbsClientStep_UpdateOptions::doTestStepL() Failed: Time received outside valid range")); |
|
422 SetTestStepResult(EFail); |
|
423 } |
|
424 else |
|
425 { |
|
426 TInt numOfPosInfos = iParent.iSharedData->iVerifyPosInfoArr.Count() - 2; // -2 because first 2 positions used above |
|
427 for(TInt i = 0 ; i < numOfPosInfos ; i++) |
|
428 { |
|
429 // get current time |
|
430 timeRequested.UniversalTime(); |
|
431 INFO_PRINTF1(_L("Position requested at: ")); |
|
432 INFO_PRINTF4(_L("%d/%d/%d"), timeRequested.DateTime().Day() + 1, timeRequested.DateTime().Month() + 1, timeRequested.DateTime().Year()); |
|
433 INFO_PRINTF5(_L("at %d :%d :%d :%d"), timeRequested.DateTime().Hour(), timeRequested.DateTime().Minute(), timeRequested.DateTime().Second(), timeRequested.DateTime().MicroSecond()); |
|
434 |
|
435 //Do request to position update |
|
436 posInfo = new(ELeave) TPositionInfo(); |
|
437 posInfoArr.Append(posInfo); |
|
438 |
|
439 err = DoNotifyUpdateL(*posInfo); |
|
440 if (KErrNone != err) |
|
441 { |
|
442 INFO_PRINTF2(_L("Failed: Position Update failed with %d"), err); |
|
443 SetTestStepResult(EFail); |
|
444 } |
|
445 else |
|
446 { |
|
447 if(i > 0) |
|
448 { |
|
449 if(!VerifyPosTime(timeFirstStamped, updateOpts, *posInfo, i)) |
|
450 { |
|
451 INFO_PRINTF1(_L("Failed: Position received outside time range")); |
|
452 SetTestStepResult(EFail); |
|
453 } |
|
454 } |
|
455 else // first position |
|
456 { |
|
457 TPosition pos; |
|
458 |
|
459 posInfo->GetPosition(pos); |
|
460 |
|
461 // need to remember the time we received this one: |
|
462 timeFirstStamped = pos.Time(); |
|
463 if(!VerifyFirstPosTime(timeRequested, *posInfo, updateOpts)) |
|
464 { |
|
465 SetTestStepResult(EFail); |
|
466 } |
|
467 } |
|
468 } |
|
469 } |
|
470 } |
|
471 |
|
472 CleanupStack::PopAndDestroy(&iPositioner); |
|
473 |
|
474 break; |
|
475 } |
|
476 |
|
477 |
|
478 // Test case LBS-UpdateOptions-007 |
|
479 case 7: |
|
480 case 107: |
|
481 { |
|
482 // Open positioner. |
|
483 User::LeaveIfError(iPositioner.Open(iServer)); |
|
484 CleanupClosePushL(iPositioner); |
|
485 |
|
486 |
|
487 // For this test an additional reference position will be returned. |
|
488 if (testCaseId == 107) |
|
489 { |
|
490 // Setup netsim. |
|
491 User::LeaveIfError(OpenNetSim()); |
|
492 |
|
493 // Request notify for the expected reference position. |
|
494 TPositionInfo actualRefPosInfo; |
|
495 |
|
496 err = DoNotifyUpdateL(actualRefPosInfo); |
|
497 if (err) |
|
498 { |
|
499 INFO_PRINTF2(_L("Failed test, reference position request returned err %d."), err); |
|
500 |
|
501 SetTestStepResult(EFail); |
|
502 } |
|
503 |
|
504 // Verify reference position. |
|
505 T_LbsUtils utils; |
|
506 TPositionInfo verifyRefPosInfo; |
|
507 |
|
508 verifyRefPosInfo.SetPosition(iRefPos); |
|
509 if (!utils.Compare_PosInfo(verifyRefPosInfo, actualRefPosInfo)) |
|
510 { |
|
511 INFO_PRINTF1(_L("Failed test, reference position incorrect.")); |
|
512 SetTestStepResult(EFail); |
|
513 } |
|
514 } |
|
515 |
|
516 |
|
517 TPositionUpdateOptions& updateOpts = iParent.iSharedData->iVerifyUpdateOpts; |
|
518 |
|
519 iPositioner.SetUpdateOptions(updateOpts); |
|
520 |
|
521 // verify that the set worked: |
|
522 ASSERT(updateOpts.UpdateInterval() == iParent.iSharedData->iVerifyUpdateOpts.UpdateInterval()); |
|
523 |
|
524 // Create a posinfo and store in our shared array for later verification. |
|
525 RPointerArray<TAny>& posInfoArr = iParent.iSharedData->iCurrentPosInfoArr; |
|
526 T_LbsUtils utils; |
|
527 utils.ResetAndDestroy_PosInfoArr(posInfoArr); // Clear previous entries before new entry is appended. |
|
528 |
|
529 TPositionInfo* posInfo; |
|
530 TTime timeRequested; |
|
531 |
|
532 iPositioner.GetUpdateOptions(updateOpts); |
|
533 |
|
534 TInt numOfPosInfos = iParent.iSharedData->iVerifyPosInfoArr.Count(); |
|
535 TTime timeFirstStamped; |
|
536 for(TInt i = 0 ; i < numOfPosInfos ; i++) |
|
537 { |
|
538 // get current time |
|
539 timeRequested.UniversalTime(); |
|
540 INFO_PRINTF1(_L("Position requested at: ")); |
|
541 INFO_PRINTF4(_L("%d/%d/%d"), timeRequested.DateTime().Day() + 1, timeRequested.DateTime().Month() + 1, timeRequested.DateTime().Year()); |
|
542 INFO_PRINTF5(_L("at %d :%d :%d :%d"), timeRequested.DateTime().Hour(), timeRequested.DateTime().Minute(), timeRequested.DateTime().Second(), timeRequested.DateTime().MicroSecond()); |
|
543 |
|
544 //Do request to position update |
|
545 posInfo = new(ELeave) TPositionInfo(); |
|
546 posInfoArr.Append(posInfo); |
|
547 |
|
548 err = DoNotifyUpdateL(*posInfo); |
|
549 if (KErrNone != err) |
|
550 { |
|
551 INFO_PRINTF2(_L("NotifyUpdate failed with %d "), err); |
|
552 SetTestStepResult(EFail); |
|
553 } |
|
554 else |
|
555 { |
|
556 if(i > 0) |
|
557 { |
|
558 if(!VerifyPosTime(timeFirstStamped, updateOpts, *posInfo, i)) |
|
559 { |
|
560 INFO_PRINTF1(_L("Failed: Position received outside time range")); |
|
561 SetTestStepResult(EFail); |
|
562 } |
|
563 } |
|
564 else // first position |
|
565 { |
|
566 TPosition pos; |
|
567 |
|
568 posInfo->GetPosition(pos); |
|
569 |
|
570 // need to remember the time we received this one: |
|
571 timeFirstStamped = pos.Time(); |
|
572 if(!VerifyFirstPosTime(timeRequested, *posInfo, updateOpts)) |
|
573 { |
|
574 SetTestStepResult(EFail); |
|
575 } |
|
576 } |
|
577 } |
|
578 } |
|
579 |
|
580 // Clean up. |
|
581 CleanupStack::PopAndDestroy(&iPositioner); |
|
582 if (testCaseId == 107) |
|
583 { |
|
584 CloseNetSim(); |
|
585 } |
|
586 |
|
587 break; |
|
588 } |
|
589 |
|
590 // Test case LBS-UpdateOptions-008 |
|
591 case 8: |
|
592 { |
|
593 // Open positioner. |
|
594 User::LeaveIfError(iPositioner.Open(iServer)); |
|
595 CleanupClosePushL(iPositioner); |
|
596 |
|
597 //2 second interval |
|
598 TPositionUpdateOptions optsA(2000000, 0, 0, EFalse); |
|
599 optsA.SetUpdateInterval(-1); |
|
600 |
|
601 CleanupStack::PopAndDestroy(&iPositioner); |
|
602 |
|
603 break; |
|
604 } |
|
605 |
|
606 // Test case LBS-UpdateOptions-009 |
|
607 case 9: |
|
608 { |
|
609 // Open positioner. |
|
610 User::LeaveIfError(iPositioner.Open(iServer)); |
|
611 CleanupClosePushL(iPositioner); |
|
612 |
|
613 |
|
614 //10 second interval |
|
615 TPositionUpdateOptions posUpdateOptsA(10000000, 0, 0, EFalse); |
|
616 TPositionUpdateOptions posUpdateOptsB; |
|
617 iPositioner.SetUpdateOptions(posUpdateOptsA); |
|
618 iPositioner.GetUpdateOptions(posUpdateOptsB); |
|
619 |
|
620 if(!CompareUpdateOptions(posUpdateOptsA, posUpdateOptsB)) |
|
621 { |
|
622 INFO_PRINTF1(_L("SetUpdate and GetUpdate comparison didn't match")); |
|
623 SetTestStepResult(EFail); |
|
624 } |
|
625 |
|
626 //5 second timeout |
|
627 posUpdateOptsA.SetUpdateTimeOut(5000000); |
|
628 iPositioner.SetUpdateOptions(posUpdateOptsA); |
|
629 iPositioner.GetUpdateOptions(posUpdateOptsB); |
|
630 |
|
631 if(!CompareUpdateOptions(posUpdateOptsA, posUpdateOptsB)) |
|
632 { |
|
633 INFO_PRINTF1(_L("SetUpdate and GetUpdate comparison didn't match")); |
|
634 SetTestStepResult(EFail); |
|
635 } |
|
636 |
|
637 TPositionInfo posInfo; |
|
638 |
|
639 // TO DO - is this sufficient, or should we really be testing how long it takes to timeout? |
|
640 |
|
641 // Get the actual position, should time out on AGPS side |
|
642 // ** Configure test gps module to cause a timeout |
|
643 err = DoNotifyUpdateL(posInfo); |
|
644 if (KErrTimedOut != err) |
|
645 { |
|
646 INFO_PRINTF1(_L("<FONT><B>AGPS module didn't timeout as expected.</B></FONT>")); |
|
647 SetTestStepResult(EFail); |
|
648 } |
|
649 |
|
650 CleanupStack::PopAndDestroy(&iPositioner); |
|
651 |
|
652 break; |
|
653 } |
|
654 |
|
655 |
|
656 // Test case LBS-UpdateOptions-010 |
|
657 case 10: |
|
658 { |
|
659 // Open positioner. |
|
660 User::LeaveIfError(iPositioner.Open(iServer)); |
|
661 CleanupClosePushL(iPositioner); |
|
662 |
|
663 TPositionUpdateOptions optsA; |
|
664 optsA.SetUpdateTimeOut(-1); |
|
665 |
|
666 CleanupStack::PopAndDestroy(&iPositioner); |
|
667 break; |
|
668 } |
|
669 |
|
670 |
|
671 // Test case LBS-UpdateOptions-011 |
|
672 case 11: |
|
673 { |
|
674 // Open positioner with |
|
675 // configured required quality |
|
676 TPositionCriteria criteria; |
|
677 TPositionQuality quality; |
|
678 |
|
679 // set up the required accuracy |
|
680 quality.SetHorizontalAccuracy(EXPECTED_GPS_ACCURACY_HORIZONTAL); |
|
681 quality.SetVerticalAccuracy(EXPECTED_GPS_ACCURACY_VERTICAL); |
|
682 |
|
683 criteria.SetRequiredQuality(quality); |
|
684 User::LeaveIfError(iPositioner.Open(iServer, criteria)); |
|
685 CleanupClosePushL(iPositioner); |
|
686 |
|
687 //Configure partial Updates |
|
688 TPositionUpdateOptions optsA; |
|
689 optsA.SetAcceptPartialUpdates(EFalse); |
|
690 if(EFalse != optsA.AcceptPartialUpdates()) |
|
691 { |
|
692 INFO_PRINTF1(_L("Partial Updates not set.")); |
|
693 SetTestStepResult(EFail); |
|
694 } |
|
695 |
|
696 iPositioner.SetUpdateOptions(optsA); |
|
697 |
|
698 |
|
699 // NOTE: |
|
700 // -Expect to call NPU once, and have module return 2 partial updates |
|
701 // before finally returning the complete update. |
|
702 // -We need a way to inform the module that it nedes to return partial updates |
|
703 // When we have AcceptPartialUpdates SwitchedOff. |
|
704 |
|
705 // ** Test AGPS manager must already be configured to return partial location info |
|
706 // ** We should only see the full location info to required accuracy etc |
|
707 TPositionInfo positionInfo; |
|
708 TPositionInfo positionInfoTemp = reinterpret_cast<TPositionInfo&>(iParent.iSharedData->iVerifyPosInfoArr[2]); |
|
709 |
|
710 // Get the actual position |
|
711 err = DoNotifyUpdateL(positionInfo); |
|
712 if (KErrNone != err) |
|
713 { |
|
714 SetTestStepResult(EFail); |
|
715 } |
|
716 else |
|
717 { |
|
718 //Compare posInfo with Moduledata 3 |
|
719 T_LbsUtils utils; |
|
720 if(!utils.Compare_PosInfo(positionInfo, positionInfoTemp)) |
|
721 { |
|
722 INFO_PRINTF1(_L("<FONT><B>We didn't recieve complete update.</B></FONT>")); |
|
723 SetTestStepResult(EFail); |
|
724 } |
|
725 } |
|
726 |
|
727 CleanupStack::PopAndDestroy(&iPositioner); |
|
728 |
|
729 break; |
|
730 } |
|
731 |
|
732 // Test case LBS-UpdateOptions-012 |
|
733 case 12: |
|
734 { |
|
735 // Open positioner with |
|
736 // configured required quality |
|
737 TPositionCriteria criteria; |
|
738 TPositionQuality quality; |
|
739 |
|
740 // set up the required accuracy |
|
741 quality.SetHorizontalAccuracy(EXPECTED_GPS_ACCURACY_HORIZONTAL); |
|
742 quality.SetVerticalAccuracy(EXPECTED_GPS_ACCURACY_VERTICAL); |
|
743 |
|
744 criteria.SetRequiredQuality(quality); |
|
745 err = iPositioner.Open(iServer, criteria); |
|
746 User::LeaveIfError(err); |
|
747 CleanupClosePushL(iPositioner); |
|
748 |
|
749 //Configure partial Updates |
|
750 TPositionUpdateOptions optsA; |
|
751 optsA.SetAcceptPartialUpdates(ETrue); |
|
752 if(!optsA.AcceptPartialUpdates()) |
|
753 { |
|
754 INFO_PRINTF1(_L("Partial Updates not set.")); |
|
755 SetTestStepResult(EFail); |
|
756 } |
|
757 |
|
758 err = iPositioner.SetUpdateOptions(optsA); |
|
759 User::LeaveIfError(err); |
|
760 |
|
761 // NOTE: |
|
762 // -Expect to call NPU repeatedly to recieve each partial update |
|
763 // -We need a way to inform the module that it nedes to return partial updates |
|
764 // When we have AcceptPartialUpdates SwitchedOff. |
|
765 |
|
766 // ** Test AGPS manager must already be configured to return partial location info |
|
767 // ** We should only see the full location info to required accuracy etc |
|
768 |
|
769 // Create a posinfo and store in our shared array for later verification. |
|
770 RPointerArray<TAny>& posInfoArr = iParent.iSharedData->iCurrentPosInfoArr; |
|
771 T_LbsUtils utils; |
|
772 utils.ResetAndDestroy_PosInfoArr(posInfoArr); // Clear previous entries before new entry is appended. |
|
773 |
|
774 TInt loopCount = iParent.iSharedData->iCurrentPosInfoArr.Count()-1; |
|
775 // Get the actual position |
|
776 for(int i = 0 ; i < loopCount ; i++ ) |
|
777 { |
|
778 TPositionInfo* positionInfo = new(ELeave) TPositionInfo(); |
|
779 posInfoArr.Append(positionInfo); |
|
780 |
|
781 err = DoNotifyUpdateL(*positionInfo); |
|
782 if (KErrNone != err) |
|
783 { |
|
784 SetTestStepResult(EFail); |
|
785 } |
|
786 } |
|
787 |
|
788 CleanupStack::PopAndDestroy(&iPositioner); |
|
789 |
|
790 break; |
|
791 } |
|
792 |
|
793 // Test case LBS-UpdateOptions-013 |
|
794 case 13: |
|
795 { |
|
796 // Open positioner. |
|
797 User::LeaveIfError(iPositioner.Open(iServer)); |
|
798 CleanupClosePushL(iPositioner); |
|
799 |
|
800 TPositionInfo posInfo; |
|
801 TPositionInfo posInfob; |
|
802 |
|
803 // This call to NPU puts a location in cache |
|
804 err = DoNotifyUpdateL(posInfo); |
|
805 if (KErrNone != err) |
|
806 { |
|
807 SetTestStepResult(EFail); |
|
808 } |
|
809 |
|
810 // TO DO - read these from config? |
|
811 TPositionUpdateOptions posOpts; |
|
812 posOpts.SetMaxUpdateAge(1*1000000); |
|
813 posOpts.SetUpdateInterval(5*1000000); |
|
814 |
|
815 if((posOpts.MaxUpdateAge() != 1000000) || (posOpts.UpdateInterval() != 5000000)) |
|
816 { |
|
817 SetTestStepResult(EFail); |
|
818 } |
|
819 |
|
820 iPositioner.SetUpdateOptions(posOpts); |
|
821 |
|
822 //Retrieve cached location with second call to NPU |
|
823 err = DoNotifyUpdateL(posInfob); |
|
824 if (KErrNone != err) |
|
825 { |
|
826 SetTestStepResult(EFail); |
|
827 } |
|
828 |
|
829 //INTERNAL COMPARISON |
|
830 //Make sure we've retrieved the cached location |
|
831 T_LbsUtils utils; |
|
832 if(!utils.Compare_PosInfo(posInfo, posInfob)) |
|
833 { |
|
834 SetTestStepResult(EFail); |
|
835 } |
|
836 |
|
837 CleanupStack::PopAndDestroy(&iPositioner); |
|
838 |
|
839 break; |
|
840 } |
|
841 |
|
842 |
|
843 |
|
844 |
|
845 |
|
846 // Test case LBS-UpdateOptions-014 |
|
847 case 14: |
|
848 { |
|
849 T_LbsUtils utils; |
|
850 TPositionModuleId networkModId = utils.GetNetworkModuleIdL(iServer); |
|
851 |
|
852 // Open positioners. |
|
853 User::LeaveIfError(iPositioner.Open(iServer, networkModId)); |
|
854 CleanupClosePushL(iPositioner); |
|
855 |
|
856 RPositionServer server2; |
|
857 RPositioner positioner2; |
|
858 |
|
859 // Connect to self locate servers. |
|
860 User::LeaveIfError(server2.Connect()); |
|
861 CleanupClosePushL(server2); |
|
862 |
|
863 TPositionModuleId aGpsModId = utils.GetAGpsModuleIdL(server2); |
|
864 |
|
865 User::LeaveIfError(positioner2.Open(server2, aGpsModId)); |
|
866 CleanupClosePushL(positioner2); |
|
867 |
|
868 |
|
869 TPositionUpdateOptions optsA; |
|
870 TPositionUpdateOptions optsB; |
|
871 |
|
872 optsA.SetMaxUpdateAge(10000000); |
|
873 optsA.SetUpdateInterval(5000000); |
|
874 |
|
875 optsB.SetMaxUpdateAge(0); |
|
876 optsB.SetUpdateInterval(2000000); |
|
877 |
|
878 TPositionInfo posInfo; |
|
879 TPositionInfo posInfob; |
|
880 |
|
881 |
|
882 // Get the actual position |
|
883 err = DoNotifyUpdateL(posInfo); |
|
884 if (KErrNone != err) |
|
885 { |
|
886 SetTestStepResult(EFail); |
|
887 } |
|
888 |
|
889 err = DoNotifyUpdateL(posInfob); |
|
890 if (KErrNone != err) |
|
891 { |
|
892 SetTestStepResult(EFail); |
|
893 } |
|
894 |
|
895 CleanupStack::PopAndDestroy(&positioner2); |
|
896 CleanupStack::PopAndDestroy(&server2); |
|
897 CleanupStack::PopAndDestroy(&iPositioner); |
|
898 |
|
899 break; |
|
900 } |
|
901 |
|
902 |
|
903 |
|
904 |
|
905 // Test case LBS-UpdateOptions-015 |
|
906 case 15: |
|
907 { |
|
908 T_LbsUtils utils; |
|
909 TPositionModuleId networkModId = utils.GetNetworkModuleIdL(iServer); |
|
910 |
|
911 // Open positioners. |
|
912 User::LeaveIfError(iPositioner.Open(iServer, networkModId)); |
|
913 CleanupClosePushL(iPositioner); |
|
914 |
|
915 RPositionServer server2; |
|
916 RPositioner positioner2; |
|
917 |
|
918 // Connect to self locate servers. |
|
919 User::LeaveIfError(server2.Connect()); |
|
920 CleanupClosePushL(server2); |
|
921 |
|
922 User::LeaveIfError(positioner2.Open(server2, networkModId)); |
|
923 CleanupClosePushL(positioner2); |
|
924 |
|
925 |
|
926 TPositionUpdateOptions optsA; |
|
927 TPositionUpdateOptions optsB; |
|
928 |
|
929 optsA.SetMaxUpdateAge(10000000); |
|
930 optsA.SetUpdateInterval(5000000); |
|
931 |
|
932 optsB.SetMaxUpdateAge(0); |
|
933 optsB.SetUpdateInterval(2000000); |
|
934 |
|
935 TPositionInfo posInfo; |
|
936 TPositionInfo posInfob; |
|
937 |
|
938 |
|
939 // Get the actual position |
|
940 err = DoNotifyUpdateL(posInfo); |
|
941 if (KErrNone != err) |
|
942 { |
|
943 SetTestStepResult(EFail); |
|
944 } |
|
945 |
|
946 // Loop? Keep calling until full info recieved. |
|
947 err = DoNotifyUpdateL(posInfob); |
|
948 if (KErrNone != err) |
|
949 { |
|
950 SetTestStepResult(EFail); |
|
951 } |
|
952 |
|
953 CleanupStack::PopAndDestroy(&positioner2); |
|
954 CleanupStack::PopAndDestroy(&server2); |
|
955 CleanupStack::PopAndDestroy(&iPositioner); |
|
956 |
|
957 break; |
|
958 } |
|
959 |
|
960 |
|
961 |
|
962 |
|
963 |
|
964 // Test case LBS-UpdateOptions-016 |
|
965 case 16: |
|
966 { |
|
967 T_LbsUtils utils; |
|
968 TPositionModuleId networkModId = utils.GetNetworkModuleIdL(iServer); |
|
969 |
|
970 // Open positioners. |
|
971 User::LeaveIfError(iPositioner.Open(iServer, networkModId)); |
|
972 CleanupClosePushL(iPositioner); |
|
973 |
|
974 RPositionServer server2; |
|
975 RPositioner positioner2; |
|
976 |
|
977 //Connect to self locate server |
|
978 TPositionModuleId aGpsModId = utils.GetAGpsModuleIdL(server2); |
|
979 |
|
980 User::LeaveIfError(positioner2.Open(iServer, aGpsModId)); |
|
981 CleanupClosePushL(positioner2); |
|
982 |
|
983 TPositionUpdateOptions optsA; |
|
984 TPositionUpdateOptions optsB; |
|
985 |
|
986 optsA.SetMaxUpdateAge(10000000); |
|
987 optsA.SetUpdateInterval(5000000); |
|
988 |
|
989 optsB.SetMaxUpdateAge(0); |
|
990 optsB.SetUpdateInterval(2000000); |
|
991 |
|
992 TPositionInfo posInfo; |
|
993 TPositionInfo posInfob; |
|
994 |
|
995 // Get the actual position |
|
996 err = DoNotifyUpdateL(posInfo); |
|
997 if (KErrNone != err) |
|
998 { |
|
999 SetTestStepResult(EFail); |
|
1000 } |
|
1001 |
|
1002 // Loop? Keep calling until full info recieved. |
|
1003 err = DoNotifyUpdateL(posInfob); |
|
1004 if (KErrNone != err) |
|
1005 { |
|
1006 SetTestStepResult(EFail); |
|
1007 } |
|
1008 |
|
1009 CleanupStack::PopAndDestroy(&positioner2); |
|
1010 CleanupStack::PopAndDestroy(&server2); |
|
1011 CleanupStack::PopAndDestroy(&iPositioner); |
|
1012 |
|
1013 break; |
|
1014 } |
|
1015 |
|
1016 |
|
1017 |
|
1018 // Test case LBS-UpdateOptions-017 |
|
1019 case 17: |
|
1020 { |
|
1021 // Open positioner. |
|
1022 User::LeaveIfError(iPositioner.Open(iServer)); |
|
1023 CleanupClosePushL(iPositioner); |
|
1024 |
|
1025 |
|
1026 TPositionUpdateOptions optsA; |
|
1027 optsA.SetUpdateInterval(1000000); |
|
1028 optsA.SetMaxUpdateAge(5000000); |
|
1029 |
|
1030 if((optsA.MaxUpdateAge() != 5000000) || (optsA.UpdateInterval() != 1000000)) |
|
1031 { |
|
1032 SetTestStepResult(EFail); |
|
1033 } |
|
1034 |
|
1035 iPositioner.SetUpdateOptions(optsA); |
|
1036 // Test AGPS manager must already be configured to return partial location info |
|
1037 |
|
1038 TPositionInfo posInfo; |
|
1039 |
|
1040 // This call to NPU puts a location in cache |
|
1041 err = DoNotifyUpdateL(posInfo); |
|
1042 if (KErrNone != err) |
|
1043 { |
|
1044 SetTestStepResult(EFail); |
|
1045 } |
|
1046 |
|
1047 /* |
|
1048 MaxUpdateAge () returns the current age limit for |
|
1049 information returned by NotifyPositionUpdate(). |
|
1050 Zero is returned when there is no acceptable age limit. |
|
1051 */ |
|
1052 |
|
1053 if(optsA.MaxUpdateAge() != 0) |
|
1054 { |
|
1055 SetTestStepResult(EFail); |
|
1056 } |
|
1057 |
|
1058 CleanupStack::PopAndDestroy(&iPositioner); |
|
1059 |
|
1060 break; |
|
1061 } |
|
1062 |
|
1063 // Test case LBS-UpdateOptions-018 |
|
1064 case 18: |
|
1065 { |
|
1066 // Open positioner. |
|
1067 User::LeaveIfError(iPositioner.Open(iServer)); |
|
1068 CleanupClosePushL(iPositioner); |
|
1069 |
|
1070 TPositionUpdateOptions optsA; |
|
1071 optsA.SetMaxUpdateAge(-1); |
|
1072 |
|
1073 CleanupStack::PopAndDestroy(&iPositioner); |
|
1074 |
|
1075 break; |
|
1076 } |
|
1077 |
|
1078 |
|
1079 // Test case LBS-UpdateOptions-019 |
|
1080 case 19: |
|
1081 { |
|
1082 // Open positioner. |
|
1083 User::LeaveIfError(iPositioner.Open(iServer)); |
|
1084 CleanupClosePushL(iPositioner); |
|
1085 |
|
1086 //MaxUpdateAge comparision replacede by verify data step |
|
1087 TPositionUpdateOptions& updateOpts = iParent.iSharedData->iVerifyUpdateOpts; |
|
1088 |
|
1089 TPositionInfo posInfoA, posInfoB; |
|
1090 |
|
1091 //Get fresh location and have it in cache |
|
1092 err = DoNotifyUpdateL(posInfoA); |
|
1093 if (KErrNone != err) |
|
1094 { |
|
1095 SetTestStepResult(EFail); |
|
1096 } |
|
1097 |
|
1098 //Second call to NPU should have maxupdateage set. |
|
1099 iPositioner.SetUpdateOptions(updateOpts); |
|
1100 |
|
1101 err = DoNotifyUpdateL(posInfoB); |
|
1102 if (KErrNone != err) |
|
1103 { |
|
1104 SetTestStepResult(EFail); |
|
1105 } |
|
1106 |
|
1107 T_LbsUtils utils; |
|
1108 |
|
1109 if(!utils.Compare_PosInfo(posInfoA, posInfoB)) |
|
1110 { |
|
1111 //Cached copy doesnt match retrieved copy. |
|
1112 SetTestStepResult(EFail); |
|
1113 } |
|
1114 |
|
1115 CleanupStack::PopAndDestroy(&iPositioner); |
|
1116 |
|
1117 break; |
|
1118 } |
|
1119 |
|
1120 // Test case LBS-UpdateOptions-020 |
|
1121 case 20: |
|
1122 { |
|
1123 // Open positioner. |
|
1124 User::LeaveIfError(iPositioner.Open(iServer)); |
|
1125 CleanupClosePushL(iPositioner); |
|
1126 |
|
1127 TPositionInfo cachedInfo, firstposInfo, secondposInfo; |
|
1128 |
|
1129 TPositionUpdateOptions& updateOpts = iParent.iSharedData->iVerifyUpdateOpts; |
|
1130 updateOpts.SetUpdateInterval(0); |
|
1131 updateOpts.SetMaxUpdateAge(0); |
|
1132 //Second call to NPU should have maxupdateage set. |
|
1133 iPositioner.SetUpdateOptions(updateOpts); |
|
1134 |
|
1135 // Get fresh location and have it in cache |
|
1136 err = DoNotifyUpdateL(cachedInfo); |
|
1137 if (KErrNone != err) |
|
1138 { |
|
1139 SetTestStepResult(EFail); |
|
1140 } |
|
1141 |
|
1142 // Change the max fix time |
|
1143 updateOpts.SetMaxUpdateAge(5000000); |
|
1144 iPositioner.SetUpdateOptions(updateOpts); |
|
1145 |
|
1146 // Wait 4 seconds |
|
1147 User::After(4000000); |
|
1148 |
|
1149 // Get a position should be the same as in the cache |
|
1150 err = DoNotifyUpdateL(firstposInfo); |
|
1151 if (KErrNone != err) |
|
1152 { |
|
1153 SetTestStepResult(EFail); |
|
1154 } |
|
1155 |
|
1156 // Wait 2 seconds |
|
1157 User::After(2000000); |
|
1158 // Get a position should not be the same as the cache |
|
1159 err = DoNotifyUpdateL(secondposInfo); |
|
1160 if (KErrNone != err) |
|
1161 { |
|
1162 SetTestStepResult(EFail); |
|
1163 } |
|
1164 |
|
1165 T_LbsUtils utils; |
|
1166 |
|
1167 TBool a = utils.Compare_PosInfo(cachedInfo, firstposInfo); |
|
1168 TBool b = utils.Compare_PosInfo(firstposInfo, secondposInfo); |
|
1169 |
|
1170 if(!a || b) |
|
1171 { |
|
1172 //Cached copy doesnt match retrieved copy. |
|
1173 SetTestStepResult(EFail); |
|
1174 } |
|
1175 |
|
1176 CleanupStack::PopAndDestroy(&iPositioner); |
|
1177 |
|
1178 break; |
|
1179 } |
|
1180 |
|
1181 |
|
1182 // Test case LBS-UpdateOptions-101 (for DEF118183) |
|
1183 case 101: |
|
1184 { |
|
1185 // Open positioner. |
|
1186 User::LeaveIfError(iPositioner.Open(iServer)); |
|
1187 CleanupClosePushL(iPositioner); |
|
1188 |
|
1189 TPositionInfo posInfoa; |
|
1190 TPositionInfo posInfob; |
|
1191 TPositionInfo posInfoc; |
|
1192 |
|
1193 // This call to NPU puts a location in cache |
|
1194 err = DoNotifyUpdateL(posInfoa); |
|
1195 if (KErrNone != err) |
|
1196 { |
|
1197 INFO_PRINTF2(_L("Failed: During first call to NPU err is %d"), err); |
|
1198 SetTestStepResult(EFail); |
|
1199 } |
|
1200 |
|
1201 TPositionUpdateOptions posOpts; |
|
1202 posOpts.SetMaxUpdateAge(1*1000000); |
|
1203 posOpts.SetUpdateInterval(5*1000000); |
|
1204 |
|
1205 if((posOpts.MaxUpdateAge() != 1000000) || (posOpts.UpdateInterval() != 5000000)) |
|
1206 { |
|
1207 INFO_PRINTF1(_L("Failed: During check of options values")); |
|
1208 SetTestStepResult(EFail); |
|
1209 } |
|
1210 |
|
1211 iPositioner.SetUpdateOptions(posOpts); |
|
1212 |
|
1213 //Retrieve cached location with second call to NPU |
|
1214 err = DoNotifyUpdateL(posInfob); |
|
1215 if (KErrNone != err) |
|
1216 { |
|
1217 INFO_PRINTF2(_L("Failed: During NPU 2 value is %d"), err); |
|
1218 SetTestStepResult(EFail); |
|
1219 } |
|
1220 |
|
1221 //INTERNAL COMPARISON |
|
1222 //Make sure we've retrieved the cached location |
|
1223 T_LbsUtils utils; |
|
1224 if(!utils.Compare_PosInfo(posInfoa, posInfob)) |
|
1225 { |
|
1226 INFO_PRINTF1(_L("Failed: During comparison of pos info values")); |
|
1227 SetTestStepResult(EFail); |
|
1228 } |
|
1229 |
|
1230 // Make 3rd call to NPU - this one to be cancelled |
|
1231 TRequestStatus status; |
|
1232 iPositioner.NotifyPositionUpdate(posInfoc, status); |
|
1233 |
|
1234 // Wait 2 seconds and then cancel |
|
1235 User::After(2000000); |
|
1236 err = iPositioner.CancelRequest(EPositionerNotifyPositionUpdate); |
|
1237 if (KErrNone != err) |
|
1238 { |
|
1239 // Pre-DefectFix code would return -1 at this point since there would have been no request to cancel |
|
1240 INFO_PRINTF2(_L("Failed: Cancel request was rejected with error %d"), err); |
|
1241 SetTestStepResult(EFail); |
|
1242 } |
|
1243 |
|
1244 User::WaitForRequest(status); |
|
1245 if (KErrCancel != status.Int()) |
|
1246 { |
|
1247 // Pre-DefectFix code would return 0 at this point to indicate a successfully returned position |
|
1248 INFO_PRINTF2(_L("Failed: Expected NPU to complete with KErrCancel but actual value is %d"), status.Int()); |
|
1249 SetTestStepResult(EFail); |
|
1250 } |
|
1251 |
|
1252 CleanupStack::PopAndDestroy(&iPositioner); |
|
1253 |
|
1254 break; |
|
1255 } |
|
1256 |
|
1257 |
|
1258 |
|
1259 default: |
|
1260 User::Panic(KLbsClientStepUpdateOptions, KErrUnknown); |
|
1261 |
|
1262 } |
|
1263 |
|
1264 } |
|
1265 |
|
1266 |
|
1267 // All done, clean up. |
|
1268 CleanupStack::PopAndDestroy(&iServer); |
|
1269 } |
|
1270 |
|
1271 INFO_PRINTF1(_L("<<CT_LbsClientStep_UpdateOptions::doTestStepL()")); |
|
1272 |
|
1273 return TestStepResult(); |
|
1274 } |