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