|
1 /* |
|
2 * Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies). |
|
3 * All rights reserved. |
|
4 * This component and the accompanying materials are made available |
|
5 * under the terms of "Eclipse Public License v1.0" |
|
6 * which accompanies this distribution, and is available |
|
7 * at the URL "http://www.eclipse.org/legal/epl-v10.html". |
|
8 * |
|
9 * Initial Contributors: |
|
10 * Nokia Corporation - initial contribution. |
|
11 * |
|
12 * Contributors: |
|
13 * |
|
14 * Description: |
|
15 * |
|
16 */ |
|
17 |
|
18 #include <PsetContainer.h> |
|
19 #include <mpsetbarringobs.h> |
|
20 #include <psetwrappertypes.h> |
|
21 #include <nwdefs.h> |
|
22 #include "ut_psetcallbarringwrapper.h" |
|
23 #include "testutilities.h" |
|
24 #define private public |
|
25 #include <psetcallbarringwrapper.h> |
|
26 #include "psetcallbarringwrapper_p.h" |
|
27 |
|
28 const int KInvalidEnumeration = -1; |
|
29 |
|
30 class BarringObserver : public MPsetBarringObserver |
|
31 { |
|
32 void HandleBarringModeChangedL( |
|
33 TBarringProgram aType, |
|
34 TBarringStatus aStatus, |
|
35 TBool aPlural ) |
|
36 { |
|
37 Q_UNUSED(aType); |
|
38 Q_UNUSED(aStatus); |
|
39 Q_UNUSED(aPlural); |
|
40 } |
|
41 |
|
42 void HandleBarringModeStatusL( |
|
43 TUint8 aBsc[KPSetNumberOfBsc], |
|
44 TBarringStatus aStatus ) |
|
45 { |
|
46 Q_UNUSED(aBsc); |
|
47 Q_UNUSED(aStatus); |
|
48 } |
|
49 |
|
50 void HandleBarringErrorL( |
|
51 TInt aReason ) |
|
52 { |
|
53 Q_UNUSED(aReason); |
|
54 } |
|
55 |
|
56 void HandleCBRequestingL( |
|
57 TBool aTrue, |
|
58 TBool aInterrupted ) |
|
59 { |
|
60 Q_UNUSED(aTrue); |
|
61 Q_UNUSED(aInterrupted); |
|
62 } |
|
63 |
|
64 void SetEngineContact( |
|
65 MPsetCallBarring* aBarringEngine ) |
|
66 { |
|
67 Q_UNUSED(aBarringEngine); |
|
68 } |
|
69 |
|
70 void CbPasswordChangedL( |
|
71 TBool aSuccess ) |
|
72 { |
|
73 Q_UNUSED(aSuccess); |
|
74 } |
|
75 }; |
|
76 |
|
77 void simulateLeaveL() |
|
78 { |
|
79 User::Leave(KErrGeneral); |
|
80 } |
|
81 |
|
82 /*! |
|
83 UT_PSetCallBarringWrapper::UT_PSetCallBarringWrapper |
|
84 */ |
|
85 UT_PSetCallBarringWrapper::UT_PSetCallBarringWrapper() |
|
86 : |
|
87 m_psetContainerMock(NULL), |
|
88 m_wrapper(NULL) |
|
89 { |
|
90 } |
|
91 |
|
92 |
|
93 /*! |
|
94 UT_PSetCallBarringWrapper::~UT_PSetCallBarringWrapper |
|
95 */ |
|
96 UT_PSetCallBarringWrapper::~UT_PSetCallBarringWrapper() |
|
97 { |
|
98 delete m_psetContainerMock; |
|
99 delete m_wrapper; |
|
100 } |
|
101 |
|
102 |
|
103 /*! |
|
104 UT_PSetCallBarringWrapper::init |
|
105 */ |
|
106 void UT_PSetCallBarringWrapper::init() |
|
107 { |
|
108 initialize(); |
|
109 |
|
110 m_psetContainerMock = new CPsetContainer(); |
|
111 |
|
112 BarringObserver dummyObserver; |
|
113 RMobilePhone dummyPhone; |
|
114 |
|
115 CPsetCallBarring *barringMock = NULL; |
|
116 TRAPD(result, barringMock = CPsetCallBarring::NewL(dummyObserver, dummyPhone)); |
|
117 QScopedPointer<CPsetCallBarring> barringMockGuard(barringMock); |
|
118 EXPECT(CPsetContainer, CreateCBObjectL) |
|
119 .returns(barringMock); |
|
120 m_wrapper = new PSetCallBarringWrapper(*m_psetContainerMock, NULL); |
|
121 barringMockGuard.take(); |
|
122 |
|
123 QVERIFY(verify()); |
|
124 } |
|
125 |
|
126 |
|
127 /*! |
|
128 UT_PSetCallBarringWrapper::cleanup |
|
129 */ |
|
130 void UT_PSetCallBarringWrapper::cleanup() |
|
131 { |
|
132 reset(); |
|
133 |
|
134 delete m_psetContainerMock; |
|
135 m_psetContainerMock = NULL; |
|
136 delete m_wrapper; |
|
137 m_wrapper = NULL; |
|
138 } |
|
139 |
|
140 |
|
141 /*! |
|
142 UT_PSetCallBarringWrapper::t_construction |
|
143 */ |
|
144 void UT_PSetCallBarringWrapper::t_construction() |
|
145 { |
|
146 EXPECT(CPsetContainer, CreateCBObjectL). |
|
147 willOnce(invokeWithoutArguments(this, simulateLeaveAtMockMethodCall)); |
|
148 PSetCallBarringWrapper *wrapper = NULL; |
|
149 EXPECT_EXCEPTION( |
|
150 wrapper = new PSetCallBarringWrapper(*m_psetContainerMock, NULL);); |
|
151 } |
|
152 |
|
153 |
|
154 /*! |
|
155 UT_PSetCallBarringWrapper::t_barringStatus |
|
156 */ |
|
157 void UT_PSetCallBarringWrapper::t_barringStatus() |
|
158 { |
|
159 // test status query with different service groups |
|
160 EXPECT(CPsetCallBarring, GetBarringStatusL) |
|
161 .with(EServiceGroupVoice, EBarringTypeAllBarrings); |
|
162 EXPECT(CPsetCallBarring, GetBarringStatusL) |
|
163 .with(EServiceGroupData, EBarringTypeAllBarrings); |
|
164 EXPECT(CPsetCallBarring, GetBarringStatusL) |
|
165 .with(EServiceGroupFax, EBarringTypeAllBarrings); |
|
166 EXPECT(CPsetCallBarring, GetBarringStatusL) |
|
167 .with(EServiceGroupAllTeleservices, EBarringTypeAllBarrings); |
|
168 // invalid/unknown enumeration as service group identifier |
|
169 EXPECT(CPsetCallBarring, GetBarringStatusL) |
|
170 .with(EServiceGroupVoice, EBarringTypeAllBarrings); |
|
171 |
|
172 //TODO: remove SeviceGroupUnknown enumeration? |
|
173 //m_wrapper->barringStatus(ServiceGroupUnknown); |
|
174 m_wrapper->barringStatus(ServiceGroupVoice, |
|
175 PSetCallBarringWrapper::BarringTypeAllBarrings); |
|
176 m_wrapper->barringStatus(ServiceGroupData, |
|
177 PSetCallBarringWrapper::BarringTypeAllBarrings); |
|
178 m_wrapper->barringStatus(ServiceGroupFax, |
|
179 PSetCallBarringWrapper::BarringTypeAllBarrings); |
|
180 m_wrapper->barringStatus(ServiceGroupAllTeleservices, |
|
181 PSetCallBarringWrapper::BarringTypeAllBarrings); |
|
182 // invalid/unknown enumeration as service group identifier |
|
183 m_wrapper->barringStatus( |
|
184 static_cast<PsService>(KInvalidEnumeration), |
|
185 PSetCallBarringWrapper::BarringTypeAllBarrings); |
|
186 |
|
187 // test status query with different barring types |
|
188 EXPECT(CPsetCallBarring, GetBarringStatusL) |
|
189 .with(EServiceGroupVoice, EBarringTypeAllOutgoing); |
|
190 EXPECT(CPsetCallBarring, GetBarringStatusL) |
|
191 .with(EServiceGroupVoice, EBarringTypeOutgoingInternational); |
|
192 EXPECT(CPsetCallBarring, GetBarringStatusL) |
|
193 .with(EServiceGroupVoice, |
|
194 EBarringTypeOutgoingInternationalExceptToHomeCountry); |
|
195 EXPECT(CPsetCallBarring, GetBarringStatusL) |
|
196 .with(EServiceGroupVoice, EBarringTypeAllIncoming); |
|
197 EXPECT(CPsetCallBarring, GetBarringStatusL) |
|
198 .with(EServiceGroupVoice, EBarringTypeIncomingWhenRoaming); |
|
199 EXPECT(CPsetCallBarring, GetBarringStatusL) |
|
200 .with(EServiceGroupVoice, EBarringTypeAllServices); |
|
201 EXPECT(CPsetCallBarring, GetBarringStatusL) |
|
202 .with(EServiceGroupVoice, EBarringTypeAllOutgoingServices); |
|
203 EXPECT(CPsetCallBarring, GetBarringStatusL) |
|
204 .with(EServiceGroupVoice, EBarringTypeAllIncomingServices); |
|
205 // invalid/unknown enumeration as barring type |
|
206 EXPECT(CPsetCallBarring, GetBarringStatusL) |
|
207 .with(EServiceGroupVoice, EBarringTypeAllBarrings); |
|
208 m_wrapper->barringStatus(ServiceGroupVoice, |
|
209 PSetCallBarringWrapper::BarringTypeAllOutgoing); |
|
210 m_wrapper->barringStatus(ServiceGroupVoice, |
|
211 PSetCallBarringWrapper::BarringTypeOutgoingInternational); |
|
212 m_wrapper->barringStatus(ServiceGroupVoice, |
|
213 PSetCallBarringWrapper:: |
|
214 BarringTypeOutgoingInternationalExceptToHomeCountry); |
|
215 m_wrapper->barringStatus(ServiceGroupVoice, |
|
216 PSetCallBarringWrapper::BarringTypeAllIncoming); |
|
217 m_wrapper->barringStatus(ServiceGroupVoice, |
|
218 PSetCallBarringWrapper::BarringTypeIncomingWhenRoaming); |
|
219 m_wrapper->barringStatus(ServiceGroupVoice, |
|
220 PSetCallBarringWrapper::BarringTypeAllServices); |
|
221 m_wrapper->barringStatus(ServiceGroupVoice, |
|
222 PSetCallBarringWrapper::BarringTypeAllOutgoingServices); |
|
223 m_wrapper->barringStatus(ServiceGroupVoice, |
|
224 PSetCallBarringWrapper::BarringTypeAllIncomingServices); |
|
225 // invalid/unknown enumeration as barring type |
|
226 m_wrapper->barringStatus(ServiceGroupVoice, |
|
227 static_cast<PSetCallBarringWrapper::BarringType>(KInvalidEnumeration)); |
|
228 |
|
229 QVERIFY(verify()); |
|
230 } |
|
231 |
|
232 |
|
233 /*! |
|
234 UT_PSetCallBarringWrapper::t_barringStatusExceptionOccurs |
|
235 */ |
|
236 void UT_PSetCallBarringWrapper::t_barringStatusExceptionOccurs() |
|
237 { |
|
238 EXPECT(CPsetCallBarring, GetBarringStatusL) |
|
239 .willOnce(invokeWithoutArguments(this, simulateLeaveAtMockMethodCall)); |
|
240 |
|
241 EXPECT_EXCEPTION( |
|
242 m_wrapper->barringStatus( |
|
243 ServiceGroupVoice, |
|
244 PSetCallBarringWrapper::BarringTypeAllBarrings); |
|
245 ) |
|
246 |
|
247 QVERIFY(verify()); |
|
248 } |
|
249 |
|
250 |
|
251 /*! |
|
252 UT_PSetCallBarringWrapper::t_enableBarring |
|
253 */ |
|
254 void UT_PSetCallBarringWrapper::t_enableBarring() |
|
255 { |
|
256 _LIT(KPassword, "1234"); |
|
257 TCallBarringSetting setting; |
|
258 setting.iType = EBarringTypeAllBarrings; |
|
259 setting.iSetting = EActivateBarring; |
|
260 setting.iServiceGroup = EServiceGroupVoice; |
|
261 setting.iPassword.Copy(KPassword()); |
|
262 EXPECT(CPsetCallBarring, SetBarringL) |
|
263 .with(setting, EAllTeleAndBearer); |
|
264 m_wrapper->enableBarring( |
|
265 ServiceGroupVoice, |
|
266 PSetCallBarringWrapper::BarringTypeAllBarrings, |
|
267 QString("1234")); |
|
268 |
|
269 setting.iType = EBarringTypeAllOutgoing; |
|
270 EXPECT(CPsetCallBarring, SetBarringL) |
|
271 .with(setting, EAllTeleAndBearer); |
|
272 m_wrapper->enableBarring( |
|
273 ServiceGroupVoice, |
|
274 PSetCallBarringWrapper::BarringTypeAllOutgoing, |
|
275 QString("1234")); |
|
276 |
|
277 setting.iType = EBarringTypeOutgoingInternational; |
|
278 EXPECT(CPsetCallBarring, SetBarringL) |
|
279 .with(setting, EAllTeleAndBearer); |
|
280 m_wrapper->enableBarring( |
|
281 ServiceGroupVoice, |
|
282 PSetCallBarringWrapper::BarringTypeOutgoingInternational, |
|
283 QString("1234")); |
|
284 |
|
285 setting.iType = EBarringTypeOutgoingInternationalExceptToHomeCountry; |
|
286 EXPECT(CPsetCallBarring, SetBarringL) |
|
287 .with(setting, EAllTeleAndBearer); |
|
288 m_wrapper->enableBarring( |
|
289 ServiceGroupVoice, |
|
290 PSetCallBarringWrapper::BarringTypeOutgoingInternationalExceptToHomeCountry, |
|
291 QString("1234")); |
|
292 |
|
293 setting.iType = EBarringTypeAllIncoming; |
|
294 EXPECT(CPsetCallBarring, SetBarringL) |
|
295 .with(setting, EAllTeleAndBearer); |
|
296 m_wrapper->enableBarring( |
|
297 ServiceGroupVoice, |
|
298 PSetCallBarringWrapper::BarringTypeAllIncoming, |
|
299 QString("1234")); |
|
300 |
|
301 setting.iType = EBarringTypeIncomingWhenRoaming; |
|
302 EXPECT(CPsetCallBarring, SetBarringL) |
|
303 .with(setting, EAllTeleAndBearer); |
|
304 m_wrapper->enableBarring( |
|
305 ServiceGroupVoice, |
|
306 PSetCallBarringWrapper::BarringTypeIncomingWhenRoaming, |
|
307 QString("1234")); |
|
308 |
|
309 setting.iType = EBarringTypeAllServices; |
|
310 EXPECT(CPsetCallBarring, SetBarringL) |
|
311 .with(setting, EAllTeleAndBearer); |
|
312 m_wrapper->enableBarring( |
|
313 ServiceGroupVoice, |
|
314 PSetCallBarringWrapper::BarringTypeAllServices, |
|
315 QString("1234")); |
|
316 |
|
317 setting.iType = EBarringTypeAllOutgoingServices; |
|
318 EXPECT(CPsetCallBarring, SetBarringL) |
|
319 .with(setting, EAllTeleAndBearer); |
|
320 m_wrapper->enableBarring( |
|
321 ServiceGroupVoice, |
|
322 PSetCallBarringWrapper::BarringTypeAllOutgoingServices, |
|
323 QString("1234")); |
|
324 |
|
325 setting.iType = EBarringTypeAllIncomingServices; |
|
326 EXPECT(CPsetCallBarring, SetBarringL) |
|
327 .with(setting, EAllTeleAndBearer); |
|
328 m_wrapper->enableBarring( |
|
329 ServiceGroupVoice, |
|
330 PSetCallBarringWrapper::BarringTypeAllIncomingServices, |
|
331 QString("1234")); |
|
332 |
|
333 // error handling |
|
334 EXPECT(CPsetCallBarring, SetBarringL) |
|
335 .willOnce(invokeWithoutArguments(simulateLeaveL)); |
|
336 EXPECT_EXCEPTION( |
|
337 m_wrapper->enableBarring( |
|
338 ServiceGroupVoice, |
|
339 PSetCallBarringWrapper::BarringTypeAllIncomingServices, |
|
340 QString("1234")); |
|
341 ) |
|
342 |
|
343 QVERIFY(verify()); |
|
344 } |
|
345 |
|
346 |
|
347 /*! |
|
348 UT_PSetCallBarringWrapper::t_disableBarring |
|
349 */ |
|
350 void UT_PSetCallBarringWrapper::t_disableBarring() |
|
351 { |
|
352 _LIT(KPassword, "1234"); |
|
353 TCallBarringSetting setting; |
|
354 setting.iType = EBarringTypeAllBarrings; |
|
355 setting.iSetting = ECancelBarring; |
|
356 setting.iServiceGroup = EServiceGroupVoice; |
|
357 setting.iPassword.Copy(KPassword()); |
|
358 EXPECT(CPsetCallBarring, SetBarringL) |
|
359 .with(setting, EAllTeleAndBearer); |
|
360 m_wrapper->disableBarring( |
|
361 ServiceGroupVoice, |
|
362 PSetCallBarringWrapper::BarringTypeAllBarrings, |
|
363 QString("1234")); |
|
364 |
|
365 setting.iType = EBarringTypeAllOutgoing; |
|
366 EXPECT(CPsetCallBarring, SetBarringL) |
|
367 .with(setting, EAllTeleAndBearer); |
|
368 m_wrapper->disableBarring( |
|
369 ServiceGroupVoice, |
|
370 PSetCallBarringWrapper::BarringTypeAllOutgoing, |
|
371 QString("1234")); |
|
372 |
|
373 setting.iType = EBarringTypeOutgoingInternational; |
|
374 EXPECT(CPsetCallBarring, SetBarringL) |
|
375 .with(setting, EAllTeleAndBearer); |
|
376 m_wrapper->disableBarring( |
|
377 ServiceGroupVoice, |
|
378 PSetCallBarringWrapper::BarringTypeOutgoingInternational, |
|
379 QString("1234")); |
|
380 |
|
381 setting.iType = EBarringTypeOutgoingInternationalExceptToHomeCountry; |
|
382 EXPECT(CPsetCallBarring, SetBarringL) |
|
383 .with(setting, EAllTeleAndBearer); |
|
384 m_wrapper->disableBarring( |
|
385 ServiceGroupVoice, |
|
386 PSetCallBarringWrapper::BarringTypeOutgoingInternationalExceptToHomeCountry, |
|
387 QString("1234")); |
|
388 |
|
389 setting.iType = EBarringTypeAllIncoming; |
|
390 EXPECT(CPsetCallBarring, SetBarringL) |
|
391 .with(setting, EAllTeleAndBearer); |
|
392 m_wrapper->disableBarring( |
|
393 ServiceGroupVoice, |
|
394 PSetCallBarringWrapper::BarringTypeAllIncoming, |
|
395 QString("1234")); |
|
396 |
|
397 setting.iType = EBarringTypeIncomingWhenRoaming; |
|
398 EXPECT(CPsetCallBarring, SetBarringL) |
|
399 .with(setting, EAllTeleAndBearer); |
|
400 m_wrapper->disableBarring( |
|
401 ServiceGroupVoice, |
|
402 PSetCallBarringWrapper::BarringTypeIncomingWhenRoaming, |
|
403 QString("1234")); |
|
404 |
|
405 setting.iType = EBarringTypeAllServices; |
|
406 EXPECT(CPsetCallBarring, SetBarringL) |
|
407 .with(setting, EAllTeleAndBearer); |
|
408 m_wrapper->disableBarring( |
|
409 ServiceGroupVoice, |
|
410 PSetCallBarringWrapper::BarringTypeAllServices, |
|
411 QString("1234")); |
|
412 |
|
413 setting.iType = EBarringTypeAllOutgoingServices; |
|
414 EXPECT(CPsetCallBarring, SetBarringL) |
|
415 .with(setting, EAllTeleAndBearer); |
|
416 m_wrapper->disableBarring( |
|
417 ServiceGroupVoice, |
|
418 PSetCallBarringWrapper::BarringTypeAllOutgoingServices, |
|
419 QString("1234")); |
|
420 |
|
421 setting.iType = EBarringTypeAllIncomingServices; |
|
422 EXPECT(CPsetCallBarring, SetBarringL) |
|
423 .with(setting, EAllTeleAndBearer); |
|
424 m_wrapper->disableBarring( |
|
425 ServiceGroupVoice, |
|
426 PSetCallBarringWrapper::BarringTypeAllIncomingServices, |
|
427 QString("1234")); |
|
428 |
|
429 // error handling |
|
430 EXPECT(CPsetCallBarring, SetBarringL) |
|
431 .willOnce(invokeWithoutArguments(simulateLeaveL)); |
|
432 EXPECT_EXCEPTION( |
|
433 m_wrapper->disableBarring( |
|
434 ServiceGroupVoice, |
|
435 PSetCallBarringWrapper::BarringTypeAllIncomingServices, |
|
436 QString("1234")); |
|
437 ) |
|
438 |
|
439 QVERIFY(verify()); |
|
440 } |
|
441 |
|
442 |
|
443 /*! |
|
444 UT_PSetCallBarringWrapper::t_changeBarringPassword |
|
445 */ |
|
446 void UT_PSetCallBarringWrapper::t_changeBarringPassword() |
|
447 { |
|
448 QString oldPassword = "1234"; |
|
449 QString newPassword = "4321"; |
|
450 QString verifiedPassword = "4321"; |
|
451 RMobilePhone::TMobilePhonePasswordChangeV2 passwordChange; |
|
452 passwordChange.iOldPassword.Copy(oldPassword.utf16()); |
|
453 passwordChange.iNewPassword.Copy(newPassword.utf16()); |
|
454 passwordChange.iVerifiedPassword.Copy(verifiedPassword.utf16()); |
|
455 EXPECT(CPsetCallBarring, ChangePasswordL) |
|
456 .with(passwordChange); |
|
457 |
|
458 m_wrapper->changeBarringPassword( |
|
459 oldPassword, newPassword, verifiedPassword); |
|
460 |
|
461 // error handling |
|
462 EXPECT(CPsetCallBarring, ChangePasswordL) |
|
463 .willOnce(invokeWithoutArguments(simulateLeaveL)); |
|
464 EXPECT_EXCEPTION( |
|
465 m_wrapper->changeBarringPassword( |
|
466 oldPassword, newPassword, verifiedPassword); |
|
467 ) |
|
468 |
|
469 QVERIFY(verify()); |
|
470 } |
|
471 |
|
472 |
|
473 /*! |
|
474 UT_PSetCallBarringWrapper::t_HandleBarringModeChangedL |
|
475 */ |
|
476 void UT_PSetCallBarringWrapper::t_HandleBarringModeChangedL() |
|
477 { |
|
478 TBool plural = EFalse; |
|
479 QT_TRAP_THROWING( |
|
480 m_wrapper->m_privateImpl->HandleBarringModeChangedL( |
|
481 EBarringTypeAllBarrings, EBarringStatusActive, plural); |
|
482 m_wrapper->m_privateImpl->HandleBarringModeChangedL( |
|
483 EBarringTypeAllOutgoing, EBarringStatusActive, plural); |
|
484 m_wrapper->m_privateImpl->HandleBarringModeChangedL( |
|
485 EBarringTypeOutgoingInternational, EBarringStatusActive, plural); |
|
486 m_wrapper->m_privateImpl->HandleBarringModeChangedL( |
|
487 EBarringTypeOutgoingInternationalExceptToHomeCountry, EBarringStatusActive, plural); |
|
488 m_wrapper->m_privateImpl->HandleBarringModeChangedL( |
|
489 EBarringTypeAllIncoming, EBarringStatusActive, plural); |
|
490 m_wrapper->m_privateImpl->HandleBarringModeChangedL( |
|
491 EBarringTypeIncomingWhenRoaming, EBarringStatusActive, plural); |
|
492 m_wrapper->m_privateImpl->HandleBarringModeChangedL( |
|
493 EBarringTypeAllServices, EBarringStatusActive, plural); |
|
494 m_wrapper->m_privateImpl->HandleBarringModeChangedL( |
|
495 EBarringTypeAllOutgoingServices, EBarringStatusActive, plural); |
|
496 m_wrapper->m_privateImpl->HandleBarringModeChangedL( |
|
497 EBarringTypeAllIncomingServices, EBarringStatusActive, plural); |
|
498 ) |
|
499 } |
|
500 |
|
501 |
|
502 /*! |
|
503 UT_PSetCallBarringWrapper::t_HandleBarringErrorL |
|
504 */ |
|
505 void UT_PSetCallBarringWrapper::t_HandleBarringErrorL() |
|
506 { |
|
507 // TODO: dummy test as functionality not yet implemented |
|
508 QT_TRAP_THROWING( |
|
509 m_wrapper->m_privateImpl->HandleBarringErrorL(KErrGeneral); |
|
510 ) |
|
511 } |
|
512 |
|
513 |
|
514 /*! |
|
515 UT_PSetCallBarringWrapper::t_HandleCBRequestingL |
|
516 */ |
|
517 void UT_PSetCallBarringWrapper::t_HandleCBRequestingL() |
|
518 { |
|
519 // TODO: dummy test as functionality not yet implemented |
|
520 QT_TRAP_THROWING( |
|
521 m_wrapper->m_privateImpl->HandleCBRequestingL(EFalse, EFalse); |
|
522 ) |
|
523 } |
|
524 |
|
525 |
|
526 /*! |
|
527 UT_PSetCallBarringWrapper::t_SetEngineContact |
|
528 */ |
|
529 void UT_PSetCallBarringWrapper::t_SetEngineContact() |
|
530 { |
|
531 // TODO: dummy test as functionality not yet implemented |
|
532 m_wrapper->m_privateImpl->SetEngineContact(NULL); |
|
533 } |
|
534 |
|
535 |
|
536 /*! |
|
537 UT_PSetCallBarringWrapper::t_CbPasswordChangedL |
|
538 */ |
|
539 void UT_PSetCallBarringWrapper::t_CbPasswordChangedL() |
|
540 { |
|
541 TBool success = EFalse; |
|
542 QT_TRAP_THROWING( |
|
543 m_wrapper->m_privateImpl->CbPasswordChangedL(ETrue); |
|
544 m_wrapper->m_privateImpl->CbPasswordChangedL(EFalse); |
|
545 ) |
|
546 } |
|
547 |
|
548 |
|
549 /*! |
|
550 UT_PSetCallBarringWrapper::t_HandleBarringModeStatusL |
|
551 */ |
|
552 Q_DECLARE_METATYPE(PSetCallBarringWrapper::BarringStatus) |
|
553 Q_DECLARE_METATYPE(QList<unsigned char>) |
|
554 void UT_PSetCallBarringWrapper::t_HandleBarringModeStatusL() |
|
555 { |
|
556 qRegisterMetaType<PSetCallBarringWrapper::BarringStatus> |
|
557 ("PSetCallBarringWrapper::BarringStatus"); |
|
558 qRegisterMetaType<QList<unsigned char> >("QList<unsigned char>"); |
|
559 QSignalSpy spy(m_wrapper, |
|
560 SIGNAL(barringStatusRequestCompleted( |
|
561 int, |
|
562 const QList<unsigned char> &, |
|
563 PSetCallBarringWrapper::BarringStatus))); |
|
564 |
|
565 TUint8 basicServiceGroupIds[KPSetNumberOfBsc]; |
|
566 basicServiceGroupIds[0] = EServiceGroupVoice; |
|
567 basicServiceGroupIds[1] = KPSetUnusedValue; |
|
568 // test with different barring statuses |
|
569 QT_TRAP_THROWING( |
|
570 m_wrapper->barringStatus(ServiceGroupVoice, |
|
571 PSetCallBarringWrapper::BarringTypeAllBarrings); |
|
572 m_wrapper->m_privateImpl->HandleBarringModeStatusL( |
|
573 basicServiceGroupIds, EBarringStatusActive); |
|
574 m_wrapper->m_privateImpl->RequestComplete(); |
|
575 |
|
576 m_wrapper->barringStatus(ServiceGroupVoice, |
|
577 PSetCallBarringWrapper::BarringTypeAllBarrings); |
|
578 m_wrapper->m_privateImpl->HandleBarringModeStatusL( |
|
579 basicServiceGroupIds, EBarringStatusInactive); |
|
580 m_wrapper->m_privateImpl->RequestComplete(); |
|
581 |
|
582 m_wrapper->barringStatus(ServiceGroupVoice, |
|
583 PSetCallBarringWrapper::BarringTypeAllBarrings); |
|
584 m_wrapper->m_privateImpl->HandleBarringModeStatusL( |
|
585 basicServiceGroupIds, EBarringStatusNotProvisioned); |
|
586 m_wrapper->m_privateImpl->RequestComplete(); |
|
587 |
|
588 m_wrapper->barringStatus(ServiceGroupVoice, |
|
589 PSetCallBarringWrapper::BarringTypeAllBarrings); |
|
590 m_wrapper->m_privateImpl->HandleBarringModeStatusL( |
|
591 basicServiceGroupIds, EBarringStatusUnavailable); |
|
592 m_wrapper->m_privateImpl->RequestComplete(); |
|
593 |
|
594 m_wrapper->barringStatus(ServiceGroupVoice, |
|
595 PSetCallBarringWrapper::BarringTypeAllBarrings); |
|
596 m_wrapper->m_privateImpl->HandleBarringModeStatusL( |
|
597 basicServiceGroupIds, EBarringStatusUnknown); |
|
598 m_wrapper->m_privateImpl->RequestComplete(); |
|
599 |
|
600 // invalid/unknown enumeration as barring status |
|
601 m_wrapper->barringStatus(ServiceGroupVoice, |
|
602 PSetCallBarringWrapper::BarringTypeAllBarrings); |
|
603 m_wrapper->m_privateImpl->HandleBarringModeStatusL( |
|
604 basicServiceGroupIds, |
|
605 static_cast<TBarringStatus>(KInvalidEnumeration)); |
|
606 m_wrapper->m_privateImpl->RequestComplete(); |
|
607 ) |
|
608 |
|
609 if (qstrcmp(QTest::currentTestFunction(), "t_exceptionSafety") == 0) { |
|
610 // Signal emissions from RequestComplete will fail with exception safety |
|
611 // tests so it's not possible to verify signal data. |
|
612 return; |
|
613 } |
|
614 |
|
615 QCOMPARE(spy.count(), 6); |
|
616 QList<unsigned char> resultBasicServiceGroupIds = |
|
617 qvariant_cast<QList<unsigned char> >(spy.at(0).at(1)); |
|
618 QVERIFY(ServiceGroupVoice == resultBasicServiceGroupIds[0]); |
|
619 QVERIFY(PSetCallBarringWrapper::BarringStatusActive == |
|
620 qvariant_cast<PSetCallBarringWrapper::BarringStatus>(spy.at(0).at(2))); |
|
621 |
|
622 resultBasicServiceGroupIds = |
|
623 qvariant_cast<QList<unsigned char> >(spy.at(1).at(1)); |
|
624 QVERIFY(ServiceGroupVoice == resultBasicServiceGroupIds[0]); |
|
625 QVERIFY(PSetCallBarringWrapper::BarringStatusInactive == |
|
626 qvariant_cast<PSetCallBarringWrapper::BarringStatus>(spy.at(1).at(2))); |
|
627 |
|
628 resultBasicServiceGroupIds = |
|
629 qvariant_cast<QList<unsigned char> >(spy.at(2).at(1)); |
|
630 QVERIFY(ServiceGroupVoice == resultBasicServiceGroupIds[0]); |
|
631 QVERIFY(PSetCallBarringWrapper::BarringStatusNotProvisioned == |
|
632 qvariant_cast<PSetCallBarringWrapper::BarringStatus>(spy.at(2).at(2))); |
|
633 |
|
634 resultBasicServiceGroupIds = |
|
635 qvariant_cast<QList<unsigned char> >(spy.at(3).at(1)); |
|
636 QVERIFY(ServiceGroupVoice == resultBasicServiceGroupIds[0]); |
|
637 QVERIFY(PSetCallBarringWrapper::BarringStatusUnavailable == |
|
638 qvariant_cast<PSetCallBarringWrapper::BarringStatus>(spy.at(3).at(2))); |
|
639 |
|
640 resultBasicServiceGroupIds = |
|
641 qvariant_cast<QList<unsigned char> >(spy.at(4).at(1)); |
|
642 QVERIFY(ServiceGroupVoice == resultBasicServiceGroupIds[0]); |
|
643 QVERIFY(PSetCallBarringWrapper::BarringStatusUnknown == |
|
644 qvariant_cast<PSetCallBarringWrapper::BarringStatus>(spy.at(4).at(2))); |
|
645 |
|
646 // invalid/unknown enumeration as barring status |
|
647 resultBasicServiceGroupIds = |
|
648 qvariant_cast<QList<unsigned char> >(spy.at(5).at(1)); |
|
649 QVERIFY(ServiceGroupVoice == resultBasicServiceGroupIds[0]); |
|
650 QVERIFY(PSetCallBarringWrapper::BarringStatusUnknown == |
|
651 qvariant_cast<PSetCallBarringWrapper::BarringStatus>(spy.at(5).at(2))); |
|
652 } |
|
653 |
|
654 |
|
655 /*! |
|
656 UT_PSetCallBarringWrapper::t_HandleBarringModeStatusNoBasicServiceGroupIdsL |
|
657 */ |
|
658 void UT_PSetCallBarringWrapper::t_HandleBarringModeStatusNoBasicServiceGroupIdsL() |
|
659 { |
|
660 TUint8 basicServiceGroupIds[KPSetNumberOfBsc]; |
|
661 basicServiceGroupIds[0] = KPSetUnusedValue; |
|
662 QSignalSpy spy(m_wrapper, |
|
663 SIGNAL(barringStatusRequestCompleted( |
|
664 int, |
|
665 const QList<unsigned char> &, |
|
666 PSetCallBarringWrapper::BarringStatus))); |
|
667 |
|
668 QT_TRAP_THROWING( |
|
669 m_wrapper->barringStatus(ServiceGroupVoice, |
|
670 PSetCallBarringWrapper::BarringTypeAllBarrings); |
|
671 m_wrapper->m_privateImpl->HandleBarringModeStatusL( |
|
672 basicServiceGroupIds, EBarringStatusActive); |
|
673 m_wrapper->m_privateImpl->RequestComplete(); |
|
674 ) |
|
675 |
|
676 if (qstrcmp(QTest::currentTestFunction(), "t_exceptionSafety") == 0) { |
|
677 // Signal emissions from RequestComplete will fail with exception safety |
|
678 // tests so it's not possible to verify signal data. |
|
679 return; |
|
680 } |
|
681 |
|
682 QCOMPARE(spy.count(), 1); |
|
683 QVERIFY(PSetCallBarringWrapper::BarringStatusActive == |
|
684 qvariant_cast<PSetCallBarringWrapper::BarringStatus>(spy.at(0).at(2))); |
|
685 } |
|
686 |
|
687 |
|
688 /*! |
|
689 UT_PSetCallBarringWrapper::t_enableBarringRequestComplete |
|
690 */ |
|
691 Q_DECLARE_METATYPE(PSetCallBarringWrapper::BarringType) |
|
692 void UT_PSetCallBarringWrapper::t_enableBarringRequestComplete() |
|
693 { |
|
694 qRegisterMetaType<PSetCallBarringWrapper::BarringType>( |
|
695 "PSetCallBarringWrapper::BarringType"); |
|
696 QSignalSpy spy( |
|
697 m_wrapper, |
|
698 SIGNAL(enableBarringRequestCompleted(int, |
|
699 PSetCallBarringWrapper::BarringType, |
|
700 PSetCallBarringWrapper::BarringStatus, |
|
701 bool))); |
|
702 |
|
703 TCallBarringSetting setting; |
|
704 m_wrapper->enableBarring( |
|
705 ServiceGroupVoice, |
|
706 PSetCallBarringWrapper::BarringTypeAllBarrings, |
|
707 QString("1234")); |
|
708 QT_TRAP_THROWING( |
|
709 m_wrapper->m_privateImpl->HandleBarringModeChangedL( |
|
710 EBarringTypeAllBarrings, EBarringStatusActive, EFalse); |
|
711 ); |
|
712 m_wrapper->m_privateImpl->RequestComplete(); |
|
713 |
|
714 if (qstrcmp(QTest::currentTestFunction(), "t_exceptionSafety") == 0) { |
|
715 // Signal emissions from RequestComplete will fail with exception safety |
|
716 // tests so it's not possible to verify signal data. |
|
717 return; |
|
718 } |
|
719 |
|
720 QCOMPARE(spy.count(), 1); |
|
721 QCOMPARE(spy.at(0).at(0).toInt(), 0); |
|
722 QCOMPARE(spy.at(0).at(1).value<PSetCallBarringWrapper::BarringType>(), |
|
723 PSetCallBarringWrapper::BarringTypeAllBarrings); |
|
724 QCOMPARE(spy.at(0).at(2).value<PSetCallBarringWrapper::BarringStatus>(), |
|
725 PSetCallBarringWrapper::BarringStatusActive); |
|
726 QCOMPARE(spy.at(0).at(3).toBool(), false); |
|
727 } |
|
728 |
|
729 |
|
730 /*! |
|
731 UT_PSetCallBarringWrapper::t_disableBarringRequestComplete |
|
732 */ |
|
733 void UT_PSetCallBarringWrapper::t_disableBarringRequestComplete() |
|
734 { |
|
735 QSignalSpy spy( |
|
736 m_wrapper, |
|
737 SIGNAL(disableBarringRequestCompleted(int, |
|
738 PSetCallBarringWrapper::BarringType, |
|
739 PSetCallBarringWrapper::BarringStatus, |
|
740 bool))); |
|
741 |
|
742 TCallBarringSetting setting; |
|
743 m_wrapper->disableBarring( |
|
744 ServiceGroupVoice, |
|
745 PSetCallBarringWrapper::BarringTypeAllBarrings, |
|
746 QString("1234")); |
|
747 QT_TRAP_THROWING( |
|
748 m_wrapper->m_privateImpl->HandleBarringModeChangedL( |
|
749 EBarringTypeAllBarrings, EBarringStatusNotProvisioned, EFalse); |
|
750 ); |
|
751 m_wrapper->m_privateImpl->RequestComplete(); |
|
752 |
|
753 if (qstrcmp(QTest::currentTestFunction(), "t_exceptionSafety") == 0) { |
|
754 // Signal emissions from RequestComplete will fail with exception safety |
|
755 // tests so it's not possible to verify signal data. |
|
756 return; |
|
757 } |
|
758 |
|
759 QCOMPARE(spy.count(), 1); |
|
760 QCOMPARE(spy.at(0).at(0).toInt(), 0); |
|
761 QCOMPARE(spy.at(0).at(1).value<PSetCallBarringWrapper::BarringType>(), |
|
762 PSetCallBarringWrapper::BarringTypeAllBarrings); |
|
763 QCOMPARE(spy.at(0).at(2).value<PSetCallBarringWrapper::BarringStatus>(), |
|
764 PSetCallBarringWrapper::BarringStatusNotProvisioned); |
|
765 QCOMPARE(spy.at(0).at(3).toBool(), false); |
|
766 } |
|
767 |
|
768 |
|
769 /*! |
|
770 UT_PSetCallBarringWrapper::t_changeBarringPasswordRequestComplete |
|
771 */ |
|
772 void UT_PSetCallBarringWrapper::t_changeBarringPasswordRequestComplete() |
|
773 { |
|
774 QSignalSpy spy( |
|
775 m_wrapper, |
|
776 SIGNAL(barringPasswordChangeRequestCompleted(int))); |
|
777 |
|
778 QString oldPassword = "1234"; |
|
779 QString newPassword = "4321"; |
|
780 QString verifiedPassword = "4321"; |
|
781 m_wrapper->changeBarringPassword( |
|
782 oldPassword, newPassword, verifiedPassword); |
|
783 |
|
784 m_wrapper->m_privateImpl->RequestComplete(); |
|
785 |
|
786 if (qstrcmp(QTest::currentTestFunction(), "t_exceptionSafety") == 0) { |
|
787 // Signal emissions from RequestComplete will fail with exception safety |
|
788 // tests so it's not possible to verify signal data. |
|
789 return; |
|
790 } |
|
791 |
|
792 QCOMPARE(spy.count(), 1); |
|
793 QCOMPARE(spy.at(0).at(0).toInt(), 0); |
|
794 } |
|
795 |
|
796 |
|
797 /*! |
|
798 UT_PSetCallBarringWrapper::t_RequestStatusChanged |
|
799 */ |
|
800 void UT_PSetCallBarringWrapper::t_RequestStatusChanged() |
|
801 { |
|
802 m_wrapper->m_privateImpl->RequestStatusChanged(0); |
|
803 } |
|
804 |
|
805 |
|
806 /*! |
|
807 UT_PSetCallBarringWrapper::t_exceptionSafety |
|
808 */ |
|
809 void UT_PSetCallBarringWrapper::t_exceptionSafety() |
|
810 { |
|
811 cleanup(); |
|
812 |
|
813 OomTestExecuter::runAllTests(*this, "t_exceptionSafety"); |
|
814 } |
|
815 |
|
816 |
|
817 /*! |
|
818 UT_PSetCallBarringWrapper::simulateLeaveAtMockMethodCall |
|
819 */ |
|
820 void UT_PSetCallBarringWrapper::simulateLeaveAtMockMethodCall() |
|
821 { |
|
822 User::Leave(KErrGeneral); |
|
823 } |
|
824 |
|
825 QTEST_MAIN_S60(UT_PSetCallBarringWrapper) |