|
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 Hybrid MoLr Tests |
|
15 // |
|
16 // |
|
17 |
|
18 |
|
19 // EPOC includes. |
|
20 #include <e32math.h> |
|
21 |
|
22 // LBS includes. |
|
23 #include <lbssatellite.h> |
|
24 #include <lbs/lbsgpsmeasurement.h> |
|
25 #include <lbs/lbsnetprotocolbase.h> |
|
26 #include <lbs/lbsassistancedatabuilderset.h> |
|
27 #include <lbs/lbsloccommon.h> |
|
28 #include <lbs/lbsx3p.h> |
|
29 #include <lbs/lbsnetprotocolbase.h> |
|
30 |
|
31 // LBS test includes. |
|
32 #include "ctlbsuebasedmolrself.h" |
|
33 #include "ctlbsueassistedmolrselfgpslate.h" |
|
34 #include <lbs/test/tlbsutils.h> |
|
35 #include "argutils.h" |
|
36 #include <lbs/test/activeyield.h> |
|
37 |
|
38 |
|
39 /** |
|
40 Static Constructor |
|
41 */ |
|
42 CT_LbsUEAssistedMOLRSelfGPSLate* CT_LbsUEAssistedMOLRSelfGPSLate::New(CT_LbsHybridMOLRServer& aParent) |
|
43 { |
|
44 // Note the lack of ELeave. |
|
45 // This means that having insufficient memory will return NULL; |
|
46 CT_LbsUEAssistedMOLRSelfGPSLate* testStep = new CT_LbsUEAssistedMOLRSelfGPSLate(aParent); |
|
47 if (testStep) |
|
48 { |
|
49 TInt err = KErrNone; |
|
50 |
|
51 TRAP(err, testStep->ConstructL()); |
|
52 if (err) |
|
53 { |
|
54 delete testStep; |
|
55 testStep = NULL; |
|
56 } |
|
57 } |
|
58 return testStep; |
|
59 } |
|
60 |
|
61 |
|
62 /** |
|
63 * Constructor |
|
64 */ |
|
65 CT_LbsUEAssistedMOLRSelfGPSLate::CT_LbsUEAssistedMOLRSelfGPSLate(CT_LbsHybridMOLRServer& aParent) : CT_LbsHybridMOLRStep(aParent) |
|
66 { |
|
67 SetTestStepName(KLbsUEAssistedMOLRSelfGPSLate); |
|
68 |
|
69 iSessionId.SetSessionOwner(KRequestUid); |
|
70 iSessionId.SetSessionNum(0x0001); |
|
71 |
|
72 // iPositionUpdateRef = EFalse; |
|
73 } |
|
74 |
|
75 |
|
76 void CT_LbsUEAssistedMOLRSelfGPSLate::ConstructL() |
|
77 { |
|
78 // Create the base class objects. |
|
79 CT_LbsHybridMOLRStep::ConstructL(); |
|
80 } |
|
81 |
|
82 /** |
|
83 * Destructor |
|
84 */ |
|
85 CT_LbsUEAssistedMOLRSelfGPSLate::~CT_LbsUEAssistedMOLRSelfGPSLate() |
|
86 { |
|
87 } |
|
88 |
|
89 |
|
90 TVerdict CT_LbsUEAssistedMOLRSelfGPSLate::doTestStepL() |
|
91 { |
|
92 INFO_PRINTF1(_L("CT_LbsUEAssistedMOLRSelfGPSLate::doTestStepL()")); |
|
93 // Stop the test if the preable failed |
|
94 TESTL(TestStepResult() == EPass); |
|
95 |
|
96 const TInt KTimeOut = 60*1000*1000; |
|
97 |
|
98 // Create Network Protocol Proxy |
|
99 CNetProtocolProxy* proxy = CNetProtocolProxy::NewL(); |
|
100 CleanupStack::PushL(proxy); |
|
101 |
|
102 // Recv --> GetCurrentCapabilitiesResponse. |
|
103 // Soak up the Lbs System Status (produced by A-GPS Manager startup). |
|
104 TESTL(proxy->WaitForResponse(KTimeOut) == ENetMsgGetCurrentCapabilitiesResponse); |
|
105 CLbsNetworkProtocolBase::TLbsSystemStatus status; |
|
106 TInt cleanupCnt; |
|
107 cleanupCnt = proxy->GetArgsLC(ENetMsgGetCurrentCapabilitiesResponse, &status); |
|
108 TESTL(status == CLbsNetworkProtocolBase::ESystemStatusNone); |
|
109 CleanupStack::PopAndDestroy(cleanupCnt); |
|
110 |
|
111 |
|
112 // Do the /actual/ test step! |
|
113 |
|
114 // Setup location session and position watcher. |
|
115 RPositionServer server; |
|
116 TESTL(KErrNone == server.Connect()); |
|
117 CleanupClosePushL(server); |
|
118 |
|
119 RPositioner pos; |
|
120 TESTL(KErrNone == pos.Open(server)); |
|
121 CleanupClosePushL(pos); |
|
122 |
|
123 // Set the max fix time for the client request to ensure the location server does not complete the request too soon during the test. |
|
124 TPositionUpdateOptions posOpts(TTimeIntervalMicroSeconds(0), TTimeIntervalMicroSeconds(KMOLRFixTime)); |
|
125 pos.SetUpdateOptions(posOpts); |
|
126 |
|
127 CPosServerWatcher *pWatch = CPosServerWatcher::NewLC(pos, *this); |
|
128 |
|
129 |
|
130 // Client Send - a self-locate request. |
|
131 pWatch->IssueNotifyPositionUpdate(); |
|
132 |
|
133 |
|
134 // Recv --> RequestSelfLocation. |
|
135 TESTL(proxy->WaitForResponse(KTimeOut) == ENetMsgRequestSelfLocation); |
|
136 |
|
137 // Process the response. |
|
138 TLbsNetSessionId* sessionId = NULL; |
|
139 TLbsNetPosRequestOptionsAssistance* opts = NULL; |
|
140 |
|
141 cleanupCnt = proxy->GetArgsLC(ENetMsgRequestSelfLocation, &sessionId, &opts); |
|
142 |
|
143 TBool qualitycheck = ArgUtils::CompareQuality( opts, |
|
144 ETrue, |
|
145 KMinHorizontalAcc, |
|
146 KMinVerticalAcc, |
|
147 KMOLRFixTime, |
|
148 0, |
|
149 EAssistanceDataReferenceTime, |
|
150 (TPositionModuleInfo::ETechnologyTerminal |
|
151 | TPositionModuleInfo::ETechnologyAssisted) |
|
152 ); |
|
153 |
|
154 TESTL(qualitycheck); |
|
155 |
|
156 iSessionId.SetSessionNum(sessionId->SessionNum()); |
|
157 iSessionId.SetSessionOwner(sessionId->SessionOwner()); |
|
158 |
|
159 CleanupStack::PopAndDestroy(cleanupCnt); |
|
160 sessionId = NULL; |
|
161 opts = NULL; |
|
162 |
|
163 |
|
164 // Send <-- ProcessStatusUpdate. |
|
165 MLbsNetworkProtocolObserver::TLbsNetProtocolService serviceMask = MLbsNetworkProtocolObserver::EServiceSelfLocation; |
|
166 proxy->CallL(ENetMsgProcessStatusUpdate, &serviceMask); |
|
167 |
|
168 |
|
169 // Send <-- ProcessLocationUpdate. |
|
170 TPositionInfo refPosInfo = ArgUtils::MolrReferencePositionInfo(); |
|
171 proxy->CallL(ENetMsgProcessLocationUpdate, &iSessionId, &refPosInfo); |
|
172 |
|
173 // Client recv - the ref position app side. |
|
174 CheckForObserverEventTestsL(KTimeOut, *this); |
|
175 |
|
176 |
|
177 // Send <-- ProcessAssistanceData. |
|
178 TLbsAsistanceDataGroup dataMask = EAssistanceDataReferenceTime; |
|
179 RLbsAssistanceDataBuilderSet data; |
|
180 TInt reason = KErrNone; |
|
181 ArgUtils::PopulateLC(data); |
|
182 proxy->CallL(ENetMsgProcessAssistanceData, &dataMask, &data, &reason); |
|
183 CleanupStack::PopAndDestroy(); // data |
|
184 |
|
185 |
|
186 // Send <-- ProcessLocationRequest. |
|
187 TBool emergency = EFalse; |
|
188 MLbsNetworkProtocolObserver::TLbsNetProtocolService service = MLbsNetworkProtocolObserver::EServiceSelfLocation; |
|
189 TLbsNetPosRequestQuality quality = ArgUtils::Quality(); |
|
190 TLbsNetPosRequestMethod method = ArgUtils::RequestHybridMethod(); |
|
191 quality.SetMaxFixTime(ArgUtils::Alpha2()); |
|
192 proxy->CallL(ENetMsgProcessLocationRequest, &iSessionId, &emergency, &service, &quality, &method); |
|
193 |
|
194 // Now that the hybrid/alpha2 has been requested, record current time to verify alpha2 timer expires correctly. |
|
195 TTime startTime; |
|
196 startTime.HomeTime(); |
|
197 |
|
198 |
|
199 // Recv --> RequestAssistanceData. |
|
200 TESTL(proxy->WaitForResponse(KTimeOut) == ENetMsgRequestAssistanceData); |
|
201 cleanupCnt = proxy->GetArgsLC(ENetMsgRequestAssistanceData, &dataMask); |
|
202 TESTL(dataMask == EAssistanceDataNone); |
|
203 CleanupStack::PopAndDestroy(cleanupCnt); |
|
204 |
|
205 // Client Send - a self-locate request. |
|
206 pWatch->IssueNotifyPositionUpdate(); |
|
207 |
|
208 // Rev --> RequestAssistanceData - we get this as the result of client notify update request. |
|
209 TESTL(proxy->WaitForResponse(KTimeOut) == ENetMsgRequestAssistanceData); |
|
210 cleanupCnt = proxy->GetArgsLC(ENetMsgRequestAssistanceData, &dataMask); |
|
211 TESTL(dataMask == EAssistanceDataNone); |
|
212 CleanupStack::PopAndDestroy(cleanupCnt); |
|
213 |
|
214 // Determine the value to take off the alpha2 value. This is required because we had to wait for the assistance data response. |
|
215 TTimeIntervalMicroSeconds microseconds; |
|
216 TTime stopTime; |
|
217 stopTime.HomeTime(); |
|
218 microseconds = stopTime.MicroSecondsFrom(startTime); |
|
219 TInt64 timeElapsed = microseconds.Int64(); |
|
220 |
|
221 |
|
222 // Recv --> RespondLocationRequest. |
|
223 // First ensure we don't recv response before Alpha2. |
|
224 TInt delta = 2 * 1000 * 1000; // 2 secs. |
|
225 TESTL(proxy->WaitForResponse(ArgUtils::Alpha2() - timeElapsed - delta) == ENetMsgTimeoutExpired); |
|
226 |
|
227 // Wait for and process the response. |
|
228 TESTL(proxy->WaitForResponse(2 * delta) == ENetMsgRespondLocationRequest); |
|
229 |
|
230 TPositionGpsMeasurementInfo* measurementInfo = NULL; |
|
231 cleanupCnt = proxy->GetArgsLC(ENetMsgRespondLocationRequest, &sessionId, &reason, &measurementInfo); |
|
232 TESTL(sessionId->SessionNum() == iSessionId.SessionNum()); |
|
233 TESTL(reason == KErrNone); |
|
234 TESTL(measurementInfo->PositionClassType() == EPositionGpsMeasurementInfoClass); |
|
235 |
|
236 CleanupStack::PopAndDestroy(cleanupCnt); |
|
237 sessionId = NULL; |
|
238 measurementInfo = NULL; |
|
239 |
|
240 |
|
241 // Recv -> RequestAssistanceData - we get an extra msg as the result of the A-GPS manager re-issueing a location request when it's |
|
242 // max fix time timer expries. |
|
243 TESTL(proxy->WaitForResponse(KTimeOut) == ENetMsgRequestAssistanceData); |
|
244 cleanupCnt = proxy->GetArgsLC(ENetMsgRequestAssistanceData, &dataMask); |
|
245 TESTL(dataMask == EAssistanceDataNone); |
|
246 CleanupStack::PopAndDestroy(cleanupCnt); |
|
247 |
|
248 const TInt t = 8 * 1000 * 1000; // 8 secs. |
|
249 quality.SetMaxFixTime(t); |
|
250 |
|
251 for (TInt i = 0; i < 2; i++) |
|
252 { |
|
253 // Send <-- ProcessLocationRequest - time t. |
|
254 proxy->CallL(ENetMsgProcessLocationRequest, &iSessionId, &emergency, &service, &quality, &method); |
|
255 |
|
256 // Recv --> RequestAssistanceData. |
|
257 TESTL(proxy->WaitForResponse(KTimeOut) == ENetMsgRequestAssistanceData); |
|
258 cleanupCnt = proxy->GetArgsLC(ENetMsgRequestAssistanceData, &dataMask); |
|
259 TESTL(dataMask == EAssistanceDataNone); |
|
260 CleanupStack::PopAndDestroy(cleanupCnt); |
|
261 |
|
262 // Recv --> RespondLocationRequest - first measurement, second position. |
|
263 TESTL(proxy->WaitForResponse(t + delta) == ENetMsgRespondLocationRequest); |
|
264 |
|
265 sessionId = NULL; |
|
266 |
|
267 // Expect measurement first time. |
|
268 if (i == 0) |
|
269 { |
|
270 measurementInfo = NULL; |
|
271 |
|
272 cleanupCnt = proxy->GetArgsLC(ENetMsgRespondLocationRequest, &sessionId, &reason, &measurementInfo); |
|
273 |
|
274 // Check it is a measurement. |
|
275 TESTL(measurementInfo->PositionClassType() == EPositionGpsMeasurementInfoClass); |
|
276 |
|
277 |
|
278 // Recv -> RequestAssistanceData - we get an extra msg as the result of the A-GPS manager re-issueing a location request when it's |
|
279 // max fix time timer expries. |
|
280 TESTL(proxy->WaitForResponse(KTimeOut) == ENetMsgRequestAssistanceData); |
|
281 TInt cleanupCnt2 = proxy->GetArgsLC(ENetMsgRequestAssistanceData, &dataMask); |
|
282 TESTL(dataMask == EAssistanceDataNone); |
|
283 CleanupStack::PopAndDestroy(cleanupCnt2); |
|
284 } |
|
285 |
|
286 // Expect position second time. |
|
287 else |
|
288 { |
|
289 TPositionInfo* positionInfo = NULL; |
|
290 |
|
291 cleanupCnt = proxy->GetArgsLC(ENetMsgRespondLocationRequest, &sessionId, &reason, &positionInfo); |
|
292 |
|
293 // Check it is a position. |
|
294 TESTL(positionInfo->PositionClassType() == (EPositionInfoClass|EPositionCourseInfoClass|EPositionSatelliteInfoClass|EPositionExtendedSatelliteInfoClass)); |
|
295 } |
|
296 |
|
297 TESTL(sessionId->SessionNum() == iSessionId.SessionNum()); |
|
298 TESTL(reason == KErrNone); |
|
299 CleanupStack::PopAndDestroy(cleanupCnt); |
|
300 } |
|
301 |
|
302 |
|
303 // Send <-- ProcessLocationUpdate - return network calculated pos |
|
304 TPositionInfo networkPosInfo = ArgUtils::MolrNetworkPositionInfo(); |
|
305 proxy->CallL(ENetMsgProcessLocationUpdate, &iSessionId, &networkPosInfo); |
|
306 |
|
307 |
|
308 // Send <-- ProcessSessionComplete. |
|
309 reason = KErrNone; |
|
310 proxy->CallL(ENetMsgProcessSessionComplete, &iSessionId, &reason); |
|
311 |
|
312 |
|
313 // Send <-- ProcessStatusUpdate. NOTE: this is missing from the sequence diagram. |
|
314 serviceMask = MLbsNetworkProtocolObserver::EServiceNone; |
|
315 proxy->CallL(ENetMsgProcessStatusUpdate, &serviceMask); |
|
316 |
|
317 |
|
318 // Client recv - the gps position determined by the gps module. |
|
319 CheckForObserverEventTestsL(KTimeOut, *this); |
|
320 TESTL(iState == EGpsLocReceived); |
|
321 |
|
322 // Wait for 10 seconds to ensure no additional responses turn up. |
|
323 delta = 10 * 1000 * 1000; |
|
324 TNetProtocolResponseType mType = proxy->WaitForResponse(delta); |
|
325 TESTL(mType == ENetMsgTimeoutExpired); |
|
326 |
|
327 // Done. Now cleanup... |
|
328 CleanupStack::PopAndDestroy(pWatch); |
|
329 CleanupStack::PopAndDestroy(); // pos |
|
330 CleanupStack::PopAndDestroy(); // server |
|
331 CleanupStack::PopAndDestroy(proxy); |
|
332 |
|
333 |
|
334 return TestStepResult(); |
|
335 } |
|
336 |
|
337 |
|
338 |
|
339 |
|
340 // MPosServerObserver |
|
341 void CT_LbsUEAssistedMOLRSelfGPSLate::OnGetLastKnownPosition(TInt32 /*aErr*/, const TPositionInfoBase& /*aPosInfo*/) |
|
342 { |
|
343 TEST(EFalse); // Shouldn't see this... |
|
344 ReturnToTestStep(); |
|
345 } |
|
346 |
|
347 |
|
348 void CT_LbsUEAssistedMOLRSelfGPSLate::OnNotifyPositionUpdate(TInt32 aErr, const TPositionInfoBase& aPosInfo) |
|
349 { |
|
350 // Verify error. |
|
351 TEST(aErr == KErrNone); |
|
352 |
|
353 // Verify position. |
|
354 TEST(aPosInfo.PositionClassType() == EPositionInfoClass); |
|
355 |
|
356 // Expecting ref pos. |
|
357 if (iState == EInitializing) |
|
358 { |
|
359 iState = ERefLocReceived; |
|
360 |
|
361 TEST(aPosInfo.PositionMode() == TPositionModuleInfo::ETechnologyNetwork); |
|
362 |
|
363 // check for refpos details |
|
364 const TPositionInfo posInfo = static_cast<const TPositionInfo&>(aPosInfo); |
|
365 TESTL(ArgUtils::ComparePositionInfoToMolrRefPos(posInfo)); |
|
366 } |
|
367 |
|
368 // Expecting network pos. |
|
369 else if (iState == ERefLocReceived) |
|
370 { |
|
371 iState = EGpsLocReceived; |
|
372 |
|
373 TEST(aPosInfo.PositionMode() == (TPositionModuleInfo::ETechnologyTerminal | TPositionModuleInfo::ETechnologyAssisted)); |
|
374 } |
|
375 |
|
376 // Not expecting anything else. |
|
377 else |
|
378 { |
|
379 TEST(EFalse); |
|
380 } |
|
381 |
|
382 ReturnToTestStep(); |
|
383 } |
|
384 |