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