|
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 <HbDataFormModel> |
|
19 #include <HbCheckBox> |
|
20 #include <psetwrapper.h> |
|
21 #include "ut_barringplugingroup.h" |
|
22 #include "qtestmains60.h" |
|
23 #include "cpitemdatahelper.h" |
|
24 #include "cpphonenotes.h" |
|
25 #define private friend class UT_CpBarringPluginGroup; private |
|
26 #include "cpbarringplugingroup.h" |
|
27 |
|
28 void setNoteIdentifier(int ¬eId, const QString& text) |
|
29 { |
|
30 Q_UNUSED(text) |
|
31 |
|
32 noteId = 1; |
|
33 } |
|
34 |
|
35 |
|
36 const QString KCurrentPassword = "1234"; |
|
37 void setCurrentPasswordParams( |
|
38 const QString &title, |
|
39 const QValidator &validator, |
|
40 int maxPasswordLength, |
|
41 QString &password, |
|
42 bool &ok) |
|
43 { |
|
44 Q_UNUSED(title) |
|
45 Q_UNUSED(validator) |
|
46 Q_UNUSED(maxPasswordLength) |
|
47 |
|
48 password = KCurrentPassword; |
|
49 ok = true; |
|
50 } |
|
51 |
|
52 |
|
53 const QString KNewAndVerifiedPassword = "4321"; |
|
54 void setNewAndVerifiedPasswordParams( |
|
55 const QString &title, |
|
56 const QValidator &validator, |
|
57 int maxPasswordLength, |
|
58 QString &password, |
|
59 bool &ok) |
|
60 { |
|
61 Q_UNUSED(title) |
|
62 Q_UNUSED(validator) |
|
63 Q_UNUSED(maxPasswordLength) |
|
64 |
|
65 password = KNewAndVerifiedPassword; |
|
66 ok = true; |
|
67 } |
|
68 |
|
69 |
|
70 void setPasswordParamsCancel( |
|
71 const QString &title, |
|
72 const QValidator &validator, |
|
73 int maxPasswordLength, |
|
74 QString &password, |
|
75 bool &ok) |
|
76 { |
|
77 Q_UNUSED(title) |
|
78 Q_UNUSED(validator) |
|
79 Q_UNUSED(maxPasswordLength) |
|
80 Q_UNUSED(password) |
|
81 |
|
82 ok = false; |
|
83 } |
|
84 |
|
85 |
|
86 /*! |
|
87 UT_CpBarringPluginGroup::UT_CpBarringPluginGroup |
|
88 */ |
|
89 UT_CpBarringPluginGroup::UT_CpBarringPluginGroup() |
|
90 : |
|
91 m_barringpluginGroup(NULL), |
|
92 m_barringWrapperMock(NULL), |
|
93 m_dataFormModel(NULL) |
|
94 { |
|
95 |
|
96 } |
|
97 |
|
98 |
|
99 /*! |
|
100 UT_CpBarringPluginGroup::~UT_CpBarringPluginGroup |
|
101 */ |
|
102 UT_CpBarringPluginGroup::~UT_CpBarringPluginGroup() |
|
103 { |
|
104 delete m_barringpluginGroup; |
|
105 delete m_barringWrapperMock; |
|
106 } |
|
107 |
|
108 |
|
109 /*! |
|
110 UT_CpBarringPluginGroup::init |
|
111 */ |
|
112 void UT_CpBarringPluginGroup::init() |
|
113 { |
|
114 initialize(); |
|
115 QT_TRAP_THROWING(SmcDefaultValue<QString>::SetL(QString(""))); |
|
116 |
|
117 CPsetContainer &dummyContainer = reinterpret_cast<CPsetContainer &>(*this); |
|
118 m_barringWrapperMock = new PSetCallBarringWrapper(dummyContainer); |
|
119 EXPECT(PSetWrapper::callBarringWrapper).returns(m_barringWrapperMock); |
|
120 |
|
121 CpItemDataHelper itemDataHelper; |
|
122 m_barringpluginGroup = new CpBarringPluginGroup(itemDataHelper); |
|
123 |
|
124 m_dataFormModel = new HbDataFormModel(); |
|
125 m_barringpluginGroup->setModel(m_dataFormModel); |
|
126 |
|
127 QVERIFY(verify()); |
|
128 |
|
129 connect( |
|
130 this, SIGNAL(simulateCheckStateChange(int)), |
|
131 m_barringpluginGroup, SLOT(changeBarringStateRequested(int))); |
|
132 } |
|
133 |
|
134 |
|
135 /*! |
|
136 UT_CpBarringPluginGroup::cleanup |
|
137 */ |
|
138 void UT_CpBarringPluginGroup::cleanup() |
|
139 { |
|
140 reset(); |
|
141 |
|
142 disconnect( |
|
143 this, SIGNAL(simulateCheckStateChange(int)), |
|
144 m_barringpluginGroup, SLOT(changeBarringStateRequested(int))); |
|
145 |
|
146 delete m_barringpluginGroup; |
|
147 m_barringpluginGroup = NULL; |
|
148 delete m_barringWrapperMock; |
|
149 m_barringWrapperMock = NULL; |
|
150 delete m_dataFormModel; |
|
151 m_dataFormModel = NULL; |
|
152 } |
|
153 |
|
154 |
|
155 /*! |
|
156 UT_CpBarringPluginGroup::t_memleak |
|
157 */ |
|
158 void UT_CpBarringPluginGroup::t_memleak() |
|
159 { |
|
160 |
|
161 } |
|
162 |
|
163 |
|
164 /*! |
|
165 UT_CpBarringPluginGroup::t_itemShownNotBarringItem |
|
166 Tests that itemShown() for other setting group's item is not handled. |
|
167 */ |
|
168 void UT_CpBarringPluginGroup::t_itemShownNotBarringItem() |
|
169 { |
|
170 EXPECT(PSetCallBarringWrapper::barringStatus).times(0); |
|
171 |
|
172 QScopedPointer<CpSettingFormItemData> item(new CpSettingFormItemData( |
|
173 HbDataFormModelItem::CheckBoxItem, hbTrId(""), NULL)); |
|
174 m_dataFormModel->appendDataFormItem(item.data(), m_barringpluginGroup); |
|
175 m_barringpluginGroup->itemShown( |
|
176 m_dataFormModel->indexFromItem(item.data())); |
|
177 m_dataFormModel->removeItem(item.take()); |
|
178 |
|
179 QVERIFY(verify()); |
|
180 } |
|
181 |
|
182 |
|
183 /*! |
|
184 UT_CpBarringPluginGroup::t_itemShownBarringStatusRequestOngoing |
|
185 Tests that another progress note is not launched if one is already shown. |
|
186 */ |
|
187 void UT_CpBarringPluginGroup::t_itemShownBarringStatusRequestOngoing() |
|
188 { |
|
189 EXPECT(PSetCallBarringWrapper::barringStatus); |
|
190 EXPECT(CpPhoneNotes::noteShowing).returns(true); |
|
191 EXPECT(CpPhoneNotes::showGlobalProgressNote).times(0); |
|
192 |
|
193 HbDataFormModelItem *item = m_barringpluginGroup->childAt(0); |
|
194 m_barringpluginGroup->itemShown(m_dataFormModel->indexFromItem(item)); |
|
195 |
|
196 QVERIFY(verify()); |
|
197 } |
|
198 |
|
199 |
|
200 /*! |
|
201 UT_CpBarringPluginGroup::t_barringStatusRequestCompletedForUpdateInquiry |
|
202 */ |
|
203 void UT_CpBarringPluginGroup::t_barringStatusRequestCompletedForUpdateInquiry() |
|
204 { |
|
205 // simulate successfull initial status inquiry |
|
206 QList<unsigned char> basicServiceGroupIds; |
|
207 const int errorCode = 0; |
|
208 int numOfChilds = m_barringpluginGroup->childCount(); |
|
209 for (int childIndex = 0; childIndex < numOfChilds - 1; childIndex++) { |
|
210 HbDataFormModelItem *item = m_barringpluginGroup->childAt(childIndex); |
|
211 m_barringpluginGroup->itemShown(m_dataFormModel->indexFromItem(item)); |
|
212 |
|
213 m_barringpluginGroup->barringStatusRequestCompleted( |
|
214 errorCode, |
|
215 basicServiceGroupIds, |
|
216 PSetCallBarringWrapper::BarringStatusActive); |
|
217 } |
|
218 |
|
219 // simulate barring enable request |
|
220 EXPECT(CpItemDataHelper::widgetFromModelIndex).returns(this).times(1); |
|
221 EXPECT(CpPhoneNotes::showPasswordQueryDialog) |
|
222 .willOnce(invoke(setCurrentPasswordParams)); |
|
223 emit simulateCheckStateChange(Qt::Checked); |
|
224 |
|
225 // verify that already connected items are not enabled/connected again |
|
226 EXPECT(CpItemDataHelper::removeConnection).times(1); |
|
227 EXPECT(CpItemDataHelper::addConnection).times(1); |
|
228 m_barringpluginGroup->barringStatusRequestCompleted( |
|
229 errorCode, |
|
230 basicServiceGroupIds, |
|
231 PSetCallBarringWrapper::BarringStatusActive); |
|
232 QVERIFY(verify()); |
|
233 } |
|
234 |
|
235 |
|
236 /*! |
|
237 UT_CpBarringPluginGroup::t_barringStatusRequestCompletedWithAnError |
|
238 */ |
|
239 void UT_CpBarringPluginGroup::t_barringStatusRequestCompletedWithAnError() |
|
240 { |
|
241 EXPECT(CpPhoneNotes::cancelNote); |
|
242 EXPECT(CpPhoneNotes::showGlobalErrorNote); |
|
243 EXPECT(CpItemDataHelper::addConnection).times(0); |
|
244 |
|
245 QList<unsigned char> basicServiceGroupIds; |
|
246 const int errorCode = -1; |
|
247 m_barringpluginGroup->barringStatusRequestCompleted( |
|
248 errorCode, |
|
249 basicServiceGroupIds, |
|
250 PSetCallBarringWrapper::BarringStatusUnavailable); |
|
251 |
|
252 QVERIFY(verify()); |
|
253 } |
|
254 |
|
255 |
|
256 /*! |
|
257 UT_CpBarringPluginGroup::t_getBarringStatuses |
|
258 Tests functions |
|
259 CpBarringPluginGroup::itemShown, |
|
260 CpBarringPluginGroup::barringStatusRequestCompleted |
|
261 */ |
|
262 Q_DECLARE_METATYPE(QModelIndex) |
|
263 void UT_CpBarringPluginGroup::t_getBarringStatuses() |
|
264 { |
|
265 qRegisterMetaType<QModelIndex>("QModelIndex"); |
|
266 |
|
267 EXPECT(PSetCallBarringWrapper::barringStatus) |
|
268 .with(ServiceGroupVoice, |
|
269 PSetCallBarringWrapper::BarringTypeAllOutgoing); |
|
270 EXPECT(PSetCallBarringWrapper::barringStatus) |
|
271 .with(ServiceGroupVoice, |
|
272 PSetCallBarringWrapper::BarringTypeOutgoingInternational); |
|
273 EXPECT(PSetCallBarringWrapper::barringStatus) |
|
274 .with(ServiceGroupVoice, |
|
275 PSetCallBarringWrapper::BarringTypeOutgoingInternationalExceptToHomeCountry); |
|
276 EXPECT(PSetCallBarringWrapper::barringStatus) |
|
277 .with(ServiceGroupVoice, |
|
278 PSetCallBarringWrapper::BarringTypeAllIncoming); |
|
279 EXPECT(PSetCallBarringWrapper::barringStatus) |
|
280 .with(ServiceGroupVoice, |
|
281 PSetCallBarringWrapper::BarringTypeIncomingWhenRoaming); |
|
282 EXPECT(CpPhoneNotes::showGlobalProgressNote) |
|
283 .willOnce(invoke(setNoteIdentifier)); |
|
284 EXPECT(CpItemDataHelper::addConnection).times(6); |
|
285 |
|
286 int numOfChilds = m_barringpluginGroup->childCount(); |
|
287 for (int childIndex = 0; childIndex < numOfChilds; childIndex++) { |
|
288 HbDataFormModelItem *item = m_barringpluginGroup->childAt(childIndex); |
|
289 m_barringpluginGroup->itemShown(m_dataFormModel->indexFromItem(item)); |
|
290 } |
|
291 |
|
292 connect( |
|
293 m_dataFormModel, |
|
294 SIGNAL(dataChanged(const QModelIndex &, const QModelIndex &)), |
|
295 this, |
|
296 SLOT(dataChanged(const QModelIndex &, const QModelIndex &))); |
|
297 |
|
298 QSignalSpy spy( |
|
299 m_dataFormModel, |
|
300 SIGNAL(dataChanged(const QModelIndex &, const QModelIndex &))); |
|
301 QList<unsigned char> basicServiceGroupIds; |
|
302 m_barringpluginGroup->barringStatusRequestCompleted( |
|
303 PSetCallBarringWrapper::BarringErrorNone, |
|
304 basicServiceGroupIds, PSetCallBarringWrapper::BarringStatusActive); |
|
305 m_barringpluginGroup->barringStatusRequestCompleted( |
|
306 PSetCallBarringWrapper::BarringErrorNone, |
|
307 basicServiceGroupIds, PSetCallBarringWrapper::BarringStatusInactive); |
|
308 m_barringpluginGroup->barringStatusRequestCompleted( |
|
309 PSetCallBarringWrapper::BarringErrorNone, |
|
310 basicServiceGroupIds, PSetCallBarringWrapper::BarringStatusNotProvisioned); |
|
311 m_barringpluginGroup->barringStatusRequestCompleted( |
|
312 PSetCallBarringWrapper::BarringErrorNone, |
|
313 basicServiceGroupIds, PSetCallBarringWrapper::BarringStatusUnavailable); |
|
314 m_barringpluginGroup->barringStatusRequestCompleted( |
|
315 PSetCallBarringWrapper::BarringErrorNone, |
|
316 basicServiceGroupIds, PSetCallBarringWrapper::BarringStatusUnknown); |
|
317 QCOMPARE(spy.count(), 11); |
|
318 |
|
319 QVERIFY(verify()); |
|
320 |
|
321 // Verify that barring status checking is not started on item show if |
|
322 // status is already queried. |
|
323 EXPECT(PSetCallBarringWrapper::barringStatus).times(0); |
|
324 HbDataFormModelItem *item = m_barringpluginGroup->childAt(0); |
|
325 item->setContentWidgetData("checkState", QVariant(Qt::Checked)); |
|
326 m_barringpluginGroup->itemShown(m_dataFormModel->indexFromItem(item)); |
|
327 |
|
328 QVERIFY(verify()); |
|
329 } |
|
330 |
|
331 |
|
332 /*! |
|
333 UT_CpBarringPluginGroup::t_enableBarringRequestCompleted |
|
334 */ |
|
335 void UT_CpBarringPluginGroup::t_enableBarringRequestCompleted() |
|
336 { |
|
337 // request completed succesfully -case |
|
338 EXPECT(CpItemDataHelper::widgetFromModelIndex).returns(this).times(1); |
|
339 EXPECT(CpPhoneNotes::showPasswordQueryDialog) |
|
340 .willOnce(invoke(setCurrentPasswordParams)); |
|
341 EXPECT(CpPhoneNotes::cancelNote); |
|
342 EXPECT(CpPhoneNotes::showGlobalNote); |
|
343 |
|
344 emit simulateCheckStateChange(Qt::Checked); |
|
345 m_barringpluginGroup->enableBarringRequestCompleted( |
|
346 0, |
|
347 PSetCallBarringWrapper::BarringTypeAllBarrings, |
|
348 PSetCallBarringWrapper::BarringStatusActive, |
|
349 false); |
|
350 |
|
351 QVERIFY(verify()); |
|
352 QList<unsigned char> basicServiceGroupIds; |
|
353 |
|
354 // request completed with an error -case |
|
355 HbDataFormModelItem *item = m_barringpluginGroup->childAt(0); |
|
356 item->setContentWidgetData("checkState", QVariant(Qt::Checked)); |
|
357 EXPECT(CpItemDataHelper::widgetFromModelIndex).returns(this); |
|
358 EXPECT(CpPhoneNotes::showPasswordQueryDialog) |
|
359 .willOnce(invoke(setCurrentPasswordParams)); |
|
360 EXPECT(CpItemDataHelper::removeConnection); |
|
361 EXPECT(CpItemDataHelper::addConnection); |
|
362 EXPECT(CpPhoneNotes::cancelNote); |
|
363 EXPECT(CpPhoneNotes::showGlobalErrorNote); |
|
364 |
|
365 emit simulateCheckStateChange(Qt::Checked); |
|
366 m_barringpluginGroup->enableBarringRequestCompleted( |
|
367 -1, |
|
368 PSetCallBarringWrapper::BarringTypeAllBarrings, |
|
369 PSetCallBarringWrapper::BarringStatusActive, |
|
370 false); |
|
371 |
|
372 QVERIFY(verify()); |
|
373 |
|
374 // request completed successfully and dependent barring setting needs |
|
375 // status inquiry |
|
376 EXPECT(CpItemDataHelper::widgetFromModelIndex).returns(this); |
|
377 EXPECT(CpPhoneNotes::showPasswordQueryDialog) |
|
378 .willOnce(invoke(setCurrentPasswordParams)); |
|
379 // some other (outgoing) barring is enabled, status inquiery for that |
|
380 // should be done. |
|
381 item = m_barringpluginGroup->childAt(1); |
|
382 item->setContentWidgetData("checkState", QVariant(Qt::Checked)); |
|
383 EXPECT(PSetCallBarringWrapper::barringStatus); |
|
384 EXPECT(CpPhoneNotes::cancelNote).times(0); |
|
385 EXPECT(CpPhoneNotes::showGlobalNote).times(0); |
|
386 |
|
387 emit simulateCheckStateChange(Qt::Checked); |
|
388 m_barringpluginGroup->enableBarringRequestCompleted( |
|
389 0, |
|
390 PSetCallBarringWrapper::BarringTypeAllBarrings, |
|
391 PSetCallBarringWrapper::BarringStatusActive, |
|
392 false); |
|
393 |
|
394 QVERIFY(verify()); |
|
395 m_barringpluginGroup->barringStatusRequestCompleted( |
|
396 PSetCallBarringWrapper::BarringErrorNone, |
|
397 basicServiceGroupIds, PSetCallBarringWrapper::BarringStatusActive); |
|
398 } |
|
399 |
|
400 |
|
401 /*! |
|
402 UT_CpBarringPluginGroup::t_enableBarringRequestCompletedUnknownBarring |
|
403 */ |
|
404 void UT_CpBarringPluginGroup::t_enableBarringRequestCompletedUnknownBarring() |
|
405 { |
|
406 // something very weird has happened and enable request completes for unknown |
|
407 // barring type. |
|
408 HbDataFormModel *formModel = qobject_cast<HbDataFormModel*>( |
|
409 m_barringpluginGroup->model()); |
|
410 HbDataFormModelItem *item = m_barringpluginGroup->childAt(5); |
|
411 QModelIndex modelIndex = formModel->indexFromItem(item); |
|
412 |
|
413 EXPECT(CpItemDataHelper::widgetFromModelIndex).with(modelIndex).returns(this); |
|
414 EXPECT(CpPhoneNotes::showPasswordQueryDialog) |
|
415 .willOnce(invoke(setCurrentPasswordParams)); |
|
416 EXPECT(CpPhoneNotes::cancelNote); |
|
417 EXPECT(CpPhoneNotes::showGlobalNote); |
|
418 // completion of unknown barring type should not lead to updating |
|
419 EXPECT(PSetCallBarringWrapper::barringStatus).times(0); |
|
420 emit simulateCheckStateChange(Qt::Checked); |
|
421 m_barringpluginGroup->enableBarringRequestCompleted( |
|
422 0, |
|
423 PSetCallBarringWrapper::BarringTypeAllBarrings, |
|
424 PSetCallBarringWrapper::BarringStatusActive, |
|
425 false); |
|
426 |
|
427 QVERIFY(verify()); |
|
428 } |
|
429 |
|
430 |
|
431 /*! |
|
432 UT_CpBarringPluginGroup::t_enableBAOCRequestCompletedStatusUpdate |
|
433 */ |
|
434 void UT_CpBarringPluginGroup::t_enableBAOCRequestCompletedStatusUpdate() |
|
435 { |
|
436 int numOfChilds = m_barringpluginGroup->childCount(); |
|
437 for (int childIndex = 0; childIndex < numOfChilds - 1; childIndex++) { |
|
438 HbDataFormModelItem *item = m_barringpluginGroup->childAt(childIndex); |
|
439 item->setContentWidgetData("checkState", QVariant(Qt::Checked)); |
|
440 } |
|
441 |
|
442 QList<unsigned char> basicServiceGroupIds; |
|
443 EXPECT(CpItemDataHelper::widgetFromModelIndex).returns(this); |
|
444 EXPECT(CpPhoneNotes::showPasswordQueryDialog) |
|
445 .willOnce(invoke(setCurrentPasswordParams)); |
|
446 emit simulateCheckStateChange(Qt::Checked); |
|
447 EXPECT(PSetCallBarringWrapper::barringStatus).with( |
|
448 ServiceGroupVoice, PSetCallBarringWrapper::BarringTypeOutgoingInternational); |
|
449 EXPECT(PSetCallBarringWrapper::barringStatus).with( |
|
450 ServiceGroupVoice, |
|
451 PSetCallBarringWrapper::BarringTypeOutgoingInternationalExceptToHomeCountry); |
|
452 m_barringpluginGroup->enableBarringRequestCompleted( |
|
453 0, |
|
454 PSetCallBarringWrapper::BarringTypeAllOutgoing, |
|
455 PSetCallBarringWrapper::BarringStatusActive, |
|
456 false); |
|
457 m_barringpluginGroup->barringStatusRequestCompleted( |
|
458 PSetCallBarringWrapper::BarringErrorNone, |
|
459 basicServiceGroupIds, PSetCallBarringWrapper::BarringStatusActive); |
|
460 m_barringpluginGroup->barringStatusRequestCompleted( |
|
461 PSetCallBarringWrapper::BarringErrorNone, |
|
462 basicServiceGroupIds, PSetCallBarringWrapper::BarringStatusActive); |
|
463 QVERIFY(verify()); |
|
464 } |
|
465 |
|
466 |
|
467 /*! |
|
468 UT_CpBarringPluginGroup::t_enableBOICRequestCompletedStatusUpdate |
|
469 */ |
|
470 void UT_CpBarringPluginGroup::t_enableBOICRequestCompletedStatusUpdate() |
|
471 { |
|
472 QModelIndex modelIndex; |
|
473 HbDataFormModel *formModel = qobject_cast<HbDataFormModel*>( |
|
474 m_barringpluginGroup->model()); |
|
475 int numOfChilds = m_barringpluginGroup->childCount(); |
|
476 for (int childIndex = 0; childIndex < numOfChilds - 1; childIndex++) { |
|
477 HbDataFormModelItem *item = m_barringpluginGroup->childAt(childIndex); |
|
478 item->setContentWidgetData("checkState", QVariant(Qt::Checked)); |
|
479 if (childIndex == 1) { |
|
480 modelIndex = formModel->indexFromItem(item); |
|
481 } |
|
482 } |
|
483 |
|
484 QList<unsigned char> basicServiceGroupIds; |
|
485 EXPECT(CpItemDataHelper::widgetFromModelIndex).with(modelIndex).returns(this); |
|
486 EXPECT(CpPhoneNotes::showPasswordQueryDialog) |
|
487 .willOnce(invoke(setCurrentPasswordParams)); |
|
488 emit simulateCheckStateChange(Qt::Checked); |
|
489 EXPECT(PSetCallBarringWrapper::barringStatus).with( |
|
490 ServiceGroupVoice, |
|
491 PSetCallBarringWrapper::BarringTypeAllOutgoing); |
|
492 EXPECT(PSetCallBarringWrapper::barringStatus).with( |
|
493 ServiceGroupVoice, |
|
494 PSetCallBarringWrapper::BarringTypeOutgoingInternationalExceptToHomeCountry); |
|
495 m_barringpluginGroup->enableBarringRequestCompleted( |
|
496 0, |
|
497 PSetCallBarringWrapper::BarringTypeOutgoingInternational, |
|
498 PSetCallBarringWrapper::BarringStatusActive, |
|
499 false); |
|
500 m_barringpluginGroup->barringStatusRequestCompleted( |
|
501 PSetCallBarringWrapper::BarringErrorNone, |
|
502 basicServiceGroupIds, PSetCallBarringWrapper::BarringStatusActive); |
|
503 m_barringpluginGroup->barringStatusRequestCompleted( |
|
504 PSetCallBarringWrapper::BarringErrorNone, |
|
505 basicServiceGroupIds, PSetCallBarringWrapper::BarringStatusActive); |
|
506 QVERIFY(verify()); |
|
507 } |
|
508 |
|
509 |
|
510 /*! |
|
511 UT_CpBarringPluginGroup::t_enableBOICexHCRequestCompletedStatusUpdate |
|
512 */ |
|
513 void UT_CpBarringPluginGroup::t_enableBOICexHCRequestCompletedStatusUpdate() |
|
514 { |
|
515 QModelIndex modelIndex; |
|
516 HbDataFormModel *formModel = qobject_cast<HbDataFormModel*>( |
|
517 m_barringpluginGroup->model()); |
|
518 int numOfChilds = m_barringpluginGroup->childCount(); |
|
519 for (int childIndex = 0; childIndex < numOfChilds - 1; childIndex++) { |
|
520 HbDataFormModelItem *item = m_barringpluginGroup->childAt(childIndex); |
|
521 item->setContentWidgetData("checkState", QVariant(Qt::Checked)); |
|
522 if (childIndex == 2) { |
|
523 modelIndex = formModel->indexFromItem(item); |
|
524 } |
|
525 } |
|
526 |
|
527 QList<unsigned char> basicServiceGroupIds; |
|
528 EXPECT(CpItemDataHelper::widgetFromModelIndex).with(modelIndex).returns(this); |
|
529 EXPECT(CpPhoneNotes::showPasswordQueryDialog) |
|
530 .willOnce(invoke(setCurrentPasswordParams)); |
|
531 emit simulateCheckStateChange(Qt::Checked); |
|
532 EXPECT(PSetCallBarringWrapper::barringStatus).with( |
|
533 ServiceGroupVoice, |
|
534 PSetCallBarringWrapper::BarringTypeAllOutgoing); |
|
535 EXPECT(PSetCallBarringWrapper::barringStatus).with( |
|
536 ServiceGroupVoice, |
|
537 PSetCallBarringWrapper::BarringTypeOutgoingInternational); |
|
538 EXPECT(PSetCallBarringWrapper::barringStatus).with( |
|
539 ServiceGroupVoice, |
|
540 PSetCallBarringWrapper::BarringTypeOutgoingInternationalExceptToHomeCountry); |
|
541 m_barringpluginGroup->enableBarringRequestCompleted( |
|
542 0, |
|
543 PSetCallBarringWrapper::BarringTypeOutgoingInternationalExceptToHomeCountry, |
|
544 PSetCallBarringWrapper::BarringStatusActive, |
|
545 false); |
|
546 m_barringpluginGroup->barringStatusRequestCompleted( |
|
547 PSetCallBarringWrapper::BarringErrorNone, |
|
548 basicServiceGroupIds, PSetCallBarringWrapper::BarringStatusActive); |
|
549 m_barringpluginGroup->barringStatusRequestCompleted( |
|
550 PSetCallBarringWrapper::BarringErrorNone, |
|
551 basicServiceGroupIds, PSetCallBarringWrapper::BarringStatusActive); |
|
552 m_barringpluginGroup->barringStatusRequestCompleted( |
|
553 PSetCallBarringWrapper::BarringErrorNone, |
|
554 basicServiceGroupIds, PSetCallBarringWrapper::BarringStatusActive); |
|
555 QVERIFY(verify()); |
|
556 } |
|
557 |
|
558 |
|
559 /*! |
|
560 UT_CpBarringPluginGroup::t_enableBAICRequestCompletedStatusUpdate |
|
561 */ |
|
562 void UT_CpBarringPluginGroup::t_enableBAICRequestCompletedStatusUpdate() |
|
563 { |
|
564 QModelIndex modelIndex; |
|
565 HbDataFormModel *formModel = qobject_cast<HbDataFormModel*>( |
|
566 m_barringpluginGroup->model()); |
|
567 int numOfChilds = m_barringpluginGroup->childCount(); |
|
568 for (int childIndex = 0; childIndex < numOfChilds - 1; childIndex++) { |
|
569 HbDataFormModelItem *item = m_barringpluginGroup->childAt(childIndex); |
|
570 item->setContentWidgetData("checkState", QVariant(Qt::Checked)); |
|
571 if (childIndex == 3) { |
|
572 modelIndex = formModel->indexFromItem(item); |
|
573 } |
|
574 } |
|
575 |
|
576 QList<unsigned char> basicServiceGroupIds; |
|
577 EXPECT(CpItemDataHelper::widgetFromModelIndex).with(modelIndex).returns(this); |
|
578 EXPECT(CpPhoneNotes::showPasswordQueryDialog) |
|
579 .willOnce(invoke(setCurrentPasswordParams)); |
|
580 emit simulateCheckStateChange(Qt::Checked); |
|
581 EXPECT(PSetCallBarringWrapper::barringStatus).with( |
|
582 ServiceGroupVoice, |
|
583 PSetCallBarringWrapper::BarringTypeIncomingWhenRoaming); |
|
584 m_barringpluginGroup->enableBarringRequestCompleted( |
|
585 0, |
|
586 PSetCallBarringWrapper::BarringTypeAllIncoming, |
|
587 PSetCallBarringWrapper::BarringStatusActive, |
|
588 false); |
|
589 m_barringpluginGroup->barringStatusRequestCompleted( |
|
590 PSetCallBarringWrapper::BarringErrorNone, |
|
591 basicServiceGroupIds, PSetCallBarringWrapper::BarringStatusActive); |
|
592 QVERIFY(verify()); |
|
593 } |
|
594 |
|
595 |
|
596 /*! |
|
597 UT_CpBarringPluginGroup::t_enableBICRoamRequestCompletedStatusUpdate |
|
598 */ |
|
599 void UT_CpBarringPluginGroup::t_enableBICRoamRequestCompletedStatusUpdate() |
|
600 { |
|
601 QModelIndex modelIndex; |
|
602 HbDataFormModel *formModel = qobject_cast<HbDataFormModel*>( |
|
603 m_barringpluginGroup->model()); |
|
604 int numOfChilds = m_barringpluginGroup->childCount(); |
|
605 for (int childIndex = 0; childIndex < numOfChilds - 1; childIndex++) { |
|
606 HbDataFormModelItem *item = m_barringpluginGroup->childAt(childIndex); |
|
607 item->setContentWidgetData("checkState", QVariant(Qt::Checked)); |
|
608 if (childIndex == 4) { |
|
609 modelIndex = formModel->indexFromItem(item); |
|
610 } |
|
611 } |
|
612 |
|
613 QList<unsigned char> basicServiceGroupIds; |
|
614 EXPECT(CpItemDataHelper::widgetFromModelIndex).with(modelIndex).returns(this); |
|
615 EXPECT(CpPhoneNotes::showPasswordQueryDialog) |
|
616 .willOnce(invoke(setCurrentPasswordParams)); |
|
617 emit simulateCheckStateChange(Qt::Checked); |
|
618 EXPECT(PSetCallBarringWrapper::barringStatus).with( |
|
619 ServiceGroupVoice, |
|
620 PSetCallBarringWrapper::BarringTypeAllIncoming); |
|
621 m_barringpluginGroup->enableBarringRequestCompleted( |
|
622 0, |
|
623 PSetCallBarringWrapper::BarringTypeIncomingWhenRoaming, |
|
624 PSetCallBarringWrapper::BarringStatusActive, |
|
625 false); |
|
626 m_barringpluginGroup->barringStatusRequestCompleted( |
|
627 PSetCallBarringWrapper::BarringErrorNone, |
|
628 basicServiceGroupIds, PSetCallBarringWrapper::BarringStatusActive); |
|
629 QVERIFY(verify()); |
|
630 } |
|
631 |
|
632 |
|
633 /*! |
|
634 UT_CpBarringPluginGroup::t_disableBarringRequestCompleted |
|
635 */ |
|
636 void UT_CpBarringPluginGroup::t_disableBarringRequestCompleted() |
|
637 { |
|
638 // request completed succesfully -case |
|
639 EXPECT(CpItemDataHelper::widgetFromModelIndex).returns(this).times(1); |
|
640 EXPECT(CpPhoneNotes::showPasswordQueryDialog) |
|
641 .willOnce(invoke(setCurrentPasswordParams)); |
|
642 EXPECT(CpPhoneNotes::cancelNote); |
|
643 EXPECT(CpPhoneNotes::showGlobalNote); |
|
644 emit simulateCheckStateChange(Qt::Unchecked); |
|
645 |
|
646 m_barringpluginGroup->disableBarringRequestCompleted( |
|
647 0, |
|
648 PSetCallBarringWrapper::BarringTypeAllBarrings, |
|
649 PSetCallBarringWrapper::BarringStatusActive, |
|
650 false); |
|
651 |
|
652 QVERIFY(verify()); |
|
653 |
|
654 // request completed with an error -case |
|
655 HbDataFormModelItem *item = m_barringpluginGroup->childAt(0); |
|
656 item->setContentWidgetData("checkState", QVariant(Qt::Unchecked)); |
|
657 EXPECT(CpItemDataHelper::widgetFromModelIndex).returns(this); |
|
658 EXPECT(CpPhoneNotes::showPasswordQueryDialog) |
|
659 .willOnce(invoke(setCurrentPasswordParams)); |
|
660 EXPECT(CpItemDataHelper::removeConnection); |
|
661 EXPECT(CpItemDataHelper::addConnection); |
|
662 EXPECT(CpPhoneNotes::cancelNote); |
|
663 EXPECT(CpPhoneNotes::showGlobalErrorNote); |
|
664 |
|
665 emit simulateCheckStateChange(Qt::Unchecked); |
|
666 m_barringpluginGroup->disableBarringRequestCompleted( |
|
667 -1, |
|
668 PSetCallBarringWrapper::BarringTypeAllBarrings, |
|
669 PSetCallBarringWrapper::BarringStatusActive, |
|
670 false); |
|
671 |
|
672 QVERIFY(verify()); |
|
673 } |
|
674 |
|
675 |
|
676 /*! |
|
677 UT_CpBarringPluginGroup::t_barringPasswordChangeRequestCompleted |
|
678 */ |
|
679 void UT_CpBarringPluginGroup::t_barringPasswordChangeRequestCompleted() |
|
680 { |
|
681 // request completed with no error |
|
682 EXPECT(CpPhoneNotes::cancelNote); |
|
683 EXPECT(CpPhoneNotes::showGlobalNote); |
|
684 |
|
685 m_barringpluginGroup->barringPasswordChangeRequestCompleted(0); |
|
686 |
|
687 QVERIFY(verify()); |
|
688 |
|
689 // request completed with an error |
|
690 EXPECT(CpPhoneNotes::cancelNote); |
|
691 EXPECT(CpPhoneNotes::showGlobalErrorNote); |
|
692 |
|
693 m_barringpluginGroup->barringPasswordChangeRequestCompleted(-1); |
|
694 |
|
695 QVERIFY(verify()); |
|
696 } |
|
697 |
|
698 |
|
699 /*! |
|
700 UT_CpBarringPluginGroup::t_changeBarringStateRequested |
|
701 */ |
|
702 void UT_CpBarringPluginGroup::t_changeBarringStateRequested() |
|
703 { |
|
704 // barring enable request case |
|
705 EXPECT(CpItemDataHelper::widgetFromModelIndex).returns(this); |
|
706 EXPECT(CpPhoneNotes::showPasswordQueryDialog) |
|
707 .willOnce(invoke(setCurrentPasswordParams)); |
|
708 EXPECT(PSetCallBarringWrapper::enableBarring) |
|
709 .with(ServiceGroupVoice, |
|
710 PSetCallBarringWrapper::BarringTypeAllOutgoing, KCurrentPassword); |
|
711 EXPECT(CpPhoneNotes::showGlobalProgressNote); |
|
712 |
|
713 emit simulateCheckStateChange(Qt::Checked); |
|
714 |
|
715 QVERIFY(verify()); |
|
716 |
|
717 // barring disable request case |
|
718 EXPECT(CpItemDataHelper::widgetFromModelIndex).returns(this); |
|
719 EXPECT(CpPhoneNotes::showPasswordQueryDialog) |
|
720 .willOnce(invoke(setCurrentPasswordParams)); |
|
721 EXPECT(PSetCallBarringWrapper::disableBarring) |
|
722 .with(ServiceGroupVoice, |
|
723 PSetCallBarringWrapper::BarringTypeAllOutgoing, KCurrentPassword); |
|
724 EXPECT(CpPhoneNotes::showGlobalProgressNote); |
|
725 |
|
726 emit simulateCheckStateChange(Qt::Unchecked); |
|
727 |
|
728 QVERIFY(verify()); |
|
729 |
|
730 // cancel pressed while querying barring password |
|
731 EXPECT(CpItemDataHelper::widgetFromModelIndex).returns(this); |
|
732 EXPECT(CpPhoneNotes::showPasswordQueryDialog) |
|
733 .willOnce(invoke(setPasswordParamsCancel)); |
|
734 EXPECT(CpItemDataHelper::removeConnection); |
|
735 EXPECT(CpItemDataHelper::addConnection); |
|
736 EXPECT(PSetCallBarringWrapper::disableBarring).times(0); |
|
737 EXPECT(CpPhoneNotes::showGlobalProgressNote).times(0); |
|
738 |
|
739 emit simulateCheckStateChange(Qt::Unchecked); |
|
740 |
|
741 QVERIFY(verify()); |
|
742 |
|
743 // barring item not found case |
|
744 EXPECT(PSetCallBarringWrapper::enableBarring).times(0); |
|
745 EXPECT(CpPhoneNotes::showGlobalProgressNote).times(0); |
|
746 |
|
747 emit simulateCheckStateChange(Qt::Checked); |
|
748 |
|
749 QVERIFY(verify()); |
|
750 } |
|
751 |
|
752 |
|
753 /*! |
|
754 UT_CpBarringPluginGroup::t_changeBarringPasswordRequested |
|
755 */ |
|
756 void UT_CpBarringPluginGroup::t_changeBarringPasswordRequested() |
|
757 { |
|
758 connect( |
|
759 this, SIGNAL(simulateEditPasswordButtonClicked(bool)), |
|
760 m_barringpluginGroup, SLOT(changeBarringPasswordRequested(bool))); |
|
761 |
|
762 // cancel from current password query |
|
763 EXPECT(CpPhoneNotes::showPasswordQueryDialog) |
|
764 .willOnce(invoke(setPasswordParamsCancel)); |
|
765 emit simulateEditPasswordButtonClicked(false); |
|
766 QVERIFY(verify()); |
|
767 |
|
768 // cancel from new password query |
|
769 EXPECT(CpPhoneNotes::showPasswordQueryDialog) |
|
770 .willOnce(invoke(setCurrentPasswordParams)); |
|
771 EXPECT(CpPhoneNotes::showPasswordQueryDialog) |
|
772 .willOnce(invoke(setPasswordParamsCancel)); |
|
773 emit simulateEditPasswordButtonClicked(false); |
|
774 QVERIFY(verify()); |
|
775 |
|
776 // cancel from verify new password query |
|
777 EXPECT(CpPhoneNotes::showPasswordQueryDialog) |
|
778 .willOnce(invoke(setCurrentPasswordParams)); |
|
779 EXPECT(CpPhoneNotes::showPasswordQueryDialog) |
|
780 .willOnce(invoke(setNewAndVerifiedPasswordParams)); |
|
781 EXPECT(CpPhoneNotes::showPasswordQueryDialog) |
|
782 .willOnce(invoke(setPasswordParamsCancel)); |
|
783 emit simulateEditPasswordButtonClicked(false); |
|
784 QVERIFY(verify()); |
|
785 |
|
786 // all data successfully queried |
|
787 EXPECT(CpPhoneNotes::showPasswordQueryDialog) |
|
788 .willOnce(invoke(setCurrentPasswordParams)); |
|
789 EXPECT(CpPhoneNotes::showPasswordQueryDialog) |
|
790 .willOnce(invoke(setNewAndVerifiedPasswordParams)); |
|
791 EXPECT(CpPhoneNotes::showPasswordQueryDialog) |
|
792 .willOnce(invoke(setNewAndVerifiedPasswordParams)); |
|
793 EXPECT(PSetCallBarringWrapper::changeBarringPassword) |
|
794 .with(KCurrentPassword, KNewAndVerifiedPassword, KNewAndVerifiedPassword); |
|
795 emit simulateEditPasswordButtonClicked(false); |
|
796 QVERIFY(verify()); |
|
797 } |
|
798 |
|
799 QTEST_MAIN_S60(UT_CpBarringPluginGroup) |