|
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 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 ctlbsclientstepignoreaccurracysetting.cpp |
|
15 // |
|
16 // |
|
17 |
|
18 #include "ctlbsclientstepignoreaccurracysetting.h" |
|
19 |
|
20 #include <lbs.h> |
|
21 #include <lbssatellite.h> |
|
22 #include <lbsadmin.h> |
|
23 |
|
24 #include "tlbsutils.h" |
|
25 #include "ctlbsasyncwaiter.h" |
|
26 |
|
27 #define EXPECTED_GPS_ACCURACY_HORIZONTAL 10 |
|
28 #define EXPECTED_GPS_ACCURACY_VERTICAL 10 |
|
29 |
|
30 const TTimeIntervalMicroSeconds KModuleTimeout = 5000000;//makes test module time out(which should be more than the Maxtime in lbsprofile.ini) |
|
31 |
|
32 /** |
|
33 * Construction. |
|
34 */ |
|
35 CT_LbsClientStep_IgnoreAccuracySetting* CT_LbsClientStep_IgnoreAccuracySetting::New(CT_LbsClientServer& aParent) |
|
36 { |
|
37 // Note the lack of ELeave. |
|
38 // This means that having insufficient memory will return NULL; |
|
39 CT_LbsClientStep_IgnoreAccuracySetting* testStep = new CT_LbsClientStep_IgnoreAccuracySetting(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 |
|
52 return testStep; |
|
53 } |
|
54 |
|
55 |
|
56 CT_LbsClientStep_IgnoreAccuracySetting::CT_LbsClientStep_IgnoreAccuracySetting(CT_LbsClientServer& aParent) |
|
57 : CT_LbsClientStep(aParent), iTestCaseId(0) |
|
58 { |
|
59 SetTestStepName(KLbsClientStep_IgnoreAccuracySetting); |
|
60 } |
|
61 |
|
62 |
|
63 void CT_LbsClientStep_IgnoreAccuracySetting::ConstructL() |
|
64 { |
|
65 // Connect server. |
|
66 User::LeaveIfError(iServer.Connect()); |
|
67 } |
|
68 |
|
69 |
|
70 /** |
|
71 * Destructor |
|
72 */ |
|
73 CT_LbsClientStep_IgnoreAccuracySetting::~CT_LbsClientStep_IgnoreAccuracySetting() |
|
74 { |
|
75 iPositioner.Close(); |
|
76 CloseNetSim(); |
|
77 iServer.Close(); |
|
78 } |
|
79 /** |
|
80 * The set-up for the tests open the net sim, where required (the terminal based |
|
81 * tests) and open the connection to the server. Also it sets the update options |
|
82 * for the requests with those in the ini file. RPositioner is open through one |
|
83 * of the three APIs, depending on the tests |
|
84 */ |
|
85 TVerdict CT_LbsClientStep_IgnoreAccuracySetting::doTestStepPreambleL() |
|
86 { |
|
87 // Process some common pre setting to test steps then set SetTestStepResult to EFail or Epass. |
|
88 INFO_PRINTF1(_L(">>CT_LbsClientStep::doTestStepPreambleL()")); |
|
89 SetTestStepResult(EPass); |
|
90 T_LbsUtils utils; |
|
91 |
|
92 if(GetIntFromConfig(ConfigSection(), KTestCaseId, iTestCaseId)) |
|
93 { |
|
94 switch(iTestCaseId) |
|
95 { // open the network simulator for the tests that run in terminal based |
|
96 case 151: // LBS-IGNORE-ACCURACY-ON-TERMINAL-BASED-001 |
|
97 case 152: // LBS-IGNORE-ACCURACY-ON-TERMINAL-BASED-002 |
|
98 case 153: // LBS-IGNORE-ACCURACY-ON-TERMINAL-BASED-003 |
|
99 { |
|
100 CloseNetSim(); |
|
101 User::LeaveIfError(OpenNetSim()); |
|
102 break; |
|
103 } |
|
104 default: |
|
105 { |
|
106 } |
|
107 } |
|
108 |
|
109 switch(iTestCaseId) |
|
110 { // open the positioner for the tests that are doing a position update |
|
111 // the positioner is opened through the required API for each test |
|
112 case 1: // LBS-IGNORE-ACCURACY-ENABLED-001 |
|
113 case 2: // LBS-IGNORE-ACCURACY-DISABLED-001 |
|
114 { // do nothing, these tests don't ask for a position update |
|
115 break; |
|
116 } |
|
117 case 3: // LBS-IGNORE-ACCURACY-ABSENT-001 |
|
118 case 101: // LBS-MOLR-IGNORE-ACCURACY-ON-ACCURATE-001 |
|
119 case 104: // LBS-MOLR-IGNORE-ACCURACY-ON-INACCURATE-001 |
|
120 case 107: // LBS-MOLR-IGNORE-ACCURACY-ON-TIMEOUT-001 |
|
121 case 110: // LBS-IGNORE-ACCURACY-ON-PARTIAL-UPDATE-001 |
|
122 case 111: // LBS-IGNORE-ACCURACY-ON-PARTIAL-UPDATE-002 |
|
123 case 114: // LBS-IGNORE-ACCURACY-ON-EARLY-COMPLETE-001 |
|
124 case 151: // LBS-IGNORE-ACCURACY-ON-TERMINAL-BASED-001 |
|
125 case 201: // LBS-MOLR-IGNORE-ACCURACY-OFF-ACCURATE-001 |
|
126 case 204: // LBS-MOLR-IGNORE-ACCURACY-OFF-INACCURATE-001 |
|
127 case 207: // LBS-MOLR-IGNORE-ACCURACY-OFF-TIMEOUT-001 |
|
128 case 210: // LBS-IGNORE-ACCURACY-OFF-PARTIAL-UPDATE-001 |
|
129 case 211: // LBS-IGNORE-ACCURACY-OFF-PARTIAL-UPDATE-002 |
|
130 case 214: // LBS-IGNORE-ACCURACY-OFF-EARLY-COMPLETE-001 |
|
131 { |
|
132 User::LeaveIfError(iPositioner.Open(iServer)); |
|
133 break; |
|
134 } |
|
135 case 102: // LBS-MOLR-IGNORE-ACCURACY-ON-ACCURATE-002 |
|
136 case 105: // LBS-MOLR-IGNORE-ACCURACY-ON-INACCURATE-002 |
|
137 case 108: // LBS-MOLR-IGNORE-ACCURACY-ON-TIMEOUT-002 |
|
138 case 152: // LBS-IGNORE-ACCURACY-ON-TERMINAL-BASED-002 |
|
139 case 202: // LBS-MOLR-IGNORE-ACCURACY-OFF-ACCURATE-002 |
|
140 case 205: // LBS-MOLR-IGNORE-ACCURACY-OFF-INACCURATE-002 |
|
141 case 208: // LBS-MOLR-IGNORE-ACCURACY-OFF-TIMEOUT-002 |
|
142 { |
|
143 TPositionModuleId networkModuleId = utils.GetAGpsModuleIdL(iServer); |
|
144 User::LeaveIfError(iPositioner.Open(iServer, networkModuleId)); |
|
145 break; |
|
146 } |
|
147 case 103: // LBS-MOLR-IGNORE-ACCURACY-ON-ACCURATE-003 |
|
148 case 106: // LBS-MOLR-IGNORE-ACCURACY-ON-INACCURATE-003 |
|
149 case 109: // LBS-MOLR-IGNORE-ACCURACY-ON-TIMEOUT-003 |
|
150 case 153: // LBS-IGNORE-ACCURACY-ON-TERMINAL-BASED-003 |
|
151 case 203: // LBS-MOLR-IGNORE-ACCURACY-OFF-ACCURATE-003 |
|
152 case 206: // LBS-MOLR-IGNORE-ACCURACY-OFF-INACCURATE-003 |
|
153 case 209: // LBS-MOLR-IGNORE-ACCURACY-OFF-TIMEOUT-003 |
|
154 { |
|
155 TPositionCriteria criteria; |
|
156 TPositionQuality quality; |
|
157 // set up the required accuracy |
|
158 quality.SetHorizontalAccuracy(EXPECTED_GPS_ACCURACY_HORIZONTAL); |
|
159 quality.SetVerticalAccuracy(EXPECTED_GPS_ACCURACY_VERTICAL); |
|
160 criteria.SetRequiredQuality(quality); |
|
161 User::LeaveIfError(iPositioner.Open(iServer, criteria)); |
|
162 break; |
|
163 } |
|
164 default: |
|
165 { |
|
166 SetTestStepResult(EFail); |
|
167 } |
|
168 } |
|
169 if(iTestCaseId != 1 && iTestCaseId !=2) |
|
170 { // Loading the update options for all tests, except those that |
|
171 // don't request a position update |
|
172 TPtrC configFileName; |
|
173 _LIT(KUpdateOptionsFile, "pos_infos_file"); |
|
174 |
|
175 GetStringFromConfig(ConfigSection(), KUpdateOptionsFile, configFileName); |
|
176 |
|
177 TPositionUpdateOptions updateOpts; |
|
178 |
|
179 utils.GetConfigured_ModuleUpdateOptionsL(configFileName, ConfigSection(), updateOpts); |
|
180 iPositioner.SetUpdateOptions(updateOpts); |
|
181 } |
|
182 } |
|
183 else |
|
184 { |
|
185 SetTestStepResult(EFail); |
|
186 } |
|
187 |
|
188 return TestStepResult(); |
|
189 } |
|
190 |
|
191 /** |
|
192 * @return - TVerdict code |
|
193 * Override of base class pure virtual |
|
194 * Our implementation only gets called if the base class doTestStepPreambleL() did |
|
195 * not leave. That being the case, the current test result value will be EPass. |
|
196 */ |
|
197 TVerdict CT_LbsClientStep_IgnoreAccuracySetting::doTestStepL() |
|
198 { |
|
199 // Generic test step used to test the LBS SetUpdateOptions API. |
|
200 INFO_PRINTF1(_L(">>CT_LbsClientStep_IgnoreAccuracySetting::doTestStepL()")); |
|
201 |
|
202 if(iTestCaseId == 1 || iTestCaseId == 2) |
|
203 { // Testing the ignore accuracy setting is as required |
|
204 CLbsAdmin* lbsAdmin = CLbsAdmin::NewL(); |
|
205 CleanupStack::PushL(lbsAdmin); |
|
206 CLbsAdmin::TSpecialFeature ignoreAccuracySetting; |
|
207 TInt err = lbsAdmin->Get(KLbsSpecialFeatureIgnoreAccuracy, ignoreAccuracySetting); |
|
208 if(err != KErrNone) |
|
209 { |
|
210 SetTestStepResult(EFail); |
|
211 } |
|
212 else |
|
213 { |
|
214 switch(iTestCaseId) |
|
215 { |
|
216 case 1: // LBS-IGNORE-ACCURACY-ENABLED-001 |
|
217 { |
|
218 if(ignoreAccuracySetting != CLbsAdmin::ESpecialFeatureOn) |
|
219 { |
|
220 SetTestStepResult(EFail); |
|
221 } |
|
222 break; |
|
223 } |
|
224 case 2: // LBS-IGNORE-ACCURACY-DISABLED-001 |
|
225 { |
|
226 if(ignoreAccuracySetting != CLbsAdmin::ESpecialFeatureOff) |
|
227 { |
|
228 SetTestStepResult(EFail); |
|
229 } |
|
230 break; |
|
231 } |
|
232 default: |
|
233 { |
|
234 SetTestStepResult(EFail); |
|
235 } |
|
236 } |
|
237 } |
|
238 |
|
239 CleanupStack::PopAndDestroy(lbsAdmin); |
|
240 } |
|
241 else |
|
242 { |
|
243 // Testing the ignore accuracy setting is absent |
|
244 if(iTestCaseId == 3) |
|
245 { // Testing the ignore accuracy setting is absent |
|
246 CLbsAdmin* lbsAdmin = CLbsAdmin::NewL(); |
|
247 CleanupStack::PushL(lbsAdmin); |
|
248 TInt err(KErrNone); |
|
249 CLbsAdmin::TSpecialFeature ignoreAccuracySetting; |
|
250 err = lbsAdmin->Get(KLbsSpecialFeatureIgnoreAccuracy, ignoreAccuracySetting); |
|
251 if(err != KErrNone || ignoreAccuracySetting != CLbsAdmin::ESpecialFeatureOff) |
|
252 { |
|
253 SetTestStepResult(EFail); |
|
254 } |
|
255 CleanupStack::PopAndDestroy(lbsAdmin); |
|
256 } |
|
257 |
|
258 switch(iTestCaseId) |
|
259 { // Requesting the module to delay it's response so we get a time-out |
|
260 case 107: // LBS-MOLR-IGNORE-ACCURACY-ON-TIMEOUT-001 |
|
261 case 108: // LBS-MOLR-IGNORE-ACCURACY-ON-TIMEOUT-002 |
|
262 case 109: // LBS-MOLR-IGNORE-ACCURACY-ON-TIMEOUT-003 |
|
263 case 207: // LBS-MOLR-IGNORE-ACCURACY-OFF-TIMEOUT-001 |
|
264 case 208: // LBS-MOLR-IGNORE-ACCURACY-OFF-TIMEOUT-002 |
|
265 case 209: // LBS-MOLR-IGNORE-ACCURACY-OFF-TIMEOUT-003 |
|
266 { |
|
267 if (iParent.iSharedData->iTestModuleInUse) |
|
268 { |
|
269 T_LbsUtils utils; |
|
270 TModuleDataIn modDataIn; |
|
271 |
|
272 modDataIn.iRequestType = TModuleDataIn::EModuleRequestTimeOut; |
|
273 modDataIn.iTimeOut = KModuleTimeout; |
|
274 |
|
275 utils.NotifyModuleOfConfigChangeL(modDataIn); // This will block. |
|
276 } |
|
277 else |
|
278 { |
|
279 SetTestStepResult(EFail); |
|
280 } |
|
281 break; |
|
282 } |
|
283 default: |
|
284 { |
|
285 break; |
|
286 } |
|
287 } |
|
288 |
|
289 if (TestStepResult()==EPass) |
|
290 { |
|
291 T_LbsUtils utils; |
|
292 |
|
293 // Create a posinfo and store in our shared array for later verification. |
|
294 RPointerArray<TAny>& posInfoArr = iParent.iSharedData->iCurrentPosInfoArr; |
|
295 // The posInfo shouldn't be put on the cleanup stack because ownership is passed to the parent |
|
296 TPositionInfo* posInfo = new(ELeave) TPositionInfo(); |
|
297 |
|
298 utils.ResetAndDestroy_PosInfoArr(posInfoArr); // Clear previous entries before new entry is appended. |
|
299 |
|
300 posInfoArr.Append(posInfo); |
|
301 TInt err; |
|
302 |
|
303 // Request a position update |
|
304 switch(iTestCaseId) |
|
305 { |
|
306 case 114: // LBS-IGNORE-ACCURACY-ON-EARLY-COMPLETE-001 |
|
307 case 214: // LBS-IGNORE-ACCURACY-OFF-EARLY-COMPLETE-001 |
|
308 { // In the early complete tests we request for a position |
|
309 // update in a different way so the client can complete |
|
310 // the request early |
|
311 err = DoNotifyUpdateL(*posInfo); |
|
312 if(err != KPositionPartialUpdate) |
|
313 { |
|
314 SetTestStepResult(EFail); |
|
315 break; |
|
316 } |
|
317 |
|
318 TRequestStatus status; |
|
319 iPositioner.NotifyPositionUpdate(*posInfo, status); |
|
320 |
|
321 err = iPositioner.CompleteRequest(EPositionerNotifyPositionUpdate); |
|
322 if(err != KErrNone) |
|
323 { |
|
324 SetTestStepResult(EFail); |
|
325 } |
|
326 // this should complete with either KErrNone or KErrCancel |
|
327 User::WaitForRequest(status); |
|
328 |
|
329 err = status.Int(); |
|
330 break; |
|
331 } |
|
332 default: |
|
333 { |
|
334 // Get the actual position |
|
335 err = DoNotifyUpdateL(*posInfo); |
|
336 } |
|
337 } |
|
338 |
|
339 if(iTestCaseId == 151 || iTestCaseId == 153) |
|
340 { // expect reference position in the appropiate terminal based tests |
|
341 if(KErrNone != err) |
|
342 { |
|
343 SetTestStepResult(EFail); |
|
344 } |
|
345 else |
|
346 { |
|
347 // Verify reference position. |
|
348 TPositionInfo verifyRefPosInfo; |
|
349 verifyRefPosInfo.SetPosition(iRefPos); |
|
350 |
|
351 if (!utils.Compare_PosInfo(verifyRefPosInfo, *posInfo)) |
|
352 { |
|
353 if(!iParent.iSharedData->iTestModuleInUse) |
|
354 { |
|
355 WARN_PRINTF1(_L("WARNING: position received was not reference position")); |
|
356 } |
|
357 else |
|
358 { |
|
359 INFO_PRINTF1(_L("Failed test, reference position incorrect.")); |
|
360 SetTestStepResult(EFail); |
|
361 } |
|
362 } |
|
363 } |
|
364 err = DoNotifyUpdateL(*posInfo); |
|
365 } |
|
366 |
|
367 // check we receive the appropiate error code from the request we made |
|
368 switch(iTestCaseId) |
|
369 { |
|
370 case 101: // LBS-MOLR-IGNORE-ACCURACY-ON-ACCURATE-001 |
|
371 case 104: // LBS-MOLR-IGNORE-ACCURACY-ON-INACCURATE-001 |
|
372 case 201: // LBS-MOLR-IGNORE-ACCURACY-OFF-ACCURATE-001 |
|
373 case 102: // LBS-MOLR-IGNORE-ACCURACY-ON-ACCURATE-002 |
|
374 case 105: // LBS-MOLR-IGNORE-ACCURACY-ON-INACCURATE-002 |
|
375 case 151: // LBS-IGNORE-ACCURACY-ON-TERMINAL-BASED-001 |
|
376 case 152: // LBS-IGNORE-ACCURACY-ON-TERMINAL-BASED-002 |
|
377 case 153: // LBS-IGNORE-ACCURACY-ON-TERMINAL-BASED-003 |
|
378 case 202: // LBS-MOLR-IGNORE-ACCURACY-OFF-ACCURATE-002 |
|
379 case 103: // LBS-MOLR-IGNORE-ACCURACY-ON-ACCURATE-003 |
|
380 case 106: // LBS-MOLR-IGNORE-ACCURACY-ON-INACCURATE-003 |
|
381 case 203: // LBS-MOLR-IGNORE-ACCURACY-OFF-ACCURATE-003 |
|
382 { |
|
383 if (KErrNone != err) |
|
384 { |
|
385 INFO_PRINTF2(_L("Failed test, error = %d."), err); |
|
386 SetTestStepResult(EFail); |
|
387 } |
|
388 break; |
|
389 } |
|
390 case 107: // LBS-MOLR-IGNORE-ACCURACY-ON-TIMEOUT-001 |
|
391 case 108: // LBS-MOLR-IGNORE-ACCURACY-ON-TIMEOUT-002 |
|
392 case 109: // LBS-MOLR-IGNORE-ACCURACY-ON-TIMEOUT-003 |
|
393 case 207: // LBS-MOLR-IGNORE-ACCURACY-OFF-TIMEOUT-001 |
|
394 case 208: // LBS-MOLR-IGNORE-ACCURACY-OFF-TIMEOUT-002 |
|
395 case 209: // LBS-MOLR-IGNORE-ACCURACY-OFF-TIMEOUT-003 |
|
396 { |
|
397 if (KErrTimedOut != err) |
|
398 { |
|
399 INFO_PRINTF2(_L("Failed test, expected KErrTimedOut, got error = %d."), err); |
|
400 SetTestStepResult(EFail); |
|
401 } |
|
402 break; |
|
403 } |
|
404 case 3: // LBS-IGNORE-ACCURACY-ABSENT-001 |
|
405 case 110: // LBS-IGNORE-ACCURACY-ON-PARTIAL-UPDATE-001 |
|
406 case 204: // LBS-MOLR-IGNORE-ACCURACY-OFF-INACCURATE-001 |
|
407 case 205: // LBS-MOLR-IGNORE-ACCURACY-OFF-INACCURATE-002 |
|
408 case 206: // LBS-MOLR-IGNORE-ACCURACY-OFF-INACCURATE-003 |
|
409 case 210: // LBS-IGNORE-ACCURACY-OFF-PARTIAL-UPDATE-001 |
|
410 { |
|
411 if (KPositionQualityLoss != err) |
|
412 { |
|
413 INFO_PRINTF2(_L("Failed test, expected KPositionQualityLoss, got error = %d."), err); |
|
414 SetTestStepResult(EFail); |
|
415 } |
|
416 break; |
|
417 } |
|
418 case 111: // LBS-IGNORE-ACCURACY-ON-PARTIAL-UPDATE-002 |
|
419 case 211: // LBS-IGNORE-ACCURACY-OFF-PARTIAL-UPDATE-002 |
|
420 { |
|
421 if (KPositionPartialUpdate != err) |
|
422 { |
|
423 INFO_PRINTF2(_L("Failed test, expected KPositionPartialUpdate, got error = %d."), err); |
|
424 SetTestStepResult(EFail); |
|
425 } |
|
426 break; |
|
427 } |
|
428 case 114: // LBS-IGNORE-ACCURACY-ON-EARLY-COMPLETE-001 |
|
429 case 214: // LBS-IGNORE-ACCURACY-OFF-EARLY-COMPLETE-001 |
|
430 { |
|
431 if (KPositionEarlyComplete != err) |
|
432 { |
|
433 INFO_PRINTF2(_L("Failed test, expected KPositionEarlyComplete, got error = %d."), err); |
|
434 SetTestStepResult(EFail); |
|
435 } |
|
436 break; |
|
437 } |
|
438 default: |
|
439 { |
|
440 INFO_PRINTF2(_L("Failed test, unexpected Test Case Id %d"), iTestCaseId); |
|
441 SetTestStepResult(EFail); |
|
442 } |
|
443 } |
|
444 } |
|
445 } |
|
446 |
|
447 INFO_PRINTF1(_L("<<CT_LbsClientStep_IgnoreAccuracySetting::doTestStepL()")); |
|
448 |
|
449 return TestStepResult(); |
|
450 } |