|
1 /* |
|
2 * Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies). |
|
3 * All rights reserved. |
|
4 * |
|
5 * This program is free software: you can redistribute it and/or modify |
|
6 * it under the terms of the GNU Lesser General Public License as published by |
|
7 * the Free Software Foundation, version 2.1 of the License. |
|
8 * |
|
9 * This program is distributed in the hope that it will be useful, |
|
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of |
|
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
|
12 * GNU Lesser General Public License for more details. |
|
13 * |
|
14 * You should have received a copy of the GNU Lesser General Public License |
|
15 * along with this program. If not, |
|
16 * see "http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html/". |
|
17 * |
|
18 * Description: |
|
19 * |
|
20 */ |
|
21 |
|
22 |
|
23 #include "at_servicesregression.h" |
|
24 |
|
25 #include <QtTest/QtTest> |
|
26 #include <QUrl> |
|
27 #include <QFile> |
|
28 |
|
29 #include <xqaiwrequest.h> |
|
30 #include <xqsharablefile.h> |
|
31 #include <xqaiwdecl.h> |
|
32 #include <xqaiwdeclplat.h> |
|
33 #include <akndef.h> |
|
34 #include <w32std.h> |
|
35 #include <coemain.h> |
|
36 |
|
37 #define LASTEROR QString(" - Last Error: " + QString::number(mAppManager->lastError())) |
|
38 |
|
39 void TestServicesRegression::initTestCase() |
|
40 { |
|
41 request = NULL; |
|
42 mAppManager = NULL; |
|
43 } |
|
44 |
|
45 void TestServicesRegression::cleanupTestCase() |
|
46 { |
|
47 |
|
48 } |
|
49 |
|
50 void TestServicesRegression::init() |
|
51 { |
|
52 mAppManager = new XQApplicationManager(); |
|
53 QVERIFY(mAppManager != NULL); |
|
54 QVERIFY(mAppManager->lastError() == XQService::ENoError); |
|
55 closeApp = false; |
|
56 } |
|
57 |
|
58 void TestServicesRegression::cleanup() |
|
59 { |
|
60 delete mAppManager; |
|
61 mAppManager = NULL; |
|
62 if (closeApp) |
|
63 closeFocusedWG(); |
|
64 } |
|
65 |
|
66 void TestServicesRegression::platform_services_data() |
|
67 { |
|
68 QStringList operations; |
|
69 |
|
70 QTest::addColumn<QString>("interface"); |
|
71 QTest::addColumn<QStringList>("operations"); |
|
72 |
|
73 operations << XQOP_IMAGE_FETCH.latin1(); |
|
74 QTest::newRow("photos") << XQI_IMAGE_FETCH.latin1() << operations; |
|
75 operations.clear(); |
|
76 |
|
77 operations << XQOP_MUSIC_FETCH.latin1(); |
|
78 QTest::newRow("musicplayer") << XQI_MUSIC_FETCH.latin1() << operations; |
|
79 operations.clear(); |
|
80 |
|
81 operations << XQOP_TONE_FETCH.latin1(); |
|
82 QTest::newRow("tonefetcher") << XQI_TONE_FETCH.latin1() << operations; |
|
83 operations.clear(); |
|
84 |
|
85 operations << XQOP_VIDEO_FETCH.latin1(); |
|
86 QTest::newRow("videoplayer") << XQI_VIDEO_FETCH.latin1() << operations; |
|
87 operations.clear(); |
|
88 |
|
89 operations << XQOP_VIDEO_PLAY.latin1() << XQOP_VIDEO_PLAY_PD.latin1() << XQOP_VIDEO_CLOSE.latin1(); |
|
90 QTest::newRow("videoplayer") << XQI_VIDEO_PLAY.latin1() << operations; |
|
91 operations.clear(); |
|
92 |
|
93 operations << XQOP_VIDEO_BROWSE.latin1(); |
|
94 QTest::newRow("videoplayer") << XQI_VIDEO_BROWSE.latin1() << operations; |
|
95 operations.clear(); |
|
96 |
|
97 operations << XQOP_CAMERA_CAPTURE.latin1(); |
|
98 QTest::newRow("cxui") << XQI_CAMERA_CAPTURE.latin1() << operations; |
|
99 operations.clear(); |
|
100 |
|
101 operations << XQOP_LOGS_SHOW.latin1(); |
|
102 QTest::newRow("logs") << XQI_LOGS_VIEW.latin1() << operations; |
|
103 operations.clear(); |
|
104 |
|
105 operations << XQOP_CONTACTS_EDIT_CREATE_NEW.latin1() << XQOP_CONTACTS_EDIT_CREATE_NEW_WITH_SUBTYPE.latin1() << XQOP_CONTACTS_EDIT_CREATE_NEW_VCARD.latin1() |
|
106 << XQOP_CONTACTS_EDIT_EXISTING.latin1() << XQOP_CONTACTS_EDIT_UPDATE_EXISTING.latin1() << XQOP_CONTACTS_EDIT_UPDATE_EXISTING_WITH_SUBTYPE.latin1(); |
|
107 QTest::newRow("phonebookservices") << XQI_CONTACTS_EDIT.latin1() << operations; |
|
108 operations.clear(); |
|
109 |
|
110 operations << XQOP_CONTACTS_FETCH_MULTIPLE.latin1() << XQOP_CONTACTS_FETCH_SINGLE.latin1(); |
|
111 QTest::newRow("phonebookservices") << XQI_CONTACTS_FETCH.latin1() << operations; |
|
112 operations.clear(); |
|
113 |
|
114 operations << XQOP_CONTACTS_VIEW_CONTACT_CARD.latin1() << XQOP_CONTACTS_VIEW_TEMP_CONTACT_CARD_WITH_DETAIL.latin1() << XQOP_CONTACTS_VIEW_GROUP.latin1(); |
|
115 QTest::newRow("phonebookservices") << XQI_CONTACTS_VIEW.latin1() << operations; |
|
116 operations.clear(); |
|
117 |
|
118 operations << "send(const QString,const qint32, const QString)" << "send(const QString,const QString,const QString)" |
|
119 << "send(QVariantMap,const QString)"; |
|
120 QTest::newRow("messaging") << XQI_MESSAGE_SEND.latin1() << operations; |
|
121 operations.clear(); |
|
122 |
|
123 operations << "fetch(QVariantMap, QVariant)"; |
|
124 QTest::newRow("filemgr") << XQI_FILE_FETCH.latin1() << operations; |
|
125 operations.clear(); |
|
126 |
|
127 operations << XQOP_RADIO_CONTROL.latin1(); |
|
128 QTest::newRow("qtfmradio") << XQI_RADIO_CONTROL.latin1() << operations; |
|
129 operations.clear(); |
|
130 |
|
131 operations << XQOP_RADIO_MONITOR.latin1(); |
|
132 QTest::newRow("qtfmradio") << XQI_RADIO_MONITOR.latin1() << operations; |
|
133 operations.clear(); |
|
134 |
|
135 operations << XQOP_WLAN_SNIFFER.latin1(); |
|
136 QTest::newRow("wlansniffer") << XQI_WLAN_SNIFFER.latin1() << operations; |
|
137 operations.clear(); |
|
138 |
|
139 operations << XQOP1_WLAN_LOGIN.latin1() << XQOP2_WLAN_LOGIN.latin1(); |
|
140 QTest::newRow("wlanlogin") << XQI_WLAN_LOGIN.latin1() << operations; |
|
141 operations.clear(); |
|
142 |
|
143 operations << XQOP_EMAIL_INBOX_VIEW.latin1(); |
|
144 QTest::newRow("nmailui") << XQI_EMAIL_INBOX_VIEW.latin1() << operations; |
|
145 operations.clear(); |
|
146 |
|
147 operations << XQOP_EMAIL_MESSAGE_VIEW.latin1(); |
|
148 QTest::newRow("nmailui") << XQI_EMAIL_MESSAGE_VIEW.latin1() << operations; |
|
149 operations.clear(); |
|
150 |
|
151 operations << XQOP_EMAIL_MESSAGE_SEND.latin1(); |
|
152 QTest::newRow("nmailui") << XQI_EMAIL_MESSAGE_SEND.latin1() << operations; |
|
153 operations.clear(); |
|
154 |
|
155 operations << XQOP_EMAIL_REGISTER_ACCOUNT.latin1() << XQOP_EMAIL_UPDATE_MAILBOX.latin1() << XQOP_EMAIL_UNREGISTER_MAILBOX.latin1(); |
|
156 QTest::newRow("nmailui") << XQI_EMAIL_REGISTER_ACCOUNT.latin1() << operations; |
|
157 operations.clear(); |
|
158 |
|
159 operations << XQOP_EMAIL_MAILBOX_CONFIGURE.latin1(); |
|
160 QTest::newRow("nmailui") << XQI_EMAIL_MAILBOX_CONFIGURE.latin1() << operations; |
|
161 operations.clear(); |
|
162 |
|
163 operations << "dial(const QString&)" << "dial(const QString&, int)" << "dialVideo(const QString&)" << "dialVideo(const QString&, int)" |
|
164 << "dialVoip(const QString&)" << "dialVoip(const QString&, int)" << "dialVoipService(const QString&, int)" |
|
165 << "dialVoipService(const QString&, int, int)"; |
|
166 QTest::newRow("phoneui") << XQI_CALL_DIAL.latin1() << operations; |
|
167 operations.clear(); |
|
168 |
|
169 operations << "playDTMFTone(const QChar&)" << "stopDTMFPlay()"; |
|
170 QTest::newRow("phoneui") << XQI_DTMF_PLAY.latin1() << operations; |
|
171 operations.clear(); |
|
172 } |
|
173 |
|
174 void TestServicesRegression::platform_services() |
|
175 { |
|
176 QFETCH(QString, interface); |
|
177 QFETCH(QStringList, operations); |
|
178 |
|
179 foreach (QString operation, operations) { |
|
180 XQAiwRequest* req = mAppManager->create(interface, operation); |
|
181 QVERIFY2(req != NULL, |
|
182 QString("Cannot create request for interface:" + interface + ", operation:" + operation + LASTEROR).toAscii()); |
|
183 delete req; |
|
184 } |
|
185 |
|
186 } |
|
187 |
|
188 void TestServicesRegression::platform_services_operations_data() |
|
189 { |
|
190 platform_services_data(); |
|
191 } |
|
192 |
|
193 void TestServicesRegression::platform_services_operations() |
|
194 { |
|
195 QFETCH(QString, interface); |
|
196 QFETCH(QStringList, operations); |
|
197 |
|
198 foreach (QString operation, operations){ |
|
199 if (closeApp) |
|
200 closeFocusedWG(); |
|
201 |
|
202 request = mAppManager->create(interface, operation, false); |
|
203 if (request) { |
|
204 request->setSynchronous(false); |
|
205 closeApp = true; |
|
206 |
|
207 QVERIFY2(request->send(), QString("Send request failed, interface:" + interface + ", operation:" + operation + LASTEROR).toAscii()); |
|
208 } |
|
209 else |
|
210 closeApp = false; |
|
211 } |
|
212 } |
|
213 |
|
214 void TestServicesRegression::platform_url_data() |
|
215 { |
|
216 QTest::addColumn<QString>("url"); |
|
217 |
|
218 QTest::newRow("http") << "http:"; |
|
219 QTest::newRow("https") << "https:"; |
|
220 QTest::newRow("mailto") << "mailto:"; |
|
221 QTest::newRow("cti") << "cti:"; |
|
222 QTest::newRow("mmsto") << "mmsto:"; |
|
223 QTest::newRow("sms") << "sms:"; |
|
224 QTest::newRow("javaapp") << "javaapp:"; |
|
225 QTest::newRow("tel") << "tel:"; |
|
226 } |
|
227 |
|
228 void TestServicesRegression::platform_url() |
|
229 { |
|
230 QFETCH(QString, url); |
|
231 |
|
232 url += "temp"; |
|
233 |
|
234 XQAiwRequest* request = mAppManager->create(QUrl(url), false); |
|
235 QVERIFY2(request != NULL, QString("Cannot create request for url:" + url + LASTEROR).toAscii()); |
|
236 request->setSynchronous(false); |
|
237 |
|
238 QList<QVariant> args; |
|
239 args << url; |
|
240 request->setArguments(args); |
|
241 |
|
242 closeApp = true; |
|
243 |
|
244 QVERIFY2(request->send(), QString("Send request failed, url:" + url + LASTEROR).toAscii()); |
|
245 } |
|
246 |
|
247 void TestServicesRegression::platform_file_data() |
|
248 { |
|
249 #ifdef __WINS__ |
|
250 const QString drive = "c"; |
|
251 #else |
|
252 const QString drive = "z"; |
|
253 #endif |
|
254 |
|
255 QTest::addColumn<QString>("fileStr"); |
|
256 QTest::newRow("image") << drive + ":\\data\\Others\\one_v2.jpg"; |
|
257 QTest::newRow("audio") << drive + ":\\data\\Others\\111-test1_v2.odf"; |
|
258 QTest::newRow("video") << drive + ":\\data\\Others\\324kbps_MPEG4_352x288_AAC_15fps.3gp"; |
|
259 } |
|
260 |
|
261 void TestServicesRegression::platform_file() |
|
262 { |
|
263 QFETCH(QString, fileStr); |
|
264 |
|
265 QFile file(fileStr); |
|
266 |
|
267 XQAiwRequest* request = mAppManager->create(file, false); |
|
268 QVERIFY2(request != NULL, QString("Cannot create request for file:" + fileStr + LASTEROR).toAscii()); |
|
269 request->setSynchronous(false); |
|
270 |
|
271 QList<QVariant> args; |
|
272 args << fileStr; |
|
273 request->setArguments(args); |
|
274 |
|
275 closeApp = true; |
|
276 |
|
277 QVERIFY2(request->send(), QString("Send request failed, file:" + fileStr + LASTEROR).toAscii()); |
|
278 } |
|
279 |
|
280 void TestServicesRegression::platform_file_share() |
|
281 { |
|
282 QList<XQAiwInterfaceDescriptor> listFileShare = mAppManager->list(XQI_FILE_SHARE.latin1(), XQOP_FILE_SHARE.latin1()); |
|
283 |
|
284 QVERIFY2(listFileShare.count() > 2, "There must be minimum three implementations in platform"); |
|
285 |
|
286 foreach (XQAiwInterfaceDescriptor interface, listFileShare) { |
|
287 XQAiwRequest* request = mAppManager->create(interface, XQOP_FILE_SHARE.latin1()); |
|
288 QVERIFY2(request != NULL, QString("Cannot create request for file share:" + interface.serviceName() + LASTEROR).toAscii()); |
|
289 delete request; |
|
290 } |
|
291 } |
|
292 |
|
293 void TestServicesRegression::closeFocusedWG() |
|
294 { |
|
295 QTest::qWait(10000); // wait for service start |
|
296 |
|
297 TInt myWGId = CCoeEnv::Static()->RootWin().Identifier(); |
|
298 TInt focusedWGId = CCoeEnv::Static()->WsSession().GetFocusWindowGroup(); |
|
299 |
|
300 if (myWGId != focusedWGId) { |
|
301 TWsEvent event; |
|
302 event.SetType(EEventKey); |
|
303 event.SetTimeNow(); |
|
304 event.SetType(KAknShutOrHideApp); |
|
305 CCoeEnv::Static()->WsSession().SendEventToWindowGroup(focusedWGId, event); |
|
306 } |
|
307 |
|
308 if (request) { |
|
309 delete request; |
|
310 request = NULL; |
|
311 } |
|
312 |
|
313 QTest::qWait(4000); // wait for service close |
|
314 } |
|
315 |
|
316 int main (int argc, char* argv[]) |
|
317 { |
|
318 QApplication app(argc, argv); |
|
319 QTEST_DISABLE_KEYPAD_NAVIGATION |
|
320 TestServicesRegression tc; |
|
321 int ret = 0; |
|
322 if (argc == 1) { |
|
323 int c = 5; |
|
324 char* v[] = {argv[0], "-o", "c:/at_regression.txt", "-maxwarnings", "0"}; |
|
325 ret = QTest::qExec(&tc, c, v); |
|
326 } |
|
327 else { |
|
328 ret = QTest::qExec(&tc, argc, argv); |
|
329 } |
|
330 return ret; |
|
331 } |
|
332 |