|
1 // Copyright (c) 2007-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 // This is the class implementation for the MTLR GPS Mode Tests |
|
15 // EPOC includes.sue |
|
16 // |
|
17 // |
|
18 |
|
19 // LBS includes. |
|
20 #include <lbssatellite.h> |
|
21 #include <lbs/lbsnetprotocolbase.h> |
|
22 #include <lbs/lbsassistancedatabuilderset.h> |
|
23 #include <e32math.h> |
|
24 #include <lbs/lbsloccommon.h> |
|
25 #include <lbs/lbsnetprotocolbase.h> |
|
26 #include <lbs/lbslocdatasourceclasstypes.h> |
|
27 #include <lbs/lbslocdatasourcegpsbase.h> |
|
28 #include <e32property.h> |
|
29 #include <lbserrors.h> |
|
30 #include "lbsnetinternalapi.h" |
|
31 #include "LbsInternalInterface.h" |
|
32 #include "LbsExtendModuleInfo.h" |
|
33 #include "lbsdevloggermacros.h" |
|
34 |
|
35 // LBS test includes. |
|
36 #include "ctlbsmtlrresetassistance.h" |
|
37 #include <lbs/test/tlbsutils.h> |
|
38 #include "argutils.h" |
|
39 |
|
40 #include <lbs/test/activeyield.h> |
|
41 |
|
42 const TInt KTimeOut = 60*1000*1000; |
|
43 const TInt KAdviceSystemStatusTimeout = 40*1000*1000; |
|
44 const TInt KSmallTimeOut = 3*1000*1000; |
|
45 const TInt KTimeoutWaitingForResetAssistanceData = 2 * 1000 * 1000; |
|
46 |
|
47 /** |
|
48 Static Constructor |
|
49 */ |
|
50 CT_LbsMTLRResetAssistance* CT_LbsMTLRResetAssistance::New(CT_LbsHybridMTLRServer& aParent) |
|
51 { |
|
52 // Note the lack of ELeave. |
|
53 // This means that having insufficient memory will return NULL; |
|
54 CT_LbsMTLRResetAssistance* testStep = new CT_LbsMTLRResetAssistance(aParent); |
|
55 if (testStep) |
|
56 { |
|
57 TInt err = KErrNone; |
|
58 |
|
59 TRAP(err, testStep->ConstructL()); |
|
60 if (err) |
|
61 { |
|
62 delete testStep; |
|
63 testStep = NULL; |
|
64 } |
|
65 } |
|
66 return testStep; |
|
67 } |
|
68 |
|
69 |
|
70 /** |
|
71 * Constructor |
|
72 */ |
|
73 CT_LbsMTLRResetAssistance::CT_LbsMTLRResetAssistance(CT_LbsHybridMTLRServer& aParent) |
|
74 : CT_LbsHybridMTLRStep(aParent), iProxy(NULL), |
|
75 iNetworkMethod(ENetworkMethodInvalid), |
|
76 iPlannedPositionOriginator(EPositionOriginatorUnkown), |
|
77 iNetRequestRejected(EFalse), |
|
78 iAdminGpsMode(CLbsAdmin::EGpsModeUnknown) |
|
79 { |
|
80 SetTestStepName(KLbsMTLRResetAssistance); |
|
81 iState = EInitializing; |
|
82 iSessionId.SetSessionOwner(KRequestUid); |
|
83 iSessionId.SetSessionNum(0x0005); |
|
84 } |
|
85 |
|
86 |
|
87 void CT_LbsMTLRResetAssistance::ConstructL() |
|
88 { |
|
89 // Create the base class objects. |
|
90 CT_LbsHybridMTLRStep::ConstructL(); |
|
91 iController = CLbsPrivacyController::NewL(*this); |
|
92 } |
|
93 |
|
94 /** |
|
95 * Destructor |
|
96 */ |
|
97 CT_LbsMTLRResetAssistance::~CT_LbsMTLRResetAssistance() |
|
98 { |
|
99 delete iController; |
|
100 } |
|
101 |
|
102 TVerdict CT_LbsMTLRResetAssistance::doTestStepPreambleL() |
|
103 { |
|
104 INFO_PRINTF1(_L(">>CT_LbsMTLRResetAssistance::doTestStepPreambleL()")); |
|
105 CT_LbsHybridMTLRStep::doTestStepPreambleL(); |
|
106 iNetworkExpectsMeasurements = EFalse; |
|
107 iNetworkExpectsPositions = EFalse; |
|
108 |
|
109 // Get the GPS mode set in the Admin |
|
110 CLbsAdmin* admin = CLbsAdmin::NewL(); |
|
111 CleanupStack::PushL(admin); |
|
112 |
|
113 TESTL(KErrNone == admin->Get(KLbsSettingRoamingGpsMode, iAdminGpsMode)); |
|
114 CleanupStack::PopAndDestroy(admin); |
|
115 |
|
116 // Set the network step |
|
117 iNetworkMethod = ENetworkMethodInvalid; |
|
118 |
|
119 SetTestStepResult(EPass); |
|
120 T_LbsUtils utils; |
|
121 |
|
122 // Get the Network Method |
|
123 _LIT(KNetworkMethod, "NetworkMethod"); |
|
124 TInt networkMethodInt; |
|
125 if(GetIntFromConfig(ConfigSection(), KNetworkMethod, networkMethodInt)) |
|
126 { |
|
127 iNetworkMethod = static_cast<TChosenNetworkMethod>(networkMethodInt); |
|
128 TEST(iNetworkMethod != ENetworkMethodInvalid); |
|
129 } |
|
130 else |
|
131 { |
|
132 INFO_PRINTF1(_L("CT_LbsMTLRResetAssistance::doTestStepPreambleL() - FAILED: no network method configured")); |
|
133 TEST(EFalse); |
|
134 } |
|
135 |
|
136 // Is network method supported by module? |
|
137 TPositionModuleInfoExtended::TDeviceGpsModeCapabilities deviceCapabilities; |
|
138 TInt err = LbsModuleInfo::GetDeviceCapabilities(KLbsGpsLocManagerUid, deviceCapabilities); |
|
139 if((!(deviceCapabilities & TPositionModuleInfoExtended::EDeviceGpsModeTerminalAssisted)) && (!(deviceCapabilities & TPositionModuleInfoExtended::EDeviceGpsModeSimultaneousTATB))) |
|
140 { |
|
141 if(iNetworkMethod == ETerminalAssistedNetworkMethod) |
|
142 { |
|
143 iNetRequestRejected = ETrue; |
|
144 } |
|
145 } |
|
146 if((!(deviceCapabilities & TPositionModuleInfoExtended::EDeviceGpsModeTerminalBased)) && (!(deviceCapabilities & TPositionModuleInfoExtended::EDeviceGpsModeSimultaneousTATB))) |
|
147 { |
|
148 if(iNetworkMethod == ETerminalBasedNetworkMethod) |
|
149 { |
|
150 iNetRequestRejected = ETrue; |
|
151 } |
|
152 } |
|
153 |
|
154 // Get the position originator |
|
155 _LIT(KPositionOriginator, "PositionOriginator"); |
|
156 TInt positionOriginatorInt; |
|
157 if(GetIntFromConfig(ConfigSection(), KPositionOriginator, positionOriginatorInt)) |
|
158 { |
|
159 iPlannedPositionOriginator = static_cast<TPlannedPositionOriginator>(positionOriginatorInt); |
|
160 TEST(iPlannedPositionOriginator != EPositionOriginatorUnkown); |
|
161 } |
|
162 else |
|
163 { |
|
164 INFO_PRINTF1(_L("CT_LbsMTLRResetAssistance::doTestStepPreambleL() - FAILED: no position originator configured")); |
|
165 TEST(EFalse); |
|
166 } |
|
167 |
|
168 // Get the step for sending reset |
|
169 _LIT(KStepForSendingReset, "StepForReset"); |
|
170 TInt stepForResetInt; |
|
171 if(GetIntFromConfig(ConfigSection(), KStepForSendingReset, stepForResetInt)) |
|
172 { |
|
173 iStepForSendingReset = static_cast<TNetworkStep>(stepForResetInt); |
|
174 TEST(iStepForSendingReset >= EInitial && iStepForSendingReset <= EAfterSessionClose); |
|
175 } |
|
176 else |
|
177 { |
|
178 INFO_PRINTF1(_L("CT_LbsMTLRResetAssistance::doTestStepPreambleL() - FAILED: no step for sending reset configured")); |
|
179 TEST(EFalse); |
|
180 } |
|
181 |
|
182 // Get the warm up option |
|
183 _LIT(KWarmUpModule, "WarmUpModule"); |
|
184 TInt warmUpModuleInt; |
|
185 if(GetIntFromConfig(ConfigSection(), KWarmUpModule, warmUpModuleInt)) |
|
186 { |
|
187 iWarmUpModule = warmUpModuleInt == 0 ? EFalse : ETrue; |
|
188 } |
|
189 else |
|
190 { |
|
191 iWarmUpModule = EFalse; |
|
192 } |
|
193 |
|
194 // Get the warm up option |
|
195 _LIT(KResetMark, "ResetMask"); |
|
196 TInt resetMask; |
|
197 if(!GetIntFromConfig(ConfigSection(), KResetMark, resetMask)) |
|
198 { |
|
199 resetMask = 0xFFFFFFFF; |
|
200 } |
|
201 iResetMask = resetMask; |
|
202 |
|
203 iProxy = CNetProtocolProxy::NewL(); |
|
204 return TestStepResult(); |
|
205 } |
|
206 |
|
207 TVerdict CT_LbsMTLRResetAssistance::doTestStepPostambleL() |
|
208 { |
|
209 INFO_PRINTF1(_L(">>CT_LbsMTLRResetAssistance::doTestStepPostambleL()")); |
|
210 iNetworkExpectsMeasurements = EFalse; |
|
211 iNetworkExpectsPositions = EFalse; |
|
212 iNetworkMethod = ENetworkMethodInvalid; |
|
213 iPlannedPositionOriginator = EPositionOriginatorUnkown; |
|
214 delete iProxy; |
|
215 iProxy = NULL; |
|
216 CT_LbsHybridMTLRStep::doTestStepPostambleL(); |
|
217 return TestStepResult(); |
|
218 } |
|
219 |
|
220 TVerdict CT_LbsMTLRResetAssistance::doTestStepL() |
|
221 { |
|
222 INFO_PRINTF1(_L("CT_LbsMTLRResetAssistance::doTestStepL()")); |
|
223 // Stop the test if the preamble failed |
|
224 TESTL(TestStepResult() == EPass); |
|
225 |
|
226 // >> AdviceSystemStatus(0) |
|
227 TESTL(iProxy->WaitForResponse(KAdviceSystemStatusTimeout) == ENetMsgGetCurrentCapabilitiesResponse); |
|
228 INFO_PRINTF1(_L(">> AdviceSystemStatus(ESystemStatusNone)")); |
|
229 CLbsNetworkProtocolBase::TLbsSystemStatus status; |
|
230 TInt cleanupCnt; |
|
231 cleanupCnt = iProxy->GetArgsLC(ENetMsgGetCurrentCapabilitiesResponse, &status); |
|
232 TESTL(status == CLbsNetworkProtocolBase::ESystemStatusNone); |
|
233 CleanupStack::PopAndDestroy(cleanupCnt); |
|
234 |
|
235 TBool moduleWarmedUp(EFalse); |
|
236 TBool expectExtraRequestForAssistanceData(EFalse); |
|
237 do |
|
238 { |
|
239 iState = EInitializing; |
|
240 if(moduleWarmedUp) |
|
241 { |
|
242 iWarmUpModule = EFalse; |
|
243 } |
|
244 |
|
245 if(!iWarmUpModule && iStepForSendingReset == EBeforeSession) |
|
246 { |
|
247 SendResetAssistanceDataL(); |
|
248 } |
|
249 |
|
250 // Initiate MTLR Start |
|
251 // << ProcessStatusUpdate() |
|
252 MLbsNetworkProtocolObserver::TLbsNetProtocolServiceMask activeServiceMask = MLbsNetworkProtocolObserver::EServiceMobileTerminated; |
|
253 INFO_PRINTF1(_L("<< ProcessStatusUpdate(EServiceMobileTerminated)")); |
|
254 iProxy->CallL(ENetMsgProcessStatusUpdate, &activeServiceMask); |
|
255 |
|
256 // << ProcessPrivacyRequest() |
|
257 const TBool emergency = EFalse; // lrm - why is this true in hybrid mtlr testing!? |
|
258 TLbsNetPosRequestPrivacy privacy = ArgUtils::Privacy(); // notify allow |
|
259 TLbsExternalRequestInfo requestInfo = ArgUtils::RequestInfo(); |
|
260 INFO_PRINTF1(_L("<< ProcessPrivacyRequest()")); |
|
261 iProxy->CallL(ENetMsgProcessPrivacyRequest, &iSessionId, &emergency, &privacy, &requestInfo); |
|
262 |
|
263 // >> ProcessNetworkLocationRequest() callback |
|
264 CheckForObserverEventTestsL(KTimeOut, *this); |
|
265 |
|
266 // >> Respond Privacy Request |
|
267 TESTL(iProxy->WaitForResponse(KTimeOut) == ENetMsgRespondPrivacyRequest); |
|
268 INFO_PRINTF1(_L(">> RespondPrivacyRequest(EPrivacyResponseAccepted)")); |
|
269 TLbsNetSessionId* getSessionId = NULL; |
|
270 CLbsNetworkProtocolBase::TLbsPrivacyResponse getPrivacy; |
|
271 cleanupCnt = iProxy->GetArgsLC(ENetMsgRespondPrivacyRequest, &getSessionId, &getPrivacy); |
|
272 TESTL(getSessionId->SessionNum()==iSessionId.SessionNum()); |
|
273 TESTL(getPrivacy==CLbsNetworkProtocolBase::EPrivacyResponseAccepted); |
|
274 CleanupStack::PopAndDestroy(cleanupCnt);//getSessionId |
|
275 |
|
276 if(!iWarmUpModule && iStepForSendingReset == EBeginningOfSession) |
|
277 { |
|
278 SendResetAssistanceDataL(); |
|
279 } |
|
280 |
|
281 // MTLR Reference Position Notification Start |
|
282 // << ProcessLocationUpdate() |
|
283 TPositionInfo positionInfo = ArgUtils::ReferencePositionInfo(); |
|
284 INFO_PRINTF1(_L("<< ProcessLocationUpdate(ref pos)")); |
|
285 iProxy->CallL(ENetMsgProcessLocationUpdate, &iSessionId, &positionInfo); |
|
286 // MTLR Reference Position Notification Stop |
|
287 TInt reason = KErrNone; |
|
288 |
|
289 if(iNetworkMethod != EAutonomousNetworkMethod || iWarmUpModule) |
|
290 { |
|
291 // MTLR Assistance Data Notification Start |
|
292 // << ProcessAssistanceData() |
|
293 TLbsAsistanceDataGroup dataRequestMask = EAssistanceDataReferenceTime; |
|
294 RLbsAssistanceDataBuilderSet assistanceData; |
|
295 ArgUtils::PopulateLC(assistanceData); |
|
296 reason = KErrNone; |
|
297 INFO_PRINTF1(_L("<< ProcessAssistanceData(EAssistanceDataReferenceTime)")); |
|
298 iProxy->CallL(ENetMsgProcessAssistanceData, &dataRequestMask, &assistanceData, &reason); |
|
299 CleanupStack::PopAndDestroy(); //assistanceData |
|
300 // MTLR Assistance Data Notification Stop |
|
301 |
|
302 if(!iWarmUpModule && iStepForSendingReset == EAfterAssistanceData) |
|
303 { |
|
304 expectExtraRequestForAssistanceData = SendResetAssistanceDataL(); |
|
305 } |
|
306 } |
|
307 |
|
308 // MTLR Network Location Request Start |
|
309 // << ProcessLocationRequest() |
|
310 MLbsNetworkProtocolObserver::TLbsNetProtocolService service = MLbsNetworkProtocolObserver::EServiceMobileTerminated; |
|
311 TLbsNetPosRequestQuality quality = ArgUtils::QualityAlpha2(); |
|
312 TLbsNetPosRequestMethod method = RequestNetworkMethod(iWarmUpModule); |
|
313 INFO_PRINTF1(_L("<< ProcessLocationRequest(timeout = alpha2)")); |
|
314 iProxy->CallL(ENetMsgProcessLocationRequest, &iSessionId, &emergency, &service, &quality, &method); |
|
315 // MTLR Network Location Request Stop |
|
316 // Initiate MTLR End |
|
317 |
|
318 //Start the timer |
|
319 TTime timerStart; |
|
320 timerStart.HomeTime(); |
|
321 |
|
322 // >> ProcessNetworkPositionUpdate(refPosition) callback |
|
323 CheckForObserverEventTestsL(KSmallTimeOut, *this); |
|
324 |
|
325 if(!iNetRequestRejected) |
|
326 { |
|
327 // >> RequestAssistanceData() |
|
328 TESTL(iProxy->WaitForResponse(KSmallTimeOut) == ENetMsgRequestAssistanceData); |
|
329 TLbsAsistanceDataGroup dataGroup; |
|
330 cleanupCnt = iProxy->GetArgsLC(ENetMsgRequestAssistanceData, &dataGroup); |
|
331 if(!expectExtraRequestForAssistanceData || (iNetworkMethod == EAutonomousNetworkMethod && !iWarmUpModule)) |
|
332 { |
|
333 INFO_PRINTF1(_L(">> RequestAssistanceData(0)")); |
|
334 TESTL(dataGroup == EAssistanceDataNone); |
|
335 } |
|
336 else |
|
337 { |
|
338 expectExtraRequestForAssistanceData = EFalse; |
|
339 INFO_PRINTF1(_L(">> RequestAssistanceData(EAssistanceDataReferenceTime)")); |
|
340 TESTL(dataGroup == EAssistanceDataReferenceTime); |
|
341 // << ProcessAssistanceData(EAssistanceDataReferenceTime) |
|
342 TLbsAsistanceDataGroup dataRequestMask = EAssistanceDataReferenceTime; |
|
343 RLbsAssistanceDataBuilderSet assistanceData; |
|
344 ArgUtils::PopulateLC(assistanceData); |
|
345 reason = KErrNone; |
|
346 INFO_PRINTF1(_L("<< ProcessAssistanceData(EAssistanceDataReferenceTime)")); |
|
347 iProxy->CallL(ENetMsgProcessAssistanceData, &dataRequestMask, &assistanceData, &reason); |
|
348 CleanupStack::PopAndDestroy(&assistanceData); |
|
349 } |
|
350 CleanupStack::PopAndDestroy(cleanupCnt); |
|
351 } |
|
352 |
|
353 DecideWhatNetworkReceives(); // lrm - hit this line before request from network has been processed!? |
|
354 |
|
355 /*** NRH's Alpha2 timer expires; should get a response now ***/ |
|
356 //Find the time elapsed from timer |
|
357 TTimeIntervalMicroSeconds microseconds; |
|
358 TTime timerStop; |
|
359 timerStop.HomeTime(); |
|
360 microseconds = timerStop.MicroSecondsFrom(timerStart); |
|
361 TInt64 timeElapsed = microseconds.Int64(); |
|
362 TInt delta = 1000*1000; // 1s |
|
363 |
|
364 getSessionId = NULL; |
|
365 TInt getReason = KErrNone; |
|
366 TPositionSatelliteInfo* getPositionInfo = NULL; |
|
367 TPositionGpsMeasurementInfo* getMeasurementInfo = NULL; |
|
368 // >> RespondLocationRequest() |
|
369 if(iNetRequestRejected) // network has asked for an unsupported gps mode |
|
370 {// we may get an error response _before_ alpha2 timer expires |
|
371 TESTL(iProxy->WaitForResponse(KAlpha2Timeout-timeElapsed+delta) == ENetMsgRespondLocationRequest); |
|
372 cleanupCnt = iProxy->GetArgsLC(ENetMsgRespondLocationRequest, &getSessionId, &getReason, &getPositionInfo); |
|
373 INFO_PRINTF2(_L(">> RespondLocationRequest(%d)"), getReason); |
|
374 TEST(getReason==KErrNotSupported); |
|
375 CleanupStack::PopAndDestroy(cleanupCnt); |
|
376 } |
|
377 else |
|
378 { |
|
379 // The measurements: |
|
380 if(iNetworkExpectsMeasurements) // If network expecting measurements, they will come first |
|
381 { |
|
382 // >> RespondLocationRequest(meas) |
|
383 //Test that we do not get response before alpha2 has expired |
|
384 TESTL(iProxy->WaitForResponse(KAlpha2Timeout-timeElapsed-delta) == ENetMsgTimeoutExpired); |
|
385 INFO_PRINTF1(_L(" No RespondLocationRequest before Alpha2 timer expired")); |
|
386 TESTL(iProxy->WaitForResponse(2*delta) == ENetMsgRespondLocationRequest); |
|
387 INFO_PRINTF1(_L(">> RespondLocationRequest(meas)")); |
|
388 getSessionId = NULL; |
|
389 TInt getReason = KErrNone; |
|
390 cleanupCnt = iProxy->GetArgsLC(ENetMsgRespondLocationRequest, &getSessionId, &getReason, &getMeasurementInfo); |
|
391 TESTL(getSessionId->SessionNum() == iSessionId.SessionNum()); |
|
392 TESTL(getReason==KErrNone); |
|
393 CleanupStack::PopAndDestroy(cleanupCnt); |
|
394 |
|
395 if(!iWarmUpModule && iStepForSendingReset == EAfterMeasurements) |
|
396 { |
|
397 expectExtraRequestForAssistanceData = SendResetAssistanceDataL(); |
|
398 } |
|
399 |
|
400 // Make another request from the network |
|
401 //<< ProcessLocationRequest() |
|
402 quality = ArgUtils::Quality(); //Set timeout to t |
|
403 INFO_PRINTF1(_L("<< ProcessLocationRequest(timeout = t)")); |
|
404 iProxy->CallL(ENetMsgProcessLocationRequest, &iSessionId, &emergency, &service, &quality, &method); |
|
405 |
|
406 TESTL(iProxy->WaitForResponse(KSmallTimeOut) == ENetMsgRequestAssistanceData); |
|
407 TLbsAsistanceDataGroup dataGroup; |
|
408 cleanupCnt = iProxy->GetArgsLC(ENetMsgRequestAssistanceData, &dataGroup); |
|
409 if(!expectExtraRequestForAssistanceData) |
|
410 { |
|
411 INFO_PRINTF1(_L(">> RequestAssistanceData(0)")); |
|
412 TESTL(dataGroup == EAssistanceDataNone); |
|
413 } |
|
414 else |
|
415 { |
|
416 expectExtraRequestForAssistanceData = EFalse; |
|
417 INFO_PRINTF1(_L(">> RequestAssistanceData(EAssistanceDataReferenceTime)")); |
|
418 TESTL(dataGroup == EAssistanceDataReferenceTime); |
|
419 // << ProcessAssistanceData(EAssistanceDataReferenceTime) |
|
420 TLbsAsistanceDataGroup dataRequestMask = EAssistanceDataReferenceTime; |
|
421 RLbsAssistanceDataBuilderSet assistanceData; |
|
422 ArgUtils::PopulateLC(assistanceData); |
|
423 reason = KErrNone; |
|
424 INFO_PRINTF1(_L("<< ProcessAssistanceData(EAssistanceDataReferenceTime)")); |
|
425 iProxy->CallL(ENetMsgProcessAssistanceData, &dataRequestMask, &assistanceData, &reason); |
|
426 CleanupStack::PopAndDestroy(&assistanceData); |
|
427 } |
|
428 CleanupStack::PopAndDestroy(cleanupCnt); |
|
429 } |
|
430 // The final position: |
|
431 if(iPlannedPositionOriginator == EPositionOriginatorModule) |
|
432 { |
|
433 // The module should return the position |
|
434 INFO_PRINTF1(_L(" Network expecting position")); |
|
435 // >> RespondLocationRequest() position. |
|
436 TESTL(iProxy->WaitForResponse(KTTimeout + delta) == ENetMsgRespondLocationRequest); |
|
437 INFO_PRINTF1(_L(">> RespondLocationRequest(gpspos)")); |
|
438 getPositionInfo = NULL; |
|
439 getSessionId = NULL; |
|
440 getReason = KErrNone; |
|
441 cleanupCnt = iProxy->GetArgsLC(ENetMsgRespondLocationRequest, &getSessionId, &getReason, &getPositionInfo); |
|
442 // check it is a position |
|
443 TESTL(getPositionInfo->PositionClassType() == (EPositionInfoClass|EPositionCourseInfoClass|EPositionSatelliteInfoClass|EPositionExtendedSatelliteInfoClass)); |
|
444 TESTL(getSessionId->SessionNum() == iSessionId.SessionNum()); |
|
445 TESTL(getReason == KErrNone); |
|
446 TESTL(getPositionInfo->PositionMode() == TPositionModuleInfo::ETechnologyTerminal | TPositionModuleInfo::ETechnologyAssisted); |
|
447 // Test position is the same as in the ini file data fed to the GPS module ($update,1,0,49.2,3.5,50,20,20*) |
|
448 TPosition gpsPos; |
|
449 getPositionInfo->GetPosition(gpsPos); |
|
450 TESTL(gpsPos.Latitude()==49.2 && gpsPos.Longitude()==3.5 && gpsPos.Altitude()==50 && gpsPos.HorizontalAccuracy()==20 && gpsPos.VerticalAccuracy()==20); |
|
451 CleanupStack::PopAndDestroy(cleanupCnt); |
|
452 |
|
453 if(!iWarmUpModule && iStepForSendingReset == EAfterPosition) |
|
454 { |
|
455 SendResetAssistanceDataL(); |
|
456 } |
|
457 |
|
458 //<< ProcessNetworkPositionUpdate(GPS Pos) Callback |
|
459 CheckForObserverEventTestsL(KTimeOut, *this); |
|
460 TESTL(iState==EGpsLocReceived); |
|
461 } |
|
462 else // position supplied by network |
|
463 { |
|
464 __ASSERT_DEBUG(iPlannedPositionOriginator == EPositionOriginatorNetwork, User::Invariant()); |
|
465 // privacy app doesn't see network-calculated position, so nothing much happens in this case |
|
466 } |
|
467 |
|
468 } |
|
469 |
|
470 // MTLR Session Completion Start |
|
471 // << ProcessSessionComplete() |
|
472 if(iNetRequestRejected) |
|
473 { |
|
474 reason = KErrNotSupported; |
|
475 } |
|
476 else |
|
477 { |
|
478 reason = KErrNone; |
|
479 } |
|
480 INFO_PRINTF1(_L("<< ProcessSessionComplete()")); |
|
481 iProxy->CallL(ENetMsgProcessSessionComplete, &iSessionId, &reason); |
|
482 |
|
483 if(!iWarmUpModule && iStepForSendingReset == EAfterSessionClose) |
|
484 { |
|
485 SendResetAssistanceDataL(); |
|
486 } |
|
487 |
|
488 // << ProcessStatusUpdate() |
|
489 MLbsNetworkProtocolObserver::TLbsNetProtocolServiceMask activeServiceMask2 = MLbsNetworkProtocolObserver::EServiceNone; |
|
490 INFO_PRINTF1(_L("<< ProcessStatusUpdate(EServiceNone)")); |
|
491 iProxy->CallL(ENetMsgProcessStatusUpdate, &activeServiceMask2); |
|
492 |
|
493 // >> ProcessRequestComplete() callback |
|
494 CheckForObserverEventTestsL(KTimeOut, *this); |
|
495 |
|
496 // Verify that the last callback was to ProcessSessionComplete() |
|
497 TESTL(iState==ERequestComplete); |
|
498 moduleWarmedUp = ETrue; |
|
499 } while(iWarmUpModule); |
|
500 // MTLR Session Completion Stop |
|
501 |
|
502 return TestStepResult(); |
|
503 } |
|
504 |
|
505 |
|
506 TLbsNetPosRequestMethod CT_LbsMTLRResetAssistance::RequestNetworkMethod(TBool aWarmUp) |
|
507 /** |
|
508 This method will chose the appropiate method requested by the network, depending |
|
509 on the test settings |
|
510 |
|
511 @return The network method |
|
512 */ |
|
513 { |
|
514 TLbsNetPosRequestMethod method; |
|
515 if(aWarmUp) |
|
516 { // warm up in TB |
|
517 iNetworkExpectsPositions = ETrue; |
|
518 method = ArgUtils::RequestTerminalBasedMethod(); |
|
519 return method; |
|
520 } |
|
521 |
|
522 switch(iNetworkMethod) |
|
523 { |
|
524 case ETerminalBasedNetworkMethod: |
|
525 { |
|
526 iNetworkExpectsPositions = ETrue; |
|
527 method = ArgUtils::RequestTerminalBasedMethod(); |
|
528 break; |
|
529 } |
|
530 case ETerminalBasedTerminalAssistedNetworkMethod: |
|
531 { |
|
532 iNetworkExpectsMeasurements = ETrue; |
|
533 iNetworkExpectsPositions = ETrue; |
|
534 method = ArgUtils::RequestHybridMethod(); |
|
535 break; |
|
536 } |
|
537 case ETerminalAssistedNetworkMethod: |
|
538 { |
|
539 iNetworkExpectsMeasurements = ETrue; |
|
540 method = ArgUtils::RequestTAPMethod(); |
|
541 break; |
|
542 } |
|
543 case ETerminalAssistedTerminalBasedNetworkMethod: |
|
544 { |
|
545 iNetworkExpectsMeasurements = ETrue; |
|
546 iNetworkExpectsPositions = ETrue; |
|
547 method = ArgUtils::RequestTerminalAssistedAndTerminalBasedMethod(); |
|
548 break; |
|
549 } |
|
550 case EAutonomousNetworkMethod: |
|
551 { |
|
552 iNetworkExpectsPositions = ETrue; |
|
553 method = ArgUtils::RequestAutonomousMethod(); |
|
554 break; |
|
555 } |
|
556 case ENetworkMethodNotSet: |
|
557 { |
|
558 //we should set mode according to default admin |
|
559 TEST(iAdminGpsMode != CLbsAdmin::EGpsModeUnknown); |
|
560 switch(iAdminGpsMode) |
|
561 { |
|
562 case CLbsAdmin::EGpsPreferTerminalBased: |
|
563 { |
|
564 iNetworkExpectsPositions = ETrue; |
|
565 break; |
|
566 } |
|
567 case CLbsAdmin::EGpsPreferTerminalAssisted: |
|
568 case CLbsAdmin::EGpsAlwaysTerminalAssisted: |
|
569 { |
|
570 iNetworkExpectsMeasurements = ETrue; |
|
571 break; |
|
572 } |
|
573 case CLbsAdmin::EGpsAutonomous: // test framework doesn't currently support this |
|
574 default: |
|
575 { |
|
576 User::Invariant(); |
|
577 } |
|
578 } |
|
579 |
|
580 method = ArgUtils::RequestUnspecifiedMethod(); |
|
581 break; |
|
582 } |
|
583 default: |
|
584 { |
|
585 method = ArgUtils::RequestHybridMethod(); |
|
586 User::Invariant(); |
|
587 } |
|
588 } |
|
589 |
|
590 return method; |
|
591 } |
|
592 |
|
593 |
|
594 void CT_LbsMTLRResetAssistance::DecideWhatNetworkReceives() |
|
595 /** |
|
596 This method checks what the module was finally set to and decides if the network |
|
597 should expect measuments, or positions |
|
598 */ |
|
599 { |
|
600 TLbsGpsOptionsArray options; |
|
601 TPckg<TLbsGpsOptionsArray> pckgOptions(options); |
|
602 TEST(KErrNone == RProperty::Get(KUidSystemCategory, ELbsTestAGpsModuleModeChanges, pckgOptions)); |
|
603 |
|
604 if(options.ClassType() & ELbsGpsOptionsArrayClass) |
|
605 { |
|
606 if(options.NumOptionItems() > 1) |
|
607 { |
|
608 // don't change anything (from what was set in RequestNetworkMethod()), the module is running in hybrid |
|
609 return; |
|
610 } |
|
611 } |
|
612 switch(options.GpsMode()) |
|
613 { |
|
614 case CLbsAdmin::EGpsAutonomous: |
|
615 { |
|
616 INFO_PRINTF1(_L(" Module was asked to use Autonomous mode")); |
|
617 iNetworkExpectsPositions = EFalse; |
|
618 iNetworkExpectsMeasurements = EFalse; |
|
619 break; |
|
620 } |
|
621 case CLbsAdmin::EGpsPreferTerminalBased: |
|
622 case CLbsAdmin::EGpsAlwaysTerminalBased: |
|
623 { |
|
624 INFO_PRINTF1(_L(" Module was asked to use Terminal Based mode")); |
|
625 iNetworkExpectsMeasurements = EFalse; |
|
626 break; |
|
627 } |
|
628 case CLbsAdmin::EGpsPreferTerminalAssisted: |
|
629 case CLbsAdmin::EGpsAlwaysTerminalAssisted: |
|
630 { |
|
631 INFO_PRINTF1(_L(" Module was asked to use Terminal Assisted mode")); |
|
632 iNetworkExpectsPositions = EFalse; |
|
633 break; |
|
634 } |
|
635 default: |
|
636 { |
|
637 // change nothing |
|
638 } |
|
639 return; |
|
640 } |
|
641 } |
|
642 |
|
643 void CT_LbsMTLRResetAssistance::ProcessNetworkLocationRequest(TUint aRequestId, const TLbsExternalRequestInfo& /*aRequestInfo*/, const TNotificationType& /*aNotificationType*/) |
|
644 { |
|
645 TEST(iState==EInitializing); |
|
646 INFO_PRINTF1(_L(">> ProcessNetworkLocationRequest()")); |
|
647 iController->RespondNetworkLocationRequest(aRequestId, CLbsPrivacyController::ERequestAccepted); |
|
648 iState = EPrivacyCheckOk; |
|
649 ReturnToTestStep(); |
|
650 } |
|
651 |
|
652 void CT_LbsMTLRResetAssistance::ProcessNetworkPositionUpdate(TUint /*aRequestId*/, const TPositionInfo& aPosInfo) |
|
653 { |
|
654 if(iState==EPrivacyCheckOk) // waiting for ref pos |
|
655 { |
|
656 iState=ERefLocReceived; |
|
657 INFO_PRINTF1(_L(">> Privacy App - ProcessNetworkPositionUpdate(Ref pos)")); |
|
658 } |
|
659 else if(iState==ERefLocReceived) // waiting for gps pos |
|
660 { |
|
661 TPosition getPos; |
|
662 aPosInfo.GetPosition(getPos); |
|
663 TESTL(aPosInfo.PositionModeReason() == EPositionModeReasonNone); |
|
664 // Verify we got what network sent: |
|
665 if(iPlannedPositionOriginator == EPositionOriginatorModule) |
|
666 { |
|
667 TESTL(aPosInfo.PositionMode() == TPositionModuleInfo::ETechnologyTerminal | TPositionModuleInfo::ETechnologyAssisted); |
|
668 // compare to gps pos in test ini ($update,1,0,49.2,3.5,50,20,20*) : |
|
669 TESTL(getPos.Latitude()==49.2 && getPos.Longitude()==3.5 && getPos.Altitude()==50 && getPos.HorizontalAccuracy()==20 && getPos.VerticalAccuracy()==20); |
|
670 } |
|
671 else |
|
672 {// compare to gps pos supplied by network: |
|
673 TPositionInfo positionInfo = ArgUtils::AccurateNetworkPositionInfo(); |
|
674 TPosition getFNP; |
|
675 positionInfo.GetPosition(getFNP); |
|
676 TESTL(aPosInfo.PositionMode() == TPositionModuleInfo::ETechnologyNetwork | TPositionModuleInfo::ETechnologyAssisted); |
|
677 TESTL(getPos.Latitude()==getFNP.Latitude() && getPos.Longitude()==getFNP.Longitude() && getPos.Altitude()==getFNP.Altitude() && getPos.HorizontalAccuracy()==getFNP.HorizontalAccuracy() && getPos.VerticalAccuracy()==getFNP.VerticalAccuracy()); |
|
678 } |
|
679 |
|
680 INFO_PRINTF1(_L(">> Privacy App - ProcessNetworkPositionUpdate(Gps pos)")); |
|
681 iState=EGpsLocReceived; |
|
682 } |
|
683 ReturnToTestStep(); |
|
684 } |
|
685 |
|
686 void CT_LbsMTLRResetAssistance::ProcessRequestComplete(TUint /*aRequestId*/, TInt aReason) |
|
687 { |
|
688 INFO_PRINTF2(_L(">> Privacy App - ProcessRequestComplete(%d)"), aReason); |
|
689 if(!iNetRequestRejected && (iPlannedPositionOriginator == EPositionOriginatorModule)) |
|
690 { |
|
691 TEST(iState==EGpsLocReceived); |
|
692 } |
|
693 if(iNetRequestRejected) |
|
694 { |
|
695 TEST(aReason == KErrNotSupported); |
|
696 } |
|
697 else |
|
698 { |
|
699 TEST(aReason == KErrNone); |
|
700 } |
|
701 iState=ERequestComplete; |
|
702 ReturnToTestStep(); |
|
703 } |
|
704 |
|
705 TBool CT_LbsMTLRResetAssistance::SendResetAssistanceDataL() |
|
706 { |
|
707 // First make sure that no reset of assistance data has been received by the GPS module |
|
708 RProperty resetAssistanceDataReceivedProperty; |
|
709 User::LeaveIfError(resetAssistanceDataReceivedProperty.Attach(KUidSystemCategory, ELbsTestAGpsModuleResetAssistanceDataFlag)); |
|
710 TInt resetReceivedStatus; |
|
711 TInt err = resetAssistanceDataReceivedProperty.Get(resetReceivedStatus); |
|
712 TESTL(err == KErrNone || err == KErrNotFound); |
|
713 if(err == KErrNone) |
|
714 { |
|
715 TESTL(resetReceivedStatus == ELbsTestAGpsResetAssistanceDataNotReceived); |
|
716 } |
|
717 |
|
718 // << ProcessAssistanceData(KPositionAssistanceDataReset) |
|
719 RLbsAssistanceDataBuilderSet assistanceData; |
|
720 CleanupClosePushL(assistanceData); |
|
721 assistanceData.OpenL(); |
|
722 TInt reason = KPositionAssistanceDataReset; |
|
723 INFO_PRINTF1(_L("<< ProcessAssistanceData(KPositionAssistanceDataReset)")); |
|
724 iProxy->CallL(ENetMsgProcessAssistanceData, &iResetMask, &assistanceData, &reason); |
|
725 CleanupStack::PopAndDestroy(&assistanceData); |
|
726 |
|
727 // Now check the the module receives and verifies the ResetAssistanceData |
|
728 err = resetAssistanceDataReceivedProperty.Get(resetReceivedStatus); |
|
729 TESTL(err == KErrNone || err == KErrNotFound); |
|
730 if(err == KErrNotFound || resetReceivedStatus != ELbsTestAGpsResetAssistanceDataReceived) |
|
731 { |
|
732 RTimer timeout; |
|
733 timeout.CreateLocal(); |
|
734 CleanupClosePushL(timeout); |
|
735 |
|
736 TRequestStatus statTime = KRequestPending, |
|
737 statProp = KRequestPending; |
|
738 timeout.After(statTime, KTimeoutWaitingForResetAssistanceData); |
|
739 resetAssistanceDataReceivedProperty.Subscribe(statProp); |
|
740 User::WaitForRequest(statProp, statTime); |
|
741 |
|
742 if(KRequestPending == statProp.Int()) |
|
743 { |
|
744 resetAssistanceDataReceivedProperty.Cancel(); |
|
745 err = KErrTimedOut; |
|
746 } |
|
747 else |
|
748 { |
|
749 err = KErrNone; |
|
750 timeout.Cancel(); |
|
751 } |
|
752 |
|
753 User::WaitForRequest(statProp, statTime); // Coz the one that didn't signal earlier has |
|
754 // just been completed with KErrCancel, and |
|
755 // we want to avoid the otherwise inevitable |
|
756 // stray signal in any (nested) schedulers. |
|
757 if(err == KErrNone) |
|
758 { |
|
759 err = resetAssistanceDataReceivedProperty.Get(resetReceivedStatus); |
|
760 } |
|
761 CleanupStack::PopAndDestroy(&timeout); |
|
762 TESTL(err == KErrNone && resetReceivedStatus == ELbsTestAGpsResetAssistanceDataReceived); |
|
763 } |
|
764 // Reset the status on the property |
|
765 err = resetAssistanceDataReceivedProperty.Set(ELbsTestAGpsResetAssistanceDataNotReceived); |
|
766 TESTL(err == KErrNone); |
|
767 if((iResetMask & EAssistanceDataReferenceTime) != 0) |
|
768 { |
|
769 return ETrue; |
|
770 } |
|
771 else |
|
772 { |
|
773 return EFalse; |
|
774 } |
|
775 } |