|
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 // |
|
15 |
|
16 // LBS includes. |
|
17 #include <lbs/lbsnetprotocolbase.h> |
|
18 #include <lbs/lbsassistancedatabuilderset.h> |
|
19 #include <lbs/lbsloccommon.h> |
|
20 #include <lbserrors.h> |
|
21 |
|
22 // LBS test includes. |
|
23 #include "ctlbshybridmtlrfutile.h" |
|
24 #include <lbs/test/tlbsutils.h> |
|
25 #include "argutils.h" |
|
26 #include <lbs/test/activeyield.h> |
|
27 |
|
28 /** |
|
29 Static Constructor |
|
30 */ |
|
31 CT_LbsHybridMTLRFutile* CT_LbsHybridMTLRFutile::New(CT_LbsHybridMTLRServer& aParent) |
|
32 { |
|
33 // Note the lack of ELeave. |
|
34 // This means that having insufficient memory will return NULL; |
|
35 CT_LbsHybridMTLRFutile* testStep = new CT_LbsHybridMTLRFutile(aParent); |
|
36 if (testStep) |
|
37 { |
|
38 TInt err = KErrNone; |
|
39 |
|
40 TRAP(err, testStep->ConstructL()); |
|
41 if (err) |
|
42 { |
|
43 delete testStep; |
|
44 testStep = NULL; |
|
45 } |
|
46 } |
|
47 return testStep; |
|
48 } |
|
49 |
|
50 |
|
51 /** |
|
52 * Constructor |
|
53 */ |
|
54 CT_LbsHybridMTLRFutile::CT_LbsHybridMTLRFutile(CT_LbsHybridMTLRServer& aParent) : CT_LbsHybridMTLRStep(aParent) |
|
55 { |
|
56 SetTestStepName(KLbsHybridMTLRFutile); |
|
57 iSessionId.SetSessionOwner(KRequestUid); |
|
58 iSessionId.SetSessionNum(0x0001); |
|
59 iPositionUpdateRef = EFalse; |
|
60 } |
|
61 |
|
62 |
|
63 void CT_LbsHybridMTLRFutile::ConstructL() |
|
64 { |
|
65 // Create the base class objects. |
|
66 CT_LbsHybridMTLRStep::ConstructL(); |
|
67 iController = CLbsPrivacyController::NewL(*this); |
|
68 iProxy = CNetProtocolProxy::NewL(); |
|
69 iAGpsHandler = CT_LbsAGpsHandler::NewL(this); |
|
70 } |
|
71 |
|
72 |
|
73 /** |
|
74 * Destructor |
|
75 */ |
|
76 CT_LbsHybridMTLRFutile::~CT_LbsHybridMTLRFutile() |
|
77 { |
|
78 delete iAGpsHandler; |
|
79 delete iController; |
|
80 delete iProxy; |
|
81 } |
|
82 |
|
83 /** |
|
84 * HYBRID MTLR FUTILE SCENARIOS: |
|
85 * Test Case Id 1: Hybrid LBS MTLR UE Based - Futile |
|
86 * Test Case Id 2: Hybrid LBS MTLR UE Assisted - Futile |
|
87 * Test Case Id 3: LBS MTLR UE Based - Futile |
|
88 */ |
|
89 TVerdict CT_LbsHybridMTLRFutile::doTestStepL() |
|
90 { |
|
91 INFO_PRINTF1(_L("CT_LbsHybridMTLRFutile::doTestStepL()")); |
|
92 // Stop the test if the preable failed |
|
93 TESTL(TestStepResult() == EPass); |
|
94 |
|
95 const TInt KTimeOut = 60*1000*1000; |
|
96 |
|
97 // Carryout unique test actions. |
|
98 if (GetIntFromConfig(ConfigSection(), KTestCaseId, iTestCaseId)) |
|
99 { |
|
100 INFO_PRINTF2(_L("Test id %d."), iTestCaseId); |
|
101 |
|
102 // Comment out while lbs is restarted in this test's script |
|
103 // if (iTestCaseId == 1) |
|
104 { |
|
105 // >> AdviceSystemStatus(0) |
|
106 TESTL(iProxy->WaitForResponse(KTimeOut) == ENetMsgGetCurrentCapabilitiesResponse); |
|
107 CLbsNetworkProtocolBase::TLbsSystemStatus status; |
|
108 CleanupStack::PopAndDestroy(iProxy->GetArgsLC(ENetMsgGetCurrentCapabilitiesResponse, &status)); |
|
109 TESTL(status == CLbsNetworkProtocolBase::ESystemStatusNone); |
|
110 } |
|
111 |
|
112 // Initiate MTLR Start |
|
113 // << ProcessStatusUpdate() |
|
114 MLbsNetworkProtocolObserver::TLbsNetProtocolServiceMask activeServiceMask = MLbsNetworkProtocolObserver::EServiceMobileTerminated; |
|
115 iProxy->CallL(ENetMsgProcessStatusUpdate, &activeServiceMask); |
|
116 |
|
117 // << ProcessPrivacyRequest() |
|
118 TBool emergency = ETrue; |
|
119 TLbsNetPosRequestPrivacy privacy = ArgUtils::Privacy(); |
|
120 TLbsExternalRequestInfo requestInfo = ArgUtils::RequestInfo(); |
|
121 iProxy->CallL(ENetMsgProcessPrivacyRequest, &iSessionId, &emergency, &privacy, &requestInfo); |
|
122 |
|
123 // >> Callback from RespondNetworkLocationRequest(ERequestAccepted) |
|
124 CheckForObserverEventTestsL(KTimeOut, *this); |
|
125 |
|
126 TInt cleanupCnt; |
|
127 |
|
128 // >> Respond Privacy Request |
|
129 TESTL(iProxy->WaitForResponse(KTimeOut) == ENetMsgRespondPrivacyRequest); |
|
130 TLbsNetSessionId* sessionId = NULL; |
|
131 CLbsNetworkProtocolBase::TLbsPrivacyResponse getPrivacy; |
|
132 cleanupCnt = iProxy->GetArgsLC(ENetMsgRespondPrivacyRequest, &sessionId, &getPrivacy); |
|
133 TESTL(sessionId->SessionNum()==iSessionId.SessionNum()); |
|
134 TESTL(getPrivacy==CLbsNetworkProtocolBase::EPrivacyResponseAccepted); |
|
135 CleanupStack::PopAndDestroy(cleanupCnt); |
|
136 // Initiate MTLR End |
|
137 |
|
138 // MTLR Reference Position Notification Start |
|
139 // << ProcessLocationUpdate() |
|
140 TPositionInfo refPosition = ArgUtils::ReferencePositionInfo(); |
|
141 iProxy->CallL(ENetMsgProcessLocationUpdate, &iSessionId, &refPosition); |
|
142 // MTLR Reference Position Notification End |
|
143 |
|
144 // MTLR Assistance Data Notification Start |
|
145 // << ProcessAssistanceData() |
|
146 TLbsAsistanceDataGroup dataRequestMask = EAssistanceDataReferenceTime; |
|
147 RLbsAssistanceDataBuilderSet assistanceData; |
|
148 ArgUtils::PopulateLC(assistanceData); |
|
149 TInt reason = KErrNone; |
|
150 iProxy->CallL(ENetMsgProcessAssistanceData, &dataRequestMask, &assistanceData, &reason); |
|
151 CleanupStack::PopAndDestroy(); |
|
152 // MTLR Assistance Data Notification End |
|
153 |
|
154 // MTLR Network Location Request Start |
|
155 // << ProcessLocationRequest() |
|
156 MLbsNetworkProtocolObserver::TLbsNetProtocolService service = MLbsNetworkProtocolObserver::EServiceMobileTerminated; |
|
157 TLbsNetPosRequestQuality quality = ArgUtils::QualityAlpha2(); |
|
158 TLbsNetPosRequestMethod method; |
|
159 if ((iTestCaseId == 1) || (iTestCaseId == 2) || (iTestCaseId == 4)) |
|
160 { |
|
161 method = ArgUtils::RequestHybridMethod(); |
|
162 } |
|
163 else if (iTestCaseId == 3) |
|
164 { |
|
165 method = ArgUtils::RequestMethod(); |
|
166 } |
|
167 iProxy->CallL(ENetMsgProcessLocationRequest, &iSessionId, &emergency, &service, &quality, &method); |
|
168 // MTLR Network Location Request End |
|
169 |
|
170 //Start the timer |
|
171 TTime timerStart; |
|
172 timerStart.HomeTime(); |
|
173 |
|
174 // >> Callback from ProcessNetworkPostionUpdate(refPosition) |
|
175 CheckForObserverEventTestsL(KTimeOut, *this); |
|
176 |
|
177 // MTLR Assistance Data Notification Start |
|
178 // >> RequestAssistanceData(0) |
|
179 TESTL(iProxy->WaitForResponse(KTimeOut) == ENetMsgRequestAssistanceData); |
|
180 TLbsAsistanceDataGroup dataGroup; |
|
181 CleanupStack::PopAndDestroy(iProxy->GetArgsLC(ENetMsgRequestAssistanceData, &dataGroup)); |
|
182 TESTL(dataGroup == EAssistanceDataNone); |
|
183 // MTLR Assistance Data Notification End |
|
184 |
|
185 TPositionGpsMeasurementInfo* measurementInfo = NULL; |
|
186 |
|
187 if ((iTestCaseId == 2) || (iTestCaseId == 4)) |
|
188 { |
|
189 //Find the time elapsed from timer |
|
190 TTimeIntervalMicroSeconds microseconds; |
|
191 TTime timerStop; |
|
192 timerStop.HomeTime(); |
|
193 microseconds = timerStop.MicroSecondsFrom(timerStart); |
|
194 TInt64 timeElapsed = microseconds.Int64(); |
|
195 |
|
196 // >> RespondLocationRequest() |
|
197 //Test that we do not get response before alpha2 has expired |
|
198 TESTL(iProxy->WaitForResponse(ArgUtils::Alpha2() - timeElapsed - KDelta) == ENetMsgTimeoutExpired); |
|
199 TESTL(iProxy->WaitForResponse(2 * KDelta) == ENetMsgRespondLocationRequest); |
|
200 |
|
201 sessionId = NULL; |
|
202 reason = KErrNone; |
|
203 cleanupCnt = iProxy->GetArgsLC(ENetMsgRespondLocationRequest, &sessionId, &reason, &measurementInfo); |
|
204 TESTL(sessionId->SessionNum() == iSessionId.SessionNum()); |
|
205 TESTL(reason == KErrNone); |
|
206 // Check it is a measurement |
|
207 TESTL(measurementInfo->PositionClassType() == EPositionGpsMeasurementInfoClass); |
|
208 CleanupStack::PopAndDestroy(cleanupCnt); //sessionId, measurementInfo |
|
209 |
|
210 // Force a nother GPS update - this should be the futile one, and it will be returned |
|
211 // in response to the location request below. |
|
212 if (iTestCaseId == 4) |
|
213 { |
|
214 iAGpsHandler->SendRequestForcedUpdate(); |
|
215 CActiveScheduler::Start(); |
|
216 } |
|
217 |
|
218 //NHR's timer alpha2 times out -> Hybrid Positioning Start |
|
219 //<< ProcessLocationRequest() |
|
220 quality = ArgUtils::Quality(); //Set timeout t to KTimeOut |
|
221 iProxy->CallL(ENetMsgProcessLocationRequest, &iSessionId, &emergency, &service, &quality, &method); |
|
222 |
|
223 // MTLR Assistance Data Notification Start |
|
224 // >> RequestAssistanceData(0) |
|
225 if (iTestCaseId == 2) |
|
226 { |
|
227 TESTL(iProxy->WaitForResponse(KTimeOut) == ENetMsgRequestAssistanceData); |
|
228 CleanupStack::PopAndDestroy(iProxy->GetArgsLC(ENetMsgRequestAssistanceData, &dataGroup)); |
|
229 TESTL(dataGroup == EAssistanceDataNone); |
|
230 } |
|
231 // MTLR Assistance Data Notification End |
|
232 } |
|
233 |
|
234 // >> RespondLocationRequest() |
|
235 // Error returned by module should be KPositionCalculationFutile |
|
236 // the alpha or t timeout |
|
237 if ((iTestCaseId == 1) || (iTestCaseId == 3)) |
|
238 { |
|
239 TESTL(iProxy->WaitForResponse(ArgUtils::Alpha2()) == ENetMsgRespondLocationRequest); |
|
240 } |
|
241 else if ((iTestCaseId == 2) || (iTestCaseId == 4)) |
|
242 { |
|
243 TESTL(iProxy->WaitForResponse(KTimeOut) == ENetMsgRespondLocationRequest); |
|
244 } |
|
245 sessionId = NULL; |
|
246 reason = KErrNone; |
|
247 if ((iTestCaseId == 1) || (iTestCaseId == 2) || (iTestCaseId == 4)) |
|
248 { |
|
249 // Check it is a measurement |
|
250 measurementInfo = NULL; |
|
251 cleanupCnt = iProxy->GetArgsLC(ENetMsgRespondLocationRequest, &sessionId, &reason, &measurementInfo); |
|
252 TESTL(measurementInfo->PositionClassType() == EPositionGpsMeasurementInfoClass); |
|
253 } |
|
254 else if (iTestCaseId == 3) |
|
255 { |
|
256 // check it is a position |
|
257 TPositionInfo* posInfo = NULL; |
|
258 cleanupCnt = iProxy->GetArgsLC(ENetMsgRespondLocationRequest, &sessionId, &reason, &posInfo); |
|
259 TESTL(posInfo->PositionClassType() == (EPositionInfoClass|EPositionCourseInfoClass|EPositionSatelliteInfoClass|EPositionExtendedSatelliteInfoClass)); |
|
260 } |
|
261 TESTL(sessionId->SessionNum() == iSessionId.SessionNum()); |
|
262 TESTL(reason == KPositionCalculationFutile); |
|
263 CleanupStack::PopAndDestroy(cleanupCnt); //sessionId, measurementInfo\positionInfo |
|
264 |
|
265 // MTLR Session Completion Start |
|
266 // << ProcessSessionComplete() |
|
267 reason = KErrNone; |
|
268 iProxy->CallL(ENetMsgProcessSessionComplete, &iSessionId, &reason); |
|
269 |
|
270 // << ProcessStatusUpdate() |
|
271 MLbsNetworkProtocolObserver::TLbsNetProtocolServiceMask activeServiceMask2 = MLbsNetworkProtocolObserver::EServiceNone; |
|
272 iProxy->CallL(ENetMsgProcessStatusUpdate, &activeServiceMask2); |
|
273 |
|
274 // >> Callback from ProcessRequestComplete() |
|
275 CheckForObserverEventTestsL(KTimeOut, *this); |
|
276 // Verify that the last callback was to ProcessSessionComplete() |
|
277 TESTL(iState==ERequestComplete); |
|
278 // MTLR Session Completion End |
|
279 } |
|
280 |
|
281 return TestStepResult(); |
|
282 } |
|
283 |
|
284 void CT_LbsHybridMTLRFutile::ProcessNetworkLocationRequest(TUint aRequestId, const TLbsExternalRequestInfo& /*aRequestInfo*/, const TNotificationType& /*aNotificationType*/) |
|
285 { |
|
286 INFO_PRINTF1(_L(">>CT_LbsHybridMTLRFutile::ProcessNetworkLocationRequest()")); |
|
287 TEST(iState==EInitializing); |
|
288 iController->RespondNetworkLocationRequest(aRequestId, CLbsPrivacyController::ERequestAccepted); |
|
289 iState = EPrivacyCheckOk; |
|
290 ReturnToTestStep(); |
|
291 } |
|
292 |
|
293 void CT_LbsHybridMTLRFutile::ProcessNetworkPositionUpdate(TUint /*aRequestId*/, const TPositionInfo& /*aPosInfo*/) |
|
294 { |
|
295 INFO_PRINTF1(_L(">>CT_LbsHybridMTLR::ProcessNetworkPositionUpdate()")); |
|
296 if(!iPositionUpdateRef) |
|
297 { |
|
298 TEST(iState == EPrivacyCheckOk); |
|
299 iState = ERefLocReceived; |
|
300 iPositionUpdateRef = ETrue; |
|
301 } |
|
302 else |
|
303 { |
|
304 // None of this tests shoud get here |
|
305 TEST(EFalse); |
|
306 } |
|
307 ReturnToTestStep(); |
|
308 } |
|
309 |
|
310 void CT_LbsHybridMTLRFutile::ProcessRequestComplete(TUint aRequestId, TInt aReason) |
|
311 { |
|
312 INFO_PRINTF1(_L(">>CT_LbsHybridMTLRFutile::ProcessRequestComplete()")); |
|
313 |
|
314 TEST(iState == ERefLocReceived); |
|
315 TEST(aReason == KErrNone); |
|
316 TEST(aRequestId == iSessionId.SessionNum()); |
|
317 iState = ERequestComplete; |
|
318 ReturnToTestStep(); |
|
319 } |
|
320 |
|
321 void CT_LbsHybridMTLRFutile::ProcessAGpsResponseMessage(const TT_LbsAGpsResponseMsg::TModuleResponseType aResponse) |
|
322 { |
|
323 if (TT_LbsAGpsResponseMsg::EModuleResponseOk != aResponse) |
|
324 { |
|
325 SetTestStepResult(EPass); |
|
326 } |
|
327 |
|
328 CActiveScheduler::Stop(); |
|
329 } |
|
330 |
|
331 |
|
332 |
|
333 |