|
1 // Copyright (c) 2006-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 // @file ctlbsconflictstepmtlrx3ppush.cpp |
|
15 // This is the class implementation for a MTLR - X3P Push conflict test. |
|
16 // EPOC includes. |
|
17 // |
|
18 // |
|
19 |
|
20 // LBS includes. |
|
21 #include <lbs.h> |
|
22 #include <lbs/lbsnetcommon.h> |
|
23 #include <lbssatellite.h> |
|
24 #include <lbs/lbsnetprotocolbase.h> |
|
25 #include <lbs/lbsassistancedatabuilderset.h> |
|
26 #include <e32math.h> |
|
27 |
|
28 // LBS test includes. |
|
29 #include "ctlbsconflictstepmtlrx3ppush.h" |
|
30 #include <lbs/test/tlbsutils.h> |
|
31 |
|
32 |
|
33 /** Static Constructor |
|
34 */ |
|
35 CT_LbsConflictStep_MTLRX3PPush* CT_LbsConflictStep_MTLRX3PPush::New(CT_LbsConflictServer& aParent) |
|
36 { |
|
37 // Note the lack of ELeave. |
|
38 // This means that having insufficient memory will return NULL; |
|
39 CT_LbsConflictStep_MTLRX3PPush* testStep = new CT_LbsConflictStep_MTLRX3PPush(aParent); |
|
40 if (testStep) |
|
41 { |
|
42 TInt err = KErrNone; |
|
43 |
|
44 TRAP(err, testStep->ConstructL()); |
|
45 if (err) |
|
46 { |
|
47 delete testStep; |
|
48 testStep = NULL; |
|
49 } |
|
50 } |
|
51 return testStep; |
|
52 } |
|
53 |
|
54 |
|
55 /** Constructor |
|
56 */ |
|
57 CT_LbsConflictStep_MTLRX3PPush::CT_LbsConflictStep_MTLRX3PPush(CT_LbsConflictServer& aParent) : CT_LbsConflictStep(aParent) |
|
58 { |
|
59 SetTestStepName(KLbsConflictStep_MTLRX3PPush); |
|
60 } |
|
61 |
|
62 |
|
63 void CT_LbsConflictStep_MTLRX3PPush::ConstructL() |
|
64 { |
|
65 // Create the base class objects. |
|
66 CT_LbsConflictStep::ConstructL(); |
|
67 |
|
68 // MTLR privacy controller. |
|
69 iPrivacyController = CLbsPrivacyController::NewL(*this); |
|
70 |
|
71 // X3P async wrapper. |
|
72 iDoX3PPush = CT_LbsDoX3P::NewL(this); |
|
73 } |
|
74 |
|
75 |
|
76 /** Destructor |
|
77 */ |
|
78 CT_LbsConflictStep_MTLRX3PPush::~CT_LbsConflictStep_MTLRX3PPush() |
|
79 { |
|
80 iPrivacyController->CancelNetworkLocationRequest(0); |
|
81 delete iPrivacyController; |
|
82 |
|
83 iDoX3PPush->Cancel(); |
|
84 delete iDoX3PPush; |
|
85 } |
|
86 |
|
87 |
|
88 /** Expected sequence events. |
|
89 */ |
|
90 void CT_LbsConflictStep_MTLRX3PPush::SetExpectedSeq() |
|
91 { |
|
92 // MTLR (iState = EStartMTLRPrivReq) |
|
93 SetVerifySeqEvent(EClient_Priv_Got_ProcessNetworkLocationRequest); |
|
94 SetVerifySeqEvent(EMTLR_NetSim_Got_NotifyReleaseLcsLocationNotification); |
|
95 |
|
96 // after location notification (iState = EStartMTLRLocReq) |
|
97 SetVerifySeqEvent(EMTLR_NetSim_Got_NotifyMeasurementControlLocation); |
|
98 SetVerifySeqEvent(EClient_Priv_Got_ProcessNetworkPositionUpdate); // Expect reference position. |
|
99 SetVerifySeqEvent(EClient_Priv_Got_ProcessNetworkPositionUpdate); // Expect real position. |
|
100 SetVerifySeqEvent(EMTLR_NetSim_Got_NotifyMeasurementReportLocation); |
|
101 SetVerifySeqEvent(EClient_Priv_Got_ProcessRequestComplete); |
|
102 |
|
103 // after MTLR complete (iState = EWaiting). |
|
104 |
|
105 SetVerifyAdhocEvent(EClient_Got_X3P_Complete); |
|
106 } |
|
107 |
|
108 |
|
109 /** Run the test. |
|
110 */ |
|
111 TVerdict CT_LbsConflictStep_MTLRX3PPush::doTestStepL() |
|
112 { |
|
113 // Generic test step used to test the LBS Client Notify position update API. |
|
114 INFO_PRINTF1(_L(">>CT_LbsConflictStep_MTLRX3PPush::doTestStepL()")); |
|
115 |
|
116 if (TestStepResult() == EPass) |
|
117 { |
|
118 // Setup the expected sequence events for the test. |
|
119 SetExpectedSeq(); |
|
120 |
|
121 // Open and setup net sim. |
|
122 OpenNetSim(this); |
|
123 |
|
124 // Setup emergency locate service and pause to ensure value is set. |
|
125 CLbsAdmin* admin = CLbsAdmin::NewL(); |
|
126 CleanupStack::PushL(admin); |
|
127 User::LeaveIfError(admin->Set(KLbsSettingHomeEmergencyLocate, CLbsAdmin::EExternalLocateOn)); |
|
128 User::After(5000000); |
|
129 CleanupStack::PopAndDestroy(admin); |
|
130 |
|
131 // Kick off the test abort and keep alive timers. |
|
132 TTimeIntervalMicroSeconds32 abortInterval(KLbsAbortPeriod); |
|
133 TTimeIntervalMicroSeconds32 keepAliveInterval(KLbsKeepAlivePeriod); |
|
134 |
|
135 iAbortTimer->SetTimer(abortInterval); |
|
136 iKeepAliveTimer->SetTimer(keepAliveInterval); |
|
137 |
|
138 // Kick off test. |
|
139 CActiveScheduler::Start(); |
|
140 |
|
141 // Clean up. |
|
142 CloseNetSim(); |
|
143 } |
|
144 |
|
145 INFO_PRINTF1(_L("<<CT_LbsConflictStep_MTLRX3PPush::doTestStepL()")); |
|
146 |
|
147 return TestStepResult(); |
|
148 } |
|
149 |
|
150 |
|
151 /** NetSim callbacks. |
|
152 */ |
|
153 void CT_LbsConflictStep_MTLRX3PPush::Connected() |
|
154 { |
|
155 // Call base implementation. |
|
156 CT_LbsConflictStep::Connected(); |
|
157 |
|
158 // Start a MT-LR request. |
|
159 _LIT8(KTestRequesterId, "LbsConflict test requester id"); |
|
160 _LIT8(KTestClientName, "LbsConflict test client name"); |
|
161 _LIT8(KTestClientExternalId, "LbsConflict test client external id"); |
|
162 |
|
163 TLbsExternalRequestInfo reqInfo; |
|
164 reqInfo.SetRequesterId(KTestRequesterId); |
|
165 reqInfo.SetClientName(KTestClientName); |
|
166 reqInfo.SetClientExternalId(KTestClientExternalId); |
|
167 |
|
168 TLbsNetPosRequestPrivacy reqType; |
|
169 reqType.SetRequestAction(TLbsNetPosRequestPrivacy::ERequestActionAllow); |
|
170 reqType.SetRequestAdvice(TLbsNetPosRequestPrivacy::ERequestAdviceNotify); |
|
171 |
|
172 iNetSim.SetEmergenyStatus(ETrue); |
|
173 |
|
174 // kick off the privacy request: |
|
175 iNetSim.StartNetworkPrivacyRequest(reqType, reqInfo); |
|
176 |
|
177 iState = EStartMTLRPrivReq; |
|
178 } |
|
179 |
|
180 |
|
181 void CT_LbsConflictStep_MTLRX3PPush::Disconnected() |
|
182 { |
|
183 // Call base implementation. |
|
184 CT_LbsConflictStep::Disconnected(); |
|
185 } |
|
186 |
|
187 |
|
188 void CT_LbsConflictStep_MTLRX3PPush::NotifyRegisterLcsMoLr(const TDesC& aData) |
|
189 { |
|
190 (void)aData; |
|
191 |
|
192 INFO_PRINTF1(_L("Failed test, got unexpected - NetSim Notify Register Lcs MoLr - Event.")); |
|
193 SetTestStepResult(EFail); |
|
194 } |
|
195 |
|
196 |
|
197 void CT_LbsConflictStep_MTLRX3PPush::NotifyReleaseLcsMoLr(TInt aReason) |
|
198 { |
|
199 (void)aReason; |
|
200 |
|
201 INFO_PRINTF1(_L("Failed test, got unexpected - NetSim Notify Release Lcs MoLr - Event.")); |
|
202 SetTestStepResult(EFail); |
|
203 } |
|
204 |
|
205 |
|
206 void CT_LbsConflictStep_MTLRX3PPush::NotifyMeasurementControlLocation(const TPositionInfo& aPosition, |
|
207 const RLbsAssistanceDataBuilderSet& aData, |
|
208 const TLbsNetPosRequestQuality& aQuality) |
|
209 { |
|
210 T_LbsUtils utils; |
|
211 TInt err; |
|
212 |
|
213 // Determine and record sequence event. |
|
214 if (iState == EStartMTLRLocReq) |
|
215 { |
|
216 INFO_PRINTF1(_L("Got - MTLR - NetSim Notify Measurement Control Location - Event.")); |
|
217 SetCurrentSeqEvent(EMTLR_NetSim_Got_NotifyMeasurementControlLocation); |
|
218 } |
|
219 |
|
220 else |
|
221 { |
|
222 INFO_PRINTF1(_L("Failed test, got unxpected - NetSim Notify Measurement Control Location - Event.")); |
|
223 SetTestStepResult(EFail); |
|
224 } |
|
225 |
|
226 // Verify the reference position. |
|
227 TPositionInfo verifyRefPosInfo; |
|
228 |
|
229 verifyRefPosInfo.SetPosition(iRefPos); |
|
230 if (!utils.Compare_PosInfo(verifyRefPosInfo, aPosition)) |
|
231 { |
|
232 INFO_PRINTF1(_L("Failed test, position incorrect.")); |
|
233 SetTestStepResult(EFail); |
|
234 } |
|
235 |
|
236 |
|
237 // Verify the assistance data. |
|
238 RLbsAssistanceDataBuilderSet& data = const_cast<RLbsAssistanceDataBuilderSet&>(aData); |
|
239 RUEPositioningGpsReferenceTimeBuilder* refTimeBuilder = NULL; |
|
240 |
|
241 data.GetDataBuilder(refTimeBuilder); |
|
242 |
|
243 // Create a reader from the builder's data to allow us to verify the actual |
|
244 // assistance data. |
|
245 RUEPositioningGpsReferenceTimeReader refTimeReader; |
|
246 |
|
247 TRAP(err, refTimeReader.OpenL()); |
|
248 if (err == KErrNone) |
|
249 { |
|
250 refTimeReader.DataBuffer() = refTimeBuilder->DataBuffer(); |
|
251 |
|
252 if (!utils.VerifySimpleAssistanceData(refTimeReader)) |
|
253 { |
|
254 INFO_PRINTF1(_L("Failed test, assistance data incorrect.")); |
|
255 SetTestStepResult(EFail); |
|
256 } |
|
257 refTimeReader.Close(); |
|
258 } |
|
259 |
|
260 else |
|
261 { |
|
262 INFO_PRINTF2(_L("Failed test, assistance data reader err %d."), err); |
|
263 SetTestStepResult(EFail); |
|
264 } |
|
265 |
|
266 |
|
267 // TODO: Check if we can verify aQuality in any way. |
|
268 (void)aQuality; |
|
269 } |
|
270 |
|
271 |
|
272 void CT_LbsConflictStep_MTLRX3PPush::NotifyReleaseLcsLocationNotification(const CLbsNetworkProtocolBase::TLbsPrivacyResponse& aResult) |
|
273 { |
|
274 // Record the sequence event. |
|
275 if (iState == EStartMTLRPrivReq) |
|
276 { |
|
277 INFO_PRINTF1(_L("Got - MTLR - NetSim Notify Release Lcs Location Notification - Event.")); |
|
278 SetCurrentSeqEvent(EMTLR_NetSim_Got_NotifyReleaseLcsLocationNotification); |
|
279 } |
|
280 |
|
281 else |
|
282 { |
|
283 INFO_PRINTF1(_L("Failed test, got unxpected - NetSim Notify Release Lcs Location Notification - Event.")); |
|
284 SetTestStepResult(EFail); |
|
285 } |
|
286 |
|
287 // Should allways expect privacy requests to be excepted. |
|
288 if (CLbsNetworkProtocolBase::EPrivacyResponseAccepted == aResult) |
|
289 { |
|
290 // Now invoke MT-LR location request. |
|
291 iNetSim.StartNetworkLocationRequest(); |
|
292 |
|
293 iState = EStartMTLRLocReq; |
|
294 } |
|
295 |
|
296 // Un-expected response. |
|
297 else |
|
298 { |
|
299 INFO_PRINTF1(_L("Failed test, should have excepted MT-LR privacy request.")); |
|
300 SetTestStepResult(EFail); |
|
301 } |
|
302 } |
|
303 |
|
304 |
|
305 void CT_LbsConflictStep_MTLRX3PPush::NotifyFacilityLcsMoLrResult(TInt aReason, const TPositionInfo& aPosition) |
|
306 { |
|
307 (void)aReason; |
|
308 (void)aPosition; |
|
309 |
|
310 INFO_PRINTF1(_L("Failed test, got unxpected - NetSim Notify Facility Lcs MoLr Result - Event.")); |
|
311 SetTestStepResult(EFail); |
|
312 } |
|
313 |
|
314 |
|
315 void CT_LbsConflictStep_MTLRX3PPush::NotifyMeasurementReportLocation(const TPositionInfo& aPosition) |
|
316 { |
|
317 // Determine and record sequence event. |
|
318 if(iState == EWaitMTLRLocRes) |
|
319 { |
|
320 INFO_PRINTF1(_L("Got - MTLR - NetSim Notify Measurement Report - Event.")); |
|
321 SetCurrentSeqEvent(EMTLR_NetSim_Got_NotifyMeasurementReportLocation); |
|
322 } |
|
323 |
|
324 else |
|
325 { |
|
326 INFO_PRINTF1(_L("Failed test, got unxpected - NetSim Notify Measurement Report - Event.")); |
|
327 SetTestStepResult(EFail); |
|
328 } |
|
329 |
|
330 // Verify the real position given to the network, this will be the same position |
|
331 // returned as the result of the MO-LR, thus use the entry given by |
|
332 // the test module. |
|
333 T_LbsUtils utils; |
|
334 RPointerArray<TAny>& verifyPosInfoArr = iParent.iSharedData->iVerifyPosInfoArr; |
|
335 TPositionInfo* verifyRealPosInfo = reinterpret_cast<TPositionInfo*>(verifyPosInfoArr[0]); |
|
336 |
|
337 if (!utils.Compare_PosInfo(*verifyRealPosInfo, aPosition)) |
|
338 { |
|
339 INFO_PRINTF1(_L("Failed test, position incorrect.")); |
|
340 SetTestStepResult(EFail); |
|
341 } |
|
342 } |
|
343 |
|
344 |
|
345 void CT_LbsConflictStep_MTLRX3PPush::NotifyMeasurementReportRequestMoreAssistanceData(const TLbsAssistanceDataGroup& aFilter) |
|
346 { |
|
347 (void)aFilter; |
|
348 |
|
349 INFO_PRINTF1(_L("Failed test, got unxpected - NetSim Notify Measurement Report Request More Assistance Data - Event.")); |
|
350 SetTestStepResult(EFail); |
|
351 } |
|
352 |
|
353 |
|
354 void CT_LbsConflictStep_MTLRX3PPush::NotifyMeasurementReportControlFailure(TInt aReason) |
|
355 { |
|
356 INFO_PRINTF2(_L("Failed test, got unxpected - Net Sim Notify Measurement Report Control Failure - Event. Reason = %d"), aReason); |
|
357 SetTestStepResult(EFail); |
|
358 } |
|
359 |
|
360 |
|
361 /** MTLR Privacy controller callbacks. |
|
362 */ |
|
363 void CT_LbsConflictStep_MTLRX3PPush::ProcessNetworkLocationRequest(TUint aRequestId, const TLbsExternalRequestInfo& aRequestInfo, const TNotificationType& aNotificationType) |
|
364 { |
|
365 // We not aiming to test MT-LR in general here so only carryout minimal verification - verify the request id only. |
|
366 (void)aRequestInfo; |
|
367 (void)aNotificationType; |
|
368 |
|
369 iMtlrRequestId = aRequestId; |
|
370 |
|
371 // Record sequence event. |
|
372 INFO_PRINTF2(_L("Got - Privacy Process Network Location Request. Request Id = %d."), aRequestId); |
|
373 SetCurrentSeqEvent(EClient_Priv_Got_ProcessNetworkLocationRequest); |
|
374 |
|
375 // Start the MTLR location request. |
|
376 iPrivacyController->RespondNetworkLocationRequest(aRequestId, CLbsPrivacyController::ERequestAccepted); |
|
377 |
|
378 |
|
379 // Start the X3P. |
|
380 |
|
381 // Create a posinfo and store in our shared array for later verification. |
|
382 RPointerArray<TAny>& posInfoArr = iParent.iSharedData->iCurrentPosInfoArr; |
|
383 TPositionInfo* posInfo = new(ELeave) TPositionInfo(); |
|
384 |
|
385 posInfoArr.Append(posInfo); |
|
386 |
|
387 // Transmit X3P. |
|
388 TLbsTransmitPositionOptions transOpts; |
|
389 |
|
390 iDoX3PPush->SetOptions(transOpts); // Set timeout value to 0, to disable the timeout. |
|
391 iDoX3PPush->StartL(KTransmitPushDestination, KTransmitPushPriority, *posInfo); |
|
392 } |
|
393 |
|
394 |
|
395 void CT_LbsConflictStep_MTLRX3PPush::ProcessNetworkPositionUpdate(TUint aRequestId, const TPositionInfo& aPosInfo) |
|
396 { |
|
397 // Record sequence event. |
|
398 INFO_PRINTF2(_L("Got - Privacy Process Network Position Update. Request Id = %d."), aRequestId); |
|
399 SetCurrentSeqEvent(EClient_Priv_Got_ProcessNetworkPositionUpdate); |
|
400 |
|
401 // Verify the request id. |
|
402 if (aRequestId != iMtlrRequestId) |
|
403 { |
|
404 INFO_PRINTF3(_L("Failed test, incorrect request ID, got %d, expecting %d."), aRequestId, iMtlrRequestId); |
|
405 SetTestStepResult(EFail); |
|
406 } |
|
407 |
|
408 |
|
409 // Verify the position. |
|
410 |
|
411 // First time around the position will be the reference, second the actual position. |
|
412 T_LbsUtils utils; |
|
413 |
|
414 if (iState == EStartMTLRLocReq) |
|
415 { |
|
416 // Verify the reference position. |
|
417 TPositionInfo verifyRefPosInfo; |
|
418 |
|
419 verifyRefPosInfo.SetPosition(iRefPos); |
|
420 if (!utils.Compare_PosInfo(verifyRefPosInfo, aPosInfo)) |
|
421 { |
|
422 INFO_PRINTF1(_L("Failed test, reference position incorrect.")); |
|
423 SetTestStepResult(EFail); |
|
424 } |
|
425 |
|
426 iState = EWaitMTLRLocRes; |
|
427 } |
|
428 |
|
429 else if (iState == EWaitMTLRLocRes) |
|
430 { |
|
431 RPointerArray<TAny>& verifyPosInfoArr = iParent.iSharedData->iVerifyPosInfoArr; |
|
432 TPositionInfo* verifyRealPosInfo = reinterpret_cast<TPositionInfo*>(verifyPosInfoArr[0]); |
|
433 |
|
434 if (!utils.Compare_PosInfo(*verifyRealPosInfo, aPosInfo)) |
|
435 { |
|
436 INFO_PRINTF1(_L("Failed test, real position incorrect.")); |
|
437 SetTestStepResult(EFail); |
|
438 } |
|
439 } |
|
440 } |
|
441 |
|
442 |
|
443 void CT_LbsConflictStep_MTLRX3PPush::ProcessRequestComplete(TUint aRequestId, TInt aReason) |
|
444 { |
|
445 // Record sequence event. |
|
446 INFO_PRINTF3(_L("Got - Privacy Process Request Complete. Request Id = %d, Reason = %d."), aRequestId, aReason); |
|
447 SetCurrentSeqEvent(EClient_Priv_Got_ProcessRequestComplete); |
|
448 |
|
449 // Verify the request id. |
|
450 if (aRequestId != iMtlrRequestId) |
|
451 { |
|
452 INFO_PRINTF3(_L("Failed test, incorrect request ID, got %d, expecting %d."), aRequestId, iMtlrRequestId); |
|
453 SetTestStepResult(EFail); |
|
454 } |
|
455 |
|
456 // Verify the reason code. |
|
457 if (aReason) |
|
458 { |
|
459 INFO_PRINTF2(_L("Failed test, incorrect reason code, got %d, expecting KErrNone."), aReason); |
|
460 SetTestStepResult(EFail); |
|
461 } |
|
462 |
|
463 iState = EWaiting; |
|
464 } |
|
465 |
|
466 |
|
467 /** X3P transmit callback. |
|
468 |
|
469 The X3P transmit request has completed. |
|
470 */ |
|
471 void CT_LbsConflictStep_MTLRX3PPush::MT_LbsDoX3PCallback(TInt aTransmitId, TRequestStatus& aStatus) |
|
472 { |
|
473 (void)aTransmitId; |
|
474 |
|
475 SetCurrentSeqEvent(EClient_Got_X3P_Complete); |
|
476 INFO_PRINTF1(_L("Got - Client X3P Push Complete - Callback Event.")); |
|
477 |
|
478 // Verify X3P push position, entry 0 of the array. We expect a position containing NaNs. |
|
479 RPointerArray<TAny>& currPosInfoArr = iParent.iSharedData->iCurrentPosInfoArr; |
|
480 TPositionInfo* currPosInfo; |
|
481 |
|
482 currPosInfo = reinterpret_cast<TPositionInfo*>(currPosInfoArr[0]); |
|
483 TPosition pos; |
|
484 currPosInfo->GetPosition(pos); |
|
485 if (!Math::IsNaN(pos.Latitude())) |
|
486 { |
|
487 INFO_PRINTF1(_L("Failed test, Position does not contain NANs")); |
|
488 |
|
489 SetTestStepResult(EFail); |
|
490 } |
|
491 if (!Math::IsNaN(pos.Longitude())) |
|
492 { |
|
493 INFO_PRINTF1(_L("Failed test, Position does not contain NANs")); |
|
494 |
|
495 SetTestStepResult(EFail); |
|
496 } |
|
497 |
|
498 // Ensure it completes with correct err. |
|
499 if (KErrServerBusy != aStatus.Int()) |
|
500 { |
|
501 INFO_PRINTF2(_L("Failed test, X3P transmit request err = %d, expecting KErrServerBusy."), aStatus.Int()); |
|
502 SetTestStepResult(EFail); |
|
503 iState = EWaiting; |
|
504 } |
|
505 } |
|
506 |
|
507 |