|
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 |
|
78 /*! |
|
79 UT_PSetCallBarringWrapper::UT_PSetCallBarringWrapper |
|
80 */ |
|
81 UT_PSetCallBarringWrapper::UT_PSetCallBarringWrapper() |
|
82 : |
|
83 m_psetContainerMock(NULL), |
|
84 m_wrapper(NULL) |
|
85 { |
|
86 } |
|
87 |
|
88 |
|
89 /*! |
|
90 UT_PSetCallBarringWrapper::~UT_PSetCallBarringWrapper |
|
91 */ |
|
92 UT_PSetCallBarringWrapper::~UT_PSetCallBarringWrapper() |
|
93 { |
|
94 delete m_psetContainerMock; |
|
95 delete m_wrapper; |
|
96 } |
|
97 |
|
98 |
|
99 /*! |
|
100 UT_PSetCallBarringWrapper::init |
|
101 */ |
|
102 void UT_PSetCallBarringWrapper::init() |
|
103 { |
|
104 initialize(); |
|
105 |
|
106 m_psetContainerMock = new CPsetContainer(); |
|
107 |
|
108 BarringObserver dummyObserver; |
|
109 RMobilePhone dummyPhone; |
|
110 |
|
111 CPsetCallBarring *barringMock = NULL; |
|
112 TRAPD(result, barringMock = CPsetCallBarring::NewL(dummyObserver, dummyPhone)); |
|
113 QScopedPointer<CPsetCallBarring> barringMockGuard(barringMock); |
|
114 EXPECT(CPsetContainer::CreateCBObjectL) |
|
115 .returns(barringMock); |
|
116 m_wrapper = new PSetCallBarringWrapper(*m_psetContainerMock, NULL); |
|
117 barringMockGuard.take(); |
|
118 |
|
119 QVERIFY(verify()); |
|
120 } |
|
121 |
|
122 |
|
123 /*! |
|
124 UT_PSetCallBarringWrapper::cleanup |
|
125 */ |
|
126 void UT_PSetCallBarringWrapper::cleanup() |
|
127 { |
|
128 reset(); |
|
129 |
|
130 delete m_psetContainerMock; |
|
131 m_psetContainerMock = NULL; |
|
132 delete m_wrapper; |
|
133 m_wrapper = NULL; |
|
134 } |
|
135 |
|
136 |
|
137 /*! |
|
138 UT_PSetCallBarringWrapper::t_construction |
|
139 */ |
|
140 void UT_PSetCallBarringWrapper::t_construction() |
|
141 { |
|
142 EXPECT(CPsetContainer::CreateCBObjectL). |
|
143 willOnce(invokeWithoutArguments(this, simulateLeaveAtMockMethodCall)); |
|
144 PSetCallBarringWrapper *wrapper = NULL; |
|
145 EXPECT_EXCEPTION( |
|
146 wrapper = new PSetCallBarringWrapper(*m_psetContainerMock, NULL);); |
|
147 } |
|
148 |
|
149 |
|
150 /*! |
|
151 UT_PSetCallBarringWrapper::t_barringStatus |
|
152 */ |
|
153 void UT_PSetCallBarringWrapper::t_barringStatus() |
|
154 { |
|
155 // test status query with different service groups |
|
156 EXPECT(CPsetCallBarring::GetBarringStatusL) |
|
157 .with(EServiceGroupVoice, EBarringTypeAllBarrings); |
|
158 EXPECT(CPsetCallBarring::GetBarringStatusL) |
|
159 .with(EServiceGroupData, EBarringTypeAllBarrings); |
|
160 EXPECT(CPsetCallBarring::GetBarringStatusL) |
|
161 .with(EServiceGroupFax, EBarringTypeAllBarrings); |
|
162 EXPECT(CPsetCallBarring::GetBarringStatusL) |
|
163 .with(EServiceGroupAllTeleservices, EBarringTypeAllBarrings); |
|
164 // invalid/unknown enumeration as service group identifier |
|
165 EXPECT(CPsetCallBarring::GetBarringStatusL) |
|
166 .with(EServiceGroupVoice, EBarringTypeAllBarrings); |
|
167 |
|
168 //TODO: remove SeviceGroupUnknown enumeration? |
|
169 //m_wrapper->barringStatus(ServiceGroupUnknown); |
|
170 m_wrapper->barringStatus(ServiceGroupVoice, |
|
171 PSetCallBarringWrapper::BarringTypeAllBarrings); |
|
172 m_wrapper->barringStatus(ServiceGroupData, |
|
173 PSetCallBarringWrapper::BarringTypeAllBarrings); |
|
174 m_wrapper->barringStatus(ServiceGroupFax, |
|
175 PSetCallBarringWrapper::BarringTypeAllBarrings); |
|
176 m_wrapper->barringStatus(ServiceGroupAllTeleservices, |
|
177 PSetCallBarringWrapper::BarringTypeAllBarrings); |
|
178 // invalid/unknown enumeration as service group identifier |
|
179 m_wrapper->barringStatus( |
|
180 static_cast<PsService>(KInvalidEnumeration), |
|
181 PSetCallBarringWrapper::BarringTypeAllBarrings); |
|
182 |
|
183 // test status query with different barring types |
|
184 EXPECT(CPsetCallBarring::GetBarringStatusL) |
|
185 .with(EServiceGroupVoice, EBarringTypeAllOutgoing); |
|
186 EXPECT(CPsetCallBarring::GetBarringStatusL) |
|
187 .with(EServiceGroupVoice, EBarringTypeOutgoingInternational); |
|
188 EXPECT(CPsetCallBarring::GetBarringStatusL) |
|
189 .with(EServiceGroupVoice, |
|
190 EBarringTypeOutgoingInternationalExceptToHomeCountry); |
|
191 EXPECT(CPsetCallBarring::GetBarringStatusL) |
|
192 .with(EServiceGroupVoice, EBarringTypeAllIncoming); |
|
193 EXPECT(CPsetCallBarring::GetBarringStatusL) |
|
194 .with(EServiceGroupVoice, EBarringTypeIncomingWhenRoaming); |
|
195 EXPECT(CPsetCallBarring::GetBarringStatusL) |
|
196 .with(EServiceGroupVoice, EBarringTypeAllServices); |
|
197 EXPECT(CPsetCallBarring::GetBarringStatusL) |
|
198 .with(EServiceGroupVoice, EBarringTypeAllOutgoingServices); |
|
199 EXPECT(CPsetCallBarring::GetBarringStatusL) |
|
200 .with(EServiceGroupVoice, EBarringTypeAllIncomingServices); |
|
201 // invalid/unknown enumeration as barring type |
|
202 EXPECT(CPsetCallBarring::GetBarringStatusL) |
|
203 .with(EServiceGroupVoice, EBarringTypeAllBarrings); |
|
204 m_wrapper->barringStatus(ServiceGroupVoice, |
|
205 PSetCallBarringWrapper::BarringTypeAllOutgoing); |
|
206 m_wrapper->barringStatus(ServiceGroupVoice, |
|
207 PSetCallBarringWrapper::BarringTypeOutgoingInternational); |
|
208 m_wrapper->barringStatus(ServiceGroupVoice, |
|
209 PSetCallBarringWrapper:: |
|
210 BarringTypeOutgoingInternationalExceptToHomeCountry); |
|
211 m_wrapper->barringStatus(ServiceGroupVoice, |
|
212 PSetCallBarringWrapper::BarringTypeAllIncoming); |
|
213 m_wrapper->barringStatus(ServiceGroupVoice, |
|
214 PSetCallBarringWrapper::BarringTypeIncomingWhenRoaming); |
|
215 m_wrapper->barringStatus(ServiceGroupVoice, |
|
216 PSetCallBarringWrapper::BarringTypeAllServices); |
|
217 m_wrapper->barringStatus(ServiceGroupVoice, |
|
218 PSetCallBarringWrapper::BarringTypeAllOutgoingServices); |
|
219 m_wrapper->barringStatus(ServiceGroupVoice, |
|
220 PSetCallBarringWrapper::BarringTypeAllIncomingServices); |
|
221 // invalid/unknown enumeration as barring type |
|
222 m_wrapper->barringStatus(ServiceGroupVoice, |
|
223 static_cast<PSetCallBarringWrapper::BarringType>(KInvalidEnumeration)); |
|
224 |
|
225 QVERIFY(verify()); |
|
226 } |
|
227 |
|
228 |
|
229 /*! |
|
230 UT_PSetCallBarringWrapper::t_barringStatusExceptionOccurs |
|
231 */ |
|
232 void UT_PSetCallBarringWrapper::t_barringStatusExceptionOccurs() |
|
233 { |
|
234 EXPECT(CPsetCallBarring::GetBarringStatusL) |
|
235 .willOnce(invokeWithoutArguments(this, simulateLeaveAtMockMethodCall)); |
|
236 |
|
237 EXPECT_EXCEPTION( |
|
238 m_wrapper->barringStatus( |
|
239 ServiceGroupVoice, |
|
240 PSetCallBarringWrapper::BarringTypeAllBarrings); |
|
241 ) |
|
242 |
|
243 QVERIFY(verify()); |
|
244 } |
|
245 |
|
246 |
|
247 /*! |
|
248 UT_PSetCallBarringWrapper::t_enableBarring |
|
249 */ |
|
250 void UT_PSetCallBarringWrapper::t_enableBarring() |
|
251 { |
|
252 _LIT(KPassword, "1234"); |
|
253 TCallBarringSetting setting; |
|
254 setting.iType = EBarringTypeAllBarrings; |
|
255 setting.iSetting = EActivateBarring; |
|
256 setting.iServiceGroup = EServiceGroupVoice; |
|
257 setting.iPassword.Copy(KPassword()); |
|
258 EXPECT(CPsetCallBarring::SetBarringL) |
|
259 .with(setting, EAllTeleAndBearer); |
|
260 m_wrapper->enableBarring( |
|
261 ServiceGroupVoice, |
|
262 PSetCallBarringWrapper::BarringTypeAllBarrings, |
|
263 QString("1234")); |
|
264 |
|
265 setting.iType = EBarringTypeAllOutgoing; |
|
266 EXPECT(CPsetCallBarring::SetBarringL) |
|
267 .with(setting, EAllTeleAndBearer); |
|
268 m_wrapper->enableBarring( |
|
269 ServiceGroupVoice, |
|
270 PSetCallBarringWrapper::BarringTypeAllOutgoing, |
|
271 QString("1234")); |
|
272 |
|
273 setting.iType = EBarringTypeOutgoingInternational; |
|
274 EXPECT(CPsetCallBarring::SetBarringL) |
|
275 .with(setting, EAllTeleAndBearer); |
|
276 m_wrapper->enableBarring( |
|
277 ServiceGroupVoice, |
|
278 PSetCallBarringWrapper::BarringTypeOutgoingInternational, |
|
279 QString("1234")); |
|
280 |
|
281 setting.iType = EBarringTypeOutgoingInternationalExceptToHomeCountry; |
|
282 EXPECT(CPsetCallBarring::SetBarringL) |
|
283 .with(setting, EAllTeleAndBearer); |
|
284 m_wrapper->enableBarring( |
|
285 ServiceGroupVoice, |
|
286 PSetCallBarringWrapper::BarringTypeOutgoingInternationalExceptToHomeCountry, |
|
287 QString("1234")); |
|
288 |
|
289 setting.iType = EBarringTypeAllIncoming; |
|
290 EXPECT(CPsetCallBarring::SetBarringL) |
|
291 .with(setting, EAllTeleAndBearer); |
|
292 m_wrapper->enableBarring( |
|
293 ServiceGroupVoice, |
|
294 PSetCallBarringWrapper::BarringTypeAllIncoming, |
|
295 QString("1234")); |
|
296 |
|
297 setting.iType = EBarringTypeIncomingWhenRoaming; |
|
298 EXPECT(CPsetCallBarring::SetBarringL) |
|
299 .with(setting, EAllTeleAndBearer); |
|
300 m_wrapper->enableBarring( |
|
301 ServiceGroupVoice, |
|
302 PSetCallBarringWrapper::BarringTypeIncomingWhenRoaming, |
|
303 QString("1234")); |
|
304 |
|
305 setting.iType = EBarringTypeAllServices; |
|
306 EXPECT(CPsetCallBarring::SetBarringL) |
|
307 .with(setting, EAllTeleAndBearer); |
|
308 m_wrapper->enableBarring( |
|
309 ServiceGroupVoice, |
|
310 PSetCallBarringWrapper::BarringTypeAllServices, |
|
311 QString("1234")); |
|
312 |
|
313 setting.iType = EBarringTypeAllOutgoingServices; |
|
314 EXPECT(CPsetCallBarring::SetBarringL) |
|
315 .with(setting, EAllTeleAndBearer); |
|
316 m_wrapper->enableBarring( |
|
317 ServiceGroupVoice, |
|
318 PSetCallBarringWrapper::BarringTypeAllOutgoingServices, |
|
319 QString("1234")); |
|
320 |
|
321 setting.iType = EBarringTypeAllIncomingServices; |
|
322 EXPECT(CPsetCallBarring::SetBarringL) |
|
323 .with(setting, EAllTeleAndBearer); |
|
324 m_wrapper->enableBarring( |
|
325 ServiceGroupVoice, |
|
326 PSetCallBarringWrapper::BarringTypeAllIncomingServices, |
|
327 QString("1234")); |
|
328 |
|
329 QVERIFY(verify()); |
|
330 } |
|
331 |
|
332 |
|
333 /*! |
|
334 UT_PSetCallBarringWrapper::t_disableBarring |
|
335 */ |
|
336 void UT_PSetCallBarringWrapper::t_disableBarring() |
|
337 { |
|
338 _LIT(KPassword, "1234"); |
|
339 TCallBarringSetting setting; |
|
340 setting.iType = EBarringTypeAllBarrings; |
|
341 setting.iSetting = ECancelBarring; |
|
342 setting.iServiceGroup = EServiceGroupVoice; |
|
343 setting.iPassword.Copy(KPassword()); |
|
344 EXPECT(CPsetCallBarring::SetBarringL) |
|
345 .with(setting, EAllTeleAndBearer); |
|
346 m_wrapper->disableBarring( |
|
347 ServiceGroupVoice, |
|
348 PSetCallBarringWrapper::BarringTypeAllBarrings, |
|
349 QString("1234")); |
|
350 |
|
351 setting.iType = EBarringTypeAllOutgoing; |
|
352 EXPECT(CPsetCallBarring::SetBarringL) |
|
353 .with(setting, EAllTeleAndBearer); |
|
354 m_wrapper->disableBarring( |
|
355 ServiceGroupVoice, |
|
356 PSetCallBarringWrapper::BarringTypeAllOutgoing, |
|
357 QString("1234")); |
|
358 |
|
359 setting.iType = EBarringTypeOutgoingInternational; |
|
360 EXPECT(CPsetCallBarring::SetBarringL) |
|
361 .with(setting, EAllTeleAndBearer); |
|
362 m_wrapper->disableBarring( |
|
363 ServiceGroupVoice, |
|
364 PSetCallBarringWrapper::BarringTypeOutgoingInternational, |
|
365 QString("1234")); |
|
366 |
|
367 setting.iType = EBarringTypeOutgoingInternationalExceptToHomeCountry; |
|
368 EXPECT(CPsetCallBarring::SetBarringL) |
|
369 .with(setting, EAllTeleAndBearer); |
|
370 m_wrapper->disableBarring( |
|
371 ServiceGroupVoice, |
|
372 PSetCallBarringWrapper::BarringTypeOutgoingInternationalExceptToHomeCountry, |
|
373 QString("1234")); |
|
374 |
|
375 setting.iType = EBarringTypeAllIncoming; |
|
376 EXPECT(CPsetCallBarring::SetBarringL) |
|
377 .with(setting, EAllTeleAndBearer); |
|
378 m_wrapper->disableBarring( |
|
379 ServiceGroupVoice, |
|
380 PSetCallBarringWrapper::BarringTypeAllIncoming, |
|
381 QString("1234")); |
|
382 |
|
383 setting.iType = EBarringTypeIncomingWhenRoaming; |
|
384 EXPECT(CPsetCallBarring::SetBarringL) |
|
385 .with(setting, EAllTeleAndBearer); |
|
386 m_wrapper->disableBarring( |
|
387 ServiceGroupVoice, |
|
388 PSetCallBarringWrapper::BarringTypeIncomingWhenRoaming, |
|
389 QString("1234")); |
|
390 |
|
391 setting.iType = EBarringTypeAllServices; |
|
392 EXPECT(CPsetCallBarring::SetBarringL) |
|
393 .with(setting, EAllTeleAndBearer); |
|
394 m_wrapper->disableBarring( |
|
395 ServiceGroupVoice, |
|
396 PSetCallBarringWrapper::BarringTypeAllServices, |
|
397 QString("1234")); |
|
398 |
|
399 setting.iType = EBarringTypeAllOutgoingServices; |
|
400 EXPECT(CPsetCallBarring::SetBarringL) |
|
401 .with(setting, EAllTeleAndBearer); |
|
402 m_wrapper->disableBarring( |
|
403 ServiceGroupVoice, |
|
404 PSetCallBarringWrapper::BarringTypeAllOutgoingServices, |
|
405 QString("1234")); |
|
406 |
|
407 setting.iType = EBarringTypeAllIncomingServices; |
|
408 EXPECT(CPsetCallBarring::SetBarringL) |
|
409 .with(setting, EAllTeleAndBearer); |
|
410 m_wrapper->disableBarring( |
|
411 ServiceGroupVoice, |
|
412 PSetCallBarringWrapper::BarringTypeAllIncomingServices, |
|
413 QString("1234")); |
|
414 |
|
415 QVERIFY(verify()); |
|
416 } |
|
417 |
|
418 |
|
419 /*! |
|
420 UT_PSetCallBarringWrapper::t_HandleBarringModeChangedL |
|
421 */ |
|
422 void UT_PSetCallBarringWrapper::t_HandleBarringModeChangedL() |
|
423 { |
|
424 TBool plural = EFalse; |
|
425 QT_TRAP_THROWING( |
|
426 m_wrapper->m_privateImpl->HandleBarringModeChangedL( |
|
427 EBarringTypeAllBarrings, EBarringStatusActive, plural); |
|
428 m_wrapper->m_privateImpl->HandleBarringModeChangedL( |
|
429 EBarringTypeAllOutgoing, EBarringStatusActive, plural); |
|
430 m_wrapper->m_privateImpl->HandleBarringModeChangedL( |
|
431 EBarringTypeOutgoingInternational, EBarringStatusActive, plural); |
|
432 m_wrapper->m_privateImpl->HandleBarringModeChangedL( |
|
433 EBarringTypeOutgoingInternationalExceptToHomeCountry, EBarringStatusActive, plural); |
|
434 m_wrapper->m_privateImpl->HandleBarringModeChangedL( |
|
435 EBarringTypeAllIncoming, EBarringStatusActive, plural); |
|
436 m_wrapper->m_privateImpl->HandleBarringModeChangedL( |
|
437 EBarringTypeIncomingWhenRoaming, EBarringStatusActive, plural); |
|
438 m_wrapper->m_privateImpl->HandleBarringModeChangedL( |
|
439 EBarringTypeAllServices, EBarringStatusActive, plural); |
|
440 m_wrapper->m_privateImpl->HandleBarringModeChangedL( |
|
441 EBarringTypeAllOutgoingServices, EBarringStatusActive, plural); |
|
442 m_wrapper->m_privateImpl->HandleBarringModeChangedL( |
|
443 EBarringTypeAllIncomingServices, EBarringStatusActive, plural); |
|
444 ) |
|
445 } |
|
446 |
|
447 |
|
448 /*! |
|
449 UT_PSetCallBarringWrapper::t_HandleBarringErrorL |
|
450 */ |
|
451 void UT_PSetCallBarringWrapper::t_HandleBarringErrorL() |
|
452 { |
|
453 // TODO: dummy test as functionality not yet implemented |
|
454 QT_TRAP_THROWING( |
|
455 m_wrapper->m_privateImpl->HandleBarringErrorL(KErrGeneral); |
|
456 ) |
|
457 } |
|
458 |
|
459 |
|
460 /*! |
|
461 UT_PSetCallBarringWrapper::t_HandleCBRequestingL |
|
462 */ |
|
463 void UT_PSetCallBarringWrapper::t_HandleCBRequestingL() |
|
464 { |
|
465 // TODO: dummy test as functionality not yet implemented |
|
466 QT_TRAP_THROWING( |
|
467 m_wrapper->m_privateImpl->HandleCBRequestingL(EFalse, EFalse); |
|
468 ) |
|
469 } |
|
470 |
|
471 |
|
472 /*! |
|
473 UT_PSetCallBarringWrapper::t_SetEngineContact |
|
474 */ |
|
475 void UT_PSetCallBarringWrapper::t_SetEngineContact() |
|
476 { |
|
477 // TODO: dummy test as functionality not yet implemented |
|
478 m_wrapper->m_privateImpl->SetEngineContact(NULL); |
|
479 } |
|
480 |
|
481 |
|
482 /*! |
|
483 UT_PSetCallBarringWrapper::t_CbPasswordChangedL |
|
484 */ |
|
485 void UT_PSetCallBarringWrapper::t_CbPasswordChangedL() |
|
486 { |
|
487 // TODO: dummy test as functionality not yet implemented |
|
488 TBool success = EFalse; |
|
489 QT_TRAP_THROWING( |
|
490 m_wrapper->m_privateImpl->CbPasswordChangedL(success); |
|
491 ) |
|
492 } |
|
493 |
|
494 |
|
495 /*! |
|
496 UT_PSetCallBarringWrapper::t_HandleBarringModeStatusL |
|
497 */ |
|
498 Q_DECLARE_METATYPE(PSetCallBarringWrapper::BarringStatus) |
|
499 Q_DECLARE_METATYPE(QList<unsigned char>) |
|
500 void UT_PSetCallBarringWrapper::t_HandleBarringModeStatusL() |
|
501 { |
|
502 qRegisterMetaType<PSetCallBarringWrapper::BarringStatus> |
|
503 ("PSetCallBarringWrapper::BarringStatus"); |
|
504 qRegisterMetaType<QList<unsigned char> >("QList<unsigned char>"); |
|
505 QSignalSpy spy(m_wrapper, |
|
506 SIGNAL(barringStatusRequestCompleted( |
|
507 int, |
|
508 const QList<unsigned char> &, |
|
509 PSetCallBarringWrapper::BarringStatus))); |
|
510 |
|
511 TUint8 basicServiceGroupIds[KPSetNumberOfBsc]; |
|
512 basicServiceGroupIds[0] = EServiceGroupVoice; |
|
513 basicServiceGroupIds[1] = KPSetUnusedValue; |
|
514 // test with different barring statuses |
|
515 QT_TRAP_THROWING( |
|
516 m_wrapper->barringStatus(ServiceGroupVoice, |
|
517 PSetCallBarringWrapper::BarringTypeAllBarrings); |
|
518 m_wrapper->m_privateImpl->HandleBarringModeStatusL( |
|
519 basicServiceGroupIds, EBarringStatusActive); |
|
520 m_wrapper->m_privateImpl->RequestComplete(); |
|
521 |
|
522 m_wrapper->barringStatus(ServiceGroupVoice, |
|
523 PSetCallBarringWrapper::BarringTypeAllBarrings); |
|
524 m_wrapper->m_privateImpl->HandleBarringModeStatusL( |
|
525 basicServiceGroupIds, EBarringStatusInactive); |
|
526 m_wrapper->m_privateImpl->RequestComplete(); |
|
527 |
|
528 m_wrapper->barringStatus(ServiceGroupVoice, |
|
529 PSetCallBarringWrapper::BarringTypeAllBarrings); |
|
530 m_wrapper->m_privateImpl->HandleBarringModeStatusL( |
|
531 basicServiceGroupIds, EBarringStatusNotProvisioned); |
|
532 m_wrapper->m_privateImpl->RequestComplete(); |
|
533 |
|
534 m_wrapper->barringStatus(ServiceGroupVoice, |
|
535 PSetCallBarringWrapper::BarringTypeAllBarrings); |
|
536 m_wrapper->m_privateImpl->HandleBarringModeStatusL( |
|
537 basicServiceGroupIds, EBarringStatusUnavailable); |
|
538 m_wrapper->m_privateImpl->RequestComplete(); |
|
539 |
|
540 m_wrapper->barringStatus(ServiceGroupVoice, |
|
541 PSetCallBarringWrapper::BarringTypeAllBarrings); |
|
542 m_wrapper->m_privateImpl->HandleBarringModeStatusL( |
|
543 basicServiceGroupIds, EBarringStatusUnknown); |
|
544 m_wrapper->m_privateImpl->RequestComplete(); |
|
545 |
|
546 // invalid/unknown enumeration as barring status |
|
547 m_wrapper->barringStatus(ServiceGroupVoice, |
|
548 PSetCallBarringWrapper::BarringTypeAllBarrings); |
|
549 m_wrapper->m_privateImpl->HandleBarringModeStatusL( |
|
550 basicServiceGroupIds, |
|
551 static_cast<TBarringStatus>(KInvalidEnumeration)); |
|
552 m_wrapper->m_privateImpl->RequestComplete(); |
|
553 ) |
|
554 |
|
555 if (qstrcmp(QTest::currentTestFunction(), "t_exceptionSafety") == 0) { |
|
556 // Signal emissions from RequestComplete will fail with exception safety |
|
557 // tests so it's not possible to verify signal data. |
|
558 return; |
|
559 } |
|
560 |
|
561 QCOMPARE(spy.count(), 6); |
|
562 QList<unsigned char> resultBasicServiceGroupIds = |
|
563 qvariant_cast<QList<unsigned char> >(spy.at(0).at(1)); |
|
564 QVERIFY(ServiceGroupVoice == resultBasicServiceGroupIds[0]); |
|
565 QVERIFY(PSetCallBarringWrapper::BarringStatusActive == |
|
566 qvariant_cast<PSetCallBarringWrapper::BarringStatus>(spy.at(0).at(2))); |
|
567 |
|
568 resultBasicServiceGroupIds = |
|
569 qvariant_cast<QList<unsigned char> >(spy.at(1).at(1)); |
|
570 QVERIFY(ServiceGroupVoice == resultBasicServiceGroupIds[0]); |
|
571 QVERIFY(PSetCallBarringWrapper::BarringStatusInactive == |
|
572 qvariant_cast<PSetCallBarringWrapper::BarringStatus>(spy.at(1).at(2))); |
|
573 |
|
574 resultBasicServiceGroupIds = |
|
575 qvariant_cast<QList<unsigned char> >(spy.at(2).at(1)); |
|
576 QVERIFY(ServiceGroupVoice == resultBasicServiceGroupIds[0]); |
|
577 QVERIFY(PSetCallBarringWrapper::BarringStatusNotProvisioned == |
|
578 qvariant_cast<PSetCallBarringWrapper::BarringStatus>(spy.at(2).at(2))); |
|
579 |
|
580 resultBasicServiceGroupIds = |
|
581 qvariant_cast<QList<unsigned char> >(spy.at(3).at(1)); |
|
582 QVERIFY(ServiceGroupVoice == resultBasicServiceGroupIds[0]); |
|
583 QVERIFY(PSetCallBarringWrapper::BarringStatusUnavailable == |
|
584 qvariant_cast<PSetCallBarringWrapper::BarringStatus>(spy.at(3).at(2))); |
|
585 |
|
586 resultBasicServiceGroupIds = |
|
587 qvariant_cast<QList<unsigned char> >(spy.at(4).at(1)); |
|
588 QVERIFY(ServiceGroupVoice == resultBasicServiceGroupIds[0]); |
|
589 QVERIFY(PSetCallBarringWrapper::BarringStatusUnknown == |
|
590 qvariant_cast<PSetCallBarringWrapper::BarringStatus>(spy.at(4).at(2))); |
|
591 |
|
592 // invalid/unknown enumeration as barring status |
|
593 resultBasicServiceGroupIds = |
|
594 qvariant_cast<QList<unsigned char> >(spy.at(5).at(1)); |
|
595 QVERIFY(ServiceGroupVoice == resultBasicServiceGroupIds[0]); |
|
596 QVERIFY(PSetCallBarringWrapper::BarringStatusUnknown == |
|
597 qvariant_cast<PSetCallBarringWrapper::BarringStatus>(spy.at(5).at(2))); |
|
598 } |
|
599 |
|
600 |
|
601 /*! |
|
602 UT_PSetCallBarringWrapper::t_HandleBarringModeStatusNoBasicServiceGroupIdsL |
|
603 */ |
|
604 void UT_PSetCallBarringWrapper::t_HandleBarringModeStatusNoBasicServiceGroupIdsL() |
|
605 { |
|
606 TUint8 basicServiceGroupIds[KPSetNumberOfBsc]; |
|
607 basicServiceGroupIds[0] = KPSetUnusedValue; |
|
608 QSignalSpy spy(m_wrapper, |
|
609 SIGNAL(barringStatusRequestCompleted( |
|
610 int, |
|
611 const QList<unsigned char> &, |
|
612 PSetCallBarringWrapper::BarringStatus))); |
|
613 |
|
614 QT_TRAP_THROWING( |
|
615 m_wrapper->barringStatus(ServiceGroupVoice, |
|
616 PSetCallBarringWrapper::BarringTypeAllBarrings); |
|
617 m_wrapper->m_privateImpl->HandleBarringModeStatusL( |
|
618 basicServiceGroupIds, EBarringStatusActive); |
|
619 m_wrapper->m_privateImpl->RequestComplete(); |
|
620 ) |
|
621 |
|
622 if (qstrcmp(QTest::currentTestFunction(), "t_exceptionSafety") == 0) { |
|
623 // Signal emissions from RequestComplete will fail with exception safety |
|
624 // tests so it's not possible to verify signal data. |
|
625 return; |
|
626 } |
|
627 |
|
628 QCOMPARE(spy.count(), 1); |
|
629 QVERIFY(PSetCallBarringWrapper::BarringStatusActive == |
|
630 qvariant_cast<PSetCallBarringWrapper::BarringStatus>(spy.at(0).at(2))); |
|
631 } |
|
632 |
|
633 |
|
634 /*! |
|
635 UT_PSetCallBarringWrapper::t_enableBarringRequestComplete |
|
636 */ |
|
637 Q_DECLARE_METATYPE(PSetCallBarringWrapper::BarringType) |
|
638 void UT_PSetCallBarringWrapper::t_enableBarringRequestComplete() |
|
639 { |
|
640 qRegisterMetaType<PSetCallBarringWrapper::BarringType>( |
|
641 "PSetCallBarringWrapper::BarringType"); |
|
642 QSignalSpy spy( |
|
643 m_wrapper, |
|
644 SIGNAL(enableBarringRequestCompleted(int, |
|
645 PSetCallBarringWrapper::BarringType, |
|
646 PSetCallBarringWrapper::BarringStatus, |
|
647 bool))); |
|
648 |
|
649 TCallBarringSetting setting; |
|
650 m_wrapper->enableBarring( |
|
651 ServiceGroupVoice, |
|
652 PSetCallBarringWrapper::BarringTypeAllBarrings, |
|
653 QString("1234")); |
|
654 QT_TRAP_THROWING( |
|
655 m_wrapper->m_privateImpl->HandleBarringModeChangedL( |
|
656 EBarringTypeAllBarrings, EBarringStatusActive, EFalse); |
|
657 ); |
|
658 m_wrapper->m_privateImpl->RequestComplete(); |
|
659 |
|
660 if (qstrcmp(QTest::currentTestFunction(), "t_exceptionSafety") == 0) { |
|
661 // Signal emissions from RequestComplete will fail with exception safety |
|
662 // tests so it's not possible to verify signal data. |
|
663 return; |
|
664 } |
|
665 |
|
666 QCOMPARE(spy.count(), 1); |
|
667 QCOMPARE(spy.at(0).at(0).toInt(), 0); |
|
668 QCOMPARE(spy.at(0).at(1).value<PSetCallBarringWrapper::BarringType>(), |
|
669 PSetCallBarringWrapper::BarringTypeAllBarrings); |
|
670 QCOMPARE(spy.at(0).at(2).value<PSetCallBarringWrapper::BarringStatus>(), |
|
671 PSetCallBarringWrapper::BarringStatusActive); |
|
672 QCOMPARE(spy.at(0).at(3).toBool(), false); |
|
673 } |
|
674 |
|
675 |
|
676 /*! |
|
677 UT_PSetCallBarringWrapper::t_disableBarringRequestComplete |
|
678 */ |
|
679 void UT_PSetCallBarringWrapper::t_disableBarringRequestComplete() |
|
680 { |
|
681 QSignalSpy spy( |
|
682 m_wrapper, |
|
683 SIGNAL(disableBarringRequestCompleted(int, |
|
684 PSetCallBarringWrapper::BarringType, |
|
685 PSetCallBarringWrapper::BarringStatus, |
|
686 bool))); |
|
687 |
|
688 TCallBarringSetting setting; |
|
689 m_wrapper->disableBarring( |
|
690 ServiceGroupVoice, |
|
691 PSetCallBarringWrapper::BarringTypeAllBarrings, |
|
692 QString("1234")); |
|
693 QT_TRAP_THROWING( |
|
694 m_wrapper->m_privateImpl->HandleBarringModeChangedL( |
|
695 EBarringTypeAllBarrings, EBarringStatusNotProvisioned, EFalse); |
|
696 ); |
|
697 m_wrapper->m_privateImpl->RequestComplete(); |
|
698 |
|
699 if (qstrcmp(QTest::currentTestFunction(), "t_exceptionSafety") == 0) { |
|
700 // Signal emissions from RequestComplete will fail with exception safety |
|
701 // tests so it's not possible to verify signal data. |
|
702 return; |
|
703 } |
|
704 |
|
705 QCOMPARE(spy.count(), 1); |
|
706 QCOMPARE(spy.at(0).at(0).toInt(), 0); |
|
707 QCOMPARE(spy.at(0).at(1).value<PSetCallBarringWrapper::BarringType>(), |
|
708 PSetCallBarringWrapper::BarringTypeAllBarrings); |
|
709 QCOMPARE(spy.at(0).at(2).value<PSetCallBarringWrapper::BarringStatus>(), |
|
710 PSetCallBarringWrapper::BarringStatusNotProvisioned); |
|
711 QCOMPARE(spy.at(0).at(3).toBool(), false); |
|
712 } |
|
713 |
|
714 |
|
715 /*! |
|
716 UT_PSetCallBarringWrapper::t_RequestStatusChanged |
|
717 */ |
|
718 void UT_PSetCallBarringWrapper::t_RequestStatusChanged() |
|
719 { |
|
720 m_wrapper->m_privateImpl->RequestStatusChanged(0); |
|
721 } |
|
722 |
|
723 |
|
724 /*! |
|
725 UT_PSetCallBarringWrapper::t_exceptionSafety |
|
726 */ |
|
727 void UT_PSetCallBarringWrapper::t_exceptionSafety() |
|
728 { |
|
729 cleanup(); |
|
730 |
|
731 OomTestExecuter::runAllTests(*this, "t_exceptionSafety"); |
|
732 } |
|
733 |
|
734 |
|
735 /*! |
|
736 UT_PSetCallBarringWrapper::simulateLeaveAtMockMethodCall |
|
737 */ |
|
738 void UT_PSetCallBarringWrapper::simulateLeaveAtMockMethodCall() |
|
739 { |
|
740 User::Leave(KErrGeneral); |
|
741 } |
|
742 |
|
743 QTEST_MAIN_S60(UT_PSetCallBarringWrapper) |