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