|
1 // Copyright (c) 2005-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 // Example CTestStep derived implementation |
|
15 // |
|
16 // |
|
17 |
|
18 /** |
|
19 @file NoServerStep.cpp |
|
20 @internalTechnology |
|
21 */ |
|
22 #include "noserverstep.h" |
|
23 #include "te_lbsapisuitedefs.h" |
|
24 |
|
25 #include "lcfsbucommondefinitions.h" |
|
26 |
|
27 #include <lbs.h> |
|
28 #include <lbssatellite.h> |
|
29 #include <e32math.h> |
|
30 #include <s32mem.h> |
|
31 #include <bautils.h> |
|
32 |
|
33 CNoServerStep::~CNoServerStep() |
|
34 /** |
|
35 * Destructor |
|
36 */ |
|
37 { |
|
38 } |
|
39 |
|
40 CNoServerStep::CNoServerStep() |
|
41 /** |
|
42 * Constructor |
|
43 */ |
|
44 { |
|
45 // **MUST** call SetTestStepName in the constructor as the controlling |
|
46 // framework uses the test step name immediately following construction to set |
|
47 // up the step's unique logging ID. |
|
48 SetTestStepName(KNoServerStep); |
|
49 } |
|
50 |
|
51 TVerdict CNoServerStep::doTestStepPreambleL() |
|
52 /** |
|
53 * @return - TVerdict code |
|
54 * Override of base class virtual |
|
55 */ |
|
56 { |
|
57 CTe_LbsApiSuiteStepBase::doTestStepPreambleL(); |
|
58 if (TestStepResult()!=EPass) |
|
59 return TestStepResult(); |
|
60 // process some pre setting to this test step then set SetTestStepResult to EFail or Epass. |
|
61 SetTestStepResult(EPass); |
|
62 return TestStepResult(); |
|
63 } |
|
64 |
|
65 |
|
66 TVerdict CNoServerStep::doTestStepL() |
|
67 /** |
|
68 * @return - TVerdict code |
|
69 * Override of base class pure virtual |
|
70 * Our implementation only gets called if the base class doTestStepPreambleL() did |
|
71 * not leave. That being the case, the current test result value will be EPass. |
|
72 */ |
|
73 { |
|
74 if (TestStepResult()==EPass) |
|
75 { |
|
76 TInt test; |
|
77 if(!GetIntFromConfig(ConfigSection(),KTe_LbsApiSuiteInt,test) |
|
78 ) |
|
79 { |
|
80 // Leave if there's any error. |
|
81 User::Leave(KErrNotFound); |
|
82 } |
|
83 SetTestStepResult(EPass); |
|
84 StartL(test); |
|
85 } |
|
86 return TestStepResult(); |
|
87 } |
|
88 |
|
89 |
|
90 |
|
91 TVerdict CNoServerStep::doTestStepPostambleL() |
|
92 /** |
|
93 * @return - TVerdict code |
|
94 * Override of base class virtual |
|
95 */ |
|
96 { |
|
97 // process something post setting to the test step |
|
98 // uncomment the following line if you have common post setting to all the test steps in there |
|
99 // CTe_LbsApiSuiteStepBase::doTestStepPostambleL(); |
|
100 // uncomment the following line if you have post process or remove the following line if no post process |
|
101 // SetTestStepResult(EPass); // or EFail |
|
102 return TestStepResult(); |
|
103 } |
|
104 |
|
105 |
|
106 void CNoServerStep::StartL (TInt aIndex) |
|
107 { |
|
108 switch (aIndex) |
|
109 { |
|
110 case 0: |
|
111 RPositionServer_NoConnectionL (); |
|
112 break; |
|
113 case 1: |
|
114 RPositionServer_NoL (); |
|
115 break; |
|
116 case 2: |
|
117 RPositioner_NoL (); |
|
118 break; |
|
119 default: |
|
120 break; |
|
121 } |
|
122 } |
|
123 |
|
124 void CNoServerStep::CheckThereIsNoServerL() |
|
125 { |
|
126 DECLARE_ERROR_LOGGING; |
|
127 |
|
128 RPositionServer server; |
|
129 CleanupClosePushL(server); |
|
130 FAIL(server.Connect() == KErrNone, |
|
131 "Location Server must be deleted to run this test case"); |
|
132 |
|
133 CleanupStack::PopAndDestroy(&server); |
|
134 } |
|
135 |
|
136 |
|
137 // 1.1.2 Connect but server doesn't start |
|
138 // The test must be started when there is no server |
|
139 // See LBSAPIACCTESTNOSVR.BAT for details |
|
140 void CNoServerStep::RPositionServer_NoConnectionL() |
|
141 { |
|
142 DECLARE_ERROR_LOGGING; |
|
143 StandardPrepareL(); |
|
144 CheckThereIsNoServerL(); |
|
145 |
|
146 RPositionServer server; |
|
147 |
|
148 __UHEAP_MARK; |
|
149 CHECK( 0 == server.Handle() ); |
|
150 CHECK( KErrNone != server.Connect() ); |
|
151 CHECK( server.Handle() == 0 ); |
|
152 __UHEAP_MARKEND; |
|
153 |
|
154 StandardCleanup(); |
|
155 } |
|
156 |
|
157 // x.x.x Connect and try to execute RPositionServer methods |
|
158 // This should fail with panic |
|
159 |
|
160 TInt No_Server_GetDefaultModuleId(TAny* /*aPtr*/) |
|
161 { |
|
162 RPositionServer server; |
|
163 TPositionModuleId moduleId = KPositionNullModuleId; |
|
164 server.GetDefaultModuleId(moduleId); |
|
165 return KErrGeneral; |
|
166 } |
|
167 |
|
168 |
|
169 TInt No_Server_GetNumModules(TAny* /*aPtr*/) |
|
170 { |
|
171 RPositionServer server; |
|
172 TUint numModules; |
|
173 server.GetNumModules(numModules); |
|
174 return KErrGeneral; |
|
175 } |
|
176 |
|
177 |
|
178 TInt No_Server_GetModuleInfoByIndex(TAny* /*aPtr*/) |
|
179 { |
|
180 RPositionServer server; |
|
181 TUint index = 0; |
|
182 TPositionModuleInfo info; |
|
183 server.GetModuleInfoByIndex(index, info); |
|
184 return KErrGeneral; |
|
185 } |
|
186 |
|
187 |
|
188 TInt No_Server_GetModuleInfoById(TAny* /*aPtr*/) |
|
189 { |
|
190 RPositionServer server; |
|
191 TPositionModuleId moduleId = KPositionNullModuleId; |
|
192 TPositionModuleInfo info; |
|
193 server.GetModuleInfoById(moduleId, info); |
|
194 return KErrGeneral; |
|
195 } |
|
196 |
|
197 |
|
198 TInt No_Server_GetModuleStatus(TAny* /*aPtr*/) |
|
199 { |
|
200 RPositionServer server; |
|
201 TPositionModuleStatus moduleStatus; |
|
202 TPositionModuleId moduleId = KPositionNullModuleId; |
|
203 server.GetModuleStatus(moduleStatus, moduleId); |
|
204 return KErrGeneral; |
|
205 } |
|
206 |
|
207 |
|
208 TInt No_Server_NotifyModuleStatusEvent(TAny* /*aPtr*/) |
|
209 { |
|
210 RPositionServer server; |
|
211 TPositionModuleStatusEvent event; |
|
212 TPositionModuleId moduleId = KPositionNullModuleId; |
|
213 TRequestStatus request; |
|
214 server.NotifyModuleStatusEvent(event, request, moduleId); |
|
215 return KErrGeneral; |
|
216 } |
|
217 |
|
218 |
|
219 TInt No_Server_CancelRequest(TAny* /*aPtr*/) |
|
220 { |
|
221 RPositionServer server; |
|
222 server.CancelRequest(EPositionServerNotifyModuleStatusEvent); |
|
223 return KErrGeneral; |
|
224 } |
|
225 |
|
226 |
|
227 void CNoServerStep::RPositionServer_NoL() |
|
228 { |
|
229 DECLARE_ERROR_LOGGING; |
|
230 StandardPrepareL(); |
|
231 CheckThereIsNoServerL(); |
|
232 |
|
233 RPositionServer server; |
|
234 |
|
235 CHECK( KErrNone != server.Connect() ); |
|
236 FAIL( server.Handle() != 0 , "Server found, while should not be"); |
|
237 |
|
238 DO_PANIC_TEST_L( |
|
239 No_Server_GetDefaultModuleId, |
|
240 KPosClientFault, |
|
241 EPositionServerBadHandle, |
|
242 KDefaultTestTimeout); |
|
243 |
|
244 DO_PANIC_TEST_L( |
|
245 No_Server_GetNumModules, |
|
246 KPosClientFault, |
|
247 EPositionServerBadHandle, |
|
248 KDefaultTestTimeout); |
|
249 |
|
250 DO_PANIC_TEST_L( |
|
251 No_Server_GetModuleInfoByIndex, |
|
252 KPosClientFault, |
|
253 EPositionServerBadHandle, |
|
254 KDefaultTestTimeout); |
|
255 |
|
256 DO_PANIC_TEST_L( |
|
257 No_Server_GetModuleInfoById, |
|
258 KPosClientFault, |
|
259 EPositionServerBadHandle, |
|
260 KDefaultTestTimeout); |
|
261 |
|
262 DO_PANIC_TEST_L( |
|
263 No_Server_GetModuleStatus, |
|
264 KPosClientFault, |
|
265 EPositionServerBadHandle, |
|
266 KDefaultTestTimeout); |
|
267 |
|
268 DO_PANIC_TEST_L( |
|
269 No_Server_NotifyModuleStatusEvent, |
|
270 KPosClientFault, |
|
271 EPositionServerBadHandle, |
|
272 KDefaultTestTimeout); |
|
273 |
|
274 DO_PANIC_TEST_L( |
|
275 No_Server_CancelRequest, |
|
276 KPosClientFault, |
|
277 EPositionServerBadHandle, |
|
278 KDefaultTestTimeout); |
|
279 |
|
280 StandardCleanup(); |
|
281 } |
|
282 |
|
283 |
|
284 // 9.1.3 Connect and try to execute RPositioner methods |
|
285 // This should fail with panic |
|
286 |
|
287 TInt No_Positioner_CancelRequest(TAny* /*aPtr*/) |
|
288 { |
|
289 RPositionServer server; |
|
290 server.Connect(); |
|
291 |
|
292 RPositioner positioner; |
|
293 positioner.CancelRequest(EPositionerGetLastKnownPosition); |
|
294 return KErrGeneral; |
|
295 } |
|
296 |
|
297 |
|
298 TInt No_Positioner_Open(TAny* /*aPtr*/) |
|
299 { |
|
300 RPositionServer server; |
|
301 server.Connect(); |
|
302 |
|
303 RPositioner positioner; |
|
304 positioner.Open(server); |
|
305 return KErrGeneral; |
|
306 } |
|
307 |
|
308 |
|
309 TInt No_Positioner_Open_ModuleId(TAny* /*aPtr*/) |
|
310 { |
|
311 RPositionServer server; |
|
312 server.Connect(); |
|
313 |
|
314 TPositionModuleId moduleId = {0x012345678}; |
|
315 |
|
316 RPositioner positioner; |
|
317 positioner.Open(server, moduleId); |
|
318 return KErrGeneral; |
|
319 } |
|
320 |
|
321 |
|
322 TInt No_Positioner_Open_Criteria(TAny* /*aPtr*/) |
|
323 { |
|
324 RPositionServer server; |
|
325 server.Connect(); |
|
326 |
|
327 TPositionCriteria crit; |
|
328 |
|
329 RPositioner positioner; |
|
330 positioner.Open(server, crit); |
|
331 return KErrGeneral; |
|
332 } |
|
333 |
|
334 |
|
335 // Close method should not fail |
|
336 TInt No_Positioner_Close(TAny* /*aPtr*/) |
|
337 { |
|
338 RPositionServer server; |
|
339 server.Connect(); |
|
340 |
|
341 RPositioner positioner; |
|
342 positioner.Close(); |
|
343 return KErrNone; |
|
344 } |
|
345 |
|
346 |
|
347 TInt No_Positioner_SetRequestor(TAny* /*aPtr*/) |
|
348 { |
|
349 RPositionServer server; |
|
350 server.Connect(); |
|
351 |
|
352 RPositioner positioner; |
|
353 positioner.SetRequestor(0, 0, KNullDesC); |
|
354 return KErrGeneral; |
|
355 } |
|
356 |
|
357 |
|
358 TInt No_Positioner_SetRequestor_Stack(TAny* /*aPtr*/) |
|
359 { |
|
360 RPositionServer server; |
|
361 server.Connect(); |
|
362 |
|
363 RRequestorStack stack; |
|
364 |
|
365 RPositioner positioner; |
|
366 positioner.SetRequestor(stack); |
|
367 return KErrGeneral; |
|
368 } |
|
369 |
|
370 |
|
371 TInt No_Positioner_SetUpdateOptions(TAny* /*aPtr*/) |
|
372 { |
|
373 RPositionServer server; |
|
374 server.Connect(); |
|
375 |
|
376 TPositionUpdateOptions options; |
|
377 |
|
378 RPositioner positioner; |
|
379 positioner.SetUpdateOptions(options); |
|
380 return KErrGeneral; |
|
381 } |
|
382 |
|
383 |
|
384 TInt No_Positioner_GetUpdateOptions(TAny* /*aPtr*/) |
|
385 { |
|
386 RPositionServer server; |
|
387 server.Connect(); |
|
388 |
|
389 TPositionUpdateOptions options; |
|
390 |
|
391 RPositioner positioner; |
|
392 positioner.GetUpdateOptions(options); |
|
393 return KErrGeneral; |
|
394 } |
|
395 |
|
396 |
|
397 TInt No_Positioner_GetLastKnownPosition(TAny* /*aPtr*/) |
|
398 { |
|
399 RPositionServer server; |
|
400 server.Connect(); |
|
401 |
|
402 TPositionInfo info; |
|
403 TRequestStatus status; |
|
404 |
|
405 RPositioner positioner; |
|
406 positioner.GetLastKnownPosition(info, status); |
|
407 return KErrGeneral; |
|
408 } |
|
409 |
|
410 |
|
411 TInt No_Positioner_NotifyPositionUpdate(TAny* /*aPtr*/) |
|
412 { |
|
413 RPositionServer server; |
|
414 server.Connect(); |
|
415 |
|
416 TPositionInfo info; |
|
417 TRequestStatus status; |
|
418 |
|
419 RPositioner positioner; |
|
420 positioner.NotifyPositionUpdate(info, status); |
|
421 return KErrGeneral; |
|
422 } |
|
423 |
|
424 |
|
425 void CNoServerStep::RPositioner_NoL() |
|
426 { |
|
427 DECLARE_ERROR_LOGGING; |
|
428 StandardPrepareL(); |
|
429 CheckThereIsNoServerL(); |
|
430 |
|
431 RPositionServer server; |
|
432 |
|
433 CHECK( KErrNone != server.Connect() ); |
|
434 FAIL( server.Handle() != 0, "Server found, while should not be" ); |
|
435 |
|
436 DO_PANIC_TEST_L( |
|
437 No_Positioner_CancelRequest, |
|
438 KPosClientFault, |
|
439 EPositionServerBadHandle, |
|
440 KDefaultTestTimeout); |
|
441 |
|
442 DO_PANIC_TEST_L( |
|
443 No_Positioner_Open, |
|
444 KPosClientFault, |
|
445 EPositionServerBadHandle, |
|
446 KDefaultTestTimeout); |
|
447 |
|
448 DO_PANIC_TEST_L( |
|
449 No_Positioner_Open_ModuleId, |
|
450 KPosClientFault, |
|
451 EPositionServerBadHandle, |
|
452 KDefaultTestTimeout); |
|
453 |
|
454 DO_PANIC_TEST_L( |
|
455 No_Positioner_Open_Criteria, |
|
456 KPosClientFault, |
|
457 EPositionServerBadHandle, |
|
458 KDefaultTestTimeout); |
|
459 |
|
460 DO_PANIC_TEST_L( |
|
461 No_Positioner_Close, |
|
462 KNoClientFault, |
|
463 KErrNone, |
|
464 KDefaultTestTimeout); |
|
465 |
|
466 DO_PANIC_TEST_L( |
|
467 No_Positioner_SetRequestor, |
|
468 KPosClientFault, |
|
469 EPositionServerBadHandle, |
|
470 KDefaultTestTimeout); |
|
471 |
|
472 DO_PANIC_TEST_L( |
|
473 No_Positioner_SetRequestor_Stack, |
|
474 KPosClientFault, |
|
475 EPositionServerBadHandle, |
|
476 KDefaultTestTimeout); |
|
477 |
|
478 DO_PANIC_TEST_L( |
|
479 No_Positioner_SetUpdateOptions, |
|
480 KPosClientFault, |
|
481 EPositionServerBadHandle, |
|
482 KDefaultTestTimeout); |
|
483 |
|
484 DO_PANIC_TEST_L( |
|
485 No_Positioner_GetUpdateOptions, |
|
486 KPosClientFault, |
|
487 EPositionServerBadHandle, |
|
488 KDefaultTestTimeout); |
|
489 |
|
490 DO_PANIC_TEST_L( |
|
491 No_Positioner_GetLastKnownPosition, |
|
492 KPosClientFault, |
|
493 EPositionServerBadHandle, |
|
494 KDefaultTestTimeout); |
|
495 |
|
496 DO_PANIC_TEST_L( |
|
497 No_Positioner_NotifyPositionUpdate, |
|
498 KPosClientFault, |
|
499 EPositionServerBadHandle, |
|
500 KDefaultTestTimeout); |
|
501 |
|
502 StandardCleanup(); |
|
503 } |