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