19 #include <QtGui> |
19 #include <QtGui> |
20 #include <hbapplication.h> |
20 #include <hbapplication.h> |
21 #include <QSignalSpy> |
21 #include <QSignalSpy> |
22 #include <xqservicerequest.h> |
22 #include <xqservicerequest.h> |
23 #include <hbmenu.h> |
23 #include <hbmenu.h> |
|
24 #include <mockservice.h> |
24 |
25 |
25 #include "telephonyservice.h" |
26 #include "telephonyservice.h" |
26 #include "phoneuiqtviewif.h" |
27 #include "phoneuiqtviewif.h" |
27 #include "phoneuiqtviewadapter.h" |
28 #include "phoneuiqtviewadapter.h" |
|
29 #include "tphonecmdparaminteger.h" |
|
30 #include "qtestmains60.h" |
28 |
31 |
29 extern bool phoneAppStart; |
32 class TestTelephonyService : public QObject, PhoneUIQtViewIF, MockService |
30 extern bool inCallDialerStart; |
|
31 |
|
32 #define PHONE_QT_NOTE_CONTROLLER_TEST_MAIN(TestObject) \ |
|
33 int main(int argc, char *argv[]) \ |
|
34 { \ |
|
35 HbApplication app(argc, argv); \ |
|
36 TestObject tc; \ |
|
37 QResource::registerResource("../hbcore.rcc"); \ |
|
38 int ret = QTest::qExec(&tc, argc, argv); \ |
|
39 /* Core dump if HbIconLoader instance is not destroyed before the application instance. */ \ |
|
40 /* HbIconLoader uses QCoreApplication::aboutToQuit() signal to destroy itself. */ \ |
|
41 /* app.exec() where the signal is normally emitted is not called here. */ \ |
|
42 /* So, invoking the signal explicitly. */ \ |
|
43 QMetaObject::invokeMethod(&app, "aboutToQuit", Qt::DirectConnection); \ |
|
44 return ret; \ |
|
45 } |
|
46 |
|
47 class TestTelephonyService : public QObject, public PhoneUIQtViewIF |
|
48 { |
33 { |
49 Q_OBJECT |
34 Q_OBJECT |
50 public: |
35 public: |
51 TestTelephonyService(); |
36 TestTelephonyService(); |
52 virtual ~TestTelephonyService(); |
37 virtual ~TestTelephonyService(); |
84 void clearDialpad() {}; |
69 void clearDialpad() {}; |
85 void bringToForeground() {}; |
70 void bringToForeground() {}; |
86 void setMenuActions(const QList<PhoneAction*>& ){}; |
71 void setMenuActions(const QList<PhoneAction*>& ){}; |
87 void shutdownPhoneApp() {}; |
72 void shutdownPhoneApp() {}; |
88 void setBackButtonVisible(bool ) {}; |
73 void setBackButtonVisible(bool ) {}; |
89 HbMenu &menuReference() { return mMenu; }; |
74 HbMenu &menuReference() {}; |
90 void captureKey(Qt::Key , bool ) {}; |
75 void captureKey(Qt::Key , bool ) {}; |
91 void setRestrictedMode(bool ) {}; |
76 void setRestrictedMode(bool ) {}; |
92 |
77 |
93 public slots: |
78 public slots: |
94 void initTestCase (); |
79 void initTestCase (); |
100 void testConstructionDestruction (); |
85 void testConstructionDestruction (); |
101 void startPhoneApp (); |
86 void startPhoneApp (); |
102 void startInCallDialer (); |
87 void startInCallDialer (); |
103 |
88 |
104 private: |
89 private: |
|
90 PhoneUIQtViewAdapter* m_viewAdapter; |
105 TelephonyService *m_service; // class under test |
91 TelephonyService *m_service; // class under test |
106 PhoneUIQtViewAdapter *m_viewstub; // stub test |
|
107 HbMenu mMenu; |
|
108 }; |
92 }; |
109 |
93 |
110 TestTelephonyService::TestTelephonyService () |
94 TestTelephonyService::TestTelephonyService () |
111 { |
95 { |
112 } |
96 } |
115 { |
99 { |
116 } |
100 } |
117 |
101 |
118 void TestTelephonyService::initTestCase () |
102 void TestTelephonyService::initTestCase () |
119 { |
103 { |
120 m_viewstub = new PhoneUIQtViewAdapter (*this); |
104 m_viewAdapter = new PhoneUIQtViewAdapter(*this); |
121 m_service = new TelephonyService(m_viewstub, this); |
105 m_service = new TelephonyService(m_viewAdapter, this); |
122 } |
106 } |
123 |
107 |
124 void TestTelephonyService::cleanupTestCase () |
108 void TestTelephonyService::cleanupTestCase () |
125 { |
109 { |
126 if (m_viewstub) { |
110 delete m_viewAdapter; |
127 delete m_viewstub; |
|
128 } |
|
129 |
|
130 if (m_service) { |
|
131 delete m_service; |
111 delete m_service; |
132 } |
|
133 } |
112 } |
134 |
113 |
135 void TestTelephonyService::init () |
114 void TestTelephonyService::init () |
136 { |
115 { |
|
116 initialize(); |
137 } |
117 } |
138 |
118 |
139 void TestTelephonyService::cleanup () |
119 void TestTelephonyService::cleanup () |
140 { |
120 { |
|
121 reset(); |
141 } |
122 } |
142 |
123 |
143 void TestTelephonyService::testConstructionDestruction () |
124 void TestTelephonyService::testConstructionDestruction () |
144 { |
125 { |
145 // empty |
126 // empty |
146 } |
127 } |
147 |
128 |
148 void TestTelephonyService::startPhoneApp () |
129 void TestTelephonyService::startPhoneApp () |
149 { |
130 { |
150 phoneAppStart = false; |
131 int phoneApp(0); |
151 inCallDialerStart = false; |
132 EXPECT( PhoneUIQtViewAdapter, ExecuteCommandL ).with<TPhoneViewCommandId>( EPhoneViewBringPhoneAppToForeground ); |
152 int phoneApp(0); |
|
153 m_service->start(phoneApp); |
133 m_service->start(phoneApp); |
154 QVERIFY (phoneAppStart == true); |
134 QVERIFY(verify()); |
155 QVERIFY (inCallDialerStart == false); |
|
156 } |
135 } |
157 |
136 |
158 void TestTelephonyService::startInCallDialer () |
137 void TestTelephonyService::startInCallDialer () |
159 { |
138 { |
160 phoneAppStart = false; |
|
161 inCallDialerStart = false; |
|
162 int dialer(1); |
139 int dialer(1); |
|
140 |
|
141 EXPECT( PhoneUIQtViewAdapter, ExecuteCommandL ).with( EPhoneViewOpenDialer ); |
|
142 EXPECT( PhoneUIQtViewAdapter, ExecuteCommandL ).with<TPhoneViewCommandId>( EPhoneViewBringPhoneAppToForeground ); |
163 m_service->start(dialer); |
143 m_service->start(dialer); |
164 QVERIFY (phoneAppStart == true); |
144 QVERIFY(verify()); |
165 QVERIFY (inCallDialerStart == true); |
|
166 } |
145 } |
167 |
146 |
168 PHONE_QT_NOTE_CONTROLLER_TEST_MAIN(TestTelephonyService) |
147 QTEST_MAIN_S60(TestTelephonyService) |
169 #include "unit_tests.moc" |
148 #include "unit_tests.moc" |