|
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 PhoneNoteController. |
|
15 * |
|
16 */ |
|
17 |
|
18 #include <QtTest/QtTest> |
|
19 #include <QtGui> |
|
20 #include <hbapplication.h> |
|
21 #include <QSignalSpy> |
|
22 //#include <hbglobal_p.h> |
|
23 #include "phonenotecontroller.h" |
|
24 #include "phoneresourceids.h" |
|
25 #include "phoneui.hrh" |
|
26 #include "tphonecmdparamglobalnote.h" |
|
27 #include "tphonecmdparamquery.h" |
|
28 #include "phoneresourceadapter.h" |
|
29 #include "phoneconstants.h" |
|
30 |
|
31 #define PHONE_QT_NOTE_CONTROLLER_TEST_MAIN(TestObject) \ |
|
32 int main(int argc, char *argv[]) \ |
|
33 { \ |
|
34 HbApplication app(argc, argv); \ |
|
35 TestObject tc; \ |
|
36 QResource::registerResource("../hbcore.rcc"); \ |
|
37 int ret = QTest::qExec(&tc, argc, argv); \ |
|
38 /* Core dump if HbIconLoader instance is not destroyed before the application instance. */ \ |
|
39 /* HbIconLoader uses QCoreApplication::aboutToQuit() signal to destroy itself. */ \ |
|
40 /* app.exec() where the signal is normally emitted is not called here. */ \ |
|
41 /* So, invoking the signal explicitly. */ \ |
|
42 QMetaObject::invokeMethod(&app, "aboutToQuit", Qt::DirectConnection); \ |
|
43 return ret; \ |
|
44 } |
|
45 |
|
46 class TestPhoneNoteController : public QObject |
|
47 { |
|
48 Q_OBJECT |
|
49 public: |
|
50 TestPhoneNoteController(); |
|
51 virtual ~TestPhoneNoteController(); |
|
52 |
|
53 public slots: |
|
54 void initTestCase (); |
|
55 void cleanupTestCase (); |
|
56 void init (); |
|
57 void cleanup (); |
|
58 |
|
59 private slots: |
|
60 void testShowGlobalNoteDefault (); |
|
61 void testShowGlobalInfoNoteWithResourceId (); |
|
62 void testShowGlobalWarningNoteWithText (); |
|
63 void testShowGlobalNoteWithTextAndResourceId (); |
|
64 void testShowGlobalNoteTwoTimes (); |
|
65 void testShowGlobalNoteThreeTimes (); |
|
66 void testShowNote(); |
|
67 void testShowQuery(); |
|
68 void testShowClobalWaitNote(); |
|
69 void testShowIndicationDialogDefault (); |
|
70 void testShowIndicationDialogWithResourceId (); |
|
71 void testShowIndicationDialogWithText (); |
|
72 void testShowIndicationDialogTextAndResourceId (); |
|
73 void testShowIndicationDialogTwoTimes (); |
|
74 void testShowIndicationDialogThreeTimes (); |
|
75 |
|
76 private: |
|
77 PhoneNoteController *m_noteController; // class under test |
|
78 }; |
|
79 |
|
80 TestPhoneNoteController::TestPhoneNoteController () |
|
81 { |
|
82 } |
|
83 |
|
84 TestPhoneNoteController::~TestPhoneNoteController () |
|
85 { |
|
86 } |
|
87 |
|
88 void TestPhoneNoteController::initTestCase () |
|
89 { |
|
90 m_noteController = new PhoneNoteController(); |
|
91 } |
|
92 |
|
93 void TestPhoneNoteController::cleanupTestCase () |
|
94 { |
|
95 delete m_noteController; |
|
96 } |
|
97 |
|
98 void TestPhoneNoteController::init () |
|
99 { |
|
100 } |
|
101 |
|
102 void TestPhoneNoteController::cleanup () |
|
103 { |
|
104 } |
|
105 |
|
106 void TestPhoneNoteController::testShowGlobalNoteDefault () |
|
107 { |
|
108 TPhoneCmdParamGlobalNote globalNoteParam; |
|
109 globalNoteParam.SetTimeout(0); |
|
110 globalNoteParam.SetWaitForReady(ETrue); |
|
111 m_noteController->showGlobalNote(&globalNoteParam); |
|
112 QTest::qWait(2500); |
|
113 |
|
114 globalNoteParam.SetTimeout(KPhoneNoteNoTimeout); |
|
115 m_noteController->showGlobalNote(&globalNoteParam); |
|
116 QTest::qWait(2500); |
|
117 } |
|
118 |
|
119 void TestPhoneNoteController::testShowGlobalInfoNoteWithResourceId () |
|
120 { |
|
121 TPhoneCmdParamGlobalNote globalNoteParam; |
|
122 globalNoteParam.SetTextResourceId(R_NOTETEXT_NO_ANSWER); |
|
123 globalNoteParam.SetWaitForReady(EFalse); |
|
124 globalNoteParam.SetType( EPhoneMessageBoxInformation ); |
|
125 |
|
126 m_noteController->showGlobalNote(&globalNoteParam); |
|
127 |
|
128 QTest::qWait(5000); |
|
129 } |
|
130 |
|
131 void TestPhoneNoteController::testShowGlobalWarningNoteWithText () |
|
132 { |
|
133 TPhoneCmdParamGlobalNote globalNoteParam; |
|
134 globalNoteParam.SetWaitForReady(ETrue); |
|
135 globalNoteParam.SetType( EPhoneMessageBoxWarning ); |
|
136 globalNoteParam.SetText(_L("Test note 1")); |
|
137 |
|
138 m_noteController->showGlobalNote(&globalNoteParam); |
|
139 } |
|
140 |
|
141 void TestPhoneNoteController::testShowGlobalNoteWithTextAndResourceId () |
|
142 { |
|
143 TPhoneCmdParamGlobalNote globalNoteParam; |
|
144 globalNoteParam.SetTextResourceId(R_PHONE_TEXT_COLP_CONNECTED); |
|
145 globalNoteParam.SetWaitForReady(EFalse); |
|
146 globalNoteParam.SetType( EPhoneMessageBoxInformation ); |
|
147 globalNoteParam.SetText(_L("Test number")); |
|
148 |
|
149 m_noteController->showGlobalNote(&globalNoteParam); |
|
150 |
|
151 QTest::qWait(5000); |
|
152 } |
|
153 |
|
154 void TestPhoneNoteController::testShowGlobalNoteTwoTimes () |
|
155 { |
|
156 TPhoneCmdParamGlobalNote globalNoteParam; |
|
157 //globalNoteParam.SetTextResourceId(R_NOTETEXT_NO_ANSWER); |
|
158 globalNoteParam.SetWaitForReady(EFalse); |
|
159 globalNoteParam.SetType( EPhoneMessageBoxInformation ); |
|
160 globalNoteParam.SetText(_L("Test note 2")); |
|
161 |
|
162 m_noteController->showGlobalNote(&globalNoteParam); |
|
163 |
|
164 globalNoteParam.SetText(_L("Test note 3")); |
|
165 |
|
166 m_noteController->showGlobalNote(&globalNoteParam); |
|
167 |
|
168 QTest::qWait(10000); |
|
169 |
|
170 } |
|
171 |
|
172 void TestPhoneNoteController::testShowGlobalNoteThreeTimes () |
|
173 { |
|
174 TPhoneCmdParamGlobalNote globalNoteParam; |
|
175 //globalNoteParam.SetTextResourceId(R_NOTETEXT_NO_ANSWER); |
|
176 globalNoteParam.SetWaitForReady(EFalse); |
|
177 globalNoteParam.SetType( EPhoneMessageBoxInformation ); |
|
178 globalNoteParam.SetText(_L("Test note 4")); |
|
179 |
|
180 m_noteController->showGlobalNote(&globalNoteParam); |
|
181 |
|
182 globalNoteParam.SetText(_L("Test note 5")); |
|
183 |
|
184 m_noteController->showGlobalNote(&globalNoteParam); |
|
185 |
|
186 globalNoteParam.SetText(_L("Test note 6")); |
|
187 |
|
188 m_noteController->showGlobalNote(&globalNoteParam); |
|
189 |
|
190 QTest::qWait(5000); |
|
191 } |
|
192 |
|
193 void TestPhoneNoteController::testShowNote() |
|
194 { |
|
195 TPhoneCmdParamNote noteParam; |
|
196 |
|
197 m_noteController->showNote(¬eParam); |
|
198 m_noteController->removeDtmfNote(); |
|
199 m_noteController->removeNote(); |
|
200 |
|
201 noteParam.SetType(EPhoneNoteDtmfSending); |
|
202 m_noteController->showNote(¬eParam); |
|
203 |
|
204 noteParam.SetResourceId(R_PHONEUI_SENDING_DTMF_WAIT_NOTE); |
|
205 noteParam.SetText(_L("Sending:\n123p456")); |
|
206 |
|
207 m_noteController->showNote(¬eParam); |
|
208 QTest::qWait(5000); |
|
209 |
|
210 noteParam.SetText(_L("Sending:\n123p456")); |
|
211 m_noteController->showNote(¬eParam); |
|
212 |
|
213 QTest::qWait(5000); |
|
214 |
|
215 m_noteController->removeNote(); |
|
216 |
|
217 QTest::qWait(5000); |
|
218 } |
|
219 |
|
220 void TestPhoneNoteController::testShowQuery() |
|
221 { |
|
222 TPhoneCmdParamQuery queryParam; |
|
223 m_noteController->showQuery(&queryParam); |
|
224 |
|
225 queryParam.SetQueryType(EPhoneQueryDialog); |
|
226 m_noteController->showQuery(&queryParam); |
|
227 |
|
228 queryParam.SetQueryPrompt(_L("TestQuery")); |
|
229 m_noteController->showQuery(&queryParam); |
|
230 m_noteController->removeQuery(); |
|
231 |
|
232 queryParam.SetQueryResourceId(R_PHONEUI_DTMF_WAIT_CHARACTER_CONFIRMATION_QUERY); |
|
233 m_noteController->showQuery(&queryParam); |
|
234 |
|
235 QTest::qWait(5000); |
|
236 m_noteController->showQuery(&queryParam); |
|
237 |
|
238 m_noteController->removeQuery(); |
|
239 |
|
240 QTest::qWait(5000); |
|
241 } |
|
242 |
|
243 void TestPhoneNoteController::testShowClobalWaitNote() |
|
244 { |
|
245 TPhoneCmdParamQuery queryParam; |
|
246 |
|
247 queryParam.SetQueryType(EPhoneGlobalWaitNote); |
|
248 m_noteController->showQuery(&queryParam); |
|
249 QTest::qWait(5000); |
|
250 m_noteController->removeGlobalWaitNote(); |
|
251 QTest::qWait(5000); |
|
252 |
|
253 queryParam.SetQueryPrompt(_L("TestQuery")); |
|
254 m_noteController->showQuery(&queryParam); |
|
255 QTest::qWait(5000); |
|
256 m_noteController->removeGlobalWaitNote(); |
|
257 QTest::qWait(5000); |
|
258 |
|
259 queryParam.SetQueryPrompt(KNullDesC); |
|
260 TBuf<4> buf(_L("test")); |
|
261 queryParam.SetDataText(&buf); |
|
262 queryParam.SetTimeOut(2000); |
|
263 m_noteController->showQuery(&queryParam); |
|
264 QTest::qWait(5000); |
|
265 |
|
266 queryParam.SetCustomCommandForTimeOut(10); |
|
267 m_noteController->showQuery(&queryParam); |
|
268 QTest::qWait(5000); |
|
269 } |
|
270 |
|
271 void TestPhoneNoteController::testShowIndicationDialogDefault () |
|
272 { |
|
273 TPhoneCmdParamGlobalNote globalNoteParam; |
|
274 globalNoteParam.SetNotificationDialog( ETrue ); |
|
275 globalNoteParam.SetTimeout(0); |
|
276 m_noteController->showGlobalNote(&globalNoteParam); |
|
277 QTest::qWait(2500); |
|
278 |
|
279 globalNoteParam.SetTimeout(KPhoneNoteNoTimeout); |
|
280 m_noteController->showGlobalNote(&globalNoteParam); |
|
281 QTest::qWait(2500); |
|
282 } |
|
283 |
|
284 void TestPhoneNoteController::testShowIndicationDialogWithResourceId () |
|
285 { |
|
286 TPhoneCmdParamGlobalNote globalNoteParam; |
|
287 globalNoteParam.SetNotificationDialog( ETrue ); |
|
288 globalNoteParam.SetTextResourceId(R_NOTETEXT_NO_ANSWER); |
|
289 globalNoteParam.SetType( EPhoneNotificationDialog ); |
|
290 |
|
291 m_noteController->showGlobalNote(&globalNoteParam); |
|
292 |
|
293 QTest::qWait(5000); |
|
294 } |
|
295 |
|
296 void TestPhoneNoteController::testShowIndicationDialogWithText () |
|
297 { |
|
298 TPhoneCmdParamGlobalNote globalNoteParam; |
|
299 globalNoteParam.SetNotificationDialog( ETrue ); |
|
300 globalNoteParam.SetType( EAknGlobalWarningNote ); |
|
301 globalNoteParam.SetText(_L("Test indication 1")); |
|
302 |
|
303 m_noteController->showGlobalNote(&globalNoteParam); |
|
304 } |
|
305 |
|
306 void TestPhoneNoteController::testShowIndicationDialogTextAndResourceId () |
|
307 { |
|
308 TPhoneCmdParamGlobalNote globalNoteParam; |
|
309 globalNoteParam.SetNotificationDialog( ETrue ); |
|
310 globalNoteParam.SetTextResourceId(R_PHONE_TEXT_COLP_CONNECTED); |
|
311 globalNoteParam.SetType( EPhoneNotificationDialog ); |
|
312 globalNoteParam.SetText(_L("Indication number")); |
|
313 globalNoteParam.SetTimeout(1000); |
|
314 |
|
315 m_noteController->showGlobalNote(&globalNoteParam); |
|
316 |
|
317 QTest::qWait(2000); |
|
318 } |
|
319 |
|
320 void TestPhoneNoteController::testShowIndicationDialogTwoTimes () |
|
321 { |
|
322 TPhoneCmdParamGlobalNote globalNoteParam; |
|
323 globalNoteParam.SetNotificationDialog( ETrue ); |
|
324 //globalNoteParam.SetTextResourceId(R_NOTETEXT_NO_ANSWER); |
|
325 globalNoteParam.SetType( EPhoneNotificationDialog ); |
|
326 globalNoteParam.SetText(_L("Test indication 2")); |
|
327 |
|
328 m_noteController->showGlobalNote(&globalNoteParam); |
|
329 |
|
330 globalNoteParam.SetText(_L("Test indication 3")); |
|
331 |
|
332 m_noteController->showGlobalNote(&globalNoteParam); |
|
333 |
|
334 QTest::qWait(5000); |
|
335 |
|
336 } |
|
337 |
|
338 void TestPhoneNoteController::testShowIndicationDialogThreeTimes () |
|
339 { |
|
340 TPhoneCmdParamGlobalNote globalNoteParam; |
|
341 globalNoteParam.SetNotificationDialog( ETrue ); |
|
342 globalNoteParam.SetType( EPhoneNotificationDialog ); |
|
343 globalNoteParam.SetText(_L("Test indication 4")); |
|
344 |
|
345 m_noteController->showGlobalNote(&globalNoteParam); |
|
346 |
|
347 globalNoteParam.SetText(_L("Test indication 5")); |
|
348 |
|
349 globalNoteParam.SetTimeout(1000); |
|
350 m_noteController->showGlobalNote(&globalNoteParam); |
|
351 |
|
352 globalNoteParam.SetText(_L("Test indication 6")); |
|
353 |
|
354 m_noteController->showGlobalNote(&globalNoteParam); |
|
355 |
|
356 QTest::qWait(20000); |
|
357 } |
|
358 |
|
359 PHONE_QT_NOTE_CONTROLLER_TEST_MAIN(TestPhoneNoteController) |
|
360 #include "unit_tests.moc" |