|
1 // Copyright (c) 2001-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 // Telephony Watchers Integration Test main test code. |
|
15 // |
|
16 // |
|
17 |
|
18 /** |
|
19 @file |
|
20 */ |
|
21 |
|
22 #include <e32uid.h> |
|
23 #include <f32file.h> |
|
24 #include <bafindf.h> |
|
25 #include <cdbcols.h> |
|
26 #include <simtsy.h> |
|
27 #include <ecom/ecom.h> |
|
28 |
|
29 #include "indicatorwatcher.h" |
|
30 #include "signalstrengthwatcher.h" |
|
31 |
|
32 #include "TE_TelWatchersIntBase.h" |
|
33 #include "TE_TelWatchersIntTest.h" |
|
34 |
|
35 |
|
36 /** |
|
37 * Each test step initialises it's own name |
|
38 */ |
|
39 CTelWatchersIntTestRetrieveSignalStrengthWithPublishSubscribe::CTelWatchersIntTestRetrieveSignalStrengthWithPublishSubscribe() |
|
40 { |
|
41 // |
|
42 // Store the name of this test case. This is the name that is used by |
|
43 // the script file. |
|
44 // |
|
45 SetTestStepName(_L("TestRetrieveSignalStrengthWithPublishSubscribe")); |
|
46 } // CTelWatchersIntTestRetrieveSignalStrengthWithPublishSubscribe::CTelWatchersIntTestRetrieveSignalStrengthWithPublishSubscribe |
|
47 |
|
48 |
|
49 /** |
|
50 * Simple destructor. |
|
51 */ |
|
52 CTelWatchersIntTestRetrieveSignalStrengthWithPublishSubscribe::~CTelWatchersIntTestRetrieveSignalStrengthWithPublishSubscribe() |
|
53 { |
|
54 // NOP |
|
55 } // CTelWatchersIntTestRetrieveSignalStrengthWithPublishSubscribe::~CTelWatchersIntTestRetrieveSignalStrengthWithPublishSubscribe |
|
56 |
|
57 |
|
58 /** |
|
59 * This test tests the retrieval of the signal strength. |
|
60 * |
|
61 * @test GT83-SSW-Test01 Test retrieval of the Signal Strength setting. |
|
62 */ |
|
63 enum TVerdict CTelWatchersIntTestRetrieveSignalStrengthWithPublishSubscribe::doTestStepL() |
|
64 { |
|
65 // |
|
66 // Make sure watchers are stopped and unloaded before running this test |
|
67 // This forces SIMTSY to be loaded again. |
|
68 // |
|
69 StopWatcher(); |
|
70 SetSimTsyTestNumberL(0); |
|
71 StartWatcher(); |
|
72 CheckSimTsyTestNumberL(0); |
|
73 |
|
74 TInt state; |
|
75 TRequestStatus localStatus; |
|
76 RProperty localProperty; |
|
77 |
|
78 //-- attach and subscribe to KUidNetworkStrength property |
|
79 TESTCHECKL(localProperty.Attach(KUidSystemCategory,KUidNetworkStrength.iUid), KErrNone); |
|
80 localProperty.Subscribe(localStatus); |
|
81 |
|
82 TInt ret = localProperty.Get(state); |
|
83 TESTCHECKL(ret, KErrNone); |
|
84 INFO_PRINTF2(_L("Initial Signal Strength State is %d"), state); |
|
85 |
|
86 INFO_PRINTF1(_L("Commence Wait for Request local status...")); |
|
87 INFO_PRINTF2(_L("Prior to wait cycle, status is %d"), localStatus.Int()); |
|
88 User::WaitForRequest(localStatus); |
|
89 INFO_PRINTF1(_L("Complete Wait for Request local status.")); |
|
90 localProperty.Subscribe(localStatus); |
|
91 ret = localProperty.Get(state); |
|
92 TESTCHECKL(ret, KErrNone); |
|
93 |
|
94 INFO_PRINTF2(_L("Signal Strength State is %d"), state); |
|
95 TESTCHECK(state, ESANetworkStrengthNone); |
|
96 |
|
97 User::WaitForRequest(localStatus); |
|
98 ret = localProperty.Get(state); |
|
99 localProperty.Subscribe(localStatus); |
|
100 TESTCHECKL(ret, KErrNone); |
|
101 |
|
102 INFO_PRINTF2(_L("Signal Strength State is %d"),state); |
|
103 TESTCHECK(state, ESANetworkStrengthLow); |
|
104 |
|
105 User::WaitForRequest(localStatus); |
|
106 ret = localProperty.Get(state); |
|
107 localProperty.Subscribe(localStatus); |
|
108 TESTCHECKL(ret, KErrNone); |
|
109 |
|
110 INFO_PRINTF2(_L("Signal Strength State is %d"),state); |
|
111 TESTCHECK(state, ESANetworkStrengthMedium); |
|
112 |
|
113 User::WaitForRequest(localStatus); |
|
114 ret = localProperty.Get(state); |
|
115 localProperty.Subscribe(localStatus); |
|
116 TESTCHECKL(ret, KErrNone); |
|
117 |
|
118 INFO_PRINTF2(_L("Signal Strength State is %d"),state); |
|
119 TESTCHECK(state, ESANetworkStrengthHigh); |
|
120 |
|
121 User::WaitForRequest(localStatus); |
|
122 ret = localProperty.Get(state); |
|
123 TESTCHECKL(ret, KErrNone); |
|
124 |
|
125 INFO_PRINTF2(_L("Signal Strength State is %d"),state); |
|
126 TESTCHECK(state, ESANetworkStrengthUnknown); |
|
127 |
|
128 return TestStepResult(); |
|
129 } // CTelWatchersIntTestRetrieveSignalStrengthWithPublishSubscribe::doTestStepL |
|
130 |
|
131 /** |
|
132 * Each test step initialises it's own name |
|
133 */ |
|
134 CTelWatchersIntTestRetrieveChargerStatusWithPublishSubscribe::CTelWatchersIntTestRetrieveChargerStatusWithPublishSubscribe() |
|
135 { |
|
136 // |
|
137 // Store the name of this test case. This is the name that is used by |
|
138 // the script file. |
|
139 // |
|
140 SetTestStepName(_L("TestRetrieveChargerStatusWithPublishSubscribe")); |
|
141 } // CTelWatchersIntTestRetrieveChargerStatusWithPublishSubscribe::CTelWatchersIntTestRetrieveChargerStatusWithPublishSubscribe |
|
142 |
|
143 |
|
144 /** |
|
145 * Simple destructor. |
|
146 */ |
|
147 CTelWatchersIntTestRetrieveChargerStatusWithPublishSubscribe::~CTelWatchersIntTestRetrieveChargerStatusWithPublishSubscribe() |
|
148 { |
|
149 // NOP |
|
150 } // CTelWatchersIntTestRetrieveChargerStatusWithPublishSubscribe::~CTelWatchersIntTestRetrieveChargerStatusWithPublishSubscribe |
|
151 |
|
152 |
|
153 /** |
|
154 * This tests the retrieval of the charger Strength. ESAChargerNotCharging |
|
155 * does not appear to be used in the indicatorwatcher, apart from the |
|
156 * #ifdef'ed test code that is not available to this "in situ" test. |
|
157 * |
|
158 * @test GT83-SSW-Test02 Test retrieval of the Battery and Charger setting. |
|
159 */ |
|
160 enum TVerdict CTelWatchersIntTestRetrieveChargerStatusWithPublishSubscribe::doTestStepL() |
|
161 { |
|
162 // |
|
163 // Make sure watchers are stopped and unloaded before running this test. |
|
164 // This forces SIMTSY to be loaded again. |
|
165 // |
|
166 StopWatcher(); |
|
167 SetSimTsyTestNumberL(1); |
|
168 StartWatcher(); |
|
169 |
|
170 TInt state; |
|
171 TRequestStatus localStatus; |
|
172 RProperty localProperty; |
|
173 |
|
174 //-- attach and subscribe to KUidChargerStatus property |
|
175 TInt ret = localProperty.Attach(KUidSystemCategory,KUidChargerStatus.iUid); |
|
176 TESTCHECKL(ret, KErrNone); |
|
177 localProperty.Subscribe(localStatus); |
|
178 |
|
179 // |
|
180 // Get initial battery charge state |
|
181 // |
|
182 ret = localProperty.Get(state); |
|
183 TESTCHECKL(ret, KErrNone); |
|
184 INFO_PRINTF2(_L("Initial Battery Charger State is %d"), state); |
|
185 |
|
186 |
|
187 User::WaitForRequest(localStatus); |
|
188 localProperty.Subscribe(localStatus); |
|
189 ret = localProperty.Get(state); |
|
190 TESTCHECKL(ret, KErrNone); |
|
191 INFO_PRINTF2(_L("Battery Charger State is %d"), state); |
|
192 TESTCHECK(state, ESAChargerConnected); |
|
193 |
|
194 User::WaitForRequest(localStatus); |
|
195 localProperty.Subscribe(localStatus); |
|
196 ret = localProperty.Get(state); |
|
197 TESTCHECKL(ret, KErrNone); |
|
198 INFO_PRINTF2(_L("Battery Charger State is %d"), state); |
|
199 TESTCHECK(state, ESAChargerDisconnected); |
|
200 |
|
201 User::WaitForRequest(localStatus); |
|
202 localProperty.Subscribe(localStatus); |
|
203 ret = localProperty.Get(state); |
|
204 TESTCHECKL(ret, KErrNone); |
|
205 INFO_PRINTF2(_L("Battery Charger State is %d"), state); |
|
206 TESTCHECK(state, KErrUnknown); |
|
207 |
|
208 User::WaitForRequest(localStatus); |
|
209 ret = localProperty.Get(state); |
|
210 TESTCHECKL(ret, KErrNone); |
|
211 INFO_PRINTF2(_L("Battery Charger State is %d"), state); |
|
212 TESTCHECK(state, ESAChargerConnected); |
|
213 |
|
214 CheckSimTsyTestNumberL(1); |
|
215 |
|
216 return TestStepResult(); |
|
217 } // CTelWatchersIntTestRetrieveChargerStatusWithPublishSubscribe::doTestStepL |
|
218 |
|
219 /** |
|
220 * Each test step initialises it's own name |
|
221 */ |
|
222 CTelWatchersIntTestNetworkStatusWithPublishSubscribe::CTelWatchersIntTestNetworkStatusWithPublishSubscribe() |
|
223 { |
|
224 // |
|
225 // Store the name of this test case. This is the name that is used by |
|
226 // the script file. |
|
227 // |
|
228 SetTestStepName(_L("TestNetworkStatusWithPublishSubscribe")); |
|
229 } // CTelWatchersIntTestNetworkStatusWithPublishSubscribe::CTelWatchersIntTestNetworkStatusWithPublishSubscribe |
|
230 |
|
231 |
|
232 /** |
|
233 * Simple destructor. |
|
234 */ |
|
235 CTelWatchersIntTestNetworkStatusWithPublishSubscribe::~CTelWatchersIntTestNetworkStatusWithPublishSubscribe() |
|
236 { |
|
237 // NOP |
|
238 } // CTelWatchersIntTestNetworkStatusWithPublishSubscribe::~CTelWatchersIntTestNetworkStatusWithPublishSubscribe |
|
239 |
|
240 |
|
241 /** |
|
242 * This tests the retrieval of the Network Status. |
|
243 * |
|
244 * @test GT83-SSW-Test03 Test retrieval of the Network status information. |
|
245 */ |
|
246 enum TVerdict CTelWatchersIntTestNetworkStatusWithPublishSubscribe::doTestStepL() |
|
247 { |
|
248 // |
|
249 // Make sure watchers are stopped and unloaded before running this test. |
|
250 // This forces SIMTSY to be loaded again. |
|
251 // |
|
252 StopWatcher(); |
|
253 SetSimTsyTestNumberL(2); |
|
254 StartWatcher(); |
|
255 |
|
256 TInt state; |
|
257 TRequestStatus localStatus; |
|
258 RProperty localProperty; |
|
259 |
|
260 // |
|
261 // Get initial network available status... |
|
262 // |
|
263 TInt ret = RProperty::Get(KUidSystemCategory, KUidChargerStatus.iUid, state); |
|
264 TESTCHECKL(ret, KErrNone); |
|
265 INFO_PRINTF2(_L("Initial Network Available Status is %d"), state); |
|
266 |
|
267 //-- attach and subscribe to KUidNetworkStatus property |
|
268 ret = localProperty.Attach(KUidSystemCategory,KUidNetworkStatus.iUid); |
|
269 TESTCHECKL(ret, KErrNone); |
|
270 localProperty.Subscribe(localStatus); |
|
271 |
|
272 User::WaitForRequest(localStatus); |
|
273 localProperty.Subscribe(localStatus); |
|
274 ret = localProperty.Get(state); |
|
275 TESTCHECKL(ret, KErrNone); |
|
276 INFO_PRINTF2(_L("Network Available Status is %d"), state); |
|
277 TESTCHECK(state, ESANetworkAvailable); |
|
278 |
|
279 User::WaitForRequest(localStatus); |
|
280 ret = localProperty.Get(state); |
|
281 TESTCHECKL(ret, KErrNone); |
|
282 INFO_PRINTF2(_L("Network Available Status is %d"), state); |
|
283 TESTCHECK(state, ESANetworkUnAvailable); |
|
284 |
|
285 CheckSimTsyTestNumberL(2); |
|
286 |
|
287 return TestStepResult(); |
|
288 } // CTelWatchersIntTestNetworkStatusWithPublishSubscribe::doTestStepL |
|
289 |
|
290 /** |
|
291 * Each test step initialises it's own name |
|
292 */ |
|
293 CTelWatchersIntTestOutgoingCallStatusWithPublishSubscribe::CTelWatchersIntTestOutgoingCallStatusWithPublishSubscribe() |
|
294 { |
|
295 // |
|
296 // Store the name of this test case. This is the name that is used by |
|
297 // the script file. |
|
298 // |
|
299 SetTestStepName(_L("TestOutgoingCallStatusWithPublishSubscribe")); |
|
300 } // CTelWatchersIntTestOutgoingCallStatusWithPublishSubscribe::CTelWatchersIntTestOutgoingCallStatusWithPublishSubscribe |
|
301 |
|
302 |
|
303 /** |
|
304 * Simple destructor. |
|
305 */ |
|
306 CTelWatchersIntTestOutgoingCallStatusWithPublishSubscribe::~CTelWatchersIntTestOutgoingCallStatusWithPublishSubscribe() |
|
307 { |
|
308 // NOP |
|
309 } // CTelWatchersIntTestOutgoingCallStatus::~CTelWatchersIntTestOutgoingCallStatus |
|
310 |
|
311 |
|
312 /** |
|
313 * "Outgoing Call" function. This function will wait until the |
|
314 * Watchers have started and then will make and terminate a call. |
|
315 */ |
|
316 void CTelWatchersIntTestOutgoingCallStatusWithPublishSubscribe::OutgoingCallL() |
|
317 { |
|
318 const TInt KStartupPollPeriod = 1*1000000; |
|
319 const TInt KCallActivePeriod = 5*1000000; |
|
320 |
|
321 TInt val(KErrNotFound); |
|
322 |
|
323 while (val < KErrNone) |
|
324 { |
|
325 User::After(KStartupPollPeriod); |
|
326 User::LeaveIfError(RProperty::Get(KUidSystemCategory, KUidCurrentCall.iUid, val)); |
|
327 } |
|
328 |
|
329 RTelServer telServer; |
|
330 |
|
331 User::LeaveIfError(telServer.Connect()); |
|
332 CleanupClosePushL(telServer); |
|
333 |
|
334 RPhone phone; |
|
335 |
|
336 User::LeaveIfError(phone.Open(telServer, KPhoneName)); |
|
337 CleanupClosePushL(phone); |
|
338 |
|
339 RLine line; |
|
340 |
|
341 User::LeaveIfError(line.Open(phone, KVoiceLineName)); |
|
342 CleanupClosePushL(line); |
|
343 |
|
344 RCall call; |
|
345 TName callName; |
|
346 |
|
347 User::LeaveIfError(call.OpenNewCall(line, callName)); |
|
348 CleanupClosePushL(call); |
|
349 |
|
350 _LIT(KTelNumber,"1234"); |
|
351 |
|
352 User::LeaveIfError(call.Dial(KTelNumber)); |
|
353 |
|
354 User::After(KCallActivePeriod); |
|
355 call.HangUp(); |
|
356 |
|
357 CleanupStack::PopAndDestroy(&call); |
|
358 CleanupStack::PopAndDestroy(&line); |
|
359 CleanupStack::PopAndDestroy(&phone); |
|
360 CleanupStack::PopAndDestroy(&telServer); |
|
361 } // CTelWatchersIntTestOutgoingCallStatusWithPublishSubscribe::OutgoingCallL |
|
362 |
|
363 |
|
364 /** |
|
365 * "Outgoing Call Thread" function. This function just calls OutgoingCallL. |
|
366 * |
|
367 * @param aPtr A pointer to a CTelWatchersIntTestOutgoingCallStatus object. |
|
368 * @return TInt Standard error code. |
|
369 */ |
|
370 TInt CTelWatchersIntTestOutgoingCallStatusWithPublishSubscribe::OutgoingCallThreadFunction(TAny* aPtr) |
|
371 { |
|
372 CTelWatchersIntTestOutgoingCallStatusWithPublishSubscribe* testStep = |
|
373 REINTERPRET_CAST(CTelWatchersIntTestOutgoingCallStatusWithPublishSubscribe*, aPtr); |
|
374 |
|
375 // |
|
376 // Create a clean up stack... |
|
377 // |
|
378 CTrapCleanup* cleanup; |
|
379 |
|
380 cleanup = CTrapCleanup::New(); |
|
381 if (cleanup == NULL) |
|
382 { |
|
383 return KErrGeneral; |
|
384 } |
|
385 |
|
386 // |
|
387 // Call the OutgoingCallL() function... |
|
388 // |
|
389 TRAPD(leaveCode, testStep->OutgoingCallL()); |
|
390 |
|
391 // |
|
392 // Clean up the clean up stack. |
|
393 // |
|
394 delete cleanup; |
|
395 |
|
396 return leaveCode; |
|
397 } // CTelWatchersIntTestOutgoingCallStatusWithPublishSubscribe::OutgoingCallThreadFunction |
|
398 |
|
399 |
|
400 /** |
|
401 * This tests the retrieval of the Current MO Call State. |
|
402 */ |
|
403 enum TVerdict CTelWatchersIntTestOutgoingCallStatusWithPublishSubscribe::doTestStepL() |
|
404 { |
|
405 const TInt KStackSize = 0x8000; |
|
406 const TInt KHeapSize = 0x8000; |
|
407 const TInt KMaxHeapSize = 0x80000; |
|
408 _LIT(KCallThreadName, "OutgoingCallThreadWithPublishSubscribe"); |
|
409 _LIT(KOutgoingThreadSuccess, "Kill"); |
|
410 |
|
411 // |
|
412 // Make sure watchers are stopped and unloaded before running this test |
|
413 // This forces SIMTSY to be loaded again |
|
414 // |
|
415 StopWatcher(); |
|
416 SetSimTsyTestNumberL(3); |
|
417 |
|
418 // |
|
419 // The following is required when running all the tests in "batch" mode. |
|
420 // Since the property persists and the "Call Thread" uses the |
|
421 // KUidCurrentCall>=KErrNone as an indicator that the Watchers are loaded, |
|
422 // its important to ensure that it starts out with an error condition. |
|
423 // This will be reset by the Indicator Watcher. |
|
424 // |
|
425 |
|
426 TInt initialState; |
|
427 User::LeaveIfError(RProperty::Get(KUidSystemCategory,KUidCurrentCall.iUid,initialState)); |
|
428 INFO_PRINTF2(_L("Initial Call Status is %d"), initialState); |
|
429 if (initialState >= KErrNone) |
|
430 { |
|
431 User::LeaveIfError(RProperty::Set(KUidSystemCategory,KUidCurrentCall.iUid,KErrUnknown)); |
|
432 } |
|
433 |
|
434 StartWatcher(); |
|
435 |
|
436 // |
|
437 // Start an outgoing call in a separate thread. |
|
438 // |
|
439 RThread thread; |
|
440 TRequestStatus status; |
|
441 TInt res; |
|
442 |
|
443 res = thread.Create(KCallThreadName, OutgoingCallThreadFunction, |
|
444 KStackSize, KHeapSize, KMaxHeapSize, this); |
|
445 TESTCHECKL(res, KErrNone) |
|
446 |
|
447 thread.Logon(status); |
|
448 thread.Resume(); |
|
449 |
|
450 // |
|
451 // Monitor the Current Call Status through each state... |
|
452 // |
|
453 TInt state; |
|
454 TRequestStatus localStatus; |
|
455 RProperty localProperty; |
|
456 |
|
457 //-- attach and subscribe to KUidCurrentCall property |
|
458 res = localProperty.Attach(KUidSystemCategory,KUidCurrentCall.iUid); |
|
459 TESTCHECKL(res, KErrNone); |
|
460 |
|
461 localProperty.Subscribe(localStatus); |
|
462 User::WaitForRequest(localStatus); |
|
463 res = localProperty.Get(state); |
|
464 localProperty.Subscribe(localStatus); |
|
465 TESTCHECKL(res, KErrNone); |
|
466 INFO_PRINTF2(_L("Current Call Status is %d"), state); |
|
467 TESTCHECK(state, ESACallNone); |
|
468 |
|
469 User::WaitForRequest(localStatus); |
|
470 res = localProperty.Get(state); |
|
471 localProperty.Subscribe(localStatus); |
|
472 TESTCHECKL(res, KErrNone); |
|
473 INFO_PRINTF2(_L("Current Call Status is %d"), state); |
|
474 TESTCHECK(state, ESACallDialling); |
|
475 |
|
476 User::WaitForRequest(localStatus); |
|
477 res = localProperty.Get(state); |
|
478 localProperty.Subscribe(localStatus); |
|
479 TESTCHECKL(res, KErrNone); |
|
480 INFO_PRINTF2(_L("Current Call Status is %d"), state); |
|
481 TESTCHECK(state, ESACallAlerting); |
|
482 |
|
483 User::WaitForRequest(localStatus); |
|
484 res = localProperty.Get(state); |
|
485 localProperty.Subscribe(localStatus); |
|
486 TESTCHECKL(res, KErrNone); |
|
487 INFO_PRINTF2(_L("Current Call Status is %d"), state); |
|
488 TESTCHECK(state, ESACallVoice); |
|
489 |
|
490 User::WaitForRequest(localStatus); |
|
491 res = localProperty.Get(state); |
|
492 localProperty.Subscribe(localStatus); |
|
493 TESTCHECKL(res, KErrNone); |
|
494 INFO_PRINTF2(_L("Current Call Status is %d"), state); |
|
495 TESTCHECK(state, ESACallDisconnecting); |
|
496 |
|
497 User::WaitForRequest(localStatus); |
|
498 res = localProperty.Get(state); |
|
499 TESTCHECKL(res, KErrNone); |
|
500 INFO_PRINTF2(_L("Current Call Status is %d"), state); |
|
501 TESTCHECK(state, ESACallNone); |
|
502 |
|
503 User::WaitForRequest(status); |
|
504 TESTCHECK(status.Int(), KErrNone); |
|
505 TESTCHECKSTR(thread.ExitCategory(), KOutgoingThreadSuccess); |
|
506 TESTCHECK(thread.ExitReason(), KErrNone); |
|
507 TESTCHECK(thread.ExitType(), EExitKill); |
|
508 |
|
509 thread.Close(); |
|
510 |
|
511 CheckSimTsyTestNumberL(3); |
|
512 |
|
513 return TestStepResult(); |
|
514 } // CTelWatchersIntTestOutgoingCallStatusWithPublishSubscribe::doTestStepL |
|
515 |
|
516 /** |
|
517 * Each test step initialises it's own name |
|
518 */ |
|
519 CTelWatchersIntTestIncomingCallStatusWithPublishSubscribe::CTelWatchersIntTestIncomingCallStatusWithPublishSubscribe() |
|
520 { |
|
521 // |
|
522 // Store the name of this test case. This is the name that is used by |
|
523 // the script file. |
|
524 // |
|
525 SetTestStepName(_L("TestIncomingCallStatusWithPublishSubscribe")); |
|
526 } // CTelWatchersIntTestIncomingCallStatusWithPublishSubscribe::CTelWatchersIntTestIncomingCallStatusWithPublishSubscribe |
|
527 |
|
528 |
|
529 /** |
|
530 * Simple destructor. |
|
531 */ |
|
532 CTelWatchersIntTestIncomingCallStatusWithPublishSubscribe::~CTelWatchersIntTestIncomingCallStatusWithPublishSubscribe() |
|
533 { |
|
534 // NOP |
|
535 } // CTelWatchersIntTestIncomingCallStatusWithPublishSubscribe::~CTelWatchersIntTestIncomingCallStatusWithPublishSubscribe |
|
536 |
|
537 |
|
538 /** |
|
539 * "Incoming Call" function. This function will wait until the |
|
540 * Watchers have started and then will receive an incoming data call. |
|
541 */ |
|
542 void CTelWatchersIntTestIncomingCallStatusWithPublishSubscribe::IncomingCallL() |
|
543 { |
|
544 const TInt KStartupPollPeriod = 1*1000000; |
|
545 const TInt KCallRingingPeriod = 5*1000000; |
|
546 const TInt KCallActivePeriod = 5*1000000; |
|
547 |
|
548 TInt val(KErrNotFound); |
|
549 |
|
550 while (val < KErrNone) |
|
551 { |
|
552 User::After(KStartupPollPeriod); |
|
553 User::LeaveIfError(RProperty::Get(KUidSystemCategory, KUidCurrentCall.iUid, val)); |
|
554 } |
|
555 |
|
556 RTelServer telServer; |
|
557 |
|
558 User::LeaveIfError(telServer.Connect()); |
|
559 CleanupClosePushL(telServer); |
|
560 |
|
561 RPhone phone; |
|
562 |
|
563 User::LeaveIfError(phone.Open(telServer, KPhoneName)); |
|
564 CleanupClosePushL(phone); |
|
565 |
|
566 RLine line; |
|
567 |
|
568 User::LeaveIfError(line.Open(phone, KVoiceLineName)); |
|
569 CleanupClosePushL(line); |
|
570 |
|
571 TRequestStatus reqStatus; |
|
572 TName callName; |
|
573 |
|
574 line.NotifyIncomingCall(reqStatus, callName); |
|
575 |
|
576 // |
|
577 // Now initiate incoming call using published property. |
|
578 // Toggle a UID to opposite state to kick SIMTSY. |
|
579 // |
|
580 TInt state; |
|
581 User::LeaveIfError(RProperty::Get(KUidPSSimTsyCategory, KPSSimTsyIncomingVoiceCall, state)); |
|
582 |
|
583 if (state == 0) |
|
584 { |
|
585 state = 1; |
|
586 } |
|
587 else |
|
588 { |
|
589 state = 0; |
|
590 } |
|
591 |
|
592 User::LeaveIfError(RProperty::Set(KUidPSSimTsyCategory, KPSSimTsyIncomingVoiceCall, state)); |
|
593 |
|
594 User::WaitForRequest(reqStatus); |
|
595 User::LeaveIfError(reqStatus.Int()); |
|
596 |
|
597 RCall call; |
|
598 |
|
599 User::LeaveIfError(call.OpenExistingCall(line, callName)); |
|
600 CleanupClosePushL(call); |
|
601 |
|
602 // Delay answering to allow watcher to notice ringing state |
|
603 User::After(KCallRingingPeriod); |
|
604 |
|
605 TInt ret; |
|
606 |
|
607 ret = call.AnswerIncomingCall(); |
|
608 if (ret != KErrNone) |
|
609 { |
|
610 call.HangUp(); |
|
611 User::Leave(ret); |
|
612 } |
|
613 |
|
614 User::After(KCallActivePeriod); |
|
615 call.HangUp(); |
|
616 |
|
617 CleanupStack::PopAndDestroy(&call); |
|
618 CleanupStack::PopAndDestroy(&line); |
|
619 CleanupStack::PopAndDestroy(&phone); |
|
620 CleanupStack::PopAndDestroy(&telServer); |
|
621 } // CTelWatchersIntTestIncomingCallStatusWithPublishSubscribe::IncomingCallThreadFunction |
|
622 |
|
623 /** |
|
624 * "Incoming Call Thread" function. This function just calls IncomingCallL. |
|
625 * |
|
626 * @param aPtr A pointer to a CTelWatchersIntTestIncomingCallStatus object. |
|
627 * @return TInt Standard error code. |
|
628 */ |
|
629 TInt CTelWatchersIntTestIncomingCallStatusWithPublishSubscribe::IncomingCallThreadFunction(TAny* aPtr) |
|
630 { |
|
631 CTelWatchersIntTestIncomingCallStatusWithPublishSubscribe* testStep = |
|
632 REINTERPRET_CAST(CTelWatchersIntTestIncomingCallStatusWithPublishSubscribe*, aPtr); |
|
633 |
|
634 // |
|
635 // Create a clean up stack... |
|
636 // |
|
637 CTrapCleanup* cleanup; |
|
638 |
|
639 cleanup = CTrapCleanup::New(); |
|
640 if (cleanup == NULL) |
|
641 { |
|
642 return KErrGeneral; |
|
643 } |
|
644 |
|
645 // |
|
646 // Call the IncomingCallL() function... |
|
647 // |
|
648 TRAPD(leaveCode, testStep->IncomingCallL()); |
|
649 |
|
650 // |
|
651 // Clean up the clean up stack. |
|
652 // |
|
653 delete cleanup; |
|
654 |
|
655 return leaveCode; |
|
656 } // CTelWatchersIntTestIncomingCallStatusWithPublishSubscribe::IncomingCallThreadFunction |
|
657 |
|
658 /** |
|
659 * This tests the retrieval of the Current MT Call State. |
|
660 * |
|
661 * @test GT83-SSW-Test04 Test retrieval of the Call status information. |
|
662 */ |
|
663 enum TVerdict CTelWatchersIntTestIncomingCallStatusWithPublishSubscribe::doTestStepL() |
|
664 { |
|
665 const TInt KStackSize = 0x8000; |
|
666 const TInt KHeapSize = 0x8000; |
|
667 const TInt KMaxHeapSize = 0x80000; |
|
668 _LIT(KCallThreadName, "IncomingCallThreadWithPublishSubscribe"); |
|
669 _LIT(KIncomingThreadSuccess, "Kill"); |
|
670 |
|
671 // |
|
672 // Make sure watchers are stopped and unloaded before running this test. |
|
673 // This forces SIMTSY to be loaded again. |
|
674 // |
|
675 StopWatcher(); |
|
676 SetSimTsyTestNumberL(4); |
|
677 |
|
678 // |
|
679 // The following is required when running all the tests in "batch" mode. |
|
680 // Since the property persists and the "Call Thread" uses the |
|
681 // KUidCurrentCall>=KErrNone as an indicator that the Watchers are loaded, |
|
682 // its important to ensure that it starts out with an error condition. |
|
683 // This will be reset by the Indicator Watcher. |
|
684 // |
|
685 TInt initialState; |
|
686 User::LeaveIfError(RProperty::Get(KUidSystemCategory,KUidCurrentCall.iUid,initialState)); |
|
687 |
|
688 INFO_PRINTF2(_L("Initial Call Status is %d"), initialState); |
|
689 if (initialState >= KErrNone) |
|
690 { |
|
691 User::LeaveIfError(RProperty::Set(KUidSystemCategory,KUidCurrentCall.iUid,KErrUnknown)); |
|
692 } |
|
693 |
|
694 StartWatcher(); |
|
695 |
|
696 RThread thread; |
|
697 TRequestStatus status; |
|
698 TInt res; |
|
699 |
|
700 res = thread.Create(KCallThreadName, IncomingCallThreadFunction, |
|
701 KStackSize, KHeapSize, KMaxHeapSize, this); |
|
702 TESTCHECKL(res, KErrNone); |
|
703 |
|
704 thread.Logon(status); |
|
705 thread.Resume(); |
|
706 |
|
707 TInt state; |
|
708 TRequestStatus localStatus; |
|
709 RProperty localProperty; |
|
710 |
|
711 //-- attach and subscribe to KUidCurrentCall property |
|
712 res = localProperty.Attach(KUidSystemCategory,KUidCurrentCall.iUid); |
|
713 TESTCHECKL(res, KErrNone); |
|
714 |
|
715 localProperty.Subscribe(localStatus); |
|
716 User::WaitForRequest(localStatus); |
|
717 res = localProperty.Get(state); |
|
718 localProperty.Subscribe(localStatus); |
|
719 TESTCHECKL(res, KErrNone); |
|
720 INFO_PRINTF2(_L("Current Call Status is %d"), state); |
|
721 TESTCHECK(state, ESACallNone); |
|
722 |
|
723 User::WaitForRequest(localStatus); |
|
724 res = localProperty.Get(state); |
|
725 localProperty.Subscribe(localStatus); |
|
726 TESTCHECKL(res, KErrNone); |
|
727 |
|
728 INFO_PRINTF2(_L("Current Call Status is %d"), state); |
|
729 TESTCHECK(state, ESACallRinging); |
|
730 |
|
731 User::WaitForRequest(localStatus); |
|
732 res = localProperty.Get(state); |
|
733 localProperty.Subscribe(localStatus); |
|
734 TESTCHECKL(res, KErrNone); |
|
735 INFO_PRINTF2(_L("Current Call Status is %d"), state); |
|
736 TESTCHECK(state, ESACallAnswering); |
|
737 |
|
738 User::WaitForRequest(localStatus); |
|
739 res = localProperty.Get(state); |
|
740 localProperty.Subscribe(localStatus); |
|
741 TESTCHECKL(res, KErrNone); |
|
742 INFO_PRINTF2(_L("Current Call Status is %d"), state); |
|
743 TESTCHECK(state, ESACallVoice); |
|
744 |
|
745 User::WaitForRequest(localStatus); |
|
746 res = localProperty.Get(state); |
|
747 localProperty.Subscribe(localStatus); |
|
748 TESTCHECKL(res, KErrNone); |
|
749 INFO_PRINTF2(_L("Current Call Status is %d"), state); |
|
750 TESTCHECK(state, ESACallDisconnecting); |
|
751 |
|
752 User::WaitForRequest(localStatus); |
|
753 res = localProperty.Get(state); |
|
754 TESTCHECKL(res, KErrNone); |
|
755 INFO_PRINTF2(_L("Current Call Status is %d"), state); |
|
756 TESTCHECK(state, ESACallNone); |
|
757 |
|
758 User::WaitForRequest(status); |
|
759 TESTCHECK(status.Int(), KErrNone); |
|
760 TESTCHECKSTR(thread.ExitCategory(), KIncomingThreadSuccess); |
|
761 TESTCHECK(thread.ExitReason(), KErrNone); |
|
762 TESTCHECK(thread.ExitType(), EExitKill); |
|
763 thread.Close(); |
|
764 |
|
765 CheckSimTsyTestNumberL(4); |
|
766 |
|
767 return TestStepResult(); |
|
768 } // CTelWatchersIntTestIncomingCallStatusWithPublishSubscribe::doTestStepL |
|
769 |
|
770 /** |
|
771 * Each test step initialises it's own name |
|
772 */ |
|
773 CTelWatchersIntTestIndicatorKErrNotSupportedScenarioWithPublishSubscribe::CTelWatchersIntTestIndicatorKErrNotSupportedScenarioWithPublishSubscribe() |
|
774 { |
|
775 // |
|
776 // Store the name of this test case. This is the name that is used by |
|
777 // the script file. |
|
778 // |
|
779 SetTestStepName(_L("TestIndicatorKErrNotSupportedScenarioWithPublishSubscribe")); |
|
780 } // CTelWatchersIntTestIndicatorKErrNotSupportedScenarioWithPublishSubscribe::CTelWatchersIntTestIndicatorKErrNotSupportedScenarioWithPublishSubscribe |
|
781 |
|
782 |
|
783 /** |
|
784 * Simple destructor. |
|
785 */ |
|
786 CTelWatchersIntTestIndicatorKErrNotSupportedScenarioWithPublishSubscribe::~CTelWatchersIntTestIndicatorKErrNotSupportedScenarioWithPublishSubscribe() |
|
787 { |
|
788 // NOP |
|
789 } // CTelWatchersIntTestIndicatorKErrNotSupportedScenarioWithPublishSubscribe::~CTelWatchersIntTestIndicatorKErrNotSupportedScenarioWithPublishSubscribe |
|
790 |
|
791 |
|
792 /** |
|
793 * This tests the Indicator Error response when facing with TSY errors that |
|
794 * cause it to disable further requests. |
|
795 */ |
|
796 enum TVerdict CTelWatchersIntTestIndicatorKErrNotSupportedScenarioWithPublishSubscribe::doTestStepL() |
|
797 { |
|
798 SetSimTsyTestNumberL(5); |
|
799 |
|
800 // |
|
801 // Make sure watchers are stopped and unloaded before running this test. |
|
802 // This forces SIMTSY to be loaded again. |
|
803 // |
|
804 StopWatcher(); |
|
805 StartWatcher(); |
|
806 |
|
807 TInt state; |
|
808 TRequestStatus localStatus; |
|
809 RProperty localProperty; |
|
810 |
|
811 //-- attach and subscribe to KUidNetworkStrength property |
|
812 TInt ret = localProperty.Attach(KUidSystemCategory,KUidNetworkStrength.iUid); |
|
813 TESTCHECKL(ret, KErrNone); |
|
814 localProperty.Subscribe(localStatus); |
|
815 |
|
816 // |
|
817 // Get initial signal state... |
|
818 // |
|
819 ret = localProperty.Get(state); |
|
820 TESTCHECKL(ret, KErrNone ); |
|
821 INFO_PRINTF2(_L("Initial Signal Strength State is %d"), state); |
|
822 |
|
823 // |
|
824 // Wait for change to known state... |
|
825 // |
|
826 User::WaitForRequest(localStatus); |
|
827 localProperty.Subscribe(localStatus); |
|
828 ret = localProperty.Get(state); |
|
829 TESTCHECKL(ret, KErrNone); |
|
830 INFO_PRINTF2(_L("Signal Strength State is %d"), state); |
|
831 TESTCHECK(state, ESANetworkStrengthNone); |
|
832 |
|
833 // |
|
834 // Now wait for change back to unknown state. It should stay unknown for |
|
835 // the next 15 seconds. |
|
836 // |
|
837 User::WaitForRequest(localStatus); |
|
838 ret = localProperty.Get(state); |
|
839 TESTCHECKL(ret, KErrNone); |
|
840 INFO_PRINTF2(_L("Signal Strength State is %d"), state); |
|
841 TESTCHECK(state, ESANetworkStrengthUnknown); |
|
842 |
|
843 RTimer timer; |
|
844 TRequestStatus timerRequestStatus; |
|
845 const TTimeIntervalMicroSeconds32 timerPeriod=15*1000000; |
|
846 TInt err; |
|
847 |
|
848 err = timer.CreateLocal(); |
|
849 TESTCHECKL(err, KErrNone); |
|
850 timer.After(timerRequestStatus, timerPeriod); |
|
851 |
|
852 localProperty.Subscribe(localStatus); |
|
853 |
|
854 User::WaitForRequest(timerRequestStatus, localStatus); |
|
855 |
|
856 TESTCHECKL(localStatus.Int(), KRequestPending); |
|
857 TESTCHECKL(timerRequestStatus.Int(), KErrNone); |
|
858 |
|
859 localProperty.Cancel(); |
|
860 User::WaitForRequest(localStatus); |
|
861 |
|
862 TESTCHECKL(localStatus.Int(), KErrCancel); |
|
863 timer.Close(); |
|
864 |
|
865 CheckSimTsyTestNumberL(5); |
|
866 |
|
867 return TestStepResult(); |
|
868 } // CTelWatchersIntTestIndicatorKErrNotSupportedScenarioWithPublishSubscribe::doTestStepL |
|
869 |
|
870 /** |
|
871 * Each test step initialises it's own name |
|
872 */ |
|
873 CTelWatchersIntTestIndicatorKErrEtelModemNotDetectedScenarioWithPublishSubscribe::CTelWatchersIntTestIndicatorKErrEtelModemNotDetectedScenarioWithPublishSubscribe() |
|
874 { |
|
875 // |
|
876 // Store the name of this test case. This is the name that is used by |
|
877 // the script file. |
|
878 // |
|
879 SetTestStepName(_L("TestIndicatorKErrEtelModemNotDetectedScenarioWithPublishSubscribe")); |
|
880 } // CTelWatchersIntTestIndicatorKErrEtelModemNotDetectedScenarioWithPublishSubscribe::CTelWatchersIntTestIndicatorKErrEtelModemNotDetectedScenarioWithPublishSubscribe |
|
881 |
|
882 |
|
883 /** |
|
884 * Simple destructor. |
|
885 */ |
|
886 CTelWatchersIntTestIndicatorKErrEtelModemNotDetectedScenarioWithPublishSubscribe::~CTelWatchersIntTestIndicatorKErrEtelModemNotDetectedScenarioWithPublishSubscribe() |
|
887 { |
|
888 // NOP |
|
889 } // CTelWatchersIntTestIndicatorKErrEtelModemNotDetectedScenarioWithPublishSubscribe::~CTelWatchersIntTestIndicatorKErrEtelModemNotDetectedScenarioWithPublishSubscribe |
|
890 |
|
891 |
|
892 /** |
|
893 * This tests the Indicator Error response when faced with a TSY failure -2017 |
|
894 * and the restart of the watchers. |
|
895 */ |
|
896 enum TVerdict CTelWatchersIntTestIndicatorKErrEtelModemNotDetectedScenarioWithPublishSubscribe::doTestStepL() |
|
897 { |
|
898 TInt ret = RProperty::Set(KUidSystemCategory,KUidPhonePwr.iUid,ESAPhoneOff); |
|
899 TESTCHECKL(ret, KErrNone); |
|
900 |
|
901 SetSimTsyTestNumberL(6); |
|
902 |
|
903 TInt state; |
|
904 TRequestStatus localStatus; |
|
905 RProperty localProperty; |
|
906 |
|
907 //-- attach and subscribe to KUidNetworkStrength property |
|
908 ret = localProperty.Attach(KUidSystemCategory,KUidNetworkStrength.iUid); |
|
909 TESTCHECKL(ret, KErrNone); |
|
910 localProperty.Subscribe(localStatus); |
|
911 |
|
912 User::WaitForRequest(localStatus); |
|
913 localProperty.Subscribe(localStatus); |
|
914 ret = localProperty.Get(state); |
|
915 TESTCHECKL(ret, KErrNone); |
|
916 TESTCHECK(state, ESANetworkStrengthNone); |
|
917 |
|
918 User::WaitForRequest(localStatus); |
|
919 localProperty.Subscribe(localStatus); |
|
920 ret = localProperty.Get(state); |
|
921 TESTCHECKL(ret, KErrNone); |
|
922 INFO_PRINTF2(_L("Signal Strength State is %d"), state); |
|
923 TESTCHECK(state, ESANetworkStrengthUnknown); |
|
924 |
|
925 User::After(1*1000000); |
|
926 |
|
927 ret = RProperty::Set(KUidSystemCategory,KUidPhonePwr.iUid,ESAPhoneOn); |
|
928 TESTCHECKL(ret, KErrNone); |
|
929 |
|
930 TInt previousState = state; |
|
931 do |
|
932 { |
|
933 User::WaitForRequest(localStatus); |
|
934 localProperty.Subscribe(localStatus); |
|
935 ret = localProperty.Get(state); |
|
936 TESTCHECKL(ret, KErrNone); |
|
937 } while (state == previousState); // wait until state changes |
|
938 |
|
939 INFO_PRINTF2(_L("Signal Strength State is %d"), state); |
|
940 TESTCHECK(state, ESANetworkStrengthHigh); |
|
941 |
|
942 CheckSimTsyTestNumberL(6); |
|
943 |
|
944 return TestStepResult(); |
|
945 } // CTelWatchersIntTestIndicatorKErrEtelModemNotDetectedScenarioWithPublishSubscribe::doTestStepL |