Merge lp:~abreu-alexandre/unity-webapps-qml/fix-issues-uncovered-by-qmlplugindump into lp:unity-webapps-qml
- fix-issues-uncovered-by-qmlplugindump
- Merge into trunk
Proposed by
Alexandre Abreu
Status: | Merged | ||||
---|---|---|---|---|---|
Merged at revision: | 125 | ||||
Proposed branch: | lp:~abreu-alexandre/unity-webapps-qml/fix-issues-uncovered-by-qmlplugindump | ||||
Merge into: | lp:unity-webapps-qml | ||||
Diff against target: |
1031 lines (+453/-253) 27 files modified
debian/unity-webapps-qml-autopilot.install (+1/-0) src/Ubuntu/UnityWebApps/UnityWebApps.qml (+19/-1) src/Ubuntu/UnityWebApps/UnityWebAppsUtils.js (+4/-0) src/Ubuntu/UnityWebApps/plugin/plugin.pro (+0/-2) src/Ubuntu/UnityWebApps/plugin/qml-plugin.cpp (+0/-2) src/Ubuntu/UnityWebApps/plugin/unity-webapps-app-infos.cpp (+2/-1) src/Ubuntu/UnityWebApps/plugin/unity-webapps-app-model-filter-proxy.cpp (+0/-76) src/Ubuntu/UnityWebApps/plugin/unity-webapps-app-model-filter-proxy.h (+0/-87) src/Ubuntu/UnityWebApps/plugin/unity-webapps-app-model.cpp (+1/-1) src/Ubuntu/UnityWebApps/plugin/unity-webapps-app-model.h (+1/-1) tests/integration/autopilot/autopilot.pro (+7/-2) tests/integration/autopilot/data/all-in-same-folder/script.user.js (+1/-0) tests/integration/autopilot/data/all-in-same-folder/webapp-properties.json (+8/-0) tests/integration/autopilot/data/unity-webapps-normal/manifest.json (+7/-0) tests/integration/autopilot/data/unity-webapps-normal/script.user.js (+1/-0) tests/integration/autopilot/data/unity-webapps-with-altered-ua-string/manifest.json (+8/-0) tests/integration/autopilot/data/unity-webapps-with-altered-ua-string/script.user.js (+1/-0) tests/integration/autopilot/qml/FullWebViewApp.qml (+48/-23) tests/integration/autopilot/qml/WebviewBackendOxide.qml (+87/-0) tests/integration/autopilot/qml/WebviewBackendWebkit.qml (+19/-0) tests/integration/autopilot/qml/message-server.js (+29/-0) tests/integration/autopilot/unity_webapps_qml/emulators/__init__.py (+0/-7) tests/integration/autopilot/unity_webapps_qml/tests/__init__.py (+66/-31) tests/integration/autopilot/unity_webapps_qml/tests/fake_servers.py (+70/-0) tests/integration/autopilot/unity_webapps_qml/tests/test_installedWebapp.py (+59/-0) tests/integration/test-server.py (+0/-18) tools/qml-launcher/qml-launcher.cpp (+14/-1) |
||||
To merge this branch: | bzr merge lp:~abreu-alexandre/unity-webapps-qml/fix-issues-uncovered-by-qmlplugindump | ||||
Related bugs: |
|
Reviewer | Review Type | Date Requested | Status |
---|---|---|---|
PS Jenkins bot (community) | continuous-integration | Approve | |
WebApps | Pending | ||
Review via email: mp+226026@code.launchpad.net |
Commit message
Fix issue with qmlplugindump using 100% cpu
Fix and expanded AP tests to properly test the installed webapps case
Description of the change
Fix issue with qmlplugindump using 100% cpu
Fix and expanded AP tests to properly test the installed webapps case
To post a comment you must log in.
- 128. By Alexandre Abreu
-
update debian install file
Revision history for this message
PS Jenkins bot (ps-jenkins) wrote : | # |
review:
Needs Fixing
(continuous-integration)
- 129. By Alexandre Abreu
-
forgotten files
Revision history for this message
PS Jenkins bot (ps-jenkins) wrote : | # |
PASSED: Continuous integration, rev:129
http://
Executed test runs:
SUCCESS: http://
SUCCESS: http://
Click here to trigger a rebuild:
http://
review:
Approve
(continuous-integration)
Preview Diff
[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1 | === modified file 'debian/unity-webapps-qml-autopilot.install' | |||
2 | --- debian/unity-webapps-qml-autopilot.install 2013-07-25 04:03:42 +0000 | |||
3 | +++ debian/unity-webapps-qml-autopilot.install 2014-07-08 20:49:15 +0000 | |||
4 | @@ -1,3 +1,4 @@ | |||
5 | 1 | tests/integration/autopilot/html/* usr/share/unity-webapps-qml/autopilot-tests/html/ | 1 | tests/integration/autopilot/html/* usr/share/unity-webapps-qml/autopilot-tests/html/ |
6 | 2 | tests/integration/autopilot/data/* usr/share/unity-webapps-qml/autopilot-tests/data/ | ||
7 | 2 | tests/integration/autopilot/qml/* usr/share/unity-webapps-qml/autopilot-tests/qml/ | 3 | tests/integration/autopilot/qml/* usr/share/unity-webapps-qml/autopilot-tests/qml/ |
8 | 3 | usr/lib/python* | 4 | usr/lib/python* |
9 | 4 | 5 | ||
10 | === modified file 'src/Ubuntu/UnityWebApps/UnityWebApps.qml' | |||
11 | --- src/Ubuntu/UnityWebApps/UnityWebApps.qml 2014-06-26 01:46:36 +0000 | |||
12 | +++ src/Ubuntu/UnityWebApps/UnityWebApps.qml 2014-07-08 20:49:15 +0000 | |||
13 | @@ -150,6 +150,15 @@ | |||
14 | 150 | */ | 150 | */ |
15 | 151 | property var _opt_backendProxies: null | 151 | property var _opt_backendProxies: null |
16 | 152 | 152 | ||
17 | 153 | /*! | ||
18 | 154 | \qmlproperty string UnityWebApps::_opt_homepage | ||
19 | 155 | |||
20 | 156 | Used only for testing. | ||
21 | 157 | Allows an optional a homepage to be specified when running a local http server. | ||
22 | 158 | |||
23 | 159 | */ | ||
24 | 160 | property string _opt_homepage: "" | ||
25 | 161 | |||
26 | 153 | 162 | ||
27 | 154 | Settings { | 163 | Settings { |
28 | 155 | id: settings | 164 | id: settings |
29 | @@ -325,6 +334,9 @@ | |||
30 | 325 | var idx = model.getWebappIndex(webappName); | 334 | var idx = model.getWebappIndex(webappName); |
31 | 326 | var homepage = model.data(idx, UbuntuUnityWebApps.UnityWebappsAppModel.Homepage); | 335 | var homepage = model.data(idx, UbuntuUnityWebApps.UnityWebappsAppModel.Homepage); |
32 | 327 | 336 | ||
33 | 337 | if (!homepage || homepage.length === 0) { | ||
34 | 338 | homepage = _opt_homepage; | ||
35 | 339 | } | ||
36 | 328 | console.debug('Requesting the bindee to navigate to homepage: ' + homepage); | 340 | console.debug('Requesting the bindee to navigate to homepage: ' + homepage); |
37 | 329 | 341 | ||
38 | 330 | // We recreate a bindee object, but we call any function that requires | 342 | // We recreate a bindee object, but we call any function that requires |
39 | @@ -352,7 +364,7 @@ | |||
40 | 352 | 364 | ||
41 | 353 | Component.onCompleted: { | 365 | Component.onCompleted: { |
42 | 354 | if (model) { | 366 | if (model) { |
44 | 355 | model.modelChanged.connect(function() { __setupNamedWebappEnvironment() }); | 367 | __setupNamedWebappEnvironment(); |
45 | 356 | } | 368 | } |
46 | 357 | } | 369 | } |
47 | 358 | 370 | ||
48 | @@ -360,6 +372,12 @@ | |||
49 | 360 | \internal | 372 | \internal |
50 | 361 | 373 | ||
51 | 362 | */ | 374 | */ |
52 | 375 | onModelChanged: model.modelContentChanged.connect(__setupNamedWebappEnvironment) | ||
53 | 376 | |||
54 | 377 | /*! | ||
55 | 378 | \internal | ||
56 | 379 | |||
57 | 380 | */ | ||
58 | 363 | onBindeeChanged: { | 381 | onBindeeChanged: { |
59 | 364 | // cleanup old refs & go | 382 | // cleanup old refs & go |
60 | 365 | webapps.__unbind(); | 383 | webapps.__unbind(); |
61 | 366 | 384 | ||
62 | === modified file 'src/Ubuntu/UnityWebApps/UnityWebAppsUtils.js' | |||
63 | --- src/Ubuntu/UnityWebApps/UnityWebAppsUtils.js 2014-06-26 01:48:23 +0000 | |||
64 | +++ src/Ubuntu/UnityWebApps/UnityWebAppsUtils.js 2014-07-08 20:49:15 +0000 | |||
65 | @@ -71,6 +71,10 @@ | |||
66 | 71 | return; | 71 | return; |
67 | 72 | 72 | ||
68 | 73 | var context = this.webview.context; | 73 | var context = this.webview.context; |
69 | 74 | if (!context) { | ||
70 | 75 | console.error('No context found for the current Oxide webview. Cannot inject user scripts.'); | ||
71 | 76 | return; | ||
72 | 77 | } | ||
73 | 74 | 78 | ||
74 | 75 | for (var i = 0; i < userScriptUrls.length; ++i) { | 79 | for (var i = 0; i < userScriptUrls.length; ++i) { |
75 | 76 | var scriptStart = "import com.canonical.Oxide 1.0 as Oxide; Oxide.UserScript { context:"; | 80 | var scriptStart = "import com.canonical.Oxide 1.0 as Oxide; Oxide.UserScript { context:"; |
76 | 77 | 81 | ||
77 | === modified file 'src/Ubuntu/UnityWebApps/plugin/plugin.pro' | |||
78 | --- src/Ubuntu/UnityWebApps/plugin/plugin.pro 2014-03-25 20:56:01 +0000 | |||
79 | +++ src/Ubuntu/UnityWebApps/plugin/plugin.pro 2014-07-08 20:49:15 +0000 | |||
80 | @@ -35,7 +35,6 @@ | |||
81 | 35 | unity-webapps-api-mediaplayer.cpp \ | 35 | unity-webapps-api-mediaplayer.cpp \ |
82 | 36 | unity-webapps-app-model.cpp \ | 36 | unity-webapps-app-model.cpp \ |
83 | 37 | unity-webapps-app-manifest-parser.cpp \ | 37 | unity-webapps-app-manifest-parser.cpp \ |
84 | 38 | unity-webapps-app-model-filter-proxy.cpp \ | ||
85 | 39 | unity-webapps-app-infos.cpp \ | 38 | unity-webapps-app-infos.cpp \ |
86 | 40 | unity-webapps-desktop-infos.cpp \ | 39 | unity-webapps-desktop-infos.cpp \ |
87 | 41 | unity-webapps-icon-utils.cpp \ | 40 | unity-webapps-icon-utils.cpp \ |
88 | @@ -54,7 +53,6 @@ | |||
89 | 54 | unity-webapps-app-model.h \ | 53 | unity-webapps-app-model.h \ |
90 | 55 | unity-webapps-app-manifest-parser.h \ | 54 | unity-webapps-app-manifest-parser.h \ |
91 | 56 | unity-webapps-common-priv.h \ | 55 | unity-webapps-common-priv.h \ |
92 | 57 | unity-webapps-app-model-filter-proxy.h \ | ||
93 | 58 | unity-webapps-app-infos.h \ | 56 | unity-webapps-app-infos.h \ |
94 | 59 | unity-webapps-desktop-infos.h \ | 57 | unity-webapps-desktop-infos.h \ |
95 | 60 | unity-webapps-icon-utils.h \ | 58 | unity-webapps-icon-utils.h \ |
96 | 61 | 59 | ||
97 | === modified file 'src/Ubuntu/UnityWebApps/plugin/qml-plugin.cpp' | |||
98 | --- src/Ubuntu/UnityWebApps/plugin/qml-plugin.cpp 2014-03-21 20:07:16 +0000 | |||
99 | +++ src/Ubuntu/UnityWebApps/plugin/qml-plugin.cpp 2014-07-08 20:49:15 +0000 | |||
100 | @@ -26,7 +26,6 @@ | |||
101 | 26 | #include "unity-webapps-api-messaging-menu.h" | 26 | #include "unity-webapps-api-messaging-menu.h" |
102 | 27 | #include "unity-webapps-api-launcher.h" | 27 | #include "unity-webapps-api-launcher.h" |
103 | 28 | #include "unity-webapps-api-mediaplayer.h" | 28 | #include "unity-webapps-api-mediaplayer.h" |
104 | 29 | #include "unity-webapps-app-model-filter-proxy.h" | ||
105 | 30 | #include "unity-webapps-app-model.h" | 29 | #include "unity-webapps-app-model.h" |
106 | 31 | #include "unity-webapps-app-infos.h" | 30 | #include "unity-webapps-app-infos.h" |
107 | 32 | 31 | ||
108 | @@ -55,7 +54,6 @@ | |||
109 | 55 | 54 | ||
110 | 56 | // misc | 55 | // misc |
111 | 57 | qmlRegisterType<UnityWebappsAppModel> (uri, 0, 1, "UnityWebappsAppModel"); | 56 | qmlRegisterType<UnityWebappsAppModel> (uri, 0, 1, "UnityWebappsAppModel"); |
112 | 58 | qmlRegisterType<UnityWebappsAppModelFilterProxy> (uri, 0, 1, "UnityWebappsAppModelFilterProxy"); | ||
113 | 59 | qmlRegisterType<UnityWebappsCallback> (uri, 0, 1, "UnityWebappsCallback"); | 57 | qmlRegisterType<UnityWebappsCallback> (uri, 0, 1, "UnityWebappsCallback"); |
114 | 60 | qmlRegisterType<UnityWebappsAppInfos> (uri, 0, 1, "UnityWebappsAppInfos"); | 58 | qmlRegisterType<UnityWebappsAppInfos> (uri, 0, 1, "UnityWebappsAppInfos"); |
115 | 61 | 59 | ||
116 | 62 | 60 | ||
117 | === modified file 'src/Ubuntu/UnityWebApps/plugin/unity-webapps-app-infos.cpp' | |||
118 | --- src/Ubuntu/UnityWebApps/plugin/unity-webapps-app-infos.cpp 2014-03-07 16:48:42 +0000 | |||
119 | +++ src/Ubuntu/UnityWebApps/plugin/unity-webapps-app-infos.cpp 2014-07-08 20:49:15 +0000 | |||
120 | @@ -28,7 +28,8 @@ | |||
121 | 28 | 28 | ||
122 | 29 | 29 | ||
123 | 30 | UnityWebappsAppInfos::UnityWebappsAppInfos(QObject *parent) | 30 | UnityWebappsAppInfos::UnityWebappsAppInfos(QObject *parent) |
125 | 31 | : QObject(parent) | 31 | : QObject(parent), |
126 | 32 | _model(NULL) | ||
127 | 32 | {} | 33 | {} |
128 | 33 | 34 | ||
129 | 34 | UnityWebappsAppInfos::~UnityWebappsAppInfos() | 35 | UnityWebappsAppInfos::~UnityWebappsAppInfos() |
130 | 35 | 36 | ||
131 | === removed file 'src/Ubuntu/UnityWebApps/plugin/unity-webapps-app-model-filter-proxy.cpp' | |||
132 | --- src/Ubuntu/UnityWebApps/plugin/unity-webapps-app-model-filter-proxy.cpp 2014-01-17 15:51:27 +0000 | |||
133 | +++ src/Ubuntu/UnityWebApps/plugin/unity-webapps-app-model-filter-proxy.cpp 1970-01-01 00:00:00 +0000 | |||
134 | @@ -1,76 +0,0 @@ | |||
135 | 1 | /* | ||
136 | 2 | * Copyright 2013 Canonical Ltd. | ||
137 | 3 | * | ||
138 | 4 | * This file is part of unity-webapps-qml. | ||
139 | 5 | * | ||
140 | 6 | * unity-webapps-qml is free software; you can redistribute it and/or modify | ||
141 | 7 | * it under the terms of the GNU General Public License as published by | ||
142 | 8 | * the Free Software Foundation; version 3. | ||
143 | 9 | * | ||
144 | 10 | * unity-webapps-qml is distributed in the hope that it will be useful, | ||
145 | 11 | * but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
146 | 12 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
147 | 13 | * GNU General Public License for more details. | ||
148 | 14 | * | ||
149 | 15 | * You should have received a copy of the GNU General Public License | ||
150 | 16 | * along with this program. If not, see <http://www.gnu.org/licenses/>. | ||
151 | 17 | */ | ||
152 | 18 | |||
153 | 19 | #include "unity-webapps-app-model-filter-proxy.h" | ||
154 | 20 | |||
155 | 21 | #include "unity-webapps-app-model.h" | ||
156 | 22 | |||
157 | 23 | |||
158 | 24 | UnityWebappsAppModelFilterProxy::UnityWebappsAppModelFilterProxy(QObject *parent) | ||
159 | 25 | : QSortFilterProxyModel(parent) | ||
160 | 26 | {} | ||
161 | 27 | |||
162 | 28 | |||
163 | 29 | UnityWebappsAppModelFilterProxy::~UnityWebappsAppModelFilterProxy() | ||
164 | 30 | {} | ||
165 | 31 | |||
166 | 32 | |||
167 | 33 | UnityWebappsAppModel* UnityWebappsAppModelFilterProxy::sourceModel () const | ||
168 | 34 | { | ||
169 | 35 | return sourceModel(); | ||
170 | 36 | } | ||
171 | 37 | |||
172 | 38 | |||
173 | 39 | void UnityWebappsAppModelFilterProxy::setsourceModel (UnityWebappsAppModel * model) | ||
174 | 40 | { | ||
175 | 41 | setSourceModel(model); | ||
176 | 42 | |||
177 | 43 | Q_EMIT sourceModelChanged(); | ||
178 | 44 | } | ||
179 | 45 | |||
180 | 46 | |||
181 | 47 | QString UnityWebappsAppModelFilterProxy::webappName () const | ||
182 | 48 | { | ||
183 | 49 | return _name; | ||
184 | 50 | } | ||
185 | 51 | |||
186 | 52 | |||
187 | 53 | void UnityWebappsAppModelFilterProxy::setwebappName (const QString& name) | ||
188 | 54 | { | ||
189 | 55 | _name = name; | ||
190 | 56 | |||
191 | 57 | Q_EMIT webappNameChanged(); | ||
192 | 58 | } | ||
193 | 59 | |||
194 | 60 | |||
195 | 61 | bool UnityWebappsAppModelFilterProxy::filterAcceptsRow(int source_row, | ||
196 | 62 | const QModelIndex &source_parent) const | ||
197 | 63 | { | ||
198 | 64 | if (_name.isEmpty() || !sourceModel()) | ||
199 | 65 | { | ||
200 | 66 | // filter out everything | ||
201 | 67 | return false; | ||
202 | 68 | } | ||
203 | 69 | |||
204 | 70 | QString rowName = | ||
205 | 71 | sourceModel()->data(sourceModel()->index(source_row, 0, source_parent), | ||
206 | 72 | UnityWebappsAppModel::Name).toString(); | ||
207 | 73 | |||
208 | 74 | return 0 == _name.toLower().compare(rowName.toLower()); | ||
209 | 75 | } | ||
210 | 76 | |||
211 | 77 | 0 | ||
212 | === removed file 'src/Ubuntu/UnityWebApps/plugin/unity-webapps-app-model-filter-proxy.h' | |||
213 | --- src/Ubuntu/UnityWebApps/plugin/unity-webapps-app-model-filter-proxy.h 2014-01-17 15:51:27 +0000 | |||
214 | +++ src/Ubuntu/UnityWebApps/plugin/unity-webapps-app-model-filter-proxy.h 1970-01-01 00:00:00 +0000 | |||
215 | @@ -1,87 +0,0 @@ | |||
216 | 1 | /* | ||
217 | 2 | * Copyright 2013 Canonical Ltd. | ||
218 | 3 | * | ||
219 | 4 | * This file is part of unity-webapps-qml. | ||
220 | 5 | * | ||
221 | 6 | * unity-webapps-qml is free software; you can redistribute it and/or modify | ||
222 | 7 | * it under the terms of the GNU General Public License as published by | ||
223 | 8 | * the Free Software Foundation; version 3. | ||
224 | 9 | * | ||
225 | 10 | * unity-webapps-qml is distributed in the hope that it will be useful, | ||
226 | 11 | * but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
227 | 12 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
228 | 13 | * GNU General Public License for more details. | ||
229 | 14 | * | ||
230 | 15 | * You should have received a copy of the GNU General Public License | ||
231 | 16 | * along with this program. If not, see <http://www.gnu.org/licenses/>. | ||
232 | 17 | */ | ||
233 | 18 | |||
234 | 19 | #if !defined(__UNITY_WEBAPPS_APP_MODEL_FILTER_PROXY_H__) | ||
235 | 20 | #define __UNITY_WEBAPPS_APP_MODEL_FILTER_PROXY_H__ | ||
236 | 21 | |||
237 | 22 | // Qt | ||
238 | 23 | #include <QHash> | ||
239 | 24 | #include <QSharedPointer> | ||
240 | 25 | #include <QSortFilterProxyModel> | ||
241 | 26 | |||
242 | 27 | |||
243 | 28 | class UnityWebappsAppModel; | ||
244 | 29 | |||
245 | 30 | /*! | ||
246 | 31 | * \brief The UnityWebappsAppModelFilterProxy class | ||
247 | 32 | */ | ||
248 | 33 | class UnityWebappsAppModelFilterProxy : public QSortFilterProxyModel | ||
249 | 34 | { | ||
250 | 35 | Q_OBJECT | ||
251 | 36 | |||
252 | 37 | Q_PROPERTY(QString webappName READ webappName WRITE setwebappName NOTIFY webappNameChanged) | ||
253 | 38 | Q_PROPERTY(UnityWebappsAppModel * sourceModel READ sourceModel WRITE setsourceModel NOTIFY sourceModelChanged) | ||
254 | 39 | |||
255 | 40 | |||
256 | 41 | public: | ||
257 | 42 | UnityWebappsAppModelFilterProxy(QObject *parent = 0); | ||
258 | 43 | virtual ~UnityWebappsAppModelFilterProxy(); | ||
259 | 44 | |||
260 | 45 | /*! | ||
261 | 46 | * \brief webappName | ||
262 | 47 | * \return | ||
263 | 48 | */ | ||
264 | 49 | QString webappName () const; | ||
265 | 50 | |||
266 | 51 | /*! | ||
267 | 52 | * \brief setwebappName | ||
268 | 53 | * \param name | ||
269 | 54 | */ | ||
270 | 55 | void setwebappName (const QString& name); | ||
271 | 56 | |||
272 | 57 | /*! | ||
273 | 58 | * \brief sourceModel | ||
274 | 59 | * \return | ||
275 | 60 | */ | ||
276 | 61 | UnityWebappsAppModel * sourceModel() const; | ||
277 | 62 | |||
278 | 63 | /*! | ||
279 | 64 | * \brief setSourceModel | ||
280 | 65 | * \param model | ||
281 | 66 | */ | ||
282 | 67 | void setsourceModel(UnityWebappsAppModel * model); | ||
283 | 68 | |||
284 | 69 | |||
285 | 70 | Q_SIGNALS: | ||
286 | 71 | |||
287 | 72 | void webappNameChanged () const; | ||
288 | 73 | void sourceModelChanged () const; | ||
289 | 74 | |||
290 | 75 | |||
291 | 76 | protected: | ||
292 | 77 | |||
293 | 78 | // From QSortFilterProxyModel::filterAcceptsRow | ||
294 | 79 | bool filterAcceptsRow(int source_row, const QModelIndex& source_parent) const; | ||
295 | 80 | |||
296 | 81 | |||
297 | 82 | private: | ||
298 | 83 | |||
299 | 84 | QString _name; | ||
300 | 85 | }; | ||
301 | 86 | |||
302 | 87 | #endif // __UNITY_WEBAPPS_APP_MODEL_FILTER_PROXY_H__ | ||
303 | 88 | 0 | ||
304 | === modified file 'src/Ubuntu/UnityWebApps/plugin/unity-webapps-app-model.cpp' | |||
305 | --- src/Ubuntu/UnityWebApps/plugin/unity-webapps-app-model.cpp 2014-05-22 08:54:56 +0000 | |||
306 | +++ src/Ubuntu/UnityWebApps/plugin/unity-webapps-app-model.cpp 2014-07-08 20:49:15 +0000 | |||
307 | @@ -301,7 +301,7 @@ | |||
308 | 301 | content); | 301 | content); |
309 | 302 | } | 302 | } |
310 | 303 | 303 | ||
312 | 304 | Q_EMIT modelChanged(); | 304 | Q_EMIT modelContentChanged(); |
313 | 305 | } | 305 | } |
314 | 306 | 306 | ||
315 | 307 | QString | 307 | QString |
316 | 308 | 308 | ||
317 | === modified file 'src/Ubuntu/UnityWebApps/plugin/unity-webapps-app-model.h' | |||
318 | --- src/Ubuntu/UnityWebApps/plugin/unity-webapps-app-model.h 2014-05-22 08:54:56 +0000 | |||
319 | +++ src/Ubuntu/UnityWebApps/plugin/unity-webapps-app-model.h 2014-07-08 20:49:15 +0000 | |||
320 | @@ -137,7 +137,7 @@ | |||
321 | 137 | Q_SIGNALS: | 137 | Q_SIGNALS: |
322 | 138 | 138 | ||
323 | 139 | void searchPathChanged(const QString & path); | 139 | void searchPathChanged(const QString & path); |
325 | 140 | void modelChanged(); | 140 | void modelContentChanged(); |
326 | 141 | 141 | ||
327 | 142 | 142 | ||
328 | 143 | private Q_SLOTS: | 143 | private Q_SLOTS: |
329 | 144 | 144 | ||
330 | === modified file 'tests/integration/autopilot/autopilot.pro' | |||
331 | --- tests/integration/autopilot/autopilot.pro 2013-08-26 20:16:16 +0000 | |||
332 | +++ tests/integration/autopilot/autopilot.pro 2014-07-08 20:49:15 +0000 | |||
333 | @@ -5,5 +5,10 @@ | |||
334 | 5 | $$system(ls ./html/*) \ | 5 | $$system(ls ./html/*) \ |
335 | 6 | $$system(ls ./unity_webapps_qml/emulators/*.py) \ | 6 | $$system(ls ./unity_webapps_qml/emulators/*.py) \ |
336 | 7 | $$system(ls ./unity_webapps_qml/tests/*.py) \ | 7 | $$system(ls ./unity_webapps_qml/tests/*.py) \ |
339 | 8 | $$system(ls ./data/installed-webapps/*) | 8 | $$system(ls ./unity_webapps_qml/*.py) \ |
340 | 9 | 9 | $$system(ls ./data/*/*) \ | |
341 | 10 | unity_webapps_qml/tests/test_installedWebapp.py \ | ||
342 | 11 | unity_webapps_qml/tests/fake_servers.py \ | ||
343 | 12 | qml/WebviewBackendWebkit.qml \ | ||
344 | 13 | qml/WebviewBackendOxide.qml \ | ||
345 | 14 | qml/message-server.js | ||
346 | 10 | 15 | ||
347 | === added directory 'tests/integration/autopilot/data' | |||
348 | === added directory 'tests/integration/autopilot/data/all-in-same-folder' | |||
349 | === added file 'tests/integration/autopilot/data/all-in-same-folder/script.user.js' | |||
350 | --- tests/integration/autopilot/data/all-in-same-folder/script.user.js 1970-01-01 00:00:00 +0000 | |||
351 | +++ tests/integration/autopilot/data/all-in-same-folder/script.user.js 2014-07-08 20:49:15 +0000 | |||
352 | @@ -0,0 +1,1 @@ | |||
353 | 1 | document.getElementById('content').innerHTML="WebApp Script Injected" | ||
354 | 0 | 2 | ||
355 | === added file 'tests/integration/autopilot/data/all-in-same-folder/webapp-properties.json' | |||
356 | --- tests/integration/autopilot/data/all-in-same-folder/webapp-properties.json 1970-01-01 00:00:00 +0000 | |||
357 | +++ tests/integration/autopilot/data/all-in-same-folder/webapp-properties.json 2014-07-08 20:49:15 +0000 | |||
358 | @@ -0,0 +1,8 @@ | |||
359 | 1 | { | ||
360 | 2 | "includes": ["http://localhost:*/*"], | ||
361 | 3 | "name": "ExtendedWebappProperties", | ||
362 | 4 | "scripts": ["script.user.js"], | ||
363 | 5 | "domain":"", | ||
364 | 6 | "homepage":"", | ||
365 | 7 | "user-agent-override": "My Override" | ||
366 | 8 | } | ||
367 | 0 | 9 | ||
368 | === added directory 'tests/integration/autopilot/data/unity-webapps-normal' | |||
369 | === added file 'tests/integration/autopilot/data/unity-webapps-normal/manifest.json' | |||
370 | --- tests/integration/autopilot/data/unity-webapps-normal/manifest.json 1970-01-01 00:00:00 +0000 | |||
371 | +++ tests/integration/autopilot/data/unity-webapps-normal/manifest.json 2014-07-08 20:49:15 +0000 | |||
372 | @@ -0,0 +1,7 @@ | |||
373 | 1 | { | ||
374 | 2 | "includes": ["http://localhost:*/*"], | ||
375 | 3 | "name": "Normal", | ||
376 | 4 | "scripts": ["script.user.js"], | ||
377 | 5 | "domain":"", | ||
378 | 6 | "homepage":"" | ||
379 | 7 | } | ||
380 | 0 | 8 | ||
381 | === added file 'tests/integration/autopilot/data/unity-webapps-normal/script.user.js' | |||
382 | --- tests/integration/autopilot/data/unity-webapps-normal/script.user.js 1970-01-01 00:00:00 +0000 | |||
383 | +++ tests/integration/autopilot/data/unity-webapps-normal/script.user.js 2014-07-08 20:49:15 +0000 | |||
384 | @@ -0,0 +1,1 @@ | |||
385 | 1 | document.getElementById('content').innerHTML="WebApp Script Injected" | ||
386 | 0 | 2 | ||
387 | === added directory 'tests/integration/autopilot/data/unity-webapps-with-altered-ua-string' | |||
388 | === added file 'tests/integration/autopilot/data/unity-webapps-with-altered-ua-string/manifest.json' | |||
389 | --- tests/integration/autopilot/data/unity-webapps-with-altered-ua-string/manifest.json 1970-01-01 00:00:00 +0000 | |||
390 | +++ tests/integration/autopilot/data/unity-webapps-with-altered-ua-string/manifest.json 2014-07-08 20:49:15 +0000 | |||
391 | @@ -0,0 +1,8 @@ | |||
392 | 1 | { | ||
393 | 2 | "includes": ["http://localhost:*/*"], | ||
394 | 3 | "name": "AlteredUAWebapp", | ||
395 | 4 | "scripts": ["script.user.js"], | ||
396 | 5 | "domain":"", | ||
397 | 6 | "homepage":"", | ||
398 | 7 | "user-agent-override": "My Override" | ||
399 | 8 | } | ||
400 | 0 | 9 | ||
401 | === added file 'tests/integration/autopilot/data/unity-webapps-with-altered-ua-string/script.user.js' | |||
402 | --- tests/integration/autopilot/data/unity-webapps-with-altered-ua-string/script.user.js 1970-01-01 00:00:00 +0000 | |||
403 | +++ tests/integration/autopilot/data/unity-webapps-with-altered-ua-string/script.user.js 2014-07-08 20:49:15 +0000 | |||
404 | @@ -0,0 +1,1 @@ | |||
405 | 1 | document.getElementById('content').innerHTML="WebApp Script Injected" | ||
406 | 0 | 2 | ||
407 | === modified file 'tests/integration/autopilot/qml/FullWebViewApp.qml' | |||
408 | --- tests/integration/autopilot/qml/FullWebViewApp.qml 2014-05-13 17:48:43 +0000 | |||
409 | +++ tests/integration/autopilot/qml/FullWebViewApp.qml 2014-07-08 20:49:15 +0000 | |||
410 | @@ -18,10 +18,9 @@ | |||
411 | 18 | 18 | ||
412 | 19 | import QtQuick 2.0 | 19 | import QtQuick 2.0 |
413 | 20 | import QtQuick.Window 2.0 | 20 | import QtQuick.Window 2.0 |
414 | 21 | import QtWebKit 3.0 | ||
415 | 22 | import QtWebKit.experimental 1.0 | ||
416 | 23 | import Ubuntu.Unity.Action 1.0 as UnityActions | 21 | import Ubuntu.Unity.Action 1.0 as UnityActions |
417 | 24 | import Ubuntu.UnityWebApps 0.1 | 22 | import Ubuntu.UnityWebApps 0.1 |
418 | 23 | import "." | ||
419 | 25 | 24 | ||
420 | 26 | import "dom-introspection-utils.js" as DomIntrospectionUtils | 25 | import "dom-introspection-utils.js" as DomIntrospectionUtils |
421 | 27 | 26 | ||
422 | @@ -36,15 +35,25 @@ | |||
423 | 36 | signal resultUpdated(string message) | 35 | signal resultUpdated(string message) |
424 | 37 | 36 | ||
425 | 38 | function evalInPageUnsafe(expr) { | 37 | function evalInPageUnsafe(expr) { |
430 | 39 | var tid = DomIntrospectionUtils.gentid(); | 38 | if (webView && webView.experimental) { |
431 | 40 | console.log(DomIntrospectionUtils.wrapJsCommands(expr)) | 39 | webView.experimental.evaluateJavaScript(DomIntrospectionUtils.wrapJsCommands(expr), |
432 | 41 | webView.experimental.evaluateJavaScript(DomIntrospectionUtils.wrapJsCommands(expr), | 40 | function(result) { |
433 | 42 | function(result) { console.log('Result: ' + result); root.resultUpdated(DomIntrospectionUtils.createResult(result)); }); | 41 | console.log('Result: ' + result); |
434 | 42 | root.resultUpdated(DomIntrospectionUtils.createResult(result)); | ||
435 | 43 | }); | ||
436 | 44 | } | ||
437 | 45 | else { | ||
438 | 46 | root.resultUpdated(DomIntrospectionUtils.createResult(webView.evaluateCode("return navigator.userAgent", true))) | ||
439 | 47 | } | ||
440 | 43 | } | 48 | } |
441 | 44 | 49 | ||
443 | 45 | property alias url: webView.url | 50 | property var webView: null |
444 | 51 | |||
445 | 52 | property bool useOxide: false | ||
446 | 53 | property string url: "" | ||
447 | 46 | property string webappName: "" | 54 | property string webappName: "" |
448 | 47 | property string webappSearchPath: "" | 55 | property string webappSearchPath: "" |
449 | 56 | property string webappHomepage: "" | ||
450 | 48 | 57 | ||
451 | 49 | UnityActions.ActionManager { | 58 | UnityActions.ActionManager { |
452 | 50 | localContexts: [webappsActionsContext] | 59 | localContexts: [webappsActionsContext] |
453 | @@ -54,21 +63,37 @@ | |||
454 | 54 | active: true | 63 | active: true |
455 | 55 | } | 64 | } |
456 | 56 | 65 | ||
461 | 57 | WebView { | 66 | Loader { |
462 | 58 | id: webView | 67 | id: webviewLoader |
463 | 59 | objectName: "webview" | 68 | onLoaded: { |
464 | 60 | 69 | webView = webviewLoader.item | |
465 | 70 | } | ||
466 | 71 | } | ||
467 | 72 | |||
468 | 73 | Component.onCompleted: { | ||
469 | 74 | var webviewSource = useOxide ? | ||
470 | 75 | Qt.resolvedUrl("WebviewBackendOxide.qml") | ||
471 | 76 | : Qt.resolvedUrl("WebviewBackendWebkit.qml"); | ||
472 | 77 | var override = webappName && webappModel.exists(webappName) ? | ||
473 | 78 | webappModel.userAgentOverrideFor(webappName) : "" | ||
474 | 79 | webviewLoader.setSource(webviewSource, | ||
475 | 80 | { url: root.url, | ||
476 | 81 | localUserAgentOverride: override}) | ||
477 | 82 | } | ||
478 | 83 | |||
479 | 84 | Loader { | ||
480 | 85 | id: unityWebappsComponentLoader | ||
481 | 61 | anchors.fill: parent | 86 | anchors.fill: parent |
492 | 62 | width: parent.width | 87 | sourceComponent: webView !== null && webappName.length !== 0 ? unityWebappsComponent : null |
493 | 63 | height: parent.height | 88 | } |
494 | 64 | 89 | ||
495 | 65 | experimental.userScripts: [] | 90 | UnityWebappsAppModel { |
496 | 66 | experimental.preferences.navigatorQtObjectEnabled: true | 91 | id: webappModel |
497 | 67 | experimental.preferences.developerExtrasEnabled: true | 92 | searchPath: root.webappSearchPath |
498 | 68 | 93 | } | |
499 | 69 | function getUnityWebappsProxies() { | 94 | |
500 | 70 | return UnityWebAppsUtils.makeProxiesForQtWebViewBindee(webView); | 95 | Component { |
501 | 71 | } | 96 | id: unityWebappsComponent |
502 | 72 | 97 | ||
503 | 73 | UnityWebApps { | 98 | UnityWebApps { |
504 | 74 | id: webapps | 99 | id: webapps |
505 | @@ -76,8 +101,8 @@ | |||
506 | 76 | actionsContext: webappsActionsContext | 101 | actionsContext: webappsActionsContext |
507 | 77 | name: root.webappName | 102 | name: root.webappName |
508 | 78 | bindee: webView | 103 | bindee: webView |
511 | 79 | //searchPath: '/home/alex/dev/work/webapps/branches/webapps-qml/latest/examples/data/userscripts' | 104 | _opt_homepage: root.webappHomepage |
512 | 80 | model: UnityWebappsAppModel { } | 105 | model: webappModel |
513 | 81 | } | 106 | } |
514 | 82 | } | 107 | } |
515 | 83 | } | 108 | } |
516 | 84 | 109 | ||
517 | === added file 'tests/integration/autopilot/qml/WebviewBackendOxide.qml' | |||
518 | --- tests/integration/autopilot/qml/WebviewBackendOxide.qml 1970-01-01 00:00:00 +0000 | |||
519 | +++ tests/integration/autopilot/qml/WebviewBackendOxide.qml 2014-07-08 20:49:15 +0000 | |||
520 | @@ -0,0 +1,87 @@ | |||
521 | 1 | import QtQuick 2.0 | ||
522 | 2 | import QtTest 1.0 | ||
523 | 3 | import com.canonical.Oxide 1.0 as Oxide | ||
524 | 4 | import Ubuntu.UnityWebApps 0.1 | ||
525 | 5 | |||
526 | 6 | Oxide.WebView { | ||
527 | 7 | id: webView | ||
528 | 8 | objectName: "webview" | ||
529 | 9 | |||
530 | 10 | property string localUserAgentOverride: "" | ||
531 | 11 | |||
532 | 12 | function _waitForResult(req, timeout) { | ||
533 | 13 | var result; | ||
534 | 14 | var error; | ||
535 | 15 | req.onreply = function(response) { | ||
536 | 16 | result = response; | ||
537 | 17 | error = 0; | ||
538 | 18 | }; | ||
539 | 19 | req.onerror = function(error_code, msg) { | ||
540 | 20 | result = msg; | ||
541 | 21 | error = error_code; | ||
542 | 22 | }; | ||
543 | 23 | webView._waitFor(function() { return error !== undefined; }, | ||
544 | 24 | timeout); | ||
545 | 25 | |||
546 | 26 | if (error > 0) { | ||
547 | 27 | console.error('Error:' + error + ', result:' + result) | ||
548 | 28 | } else if (error === 0) { | ||
549 | 29 | return result; | ||
550 | 30 | } else { | ||
551 | 31 | throw new Error("Message call timed out"); | ||
552 | 32 | } | ||
553 | 33 | } | ||
554 | 34 | |||
555 | 35 | function _waitFor(predicate, timeout) { | ||
556 | 36 | timeout = timeout || 5000000; | ||
557 | 37 | var end = Date.now() + timeout; | ||
558 | 38 | var i = Date.now(); | ||
559 | 39 | while (i < end && !predicate()) { | ||
560 | 40 | qtest_testResult.wait(50); | ||
561 | 41 | i = Date.now(); | ||
562 | 42 | } | ||
563 | 43 | return predicate(); | ||
564 | 44 | } | ||
565 | 45 | |||
566 | 46 | function evaluateCode(code, wrap) { | ||
567 | 47 | var value = webView._waitForResult( | ||
568 | 48 | webView.rootFrame.sendMessage( | ||
569 | 49 | "webview-oxide://test/", | ||
570 | 50 | "EVALUATE-CODE", | ||
571 | 51 | { code: code, | ||
572 | 52 | wrap: wrap === undefined ? false : wrap })); | ||
573 | 53 | return value ? value.result : undefined; | ||
574 | 54 | } | ||
575 | 55 | |||
576 | 56 | context: Oxide.WebContext { | ||
577 | 57 | userAgent: webView.localUserAgentOverride.length === 0 ? undefined : webView.localUserAgentOverride | ||
578 | 58 | userScripts: [ | ||
579 | 59 | Oxide.UserScript { | ||
580 | 60 | context: "webview-oxide://test/" | ||
581 | 61 | url: Qt.resolvedUrl("message-server.js") | ||
582 | 62 | matchAllFrames: true | ||
583 | 63 | } | ||
584 | 64 | ] | ||
585 | 65 | } | ||
586 | 66 | |||
587 | 67 | function getUnityWebappsProxies() { | ||
588 | 68 | return UnityWebAppsUtils.makeProxiesForWebViewBindee(webView); | ||
589 | 69 | } | ||
590 | 70 | |||
591 | 71 | onJavaScriptConsoleMessage: { | ||
592 | 72 | var msg = "[JS] (%1:%2) %3".arg(sourceId).arg(lineNumber).arg(message) | ||
593 | 73 | if (level === Oxide.WebView.LogSeverityVerbose) { | ||
594 | 74 | console.log(msg) | ||
595 | 75 | } else if (level === Oxide.WebView.LogSeverityInfo) { | ||
596 | 76 | console.info(msg) | ||
597 | 77 | } else if (level === Oxide.WebView.LogSeverityWarning) { | ||
598 | 78 | console.warn(msg) | ||
599 | 79 | } else if ((level === Oxide.WebView.LogSeverityError) || | ||
600 | 80 | (level === Oxide.WebView.LogSeverityErrorReport) || | ||
601 | 81 | (level === Oxide.WebView.LogSeverityFatal)) { | ||
602 | 82 | console.error(msg) | ||
603 | 83 | } | ||
604 | 84 | } | ||
605 | 85 | |||
606 | 86 | TestResult { id: qtest_testResult } | ||
607 | 87 | } | ||
608 | 0 | 88 | ||
609 | === added file 'tests/integration/autopilot/qml/WebviewBackendWebkit.qml' | |||
610 | --- tests/integration/autopilot/qml/WebviewBackendWebkit.qml 1970-01-01 00:00:00 +0000 | |||
611 | +++ tests/integration/autopilot/qml/WebviewBackendWebkit.qml 2014-07-08 20:49:15 +0000 | |||
612 | @@ -0,0 +1,19 @@ | |||
613 | 1 | import QtQuick 2.0 | ||
614 | 2 | import QtWebKit 3.0 | ||
615 | 3 | import QtWebKit.experimental 1.0 | ||
616 | 4 | import Ubuntu.UnityWebApps 0.1 | ||
617 | 5 | |||
618 | 6 | WebView { | ||
619 | 7 | id: webView | ||
620 | 8 | objectName: "webview" | ||
621 | 9 | |||
622 | 10 | property string localUserAgentOverride: "" | ||
623 | 11 | |||
624 | 12 | experimental.userScripts: [] | ||
625 | 13 | experimental.preferences.navigatorQtObjectEnabled: true | ||
626 | 14 | experimental.preferences.developerExtrasEnabled: true | ||
627 | 15 | |||
628 | 16 | function getUnityWebappsProxies() { | ||
629 | 17 | return UnityWebAppsUtils.makeProxiesForQtWebViewBindee(webView); | ||
630 | 18 | } | ||
631 | 19 | } | ||
632 | 0 | 20 | ||
633 | === added file 'tests/integration/autopilot/qml/message-server.js' | |||
634 | --- tests/integration/autopilot/qml/message-server.js 1970-01-01 00:00:00 +0000 | |||
635 | +++ tests/integration/autopilot/qml/message-server.js 2014-07-08 20:49:15 +0000 | |||
636 | @@ -0,0 +1,29 @@ | |||
637 | 1 | // Copyright (C) 2014 Canonical Ltd. | ||
638 | 2 | |||
639 | 3 | // This library is free software; you can redistribute it and/or | ||
640 | 4 | // modify it under the terms of the GNU Lesser General Public | ||
641 | 5 | // License as published by the Free Software Foundation; either | ||
642 | 6 | // version 2.1 of the License, or (at your option) any later version. | ||
643 | 7 | |||
644 | 8 | // This library is distributed in the hope that it will be useful, | ||
645 | 9 | // but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
646 | 10 | // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | ||
647 | 11 | // Lesser General Public License for more details. | ||
648 | 12 | |||
649 | 13 | // You should have received a copy of the GNU Lesser General Public | ||
650 | 14 | // License along with this library; if not, write to the Free Software | ||
651 | 15 | // Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA | ||
652 | 16 | |||
653 | 17 | oxide.addMessageHandler("EVALUATE-CODE", function(msg) { | ||
654 | 18 | var code = msg.args.code; | ||
655 | 19 | if (msg.args.wrap) { | ||
656 | 20 | code = "(function() {" + code + "})()"; | ||
657 | 21 | } | ||
658 | 22 | try { | ||
659 | 23 | var result = eval(code); | ||
660 | 24 | msg.reply({result: result}); | ||
661 | 25 | } catch(e) { | ||
662 | 26 | msg.error("Code threw exception: \"" + e + "\""); | ||
663 | 27 | } | ||
664 | 28 | }); | ||
665 | 29 | |||
666 | 0 | 30 | ||
667 | === removed directory 'tests/integration/autopilot/unity_webapps_qml/emulators' | |||
668 | === removed file 'tests/integration/autopilot/unity_webapps_qml/emulators/__init__.py' | |||
669 | --- tests/integration/autopilot/unity_webapps_qml/emulators/__init__.py 2013-06-17 14:46:51 +0000 | |||
670 | +++ tests/integration/autopilot/unity_webapps_qml/emulators/__init__.py 1970-01-01 00:00:00 +0000 | |||
671 | @@ -1,7 +0,0 @@ | |||
672 | 1 | # -*- Mode: Python; coding: utf-8; indent-tabs-mode: nil; tab-width: 4 -*- | ||
673 | 2 | # Copyright 2013 Canonical | ||
674 | 3 | # | ||
675 | 4 | # This program is free software: you can redistribute it and/or modify it | ||
676 | 5 | # under the terms of the GNU General Public License version 3, as published | ||
677 | 6 | # by the Free Software Foundation. | ||
678 | 7 | |||
679 | 8 | 0 | ||
680 | === modified file 'tests/integration/autopilot/unity_webapps_qml/tests/__init__.py' | |||
681 | --- tests/integration/autopilot/unity_webapps_qml/tests/__init__.py 2014-04-22 15:40:04 +0000 | |||
682 | +++ tests/integration/autopilot/unity_webapps_qml/tests/__init__.py 2014-07-08 20:49:15 +0000 | |||
683 | @@ -15,62 +15,86 @@ | |||
684 | 15 | 15 | ||
685 | 16 | from testtools.matchers import Contains, Equals, GreaterThan | 16 | from testtools.matchers import Contains, Equals, GreaterThan |
686 | 17 | from autopilot.matchers import Eventually | 17 | from autopilot.matchers import Eventually |
687 | 18 | from unity_webapps_qml.tests import fake_servers | ||
688 | 18 | 19 | ||
689 | 19 | from unity.emulators.unity import Unity | 20 | from unity.emulators.unity import Unity |
690 | 20 | 21 | ||
691 | 21 | from unity.tests import UnityTestCase | 22 | from unity.tests import UnityTestCase |
692 | 22 | 23 | ||
693 | 24 | LOCAL_QML_LAUNCHER_APP_PATH = "%s/%s" % (os.path.dirname(os.path.realpath(__file__)), '../../../../../tools/qml-launcher/unity-webapps-qml-launcher') | ||
694 | 25 | INSTALLED_QML_LAUNCHER_APP_PATH = 'unity-webapps-qml-launcher' | ||
695 | 26 | |||
696 | 27 | # TODO create __init__.py.in | ||
697 | 28 | LOCAL_BROWSER_CONTAINER_PATH = "%s/%s" % (os.path.dirname(os.path.realpath(__file__)), '../../qml/FullWebViewApp.qml') | ||
698 | 29 | INSTALLED_BROWSER_CONTAINER_PATH = '/usr/share/unity-webapps-qml/autopilot-tests/qml/FullWebViewApp.qml' | ||
699 | 30 | |||
700 | 31 | BASE_URL = '' | ||
701 | 32 | |||
702 | 23 | class UnityWebappsTestCaseBase(UnityTestCase): | 33 | class UnityWebappsTestCaseBase(UnityTestCase): |
711 | 24 | LOCAL_QML_LAUNCHER_APP_PATH = "%s/%s" % (os.path.dirname(os.path.realpath(__file__)), '../../../../../tools/qml-launcher/unity-webapps-qml-launcher') | 34 | def setUp(self): |
712 | 25 | INSTALLED_QML_LAUNCHER_APP_PATH = 'unity-webapps-qml-launcher' | 35 | super(UnityWebappsTestCaseBase, self).setUp() |
713 | 26 | 36 | self.use_oxide = False | |
714 | 27 | # TODO create __init__.py.in | 37 | |
715 | 28 | LOCAL_BROWSER_CONTAINER_PATH = "%s/%s" % (os.path.dirname(os.path.realpath(__file__)), '../../qml/FullWebViewApp.qml') | 38 | def tearDown(self): |
716 | 29 | INSTALLED_BROWSER_CONTAINER_PATH = '/usr/share/unity-webapps-qml/autopilot-tests/qml/FullWebViewApp.qml' | 39 | super(UnityWebappsTestCaseBase, self).tearDown() |
709 | 30 | |||
710 | 31 | BASE_URL = '' | ||
717 | 32 | 40 | ||
718 | 33 | def create_file_url(self, path): | 41 | def create_file_url(self, path): |
719 | 34 | return 'file://' + path | 42 | return 'file://' + path |
720 | 35 | 43 | ||
721 | 36 | def get_qml_browser_container_path(self): | 44 | def get_qml_browser_container_path(self): |
725 | 37 | if os.path.exists(self.LOCAL_BROWSER_CONTAINER_PATH): | 45 | if os.path.exists(LOCAL_BROWSER_CONTAINER_PATH): |
726 | 38 | return self.LOCAL_BROWSER_CONTAINER_PATH | 46 | return LOCAL_BROWSER_CONTAINER_PATH |
727 | 39 | return self.INSTALLED_BROWSER_CONTAINER_PATH | 47 | return INSTALLED_BROWSER_CONTAINER_PATH |
728 | 40 | 48 | ||
729 | 41 | def get_qml_launcher_path(self): | 49 | def get_qml_launcher_path(self): |
737 | 42 | if os.path.exists(self.LOCAL_QML_LAUNCHER_APP_PATH): | 50 | if os.path.exists(LOCAL_QML_LAUNCHER_APP_PATH): |
738 | 43 | return self.LOCAL_QML_LAUNCHER_APP_PATH | 51 | return LOCAL_QML_LAUNCHER_APP_PATH |
739 | 44 | return self.INSTALLED_QML_LAUNCHER_APP_PATH | 52 | return INSTALLED_QML_LAUNCHER_APP_PATH |
740 | 45 | 53 | ||
741 | 46 | def get_launch_params(self, url): | 54 | def get_launch_params(self, |
742 | 47 | base_params = ['--qml=' + self.get_qml_browser_container_path(), '--url=' + url, '--app-id=unitywebappsqmllauncher', '--webappName=unitywebappsqmllauncher'] | 55 | url, |
743 | 48 | if os.path.exists(self.LOCAL_QML_LAUNCHER_APP_PATH): | 56 | webapp_name='unitywebappsqmllauncher', |
744 | 57 | webapp_search_path="", | ||
745 | 58 | webapp_homepage="", | ||
746 | 59 | use_oxide=False): | ||
747 | 60 | base_params = ['--qml=' + self.get_qml_browser_container_path(), | ||
748 | 61 | '--app-id=' + webapp_name, | ||
749 | 62 | '--webappName=' + webapp_name, | ||
750 | 63 | '--webappSearchPath=' + webapp_search_path] | ||
751 | 64 | |||
752 | 65 | if len(webapp_homepage) != 0: | ||
753 | 66 | base_params.append('--webappHomepage=' + webapp_homepage) | ||
754 | 67 | |||
755 | 68 | if len(url) != 0: | ||
756 | 69 | base_params.append('--url=' + url) | ||
757 | 70 | |||
758 | 71 | if use_oxide: | ||
759 | 72 | base_params.append('--useOxide') | ||
760 | 73 | |||
761 | 74 | if os.path.exists(LOCAL_QML_LAUNCHER_APP_PATH): | ||
762 | 49 | # we are local | 75 | # we are local |
764 | 50 | base_params.append('--import=' + os.path.join (os.path.dirname(os.path.realpath(__file__)), '../../../../../src')) | 76 | base_params.append('--import=' + os.path.join (os.path.dirname(os.path.realpath(__file__)), |
765 | 77 | '../../../../../src')) | ||
766 | 78 | |||
767 | 51 | return base_params | 79 | return base_params |
768 | 52 | 80 | ||
769 | 53 | def launch_with_html_filepath(self, html_filepath): | 81 | def launch_with_html_filepath(self, html_filepath): |
770 | 54 | self.assertThat(os.path.exists(html_filepath), Equals(True)) | 82 | self.assertThat(os.path.exists(html_filepath), Equals(True)) |
771 | 55 | |||
772 | 56 | url = self.create_file_url(html_filepath) | 83 | url = self.create_file_url(html_filepath) |
776 | 57 | params = self.get_launch_params(url) | 84 | |
777 | 58 | 85 | self.launch_application(self.get_launch_params(url)) | |
778 | 59 | print 'Launching test with params:', params | 86 | self.assert_url_eventually_loaded(url) |
779 | 87 | |||
780 | 88 | def launch_application(self, args): | ||
781 | 89 | print 'Launching test with params:', args, "with", self.get_qml_launcher_path() | ||
782 | 90 | |||
783 | 60 | self.app = self.launch_test_application(self.get_qml_launcher_path(), | 91 | self.app = self.launch_test_application(self.get_qml_launcher_path(), |
785 | 61 | *params, | 92 | *args, |
786 | 62 | app_type='qt') | 93 | app_type='qt') |
787 | 63 | 94 | ||
788 | 64 | self.assert_url_eventually_loaded(url) | ||
789 | 65 | self.webviewContainer = self.get_webviewContainer() | 95 | self.webviewContainer = self.get_webviewContainer() |
790 | 66 | self.watcher = self.webviewContainer.watch_signal('resultUpdated(QString)') | 96 | self.watcher = self.webviewContainer.watch_signal('resultUpdated(QString)') |
791 | 67 | 97 | ||
792 | 68 | def setUp(self): | ||
793 | 69 | super(UnityWebappsTestCaseBase, self).setUp() | ||
794 | 70 | |||
795 | 71 | def tearDown(self): | ||
796 | 72 | super(UnityWebappsTestCaseBase, self).tearDown() | ||
797 | 73 | |||
798 | 74 | def pick_app_launcher(self, app_path): | 98 | def pick_app_launcher(self, app_path): |
799 | 75 | # force Qt app introspection: | 99 | # force Qt app introspection: |
800 | 76 | from autopilot.introspection.qt import QtApplicationLauncher | 100 | from autopilot.introspection.qt import QtApplicationLauncher |
801 | @@ -99,3 +123,14 @@ | |||
802 | 99 | results = json.loads(webview.get_signal_emissions('resultUpdated(QString)')[-1][0]) | 123 | results = json.loads(webview.get_signal_emissions('resultUpdated(QString)')[-1][0]) |
803 | 100 | return results.has_key('result') and results['result'] or None | 124 | return results.has_key('result') and results['result'] or None |
804 | 101 | 125 | ||
805 | 126 | class WebappsTestCaseBaseWithLocalHttpContentBase(UnityWebappsTestCaseBase): | ||
806 | 127 | def setUp(self): | ||
807 | 128 | super(WebappsTestCaseBaseWithLocalHttpContentBase, self).setUp() | ||
808 | 129 | self.http_server = fake_servers.WebappsQmlContentHttpServer() | ||
809 | 130 | self.addCleanup(self.http_server.shutdown) | ||
810 | 131 | self.base_url = "http://localhost:{}/".format(self.http_server.port) | ||
811 | 132 | |||
812 | 133 | def launch_with_webapp(self, name, webapp_search_path, use_oxide=False): | ||
813 | 134 | self.use_oxide = use_oxide | ||
814 | 135 | self.launch_application(self.get_launch_params("", name, webapp_search_path, self.base_url, use_oxide)) | ||
815 | 136 | self.assert_url_eventually_loaded(self.base_url) | ||
816 | 102 | 137 | ||
817 | === added file 'tests/integration/autopilot/unity_webapps_qml/tests/fake_servers.py' | |||
818 | --- tests/integration/autopilot/unity_webapps_qml/tests/fake_servers.py 1970-01-01 00:00:00 +0000 | |||
819 | +++ tests/integration/autopilot/unity_webapps_qml/tests/fake_servers.py 2014-07-08 20:49:15 +0000 | |||
820 | @@ -0,0 +1,70 @@ | |||
821 | 1 | # -*- Mode: Python; coding: utf-8; indent-tabs-mode: nil; tab-width: 4 -*- | ||
822 | 2 | # Copyright 2014 Canonical | ||
823 | 3 | # | ||
824 | 4 | # This program is free software: you can redistribute it and/or modify it | ||
825 | 5 | # under the terms of the GNU General Public License version 3, as published | ||
826 | 6 | # by the Free Software Foundation. | ||
827 | 7 | # | ||
828 | 8 | # This program is distributed in the hope that it will be useful, | ||
829 | 9 | # but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
830 | 10 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
831 | 11 | # GNU General Public License for more details. | ||
832 | 12 | # | ||
833 | 13 | # You should have received a copy of the GNU General Public License | ||
834 | 14 | # along with this program. If not, see <http://www.gnu.org/licenses/>. | ||
835 | 15 | |||
836 | 16 | """ Autopilot tests for the unity_webapps_qml package """ | ||
837 | 17 | |||
838 | 18 | import BaseHTTPServer | ||
839 | 19 | import logging | ||
840 | 20 | import threading | ||
841 | 21 | |||
842 | 22 | |||
843 | 23 | class RequestHandler(BaseHTTPServer.BaseHTTPRequestHandler): | ||
844 | 24 | def serve_content(self, content, mime_type='text/html'): | ||
845 | 25 | self.send_header('Content-type', mime_type) | ||
846 | 26 | self.end_headers() | ||
847 | 27 | self.wfile.write(content.encode()) | ||
848 | 28 | |||
849 | 29 | def basic_html_content(self): | ||
850 | 30 | return """ | ||
851 | 31 | <html> | ||
852 | 32 | <head> | ||
853 | 33 | <title>Some content</title> | ||
854 | 34 | </head> | ||
855 | 35 | <body> | ||
856 | 36 | <div id='content'> | ||
857 | 37 | This is some content | ||
858 | 38 | </div> | ||
859 | 39 | </body> | ||
860 | 40 | </html> | ||
861 | 41 | """ | ||
862 | 42 | |||
863 | 43 | def do_GET(self): | ||
864 | 44 | if self.path == '/': | ||
865 | 45 | self.send_response(200) | ||
866 | 46 | self.serve_content(self.basic_html_content()) | ||
867 | 47 | else: | ||
868 | 48 | self.send_error(404) | ||
869 | 49 | |||
870 | 50 | |||
871 | 51 | class WebappsQmlContentHttpServer(object): | ||
872 | 52 | def __init__(self): | ||
873 | 53 | super(WebappsQmlContentHttpServer, self).__init__() | ||
874 | 54 | self.server = BaseHTTPServer.HTTPServer(("", 0), RequestHandler) | ||
875 | 55 | self.server.allow_reuse_address = True | ||
876 | 56 | self.server_thread = threading.Thread(target=self.server.serve_forever) | ||
877 | 57 | self.server_thread.start() | ||
878 | 58 | logging.info("now serving on port {}".format(self.server.server_port)) | ||
879 | 59 | |||
880 | 60 | @property | ||
881 | 61 | def port(self): | ||
882 | 62 | return self.server.server_port | ||
883 | 63 | |||
884 | 64 | def run(self): | ||
885 | 65 | self.server.serve_forever() | ||
886 | 66 | |||
887 | 67 | def shutdown(self): | ||
888 | 68 | self.server.shutdown() | ||
889 | 69 | self.server.server_close() | ||
890 | 70 | self.server_thread.join() | ||
891 | 0 | 71 | ||
892 | === added file 'tests/integration/autopilot/unity_webapps_qml/tests/test_installedWebapp.py' | |||
893 | --- tests/integration/autopilot/unity_webapps_qml/tests/test_installedWebapp.py 1970-01-01 00:00:00 +0000 | |||
894 | +++ tests/integration/autopilot/unity_webapps_qml/tests/test_installedWebapp.py 2014-07-08 20:49:15 +0000 | |||
895 | @@ -0,0 +1,59 @@ | |||
896 | 1 | # -*- Mode: Python; coding: utf-8; indent-tabs-mode: nil; tab-width: 4 -*- | ||
897 | 2 | # Copyright 2013 Canonical | ||
898 | 3 | # | ||
899 | 4 | # This program is free software: you can redistribute it and/or modify it | ||
900 | 5 | # under the terms of the GNU General Public License version 3, as published | ||
901 | 6 | # by the Free Software Foundation. | ||
902 | 7 | |||
903 | 8 | from __future__ import absolute_import | ||
904 | 9 | |||
905 | 10 | import time | ||
906 | 11 | import os | ||
907 | 12 | |||
908 | 13 | from testtools.matchers import Equals, GreaterThan, NotEquals | ||
909 | 14 | from autopilot.matchers import Eventually | ||
910 | 15 | |||
911 | 16 | from unity_webapps_qml.tests import WebappsTestCaseBaseWithLocalHttpContentBase | ||
912 | 17 | |||
913 | 18 | LOCAL_HTML_TEST_FILE = "%s/%s" % (os.path.dirname(os.path.realpath(__file__)), '../../data') | ||
914 | 19 | INSTALLED_HTML_TEST_FILE = '/usr/share/unity-webapps-qml/autopilot-tests/data' | ||
915 | 20 | |||
916 | 21 | class InstalledWebappsTestCaseBase(WebappsTestCaseBaseWithLocalHttpContentBase): | ||
917 | 22 | def setUp(self): | ||
918 | 23 | super(InstalledWebappsTestCaseBase, self).setUp() | ||
919 | 24 | |||
920 | 25 | def get_webapp_install_folder(self): | ||
921 | 26 | if os.path.exists(LOCAL_HTML_TEST_FILE): | ||
922 | 27 | return os.path.abspath(LOCAL_HTML_TEST_FILE) | ||
923 | 28 | return INSTALLED_HTML_TEST_FILE | ||
924 | 29 | |||
925 | 30 | def test_normalWebappFound(self): | ||
926 | 31 | self.launch_with_webapp('Normal', self.get_webapp_install_folder()) | ||
927 | 32 | |||
928 | 33 | self.assertThat(lambda: self.eval_expression_in_page_unsafe('return window.external.getUnityObject("1.0") != null;'), Eventually(Equals(True))) | ||
929 | 34 | |||
930 | 35 | expression = """ | ||
931 | 36 | var contentElement = document.getElementById('content'); | ||
932 | 37 | return contentElement.innerHTML; | ||
933 | 38 | """ | ||
934 | 39 | self.assertThat(lambda: self.eval_expression_in_page_unsafe(expression), Eventually(Equals("WebApp Script Injected"))) | ||
935 | 40 | |||
936 | 41 | def test_webappWithUAOverrideFound(self): | ||
937 | 42 | self.launch_with_webapp('AlteredUAWebapp', self.get_webapp_install_folder(), True) | ||
938 | 43 | self.assertThat(lambda: self.eval_expression_in_page_unsafe('return navigator.userAgent;'), Eventually(Equals("My Override"))) | ||
939 | 44 | |||
940 | 45 | def test_webappFoundWithSpecialWebappPropertiesFile(self): | ||
941 | 46 | self.launch_with_webapp('ExtendedWebappProperties', self.get_webapp_install_folder() + '/all-in-same-folder') | ||
942 | 47 | |||
943 | 48 | self.assertThat(lambda: self.eval_expression_in_page_unsafe('return window.external.getUnityObject("1.0") != null;'), Eventually(Equals(True))) | ||
944 | 49 | |||
945 | 50 | expression = """ | ||
946 | 51 | var contentElement = document.getElementById('content'); | ||
947 | 52 | return contentElement.innerHTML; | ||
948 | 53 | """ | ||
949 | 54 | self.assertThat(lambda: self.eval_expression_in_page_unsafe(expression), Eventually(Equals("WebApp Script Injected"))) | ||
950 | 55 | |||
951 | 56 | def test_webappPropertiesFileWithUA(self): | ||
952 | 57 | self.launch_with_webapp('ExtendedWebappProperties', self.get_webapp_install_folder() + '/all-in-same-folder', True) | ||
953 | 58 | self.assertThat(lambda: self.eval_expression_in_page_unsafe('return navigator.userAgent;'), Eventually(Equals("My Override"))) | ||
954 | 59 | |||
955 | 0 | 60 | ||
956 | === removed file 'tests/integration/test-server.py' | |||
957 | --- tests/integration/test-server.py 2013-05-29 15:03:32 +0000 | |||
958 | +++ tests/integration/test-server.py 1970-01-01 00:00:00 +0000 | |||
959 | @@ -1,18 +0,0 @@ | |||
960 | 1 | #!/usr/bin/env python | ||
961 | 2 | |||
962 | 3 | import SocketServer | ||
963 | 4 | import SimpleHTTPServer | ||
964 | 5 | import urllib | ||
965 | 6 | |||
966 | 7 | PORT = 8181 | ||
967 | 8 | |||
968 | 9 | class Proxy(SimpleHTTPServer.SimpleHTTPRequestHandler): | ||
969 | 10 | def do_GET(self): | ||
970 | 11 | if self.path == '/': | ||
971 | 12 | self.path = '/unity-integration.html' | ||
972 | 13 | return SimpleHTTPServer.SimpleHTTPRequestHandler.do_GET(self) | ||
973 | 14 | |||
974 | 15 | httpd = SocketServer.TCPServer(('0.0.0.0', PORT), Proxy) | ||
975 | 16 | print "serving at port", PORT | ||
976 | 17 | httpd.serve_forever() | ||
977 | 18 | |||
978 | 19 | 0 | ||
979 | === modified file 'tools/qml-launcher/qml-launcher.cpp' | |||
980 | --- tools/qml-launcher/qml-launcher.cpp 2014-04-22 15:40:04 +0000 | |||
981 | +++ tools/qml-launcher/qml-launcher.cpp 2014-07-08 20:49:15 +0000 | |||
982 | @@ -68,6 +68,7 @@ | |||
983 | 68 | const QString QML_FILE_IMPORT_ARG_HEADER = "--import="; | 68 | const QString QML_FILE_IMPORT_ARG_HEADER = "--import="; |
984 | 69 | const QString QML_APP_ID_ARG_HEADER = "--app-id="; | 69 | const QString QML_APP_ID_ARG_HEADER = "--app-id="; |
985 | 70 | const QString QML_INSPECTOR_ARG_HEADER = "--inspector="; | 70 | const QString QML_INSPECTOR_ARG_HEADER = "--inspector="; |
986 | 71 | const QString QML_USE_OXIDE_ARG_HEADER = "--useOxide"; | ||
987 | 71 | const QString ARG_HEADER = "--"; | 72 | const QString ARG_HEADER = "--"; |
988 | 72 | const QString VALUE_HEADER = "="; | 73 | const QString VALUE_HEADER = "="; |
989 | 73 | QHash<QString, QString> properties; | 74 | QHash<QString, QString> properties; |
990 | @@ -75,6 +76,7 @@ | |||
991 | 75 | QString appid; | 76 | QString appid; |
992 | 76 | QString importPath; | 77 | QString importPath; |
993 | 77 | QString inspector; | 78 | QString inspector; |
994 | 79 | bool useOxide = false; | ||
995 | 78 | bool maximized = false; | 80 | bool maximized = false; |
996 | 79 | 81 | ||
997 | 80 | Q_FOREACH(QString argument, app.arguments()) | 82 | Q_FOREACH(QString argument, app.arguments()) |
998 | @@ -99,6 +101,11 @@ | |||
999 | 99 | inspector = argument.right(argument.count() - QML_INSPECTOR_ARG_HEADER.count()); | 101 | inspector = argument.right(argument.count() - QML_INSPECTOR_ARG_HEADER.count()); |
1000 | 100 | } | 102 | } |
1001 | 101 | else | 103 | else |
1002 | 104 | if (argument.contains(QML_USE_OXIDE_ARG_HEADER)) | ||
1003 | 105 | { | ||
1004 | 106 | useOxide = true; | ||
1005 | 107 | } | ||
1006 | 108 | else | ||
1007 | 102 | if (argument.contains(QML_MAXIMIZED_ARG)) | 109 | if (argument.contains(QML_MAXIMIZED_ARG)) |
1008 | 103 | { | 110 | { |
1009 | 104 | maximized = true; | 111 | maximized = true; |
1010 | @@ -169,7 +176,7 @@ | |||
1011 | 169 | QQmlContext *context = new QQmlContext(engine.rootContext()); | 176 | QQmlContext *context = new QQmlContext(engine.rootContext()); |
1012 | 170 | 177 | ||
1013 | 171 | QQmlComponent component(&engine, qmlfile); | 178 | QQmlComponent component(&engine, qmlfile); |
1015 | 172 | QObject *object = component.create(context); | 179 | QObject *object = component.beginCreate(context); |
1016 | 173 | 180 | ||
1017 | 174 | if (!component.isReady()) { | 181 | if (!component.isReady()) { |
1018 | 175 | qWarning() << component.errorString(); | 182 | qWarning() << component.errorString(); |
1019 | @@ -192,6 +199,12 @@ | |||
1020 | 192 | object->setProperty(it.key().toStdString().c_str(), QUrl(it.value())); | 199 | object->setProperty(it.key().toStdString().c_str(), QUrl(it.value())); |
1021 | 193 | } | 200 | } |
1022 | 194 | 201 | ||
1023 | 202 | if (useOxide) { | ||
1024 | 203 | object->setProperty("useOxide", true); | ||
1025 | 204 | } | ||
1026 | 205 | |||
1027 | 206 | component.completeCreate(); | ||
1028 | 207 | |||
1029 | 195 | if (window) | 208 | if (window) |
1030 | 196 | { | 209 | { |
1031 | 197 | if (maximized) | 210 | if (maximized) |
FAILED: Continuous integration, rev:128 jenkins. qa.ubuntu. com/job/ unity-webapps- qml-ci/ 136/ jenkins. qa.ubuntu. com/job/ unity-webapps- qml-utopic- amd64-ci/ 22/console jenkins. qa.ubuntu. com/job/ unity-webapps- qml-utopic- armhf-ci/ 22/console
http://
Executed test runs:
FAILURE: http://
FAILURE: http://
Click here to trigger a rebuild: s-jenkins. ubuntu- ci:8080/ job/unity- webapps- qml-ci/ 136/rebuild
http://