author | William Roberts <williamr@symbian.org> |
Thu, 22 Jul 2010 16:33:21 +0100 | |
branch | GCC_SURGE |
changeset 51 | f39ed5e045e0 |
parent 30 | ebdbd102c78a |
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: Unit tests for PhoneUIQtView. |
|
15 |
* |
|
16 |
*/ |
|
17 |
||
18 |
#include <QtTest/QtTest> |
|
19 |
#include <QtGui> |
|
20 |
#include <QVariant> |
|
21 |
#include <QKeyEvent> |
|
22 |
#include <QTimer> |
|
23 |
#include <QShortcutEvent> |
|
24 |
#include <QSignalSpy> |
|
25 |
#include <hbapplication.h> |
|
26 |
#include <hbmainwindow.h> |
|
27 |
#include <hbinstance.h> |
|
28 |
#include <hbmainwindow.h> |
|
29 |
#include <bubblemanagerif.h> |
|
30 |
#define protected public |
|
46
bc5a64e5bc3c
Revision: 201025
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
45
diff
changeset
|
31 |
#define private public |
37 | 32 |
#include "phoneuiqtview.h" |
33 |
#undef public |
|
34 |
#include "phoneaction.h" |
|
35 |
#include <hbtoolbar.h> |
|
36 |
#include <hbvolumesliderpopup.h> |
|
37 |
#include <hbaction.h> |
|
46
bc5a64e5bc3c
Revision: 201025
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
45
diff
changeset
|
38 |
#include <dialpad.h> |
bc5a64e5bc3c
Revision: 201025
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
45
diff
changeset
|
39 |
#include <hblineedit.h> |
37 | 40 |
#include "xqserviceutil.h" |
41 |
#include "phoneaction.h" |
|
42 |
||
43 |
//CONSTANTS |
|
44 |
static const int KMAXVOLUME = 10; |
|
45 |
static const int KMINVOLUME = 0; |
|
46 |
static const int KVOLUMECOMMAND = 5; |
|
47 |
||
48 |
bool m_qtimer_stop_called; |
|
49 |
QString m_networkName; |
|
50 |
||
51 |
#define PHONE_QT_VIEW_TEST_MAIN(TestObject) \ |
|
52 |
int main(int argc, char *argv[]) \ |
|
53 |
{ \ |
|
54 |
HbApplication app(argc, argv); \ |
|
55 |
TestObject tc; \ |
|
56 |
QResource::registerResource("../hbcore.rcc"); \ |
|
57 |
int ret = QTest::qExec(&tc, argc, argv); \ |
|
58 |
/* Core dump if HbIconLoader instance is not destroyed before the application instance. */ \ |
|
59 |
/* HbIconLoader uses QCoreApplication::aboutToQuit() signal to destroy itself. */ \ |
|
60 |
/* app.exec() where the signal is normally emitted is not called here. */ \ |
|
61 |
/* So, invoking the signal explicitly. */ \ |
|
62 |
QMetaObject::invokeMethod(&app, "aboutToQuit", Qt::DirectConnection); \ |
|
63 |
return ret; \ |
|
64 |
} |
|
65 |
||
66 |
class TestPhoneUIQtView : public QObject |
|
67 |
{ |
|
68 |
Q_OBJECT |
|
69 |
||
70 |
public: |
|
71 |
TestPhoneUIQtView (); |
|
72 |
~TestPhoneUIQtView (); |
|
73 |
||
74 |
||
75 |
public slots: |
|
76 |
void initTestCase (); |
|
77 |
void cleanupTestCase (); |
|
78 |
void init (); |
|
79 |
void cleanup (); |
|
80 |
||
81 |
private slots: |
|
82 |
void testAddBubbleCommand (); |
|
83 |
void testHideToolbar (); |
|
84 |
void testShowToolbar (); |
|
85 |
void testAddToolbarActions (); |
|
86 |
void testSetVolumeSliderValue (); |
|
87 |
void testRemoveVolumeSlider (); |
|
88 |
void testVolumeSliderValue (); |
|
89 |
void testVolumeSliderChanged (); |
|
90 |
void testParticipantListAction (); |
|
91 |
void testSetExpandAction (); |
|
92 |
void testPhoneAction (); |
|
93 |
void testSetOrientation (); |
|
94 |
void testBackButtonClicked(); |
|
95 |
void testShowDialpad(); |
|
96 |
void testDialpadText(); |
|
97 |
void testSetMenuActions(); |
|
98 |
void testLongEndKeyPressEventOutsideTelephony(); |
|
99 |
void testNetworkNameChanged(); |
|
46
bc5a64e5bc3c
Revision: 201025
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
45
diff
changeset
|
100 |
void testCaptureKey(); |
bc5a64e5bc3c
Revision: 201025
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
45
diff
changeset
|
101 |
void testRestrictedMode(); |
37 | 102 |
|
103 |
private: |
|
104 |
int createCallHeader(); |
|
105 |
||
106 |
private: |
|
107 |
PhoneUIQtView *m_view; // class under test |
|
108 |
HbMainWindow *m_main_window; |
|
109 |
||
110 |
}; |
|
111 |
||
112 |
void QTimer::stop() |
|
113 |
{ |
|
114 |
m_qtimer_stop_called = true; |
|
115 |
} |
|
116 |
||
117 |
TestPhoneUIQtView::TestPhoneUIQtView () |
|
118 |
{ |
|
119 |
} |
|
120 |
||
121 |
TestPhoneUIQtView::~TestPhoneUIQtView () |
|
122 |
{ |
|
123 |
} |
|
124 |
||
125 |
void TestPhoneUIQtView::initTestCase () |
|
126 |
{ |
|
127 |
m_main_window = new HbMainWindow(); |
|
128 |
m_view = new PhoneUIQtView(*m_main_window); |
|
129 |
QCOMPARE(m_networkName, QString("Unit test network")); |
|
130 |
} |
|
131 |
||
132 |
void TestPhoneUIQtView::cleanupTestCase () |
|
133 |
{ |
|
134 |
delete m_view; |
|
135 |
} |
|
136 |
||
137 |
void TestPhoneUIQtView::init () |
|
138 |
{ |
|
139 |
m_qtimer_stop_called = false; |
|
140 |
} |
|
141 |
||
142 |
void TestPhoneUIQtView::cleanup () |
|
143 |
{ |
|
144 |
} |
|
145 |
||
146 |
void TestPhoneUIQtView::testAddBubbleCommand () |
|
147 |
{ |
|
148 |
m_view->bubbleManager ().startChanges (); |
|
149 |
int bubbleId = createCallHeader(); |
|
150 |
int bubbleId2 = createCallHeader(); |
|
151 |
||
152 |
PhoneAction action1; |
|
153 |
action1.setText("Command 1"); |
|
154 |
action1.setCommand(1); |
|
155 |
action1.setActionRole(PhoneAction::None); |
|
156 |
||
157 |
PhoneAction action2; |
|
158 |
action2.setText("Command 2"); |
|
159 |
action2.setCommand(2); |
|
160 |
action2.setActionRole(PhoneAction::Accept); |
|
161 |
||
162 |
PhoneAction action3; |
|
163 |
action3.setText("Command 3"); |
|
164 |
action3.setCommand(3); |
|
165 |
action3.setActionRole(PhoneAction::Decline); |
|
166 |
||
167 |
m_view->addBubbleCommand (bubbleId, action1); |
|
168 |
m_view->addBubbleCommand (bubbleId, action2); |
|
169 |
m_view->addBubbleCommand (bubbleId2, action3); |
|
170 |
m_view->bubbleManager ().endChanges (); |
|
171 |
||
172 |
m_view->bubbleManager ().startChanges (); |
|
173 |
m_view->clearBubbleCommands (bubbleId); |
|
174 |
m_view->clearBubbleCommands (bubbleId2); |
|
175 |
m_view->clearBubbleCommands (bubbleId2); |
|
176 |
m_view->bubbleManager ().endChanges (); |
|
177 |
} |
|
178 |
||
179 |
void TestPhoneUIQtView::testHideToolbar () |
|
180 |
{ |
|
181 |
m_view->hideToolbar (); |
|
182 |
QCOMPARE (m_hideCalled, true); |
|
183 |
} |
|
184 |
||
185 |
void TestPhoneUIQtView::testShowToolbar () |
|
186 |
{ |
|
187 |
m_view->showToolbar (); |
|
188 |
QCOMPARE (m_showCalled, true); |
|
189 |
} |
|
190 |
||
191 |
void TestPhoneUIQtView::testAddToolbarActions () |
|
192 |
{ |
|
193 |
m_actions.clear(); |
|
194 |
HbIcon icon ("foo.jpg"); |
|
195 |
PhoneAction *testAction = new PhoneAction (); |
|
196 |
testAction->setIcon(icon); |
|
197 |
testAction->setText("foo"); |
|
198 |
testAction->setCommand(20); |
|
199 |
QList<PhoneAction*> actions; |
|
200 |
actions.append(testAction); |
|
201 |
||
202 |
m_view->setToolbarActions(actions); |
|
203 |
QCOMPARE (m_action->icon(), icon); |
|
204 |
QCOMPARE(true, m_toolBarUpdateCalled); |
|
205 |
||
206 |
m_view->setToolbarActions(actions); |
|
207 |
||
208 |
m_toolBarUpdateCalled = false; |
|
209 |
PhoneAction *testAction2 = new PhoneAction (); |
|
210 |
testAction2->setIcon(icon); |
|
211 |
testAction2->setText("foo2"); |
|
212 |
testAction2->setCommand(21); |
|
213 |
actions.append(testAction2); |
|
214 |
||
215 |
m_view->setToolbarActions(actions); |
|
216 |
QCOMPARE(true, m_toolBarUpdateCalled); |
|
217 |
actions.removeOne(testAction2); |
|
218 |
||
219 |
m_toolBarUpdateCalled = false; |
|
220 |
m_view->setToolbarActions(actions); |
|
221 |
QCOMPARE(true, m_toolBarUpdateCalled); |
|
222 |
||
223 |
actions.clear(); |
|
224 |
delete testAction; |
|
225 |
delete testAction2; |
|
226 |
} |
|
227 |
||
228 |
void TestPhoneUIQtView::testSetVolumeSliderValue () |
|
229 |
{ |
|
230 |
m_view->setVolumeSliderValue (1, KVOLUMECOMMAND, KMAXVOLUME, KMINVOLUME); |
|
231 |
QCOMPARE (m_volumeSliderContructorCalled, true); |
|
232 |
QCOMPARE (m_sliderRangeMin, KMINVOLUME); |
|
233 |
QCOMPARE (m_sliderRangeMax, KMAXVOLUME); |
|
234 |
QCOMPARE (m_volumeSliderSetTimeoutCalled, true); |
|
235 |
QCOMPARE (m_sliderTimeout, 10000); |
|
236 |
QCOMPARE (m_volumeSliderSetValueCalled, true); |
|
237 |
QCOMPARE (m_sliderValue, 1); |
|
238 |
QCOMPARE (m_volumeSliderShowCalled, true); |
|
239 |
||
240 |
// reset values |
|
241 |
m_volumeSliderContructorCalled = false; |
|
242 |
m_volumeSliderSetValueCalled = false; |
|
243 |
m_sliderRangeMin = -1; |
|
244 |
m_sliderRangeMax = -1; |
|
245 |
m_volumeSliderSetTimeoutCalled = false; |
|
246 |
m_sliderTimeout = -1; |
|
247 |
m_volumeSliderSetValueCalled = false; |
|
248 |
m_sliderValue = -1; |
|
249 |
m_volumeSliderShowCalled = false; |
|
250 |
||
251 |
// The second call shouldn't create a new instance |
|
252 |
m_view->setVolumeSliderValue (2, KVOLUMECOMMAND, KMAXVOLUME, KMINVOLUME); |
|
253 |
QCOMPARE (m_volumeSliderContructorCalled, false); |
|
254 |
QCOMPARE (m_sliderRangeMin, KMINVOLUME); |
|
255 |
QCOMPARE (m_sliderRangeMax, KMAXVOLUME); |
|
256 |
QCOMPARE (m_volumeSliderSetTimeoutCalled, false); |
|
257 |
QCOMPARE (m_sliderTimeout, -1); |
|
258 |
QCOMPARE (m_volumeSliderSetValueCalled, true); |
|
259 |
QCOMPARE (m_sliderValue, 2); |
|
260 |
QCOMPARE (m_volumeSliderShowCalled, false); |
|
261 |
} |
|
262 |
||
263 |
void TestPhoneUIQtView::testRemoveVolumeSlider () |
|
264 |
{ |
|
265 |
m_view->setVolumeSliderValue (1, KVOLUMECOMMAND, KMAXVOLUME, KMINVOLUME); |
|
266 |
m_view->removeVolumeSlider (); |
|
267 |
QCOMPARE (m_volumeSliderHideCalled, true); |
|
268 |
} |
|
269 |
||
270 |
void TestPhoneUIQtView::testVolumeSliderValue () |
|
271 |
{ |
|
272 |
m_sliderValue = -1; |
|
273 |
int value = m_view->volumeSliderValue (); |
|
274 |
QCOMPARE (m_sliderValue, -1); |
|
275 |
m_view->setVolumeSliderValue (3, KVOLUMECOMMAND, KMAXVOLUME, KMINVOLUME); |
|
276 |
value = m_view->volumeSliderValue (); |
|
277 |
QCOMPARE (m_volumeSliderValueCalled, true); |
|
278 |
QCOMPARE (value, 3); |
|
279 |
} |
|
280 |
||
281 |
void TestPhoneUIQtView::testVolumeSliderChanged () |
|
282 |
{ |
|
283 |
m_view->setVolumeSliderValue (3, KVOLUMECOMMAND, KMAXVOLUME, KMINVOLUME); |
|
284 |
QSignalSpy spy (m_view, SIGNAL(command(int))); |
|
285 |
m_view->volumeSliderChanged (1); |
|
286 |
QCOMPARE (spy.count(), 1); |
|
287 |
int command = qvariant_cast<int>(spy.at (0).at (0)); |
|
288 |
QCOMPARE (command, (int)KVOLUMECOMMAND); |
|
289 |
} |
|
290 |
||
291 |
void TestPhoneUIQtView::testParticipantListAction () |
|
292 |
{ |
|
293 |
m_view->bubbleManager ().startChanges (); |
|
294 |
m_view->addParticipantListAction (1,"Command 1", HbIcon ()); |
|
295 |
m_view->addParticipantListAction (2,"Command 2", HbIcon ()); |
|
296 |
m_view->bubbleManager ().endChanges (); |
|
297 |
||
298 |
m_view->bubbleManager ().startChanges (); |
|
299 |
m_view->clearParticipantListActions (); |
|
300 |
m_view->clearParticipantListActions (); |
|
301 |
m_view->bubbleManager ().endChanges (); |
|
302 |
} |
|
303 |
||
304 |
void TestPhoneUIQtView::testSetExpandAction () |
|
305 |
{ |
|
306 |
m_view->bubbleManager ().startChanges (); |
|
307 |
int bubbleId = createCallHeader(); |
|
308 |
int bubbleId2 = createCallHeader(); |
|
309 |
||
310 |
m_view->setExpandAction(bubbleId, 1); |
|
311 |
m_view->setExpandAction(bubbleId2, 2); |
|
312 |
m_view->bubbleManager ().endChanges (); |
|
313 |
||
314 |
m_view->bubbleManager ().startChanges (); |
|
315 |
m_view->removeExpandAction(bubbleId); |
|
316 |
m_view->removeExpandAction(bubbleId2); |
|
317 |
m_view->bubbleManager().removeCallHeader(bubbleId); |
|
318 |
m_view->bubbleManager().removeCallHeader(bubbleId2); |
|
319 |
m_view->bubbleManager ().endChanges (); |
|
320 |
} |
|
321 |
||
322 |
void TestPhoneUIQtView::testPhoneAction () |
|
323 |
{ |
|
324 |
PhoneAction *action = new PhoneAction (); |
|
325 |
QString string("Action"); |
|
326 |
action->setText(string); |
|
327 |
HbIcon icon; |
|
328 |
action->setIcon(icon); |
|
329 |
int commandId(1); |
|
330 |
action->setCommand(commandId); |
|
331 |
action->setDisabled(true); |
|
332 |
QCOMPARE( string, action->text() ); |
|
333 |
QCOMPARE( icon, action->icon() ); |
|
334 |
QCOMPARE( commandId, action->command() ); |
|
335 |
QCOMPARE( true, action->isDisabled() ); |
|
336 |
delete action; |
|
337 |
} |
|
338 |
||
339 |
void TestPhoneUIQtView::testSetOrientation () |
|
340 |
{ |
|
341 |
||
342 |
m_setOrientationCalled = false; |
|
343 |
||
344 |
m_view->handleOrientationChange(Qt::Vertical); |
|
345 |
QVERIFY( false == m_setOrientationCalled ); |
|
346 |
||
347 |
m_view->handleOrientationChange(Qt::Horizontal); |
|
348 |
QVERIFY( true == m_setOrientationCalled ); |
|
349 |
||
350 |
} |
|
351 |
||
352 |
void TestPhoneUIQtView::testBackButtonClicked() |
|
353 |
{ |
|
354 |
// not possible to mock xqservice because it is in \epoc32\include |
|
355 |
// calling backButtonClicked would send this test background. |
|
356 |
// m_view->backButtonClicked(); |
|
357 |
} |
|
358 |
||
359 |
void TestPhoneUIQtView::testShowDialpad() |
|
360 |
{ |
|
361 |
m_view->hideDialpad(); |
|
362 |
m_view->showDialpad(); |
|
363 |
m_view->showDialpad(); |
|
364 |
QVERIFY(true == m_view->isDialpadVisible()); |
|
365 |
m_view->hideDialpad(); |
|
366 |
} |
|
367 |
||
368 |
void TestPhoneUIQtView::testDialpadText() |
|
369 |
{ |
|
370 |
m_view->showDialpad(); |
|
45
6b911d05207e
Revision: 201023
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
37
diff
changeset
|
371 |
m_view->clearDialpad(); |
37 | 372 |
QVERIFY(QString("") == m_view->dialpadText()); |
373 |
m_view->clearAndHideDialpad(); |
|
374 |
} |
|
375 |
||
376 |
void TestPhoneUIQtView::testSetMenuActions() |
|
377 |
{ |
|
378 |
QList<PhoneAction*> actions; |
|
379 |
m_view->setMenuActions(actions); |
|
380 |
||
381 |
PhoneAction* phoneAction = new PhoneAction; |
|
382 |
phoneAction->setText(QString("test")); |
|
383 |
phoneAction->setCommand(1); |
|
384 |
actions.append(phoneAction); |
|
385 |
||
386 |
m_view->setMenuActions(actions); |
|
387 |
qDeleteAll(actions); |
|
388 |
actions.clear(); |
|
389 |
||
390 |
m_view->setMenuActions(actions); |
|
391 |
} |
|
392 |
||
393 |
//Private methods |
|
394 |
int TestPhoneUIQtView::createCallHeader () |
|
395 |
{ |
|
396 |
int bubble = m_view->bubbleManager().createCallHeader (); |
|
397 |
||
398 |
return bubble; |
|
399 |
} |
|
400 |
||
401 |
void TestPhoneUIQtView::testLongEndKeyPressEventOutsideTelephony() |
|
402 |
{ |
|
403 |
/*QSignalSpy spy(m_view, SIGNAL(endKeyLongPress())); |
|
404 |
QKeyEvent* event = new QKeyEvent(QEvent::ShortcutOverride, Qt::Key_No, Qt::NoModifier); |
|
405 |
||
406 |
bool returnValue = m_view->eventFilter(new QObject(), event); |
|
407 |
||
408 |
QVERIFY(returnValue == true); |
|
409 |
QCOMPARE(spy.count(), 1);*/ |
|
410 |
} |
|
411 |
||
412 |
void TestPhoneUIQtView::testNetworkNameChanged() |
|
413 |
{ |
|
45
6b911d05207e
Revision: 201023
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
37
diff
changeset
|
414 |
// Title is changed for GmsMode |
37 | 415 |
m_view->networkNameChanged(QSystemNetworkInfo::GsmMode, QString("test")); |
416 |
QCOMPARE(m_networkName, QString("test")); |
|
417 |
||
45
6b911d05207e
Revision: 201023
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
37
diff
changeset
|
418 |
// Title is changed for WcdmaMode |
6b911d05207e
Revision: 201023
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
37
diff
changeset
|
419 |
m_view->networkNameChanged(QSystemNetworkInfo::WcdmaMode, QString("test2")); |
6b911d05207e
Revision: 201023
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
37
diff
changeset
|
420 |
QCOMPARE(m_networkName, QString("test2")); |
6b911d05207e
Revision: 201023
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
37
diff
changeset
|
421 |
|
37 | 422 |
// Other modes shouldn't affect the title |
423 |
m_view->networkNameChanged(QSystemNetworkInfo::CdmaMode, QString("another operator")); |
|
45
6b911d05207e
Revision: 201023
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
37
diff
changeset
|
424 |
QCOMPARE(m_networkName, QString("test2")); |
37 | 425 |
} |
426 |
||
46
bc5a64e5bc3c
Revision: 201025
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
45
diff
changeset
|
427 |
void TestPhoneUIQtView::testCaptureKey() |
bc5a64e5bc3c
Revision: 201025
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
45
diff
changeset
|
428 |
{ |
bc5a64e5bc3c
Revision: 201025
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
45
diff
changeset
|
429 |
m_view->captureKey( Qt::Key_No, true ); |
bc5a64e5bc3c
Revision: 201025
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
45
diff
changeset
|
430 |
m_view->captureKey( Qt::Key_No, true ); |
bc5a64e5bc3c
Revision: 201025
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
45
diff
changeset
|
431 |
m_view->captureKey( Qt::Key_Yes, false ); |
bc5a64e5bc3c
Revision: 201025
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
45
diff
changeset
|
432 |
m_view->captureKey( Qt::Key_No, false ); |
bc5a64e5bc3c
Revision: 201025
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
45
diff
changeset
|
433 |
m_view->captureKey( Qt::Key_No, false ); |
bc5a64e5bc3c
Revision: 201025
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
45
diff
changeset
|
434 |
} |
bc5a64e5bc3c
Revision: 201025
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
45
diff
changeset
|
435 |
|
bc5a64e5bc3c
Revision: 201025
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
45
diff
changeset
|
436 |
void TestPhoneUIQtView::testRestrictedMode() |
bc5a64e5bc3c
Revision: 201025
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
45
diff
changeset
|
437 |
{ |
bc5a64e5bc3c
Revision: 201025
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
45
diff
changeset
|
438 |
qRegisterMetaType<QKeyEvent*>("QKeyEvent*"); |
bc5a64e5bc3c
Revision: 201025
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
45
diff
changeset
|
439 |
QKeyEvent yesDown(QEvent::KeyPress, Qt::Key_Yes, Qt::NoModifier); |
bc5a64e5bc3c
Revision: 201025
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
45
diff
changeset
|
440 |
QKeyEvent yesUp(QEvent::KeyRelease, Qt::Key_Yes, Qt::NoModifier); |
bc5a64e5bc3c
Revision: 201025
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
45
diff
changeset
|
441 |
QKeyEvent oneDown(QEvent::KeyPress, Qt::Key_1, Qt::NoModifier); |
bc5a64e5bc3c
Revision: 201025
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
45
diff
changeset
|
442 |
QKeyEvent oneUp(QEvent::KeyRelease, Qt::Key_1, Qt::NoModifier); |
bc5a64e5bc3c
Revision: 201025
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
45
diff
changeset
|
443 |
QSignalSpy downSpy(m_view, SIGNAL(keyPressed(QKeyEvent*))); |
bc5a64e5bc3c
Revision: 201025
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
45
diff
changeset
|
444 |
QSignalSpy upSpy(m_view, SIGNAL(keyReleased(QKeyEvent*))); |
bc5a64e5bc3c
Revision: 201025
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
45
diff
changeset
|
445 |
|
bc5a64e5bc3c
Revision: 201025
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
45
diff
changeset
|
446 |
m_view->setRestrictedMode(true); |
bc5a64e5bc3c
Revision: 201025
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
45
diff
changeset
|
447 |
m_view->m_dialpad->editor().setText("1"); // emits signal |
bc5a64e5bc3c
Revision: 201025
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
45
diff
changeset
|
448 |
QCOMPARE(m_view->m_dialpad->isCallButtonEnabled(), false); |
bc5a64e5bc3c
Revision: 201025
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
45
diff
changeset
|
449 |
m_view->eventFilter(0, &oneDown); |
bc5a64e5bc3c
Revision: 201025
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
45
diff
changeset
|
450 |
m_view->eventFilter(0, &oneUp); |
bc5a64e5bc3c
Revision: 201025
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
45
diff
changeset
|
451 |
m_view->eventFilter(0, &yesDown); |
bc5a64e5bc3c
Revision: 201025
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
45
diff
changeset
|
452 |
m_view->eventFilter(0, &yesUp); |
bc5a64e5bc3c
Revision: 201025
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
45
diff
changeset
|
453 |
QCOMPARE(downSpy.count(), 1); // Only Key_1 is passed |
bc5a64e5bc3c
Revision: 201025
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
45
diff
changeset
|
454 |
QCOMPARE(upSpy.count(), 1); // Only Key_1 is passed |
bc5a64e5bc3c
Revision: 201025
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
45
diff
changeset
|
455 |
QCOMPARE(m_view->m_dialpad->isCallButtonEnabled(), false); |
bc5a64e5bc3c
Revision: 201025
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
45
diff
changeset
|
456 |
QCOMPARE(m_view->m_backAction->isEnabled(), false); |
bc5a64e5bc3c
Revision: 201025
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
45
diff
changeset
|
457 |
|
bc5a64e5bc3c
Revision: 201025
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
45
diff
changeset
|
458 |
// Test backbutton |
bc5a64e5bc3c
Revision: 201025
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
45
diff
changeset
|
459 |
m_view->setBackButtonVisible(true); |
bc5a64e5bc3c
Revision: 201025
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
45
diff
changeset
|
460 |
QCOMPARE(m_view->m_backAction->isEnabled(), false); |
bc5a64e5bc3c
Revision: 201025
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
45
diff
changeset
|
461 |
|
bc5a64e5bc3c
Revision: 201025
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
45
diff
changeset
|
462 |
// Test return to normal mode |
bc5a64e5bc3c
Revision: 201025
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
45
diff
changeset
|
463 |
downSpy.clear(); |
bc5a64e5bc3c
Revision: 201025
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
45
diff
changeset
|
464 |
upSpy.clear(); |
bc5a64e5bc3c
Revision: 201025
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
45
diff
changeset
|
465 |
m_view->setRestrictedMode(false); |
bc5a64e5bc3c
Revision: 201025
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
45
diff
changeset
|
466 |
m_view->m_dialpad->editor().setText("1"); // emits signal |
bc5a64e5bc3c
Revision: 201025
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
45
diff
changeset
|
467 |
QCOMPARE(m_view->m_dialpad->isCallButtonEnabled(), true); |
bc5a64e5bc3c
Revision: 201025
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
45
diff
changeset
|
468 |
m_view->eventFilter(0, &oneDown); |
bc5a64e5bc3c
Revision: 201025
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
45
diff
changeset
|
469 |
m_view->eventFilter(0, &oneUp); |
bc5a64e5bc3c
Revision: 201025
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
45
diff
changeset
|
470 |
m_view->eventFilter(0, &yesDown); |
bc5a64e5bc3c
Revision: 201025
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
45
diff
changeset
|
471 |
m_view->eventFilter(0, &yesUp); |
bc5a64e5bc3c
Revision: 201025
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
45
diff
changeset
|
472 |
QCOMPARE(downSpy.count(), 2); |
bc5a64e5bc3c
Revision: 201025
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
45
diff
changeset
|
473 |
QCOMPARE(upSpy.count(), 2); |
bc5a64e5bc3c
Revision: 201025
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
45
diff
changeset
|
474 |
QCOMPARE(m_view->m_dialpad->isCallButtonEnabled(), true); |
bc5a64e5bc3c
Revision: 201025
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
45
diff
changeset
|
475 |
QCOMPARE(m_view->m_backAction->isEnabled(), true); |
bc5a64e5bc3c
Revision: 201025
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
45
diff
changeset
|
476 |
} |
bc5a64e5bc3c
Revision: 201025
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
45
diff
changeset
|
477 |
|
37 | 478 |
void HbView::setTitle (const QString &title) |
479 |
{ |
|
480 |
m_networkName = title; |
|
481 |
} |
|
482 |
||
46
bc5a64e5bc3c
Revision: 201025
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
45
diff
changeset
|
483 |
|
37 | 484 |
PHONE_QT_VIEW_TEST_MAIN(TestPhoneUIQtView) |
485 |
Q_DECLARE_METATYPE(QKeyEvent *) |
|
486 |
#include "unit_tests.moc" |