Merge lp:~abreu-alexandre/unity-webapps-qml/port-to-oxide into lp:unity-webapps-qml
- port-to-oxide
- Merge into trunk
Proposed by
Alexandre Abreu
Status: | Merged | ||||
---|---|---|---|---|---|
Approved by: | David Barth | ||||
Approved revision: | 136 | ||||
Merged at revision: | 136 | ||||
Proposed branch: | lp:~abreu-alexandre/unity-webapps-qml/port-to-oxide | ||||
Merge into: | lp:unity-webapps-qml | ||||
Diff against target: |
2242 lines (+500/-921) 41 files modified
README (+45/-1) debian/control (+2/-3) examples/api-bindings/alarm/main.qml.in (+9/-10) examples/api-bindings/content-hub-exporter/main.qml.in (+8/-10) examples/api-bindings/content-hub/main.qml.in (+8/-10) examples/api-bindings/content-peer-picker/main.qml.in (+8/-10) examples/api-bindings/download-manager/main.qml.in (+8/-10) examples/api-bindings/online-accounts/main.qml.in (+8/-10) examples/api-bindings/runtime-api/main.qml.in (+7/-9) examples/basic-webview/main.qml (+9/-25) examples/examples.pro (+3/-0) examples/facebook-share/content-hub/webapp-facebook.json (+0/-5) examples/facebook-share/manifest.json (+0/-18) examples/facebook-share/unity-webapps-facebook/HubSharer.qml (+0/-41) examples/facebook-share/unity-webapps-facebook/Share.qml (+0/-323) examples/facebook-share/unity-webapps-facebook/facebook.user.js (+0/-47) examples/facebook-share/unity-webapps-facebook/manifest.json (+0/-7) examples/facebook-share/webapp-facebook.application (+0/-11) examples/facebook-share/webapp-facebook.desktop (+0/-9) examples/facebook-share/webapp-facebook.json (+0/-13) examples/facebook-share/webapp-facebook.service (+0/-6) examples/unity-webapps-example-bbcnews/main.qml (+10/-15) examples/unity-webapps-example-facebookmessenger/main.qml (+9/-12) src/Ubuntu/UnityWebApps/UnityWebApps.js (+1/-2) src/Ubuntu/UnityWebApps/UnityWebApps.qml (+16/-7) src/Ubuntu/UnityWebApps/UnityWebAppsUtils.js (+11/-4) src/Ubuntu/UnityWebApps/common/js/unity-backend-messaging-proxy.js (+1/-1) src/Ubuntu/UnityWebApps/unity-webapps-api.js.in (+4/-0) tests/autopilot/autopilot.pro (+0/-1) tests/autopilot/qml/FullWebViewApp.qml (+12/-35) tests/autopilot/qml/WebviewBackendOxide.qml (+8/-3) tests/autopilot/qml/WebviewBackendWebkit.qml (+0/-19) tests/autopilot/unity_webapps_qml/tests/__init__.py (+50/-35) tests/autopilot/unity_webapps_qml/tests/fake_servers.py (+3/-3) tests/autopilot/unity_webapps_qml/tests/test_callbackDispatch.py (+27/-13) tests/autopilot/unity_webapps_qml/tests/test_hud.py (+0/-81) tests/autopilot/unity_webapps_qml/tests/test_injectedOnWebapp.py (+52/-23) tests/autopilot/unity_webapps_qml/tests/test_installedWebapp.py (+49/-18) tests/autopilot/unity_webapps_qml/tests/test_launcher.py (+52/-28) tests/autopilot/unity_webapps_qml/tests/test_mediaplayer.py (+80/-33) tools/qml-launcher/qml-launcher.cpp (+0/-10) |
||||
To merge this branch: | bzr merge lp:~abreu-alexandre/unity-webapps-qml/port-to-oxide | ||||
Related bugs: |
|
Reviewer | Review Type | Date Requested | Status |
---|---|---|---|
PS Jenkins bot (community) | continuous-integration | Needs Fixing | |
WebApps | Pending | ||
Review via email: mp+236115@code.launchpad.net |
Commit message
Port qml bindings to oxide
Description of the change
Port qml bindings to oxide
To post a comment you must log in.
Revision history for this message
PS Jenkins bot (ps-jenkins) wrote : | # |
review:
Needs Fixing
(continuous-integration)
Revision history for this message
PS Jenkins bot (ps-jenkins) wrote : | # |
FAILED: Continuous integration, rev:138
http://
Executed test runs:
FAILURE: http://
FAILURE: http://
Click here to trigger a rebuild:
http://
review:
Needs Fixing
(continuous-integration)
- 136. By Alexandre Abreu
-
Port to oxide
Preview Diff
[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1 | === modified file 'README' |
2 | --- README 2013-06-17 14:46:51 +0000 |
3 | +++ README 2014-11-22 00:43:58 +0000 |
4 | @@ -1,1 +1,45 @@ |
5 | -# |
6 | \ No newline at end of file |
7 | +unity-webapps-qml offers a QML component that depending on runtime |
8 | +settings and configurations: |
9 | + |
10 | +- allows one to inject the UbuntuTouch Javascript platform bindings, |
11 | + |
12 | +- allows one to inject a restricted set of API bindings when running as a webapp |
13 | +(see http://developer.ubuntu.com/publish/webapp/packaging-web-apps/), |
14 | + |
15 | +- allows one to load local javscript snipets that are to be dynamically injected |
16 | +in the webview as part of a webapp, |
17 | + |
18 | +The QML component supports Oxide and QtWebkit as a web engine backend. |
19 | + |
20 | += Building = |
21 | + |
22 | +The build system uses qmake. |
23 | +To compile, simply invoke qmake and then make: |
24 | + |
25 | + $ qmake . |
26 | + $ make |
27 | + |
28 | += Running = |
29 | + |
30 | +Some examples are being provided in the examples/ folder. Examples range from |
31 | +webapp definitions, to api bindings, etc. |
32 | + |
33 | += Unit tests = |
34 | + |
35 | +To run the unit tests, you can use the commands below: |
36 | + |
37 | + $ make test |
38 | + |
39 | += Automated UI tests = |
40 | + |
41 | +The unity-webapps-qml component uses autopilot (https://launchpad.net/autopilot) to test its |
42 | +internal sub-componenets. |
43 | +To run the tests, you will need to install python3-autopilot and libautopilot-qt. |
44 | +Then do the following: |
45 | + |
46 | + $ cd tests/autopilot/ |
47 | + $ autopilot3 run unity_webapps_qml |
48 | + |
49 | +You can get a list of all available tests with the following command: |
50 | + |
51 | + $ autopilot3 list unity_webapps_qml |
52 | |
53 | === modified file 'debian/control' |
54 | --- debian/control 2014-10-14 10:02:49 +0000 |
55 | +++ debian/control 2014-11-22 00:43:58 +0000 |
56 | @@ -8,7 +8,7 @@ |
57 | libnotify-dev, |
58 | # depend on oxide so that we don't build for archs that we can't install on |
59 | liboxideqtcore0, |
60 | - libqt5webkit5-dev, |
61 | + liboxideqt-qmlplugin (>= 1.2.0), |
62 | libunity-action-qt1-dev, |
63 | libunity-dev, |
64 | pkg-config, |
65 | @@ -28,8 +28,7 @@ |
66 | |
67 | Package: unity-webapps-qml |
68 | Architecture: any |
69 | -Depends: qml-module-qtwebkit, |
70 | - liboxideqt-qmlplugin (>= 1.0), |
71 | +Depends: liboxideqt-qmlplugin (>= 1.2.0) | qml-module-qtwebkit, |
72 | qtdeclarative5-qtquick2-plugin, |
73 | qtdeclarative5-unity-action-plugin, |
74 | qtdeclarative5-ubuntu-ui-toolkit-plugin | qtdeclarative5-ubuntu-ui-toolkit-plugin-gles, |
75 | |
76 | === modified file 'examples/api-bindings/alarm/main.qml.in' |
77 | --- examples/api-bindings/alarm/main.qml.in 2014-05-08 13:58:56 +0000 |
78 | +++ examples/api-bindings/alarm/main.qml.in 2014-11-22 00:43:58 +0000 |
79 | @@ -1,9 +1,9 @@ |
80 | import QtQuick 2.0 |
81 | -import QtWebKit 3.0 |
82 | -import QtWebKit.experimental 1.0 |
83 | +import com.canonical.Oxide 1.0 |
84 | import Ubuntu.Components 0.1 |
85 | import Ubuntu.UnityWebApps 0.1 |
86 | |
87 | + |
88 | Item { |
89 | id: root |
90 | focus: true |
91 | @@ -16,17 +16,16 @@ |
92 | anchors.fill: parent |
93 | url: \"file://$$OUT_PWD/alarm/www/index.html\" |
94 | |
95 | - experimental.preferences.navigatorQtObjectEnabled: true |
96 | - experimental.preferences.developerExtrasEnabled: true |
97 | + context: WebContext { } |
98 | |
99 | function getUnityWebappsProxies() { |
100 | - return UnityWebAppsUtils.makeProxiesForQtWebViewBindee(webview); |
101 | + return UnityWebAppsUtils.makeProxiesForWebViewBindee(webview); |
102 | } |
103 | + } |
104 | |
105 | - UnityWebApps { |
106 | - id: webapps |
107 | - bindee: webview |
108 | - injectExtraUbuntuApis: true |
109 | - } |
110 | + UnityWebApps { |
111 | + id: webapps |
112 | + bindee: webview |
113 | + injectExtraUbuntuApis: true |
114 | } |
115 | } |
116 | |
117 | === modified file 'examples/api-bindings/content-hub-exporter/main.qml.in' |
118 | --- examples/api-bindings/content-hub-exporter/main.qml.in 2014-05-08 13:58:56 +0000 |
119 | +++ examples/api-bindings/content-hub-exporter/main.qml.in 2014-11-22 00:43:58 +0000 |
120 | @@ -1,6 +1,5 @@ |
121 | import QtQuick 2.0 |
122 | -import QtWebKit 3.0 |
123 | -import QtWebKit.experimental 1.0 |
124 | +import com.canonical.Oxide 1.0 |
125 | import Ubuntu.Components 0.1 |
126 | import Ubuntu.UnityWebApps 0.1 |
127 | |
128 | @@ -16,17 +15,16 @@ |
129 | anchors.fill: parent |
130 | url: \"file://$$OUT_PWD/content-hub-exporter/www/index.html\" |
131 | |
132 | - experimental.preferences.navigatorQtObjectEnabled: true |
133 | - experimental.preferences.developerExtrasEnabled: true |
134 | + context: WebContext { } |
135 | |
136 | function getUnityWebappsProxies() { |
137 | - return UnityWebAppsUtils.makeProxiesForQtWebViewBindee(webview); |
138 | + return UnityWebAppsUtils.makeProxiesForWebViewBindee(webview); |
139 | } |
140 | + } |
141 | |
142 | - UnityWebApps { |
143 | - id: webapps |
144 | - bindee: webview |
145 | - injectExtraUbuntuApis: true |
146 | - } |
147 | + UnityWebApps { |
148 | + id: webapps |
149 | + bindee: webview |
150 | + injectExtraUbuntuApis: true |
151 | } |
152 | } |
153 | |
154 | === modified file 'examples/api-bindings/content-hub/main.qml.in' |
155 | --- examples/api-bindings/content-hub/main.qml.in 2014-05-08 13:58:56 +0000 |
156 | +++ examples/api-bindings/content-hub/main.qml.in 2014-11-22 00:43:58 +0000 |
157 | @@ -1,6 +1,5 @@ |
158 | import QtQuick 2.0 |
159 | -import QtWebKit 3.0 |
160 | -import QtWebKit.experimental 1.0 |
161 | +import com.canonical.Oxide 1.0 |
162 | import Ubuntu.Components 0.1 |
163 | import Ubuntu.UnityWebApps 0.1 |
164 | |
165 | @@ -17,17 +16,16 @@ |
166 | anchors.fill: parent |
167 | url: \"file://$$OUT_PWD/content-hub/www/index.html\" |
168 | |
169 | - experimental.preferences.navigatorQtObjectEnabled: true |
170 | - experimental.preferences.developerExtrasEnabled: true |
171 | + context: WebContext { } |
172 | |
173 | function getUnityWebappsProxies() { |
174 | - return UnityWebAppsUtils.makeProxiesForQtWebViewBindee(webview); |
175 | + return UnityWebAppsUtils.makeProxiesForWebViewBindee(webview); |
176 | } |
177 | + } |
178 | |
179 | - UnityWebApps { |
180 | - id: webapps |
181 | - bindee: webview |
182 | - injectExtraUbuntuApis: true |
183 | - } |
184 | + UnityWebApps { |
185 | + id: webapps |
186 | + bindee: webview |
187 | + injectExtraUbuntuApis: true |
188 | } |
189 | } |
190 | |
191 | === modified file 'examples/api-bindings/content-peer-picker/main.qml.in' |
192 | --- examples/api-bindings/content-peer-picker/main.qml.in 2014-05-08 14:21:54 +0000 |
193 | +++ examples/api-bindings/content-peer-picker/main.qml.in 2014-11-22 00:43:58 +0000 |
194 | @@ -1,6 +1,5 @@ |
195 | import QtQuick 2.0 |
196 | -import QtWebKit 3.0 |
197 | -import QtWebKit.experimental 1.0 |
198 | +import com.canonical.Oxide 1.0 |
199 | import Ubuntu.Components 0.1 |
200 | import Ubuntu.UnityWebApps 0.1 |
201 | |
202 | @@ -17,17 +16,16 @@ |
203 | anchors.fill: parent |
204 | url: \"file://$$OUT_PWD/content-peer-picker/www/index.html\" |
205 | |
206 | - experimental.preferences.navigatorQtObjectEnabled: true |
207 | - experimental.preferences.developerExtrasEnabled: true |
208 | + context: WebContext { } |
209 | |
210 | function getUnityWebappsProxies() { |
211 | - return UnityWebAppsUtils.makeProxiesForQtWebViewBindee(webview); |
212 | + return UnityWebAppsUtils.makeProxiesForWebViewBindee(webview); |
213 | } |
214 | + } |
215 | |
216 | - UnityWebApps { |
217 | - id: webapps |
218 | - bindee: webview |
219 | - injectExtraUbuntuApis: true |
220 | - } |
221 | + UnityWebApps { |
222 | + id: webapps |
223 | + bindee: webview |
224 | + injectExtraUbuntuApis: true |
225 | } |
226 | } |
227 | |
228 | === modified file 'examples/api-bindings/download-manager/main.qml.in' |
229 | --- examples/api-bindings/download-manager/main.qml.in 2014-05-13 17:48:43 +0000 |
230 | +++ examples/api-bindings/download-manager/main.qml.in 2014-11-22 00:43:58 +0000 |
231 | @@ -1,6 +1,5 @@ |
232 | import QtQuick 2.0 |
233 | -import QtWebKit 3.0 |
234 | -import QtWebKit.experimental 1.0 |
235 | +import com.canonical.Oxide 1.0 |
236 | import Ubuntu.Components 0.1 |
237 | import Ubuntu.UnityWebApps 0.1 |
238 | |
239 | @@ -17,17 +16,16 @@ |
240 | anchors.fill: parent |
241 | url: \"file://$$OUT_PWD/download-manager/www/index.html\" |
242 | |
243 | - experimental.preferences.navigatorQtObjectEnabled: true |
244 | - experimental.preferences.developerExtrasEnabled: true |
245 | + context: WebContext { } |
246 | |
247 | function getUnityWebappsProxies() { |
248 | - return UnityWebAppsUtils.makeProxiesForQtWebViewBindee(webview); |
249 | + return UnityWebAppsUtils.makeProxiesForWebViewBindee(webview); |
250 | } |
251 | + } |
252 | |
253 | - UnityWebApps { |
254 | - id: webapps |
255 | - bindee: webview |
256 | - injectExtraUbuntuApis: true |
257 | - } |
258 | + UnityWebApps { |
259 | + id: webapps |
260 | + bindee: webview |
261 | + injectExtraUbuntuApis: true |
262 | } |
263 | } |
264 | |
265 | === modified file 'examples/api-bindings/online-accounts/main.qml.in' |
266 | --- examples/api-bindings/online-accounts/main.qml.in 2014-05-08 13:58:56 +0000 |
267 | +++ examples/api-bindings/online-accounts/main.qml.in 2014-11-22 00:43:58 +0000 |
268 | @@ -1,6 +1,5 @@ |
269 | import QtQuick 2.0 |
270 | -import QtWebKit 3.0 |
271 | -import QtWebKit.experimental 1.0 |
272 | +import com.canonical.Oxide 1.0 |
273 | import Ubuntu.Components 0.1 |
274 | import Ubuntu.UnityWebApps 0.1 |
275 | |
276 | @@ -16,17 +15,16 @@ |
277 | anchors.fill: parent |
278 | url: \"file://$$OUT_PWD/online-accounts/www/index.html\" |
279 | |
280 | - experimental.preferences.navigatorQtObjectEnabled: true |
281 | - experimental.preferences.developerExtrasEnabled: true |
282 | + context: WebContext { } |
283 | |
284 | function getUnityWebappsProxies() { |
285 | - return UnityWebAppsUtils.makeProxiesForQtWebViewBindee(webview); |
286 | + return UnityWebAppsUtils.makeProxiesForWebViewBindee(webview); |
287 | } |
288 | + } |
289 | |
290 | - UnityWebApps { |
291 | - id: webapps |
292 | - bindee: webview |
293 | - injectExtraUbuntuApis: true |
294 | - } |
295 | + UnityWebApps { |
296 | + id: webapps |
297 | + bindee: webview |
298 | + injectExtraUbuntuApis: true |
299 | } |
300 | } |
301 | |
302 | === modified file 'examples/api-bindings/runtime-api/main.qml.in' |
303 | --- examples/api-bindings/runtime-api/main.qml.in 2014-03-26 14:38:17 +0000 |
304 | +++ examples/api-bindings/runtime-api/main.qml.in 2014-11-22 00:43:58 +0000 |
305 | @@ -1,6 +1,5 @@ |
306 | import QtQuick 2.0 |
307 | -import QtWebKit 3.0 |
308 | -import QtWebKit.experimental 1.0 |
309 | +import com.canonical.Oxide 1.0 |
310 | import Ubuntu.Components 0.1 |
311 | import Ubuntu.UnityWebApps 0.1 |
312 | |
313 | @@ -17,16 +16,15 @@ |
314 | anchors.fill: parent |
315 | url: \"file://$$OUT_PWD/runtime-api/www/index.html\" |
316 | |
317 | - experimental.preferences.navigatorQtObjectEnabled: true |
318 | - experimental.preferences.developerExtrasEnabled: true |
319 | + context: WebContext { } |
320 | |
321 | function getUnityWebappsProxies() { |
322 | - return UnityWebAppsUtils.makeProxiesForQtWebViewBindee(webview); |
323 | + return UnityWebAppsUtils.makeProxiesForWebViewBindee(webview); |
324 | } |
325 | + } |
326 | |
327 | - UnityWebApps { |
328 | - id: webapps |
329 | - bindee: webview |
330 | - } |
331 | + UnityWebApps { |
332 | + id: webapps |
333 | + bindee: webview |
334 | } |
335 | } |
336 | |
337 | === modified file 'examples/basic-webview/main.qml' |
338 | --- examples/basic-webview/main.qml 2014-01-17 15:51:27 +0000 |
339 | +++ examples/basic-webview/main.qml 2014-11-22 00:43:58 +0000 |
340 | @@ -1,7 +1,6 @@ |
341 | import QtQuick 2.0 |
342 | import QtQuick.Window 2.0 |
343 | -import QtWebKit 3.0 |
344 | -import QtWebKit.experimental 1.0 |
345 | +import com.canonical.Oxide 1.0 |
346 | import Ubuntu.UnityWebApps 0.1 |
347 | |
348 | Window { |
349 | @@ -15,36 +14,21 @@ |
350 | url: "file:///usr/share/unity-webapps-qml/examples/data/html/big-test.html" |
351 | anchors.fill: parent |
352 | |
353 | - experimental.userScripts: [] |
354 | - experimental.preferences.navigatorQtObjectEnabled: true |
355 | - experimental.preferences.developerExtrasEnabled: true |
356 | - |
357 | - experimental.userAgent: { |
358 | - return "Mozilla/5.0 (iPad; CPU OS 5_0 like Mac OS X) AppleWebKit/534.46 (KHTML, like Gecko) Version/5.1 Mobile/9A334 Safari/7534.48.3" |
359 | - } |
360 | - experimental.onMessageReceived: { |
361 | - var msg = null |
362 | - try { |
363 | - msg = JSON.parse(message.data) |
364 | - } catch (error) { |
365 | - console.debug('DEBUG:', message.data) |
366 | - return |
367 | - } |
368 | - } |
369 | + context: WebContext { } |
370 | |
371 | function getUnityWebappsProxies() { |
372 | - var proxies = UnityWebAppsUtils.makeProxiesForQtWebViewBindee(webView); |
373 | + var proxies = UnityWebAppsUtils.makeProxiesForWebViewBindee(webView); |
374 | |
375 | // override the default navigate to request |
376 | proxies.navigateTo = function(url) {}; |
377 | return proxies; |
378 | } |
379 | + } |
380 | |
381 | - UnityWebApps { |
382 | - id: webapps |
383 | - name: "BBCNews" |
384 | - bindee: webView |
385 | - model: UnityWebappsAppModel { } |
386 | - } |
387 | + UnityWebApps { |
388 | + id: webapps |
389 | + name: "BBCNews" |
390 | + bindee: webView |
391 | + model: UnityWebappsAppModel { } |
392 | } |
393 | } |
394 | |
395 | === modified file 'examples/examples.pro' |
396 | --- examples/examples.pro 2014-01-17 15:51:27 +0000 |
397 | +++ examples/examples.pro 2014-11-22 00:43:58 +0000 |
398 | @@ -41,6 +41,9 @@ |
399 | basic_webview_install.path = /usr/share/unity-webapps-qml/examples/basic-webview |
400 | basic_webview_install.files = $$system(ls basic-webview/*) |
401 | |
402 | +html5_api_bindings_install.path = /usr/share/unity-webapps-qml/examples/api-bindings |
403 | +html5_api_bindings_install.files = $$system(ls api-bindings/*) |
404 | + |
405 | webapps_apps_model_install.path = /usr/share/unity-webapps-qml/examples/webapps-apps-model |
406 | webapps_apps_model_install.files = $$system(ls webapps-app-model/*) |
407 | |
408 | |
409 | === removed directory 'examples/facebook-share' |
410 | === removed directory 'examples/facebook-share/content-hub' |
411 | === removed file 'examples/facebook-share/content-hub/webapp-facebook.json' |
412 | --- examples/facebook-share/content-hub/webapp-facebook.json 2014-06-17 20:34:32 +0000 |
413 | +++ examples/facebook-share/content-hub/webapp-facebook.json 1970-01-01 00:00:00 +0000 |
414 | @@ -1,5 +0,0 @@ |
415 | -{ |
416 | - "share": [ |
417 | - "pictures" |
418 | - ] |
419 | -} |
420 | |
421 | === removed file 'examples/facebook-share/facebook.png' |
422 | Binary files examples/facebook-share/facebook.png 2014-05-22 08:54:56 +0000 and examples/facebook-share/facebook.png 1970-01-01 00:00:00 +0000 differ |
423 | === removed file 'examples/facebook-share/manifest.json' |
424 | --- examples/facebook-share/manifest.json 2014-06-17 20:34:32 +0000 |
425 | +++ examples/facebook-share/manifest.json 1970-01-01 00:00:00 +0000 |
426 | @@ -1,18 +0,0 @@ |
427 | -{ |
428 | - "description": "Facebook (webapp version)", |
429 | - "framework": "ubuntu-sdk-14.10-dev1", |
430 | - "architecture": "all", |
431 | - "hooks": { |
432 | - "webapp-facebook": { |
433 | - "account-application": "webapp-facebook.application", |
434 | - "content-hub": "content-hub/webapp-facebook.json", |
435 | - "account-service": "webapp-facebook.service", |
436 | - "apparmor": "webapp-facebook.json", |
437 | - "desktop": "webapp-facebook.desktop" |
438 | - } |
439 | - }, |
440 | - "maintainer": "Webapps Team <webapps@lists.launchpad.net>", |
441 | - "name": "com.ubuntu.developer.webapps.webapp-facebook", |
442 | - "title": "webapp-facebook", |
443 | - "version": "1.0.17.4" |
444 | -} |
445 | |
446 | === removed directory 'examples/facebook-share/unity-webapps-facebook' |
447 | === removed file 'examples/facebook-share/unity-webapps-facebook/HubSharer.qml' |
448 | --- examples/facebook-share/unity-webapps-facebook/HubSharer.qml 2014-06-17 20:49:12 +0000 |
449 | +++ examples/facebook-share/unity-webapps-facebook/HubSharer.qml 1970-01-01 00:00:00 +0000 |
450 | @@ -1,41 +0,0 @@ |
451 | -import QtQuick 2.0 |
452 | -import Ubuntu.Components 0.1 |
453 | -import Ubuntu.Content 0.1 |
454 | - |
455 | -Item { |
456 | - id: main |
457 | - anchors.fill: parent |
458 | - |
459 | - signal completed(string result) |
460 | - |
461 | - property string fileToShare |
462 | - |
463 | - function _callback(accessToken, fileToShare, message, cb) { |
464 | - print ("_callback: " + accessToken); |
465 | - print ("_callback: " + fileToShare); |
466 | - print ("_callback: " + message); |
467 | - |
468 | - itemComp.url = fileToShare; |
469 | - var dataUri = itemComp.toDataURI(); |
470 | - var result = {accessToken: accessToken, |
471 | - fileToShare: dataUri.toString(), |
472 | - message: message}; |
473 | - |
474 | - completed(JSON.stringify(result)); |
475 | - } |
476 | - |
477 | - ContentItem { |
478 | - id: itemComp |
479 | - } |
480 | - |
481 | - Share { |
482 | - anchors.fill: parent |
483 | - visible: true |
484 | - fileToShare: main.fileToShare |
485 | - callback: _callback |
486 | - provider: "facebook" |
487 | - onCanceled: completed(JSON.stringify({status: "cancelled"})) |
488 | - onUploadCompleted: console.log (success) |
489 | - Component.onCompleted: print ("Page completed " + height + " : " + width) |
490 | - } |
491 | -} |
492 | |
493 | === removed file 'examples/facebook-share/unity-webapps-facebook/Share.qml' |
494 | --- examples/facebook-share/unity-webapps-facebook/Share.qml 2014-06-17 21:18:53 +0000 |
495 | +++ examples/facebook-share/unity-webapps-facebook/Share.qml 1970-01-01 00:00:00 +0000 |
496 | @@ -1,323 +0,0 @@ |
497 | -/* |
498 | - * Copyright (C) 2012-2013 Canonical, Ltd. |
499 | - * |
500 | - * This program is free software; you can redistribute it and/or modify |
501 | - * it under the terms of the GNU General Public License as published by |
502 | - * the Free Software Foundation; version 3. |
503 | - * |
504 | - * This program is distributed in the hope that it will be useful, |
505 | - * but WITHOUT ANY WARRANTY; without even the implied warranty of |
506 | - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
507 | - * GNU General Public License for more details. |
508 | - * |
509 | - * You should have received a copy of the GNU General Public License |
510 | - * along with this program. If not, see <http://www.gnu.org/licenses/>. |
511 | - */ |
512 | - |
513 | -import QtQuick 2.0 |
514 | -import QtQuick.Window 2.0 |
515 | -import Ubuntu.Components 0.1 |
516 | -import Ubuntu.Components.ListItems 0.1 as ListItem |
517 | -import Ubuntu.OnlineAccounts 0.1 |
518 | - |
519 | -Rectangle { |
520 | - id: root |
521 | - anchors.fill: parent |
522 | - color: Theme.palette.normal.background |
523 | - property string fileToShare |
524 | - property var callback |
525 | - property string serviceType: "webapps" |
526 | - property string provider: "facebook" |
527 | - property string userAccountId |
528 | - property string accessToken |
529 | - property var account |
530 | - signal accountSelected |
531 | - signal canceled() |
532 | - signal uploadCompleted(bool success) |
533 | - |
534 | - onUploadCompleted: { |
535 | - activitySpinner.visible = false; |
536 | - if (success) |
537 | - print ("Successfully posted"); |
538 | - else |
539 | - print ("Failed to post"); |
540 | - } |
541 | - |
542 | - AccountServiceModel { |
543 | - id: accounts |
544 | - serviceType: root.serviceType |
545 | - provider: root.provider |
546 | - Component.onCompleted: { |
547 | - if (count == 1) { |
548 | - srv.objectHandle = get(0, "accountServiceHandle"); |
549 | - } |
550 | - } |
551 | - } |
552 | - |
553 | - AccountService { |
554 | - id: srv |
555 | - onObjectHandleChanged: { |
556 | - root.account = srv; |
557 | - root.account.authenticate(null); |
558 | - } |
559 | - onAuthenticated: { |
560 | - root.userAccountId = accountId; |
561 | - root.accessToken = reply.AccessToken; |
562 | - shareComponent.visible = true; |
563 | - sharemenu.visible = false; |
564 | - } |
565 | - } |
566 | - |
567 | - |
568 | - Rectangle { |
569 | - id: shareComponent |
570 | - objectName: "shareComponent" |
571 | - anchors.fill: parent |
572 | - color: Theme.palette.normal.background |
573 | - visible: false |
574 | - |
575 | - Column { |
576 | - anchors.fill: parent |
577 | - spacing: units.gu(1) |
578 | - |
579 | - Item { |
580 | - id: serviceHeader |
581 | - y: 0 |
582 | - anchors.left: parent.left |
583 | - anchors.right: parent.right |
584 | - anchors.topMargin: units.gu(1) |
585 | - anchors.leftMargin: units.gu(1) |
586 | - anchors.rightMargin: units.gu(1) |
587 | - height: childrenRect.height |
588 | - |
589 | - ListItem.Subtitled { |
590 | - anchors { |
591 | - left: parent.left |
592 | - right: parent.right |
593 | - } |
594 | - iconName: root.account.provider.iconName |
595 | - text: root.account.provider.displayName |
596 | - subText: root.account.displayName |
597 | - showDivider: false |
598 | - } |
599 | - } |
600 | - |
601 | - ListItem.ThinDivider {} |
602 | - |
603 | - UbuntuShape { |
604 | - id: messageArea |
605 | - objectName: "messageArea" |
606 | - anchors.left: parent.left |
607 | - anchors.right: parent.right |
608 | - anchors.topMargin: units.gu(1) |
609 | - anchors.leftMargin: units.gu(1) |
610 | - anchors.rightMargin: units.gu(1) |
611 | - |
612 | - height: units.gu(20) |
613 | - color: "#f2f2f2" |
614 | - |
615 | - TextEdit { |
616 | - id: message |
617 | - color: "#333333" |
618 | - anchors.top: parent.top |
619 | - anchors.left: snapshot.right |
620 | - anchors.bottom: parent.bottom |
621 | - anchors.margins: units.gu(1) |
622 | - wrapMode: Text.Wrap |
623 | - width: parent.width - snapshot.width - |
624 | - snapshot.anchors.margins * 2 - |
625 | - message.anchors.leftMargin - message.anchors.rightMargin |
626 | - clip: true |
627 | - font.pixelSize: FontUtils.sizeToPixels("medium") |
628 | - font.weight: Font.Light |
629 | - focus: true |
630 | - } |
631 | - |
632 | - ActivityIndicator { |
633 | - id: activitySpinner |
634 | - anchors.centerIn: message |
635 | - visible: false |
636 | - running: visible |
637 | - } |
638 | - |
639 | - UbuntuShape { |
640 | - id: snapshot |
641 | - anchors.top: parent.top |
642 | - anchors.left: parent.left |
643 | - anchors.margins: units.gu(1) |
644 | - width: units.gu(10) |
645 | - height: units.gu(10) |
646 | - |
647 | - image: Image { |
648 | - source: fileToShare |
649 | - sourceSize.height: snapshot.height |
650 | - sourceSize.width: snapshot.width |
651 | - fillMode: Image.PreserveAspectCrop |
652 | - } |
653 | - } |
654 | - } |
655 | - |
656 | - Item { |
657 | - id: actionsBar |
658 | - anchors.left: parent.left |
659 | - anchors.right: parent.right |
660 | - anchors.topMargin: units.gu(2) |
661 | - anchors.leftMargin: units.gu(1) |
662 | - anchors.rightMargin: units.gu(1) |
663 | - height: childrenRect.height |
664 | - |
665 | - Button { |
666 | - objectName: "cancelButton" |
667 | - anchors.left: parent.left |
668 | - text: i18n.dtr("ubuntu-ui-extras", "Cancel") |
669 | - color: "#cccccc" |
670 | - width: units.gu(10) |
671 | - height: units.gu(4) |
672 | - onClicked: canceled() |
673 | - } |
674 | - |
675 | - Button { |
676 | - objectName: "postButton" |
677 | - anchors.right: parent.right |
678 | - anchors.top: parent.top |
679 | - text: i18n.dtr("ubuntu-ui-extras", "Post") |
680 | - color: "#dd4814" |
681 | - width: units.gu(10) |
682 | - height: units.gu(4) |
683 | - enabled: !activitySpinner.visible |
684 | - onClicked: { |
685 | - activitySpinner.visible = true; |
686 | - callback(accessToken, fileToShare, message.text, uploadCompleted); |
687 | - } |
688 | - } |
689 | - } |
690 | - |
691 | - UbuntuShape { |
692 | - id: useLocation |
693 | - anchors { |
694 | - left: parent.left |
695 | - leftMargin: units.gu(1) |
696 | - topMargin: units.gu(1) |
697 | - } |
698 | - color: selected ? "#cccccc" : "transparent" |
699 | - property bool selected: false |
700 | - width: units.gu(4.5) |
701 | - height: units.gu(4) |
702 | - |
703 | - AbstractButton { |
704 | - anchors.fill: parent |
705 | - onClicked: parent.selected = !parent.selected |
706 | - Image { |
707 | - source: "assets/icon_location.png" |
708 | - anchors.centerIn: parent |
709 | - height: parent.height * 0.75 |
710 | - fillMode: Image.PreserveAspectFit |
711 | - smooth: true |
712 | - } |
713 | - } |
714 | - } |
715 | - |
716 | - Label { |
717 | - anchors.left: useLocation.right |
718 | - anchors.baseline: useLocation.top |
719 | - anchors.baselineOffset: units.gu(3) |
720 | - anchors.leftMargin: units.gu(1) |
721 | - text: i18n.dtr("ubuntu-ui-extras", "Include location") |
722 | - fontSize: "small" |
723 | - } |
724 | - |
725 | - } |
726 | - |
727 | - states: [ |
728 | - State { |
729 | - name: "landscape-with-keyborad" |
730 | - PropertyChanges { |
731 | - target: serviceHeader |
732 | - y: - serviceHeader.height |
733 | - } |
734 | - PropertyChanges { |
735 | - target: messageArea |
736 | - height: units.gu(12) |
737 | - } |
738 | - } |
739 | - ] |
740 | - |
741 | - state: ((Screen.orientation === Qt.LandscapeOrientation) || |
742 | - (Screen.orientation === Qt.InvertedLandscapeOrientation)) && |
743 | - Qt.inputMethod.visible ? "landscape-with-keyborad" : "" |
744 | - } |
745 | - |
746 | - /* Menu listing online accounts */ |
747 | - Item { |
748 | - id: sharemenu |
749 | - anchors.fill: parent |
750 | - visible: true |
751 | - |
752 | - signal selected(string accountId, string token) |
753 | - |
754 | - Component.onCompleted: { |
755 | - visible = true; |
756 | - } |
757 | - onSelected: { |
758 | - root.userAccountId = accountId; |
759 | - root.accessToken = token; |
760 | - shareComponent.visible = true; |
761 | - sharemenu.visible = false; |
762 | - } |
763 | - |
764 | - Component { |
765 | - id: acctDelegate |
766 | - Item { |
767 | - anchors { |
768 | - left: parent.left |
769 | - right: parent.right |
770 | - } |
771 | - AccountService { |
772 | - id: service |
773 | - objectHandle: accountServiceHandle |
774 | - onAuthenticated: { |
775 | - sharemenu.selected(accountId, reply.AccessToken); |
776 | - } |
777 | - } |
778 | - |
779 | - height: childrenRect.height |
780 | - |
781 | - ListItem.Subtitled { |
782 | - anchors { |
783 | - left: parent.left |
784 | - right: parent.right |
785 | - } |
786 | - text: service.provider.displayName |
787 | - subText: displayName |
788 | - iconName: service.provider.iconName |
789 | - __iconHeight: units.gu(5) |
790 | - __iconWidth: units.gu(5) |
791 | - |
792 | - onClicked: { |
793 | - root.account = service; |
794 | - root.account.authenticate(null); |
795 | - } |
796 | - } |
797 | - } |
798 | - } |
799 | - |
800 | - ListView { |
801 | - anchors { |
802 | - top: parent.top |
803 | - left: parent.left |
804 | - right: parent.right |
805 | - } |
806 | - height: childrenRect.height |
807 | - interactive: false |
808 | - model: accounts |
809 | - header: ListItem.Header { |
810 | - anchors { |
811 | - left: parent.left |
812 | - right: parent.right |
813 | - } |
814 | - text: i18n.tr("Select account") |
815 | - } |
816 | - delegate: acctDelegate |
817 | - } |
818 | - } |
819 | -} |
820 | |
821 | === removed directory 'examples/facebook-share/unity-webapps-facebook/assets' |
822 | === removed file 'examples/facebook-share/unity-webapps-facebook/assets/avatar_image.jpg' |
823 | Binary files examples/facebook-share/unity-webapps-facebook/assets/avatar_image.jpg 2014-05-23 10:05:07 +0000 and examples/facebook-share/unity-webapps-facebook/assets/avatar_image.jpg 1970-01-01 00:00:00 +0000 differ |
824 | === removed file 'examples/facebook-share/unity-webapps-facebook/assets/icon_location.png' |
825 | Binary files examples/facebook-share/unity-webapps-facebook/assets/icon_location.png 2014-05-23 10:05:07 +0000 and examples/facebook-share/unity-webapps-facebook/assets/icon_location.png 1970-01-01 00:00:00 +0000 differ |
826 | === removed file 'examples/facebook-share/unity-webapps-facebook/facebook.user.js' |
827 | --- examples/facebook-share/unity-webapps-facebook/facebook.user.js 2014-06-17 20:34:32 +0000 |
828 | +++ examples/facebook-share/unity-webapps-facebook/facebook.user.js 1970-01-01 00:00:00 +0000 |
829 | @@ -1,47 +0,0 @@ |
830 | -var api = external.getUnityObject('1.0'); |
831 | -var hub = api.ContentHub; |
832 | -var activeTransfer; |
833 | - |
834 | -function _shareRequested(transfer) { |
835 | - activeTransfer = transfer; |
836 | - transfer.items(function(items) { |
837 | - api.launchEmbeddedUI("HubSharer", upload, {"fileToShare": items[0]}); |
838 | - }); |
839 | -}; |
840 | - |
841 | -hub.onShareRequested(_shareRequested); |
842 | - |
843 | -function upload(res) { |
844 | - var results = JSON.parse(res); |
845 | - if (results.status == "cancelled") |
846 | - activeTransfer.setState(hub.ContentTransfer.State.Aborted); |
847 | - |
848 | - var xhr = new XMLHttpRequest(); |
849 | - xhr.open( 'POST', 'https://graph.facebook.com/me/photos?access_token=' + results.accessToken, true ); |
850 | - xhr.onload = xhr.onerror = function() { |
851 | - if ( xhr.status == 200 ) |
852 | - window.location.reload(); |
853 | - }; |
854 | - |
855 | - var contentType = results.fileToShare.split(',')[0].split(':')[1]; |
856 | - var b64data = results.fileToShare.split(',')[1]; |
857 | - |
858 | - var byteCharacters = atob(b64data); |
859 | - var byteNumbers = new Array(byteCharacters.length); |
860 | - for (var i = 0; i < byteCharacters.length; i++) { |
861 | - byteNumbers[i] = byteCharacters.charCodeAt(i); |
862 | - } |
863 | - var byteArray = new Uint8Array(byteNumbers); |
864 | - |
865 | - var div = document.createElement('div'); |
866 | - div.innerHTML = '<form enctype="multipart/form-data" method="post" id="uploadForm"><textarea id="message" name="message"></textarea></form>'; |
867 | - document.getElementsByTagName('body')[0].appendChild(div); |
868 | - |
869 | - var blob = new Blob([byteArray], {type: contentType}); |
870 | - |
871 | - var uploadForm = document.forms.namedItem("uploadForm"); |
872 | - var formData = new FormData(uploadForm); |
873 | - formData.append('source', blob); |
874 | - formData.append('message', results.message); |
875 | - xhr.send(formData); |
876 | -} |
877 | |
878 | === removed file 'examples/facebook-share/unity-webapps-facebook/manifest.json' |
879 | --- examples/facebook-share/unity-webapps-facebook/manifest.json 2014-05-23 07:42:14 +0000 |
880 | +++ examples/facebook-share/unity-webapps-facebook/manifest.json 1970-01-01 00:00:00 +0000 |
881 | @@ -1,7 +0,0 @@ |
882 | -{ |
883 | - "name": "facebook", |
884 | - "includes": ["https://*.facebook.com/*"], |
885 | - "homepage": "https://m.facebook.com/", |
886 | - "domain": "facebook.com", |
887 | - "scripts": ["facebook.user.js"] |
888 | -} |
889 | |
890 | === removed file 'examples/facebook-share/webapp-facebook.application' |
891 | --- examples/facebook-share/webapp-facebook.application 2014-05-22 08:54:56 +0000 |
892 | +++ examples/facebook-share/webapp-facebook.application 1970-01-01 00:00:00 +0000 |
893 | @@ -1,11 +0,0 @@ |
894 | -<?xml version="1.0" encoding="UTF-8" ?> |
895 | -<application id="com.ubuntu.developer.webapps.webapp-facebook_webapp-facebook"> |
896 | - <description>Facebook webapp</description> |
897 | - |
898 | - <services> |
899 | - <service id="com.ubuntu.developer.webapps.webapp-facebook_webapp-facebook"> |
900 | - <description>Use the service in a webapp</description> |
901 | - </service> |
902 | - </services> |
903 | - |
904 | -</application> |
905 | |
906 | === removed file 'examples/facebook-share/webapp-facebook.desktop' |
907 | --- examples/facebook-share/webapp-facebook.desktop 2014-06-17 17:53:45 +0000 |
908 | +++ examples/facebook-share/webapp-facebook.desktop 1970-01-01 00:00:00 +0000 |
909 | @@ -1,9 +0,0 @@ |
910 | -[Desktop Entry] |
911 | -Type=Application |
912 | -Terminal=false |
913 | -Exec=webapp-container --enable-back-forward --webapp='ZmFjZWJvb2s=' --webappModelSearchPath=. --webappUrlPatterns=https?://*.facebook.com/* |
914 | -Name=Facebook |
915 | -Icon=./facebook.png |
916 | -X-Ubuntu-Touch=true |
917 | -X-Ubuntu-StageHint=SideStage |
918 | -X-Ubuntu-Single-Instance=true |
919 | |
920 | === removed file 'examples/facebook-share/webapp-facebook.json' |
921 | --- examples/facebook-share/webapp-facebook.json 2014-05-23 13:00:57 +0000 |
922 | +++ examples/facebook-share/webapp-facebook.json 1970-01-01 00:00:00 +0000 |
923 | @@ -1,13 +0,0 @@ |
924 | -{ |
925 | - "template": "ubuntu-webapp", |
926 | - "policy_groups": [ |
927 | - "networking", |
928 | - "accounts", |
929 | - "audio", |
930 | - "video", |
931 | - "webview", |
932 | - "location", |
933 | - "content_exchange" |
934 | - ], |
935 | - "policy_version": 1.2 |
936 | -} |
937 | |
938 | === removed file 'examples/facebook-share/webapp-facebook.service' |
939 | --- examples/facebook-share/webapp-facebook.service 2014-05-23 13:00:57 +0000 |
940 | +++ examples/facebook-share/webapp-facebook.service 1970-01-01 00:00:00 +0000 |
941 | @@ -1,6 +0,0 @@ |
942 | -<?xml version="1.0" encoding="UTF-8"?> |
943 | -<service id="com.ubuntu.developer.webapps.webapp-facebook_webapp-facebook"> |
944 | - <type>webapps</type> |
945 | - <name>Facebook Webapp</name> |
946 | - <provider>facebook</provider> |
947 | -</service> |
948 | |
949 | === modified file 'examples/unity-webapps-example-bbcnews/main.qml' |
950 | --- examples/unity-webapps-example-bbcnews/main.qml 2013-07-31 17:27:00 +0000 |
951 | +++ examples/unity-webapps-example-bbcnews/main.qml 2014-11-22 00:43:58 +0000 |
952 | @@ -18,8 +18,7 @@ |
953 | |
954 | import QtQuick 2.0 |
955 | import QtQuick.Window 2.0 |
956 | -import QtWebKit 3.0 |
957 | -import QtWebKit.experimental 1.0 |
958 | +import com.canonical.Oxide 1.0 |
959 | import Ubuntu.UnityWebApps 0.1 |
960 | |
961 | Window { |
962 | @@ -33,23 +32,19 @@ |
963 | width: parent.width |
964 | height: parent.height |
965 | |
966 | - experimental.userScripts: [] |
967 | - experimental.preferences.navigatorQtObjectEnabled: true |
968 | - experimental.preferences.developerExtrasEnabled: true |
969 | - |
970 | - experimental.userAgent: { |
971 | - return "Mozilla/5.0 (iPad; CPU OS 5_0 like Mac OS X) AppleWebKit/534.46 (KHTML, like Gecko) Version/5.1 Mobile/9A334 Safari/7534.48.3" |
972 | + context: WebContext { |
973 | + userAgent: "Mozilla/5.0 (iPad; CPU OS 5_0 like Mac OS X) AppleWebKit/534.46 (KHTML, like Gecko) Version/5.1 Mobile/9A334 Safari/7534.48.3" |
974 | } |
975 | |
976 | function getUnityWebappsProxies() { |
977 | - return UnityWebAppsUtils.makeProxiesForQtWebViewBindee(webView); |
978 | + return UnityWebAppsUtils.makeProxiesForWebViewBindee(webView); |
979 | } |
980 | + } |
981 | |
982 | - UnityWebApps { |
983 | - id: webapps |
984 | - name: "BBCNews" |
985 | - bindee: webView |
986 | - model: UnityWebappsAppModel { searchPath: '/usr/share/unity-webapps-qml/examples/data/userscripts'} |
987 | - } |
988 | + UnityWebApps { |
989 | + id: webapps |
990 | + name: "BBCNews" |
991 | + bindee: webView |
992 | + model: UnityWebappsAppModel { searchPath: '/usr/share/unity-webapps-qml/examples/data/userscripts'} |
993 | } |
994 | } |
995 | |
996 | === modified file 'examples/unity-webapps-example-facebookmessenger/main.qml' |
997 | --- examples/unity-webapps-example-facebookmessenger/main.qml 2013-07-31 19:27:51 +0000 |
998 | +++ examples/unity-webapps-example-facebookmessenger/main.qml 2014-11-22 00:43:58 +0000 |
999 | @@ -18,8 +18,7 @@ |
1000 | |
1001 | import QtQuick 2.0 |
1002 | import QtQuick.Window 2.0 |
1003 | -import QtWebKit 3.0 |
1004 | -import QtWebKit.experimental 1.0 |
1005 | +import com.canonical.Oxide 1.0 |
1006 | import Ubuntu.UnityWebApps 0.1 |
1007 | |
1008 | Window { |
1009 | @@ -33,19 +32,17 @@ |
1010 | width: parent.width |
1011 | height: parent.height |
1012 | |
1013 | - experimental.userScripts: [] |
1014 | - experimental.preferences.navigatorQtObjectEnabled: true |
1015 | - experimental.preferences.developerExtrasEnabled: true |
1016 | + context: WebContext { } |
1017 | |
1018 | function getUnityWebappsProxies() { |
1019 | - return UnityWebAppsUtils.makeProxiesForQtWebViewBindee(webView); |
1020 | + return UnityWebAppsUtils.makeProxiesForWebViewBindee(webView); |
1021 | } |
1022 | + } |
1023 | |
1024 | - UnityWebApps { |
1025 | - id: webapps |
1026 | - name: "FacebookMessenger" |
1027 | - bindee: webView |
1028 | - model: UnityWebappsAppModel { searchPath: '/usr/share/unity-webapps-qml/examples/data/userscripts'} |
1029 | - } |
1030 | + UnityWebApps { |
1031 | + id: webapps |
1032 | + name: "FacebookMessenger" |
1033 | + bindee: webView |
1034 | + model: UnityWebappsAppModel { searchPath: '/usr/share/unity-webapps-qml/examples/data/userscripts'} |
1035 | } |
1036 | } |
1037 | |
1038 | === modified file 'src/Ubuntu/UnityWebApps/UnityWebApps.js' |
1039 | --- src/Ubuntu/UnityWebApps/UnityWebApps.js 2014-07-18 13:43:55 +0000 |
1040 | +++ src/Ubuntu/UnityWebApps/UnityWebApps.js 2014-11-22 00:43:58 +0000 |
1041 | @@ -75,8 +75,7 @@ |
1042 | var cb = this._onMessageReceivedCallback.bind(self); |
1043 | self._bindeeProxies.messageReceivedConnect(cb); |
1044 | |
1045 | - cb = this._onLoadingStartedCallback.bind(self); |
1046 | - self._bindeeProxies.loadingStartedConnect(cb); |
1047 | + this._onLoadingStartedCallback(); |
1048 | }, |
1049 | |
1050 | /** |
1051 | |
1052 | === modified file 'src/Ubuntu/UnityWebApps/UnityWebApps.qml' |
1053 | --- src/Ubuntu/UnityWebApps/UnityWebApps.qml 2014-07-18 21:46:57 +0000 |
1054 | +++ src/Ubuntu/UnityWebApps/UnityWebApps.qml 2014-11-22 00:43:58 +0000 |
1055 | @@ -168,17 +168,20 @@ |
1056 | property string _opt_homepage: "" |
1057 | |
1058 | |
1059 | + /*! |
1060 | + \qmlsignal UnityWebApps::userScriptsInjected() |
1061 | + |
1062 | + This signal is emitted when the component has completed its initialization and |
1063 | + the userscripts have been injected into the binded webview. |
1064 | + */ |
1065 | + signal userScriptsInjected() |
1066 | + |
1067 | + |
1068 | Settings { |
1069 | id: settings |
1070 | injectExtraContentShareCapabilities: name && name.length && name.length !== 0 |
1071 | } |
1072 | |
1073 | -/* |
1074 | - Loader { |
1075 | - id: apiBindingModelComponentLoader |
1076 | - sourceComponent: settings.injectExtraUbuntuApis ? apiBindingModelComponent : undefined |
1077 | - } |
1078 | -*/ |
1079 | |
1080 | /*! |
1081 | \internal |
1082 | @@ -237,6 +240,8 @@ |
1083 | |
1084 | if (internal.backends) |
1085 | internal.instance.setBackends(internal.backends) |
1086 | + |
1087 | + userScriptsInjected(); |
1088 | } |
1089 | |
1090 | /*! |
1091 | @@ -392,7 +397,11 @@ |
1092 | \internal |
1093 | |
1094 | */ |
1095 | - onModelChanged: model.modelContentChanged.connect(__setupNamedWebappEnvironment) |
1096 | + onModelChanged: { |
1097 | + if (model) { |
1098 | + model.modelContentChanged.connect(__setupNamedWebappEnvironment) |
1099 | + } |
1100 | + } |
1101 | |
1102 | /*! |
1103 | \internal |
1104 | |
1105 | === modified file 'src/Ubuntu/UnityWebApps/UnityWebAppsUtils.js' |
1106 | --- src/Ubuntu/UnityWebApps/UnityWebAppsUtils.js 2014-10-08 17:16:47 +0000 |
1107 | +++ src/Ubuntu/UnityWebApps/UnityWebAppsUtils.js 2014-11-22 00:43:58 +0000 |
1108 | @@ -64,7 +64,7 @@ |
1109 | this.disposer = disposer; |
1110 | this.makeSignalDisconnecter = makeSignalDisconnecter; |
1111 | this._userScriptInjected = false; |
1112 | - this._WEBAPPS_USER_SCRIPT_CONTEXT = "oxide://UnityWebappsApi"; |
1113 | + this._WEBAPPS_USER_SCRIPT_CONTEXT = "oxide://main-world"; |
1114 | } |
1115 | OxideWebviewAdapter.prototype = { |
1116 | injectUserScripts: function(userScriptUrls) { |
1117 | @@ -79,12 +79,19 @@ |
1118 | |
1119 | for (var i = 0; i < userScriptUrls.length; ++i) { |
1120 | var scriptStart = "import com.canonical.Oxide 1.0 as Oxide; Oxide.UserScript { context:"; |
1121 | - var scriptEnd = "}"; |
1122 | + var scriptEnd = " }"; |
1123 | var statement = scriptStart + |
1124 | - '"' + this._WEBAPPS_USER_SCRIPT_CONTEXT + '"' + |
1125 | - '; matchAllFrames: false; url: "' + userScriptUrls[i] + '";' + scriptEnd; |
1126 | + '"' + |
1127 | + this._WEBAPPS_USER_SCRIPT_CONTEXT + |
1128 | + '"' + |
1129 | + '; matchAllFrames: false; emulateGreasemonkey: true; url: "' + |
1130 | + userScriptUrls[i] + |
1131 | + '";' |
1132 | + + scriptEnd; |
1133 | + |
1134 | context.addUserScript(Qt.createQmlObject(statement, this.webview)); |
1135 | } |
1136 | + |
1137 | this._userScriptInjected = true; |
1138 | }, |
1139 | sendToPage: function (message) { |
1140 | |
1141 | === modified file 'src/Ubuntu/UnityWebApps/common/js/unity-backend-messaging-proxy.js' |
1142 | --- src/Ubuntu/UnityWebApps/common/js/unity-backend-messaging-proxy.js 2014-03-28 13:21:47 +0000 |
1143 | +++ src/Ubuntu/UnityWebApps/common/js/unity-backend-messaging-proxy.js 2014-11-22 00:43:58 +0000 |
1144 | @@ -4,7 +4,7 @@ |
1145 | navigator.qt.postMessage) { |
1146 | return new UnityQtWebkitBackendMessagingProxy(); |
1147 | } |
1148 | - else if (window.oxide) { |
1149 | + else if (oxide) { |
1150 | return new UnityOxideBackendMessagingProxy(); |
1151 | } |
1152 | return null; |
1153 | |
1154 | === modified file 'src/Ubuntu/UnityWebApps/unity-webapps-api.js.in' |
1155 | --- src/Ubuntu/UnityWebApps/unity-webapps-api.js.in 2014-06-04 21:17:00 +0000 |
1156 | +++ src/Ubuntu/UnityWebApps/unity-webapps-api.js.in 2014-11-22 00:43:58 +0000 |
1157 | @@ -1,3 +1,7 @@ |
1158 | +// ==UserScript== |
1159 | +// @inject_in_main_world |
1160 | +// ==/UserScript== |
1161 | + |
1162 | /* |
1163 | * Copyright 2013 Canonical Ltd. |
1164 | * |
1165 | |
1166 | === modified file 'tests/autopilot/autopilot.pro' |
1167 | --- tests/autopilot/autopilot.pro 2014-07-14 19:04:25 +0000 |
1168 | +++ tests/autopilot/autopilot.pro 2014-11-22 00:43:58 +0000 |
1169 | @@ -20,7 +20,6 @@ |
1170 | $$system(ls ./data/*/*) \ |
1171 | unity_webapps_qml/tests/test_installedWebapp.py \ |
1172 | unity_webapps_qml/tests/fake_servers.py \ |
1173 | - qml/WebviewBackendWebkit.qml \ |
1174 | qml/WebviewBackendOxide.qml \ |
1175 | qml/message-server.js \ |
1176 | $$system(ls ./data/installed-webapps/*) \ |
1177 | |
1178 | === modified file 'tests/autopilot/qml/FullWebViewApp.qml' |
1179 | --- tests/autopilot/qml/FullWebViewApp.qml 2014-07-18 21:46:57 +0000 |
1180 | +++ tests/autopilot/qml/FullWebViewApp.qml 2014-11-22 00:43:58 +0000 |
1181 | @@ -35,21 +35,9 @@ |
1182 | signal resultUpdated(string message) |
1183 | |
1184 | function evalInPageUnsafe(expr) { |
1185 | - if (webView && webView.experimental) { |
1186 | - webView.experimental.evaluateJavaScript(DomIntrospectionUtils.wrapJsCommands(expr), |
1187 | - function(result) { |
1188 | - console.log('Result: ' + result); |
1189 | - root.resultUpdated(DomIntrospectionUtils.createResult(result)); |
1190 | - }); |
1191 | - } |
1192 | - else { |
1193 | - root.resultUpdated(DomIntrospectionUtils.createResult(webView.evaluateCode("return navigator.userAgent", true))) |
1194 | - } |
1195 | + return webView.evaluateCode(expr, true); |
1196 | } |
1197 | |
1198 | - property var webView: null |
1199 | - |
1200 | - property bool useOxide: false |
1201 | property string url: "" |
1202 | |
1203 | property string apiBackendQmlFileUrl: "" |
1204 | @@ -67,24 +55,14 @@ |
1205 | active: true |
1206 | } |
1207 | |
1208 | - Loader { |
1209 | - id: webviewLoader |
1210 | - onLoaded: { |
1211 | - webView = webviewLoader.item |
1212 | - } |
1213 | - } |
1214 | - |
1215 | - Component.onCompleted: { |
1216 | - var webviewSource = useOxide ? |
1217 | - Qt.resolvedUrl("WebviewBackendOxide.qml") |
1218 | - : Qt.resolvedUrl("WebviewBackendWebkit.qml"); |
1219 | - var override = webappName && webappModel.exists(webappName) ? |
1220 | - webappModel.userAgentOverrideFor(webappName) : "" |
1221 | - webviewLoader.setSource(webviewSource, |
1222 | - { url: root.url, |
1223 | - localUserAgentOverride: override}) |
1224 | - } |
1225 | - |
1226 | + WebviewBackendOxide { |
1227 | + id: webView |
1228 | + url: root.url |
1229 | + localUserAgentOverride: webappName && webappModel.exists(webappName) |
1230 | + ? webappModel.userAgentOverrideFor(webappName) : "" |
1231 | + } |
1232 | + |
1233 | + // Offers a way to override/mock the API backends |
1234 | Loader { |
1235 | id: apiBackendQmlFileLoader |
1236 | source: apiBackendQmlFileUrl.length !== 0 ? apiBackendQmlFileUrl : "" |
1237 | @@ -93,10 +71,9 @@ |
1238 | Loader { |
1239 | id: unityWebappsComponentLoader |
1240 | anchors.fill: parent |
1241 | - sourceComponent: webView !== null ? |
1242 | - (apiBackendQmlFileUrl.length !== 0 ? |
1243 | - (apiBackendQmlFileLoader.item ? unityWebappsComponent : undefined) |
1244 | - : unityWebappsComponent) : null |
1245 | + sourceComponent: (apiBackendQmlFileUrl.length !== 0 |
1246 | + && !apiBackendQmlFileLoader.item) |
1247 | + ? undefined : unityWebappsComponent |
1248 | } |
1249 | |
1250 | UnityWebappsAppModel { |
1251 | |
1252 | === modified file 'tests/autopilot/qml/WebviewBackendOxide.qml' |
1253 | --- tests/autopilot/qml/WebviewBackendOxide.qml 2014-07-16 20:15:17 +0000 |
1254 | +++ tests/autopilot/qml/WebviewBackendOxide.qml 2014-11-22 00:43:58 +0000 |
1255 | @@ -9,6 +9,9 @@ |
1256 | |
1257 | property string localUserAgentOverride: "" |
1258 | |
1259 | + preferences.localStorageEnabled: true |
1260 | + preferences.appCacheEnabled: true |
1261 | + |
1262 | function _waitForResult(req, timeout) { |
1263 | var result; |
1264 | var error; |
1265 | @@ -46,7 +49,7 @@ |
1266 | function evaluateCode(code, wrap) { |
1267 | var value = webView._waitForResult( |
1268 | webView.rootFrame.sendMessage( |
1269 | - "webview-oxide://test/", |
1270 | + "oxide://main-world", |
1271 | "EVALUATE-CODE", |
1272 | { code: code, |
1273 | wrap: wrap === undefined ? false : wrap })); |
1274 | @@ -54,10 +57,12 @@ |
1275 | } |
1276 | |
1277 | context: Oxide.WebContext { |
1278 | - userAgent: webView.localUserAgentOverride.length === 0 ? "" : webView.localUserAgentOverride |
1279 | + userAgent: webView.localUserAgentOverride.length === 0 |
1280 | + ? "" : webView.localUserAgentOverride |
1281 | userScripts: [ |
1282 | Oxide.UserScript { |
1283 | - context: "webview-oxide://test/" |
1284 | + context: "oxide://main-world" |
1285 | + emulateGreasemonkey: true |
1286 | url: Qt.resolvedUrl("message-server.js") |
1287 | matchAllFrames: true |
1288 | } |
1289 | |
1290 | === removed file 'tests/autopilot/qml/WebviewBackendWebkit.qml' |
1291 | --- tests/autopilot/qml/WebviewBackendWebkit.qml 2014-07-08 19:27:21 +0000 |
1292 | +++ tests/autopilot/qml/WebviewBackendWebkit.qml 1970-01-01 00:00:00 +0000 |
1293 | @@ -1,19 +0,0 @@ |
1294 | -import QtQuick 2.0 |
1295 | -import QtWebKit 3.0 |
1296 | -import QtWebKit.experimental 1.0 |
1297 | -import Ubuntu.UnityWebApps 0.1 |
1298 | - |
1299 | -WebView { |
1300 | - id: webView |
1301 | - objectName: "webview" |
1302 | - |
1303 | - property string localUserAgentOverride: "" |
1304 | - |
1305 | - experimental.userScripts: [] |
1306 | - experimental.preferences.navigatorQtObjectEnabled: true |
1307 | - experimental.preferences.developerExtrasEnabled: true |
1308 | - |
1309 | - function getUnityWebappsProxies() { |
1310 | - return UnityWebAppsUtils.makeProxiesForQtWebViewBindee(webView); |
1311 | - } |
1312 | -} |
1313 | |
1314 | === modified file 'tests/autopilot/unity_webapps_qml/tests/__init__.py' |
1315 | --- tests/autopilot/unity_webapps_qml/tests/__init__.py 2014-07-14 19:01:17 +0000 |
1316 | +++ tests/autopilot/unity_webapps_qml/tests/__init__.py 2014-11-22 00:43:58 +0000 |
1317 | @@ -9,29 +9,31 @@ |
1318 | |
1319 | import os |
1320 | import os.path |
1321 | -import shutil |
1322 | -import tempfile |
1323 | -import json |
1324 | |
1325 | -from testtools.matchers import Contains, Equals, GreaterThan |
1326 | +from testtools.matchers import Equals |
1327 | from autopilot.matchers import Eventually |
1328 | from unity_webapps_qml.tests import fake_servers |
1329 | |
1330 | -from unity.emulators.unity import Unity |
1331 | - |
1332 | -from unity.tests import UnityTestCase |
1333 | - |
1334 | -LOCAL_QML_LAUNCHER_APP_PATH = "%s/%s" % (os.path.dirname(os.path.realpath(__file__)), '../../../../tools/qml-launcher/unity-webapps-qml-launcher') |
1335 | +from autopilot.testcase import AutopilotTestCase |
1336 | + |
1337 | +LOCAL_QML_LAUNCHER_APP_PATH = "{}/{}".format( |
1338 | + os.path.dirname(os.path.realpath(__file__)), |
1339 | + '../../../../tools/qml-launcher/unity-webapps-qml-launcher') |
1340 | + |
1341 | INSTALLED_QML_LAUNCHER_APP_PATH = 'unity-webapps-qml-launcher' |
1342 | |
1343 | # TODO create __init__.py.in |
1344 | -LOCAL_BROWSER_CONTAINER_PATH = "%s/%s" % (os.path.dirname(os.path.realpath(__file__)), '../../qml/FullWebViewApp.qml') |
1345 | -INSTALLED_BROWSER_CONTAINER_PATH = '/usr/share/unity-webapps-qml/autopilot-tests/qml/FullWebViewApp.qml' |
1346 | +LOCAL_BROWSER_CONTAINER_PATH = "{}/{}".format( |
1347 | + os.path.dirname(os.path.realpath(__file__)), |
1348 | + '../../qml/FullWebViewApp.qml') |
1349 | + |
1350 | +INSTALLED_BROWSER_CONTAINER_PATH = \ |
1351 | + '/usr/share/unity-webapps-qml/autopilot-tests/qml/FullWebViewApp.qml' |
1352 | |
1353 | BASE_URL = '' |
1354 | |
1355 | -class UnityWebappsTestCaseBase(UnityTestCase): |
1356 | |
1357 | +class UnityWebappsTestCaseBase(AutopilotTestCase): |
1358 | def setUp(self): |
1359 | super(UnityWebappsTestCaseBase, self).setUp() |
1360 | self.use_oxide = False |
1361 | @@ -52,17 +54,18 @@ |
1362 | return LOCAL_QML_LAUNCHER_APP_PATH |
1363 | return INSTALLED_QML_LAUNCHER_APP_PATH |
1364 | |
1365 | - def get_launch_params(self, |
1366 | - url, |
1367 | - webapp_name='unitywebappsqmllauncher', |
1368 | - webapp_search_path="", |
1369 | - webapp_homepage="", |
1370 | - use_oxide=False, |
1371 | - extra_params=[]): |
1372 | + def get_launch_params( |
1373 | + self, |
1374 | + url, |
1375 | + webapp_name='unitywebappsqmllauncher', |
1376 | + webapp_search_path="", |
1377 | + webapp_homepage="", |
1378 | + use_oxide=False, |
1379 | + extra_params=[]): |
1380 | base_params = ['--qml=' + self.get_qml_browser_container_path(), |
1381 | - '--app-id=' + webapp_name, |
1382 | - '--webappName=' + webapp_name, |
1383 | - '--webappSearchPath=' + webapp_search_path] |
1384 | + '--app-id=' + webapp_name, |
1385 | + '--webappName=' + webapp_name, |
1386 | + '--webappSearchPath=' + webapp_search_path] |
1387 | |
1388 | if len(webapp_homepage) != 0: |
1389 | base_params.append('--webappHomepage=' + webapp_homepage) |
1390 | @@ -75,8 +78,10 @@ |
1391 | |
1392 | if os.path.exists(LOCAL_QML_LAUNCHER_APP_PATH): |
1393 | # we are local |
1394 | - base_params.append('--import=' + os.path.join (os.path.dirname(os.path.realpath(__file__)), |
1395 | - '../../../../src')) |
1396 | + base_params.append( |
1397 | + '--import={}'.format( |
1398 | + os.path.join(os.path.dirname(os.path.realpath(__file__))), |
1399 | + '../../../../src')) |
1400 | |
1401 | base_params += extra_params |
1402 | |
1403 | @@ -86,18 +91,25 @@ |
1404 | self.assertThat(os.path.exists(html_filepath), Equals(True)) |
1405 | url = self.create_file_url(html_filepath) |
1406 | |
1407 | - self.launch_application(self.get_launch_params(url, 'unitywebappsqmllauncher', '', '', False, extra_params)) |
1408 | + self.launch_application( |
1409 | + self.get_launch_params( |
1410 | + url, |
1411 | + 'unitywebappsqmllauncher', |
1412 | + '', |
1413 | + '', |
1414 | + False, |
1415 | + extra_params)) |
1416 | self.assert_url_eventually_loaded(url) |
1417 | |
1418 | def launch_application(self, args): |
1419 | - print 'Launching test with params:', args, "with", self.get_qml_launcher_path() |
1420 | - |
1421 | - self.app = self.launch_test_application(self.get_qml_launcher_path(), |
1422 | + self.app = self.launch_test_application( |
1423 | + self.get_qml_launcher_path(), |
1424 | *args, |
1425 | app_type='qt') |
1426 | |
1427 | self.webviewContainer = self.get_webviewContainer() |
1428 | - self.watcher = self.webviewContainer.watch_signal('resultUpdated(QString)') |
1429 | + self.watcher = self.webviewContainer.watch_signal( |
1430 | + 'resultUpdated(QString)') |
1431 | |
1432 | def pick_app_launcher(self, app_path): |
1433 | # force Qt app introspection: |
1434 | @@ -121,11 +133,8 @@ |
1435 | |
1436 | def eval_expression_in_page_unsafe(self, expr): |
1437 | webview = self.get_webviewContainer() |
1438 | - prev_emissions = self.watcher.num_emissions |
1439 | - webview.slots.evalInPageUnsafe(expr) |
1440 | - self.assertThat(lambda: self.watcher.num_emissions, Eventually(GreaterThan(prev_emissions))) |
1441 | - results = json.loads(webview.get_signal_emissions('resultUpdated(QString)')[-1][0]) |
1442 | - return results.has_key('result') and results['result'] or None |
1443 | + return webview.slots.evalInPageUnsafe(expr) |
1444 | + |
1445 | |
1446 | class WebappsTestCaseBaseWithLocalHttpContentBase(UnityWebappsTestCaseBase): |
1447 | def setUp(self): |
1448 | @@ -136,5 +145,11 @@ |
1449 | |
1450 | def launch_with_webapp(self, name, webapp_search_path, use_oxide=False): |
1451 | self.use_oxide = use_oxide |
1452 | - self.launch_application(self.get_launch_params("", name, webapp_search_path, self.base_url, use_oxide)) |
1453 | + self.launch_application( |
1454 | + self.get_launch_params( |
1455 | + "", |
1456 | + name, |
1457 | + webapp_search_path, |
1458 | + self.base_url, |
1459 | + use_oxide)) |
1460 | self.assert_url_eventually_loaded(self.base_url) |
1461 | |
1462 | === modified file 'tests/autopilot/unity_webapps_qml/tests/fake_servers.py' |
1463 | --- tests/autopilot/unity_webapps_qml/tests/fake_servers.py 2014-07-08 19:27:21 +0000 |
1464 | +++ tests/autopilot/unity_webapps_qml/tests/fake_servers.py 2014-11-22 00:43:58 +0000 |
1465 | @@ -15,12 +15,12 @@ |
1466 | |
1467 | """ Autopilot tests for the unity_webapps_qml package """ |
1468 | |
1469 | -import BaseHTTPServer |
1470 | +import http.server as http |
1471 | import logging |
1472 | import threading |
1473 | |
1474 | |
1475 | -class RequestHandler(BaseHTTPServer.BaseHTTPRequestHandler): |
1476 | +class RequestHandler(http.BaseHTTPRequestHandler): |
1477 | def serve_content(self, content, mime_type='text/html'): |
1478 | self.send_header('Content-type', mime_type) |
1479 | self.end_headers() |
1480 | @@ -51,7 +51,7 @@ |
1481 | class WebappsQmlContentHttpServer(object): |
1482 | def __init__(self): |
1483 | super(WebappsQmlContentHttpServer, self).__init__() |
1484 | - self.server = BaseHTTPServer.HTTPServer(("", 0), RequestHandler) |
1485 | + self.server = http.HTTPServer(("", 0), RequestHandler) |
1486 | self.server.allow_reuse_address = True |
1487 | self.server_thread = threading.Thread(target=self.server.serve_forever) |
1488 | self.server_thread.start() |
1489 | |
1490 | === modified file 'tests/autopilot/unity_webapps_qml/tests/test_callbackDispatch.py' |
1491 | --- tests/autopilot/unity_webapps_qml/tests/test_callbackDispatch.py 2014-07-11 17:13:18 +0000 |
1492 | +++ tests/autopilot/unity_webapps_qml/tests/test_callbackDispatch.py 2014-11-22 00:43:58 +0000 |
1493 | @@ -7,22 +7,37 @@ |
1494 | |
1495 | from __future__ import absolute_import |
1496 | |
1497 | -import time |
1498 | import os |
1499 | |
1500 | -from testtools.matchers import Equals, GreaterThan, NotEquals |
1501 | +from testtools.matchers import Equals |
1502 | from autopilot.matchers import Eventually |
1503 | |
1504 | from unity_webapps_qml.tests import UnityWebappsTestCaseBase |
1505 | |
1506 | -LOCAL_HTML_TEST_FILE = "%s/%s" % (os.path.dirname(os.path.realpath(__file__)), '../../html/test_webapps_callback_dispatch.html') |
1507 | -INSTALLED_HTML_TEST_FILE = '/usr/share/unity-webapps-qml/autopilot-tests/html/test_webapps_callback_dispatch.html' |
1508 | - |
1509 | -LOCAL_JS_TEST_FILE = "%s/%s" % (os.path.dirname(os.path.realpath(__file__)), '../../html/test_webapps_callback_dispatch_api.js') |
1510 | -INSTALLED_JS_TEST_FILE = '/usr/share/unity-webapps-qml/autopilot-tests/html/test_webapps_callback_dispatch_api.js' |
1511 | - |
1512 | -LOCAL_QML_BACKEND_TEST_FILE = "%s/%s" % (os.path.dirname(os.path.realpath(__file__)), '../../qml/test_webapps_callback_dispatch_api.qml') |
1513 | -INSTALLED_QML_BACKEND_TEST_FILE = '/usr/share/unity-webapps-qml/autopilot-tests/qml/test_webapps_callback_dispatch_api.qml' |
1514 | +LOCAL_HTML_TEST_FILE = "{}/{}".format( |
1515 | + os.path.dirname(os.path.realpath(__file__)), |
1516 | + '../../html/test_webapps_callback_dispatch.html') |
1517 | + |
1518 | +INSTALLED_HTML_TEST_FILE = \ |
1519 | + '/usr/share/unity-webapps-qml/autopilot-tests/' \ |
1520 | + 'html/test_webapps_callback_dispatch.html' |
1521 | + |
1522 | +LOCAL_JS_TEST_FILE = "{}/{}".format( |
1523 | + os.path.dirname(os.path.realpath(__file__)), |
1524 | + '../../html/test_webapps_callback_dispatch_api.js') |
1525 | + |
1526 | +INSTALLED_JS_TEST_FILE = \ |
1527 | + '/usr/share/unity-webapps-qml/autopilot-tests/' \ |
1528 | + 'html/test_webapps_callback_dispatch_api.js' |
1529 | + |
1530 | +LOCAL_QML_BACKEND_TEST_FILE = "{}/{}".format( |
1531 | + os.path.dirname(os.path.realpath(__file__)), |
1532 | + '../../qml/test_webapps_callback_dispatch_api.qml') |
1533 | + |
1534 | +INSTALLED_QML_BACKEND_TEST_FILE = \ |
1535 | + '/usr/share/unity-webapps-qml/autopilot-tests/' \ |
1536 | + 'qml/test_webapps_callback_dispatch_api.qml' |
1537 | + |
1538 | |
1539 | class WebappsCallbackDispatchTestCaseBase(UnityWebappsTestCaseBase): |
1540 | def setUp(self): |
1541 | @@ -43,7 +58,6 @@ |
1542 | return INSTALLED_JS_TEST_FILE |
1543 | |
1544 | def get_qml_test_file(self): |
1545 | - print LOCAL_QML_BACKEND_TEST_FILE |
1546 | if os.path.exists(LOCAL_QML_BACKEND_TEST_FILE): |
1547 | return os.path.abspath(LOCAL_QML_BACKEND_TEST_FILE) |
1548 | return INSTALLED_QML_BACKEND_TEST_FILE |
1549 | @@ -55,6 +69,6 @@ |
1550 | Eventually(Equals(True))) |
1551 | |
1552 | self.assertThat( |
1553 | - lambda: self.eval_expression_in_page_unsafe("return document.getElementById('content').innerHTML;"), |
1554 | + lambda: self.eval_expression_in_page_unsafe( |
1555 | + "return document.getElementById('content').innerHTML;"), |
1556 | Eventually(Equals('callback-loop-count-reached'))) |
1557 | - |
1558 | |
1559 | === removed file 'tests/autopilot/unity_webapps_qml/tests/test_hud.py' |
1560 | --- tests/autopilot/unity_webapps_qml/tests/test_hud.py 2014-04-22 15:40:04 +0000 |
1561 | +++ tests/autopilot/unity_webapps_qml/tests/test_hud.py 1970-01-01 00:00:00 +0000 |
1562 | @@ -1,81 +0,0 @@ |
1563 | -#!/usr/bin/env python |
1564 | -# Copyright 2013 Canonical |
1565 | -# |
1566 | -# This program is free software: you can redistribute it and/or modify it |
1567 | -# under the terms of the GNU General Public License version 3, as published |
1568 | -# by the Free Software Foundation. |
1569 | - |
1570 | -import os |
1571 | -import time |
1572 | - |
1573 | -from testtools.matchers import Equals, GreaterThan, NotEquals |
1574 | -from autopilot.matchers import Eventually |
1575 | - |
1576 | -from autopilot import platform |
1577 | - |
1578 | -from unity.emulators.icons import HudLauncherIcon |
1579 | -from unity.emulators import ensure_unity_is_running |
1580 | - |
1581 | -from unity_webapps_qml.tests import UnityWebappsTestCaseBase |
1582 | - |
1583 | -class UnityWebappsHudTestCase(UnityWebappsTestCaseBase): |
1584 | - LOCAL_HTML_TEST_FILE = "%s/%s" % (os.path.dirname(os.path.realpath(__file__)), '../../html/test_webapps_hud.html') |
1585 | - INSTALLED_HTML_TEST_FILE = '/usr/share/unity-webapps-qml/autopilot-tests/html/test_webapps_hud.html' |
1586 | - |
1587 | - def get_html_test_file(self): |
1588 | - if os.path.exists(self.LOCAL_HTML_TEST_FILE): |
1589 | - return os.path.abspath(self.LOCAL_HTML_TEST_FILE) |
1590 | - return self.INSTALLED_HTML_TEST_FILE |
1591 | - |
1592 | - def setUp(self): |
1593 | - super(UnityWebappsHudTestCase, self).setUp() |
1594 | - # On Touch the dbus unity if does is not exposed |
1595 | - if platform.model() == 'Desktop': |
1596 | - ensure_unity_is_running() |
1597 | - self.launch_with_html_filepath(self.get_html_test_file()) |
1598 | - |
1599 | - def test_addAction(self): |
1600 | - self.assertThat(lambda: self.eval_expression_in_page_unsafe("return document.getElementById('status').innerHTML;"), Eventually(Equals('actionadded'))) |
1601 | - |
1602 | - self.unity.hud.ensure_visible() |
1603 | - self.addCleanup(self.unity.hud.ensure_hidden) |
1604 | - |
1605 | - self.keyboard.type("Hello") |
1606 | - self.keyboard.press_and_release("Enter") |
1607 | - |
1608 | - self.assertThat(lambda: self.eval_expression_in_page_unsafe("return document.getElementById('content').style.display;"), Eventually(Equals('none'))) |
1609 | - |
1610 | - def test_clearAction(self): |
1611 | - self.assertThat(lambda: self.eval_expression_in_page_unsafe("return document.getElementById('status').innerHTML;"), Eventually(Equals('actionadded'))) |
1612 | - expr = """ |
1613 | - var e = new CustomEvent ("unity-webapps-do-call", {"detail": JSON.stringify({"name": 'clearAction', 'args': ['Hello']})}); |
1614 | - document.dispatchEvent (e); |
1615 | - return true; |
1616 | - """ |
1617 | - self.eval_expression_in_page_unsafe(expr) |
1618 | - |
1619 | - self.unity.hud.ensure_visible() |
1620 | - self.addCleanup(self.unity.hud.ensure_hidden) |
1621 | - |
1622 | - self.keyboard.type("Hello") |
1623 | - self.keyboard.press_and_release("Enter") |
1624 | - self.assertThat(self.eval_expression_in_page_unsafe("return document.getElementById('content').style.display;"), NotEquals('none')) |
1625 | - |
1626 | - def test_clearActions(self): |
1627 | - self.assertThat(lambda: self.eval_expression_in_page_unsafe("return document.getElementById('status').innerHTML;"), Eventually(Equals('actionadded'))) |
1628 | - expr = """ |
1629 | - var e = new CustomEvent ("unity-webapps-do-call", {"detail": JSON.stringify({"name": 'clearActions', 'args': []})}); |
1630 | - document.dispatchEvent (e); |
1631 | - return true; |
1632 | - """ |
1633 | - |
1634 | - self.eval_expression_in_page_unsafe(expr) |
1635 | - |
1636 | - actions = ['Hello', 'Another action'] |
1637 | - for action in actions: |
1638 | - self.unity.hud.ensure_visible() |
1639 | - self.addCleanup(self.unity.hud.ensure_hidden) |
1640 | - self.keyboard.type(action) |
1641 | - self.keyboard.press_and_release("Enter") |
1642 | - |
1643 | - self.assertThat(self.eval_expression_in_page_unsafe("return document.getElementById('content').style.display;"), NotEquals('none')) |
1644 | |
1645 | === modified file 'tests/autopilot/unity_webapps_qml/tests/test_injectedOnWebapp.py' |
1646 | --- tests/autopilot/unity_webapps_qml/tests/test_injectedOnWebapp.py 2014-04-22 15:40:04 +0000 |
1647 | +++ tests/autopilot/unity_webapps_qml/tests/test_injectedOnWebapp.py 2014-11-22 00:43:58 +0000 |
1648 | @@ -7,51 +7,74 @@ |
1649 | |
1650 | from __future__ import absolute_import |
1651 | |
1652 | -import time |
1653 | import os |
1654 | |
1655 | -from testtools.matchers import Equals, GreaterThan, NotEquals |
1656 | +from testtools.matchers import Equals |
1657 | from autopilot.matchers import Eventually |
1658 | |
1659 | from unity_webapps_qml.tests import UnityWebappsTestCaseBase |
1660 | |
1661 | +LOCAL_HTML_TEST_FILE = "{}/{}".format( |
1662 | + os.path.dirname(os.path.realpath(__file__)), |
1663 | + '../../html/test_webapps_api_injected.html') |
1664 | + |
1665 | +INSTALLED_HTML_TEST_FILE = \ |
1666 | + '/usr/share/unity-webapps-qml/' \ |
1667 | + 'autopilot-tests/html/test_webapps_api_injected.html' |
1668 | + |
1669 | + |
1670 | class UnityWebappsApiInjectedTestCaseBase(UnityWebappsTestCaseBase): |
1671 | - LOCAL_HTML_TEST_FILE = "%s/%s" % (os.path.dirname(os.path.realpath(__file__)), '../../html/test_webapps_api_injected.html') |
1672 | - |
1673 | - INSTALLED_HTML_TEST_FILE = '/usr/share/unity-webapps-qml/autopilot-tests/html/test_webapps_api_injected.html' |
1674 | - |
1675 | def get_html_test_file(self): |
1676 | - if os.path.exists(self.LOCAL_HTML_TEST_FILE): |
1677 | - return os.path.abspath(self.LOCAL_HTML_TEST_FILE) |
1678 | - return self.INSTALLED_HTML_TEST_FILE |
1679 | + if os.path.exists(LOCAL_HTML_TEST_FILE): |
1680 | + return os.path.abspath(LOCAL_HTML_TEST_FILE) |
1681 | + return INSTALLED_HTML_TEST_FILE |
1682 | |
1683 | def setUp(self): |
1684 | super(UnityWebappsApiInjectedTestCaseBase, self).setUp() |
1685 | self.launch_with_html_filepath(self.get_html_test_file()) |
1686 | |
1687 | def test_getUnityObjectFound(self): |
1688 | - self.assertThat(lambda: self.eval_expression_in_page_unsafe('return window.external.getUnityObject("1.0") != null'), Eventually(Equals(True))) |
1689 | + self.assertThat( |
1690 | + lambda: self.eval_expression_in_page_unsafe( |
1691 | + 'return window.external.getUnityObject("1.0") != null'), |
1692 | + Eventually(Equals(True))) |
1693 | |
1694 | def test_actionsApiFound(self): |
1695 | - self.assertThat(lambda: self.eval_expression_in_page_unsafe('return window.external.getUnityObject("1.0") != null;'), Eventually(Equals(True))) |
1696 | + self.assertThat( |
1697 | + lambda: self.eval_expression_in_page_unsafe( |
1698 | + 'return window.external.getUnityObject("1.0") != null;'), |
1699 | + Eventually(Equals(True))) |
1700 | |
1701 | expression = """ |
1702 | var unity = window.external.getUnityObject("1.0"); |
1703 | - return unity.addAction != null && unity.clearActions != null && unity.clearAction != null; |
1704 | + return unity.addAction != null && |
1705 | + unity.clearActions != null && |
1706 | + unity.clearAction != null; |
1707 | """ |
1708 | - self.assertThat(lambda: self.eval_expression_in_page_unsafe(expression), Eventually(Equals(True))) |
1709 | + self.assertThat( |
1710 | + lambda: self.eval_expression_in_page_unsafe(expression), |
1711 | + Eventually(Equals(True))) |
1712 | |
1713 | def test_notificationApiFound(self): |
1714 | - self.assertThat(lambda: self.eval_expression_in_page_unsafe('return window.external.getUnityObject("1.0") != null;'), Eventually(Equals(True))) |
1715 | + self.assertThat( |
1716 | + lambda: self.eval_expression_in_page_unsafe( |
1717 | + 'return window.external.getUnityObject("1.0") != null;'), |
1718 | + Eventually(Equals(True))) |
1719 | |
1720 | expression = """ |
1721 | var unity = window.external.getUnityObject("1.0"); |
1722 | - return unity.Notification != null && unity.Notification.showNotification != null; |
1723 | + return unity.Notification != null && |
1724 | + unity.Notification.showNotification != null; |
1725 | """ |
1726 | - self.assertThat(lambda: self.eval_expression_in_page_unsafe(expression), Eventually(Equals(True))) |
1727 | + self.assertThat( |
1728 | + lambda: self.eval_expression_in_page_unsafe(expression), |
1729 | + Eventually(Equals(True))) |
1730 | |
1731 | def test_messagingIndicatorApiFound(self): |
1732 | - self.assertThat(lambda: self.eval_expression_in_page_unsafe('return window.external.getUnityObject("1.0") != null;'), Eventually(Equals(True))) |
1733 | + self.assertThat( |
1734 | + lambda: self.eval_expression_in_page_unsafe( |
1735 | + 'return window.external.getUnityObject("1.0") != null;'), |
1736 | + Eventually(Equals(True))) |
1737 | |
1738 | expression = """ |
1739 | var unity = window.external.getUnityObject("1.0"); |
1740 | @@ -61,15 +84,21 @@ |
1741 | unity.MessagingIndicator.clearIndicators != null && |
1742 | unity.MessagingIndicator.showIndicator != null; |
1743 | """ |
1744 | - self.assertThat(lambda: self.eval_expression_in_page_unsafe(expression), Eventually(Equals(True))) |
1745 | + self.assertThat( |
1746 | + lambda: self.eval_expression_in_page_unsafe(expression), |
1747 | + Eventually(Equals(True))) |
1748 | |
1749 | def test_ubuntuReadyEventSent(self): |
1750 | - self.assertThat(lambda: self.eval_expression_in_page_unsafe('return window.external.getUnityObject("1.0") != null;'), Eventually(Equals(True))) |
1751 | + self.assertThat( |
1752 | + lambda: self.eval_expression_in_page_unsafe( |
1753 | + 'return window.external.getUnityObject("1.0") != null;'), |
1754 | + Eventually(Equals(True))) |
1755 | |
1756 | expression = """ |
1757 | - var api_ready_count = window.localStorage['ubuntu-webapps-api-ready-key']; |
1758 | + var api_ready_count = |
1759 | + window.localStorage['ubuntu-webapps-api-ready-key']; |
1760 | return api_ready_count != null && api_ready_count > 0; |
1761 | """ |
1762 | - self.assertThat(lambda: self.eval_expression_in_page_unsafe(expression), Eventually(Equals(True))) |
1763 | - |
1764 | - |
1765 | + self.assertThat( |
1766 | + lambda: self.eval_expression_in_page_unsafe(expression), |
1767 | + Eventually(Equals(True))) |
1768 | |
1769 | === modified file 'tests/autopilot/unity_webapps_qml/tests/test_installedWebapp.py' |
1770 | --- tests/autopilot/unity_webapps_qml/tests/test_installedWebapp.py 2014-07-16 20:15:17 +0000 |
1771 | +++ tests/autopilot/unity_webapps_qml/tests/test_installedWebapp.py 2014-11-22 00:43:58 +0000 |
1772 | @@ -7,18 +7,23 @@ |
1773 | |
1774 | from __future__ import absolute_import |
1775 | |
1776 | -import time |
1777 | import os |
1778 | |
1779 | -from testtools.matchers import Equals, GreaterThan, NotEquals |
1780 | +from testtools.matchers import Equals |
1781 | from autopilot.matchers import Eventually |
1782 | |
1783 | from unity_webapps_qml.tests import WebappsTestCaseBaseWithLocalHttpContentBase |
1784 | |
1785 | -LOCAL_HTML_TEST_FILE = "%s/%s" % (os.path.dirname(os.path.realpath(__file__)), '../../data') |
1786 | -INSTALLED_HTML_TEST_FILE = '/usr/share/unity-webapps-qml/autopilot-tests/data' |
1787 | - |
1788 | -class InstalledWebappsTestCaseBase(WebappsTestCaseBaseWithLocalHttpContentBase): |
1789 | +LOCAL_HTML_TEST_FILE = "{}/{}".format( |
1790 | + os.path.dirname(os.path.realpath(__file__)), |
1791 | + '../../data') |
1792 | + |
1793 | +INSTALLED_HTML_TEST_FILE = \ |
1794 | + '/usr/share/unity-webapps-qml/autopilot-tests/data' |
1795 | + |
1796 | + |
1797 | +class InstalledWebappsTestCaseBase( |
1798 | + WebappsTestCaseBaseWithLocalHttpContentBase): |
1799 | def setUp(self): |
1800 | super(InstalledWebappsTestCaseBase, self).setUp() |
1801 | |
1802 | @@ -30,34 +35,60 @@ |
1803 | def test_normalWebappFound(self): |
1804 | self.launch_with_webapp('Normal', self.get_webapp_install_folder()) |
1805 | |
1806 | - self.assertThat(lambda: self.eval_expression_in_page_unsafe('return window.external.getUnityObject("1.0") != null;'), Eventually(Equals(True))) |
1807 | + self.assertThat( |
1808 | + lambda: self.eval_expression_in_page_unsafe( |
1809 | + 'return window.external.getUnityObject("1.0") != null;'), |
1810 | + Eventually(Equals(True))) |
1811 | |
1812 | expression = """ |
1813 | var contentElement = document.getElementById('content'); |
1814 | return contentElement.innerHTML; |
1815 | """ |
1816 | - self.assertThat(lambda: self.eval_expression_in_page_unsafe(expression), Eventually(Equals("WebApp Script Injected"))) |
1817 | + self.assertThat( |
1818 | + lambda: self.eval_expression_in_page_unsafe(expression), |
1819 | + Eventually(Equals("WebApp Script Injected"))) |
1820 | |
1821 | def test_webappWithUAOverrideFound(self): |
1822 | - self.launch_with_webapp('AlteredUAWebapp', self.get_webapp_install_folder(), True) |
1823 | - self.assertThat(lambda: self.eval_expression_in_page_unsafe('return navigator.userAgent;'), Eventually(Equals("My Override"))) |
1824 | + self.launch_with_webapp( |
1825 | + 'AlteredUAWebapp', |
1826 | + self.get_webapp_install_folder(), True) |
1827 | + self.assertThat( |
1828 | + lambda: self.eval_expression_in_page_unsafe( |
1829 | + 'return navigator.userAgent;'), |
1830 | + Eventually(Equals("My Override"))) |
1831 | |
1832 | def test_webappFoundWithSpecialWebappPropertiesFile(self): |
1833 | - self.launch_with_webapp('ExtendedWebappProperties', self.get_webapp_install_folder() + '/all-in-same-folder') |
1834 | + self.launch_with_webapp( |
1835 | + 'ExtendedWebappProperties', |
1836 | + self.get_webapp_install_folder() + '/all-in-same-folder') |
1837 | |
1838 | - self.assertThat(lambda: self.eval_expression_in_page_unsafe('return window.external.getUnityObject("1.0") != null;'), Eventually(Equals(True))) |
1839 | + self.assertThat( |
1840 | + lambda: self.eval_expression_in_page_unsafe( |
1841 | + 'return window.external.getUnityObject("1.0") != null;'), |
1842 | + Eventually(Equals(True))) |
1843 | |
1844 | expression = """ |
1845 | var contentElement = document.getElementById('content'); |
1846 | return contentElement.innerHTML; |
1847 | """ |
1848 | - self.assertThat(lambda: self.eval_expression_in_page_unsafe(expression), Eventually(Equals("WebApp Script Injected"))) |
1849 | + self.assertThat( |
1850 | + lambda: self.eval_expression_in_page_unsafe(expression), |
1851 | + Eventually(Equals("WebApp Script Injected"))) |
1852 | |
1853 | def test_webappPropertiesFileWithUA(self): |
1854 | - self.launch_with_webapp('ExtendedWebappProperties', self.get_webapp_install_folder() + '/all-in-same-folder', True) |
1855 | - self.assertThat(lambda: self.eval_expression_in_page_unsafe('return navigator.userAgent;'), Eventually(Equals("My Override"))) |
1856 | + self.launch_with_webapp( |
1857 | + 'ExtendedWebappProperties', |
1858 | + self.get_webapp_install_folder() + '/all-in-same-folder', True) |
1859 | + self.assertThat( |
1860 | + lambda: self.eval_expression_in_page_unsafe( |
1861 | + 'return navigator.userAgent;'), |
1862 | + Eventually(Equals("My Override"))) |
1863 | |
1864 | def test_webappPropertiesNameUpdated(self): |
1865 | - self.launch_with_webapp('', self.get_webapp_install_folder() + '/all-in-same-folder') |
1866 | - self.assertThat(lambda: self.eval_expression_in_page_unsafe('return window.external.getUnityObject("1.0") != null;'), Eventually(Equals(True))) |
1867 | - |
1868 | + self.launch_with_webapp( |
1869 | + '', |
1870 | + self.get_webapp_install_folder() + '/all-in-same-folder') |
1871 | + self.assertThat( |
1872 | + lambda: self.eval_expression_in_page_unsafe( |
1873 | + 'return window.external.getUnityObject("1.0") != null;'), |
1874 | + Eventually(Equals(True))) |
1875 | |
1876 | === modified file 'tests/autopilot/unity_webapps_qml/tests/test_launcher.py' |
1877 | --- tests/autopilot/unity_webapps_qml/tests/test_launcher.py 2013-09-23 19:59:29 +0000 |
1878 | +++ tests/autopilot/unity_webapps_qml/tests/test_launcher.py 2014-11-22 00:43:58 +0000 |
1879 | @@ -6,78 +6,102 @@ |
1880 | # by the Free Software Foundation. |
1881 | |
1882 | import os |
1883 | -import time |
1884 | - |
1885 | -from gi.repository import Unity, GObject |
1886 | - |
1887 | -from testtools.matchers import Equals, GreaterThan, NotEquals |
1888 | + |
1889 | +from gi.repository import Unity |
1890 | + |
1891 | +from testtools.matchers import Equals, NotEquals |
1892 | from testtools import skipUnless |
1893 | |
1894 | from autopilot import platform |
1895 | from autopilot.matchers import Eventually |
1896 | |
1897 | -from unity.emulators.icons import HudLauncherIcon |
1898 | -from unity.emulators import ensure_unity_is_running |
1899 | - |
1900 | from unity_webapps_qml.tests import UnityWebappsTestCaseBase |
1901 | |
1902 | +LOCAL_HTML_TEST_FILE = "{}/{}".format( |
1903 | + os.path.dirname(os.path.realpath(__file__)), |
1904 | + '../../html/test_webapps_launcher.html') |
1905 | + |
1906 | +INSTALLED_HTML_TEST_FILE = \ |
1907 | + '/usr/share/unity-webapps-qml/' \ |
1908 | + 'autopilot-tests/html/test_webapps_launcher.html' |
1909 | + |
1910 | + |
1911 | class UnityWebappsLauncherTestCase(UnityWebappsTestCaseBase): |
1912 | - LOCAL_HTML_TEST_FILE = "%s/%s" % (os.path.dirname(os.path.realpath(__file__)), '../../html/test_webapps_launcher.html') |
1913 | - INSTALLED_HTML_TEST_FILE = '/usr/share/unity-webapps-qml/autopilot-tests/html/test_webapps_launcher.html' |
1914 | - |
1915 | def get_html_test_file(self): |
1916 | - if os.path.exists(self.LOCAL_HTML_TEST_FILE): |
1917 | - return os.path.abspath(self.LOCAL_HTML_TEST_FILE) |
1918 | - return self.INSTALLED_HTML_TEST_FILE |
1919 | + if os.path.exists(LOCAL_HTML_TEST_FILE): |
1920 | + return os.path.abspath(LOCAL_HTML_TEST_FILE) |
1921 | + return INSTALLED_HTML_TEST_FILE |
1922 | |
1923 | def setUp(self): |
1924 | super(UnityWebappsLauncherTestCase, self).setUp() |
1925 | - # On Touch the dbus unity if does is not exposed |
1926 | - if platform.model() == 'Desktop': |
1927 | - ensure_unity_is_running() |
1928 | self.launch_with_html_filepath(self.get_html_test_file()) |
1929 | |
1930 | @skipUnless(platform.model() == 'Desktop', "Only runs on the Desktop") |
1931 | def test_checkCounts(self): |
1932 | - self.assertThat(lambda: self.eval_expression_in_page_unsafe("return document.getElementById('status').innerHTML;"), Eventually(Equals('launcher-updated'))) |
1933 | + self.assertThat( |
1934 | + lambda: self.eval_expression_in_page_unsafe( |
1935 | + "return document.getElementById('status').innerHTML;"), |
1936 | + Eventually(Equals('launcher-updated'))) |
1937 | |
1938 | - launcher_icon = self.unity.launcher.model.get_icon(desktop_id='unitywebappsqmllauncher.desktop') |
1939 | + launcher_icon = self.unity.launcher.model.get_icon( |
1940 | + desktop_id='unitywebappsqmllauncher.desktop') |
1941 | self.assertThat(launcher_icon, NotEquals(None)) |
1942 | |
1943 | expr = """ |
1944 | - document.addEventListener('unity-webapps-do-call-response', function(e) { |
1945 | + document.addEventListener('unity-webapps-do-call-response', |
1946 | + function(e) { |
1947 | var response = e.detail; |
1948 | document.getElementById('status').innerHTML = '' + e.detail; |
1949 | }); |
1950 | |
1951 | - var e = new CustomEvent ("unity-webapps-do-call", {"detail": JSON.stringify({"name": 'Launcher.__get', 'with_callback': true, 'args': ['count']})}); |
1952 | + var e = new CustomEvent ( |
1953 | + "unity-webapps-do-call", |
1954 | + {"detail": JSON.stringify( |
1955 | + {"name": 'Launcher.__get', |
1956 | + 'with_callback': true, |
1957 | + 'args': ['count']})}); |
1958 | document.dispatchEvent (e); |
1959 | return true; |
1960 | """ |
1961 | self.eval_expression_in_page_unsafe(expr) |
1962 | |
1963 | - self.assertThat(lambda: self.eval_expression_in_page_unsafe("return document.getElementById('status').innerHTML;"), Eventually(Equals('42'))) |
1964 | + self.assertThat( |
1965 | + lambda: self.eval_expression_in_page_unsafe( |
1966 | + "return document.getElementById('status').innerHTML;"), |
1967 | + Eventually(Equals('42'))) |
1968 | |
1969 | # self.assertThat(launcher.get_property('progress'), Equals(0.09375)) |
1970 | |
1971 | @skipUnless(platform.model() == 'Desktop', "Only runs on the Desktop") |
1972 | def test_checkProgress(self): |
1973 | - self.assertThat(lambda: self.eval_expression_in_page_unsafe("return document.getElementById('status').innerHTML;"), Eventually(Equals('launcher-updated'))) |
1974 | + self.assertThat( |
1975 | + lambda: self.eval_expression_in_page_unsafe( |
1976 | + "return document.getElementById('status').innerHTML;"), |
1977 | + Eventually(Equals('launcher-updated'))) |
1978 | |
1979 | - launcher_icon = self.unity.launcher.model.get_icon(desktop_id='unitywebappsqmllauncher.desktop') |
1980 | + launcher_icon = self.unity.launcher.model.get_icon( |
1981 | + desktop_id='unitywebappsqmllauncher.desktop') |
1982 | self.assertThat(launcher_icon, NotEquals(None)) |
1983 | |
1984 | expr = """ |
1985 | - document.addEventListener('unity-webapps-do-call-response', function(e) { |
1986 | + document.addEventListener( |
1987 | + 'unity-webapps-do-call-response', function(e) { |
1988 | var response = e.detail; |
1989 | document.getElementById('status').innerHTML = '' + e.detail; |
1990 | }); |
1991 | |
1992 | - var e = new CustomEvent ("unity-webapps-do-call", {"detail": JSON.stringify({"name": 'Launcher.__get', 'with_callback': true, 'args': ['progress']})}); |
1993 | + var e = new CustomEvent ( |
1994 | + "unity-webapps-do-call", |
1995 | + {"detail": JSON.stringify( |
1996 | + {"name": 'Launcher.__get', |
1997 | + 'with_callback': true, |
1998 | + 'args': ['progress']})}); |
1999 | document.dispatchEvent (e); |
2000 | return true; |
2001 | """ |
2002 | self.eval_expression_in_page_unsafe(expr) |
2003 | |
2004 | - self.assertThat(lambda: self.eval_expression_in_page_unsafe("return document.getElementById('status').innerHTML;"), Eventually(Equals('0.09375'))) |
2005 | - |
2006 | + self.assertThat( |
2007 | + lambda: self.eval_expression_in_page_unsafe( |
2008 | + "return document.getElementById('status').innerHTML;"), |
2009 | + Eventually(Equals('0.09375'))) |
2010 | |
2011 | === modified file 'tests/autopilot/unity_webapps_qml/tests/test_mediaplayer.py' |
2012 | --- tests/autopilot/unity_webapps_qml/tests/test_mediaplayer.py 2013-09-23 19:59:29 +0000 |
2013 | +++ tests/autopilot/unity_webapps_qml/tests/test_mediaplayer.py 2014-11-22 00:43:58 +0000 |
2014 | @@ -6,106 +6,153 @@ |
2015 | # by the Free Software Foundation. |
2016 | |
2017 | import os |
2018 | -import time |
2019 | - |
2020 | -from gi.repository import Unity, GObject |
2021 | - |
2022 | -from testtools.matchers import Equals, GreaterThan, NotEquals |
2023 | + |
2024 | +from gi.repository import Unity |
2025 | + |
2026 | +from testtools.matchers import Equals |
2027 | from testtools import skipUnless |
2028 | |
2029 | from autopilot import platform |
2030 | from autopilot.matchers import Eventually |
2031 | |
2032 | -from unity.emulators import ensure_unity_is_running |
2033 | - |
2034 | from unity_webapps_qml.tests import UnityWebappsTestCaseBase |
2035 | |
2036 | +LOCAL_HTML_TEST_FILE = "{}/{}".format( |
2037 | + os.path.dirname(os.path.realpath(__file__)), |
2038 | + '../../html/test_webapps_mediaplayer.html') |
2039 | + |
2040 | +INSTALLED_HTML_TEST_FILE = \ |
2041 | + '/usr/share/unity-webapps-qml/' \ |
2042 | + 'autopilot-tests/html/test_webapps_mediaplayer.html' |
2043 | + |
2044 | |
2045 | class UnityWebappsMediaplayerTestCase(UnityWebappsTestCaseBase): |
2046 | - LOCAL_HTML_TEST_FILE = "%s/%s" % (os.path.dirname(os.path.realpath(__file__)), '../../html/test_webapps_mediaplayer.html') |
2047 | - INSTALLED_HTML_TEST_FILE = '/usr/share/unity-webapps-qml/autopilot-tests/html/test_webapps_mediaplayer.html' |
2048 | - |
2049 | def get_html_test_file(self): |
2050 | - if os.path.exists(self.LOCAL_HTML_TEST_FILE): |
2051 | - return os.path.abspath(self.LOCAL_HTML_TEST_FILE) |
2052 | - return self.INSTALLED_HTML_TEST_FILE |
2053 | + if os.path.exists(LOCAL_HTML_TEST_FILE): |
2054 | + return os.path.abspath(LOCAL_HTML_TEST_FILE) |
2055 | + return INSTALLED_HTML_TEST_FILE |
2056 | |
2057 | def setUp(self): |
2058 | super(UnityWebappsMediaplayerTestCase, self).setUp() |
2059 | - # On Touch the dbus unity if does is not exposed |
2060 | - if platform.model() == 'Desktop': |
2061 | - ensure_unity_is_running() |
2062 | self.launch_with_html_filepath(self.get_html_test_file()) |
2063 | |
2064 | @skipUnless(platform.model() == 'Desktop', "Only runs on the Desktop") |
2065 | def test_checkInitialSetTrack(self): |
2066 | - self.assertThat(lambda: self.eval_expression_in_page_unsafe("return document.getElementById('status').innerHTML;"), Eventually(Equals('mediaplayer-updated'))) |
2067 | + self.assertThat( |
2068 | + lambda: self.eval_expression_in_page_unsafe( |
2069 | + "return document.getElementById('status').innerHTML;"), |
2070 | + Eventually(Equals('mediaplayer-updated'))) |
2071 | |
2072 | expr = """ |
2073 | - document.addEventListener('unity-webapps-do-call-response', function(e) { |
2074 | + document.addEventListener( |
2075 | + 'unity-webapps-do-call-response', |
2076 | + function(e) { |
2077 | var response = e.detail; |
2078 | document.getElementById('status').innerHTML = '' + e.detail; |
2079 | }); |
2080 | |
2081 | - var e = new CustomEvent ("unity-webapps-do-call", {"detail": JSON.stringify({"name": 'MediaPlayer.__get', 'with_callback': true, 'args': ['track']})}); |
2082 | + var e = new CustomEvent ( |
2083 | + "unity-webapps-do-call", |
2084 | + {"detail": JSON.stringify( |
2085 | + {"name": 'MediaPlayer.__get', |
2086 | + 'with_callback': true, |
2087 | + 'args': ['track']})}); |
2088 | document.dispatchEvent (e); |
2089 | return true; |
2090 | """ |
2091 | self.eval_expression_in_page_unsafe(expr) |
2092 | |
2093 | - self.assertThat(lambda: self.eval_expression_in_page_unsafe("return document.getElementById('status').innerHTML;"), Eventually(Equals('TXlBcnRpc3Q=;TXlUaXRsZQ==;TXlBbGJ1bQ=='))) |
2094 | + self.assertThat( |
2095 | + lambda: self.eval_expression_in_page_unsafe( |
2096 | + "return document.getElementById('status').innerHTML;"), |
2097 | + Eventually(Equals('TXlBcnRpc3Q=;TXlUaXRsZQ==;TXlBbGJ1bQ=='))) |
2098 | |
2099 | @skipUnless(platform.model() == 'Desktop', "Only runs on the Desktop") |
2100 | def test_checkInitialSetCanGoNext(self): |
2101 | - self.assertThat(lambda: self.eval_expression_in_page_unsafe("return document.getElementById('status').innerHTML;"), Eventually(Equals('mediaplayer-updated'))) |
2102 | + self.assertThat( |
2103 | + lambda: self.eval_expression_in_page_unsafe( |
2104 | + "return document.getElementById('status').innerHTML;"), |
2105 | + Eventually(Equals('mediaplayer-updated'))) |
2106 | |
2107 | expr = """ |
2108 | - document.addEventListener('unity-webapps-do-call-response', function(e) { |
2109 | + document.addEventListener( |
2110 | + 'unity-webapps-do-call-response', function(e) { |
2111 | var response = e.detail; |
2112 | document.getElementById('status').innerHTML = '' + e.detail; |
2113 | }); |
2114 | |
2115 | - var e = new CustomEvent ("unity-webapps-do-call", {"detail": JSON.stringify({"name": 'MediaPlayer.__get', 'with_callback': true, 'args': ['can-go-next']})}); |
2116 | + var e = new CustomEvent ( |
2117 | + "unity-webapps-do-call", |
2118 | + {"detail": JSON.stringify( |
2119 | + {"name": 'MediaPlayer.__get', |
2120 | + 'with_callback': true, |
2121 | + 'args': ['can-go-next']})}); |
2122 | document.dispatchEvent (e); |
2123 | return true; |
2124 | """ |
2125 | self.eval_expression_in_page_unsafe(expr) |
2126 | |
2127 | - self.assertThat(lambda: self.eval_expression_in_page_unsafe("return document.getElementById('status').innerHTML;"), Eventually(Equals('true'))) |
2128 | + self.assertThat( |
2129 | + lambda: self.eval_expression_in_page_unsafe( |
2130 | + "return document.getElementById('status').innerHTML;"), |
2131 | + Eventually(Equals('true'))) |
2132 | |
2133 | @skipUnless(platform.model() == 'Desktop', "Only runs on the Desktop") |
2134 | def test_checkInitialSetCanGoPrevious(self): |
2135 | - self.assertThat(lambda: self.eval_expression_in_page_unsafe("return document.getElementById('status').innerHTML;"), Eventually(Equals('mediaplayer-updated'))) |
2136 | + self.assertThat( |
2137 | + lambda: self.eval_expression_in_page_unsafe( |
2138 | + "return document.getElementById('status').innerHTML;"), |
2139 | + Eventually(Equals('mediaplayer-updated'))) |
2140 | |
2141 | expr = """ |
2142 | - document.addEventListener('unity-webapps-do-call-response', function(e) { |
2143 | + document.addEventListener('unity-webapps-do-call-response', |
2144 | + function(e) { |
2145 | var response = e.detail; |
2146 | document.getElementById('status').innerHTML = '' + e.detail; |
2147 | }); |
2148 | |
2149 | - var e = new CustomEvent ("unity-webapps-do-call", {"detail": JSON.stringify({"name": 'MediaPlayer.__get', 'with_callback': true, 'args': ['can-go-previous']})}); |
2150 | + var e = new CustomEvent ( |
2151 | + "unity-webapps-do-call", |
2152 | + {"detail": JSON.stringify( |
2153 | + {"name": 'MediaPlayer.__get', |
2154 | + 'with_callback': true, |
2155 | + 'args': ['can-go-previous']})}); |
2156 | document.dispatchEvent (e); |
2157 | return true; |
2158 | """ |
2159 | self.eval_expression_in_page_unsafe(expr) |
2160 | |
2161 | - self.assertThat(lambda: self.eval_expression_in_page_unsafe("return document.getElementById('status').innerHTML;"), Eventually(Equals('true'))) |
2162 | + self.assertThat( |
2163 | + lambda: self.eval_expression_in_page_unsafe( |
2164 | + "return document.getElementById('status').innerHTML;"), |
2165 | + Eventually(Equals('true'))) |
2166 | |
2167 | @skipUnless(platform.model() == 'Desktop', "Only runs on the Desktop") |
2168 | def test_checkInitialSetCanPlay(self): |
2169 | - self.assertThat(lambda: self.eval_expression_in_page_unsafe("return document.getElementById('status').innerHTML;"), Eventually(Equals('mediaplayer-updated'))) |
2170 | + self.assertThat( |
2171 | + lambda: self.eval_expression_in_page_unsafe( |
2172 | + "return document.getElementById('status').innerHTML;"), |
2173 | + Eventually(Equals('mediaplayer-updated'))) |
2174 | |
2175 | expr = """ |
2176 | - document.addEventListener('unity-webapps-do-call-response', function(e) { |
2177 | + document.addEventListener('unity-webapps-do-call-response', |
2178 | + function(e) { |
2179 | var response = e.detail; |
2180 | document.getElementById('status').innerHTML = '' + e.detail; |
2181 | }); |
2182 | |
2183 | - var e = new CustomEvent ("unity-webapps-do-call", {"detail": JSON.stringify({"name": 'MediaPlayer.__get', 'with_callback': true, 'args': ['can-play']})}); |
2184 | + var e = new CustomEvent ( |
2185 | + "unity-webapps-do-call", |
2186 | + {"detail": JSON.stringify( |
2187 | + {"name": 'MediaPlayer.__get', |
2188 | + 'with_callback': true, |
2189 | + 'args': ['can-play']})}); |
2190 | document.dispatchEvent (e); |
2191 | return true; |
2192 | """ |
2193 | self.eval_expression_in_page_unsafe(expr) |
2194 | |
2195 | - self.assertThat(lambda: self.eval_expression_in_page_unsafe("return document.getElementById('status').innerHTML;"), Eventually(Equals('true'))) |
2196 | - |
2197 | + self.assertThat( |
2198 | + lambda: self.eval_expression_in_page_unsafe( |
2199 | + "return document.getElementById('status').innerHTML;"), |
2200 | + Eventually(Equals('true'))) |
2201 | |
2202 | === modified file 'tools/qml-launcher/qml-launcher.cpp' |
2203 | --- tools/qml-launcher/qml-launcher.cpp 2014-07-14 19:01:17 +0000 |
2204 | +++ tools/qml-launcher/qml-launcher.cpp 2014-11-22 00:43:58 +0000 |
2205 | @@ -68,7 +68,6 @@ |
2206 | const QString QML_FILE_IMPORT_ARG_HEADER = "--import="; |
2207 | const QString QML_APP_ID_ARG_HEADER = "--app-id="; |
2208 | const QString QML_INSPECTOR_ARG_HEADER = "--inspector="; |
2209 | - const QString QML_USE_OXIDE_ARG_HEADER = "--useOxide"; |
2210 | const QString ARG_HEADER = "--"; |
2211 | const QString VALUE_HEADER = "="; |
2212 | QHash<QString, QString> properties; |
2213 | @@ -76,7 +75,6 @@ |
2214 | QString appid; |
2215 | QString importPath; |
2216 | QString inspector; |
2217 | - bool useOxide = false; |
2218 | bool maximized = false; |
2219 | |
2220 | Q_FOREACH(QString argument, app.arguments()) |
2221 | @@ -101,11 +99,6 @@ |
2222 | inspector = argument.right(argument.count() - QML_INSPECTOR_ARG_HEADER.count()); |
2223 | } |
2224 | else |
2225 | - if (argument.contains(QML_USE_OXIDE_ARG_HEADER)) |
2226 | - { |
2227 | - useOxide = true; |
2228 | - } |
2229 | - else |
2230 | if (argument.contains(QML_MAXIMIZED_ARG)) |
2231 | { |
2232 | maximized = true; |
2233 | @@ -199,9 +192,6 @@ |
2234 | object->setProperty(it.key().toStdString().c_str(), QUrl(it.value())); |
2235 | } |
2236 | |
2237 | - if (useOxide) { |
2238 | - object->setProperty("useOxide", true); |
2239 | - } |
2240 | component.completeCreate(); |
2241 | |
2242 | if (window) |
FAILED: Continuous integration, rev:136 jenkins. qa.ubuntu. com/job/ unity-webapps- qml-ci/ 147/ jenkins. qa.ubuntu. com/job/ unity-webapps- qml-vivid- amd64-ci/ 1/console jenkins. qa.ubuntu. com/job/ unity-webapps- qml-vivid- armhf-ci/ 1/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/ 147/rebuild
http://