Merge lp:~abreu-alexandre/ubuntu-html5-theme/fix-oxide-support-rtm-14.09 into lp:ubuntu-html5-theme/rtm-14.09

Proposed by Alexandre Abreu
Status: Merged
Merged at revision: 178
Proposed branch: lp:~abreu-alexandre/ubuntu-html5-theme/fix-oxide-support-rtm-14.09
Merge into: lp:ubuntu-html5-theme/rtm-14.09
Diff against target: 1175 lines (+388/-225)
18 files modified
CMakeLists.txt (+4/-0)
debian/control (+5/-6)
src/plugin/Ubuntu/WebApps/CordovaLoader.qml (+5/-0)
src/plugin/Ubuntu/WebApps/UbuntuJavascriptBindings.qml (+5/-1)
src/plugin/Ubuntu/WebApps/WebAppContainer.qml (+26/-63)
src/ubuntu-html5-app-launcher/main.cpp (+47/-11)
src/ubuntu-html5-app-launcher/main.qml (+4/-1)
tests/autopilot/tools/qml/webview.qml (+91/-25)
tests/autopilot/ubuntu_html5_container/__init__.py (+2/-4)
tests/autopilot/ubuntu_html5_container/emulators/__init__.py (+0/-10)
tests/autopilot/ubuntu_html5_container/tests/__init__.py (+12/-7)
tests/autopilot/ubuntu_html5_container/tests/test_appLaunch.py (+5/-6)
tests/autopilot/ubuntu_html5_ui_toolkit/__init__.py (+2/-3)
tests/autopilot/ubuntu_html5_ui_toolkit/emulators/__init__.py (+0/-10)
tests/autopilot/ubuntu_html5_ui_toolkit/tests/__init__.py (+88/-38)
tests/autopilot/ubuntu_html5_ui_toolkit/tests/test_pagestack.py (+58/-22)
tests/autopilot/ubuntu_html5_ui_toolkit/tests/test_rss_reader.py (+7/-6)
tests/autopilot/ubuntu_html5_ui_toolkit/tests/test_tabs.py (+27/-12)
To merge this branch: bzr merge lp:~abreu-alexandre/ubuntu-html5-theme/fix-oxide-support-rtm-14.09
Reviewer Review Type Date Requested Status
Ubuntu HTML5 Theme Developers Pending
Review via email: mp+243874@code.launchpad.net

Commit message

Fix oxide support

Description of the change

Fix oxide support

To post a comment you must log in.
178. By Alexandre Abreu

Fix oxide support

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
=== modified file 'CMakeLists.txt'
--- CMakeLists.txt 2014-02-06 22:51:33 +0000
+++ CMakeLists.txt 2014-12-05 21:46:03 +0000
@@ -26,5 +26,9 @@
26add_custom_target(uninstall26add_custom_target(uninstall
27 COMMAND ${CMAKE_COMMAND} -P ${CMAKE_CURRENT_BINARY_DIR}/cmake_uninstall.cmake)27 COMMAND ${CMAKE_COMMAND} -P ${CMAKE_CURRENT_BINARY_DIR}/cmake_uninstall.cmake)
2828
29# make non compiled files (QML, JS, images, etc.) visible in QtCreator
30file(GLOB_RECURSE NON_COMPILED_FILES *.qml *.js *.png *.py *.pot *.po *.qdoc *.qdocconf *.css *.html)
31add_custom_target(NON_COMPILED_TARGET ALL SOURCES ${NON_COMPILED_FILES})
32
29add_subdirectory(src)33add_subdirectory(src)
30add_subdirectory(tests)34add_subdirectory(tests)
3135
=== modified file 'debian/control'
--- debian/control 2014-09-22 21:12:32 +0000
+++ debian/control 2014-12-05 21:46:03 +0000
@@ -4,8 +4,7 @@
4Maintainer: Michael Hall <mhall119@ubuntu.com>4Maintainer: Michael Hall <mhall119@ubuntu.com>
5Build-Depends: cmake (>= 2.8.9),5Build-Depends: cmake (>= 2.8.9),
6 debhelper (>= 9),6 debhelper (>= 9),
7 libqt5webkit5-dev,7 liboxideqt-qmlplugin (>= 1.2.0),
8 qml-module-qtwebkit,
9 python (>= 2.7),8 python (>= 2.7),
10 python-setuptools,9 python-setuptools,
11 qt5-default,10 qt5-default,
@@ -48,7 +47,7 @@
48Package: ubuntu-html5-ui-toolkit-examples47Package: ubuntu-html5-ui-toolkit-examples
49Architecture: all48Architecture: all
50Depends: libjs-jquery,49Depends: libjs-jquery,
51 qml-module-qtwebkit,50 liboxideqt-qmlplugin (>= 1.2.0),
52 qmlscene,51 qmlscene,
53 qtdeclarative5-qtquick2-plugin,52 qtdeclarative5-qtquick2-plugin,
54 ubuntu-html5-ui-toolkit (= ${binary:Version}),53 ubuntu-html5-ui-toolkit (= ${binary:Version}),
@@ -66,7 +65,7 @@
66 libautopilot-qt (>= 1.4),65 libautopilot-qt (>= 1.4),
67 libjs-jquery,66 libjs-jquery,
68 libqt5test5,67 libqt5test5,
69 qml-module-qtwebkit,68 liboxideqt-qmlplugin (>= 1.2.0),
70 python-xlib,69 python-xlib,
71 qmlscene,70 qmlscene,
72 qtdeclarative5-qtquick2-plugin,71 qtdeclarative5-qtquick2-plugin,
@@ -84,7 +83,7 @@
84Package: ubuntu-html5-container83Package: ubuntu-html5-container
85Architecture: any84Architecture: any
86Multi-Arch: foreign85Multi-Arch: foreign
87Depends: qml-module-qtwebkit,86Depends: liboxideqt-qmlplugin (>= 1.3.5),
88 qmlscene,87 qmlscene,
89 qtdeclarative5-cordova-2.8-plugin,88 qtdeclarative5-cordova-2.8-plugin,
90 qtdeclarative5-qtquick2-plugin,89 qtdeclarative5-qtquick2-plugin,
@@ -102,7 +101,7 @@
102Architecture: all101Architecture: all
103Depends: libautopilot-qt (>= 1.4),102Depends: libautopilot-qt (>= 1.4),
104 libqt5test5,103 libqt5test5,
105 qml-module-qtwebkit,104 liboxideqt-qmlplugin (>= 1.2.0),
106 qtdeclarative5-qtquick2-plugin,105 qtdeclarative5-qtquick2-plugin,
107 ubuntu-html5-container (>= ${binary:Version}),106 ubuntu-html5-container (>= ${binary:Version}),
108 ${misc:Depends},107 ${misc:Depends},
109108
=== modified file 'src/plugin/Ubuntu/WebApps/CordovaLoader.qml'
--- src/plugin/Ubuntu/WebApps/CordovaLoader.qml 2014-02-10 16:15:29 +0000
+++ src/plugin/Ubuntu/WebApps/CordovaLoader.qml 2014-12-05 21:46:03 +0000
@@ -23,6 +23,11 @@
2323
24 property string htmlIndexDirectory24 property string htmlIndexDirectory
2525
26 // Remote Inspector Properties
27 property string remoteInspectorEnabled
28 property string remoteInspectorPort
29 property string remoteInspectorHost
30
26 // Cordova plugin instance31 // Cordova plugin instance
27 property var cordovaInstance: null32 property var cordovaInstance: null
2833
2934
=== modified file 'src/plugin/Ubuntu/WebApps/UbuntuJavascriptBindings.qml'
--- src/plugin/Ubuntu/WebApps/UbuntuJavascriptBindings.qml 2014-02-10 17:58:49 +0000
+++ src/plugin/Ubuntu/WebApps/UbuntuJavascriptBindings.qml 2014-12-05 21:46:03 +0000
@@ -25,11 +25,13 @@
2525
26 property var bindingMainWebview: null26 property var bindingMainWebview: null
2727
28 signal ready()
29
28 /*!30 /*!
29 \internal31 \internal
30 */32 */
31 function getUnityWebappsProxies() {33 function getUnityWebappsProxies() {
32 return UnityWebAppsUtils.makeProxiesForQtWebViewBindee(bindingMainWebview);34 return UnityWebAppsUtils.makeProxiesForWebViewBindee(bindingMainWebview);
33 }35 }
3436
35 /*!37 /*!
@@ -53,6 +55,8 @@
53 bindee: root55 bindee: root
54 injectExtraUbuntuApis: true56 injectExtraUbuntuApis: true
55 requiresInit: false57 requiresInit: false
58
59 onUserScriptsInjected: root.ready()
56 }60 }
57 }61 }
58}62}
5963
=== modified file 'src/plugin/Ubuntu/WebApps/WebAppContainer.qml'
--- src/plugin/Ubuntu/WebApps/WebAppContainer.qml 2014-03-29 15:04:02 +0000
+++ src/plugin/Ubuntu/WebApps/WebAppContainer.qml 2014-12-05 21:46:03 +0000
@@ -18,7 +18,6 @@
1818
19import QtQuick 2.019import QtQuick 2.0
20import Ubuntu.Components 0.120import Ubuntu.Components 0.1
21import Ubuntu.Components.Extras.Browser 0.1
2221
2322
24/*!23/*!
@@ -30,17 +29,31 @@
30MainView {29MainView {
31 id: root30 id: root
32 objectName: "root"31 objectName: "root"
32
33 anchorToKeyboard: true33 anchorToKeyboard: true
34 automaticOrientation: true34 automaticOrientation: true
3535
36 /*!36 /*!
37 \preliminary37 \preliminary
38 The property defines if oxide is to be used as the webengine backend.
39 */
40 property bool oxide: true
41
42 /*!
43 \preliminary
38 The property holds the path to the filesystem location where the 'index.html'44 The property holds the path to the filesystem location where the 'index.html'
39 file can be found (root of the HTML5 application).45 file can be found (root of the HTML5 application).
4046
41 The path is absolute or relative to the current dir.47 The path is absolute or relative to the current dir.
42 */48 */
43 property alias htmlIndexDirectory: cordovaWebviewProvider.htmlIndexDirectory49 property string htmlIndexDirectory: ""
50
51 /*!
52 \preliminary
53 The properties hold whether the remote debugging interface should be enabled for the
54 Web View. The host ip and port for accessing the remote interface should be provided.
55 */
56 property bool remoteInspectorEnabled: false
4457
45 Page {58 Page {
46 id: mainPage59 id: mainPage
@@ -49,41 +62,6 @@
49 /*!62 /*!
50 \internal63 \internal
51 */64 */
52 CordovaLoader {
53 id: cordovaWebviewProvider
54 anchors.fill: parent
55 onCreationError: {
56 mainPage._onCordovaCreationError();
57 }
58 onCreated: {
59 bindings.bindingMainWebview = Qt.binding(function() {
60 return cordovaInstance.mainWebview;
61 });
62 }
63 }
64
65 /*!
66 \internal
67 */
68 function _onCordovaCreationError() {
69 mainPage._fallbackToWebview();
70 }
71
72 /*!
73 \internal
74 */
75 function _fallbackToWebview() {
76 console.debug('Falling back on the plain Webview backend.')
77
78 webviewFallbackComponentLoader.sourceComponent = Qt.binding(function() {
79 return root.htmlIndexDirectory.length !== 0
80 ? webviewFallbackComponent : null;
81 });
82 }
83
84 /*!
85 \internal
86 */
87 function _getAppStartupIndexFileUri() {65 function _getAppStartupIndexFileUri() {
88 return 'file://' + root.htmlIndexDirectory + '/index.html';66 return 'file://' + root.htmlIndexDirectory + '/index.html';
89 }67 }
@@ -92,38 +70,19 @@
92 \internal70 \internal
93 */71 */
94 Loader {72 Loader {
95 id: webviewFallbackComponentLoader73 id: webviewComponentLoader
96 anchors.fill: parent74 anchors.fill: parent
97 onLoaded: {75 onLoaded: {
98 bindings.bindingMainWebview = item;76 bindings.bindingMainWebview = item;
99 }77 }
100 }78 }
10179
102 /*!80 Component.onCompleted: {
103 \internal81 var webview = oxide ?
104 */82 Qt.resolvedUrl("WebViewOxide.qml")
105 Component {83 : Qt.resolvedUrl("WebViewWebkit.qml");
106 id: webviewFallbackComponent84 webviewComponentLoader.setSource(webview, {
107 UbuntuWebView {85 remoteInspectorEnabled: root.remoteInspectorEnabled});
108 url: mainPage._getAppStartupIndexFileUri()
109
110 experimental.preferences.localStorageEnabled: true
111 experimental.preferences.offlineWebApplicationCacheEnabled: true
112 experimental.preferences.universalAccessFromFileURLsAllowed: true
113 experimental.preferences.webGLEnabled: true
114
115 experimental.databaseQuotaDialog: Item {
116 Timer {
117 interval: 1
118 running: true
119 onTriggered: {
120 model.accept(model.expectedUsage)
121 }
122 }
123 }
124 // port in QTWEBKIT_INSPECTOR_SERVER enviroment variable
125 experimental.preferences.developerExtrasEnabled: true
126 }
127 }86 }
12887
129 /*!88 /*!
@@ -131,6 +90,10 @@
131 */90 */
132 UbuntuJavascriptBindings {91 UbuntuJavascriptBindings {
133 id: bindings92 id: bindings
93 onReady: {
94 webviewComponentLoader.item.url =
95 mainPage._getAppStartupIndexFileUri();
96 }
134 }97 }
135 }98 }
136}99}
137100
=== modified file 'src/ubuntu-html5-app-launcher/main.cpp'
--- src/ubuntu-html5-app-launcher/main.cpp 2014-04-03 13:57:30 +0000
+++ src/ubuntu-html5-app-launcher/main.cpp 2014-12-05 21:46:03 +0000
@@ -56,6 +56,33 @@
56 }56 }
57}57}
5858
59static QString currentArchitecturePathName()
60{
61#if defined(Q_PROCESSOR_X86_32)
62 return QLatin1String("i386-linux-gnu");
63#elif defined(Q_PROCESSOR_X86_64)
64 return QLatin1String("x86_64-linux-gnu");
65#elif defined(Q_PROCESSOR_ARM)
66 return QLatin1String("arm-linux-gnueabihf");
67#else
68#error Unable to determine target architecture
69#endif
70}
71
72static bool canUseOxide()
73{
74 // Use a runtime hint to transparently know if oxide
75 // can be used as a backend without the user/dev having
76 // to update its app or change something in the Exec args.
77 // Version 1.1 of ubuntu apparmor policy allows this file to
78 // be accessed whereas v1.0 only knows about qtwebkit.
79 QString oxideHintLocation =
80 QString("/usr/lib/%1/oxide-qt/oxide-renderer")
81 .arg(currentArchitecturePathName());
82
83 return QFile(oxideHintLocation).open(QIODevice::ReadOnly);
84}
85
59} // namespace86} // namespace
6087
6188
@@ -142,6 +169,10 @@
142 QString wwwfolderArg;169 QString wwwfolderArg;
143 bool maximized = false;170 bool maximized = false;
144171
172 QString remoteInspectorHost = "";
173 QString remoteInspectorPort = QString::number(REMOTE_INSPECTOR_PORT);
174 bool remoteInspectorEnabled = false;
175
145 QStringList arguments = app.arguments();176 QStringList arguments = app.arguments();
146 arguments.pop_front();177 arguments.pop_front();
147178
@@ -149,7 +180,7 @@
149 {180 {
150 if (argument.contains(WWW_LOCATION_ARG_HEADER))181 if (argument.contains(WWW_LOCATION_ARG_HEADER))
151 {182 {
152 wwwfolderArg = argument.right(argument.count() - WWW_LOCATION_ARG_HEADER.count());183 wwwfolderArg = argument.split(WWW_LOCATION_ARG_HEADER)[1];
153 }184 }
154 else185 else
155 if (argument.contains(MAXIMIZED_ARG_HEADER))186 if (argument.contains(MAXIMIZED_ARG_HEADER))
@@ -159,20 +190,16 @@
159 else190 else
160 if (argument.contains(INSPECTOR))191 if (argument.contains(INSPECTOR))
161 {192 {
162 QString host;193 remoteInspectorEnabled = true;
163 Q_FOREACH(QHostAddress address, QNetworkInterface::allAddresses()) {194 Q_FOREACH(QHostAddress address, QNetworkInterface::allAddresses()) {
164 if (!address.isLoopback() && (address.protocol() == QAbstractSocket::IPv4Protocol)) {195 if (!address.isLoopback() && (address.protocol() == QAbstractSocket::IPv4Protocol)) {
165 host = address.toString();196 remoteInspectorHost = address.toString();
166 break;197 break;
167 }198 }
168 }199 }
169 QString server;200 if (argument.startsWith(INSPECTOR + "=")) {
170 if (host.isEmpty()) {201 remoteInspectorPort = argument.split(INSPECTOR + "=")[1];
171 server = QString::number(REMOTE_INSPECTOR_PORT);
172 } else {
173 server = QString("%1:%2").arg(host, QString::number(REMOTE_INSPECTOR_PORT));
174 }202 }
175 qputenv("QTWEBKIT_INSPECTOR_SERVER", server.toUtf8());
176 }203 }
177 else204 else
178 {205 {
@@ -188,7 +215,6 @@
188 }215 }
189216
190 QFileInfo wwwFolder(wwwfolderArg);217 QFileInfo wwwFolder(wwwfolderArg);
191
192 if (wwwFolder.isRelative())218 if (wwwFolder.isRelative())
193 {219 {
194 wwwFolder.makeAbsolute();220 wwwFolder.makeAbsolute();
@@ -218,6 +244,17 @@
218 setUpQmlImportPathIfNecessary(plugin_path);244 setUpQmlImportPathIfNecessary(plugin_path);
219245
220 QQuickView view;246 QQuickView view;
247 QQmlEngine* engine = view.engine();
248 engine->rootContext()->setContextProperty("withOxide", canUseOxide());
249
250 if (remoteInspectorEnabled) {
251 qputenv("UBUNTU_WEBVIEW_DEVTOOLS_HOST", remoteInspectorHost.toUtf8());
252 qputenv("UBUNTU_WEBVIEW_DEVTOOLS_PORT", remoteInspectorPort.toUtf8());
253 }
254
255 engine->rootContext()->setContextProperty("inspector", remoteInspectorEnabled);
256 engine->rootContext()->setContextProperty("wwwFolder", wwwFolder.absoluteFilePath());
257
221 view.setSource(QUrl::fromLocalFile(Webapp::Config::getContainerMainQmlPath()258 view.setSource(QUrl::fromLocalFile(Webapp::Config::getContainerMainQmlPath()
222 + "/main.qml"));259 + "/main.qml"));
223 if (view.status() != QQuickView::Ready)260 if (view.status() != QQuickView::Ready)
@@ -225,7 +262,6 @@
225 qCritical() << "Main application component cannot be loaded.";262 qCritical() << "Main application component cannot be loaded.";
226 return EXIT_FAILURE;263 return EXIT_FAILURE;
227 }264 }
228 view.rootObject()->setProperty("htmlIndexDirectory", wwwFolder.canonicalFilePath());
229265
230 view.setTitle(QCoreApplication::applicationName());266 view.setTitle(QCoreApplication::applicationName());
231 view.setResizeMode(QQuickView::SizeRootObjectToView);267 view.setResizeMode(QQuickView::SizeRootObjectToView);
232268
=== modified file 'src/ubuntu-html5-app-launcher/main.qml'
--- src/ubuntu-html5-app-launcher/main.qml 2014-02-10 16:15:29 +0000
+++ src/ubuntu-html5-app-launcher/main.qml 2014-12-05 21:46:03 +0000
@@ -23,5 +23,8 @@
23WebAppContainer {23WebAppContainer {
24 width: units.gu(100)24 width: units.gu(100)
25 height: units.gu(75)25 height: units.gu(75)
26
27 oxide: withOxide
28 remoteInspectorEnabled: inspector
29 htmlIndexDirectory: wwwFolder
26}30}
27
2831
=== modified file 'tests/autopilot/tools/qml/webview.qml'
--- tests/autopilot/tools/qml/webview.qml 2014-04-03 17:15:24 +0000
+++ tests/autopilot/tools/qml/webview.qml 2014-12-05 21:46:03 +0000
@@ -17,8 +17,8 @@
17 */17 */
1818
19import QtQuick 2.019import QtQuick 2.0
20import QtWebKit 3.020import QtTest 1.0
21import QtWebKit.experimental 1.021import com.canonical.Oxide 1.0 as Oxide
2222
23Item {23Item {
24 id: root24 id: root
@@ -31,6 +31,8 @@
3131
32 signal resultUpdated(string message)32 signal resultUpdated(string message)
3333
34 TestResult { id: qtest_testResult }
35
34 function __gentid() {36 function __gentid() {
35 return Math.random() + '';37 return Math.random() + '';
36 }38 }
@@ -64,23 +66,21 @@
64 var tid = __gentid();66 var tid = __gentid();
65 var statement = 'document.getElementById("' + id + '").click();';67 var statement = 'document.getElementById("' + id + '").click();';
6668
67 webview.experimental.evaluateJavaScript(__wrapJsCommands(statement),69 var result = webview.evaluateCode(statement, true);
68 function(result) { root.resultUpdated(root.__createResult(result)); });70 root.resultUpdated(root.__createResult(result, tid));
69 }71 }
7072
71 function evalInPageUnsafe(expr) {73 function evalInPageUnsafe(expr) {
72 var tid = __gentid();74 var result = webview.evaluateCode(expr, true);
7375 root.resultUpdated(result.toString())
74 webview.experimental.evaluateJavaScript(__wrapJsCommands(expr),
75 function(result) { root.resultUpdated(root.__createResult(result)); });
76 }76 }
7777
78 function clickAnyElementBySelector(selector) {78 function clickAnyElementBySelector(selector) {
79 var tid = __gentid();79 var tid = __gentid();
80 var statement = 'document.querySelectorAll("' + selector + '")[0].click();';80 var statement = 'document.querySelectorAll("' + selector + '")[0].click();';
8181
82 webview.experimental.evaluateJavaScript(__wrapJsCommands(statement),82 var result = webview.evaluateCode(statement, true);
83 function(result) { root.resultUpdated(root.__createResult(result)); });83 root.resultUpdated(root.__createResult(result, tid));
84 }84 }
8585
86 function elementWithIdHasAttribute(id,attribute,value) {86 function elementWithIdHasAttribute(id,attribute,value) {
@@ -95,13 +95,13 @@
95 statement += hasAttributeWithIdFunc;95 statement += hasAttributeWithIdFunc;
96 statement += "; return __hasAttributeWithId(id,attribute,value); "96 statement += "; return __hasAttributeWithId(id,attribute,value); "
9797
98 webview.experimental.evaluateJavaScript(__wrapJsCommands(statement),98 var result = webview.evaluateCode(statement, true);
99 function(result) { root.resultUpdated(root.__createResult(result, tid)); });99 root.resultUpdated(root.__createResult(result, tid));
100 }100 }
101101
102 function isNodeWithIdVisible(id) {102 function isNodeWithIdVisible(id) {
103 var tid = __gentid();103 var tid = __gentid();
104 var isNodeWithIdVisibleFunc = '104 var isNodeWithIdVisibleFunc = '
105 function __isNodeWithIdVisible() {105 function __isNodeWithIdVisible() {
106 try { return document.getElementById(id).style.display !== "none"; } catch (e) { return e.toString(); };106 try { return document.getElementById(id).style.display !== "none"; } catch (e) { return e.toString(); };
107 return false;107 return false;
@@ -110,14 +110,15 @@
110 var statement = __setupClosedVariables({'id': id});110 var statement = __setupClosedVariables({'id': id});
111 statement += isNodeWithIdVisibleFunc;111 statement += isNodeWithIdVisibleFunc;
112 statement += "; return __isNodeWithIdVisible(id); "112 statement += "; return __isNodeWithIdVisible(id); "
113 webview.experimental.evaluateJavaScript(__wrapJsCommands(statement),113
114 function(result) { root.resultUpdated(root.__createResult(result, tid)); });114 var result = webview.evaluateCode(statement, true);
115 root.resultUpdated(root.__createResult(result, tid));
115 }116 }
116117
117 function getAttributeForElementWithId(id,attribute) {118 function getAttributeForElementWithId(id,attribute) {
118 var tid = __gentid();119 var tid = __gentid();
119 var getAttributeWithIdFunc = '120 var getAttributeWithIdFunc = '
120 function __getAttributeWithId() {121 function __getAttributeWithId() {
121 try { var value = document.querySelector("#" + id).getAttribute(attribute); return value || ""; } catch (e) { return e.toString(); };122 try { var value = document.querySelector("#" + id).getAttribute(attribute); return value || ""; } catch (e) { return e.toString(); };
122 return "";123 return "";
123 };';124 };';
@@ -126,11 +127,11 @@
126 statement += getAttributeWithIdFunc;127 statement += getAttributeWithIdFunc;
127 statement += "; return __getAttributeWithId(); "128 statement += "; return __getAttributeWithId(); "
128129
129 webview.experimental.evaluateJavaScript(__wrapJsCommands(statement),130 var result = webview.evaluateCode(statement, true);
130 function(result) { root.resultUpdated(root.__createResult(result, tid)); });131 root.resultUpdated(root.__createResult(result, tid));
131 }132 }
132133
133 WebView {134 Oxide.WebView {
134 objectName: "webview"135 objectName: "webview"
135 id: webview136 id: webview
136137
@@ -146,12 +147,77 @@
146 left: parent.left147 left: parent.left
147 }148 }
148149
149 experimental.userScripts: []150 preferences.localStorageEnabled: true
150 experimental.preferences.navigatorQtObjectEnabled: true151 preferences.appCacheEnabled: true
151 experimental.preferences.developerExtrasEnabled: true152
152153 function evaluateCode(code, wrap) {
153 experimental.userAgent: {154 var value = webview._waitForResult(
154 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"155 webview.rootFrame.sendMessage(
156 "oxide://main-world",
157 "EVALUATE-CODE",
158 { code: code,
159 wrap: wrap === undefined ? false : wrap }));
160 return value ? value.result : undefined;
161 }
162
163 function _waitForResult(req, timeout) {
164 var result;
165 var error;
166 req.onreply = function(response) {
167 result = response;
168 error = 0;
169 };
170 req.onerror = function(error_code, msg) {
171 result = msg;
172 error = error_code;
173 };
174 webview._waitFor(function() { return error !== undefined; },
175 timeout);
176
177 if (error > 0) {
178 console.error('Error:' + error + ', result:' + result)
179 } else if (error === 0) {
180 return result;
181 } else {
182 throw new Error("Message call timed out");
183 }
184 }
185
186 function _waitFor(predicate, timeout) {
187 timeout = timeout || 5000000;
188 var end = Date.now() + timeout;
189 var i = Date.now();
190 while (i < end && !predicate()) {
191 qtest_testResult.wait(50);
192 i = Date.now();
193 }
194 return predicate();
195 }
196
197 context: Oxide.WebContext {
198 userScripts: [
199 Oxide.UserScript {
200 context: "oxide://main-world"
201 emulateGreasemonkey: true
202 url: Qt.resolvedUrl("message-server.js")
203 matchAllFrames: true
204 }
205 ]
206 }
207
208 onJavaScriptConsoleMessage: {
209 var msg = "[JS] (%1:%2) %3".arg(sourceId).arg(lineNumber).arg(message)
210 if (level === Oxide.WebView.LogSeverityVerbose) {
211 console.log(msg)
212 } else if (level === Oxide.WebView.LogSeverityInfo) {
213 console.info(msg)
214 } else if (level === Oxide.WebView.LogSeverityWarning) {
215 console.warn(msg)
216 } else if ((level === Oxide.WebView.LogSeverityError) ||
217 (level === Oxide.WebView.LogSeverityErrorReport) ||
218 (level === Oxide.WebView.LogSeverityFatal)) {
219 console.error(msg)
220 }
155 }221 }
156 }222 }
157223
158224
=== modified file 'tests/autopilot/ubuntu_html5_container/__init__.py'
--- tests/autopilot/ubuntu_html5_container/__init__.py 2014-02-06 22:51:33 +0000
+++ tests/autopilot/ubuntu_html5_container/__init__.py 2014-12-05 21:46:03 +0000
@@ -2,9 +2,7 @@
2# Copyright 2014 Canonical2# Copyright 2014 Canonical
3#3#
4# This program is free software: you can redistribute it and/or modify it4# This program is free software: you can redistribute it and/or modify it
5# under the terms of the GNU Lesser General Public License version 3, as published5# under the terms of the GNU Lesser General Public License version 3, as
6# by the Free Software Foundation.6# published by the Free Software Foundation.
77
8"""Tests for the Ubuntu HTML5 Launcher package """8"""Tests for the Ubuntu HTML5 Launcher package """
9
10
119
=== removed directory 'tests/autopilot/ubuntu_html5_container/emulators'
=== removed file 'tests/autopilot/ubuntu_html5_container/emulators/__init__.py'
--- tests/autopilot/ubuntu_html5_container/emulators/__init__.py 2014-02-06 22:51:33 +0000
+++ tests/autopilot/ubuntu_html5_container/emulators/__init__.py 1970-01-01 00:00:00 +0000
@@ -1,10 +0,0 @@
1# -*- Mode: Python; coding: utf-8; indent-tabs-mode: nil; tab-width: 4 -*-
2# Copyright 2014 Canonical
3#
4# This program is free software: you can redistribute it and/or modify it
5# under the terms of the GNU Lesser General Public License version 3, as published
6# by the Free Software Foundation.
7
8"""Tests for the Ubuntu HTML5 Launcher package """
9
10
110
=== modified file 'tests/autopilot/ubuntu_html5_container/tests/__init__.py'
--- tests/autopilot/ubuntu_html5_container/tests/__init__.py 2014-02-06 22:51:33 +0000
+++ tests/autopilot/ubuntu_html5_container/tests/__init__.py 2014-12-05 21:46:03 +0000
@@ -2,18 +2,22 @@
2# Copyright 2014 Canonical2# Copyright 2014 Canonical
3#3#
4# This program is free software: you can redistribute it and/or modify it4# This program is free software: you can redistribute it and/or modify it
5# under the terms of the GNU Lesser General Public License version 3, as published5# under the terms of the GNU Lesser General Public License version 3, as
6# by the Free Software Foundation.6# published by the Free Software Foundation.
77
8"""Tests for the Ubuntu HTML5 Launcher package """8"""Tests for the Ubuntu HTML5 Launcher package """
99
10import os10import os
11from autopilot.testcase import AutopilotTestCase11from autopilot.testcase import AutopilotTestCase
1212
13
13LAUNCHER_EXEC_NAME = 'ubuntu-html5-app-launcher'14LAUNCHER_EXEC_NAME = 'ubuntu-html5-app-launcher'
1415
15LOCAL_LAUNCHER_PATH = os.path.abspath("%s/%s" % (os.path.dirname(os.path.realpath(__file__))16LOCAL_LAUNCHER_PATH = os.path.abspath(
16 , '../../../../src/ubuntu-html5-app-launcher/' + LAUNCHER_EXEC_NAME))17 "{}/{}".format(
18 os.path.dirname(os.path.realpath(__file__)),
19 '../../../../src/ubuntu-html5-app-launcher/' + LAUNCHER_EXEC_NAME))
20
17INSTALLED_LAUNCHER_PATH = '/usr/bin/' + LAUNCHER_EXEC_NAME21INSTALLED_LAUNCHER_PATH = '/usr/bin/' + LAUNCHER_EXEC_NAME
1822
1923
@@ -35,7 +39,8 @@
3539
36 def launch_with_argument(self, args):40 def launch_with_argument(self, args):
37 try:41 try:
38 self.app = self.launch_test_application(self.get_launcher_path(), args)42 self.app = self.launch_test_application(
39 except Exception, e:43 self.get_launcher_path(),
44 args)
45 except Exception:
40 pass46 pass
41
4247
=== modified file 'tests/autopilot/ubuntu_html5_container/tests/test_appLaunch.py'
--- tests/autopilot/ubuntu_html5_container/tests/test_appLaunch.py 2014-02-06 22:51:33 +0000
+++ tests/autopilot/ubuntu_html5_container/tests/test_appLaunch.py 2014-12-05 21:46:03 +0000
@@ -2,12 +2,12 @@
2# Copyright 2014 Canonical2# Copyright 2014 Canonical
3#3#
4# This program is free software: you can redistribute it and/or modify it4# This program is free software: you can redistribute it and/or modify it
5# under the terms of the GNU Lesser General Public License version 3, as published5# under the terms of the GNU Lesser General Public License version 3, as
6# by the Free Software Foundation.6# published by the Free Software Foundation.
77
8from __future__ import absolute_import8from __future__ import absolute_import
99
10from testtools.matchers import Equals10from testtools.matchers import NotEquals
1111
12from ubuntu_html5_container.tests import UbuntuHtml5LauncherTestCase12from ubuntu_html5_container.tests import UbuntuHtml5LauncherTestCase
1313
@@ -16,7 +16,6 @@
16 def setUp(self):16 def setUp(self):
17 super(UbuntuHtml5LauncherAppLaunchTestCase, self).setUp()17 super(UbuntuHtml5LauncherAppLaunchTestCase, self).setUp()
1818
19 def test_launcherFailsWithNoWWW(self):19 def test_launcher_succeeds_with_no_www(self):
20 self.launch_with_argument('')20 self.launch_with_argument('')
21 self.assertThat(self.get_app(), Equals(None))21 self.assertThat(self.get_app(), NotEquals(None))
22
2322
=== modified file 'tests/autopilot/ubuntu_html5_ui_toolkit/__init__.py'
--- tests/autopilot/ubuntu_html5_ui_toolkit/__init__.py 2014-01-28 18:25:08 +0000
+++ tests/autopilot/ubuntu_html5_ui_toolkit/__init__.py 2014-12-05 21:46:03 +0000
@@ -2,8 +2,7 @@
2# Copyright 2013 Canonical2# Copyright 2013 Canonical
3#3#
4# This program is free software: you can redistribute it and/or modify it4# This program is free software: you can redistribute it and/or modify it
5# under the terms of the GNU Lesser General Public License version 3, as published5# under the terms of the GNU Lesser General Public License version 3, as
6# by the Free Software Foundation.6# published by the Free Software Foundation.
77
8"""Tests for the Ubuntu HTML5 UI SDK package """8"""Tests for the Ubuntu HTML5 UI SDK package """
9
109
=== removed directory 'tests/autopilot/ubuntu_html5_ui_toolkit/emulators'
=== removed file 'tests/autopilot/ubuntu_html5_ui_toolkit/emulators/__init__.py'
--- tests/autopilot/ubuntu_html5_ui_toolkit/emulators/__init__.py 2014-01-28 18:25:08 +0000
+++ tests/autopilot/ubuntu_html5_ui_toolkit/emulators/__init__.py 1970-01-01 00:00:00 +0000
@@ -1,10 +0,0 @@
1# -*- Mode: Python; coding: utf-8; indent-tabs-mode: nil; tab-width: 4 -*-
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 Lesser General Public License version 3, as published
6# by the Free Software Foundation.
7
8"""Tests for the Ubuntu HTML5 UI SDK package """
9
10
110
=== modified file 'tests/autopilot/ubuntu_html5_ui_toolkit/tests/__init__.py'
--- tests/autopilot/ubuntu_html5_ui_toolkit/tests/__init__.py 2014-02-11 12:11:48 +0000
+++ tests/autopilot/ubuntu_html5_ui_toolkit/tests/__init__.py 2014-12-05 21:46:03 +0000
@@ -2,20 +2,20 @@
2# Copyright 2013 Canonical2# Copyright 2013 Canonical
3#3#
4# This program is free software: you can redistribute it and/or modify it4# This program is free software: you can redistribute it and/or modify it
5# under the terms of the GNU Lesser General Public License version 3, as published5# under the terms of the GNU Lesser General Public License version 3, as
6# by the Free Software Foundation.6# published by the Free Software Foundation.
77
8"""Tests for the Ubuntu HTML5 package """8"""Tests for the Ubuntu HTML5 package """
99
10import os10import os
11import json11import json
12import BaseHTTPServer12import http.server as http
13import threading13import threading
14import subprocess14import subprocess
1515
16HTTP_SERVER_PORT = 838316HTTP_SERVER_PORT = 8383
1717
18from testtools.matchers import Contains, Equals, GreaterThan18from testtools.matchers import Equals, GreaterThan
19from autopilot.matchers import Eventually19from autopilot.matchers import Eventually
20from autopilot.testcase import AutopilotTestCase20from autopilot.testcase import AutopilotTestCase
21from autopilot.input import Mouse, Touch, Pointer21from autopilot.input import Mouse, Touch, Pointer
@@ -25,14 +25,17 @@
25# from autopilot.introspection.qt import QtIntrospectionTestMixin25# from autopilot.introspection.qt import QtIntrospectionTestMixin
2626
2727
28class RequestHandler(BaseHTTPServer.BaseHTTPRequestHandler):28class RequestHandler(http.BaseHTTPRequestHandler):
29 BASE_PATH_FOR_SERVED_APPS = {'rss-reader': "%s/%s" % (os.path.dirname(os.path.realpath(__file__)), '../../../../0.1/examples/apps/rss-reader')}29 BASE_PATH_FOR_SERVED_APPS = {'rss-reader': "{}/{}".format(
30 os.path.dirname(os.path.realpath(__file__)),
31 '../../../../0.1/examples/apps/rss-reader')}
3032
31 def get_served_filename(self, appname, filename):33 def get_served_filename(self, appname, filename):
32 if len(filename) == 0 or filename == '/':34 if len(filename) == 0 or filename == '/':
33 filename = 'autopilot.html'35 filename = 'autopilot.html'
34 print os.path.join(self.BASE_PATH_FOR_SERVED_APPS[appname], filename)36 return os.path.join(
35 return os.path.join(self.BASE_PATH_FOR_SERVED_APPS[appname], filename)37 self.BASE_PATH_FOR_SERVED_APPS[appname],
38 filename)
3639
37 def serve_file(self, filename):40 def serve_file(self, filename):
38 import mimetypes41 import mimetypes
@@ -51,7 +54,10 @@
51 if self.path.startswith('/rss-reader'):54 if self.path.startswith('/rss-reader'):
52 filename = self.path[len('/rss-reader'):]55 filename = self.path[len('/rss-reader'):]
53 self.send_response(200)56 self.send_response(200)
54 self.serve_file(self.get_served_filename('rss-reader', filename))57 self.serve_file(
58 self.get_served_filename(
59 'rss-reader',
60 filename))
55 else:61 else:
56 self.send_error(404)62 self.send_error(404)
5763
@@ -59,7 +65,9 @@
59class UbuntuHTML5HTTPServer(threading.Thread):65class UbuntuHTML5HTTPServer(threading.Thread):
60 def __init__(self, port):66 def __init__(self, port):
61 super(UbuntuHTML5HTTPServer, self).__init__()67 super(UbuntuHTML5HTTPServer, self).__init__()
62 self.server = BaseHTTPServer.HTTPServer(("", port), RequestHandler)68 self.server = http.BaseHTTPServer.HTTPServer(
69 ("", port),
70 RequestHandler)
63 self.server.allow_reuse_address = True71 self.server.allow_reuse_address = True
6472
65 def run(self):73 def run(self):
@@ -71,15 +79,22 @@
7179
7280
73class UbuntuHTML5TestCaseBase(AutopilotTestCase):81class UbuntuHTML5TestCaseBase(AutopilotTestCase):
74 BROWSER_CONTAINER_PATH = "%s/%s" % (os.path.dirname(os.path.realpath(__file__)), '../../tools/qml/webview.qml')82 BROWSER_CONTAINER_PATH = "{}/{}".format(
75 INSTALLED_BROWSER_CONTAINER_PATH = '/usr/share/ubuntu-html5-ui-toolkit/tests/tools/qml/webview.qml'83 os.path.dirname(os.path.realpath(__file__)),
76 arch = subprocess.check_output(84 '../../tools/qml/webview.qml')
77 ["dpkg-architecture", "-qDEB_HOST_MULTIARCH"]).strip()85 INSTALLED_BROWSER_CONTAINER_PATH = \
78 BROWSER_QML_APP_LAUNCHER = "/usr/lib/" + arch + "/qt5/bin/qmlscene"86 '/usr/share/ubuntu-html5-ui-toolkit/tests/tools/qml/webview.qml'
87 BROWSER_QML_APP_LAUNCHER = "/usr/lib/{}/qt5/bin/qmlscene".format(
88 subprocess.check_output(
89 ["dpkg-architecture", "-qDEB_HOST_MULTIARCH"]).strip().decode('utf-8'))
7990
80 # TODO: fix version91 # TODO: fix version
81 LOCAL_HTML_EXAMPLES_PATH = os.path.abspath("%s/%s" % (os.path.dirname(os.path.realpath(__file__)), '../../../../tests'))92 LOCAL_HTML_EXAMPLES_PATH = os.path.abspath(
82 INSTALLED_HTML_EXAMPLES_PATH = '/usr/share/ubuntu-html5-ui-toolkit/tests/'93 "{}/{}".format(
94 os.path.dirname(os.path.realpath(__file__)),
95 '../../../../tests'))
96 INSTALLED_HTML_EXAMPLES_PATH = \
97 '/usr/share/ubuntu-html5-ui-toolkit/tests/'
8398
84 APPS_SUBFOLDER_NAME = 'apps'99 APPS_SUBFOLDER_NAME = 'apps'
85100
@@ -106,16 +121,20 @@
106 else:121 else:
107 self.pointer = Pointer(Touch.create())122 self.pointer = Pointer(Touch.create())
108123
109 params = [self.BROWSER_QML_APP_LAUNCHER, self.get_browser_container_path()]124 params = [self.BROWSER_QML_APP_LAUNCHER,
110 if (platform.model() <> 'Desktop'):125 self.get_browser_container_path()]
111 params.append('--desktop_file_hint=/usr/share/applications/unitywebappsqmllauncher.desktop')126 if (platform.model() != 'Desktop'):
127 params.append(
128 '--desktop_file_hint=/usr/share/" \
129 + "applications/unitywebappsqmllauncher.desktop')
112130
113 self.app = self.launch_test_application(131 self.app = self.launch_test_application(
114 *params,132 *params,
115 app_type='qt')133 app_type='qt')
116134
117 self.webviewContainer = self.get_webviewContainer()135 self.webviewContainer = self.get_webviewContainer()
118 self.watcher = self.webviewContainer.watch_signal('resultUpdated(QString)')136 self.watcher = self.webviewContainer.watch_signal(
137 'resultUpdated(QString)')
119 super(UbuntuHTML5TestCaseBase, self).setUp()138 super(UbuntuHTML5TestCaseBase, self).setUp()
120139
121 def tearDown(self):140 def tearDown(self):
@@ -143,40 +162,60 @@
143162
144 def assert_url_eventually_loaded(self, url):163 def assert_url_eventually_loaded(self, url):
145 webview = self.get_webview()164 webview = self.get_webview()
146 self.assertThat(webview.loadProgress, Eventually(Equals(100)))165 self.assertThat(
147 self.assertThat(webview.loading, Eventually(Equals(False)))166 webview.loadProgress,
148 self.assertThat(webview.url, Eventually(Equals(url)))167 Eventually(Equals(100)))
168 self.assertThat(
169 webview.loading,
170 Eventually(Equals(False)))
171 self.assertThat(
172 webview.url,
173 Eventually(Equals(url)))
149174
150 def click_dom_node_with_id(self, id):175 def click_dom_node_with_id(self, id):
151 webview = self.get_webviewContainer()176 webview = self.get_webviewContainer()
152 webview.slots.clickElementById(id)177 webview.slots.clickElementById(id)
153 self.assertThat(lambda: self.watcher.num_emissions, Eventually(Equals(1)))178 self.assertThat(
179 lambda: self.watcher.num_emissions,
180 Eventually(Equals(1)))
154181
155 def click_any_dom_node_by_selector(self, selector):182 def click_any_dom_node_by_selector(self, selector):
156 webview = self.get_webviewContainer()183 webview = self.get_webviewContainer()
157 webview.slots.clickAnyElementBySelector(selector)184 webview.slots.clickAnyElementBySelector(selector)
158 self.assertThat(lambda: self.watcher.num_emissions, Eventually(Equals(1)))185 self.assertThat(
186 lambda: self.watcher.num_emissions,
187 Eventually(Equals(1)))
159188
160 def is_dom_node_visible(self, id):189 def is_dom_node_visible(self, id):
161 webview = self.get_webviewContainer()190 webview = self.get_webviewContainer()
162 prev_emissions = self.watcher.num_emissions191 prev_emissions = self.watcher.num_emissions
163 webview.slots.isNodeWithIdVisible(id)192 webview.slots.isNodeWithIdVisible(id)
164 self.assertThat(lambda: self.watcher.num_emissions, Eventually(GreaterThan(prev_emissions)))193 self.assertThat(
165 return json.loads(webview.get_signal_emissions('resultUpdated(QString)')[-1][0])['result']194 lambda: self.watcher.num_emissions,
195 Eventually(GreaterThan(prev_emissions)))
196 return json.loads(
197 webview.get_signal_emissions(
198 'resultUpdated(QString)')[-1][0])['result']
166199
167 def eval_expression_in_page_unsafe(self, expr):200 def eval_expression_in_page_unsafe(self, expr):
168 webview = self.get_webviewContainer()201 webview = self.get_webviewContainer()
169 prev_emissions = self.watcher.num_emissions202 prev_emissions = self.watcher.num_emissions
170 webview.slots.evalInPageUnsafe(expr)203 result = webview.slots.evalInPageUnsafe(expr)
171 self.assertThat(lambda: self.watcher.num_emissions, Eventually(GreaterThan(prev_emissions)))204 self.assertThat(
172 return json.loads(webview.get_signal_emissions('resultUpdated(QString)')[-1][0])['result']205 lambda: self.watcher.num_emissions,
206 Eventually(GreaterThan(prev_emissions)))
207 return webview.get_signal_emissions('resultUpdated(QString)')[-1][0]
173208
174 def get_dom_node_id_attribute(self, id, attribute):209 def get_dom_node_id_attribute(self, id, attribute):
175 webview = self.get_webviewContainer()210 webview = self.get_webviewContainer()
176 prev_emissions = self.watcher.num_emissions211 prev_emissions = self.watcher.num_emissions
177 webview.slots.getAttributeForElementWithId(id, attribute)212 webview.slots.getAttributeForElementWithId(id, attribute)
178 self.assertThat(lambda: self.watcher.num_emissions, Eventually(GreaterThan(prev_emissions)))213 self.assertThat(
179 return json.loads(webview.get_signal_emissions('resultUpdated(QString)')[-1][0])['result']214 lambda: self.watcher.num_emissions,
215 Eventually(GreaterThan(prev_emissions)))
216 return json.loads(
217 webview.get_signal_emissions(
218 'resultUpdated(QString)')[-1][0])['result']
180219
181 def get_address_bar_action_button(self):220 def get_address_bar_action_button(self):
182 addressbar = self.get_addressbar()221 addressbar = self.get_addressbar()
@@ -185,23 +224,29 @@
185 def browse_to_url(self, url):224 def browse_to_url(self, url):
186 import time225 import time
187 addressbar = self.get_addressbar()226 addressbar = self.get_addressbar()
188 self.assertThat(addressbar.activeFocus, Eventually(Equals(True)))227 self.assertThat(
228 addressbar.activeFocus,
229 Eventually(Equals(True)))
189230
190 self.keyboard.type(url, 0.001)231 self.keyboard.type(url, 0.001)
191232
192 self.pointer.click_object(self.get_webview())233 self.pointer.click_object(self.get_webview())
234
235 # XXX: very bad, but wont fix
193 time.sleep(1)236 time.sleep(1)
194237
195 button = self.get_address_bar_action_button();238 button = self.get_address_bar_action_button()
196 self.pointer.move_to_object(button)239 self.pointer.move_to_object(button)
197 self.pointer.press()240 self.pointer.press()
241 # XXX: very bad, but wont fix
198 time.sleep(1)242 time.sleep(1)
199 self.pointer.release()243 self.pointer.release()
200244
201 self.assert_url_eventually_loaded(url);245 self.assert_url_eventually_loaded(url)
202246
203 def browse_to_app(self, appname):247 def browse_to_app(self, appname):
204 appfilepath = os.path.abspath(self.BASE_PATH +248 appfilepath = os.path.abspath(
249 self.BASE_PATH +
205 '/data/html/' +250 '/data/html/' +
206 self.APPS_SUBFOLDER_NAME +251 self.APPS_SUBFOLDER_NAME +
207 '/' +252 '/' +
@@ -213,7 +258,12 @@
213 self.browse_to_url(APP_HTML_PATH)258 self.browse_to_url(APP_HTML_PATH)
214259
215 def browse_to_test_html(self, html_filename):260 def browse_to_test_html(self, html_filename):
216 self.browse_to_url(self.create_file_url_from(os.path.abspath(self.BASE_PATH + '/data/html/' + html_filename)))261 self.browse_to_url(
262 self.create_file_url_from(
263 os.path.abspath(
264 '{}/data/html/{}'.format(
265 self.BASE_PATH,
266 html_filename))))
217267
218268
219class UbuntuThemeWithHttpServerTestCaseBase(UbuntuHTML5TestCaseBase):269class UbuntuThemeWithHttpServerTestCaseBase(UbuntuHTML5TestCaseBase):
220270
=== modified file 'tests/autopilot/ubuntu_html5_ui_toolkit/tests/test_pagestack.py'
--- tests/autopilot/ubuntu_html5_ui_toolkit/tests/test_pagestack.py 2014-03-05 16:21:16 +0000
+++ tests/autopilot/ubuntu_html5_ui_toolkit/tests/test_pagestack.py 2014-12-05 21:46:03 +0000
@@ -2,17 +2,16 @@
2# Copyright 2013 Canonical2# Copyright 2013 Canonical
3#3#
4# This program is free software: you can redistribute it and/or modify it4# This program is free software: you can redistribute it and/or modify it
5# under the terms of the GNU Lesser General Public License version 3, as published5# under the terms of the GNU Lesser General Public License version 3, as
6# by the Free Software Foundation.6# published by the Free Software Foundation.
77
8from __future__ import absolute_import8from __future__ import absolute_import
99
10import time10from testtools.matchers import Equals
11
12from testtools.matchers import Contains, Equals
13from autopilot.matchers import Eventually11from autopilot.matchers import Eventually
1412
15from ubuntu_html5_ui_toolkit.tests import UbuntuHTML5TestCaseBase, UbuntuThemeRemotePageTestCaseBase13from ubuntu_html5_ui_toolkit.tests import UbuntuHTML5TestCaseBase
14
1615
17class UbuntuThemePageStackTestCase(UbuntuHTML5TestCaseBase):16class UbuntuThemePageStackTestCase(UbuntuHTML5TestCaseBase):
1817
@@ -21,25 +20,54 @@
2120
22 def test_pageLoadsWithNoPageStacks(self):21 def test_pageLoadsWithNoPageStacks(self):
23 self.browse_to_test_html('test-nopagestack-in-app.html')22 self.browse_to_test_html('test-nopagestack-in-app.html')
24 self.assertThat(self.eval_expression_in_page_unsafe('var UI = new UbuntuUI(); UI.init(); return "ok";'), Equals('ok'));23 self.assertThat(
24 self.eval_expression_in_page_unsafe(
25 'var UI = new UbuntuUI(); UI.init(); return "ok";'),
26 Equals('ok'))
2527
26 def test_pageLoadsWithPageStacks(self):28 def test_pageLoadsWithPageStacks(self):
27 self.browse_to_test_html('test-pagestack-in-app.html')29 self.browse_to_test_html('test-pagestack-in-app.html')
28 self.assertThat(self.eval_expression_in_page_unsafe('var UI = new UbuntuUI(); UI.init(); return "ok";'), Equals('ok'));30 self.assertThat(
29 self.assertThat(self.is_dom_node_visible('main'), Equals(True))31 self.eval_expression_in_page_unsafe(
32 'var UI = new UbuntuUI(); UI.init(); return "ok";'),
33 Equals('ok'))
34 self.assertThat(
35 self.is_dom_node_visible('main'),
36 Equals(True))
3037
31 def test_pageChangeWithPageStackPush(self):38 def test_pageChangeWithPageStackPush(self):
32 self.browse_to_test_html('test-pagestack-in-app.html')39 self.browse_to_test_html('test-pagestack-in-app.html')
33 self.assertThat(self.eval_expression_in_page_unsafe('var UI = new UbuntuUI(); UI.init(); UI.pagestack.push("results"); return "ok";'), Equals('ok'));40 self.assertThat(
34 self.assertThat(self.is_dom_node_visible('main'), Equals(False))41 self.eval_expression_in_page_unsafe(
35 self.assertThat(self.is_dom_node_visible('results'), Equals(True))42 'var UI = new UbuntuUI(); UI.init(); '
43 'UI.pagestack.push("results"); return "ok";'),
44 Equals('ok'))
45 self.assertThat(
46 self.is_dom_node_visible('main'),
47 Equals(False))
48 self.assertThat(
49 self.is_dom_node_visible('results'),
50 Equals(True))
3651
37 def test_pageChangeWithPageStackPopped(self):52 def test_pageChangeWithPageStackPopped(self):
38 self.browse_to_test_html('test-pagestack-in-app.html')53 self.browse_to_test_html('test-pagestack-in-app.html')
39 self.assertThat(self.eval_expression_in_page_unsafe('var UI = new UbuntuUI(); UI.init(); UI.pagestack.push("main"); UI.pagestack.push("results"); UI.pagestack.push("article"); UI.pagestack.pop(); return "ok";'), Equals('ok'));54 self.assertThat(
40 self.assertThat(self.is_dom_node_visible('main'), Equals(False))55 self.eval_expression_in_page_unsafe(
41 self.assertThat(self.is_dom_node_visible('results'), Equals(True))56 'var UI = new UbuntuUI(); UI.init(); '
42 self.assertThat(self.is_dom_node_visible('article'), Equals(False))57 'UI.pagestack.push("main"); '
58 'UI.pagestack.push("results"); '
59 'UI.pagestack.push("article"); '
60 'UI.pagestack.pop(); return "ok";'),
61 Equals('ok'))
62 self.assertThat(
63 self.is_dom_node_visible('main'),
64 Equals(False))
65 self.assertThat(
66 self.is_dom_node_visible('results'),
67 Equals(True))
68 self.assertThat(
69 self.is_dom_node_visible('article'),
70 Equals(False))
4371
44 def test_pagePushWithProperties(self):72 def test_pagePushWithProperties(self):
45 self.browse_to_test_html('test-pagestack-in-app.html')73 self.browse_to_test_html('test-pagestack-in-app.html')
@@ -50,14 +78,22 @@
5078
51 (new Page('results')).onactivated(79 (new Page('results')).onactivated(
52 function(properties) {80 function(properties) {
53 document.getElementById('results').innerHTML = JSON.stringify(properties);81 document.getElementById('results').innerHTML =
82 JSON.stringify(properties);
54 });83 });
5584
56 ui.pagestack.push('results', 'WORKS');85 ui.pagestack.push('results', 'WORKS');
57 return 'ok';86 return 'ok';
58 """87 """
59 self.assertThat(self.eval_expression_in_page_unsafe(expression), Equals('ok'));88 self.assertThat(
60 self.assertThat(lambda: self.is_dom_node_visible('results'), Eventually(Equals(True)))89 self.eval_expression_in_page_unsafe(expression),
61 results_html_content = "return document.getElementById('results').innerHTML;"90 Equals('ok'))
62 self.assertThat(self.eval_expression_in_page_unsafe(results_html_content), Equals('"WORKS"'));91 self.assertThat(
6392 lambda: self.is_dom_node_visible('results'),
93 Eventually(Equals(True)))
94 results_html_content = \
95 "return document.getElementById('results').innerHTML;"
96 self.assertThat(
97 self.eval_expression_in_page_unsafe(
98 results_html_content),
99 Equals('"WORKS"'))
64100
=== modified file 'tests/autopilot/ubuntu_html5_ui_toolkit/tests/test_rss_reader.py'
--- tests/autopilot/ubuntu_html5_ui_toolkit/tests/test_rss_reader.py 2014-01-27 21:34:44 +0000
+++ tests/autopilot/ubuntu_html5_ui_toolkit/tests/test_rss_reader.py 2014-12-05 21:46:03 +0000
@@ -2,17 +2,16 @@
2# Copyright 2013 Canonical2# Copyright 2013 Canonical
3#3#
4# This program is free software: you can redistribute it and/or modify it4# This program is free software: you can redistribute it and/or modify it
5# under the terms of the GNU Lesser General Public License version 3, as published5# under the terms of the GNU Lesser General Public License version 3, as
6# by the Free Software Foundation.6# published by the Free Software Foundation.
77
8from __future__ import absolute_import8from __future__ import absolute_import
99
10import time
11
12from testtools.matchers import Contains, Equals10from testtools.matchers import Contains, Equals
13from autopilot.matchers import Eventually11from autopilot.matchers import Eventually
1412
15from ubuntu_html5_ui_toolkit.tests import UbuntuHTML5TestCaseBase, UbuntuThemeRemotePageTestCaseBase13from ubuntu_html5_ui_toolkit.tests import UbuntuHTML5TestCaseBase
14
1615
17class UbuntuThemeRSSReaderTestCase(UbuntuHTML5TestCaseBase):16class UbuntuThemeRSSReaderTestCase(UbuntuHTML5TestCaseBase):
18 def setUp(self):17 def setUp(self):
@@ -29,6 +28,8 @@
2928
30 def test_switchToFeedView(self):29 def test_switchToFeedView(self):
31 self.click_any_dom_node_by_selector('#yourfeeds li a')30 self.click_any_dom_node_by_selector('#yourfeeds li a')
32 self.assertThat(lambda: self.is_dom_node_visible('main'), Eventually(Equals(False)))31 self.assertThat(
32 lambda: self.is_dom_node_visible('main'),
33 Eventually(Equals(False)))
33 self.assertThat(self.is_dom_node_visible('article'), Equals(False))34 self.assertThat(self.is_dom_node_visible('article'), Equals(False))
34 self.assertThat(self.is_dom_node_visible('results'), Equals(True))35 self.assertThat(self.is_dom_node_visible('results'), Equals(True))
3536
=== modified file 'tests/autopilot/ubuntu_html5_ui_toolkit/tests/test_tabs.py'
--- tests/autopilot/ubuntu_html5_ui_toolkit/tests/test_tabs.py 2014-03-05 20:06:49 +0000
+++ tests/autopilot/ubuntu_html5_ui_toolkit/tests/test_tabs.py 2014-12-05 21:46:03 +0000
@@ -2,18 +2,17 @@
2# Copyright 2014 Canonical2# Copyright 2014 Canonical
3#3#
4# This program is free software: you can redistribute it and/or modify it4# This program is free software: you can redistribute it and/or modify it
5# under the terms of the GNU Lesser General Public License version 3, as published5# under the terms of the GNU Lesser General Public License version 3, as
6# by the Free Software Foundation.6# published by the Free Software Foundation.
77
8from __future__ import absolute_import8from __future__ import absolute_import
99
10import time10from testtools.matchers import Equals
11
12from testtools.matchers import Contains, Equals
13from autopilot.matchers import Eventually11from autopilot.matchers import Eventually
1412
15from ubuntu_html5_ui_toolkit.tests import UbuntuHTML5TestCaseBase13from ubuntu_html5_ui_toolkit.tests import UbuntuHTML5TestCaseBase
1614
15
17class UbuntuUIToolkitTabsTestCase(UbuntuHTML5TestCaseBase):16class UbuntuUIToolkitTabsTestCase(UbuntuHTML5TestCaseBase):
1817
19 def setUp(self):18 def setUp(self):
@@ -21,11 +20,27 @@
2120
22 def test_programaticTabSelectIndex(self):21 def test_programaticTabSelectIndex(self):
23 self.browse_to_test_html('test-tabs-in-app.html')22 self.browse_to_test_html('test-tabs-in-app.html')
24 self.assertThat(self.eval_expression_in_page_unsafe('var UI = new UbuntuUI(); UI.init(); UI.tabs.selectedTabIndex = 1; return "ok";'), Equals('ok'));23 self.assertThat(
2524 self.eval_expression_in_page_unsafe(
26 self.assertThat(lambda: self.is_dom_node_visible('tab1'), Eventually(Equals(False)))25 'var UI = new UbuntuUI(); '
27 self.assertThat(lambda: self.is_dom_node_visible('tab2'), Eventually(Equals(True)))26 'UI.init(); UI.tabs.selectedTabIndex = 1; '
28 self.assertThat(lambda: self.is_dom_node_visible('tab3'), Eventually(Equals(False)))27 'return "ok";'),
2928 Equals('ok'))
30 self.assertThat(self.eval_expression_in_page_unsafe('var UI = new UbuntuUI(); UI.init(); return UI.tabs.selectedTabIndex = 1;'), Equals(1));29
30 self.assertThat(
31 lambda: self.is_dom_node_visible('tab1'),
32 Eventually(Equals(False)))
33 self.assertThat(
34 lambda: self.is_dom_node_visible('tab2'),
35 Eventually(Equals(True)))
36 self.assertThat(
37 lambda: self.is_dom_node_visible('tab3'),
38 Eventually(Equals(False)))
39
40 self.assertThat(
41 self.eval_expression_in_page_unsafe(
42 'var UI = new UbuntuUI(); '
43 'UI.init(); '
44 'return UI.tabs.selectedTabIndex;'),
45 Equals('1'))
3146

Subscribers

People subscribed via source and target branches