|
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 the License "Symbian Foundation License v1.0" |
|
5 // which accompanies this distribution, and is available |
|
6 // at the URL "http://www.symbianfoundation.org/legal/sfl-v10.html". |
|
7 // |
|
8 // Initial Contributors: |
|
9 // Nokia Corporation - initial contribution. |
|
10 // |
|
11 // Contributors: |
|
12 // |
|
13 // Description: |
|
14 // @file CT_LbsClientStepAssistance.cpp |
|
15 // This is the class implementation for the LBS Client Step Assistance |
|
16 // |
|
17 // |
|
18 |
|
19 //LBS includes. |
|
20 #include <lbs.h> |
|
21 #include <lbsnetcommon.h> |
|
22 #include <lbsnetprotocolbase.h> |
|
23 |
|
24 // LBS test includes. |
|
25 #include "ctlbsclientstepassistance.h" |
|
26 #include "tlbsutils.h" |
|
27 |
|
28 |
|
29 const TInt KAssistanceDataProviderPluginUidValue = 0x1028225B; |
|
30 |
|
31 |
|
32 /** |
|
33 Static Constructor |
|
34 */ |
|
35 CT_LbsClientStep_Assistance* CT_LbsClientStep_Assistance::New(CT_LbsClientServer& aParent) |
|
36 { |
|
37 // Note the lack of ELeave. |
|
38 // This means that having insufficient memory will return NULL; |
|
39 CT_LbsClientStep_Assistance* testStep = new CT_LbsClientStep_Assistance(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_LbsClientStep_Assistance::CT_LbsClientStep_Assistance(CT_LbsClientServer& aParent) : CT_LbsNetSimStep(), iParent(aParent),iLbsAdmin(NULL) |
|
58 { |
|
59 SetTestStepName(KLbsClientStep_Assistance); |
|
60 } |
|
61 |
|
62 |
|
63 void CT_LbsClientStep_Assistance::ConstructL() |
|
64 { |
|
65 // Create the base class objects. |
|
66 CT_LbsNetSimStep::ConstructL(); |
|
67 |
|
68 // and the active object wrapper for the notify position update. |
|
69 iDoPosUpdate = CT_LbsDoPosUpdate::NewL(this); |
|
70 |
|
71 // create the admin |
|
72 iLbsAdmin = CLbsAdmin::NewL(); |
|
73 } |
|
74 |
|
75 /** |
|
76 * Destructor |
|
77 */ |
|
78 CT_LbsClientStep_Assistance::~CT_LbsClientStep_Assistance() |
|
79 { |
|
80 delete iLbsAdmin; |
|
81 |
|
82 iDoPosUpdate->Cancel(); |
|
83 delete iDoPosUpdate; |
|
84 |
|
85 } |
|
86 |
|
87 /** |
|
88 * @return - TVerdict code |
|
89 * Override of base class pure virtual |
|
90 * Our implementation only gets called if the base class doTestStepPreambleL() did |
|
91 * not leave. That being the case, the current test result value will be EPass. |
|
92 */ |
|
93 TVerdict CT_LbsClientStep_Assistance::doTestStepL() |
|
94 { |
|
95 // Generic test step used to test the LBS Client Notify position update API with assistant data. |
|
96 INFO_PRINTF1(_L(">> CT_LbsClientStep_Assistance::doTestStepL()")); |
|
97 |
|
98 if (TestStepResult() == EPass) |
|
99 { |
|
100 |
|
101 // Expected callbacks flags, most test steps require MO-LR. |
|
102 iFlagsToHaltOn = KLbsCallback_NetSim_Got_Connect | // Net Sim callback events. |
|
103 KLbsCallback_MoLr | |
|
104 KLbsCallback_Got_NotifyUpdate; // notifypositionupdate completed. |
|
105 |
|
106 // Carry out unique test actions. |
|
107 if (GetIntFromConfig(ConfigSection(), KTestCaseId, iTestCaseId)) |
|
108 { |
|
109 switch (iTestCaseId) |
|
110 { |
|
111 |
|
112 case 16: |
|
113 { |
|
114 |
|
115 // Set 'assisted-if-possible' (EGpsPreferTerminalBased) mode |
|
116 |
|
117 CLbsAdmin::TGpsMode mode; |
|
118 |
|
119 User::LeaveIfError(iLbsAdmin->Set(KLbsSettingHomeGpsMode, CLbsAdmin::EGpsPreferTerminalBased)); |
|
120 User::LeaveIfError(iLbsAdmin->Get(KLbsSettingHomeGpsMode, mode)); |
|
121 |
|
122 if(mode != CLbsAdmin::EGpsPreferTerminalBased) |
|
123 { |
|
124 SetTestStepResult(EFail); |
|
125 } |
|
126 |
|
127 } |
|
128 break; |
|
129 |
|
130 |
|
131 case 18: |
|
132 { |
|
133 |
|
134 |
|
135 // Set 'assisted-if-possible' (EGpsPreferTerminalBased) mode |
|
136 |
|
137 CLbsAdmin::TGpsMode mode; |
|
138 |
|
139 User::LeaveIfError(iLbsAdmin->Set(KLbsSettingHomeGpsMode, CLbsAdmin::EGpsPreferTerminalBased)); |
|
140 User::LeaveIfError(iLbsAdmin->Get(KLbsSettingHomeGpsMode, mode)); |
|
141 |
|
142 if(mode != CLbsAdmin::EGpsPreferTerminalBased) |
|
143 { |
|
144 SetTestStepResult(EFail); |
|
145 } |
|
146 } |
|
147 break; |
|
148 |
|
149 // Test case LBS-NotifyPosUpdate-0020 |
|
150 case 20: |
|
151 { |
|
152 |
|
153 // Set 'assisted-if-possible' (EGpsPreferTerminalBased) mode |
|
154 |
|
155 CLbsAdmin::TGpsMode mode; |
|
156 |
|
157 User::LeaveIfError(iLbsAdmin->Set(KLbsSettingHomeGpsMode, CLbsAdmin::EGpsPreferTerminalBased)); |
|
158 User::LeaveIfError(iLbsAdmin->Get(KLbsSettingHomeGpsMode, mode)); |
|
159 // TO DO - ideally we should wait for the admin callback for this change here instead of pausing: |
|
160 User::After(5000000); |
|
161 if(mode != CLbsAdmin::EGpsPreferTerminalBased) |
|
162 { |
|
163 SetTestStepResult(EFail); |
|
164 } |
|
165 } |
|
166 break; |
|
167 |
|
168 default: |
|
169 { |
|
170 User::Panic(KLbsClientStep_Assistance, KErrUnknown); |
|
171 } |
|
172 } |
|
173 } |
|
174 |
|
175 |
|
176 // Inform the test module of the required test mode - will block. |
|
177 |
|
178 // TODO remove modDataIn stuff all of it |
|
179 // utils.NotifyModuleOfConfigChangeL(modDataIn); |
|
180 |
|
181 // Connect to net sim. |
|
182 |
|
183 iNetSim.ConnectL(/*(MLbsNetSimTestObserver*)*/this); |
|
184 |
|
185 // Setup net sim's assistance data. |
|
186 |
|
187 // Create reference location. The test step will verify this is returned correctly |
|
188 // in the netsim callbacks only, it will not be used by the test assistance data provider. |
|
189 |
|
190 // Location to use. |
|
191 RPointerArray<TAny>& srcPosInfoArr = iParent.iSharedData->iVerifyPosInfoArr; |
|
192 TPositionInfo* srcPosInfo = reinterpret_cast<TPositionInfo*>(srcPosInfoArr[0]); |
|
193 TPosition srcPos; |
|
194 srcPosInfo->GetPosition(srcPos); |
|
195 |
|
196 if (!iNetSim.SetReferenceLocation(srcPos)) |
|
197 { |
|
198 INFO_PRINTF1(_L("Failed test, can't set NetSim's reference location.")); |
|
199 SetTestStepResult(EFail); |
|
200 |
|
201 iNetSim.Close(); |
|
202 |
|
203 return TestStepResult(); |
|
204 } |
|
205 // Set plugin to use. |
|
206 TUid pluginUid = TUid::Uid(KAssistanceDataProviderPluginUidValue); |
|
207 if (!iNetSim.SetAssistanceDataProvider(pluginUid)) |
|
208 { |
|
209 INFO_PRINTF1(_L("Failed test, can't set NetSim's assistance data plugin uid.")); |
|
210 SetTestStepResult(EFail); |
|
211 |
|
212 iNetSim.Close(); |
|
213 |
|
214 return TestStepResult(); |
|
215 } |
|
216 |
|
217 |
|
218 // Kick off the keep alive timer - do last to ensure NetSim is ready otherwise the |
|
219 // timer callback may start a MO-LR if the NetSim connected to early. |
|
220 TTimeIntervalMicroSeconds32 interval(KLbsKeepAlivePeriod); |
|
221 |
|
222 iKeepAliveTimer->SetTimer(interval); |
|
223 |
|
224 |
|
225 // Kick off test. |
|
226 CActiveScheduler::Start(); |
|
227 |
|
228 |
|
229 // Clean up. |
|
230 |
|
231 //iNetSim.ClearAssistanceDataFilters(); |
|
232 iNetSim.Close(); |
|
233 } |
|
234 |
|
235 INFO_PRINTF1(_L("<<CT_LbsClientStep_Assistance::doTestStepL()")); |
|
236 |
|
237 return TestStepResult(); |
|
238 } |
|
239 |
|
240 /** NetSim callbacks given for a MoLr, which we invoke as a result of the notify position update. |
|
241 */ |
|
242 |
|
243 // This method called when a client connects to the gateway API |
|
244 |
|
245 void CT_LbsClientStep_Assistance::Connected() |
|
246 { |
|
247 // Call base implementation. |
|
248 CT_LbsNetSimStep::Connected(); |
|
249 |
|
250 switch (iTestCaseId) |
|
251 { |
|
252 |
|
253 case 16: |
|
254 { |
|
255 //Configure network simulation to ensure it does not deliver assistance data. |
|
256 //need to be changed |
|
257 TBool ret = iNetSim.SetResponseError(KErrNotReady, ETrue); |
|
258 } |
|
259 break; |
|
260 |
|
261 // All other test cases required a MO-LR. |
|
262 default: |
|
263 { |
|
264 // Create a posinfo and store in our shared array for later verification. |
|
265 RPointerArray<TAny>& posInfoArr = iParent.iSharedData->iCurrentPosInfoArr; |
|
266 TPositionInfo* posInfo = new(ELeave) TPositionInfo(); |
|
267 |
|
268 T_LbsUtils utils; |
|
269 utils.ResetAndDestroy_PosInfoArr(posInfoArr); // Clear previous entries before new entry is appended. |
|
270 |
|
271 posInfoArr.Append(posInfo); |
|
272 |
|
273 // Kick off pos update - this will invoke the assistance data processing |
|
274 // within the test module. The result of this will be reported back to |
|
275 // the test step via the module data bus monitor. |
|
276 iDoPosUpdate->StartL(*posInfo); |
|
277 |
|
278 // Move to the waiting state. |
|
279 iState = CT_LbsNetSimStep::EWaiting; |
|
280 } |
|
281 } |
|
282 } |
|
283 |
|
284 |
|
285 //called when a client disconnects to the gateway API |
|
286 void CT_LbsClientStep_Assistance::Disconnected() |
|
287 { |
|
288 // Call base implementation. |
|
289 CT_LbsNetSimStep::Disconnected(); |
|
290 } |
|
291 |
|
292 // The data to start MoLr . If this blank then we are starting an MoLr, if not then X3P |
|
293 void CT_LbsClientStep_Assistance::NotifyRegisterLcsMoLr(const TDesC& aData) |
|
294 { |
|
295 // Call base implementation. |
|
296 CT_LbsNetSimStep::NotifyRegisterLcsMoLr(aData); |
|
297 |
|
298 // Verify the aData is blank to indicate this is a MOLR. |
|
299 if (aData != KNullDesC) |
|
300 { |
|
301 INFO_PRINTF1(_L("Failed test, register contains data.")); |
|
302 SetTestStepResult(EFail); |
|
303 } |
|
304 } |
|
305 // The reason the MoLr ended |
|
306 void CT_LbsClientStep_Assistance::NotifyReleaseLcsMoLr(TInt aReason) |
|
307 { |
|
308 // Call base implementation. |
|
309 CT_LbsNetSimStep::NotifyReleaseLcsMoLr(aReason); |
|
310 |
|
311 if (aReason != KErrNone) |
|
312 { |
|
313 INFO_PRINTF2(_L("Failed test, bad release reason %d."), aReason); |
|
314 SetTestStepResult(EFail); |
|
315 } |
|
316 |
|
317 } |
|
318 // A measurement control |
|
319 |
|
320 void CT_LbsClientStep_Assistance::NotifyMeasurementControlLocation(const TPositionInfo& aPosition, |
|
321 const RLbsAssistanceDataBuilderSet& aData, |
|
322 const TLbsNetPosRequestQuality& aQuality) |
|
323 |
|
324 { |
|
325 T_LbsUtils utils; |
|
326 |
|
327 // Call base implementation. |
|
328 CT_LbsNetSimStep::NotifyMeasurementControlLocation(aPosition, aData, aQuality); |
|
329 |
|
330 // Verify the reference position - use the entry in the verify pos info array. |
|
331 RPointerArray<TAny>& verifyPosInfoArr = iParent.iSharedData->iVerifyPosInfoArr; |
|
332 TPositionInfo* verifyPosInfo = reinterpret_cast<TPositionInfo*>(verifyPosInfoArr[0]); |
|
333 |
|
334 if (!utils.Compare_PosInfo(*verifyPosInfo, aPosition, T_LbsUtils::ERoughAccuracy)) |
|
335 { |
|
336 INFO_PRINTF1(_L("Failed test, position incorrect.")); |
|
337 SetTestStepResult(EFail); |
|
338 } |
|
339 |
|
340 |
|
341 // TODO: Check if we can verify aQuality in any way. |
|
342 (void)aQuality; |
|
343 } |
|
344 |
|
345 |
|
346 void CT_LbsClientStep_Assistance::NotifyFacilityLcsMoLrResult(TInt aReason, const TPositionInfo& aPosition) |
|
347 { |
|
348 // Call base implementation. |
|
349 CT_LbsNetSimStep::NotifyFacilityLcsMoLrResult(aReason, aPosition); |
|
350 |
|
351 if (aReason != KErrNone) |
|
352 { |
|
353 INFO_PRINTF2(_L("Failed test, bad release reason %d."), aReason); |
|
354 SetTestStepResult(EFail); |
|
355 } |
|
356 |
|
357 // Verify the position returned from the network, this will be the same position |
|
358 // we sent to the network as the result of the MO-LR, thus use the entry given by |
|
359 // the test module. |
|
360 T_LbsUtils utils; |
|
361 RPointerArray<TAny>& verifyPosInfoArr = iParent.iSharedData->iVerifyPosInfoArr; |
|
362 TPositionInfo* verifyPosInfo = reinterpret_cast<TPositionInfo*>(verifyPosInfoArr[0]); |
|
363 |
|
364 if (!utils.Compare_PosInfo(*verifyPosInfo, aPosition, T_LbsUtils::ERoughAccuracy)) |
|
365 { |
|
366 INFO_PRINTF1(_L("Failed test, position incorrect.")); |
|
367 SetTestStepResult(EFail); |
|
368 } |
|
369 } |
|
370 |
|
371 void CT_LbsClientStep_Assistance::NotifyMeasurementReportLocation(const TPositionInfo& aPosition) |
|
372 { |
|
373 // Call base implementation. |
|
374 CT_LbsNetSimStep::NotifyMeasurementReportLocation(aPosition); |
|
375 |
|
376 // Verify the position given to the network, this will be the same position |
|
377 // returned as the result of the MO-LR, thus use the entry given by |
|
378 // the test module. |
|
379 T_LbsUtils utils; |
|
380 RPointerArray<TAny>& verifyPosInfoArr = iParent.iSharedData->iVerifyPosInfoArr; |
|
381 TPositionInfo* verifyPosInfo = reinterpret_cast<TPositionInfo*>(verifyPosInfoArr[0]); |
|
382 |
|
383 if (!utils.Compare_PosInfo(*verifyPosInfo, aPosition, T_LbsUtils::ERoughAccuracy)) |
|
384 { |
|
385 INFO_PRINTF1(_L("Failed test, position incorrect.")); |
|
386 SetTestStepResult(EFail); |
|
387 } |
|
388 } |
|
389 |
|
390 void CT_LbsClientStep_Assistance::NotifyMeasurementReportControlFailure(TInt aReason) |
|
391 { |
|
392 // Call base implementation. |
|
393 CT_LbsNetSimStep::NotifyMeasurementReportControlFailure(aReason); |
|
394 |
|
395 INFO_PRINTF2(_L("Failed test, got un-expected control failure with reason code = %d."), aReason); |
|
396 SetTestStepResult(EFail); |
|
397 |
|
398 } |
|
399 |
|
400 void CT_LbsClientStep_Assistance::NotifyMeasurementReportRequestMoreAssistanceData(const TLbsAssistanceDataGroup& aFilter) |
|
401 { |
|
402 (void)aFilter; |
|
403 |
|
404 INFO_PRINTF1(_L("Got - Net Sim Notify Measurement Report Request More Assistance Data - Callback Event.")); |
|
405 |
|
406 // Note that we do NOT set the callback flag here (since it may not be set and the base class does an equivalence test, so we don't test for it) |
|
407 } |
|
408 |
|
409 /** Notify position update callback. |
|
410 |
|
411 The notify position update as completed. We can mark as done in the callback flags. |
|
412 */ |
|
413 void CT_LbsClientStep_Assistance::MT_LbsDoPosUpdateCallback(TRequestStatus& aStatus) |
|
414 { |
|
415 INFO_PRINTF1(_L("Got - Notify Update - Callback Event.")); |
|
416 |
|
417 SetCallbackFlag(KLbsCallback_Got_NotifyUpdate); |
|
418 |
|
419 if (KErrNone != aStatus.Int()) |
|
420 { |
|
421 INFO_PRINTF2(_L("Failed test, pos info request err = %d."), aStatus.Int()); |
|
422 SetTestStepResult(EFail); |
|
423 } |
|
424 |
|
425 // TODO also we expect this to happen before the last netsim callbacks happen if not |
|
426 // we can't use current pos in those funcs maybe have to use the verify one not as nice. |
|
427 |
|
428 |
|
429 } |
|
430 |
|
431 |
|
432 //END |