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 <PsetCallDiverting.h> |
|
20 #include <mpsetdivertobs.h> |
|
21 #include "ut_psetcalldivertingwrapper.h" |
|
22 #include "mock_cphcltemergencycall.h" |
|
23 #include "testutilities.h" |
|
24 #define private public |
|
25 #include "psetcalldivertingwrapper.h" |
|
26 #include "psetcalldivertingwrapper_p.h" |
|
27 |
|
28 class DivertObserver : public MPsetDivertObserver |
|
29 { |
|
30 void HandleDivertingChangedL( |
|
31 const TCallDivertSetting& aSetting, TBool aPlural) |
|
32 { |
|
33 Q_UNUSED(aSetting); |
|
34 Q_UNUSED(aPlural); |
|
35 } |
|
36 |
|
37 void HandleDivertingStatusL(CMobilePhoneCFList& aSetting, TBool aPlural) |
|
38 { |
|
39 Q_UNUSED(aSetting); |
|
40 Q_UNUSED(aPlural); |
|
41 } |
|
42 |
|
43 void HandleDivertingErrorL(TInt aReason) |
|
44 { |
|
45 Q_UNUSED(aReason); |
|
46 } |
|
47 |
|
48 void HandleCFRequestingL(TBool aOngoing, |
|
49 TBool aInterrupted) |
|
50 { |
|
51 Q_UNUSED(aOngoing); |
|
52 Q_UNUSED(aInterrupted); |
|
53 } |
|
54 |
|
55 void SetEngineContact(MPsetCallDiverting* aDivertEngine) |
|
56 { |
|
57 Q_UNUSED(aDivertEngine); |
|
58 } |
|
59 }; |
|
60 |
|
61 void SimulateLeaveL() |
|
62 { |
|
63 User::Leave(KErrGeneral); |
|
64 } |
|
65 |
|
66 /*! |
|
67 UT_PSetCallDivertingWrapper::UT_PSetWrapperCallDiverting |
|
68 */ |
|
69 UT_PSetCallDivertingWrapper::UT_PSetCallDivertingWrapper() |
|
70 : mWrapper(NULL), mSetContainerMock(NULL) |
|
71 { |
|
72 } |
|
73 |
|
74 /*! |
|
75 UT_PSetCallDivertingWrapper::~UT_PSetWrapperCallDiverting |
|
76 */ |
|
77 UT_PSetCallDivertingWrapper::~UT_PSetCallDivertingWrapper() |
|
78 { |
|
79 delete mWrapper; |
|
80 delete mSetContainerMock; |
|
81 mPsetCallDivertingMock = NULL; |
|
82 } |
|
83 |
|
84 /*! |
|
85 UT_PSetCallDivertingWrapper::init |
|
86 */ |
|
87 void UT_PSetCallDivertingWrapper::init() |
|
88 { |
|
89 initialize(); |
|
90 CPhCltEmergencyCallMock::iSimulateEmergencyNumberMatch = false; |
|
91 |
|
92 mSetContainerMock = new CPsetContainer(); |
|
93 |
|
94 RMobilePhone dummyHandle; |
|
95 DivertObserver dummyObsever; |
|
96 QT_TRAP_THROWING(mPsetCallDivertingMock |
|
97 = CPsetCallDiverting::NewL(dummyObsever, dummyHandle)); |
|
98 expect("CPsetContainer::CreateCFObjectL").returns(mPsetCallDivertingMock); |
|
99 |
|
100 // Wrapper takes ownership of callDivertingMock during construction. |
|
101 // Mock must be deleted here if exception happens during construction. |
|
102 QScopedPointer<CPsetCallDiverting> divertingMockPtr(mPsetCallDivertingMock); |
|
103 mWrapper = new PSetCallDivertingWrapper(*mSetContainerMock, NULL); |
|
104 divertingMockPtr.take(); |
|
105 } |
|
106 |
|
107 /*! |
|
108 UT_PSetCallDivertingWrapper::cleanup |
|
109 */ |
|
110 void UT_PSetCallDivertingWrapper::cleanup() |
|
111 { |
|
112 reset(); |
|
113 |
|
114 delete mWrapper; |
|
115 mWrapper = NULL; |
|
116 delete mSetContainerMock; |
|
117 mSetContainerMock = NULL; |
|
118 mPsetCallDivertingMock = NULL; |
|
119 } |
|
120 |
|
121 /*! |
|
122 UT_PSetCallDivertingWrapper::t_construction |
|
123 */ |
|
124 void UT_PSetCallDivertingWrapper::t_construction() |
|
125 { |
|
126 if (qstrcmp(QTest::currentTestFunction(), "t_exceptionSafety") != 0) { |
|
127 |
|
128 expect("CPsetContainer::CreateCFObjectL"). |
|
129 willOnce(invokeWithoutArguments(SimulateLeaveL)); |
|
130 PSetCallDivertingWrapper *wrapper = NULL; |
|
131 EXPECT_EXCEPTION( |
|
132 wrapper = new PSetCallDivertingWrapper(*mSetContainerMock, NULL); |
|
133 delete wrapper; |
|
134 wrapper = NULL; |
|
135 ) |
|
136 QVERIFY(verify()); |
|
137 |
|
138 expect("CPhCltEmergencyCallMock::NewL"). |
|
139 willOnce(invokeWithoutArguments(SimulateLeaveL)); |
|
140 EXPECT_EXCEPTION( |
|
141 wrapper = new PSetCallDivertingWrapper(*mSetContainerMock, NULL); |
|
142 delete wrapper; |
|
143 wrapper = NULL; |
|
144 ) |
|
145 QVERIFY(verify()); |
|
146 } |
|
147 } |
|
148 |
|
149 /*! |
|
150 UT_PSetCallDivertingWrapper::t_setCallDivertingWithValidParameters |
|
151 */ |
|
152 void UT_PSetCallDivertingWrapper::t_setCallDivertingWithValidParameters() |
|
153 { |
|
154 PSCallDivertingCommand divertingCmd; |
|
155 divertingCmd.iCondition = DivertConditionUnconditional; |
|
156 divertingCmd.iSetting = RegisterDiverting; |
|
157 divertingCmd.iStatus = DivertingStatusUnknown; |
|
158 divertingCmd.iServiceGroup = ServiceGroupVoice; |
|
159 divertingCmd.iNumber = "1234567890"; |
|
160 divertingCmd.iNoReplyTimer = 0; |
|
161 |
|
162 TCallDivertSetting expectedParam; |
|
163 expectedParam.iCondition = EDivertConditionUnconditional; |
|
164 expectedParam.iSetting = ERegisterDiverting; |
|
165 expectedParam.iStatus = EDivertingStatusUnknown; |
|
166 expectedParam.iServiceGroup = EServiceGroupVoice; |
|
167 expectedParam.iNumber |
|
168 = TPtrC16(reinterpret_cast<const TUint16*>(divertingCmd.iNumber.utf16())); |
|
169 expectedParam.iNoReplyTimer |
|
170 = static_cast<TInt>(divertingCmd.iNoReplyTimer); |
|
171 TBool isVmbx = EFalse; |
|
172 expect("CPsetCallDiverting::SetDivertingL"). |
|
173 with(expectedParam, ETelephony, isVmbx); |
|
174 |
|
175 mWrapper->setCallDiverting(divertingCmd, ETelephony); |
|
176 |
|
177 QVERIFY(true == verify()); |
|
178 } |
|
179 |
|
180 /*! |
|
181 UT_PSetCallDivertingWrapper::t_setCallDivertingWithInvalidNumber |
|
182 */ |
|
183 void UT_PSetCallDivertingWrapper::t_setCallDivertingWithInvalidNumber() |
|
184 { |
|
185 PSCallDivertingCommand divertingCmd; |
|
186 divertingCmd.iCondition = DivertConditionUnconditional; |
|
187 divertingCmd.iSetting = RegisterDiverting; |
|
188 divertingCmd.iStatus = DivertingStatusUnknown; |
|
189 divertingCmd.iServiceGroup = ServiceGroupVoice; |
|
190 divertingCmd.iNoReplyTimer = 0; |
|
191 |
|
192 expect("CPsetCallDiverting::SetDivertingL").times(0); |
|
193 |
|
194 // DTMF digits "*#pw" are not allowed characters |
|
195 divertingCmd.iNumber = "*"; |
|
196 int result = mWrapper->setCallDiverting(divertingCmd, ETelephony); |
|
197 QVERIFY(result == KErrGsmSSUnknownAlphabet); |
|
198 divertingCmd.iNumber = "#"; |
|
199 result = mWrapper->setCallDiverting(divertingCmd, ETelephony); |
|
200 QVERIFY(result == KErrGsmSSUnknownAlphabet); |
|
201 divertingCmd.iNumber = "p"; |
|
202 result = mWrapper->setCallDiverting(divertingCmd, ETelephony); |
|
203 QVERIFY(result == KErrGsmSSUnknownAlphabet); |
|
204 divertingCmd.iNumber = "w"; |
|
205 result = mWrapper->setCallDiverting(divertingCmd, ETelephony); |
|
206 QVERIFY(result == KErrGsmSSUnknownAlphabet); |
|
207 |
|
208 // plus allowed only in the beginning of the number |
|
209 divertingCmd.iNumber = "++"; |
|
210 result = mWrapper->setCallDiverting(divertingCmd, ETelephony); |
|
211 QVERIFY(result == KErrGsmSSUnknownAlphabet); |
|
212 |
|
213 QVERIFY(true == verify()); |
|
214 } |
|
215 |
|
216 /*! |
|
217 UT_PSetCallDivertingWrapper::t_setCallDivertingWithEmergencyNumber |
|
218 */ |
|
219 void UT_PSetCallDivertingWrapper::t_setCallDivertingWithEmergencyNumber() |
|
220 { |
|
221 PSCallDivertingCommand divertingCmd; |
|
222 divertingCmd.iCondition = DivertConditionUnconditional; |
|
223 divertingCmd.iSetting = RegisterDiverting; |
|
224 divertingCmd.iStatus = DivertingStatusUnknown; |
|
225 divertingCmd.iServiceGroup = ServiceGroupVoice; |
|
226 divertingCmd.iNumber = "112"; |
|
227 divertingCmd.iNoReplyTimer = 0; |
|
228 |
|
229 expect("CPsetCallDiverting::SetDivertingL").times(0); |
|
230 CPhCltEmergencyCallMock::iSimulateEmergencyNumberMatch = ETrue; |
|
231 expect("CPhCltEmergencyCallMock::IsEmergencyPhoneNumber").returns(KErrNone); |
|
232 |
|
233 int result = mWrapper->setCallDiverting(divertingCmd, ETelephony); |
|
234 QVERIFY(result == KErrGsmSSIllegalOperation); |
|
235 |
|
236 QVERIFY(true == verify()); |
|
237 } |
|
238 |
|
239 /*! |
|
240 UT_PSetCallDivertingWrapper::t_setCallDivertingException |
|
241 */ |
|
242 void UT_PSetCallDivertingWrapper::t_setCallDivertingException() |
|
243 { |
|
244 PSCallDivertingCommand divertingCmd; |
|
245 divertingCmd.iCondition = DivertConditionUnconditional; |
|
246 divertingCmd.iSetting = RegisterDiverting; |
|
247 divertingCmd.iStatus = DivertingStatusUnknown; |
|
248 divertingCmd.iServiceGroup = ServiceGroupVoice; |
|
249 divertingCmd.iNumber = "1234567890"; |
|
250 divertingCmd.iNoReplyTimer = 0; |
|
251 |
|
252 expect("CPsetCallDiverting::SetDivertingL"). |
|
253 willOnce(invokeWithoutArguments(this, &simulateLeaveOnMockMethodCallL)); |
|
254 |
|
255 EXPECT_EXCEPTION( |
|
256 mWrapper->setCallDiverting(divertingCmd, ETelephony); |
|
257 ) |
|
258 |
|
259 QVERIFY(true == verify()); |
|
260 } |
|
261 |
|
262 /*! |
|
263 UT_PSetCallDivertingWrapper::t_getCallDivertingStatus |
|
264 */ |
|
265 void UT_PSetCallDivertingWrapper::t_getCallDivertingStatus() |
|
266 { |
|
267 expect("CPsetCallDiverting::GetDivertingStatusL"). |
|
268 with(EServiceGroupVoice, EDivertConditionUnconditional, ETelephony); |
|
269 |
|
270 mWrapper->getCallDivertingStatus( |
|
271 ServiceGroupVoice, DivertConditionUnconditional, ETelephony); |
|
272 |
|
273 QVERIFY(true == verify()); |
|
274 } |
|
275 |
|
276 /*! |
|
277 UT_PSetCallDivertingWrapper::t_getCallDivertingStatusException |
|
278 */ |
|
279 void UT_PSetCallDivertingWrapper::t_getCallDivertingStatusException() |
|
280 { |
|
281 expect("CPsetCallDiverting::GetDivertingStatusL"). |
|
282 with(EServiceGroupVoice, EDivertConditionUnconditional, ETelephony). |
|
283 willOnce(invokeWithoutArguments(this, &simulateLeaveOnMockMethodCallL)); |
|
284 |
|
285 EXPECT_EXCEPTION( |
|
286 mWrapper->getCallDivertingStatus( |
|
287 ServiceGroupVoice, DivertConditionUnconditional, ETelephony); |
|
288 ) |
|
289 |
|
290 QVERIFY(true == verify()); |
|
291 } |
|
292 |
|
293 /*! |
|
294 UT_PSetCallDivertingWrapper::t_cancelProcess |
|
295 */ |
|
296 void UT_PSetCallDivertingWrapper::t_cancelProcess() |
|
297 { |
|
298 expect("CPsetCallDiverting::CancelCurrentRequest"); |
|
299 |
|
300 mWrapper->cancelProcess(); |
|
301 |
|
302 QVERIFY(true == verify()); |
|
303 } |
|
304 |
|
305 /*! |
|
306 UT_PSetCallDivertingWrapper::t_getDefaultNumbers |
|
307 */ |
|
308 void UT_PSetCallDivertingWrapper::t_getDefaultNumbers() |
|
309 { |
|
310 expect("CPsetCallDiverting::GetDefaultNumbersL").times(1); |
|
311 |
|
312 QStringList defNumbers; |
|
313 mWrapper->getDefaultNumbers(defNumbers); |
|
314 |
|
315 // 2 numbers added in mock_psetcalldiverting.cpp |
|
316 QVERIFY(2 == defNumbers.count()); |
|
317 QVERIFY(true == verify()); |
|
318 } |
|
319 |
|
320 /*! |
|
321 UT_PSetCallDivertingWrapper::t_getDefaultNumbersException |
|
322 */ |
|
323 void UT_PSetCallDivertingWrapper::t_getDefaultNumbersException() |
|
324 { |
|
325 expect("CPsetCallDiverting::GetDefaultNumbersL"). |
|
326 willOnce(invokeWithoutArguments(this, &simulateLeaveOnMockMethodCallL)); |
|
327 |
|
328 QStringList defNumbers; |
|
329 EXPECT_EXCEPTION( |
|
330 mWrapper->getDefaultNumbers(defNumbers); |
|
331 ) |
|
332 |
|
333 QVERIFY(true == verify()); |
|
334 } |
|
335 |
|
336 /*! |
|
337 UT_PSetCallDivertingWrapper::t_setNewDefaultNumber |
|
338 */ |
|
339 void UT_PSetCallDivertingWrapper::t_setNewDefaultNumber() |
|
340 { |
|
341 expect("CPsetCallDiverting::SetNewDefaultNumberL").times(1); |
|
342 expect("CPsetCallDiverting::SwapDefaultNumberL").times(0); |
|
343 |
|
344 // number not added in mock_psetcalldiverting.cpp |
|
345 QString defNumber = "444444"; |
|
346 mWrapper->setNewDefaultNumber(defNumber); |
|
347 |
|
348 expect("CPsetCallDiverting::GetDefaultNumbersL") |
|
349 .willOnce(invoke(SimulateLeaveL)); |
|
350 EXPECT_EXCEPTION( |
|
351 mWrapper->setNewDefaultNumber(defNumber); |
|
352 ) |
|
353 |
|
354 QVERIFY(true == verify()); |
|
355 } |
|
356 |
|
357 /*! |
|
358 UT_PSetCallDivertingWrapper::t_getVoiceMailBoxNumber |
|
359 */ |
|
360 void UT_PSetCallDivertingWrapper::t_getVoiceMailBoxNumber() |
|
361 { |
|
362 // Fail case #1, illegal argument |
|
363 QString defNumber; |
|
364 int ret; |
|
365 |
|
366 expect("CVoiceMailbox::GetStoredEntry").returns(-2).times(1); |
|
367 ret = mWrapper->getVoiceMailBoxNumber(defNumber, ServiceGroupVoice); |
|
368 QCOMPARE(ret, 0); |
|
369 |
|
370 // Fail case #2, Not supported. |
|
371 expect("CVoiceMailbox::GetStoredEntry").returns(-5).times(1); |
|
372 ret = mWrapper->getVoiceMailBoxNumber(defNumber, ServiceGroupVoice); |
|
373 QCOMPARE(ret, -1); |
|
374 |
|
375 // Fail case #3, number nok |
|
376 expect("CVoiceMailbox::GetStoredEntry").times(1); |
|
377 expect("CVoiceMailboxEntry::GetVmbxNumber").returns(-1).times(1); |
|
378 ret = mWrapper->getVoiceMailBoxNumber(defNumber, ServiceGroupVoice); |
|
379 QCOMPARE(ret, 0); |
|
380 |
|
381 // ok case#1, number and save ok but no new number. |
|
382 expect("CVoiceMailbox::GetStoredEntry").returns(-1).times(1); |
|
383 ret = mWrapper->getVoiceMailBoxNumber(defNumber, ServiceGroupData); |
|
384 QCOMPARE(ret, 0); |
|
385 |
|
386 // ok case#2, number ok |
|
387 expect("CVoiceMailbox::GetStoredEntry").times(1); |
|
388 expect("CVoiceMailboxEntry::GetVmbxNumber").times(1); |
|
389 ret = mWrapper->getVoiceMailBoxNumber(defNumber, ServiceGroupVoice); |
|
390 QCOMPARE(ret, 0); |
|
391 |
|
392 expect("CVoiceMailbox::NewL") |
|
393 .willOnce(invoke(SimulateLeaveL)); |
|
394 EXPECT_EXCEPTION( |
|
395 mWrapper->getVoiceMailBoxNumber(defNumber, ServiceGroupFax); |
|
396 ) |
|
397 |
|
398 QVERIFY(true == verify()); |
|
399 } |
|
400 |
|
401 /*! |
|
402 UT_PSetCallDivertingWrapper::t_queryVoiceMailBoxNumber |
|
403 */ |
|
404 void UT_PSetCallDivertingWrapper::t_queryVoiceMailBoxNumber() |
|
405 { |
|
406 // Fail case #1, illegal argument |
|
407 QString defNumber; |
|
408 int ret; |
|
409 expect("CVoiceMailbox::GetStoredEntry").returns(-2).times(1); |
|
410 ret = mWrapper->queryVoiceMailBoxNumber(defNumber, ServiceGroupVoice); |
|
411 QCOMPARE(ret, 0); |
|
412 |
|
413 // Fail case #2, Not supported. |
|
414 expect("CVoiceMailbox::GetStoredEntry").returns(-5).times(1); |
|
415 ret = mWrapper->queryVoiceMailBoxNumber(defNumber, ServiceGroupVoice); |
|
416 QCOMPARE(ret, -1); |
|
417 |
|
418 // Fail case #3, New number not given. |
|
419 expect("CVoiceMailbox::GetStoredEntry").times(1); |
|
420 expect("CVoiceMailbox::QueryNewEntry").returns(-5).times(1); |
|
421 ret = mWrapper->queryVoiceMailBoxNumber(defNumber, ServiceGroupVoice); |
|
422 QCOMPARE(ret, 0); |
|
423 |
|
424 // Fail case #4, save nok |
|
425 expect("CVoiceMailbox::GetStoredEntry").returns(-1).times(1); |
|
426 expect("CVoiceMailbox::QueryNewEntry").times(1); |
|
427 expect("CVoiceMailbox::SaveEntry").returns(-4).times(1); |
|
428 ret = mWrapper->queryVoiceMailBoxNumber(defNumber, ServiceGroupData); |
|
429 QCOMPARE(ret, 0); |
|
430 |
|
431 // ok case#1, number and save ok but no new number. |
|
432 expect("CVoiceMailbox::GetStoredEntry").returns(-1).times(1); |
|
433 expect("CVoiceMailbox::QueryNewEntry").times(1); |
|
434 expect("CVoiceMailbox::SaveEntry").times(1); |
|
435 expect("CVoiceMailboxEntry::GetVmbxNumber").returns(-5).times(1); |
|
436 ret = mWrapper->queryVoiceMailBoxNumber(defNumber, ServiceGroupVoice); |
|
437 QCOMPARE(ret, 0); |
|
438 |
|
439 // ok case#2, number ok |
|
440 expect("CVoiceMailbox::GetStoredEntry").times(1); |
|
441 expect("CVoiceMailbox::QueryNewEntry").times(1); |
|
442 expect("CVoiceMailbox::SaveEntry").times(1); |
|
443 expect("CVoiceMailboxEntry::GetVmbxNumber").times(1); |
|
444 ret = mWrapper->queryVoiceMailBoxNumber(defNumber, ServiceGroupVoice); |
|
445 QCOMPARE(ret, 0); |
|
446 |
|
447 expect("CVoiceMailbox::NewL") |
|
448 .willOnce(invoke(SimulateLeaveL)); |
|
449 EXPECT_EXCEPTION( |
|
450 mWrapper->queryVoiceMailBoxNumber(defNumber, ServiceGroupFax); |
|
451 ) |
|
452 |
|
453 QVERIFY(true == verify()); |
|
454 } |
|
455 |
|
456 /*! |
|
457 UT_PSetCallDivertingWrapper::t_swapDefaultNumber |
|
458 */ |
|
459 void UT_PSetCallDivertingWrapper::t_swapDefaultNumber() |
|
460 { |
|
461 expect("CPsetCallDiverting::SetNewDefaultNumberL").times(0); |
|
462 expect("CPsetCallDiverting::SwapDefaultNumberL").times(1); |
|
463 |
|
464 // same number added in mock_psetcalldiverting.cpp |
|
465 QString defNumber = "222222"; |
|
466 mWrapper->setNewDefaultNumber(defNumber); |
|
467 |
|
468 QVERIFY(true == verify()); |
|
469 } |
|
470 |
|
471 |
|
472 Q_DECLARE_METATYPE(PSCallDivertingCommand) |
|
473 /*! |
|
474 UT_PSetCallDivertingWrapper::t_handleDivertingChanged |
|
475 */ |
|
476 void UT_PSetCallDivertingWrapper::t_handleDivertingChanged() |
|
477 { |
|
478 qRegisterMetaType<PSCallDivertingCommand>("PSCallDivertingCommand"); |
|
479 QSignalSpy spy(mWrapper, |
|
480 SIGNAL(handleDivertingChanged(const PSCallDivertingCommand&, bool))); |
|
481 |
|
482 TCallDivertSetting setting; |
|
483 setting.iCondition = EDivertConditionUnconditional; |
|
484 setting.iSetting = EActivateDiverting; |
|
485 setting.iStatus = EDivertingStatusUnknown; |
|
486 setting.iServiceGroup = EServiceGroupAllTeleservices; |
|
487 setting.iNumber = KNullDesC(); |
|
488 TBool plural = ETrue; |
|
489 QT_TRAP_THROWING( |
|
490 mWrapper->m_Priv->HandleDivertingChangedL(setting, plural)); |
|
491 |
|
492 setting.iCondition = EDivertConditionBusy; |
|
493 setting.iStatus = EDivertingStatusActive; |
|
494 setting.iServiceGroup = EServiceGroupVoice; |
|
495 QT_TRAP_THROWING( |
|
496 mWrapper->m_Priv->HandleDivertingChangedL(setting, plural)); |
|
497 setting.iCondition = EDivertConditionNoReply; |
|
498 setting.iStatus = EDivertingStatusInactive; |
|
499 setting.iServiceGroup = EServiceGroupData; |
|
500 QT_TRAP_THROWING( |
|
501 mWrapper->m_Priv->HandleDivertingChangedL(setting, plural)); |
|
502 setting.iCondition = EDivertConditionNotReachable; |
|
503 setting.iStatus = EDivertingStatusNotRegistered; |
|
504 setting.iServiceGroup = EServiceGroupFax; |
|
505 QT_TRAP_THROWING( |
|
506 mWrapper->m_Priv->HandleDivertingChangedL(setting, plural)); |
|
507 setting.iCondition = EDivertConditionAllCalls; |
|
508 setting.iStatus = EDivertingStatusNotProvisioned; |
|
509 setting.iServiceGroup = EServiceGroupFax; |
|
510 QT_TRAP_THROWING( |
|
511 mWrapper->m_Priv->HandleDivertingChangedL(setting, plural)); |
|
512 setting.iCondition = EDivertConditionAllConditionalCases; |
|
513 QT_TRAP_THROWING( |
|
514 mWrapper->m_Priv->HandleDivertingChangedL(setting, plural)); |
|
515 |
|
516 QCOMPARE(spy.count(), 6); |
|
517 PSCallDivertingCommand actualCmd = |
|
518 qvariant_cast<PSCallDivertingCommand>(spy.at(0).at(0)); |
|
519 QVERIFY(actualCmd.iCondition == DivertConditionUnconditional); |
|
520 QVERIFY(actualCmd.iSetting == ActivateDiverting); |
|
521 QVERIFY(actualCmd.iStatus == DivertingStatusUnknown); |
|
522 QVERIFY(actualCmd.iServiceGroup == ServiceGroupAllTeleservices); |
|
523 QVERIFY(actualCmd.iNumber == QString::fromUtf16(setting.iNumber.Ptr(), |
|
524 setting.iNumber.Length())); |
|
525 QVERIFY(spy.at(0).at(1).toBool() == true); |
|
526 |
|
527 actualCmd = qvariant_cast<PSCallDivertingCommand>(spy.at(1).at(0)); |
|
528 QVERIFY(actualCmd.iCondition == DivertConditionBusy); |
|
529 QVERIFY(actualCmd.iStatus == DivertingStatusActive); |
|
530 QVERIFY(actualCmd.iServiceGroup == ServiceGroupVoice); |
|
531 actualCmd = qvariant_cast<PSCallDivertingCommand>(spy.at(2).at(0)); |
|
532 QVERIFY(actualCmd.iCondition == DivertConditionNoReply); |
|
533 QVERIFY(actualCmd.iStatus == DivertingStatusInactive); |
|
534 QVERIFY(actualCmd.iServiceGroup == ServiceGroupData); |
|
535 actualCmd = qvariant_cast<PSCallDivertingCommand>(spy.at(3).at(0)); |
|
536 QVERIFY(actualCmd.iCondition == DivertConditionNotReachable); |
|
537 QVERIFY(actualCmd.iStatus == DivertingStatusNotRegistered); |
|
538 QVERIFY(actualCmd.iServiceGroup == ServiceGroupFax); |
|
539 actualCmd = qvariant_cast<PSCallDivertingCommand>(spy.at(4).at(0)); |
|
540 QVERIFY(actualCmd.iCondition == DivertConditionAllCalls); |
|
541 QVERIFY(actualCmd.iStatus == DivertingStatusNotProvisioned); |
|
542 QVERIFY(actualCmd.iServiceGroup == ServiceGroupFax); |
|
543 actualCmd = qvariant_cast<PSCallDivertingCommand>(spy.at(5).at(0)); |
|
544 QVERIFY(actualCmd.iCondition == DivertConditionAllConditionalCases); |
|
545 |
|
546 QVERIFY(true == verify()); |
|
547 } |
|
548 |
|
549 |
|
550 /*! |
|
551 UT_PSetCallDivertingWrapper::t_handleDivertingStatus |
|
552 */ |
|
553 void UT_PSetCallDivertingWrapper::t_handleDivertingStatus() |
|
554 { |
|
555 qRegisterMetaType<QList<PSCallDivertingStatus*> >("QList<PSCallDivertingStatus*>&"); |
|
556 QSignalSpy spy(mWrapper, |
|
557 SIGNAL(handleDivertingStatus(QList<PSCallDivertingStatus*>&, bool))); |
|
558 |
|
559 // With empty list |
|
560 CMobilePhoneCFList* cfList = NULL; |
|
561 QT_TRAP_THROWING(cfList = CMobilePhoneCFList::NewL()); |
|
562 QScopedPointer<CMobilePhoneCFList> cfListDeleter(cfList); |
|
563 TBool plural = ETrue; |
|
564 QT_TRAP_THROWING( |
|
565 mWrapper->m_Priv->HandleDivertingStatusL(*cfList, plural)); |
|
566 |
|
567 QCOMPARE(spy.count(), 1); |
|
568 QVERIFY(spy.at(0).at(1).toBool() == true); |
|
569 spy.clear(); |
|
570 |
|
571 // With list entry |
|
572 RMobilePhone::TMobilePhoneCFInfoEntryV1 entry; |
|
573 entry.iStatus = RMobilePhone::ECallForwardingStatusNotProvisioned; |
|
574 entry.iCondition = RMobilePhone::ECallForwardingAllConditionalCases; |
|
575 cfList->AddEntryL(entry); |
|
576 QT_TRAP_THROWING( |
|
577 mWrapper->m_Priv->HandleDivertingStatusL(*cfList, plural)); |
|
578 |
|
579 QCOMPARE(spy.count(), 1); |
|
580 QList<PSCallDivertingStatus*> result = |
|
581 *reinterpret_cast<const QList<PSCallDivertingStatus*> *>(spy.at(0).at(0).constData()); |
|
582 |
|
583 QVERIFY(result.at(0)->iStatus == DivertingStatusNotProvisioned); |
|
584 QVERIFY(result.at(0)->iCondition == DivertConditionAllConditionalCases); |
|
585 QVERIFY(spy.at(0).at(1).toBool() == true); |
|
586 spy.clear(); |
|
587 |
|
588 // With list, two entries |
|
589 delete cfList; |
|
590 QT_TRAP_THROWING(cfList = CMobilePhoneCFList::NewL()); |
|
591 entry.iStatus = RMobilePhone::ECallForwardingStatusNotActive; |
|
592 entry.iCondition = RMobilePhone::ECallForwardingBusy; |
|
593 cfList->AddEntryL(entry); // Takes copy |
|
594 |
|
595 RMobilePhone::TMobilePhoneCFInfoEntryV1 entry2; |
|
596 entry2.iStatus = RMobilePhone::ECallForwardingStatusActive; |
|
597 entry2.iCondition = RMobilePhone::ECallForwardingUnconditional; |
|
598 cfList->AddEntryL(entry2); |
|
599 QT_TRAP_THROWING( |
|
600 mWrapper->m_Priv->HandleDivertingStatusL(*cfList, plural)); |
|
601 |
|
602 QCOMPARE(spy.count(), 1); |
|
603 result = *reinterpret_cast<const QList<PSCallDivertingStatus*> *>(spy.at(0).at(0).constData()); |
|
604 QVERIFY(result.at(0)->iStatus == DivertingStatusInactive); |
|
605 QVERIFY(result.at(0)->iCondition == DivertConditionBusy); |
|
606 |
|
607 QVERIFY(result.at(1)->iStatus == DivertingStatusActive); |
|
608 QVERIFY(result.at(1)->iCondition == DivertConditionUnconditional); |
|
609 QVERIFY(spy.at(0).at(1).toBool() == true); |
|
610 spy.clear(); |
|
611 } |
|
612 |
|
613 /*! |
|
614 UT_PSetCallDivertingWrapper::t_handleDivertingError |
|
615 */ |
|
616 void UT_PSetCallDivertingWrapper::t_handleDivertingError() |
|
617 { |
|
618 QSignalSpy spy(mWrapper, SIGNAL(handleDivertingError(int))); |
|
619 |
|
620 QT_TRAP_THROWING(mWrapper->m_Priv->HandleDivertingErrorL(KErrGeneral)); |
|
621 |
|
622 QCOMPARE(spy.count(), 1); |
|
623 QVERIFY(spy.at(0).at(0).toInt() == KErrGeneral); |
|
624 } |
|
625 |
|
626 /*! |
|
627 UT_PSetCallDivertingWrapper::t_handleCFRequesting |
|
628 */ |
|
629 void UT_PSetCallDivertingWrapper::t_handleCFRequesting() |
|
630 { |
|
631 QSignalSpy spy(mWrapper, SIGNAL(handleCFRequesting(bool, bool))); |
|
632 |
|
633 TBool ongoing = ETrue; |
|
634 TBool interrupted = ETrue; |
|
635 QT_TRAP_THROWING( |
|
636 mWrapper->m_Priv->HandleCFRequestingL(ongoing, interrupted)); |
|
637 |
|
638 QCOMPARE(spy.count(), 1); |
|
639 QVERIFY(spy.at(0).at(0).toBool() == true); |
|
640 QVERIFY(spy.at(0).at(1).toBool() == true); |
|
641 } |
|
642 |
|
643 /*! |
|
644 UT_PSetCallDivertingWrapper::t_setEngineContact |
|
645 TODO: dummy test because no implementation for the method currently. |
|
646 */ |
|
647 void UT_PSetCallDivertingWrapper::t_setEngineContact() |
|
648 { |
|
649 mWrapper->m_Priv->SetEngineContact(mPsetCallDivertingMock); |
|
650 } |
|
651 |
|
652 /*! |
|
653 UT_PSetCallDivertingWrapper::t_handleEmergencyDial |
|
654 TODO: dummy test because no implementation for the method currently. |
|
655 */ |
|
656 void UT_PSetCallDivertingWrapper::t_handleEmergencyDial() |
|
657 { |
|
658 QT_TRAP_THROWING(mWrapper->m_Priv->HandleEmergencyDialL(KErrNone)); |
|
659 } |
|
660 |
|
661 /*! |
|
662 UT_PSetCallDivertingWrapper::t_convertPsCallDivertingCondition |
|
663 */ |
|
664 void UT_PSetCallDivertingWrapper::t_convertPsCallDivertingCondition() |
|
665 { |
|
666 QVERIFY(EDivertConditionUnconditional == |
|
667 mWrapper->m_Priv->convert(DivertConditionUnknown)); |
|
668 QVERIFY(EDivertConditionUnconditional == |
|
669 mWrapper->m_Priv->convert(DivertConditionUnconditional)); |
|
670 QVERIFY(EDivertConditionBusy == |
|
671 mWrapper->m_Priv->convert(DivertConditionBusy)); |
|
672 QVERIFY(EDivertConditionNoReply == |
|
673 mWrapper->m_Priv->convert(DivertConditionNoReply)); |
|
674 QVERIFY(EDivertConditionNotReachable == |
|
675 mWrapper->m_Priv->convert(DivertConditionNotReachable)); |
|
676 QVERIFY(EDivertConditionAllCalls == |
|
677 mWrapper->m_Priv->convert(DivertConditionAllCalls)); |
|
678 QVERIFY(EDivertConditionAllConditionalCases == |
|
679 mWrapper->m_Priv->convert(DivertConditionAllConditionalCases)); |
|
680 } |
|
681 |
|
682 /*! |
|
683 UT_PSetCallDivertingWrapper::t_convertPsCallDivertingStatus |
|
684 */ |
|
685 void UT_PSetCallDivertingWrapper::t_convertPsCallDivertingStatus() |
|
686 { |
|
687 QVERIFY(EDivertingStatusActive == |
|
688 mWrapper->m_Priv->convert(DivertingStatusActive)); |
|
689 QVERIFY(EDivertingStatusInactive == |
|
690 mWrapper->m_Priv->convert(DivertingStatusInactive)); |
|
691 QVERIFY(EDivertingStatusNotRegistered == |
|
692 mWrapper->m_Priv->convert(DivertingStatusNotRegistered)); |
|
693 QVERIFY(EDivertingStatusNotProvisioned == |
|
694 mWrapper->m_Priv->convert(DivertingStatusNotProvisioned)); |
|
695 } |
|
696 |
|
697 /*! |
|
698 UT_PSetCallDivertingWrapper::t_convertPsCallDivertingSetting |
|
699 */ |
|
700 void UT_PSetCallDivertingWrapper::t_convertPsCallDivertingSetting() |
|
701 { |
|
702 QVERIFY(EActivateDiverting == |
|
703 mWrapper->m_Priv->convert(ActivateDiverting)); |
|
704 QVERIFY(ECancelDiverting == |
|
705 mWrapper->m_Priv->convert(CancelDiverting)); |
|
706 QVERIFY(ERegisterDiverting == |
|
707 mWrapper->m_Priv->convert(RegisterDiverting)); |
|
708 QVERIFY(EEraseDiverting == |
|
709 mWrapper->m_Priv->convert(EraseDiverting)); |
|
710 QVERIFY(ECheckStatus == |
|
711 mWrapper->m_Priv->convert(CheckStatus)); |
|
712 const int invalidEnumeration = -1; |
|
713 QVERIFY(ECheckStatus == mWrapper->m_Priv->convert( |
|
714 static_cast<PsCallDivertingSetting>(invalidEnumeration))); |
|
715 } |
|
716 |
|
717 /*! |
|
718 UT_PSetCallDivertingWrapper::t_exceptionSafety |
|
719 */ |
|
720 void UT_PSetCallDivertingWrapper::t_exceptionSafety() |
|
721 { |
|
722 cleanup(); |
|
723 |
|
724 OomTestExecuter::runAllTests(*this, "t_exceptionSafety"); |
|
725 } |
|
726 |
|
727 /*! |
|
728 UT_PSetCallDivertingWrapper::simulateLeaveOnMockMethodCallL |
|
729 */ |
|
730 void UT_PSetCallDivertingWrapper::simulateLeaveOnMockMethodCallL() |
|
731 { |
|
732 User::Leave(KErrGeneral); |
|
733 } |
|
734 |
|
735 QTEST_MAIN_S60(UT_PSetCallDivertingWrapper) |
|