|
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 "ctlbsueassistedmolrselfgpslatefacilitytimeout.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_LbsUEAssistedMOLRSelfGPSLateFacTimeout* CT_LbsUEAssistedMOLRSelfGPSLateFacTimeout::New(CT_LbsHybridMOLRServer& aParent) |
|
43 { |
|
44 // Note the lack of ELeave. |
|
45 // This means that having insufficient memory will return NULL; |
|
46 CT_LbsUEAssistedMOLRSelfGPSLateFacTimeout* testStep = new CT_LbsUEAssistedMOLRSelfGPSLateFacTimeout(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_LbsUEAssistedMOLRSelfGPSLateFacTimeout::CT_LbsUEAssistedMOLRSelfGPSLateFacTimeout(CT_LbsHybridMOLRServer& aParent) : CT_LbsHybridMOLRStep(aParent) |
|
66 { |
|
67 SetTestStepName(KLbsUEAssistedMOLRSelfGPSLateFacTimeout); |
|
68 |
|
69 iSessionId.SetSessionOwner(KRequestUid); |
|
70 iSessionId.SetSessionNum(0x0001); |
|
71 |
|
72 // iPositionUpdateRef = EFalse; |
|
73 } |
|
74 |
|
75 |
|
76 void CT_LbsUEAssistedMOLRSelfGPSLateFacTimeout::ConstructL() |
|
77 { |
|
78 // Create the base class objects. |
|
79 CT_LbsHybridMOLRStep::ConstructL(); |
|
80 } |
|
81 |
|
82 /** |
|
83 * Destructor |
|
84 */ |
|
85 CT_LbsUEAssistedMOLRSelfGPSLateFacTimeout::~CT_LbsUEAssistedMOLRSelfGPSLateFacTimeout() |
|
86 { |
|
87 } |
|
88 |
|
89 |
|
90 TVerdict CT_LbsUEAssistedMOLRSelfGPSLateFacTimeout::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 TESTL(qualitycheck); |
|
154 |
|
155 iSessionId.SetSessionNum(sessionId->SessionNum()); |
|
156 iSessionId.SetSessionOwner(sessionId->SessionOwner()); |
|
157 |
|
158 CleanupStack::PopAndDestroy(cleanupCnt); |
|
159 sessionId = NULL; |
|
160 opts = NULL; |
|
161 |
|
162 |
|
163 // Send <-- ProcessStatusUpdate. |
|
164 MLbsNetworkProtocolObserver::TLbsNetProtocolService serviceMask = MLbsNetworkProtocolObserver::EServiceSelfLocation; |
|
165 proxy->CallL(ENetMsgProcessStatusUpdate, &serviceMask); |
|
166 |
|
167 |
|
168 // Send <-- ProcessLocationUpdate. |
|
169 TPositionInfo refPosInfo = ArgUtils::MolrReferencePositionInfo(); |
|
170 proxy->CallL(ENetMsgProcessLocationUpdate, &iSessionId, &refPosInfo); |
|
171 |
|
172 // Client recv - the ref position app side. |
|
173 CheckForObserverEventTestsL(KTimeOut, *this); |
|
174 |
|
175 |
|
176 // Send <-- ProcessAssistanceData. |
|
177 TLbsAsistanceDataGroup dataMask = EAssistanceDataReferenceTime; |
|
178 RLbsAssistanceDataBuilderSet data; |
|
179 TInt reason = KErrNone; |
|
180 ArgUtils::PopulateLC(data); |
|
181 proxy->CallL(ENetMsgProcessAssistanceData, &dataMask, &data, &reason); |
|
182 CleanupStack::PopAndDestroy(); // data |
|
183 |
|
184 |
|
185 // Send <-- ProcessLocationRequest. |
|
186 TBool emergency = EFalse; |
|
187 MLbsNetworkProtocolObserver::TLbsNetProtocolService service = MLbsNetworkProtocolObserver::EServiceSelfLocation; |
|
188 TLbsNetPosRequestQuality quality = ArgUtils::Quality(); |
|
189 TLbsNetPosRequestMethod method = ArgUtils::RequestHybridMethod(); |
|
190 quality.SetMaxFixTime(ArgUtils::Alpha2()); |
|
191 proxy->CallL(ENetMsgProcessLocationRequest, &iSessionId, &emergency, &service, &quality, &method); |
|
192 |
|
193 // Now that the hybrid/alpha2 has been requested, record current time to verify alpha2 timer expires correctly. |
|
194 TTime startTime; |
|
195 startTime.HomeTime(); |
|
196 |
|
197 |
|
198 // Recv --> RequestAssistanceData. |
|
199 TESTL(proxy->WaitForResponse(KTimeOut) == ENetMsgRequestAssistanceData); |
|
200 cleanupCnt = proxy->GetArgsLC(ENetMsgRequestAssistanceData, &dataMask); |
|
201 TESTL(dataMask == EAssistanceDataNone); |
|
202 CleanupStack::PopAndDestroy(cleanupCnt); |
|
203 |
|
204 // Client Send - a self-locate request. |
|
205 pWatch->IssueNotifyPositionUpdate(); |
|
206 |
|
207 // Rev --> RequestAssistanceData - we get this as the result of client notify update request. |
|
208 TESTL(proxy->WaitForResponse(KTimeOut) == ENetMsgRequestAssistanceData); |
|
209 cleanupCnt = proxy->GetArgsLC(ENetMsgRequestAssistanceData, &dataMask); |
|
210 TESTL(dataMask == EAssistanceDataNone); |
|
211 CleanupStack::PopAndDestroy(cleanupCnt); |
|
212 // Determine the value to take off the alpha2 value. This is required because we had to wait for the assistance data response. |
|
213 TTimeIntervalMicroSeconds microseconds; |
|
214 TTime stopTime; |
|
215 stopTime.HomeTime(); |
|
216 microseconds = stopTime.MicroSecondsFrom(startTime); |
|
217 TInt64 timeElapsed = microseconds.Int64(); |
|
218 |
|
219 |
|
220 // Recv --> RespondLocationRequest. |
|
221 // First ensure we don't recv response before Alpha2. |
|
222 TInt delta = 2 * 1000 * 1000; // 2 secs. |
|
223 TESTL(proxy->WaitForResponse(ArgUtils::Alpha2() - timeElapsed - delta) == ENetMsgTimeoutExpired); |
|
224 |
|
225 // Wait for and process the response. |
|
226 TESTL(proxy->WaitForResponse(2 * delta) == ENetMsgRespondLocationRequest); |
|
227 |
|
228 TPositionGpsMeasurementInfo* measurementInfo = NULL; |
|
229 cleanupCnt = proxy->GetArgsLC(ENetMsgRespondLocationRequest, &sessionId, &reason, &measurementInfo); |
|
230 TESTL(sessionId->SessionNum() == iSessionId.SessionNum()); |
|
231 TESTL(reason == KErrNone); |
|
232 TESTL(measurementInfo->PositionClassType() == EPositionGpsMeasurementInfoClass); |
|
233 |
|
234 CleanupStack::PopAndDestroy(cleanupCnt); |
|
235 sessionId = NULL; |
|
236 measurementInfo = NULL; |
|
237 |
|
238 |
|
239 // Recv -> RequestAssistanceData - we get an extra msg as the result of the A-GPS manager re-issueing a location request when it's |
|
240 // max fix time timer expries. |
|
241 TESTL(proxy->WaitForResponse(KTimeOut) == ENetMsgRequestAssistanceData); |
|
242 cleanupCnt = proxy->GetArgsLC(ENetMsgRequestAssistanceData, &dataMask); |
|
243 TESTL(dataMask == EAssistanceDataNone); |
|
244 CleanupStack::PopAndDestroy(cleanupCnt); |
|
245 const TInt t = 8 * 1000 * 1000; // 8 secs. |
|
246 quality.SetMaxFixTime(t); |
|
247 |
|
248 for (TInt i = 0; i < 2; i++) |
|
249 { |
|
250 // Send <-- ProcessLocationRequest - time t. |
|
251 proxy->CallL(ENetMsgProcessLocationRequest, &iSessionId, &emergency, &service, &quality, &method); |
|
252 |
|
253 // Recv --> RequestAssistanceData. |
|
254 TESTL(proxy->WaitForResponse(KTimeOut) == ENetMsgRequestAssistanceData); |
|
255 cleanupCnt = proxy->GetArgsLC(ENetMsgRequestAssistanceData, &dataMask); |
|
256 TESTL(dataMask == EAssistanceDataNone); |
|
257 CleanupStack::PopAndDestroy(cleanupCnt); |
|
258 |
|
259 // Recv --> RespondLocationRequest - first measurement, second position. |
|
260 TESTL(proxy->WaitForResponse(t + delta) == ENetMsgRespondLocationRequest); |
|
261 |
|
262 sessionId = NULL; |
|
263 |
|
264 // Expect measurement first time. |
|
265 if (i == 0) |
|
266 { |
|
267 measurementInfo = NULL; |
|
268 |
|
269 cleanupCnt = proxy->GetArgsLC(ENetMsgRespondLocationRequest, &sessionId, &reason, &measurementInfo); |
|
270 |
|
271 // Check it is a measurement. |
|
272 TESTL(measurementInfo->PositionClassType() == EPositionGpsMeasurementInfoClass); |
|
273 |
|
274 |
|
275 // Recv -> RequestAssistanceData - we get an extra msg as the result of the A-GPS manager re-issueing a location request when it's |
|
276 // max fix time timer expries. |
|
277 TESTL(proxy->WaitForResponse(KTimeOut) == ENetMsgRequestAssistanceData); |
|
278 TInt cleanupCnt2 = proxy->GetArgsLC(ENetMsgRequestAssistanceData, &dataMask); |
|
279 TESTL(dataMask == EAssistanceDataNone); |
|
280 CleanupStack::PopAndDestroy(cleanupCnt2); |
|
281 } |
|
282 |
|
283 // Expect position second time. |
|
284 else |
|
285 { |
|
286 TPositionInfo* positionInfo = NULL; |
|
287 |
|
288 cleanupCnt = proxy->GetArgsLC(ENetMsgRespondLocationRequest, &sessionId, &reason, &positionInfo); |
|
289 |
|
290 // Check it is a position. |
|
291 TESTL(positionInfo->PositionClassType() == (EPositionInfoClass|EPositionCourseInfoClass|EPositionSatelliteInfoClass|EPositionExtendedSatelliteInfoClass)); |
|
292 } |
|
293 |
|
294 TESTL(sessionId->SessionNum() == iSessionId.SessionNum()); |
|
295 TESTL(reason == KErrNone); |
|
296 CleanupStack::PopAndDestroy(cleanupCnt); |
|
297 } |
|
298 |
|
299 |
|
300 // Send <-- ProcessLocationUpdate - return network calculated pos - this message is not sent |
|
301 // this is due to the facility message not being sent and a timeout has occurred. |
|
302 /* |
|
303 TPositionInfo networkPosInfo = MolrArgUtils::NetworkPositionInfo(); |
|
304 proxy->CallL(ENetMsgProcessLocationUpdate, &iSessionId, &networkPosInfo); |
|
305 */ |
|
306 |
|
307 // Can wait for a number of seconds |
|
308 TInt KTimeout = 10 * 1000000; // 10 seconds |
|
309 TESTL(proxy->WaitForResponse(KTimeout) == ENetMsgTimeoutExpired); |
|
310 |
|
311 /* |
|
312 Other option is to have a delay, in case there is something put on the data bus |
|
313 RTimer timer; |
|
314 |
|
315 TInt tStat = timer.CreateLocal(); |
|
316 TESTL(tStat == KErrNone); |
|
317 TRequestStatus s = KErrGeneral; |
|
318 TTime time; |
|
319 time.UniversalTime(); |
|
320 timer.AtUTC(s, time + TTimeIntervalSeconds(10)); |
|
321 TESTL(s == KRequestPending); |
|
322 User::WaitForRequest(s); |
|
323 TESTL(s == KErrNone); |
|
324 timer.Close(); |
|
325 */ |
|
326 |
|
327 // Send <-- ProcessSessionComplete. |
|
328 reason = KErrTimedOut; |
|
329 proxy->CallL(ENetMsgProcessSessionComplete, &iSessionId, &reason); |
|
330 |
|
331 |
|
332 // Send <-- ProcessStatusUpdate. NOTE: this is missing from the sequence diagram. |
|
333 serviceMask = MLbsNetworkProtocolObserver::EServiceNone; |
|
334 proxy->CallL(ENetMsgProcessStatusUpdate, &serviceMask); |
|
335 |
|
336 |
|
337 // Client recv - the gps position determined by the gps module. |
|
338 CheckForObserverEventTestsL(KTimeOut, *this); |
|
339 TESTL(iState == EGpsLocReceived); |
|
340 |
|
341 // Check no further data is being being sent. |
|
342 TESTL(proxy->WaitForResponse(KTimeout) == ENetMsgTimeoutExpired); |
|
343 |
|
344 |
|
345 // Done. Now cleanup... |
|
346 CleanupStack::PopAndDestroy(pWatch); |
|
347 CleanupStack::PopAndDestroy(); // pos |
|
348 CleanupStack::PopAndDestroy(); // server |
|
349 CleanupStack::PopAndDestroy(proxy); |
|
350 |
|
351 |
|
352 return TestStepResult(); |
|
353 } |
|
354 |
|
355 |
|
356 |
|
357 |
|
358 // MPosServerObserver |
|
359 void CT_LbsUEAssistedMOLRSelfGPSLateFacTimeout::OnGetLastKnownPosition(TInt32 /*aErr*/, const TPositionInfoBase& /*aPosInfo*/) |
|
360 { |
|
361 TEST(EFalse); // Shouldn't see this... |
|
362 ReturnToTestStep(); |
|
363 } |
|
364 |
|
365 |
|
366 void CT_LbsUEAssistedMOLRSelfGPSLateFacTimeout::OnNotifyPositionUpdate(TInt32 aErr, const TPositionInfoBase& aPosInfo) |
|
367 { |
|
368 // Verify error. |
|
369 TEST(aErr == KErrNone); |
|
370 |
|
371 // Verify position. |
|
372 TEST(aPosInfo.PositionClassType() == EPositionInfoClass); |
|
373 |
|
374 // Expecting ref pos. |
|
375 if (iState == EInitializing) |
|
376 { |
|
377 iState = ERefLocReceived; |
|
378 |
|
379 TEST(aPosInfo.PositionMode() == TPositionModuleInfo::ETechnologyNetwork); |
|
380 |
|
381 // check for refpos details |
|
382 const TPositionInfo posInfo = static_cast<const TPositionInfo&>(aPosInfo); |
|
383 TESTL(ArgUtils::ComparePositionInfoToMolrRefPos(posInfo)); |
|
384 } |
|
385 |
|
386 // Expecting network pos. |
|
387 else if (iState == ERefLocReceived) |
|
388 { |
|
389 iState = EGpsLocReceived; |
|
390 |
|
391 TEST(aPosInfo.PositionMode() == (TPositionModuleInfo::ETechnologyTerminal | TPositionModuleInfo::ETechnologyAssisted)); |
|
392 } |
|
393 |
|
394 // Not expecting anything else. |
|
395 else |
|
396 { |
|
397 TEST(EFalse); |
|
398 } |
|
399 |
|
400 ReturnToTestStep(); |
|
401 } |
|
402 |