130 { |
135 { |
131 // Empty Database |
136 // Empty Database |
132 TRequestStatus emptyStatus; |
137 TRequestStatus emptyStatus; |
133 iServer.EmptyLastKnownPositionStore(emptyStatus); |
138 iServer.EmptyLastKnownPositionStore(emptyStatus); |
134 User::WaitForRequest(emptyStatus); |
139 User::WaitForRequest(emptyStatus); |
|
140 |
|
141 TPositionInfo posInfo2; |
|
142 TPositionAreaExtendedInfo matchLevel; |
|
143 TPositionAreaExtendedInfo expectedMatchLevel; |
|
144 |
135 TPositionInfo* posInfo = new(ELeave) TPositionInfo(); |
145 TPositionInfo* posInfo = new(ELeave) TPositionInfo(); |
136 posInfoArr.Append(posInfo); |
146 posInfoArr.Append(posInfo); |
|
147 |
|
148 // Check that last known position is completed correctly with no known area and nothing in cache. |
|
149 err = DoLastKnownPosAreaL(posInfo2, matchLevel); |
|
150 |
|
151 // no position so database returns KErrUnknown, probably 'wrong' error, but will be standard behaviour now. |
|
152 if (KErrUnknown != err) |
|
153 { |
|
154 ERR_PRINTF2(_L("Expected KErrUnknown, incorrect err %d returned"), err); |
|
155 SetTestStepResult(EFail); |
|
156 } |
|
157 |
137 //1. Move to cell 234.15.1911.36464 |
158 //1. Move to cell 234.15.1911.36464 |
138 err = RProperty::Set(KUidPSSimTsyCategory, KPSSimTsyTimersReduceTime, KReduceSimTsyTimers); |
159 err = RProperty::Set(KUidPSSimTsyCategory, KPSSimTsyTimersReduceTime, KReduceSimTsyTimers); |
139 User::After(KSimTsyTransitionDelay); |
160 User::After(KSimTsyTransitionDelay); |
140 //2. NPUD |
161 //2. NPUD |
141 err = DoNotifyUpdateL(*posInfo); |
162 err = DoNotifyUpdateL(*posInfo); |
249 } |
269 } |
250 // Test case LBS-Client-LastKnownPosArea-0003 |
270 // Test case LBS-Client-LastKnownPosArea-0003 |
251 // Verify that the last position is returned if current network position is unavailable |
271 // Verify that the last position is returned if current network position is unavailable |
252 case 3: |
272 case 3: |
253 { |
273 { |
|
274 // The SIM config file used by this test switches between valid and non-valid area configs. |
|
275 // If we move from a valid config to an invalid config, GetLastKnownPositionArea should return |
|
276 // with the last stored position (posInfo) together with area information that shows the |
|
277 // area accuracy to be TPositionAreaInfo::EAreaUnknown. |
|
278 |
254 TPositionInfo* posInfo = new(ELeave) TPositionInfo(); |
279 TPositionInfo* posInfo = new(ELeave) TPositionInfo(); |
255 posInfoArr.Append(posInfo); |
280 posInfoArr.Append(posInfo); |
256 TInt err = KErrNone; |
281 TInt err = KErrNone; |
257 |
282 |
258 // The SIM config file used by this test contains an |
283 // Empty Database |
259 // invalid global cell-id (LAC is zero). A transition to |
284 TRequestStatus emptyStatus; |
260 // a new valid cell is not provoked by this test. Therefore |
285 iServer.EmptyLastKnownPositionStore(emptyStatus); |
261 // the Location Monitor never gets to know a valid cell in this test. |
286 User::WaitForRequest(emptyStatus); |
262 |
287 |
263 // Request a position so that the position goes into the database |
288 // Whilst the area is not known, request a position. This shouldn't go into the database. |
|
289 // Therefore a subsequent getlastknownposarea will return KErrUnknown |
|
290 INFO_PRINTF1(_L("Check invalid positions don't go into the database")); |
|
291 |
264 err = DoNotifyUpdateL(*posInfo); |
292 err = DoNotifyUpdateL(*posInfo); |
265 if (KErrNone != err) |
293 if (KErrNone != err) |
266 { |
294 { |
267 ERR_PRINTF2(_L("Incorrect err %d returned"), err); |
295 ERR_PRINTF2(_L("Incorrect err %d returned"), err); |
268 SetTestStepResult(EFail); |
296 SetTestStepResult(EFail); |
269 } |
297 } |
270 |
298 |
271 // Since the Location Monitor never received a valid value of |
|
272 // GCI, the call to GetLastKnownPositionArea should return |
|
273 // the last stored position (posInfo) together with area information |
|
274 // that shows the "rough area accuracy" to be TPositionAreaInfo::EAreaUnknown. |
|
275 TPositionInfo posInfo2; |
299 TPositionInfo posInfo2; |
276 TPositionAreaExtendedInfo matchLevel, expectedMatchLevel; |
300 TPositionAreaExtendedInfo matchLevel; |
277 err = DoLastKnownPosAreaL(posInfo2, matchLevel); |
301 err = DoLastKnownPosAreaL(posInfo2, matchLevel); |
278 if (KErrNone != err) |
302 if (KErrUnknown != err) |
279 { |
303 { |
280 ERR_PRINTF2(_L("Incorrect err %d returned"), err); |
304 ERR_PRINTF2(_L("Expected KErrUnknown, incorrect err %d returned"), err); |
281 SetTestStepResult(EFail); |
305 SetTestStepResult(EFail); |
282 } |
306 } |
|
307 |
|
308 //1. Move to GSM cell 234.15.1911.36463 - all valid |
|
309 err = RProperty::Set(KUidPSSimTsyCategory, KPSSimTsyTimersReduceTime, KReduceSimTsyTimers); |
|
310 User::After(KSimTsyTransitionDelay); |
283 |
311 |
284 // Verify that the position received in the call to GLKPA is the last known position |
312 // Request a position so that the position goes into the database |
285 // due to the NPUD and also that the accuracy is set to TPositionAreaInfo::EAreaUnknown |
313 // then call GetLastKnownPosArea and check everything now matches. |
286 // (in this case the rest of boolean values passed in Validate() are irrelevant). |
314 INFO_PRINTF1(_L("Check that we get EAreaCity once a position is available")); |
|
315 err = DoNotifyUpdateL(*posInfo); |
|
316 if (KErrNone != err) |
|
317 { |
|
318 ERR_PRINTF2(_L("Incorrect err %d returned"), err); |
|
319 SetTestStepResult(EFail); |
|
320 } |
|
321 err = DoLastKnownPosAreaL(posInfo2, matchLevel); |
|
322 if (KErrNone != err) |
|
323 { |
|
324 ERR_PRINTF2(_L("Incorrect err %d returned"), err); |
|
325 SetTestStepResult(EFail); |
|
326 } |
|
327 Validate(*posInfo, posInfo2, matchLevel, TPositionAreaInfo::EAreaCity, ETrue, ETrue, ETrue, ETrue); |
|
328 |
|
329 // Next error condition, WCDMA network and cell id is too low... |
|
330 INFO_PRINTF1(_L("Check that invalid current WCDMA cell id is accepted and we get EAreaCountry match")); |
|
331 |
|
332 //1. Move to WCDMA cell 234.15.1911.36463 - the WCDMA spec expects a non-zero |
|
333 // RNC ID which implies the cell id should be greater than 0x10000. However, |
|
334 // certain networks break the rule, so check this 'illegal' cell id accepted. |
|
335 err = RProperty::Set(KUidPSSimTsyCategory, KPSSimTsyTimersReduceTime, KReduceSimTsyTimers); |
|
336 User::After(KSimTsyTransitionDelay); |
|
337 |
|
338 err = DoLastKnownPosAreaL(posInfo2, matchLevel); |
|
339 if (KErrNone != err) |
|
340 { |
|
341 ERR_PRINTF2(_L("Incorrect err %d returned"), err); |
|
342 SetTestStepResult(EFail); |
|
343 } |
|
344 |
|
345 // Expect EAreaCountry. The current 'broken' cell position should have been accepted |
|
346 // and we match on country and network code (but not LAC as earlier one was GSM LAC!). |
|
347 Validate(*posInfo, posInfo2, matchLevel, TPositionAreaInfo::EAreaCountry, ETrue, ETrue, EFalse, EFalse); |
|
348 |
|
349 // Next error condition, GSM network with too high a cell id. In this case, the cell will |
|
350 // have been rejected and effectively we are unregistered, so EAreaUnknown is correct. |
|
351 INFO_PRINTF1(_L("Check that invalid GSM cell id is identified and we get EAreaUnknown returned")); |
|
352 |
|
353 //1. Move to GSM cell 234.15.1911.90000 - 90000 is too high a cell id for GSM |
|
354 err = RProperty::Set(KUidPSSimTsyCategory, KPSSimTsyTimersReduceTime, KReduceSimTsyTimers); |
|
355 User::After(KSimTsyTransitionDelay); |
|
356 |
|
357 err = DoLastKnownPosAreaL(posInfo2, matchLevel); |
|
358 if (KErrNone != err) |
|
359 { |
|
360 ERR_PRINTF2(_L("Incorrect err %d returned"), err); |
|
361 SetTestStepResult(EFail); |
|
362 } |
|
363 // As current position information is broken, expect area EAreaUknown etc. |
287 Validate(*posInfo, posInfo2, matchLevel, TPositionAreaInfo::EAreaUnknown, EFalse, EFalse, EFalse, EFalse); |
364 Validate(*posInfo, posInfo2, matchLevel, TPositionAreaInfo::EAreaUnknown, EFalse, EFalse, EFalse, EFalse); |
288 |
365 |
|
366 // Go back to a valid cell, differing only in the cell-id, check that the |
|
367 //correct accuracy is returned. |
|
368 INFO_PRINTF1(_L("Valid GSM area, only cell id varies from earlier location, so should return EAreaRegion")); |
|
369 |
|
370 //1. Move to GSM cell 234.15.1911.36000 |
|
371 err = RProperty::Set(KUidPSSimTsyCategory, KPSSimTsyTimersReduceTime, KReduceSimTsyTimers); |
|
372 User::After(KSimTsyTransitionDelay); |
|
373 |
|
374 err = DoLastKnownPosAreaL(posInfo2, matchLevel); |
|
375 if (KErrNone != err) |
|
376 { |
|
377 ERR_PRINTF2(_L("Incorrect err %d returned"), err); |
|
378 SetTestStepResult(EFail); |
|
379 } |
|
380 Validate(*posInfo, posInfo2, matchLevel, TPositionAreaInfo::EAreaRegion, ETrue, ETrue, ETrue, EFalse); |
|
381 |
289 //7. Clear Database |
382 //7. Clear Database |
290 TRequestStatus emptyStatus; |
|
291 iServer.EmptyLastKnownPositionStore(emptyStatus); |
383 iServer.EmptyLastKnownPositionStore(emptyStatus); |
292 User::WaitForRequest(emptyStatus); |
384 User::WaitForRequest(emptyStatus); |
293 break; |
385 break; |
294 } |
386 } |
295 // Test case LBS-Client-LastKnownPosArea-0004 |
387 // Test case LBS-Client-LastKnownPosArea-0004 |
517 TRequestStatus emptyStatus; |
609 TRequestStatus emptyStatus; |
518 iServer.EmptyLastKnownPositionStore(emptyStatus); |
610 iServer.EmptyLastKnownPositionStore(emptyStatus); |
519 User::WaitForRequest(emptyStatus); |
611 User::WaitForRequest(emptyStatus); |
520 break; |
612 break; |
521 } |
613 } |
|
614 |
|
615 case 9: |
|
616 { |
|
617 // Here we have both GSM and WCDMA positions in the database and we check that GetLastKnownPosArea returns the correct |
|
618 // position and match level as we switch between GSM and WCDMA cells. |
|
619 |
|
620 // Empty Database |
|
621 TRequestStatus emptyStatus; |
|
622 iServer.EmptyLastKnownPositionStore(emptyStatus); |
|
623 User::WaitForRequest(emptyStatus); |
|
624 |
|
625 TPositionInfo lastKnownPosInfo; |
|
626 TPositionAreaExtendedInfo matchLevel; |
|
627 |
|
628 //1. Get a position in the database.for a GSM cell of 234.15.1911.65535. Note that |
|
629 //this is the highest possible GSM cell id) |
|
630 INFO_PRINTF1(_L("Get a position in the database.for a GSM cell of 234.15.1911.65535")); |
|
631 TPositionInfo* gsmPosInfo = new(ELeave) TPositionInfo(); |
|
632 posInfoArr.Append(gsmPosInfo); |
|
633 err = RProperty::Set(KUidPSSimTsyCategory, KPSSimTsyTimersReduceTime, KReduceSimTsyTimers); |
|
634 User::After(KSimTsyTransitionDelay); |
|
635 if (KErrNone == err) |
|
636 { |
|
637 err = DoNotifyUpdateL(*gsmPosInfo); |
|
638 } |
|
639 if (KErrNone != err) |
|
640 { |
|
641 ERR_PRINTF2(_L("Incorrect err %d returned"), err); |
|
642 SetTestStepResult(EFail); |
|
643 } |
|
644 |
|
645 //2. Move to WCDMA cell 234.15.1913.65536 (lowest possible WCDMA cell id) and get this in the database |
|
646 TPositionInfo* wcdmaPosInfo = new(ELeave) TPositionInfo(); |
|
647 posInfoArr.Append(wcdmaPosInfo); |
|
648 INFO_PRINTF1(_L("Move to WCDMA cell 234.15.1913.65536 and get this in the database")); |
|
649 err = RProperty::Set(KUidPSSimTsyCategory, KPSSimTsyTimersReduceTime, KReduceSimTsyTimers); |
|
650 User::After(KSimTsyTransitionDelay); |
|
651 |
|
652 //2. NPUD |
|
653 if (KErrNone == err) |
|
654 { |
|
655 err = DoNotifyUpdateL(*wcdmaPosInfo); |
|
656 } |
|
657 if (KErrNone != err) |
|
658 { |
|
659 ERR_PRINTF2(_L("Incorrect err %d returned"), err); |
|
660 SetTestStepResult(EFail); |
|
661 } |
|
662 |
|
663 // Check that GetLastKnownPosArea returns the WCDMA position with area as TPositionAreaInfo::EAreaCity. |
|
664 INFO_PRINTF1(_L("check GetLastKnownPosArea returns WCDMA position - all area fields matching")); |
|
665 err = DoLastKnownPosAreaL(lastKnownPosInfo, matchLevel); |
|
666 if (KErrNone != err) |
|
667 { |
|
668 ERR_PRINTF2(_L("Incorrect err %d returned"), err); |
|
669 SetTestStepResult(EFail); |
|
670 } |
|
671 Validate(*wcdmaPosInfo, lastKnownPosInfo, matchLevel, TPositionAreaInfo::EAreaCity, ETrue, ETrue, ETrue, ETrue); |
|
672 |
|
673 |
|
674 // Move to GSM cell 234.15.1913.32121 and check GetLastKnownPosArea returns the WCDMA |
|
675 // position (as it is the most recent) with area as TPositionAreaInfo::EAreaCountry |
|
676 INFO_PRINTF1(_L("Move to GSM cell 234.15.1913.32121 and check GetLastKnownPosArea returns the WCDMA position")); |
|
677 err = RProperty::Set(KUidPSSimTsyCategory, KPSSimTsyTimersReduceTime, KReduceSimTsyTimers); |
|
678 User::After(KSimTsyTransitionDelay); |
|
679 |
|
680 if (KErrNone == err) |
|
681 { |
|
682 err = DoLastKnownPosAreaL(lastKnownPosInfo, matchLevel); |
|
683 } |
|
684 if (KErrNone != err) |
|
685 { |
|
686 ERR_PRINTF2(_L("Incorrect err %d returned"), err); |
|
687 SetTestStepResult(EFail); |
|
688 } |
|
689 Validate(*wcdmaPosInfo, lastKnownPosInfo, matchLevel, TPositionAreaInfo::EAreaCountry, ETrue, ETrue, |
|
690 EFalse, EFalse); |
|
691 |
|
692 // Move to WDCMA cell 234.15.1911.88880 and check GetLastKnownPosArea returns the WDCMA position |
|
693 // (as it is the most recent) with area as TPositionAreaInfo::EAreaCountry. |
|
694 INFO_PRINTF1(_L("Move to WDCMA cell 234.15.1911.88880 and check GetLastKnownPosArea returns the WDCMA position")); |
|
695 err = RProperty::Set(KUidPSSimTsyCategory, KPSSimTsyTimersReduceTime, KReduceSimTsyTimers); |
|
696 User::After(KSimTsyTransitionDelay); |
|
697 if (KErrNone == err) |
|
698 { |
|
699 err = DoLastKnownPosAreaL(lastKnownPosInfo, matchLevel); |
|
700 } |
|
701 if (KErrNone != err) |
|
702 { |
|
703 ERR_PRINTF2(_L("Incorrect err %d returned"), err); |
|
704 SetTestStepResult(EFail); |
|
705 } |
|
706 Validate(*wcdmaPosInfo, lastKnownPosInfo, matchLevel, TPositionAreaInfo::EAreaCountry, ETrue, ETrue, |
|
707 EFalse, EFalse); |
|
708 |
|
709 // Move to WDCMA cell 234.15.1913.76554 and check GetLastKnownPosArea returns the WDCMA position |
|
710 // (since it matches with most fields) with area as TPositionAreaInfo::EAreaRegion. |
|
711 INFO_PRINTF1(_L("Move to WDCMA cell 234.15.1913.76554 and check GetLastKnownPosArea returns the WDCMA position")); |
|
712 err = RProperty::Set(KUidPSSimTsyCategory, KPSSimTsyTimersReduceTime, KReduceSimTsyTimers); |
|
713 User::After(KSimTsyTransitionDelay); |
|
714 if (KErrNone == err) |
|
715 { |
|
716 err = DoLastKnownPosAreaL(lastKnownPosInfo, matchLevel); |
|
717 } |
|
718 if (KErrNone != err) |
|
719 { |
|
720 ERR_PRINTF2(_L("Incorrect err %d returned"), err); |
|
721 SetTestStepResult(EFail); |
|
722 } |
|
723 Validate(*wcdmaPosInfo, lastKnownPosInfo, matchLevel, TPositionAreaInfo::EAreaRegion, ETrue, ETrue, |
|
724 ETrue, EFalse); |
|
725 |
|
726 |
|
727 // Move to GSM cell 234.15.1911.19980 and check GetLastKnownPosArea returns the GSM position |
|
728 // (since it matches on most fields) with area as TPositionAreaInfo::EAreaRegion. |
|
729 INFO_PRINTF1(_L("Move to GSM cell 234.15.1911.19980 and check GetLastKnownPosArea returns the GSM position")); |
|
730 err = RProperty::Set(KUidPSSimTsyCategory, KPSSimTsyTimersReduceTime, KReduceSimTsyTimers); |
|
731 User::After(KSimTsyTransitionDelay); |
|
732 if (KErrNone == err) |
|
733 { |
|
734 err = DoLastKnownPosAreaL(lastKnownPosInfo, matchLevel); |
|
735 } |
|
736 if (KErrNone != err) |
|
737 { |
|
738 ERR_PRINTF2(_L("Incorrect err %d returned"), err); |
|
739 SetTestStepResult(EFail); |
|
740 } |
|
741 Validate(*gsmPosInfo, lastKnownPosInfo, matchLevel, TPositionAreaInfo::EAreaRegion, ETrue, ETrue, |
|
742 ETrue, EFalse); |
|
743 |
|
744 // Move to an ENetworkModeTdcdma cell 234.15.1911.66003 on a different network and check GetLastKnownPosArea |
|
745 // returns the WCDMA position (the most recent matching on 'Country') with area as TPositionAreaInfo::EAreaCountry. |
|
746 INFO_PRINTF1(_L("Move to an ENetworkModeTdcdma cell 234.15.1911.66003 on a different network")); |
|
747 err = RProperty::Set(KUidPSSimTsyCategory, KPSSimTsyTimersReduceTime, KReduceSimTsyTimers); |
|
748 User::After(KSimTsyTransitionDelay); |
|
749 if (KErrNone == err) |
|
750 { |
|
751 err = DoLastKnownPosAreaL(lastKnownPosInfo, matchLevel); |
|
752 } |
|
753 if (KErrNone != err) |
|
754 { |
|
755 ERR_PRINTF2(_L("Incorrect err %d returned"), err); |
|
756 SetTestStepResult(EFail); |
|
757 } |
|
758 Validate(*wcdmaPosInfo, lastKnownPosInfo, matchLevel, TPositionAreaInfo::EAreaCountry, ETrue, EFalse, |
|
759 EFalse, EFalse); |
|
760 |
|
761 //1. Now get a position in the database.for a GSM cell of 234.15.1911.100. |
|
762 INFO_PRINTF1(_L("Now get a position in the database.for a GSM cell of 234.15.1911.100")); |
|
763 TPositionInfo* gsmPosInfo2 = new(ELeave) TPositionInfo(); |
|
764 posInfoArr.Append(gsmPosInfo2); |
|
765 |
|
766 err = RProperty::Set(KUidPSSimTsyCategory, KPSSimTsyTimersReduceTime, KReduceSimTsyTimers); |
|
767 User::After(KSimTsyTransitionDelay); |
|
768 if (KErrNone == err) |
|
769 { |
|
770 err = DoNotifyUpdateL(*gsmPosInfo2); |
|
771 } |
|
772 if (KErrNone != err) |
|
773 { |
|
774 ERR_PRINTF2(_L("Incorrect err %d returned"), err); |
|
775 SetTestStepResult(EFail); |
|
776 } |
|
777 |
|
778 // Move to WDCMA cell 234.15.1911.88880 and check GetLastKnownPosArea returns the most recent |
|
779 // GSM position with area as TPositionAreaInfo::EAreaCountry. |
|
780 INFO_PRINTF1(_L("Move to WDCMA cell 234.15.1911.88880, check GetLastKnownPosArea returns recent GSM position")); |
|
781 err = RProperty::Set(KUidPSSimTsyCategory, KPSSimTsyTimersReduceTime, KReduceSimTsyTimers); |
|
782 User::After(KSimTsyTransitionDelay); |
|
783 if (KErrNone == err) |
|
784 { |
|
785 err = DoLastKnownPosAreaL(lastKnownPosInfo, matchLevel); |
|
786 } |
|
787 if (KErrNone != err) |
|
788 { |
|
789 ERR_PRINTF2(_L("Incorrect err %d returned"), err); |
|
790 SetTestStepResult(EFail); |
|
791 } |
|
792 Validate(*gsmPosInfo2, lastKnownPosInfo, matchLevel, TPositionAreaInfo::EAreaCountry, ETrue, ETrue, |
|
793 EFalse, EFalse); |
|
794 |
|
795 //7. Clear Database |
|
796 iServer.EmptyLastKnownPositionStore(emptyStatus); |
|
797 User::WaitForRequest(emptyStatus); |
|
798 break; |
|
799 |
|
800 } |
|
801 |
522 default: |
802 default: |
523 User::Panic(KLbsClientStepLastKnownPosArea, KErrUnknown); |
803 User::Panic(KLbsClientStepLastKnownPosArea, KErrUnknown); |
524 } |
804 } |
525 } |
805 } |
526 // All done, clean up. |
806 // All done, clean up. |