|
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 ctlbsclientstepmodstatus.cpp |
|
15 // This is the class implementation for the Module Information Tests |
|
16 // |
|
17 // |
|
18 |
|
19 #include "ctlbsclientstepmodstatus.h" |
|
20 #include "ctlbsclientstep.h" |
|
21 |
|
22 #include <e32property.h> |
|
23 #include <lbs.h> |
|
24 |
|
25 #include <lbs/test/tlbsutils.h> |
|
26 #include <lbs/test/ctlbsasyncwaiter.h> |
|
27 |
|
28 #include <lbs/EPos_CPosModules.h> |
|
29 #include <lbs/EPos_CPosModuleUpdate.h> |
|
30 #include "netpsy.hrh" |
|
31 |
|
32 /** |
|
33 * Destructor |
|
34 */ |
|
35 CT_LbsClientStep_ModStat::~CT_LbsClientStep_ModStat() |
|
36 { |
|
37 } |
|
38 |
|
39 |
|
40 /** |
|
41 * Constructor |
|
42 */ |
|
43 CT_LbsClientStep_ModStat::CT_LbsClientStep_ModStat(CT_LbsClientServer& aParent) : CT_LbsClientStep(aParent) |
|
44 { |
|
45 SetTestStepName(KLbsClientStep_ModStatus); |
|
46 } |
|
47 |
|
48 |
|
49 /** |
|
50 Static Constructor |
|
51 */ |
|
52 CT_LbsClientStep_ModStat* CT_LbsClientStep_ModStat::New(CT_LbsClientServer& aParent) |
|
53 { |
|
54 // Note the lack of ELeave. |
|
55 // This means that having insufficient memory will return NULL; |
|
56 CT_LbsClientStep_ModStat* testStep = new CT_LbsClientStep_ModStat(aParent); |
|
57 |
|
58 if (testStep) |
|
59 { |
|
60 TInt err = KErrNone; |
|
61 |
|
62 TRAP(err, testStep->ConstructL()); |
|
63 if (err) |
|
64 { |
|
65 delete testStep; |
|
66 testStep = NULL; |
|
67 } |
|
68 } |
|
69 return testStep; |
|
70 } |
|
71 |
|
72 void CT_LbsClientStep_ModStat::ConstructL() |
|
73 { |
|
74 // Re-enable the network PSY |
|
75 CPosModules* db = CPosModules::OpenL(); |
|
76 CleanupStack::PushL(db); |
|
77 |
|
78 CPosModuleUpdate* moduleUpdate = CPosModuleUpdate::NewLC(); |
|
79 |
|
80 moduleUpdate->SetUpdateAvailability(ETrue); |
|
81 moduleUpdate->SetUpdateVisibility(ETrue); |
|
82 TUid uid = TUid::Uid(KPosNETPSYImplUid); |
|
83 db->UpdateModuleL(uid, *moduleUpdate); |
|
84 |
|
85 CleanupStack::PopAndDestroy(moduleUpdate); |
|
86 CleanupStack::PopAndDestroy(db); |
|
87 } |
|
88 |
|
89 /** |
|
90 * Sets requested event mask as specified for supplied module. |
|
91 * Kicks test module to cause events requested then waits for event(s) |
|
92 * Updates the supplied module status |
|
93 * returns TRUE if everything went as expected, FALSE otherwise |
|
94 */ |
|
95 /** |
|
96 * Sets requested event mask as specified for supplied module. |
|
97 * Kicks test module to cause events requested then waits for event(s) |
|
98 * Updates the supplied module status |
|
99 * returns TRUE if everything went as expected, FALSE otherwise |
|
100 */ |
|
101 TBool CT_LbsClientStep_ModStat::DoRequestAndVerifyModStatusEventsL(TPositionModuleStatusEvent::TModuleEvent aReqEventsMask, TPositionModuleStatus& aModStatus, TPositionModuleId aModId = KPositionNullModuleId ) |
|
102 { |
|
103 TBool result = TRUE; |
|
104 TPositionModuleStatusEvent statusEvent; |
|
105 TPositionModuleId agpsmodId; |
|
106 |
|
107 // we're interested in the agps module id |
|
108 T_LbsUtils utils; |
|
109 agpsmodId = utils.GetAGpsModuleIdL(iServer); |
|
110 |
|
111 // Set event mask to select requested status events |
|
112 statusEvent.SetRequestedEvents(aReqEventsMask); |
|
113 |
|
114 // verify the set worked |
|
115 if(statusEvent.RequestedEvents() != aReqEventsMask) |
|
116 { |
|
117 INFO_PRINTF2(_L("Requested Events don't match. Got0x%x"), statusEvent.RequestedEvents()); |
|
118 return FALSE; |
|
119 } |
|
120 |
|
121 CT_LbsAsyncWaiter* waiter = CT_LbsAsyncWaiter::NewL(); |
|
122 |
|
123 // Request module status event using supplied module id |
|
124 iServer.NotifyModuleStatusEvent(statusEvent, waiter->iStatus, aModId); |
|
125 |
|
126 TPositionModuleStatusEvent::TModuleEvent eventsExpected = 0; |
|
127 |
|
128 // assume we are interested in the agps module since we can't control events from network module |
|
129 ASSERT(aModId == agpsmodId || aModId == KPositionNullModuleId); |
|
130 |
|
131 // kick the test agps module to cause the requested status event(s) |
|
132 TPckgBuf<TModuleDataIn> modDataInBuf; |
|
133 TModuleDataIn& modDataIn = modDataInBuf(); |
|
134 |
|
135 modDataIn.iRequestType = TModuleDataIn::EModuleRequestEventKickOff; |
|
136 modDataIn.iKickOffEventType = 0; |
|
137 if(aReqEventsMask & TPositionModuleStatusEvent::EEventDeviceStatus) |
|
138 { |
|
139 modDataIn.iKickOffEventType |= TModuleDataIn::EKickOffEventTypeDevice; |
|
140 eventsExpected |= TPositionModuleStatusEvent::EEventDeviceStatus; |
|
141 } |
|
142 |
|
143 if(aReqEventsMask & TPositionModuleStatusEvent::EEventDataQualityStatus) |
|
144 { |
|
145 modDataIn.iKickOffEventType |= TModuleDataIn::EKickOffEventTypeDataQuality; |
|
146 eventsExpected |= TPositionModuleStatusEvent::EEventDataQualityStatus; |
|
147 } |
|
148 |
|
149 User::LeaveIfError(RProperty::Set(KUidSystemCategory, ELbsTestAGpsModuleIn, modDataInBuf)); |
|
150 |
|
151 |
|
152 // Wait for event(s) |
|
153 while(result && eventsExpected) |
|
154 { |
|
155 waiter->StartAndWait(); |
|
156 User::LeaveIfError(waiter->Result()); |
|
157 |
|
158 |
|
159 TInt result = waiter->Result(); |
|
160 |
|
161 TPositionModuleStatusEvent::TModuleEvent eventsOccurred = statusEvent.OccurredEvents(); |
|
162 |
|
163 ASSERT(eventsOccurred); |
|
164 |
|
165 if(result) |
|
166 { |
|
167 INFO_PRINTF2(_L("Unexpected error returned %d"), result); |
|
168 result = FALSE; |
|
169 } |
|
170 // Verify correct event(s) happenned |
|
171 else |
|
172 { |
|
173 |
|
174 if(eventsOccurred & ~(eventsExpected)) |
|
175 { |
|
176 INFO_PRINTF2(_L("Unexpected event received 0x%x"), statusEvent.OccurredEvents()); |
|
177 result = FALSE; |
|
178 } |
|
179 |
|
180 if(statusEvent.ModuleId() == agpsmodId) |
|
181 { |
|
182 eventsExpected &= ~eventsOccurred; |
|
183 } |
|
184 |
|
185 // Request next module status event |
|
186 if (eventsExpected) |
|
187 { |
|
188 iServer.NotifyModuleStatusEvent(statusEvent, waiter->iStatus/*request*/, aModId); |
|
189 } |
|
190 } |
|
191 } |
|
192 |
|
193 // TODO - appropriate to do this here? |
|
194 // device status event happened. Read in new status (this will be verified in future test step): |
|
195 statusEvent.GetModuleStatus(aModStatus); |
|
196 |
|
197 delete waiter; |
|
198 |
|
199 return result; |
|
200 } |
|
201 |
|
202 /** |
|
203 * Sets requested event mask as specified for agps module. |
|
204 * Kicks test module to cause events requested then waits for event(s) |
|
205 * Updates the supplied module status |
|
206 * returns TRUE if everything went as expected, FALSE otherwise |
|
207 */ |
|
208 TBool CT_LbsClientStep_ModStat::DoRequestAndVerifyAGPSModStatusEventsL(TPositionModuleStatusEvent::TModuleEvent aReqEventsMask, TPositionModuleStatus& aModStatus) |
|
209 { |
|
210 TPositionModuleId modId; |
|
211 |
|
212 // we're interested in the agps module id |
|
213 T_LbsUtils utils; |
|
214 modId = utils.GetAGpsModuleIdL(iServer); |
|
215 |
|
216 return DoRequestAndVerifyModStatusEventsL(aReqEventsMask, aModStatus, modId); |
|
217 } |
|
218 |
|
219 |
|
220 /** |
|
221 * Sets requested event mask as specified for supplied module and asks to be notified of events |
|
222 * (note does not kick test module to cause events; use only if expect error to be returned) |
|
223 * Waits for event and returns error |
|
224 */ |
|
225 TInt CT_LbsClientStep_ModStat::DoRequestModStatusEventsWithError(TPositionModuleStatusEvent::TModuleEvent aReqEventsMask, TPositionModuleId aModId) |
|
226 { |
|
227 //TRequestStatus request; |
|
228 TPositionModuleStatusEvent statusEvent; |
|
229 |
|
230 statusEvent.SetRequestedEvents(aReqEventsMask); |
|
231 |
|
232 CT_LbsAsyncWaiter* waiter = CT_LbsAsyncWaiter::NewL(); |
|
233 |
|
234 iServer.NotifyModuleStatusEvent(statusEvent, waiter->iStatus, aModId); |
|
235 |
|
236 waiter->StartAndWait(); |
|
237 |
|
238 TInt result = waiter->Result(); |
|
239 |
|
240 //User::WaitForRequest(request); |
|
241 delete waiter; |
|
242 |
|
243 return result; |
|
244 |
|
245 } |
|
246 |
|
247 TBool CT_LbsClientStep_ModStat::DoVerifyModStatus(TPositionModuleStatusEvent::TModuleEvent aExpectedModStatus,TPositionModuleId aModId) |
|
248 { |
|
249 // Initialise current module status. |
|
250 TPositionModuleStatus& currentModStatus = iParent.iSharedData->iCurrentModuleStatus; |
|
251 iServer.GetModuleStatus(currentModStatus,aModId); |
|
252 |
|
253 if(currentModStatus.DeviceStatus()!=aExpectedModStatus) |
|
254 { |
|
255 INFO_PRINTF3(_L("Module in Unexpected State - %d and not %d"),currentModStatus.DeviceStatus(),aExpectedModStatus); |
|
256 SetTestStepResult(EFail); |
|
257 return EFalse; |
|
258 } |
|
259 else |
|
260 { |
|
261 INFO_PRINTF2(_L("Module in Expected State %d"),aExpectedModStatus); |
|
262 return ETrue; |
|
263 } |
|
264 } |
|
265 |
|
266 /** |
|
267 * @return - TVerdict code |
|
268 * Override of base class pure virtual |
|
269 * Our implementation only gets called if the base class doTestStepPreambleL() did |
|
270 * not leave. That being the case, the current test result value will be EPass. |
|
271 */ |
|
272 TVerdict CT_LbsClientStep_ModStat::doTestStepL() |
|
273 { |
|
274 // Generic test step used to test the LBS Client Notify position update API. |
|
275 INFO_PRINTF1(_L(">>CT_LbsClientStep_ModStat::doTestStepL()")); |
|
276 |
|
277 if (TestStepResult() == EPass) |
|
278 { |
|
279 TInt err = KErrNone; |
|
280 |
|
281 // Connect to self locate server. |
|
282 User::LeaveIfError(iServer.Connect()); |
|
283 CleanupClosePushL(iServer); |
|
284 |
|
285 // Carryout unique test actions. |
|
286 TInt testCaseId; |
|
287 if (GetIntFromConfig(ConfigSection(), KTestCaseId, testCaseId)) |
|
288 { |
|
289 switch (testCaseId) |
|
290 { |
|
291 // Test case LBS-ModStatus-0001 to 0004 |
|
292 case 01: |
|
293 case 02: |
|
294 case 03: |
|
295 case 04: |
|
296 { |
|
297 TPositionModuleId testmodId; |
|
298 |
|
299 T_LbsUtils utils; |
|
300 testmodId = utils.GetAGpsModuleIdL(iServer); |
|
301 |
|
302 // Get the module device status. |
|
303 TPositionModuleStatus& modStatus = iParent.iSharedData->iCurrentModuleStatus; |
|
304 err = iServer.GetModuleStatus(modStatus, testmodId); |
|
305 if(KErrNone != err) |
|
306 { |
|
307 INFO_PRINTF2(_L("Failed with err %d"), err); |
|
308 SetTestStepResult(EFail); |
|
309 } |
|
310 } |
|
311 break; |
|
312 |
|
313 // Test case LBS-ModStatus-0005 |
|
314 case 05: |
|
315 { |
|
316 TPositionModuleId badmodId; |
|
317 T_LbsUtils utils; |
|
318 badmodId = utils.GetBadModuleId(); |
|
319 |
|
320 // Get the module device status. |
|
321 TPositionModuleStatus moduleStatus; |
|
322 |
|
323 err = iServer.GetModuleStatus(moduleStatus, badmodId); |
|
324 if(KErrNotFound != err) |
|
325 { |
|
326 INFO_PRINTF2(_L("Failed with err %d. Should have been KErrNotFound(-1)"), err); |
|
327 SetTestStepResult(EFail); |
|
328 } |
|
329 } |
|
330 break; |
|
331 |
|
332 // LBS-Mod-Status-Event-0002 |
|
333 |
|
334 case 22: |
|
335 { |
|
336 if(iExpectedApiBehaviour == EApiVariant2) |
|
337 { |
|
338 T_LbsUtils utils; |
|
339 TPositionModuleId modId; |
|
340 modId = utils.GetAGpsModuleIdL(iServer); |
|
341 User::LeaveIfError(iPositioner.Open(iServer, modId)); |
|
342 CleanupClosePushL(iPositioner); |
|
343 } |
|
344 |
|
345 TPositionModuleStatus& testmodStatus = iParent.iSharedData->iCurrentModuleStatus; |
|
346 |
|
347 // Get device status events for ANY module: |
|
348 if(!DoRequestAndVerifyModStatusEventsL(TPositionModuleStatusEvent::EEventDeviceStatus, testmodStatus)) |
|
349 { |
|
350 SetTestStepResult(EFail); |
|
351 } |
|
352 |
|
353 if(iExpectedApiBehaviour == EApiVariant2) |
|
354 { |
|
355 CleanupStack::PopAndDestroy(&iPositioner); |
|
356 } |
|
357 } |
|
358 break; |
|
359 |
|
360 // LBS-Mod-Status-Event-0003 |
|
361 case 23: |
|
362 { |
|
363 if(iExpectedApiBehaviour == EApiVariant2) |
|
364 { |
|
365 T_LbsUtils utils; |
|
366 TPositionModuleId modId; |
|
367 modId = utils.GetAGpsModuleIdL(iServer); |
|
368 User::LeaveIfError(iPositioner.Open(iServer, modId)); |
|
369 CleanupClosePushL(iPositioner); |
|
370 } |
|
371 |
|
372 TPositionModuleStatus& testmodStatus = iParent.iSharedData->iCurrentModuleStatus; |
|
373 |
|
374 // Get device status events for (test) agps module |
|
375 if(!DoRequestAndVerifyAGPSModStatusEventsL(TPositionModuleStatusEvent::EEventDeviceStatus, testmodStatus)) |
|
376 { |
|
377 SetTestStepResult(EFail); |
|
378 } |
|
379 |
|
380 if(iExpectedApiBehaviour == EApiVariant1)// on variant2 we don't see any other status updates (expected) |
|
381 { |
|
382 // Get device status events for ALL modules |
|
383 if(!DoRequestAndVerifyModStatusEventsL(TPositionModuleStatusEvent::EEventDeviceStatus, testmodStatus)) |
|
384 { |
|
385 SetTestStepResult(EFail); |
|
386 } |
|
387 } |
|
388 else |
|
389 { |
|
390 CleanupStack::PopAndDestroy(&iPositioner); |
|
391 } |
|
392 } |
|
393 break; |
|
394 |
|
395 // LBS-Mod-Status-Event-0004 |
|
396 case 24: |
|
397 { |
|
398 if(iExpectedApiBehaviour == EApiVariant2) |
|
399 { |
|
400 T_LbsUtils utils; |
|
401 TPositionModuleId modId; |
|
402 modId = utils.GetAGpsModuleIdL(iServer); |
|
403 User::LeaveIfError(iPositioner.Open(iServer, modId)); |
|
404 CleanupClosePushL(iPositioner); |
|
405 } |
|
406 TPositionModuleStatus& testmodStatus = iParent.iSharedData->iCurrentModuleStatus; |
|
407 |
|
408 // Get AGPS device status events |
|
409 if(!DoRequestAndVerifyAGPSModStatusEventsL(TPositionModuleStatusEvent::EEventDeviceStatus, testmodStatus)) |
|
410 { |
|
411 SetTestStepResult(EFail); |
|
412 } |
|
413 } |
|
414 if(iExpectedApiBehaviour == EApiVariant2) |
|
415 { |
|
416 CleanupStack::PopAndDestroy(&iPositioner); |
|
417 } |
|
418 break; |
|
419 |
|
420 // LBS-Mod-Status-Event-0005 |
|
421 case 25: |
|
422 { |
|
423 if(iExpectedApiBehaviour == EApiVariant2) |
|
424 { |
|
425 T_LbsUtils utils; |
|
426 TPositionModuleId modId; |
|
427 modId = utils.GetAGpsModuleIdL(iServer); |
|
428 User::LeaveIfError(iPositioner.Open(iServer, modId)); |
|
429 CleanupClosePushL(iPositioner); |
|
430 } |
|
431 TPositionModuleStatus& testmodStatus = iParent.iSharedData->iCurrentModuleStatus; |
|
432 // Get device status events |
|
433 if(!DoRequestAndVerifyAGPSModStatusEventsL(TPositionModuleStatusEvent::EEventDataQualityStatus, testmodStatus)) |
|
434 { |
|
435 SetTestStepResult(EFail); |
|
436 } |
|
437 if(iExpectedApiBehaviour == EApiVariant2) |
|
438 { |
|
439 CleanupStack::PopAndDestroy(&iPositioner); |
|
440 } |
|
441 } |
|
442 break; |
|
443 |
|
444 // LBS-Mod-Status-Event-0009 |
|
445 case 29: |
|
446 { |
|
447 if(iExpectedApiBehaviour == EApiVariant2) |
|
448 { |
|
449 T_LbsUtils utils; |
|
450 TPositionModuleId modId; |
|
451 modId = utils.GetAGpsModuleIdL(iServer); |
|
452 User::LeaveIfError(iPositioner.Open(iServer, modId)); |
|
453 CleanupClosePushL(iPositioner); |
|
454 } |
|
455 TPositionModuleStatus& testmodStatus = iParent.iSharedData->iCurrentModuleStatus; |
|
456 |
|
457 //In feature when system events support, change TPositionModuleStatusEvent::EEventAll |
|
458 // Get device status events |
|
459 if(!DoRequestAndVerifyAGPSModStatusEventsL(((TPositionModuleStatusEvent::EEventDeviceStatus)|(TPositionModuleStatusEvent::EEventDataQualityStatus)), testmodStatus)) |
|
460 { |
|
461 SetTestStepResult(EFail); |
|
462 } |
|
463 if(iExpectedApiBehaviour == EApiVariant2) |
|
464 { |
|
465 CleanupStack::PopAndDestroy(&iPositioner); |
|
466 } |
|
467 } |
|
468 break; |
|
469 |
|
470 // LBS-Mod-Status-Event-0010 |
|
471 case 30: |
|
472 { |
|
473 TPositionModuleId modId; |
|
474 TInt err; |
|
475 |
|
476 // use bad module id |
|
477 T_LbsUtils utils; |
|
478 modId = utils.GetBadModuleId(); |
|
479 |
|
480 err = DoRequestModStatusEventsWithError(TPositionModuleStatusEvent::EEventDataQualityStatus, modId); |
|
481 if(KErrNotFound != err) |
|
482 { |
|
483 SetTestStepResult(EFail); |
|
484 } |
|
485 } |
|
486 break; |
|
487 |
|
488 // LBS-Mod-Status-Event-0011 |
|
489 case 31: |
|
490 { |
|
491 TPositionModuleId modId; |
|
492 TInt err; |
|
493 |
|
494 // use agps module id |
|
495 T_LbsUtils utils; |
|
496 modId = utils.GetAGpsModuleIdL(iServer); |
|
497 |
|
498 err = DoRequestModStatusEventsWithError(0, modId); |
|
499 if(KErrArgument != err) |
|
500 { |
|
501 SetTestStepResult(EFail); |
|
502 } |
|
503 } |
|
504 break; |
|
505 |
|
506 // LBS-Mod-Status-Event-0012 |
|
507 case 32: |
|
508 { |
|
509 TPositionModuleId modId; |
|
510 TRequestStatus request; |
|
511 TPositionModuleStatusEvent statusEvent; |
|
512 |
|
513 // use agps module id |
|
514 T_LbsUtils utils; |
|
515 modId = utils.GetAGpsModuleIdL(iServer); |
|
516 |
|
517 statusEvent.SetRequestedEvents(TPositionModuleStatusEvent::EEventDeviceStatus); |
|
518 |
|
519 iServer.NotifyModuleStatusEvent(statusEvent, request, modId); |
|
520 |
|
521 TInt err = iServer.CancelRequest(EPositionServerNotifyModuleStatusEvent); |
|
522 if(KErrNone == err) |
|
523 { |
|
524 User::WaitForRequest(request); |
|
525 if(KErrCancel != request.Int()) |
|
526 { |
|
527 INFO_PRINTF2(_L("Failed: KErrCancel not returned, Got %d"), request.Int()); |
|
528 SetTestStepResult(EFail); |
|
529 } |
|
530 } |
|
531 else |
|
532 { |
|
533 INFO_PRINTF2(_L("Failed: CancelRequest returned error %d"), err); |
|
534 SetTestStepResult(EFail); |
|
535 } |
|
536 } |
|
537 break; |
|
538 |
|
539 // LBS-Mod-Status-Event-0013 |
|
540 case 33: |
|
541 { |
|
542 TInt err = iServer.CancelRequest(EPositionServerNotifyModuleStatusEvent); |
|
543 if(KErrNotFound != err) |
|
544 { |
|
545 INFO_PRINTF2(_L("Failed: CancelRequest returned error %d, expecting KErrNotFound"), err); |
|
546 SetTestStepResult(EFail); |
|
547 } |
|
548 } |
|
549 break; |
|
550 |
|
551 // LBS-Mod-Status-Event-0014 |
|
552 case 34: |
|
553 { |
|
554 // close server since we don't want to be connected for this test |
|
555 iServer.Close(); |
|
556 |
|
557 TInt err = iServer.CancelRequest(EPositionServerNotifyModuleStatusEvent); |
|
558 |
|
559 // if we get here, something went wrong, so panic |
|
560 SetTestStepResult(EFail); |
|
561 |
|
562 User::Panic(KLbsClientStep_ModStatus, KErrGeneral); |
|
563 } |
|
564 break; |
|
565 |
|
566 // LBS-Mod-Status-Event-0015 |
|
567 case 35: |
|
568 { |
|
569 TPositionModuleId modId; |
|
570 TRequestStatus request; |
|
571 TPositionModuleStatusEvent statusEvent; |
|
572 |
|
573 // use agps module id |
|
574 T_LbsUtils utils; |
|
575 modId = utils.GetAGpsModuleIdL(iServer); |
|
576 |
|
577 // set requested events mask |
|
578 statusEvent.SetRequestedEvents(TPositionModuleStatusEvent::EEventDeviceStatus); |
|
579 |
|
580 // ask to be notified of requested events |
|
581 iServer.NotifyModuleStatusEvent(statusEvent, request, modId); |
|
582 |
|
583 // ask to be notified of requested events a second time (panics) |
|
584 iServer.NotifyModuleStatusEvent(statusEvent, request, modId); |
|
585 |
|
586 // if we get here, something went wrong, so panic |
|
587 SetTestStepResult(EFail); |
|
588 |
|
589 User::Panic(KLbsClientStep_ModStatus, KErrGeneral); |
|
590 } |
|
591 break; |
|
592 case 101: |
|
593 { |
|
594 // This test requires net sim to be open. |
|
595 OpenNetSim(); |
|
596 |
|
597 // Select the network module. |
|
598 T_LbsUtils utils; |
|
599 TPositionModuleId modId; |
|
600 modId = utils.GetNetworkModuleIdL(iServer); |
|
601 User::LeaveIfError(iPositioner.Open(iServer, modId)); |
|
602 CleanupClosePushL(iPositioner); |
|
603 |
|
604 // Initialise the position info variable. |
|
605 TPositionInfo* posInfo = new(ELeave) TPositionInfo(); |
|
606 CleanupStack::PushL(posInfo); |
|
607 |
|
608 // set requested events mask so we get notified on EEventDeviceStatus (any status change) |
|
609 TPositionModuleStatusEvent statusEvent; |
|
610 statusEvent.SetRequestedEvents(TPositionModuleStatusEvent::EEventDeviceStatus); |
|
611 CT_LbsAsyncWaiter* waiter = CT_LbsAsyncWaiter::NewL(); |
|
612 iServer.NotifyModuleStatusEvent(statusEvent, waiter->iStatus, modId); |
|
613 |
|
614 if(iExpectedApiBehaviour == EApiVariant1) |
|
615 { |
|
616 // Verify that the module status is ready before we make any requests. |
|
617 DoVerifyModStatus(TPositionModuleStatus::EDeviceReady,modId); |
|
618 } |
|
619 else // on S60 the device starts off in 'inactive' state |
|
620 { |
|
621 // Verify that the module status is ready before we make any requests. |
|
622 DoVerifyModStatus(TPositionModuleStatus::EDeviceInactive,modId); |
|
623 } |
|
624 // Request a position update, we should then see a state change to EDeviceActive |
|
625 TRequestStatus status; |
|
626 INFO_PRINTF1(_L("Performing NotifyPositionUpdate()")); |
|
627 iPositioner.NotifyPositionUpdate(*posInfo,status); |
|
628 // Use the waiter object so that we can get the device status change. |
|
629 waiter->StartAndWait(); |
|
630 waiter->Result(); |
|
631 |
|
632 TPositionModuleStatusEvent::TModuleEvent eventsExpected; |
|
633 |
|
634 if(iExpectedApiBehaviour == EApiVariant1) |
|
635 { |
|
636 // Check that the change that happened was the correct thing. |
|
637 eventsExpected = TPositionModuleStatusEvent::EEventDeviceStatus; |
|
638 } |
|
639 else // on s60 we also get a data quality status because this doesn't get reported until the PSY is loaded |
|
640 { |
|
641 eventsExpected = TPositionModuleStatusEvent::EEventDeviceStatus | TPositionModuleStatusEvent::EEventDataQualityStatus; |
|
642 } |
|
643 |
|
644 TPositionModuleStatusEvent::TModuleEvent eventsOccurred = statusEvent.OccurredEvents(); |
|
645 |
|
646 if(eventsOccurred!=eventsExpected) |
|
647 { |
|
648 INFO_PRINTF1(_L("No Module Status Event have Occured")); |
|
649 SetTestStepResult(EFail); |
|
650 } |
|
651 |
|
652 |
|
653 // Verify the device is now active |
|
654 DoVerifyModStatus(TPositionModuleStatus::EDeviceActive,modId); |
|
655 |
|
656 INFO_PRINTF1(_L("Position Received")); |
|
657 User::WaitForRequest(status); |
|
658 |
|
659 //Verify that the position is EDeviceReady again |
|
660 DoVerifyModStatus(TPositionModuleStatus::EDeviceReady,modId); |
|
661 |
|
662 // Tidy up everything |
|
663 CloseNetSim(); |
|
664 delete waiter; |
|
665 CleanupStack::PopAndDestroy(posInfo); |
|
666 CleanupStack::PopAndDestroy(&iPositioner); |
|
667 } |
|
668 break; |
|
669 default: |
|
670 { |
|
671 User::Panic(KLbsClientStep_ModStatus, KErrUnknown); |
|
672 } |
|
673 } |
|
674 |
|
675 |
|
676 } |
|
677 |
|
678 // All done, clean up. |
|
679 CleanupStack::PopAndDestroy(&iServer); |
|
680 } |
|
681 |
|
682 INFO_PRINTF1(_L("<<CT_LbsClientStep_ModStat::doTestStepL()")); |
|
683 |
|
684 return TestStepResult(); |
|
685 } |
|
686 |