|
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 "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 // |
|
15 |
|
16 #include "tphonetsytesthelper.h" |
|
17 #include <ctsy/rmmcustomapi.h> |
|
18 |
|
19 /** |
|
20 * Constructor |
|
21 */ |
|
22 TPhoneTsyTestHelper::TPhoneTsyTestHelper(CCTSYIntegrationTestSuiteStepBase& aTestStep) |
|
23 : TTsyTestHelperBase( aTestStep ) |
|
24 { |
|
25 } |
|
26 /** |
|
27 * Notify reset for RMobilePhone::NotifyCostCapsChange |
|
28 */ |
|
29 void TPhoneTsyTestHelper::WaitForMobilePhoneNotifyCostCapsChange( |
|
30 RMobilePhone& aMobilePhone, |
|
31 TEtelRequestBase& aRequestStatus, |
|
32 TUint32& aCaps, |
|
33 TUint32 aWantedCaps, |
|
34 TUint32 aUnwantedCaps, |
|
35 TInt aWantedStatus ) |
|
36 |
|
37 { |
|
38 // Wait for the request to complete |
|
39 TInt err = iTestStep.WaitForRequestWithTimeOut(aRequestStatus, ETimeShort); |
|
40 ASSERT_EQUALS(err, KErrNone, _L("RMobilePhone::NotifyCostCapsChange did not complete")) |
|
41 |
|
42 while ( err == KErrNone && aRequestStatus.Int() == KErrNone |
|
43 && ( ((aCaps & aWantedCaps) != aWantedCaps) |
|
44 || ((aCaps & aUnwantedCaps) != 0) ) ) |
|
45 { |
|
46 // Request has completed with incorrect result. Consume any outstanding |
|
47 // Repost notification until timeout or we get the right result. |
|
48 aMobilePhone.NotifyCostCapsChange(aRequestStatus, aCaps); |
|
49 err = iTestStep.WaitForRequestWithTimeOut(aRequestStatus, ETimeShort); |
|
50 } |
|
51 |
|
52 ASSERT_EQUALS(aRequestStatus.Int(), aWantedStatus, |
|
53 _L("RMobilePhone::NotifyCostCapsChange Wrong completion status")) |
|
54 ASSERT_BITS_SET(aCaps, aWantedCaps, aUnwantedCaps, |
|
55 _L("RMobilePhone::NotifyCostCapsChange Wrong caps")) |
|
56 |
|
57 // Cancel request if it is still pending |
|
58 if (aRequestStatus.Int() == KRequestPending) |
|
59 { |
|
60 aRequestStatus.Cancel(); |
|
61 } |
|
62 } |
|
63 |
|
64 |
|
65 /** |
|
66 * Notify reset for RMobilePhone::NotifyIccAccessCapsChange |
|
67 */ |
|
68 void TPhoneTsyTestHelper::WaitForMobilePhoneNotifyIccAccessCapsChange( |
|
69 RMobilePhone& aMobilePhone, |
|
70 TEtelRequestBase& aRequestStatus, |
|
71 TUint32& aCaps, |
|
72 TUint32 aWantedCaps, |
|
73 TUint32 aUnwantedCaps, |
|
74 TInt aWantedStatus ) |
|
75 |
|
76 { |
|
77 // Wait for the request to complete |
|
78 TInt err = iTestStep.WaitForRequestWithTimeOut(aRequestStatus, ETimeShort); |
|
79 ASSERT_EQUALS(err, KErrNone, _L("RMobilePhone::NotifyIccAccessCapsChange did not complete")) |
|
80 |
|
81 while ( err == KErrNone && aRequestStatus.Int() == KErrNone |
|
82 && ( ((aCaps & aWantedCaps) != aWantedCaps) |
|
83 || ((aCaps & aUnwantedCaps) != 0) ) ) |
|
84 { |
|
85 // Request has completed with incorrect result. Consume any outstanding |
|
86 // Repost notification until timeout or we get the right result. |
|
87 aMobilePhone.NotifyIccAccessCapsChange(aRequestStatus, aCaps); |
|
88 err = iTestStep.WaitForRequestWithTimeOut(aRequestStatus, ETimeShort); |
|
89 } |
|
90 |
|
91 ASSERT_EQUALS(aRequestStatus.Int(), aWantedStatus, |
|
92 _L("RMobilePhone::NotifyIccAccessCapsChange Wrong completion status")) |
|
93 ASSERT_BITS_SET(aCaps, aWantedCaps, aUnwantedCaps, |
|
94 _L("RMobilePhone::NotifyIccAccessCapsChange Wrong caps")) |
|
95 |
|
96 // Cancel request if it is still pending |
|
97 if (aRequestStatus.Int() == KRequestPending) |
|
98 { |
|
99 aRequestStatus.Cancel(); |
|
100 } |
|
101 } |
|
102 |
|
103 |
|
104 /** |
|
105 * Notify reset for RMobilePhone::NotifySecurityCapsChange |
|
106 */ |
|
107 void TPhoneTsyTestHelper::WaitForMobilePhoneNotifySecurityCapsChange( |
|
108 RMobilePhone& aMobilePhone, |
|
109 TEtelRequestBase& aRequestStatus, |
|
110 TUint32& aCaps, |
|
111 TUint32 aWantedCaps, |
|
112 TUint32 aUnwantedCaps, |
|
113 TInt aWantedStatus ) |
|
114 |
|
115 { |
|
116 // Wait for the request to complete |
|
117 TInt err = iTestStep.WaitForRequestWithTimeOut(aRequestStatus, ETimeShort); |
|
118 ASSERT_EQUALS(err, KErrNone, _L("RMobilePhone::NotifySecurityCapsChange did not complete")) |
|
119 |
|
120 while ( err == KErrNone && aRequestStatus.Int() == KErrNone |
|
121 && ( ((aCaps & aWantedCaps) != aWantedCaps) |
|
122 || ((aCaps & aUnwantedCaps) != 0) ) ) |
|
123 { |
|
124 // Request has completed with incorrect result. Consume any outstanding |
|
125 // Repost notification until timeout or we get the right result. |
|
126 aMobilePhone.NotifySecurityCapsChange(aRequestStatus, aCaps); |
|
127 err = iTestStep.WaitForRequestWithTimeOut(aRequestStatus, ETimeShort); |
|
128 } |
|
129 |
|
130 ASSERT_EQUALS(aRequestStatus.Int(), aWantedStatus, |
|
131 _L("RMobilePhone::NotifySecurityCapsChange Wrong completion status")) |
|
132 ASSERT_BITS_SET(aCaps, aWantedCaps, aUnwantedCaps, |
|
133 _L("RMobilePhone::NotifySecurityCapsChange Wrong caps")) |
|
134 |
|
135 // Cancel request if it is still pending |
|
136 if (aRequestStatus.Int() == KRequestPending) |
|
137 { |
|
138 aRequestStatus.Cancel(); |
|
139 } |
|
140 } |
|
141 |
|
142 |
|
143 /** |
|
144 * Notify reset for RMobilePhone::NotifySecurityEvent |
|
145 */ |
|
146 void TPhoneTsyTestHelper::WaitForMobilePhoneNotifySecurityEvent( |
|
147 RMobilePhone& aMobilePhone, |
|
148 TEtelRequestBase& aRequestStatus, |
|
149 RMobilePhone::TMobilePhoneSecurityEvent& aEvent, |
|
150 RMobilePhone::TMobilePhoneSecurityEvent aExpectedEvent, |
|
151 TInt aWantedStatus ) |
|
152 |
|
153 { |
|
154 // Wait for the request to complete |
|
155 TInt err = iTestStep.WaitForRequestWithTimeOut(aRequestStatus, ETimeMedium); |
|
156 ASSERT_EQUALS(err, KErrNone, _L("RMobilePhone::NotifySecurityEvent did not complete")) |
|
157 |
|
158 while ( err == KErrNone && aRequestStatus.Int() == KErrNone |
|
159 && aEvent != aExpectedEvent ) |
|
160 { |
|
161 // Request has completed with incorrect result. Consume any outstanding |
|
162 // Repost notification until timeout or we get the right result. |
|
163 |
|
164 aMobilePhone.NotifySecurityEvent(aRequestStatus, aEvent); |
|
165 err = iTestStep.WaitForRequestWithTimeOut(aRequestStatus, ETimeShort); |
|
166 } |
|
167 |
|
168 ASSERT_EQUALS(aRequestStatus.Int(), aWantedStatus, _L("RMobilePhone::NotifySecurityEvent Wrong completion status")) |
|
169 ASSERT_EQUALS(aEvent, aExpectedEvent, |
|
170 _L("RMobilePhone::NotifySecurityEvent Wrong result")) |
|
171 |
|
172 // Cancel request if it is still pending |
|
173 if (aRequestStatus.Int() == KRequestPending) |
|
174 { |
|
175 aRequestStatus.Cancel(); |
|
176 } |
|
177 } |
|
178 |
|
179 |
|
180 /** |
|
181 * Notify reset for RMobilePhone::NotifySignalStrengthChange |
|
182 */ |
|
183 void TPhoneTsyTestHelper::WaitForMobilePhoneNotifySignalStrengthChange( |
|
184 RMobilePhone& aMobilePhone, |
|
185 TEtelRequestBase& aRequestStatus, |
|
186 TInt32& aSignalStrength, |
|
187 TInt32 aExpectedSignalStrength, |
|
188 TInt8 &aBar, |
|
189 TInt aWantedStatus ) |
|
190 |
|
191 { |
|
192 // Wait for the request to complete |
|
193 TInt err = iTestStep.WaitForRequestWithTimeOut(aRequestStatus, ETimeShort); |
|
194 ASSERT_EQUALS(err, KErrNone, _L("RMobilePhone::NotifySignalStrengthChange did not complete")) |
|
195 |
|
196 while ( err == KErrNone && aRequestStatus.Int() == KErrNone |
|
197 && aSignalStrength != aExpectedSignalStrength ) |
|
198 { |
|
199 // Request has completed with incorrect result. Consume any outstanding |
|
200 // Repost notification until timeout or we get the right result. |
|
201 |
|
202 aMobilePhone.NotifySignalStrengthChange(aRequestStatus, aSignalStrength, aBar); |
|
203 err = iTestStep.WaitForRequestWithTimeOut(aRequestStatus, ETimeShort); |
|
204 } |
|
205 |
|
206 ASSERT_EQUALS(aRequestStatus.Int(), aWantedStatus, _L("RMobilePhone::NotifySignalStrengthChange Wrong completion status")) |
|
207 ASSERT_EQUALS(aSignalStrength, aExpectedSignalStrength, |
|
208 _L("RMobilePhone::NotifySignalStrengthChange Wrong result")) |
|
209 |
|
210 // Cancel request if it is still pending |
|
211 if (aRequestStatus.Int() == KRequestPending) |
|
212 { |
|
213 aRequestStatus.Cancel(); |
|
214 } |
|
215 } |
|
216 |
|
217 |
|
218 /** |
|
219 * Notify reset for RMobilePhone::NotifyLockInfoChange |
|
220 */ |
|
221 void TPhoneTsyTestHelper::WaitForMobilePhoneNotifyLockInfoChange( |
|
222 RMobilePhone& aMobilePhone, |
|
223 TEtelRequestBase& aRequestStatus, |
|
224 RMobilePhone::TMobilePhoneLock &aLock, |
|
225 RMobilePhone::TMobilePhoneLock aExpectedLock, |
|
226 TCmpBase<RMobilePhone::TMobilePhoneLockInfoV1> &aMobilePhoneLockInfoV1, |
|
227 TInt aWantedStatus ) |
|
228 |
|
229 { |
|
230 // Wait for the request to complete |
|
231 TInt err = iTestStep.WaitForRequestWithTimeOut(aRequestStatus, ETimeMedium); |
|
232 ASSERT_EQUALS(err, KErrNone, _L("RMobilePhone::NotifyLockInfoChange did not complete")) |
|
233 while ( err == KErrNone && aRequestStatus.Int() == KErrNone ) |
|
234 { |
|
235 // Request has completed with incorrect result. Consume any outstanding |
|
236 // Repost notification until timeout or we get the right result. |
|
237 DEBUG_PRINTF3(_L("requestStatus: %d, aLock:%d, "),aRequestStatus.Int(),aLock) |
|
238 DEBUG_PRINTF4(_L("setting : %d, status:%d, isEqual : %d"),aMobilePhoneLockInfoV1.GetValue().iSetting,aMobilePhoneLockInfoV1.GetValue().iStatus, aMobilePhoneLockInfoV1.IsEqual(ENoLogError)); |
|
239 if( aLock == aExpectedLock && aMobilePhoneLockInfoV1.IsEqual(ENoLogError) ) |
|
240 { |
|
241 break; |
|
242 } |
|
243 RMobilePhone::TMobilePhoneLockInfoV1Pckg pkgParam( aMobilePhoneLockInfoV1.GetValue() ); |
|
244 aMobilePhone.NotifyLockInfoChange(aRequestStatus, aLock, pkgParam); |
|
245 err = iTestStep.WaitForRequestWithTimeOut(aRequestStatus, ETimeLong); |
|
246 } |
|
247 |
|
248 ASSERT_EQUALS(aRequestStatus.Int(), aWantedStatus, _L("RMobilePhone::NotifyLockInfoChange Wrong completion status")) |
|
249 ASSERT_TRUE(aMobilePhoneLockInfoV1.IsEqual(ELogError), |
|
250 _L("RMobilePhone::NotifyLockInfoChange Wrong lock information was returned")) |
|
251 ASSERT_EQUALS(aLock, aExpectedLock, |
|
252 _L("RMobilePhone::NotifyLockInfoChange Wrong lock was returned")) |
|
253 |
|
254 // Cancel request if it is still pending |
|
255 if (aRequestStatus.Int() == KRequestPending) |
|
256 { |
|
257 aRequestStatus.Cancel(); |
|
258 } |
|
259 } |
|
260 |
|
261 |
|
262 /** |
|
263 * Notify reset for RMobilePhone::NotifyNITZInfoChange |
|
264 */ |
|
265 void TPhoneTsyTestHelper::WaitForMobilePhoneNotifyNITZInfoChange( |
|
266 RMobilePhone& aMobilePhone, |
|
267 TEtelRequestBase& aRequestStatus, |
|
268 RMobilePhone::TMobilePhoneNITZ& aNITZInfo, |
|
269 RMobilePhone::TMobilePhoneNITZ& aExpectedNITZInfo, |
|
270 TInt aWantedStatus ) |
|
271 |
|
272 { |
|
273 // Wait for the request to complete |
|
274 TInt err = iTestStep.WaitForRequestWithTimeOut(aRequestStatus, ETimeShort); |
|
275 ASSERT_EQUALS(err, KErrNone, _L("RMobilePhone::NotifyNITZInfoChange did not complete")) |
|
276 |
|
277 while ( err == KErrNone && aRequestStatus.Int() == KErrNone |
|
278 && (0 == memcmp(&aNITZInfo, &aExpectedNITZInfo, sizeof(aNITZInfo))) ) |
|
279 { |
|
280 // Request has completed with incorrect result. Consume any outstanding |
|
281 // Repost notification until timeout or we get the right result. |
|
282 |
|
283 aMobilePhone.NotifyNITZInfoChange(aRequestStatus, aNITZInfo); |
|
284 err = iTestStep.WaitForRequestWithTimeOut(aRequestStatus, ETimeShort); |
|
285 } |
|
286 |
|
287 ASSERT_EQUALS(aRequestStatus.Int(), aWantedStatus, _L("RMobilePhone::NotifyNITZInfoChange Wrong completion status")) |
|
288 ASSERT_TRUE((0 == memcmp(&aNITZInfo, &aExpectedNITZInfo, sizeof(aNITZInfo))), |
|
289 _L("RMobilePhone::NotifyNITZInfoChange Wrong result")) |
|
290 |
|
291 // Cancel request if it is still pending |
|
292 if (aRequestStatus.Int() == KRequestPending) |
|
293 { |
|
294 aRequestStatus.Cancel(); |
|
295 } |
|
296 } |
|
297 |
|
298 |
|
299 /** |
|
300 * Notify reset for RMobilePhone::NotifyNetworkSelectionSettingChange |
|
301 */ |
|
302 void TPhoneTsyTestHelper::WaitForMobilePhoneNotifyNetworkSelectionSettingChange( |
|
303 RMobilePhone& aMobilePhone, |
|
304 TEtelRequestBase& aRequestStatus, |
|
305 TCmpBase<RMobilePhone::TMobilePhoneNetworkSelectionV1> &aMobilePhoneNetworkSelectionV1, |
|
306 TInt aWantedStatus ) |
|
307 |
|
308 { |
|
309 // Wait for the request to complete |
|
310 TInt err = iTestStep.WaitForRequestWithTimeOut(aRequestStatus, ETimeShort); |
|
311 ASSERT_EQUALS(err, KErrNone, _L("RMobilePhone::NotifyNetworkSelectionSettingChange did not complete")) |
|
312 |
|
313 while ( err == KErrNone && aRequestStatus.Int() == KErrNone |
|
314 && !aMobilePhoneNetworkSelectionV1.IsEqual(ENoLogError) ) |
|
315 { |
|
316 // Request has completed with incorrect result. Consume any outstanding |
|
317 // Repost notification until timeout or we get the right result. |
|
318 RMobilePhone::TMobilePhoneNetworkSelectionV1Pckg pkgParam( aMobilePhoneNetworkSelectionV1.GetValue() ); |
|
319 aMobilePhone.NotifyNetworkSelectionSettingChange(aRequestStatus, pkgParam); |
|
320 err = iTestStep.WaitForRequestWithTimeOut(aRequestStatus, ETimeShort); |
|
321 } |
|
322 |
|
323 ASSERT_EQUALS(aRequestStatus.Int(), aWantedStatus, _L("RMobilePhone::NotifyNetworkSelectionSettingChange Wrong completion status")) |
|
324 ASSERT_TRUE(aMobilePhoneNetworkSelectionV1.IsEqual(ELogError), |
|
325 _L("RMobilePhone::NotifyNetworkSelectionSettingChange Wrong result")) |
|
326 |
|
327 // Cancel request if it is still pending |
|
328 if (aRequestStatus.Int() == KRequestPending) |
|
329 { |
|
330 aRequestStatus.Cancel(); |
|
331 } |
|
332 } |
|
333 |
|
334 |
|
335 /** |
|
336 * Notify reset for RMobilePhone::NotifySecurityCodeInfoChange |
|
337 */ |
|
338 void TPhoneTsyTestHelper::WaitForMobilePhoneNotifySecurityCodeInfoChange( |
|
339 RMobilePhone& aMobilePhone, |
|
340 TEtelRequestBase& aRequestStatus, |
|
341 RMobilePhone::TMobilePhoneSecurityCode &aSecurityCode, |
|
342 TCmpBase<RMobilePhone::TMobilePhoneSecurityCodeInfoV5> &aMobilePhoneSecurityCodeInfoV5, |
|
343 TInt aWantedStatus ) |
|
344 |
|
345 { |
|
346 // Wait for the request to complete |
|
347 TInt err = iTestStep.WaitForRequestWithTimeOut(aRequestStatus, ETimeShort); |
|
348 ASSERT_EQUALS(err, KErrNone, _L("RMobilePhone::NotifySecurityCodeInfoChange did not complete")) |
|
349 |
|
350 while ( err == KErrNone && aRequestStatus.Int() == KErrNone |
|
351 && !aMobilePhoneSecurityCodeInfoV5.IsEqual(ENoLogError) ) |
|
352 { |
|
353 // Request has completed with incorrect result. Consume any outstanding |
|
354 // Repost notification until timeout or we get the right result. |
|
355 RMobilePhone::TMobilePhoneSecurityCodeInfoV5Pckg pkgParam( aMobilePhoneSecurityCodeInfoV5.GetValue() ); |
|
356 aMobilePhone.NotifySecurityCodeInfoChange(aRequestStatus, aSecurityCode, pkgParam); |
|
357 err = iTestStep.WaitForRequestWithTimeOut(aRequestStatus, ETimeShort); |
|
358 } |
|
359 |
|
360 ASSERT_EQUALS(aRequestStatus.Int(), aWantedStatus, _L("RMobilePhone::NotifySecurityCodeInfoChange Wrong completion status")) |
|
361 ASSERT_TRUE(aMobilePhoneSecurityCodeInfoV5.IsEqual(ELogError), |
|
362 _L("RMobilePhone::NotifySecurityCodeInfoChange Wrong result")) |
|
363 |
|
364 // Cancel request if it is still pending |
|
365 if (aRequestStatus.Int() == KRequestPending) |
|
366 { |
|
367 aRequestStatus.Cancel(); |
|
368 } |
|
369 } |
|
370 |
|
371 |
|
372 /** |
|
373 * Notify reset for RMobilePhone::NotifyMmsConfig |
|
374 */ |
|
375 void TPhoneTsyTestHelper::WaitForMobilePhoneNotifyMmsConfig( |
|
376 RMobilePhone& aMobilePhone, |
|
377 TEtelRequestBase& aRequestStatus, |
|
378 RMobilePhone::TMmsConnParams& aType, |
|
379 RMobilePhone::TMmsConnParams aExpectedType, |
|
380 TDes8 &aConnectivity, |
|
381 TInt aWantedStatus ) |
|
382 |
|
383 { |
|
384 // Wait for the request to complete |
|
385 TInt err = iTestStep.WaitForRequestWithTimeOut(aRequestStatus, ETimeShort); |
|
386 ASSERT_EQUALS(err, KErrNone, _L("RMobilePhone::NotifyMmsConfig did not complete")) |
|
387 |
|
388 while ( err == KErrNone && aRequestStatus.Int() == KErrNone |
|
389 && aType != aExpectedType ) |
|
390 { |
|
391 // Request has completed with incorrect result. Consume any outstanding |
|
392 // Repost notification until timeout or we get the right result. |
|
393 |
|
394 aMobilePhone.NotifyMmsConfig(aRequestStatus, aType, aConnectivity); |
|
395 err = iTestStep.WaitForRequestWithTimeOut(aRequestStatus, ETimeShort); |
|
396 } |
|
397 |
|
398 ASSERT_EQUALS(aRequestStatus.Int(), aWantedStatus, _L("RMobilePhone::NotifyMmsConfig Wrong completion status")) |
|
399 ASSERT_EQUALS(aType, aExpectedType, |
|
400 _L("RMobilePhone::NotifyMmsConfig Wrong result")) |
|
401 |
|
402 // Cancel request if it is still pending |
|
403 if (aRequestStatus.Int() == KRequestPending) |
|
404 { |
|
405 aRequestStatus.Cancel(); |
|
406 } |
|
407 } |
|
408 |
|
409 |
|
410 /** |
|
411 * Notify reset for RMobilePhone::NotifyMmsUpdate |
|
412 */ |
|
413 void TPhoneTsyTestHelper::WaitForMobilePhoneNotifyMmsUpdate( |
|
414 RMobilePhone& aMobilePhone, |
|
415 TEtelRequestBase& aRequestStatus, |
|
416 TCmpBase<RMobilePhone::TMmsNotificationV3> &aMmsNotificationV3, |
|
417 TInt aWantedStatus ) |
|
418 |
|
419 { |
|
420 // Wait for the request to complete |
|
421 TInt err = iTestStep.WaitForRequestWithTimeOut(aRequestStatus, ETimeShort); |
|
422 ASSERT_EQUALS(err, KErrNone, _L("RMobilePhone::NotifyMmsUpdate did not complete")) |
|
423 |
|
424 while ( err == KErrNone && aRequestStatus.Int() == KErrNone |
|
425 && !aMmsNotificationV3.IsEqual(ENoLogError) ) |
|
426 { |
|
427 // Request has completed with incorrect result. Consume any outstanding |
|
428 // Repost notification until timeout or we get the right result. |
|
429 RMobilePhone::TMmsNotificationV3Pckg pkgParam( aMmsNotificationV3.GetValue() ); |
|
430 aMobilePhone.NotifyMmsUpdate(aRequestStatus, pkgParam); |
|
431 err = iTestStep.WaitForRequestWithTimeOut(aRequestStatus, ETimeShort); |
|
432 } |
|
433 |
|
434 ASSERT_EQUALS(aRequestStatus.Int(), aWantedStatus, _L("RMobilePhone::NotifyMmsUpdate Wrong completion status")) |
|
435 ASSERT_TRUE(aMmsNotificationV3.IsEqual(ELogError), |
|
436 _L("RMobilePhone::NotifyMmsUpdate Wrong result")) |
|
437 |
|
438 // Cancel request if it is still pending |
|
439 if (aRequestStatus.Int() == KRequestPending) |
|
440 { |
|
441 aRequestStatus.Cancel(); |
|
442 } |
|
443 } |
|
444 |
|
445 |
|
446 /** |
|
447 * Notify reset for RMobilePhone::NotifyBatteryInfoChange |
|
448 */ |
|
449 void TPhoneTsyTestHelper::WaitForMobilePhoneNotifyBatteryInfoChange( |
|
450 RMobilePhone& aMobilePhone, |
|
451 TEtelRequestBase& aRequestStatus, |
|
452 TCmpBase<RMobilePhone::TMobilePhoneBatteryInfoV1> &aPhoneBatteryInfoComp, |
|
453 TInt aWantedStatus ) |
|
454 |
|
455 { |
|
456 // Wait for the request to complete |
|
457 TInt err = iTestStep.WaitForRequestWithTimeOut(aRequestStatus, ETimeShort); |
|
458 ASSERT_EQUALS(err, KErrNone, _L("RMobilePhone::NotifyBatteryInfoChange did not complete")) |
|
459 |
|
460 while ( err == KErrNone && aRequestStatus.Int() == KErrNone |
|
461 && !aPhoneBatteryInfoComp.IsEqual(ENoLogError) ) |
|
462 { |
|
463 // Request has completed with incorrect result. Consume any outstanding |
|
464 // Repost notification until timeout or we get the right result. |
|
465 RMobilePhone::TMobilePhoneBatteryInfoV1 pkgParam(aPhoneBatteryInfoComp.GetValue()); |
|
466 aMobilePhone.NotifyBatteryInfoChange(aRequestStatus, pkgParam); |
|
467 err = iTestStep.WaitForRequestWithTimeOut(aRequestStatus, ETimeShort); |
|
468 } |
|
469 |
|
470 ASSERT_EQUALS(aRequestStatus.Int(), aWantedStatus, _L("RMobilePhone::NotifyBatteryInfoChange Wrong completion status")) |
|
471 ASSERT_TRUE(aPhoneBatteryInfoComp.IsEqual(ELogError), |
|
472 _L("RMobilePhone::NotifyBatteryInfoChange Wrong result")) |
|
473 |
|
474 // Cancel request if it is still pending |
|
475 if (aRequestStatus.Int() == KRequestPending) |
|
476 { |
|
477 aRequestStatus.Cancel(); |
|
478 } |
|
479 } |
|
480 |
|
481 |
|
482 /** |
|
483 * Notify reset for RMobilePhone::NotifyDefaultPrivacyChange |
|
484 */ |
|
485 void TPhoneTsyTestHelper::WaitForMobilePhoneNotifyDefaultPrivacyChange( |
|
486 RMobilePhone& aMobilePhone, |
|
487 TEtelRequestBase& aRequestStatus, |
|
488 RMobilePhone::TMobilePhonePrivacy& aSetting, |
|
489 RMobilePhone::TMobilePhonePrivacy aExpectedSetting, |
|
490 TInt aWantedStatus ) |
|
491 |
|
492 { |
|
493 // Wait for the request to complete |
|
494 TInt err = iTestStep.WaitForRequestWithTimeOut(aRequestStatus, ETimeShort); |
|
495 ASSERT_EQUALS(err, KErrNone, _L("RMobilePhone::NotifyDefaultPrivacyChange did not complete")) |
|
496 |
|
497 while ( err == KErrNone && aRequestStatus.Int() == KErrNone |
|
498 && aSetting != aExpectedSetting ) |
|
499 { |
|
500 // Request has completed with incorrect result. Consume any outstanding |
|
501 // Repost notification until timeout or we get the right result. |
|
502 |
|
503 aMobilePhone.NotifyDefaultPrivacyChange(aRequestStatus, aSetting); |
|
504 err = iTestStep.WaitForRequestWithTimeOut(aRequestStatus, ETimeShort); |
|
505 } |
|
506 |
|
507 ASSERT_EQUALS(aRequestStatus.Int(), aWantedStatus, _L("RMobilePhone::NotifyDefaultPrivacyChange Wrong completion status")) |
|
508 ASSERT_EQUALS(aSetting, aExpectedSetting, |
|
509 _L("RMobilePhone::NotifyDefaultPrivacyChange Wrong result")) |
|
510 |
|
511 // Cancel request if it is still pending |
|
512 if (aRequestStatus.Int() == KRequestPending) |
|
513 { |
|
514 aRequestStatus.Cancel(); |
|
515 } |
|
516 } |
|
517 |
|
518 void TPhoneTsyTestHelper::WaitForPhoneBookStoreCacheReadyL( |
|
519 RMmCustomAPI& aMmCustomAPI, |
|
520 TPhoneBookStoreId aPhoneBookId ) |
|
521 /** |
|
522 * helper function to check if the phone book store cache is ready, if not wait till ready |
|
523 * |
|
524 * @param aMmCustomAPI a reference to RMmCustomAPI session |
|
525 * @param aPhoneBookId a TPhoneBookStoreId type parameter holding the phonebook type adn,fdn etc |
|
526 * |
|
527 * @return void |
|
528 */ |
|
529 { |
|
530 if(aPhoneBookId != KIccAdnPhoneBook && aPhoneBookId != KIccFdnPhoneBook) |
|
531 { |
|
532 return; |
|
533 } |
|
534 TName phoneBookName; |
|
535 if(aPhoneBookId == KIccAdnPhoneBook) |
|
536 { |
|
537 phoneBookName = KETelIccAdnPhoneBook; |
|
538 } |
|
539 else if(aPhoneBookId == KIccFdnPhoneBook) |
|
540 { |
|
541 phoneBookName = KETelIccFdnPhoneBook; |
|
542 } |
|
543 |
|
544 // check if phonebook is cached already |
|
545 TExtEtelRequestStatus getPndCacheStatusStatus(aMmCustomAPI,ECustomGetPndCacheStatusIPC); |
|
546 RMmCustomAPI::TPndCacheStatus pndCacheStatus; |
|
547 aMmCustomAPI.GetPndCacheStatus(getPndCacheStatusStatus,pndCacheStatus,phoneBookName); |
|
548 TInt err = iTestStep.WaitForRequestWithTimeOut(getPndCacheStatusStatus, ETimeMedium); |
|
549 CHECK_EQUALS_L(err, KErrNone, _L("RMmCustomAPI::GetPndCacheStatus did not complete")) |
|
550 CHECK_EQUALS_L(getPndCacheStatusStatus.Int(), KErrNone, _L("RMmCustomAPI::GetPndCacheStatus wrong completion status")) |
|
551 if( pndCacheStatus == RMmCustomAPI::ECacheReady) |
|
552 { |
|
553 return; |
|
554 } |
|
555 |
|
556 //wait for notification |
|
557 TExtEtelRequestStatus notifyPndCacheReadyStatus(aMmCustomAPI,ECustomNotifyPndCacheReadyIPC); |
|
558 aMmCustomAPI.NotifyPndCacheReady(notifyPndCacheReadyStatus,phoneBookName); |
|
559 err = iTestStep.WaitForRequestWithTimeOut(notifyPndCacheReadyStatus, ETimeLong); |
|
560 CHECK_EQUALS_L(err, KErrNone, _L("RMmCustomAPI::NotifyPndCacheReady did not complete")) |
|
561 CHECK_EQUALS_L(notifyPndCacheReadyStatus.Int(), KErrNone, _L("RMmCustomAPI::NotifyPndCacheReady wrong completion status")) |
|
562 |
|
563 aMmCustomAPI.GetPndCacheStatus(getPndCacheStatusStatus,pndCacheStatus,phoneBookName); |
|
564 err = iTestStep.WaitForRequestWithTimeOut(getPndCacheStatusStatus, ETimeMedium); |
|
565 CHECK_EQUALS_L(err, KErrNone, _L("RMmCustomAPI::GetPndCacheStatus did not complete")) |
|
566 CHECK_EQUALS_L(getPndCacheStatusStatus.Int(), KErrNone, _L("RMmCustomAPI::GetPndCacheStatus wrong completion status")) |
|
567 CHECK_EQUALS_L(pndCacheStatus, RMmCustomAPI::ECacheReady,_L("RMmCustomAPI::GetPndCacheStatus returned incorrect status")) |
|
568 |
|
569 } |
|
570 |
|
571 void TPhoneTsyTestHelper::BlockPinL(RMobilePhone& aMobilePhone,RMobilePhone::TMobilePhoneSecurityCode aPhoneSecurityCode) |
|
572 /** |
|
573 * member function for blocking pin1/pin2 returing void |
|
574 * |
|
575 * @param aMobilePhone a reference to RMobilePhone object |
|
576 * @param aPhoneSecurityCode holds the pin type to be bolcked |
|
577 * |
|
578 * @return void |
|
579 */ |
|
580 { |
|
581 RMobilePhone::TMobilePhoneSecurityCodeInfoV5 getSecurityCodeInfo; |
|
582 do |
|
583 { |
|
584 TExtEtelRequestStatus getSecurityCodeInfoStatus(aMobilePhone, EMobilePhoneGetSecurityCodeInfo); |
|
585 CleanupStack::PushL( getSecurityCodeInfoStatus ); |
|
586 RMobilePhone::TMobilePhoneSecurityCodeInfoV5Pckg getSecurityCodeInfoPckg( getSecurityCodeInfo ); |
|
587 aMobilePhone.GetSecurityCodeInfo(getSecurityCodeInfoStatus, aPhoneSecurityCode, getSecurityCodeInfoPckg); |
|
588 ASSERT_EQUALS(iTestStep.WaitForRequestWithTimeOut(getSecurityCodeInfoStatus, ETimeMedium), KErrNone, _L("RMobilePhone::GetSecurityCodeInfo timed out")); |
|
589 ASSERT_EQUALS(getSecurityCodeInfoStatus.Int(), KErrNone, _L("RMobilePhone::GetSecurityCodeInfo returned an error")); |
|
590 |
|
591 TExtEtelRequestStatus verifySecurityCodeStatus(aMobilePhone, EMobilePhoneVerifySecurityCode); |
|
592 CleanupStack::PushL( verifySecurityCodeStatus ); |
|
593 TPtrC wrongPin = _L("abcdef"); |
|
594 RMobilePhone::TMobilePassword dummyUnblockCode; |
|
595 aMobilePhone.VerifySecurityCode( verifySecurityCodeStatus, aPhoneSecurityCode, |
|
596 wrongPin, dummyUnblockCode ); |
|
597 ASSERT_EQUALS(iTestStep.WaitForRequestWithTimeOut(verifySecurityCodeStatus, ETimeLong), |
|
598 KErrNone, _L("RMobilePhone::VerifySecurityCode timed-out")); |
|
599 ASSERT_TRUE( verifySecurityCodeStatus.Int() != KErrNone, _L("RMobilePhone::VerifySecurityCode returned KErrNone")); |
|
600 |
|
601 CleanupStack::PopAndDestroy(2,&getSecurityCodeInfoStatus); |
|
602 |
|
603 } while (getSecurityCodeInfo.iRemainingEntryAttempts != 0); |
|
604 |
|
605 } |
|
606 |
|
607 |
|
608 |
|
609 void TPhoneTsyTestHelper::ChangePhoneLockSettingL(RMobilePhone& aMobilePhone, |
|
610 RMobilePhone::TMobilePhoneLock aLock,RMobilePhone::TMobilePhoneLockSetting aLockSetting, |
|
611 TDesC& aPasswd, TInt aErrorCode) |
|
612 /** |
|
613 * member function for changing the lock setting returing void |
|
614 * |
|
615 * @param aMobilePhone a reference to RMobilePhone object |
|
616 * @param aLock holding the lock information for which the setting needs to be changed |
|
617 * @param aLockSetting holding the state to be set for the lock |
|
618 * @param aPasswd holding the password to be provided while changing lock setting |
|
619 * @param aErrorCode the error code that we expect to recieve |
|
620 |
|
621 * @return void |
|
622 */ |
|
623 { |
|
624 |
|
625 //post notification |
|
626 TExtEtelRequestStatus notifySecurityEventStatus(aMobilePhone, EMobilePhoneNotifySecurityEvent); |
|
627 CleanupStack::PushL( notifySecurityEventStatus ); |
|
628 RMobilePhone::TMobilePhoneSecurityEvent securityEvent; |
|
629 aMobilePhone.NotifySecurityEvent(notifySecurityEventStatus, securityEvent); |
|
630 |
|
631 TExtEtelRequestStatus setLockSettingStatus(aMobilePhone, EMobilePhoneSetLockSetting); |
|
632 CleanupStack::PushL(setLockSettingStatus); |
|
633 aMobilePhone.SetLockSetting(setLockSettingStatus, aLock, aLockSetting); |
|
634 |
|
635 RMobilePhone::TMobilePhoneSecurityCode secCode = RMobilePhone::ESecurityCodePin1; |
|
636 RMobilePhone::TMobilePhoneSecurityEvent pinRequired = RMobilePhone::EPin1Required; |
|
637 RMobilePhone::TMobilePhoneSecurityEvent pinVerified = RMobilePhone::EPin1Verified; |
|
638 |
|
639 if(aLock == RMobilePhone::ELockICC) |
|
640 { |
|
641 secCode = RMobilePhone::ESecurityCodePin1; |
|
642 pinRequired = RMobilePhone::EPin1Required; |
|
643 pinVerified = RMobilePhone::EPin1Verified; |
|
644 } |
|
645 else if(aLock == RMobilePhone::ELockPin2) |
|
646 { |
|
647 secCode = RMobilePhone::ESecurityCodePin2; |
|
648 pinRequired = RMobilePhone::EPin2Required; |
|
649 pinVerified = RMobilePhone::EPin2Verified; |
|
650 } |
|
651 else if(aLock == RMobilePhone::ELockPhoneDevice) |
|
652 { |
|
653 secCode = RMobilePhone::ESecurityCodePhonePassword; |
|
654 pinRequired = RMobilePhone::EPhonePasswordRequired; |
|
655 pinVerified = RMobilePhone::EPhonePasswordVerified; |
|
656 } |
|
657 else |
|
658 { |
|
659 ASSERT_EQUALS(1,0,_L("RMobilePhone::TMobilePhoneLock of this type not supported")); |
|
660 } |
|
661 |
|
662 TExtEtelRequestStatus verifySecurityCodeStatus(aMobilePhone, EMobilePhoneVerifySecurityCode); |
|
663 CleanupStack::PushL( verifySecurityCodeStatus ); |
|
664 WaitForMobilePhoneNotifySecurityEvent(aMobilePhone,notifySecurityEventStatus, |
|
665 securityEvent, |
|
666 pinRequired, |
|
667 KErrNone); |
|
668 |
|
669 RMobilePhone::TMobilePassword dummyUnblockCode; |
|
670 |
|
671 if( pinRequired == securityEvent ) |
|
672 { |
|
673 |
|
674 aMobilePhone.NotifySecurityEvent(notifySecurityEventStatus, securityEvent); |
|
675 aMobilePhone.VerifySecurityCode( verifySecurityCodeStatus, secCode, |
|
676 aPasswd, dummyUnblockCode ); |
|
677 if(aErrorCode == KErrNone) |
|
678 { |
|
679 ASSERT_EQUALS(iTestStep.WaitForRequestWithTimeOut(verifySecurityCodeStatus, ETimeLong), |
|
680 KErrNone, _L("RMobilePhone::VerifySecurityCode timed-out")); |
|
681 ASSERT_EQUALS( verifySecurityCodeStatus.Int(), KErrNone, _L("RMobilePhone::VerifySecurityCode returned with an error")); |
|
682 WaitForMobilePhoneNotifySecurityEvent(aMobilePhone,notifySecurityEventStatus, |
|
683 securityEvent, |
|
684 pinVerified, |
|
685 KErrNone); |
|
686 } |
|
687 } |
|
688 ASSERT_EQUALS(iTestStep.WaitForRequestWithTimeOut(setLockSettingStatus, ETimeLong), KErrNone, _L("RMobilePhone::SetLockSetting timed out")); |
|
689 ASSERT_EQUALS(setLockSettingStatus.Int(), aErrorCode, _L("RMobilePhone::SetLockSetting did not returned as expected")); |
|
690 |
|
691 |
|
692 // notifySecurityEventStatus |
|
693 // setLockSettingStatus |
|
694 // verifySecurityCodeStatus |
|
695 CleanupStack::PopAndDestroy(3,¬ifySecurityEventStatus); |
|
696 |
|
697 } |
|
698 |
|
699 /** |
|
700 * Set FDN setting on or off (i.e. enable or disable FDN for the phone) |
|
701 * @param aPhone RMobilePhone session |
|
702 * @param aPIN2Password PIN2 password |
|
703 * @param aFdnSetting Either EFdnSetOn or EFdnSetOff |
|
704 * @return KErrNone or an error code from RMobilePhone::SetFdnSetting |
|
705 */ |
|
706 TInt TPhoneTsyTestHelper::SetPhoneFdnSettingL( RMobilePhone &aPhone, |
|
707 RMobilePhone::TMobilePassword& aPIN2Password, |
|
708 RMobilePhone::TMobilePhoneFdnSetting aFdnSetting ) |
|
709 { |
|
710 // Set up the security notification |
|
711 TExtEtelRequestStatus reqNotifySecEvent(aPhone, EMobilePhoneNotifySecurityEvent); |
|
712 CleanupStack::PushL(reqNotifySecEvent); |
|
713 RMobilePhone::TMobilePhoneSecurityEvent securityEvent; |
|
714 |
|
715 aPhone.NotifySecurityEvent(reqNotifySecEvent, securityEvent); |
|
716 |
|
717 // Call RMobilePhone::SetFdnSetting with RMobilePhone::EFdnSetOn |
|
718 TExtEtelRequestStatus reqSetFdnStatus( aPhone, EMobilePhoneSetFdnSetting); |
|
719 CleanupStack::PushL(reqSetFdnStatus); |
|
720 |
|
721 aPhone.SetFdnSetting(reqSetFdnStatus, aFdnSetting); |
|
722 |
|
723 // We don't test for this request completing here, as we expect it to remain pending while the PIN2 |
|
724 // verify completes |
|
725 |
|
726 // === Check security events complete and verify PIN2 === |
|
727 // Check RMobilePhone::NotifySecurityEvent completes with RMobilePhone::EPin2Required |
|
728 WaitForMobilePhoneNotifySecurityEvent(aPhone,reqNotifySecEvent, |
|
729 securityEvent, |
|
730 RMobilePhone::EPin2Required, |
|
731 KErrNone); |
|
732 // Just for the log |
|
733 ASSERT_EQUALS(securityEvent,RMobilePhone::EPin2Required, |
|
734 _L("RMobilePhone::NotifySecurityEvent returned an unexpected result") ); |
|
735 |
|
736 // re-launch notification |
|
737 aPhone.NotifySecurityEvent(reqNotifySecEvent, securityEvent); |
|
738 |
|
739 // Verify PIN2 security code with RMobilePhone::VerifySecurityCode with RMobilePhone::ESecurityCodePin2 |
|
740 TExtEtelRequestStatus reqVerifySecCode(aPhone, EMobilePhoneVerifySecurityCode); |
|
741 CleanupStack::PushL(reqVerifySecCode); |
|
742 RMobilePhone::TMobilePassword dummyUnblockCode; |
|
743 DEBUG_PRINTF3(_L("REREREEEE %d %S"),__LINE__,&aPIN2Password); |
|
744 aPhone.VerifySecurityCode(reqVerifySecCode, RMobilePhone::ESecurityCodePin2, |
|
745 aPIN2Password, dummyUnblockCode); |
|
746 |
|
747 TInt err = iTestStep.WaitForRequestWithTimeOut(reqVerifySecCode,ETimeMedium); |
|
748 DEBUG_PRINTF2(_L("REREREEEE %d"),__LINE__); |
|
749 ASSERT_EQUALS(err, KErrNone, _L("RMobilePhone::VerifySecurityCode timed out")); |
|
750 ASSERT_EQUALS(reqVerifySecCode.Int(), KErrNone, _L("RMobilePhone::VerifySecurityCode returned an error")); |
|
751 |
|
752 // Check RMobilePhone::NotifySecurityEvent completes with RMobilePhone::EPin2Verified |
|
753 WaitForMobilePhoneNotifySecurityEvent(aPhone,reqNotifySecEvent, |
|
754 securityEvent, |
|
755 RMobilePhone::EPin2Verified, |
|
756 KErrNone); |
|
757 |
|
758 // Just for the log |
|
759 ASSERT_EQUALS(securityEvent,RMobilePhone::EPin2Verified, |
|
760 _L("RMobilePhone::NotifySecurityEvent returned an unexpected result") ); |
|
761 |
|
762 // Now wait for the FDN setting to complete |
|
763 err = iTestStep.WaitForRequestWithTimeOut(reqSetFdnStatus,ETimeMedium); |
|
764 ASSERT_EQUALS(err, KErrNone, _L("RMobilePhone::SetFdnSetting timed out")); |
|
765 |
|
766 TInt result = reqSetFdnStatus.Int(); |
|
767 |
|
768 // reqVerifySecCode |
|
769 // reqSetFdnStatus |
|
770 // reqNotifySecEvent |
|
771 CleanupStack::PopAndDestroy(3,&reqNotifySecEvent); |
|
772 |
|
773 return result; |
|
774 |
|
775 } |
|
776 |
|
777 |
|
778 |
|
779 TFdnCleanupDisable::TFdnCleanupDisable(TPhoneTsyTestHelper &aBase, |
|
780 RMobilePhone &aPhone, |
|
781 RMobilePhone::TMobilePassword& aPIN2Password):iBase(aBase),iPhone(aPhone),iPIN2Password(aPIN2Password) |
|
782 /* |
|
783 * Constructor |
|
784 * @param aBase reference to the helper. |
|
785 * @param aPhone reference to a phone session |
|
786 * @param aPIN2Password a reference to the pin2 password |
|
787 * |
|
788 */ |
|
789 { |
|
790 } |
|
791 |
|
792 void TFdnCleanupDisable::DoCleanupL(TAny* aPtr) |
|
793 /* |
|
794 * This function is a static clean up function to be saved in the cleanup stack. Its disable the FDN |
|
795 * |
|
796 * @param aPtr a pointer to a TBackupFdnDisable instance. |
|
797 * |
|
798 */ |
|
799 { |
|
800 TFdnCleanupDisable* me = static_cast<TFdnCleanupDisable*>(aPtr); |
|
801 me->CleanupL(); |
|
802 } |
|
803 |
|
804 TFdnCleanupDisable::operator TCleanupItem() |
|
805 /* |
|
806 * This operator create a TCleanupItem to save a pointer to the DoCleanup static function and this in the cleanup stack |
|
807 * |
|
808 */ |
|
809 { |
|
810 return TCleanupItem(DoCleanupL,this); |
|
811 } |
|
812 |
|
813 |
|
814 void TFdnCleanupDisable::CleanupL() |
|
815 /* |
|
816 * This function disable the FDN |
|
817 * |
|
818 */ |
|
819 { |
|
820 iBase.SetPhoneFdnSettingL(iPhone,iPIN2Password,RMobilePhone::EFdnSetOff); |
|
821 } |