|
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 "ut_cpdivertplugin.h" |
|
19 #include "qtestmains60ui.h" |
|
20 #include <psetcalldivertingwrapper.h> |
|
21 #include <hbdialog.h> |
|
22 #include <qaction> |
|
23 #include <hblabel.h> |
|
24 #include <HbListWidgetItem> |
|
25 #include <HbListWidget> |
|
26 #include <HbDialog> |
|
27 #include <HbLineEdit> |
|
28 #include <HbAbstractViewItem> |
|
29 #include <HbDataFormModel> |
|
30 #include "cpitemdatahelper.h" |
|
31 #include "cpdivertitemdata.h" |
|
32 #include "psetwrappertypes.h" |
|
33 #include "cpdivertselectioncustomitem.h" |
|
34 |
|
35 #define private public |
|
36 #include "cpdivertplugin.h" |
|
37 #include "cpdivertplugingroup.h" |
|
38 |
|
39 |
|
40 Q_DECLARE_METATYPE(PsCallDivertingCondition) |
|
41 Q_EXTERN_C const char * qt_plugin_query_verification_data(); |
|
42 Q_EXTERN_C ::QObject * qt_plugin_instance(); |
|
43 |
|
44 class CPsetContainer |
|
45 { |
|
46 public: |
|
47 CPsetContainer(){}; |
|
48 ~CPsetContainer(){}; |
|
49 }; |
|
50 |
|
51 void fillNumber(QString& number) |
|
52 { |
|
53 number = "1234567"; |
|
54 } |
|
55 |
|
56 |
|
57 /*! |
|
58 UT_CpDivertPlugin::UT_CpDivertPlugin |
|
59 */ |
|
60 UT_CpDivertPlugin::UT_CpDivertPlugin() |
|
61 : m_divertplugin(NULL) |
|
62 { |
|
63 const char * verificationData = qt_plugin_query_verification_data(); |
|
64 qRegisterMetaType<PsCallDivertingCondition>( |
|
65 "PsCallDivertingCondition"); |
|
66 } |
|
67 |
|
68 /*! |
|
69 UT_CpDivertPlugin::~UT_CpDivertPlugin |
|
70 */ |
|
71 UT_CpDivertPlugin::~UT_CpDivertPlugin() |
|
72 { |
|
73 delete m_divertpluginGroup; |
|
74 delete m_helper; |
|
75 delete m_divertplugin; |
|
76 } |
|
77 |
|
78 /*! |
|
79 UT_CpDivertPlugin::init |
|
80 */ |
|
81 void UT_CpDivertPlugin::init() |
|
82 { |
|
83 initialize(); |
|
84 |
|
85 CPsetContainer tmpPsetContainer; |
|
86 PSetCallDivertingWrapper *tmpDivWrapper = |
|
87 new PSetCallDivertingWrapper(tmpPsetContainer, this); |
|
88 expect("PSetWrapper::callDivertingWrapper").returns(tmpDivWrapper); // FIXME to mock framework |
|
89 m_divertplugin = (CpDivertPlugin*)qt_plugin_instance(); |
|
90 |
|
91 QVERIFY(m_divertplugin); |
|
92 |
|
93 m_helper = new CpItemDataHelper; |
|
94 QList<CpSettingFormItemData*> list; |
|
95 list.append(m_divertplugin->createSettingFormItemData(*m_helper)); |
|
96 m_divertpluginGroup = qobject_cast<CpDivertPluginGroup *>(list.takeFirst()); |
|
97 QVERIFY(m_divertpluginGroup); |
|
98 |
|
99 QVERIFY(verify()); |
|
100 } |
|
101 |
|
102 /*! |
|
103 UT_CpDivertPlugin::cleanup |
|
104 */ |
|
105 void UT_CpDivertPlugin::cleanup() |
|
106 { |
|
107 reset(); |
|
108 delete m_divertpluginGroup; |
|
109 m_divertpluginGroup = NULL; |
|
110 |
|
111 delete m_helper; |
|
112 m_helper = NULL; |
|
113 |
|
114 delete m_divertplugin; |
|
115 m_divertplugin = NULL; |
|
116 |
|
117 } |
|
118 |
|
119 /*! |
|
120 UT_CpDivertPlugin::t_memleak |
|
121 */ |
|
122 void UT_CpDivertPlugin::t_memleak() |
|
123 { |
|
124 |
|
125 } |
|
126 |
|
127 /*! |
|
128 UT_CpDivertPlugin::t_createSettingFormItemData |
|
129 */ |
|
130 void UT_CpDivertPlugin::t_createSettingFormItemData() |
|
131 { |
|
132 CpItemDataHelper itemDataHelper; |
|
133 CPsetContainer tmpContainer; |
|
134 PSetCallDivertingWrapper tmpDivWrapper(tmpContainer); |
|
135 |
|
136 expect("PSetWrapper::callDivertingWrapper").returns(&tmpDivWrapper); |
|
137 |
|
138 CpDivertPlugin* p = (CpDivertPlugin*)qt_plugin_instance(); // Get static |
|
139 QList<CpSettingFormItemData*> list; |
|
140 list.append(p->createSettingFormItemData(itemDataHelper)); |
|
141 qDeleteAll(list); |
|
142 QVERIFY(verify()); |
|
143 } |
|
144 |
|
145 /*! |
|
146 UT_CpDivertPlugin::t_changeDivertingStateRequested |
|
147 */ |
|
148 void UT_CpDivertPlugin::t_changeDivertingStateRequested() |
|
149 { |
|
150 //except user cancels |
|
151 appendAction("All voice calls:", selectAction, "Cancel"); |
|
152 expect("PSetCallDivertingWrapper::getDefaultNumbers"); |
|
153 m_divertpluginGroup->m_DataItemVoiceAllCalls->setContentWidgetData("number", ""); |
|
154 m_divertpluginGroup->m_DataItemVoiceAllCalls->setContentWidgetData( |
|
155 "state", CpDivertSelectionCustomitem::Disabled); |
|
156 m_divertpluginGroup->m_DataItemVoiceAllCalls->thisItemClicked(); |
|
157 QVERIFY(verify()); |
|
158 |
|
159 //except user selects vmb |
|
160 appendAction("All voice calls:", selectItem, "txt_phone_setlabel_voice_mbx"); |
|
161 expect("PSetCallDivertingWrapper::getDefaultNumbers"); |
|
162 expect("PSetCallDivertingWrapper::getVoiceMailBoxNumber").willOnce(invoke(fillNumber)); |
|
163 expect("SsSettingsWrapper::get"); |
|
164 expect("PSetCallDivertingWrapper::setCallDiverting"); |
|
165 expect("CpPhoneNotes::noteShowing").returns(false); |
|
166 expect("CpPhoneNotes::showGlobalProgressNote"); |
|
167 m_divertpluginGroup->m_DataItemVoiceAllCalls->thisItemClicked(); |
|
168 QVERIFY(verify()); // Verify item click |
|
169 PSCallDivertingCommand command; |
|
170 command.iNumber = "12345"; |
|
171 command.iStatus = DivertingStatusActive; |
|
172 command.iCondition = qvariant_cast<PsCallDivertingCondition>( |
|
173 m_divertpluginGroup->m_DataItemVoiceAllCalls->property("condition")); |
|
174 command.iServiceGroup = ServiceGroupVoice; |
|
175 expect("CpPhoneNotes::showGlobalNote"); |
|
176 m_divertpluginGroup->handleDivertingChanged(command, false); |
|
177 expect("CpPhoneNotes::cancelNote"); |
|
178 m_divertpluginGroup->divertRequestProcessed(); |
|
179 QVERIFY(verify()); // Verify result processing |
|
180 |
|
181 //except user selects one of the default numbers |
|
182 m_divertpluginGroup->m_DataItemVoiceAllCalls->setContentWidgetData("number",""); |
|
183 m_divertpluginGroup->m_DataItemVoiceAllCalls->setContentWidgetData( |
|
184 "state", CpDivertSelectionCustomitem::Disabled); |
|
185 appendAction("All voice calls:", selectItem, "0401234567"); |
|
186 expect("PSetCallDivertingWrapper::getDefaultNumbers"); |
|
187 expect("SsSettingsWrapper::get"); |
|
188 expect("PSetCallDivertingWrapper::setCallDiverting"); |
|
189 expect("CpPhoneNotes::noteShowing").returns(false); |
|
190 expect("CpPhoneNotes::showGlobalProgressNote"); |
|
191 m_divertpluginGroup->m_DataItemVoiceAllCalls->thisItemClicked(); |
|
192 command.iNumber = "0401234567"; |
|
193 command.iStatus = DivertingStatusActive; |
|
194 command.iCondition = qvariant_cast<PsCallDivertingCondition>( |
|
195 m_divertpluginGroup->m_DataItemVoiceAllCalls->property("condition")); |
|
196 command.iServiceGroup = ServiceGroupVoice; |
|
197 expect("CpPhoneNotes::cancelNote"); |
|
198 expect("CpPhoneNotes::showGlobalNote"); |
|
199 expect("PSetCallDivertingWrapper::setNewDefaultNumber").with(QString("0401234567")); |
|
200 expect("Tools::voipSupported").returns(false); |
|
201 m_divertpluginGroup->handleDivertingChanged(command, true); |
|
202 expect("CpPhoneNotes::cancelNote"); |
|
203 m_divertpluginGroup->divertRequestProcessed(); |
|
204 QVERIFY(verify()); |
|
205 |
|
206 // Divert is disabled |
|
207 expect("SsSettingsWrapper::get"); |
|
208 expect("PSetCallDivertingWrapper::setCallDiverting"); // Disable divert |
|
209 expect("CpPhoneNotes::noteShowing").returns(false); |
|
210 expect("CpPhoneNotes::showGlobalProgressNote"); |
|
211 m_divertpluginGroup->m_DataItemVoiceAllCalls->thisItemClicked(); |
|
212 command.iNumber = ""; |
|
213 command.iStatus = DivertingStatusInactive; |
|
214 command.iCondition = qvariant_cast<PsCallDivertingCondition>( |
|
215 m_divertpluginGroup->m_DataItemVoiceAllCalls->property("condition")); |
|
216 command.iServiceGroup = ServiceGroupVoice; |
|
217 expect("CpPhoneNotes::showGlobalNote"); |
|
218 m_divertpluginGroup->handleDivertingChanged(command, false); |
|
219 expect("CpPhoneNotes::cancelNote"); |
|
220 m_divertpluginGroup->divertRequestProcessed(); |
|
221 QVERIFY(verify()); |
|
222 |
|
223 //except user selects other number, inserts number and cancels |
|
224 appendAction("All voice calls:", selectItem, "Other number"); |
|
225 appendAction("Number:", insertText, "12345"); |
|
226 appendAction("Number:", selectAction, "Cancel"); |
|
227 expect("PSetCallDivertingWrapper::getDefaultNumbers"); |
|
228 m_divertpluginGroup->m_DataItemVoiceAllCalls->thisItemClicked(); |
|
229 QVERIFY(verify()); |
|
230 } |
|
231 |
|
232 /*! |
|
233 UT_CpDivertPlugin::t_itemShown |
|
234 */ |
|
235 void UT_CpDivertPlugin::t_itemShown() |
|
236 { |
|
237 HbDataFormModel* model = |
|
238 qobject_cast<HbDataFormModel*>(m_divertpluginGroup->model()); |
|
239 |
|
240 expect("PSetCallDivertingWrapper::getCallDivertingStatus"); |
|
241 expect("CpPhoneNotes::noteShowing").returns(false); |
|
242 expect("CpPhoneNotes::showGlobalProgressNote"); |
|
243 m_divertpluginGroup->itemShown( |
|
244 model->indexFromItem(m_divertpluginGroup->m_DataItemVoiceAllCalls)); |
|
245 m_divertpluginGroup->itemShown( |
|
246 model->indexFromItem(m_divertpluginGroup->m_DataItemVoiceIfBusy)); |
|
247 m_divertpluginGroup->itemShown( |
|
248 model->indexFromItem(m_divertpluginGroup->m_DataItemVoiceIfNotAnswered)); |
|
249 m_divertpluginGroup->itemShown( |
|
250 model->indexFromItem(m_divertpluginGroup->m_DataItemVoiceIfOutOfReach)); |
|
251 m_divertpluginGroup->itemShown( |
|
252 model->indexFromItem(m_divertpluginGroup->m_DataItemVoiceIfNotAvailable)); |
|
253 |
|
254 QList<PSCallDivertingStatus*> list; |
|
255 PSCallDivertingStatus divertStatus; |
|
256 list.append(&divertStatus); |
|
257 divertStatus.iCondition = qvariant_cast<PsCallDivertingCondition>( |
|
258 m_divertpluginGroup->m_DataItemVoiceAllCalls->property("condition")); |
|
259 m_divertpluginGroup->handleDivertingStatus(list, true); |
|
260 m_divertpluginGroup->divertRequestProcessed(); |
|
261 divertStatus.iCondition = qvariant_cast<PsCallDivertingCondition>( |
|
262 m_divertpluginGroup->m_DataItemVoiceIfBusy->property("condition")); |
|
263 m_divertpluginGroup->handleDivertingStatus(list, true); |
|
264 m_divertpluginGroup->divertRequestProcessed(); |
|
265 divertStatus.iCondition = qvariant_cast<PsCallDivertingCondition>( |
|
266 m_divertpluginGroup->m_DataItemVoiceIfNotAnswered->property("condition")); |
|
267 m_divertpluginGroup->handleDivertingStatus(list, true); |
|
268 m_divertpluginGroup->divertRequestProcessed(); |
|
269 divertStatus.iCondition = qvariant_cast<PsCallDivertingCondition>( |
|
270 m_divertpluginGroup->m_DataItemVoiceIfOutOfReach->property("condition")); |
|
271 m_divertpluginGroup->handleDivertingStatus(list, true); |
|
272 m_divertpluginGroup->divertRequestProcessed(); |
|
273 divertStatus.iCondition = qvariant_cast<PsCallDivertingCondition>( |
|
274 m_divertpluginGroup->m_DataItemVoiceIfNotAvailable->property("condition")); |
|
275 m_divertpluginGroup->handleDivertingStatus(list, true); |
|
276 m_divertpluginGroup->divertRequestProcessed(); |
|
277 |
|
278 m_divertpluginGroup->divertRequestProcessed(); // Test overflow |
|
279 |
|
280 // Test, Do not check status again |
|
281 m_divertpluginGroup->itemShown( |
|
282 model->indexFromItem(m_divertpluginGroup->m_DataItemVoiceAllCalls)); |
|
283 m_divertpluginGroup->itemShown( |
|
284 model->indexFromItem(m_divertpluginGroup->m_DataItemVoiceIfBusy)); |
|
285 m_divertpluginGroup->itemShown( |
|
286 model->indexFromItem(m_divertpluginGroup->m_DataItemVoiceIfNotAnswered)); |
|
287 m_divertpluginGroup->itemShown( |
|
288 model->indexFromItem(m_divertpluginGroup->m_DataItemVoiceIfOutOfReach)); |
|
289 m_divertpluginGroup->itemShown( |
|
290 model->indexFromItem(m_divertpluginGroup->m_DataItemVoiceIfNotAvailable)); |
|
291 |
|
292 |
|
293 QVERIFY(verify()); |
|
294 } |
|
295 |
|
296 /*! |
|
297 UT_CpDivertPlugin::t_popUpTimerQuery |
|
298 */ |
|
299 void UT_CpDivertPlugin::t_popUpTimerQuery() |
|
300 { |
|
301 appendAction("If not answered:", selectItem, "0401234567"); |
|
302 appendAction("Time out", selectAction, "Cancel"); |
|
303 expect("PSetCallDivertingWrapper::getDefaultNumbers"); |
|
304 m_divertpluginGroup->m_DataItemVoiceIfNotAnswered->setContentWidgetData("number", ""); |
|
305 m_divertpluginGroup->m_DataItemVoiceIfNotAnswered->setContentWidgetData( |
|
306 "state", CpDivertSelectionCustomitem::Disabled); |
|
307 m_divertpluginGroup->m_DataItemVoiceIfNotAnswered->thisItemClicked(); |
|
308 QVERIFY(verify()); |
|
309 |
|
310 appendAction("If not answered:", selectItem, "Other number"); |
|
311 appendAction("Number:", insertText, "12345"); |
|
312 appendAction("Number:", selectAction, "OK"); |
|
313 appendAction("Time out", selectItem, "15 second"); |
|
314 //except user chooses other number and inserts number and timeout |
|
315 expect("PSetCallDivertingWrapper::getDefaultNumbers"); |
|
316 expect("SsSettingsWrapper::get"); |
|
317 expect("PSetCallDivertingWrapper::setCallDiverting"); |
|
318 m_divertpluginGroup->m_DataItemVoiceIfNotAnswered->thisItemClicked(); |
|
319 PSCallDivertingCommand command; |
|
320 command.iNumber = "12345"; |
|
321 command.iNoReplyTimer = 15; |
|
322 command.iStatus = DivertingStatusActive; |
|
323 command.iCondition = qvariant_cast<PsCallDivertingCondition>( |
|
324 m_divertpluginGroup->m_DataItemVoiceIfNotAnswered->property("condition")); |
|
325 command.iServiceGroup = ServiceGroupVoice; |
|
326 expect("CpPhoneNotes::showGlobalNote"); |
|
327 m_divertpluginGroup->handleDivertingChanged(command, false); |
|
328 expect("CpPhoneNotes::cancelNote"); |
|
329 m_divertpluginGroup->divertRequestProcessed(); |
|
330 QVERIFY(verify()); |
|
331 |
|
332 expect("SsSettingsWrapper::get"); |
|
333 expect("PSetCallDivertingWrapper::setCallDiverting"); |
|
334 m_divertpluginGroup->m_DataItemVoiceIfNotAnswered->thisItemClicked(); |
|
335 command.iNumber = ""; |
|
336 command.iNoReplyTimer = 0; |
|
337 command.iStatus = DivertingStatusInactive; |
|
338 command.iCondition = qvariant_cast<PsCallDivertingCondition>( |
|
339 m_divertpluginGroup->m_DataItemVoiceIfNotAnswered->property("condition")); |
|
340 command.iServiceGroup = ServiceGroupVoice; |
|
341 expect("CpPhoneNotes::showGlobalNote"); |
|
342 m_divertpluginGroup->handleDivertingChanged(command, false); |
|
343 expect("CpPhoneNotes::cancelNote"); |
|
344 m_divertpluginGroup->divertRequestProcessed(); |
|
345 QVERIFY(verify()); |
|
346 |
|
347 } |
|
348 |
|
349 /*! |
|
350 UT_CpDivertPlugin::t_handleDivertingChanged |
|
351 */ |
|
352 void UT_CpDivertPlugin::t_handleDivertingChanged() |
|
353 { |
|
354 PSCallDivertingCommand c; |
|
355 |
|
356 c.iStatus = DivertingStatusActive; |
|
357 c.iServiceGroup = ServiceGroupAllTeleservices; |
|
358 bool bRet = false; |
|
359 expect("PSetCallDivertingWrapper::setNewDefaultNumber"); |
|
360 expect("Tools::voipSupported").returns(bRet); |
|
361 m_divertpluginGroup->handleDivertingChanged(c, true); |
|
362 |
|
363 QVERIFY(verify()); |
|
364 |
|
365 bRet = true; |
|
366 c.iServiceGroup = ServiceGroupAllTeleservices; |
|
367 c.iCondition = DivertConditionUnconditional; |
|
368 expect("PSetCallDivertingWrapper::setNewDefaultNumber"); |
|
369 expect("Tools::voipSupported").returns(bRet); |
|
370 m_divertpluginGroup->handleDivertingChanged(c, false); |
|
371 |
|
372 QVERIFY(verify()); |
|
373 |
|
374 c.iStatus = DivertingStatusInactive; |
|
375 c.iCondition = DivertConditionBusy; |
|
376 m_divertpluginGroup->handleDivertingChanged(c, true); |
|
377 m_divertpluginGroup->handleDivertingChanged(c, false); |
|
378 |
|
379 c.iStatus = DivertingStatusNotRegistered; |
|
380 c.iCondition = DivertConditionNoReply; |
|
381 m_divertpluginGroup->handleDivertingChanged(c, true); |
|
382 |
|
383 c.iStatus = DivertingStatusNotProvisioned; |
|
384 c.iCondition = DivertConditionNotReachable; |
|
385 m_divertpluginGroup->handleDivertingChanged(c, true); |
|
386 |
|
387 c.iStatus = DivertingStatusUnknown; |
|
388 c.iCondition = DivertConditionAllCalls; |
|
389 m_divertpluginGroup->handleDivertingChanged(c, true); |
|
390 |
|
391 c.iStatus = (PsCallDivertingStatus)5; |
|
392 c.iCondition = DivertConditionAllConditionalCases; |
|
393 m_divertpluginGroup->handleDivertingChanged(c, true); |
|
394 |
|
395 QVERIFY(verify()); |
|
396 } |
|
397 |
|
398 /*! |
|
399 UT_CpDivertPlugin::t_handleDivertingStatus |
|
400 */ |
|
401 void UT_CpDivertPlugin::t_handleDivertingStatus() |
|
402 { |
|
403 QList<PSCallDivertingStatus*> list; |
|
404 PSCallDivertingStatus divertStatus; |
|
405 |
|
406 divertStatus.iTimeout =5; |
|
407 divertStatus.iStatus = DivertingStatusActive; |
|
408 list.append(&divertStatus); |
|
409 m_divertpluginGroup->handleDivertingStatus(list, true); |
|
410 divertStatus.iTimeout =0; |
|
411 list.replace(0, &divertStatus); |
|
412 m_divertpluginGroup->handleDivertingStatus(list, true); |
|
413 |
|
414 divertStatus.iStatus = DivertingStatusInactive; |
|
415 list.replace(0, &divertStatus); |
|
416 m_divertpluginGroup->handleDivertingStatus(list, true); |
|
417 |
|
418 divertStatus.iStatus = DivertingStatusNotRegistered; |
|
419 list.replace(0, &divertStatus); |
|
420 m_divertpluginGroup->handleDivertingStatus(list, true); |
|
421 m_divertpluginGroup->handleDivertingStatus(list, false); |
|
422 |
|
423 divertStatus.iStatus = DivertingStatusNotProvisioned; |
|
424 list.replace(0, &divertStatus); |
|
425 m_divertpluginGroup->handleDivertingStatus(list, true); |
|
426 |
|
427 divertStatus.iStatus = DivertingStatusUnknown; |
|
428 list.replace(0, &divertStatus); |
|
429 m_divertpluginGroup->handleDivertingStatus(list, true); |
|
430 |
|
431 divertStatus.iStatus = (PsCallDivertingStatus)5; |
|
432 list.replace(0, &divertStatus); |
|
433 m_divertpluginGroup->handleDivertingStatus(list, true); |
|
434 |
|
435 } |
|
436 |
|
437 /*! |
|
438 UT_CpDivertPlugin::t_handleDivertingError |
|
439 */ |
|
440 void UT_CpDivertPlugin::t_handleDivertingError() |
|
441 { |
|
442 m_divertpluginGroup->handleDivertingError(-1); |
|
443 } |
|
444 |
|
445 /*! |
|
446 UT_CpDivertPlugin::appendAction |
|
447 */ |
|
448 void UT_CpDivertPlugin::appendAction( |
|
449 const QString& dialog, actionType actionType, const QString& action) |
|
450 { |
|
451 if (!actionQueue.count()) { |
|
452 startTimer(2000); |
|
453 } |
|
454 qDebug() << "appendAction(" << dialog << actionType << action <<")"; |
|
455 actionQueue.append(new dialogAction(dialog, actionType, action)); |
|
456 } |
|
457 |
|
458 /*! |
|
459 UT_CpDivertPlugin::executeAction |
|
460 */ |
|
461 void UT_CpDivertPlugin::executeAction( const dialogAction &action ) |
|
462 { |
|
463 qDebug() << "executeAction(" << action.dialog << action.type << action.item <<")"; |
|
464 switch (action.type) { |
|
465 case selectAction: |
|
466 doAndVerifyAction(action.dialog, action.item); |
|
467 break; |
|
468 case selectItem: |
|
469 selectItemFromListWidget(action.dialog, action.item); |
|
470 break; |
|
471 case insertText: |
|
472 HbDialog *dialog = visibleDialog(action.dialog); |
|
473 QVERIFY( dialog ); |
|
474 HbLineEdit* editor = qobject_cast<HbLineEdit*>( |
|
475 dialog->contentWidget() ); |
|
476 QVERIFY( editor ); |
|
477 editor->setText(action.item); |
|
478 break; |
|
479 default: |
|
480 break; |
|
481 } |
|
482 } |
|
483 |
|
484 /*! |
|
485 UT_CpDivertPlugin::visibleDialog |
|
486 */ |
|
487 HbDialog *UT_CpDivertPlugin::visibleDialog( const QString &heading ) |
|
488 { |
|
489 QList<QGraphicsItem*> items = mainWindow->scene()->items(); |
|
490 foreach (QGraphicsItem* item, items) { |
|
491 HbDialog *w = qobject_cast<HbDialog*>(item->parentWidget()); |
|
492 if (w && w->isVisible() && ( qobject_cast<HbLabel*>(w->headingWidget())->plainText() == heading )) { |
|
493 qDebug() << "visibleDialog: " << w->getStaticMetaObject().className() << |
|
494 "contentWidget: " << w->contentWidget()->getStaticMetaObject().className(); |
|
495 return w; |
|
496 } |
|
497 } |
|
498 |
|
499 return 0; |
|
500 } |
|
501 |
|
502 /*! |
|
503 UT_CpDivertPlugin::selectItemFromListWidget |
|
504 */ |
|
505 void UT_CpDivertPlugin::selectItemFromListWidget( |
|
506 const QString& dialog, const QString& item ) |
|
507 { |
|
508 HbDialog* d = visibleDialog(dialog); |
|
509 QVERIFY(d); |
|
510 HbListWidget *list = qobject_cast<HbListWidget*>(d->contentWidget()); |
|
511 QVERIFY(list); |
|
512 |
|
513 bool ok=true; |
|
514 HbListWidgetItem *itemObject = 0; |
|
515 for (int i=0; i < list->count();i++) { |
|
516 itemObject = list->item(i); |
|
517 if (itemObject->text() == item) { |
|
518 ok=true; |
|
519 QSignalSpy spy( d, SIGNAL(aboutToClose())); |
|
520 list->setCurrentItem(itemObject); |
|
521 d->close(); |
|
522 qDebug() << "selectItemFromListWidget: " << itemObject->text(); |
|
523 while (!spy.count()) { |
|
524 QTest::qWait(50); |
|
525 } |
|
526 QTest::qWait(50); |
|
527 } |
|
528 |
|
529 } |
|
530 |
|
531 QVERIFY(ok); |
|
532 } |
|
533 |
|
534 /*! |
|
535 UT_CpDivertPlugin::doAndVerifyAction |
|
536 */ |
|
537 void UT_CpDivertPlugin::doAndVerifyAction( |
|
538 const QString& dialog, const QString& action ) |
|
539 { |
|
540 HbDialog* d = visibleDialog(dialog); |
|
541 QVERIFY(d); |
|
542 |
|
543 QAction* o; |
|
544 bool ok=false; |
|
545 foreach (o, d->actions()) { |
|
546 if (o->text() == action) { |
|
547 ok=true; |
|
548 QSignalSpy spy( d, SIGNAL(aboutToClose())); |
|
549 o->trigger(); |
|
550 qDebug() << "doAndVerifyAction: " << o->text(); |
|
551 while (!spy.count()) { |
|
552 QTest::qWait(50); |
|
553 } |
|
554 QTest::qWait(50); |
|
555 } |
|
556 } |
|
557 QVERIFY(ok); |
|
558 } |
|
559 |
|
560 /*! |
|
561 UT_CpDivertPlugin::timerEvent |
|
562 */ |
|
563 void UT_CpDivertPlugin::timerEvent( |
|
564 QTimerEvent* event ) |
|
565 { |
|
566 QString currentTest(QTest::currentTestFunction()); |
|
567 qDebug() << "timerEvent:" << currentTest; |
|
568 killTimer(event->timerId()); |
|
569 executeAction(*actionQueue.takeFirst()); |
|
570 if (actionQueue.count()) { |
|
571 startTimer(1000); |
|
572 } |
|
573 |
|
574 qDebug() << "timerEvent, OUT"; |
|
575 } |
|
576 |
|
577 QTEST_MAIN_S60UI(UT_CpDivertPlugin) |