Merge lp:~abreu-alexandre/unity-webapps-qml/port-to-oxide into lp:unity-webapps-qml

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
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 :
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
=== modified file 'README'
--- README 2013-06-17 14:46:51 +0000
+++ README 2014-11-22 00:43:58 +0000
@@ -1,1 +1,45 @@
1#
2\ No newline at end of file1\ No newline at end of file
2unity-webapps-qml offers a QML component that depending on runtime
3settings and configurations:
4
5- allows one to inject the UbuntuTouch Javascript platform bindings,
6
7- allows one to inject a restricted set of API bindings when running as a webapp
8(see http://developer.ubuntu.com/publish/webapp/packaging-web-apps/),
9
10- allows one to load local javscript snipets that are to be dynamically injected
11in the webview as part of a webapp,
12
13The QML component supports Oxide and QtWebkit as a web engine backend.
14
15= Building =
16
17The build system uses qmake.
18To compile, simply invoke qmake and then make:
19
20 $ qmake .
21 $ make
22
23= Running =
24
25Some examples are being provided in the examples/ folder. Examples range from
26webapp definitions, to api bindings, etc.
27
28= Unit tests =
29
30To run the unit tests, you can use the commands below:
31
32 $ make test
33
34= Automated UI tests =
35
36The unity-webapps-qml component uses autopilot (https://launchpad.net/autopilot) to test its
37internal sub-componenets.
38To run the tests, you will need to install python3-autopilot and libautopilot-qt.
39Then do the following:
40
41 $ cd tests/autopilot/
42 $ autopilot3 run unity_webapps_qml
43
44You can get a list of all available tests with the following command:
45
46 $ autopilot3 list unity_webapps_qml
347
=== modified file 'debian/control'
--- debian/control 2014-10-14 10:02:49 +0000
+++ debian/control 2014-11-22 00:43:58 +0000
@@ -8,7 +8,7 @@
8 libnotify-dev,8 libnotify-dev,
9# depend on oxide so that we don't build for archs that we can't install on9# depend on oxide so that we don't build for archs that we can't install on
10 liboxideqtcore0,10 liboxideqtcore0,
11 libqt5webkit5-dev,11 liboxideqt-qmlplugin (>= 1.2.0),
12 libunity-action-qt1-dev,12 libunity-action-qt1-dev,
13 libunity-dev,13 libunity-dev,
14 pkg-config,14 pkg-config,
@@ -28,8 +28,7 @@
2828
29Package: unity-webapps-qml29Package: unity-webapps-qml
30Architecture: any30Architecture: any
31Depends: qml-module-qtwebkit,31Depends: liboxideqt-qmlplugin (>= 1.2.0) | qml-module-qtwebkit,
32 liboxideqt-qmlplugin (>= 1.0),
33 qtdeclarative5-qtquick2-plugin,32 qtdeclarative5-qtquick2-plugin,
34 qtdeclarative5-unity-action-plugin,33 qtdeclarative5-unity-action-plugin,
35 qtdeclarative5-ubuntu-ui-toolkit-plugin | qtdeclarative5-ubuntu-ui-toolkit-plugin-gles,34 qtdeclarative5-ubuntu-ui-toolkit-plugin | qtdeclarative5-ubuntu-ui-toolkit-plugin-gles,
3635
=== modified file 'examples/api-bindings/alarm/main.qml.in'
--- examples/api-bindings/alarm/main.qml.in 2014-05-08 13:58:56 +0000
+++ examples/api-bindings/alarm/main.qml.in 2014-11-22 00:43:58 +0000
@@ -1,9 +1,9 @@
1import QtQuick 2.01import QtQuick 2.0
2import QtWebKit 3.0 2import com.canonical.Oxide 1.0
3import QtWebKit.experimental 1.0
4import Ubuntu.Components 0.13import Ubuntu.Components 0.1
5import Ubuntu.UnityWebApps 0.14import Ubuntu.UnityWebApps 0.1
65
6
7Item {7Item {
8 id: root8 id: root
9 focus: true9 focus: true
@@ -16,17 +16,16 @@
16 anchors.fill: parent16 anchors.fill: parent
17 url: \"file://$$OUT_PWD/alarm/www/index.html\"17 url: \"file://$$OUT_PWD/alarm/www/index.html\"
1818
19 experimental.preferences.navigatorQtObjectEnabled: true19 context: WebContext { }
20 experimental.preferences.developerExtrasEnabled: true
2120
22 function getUnityWebappsProxies() {21 function getUnityWebappsProxies() {
23 return UnityWebAppsUtils.makeProxiesForQtWebViewBindee(webview);22 return UnityWebAppsUtils.makeProxiesForWebViewBindee(webview);
24 }23 }
24 }
2525
26 UnityWebApps {26 UnityWebApps {
27 id: webapps27 id: webapps
28 bindee: webview28 bindee: webview
29 injectExtraUbuntuApis: true29 injectExtraUbuntuApis: true
30 }
31 }30 }
32}31}
3332
=== modified file 'examples/api-bindings/content-hub-exporter/main.qml.in'
--- examples/api-bindings/content-hub-exporter/main.qml.in 2014-05-08 13:58:56 +0000
+++ examples/api-bindings/content-hub-exporter/main.qml.in 2014-11-22 00:43:58 +0000
@@ -1,6 +1,5 @@
1import QtQuick 2.01import QtQuick 2.0
2import QtWebKit 3.0 2import com.canonical.Oxide 1.0
3import QtWebKit.experimental 1.0
4import Ubuntu.Components 0.13import Ubuntu.Components 0.1
5import Ubuntu.UnityWebApps 0.14import Ubuntu.UnityWebApps 0.1
65
@@ -16,17 +15,16 @@
16 anchors.fill: parent15 anchors.fill: parent
17 url: \"file://$$OUT_PWD/content-hub-exporter/www/index.html\"16 url: \"file://$$OUT_PWD/content-hub-exporter/www/index.html\"
1817
19 experimental.preferences.navigatorQtObjectEnabled: true18 context: WebContext { }
20 experimental.preferences.developerExtrasEnabled: true
2119
22 function getUnityWebappsProxies() {20 function getUnityWebappsProxies() {
23 return UnityWebAppsUtils.makeProxiesForQtWebViewBindee(webview);21 return UnityWebAppsUtils.makeProxiesForWebViewBindee(webview);
24 }22 }
23 }
2524
26 UnityWebApps {25 UnityWebApps {
27 id: webapps26 id: webapps
28 bindee: webview27 bindee: webview
29 injectExtraUbuntuApis: true28 injectExtraUbuntuApis: true
30 }
31 }29 }
32}30}
3331
=== modified file 'examples/api-bindings/content-hub/main.qml.in'
--- examples/api-bindings/content-hub/main.qml.in 2014-05-08 13:58:56 +0000
+++ examples/api-bindings/content-hub/main.qml.in 2014-11-22 00:43:58 +0000
@@ -1,6 +1,5 @@
1import QtQuick 2.01import QtQuick 2.0
2import QtWebKit 3.0 2import com.canonical.Oxide 1.0
3import QtWebKit.experimental 1.0
4import Ubuntu.Components 0.13import Ubuntu.Components 0.1
5import Ubuntu.UnityWebApps 0.14import Ubuntu.UnityWebApps 0.1
65
@@ -17,17 +16,16 @@
17 anchors.fill: parent16 anchors.fill: parent
18 url: \"file://$$OUT_PWD/content-hub/www/index.html\"17 url: \"file://$$OUT_PWD/content-hub/www/index.html\"
1918
20 experimental.preferences.navigatorQtObjectEnabled: true19 context: WebContext { }
21 experimental.preferences.developerExtrasEnabled: true
2220
23 function getUnityWebappsProxies() {21 function getUnityWebappsProxies() {
24 return UnityWebAppsUtils.makeProxiesForQtWebViewBindee(webview);22 return UnityWebAppsUtils.makeProxiesForWebViewBindee(webview);
25 }23 }
24 }
2625
27 UnityWebApps {26 UnityWebApps {
28 id: webapps27 id: webapps
29 bindee: webview28 bindee: webview
30 injectExtraUbuntuApis: true29 injectExtraUbuntuApis: true
31 }
32 }30 }
33}31}
3432
=== modified file 'examples/api-bindings/content-peer-picker/main.qml.in'
--- examples/api-bindings/content-peer-picker/main.qml.in 2014-05-08 14:21:54 +0000
+++ examples/api-bindings/content-peer-picker/main.qml.in 2014-11-22 00:43:58 +0000
@@ -1,6 +1,5 @@
1import QtQuick 2.01import QtQuick 2.0
2import QtWebKit 3.0 2import com.canonical.Oxide 1.0
3import QtWebKit.experimental 1.0
4import Ubuntu.Components 0.13import Ubuntu.Components 0.1
5import Ubuntu.UnityWebApps 0.14import Ubuntu.UnityWebApps 0.1
65
@@ -17,17 +16,16 @@
17 anchors.fill: parent16 anchors.fill: parent
18 url: \"file://$$OUT_PWD/content-peer-picker/www/index.html\"17 url: \"file://$$OUT_PWD/content-peer-picker/www/index.html\"
1918
20 experimental.preferences.navigatorQtObjectEnabled: true19 context: WebContext { }
21 experimental.preferences.developerExtrasEnabled: true
2220
23 function getUnityWebappsProxies() {21 function getUnityWebappsProxies() {
24 return UnityWebAppsUtils.makeProxiesForQtWebViewBindee(webview);22 return UnityWebAppsUtils.makeProxiesForWebViewBindee(webview);
25 }23 }
24 }
2625
27 UnityWebApps {26 UnityWebApps {
28 id: webapps27 id: webapps
29 bindee: webview28 bindee: webview
30 injectExtraUbuntuApis: true29 injectExtraUbuntuApis: true
31 }
32 }30 }
33}31}
3432
=== modified file 'examples/api-bindings/download-manager/main.qml.in'
--- examples/api-bindings/download-manager/main.qml.in 2014-05-13 17:48:43 +0000
+++ examples/api-bindings/download-manager/main.qml.in 2014-11-22 00:43:58 +0000
@@ -1,6 +1,5 @@
1import QtQuick 2.01import QtQuick 2.0
2import QtWebKit 3.0 2import com.canonical.Oxide 1.0
3import QtWebKit.experimental 1.0
4import Ubuntu.Components 0.13import Ubuntu.Components 0.1
5import Ubuntu.UnityWebApps 0.14import Ubuntu.UnityWebApps 0.1
65
@@ -17,17 +16,16 @@
17 anchors.fill: parent16 anchors.fill: parent
18 url: \"file://$$OUT_PWD/download-manager/www/index.html\"17 url: \"file://$$OUT_PWD/download-manager/www/index.html\"
1918
20 experimental.preferences.navigatorQtObjectEnabled: true19 context: WebContext { }
21 experimental.preferences.developerExtrasEnabled: true
2220
23 function getUnityWebappsProxies() {21 function getUnityWebappsProxies() {
24 return UnityWebAppsUtils.makeProxiesForQtWebViewBindee(webview);22 return UnityWebAppsUtils.makeProxiesForWebViewBindee(webview);
25 }23 }
24 }
2625
27 UnityWebApps {26 UnityWebApps {
28 id: webapps27 id: webapps
29 bindee: webview28 bindee: webview
30 injectExtraUbuntuApis: true29 injectExtraUbuntuApis: true
31 }
32 }30 }
33}31}
3432
=== modified file 'examples/api-bindings/online-accounts/main.qml.in'
--- examples/api-bindings/online-accounts/main.qml.in 2014-05-08 13:58:56 +0000
+++ examples/api-bindings/online-accounts/main.qml.in 2014-11-22 00:43:58 +0000
@@ -1,6 +1,5 @@
1import QtQuick 2.01import QtQuick 2.0
2import QtWebKit 3.0 2import com.canonical.Oxide 1.0
3import QtWebKit.experimental 1.0
4import Ubuntu.Components 0.13import Ubuntu.Components 0.1
5import Ubuntu.UnityWebApps 0.14import Ubuntu.UnityWebApps 0.1
65
@@ -16,17 +15,16 @@
16 anchors.fill: parent15 anchors.fill: parent
17 url: \"file://$$OUT_PWD/online-accounts/www/index.html\"16 url: \"file://$$OUT_PWD/online-accounts/www/index.html\"
1817
19 experimental.preferences.navigatorQtObjectEnabled: true18 context: WebContext { }
20 experimental.preferences.developerExtrasEnabled: true
2119
22 function getUnityWebappsProxies() {20 function getUnityWebappsProxies() {
23 return UnityWebAppsUtils.makeProxiesForQtWebViewBindee(webview);21 return UnityWebAppsUtils.makeProxiesForWebViewBindee(webview);
24 }22 }
23 }
2524
26 UnityWebApps {25 UnityWebApps {
27 id: webapps26 id: webapps
28 bindee: webview27 bindee: webview
29 injectExtraUbuntuApis: true28 injectExtraUbuntuApis: true
30 }
31 }29 }
32}30}
3331
=== modified file 'examples/api-bindings/runtime-api/main.qml.in'
--- examples/api-bindings/runtime-api/main.qml.in 2014-03-26 14:38:17 +0000
+++ examples/api-bindings/runtime-api/main.qml.in 2014-11-22 00:43:58 +0000
@@ -1,6 +1,5 @@
1import QtQuick 2.01import QtQuick 2.0
2import QtWebKit 3.0 2import com.canonical.Oxide 1.0
3import QtWebKit.experimental 1.0
4import Ubuntu.Components 0.13import Ubuntu.Components 0.1
5import Ubuntu.UnityWebApps 0.14import Ubuntu.UnityWebApps 0.1
65
@@ -17,16 +16,15 @@
17 anchors.fill: parent16 anchors.fill: parent
18 url: \"file://$$OUT_PWD/runtime-api/www/index.html\"17 url: \"file://$$OUT_PWD/runtime-api/www/index.html\"
1918
20 experimental.preferences.navigatorQtObjectEnabled: true19 context: WebContext { }
21 experimental.preferences.developerExtrasEnabled: true
2220
23 function getUnityWebappsProxies() {21 function getUnityWebappsProxies() {
24 return UnityWebAppsUtils.makeProxiesForQtWebViewBindee(webview);22 return UnityWebAppsUtils.makeProxiesForWebViewBindee(webview);
25 }23 }
24 }
2625
27 UnityWebApps {26 UnityWebApps {
28 id: webapps27 id: webapps
29 bindee: webview28 bindee: webview
30 }
31 }29 }
32}30}
3331
=== modified file 'examples/basic-webview/main.qml'
--- examples/basic-webview/main.qml 2014-01-17 15:51:27 +0000
+++ examples/basic-webview/main.qml 2014-11-22 00:43:58 +0000
@@ -1,7 +1,6 @@
1import QtQuick 2.01import QtQuick 2.0
2import QtQuick.Window 2.02import QtQuick.Window 2.0
3import QtWebKit 3.03import com.canonical.Oxide 1.0
4import QtWebKit.experimental 1.0
5import Ubuntu.UnityWebApps 0.14import Ubuntu.UnityWebApps 0.1
65
7Window {6Window {
@@ -15,36 +14,21 @@
15 url: "file:///usr/share/unity-webapps-qml/examples/data/html/big-test.html"14 url: "file:///usr/share/unity-webapps-qml/examples/data/html/big-test.html"
16 anchors.fill: parent15 anchors.fill: parent
1716
18 experimental.userScripts: []17 context: WebContext { }
19 experimental.preferences.navigatorQtObjectEnabled: true
20 experimental.preferences.developerExtrasEnabled: true
21
22 experimental.userAgent: {
23 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"
24 }
25 experimental.onMessageReceived: {
26 var msg = null
27 try {
28 msg = JSON.parse(message.data)
29 } catch (error) {
30 console.debug('DEBUG:', message.data)
31 return
32 }
33 }
3418
35 function getUnityWebappsProxies() {19 function getUnityWebappsProxies() {
36 var proxies = UnityWebAppsUtils.makeProxiesForQtWebViewBindee(webView);20 var proxies = UnityWebAppsUtils.makeProxiesForWebViewBindee(webView);
3721
38 // override the default navigate to request22 // override the default navigate to request
39 proxies.navigateTo = function(url) {};23 proxies.navigateTo = function(url) {};
40 return proxies;24 return proxies;
41 }25 }
26 }
4227
43 UnityWebApps {28 UnityWebApps {
44 id: webapps29 id: webapps
45 name: "BBCNews"30 name: "BBCNews"
46 bindee: webView31 bindee: webView
47 model: UnityWebappsAppModel { }32 model: UnityWebappsAppModel { }
48 }
49 }33 }
50}34}
5135
=== modified file 'examples/examples.pro'
--- examples/examples.pro 2014-01-17 15:51:27 +0000
+++ examples/examples.pro 2014-11-22 00:43:58 +0000
@@ -41,6 +41,9 @@
41basic_webview_install.path = /usr/share/unity-webapps-qml/examples/basic-webview41basic_webview_install.path = /usr/share/unity-webapps-qml/examples/basic-webview
42basic_webview_install.files = $$system(ls basic-webview/*)42basic_webview_install.files = $$system(ls basic-webview/*)
4343
44html5_api_bindings_install.path = /usr/share/unity-webapps-qml/examples/api-bindings
45html5_api_bindings_install.files = $$system(ls api-bindings/*)
46
44webapps_apps_model_install.path = /usr/share/unity-webapps-qml/examples/webapps-apps-model47webapps_apps_model_install.path = /usr/share/unity-webapps-qml/examples/webapps-apps-model
45webapps_apps_model_install.files = $$system(ls webapps-app-model/*)48webapps_apps_model_install.files = $$system(ls webapps-app-model/*)
4649
4750
=== removed directory 'examples/facebook-share'
=== removed directory 'examples/facebook-share/content-hub'
=== removed file 'examples/facebook-share/content-hub/webapp-facebook.json'
--- examples/facebook-share/content-hub/webapp-facebook.json 2014-06-17 20:34:32 +0000
+++ examples/facebook-share/content-hub/webapp-facebook.json 1970-01-01 00:00:00 +0000
@@ -1,5 +0,0 @@
1{
2 "share": [
3 "pictures"
4 ]
5}
60
=== removed file 'examples/facebook-share/facebook.png'
7Binary 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 differ1Binary 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
=== removed file 'examples/facebook-share/manifest.json'
--- examples/facebook-share/manifest.json 2014-06-17 20:34:32 +0000
+++ examples/facebook-share/manifest.json 1970-01-01 00:00:00 +0000
@@ -1,18 +0,0 @@
1{
2 "description": "Facebook (webapp version)",
3 "framework": "ubuntu-sdk-14.10-dev1",
4 "architecture": "all",
5 "hooks": {
6 "webapp-facebook": {
7 "account-application": "webapp-facebook.application",
8 "content-hub": "content-hub/webapp-facebook.json",
9 "account-service": "webapp-facebook.service",
10 "apparmor": "webapp-facebook.json",
11 "desktop": "webapp-facebook.desktop"
12 }
13 },
14 "maintainer": "Webapps Team <webapps@lists.launchpad.net>",
15 "name": "com.ubuntu.developer.webapps.webapp-facebook",
16 "title": "webapp-facebook",
17 "version": "1.0.17.4"
18}
190
=== removed directory 'examples/facebook-share/unity-webapps-facebook'
=== removed file 'examples/facebook-share/unity-webapps-facebook/HubSharer.qml'
--- examples/facebook-share/unity-webapps-facebook/HubSharer.qml 2014-06-17 20:49:12 +0000
+++ examples/facebook-share/unity-webapps-facebook/HubSharer.qml 1970-01-01 00:00:00 +0000
@@ -1,41 +0,0 @@
1import QtQuick 2.0
2import Ubuntu.Components 0.1
3import Ubuntu.Content 0.1
4
5Item {
6 id: main
7 anchors.fill: parent
8
9 signal completed(string result)
10
11 property string fileToShare
12
13 function _callback(accessToken, fileToShare, message, cb) {
14 print ("_callback: " + accessToken);
15 print ("_callback: " + fileToShare);
16 print ("_callback: " + message);
17
18 itemComp.url = fileToShare;
19 var dataUri = itemComp.toDataURI();
20 var result = {accessToken: accessToken,
21 fileToShare: dataUri.toString(),
22 message: message};
23
24 completed(JSON.stringify(result));
25 }
26
27 ContentItem {
28 id: itemComp
29 }
30
31 Share {
32 anchors.fill: parent
33 visible: true
34 fileToShare: main.fileToShare
35 callback: _callback
36 provider: "facebook"
37 onCanceled: completed(JSON.stringify({status: "cancelled"}))
38 onUploadCompleted: console.log (success)
39 Component.onCompleted: print ("Page completed " + height + " : " + width)
40 }
41}
420
=== removed file 'examples/facebook-share/unity-webapps-facebook/Share.qml'
--- examples/facebook-share/unity-webapps-facebook/Share.qml 2014-06-17 21:18:53 +0000
+++ examples/facebook-share/unity-webapps-facebook/Share.qml 1970-01-01 00:00:00 +0000
@@ -1,323 +0,0 @@
1/*
2 * Copyright (C) 2012-2013 Canonical, Ltd.
3 *
4 * This program is free software; you can redistribute it and/or modify
5 * it under the terms of the GNU General Public License as published by
6 * the Free Software Foundation; version 3.
7 *
8 * This program is distributed in the hope that it will be useful,
9 * but WITHOUT ANY WARRANTY; without even the implied warranty of
10 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11 * GNU General Public License for more details.
12 *
13 * You should have received a copy of the GNU General Public License
14 * along with this program. If not, see <http://www.gnu.org/licenses/>.
15 */
16
17import QtQuick 2.0
18import QtQuick.Window 2.0
19import Ubuntu.Components 0.1
20import Ubuntu.Components.ListItems 0.1 as ListItem
21import Ubuntu.OnlineAccounts 0.1
22
23Rectangle {
24 id: root
25 anchors.fill: parent
26 color: Theme.palette.normal.background
27 property string fileToShare
28 property var callback
29 property string serviceType: "webapps"
30 property string provider: "facebook"
31 property string userAccountId
32 property string accessToken
33 property var account
34 signal accountSelected
35 signal canceled()
36 signal uploadCompleted(bool success)
37
38 onUploadCompleted: {
39 activitySpinner.visible = false;
40 if (success)
41 print ("Successfully posted");
42 else
43 print ("Failed to post");
44 }
45
46 AccountServiceModel {
47 id: accounts
48 serviceType: root.serviceType
49 provider: root.provider
50 Component.onCompleted: {
51 if (count == 1) {
52 srv.objectHandle = get(0, "accountServiceHandle");
53 }
54 }
55 }
56
57 AccountService {
58 id: srv
59 onObjectHandleChanged: {
60 root.account = srv;
61 root.account.authenticate(null);
62 }
63 onAuthenticated: {
64 root.userAccountId = accountId;
65 root.accessToken = reply.AccessToken;
66 shareComponent.visible = true;
67 sharemenu.visible = false;
68 }
69 }
70
71
72 Rectangle {
73 id: shareComponent
74 objectName: "shareComponent"
75 anchors.fill: parent
76 color: Theme.palette.normal.background
77 visible: false
78
79 Column {
80 anchors.fill: parent
81 spacing: units.gu(1)
82
83 Item {
84 id: serviceHeader
85 y: 0
86 anchors.left: parent.left
87 anchors.right: parent.right
88 anchors.topMargin: units.gu(1)
89 anchors.leftMargin: units.gu(1)
90 anchors.rightMargin: units.gu(1)
91 height: childrenRect.height
92
93 ListItem.Subtitled {
94 anchors {
95 left: parent.left
96 right: parent.right
97 }
98 iconName: root.account.provider.iconName
99 text: root.account.provider.displayName
100 subText: root.account.displayName
101 showDivider: false
102 }
103 }
104
105 ListItem.ThinDivider {}
106
107 UbuntuShape {
108 id: messageArea
109 objectName: "messageArea"
110 anchors.left: parent.left
111 anchors.right: parent.right
112 anchors.topMargin: units.gu(1)
113 anchors.leftMargin: units.gu(1)
114 anchors.rightMargin: units.gu(1)
115
116 height: units.gu(20)
117 color: "#f2f2f2"
118
119 TextEdit {
120 id: message
121 color: "#333333"
122 anchors.top: parent.top
123 anchors.left: snapshot.right
124 anchors.bottom: parent.bottom
125 anchors.margins: units.gu(1)
126 wrapMode: Text.Wrap
127 width: parent.width - snapshot.width -
128 snapshot.anchors.margins * 2 -
129 message.anchors.leftMargin - message.anchors.rightMargin
130 clip: true
131 font.pixelSize: FontUtils.sizeToPixels("medium")
132 font.weight: Font.Light
133 focus: true
134 }
135
136 ActivityIndicator {
137 id: activitySpinner
138 anchors.centerIn: message
139 visible: false
140 running: visible
141 }
142
143 UbuntuShape {
144 id: snapshot
145 anchors.top: parent.top
146 anchors.left: parent.left
147 anchors.margins: units.gu(1)
148 width: units.gu(10)
149 height: units.gu(10)
150
151 image: Image {
152 source: fileToShare
153 sourceSize.height: snapshot.height
154 sourceSize.width: snapshot.width
155 fillMode: Image.PreserveAspectCrop
156 }
157 }
158 }
159
160 Item {
161 id: actionsBar
162 anchors.left: parent.left
163 anchors.right: parent.right
164 anchors.topMargin: units.gu(2)
165 anchors.leftMargin: units.gu(1)
166 anchors.rightMargin: units.gu(1)
167 height: childrenRect.height
168
169 Button {
170 objectName: "cancelButton"
171 anchors.left: parent.left
172 text: i18n.dtr("ubuntu-ui-extras", "Cancel")
173 color: "#cccccc"
174 width: units.gu(10)
175 height: units.gu(4)
176 onClicked: canceled()
177 }
178
179 Button {
180 objectName: "postButton"
181 anchors.right: parent.right
182 anchors.top: parent.top
183 text: i18n.dtr("ubuntu-ui-extras", "Post")
184 color: "#dd4814"
185 width: units.gu(10)
186 height: units.gu(4)
187 enabled: !activitySpinner.visible
188 onClicked: {
189 activitySpinner.visible = true;
190 callback(accessToken, fileToShare, message.text, uploadCompleted);
191 }
192 }
193 }
194
195 UbuntuShape {
196 id: useLocation
197 anchors {
198 left: parent.left
199 leftMargin: units.gu(1)
200 topMargin: units.gu(1)
201 }
202 color: selected ? "#cccccc" : "transparent"
203 property bool selected: false
204 width: units.gu(4.5)
205 height: units.gu(4)
206
207 AbstractButton {
208 anchors.fill: parent
209 onClicked: parent.selected = !parent.selected
210 Image {
211 source: "assets/icon_location.png"
212 anchors.centerIn: parent
213 height: parent.height * 0.75
214 fillMode: Image.PreserveAspectFit
215 smooth: true
216 }
217 }
218 }
219
220 Label {
221 anchors.left: useLocation.right
222 anchors.baseline: useLocation.top
223 anchors.baselineOffset: units.gu(3)
224 anchors.leftMargin: units.gu(1)
225 text: i18n.dtr("ubuntu-ui-extras", "Include location")
226 fontSize: "small"
227 }
228
229 }
230
231 states: [
232 State {
233 name: "landscape-with-keyborad"
234 PropertyChanges {
235 target: serviceHeader
236 y: - serviceHeader.height
237 }
238 PropertyChanges {
239 target: messageArea
240 height: units.gu(12)
241 }
242 }
243 ]
244
245 state: ((Screen.orientation === Qt.LandscapeOrientation) ||
246 (Screen.orientation === Qt.InvertedLandscapeOrientation)) &&
247 Qt.inputMethod.visible ? "landscape-with-keyborad" : ""
248 }
249
250 /* Menu listing online accounts */
251 Item {
252 id: sharemenu
253 anchors.fill: parent
254 visible: true
255
256 signal selected(string accountId, string token)
257
258 Component.onCompleted: {
259 visible = true;
260 }
261 onSelected: {
262 root.userAccountId = accountId;
263 root.accessToken = token;
264 shareComponent.visible = true;
265 sharemenu.visible = false;
266 }
267
268 Component {
269 id: acctDelegate
270 Item {
271 anchors {
272 left: parent.left
273 right: parent.right
274 }
275 AccountService {
276 id: service
277 objectHandle: accountServiceHandle
278 onAuthenticated: {
279 sharemenu.selected(accountId, reply.AccessToken);
280 }
281 }
282
283 height: childrenRect.height
284
285 ListItem.Subtitled {
286 anchors {
287 left: parent.left
288 right: parent.right
289 }
290 text: service.provider.displayName
291 subText: displayName
292 iconName: service.provider.iconName
293 __iconHeight: units.gu(5)
294 __iconWidth: units.gu(5)
295
296 onClicked: {
297 root.account = service;
298 root.account.authenticate(null);
299 }
300 }
301 }
302 }
303
304 ListView {
305 anchors {
306 top: parent.top
307 left: parent.left
308 right: parent.right
309 }
310 height: childrenRect.height
311 interactive: false
312 model: accounts
313 header: ListItem.Header {
314 anchors {
315 left: parent.left
316 right: parent.right
317 }
318 text: i18n.tr("Select account")
319 }
320 delegate: acctDelegate
321 }
322 }
323}
3240
=== removed directory 'examples/facebook-share/unity-webapps-facebook/assets'
=== removed file 'examples/facebook-share/unity-webapps-facebook/assets/avatar_image.jpg'
325Binary 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 differ1Binary 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
=== removed file 'examples/facebook-share/unity-webapps-facebook/assets/icon_location.png'
326Binary 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 differ2Binary 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
=== removed file 'examples/facebook-share/unity-webapps-facebook/facebook.user.js'
--- examples/facebook-share/unity-webapps-facebook/facebook.user.js 2014-06-17 20:34:32 +0000
+++ examples/facebook-share/unity-webapps-facebook/facebook.user.js 1970-01-01 00:00:00 +0000
@@ -1,47 +0,0 @@
1var api = external.getUnityObject('1.0');
2var hub = api.ContentHub;
3var activeTransfer;
4
5function _shareRequested(transfer) {
6 activeTransfer = transfer;
7 transfer.items(function(items) {
8 api.launchEmbeddedUI("HubSharer", upload, {"fileToShare": items[0]});
9 });
10};
11
12hub.onShareRequested(_shareRequested);
13
14function upload(res) {
15 var results = JSON.parse(res);
16 if (results.status == "cancelled")
17 activeTransfer.setState(hub.ContentTransfer.State.Aborted);
18
19 var xhr = new XMLHttpRequest();
20 xhr.open( 'POST', 'https://graph.facebook.com/me/photos?access_token=' + results.accessToken, true );
21 xhr.onload = xhr.onerror = function() {
22 if ( xhr.status == 200 )
23 window.location.reload();
24 };
25
26 var contentType = results.fileToShare.split(',')[0].split(':')[1];
27 var b64data = results.fileToShare.split(',')[1];
28
29 var byteCharacters = atob(b64data);
30 var byteNumbers = new Array(byteCharacters.length);
31 for (var i = 0; i < byteCharacters.length; i++) {
32 byteNumbers[i] = byteCharacters.charCodeAt(i);
33 }
34 var byteArray = new Uint8Array(byteNumbers);
35
36 var div = document.createElement('div');
37 div.innerHTML = '<form enctype="multipart/form-data" method="post" id="uploadForm"><textarea id="message" name="message"></textarea></form>';
38 document.getElementsByTagName('body')[0].appendChild(div);
39
40 var blob = new Blob([byteArray], {type: contentType});
41
42 var uploadForm = document.forms.namedItem("uploadForm");
43 var formData = new FormData(uploadForm);
44 formData.append('source', blob);
45 formData.append('message', results.message);
46 xhr.send(formData);
47}
480
=== removed file 'examples/facebook-share/unity-webapps-facebook/manifest.json'
--- examples/facebook-share/unity-webapps-facebook/manifest.json 2014-05-23 07:42:14 +0000
+++ examples/facebook-share/unity-webapps-facebook/manifest.json 1970-01-01 00:00:00 +0000
@@ -1,7 +0,0 @@
1{
2 "name": "facebook",
3 "includes": ["https://*.facebook.com/*"],
4 "homepage": "https://m.facebook.com/",
5 "domain": "facebook.com",
6 "scripts": ["facebook.user.js"]
7}
80
=== removed file 'examples/facebook-share/webapp-facebook.application'
--- examples/facebook-share/webapp-facebook.application 2014-05-22 08:54:56 +0000
+++ examples/facebook-share/webapp-facebook.application 1970-01-01 00:00:00 +0000
@@ -1,11 +0,0 @@
1<?xml version="1.0" encoding="UTF-8" ?>
2<application id="com.ubuntu.developer.webapps.webapp-facebook_webapp-facebook">
3 <description>Facebook webapp</description>
4
5 <services>
6 <service id="com.ubuntu.developer.webapps.webapp-facebook_webapp-facebook">
7 <description>Use the service in a webapp</description>
8 </service>
9 </services>
10
11</application>
120
=== removed file 'examples/facebook-share/webapp-facebook.desktop'
--- examples/facebook-share/webapp-facebook.desktop 2014-06-17 17:53:45 +0000
+++ examples/facebook-share/webapp-facebook.desktop 1970-01-01 00:00:00 +0000
@@ -1,9 +0,0 @@
1[Desktop Entry]
2Type=Application
3Terminal=false
4Exec=webapp-container --enable-back-forward --webapp='ZmFjZWJvb2s=' --webappModelSearchPath=. --webappUrlPatterns=https?://*.facebook.com/*
5Name=Facebook
6Icon=./facebook.png
7X-Ubuntu-Touch=true
8X-Ubuntu-StageHint=SideStage
9X-Ubuntu-Single-Instance=true
100
=== removed file 'examples/facebook-share/webapp-facebook.json'
--- examples/facebook-share/webapp-facebook.json 2014-05-23 13:00:57 +0000
+++ examples/facebook-share/webapp-facebook.json 1970-01-01 00:00:00 +0000
@@ -1,13 +0,0 @@
1{
2 "template": "ubuntu-webapp",
3 "policy_groups": [
4 "networking",
5 "accounts",
6 "audio",
7 "video",
8 "webview",
9 "location",
10 "content_exchange"
11 ],
12 "policy_version": 1.2
13}
140
=== removed file 'examples/facebook-share/webapp-facebook.service'
--- examples/facebook-share/webapp-facebook.service 2014-05-23 13:00:57 +0000
+++ examples/facebook-share/webapp-facebook.service 1970-01-01 00:00:00 +0000
@@ -1,6 +0,0 @@
1<?xml version="1.0" encoding="UTF-8"?>
2<service id="com.ubuntu.developer.webapps.webapp-facebook_webapp-facebook">
3 <type>webapps</type>
4 <name>Facebook Webapp</name>
5 <provider>facebook</provider>
6</service>
70
=== modified file 'examples/unity-webapps-example-bbcnews/main.qml'
--- examples/unity-webapps-example-bbcnews/main.qml 2013-07-31 17:27:00 +0000
+++ examples/unity-webapps-example-bbcnews/main.qml 2014-11-22 00:43:58 +0000
@@ -18,8 +18,7 @@
1818
19import QtQuick 2.019import QtQuick 2.0
20import QtQuick.Window 2.020import QtQuick.Window 2.0
21import QtWebKit 3.021import com.canonical.Oxide 1.0
22import QtWebKit.experimental 1.0
23import Ubuntu.UnityWebApps 0.122import Ubuntu.UnityWebApps 0.1
2423
25Window {24Window {
@@ -33,23 +32,19 @@
33 width: parent.width32 width: parent.width
34 height: parent.height33 height: parent.height
3534
36 experimental.userScripts: []35 context: WebContext {
37 experimental.preferences.navigatorQtObjectEnabled: true36 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"
38 experimental.preferences.developerExtrasEnabled: true
39
40 experimental.userAgent: {
41 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"
42 }37 }
4338
44 function getUnityWebappsProxies() {39 function getUnityWebappsProxies() {
45 return UnityWebAppsUtils.makeProxiesForQtWebViewBindee(webView);40 return UnityWebAppsUtils.makeProxiesForWebViewBindee(webView);
46 }41 }
42 }
4743
48 UnityWebApps {44 UnityWebApps {
49 id: webapps45 id: webapps
50 name: "BBCNews"46 name: "BBCNews"
51 bindee: webView47 bindee: webView
52 model: UnityWebappsAppModel { searchPath: '/usr/share/unity-webapps-qml/examples/data/userscripts'}48 model: UnityWebappsAppModel { searchPath: '/usr/share/unity-webapps-qml/examples/data/userscripts'}
53 }
54 }49 }
55}50}
5651
=== modified file 'examples/unity-webapps-example-facebookmessenger/main.qml'
--- examples/unity-webapps-example-facebookmessenger/main.qml 2013-07-31 19:27:51 +0000
+++ examples/unity-webapps-example-facebookmessenger/main.qml 2014-11-22 00:43:58 +0000
@@ -18,8 +18,7 @@
1818
19import QtQuick 2.019import QtQuick 2.0
20import QtQuick.Window 2.020import QtQuick.Window 2.0
21import QtWebKit 3.021import com.canonical.Oxide 1.0
22import QtWebKit.experimental 1.0
23import Ubuntu.UnityWebApps 0.122import Ubuntu.UnityWebApps 0.1
2423
25Window {24Window {
@@ -33,19 +32,17 @@
33 width: parent.width32 width: parent.width
34 height: parent.height33 height: parent.height
3534
36 experimental.userScripts: []35 context: WebContext { }
37 experimental.preferences.navigatorQtObjectEnabled: true
38 experimental.preferences.developerExtrasEnabled: true
3936
40 function getUnityWebappsProxies() {37 function getUnityWebappsProxies() {
41 return UnityWebAppsUtils.makeProxiesForQtWebViewBindee(webView);38 return UnityWebAppsUtils.makeProxiesForWebViewBindee(webView);
42 }39 }
40 }
4341
44 UnityWebApps {42 UnityWebApps {
45 id: webapps43 id: webapps
46 name: "FacebookMessenger"44 name: "FacebookMessenger"
47 bindee: webView45 bindee: webView
48 model: UnityWebappsAppModel { searchPath: '/usr/share/unity-webapps-qml/examples/data/userscripts'}46 model: UnityWebappsAppModel { searchPath: '/usr/share/unity-webapps-qml/examples/data/userscripts'}
49 }
50 }47 }
51}48}
5249
=== modified file 'src/Ubuntu/UnityWebApps/UnityWebApps.js'
--- src/Ubuntu/UnityWebApps/UnityWebApps.js 2014-07-18 13:43:55 +0000
+++ src/Ubuntu/UnityWebApps/UnityWebApps.js 2014-11-22 00:43:58 +0000
@@ -75,8 +75,7 @@
75 var cb = this._onMessageReceivedCallback.bind(self);75 var cb = this._onMessageReceivedCallback.bind(self);
76 self._bindeeProxies.messageReceivedConnect(cb);76 self._bindeeProxies.messageReceivedConnect(cb);
7777
78 cb = this._onLoadingStartedCallback.bind(self);78 this._onLoadingStartedCallback();
79 self._bindeeProxies.loadingStartedConnect(cb);
80 },79 },
8180
82 /**81 /**
8382
=== modified file 'src/Ubuntu/UnityWebApps/UnityWebApps.qml'
--- src/Ubuntu/UnityWebApps/UnityWebApps.qml 2014-07-18 21:46:57 +0000
+++ src/Ubuntu/UnityWebApps/UnityWebApps.qml 2014-11-22 00:43:58 +0000
@@ -168,17 +168,20 @@
168 property string _opt_homepage: ""168 property string _opt_homepage: ""
169169
170170
171 /*!
172 \qmlsignal UnityWebApps::userScriptsInjected()
173
174 This signal is emitted when the component has completed its initialization and
175 the userscripts have been injected into the binded webview.
176 */
177 signal userScriptsInjected()
178
179
171 Settings {180 Settings {
172 id: settings181 id: settings
173 injectExtraContentShareCapabilities: name && name.length && name.length !== 0182 injectExtraContentShareCapabilities: name && name.length && name.length !== 0
174 }183 }
175184
176/*
177 Loader {
178 id: apiBindingModelComponentLoader
179 sourceComponent: settings.injectExtraUbuntuApis ? apiBindingModelComponent : undefined
180 }
181*/
182185
183 /*!186 /*!
184 \internal187 \internal
@@ -237,6 +240,8 @@
237240
238 if (internal.backends)241 if (internal.backends)
239 internal.instance.setBackends(internal.backends)242 internal.instance.setBackends(internal.backends)
243
244 userScriptsInjected();
240 }245 }
241246
242 /*!247 /*!
@@ -392,7 +397,11 @@
392 \internal397 \internal
393398
394 */399 */
395 onModelChanged: model.modelContentChanged.connect(__setupNamedWebappEnvironment)400 onModelChanged: {
401 if (model) {
402 model.modelContentChanged.connect(__setupNamedWebappEnvironment)
403 }
404 }
396405
397 /*!406 /*!
398 \internal407 \internal
399408
=== modified file 'src/Ubuntu/UnityWebApps/UnityWebAppsUtils.js'
--- src/Ubuntu/UnityWebApps/UnityWebAppsUtils.js 2014-10-08 17:16:47 +0000
+++ src/Ubuntu/UnityWebApps/UnityWebAppsUtils.js 2014-11-22 00:43:58 +0000
@@ -64,7 +64,7 @@
64 this.disposer = disposer;64 this.disposer = disposer;
65 this.makeSignalDisconnecter = makeSignalDisconnecter;65 this.makeSignalDisconnecter = makeSignalDisconnecter;
66 this._userScriptInjected = false;66 this._userScriptInjected = false;
67 this._WEBAPPS_USER_SCRIPT_CONTEXT = "oxide://UnityWebappsApi";67 this._WEBAPPS_USER_SCRIPT_CONTEXT = "oxide://main-world";
68}68}
69OxideWebviewAdapter.prototype = {69OxideWebviewAdapter.prototype = {
70 injectUserScripts: function(userScriptUrls) {70 injectUserScripts: function(userScriptUrls) {
@@ -79,12 +79,19 @@
7979
80 for (var i = 0; i < userScriptUrls.length; ++i) {80 for (var i = 0; i < userScriptUrls.length; ++i) {
81 var scriptStart = "import com.canonical.Oxide 1.0 as Oxide; Oxide.UserScript { context:";81 var scriptStart = "import com.canonical.Oxide 1.0 as Oxide; Oxide.UserScript { context:";
82 var scriptEnd = "}";82 var scriptEnd = " }";
83 var statement = scriptStart +83 var statement = scriptStart +
84 '"' + this._WEBAPPS_USER_SCRIPT_CONTEXT + '"' +84 '"' +
85 '; matchAllFrames: false; url: "' + userScriptUrls[i] + '";' + scriptEnd;85 this._WEBAPPS_USER_SCRIPT_CONTEXT +
86 '"' +
87 '; matchAllFrames: false; emulateGreasemonkey: true; url: "' +
88 userScriptUrls[i] +
89 '";'
90 + scriptEnd;
91
86 context.addUserScript(Qt.createQmlObject(statement, this.webview));92 context.addUserScript(Qt.createQmlObject(statement, this.webview));
87 }93 }
94
88 this._userScriptInjected = true;95 this._userScriptInjected = true;
89 },96 },
90 sendToPage: function (message) {97 sendToPage: function (message) {
9198
=== modified file 'src/Ubuntu/UnityWebApps/common/js/unity-backend-messaging-proxy.js'
--- src/Ubuntu/UnityWebApps/common/js/unity-backend-messaging-proxy.js 2014-03-28 13:21:47 +0000
+++ src/Ubuntu/UnityWebApps/common/js/unity-backend-messaging-proxy.js 2014-11-22 00:43:58 +0000
@@ -4,7 +4,7 @@
4 navigator.qt.postMessage) {4 navigator.qt.postMessage) {
5 return new UnityQtWebkitBackendMessagingProxy();5 return new UnityQtWebkitBackendMessagingProxy();
6 }6 }
7 else if (window.oxide) {7 else if (oxide) {
8 return new UnityOxideBackendMessagingProxy();8 return new UnityOxideBackendMessagingProxy();
9 }9 }
10 return null;10 return null;
1111
=== modified file 'src/Ubuntu/UnityWebApps/unity-webapps-api.js.in'
--- src/Ubuntu/UnityWebApps/unity-webapps-api.js.in 2014-06-04 21:17:00 +0000
+++ src/Ubuntu/UnityWebApps/unity-webapps-api.js.in 2014-11-22 00:43:58 +0000
@@ -1,3 +1,7 @@
1// ==UserScript==
2// @inject_in_main_world
3// ==/UserScript==
4
1/*5/*
2 * Copyright 2013 Canonical Ltd.6 * Copyright 2013 Canonical Ltd.
3 *7 *
48
=== modified file 'tests/autopilot/autopilot.pro'
--- tests/autopilot/autopilot.pro 2014-07-14 19:04:25 +0000
+++ tests/autopilot/autopilot.pro 2014-11-22 00:43:58 +0000
@@ -20,7 +20,6 @@
20 $$system(ls ./data/*/*) \20 $$system(ls ./data/*/*) \
21 unity_webapps_qml/tests/test_installedWebapp.py \21 unity_webapps_qml/tests/test_installedWebapp.py \
22 unity_webapps_qml/tests/fake_servers.py \22 unity_webapps_qml/tests/fake_servers.py \
23 qml/WebviewBackendWebkit.qml \
24 qml/WebviewBackendOxide.qml \23 qml/WebviewBackendOxide.qml \
25 qml/message-server.js \24 qml/message-server.js \
26 $$system(ls ./data/installed-webapps/*) \25 $$system(ls ./data/installed-webapps/*) \
2726
=== modified file 'tests/autopilot/qml/FullWebViewApp.qml'
--- tests/autopilot/qml/FullWebViewApp.qml 2014-07-18 21:46:57 +0000
+++ tests/autopilot/qml/FullWebViewApp.qml 2014-11-22 00:43:58 +0000
@@ -35,21 +35,9 @@
35 signal resultUpdated(string message)35 signal resultUpdated(string message)
3636
37 function evalInPageUnsafe(expr) {37 function evalInPageUnsafe(expr) {
38 if (webView && webView.experimental) {38 return webView.evaluateCode(expr, true);
39 webView.experimental.evaluateJavaScript(DomIntrospectionUtils.wrapJsCommands(expr),
40 function(result) {
41 console.log('Result: ' + result);
42 root.resultUpdated(DomIntrospectionUtils.createResult(result));
43 });
44 }
45 else {
46 root.resultUpdated(DomIntrospectionUtils.createResult(webView.evaluateCode("return navigator.userAgent", true)))
47 }
48 }39 }
4940
50 property var webView: null
51
52 property bool useOxide: false
53 property string url: ""41 property string url: ""
5442
55 property string apiBackendQmlFileUrl: ""43 property string apiBackendQmlFileUrl: ""
@@ -67,24 +55,14 @@
67 active: true55 active: true
68 }56 }
6957
70 Loader {58 WebviewBackendOxide {
71 id: webviewLoader59 id: webView
72 onLoaded: {60 url: root.url
73 webView = webviewLoader.item61 localUserAgentOverride: webappName && webappModel.exists(webappName)
74 }62 ? webappModel.userAgentOverrideFor(webappName) : ""
75 }63 }
7664
77 Component.onCompleted: {65 // Offers a way to override/mock the API backends
78 var webviewSource = useOxide ?
79 Qt.resolvedUrl("WebviewBackendOxide.qml")
80 : Qt.resolvedUrl("WebviewBackendWebkit.qml");
81 var override = webappName && webappModel.exists(webappName) ?
82 webappModel.userAgentOverrideFor(webappName) : ""
83 webviewLoader.setSource(webviewSource,
84 { url: root.url,
85 localUserAgentOverride: override})
86 }
87
88 Loader {66 Loader {
89 id: apiBackendQmlFileLoader67 id: apiBackendQmlFileLoader
90 source: apiBackendQmlFileUrl.length !== 0 ? apiBackendQmlFileUrl : ""68 source: apiBackendQmlFileUrl.length !== 0 ? apiBackendQmlFileUrl : ""
@@ -93,10 +71,9 @@
93 Loader {71 Loader {
94 id: unityWebappsComponentLoader72 id: unityWebappsComponentLoader
95 anchors.fill: parent73 anchors.fill: parent
96 sourceComponent: webView !== null ?74 sourceComponent: (apiBackendQmlFileUrl.length !== 0
97 (apiBackendQmlFileUrl.length !== 0 ?75 && !apiBackendQmlFileLoader.item)
98 (apiBackendQmlFileLoader.item ? unityWebappsComponent : undefined)76 ? undefined : unityWebappsComponent
99 : unityWebappsComponent) : null
100 }77 }
10178
102 UnityWebappsAppModel {79 UnityWebappsAppModel {
10380
=== modified file 'tests/autopilot/qml/WebviewBackendOxide.qml'
--- tests/autopilot/qml/WebviewBackendOxide.qml 2014-07-16 20:15:17 +0000
+++ tests/autopilot/qml/WebviewBackendOxide.qml 2014-11-22 00:43:58 +0000
@@ -9,6 +9,9 @@
99
10 property string localUserAgentOverride: ""10 property string localUserAgentOverride: ""
1111
12 preferences.localStorageEnabled: true
13 preferences.appCacheEnabled: true
14
12 function _waitForResult(req, timeout) {15 function _waitForResult(req, timeout) {
13 var result;16 var result;
14 var error;17 var error;
@@ -46,7 +49,7 @@
46 function evaluateCode(code, wrap) {49 function evaluateCode(code, wrap) {
47 var value = webView._waitForResult(50 var value = webView._waitForResult(
48 webView.rootFrame.sendMessage(51 webView.rootFrame.sendMessage(
49 "webview-oxide://test/",52 "oxide://main-world",
50 "EVALUATE-CODE",53 "EVALUATE-CODE",
51 { code: code,54 { code: code,
52 wrap: wrap === undefined ? false : wrap }));55 wrap: wrap === undefined ? false : wrap }));
@@ -54,10 +57,12 @@
54 }57 }
5558
56 context: Oxide.WebContext {59 context: Oxide.WebContext {
57 userAgent: webView.localUserAgentOverride.length === 0 ? "" : webView.localUserAgentOverride60 userAgent: webView.localUserAgentOverride.length === 0
61 ? "" : webView.localUserAgentOverride
58 userScripts: [62 userScripts: [
59 Oxide.UserScript {63 Oxide.UserScript {
60 context: "webview-oxide://test/"64 context: "oxide://main-world"
65 emulateGreasemonkey: true
61 url: Qt.resolvedUrl("message-server.js")66 url: Qt.resolvedUrl("message-server.js")
62 matchAllFrames: true67 matchAllFrames: true
63 }68 }
6469
=== removed file 'tests/autopilot/qml/WebviewBackendWebkit.qml'
--- tests/autopilot/qml/WebviewBackendWebkit.qml 2014-07-08 19:27:21 +0000
+++ tests/autopilot/qml/WebviewBackendWebkit.qml 1970-01-01 00:00:00 +0000
@@ -1,19 +0,0 @@
1import QtQuick 2.0
2import QtWebKit 3.0
3import QtWebKit.experimental 1.0
4import Ubuntu.UnityWebApps 0.1
5
6WebView {
7 id: webView
8 objectName: "webview"
9
10 property string localUserAgentOverride: ""
11
12 experimental.userScripts: []
13 experimental.preferences.navigatorQtObjectEnabled: true
14 experimental.preferences.developerExtrasEnabled: true
15
16 function getUnityWebappsProxies() {
17 return UnityWebAppsUtils.makeProxiesForQtWebViewBindee(webView);
18 }
19}
200
=== modified file 'tests/autopilot/unity_webapps_qml/tests/__init__.py'
--- tests/autopilot/unity_webapps_qml/tests/__init__.py 2014-07-14 19:01:17 +0000
+++ tests/autopilot/unity_webapps_qml/tests/__init__.py 2014-11-22 00:43:58 +0000
@@ -9,29 +9,31 @@
99
10import os10import os
11import os.path11import os.path
12import shutil
13import tempfile
14import json
1512
16from testtools.matchers import Contains, Equals, GreaterThan13from testtools.matchers import Equals
17from autopilot.matchers import Eventually14from autopilot.matchers import Eventually
18from unity_webapps_qml.tests import fake_servers15from unity_webapps_qml.tests import fake_servers
1916
20from unity.emulators.unity import Unity17from autopilot.testcase import AutopilotTestCase
2118
22from unity.tests import UnityTestCase19LOCAL_QML_LAUNCHER_APP_PATH = "{}/{}".format(
2320 os.path.dirname(os.path.realpath(__file__)),
24LOCAL_QML_LAUNCHER_APP_PATH = "%s/%s" % (os.path.dirname(os.path.realpath(__file__)), '../../../../tools/qml-launcher/unity-webapps-qml-launcher')21 '../../../../tools/qml-launcher/unity-webapps-qml-launcher')
22
25INSTALLED_QML_LAUNCHER_APP_PATH = 'unity-webapps-qml-launcher'23INSTALLED_QML_LAUNCHER_APP_PATH = 'unity-webapps-qml-launcher'
2624
27# TODO create __init__.py.in25# TODO create __init__.py.in
28LOCAL_BROWSER_CONTAINER_PATH = "%s/%s" % (os.path.dirname(os.path.realpath(__file__)), '../../qml/FullWebViewApp.qml')26LOCAL_BROWSER_CONTAINER_PATH = "{}/{}".format(
29INSTALLED_BROWSER_CONTAINER_PATH = '/usr/share/unity-webapps-qml/autopilot-tests/qml/FullWebViewApp.qml'27 os.path.dirname(os.path.realpath(__file__)),
28 '../../qml/FullWebViewApp.qml')
29
30INSTALLED_BROWSER_CONTAINER_PATH = \
31 '/usr/share/unity-webapps-qml/autopilot-tests/qml/FullWebViewApp.qml'
3032
31BASE_URL = ''33BASE_URL = ''
3234
33class UnityWebappsTestCaseBase(UnityTestCase):
3435
36class UnityWebappsTestCaseBase(AutopilotTestCase):
35 def setUp(self):37 def setUp(self):
36 super(UnityWebappsTestCaseBase, self).setUp()38 super(UnityWebappsTestCaseBase, self).setUp()
37 self.use_oxide = False39 self.use_oxide = False
@@ -52,17 +54,18 @@
52 return LOCAL_QML_LAUNCHER_APP_PATH54 return LOCAL_QML_LAUNCHER_APP_PATH
53 return INSTALLED_QML_LAUNCHER_APP_PATH55 return INSTALLED_QML_LAUNCHER_APP_PATH
5456
55 def get_launch_params(self,57 def get_launch_params(
56 url,58 self,
57 webapp_name='unitywebappsqmllauncher',59 url,
58 webapp_search_path="",60 webapp_name='unitywebappsqmllauncher',
59 webapp_homepage="",61 webapp_search_path="",
60 use_oxide=False,62 webapp_homepage="",
61 extra_params=[]):63 use_oxide=False,
64 extra_params=[]):
62 base_params = ['--qml=' + self.get_qml_browser_container_path(),65 base_params = ['--qml=' + self.get_qml_browser_container_path(),
63 '--app-id=' + webapp_name,66 '--app-id=' + webapp_name,
64 '--webappName=' + webapp_name,67 '--webappName=' + webapp_name,
65 '--webappSearchPath=' + webapp_search_path]68 '--webappSearchPath=' + webapp_search_path]
6669
67 if len(webapp_homepage) != 0:70 if len(webapp_homepage) != 0:
68 base_params.append('--webappHomepage=' + webapp_homepage)71 base_params.append('--webappHomepage=' + webapp_homepage)
@@ -75,8 +78,10 @@
7578
76 if os.path.exists(LOCAL_QML_LAUNCHER_APP_PATH):79 if os.path.exists(LOCAL_QML_LAUNCHER_APP_PATH):
77 # we are local80 # we are local
78 base_params.append('--import=' + os.path.join (os.path.dirname(os.path.realpath(__file__)),81 base_params.append(
79 '../../../../src'))82 '--import={}'.format(
83 os.path.join(os.path.dirname(os.path.realpath(__file__))),
84 '../../../../src'))
8085
81 base_params += extra_params86 base_params += extra_params
8287
@@ -86,18 +91,25 @@
86 self.assertThat(os.path.exists(html_filepath), Equals(True))91 self.assertThat(os.path.exists(html_filepath), Equals(True))
87 url = self.create_file_url(html_filepath)92 url = self.create_file_url(html_filepath)
8893
89 self.launch_application(self.get_launch_params(url, 'unitywebappsqmllauncher', '', '', False, extra_params))94 self.launch_application(
95 self.get_launch_params(
96 url,
97 'unitywebappsqmllauncher',
98 '',
99 '',
100 False,
101 extra_params))
90 self.assert_url_eventually_loaded(url)102 self.assert_url_eventually_loaded(url)
91103
92 def launch_application(self, args):104 def launch_application(self, args):
93 print 'Launching test with params:', args, "with", self.get_qml_launcher_path()105 self.app = self.launch_test_application(
94106 self.get_qml_launcher_path(),
95 self.app = self.launch_test_application(self.get_qml_launcher_path(),
96 *args,107 *args,
97 app_type='qt')108 app_type='qt')
98109
99 self.webviewContainer = self.get_webviewContainer()110 self.webviewContainer = self.get_webviewContainer()
100 self.watcher = self.webviewContainer.watch_signal('resultUpdated(QString)')111 self.watcher = self.webviewContainer.watch_signal(
112 'resultUpdated(QString)')
101113
102 def pick_app_launcher(self, app_path):114 def pick_app_launcher(self, app_path):
103 # force Qt app introspection:115 # force Qt app introspection:
@@ -121,11 +133,8 @@
121133
122 def eval_expression_in_page_unsafe(self, expr):134 def eval_expression_in_page_unsafe(self, expr):
123 webview = self.get_webviewContainer()135 webview = self.get_webviewContainer()
124 prev_emissions = self.watcher.num_emissions136 return webview.slots.evalInPageUnsafe(expr)
125 webview.slots.evalInPageUnsafe(expr)137
126 self.assertThat(lambda: self.watcher.num_emissions, Eventually(GreaterThan(prev_emissions)))
127 results = json.loads(webview.get_signal_emissions('resultUpdated(QString)')[-1][0])
128 return results.has_key('result') and results['result'] or None
129138
130class WebappsTestCaseBaseWithLocalHttpContentBase(UnityWebappsTestCaseBase):139class WebappsTestCaseBaseWithLocalHttpContentBase(UnityWebappsTestCaseBase):
131 def setUp(self):140 def setUp(self):
@@ -136,5 +145,11 @@
136145
137 def launch_with_webapp(self, name, webapp_search_path, use_oxide=False):146 def launch_with_webapp(self, name, webapp_search_path, use_oxide=False):
138 self.use_oxide = use_oxide147 self.use_oxide = use_oxide
139 self.launch_application(self.get_launch_params("", name, webapp_search_path, self.base_url, use_oxide))148 self.launch_application(
149 self.get_launch_params(
150 "",
151 name,
152 webapp_search_path,
153 self.base_url,
154 use_oxide))
140 self.assert_url_eventually_loaded(self.base_url)155 self.assert_url_eventually_loaded(self.base_url)
141156
=== modified file 'tests/autopilot/unity_webapps_qml/tests/fake_servers.py'
--- tests/autopilot/unity_webapps_qml/tests/fake_servers.py 2014-07-08 19:27:21 +0000
+++ tests/autopilot/unity_webapps_qml/tests/fake_servers.py 2014-11-22 00:43:58 +0000
@@ -15,12 +15,12 @@
1515
16""" Autopilot tests for the unity_webapps_qml package """16""" Autopilot tests for the unity_webapps_qml package """
1717
18import BaseHTTPServer18import http.server as http
19import logging19import logging
20import threading20import threading
2121
2222
23class RequestHandler(BaseHTTPServer.BaseHTTPRequestHandler):23class RequestHandler(http.BaseHTTPRequestHandler):
24 def serve_content(self, content, mime_type='text/html'):24 def serve_content(self, content, mime_type='text/html'):
25 self.send_header('Content-type', mime_type)25 self.send_header('Content-type', mime_type)
26 self.end_headers()26 self.end_headers()
@@ -51,7 +51,7 @@
51class WebappsQmlContentHttpServer(object):51class WebappsQmlContentHttpServer(object):
52 def __init__(self):52 def __init__(self):
53 super(WebappsQmlContentHttpServer, self).__init__()53 super(WebappsQmlContentHttpServer, self).__init__()
54 self.server = BaseHTTPServer.HTTPServer(("", 0), RequestHandler)54 self.server = http.HTTPServer(("", 0), RequestHandler)
55 self.server.allow_reuse_address = True55 self.server.allow_reuse_address = True
56 self.server_thread = threading.Thread(target=self.server.serve_forever)56 self.server_thread = threading.Thread(target=self.server.serve_forever)
57 self.server_thread.start()57 self.server_thread.start()
5858
=== modified file 'tests/autopilot/unity_webapps_qml/tests/test_callbackDispatch.py'
--- tests/autopilot/unity_webapps_qml/tests/test_callbackDispatch.py 2014-07-11 17:13:18 +0000
+++ tests/autopilot/unity_webapps_qml/tests/test_callbackDispatch.py 2014-11-22 00:43:58 +0000
@@ -7,22 +7,37 @@
77
8from __future__ import absolute_import8from __future__ import absolute_import
99
10import time
11import os10import os
1211
13from testtools.matchers import Equals, GreaterThan, NotEquals12from testtools.matchers import Equals
14from autopilot.matchers import Eventually13from autopilot.matchers import Eventually
1514
16from unity_webapps_qml.tests import UnityWebappsTestCaseBase15from unity_webapps_qml.tests import UnityWebappsTestCaseBase
1716
18LOCAL_HTML_TEST_FILE = "%s/%s" % (os.path.dirname(os.path.realpath(__file__)), '../../html/test_webapps_callback_dispatch.html')17LOCAL_HTML_TEST_FILE = "{}/{}".format(
19INSTALLED_HTML_TEST_FILE = '/usr/share/unity-webapps-qml/autopilot-tests/html/test_webapps_callback_dispatch.html'18 os.path.dirname(os.path.realpath(__file__)),
2019 '../../html/test_webapps_callback_dispatch.html')
21LOCAL_JS_TEST_FILE = "%s/%s" % (os.path.dirname(os.path.realpath(__file__)), '../../html/test_webapps_callback_dispatch_api.js')20
22INSTALLED_JS_TEST_FILE = '/usr/share/unity-webapps-qml/autopilot-tests/html/test_webapps_callback_dispatch_api.js'21INSTALLED_HTML_TEST_FILE = \
2322 '/usr/share/unity-webapps-qml/autopilot-tests/' \
24LOCAL_QML_BACKEND_TEST_FILE = "%s/%s" % (os.path.dirname(os.path.realpath(__file__)), '../../qml/test_webapps_callback_dispatch_api.qml')23 'html/test_webapps_callback_dispatch.html'
25INSTALLED_QML_BACKEND_TEST_FILE = '/usr/share/unity-webapps-qml/autopilot-tests/qml/test_webapps_callback_dispatch_api.qml'24
25LOCAL_JS_TEST_FILE = "{}/{}".format(
26 os.path.dirname(os.path.realpath(__file__)),
27 '../../html/test_webapps_callback_dispatch_api.js')
28
29INSTALLED_JS_TEST_FILE = \
30 '/usr/share/unity-webapps-qml/autopilot-tests/' \
31 'html/test_webapps_callback_dispatch_api.js'
32
33LOCAL_QML_BACKEND_TEST_FILE = "{}/{}".format(
34 os.path.dirname(os.path.realpath(__file__)),
35 '../../qml/test_webapps_callback_dispatch_api.qml')
36
37INSTALLED_QML_BACKEND_TEST_FILE = \
38 '/usr/share/unity-webapps-qml/autopilot-tests/' \
39 'qml/test_webapps_callback_dispatch_api.qml'
40
2641
27class WebappsCallbackDispatchTestCaseBase(UnityWebappsTestCaseBase):42class WebappsCallbackDispatchTestCaseBase(UnityWebappsTestCaseBase):
28 def setUp(self):43 def setUp(self):
@@ -43,7 +58,6 @@
43 return INSTALLED_JS_TEST_FILE58 return INSTALLED_JS_TEST_FILE
4459
45 def get_qml_test_file(self):60 def get_qml_test_file(self):
46 print LOCAL_QML_BACKEND_TEST_FILE
47 if os.path.exists(LOCAL_QML_BACKEND_TEST_FILE):61 if os.path.exists(LOCAL_QML_BACKEND_TEST_FILE):
48 return os.path.abspath(LOCAL_QML_BACKEND_TEST_FILE)62 return os.path.abspath(LOCAL_QML_BACKEND_TEST_FILE)
49 return INSTALLED_QML_BACKEND_TEST_FILE63 return INSTALLED_QML_BACKEND_TEST_FILE
@@ -55,6 +69,6 @@
55 Eventually(Equals(True)))69 Eventually(Equals(True)))
5670
57 self.assertThat(71 self.assertThat(
58 lambda: self.eval_expression_in_page_unsafe("return document.getElementById('content').innerHTML;"),72 lambda: self.eval_expression_in_page_unsafe(
73 "return document.getElementById('content').innerHTML;"),
59 Eventually(Equals('callback-loop-count-reached')))74 Eventually(Equals('callback-loop-count-reached')))
60
6175
=== removed file 'tests/autopilot/unity_webapps_qml/tests/test_hud.py'
--- tests/autopilot/unity_webapps_qml/tests/test_hud.py 2014-04-22 15:40:04 +0000
+++ tests/autopilot/unity_webapps_qml/tests/test_hud.py 1970-01-01 00:00:00 +0000
@@ -1,81 +0,0 @@
1#!/usr/bin/env python
2# Copyright 2013 Canonical
3#
4# This program is free software: you can redistribute it and/or modify it
5# under the terms of the GNU General Public License version 3, as published
6# by the Free Software Foundation.
7
8import os
9import time
10
11from testtools.matchers import Equals, GreaterThan, NotEquals
12from autopilot.matchers import Eventually
13
14from autopilot import platform
15
16from unity.emulators.icons import HudLauncherIcon
17from unity.emulators import ensure_unity_is_running
18
19from unity_webapps_qml.tests import UnityWebappsTestCaseBase
20
21class UnityWebappsHudTestCase(UnityWebappsTestCaseBase):
22 LOCAL_HTML_TEST_FILE = "%s/%s" % (os.path.dirname(os.path.realpath(__file__)), '../../html/test_webapps_hud.html')
23 INSTALLED_HTML_TEST_FILE = '/usr/share/unity-webapps-qml/autopilot-tests/html/test_webapps_hud.html'
24
25 def get_html_test_file(self):
26 if os.path.exists(self.LOCAL_HTML_TEST_FILE):
27 return os.path.abspath(self.LOCAL_HTML_TEST_FILE)
28 return self.INSTALLED_HTML_TEST_FILE
29
30 def setUp(self):
31 super(UnityWebappsHudTestCase, self).setUp()
32 # On Touch the dbus unity if does is not exposed
33 if platform.model() == 'Desktop':
34 ensure_unity_is_running()
35 self.launch_with_html_filepath(self.get_html_test_file())
36
37 def test_addAction(self):
38 self.assertThat(lambda: self.eval_expression_in_page_unsafe("return document.getElementById('status').innerHTML;"), Eventually(Equals('actionadded')))
39
40 self.unity.hud.ensure_visible()
41 self.addCleanup(self.unity.hud.ensure_hidden)
42
43 self.keyboard.type("Hello")
44 self.keyboard.press_and_release("Enter")
45
46 self.assertThat(lambda: self.eval_expression_in_page_unsafe("return document.getElementById('content').style.display;"), Eventually(Equals('none')))
47
48 def test_clearAction(self):
49 self.assertThat(lambda: self.eval_expression_in_page_unsafe("return document.getElementById('status').innerHTML;"), Eventually(Equals('actionadded')))
50 expr = """
51 var e = new CustomEvent ("unity-webapps-do-call", {"detail": JSON.stringify({"name": 'clearAction', 'args': ['Hello']})});
52 document.dispatchEvent (e);
53 return true;
54 """
55 self.eval_expression_in_page_unsafe(expr)
56
57 self.unity.hud.ensure_visible()
58 self.addCleanup(self.unity.hud.ensure_hidden)
59
60 self.keyboard.type("Hello")
61 self.keyboard.press_and_release("Enter")
62 self.assertThat(self.eval_expression_in_page_unsafe("return document.getElementById('content').style.display;"), NotEquals('none'))
63
64 def test_clearActions(self):
65 self.assertThat(lambda: self.eval_expression_in_page_unsafe("return document.getElementById('status').innerHTML;"), Eventually(Equals('actionadded')))
66 expr = """
67 var e = new CustomEvent ("unity-webapps-do-call", {"detail": JSON.stringify({"name": 'clearActions', 'args': []})});
68 document.dispatchEvent (e);
69 return true;
70 """
71
72 self.eval_expression_in_page_unsafe(expr)
73
74 actions = ['Hello', 'Another action']
75 for action in actions:
76 self.unity.hud.ensure_visible()
77 self.addCleanup(self.unity.hud.ensure_hidden)
78 self.keyboard.type(action)
79 self.keyboard.press_and_release("Enter")
80
81 self.assertThat(self.eval_expression_in_page_unsafe("return document.getElementById('content').style.display;"), NotEquals('none'))
820
=== modified file 'tests/autopilot/unity_webapps_qml/tests/test_injectedOnWebapp.py'
--- tests/autopilot/unity_webapps_qml/tests/test_injectedOnWebapp.py 2014-04-22 15:40:04 +0000
+++ tests/autopilot/unity_webapps_qml/tests/test_injectedOnWebapp.py 2014-11-22 00:43:58 +0000
@@ -7,51 +7,74 @@
77
8from __future__ import absolute_import8from __future__ import absolute_import
99
10import time
11import os10import os
1211
13from testtools.matchers import Equals, GreaterThan, NotEquals12from testtools.matchers import Equals
14from autopilot.matchers import Eventually13from autopilot.matchers import Eventually
1514
16from unity_webapps_qml.tests import UnityWebappsTestCaseBase15from unity_webapps_qml.tests import UnityWebappsTestCaseBase
1716
17LOCAL_HTML_TEST_FILE = "{}/{}".format(
18 os.path.dirname(os.path.realpath(__file__)),
19 '../../html/test_webapps_api_injected.html')
20
21INSTALLED_HTML_TEST_FILE = \
22 '/usr/share/unity-webapps-qml/' \
23 'autopilot-tests/html/test_webapps_api_injected.html'
24
25
18class UnityWebappsApiInjectedTestCaseBase(UnityWebappsTestCaseBase):26class UnityWebappsApiInjectedTestCaseBase(UnityWebappsTestCaseBase):
19 LOCAL_HTML_TEST_FILE = "%s/%s" % (os.path.dirname(os.path.realpath(__file__)), '../../html/test_webapps_api_injected.html')
20
21 INSTALLED_HTML_TEST_FILE = '/usr/share/unity-webapps-qml/autopilot-tests/html/test_webapps_api_injected.html'
22
23 def get_html_test_file(self):27 def get_html_test_file(self):
24 if os.path.exists(self.LOCAL_HTML_TEST_FILE):28 if os.path.exists(LOCAL_HTML_TEST_FILE):
25 return os.path.abspath(self.LOCAL_HTML_TEST_FILE)29 return os.path.abspath(LOCAL_HTML_TEST_FILE)
26 return self.INSTALLED_HTML_TEST_FILE30 return INSTALLED_HTML_TEST_FILE
2731
28 def setUp(self):32 def setUp(self):
29 super(UnityWebappsApiInjectedTestCaseBase, self).setUp()33 super(UnityWebappsApiInjectedTestCaseBase, self).setUp()
30 self.launch_with_html_filepath(self.get_html_test_file())34 self.launch_with_html_filepath(self.get_html_test_file())
3135
32 def test_getUnityObjectFound(self):36 def test_getUnityObjectFound(self):
33 self.assertThat(lambda: self.eval_expression_in_page_unsafe('return window.external.getUnityObject("1.0") != null'), Eventually(Equals(True)))37 self.assertThat(
38 lambda: self.eval_expression_in_page_unsafe(
39 'return window.external.getUnityObject("1.0") != null'),
40 Eventually(Equals(True)))
3441
35 def test_actionsApiFound(self):42 def test_actionsApiFound(self):
36 self.assertThat(lambda: self.eval_expression_in_page_unsafe('return window.external.getUnityObject("1.0") != null;'), Eventually(Equals(True)))43 self.assertThat(
44 lambda: self.eval_expression_in_page_unsafe(
45 'return window.external.getUnityObject("1.0") != null;'),
46 Eventually(Equals(True)))
3747
38 expression = """48 expression = """
39 var unity = window.external.getUnityObject("1.0");49 var unity = window.external.getUnityObject("1.0");
40 return unity.addAction != null && unity.clearActions != null && unity.clearAction != null;50 return unity.addAction != null &&
51 unity.clearActions != null &&
52 unity.clearAction != null;
41 """53 """
42 self.assertThat(lambda: self.eval_expression_in_page_unsafe(expression), Eventually(Equals(True)))54 self.assertThat(
55 lambda: self.eval_expression_in_page_unsafe(expression),
56 Eventually(Equals(True)))
4357
44 def test_notificationApiFound(self):58 def test_notificationApiFound(self):
45 self.assertThat(lambda: self.eval_expression_in_page_unsafe('return window.external.getUnityObject("1.0") != null;'), Eventually(Equals(True)))59 self.assertThat(
60 lambda: self.eval_expression_in_page_unsafe(
61 'return window.external.getUnityObject("1.0") != null;'),
62 Eventually(Equals(True)))
4663
47 expression = """64 expression = """
48 var unity = window.external.getUnityObject("1.0");65 var unity = window.external.getUnityObject("1.0");
49 return unity.Notification != null && unity.Notification.showNotification != null;66 return unity.Notification != null &&
67 unity.Notification.showNotification != null;
50 """68 """
51 self.assertThat(lambda: self.eval_expression_in_page_unsafe(expression), Eventually(Equals(True)))69 self.assertThat(
70 lambda: self.eval_expression_in_page_unsafe(expression),
71 Eventually(Equals(True)))
5272
53 def test_messagingIndicatorApiFound(self):73 def test_messagingIndicatorApiFound(self):
54 self.assertThat(lambda: self.eval_expression_in_page_unsafe('return window.external.getUnityObject("1.0") != null;'), Eventually(Equals(True)))74 self.assertThat(
75 lambda: self.eval_expression_in_page_unsafe(
76 'return window.external.getUnityObject("1.0") != null;'),
77 Eventually(Equals(True)))
5578
56 expression = """79 expression = """
57 var unity = window.external.getUnityObject("1.0");80 var unity = window.external.getUnityObject("1.0");
@@ -61,15 +84,21 @@
61 unity.MessagingIndicator.clearIndicators != null &&84 unity.MessagingIndicator.clearIndicators != null &&
62 unity.MessagingIndicator.showIndicator != null;85 unity.MessagingIndicator.showIndicator != null;
63 """86 """
64 self.assertThat(lambda: self.eval_expression_in_page_unsafe(expression), Eventually(Equals(True)))87 self.assertThat(
88 lambda: self.eval_expression_in_page_unsafe(expression),
89 Eventually(Equals(True)))
6590
66 def test_ubuntuReadyEventSent(self):91 def test_ubuntuReadyEventSent(self):
67 self.assertThat(lambda: self.eval_expression_in_page_unsafe('return window.external.getUnityObject("1.0") != null;'), Eventually(Equals(True)))92 self.assertThat(
93 lambda: self.eval_expression_in_page_unsafe(
94 'return window.external.getUnityObject("1.0") != null;'),
95 Eventually(Equals(True)))
6896
69 expression = """97 expression = """
70 var api_ready_count = window.localStorage['ubuntu-webapps-api-ready-key'];98 var api_ready_count =
99 window.localStorage['ubuntu-webapps-api-ready-key'];
71 return api_ready_count != null && api_ready_count > 0;100 return api_ready_count != null && api_ready_count > 0;
72 """101 """
73 self.assertThat(lambda: self.eval_expression_in_page_unsafe(expression), Eventually(Equals(True)))102 self.assertThat(
74103 lambda: self.eval_expression_in_page_unsafe(expression),
75104 Eventually(Equals(True)))
76105
=== modified file 'tests/autopilot/unity_webapps_qml/tests/test_installedWebapp.py'
--- tests/autopilot/unity_webapps_qml/tests/test_installedWebapp.py 2014-07-16 20:15:17 +0000
+++ tests/autopilot/unity_webapps_qml/tests/test_installedWebapp.py 2014-11-22 00:43:58 +0000
@@ -7,18 +7,23 @@
77
8from __future__ import absolute_import8from __future__ import absolute_import
99
10import time
11import os10import os
1211
13from testtools.matchers import Equals, GreaterThan, NotEquals12from testtools.matchers import Equals
14from autopilot.matchers import Eventually13from autopilot.matchers import Eventually
1514
16from unity_webapps_qml.tests import WebappsTestCaseBaseWithLocalHttpContentBase15from unity_webapps_qml.tests import WebappsTestCaseBaseWithLocalHttpContentBase
1716
18LOCAL_HTML_TEST_FILE = "%s/%s" % (os.path.dirname(os.path.realpath(__file__)), '../../data')17LOCAL_HTML_TEST_FILE = "{}/{}".format(
19INSTALLED_HTML_TEST_FILE = '/usr/share/unity-webapps-qml/autopilot-tests/data'18 os.path.dirname(os.path.realpath(__file__)),
2019 '../../data')
21class InstalledWebappsTestCaseBase(WebappsTestCaseBaseWithLocalHttpContentBase):20
21INSTALLED_HTML_TEST_FILE = \
22 '/usr/share/unity-webapps-qml/autopilot-tests/data'
23
24
25class InstalledWebappsTestCaseBase(
26 WebappsTestCaseBaseWithLocalHttpContentBase):
22 def setUp(self):27 def setUp(self):
23 super(InstalledWebappsTestCaseBase, self).setUp()28 super(InstalledWebappsTestCaseBase, self).setUp()
2429
@@ -30,34 +35,60 @@
30 def test_normalWebappFound(self):35 def test_normalWebappFound(self):
31 self.launch_with_webapp('Normal', self.get_webapp_install_folder())36 self.launch_with_webapp('Normal', self.get_webapp_install_folder())
3237
33 self.assertThat(lambda: self.eval_expression_in_page_unsafe('return window.external.getUnityObject("1.0") != null;'), Eventually(Equals(True)))38 self.assertThat(
39 lambda: self.eval_expression_in_page_unsafe(
40 'return window.external.getUnityObject("1.0") != null;'),
41 Eventually(Equals(True)))
3442
35 expression = """43 expression = """
36 var contentElement = document.getElementById('content');44 var contentElement = document.getElementById('content');
37 return contentElement.innerHTML;45 return contentElement.innerHTML;
38 """46 """
39 self.assertThat(lambda: self.eval_expression_in_page_unsafe(expression), Eventually(Equals("WebApp Script Injected")))47 self.assertThat(
48 lambda: self.eval_expression_in_page_unsafe(expression),
49 Eventually(Equals("WebApp Script Injected")))
4050
41 def test_webappWithUAOverrideFound(self):51 def test_webappWithUAOverrideFound(self):
42 self.launch_with_webapp('AlteredUAWebapp', self.get_webapp_install_folder(), True)52 self.launch_with_webapp(
43 self.assertThat(lambda: self.eval_expression_in_page_unsafe('return navigator.userAgent;'), Eventually(Equals("My Override")))53 'AlteredUAWebapp',
54 self.get_webapp_install_folder(), True)
55 self.assertThat(
56 lambda: self.eval_expression_in_page_unsafe(
57 'return navigator.userAgent;'),
58 Eventually(Equals("My Override")))
4459
45 def test_webappFoundWithSpecialWebappPropertiesFile(self):60 def test_webappFoundWithSpecialWebappPropertiesFile(self):
46 self.launch_with_webapp('ExtendedWebappProperties', self.get_webapp_install_folder() + '/all-in-same-folder')61 self.launch_with_webapp(
62 'ExtendedWebappProperties',
63 self.get_webapp_install_folder() + '/all-in-same-folder')
4764
48 self.assertThat(lambda: self.eval_expression_in_page_unsafe('return window.external.getUnityObject("1.0") != null;'), Eventually(Equals(True)))65 self.assertThat(
66 lambda: self.eval_expression_in_page_unsafe(
67 'return window.external.getUnityObject("1.0") != null;'),
68 Eventually(Equals(True)))
4969
50 expression = """70 expression = """
51 var contentElement = document.getElementById('content');71 var contentElement = document.getElementById('content');
52 return contentElement.innerHTML;72 return contentElement.innerHTML;
53 """73 """
54 self.assertThat(lambda: self.eval_expression_in_page_unsafe(expression), Eventually(Equals("WebApp Script Injected")))74 self.assertThat(
75 lambda: self.eval_expression_in_page_unsafe(expression),
76 Eventually(Equals("WebApp Script Injected")))
5577
56 def test_webappPropertiesFileWithUA(self):78 def test_webappPropertiesFileWithUA(self):
57 self.launch_with_webapp('ExtendedWebappProperties', self.get_webapp_install_folder() + '/all-in-same-folder', True)79 self.launch_with_webapp(
58 self.assertThat(lambda: self.eval_expression_in_page_unsafe('return navigator.userAgent;'), Eventually(Equals("My Override")))80 'ExtendedWebappProperties',
81 self.get_webapp_install_folder() + '/all-in-same-folder', True)
82 self.assertThat(
83 lambda: self.eval_expression_in_page_unsafe(
84 'return navigator.userAgent;'),
85 Eventually(Equals("My Override")))
5986
60 def test_webappPropertiesNameUpdated(self):87 def test_webappPropertiesNameUpdated(self):
61 self.launch_with_webapp('', self.get_webapp_install_folder() + '/all-in-same-folder')88 self.launch_with_webapp(
62 self.assertThat(lambda: self.eval_expression_in_page_unsafe('return window.external.getUnityObject("1.0") != null;'), Eventually(Equals(True)))89 '',
6390 self.get_webapp_install_folder() + '/all-in-same-folder')
91 self.assertThat(
92 lambda: self.eval_expression_in_page_unsafe(
93 'return window.external.getUnityObject("1.0") != null;'),
94 Eventually(Equals(True)))
6495
=== modified file 'tests/autopilot/unity_webapps_qml/tests/test_launcher.py'
--- tests/autopilot/unity_webapps_qml/tests/test_launcher.py 2013-09-23 19:59:29 +0000
+++ tests/autopilot/unity_webapps_qml/tests/test_launcher.py 2014-11-22 00:43:58 +0000
@@ -6,78 +6,102 @@
6# by the Free Software Foundation.6# by the Free Software Foundation.
77
8import os8import os
9import time9
1010from gi.repository import Unity
11from gi.repository import Unity, GObject11
1212from testtools.matchers import Equals, NotEquals
13from testtools.matchers import Equals, GreaterThan, NotEquals
14from testtools import skipUnless13from testtools import skipUnless
1514
16from autopilot import platform15from autopilot import platform
17from autopilot.matchers import Eventually16from autopilot.matchers import Eventually
1817
19from unity.emulators.icons import HudLauncherIcon
20from unity.emulators import ensure_unity_is_running
21
22from unity_webapps_qml.tests import UnityWebappsTestCaseBase18from unity_webapps_qml.tests import UnityWebappsTestCaseBase
2319
20LOCAL_HTML_TEST_FILE = "{}/{}".format(
21 os.path.dirname(os.path.realpath(__file__)),
22 '../../html/test_webapps_launcher.html')
23
24INSTALLED_HTML_TEST_FILE = \
25 '/usr/share/unity-webapps-qml/' \
26 'autopilot-tests/html/test_webapps_launcher.html'
27
28
24class UnityWebappsLauncherTestCase(UnityWebappsTestCaseBase):29class UnityWebappsLauncherTestCase(UnityWebappsTestCaseBase):
25 LOCAL_HTML_TEST_FILE = "%s/%s" % (os.path.dirname(os.path.realpath(__file__)), '../../html/test_webapps_launcher.html')
26 INSTALLED_HTML_TEST_FILE = '/usr/share/unity-webapps-qml/autopilot-tests/html/test_webapps_launcher.html'
27
28 def get_html_test_file(self):30 def get_html_test_file(self):
29 if os.path.exists(self.LOCAL_HTML_TEST_FILE):31 if os.path.exists(LOCAL_HTML_TEST_FILE):
30 return os.path.abspath(self.LOCAL_HTML_TEST_FILE)32 return os.path.abspath(LOCAL_HTML_TEST_FILE)
31 return self.INSTALLED_HTML_TEST_FILE33 return INSTALLED_HTML_TEST_FILE
3234
33 def setUp(self):35 def setUp(self):
34 super(UnityWebappsLauncherTestCase, self).setUp()36 super(UnityWebappsLauncherTestCase, self).setUp()
35 # On Touch the dbus unity if does is not exposed
36 if platform.model() == 'Desktop':
37 ensure_unity_is_running()
38 self.launch_with_html_filepath(self.get_html_test_file())37 self.launch_with_html_filepath(self.get_html_test_file())
3938
40 @skipUnless(platform.model() == 'Desktop', "Only runs on the Desktop")39 @skipUnless(platform.model() == 'Desktop', "Only runs on the Desktop")
41 def test_checkCounts(self):40 def test_checkCounts(self):
42 self.assertThat(lambda: self.eval_expression_in_page_unsafe("return document.getElementById('status').innerHTML;"), Eventually(Equals('launcher-updated')))41 self.assertThat(
42 lambda: self.eval_expression_in_page_unsafe(
43 "return document.getElementById('status').innerHTML;"),
44 Eventually(Equals('launcher-updated')))
4345
44 launcher_icon = self.unity.launcher.model.get_icon(desktop_id='unitywebappsqmllauncher.desktop')46 launcher_icon = self.unity.launcher.model.get_icon(
47 desktop_id='unitywebappsqmllauncher.desktop')
45 self.assertThat(launcher_icon, NotEquals(None))48 self.assertThat(launcher_icon, NotEquals(None))
4649
47 expr = """50 expr = """
48 document.addEventListener('unity-webapps-do-call-response', function(e) {51 document.addEventListener('unity-webapps-do-call-response',
52 function(e) {
49 var response = e.detail;53 var response = e.detail;
50 document.getElementById('status').innerHTML = '' + e.detail;54 document.getElementById('status').innerHTML = '' + e.detail;
51 });55 });
5256
53 var e = new CustomEvent ("unity-webapps-do-call", {"detail": JSON.stringify({"name": 'Launcher.__get', 'with_callback': true, 'args': ['count']})});57 var e = new CustomEvent (
58 "unity-webapps-do-call",
59 {"detail": JSON.stringify(
60 {"name": 'Launcher.__get',
61 'with_callback': true,
62 'args': ['count']})});
54 document.dispatchEvent (e);63 document.dispatchEvent (e);
55 return true;64 return true;
56 """65 """
57 self.eval_expression_in_page_unsafe(expr)66 self.eval_expression_in_page_unsafe(expr)
5867
59 self.assertThat(lambda: self.eval_expression_in_page_unsafe("return document.getElementById('status').innerHTML;"), Eventually(Equals('42')))68 self.assertThat(
69 lambda: self.eval_expression_in_page_unsafe(
70 "return document.getElementById('status').innerHTML;"),
71 Eventually(Equals('42')))
6072
61 # self.assertThat(launcher.get_property('progress'), Equals(0.09375))73 # self.assertThat(launcher.get_property('progress'), Equals(0.09375))
6274
63 @skipUnless(platform.model() == 'Desktop', "Only runs on the Desktop")75 @skipUnless(platform.model() == 'Desktop', "Only runs on the Desktop")
64 def test_checkProgress(self):76 def test_checkProgress(self):
65 self.assertThat(lambda: self.eval_expression_in_page_unsafe("return document.getElementById('status').innerHTML;"), Eventually(Equals('launcher-updated')))77 self.assertThat(
78 lambda: self.eval_expression_in_page_unsafe(
79 "return document.getElementById('status').innerHTML;"),
80 Eventually(Equals('launcher-updated')))
6681
67 launcher_icon = self.unity.launcher.model.get_icon(desktop_id='unitywebappsqmllauncher.desktop')82 launcher_icon = self.unity.launcher.model.get_icon(
83 desktop_id='unitywebappsqmllauncher.desktop')
68 self.assertThat(launcher_icon, NotEquals(None))84 self.assertThat(launcher_icon, NotEquals(None))
6985
70 expr = """86 expr = """
71 document.addEventListener('unity-webapps-do-call-response', function(e) {87 document.addEventListener(
88 'unity-webapps-do-call-response', function(e) {
72 var response = e.detail;89 var response = e.detail;
73 document.getElementById('status').innerHTML = '' + e.detail;90 document.getElementById('status').innerHTML = '' + e.detail;
74 });91 });
7592
76 var e = new CustomEvent ("unity-webapps-do-call", {"detail": JSON.stringify({"name": 'Launcher.__get', 'with_callback': true, 'args': ['progress']})});93 var e = new CustomEvent (
94 "unity-webapps-do-call",
95 {"detail": JSON.stringify(
96 {"name": 'Launcher.__get',
97 'with_callback': true,
98 'args': ['progress']})});
77 document.dispatchEvent (e);99 document.dispatchEvent (e);
78 return true;100 return true;
79 """101 """
80 self.eval_expression_in_page_unsafe(expr)102 self.eval_expression_in_page_unsafe(expr)
81103
82 self.assertThat(lambda: self.eval_expression_in_page_unsafe("return document.getElementById('status').innerHTML;"), Eventually(Equals('0.09375')))104 self.assertThat(
83105 lambda: self.eval_expression_in_page_unsafe(
106 "return document.getElementById('status').innerHTML;"),
107 Eventually(Equals('0.09375')))
84108
=== modified file 'tests/autopilot/unity_webapps_qml/tests/test_mediaplayer.py'
--- tests/autopilot/unity_webapps_qml/tests/test_mediaplayer.py 2013-09-23 19:59:29 +0000
+++ tests/autopilot/unity_webapps_qml/tests/test_mediaplayer.py 2014-11-22 00:43:58 +0000
@@ -6,106 +6,153 @@
6# by the Free Software Foundation.6# by the Free Software Foundation.
77
8import os8import os
9import time9
1010from gi.repository import Unity
11from gi.repository import Unity, GObject11
1212from testtools.matchers import Equals
13from testtools.matchers import Equals, GreaterThan, NotEquals
14from testtools import skipUnless13from testtools import skipUnless
1514
16from autopilot import platform15from autopilot import platform
17from autopilot.matchers import Eventually16from autopilot.matchers import Eventually
1817
19from unity.emulators import ensure_unity_is_running
20
21from unity_webapps_qml.tests import UnityWebappsTestCaseBase18from unity_webapps_qml.tests import UnityWebappsTestCaseBase
2219
20LOCAL_HTML_TEST_FILE = "{}/{}".format(
21 os.path.dirname(os.path.realpath(__file__)),
22 '../../html/test_webapps_mediaplayer.html')
23
24INSTALLED_HTML_TEST_FILE = \
25 '/usr/share/unity-webapps-qml/' \
26 'autopilot-tests/html/test_webapps_mediaplayer.html'
27
2328
24class UnityWebappsMediaplayerTestCase(UnityWebappsTestCaseBase):29class UnityWebappsMediaplayerTestCase(UnityWebappsTestCaseBase):
25 LOCAL_HTML_TEST_FILE = "%s/%s" % (os.path.dirname(os.path.realpath(__file__)), '../../html/test_webapps_mediaplayer.html')
26 INSTALLED_HTML_TEST_FILE = '/usr/share/unity-webapps-qml/autopilot-tests/html/test_webapps_mediaplayer.html'
27
28 def get_html_test_file(self):30 def get_html_test_file(self):
29 if os.path.exists(self.LOCAL_HTML_TEST_FILE):31 if os.path.exists(LOCAL_HTML_TEST_FILE):
30 return os.path.abspath(self.LOCAL_HTML_TEST_FILE)32 return os.path.abspath(LOCAL_HTML_TEST_FILE)
31 return self.INSTALLED_HTML_TEST_FILE33 return INSTALLED_HTML_TEST_FILE
3234
33 def setUp(self):35 def setUp(self):
34 super(UnityWebappsMediaplayerTestCase, self).setUp()36 super(UnityWebappsMediaplayerTestCase, self).setUp()
35 # On Touch the dbus unity if does is not exposed
36 if platform.model() == 'Desktop':
37 ensure_unity_is_running()
38 self.launch_with_html_filepath(self.get_html_test_file())37 self.launch_with_html_filepath(self.get_html_test_file())
3938
40 @skipUnless(platform.model() == 'Desktop', "Only runs on the Desktop")39 @skipUnless(platform.model() == 'Desktop', "Only runs on the Desktop")
41 def test_checkInitialSetTrack(self):40 def test_checkInitialSetTrack(self):
42 self.assertThat(lambda: self.eval_expression_in_page_unsafe("return document.getElementById('status').innerHTML;"), Eventually(Equals('mediaplayer-updated')))41 self.assertThat(
42 lambda: self.eval_expression_in_page_unsafe(
43 "return document.getElementById('status').innerHTML;"),
44 Eventually(Equals('mediaplayer-updated')))
4345
44 expr = """46 expr = """
45 document.addEventListener('unity-webapps-do-call-response', function(e) {47 document.addEventListener(
48 'unity-webapps-do-call-response',
49 function(e) {
46 var response = e.detail;50 var response = e.detail;
47 document.getElementById('status').innerHTML = '' + e.detail;51 document.getElementById('status').innerHTML = '' + e.detail;
48 });52 });
4953
50 var e = new CustomEvent ("unity-webapps-do-call", {"detail": JSON.stringify({"name": 'MediaPlayer.__get', 'with_callback': true, 'args': ['track']})});54 var e = new CustomEvent (
55 "unity-webapps-do-call",
56 {"detail": JSON.stringify(
57 {"name": 'MediaPlayer.__get',
58 'with_callback': true,
59 'args': ['track']})});
51 document.dispatchEvent (e);60 document.dispatchEvent (e);
52 return true;61 return true;
53 """62 """
54 self.eval_expression_in_page_unsafe(expr)63 self.eval_expression_in_page_unsafe(expr)
5564
56 self.assertThat(lambda: self.eval_expression_in_page_unsafe("return document.getElementById('status').innerHTML;"), Eventually(Equals('TXlBcnRpc3Q=;TXlUaXRsZQ==;TXlBbGJ1bQ==')))65 self.assertThat(
66 lambda: self.eval_expression_in_page_unsafe(
67 "return document.getElementById('status').innerHTML;"),
68 Eventually(Equals('TXlBcnRpc3Q=;TXlUaXRsZQ==;TXlBbGJ1bQ==')))
5769
58 @skipUnless(platform.model() == 'Desktop', "Only runs on the Desktop")70 @skipUnless(platform.model() == 'Desktop', "Only runs on the Desktop")
59 def test_checkInitialSetCanGoNext(self):71 def test_checkInitialSetCanGoNext(self):
60 self.assertThat(lambda: self.eval_expression_in_page_unsafe("return document.getElementById('status').innerHTML;"), Eventually(Equals('mediaplayer-updated')))72 self.assertThat(
73 lambda: self.eval_expression_in_page_unsafe(
74 "return document.getElementById('status').innerHTML;"),
75 Eventually(Equals('mediaplayer-updated')))
6176
62 expr = """77 expr = """
63 document.addEventListener('unity-webapps-do-call-response', function(e) {78 document.addEventListener(
79 'unity-webapps-do-call-response', function(e) {
64 var response = e.detail;80 var response = e.detail;
65 document.getElementById('status').innerHTML = '' + e.detail;81 document.getElementById('status').innerHTML = '' + e.detail;
66 });82 });
6783
68 var e = new CustomEvent ("unity-webapps-do-call", {"detail": JSON.stringify({"name": 'MediaPlayer.__get', 'with_callback': true, 'args': ['can-go-next']})});84 var e = new CustomEvent (
85 "unity-webapps-do-call",
86 {"detail": JSON.stringify(
87 {"name": 'MediaPlayer.__get',
88 'with_callback': true,
89 'args': ['can-go-next']})});
69 document.dispatchEvent (e);90 document.dispatchEvent (e);
70 return true;91 return true;
71 """92 """
72 self.eval_expression_in_page_unsafe(expr)93 self.eval_expression_in_page_unsafe(expr)
7394
74 self.assertThat(lambda: self.eval_expression_in_page_unsafe("return document.getElementById('status').innerHTML;"), Eventually(Equals('true')))95 self.assertThat(
96 lambda: self.eval_expression_in_page_unsafe(
97 "return document.getElementById('status').innerHTML;"),
98 Eventually(Equals('true')))
7599
76 @skipUnless(platform.model() == 'Desktop', "Only runs on the Desktop")100 @skipUnless(platform.model() == 'Desktop', "Only runs on the Desktop")
77 def test_checkInitialSetCanGoPrevious(self):101 def test_checkInitialSetCanGoPrevious(self):
78 self.assertThat(lambda: self.eval_expression_in_page_unsafe("return document.getElementById('status').innerHTML;"), Eventually(Equals('mediaplayer-updated')))102 self.assertThat(
103 lambda: self.eval_expression_in_page_unsafe(
104 "return document.getElementById('status').innerHTML;"),
105 Eventually(Equals('mediaplayer-updated')))
79106
80 expr = """107 expr = """
81 document.addEventListener('unity-webapps-do-call-response', function(e) {108 document.addEventListener('unity-webapps-do-call-response',
109 function(e) {
82 var response = e.detail;110 var response = e.detail;
83 document.getElementById('status').innerHTML = '' + e.detail;111 document.getElementById('status').innerHTML = '' + e.detail;
84 });112 });
85113
86 var e = new CustomEvent ("unity-webapps-do-call", {"detail": JSON.stringify({"name": 'MediaPlayer.__get', 'with_callback': true, 'args': ['can-go-previous']})});114 var e = new CustomEvent (
115 "unity-webapps-do-call",
116 {"detail": JSON.stringify(
117 {"name": 'MediaPlayer.__get',
118 'with_callback': true,
119 'args': ['can-go-previous']})});
87 document.dispatchEvent (e);120 document.dispatchEvent (e);
88 return true;121 return true;
89 """122 """
90 self.eval_expression_in_page_unsafe(expr)123 self.eval_expression_in_page_unsafe(expr)
91124
92 self.assertThat(lambda: self.eval_expression_in_page_unsafe("return document.getElementById('status').innerHTML;"), Eventually(Equals('true')))125 self.assertThat(
126 lambda: self.eval_expression_in_page_unsafe(
127 "return document.getElementById('status').innerHTML;"),
128 Eventually(Equals('true')))
93129
94 @skipUnless(platform.model() == 'Desktop', "Only runs on the Desktop")130 @skipUnless(platform.model() == 'Desktop', "Only runs on the Desktop")
95 def test_checkInitialSetCanPlay(self):131 def test_checkInitialSetCanPlay(self):
96 self.assertThat(lambda: self.eval_expression_in_page_unsafe("return document.getElementById('status').innerHTML;"), Eventually(Equals('mediaplayer-updated')))132 self.assertThat(
133 lambda: self.eval_expression_in_page_unsafe(
134 "return document.getElementById('status').innerHTML;"),
135 Eventually(Equals('mediaplayer-updated')))
97136
98 expr = """137 expr = """
99 document.addEventListener('unity-webapps-do-call-response', function(e) {138 document.addEventListener('unity-webapps-do-call-response',
139 function(e) {
100 var response = e.detail;140 var response = e.detail;
101 document.getElementById('status').innerHTML = '' + e.detail;141 document.getElementById('status').innerHTML = '' + e.detail;
102 });142 });
103143
104 var e = new CustomEvent ("unity-webapps-do-call", {"detail": JSON.stringify({"name": 'MediaPlayer.__get', 'with_callback': true, 'args': ['can-play']})});144 var e = new CustomEvent (
145 "unity-webapps-do-call",
146 {"detail": JSON.stringify(
147 {"name": 'MediaPlayer.__get',
148 'with_callback': true,
149 'args': ['can-play']})});
105 document.dispatchEvent (e);150 document.dispatchEvent (e);
106 return true;151 return true;
107 """152 """
108 self.eval_expression_in_page_unsafe(expr)153 self.eval_expression_in_page_unsafe(expr)
109154
110 self.assertThat(lambda: self.eval_expression_in_page_unsafe("return document.getElementById('status').innerHTML;"), Eventually(Equals('true')))155 self.assertThat(
111156 lambda: self.eval_expression_in_page_unsafe(
157 "return document.getElementById('status').innerHTML;"),
158 Eventually(Equals('true')))
112159
=== modified file 'tools/qml-launcher/qml-launcher.cpp'
--- tools/qml-launcher/qml-launcher.cpp 2014-07-14 19:01:17 +0000
+++ tools/qml-launcher/qml-launcher.cpp 2014-11-22 00:43:58 +0000
@@ -68,7 +68,6 @@
68 const QString QML_FILE_IMPORT_ARG_HEADER = "--import=";68 const QString QML_FILE_IMPORT_ARG_HEADER = "--import=";
69 const QString QML_APP_ID_ARG_HEADER = "--app-id=";69 const QString QML_APP_ID_ARG_HEADER = "--app-id=";
70 const QString QML_INSPECTOR_ARG_HEADER = "--inspector=";70 const QString QML_INSPECTOR_ARG_HEADER = "--inspector=";
71 const QString QML_USE_OXIDE_ARG_HEADER = "--useOxide";
72 const QString ARG_HEADER = "--";71 const QString ARG_HEADER = "--";
73 const QString VALUE_HEADER = "=";72 const QString VALUE_HEADER = "=";
74 QHash<QString, QString> properties;73 QHash<QString, QString> properties;
@@ -76,7 +75,6 @@
76 QString appid;75 QString appid;
77 QString importPath;76 QString importPath;
78 QString inspector;77 QString inspector;
79 bool useOxide = false;
80 bool maximized = false;78 bool maximized = false;
8179
82 Q_FOREACH(QString argument, app.arguments())80 Q_FOREACH(QString argument, app.arguments())
@@ -101,11 +99,6 @@
101 inspector = argument.right(argument.count() - QML_INSPECTOR_ARG_HEADER.count());99 inspector = argument.right(argument.count() - QML_INSPECTOR_ARG_HEADER.count());
102 }100 }
103 else101 else
104 if (argument.contains(QML_USE_OXIDE_ARG_HEADER))
105 {
106 useOxide = true;
107 }
108 else
109 if (argument.contains(QML_MAXIMIZED_ARG))102 if (argument.contains(QML_MAXIMIZED_ARG))
110 {103 {
111 maximized = true;104 maximized = true;
@@ -199,9 +192,6 @@
199 object->setProperty(it.key().toStdString().c_str(), QUrl(it.value()));192 object->setProperty(it.key().toStdString().c_str(), QUrl(it.value()));
200 }193 }
201194
202 if (useOxide) {
203 object->setProperty("useOxide", true);
204 }
205 component.completeCreate();195 component.completeCreate();
206196
207 if (window)197 if (window)

Subscribers

People subscribed via source and target branches

to all changes: