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