17 |
17 |
18 #include <QtTest/QtTest> |
18 #include <QtTest/QtTest> |
19 #include <QtGui> |
19 #include <QtGui> |
20 #include <QVariant> |
20 #include <QVariant> |
21 #include <QKeyEvent> |
21 #include <QKeyEvent> |
|
22 #include <QTimer> |
22 #include <hbapplication.h> |
23 #include <hbapplication.h> |
23 #include <QSignalSpy> |
24 #include <QSignalSpy> |
24 #include <hbmainwindow.h> |
25 #include <hbmainwindow.h> |
25 #include <hbinstance.h> |
26 #include <hbinstance.h> |
26 #include <hbmainwindow.h> |
27 #include <hbmainwindow.h> |
35 |
36 |
36 //CONSTANTS |
37 //CONSTANTS |
37 static const int KMAXVOLUME = 10; |
38 static const int KMAXVOLUME = 10; |
38 static const int KMINVOLUME = 0; |
39 static const int KMINVOLUME = 0; |
39 static const int KVOLUMECOMMAND = 5; |
40 static const int KVOLUMECOMMAND = 5; |
|
41 |
|
42 bool m_qtimer_stop_called; |
40 |
43 |
41 |
44 |
42 #define PHONE_QT_VIEW_TEST_MAIN(TestObject) \ |
45 #define PHONE_QT_VIEW_TEST_MAIN(TestObject) \ |
43 int main(int argc, char *argv[]) \ |
46 int main(int argc, char *argv[]) \ |
44 { \ |
47 { \ |
84 void testSetOrientation (); |
87 void testSetOrientation (); |
85 void testBackButtonClicked(); |
88 void testBackButtonClicked(); |
86 void testShowDialpad(); |
89 void testShowDialpad(); |
87 void testDialpadText(); |
90 void testDialpadText(); |
88 void testSetMenuActions(); |
91 void testSetMenuActions(); |
|
92 void testLongEndKeyPressEvent(); |
89 |
93 |
90 private: |
94 private: |
91 int createCallHeader(); |
95 int createCallHeader(); |
92 |
96 |
93 private: |
97 private: |
94 PhoneUIQtView *m_view; // class under test |
98 PhoneUIQtView *m_view; // class under test |
95 HbMainWindow *m_main_window; |
99 HbMainWindow *m_main_window; |
96 |
100 |
97 }; |
101 }; |
98 |
102 |
99 |
103 void QTimer::stop() |
|
104 { |
|
105 m_qtimer_stop_called = true; |
|
106 } |
|
107 |
100 TestPhoneUIQtView::TestPhoneUIQtView () |
108 TestPhoneUIQtView::TestPhoneUIQtView () |
101 { |
109 { |
102 } |
110 } |
103 |
111 |
104 TestPhoneUIQtView::~TestPhoneUIQtView () |
112 TestPhoneUIQtView::~TestPhoneUIQtView () |
105 { |
113 { |
106 } |
114 } |
107 |
115 |
108 void TestPhoneUIQtView::initTestCase () |
116 void TestPhoneUIQtView::initTestCase () |
109 { |
117 { |
110 } |
|
111 |
|
112 void TestPhoneUIQtView::cleanupTestCase () |
|
113 { |
|
114 } |
|
115 |
|
116 void TestPhoneUIQtView::init () |
|
117 { |
|
118 m_main_window = new HbMainWindow(); |
118 m_main_window = new HbMainWindow(); |
119 m_view = new PhoneUIQtView(*m_main_window); |
119 m_view = new PhoneUIQtView(*m_main_window); |
120 } |
120 } |
121 |
121 |
|
122 void TestPhoneUIQtView::cleanupTestCase () |
|
123 { |
|
124 delete m_view; |
|
125 } |
|
126 |
|
127 void TestPhoneUIQtView::init () |
|
128 { |
|
129 m_qtimer_stop_called = false; |
|
130 } |
|
131 |
122 void TestPhoneUIQtView::cleanup () |
132 void TestPhoneUIQtView::cleanup () |
123 { |
133 { |
124 delete m_view; |
|
125 delete m_main_window; |
|
126 } |
134 } |
127 |
135 |
128 void TestPhoneUIQtView::testAddBubbleCommand () |
136 void TestPhoneUIQtView::testAddBubbleCommand () |
129 { |
137 { |
130 m_view->bubbleManager ().startChanges (); |
138 m_view->bubbleManager ().startChanges (); |
167 void TestPhoneUIQtView::testShowToolbar () |
175 void TestPhoneUIQtView::testShowToolbar () |
168 { |
176 { |
169 m_view->showToolbar (); |
177 m_view->showToolbar (); |
170 QCOMPARE (m_showCalled, true); |
178 QCOMPARE (m_showCalled, true); |
171 } |
179 } |
|
180 |
172 void TestPhoneUIQtView::testAddToolbarActions () |
181 void TestPhoneUIQtView::testAddToolbarActions () |
173 { |
182 { |
174 m_actions.clear(); |
183 m_actions.clear(); |
175 HbIcon icon ("foo.jpg"); |
184 HbIcon icon ("foo.jpg"); |
176 PhoneAction *testAction = new PhoneAction (); |
185 PhoneAction *testAction = new PhoneAction (); |
376 int bubble = m_view->bubbleManager().createCallHeader (); |
385 int bubble = m_view->bubbleManager().createCallHeader (); |
377 |
386 |
378 return bubble; |
387 return bubble; |
379 } |
388 } |
380 |
389 |
|
390 void TestPhoneUIQtView::testLongEndKeyPressEvent() |
|
391 { |
|
392 QSignalSpy spy(m_view, SIGNAL(endKeyLongPress())); |
|
393 m_view->longEndKeyPressEvent(); |
|
394 QVERIFY(m_qtimer_stop_called == true); |
|
395 QCOMPARE(spy.count(), 1); |
|
396 } |
|
397 |
381 PHONE_QT_VIEW_TEST_MAIN(TestPhoneUIQtView) |
398 PHONE_QT_VIEW_TEST_MAIN(TestPhoneUIQtView) |
382 Q_DECLARE_METATYPE(QKeyEvent *) |
399 Q_DECLARE_METATYPE(QKeyEvent *) |
383 #include "unit_tests.moc" |
400 #include "unit_tests.moc" |