Merge lp:~abreu-alexandre/ubuntu-html5-theme/backport-oxide-fixes-14.09 into lp:ubuntu-html5-theme/rtm-14.09

Proposed by Alexandre Abreu
Status: Approved
Approved by: Alexandre Abreu
Approved revision: 193
Proposed branch: lp:~abreu-alexandre/ubuntu-html5-theme/backport-oxide-fixes-14.09
Merge into: lp:ubuntu-html5-theme/rtm-14.09
Diff against target: 1531 lines (+515/-411)
21 files modified
CMakeLists.txt (+5/-0)
debian/control (+7/-7)
src/plugin/Ubuntu/WebApps/CordovaLoader.qml (+0/-91)
src/plugin/Ubuntu/WebApps/UbuntuJavascriptBindings.qml (+0/-59)
src/plugin/Ubuntu/WebApps/WebAppContainer.qml (+55/-68)
src/plugin/Ubuntu/WebApps/WebViewOxide.qml (+42/-0)
src/plugin/Ubuntu/WebApps/WebViewWebkit.qml (+54/-0)
src/ubuntu-html5-app-launcher/CMakeLists.txt (+3/-1)
src/ubuntu-html5-app-launcher/main.cpp (+53/-41)
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/backport-oxide-fixes-14.09
Reviewer Review Type Date Requested Status
Ubuntu HTML5 Theme Developers Pending
Review via email: mp+244035@code.launchpad.net

Commit message

Fix oxide bindings, fix content hub apis

Description of the change

Fix oxide bindings, fix content hub apis

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

add --oxide flag

186. By Alexandre Abreu

fixes

187. By Alexandre Abreu

fixes

188. By Alexandre Abreu

add oxide hw compositiing support; remove clutter

189. By Alexandre Abreu

fix compilation

190. By Alexandre Abreu

updates

191. By Alexandre Abreu

cleanup oxide

192. By Alexandre Abreu

add --oxide

193. By Alexandre Abreu

oxide only bits

Unmerged revisions

193. By Alexandre Abreu

oxide only bits

192. By Alexandre Abreu

add --oxide

191. By Alexandre Abreu

cleanup oxide

190. By Alexandre Abreu

updates

189. By Alexandre Abreu

fix compilation

188. By Alexandre Abreu

add oxide hw compositiing support; remove clutter

187. By Alexandre Abreu

fixes

186. By Alexandre Abreu

fixes

185. By Alexandre Abreu

add --oxide flag

184. By Alexandre Abreu

Fix oxide bindings, fix content hub apis

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'CMakeLists.txt'
2--- CMakeLists.txt 2014-12-08 18:08:39 +0000
3+++ CMakeLists.txt 2015-01-09 00:53:11 +0000
4@@ -13,6 +13,7 @@
5 endif()
6
7 find_package(Qt5Core REQUIRED)
8+find_package(Qt5Gui REQUIRED)
9 find_package(Qt5Widgets REQUIRED)
10 find_package(Qt5Quick REQUIRED)
11
12@@ -26,5 +27,9 @@
13 add_custom_target(uninstall
14 COMMAND ${CMAKE_COMMAND} -P ${CMAKE_CURRENT_BINARY_DIR}/cmake_uninstall.cmake)
15
16+# make non compiled files (QML, JS, images, etc.) visible in QtCreator
17+file(GLOB_RECURSE NON_COMPILED_FILES *.qml *.js *.png *.py *.pot *.po *.qdoc *.qdocconf *.css *.html)
18+add_custom_target(NON_COMPILED_TARGET ALL SOURCES ${NON_COMPILED_FILES})
19+
20 add_subdirectory(src)
21 add_subdirectory(tests)
22
23=== modified file 'debian/control'
24--- debian/control 2014-12-08 18:08:39 +0000
25+++ debian/control 2015-01-09 00:53:11 +0000
26@@ -4,8 +4,7 @@
27 Maintainer: Michael Hall <mhall119@ubuntu.com>
28 Build-Depends: cmake (>= 2.8.9),
29 debhelper (>= 9),
30- libqt5webkit5-dev,
31- qml-module-qtwebkit,
32+ liboxideqt-qmlplugin (>= 1.2.0),
33 python (>= 2.7),
34 python-setuptools,
35 qt5-default,
36@@ -13,6 +12,7 @@
37 qtbase5-dev,
38 qtbase5-private-dev,
39 qtdeclarative5-dev,
40+ qtdeclarative5-private-dev,
41 qtdeclarative5-qtquick2-plugin,
42 qtdeclarative5-ubuntu-ui-toolkit-plugin,
43 Standards-Version: 3.9.5
44@@ -48,7 +48,7 @@
45 Package: ubuntu-html5-ui-toolkit-examples
46 Architecture: all
47 Depends: libjs-jquery,
48- qml-module-qtwebkit,
49+ liboxideqt-qmlplugin (>= 1.2.0),
50 qmlscene,
51 qtdeclarative5-qtquick2-plugin,
52 ubuntu-html5-ui-toolkit (= ${binary:Version}),
53@@ -66,7 +66,7 @@
54 libautopilot-qt (>= 1.4),
55 libjs-jquery,
56 libqt5test5,
57- qml-module-qtwebkit,
58+ liboxideqt-qmlplugin (>= 1.2.0),
59 python-xlib,
60 qmlscene,
61 qtdeclarative5-qtquick2-plugin,
62@@ -84,12 +84,13 @@
63 Package: ubuntu-html5-container
64 Architecture: any
65 Multi-Arch: foreign
66-Depends: qml-module-qtwebkit,
67+Depends: liboxideqt-qmlplugin (>= 1.3.5),
68+ qml-module-qtwebkit,
69 qmlscene,
70 qtdeclarative5-cordova-2.8-plugin,
71 qtdeclarative5-qtquick2-plugin,
72+ qtdeclarative5-ubuntu-web-plugin,
73 qtdeclarative5-ubuntu-ui-extras-browser-plugin,
74- ubuntu-html5-ui-toolkit (= ${source:Version}),
75 unity-webapps-qml (>= 0.1+14.04.20131106-0ubuntu2),
76 ${misc:Depends},
77 ${python:Depends},
78@@ -102,7 +103,6 @@
79 Architecture: all
80 Depends: libautopilot-qt (>= 1.4),
81 libqt5test5,
82- qml-module-qtwebkit,
83 qtdeclarative5-qtquick2-plugin,
84 ubuntu-html5-container (>= ${binary:Version}),
85 ${misc:Depends},
86
87=== removed file 'src/plugin/Ubuntu/WebApps/CordovaLoader.qml'
88--- src/plugin/Ubuntu/WebApps/CordovaLoader.qml 2014-12-08 18:08:39 +0000
89+++ src/plugin/Ubuntu/WebApps/CordovaLoader.qml 1970-01-01 00:00:00 +0000
90@@ -1,91 +0,0 @@
91-/*
92- * Copyright 2014 Canonical Ltd.
93- *
94- * This file is part of ubuntu-html5-ui-toolkit.
95- *
96- * ubuntu-html5-ui-toolkit is free software; you can redistribute it and/or modify
97- * it under the terms of the GNU General Public License as published by
98- * the Free Software Foundation; version 3.
99- *
100- * ubuntu-html5-ui-toolkit is distributed in the hope that it will be useful,
101- * but WITHOUT ANY WARRANTY; without even the implied warranty of
102- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
103- * GNU General Public License for more details.
104- *
105- * You should have received a copy of the GNU General Public License
106- * along with this program. If not, see <http://www.gnu.org/licenses/>.
107- */
108-
109-import QtQuick 2.0
110-
111-Item {
112- id: root
113-
114- property string htmlIndexDirectory
115-
116- // Cordova plugin instance
117- property var cordovaInstance: null
118-
119- // the cordova qml instance was created successfully
120- signal created();
121-
122- // an error occured while creating the cordova instance
123- signal creationError();
124-
125- function _tryCreateObject(statement, parent) {
126- var result = null;
127- try {
128- result = Qt.createQmlObject(statement, parent);
129- }
130- catch (e) {};
131-
132- return result;
133- }
134-
135- function _getCordovaObjectCreationStatementFor(version, params) {
136- return 'import CordovaUbuntu '
137- + version
138- + '; CordovaView { '
139- + ' anchors.fill: parent; '
140- + params + ';'
141- + '}';
142- }
143-
144- function _tryCreateCordovaObject(version, params) {
145- var _params = params || '';
146- return _tryCreateObject(_getCordovaObjectCreationStatementFor(version, params), root);
147- }
148-
149- function _ensureCordovaInitDone() {
150- if (cordovaInstance && htmlIndexDirectory.length !== 0) {
151- cordovaInstance.wwwDir = htmlIndexDirectory;
152- }
153- }
154-
155- onHtmlIndexDirectoryChanged: _ensureCordovaInitDone()
156-
157- Component.onCompleted: {
158- // selectively try to load cordova
159- var cordova = null;
160-
161- var candidates = [{version: '3.4', paramString: 'contentFile: "index.html"'}];
162- for (var i = 0; i < candidates.length; ++i) {
163- cordova = _tryCreateCordovaObject(candidates[i].version,
164- candidates[i].paramString);
165- if (cordova)
166- break;
167- }
168-
169- if ( ! cordova) {
170- console.error('Cannot create CordovaView object.');
171- creationError();
172- return;
173- }
174-
175- root.cordovaInstance = cordova;
176-
177- _ensureCordovaInitDone();
178-
179- created();
180- }
181-}
182
183=== removed file 'src/plugin/Ubuntu/WebApps/UbuntuJavascriptBindings.qml'
184--- src/plugin/Ubuntu/WebApps/UbuntuJavascriptBindings.qml 2014-12-08 18:08:39 +0000
185+++ src/plugin/Ubuntu/WebApps/UbuntuJavascriptBindings.qml 1970-01-01 00:00:00 +0000
186@@ -1,59 +0,0 @@
187-/*
188- * Copyright 2014 Canonical Ltd.
189- *
190- * This file is part of ubuntu-html5-container.
191- *
192- * ubuntu-html5-container is free software; you can redistribute it and/or modify
193- * it under the terms of the GNU General Public License as published by
194- * the Free Software Foundation; version 3.
195- *
196- * webbrowser-app is distributed in the hope that it will be useful,
197- * but WITHOUT ANY WARRANTY; without even the implied warranty of
198- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
199- * GNU General Public License for more details.
200- *
201- * You should have received a copy of the GNU General Public License
202- * along with this program. If not, see <http://www.gnu.org/licenses/>.
203- */
204-
205-import QtQuick 2.0
206-import Ubuntu.UnityWebApps 0.1
207-
208-
209-Item {
210- id: root
211-
212- property var bindingMainWebview: null
213-
214- /*!
215- \internal
216- */
217- function getUnityWebappsProxies() {
218- return UnityWebAppsUtils.makeProxiesForQtWebViewBindee(bindingMainWebview);
219- }
220-
221- /*!
222- \internal
223- */
224- Loader {
225- id: webappBindingsLoader
226- visible: false
227- anchors.fill: parent
228- sourceComponent: bindingMainWebview ? webappBindingsComponent : undefined
229- }
230-
231- /*!
232- \internal
233- */
234- Component {
235- id: webappBindingsComponent
236-
237- UnityWebApps {
238- id: webapps
239- bindee: root
240- injectExtraUbuntuApis: true
241- requiresInit: false
242- }
243- }
244-}
245-
246
247=== modified file 'src/plugin/Ubuntu/WebApps/WebAppContainer.qml'
248--- src/plugin/Ubuntu/WebApps/WebAppContainer.qml 2014-12-08 18:08:39 +0000
249+++ src/plugin/Ubuntu/WebApps/WebAppContainer.qml 2015-01-09 00:53:11 +0000
250@@ -18,8 +18,7 @@
251
252 import QtQuick 2.0
253 import Ubuntu.Components 0.1
254-import Ubuntu.Components.Extras.Browser 0.1
255-
256+import Ubuntu.UnityWebApps 0.1
257
258 /*!
259 \qmltype WebAppContainer
260@@ -30,17 +29,31 @@
261 MainView {
262 id: root
263 objectName: "root"
264+
265 anchorToKeyboard: true
266 automaticOrientation: true
267
268 /*!
269 \preliminary
270+ The property defines if oxide is to be used as the webengine backend.
271+ */
272+ property bool oxide: true
273+
274+ /*!
275+ \preliminary
276 The property holds the path to the filesystem location where the 'index.html'
277 file can be found (root of the HTML5 application).
278
279 The path is absolute or relative to the current dir.
280 */
281- property alias htmlIndexDirectory: cordovaWebviewProvider.htmlIndexDirectory
282+ property string htmlIndexDirectory: ""
283+
284+ /*!
285+ \preliminary
286+ The properties hold whether the remote debugging interface should be enabled for the
287+ Web View. The host ip and port for accessing the remote interface should be provided.
288+ */
289+ property bool remoteInspectorEnabled: false
290
291 Page {
292 id: mainPage
293@@ -49,41 +62,6 @@
294 /*!
295 \internal
296 */
297- CordovaLoader {
298- id: cordovaWebviewProvider
299- anchors.fill: parent
300- onCreationError: {
301- mainPage._onCordovaCreationError();
302- }
303- onCreated: {
304- bindings.bindingMainWebview = Qt.binding(function() {
305- return cordovaInstance.mainWebview;
306- });
307- }
308- }
309-
310- /*!
311- \internal
312- */
313- function _onCordovaCreationError() {
314- mainPage._fallbackToWebview();
315- }
316-
317- /*!
318- \internal
319- */
320- function _fallbackToWebview() {
321- console.debug('Falling back on the plain Webview backend.')
322-
323- webviewFallbackComponentLoader.sourceComponent = Qt.binding(function() {
324- return root.htmlIndexDirectory.length !== 0
325- ? webviewFallbackComponent : null;
326- });
327- }
328-
329- /*!
330- \internal
331- */
332 function _getAppStartupIndexFileUri() {
333 return 'file://' + root.htmlIndexDirectory + '/index.html';
334 }
335@@ -92,46 +70,55 @@
336 \internal
337 */
338 Loader {
339- id: webviewFallbackComponentLoader
340+ id: webviewComponentLoader
341 anchors.fill: parent
342 onLoaded: {
343- bindings.bindingMainWebview = item;
344+ webappBindingsLoader.sourceComponent = webappBindingsComponent
345 }
346 }
347
348+ Component.onCompleted: {
349+ var webview = oxide ?
350+ Qt.resolvedUrl("WebViewOxide.qml")
351+ : Qt.resolvedUrl("WebViewWebkit.qml");
352+ webviewComponentLoader.setSource(webview, {
353+ remoteInspectorEnabled: root.remoteInspectorEnabled});
354+ }
355+
356+ /*!
357+ \internal
358+ */
359+ function getUnityWebappsProxies() {
360+ return UnityWebAppsUtils.makeProxiesForWebViewBindee(webviewComponentLoader.item);
361+ }
362+
363+ /*!
364+ \internal
365+ */
366+ Loader {
367+ id: webappBindingsLoader
368+ visible: false
369+ anchors.fill: parent
370+ }
371+
372+ function userScriptInjected() {
373+ webviewComponentLoader.item.url =
374+ mainPage._getAppStartupIndexFileUri();
375+ }
376+
377 /*!
378 \internal
379 */
380 Component {
381- id: webviewFallbackComponent
382- UbuntuWebView {
383- url: mainPage._getAppStartupIndexFileUri()
384-
385- experimental.preferences.localStorageEnabled: true
386- experimental.preferences.offlineWebApplicationCacheEnabled: true
387- experimental.preferences.universalAccessFromFileURLsAllowed: true
388- experimental.preferences.webGLEnabled: true
389-
390- experimental.databaseQuotaDialog: Item {
391- Timer {
392- interval: 1
393- running: true
394- onTriggered: {
395- model.accept(model.expectedUsage)
396- }
397- }
398- }
399- // port in QTWEBKIT_INSPECTOR_SERVER enviroment variable
400- experimental.preferences.developerExtrasEnabled: true
401+ id: webappBindingsComponent
402+
403+ UnityWebApps {
404+ bindee: mainPage
405+ injectExtraUbuntuApis: true
406+ requiresInit: false
407+
408+ onUserScriptsInjected: mainPage.userScriptInjected()
409 }
410 }
411-
412- /*!
413- \internal
414- */
415- UbuntuJavascriptBindings {
416- id: bindings
417- }
418 }
419 }
420-
421
422=== added file 'src/plugin/Ubuntu/WebApps/WebViewOxide.qml'
423--- src/plugin/Ubuntu/WebApps/WebViewOxide.qml 1970-01-01 00:00:00 +0000
424+++ src/plugin/Ubuntu/WebApps/WebViewOxide.qml 2015-01-09 00:53:11 +0000
425@@ -0,0 +1,42 @@
426+/*
427+ * Copyright 2014 Canonical Ltd.
428+ *
429+ * This file is part of ubuntu-html5-ui-toolkit.
430+ *
431+ * ubuntu-html5-ui-toolkit is free software; you can redistribute it and/or modify
432+ * it under the terms of the GNU General Public License as published by
433+ * the Free Software Foundation; version 3.
434+ *
435+ * ubuntu-html5-ui-toolkit is distributed in the hope that it will be useful,
436+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
437+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
438+ * GNU General Public License for more details.
439+ *
440+ * You should have received a copy of the GNU General Public License
441+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
442+ */
443+
444+import QtQuick 2.0
445+import Ubuntu.Components 0.1
446+import Ubuntu.Web 0.2
447+import com.canonical.Oxide 1.0 as Oxide
448+
449+WebView {
450+ id: webview
451+
452+ property bool remoteInspectorEnabled: false
453+
454+ preferences.localStorageEnabled: true
455+ preferences.allowUniversalAccessFromFileUrls: true
456+ preferences.appCacheEnabled: true
457+
458+ function navigationRequestedDelegate(request) {
459+ var url = request.url.toString()
460+
461+ if (url.indexOf("file://") !== 0) {
462+ request.action = Oxide.NavigationRequest.ActionReject
463+ Qt.openUrlExternally(url)
464+ return
465+ }
466+ }
467+}
468
469=== added file 'src/plugin/Ubuntu/WebApps/WebViewWebkit.qml'
470--- src/plugin/Ubuntu/WebApps/WebViewWebkit.qml 1970-01-01 00:00:00 +0000
471+++ src/plugin/Ubuntu/WebApps/WebViewWebkit.qml 2015-01-09 00:53:11 +0000
472@@ -0,0 +1,54 @@
473+/*
474+ * Copyright 2015 Canonical Ltd.
475+ *
476+ * This file is part of ubuntu-html5-ui-toolkit.
477+ *
478+ * ubuntu-html5-ui-toolkit is free software; you can redistribute it and/or modify
479+ * it under the terms of the GNU General Public License as published by
480+ * the Free Software Foundation; version 3.
481+ *
482+ * ubuntu-html5-ui-toolkit is distributed in the hope that it will be useful,
483+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
484+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
485+ * GNU General Public License for more details.
486+ *
487+ * You should have received a copy of the GNU General Public License
488+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
489+ */
490+
491+import QtQuick 2.0
492+import Ubuntu.Components 0.1
493+import Ubuntu.Components.Extras.Browser 0.1
494+
495+UbuntuWebView {
496+ id: webview
497+
498+ onNewTabRequested: {
499+ if (url.toString().indexOf("file://") !== 0) {
500+ Qt.openUrlExternally(url.toString())
501+ return
502+ }
503+ }
504+
505+ property bool remoteInspectorEnabled: false
506+ property string remoteInspectorPort: ""
507+ property string remoteInspectorHost: ""
508+
509+ experimental.preferences.localStorageEnabled: true
510+ experimental.preferences.offlineWebApplicationCacheEnabled: true
511+ experimental.preferences.universalAccessFromFileURLsAllowed: true
512+ experimental.preferences.webGLEnabled: true
513+
514+ experimental.databaseQuotaDialog: Item {
515+ Timer {
516+ interval: 1
517+ running: true
518+ onTriggered: {
519+ model.accept(model.expectedUsage)
520+ }
521+ }
522+ }
523+
524+ // port in QTWEBKIT_INSPECTOR_SERVER enviroment variable
525+ experimental.preferences.developerExtrasEnabled: true
526+}
527\ No newline at end of file
528
529=== modified file 'src/ubuntu-html5-app-launcher/CMakeLists.txt'
530--- src/ubuntu-html5-app-launcher/CMakeLists.txt 2014-02-06 22:51:33 +0000
531+++ src/ubuntu-html5-app-launcher/CMakeLists.txt 2015-01-09 00:53:11 +0000
532@@ -19,7 +19,9 @@
533 add_executable(${HTML5_LAUNCHER}
534 ${HTML5_LAUNCHER_SRC}
535 )
536-qt5_use_modules(${HTML5_LAUNCHER} Core Widgets Quick)
537+qt5_use_modules(${HTML5_LAUNCHER} Core Gui Qml Quick Widgets)
538+
539+include_directories(${Qt5Quick_PRIVATE_INCLUDE_DIRS})
540
541
542 # install qml files
543
544=== modified file 'src/ubuntu-html5-app-launcher/main.cpp'
545--- src/ubuntu-html5-app-launcher/main.cpp 2014-12-08 18:08:39 +0000
546+++ src/ubuntu-html5-app-launcher/main.cpp 2015-01-09 00:53:11 +0000
547@@ -28,6 +28,11 @@
548 #include <QQmlEngine>
549 #include <QQmlContext>
550 #include <QQmlComponent>
551+#if QT_VERSION < QT_VERSION_CHECK(5, 3, 0)
552+#include <QtQuick/private/qsgcontext_p.h>
553+#else
554+#include <QtGui/private/qopenglcontext_p.h>
555+#endif
556
557
558 namespace {
559@@ -72,7 +77,7 @@
560 qputenv("QML2_IMPORT_PATH", existingImportPath.toLatin1());
561 }
562
563-void setUpQmlImportPathIfNecessary(const QString & applicationLocalSearchPath)
564+void setUpQmlImportPathIfNecessary()
565 {
566 QString importPath = Webapp::Config::getContainerImportPath();
567 if ( !importPath.isEmpty())
568@@ -80,30 +85,10 @@
569 addPathToQmlImport(importPath);
570 }
571
572- // Note: By default we add the local path to the import path
573- // mostly to account for potential Cordova 3.0 qml plugin
574- // not installed globally but embedded into apps. So the
575- // one embedded should take precedence over the ones installed
576- // system wide (2.8).
577- addPathToQmlImport(applicationLocalSearchPath);
578-
579 qDebug() << "Setting import path to: "
580 << qgetenv("QML2_IMPORT_PATH").data();
581 }
582
583-QString pluginPathForCurrentArchitecture()
584-{
585-#if defined(__i386__)
586- return QLatin1String("/lib/i386-linux-gnu");
587-#elif defined(__x86_64__)
588- return QLatin1String("/lib/x86_64-linux-gnu");
589-#elif defined(__arm__)
590- return QLatin1String("/lib/arm-linux-gnueabihf");
591-#else
592-#error Unable to determine target architecture
593-#endif
594-}
595-
596
597 void usage()
598 {
599@@ -138,10 +123,16 @@
600 const QString ARG_HEADER = "--";
601 const QString VALUE_HEADER = "=";
602 const QString INSPECTOR = "--inspector";
603+ const QString OXIDE = "--oxide";
604
605 QString wwwfolderArg;
606 bool maximized = false;
607
608+ QString remoteInspectorHost = "";
609+ QString remoteInspectorPort = QString::number(REMOTE_INSPECTOR_PORT);
610+ bool remoteInspectorEnabled = false;
611+ bool useOxide = false;
612+
613 QStringList arguments = app.arguments();
614 arguments.pop_front();
615
616@@ -149,7 +140,12 @@
617 {
618 if (argument.contains(WWW_LOCATION_ARG_HEADER))
619 {
620- wwwfolderArg = argument.right(argument.count() - WWW_LOCATION_ARG_HEADER.count());
621+ wwwfolderArg = argument.split(WWW_LOCATION_ARG_HEADER)[1];
622+ }
623+ else
624+ if (argument == OXIDE)
625+ {
626+ useOxide = true;
627 }
628 else
629 if (argument.contains(MAXIMIZED_ARG_HEADER))
630@@ -157,22 +153,18 @@
631 maximized = true;
632 }
633 else
634- if (argument.contains(INSPECTOR))
635+ if (argument.startsWith(INSPECTOR))
636 {
637- QString host;
638+ remoteInspectorEnabled = true;
639 Q_FOREACH(QHostAddress address, QNetworkInterface::allAddresses()) {
640 if (!address.isLoopback() && (address.protocol() == QAbstractSocket::IPv4Protocol)) {
641- host = address.toString();
642+ remoteInspectorHost = address.toString();
643 break;
644 }
645 }
646- QString server;
647- if (host.isEmpty()) {
648- server = QString::number(REMOTE_INSPECTOR_PORT);
649- } else {
650- server = QString("%1:%2").arg(host, QString::number(REMOTE_INSPECTOR_PORT));
651+ if (argument.startsWith(INSPECTOR + "=")) {
652+ remoteInspectorPort = argument.split(INSPECTOR + "=")[1];
653 }
654- qputenv("QTWEBKIT_INSPECTOR_SERVER", server.toUtf8());
655 }
656 else
657 {
658@@ -188,7 +180,6 @@
659 }
660
661 QFileInfo wwwFolder(wwwfolderArg);
662-
663 if (wwwFolder.isRelative())
664 {
665 wwwFolder.makeAbsolute();
666@@ -211,13 +202,38 @@
667 QString appPkgName = qgetenv("APP_ID").split('_').first();
668 QCoreApplication::setApplicationName(appPkgName);
669 }
670-
671- QString plugin_path = wwwFolder.absoluteFilePath() + "/.." +
672- pluginPathForCurrentArchitecture();
673-
674- setUpQmlImportPathIfNecessary(plugin_path);
675+ setUpQmlImportPathIfNecessary();
676+
677+ // Enable compositing in oxide
678+ if (useOxide)
679+ {
680+ QOpenGLContext* glcontext = new QOpenGLContext();
681+ glcontext->create();
682+#if QT_VERSION < QT_VERSION_CHECK(5, 3, 0)
683+ QSGContext::setSharedOpenGLContext(glcontext);
684+#elif QT_VERSION < QT_VERSION_CHECK(5, 4, 0)
685+ QOpenGLContextPrivate::setGlobalShareContext(glcontext);
686+#else
687+ qt_gl_set_global_share_context(glcontext);
688+#endif
689+ }
690
691 QQuickView view;
692+ QQmlEngine* engine = view.engine();
693+ engine->rootContext()->setContextProperty("withOxide", useOxide);
694+
695+ if (remoteInspectorEnabled && useOxide) {
696+ qputenv("UBUNTU_WEBVIEW_DEVTOOLS_HOST", remoteInspectorHost.toUtf8());
697+ qputenv("UBUNTU_WEBVIEW_DEVTOOLS_PORT", remoteInspectorPort.toUtf8());
698+ }
699+
700+ engine->rootContext()->setContextProperty("inspector", remoteInspectorEnabled);
701+ engine->rootContext()->setContextProperty("wwwFolder", wwwFolder.absoluteFilePath());
702+
703+ if (remoteInspectorEnabled) {
704+ qputenv("QTWEBKIT_INSPECTOR_SERVER", remoteInspectorPort.toUtf8());
705+ }
706+
707 view.setSource(QUrl::fromLocalFile(Webapp::Config::getContainerMainQmlPath()
708 + "/main.qml"));
709 if (view.status() != QQuickView::Ready)
710@@ -225,7 +241,6 @@
711 qCritical() << "Main application component cannot be loaded.";
712 return EXIT_FAILURE;
713 }
714- view.rootObject()->setProperty("htmlIndexDirectory", wwwFolder.canonicalFilePath());
715
716 view.setTitle(QCoreApplication::applicationName());
717 view.setResizeMode(QQuickView::SizeRootObjectToView);
718@@ -239,6 +254,3 @@
719
720 return app.exec();
721 }
722-
723-
724-
725
726=== modified file 'src/ubuntu-html5-app-launcher/main.qml'
727--- src/ubuntu-html5-app-launcher/main.qml 2014-12-08 18:08:39 +0000
728+++ src/ubuntu-html5-app-launcher/main.qml 2015-01-09 00:53:11 +0000
729@@ -23,5 +23,8 @@
730 WebAppContainer {
731 width: units.gu(100)
732 height: units.gu(75)
733+
734+ oxide: withOxide
735+ remoteInspectorEnabled: inspector
736+ htmlIndexDirectory: wwwFolder
737 }
738-
739
740=== modified file 'tests/autopilot/tools/qml/webview.qml'
741--- tests/autopilot/tools/qml/webview.qml 2014-12-08 18:08:39 +0000
742+++ tests/autopilot/tools/qml/webview.qml 2015-01-09 00:53:11 +0000
743@@ -17,8 +17,8 @@
744 */
745
746 import QtQuick 2.0
747-import QtWebKit 3.0
748-import QtWebKit.experimental 1.0
749+import QtTest 1.0
750+import com.canonical.Oxide 1.0 as Oxide
751
752 Item {
753 id: root
754@@ -31,6 +31,8 @@
755
756 signal resultUpdated(string message)
757
758+ TestResult { id: qtest_testResult }
759+
760 function __gentid() {
761 return Math.random() + '';
762 }
763@@ -64,23 +66,21 @@
764 var tid = __gentid();
765 var statement = 'document.getElementById("' + id + '").click();';
766
767- webview.experimental.evaluateJavaScript(__wrapJsCommands(statement),
768- function(result) { root.resultUpdated(root.__createResult(result)); });
769+ var result = webview.evaluateCode(statement, true);
770+ root.resultUpdated(root.__createResult(result, tid));
771 }
772
773 function evalInPageUnsafe(expr) {
774- var tid = __gentid();
775-
776- webview.experimental.evaluateJavaScript(__wrapJsCommands(expr),
777- function(result) { root.resultUpdated(root.__createResult(result)); });
778+ var result = webview.evaluateCode(expr, true);
779+ root.resultUpdated(result.toString())
780 }
781
782 function clickAnyElementBySelector(selector) {
783 var tid = __gentid();
784 var statement = 'document.querySelectorAll("' + selector + '")[0].click();';
785
786- webview.experimental.evaluateJavaScript(__wrapJsCommands(statement),
787- function(result) { root.resultUpdated(root.__createResult(result)); });
788+ var result = webview.evaluateCode(statement, true);
789+ root.resultUpdated(root.__createResult(result, tid));
790 }
791
792 function elementWithIdHasAttribute(id,attribute,value) {
793@@ -95,13 +95,13 @@
794 statement += hasAttributeWithIdFunc;
795 statement += "; return __hasAttributeWithId(id,attribute,value); "
796
797- webview.experimental.evaluateJavaScript(__wrapJsCommands(statement),
798- function(result) { root.resultUpdated(root.__createResult(result, tid)); });
799+ var result = webview.evaluateCode(statement, true);
800+ root.resultUpdated(root.__createResult(result, tid));
801 }
802
803 function isNodeWithIdVisible(id) {
804 var tid = __gentid();
805- var isNodeWithIdVisibleFunc = '
806+ var isNodeWithIdVisibleFunc = '
807 function __isNodeWithIdVisible() {
808 try { return document.getElementById(id).style.display !== "none"; } catch (e) { return e.toString(); };
809 return false;
810@@ -110,14 +110,15 @@
811 var statement = __setupClosedVariables({'id': id});
812 statement += isNodeWithIdVisibleFunc;
813 statement += "; return __isNodeWithIdVisible(id); "
814- webview.experimental.evaluateJavaScript(__wrapJsCommands(statement),
815- function(result) { root.resultUpdated(root.__createResult(result, tid)); });
816+
817+ var result = webview.evaluateCode(statement, true);
818+ root.resultUpdated(root.__createResult(result, tid));
819 }
820
821 function getAttributeForElementWithId(id,attribute) {
822 var tid = __gentid();
823 var getAttributeWithIdFunc = '
824- function __getAttributeWithId() {
825+ function __getAttributeWithId() {
826 try { var value = document.querySelector("#" + id).getAttribute(attribute); return value || ""; } catch (e) { return e.toString(); };
827 return "";
828 };';
829@@ -126,11 +127,11 @@
830 statement += getAttributeWithIdFunc;
831 statement += "; return __getAttributeWithId(); "
832
833- webview.experimental.evaluateJavaScript(__wrapJsCommands(statement),
834- function(result) { root.resultUpdated(root.__createResult(result, tid)); });
835+ var result = webview.evaluateCode(statement, true);
836+ root.resultUpdated(root.__createResult(result, tid));
837 }
838
839- WebView {
840+ Oxide.WebView {
841 objectName: "webview"
842 id: webview
843
844@@ -146,12 +147,77 @@
845 left: parent.left
846 }
847
848- experimental.userScripts: []
849- experimental.preferences.navigatorQtObjectEnabled: true
850- experimental.preferences.developerExtrasEnabled: true
851-
852- experimental.userAgent: {
853- 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"
854+ preferences.localStorageEnabled: true
855+ preferences.appCacheEnabled: true
856+
857+ function evaluateCode(code, wrap) {
858+ var value = webview._waitForResult(
859+ webview.rootFrame.sendMessage(
860+ "oxide://main-world",
861+ "EVALUATE-CODE",
862+ { code: code,
863+ wrap: wrap === undefined ? false : wrap }));
864+ return value ? value.result : undefined;
865+ }
866+
867+ function _waitForResult(req, timeout) {
868+ var result;
869+ var error;
870+ req.onreply = function(response) {
871+ result = response;
872+ error = 0;
873+ };
874+ req.onerror = function(error_code, msg) {
875+ result = msg;
876+ error = error_code;
877+ };
878+ webview._waitFor(function() { return error !== undefined; },
879+ timeout);
880+
881+ if (error > 0) {
882+ console.error('Error:' + error + ', result:' + result)
883+ } else if (error === 0) {
884+ return result;
885+ } else {
886+ throw new Error("Message call timed out");
887+ }
888+ }
889+
890+ function _waitFor(predicate, timeout) {
891+ timeout = timeout || 5000000;
892+ var end = Date.now() + timeout;
893+ var i = Date.now();
894+ while (i < end && !predicate()) {
895+ qtest_testResult.wait(50);
896+ i = Date.now();
897+ }
898+ return predicate();
899+ }
900+
901+ context: Oxide.WebContext {
902+ userScripts: [
903+ Oxide.UserScript {
904+ context: "oxide://main-world"
905+ emulateGreasemonkey: true
906+ url: Qt.resolvedUrl("message-server.js")
907+ matchAllFrames: true
908+ }
909+ ]
910+ }
911+
912+ onJavaScriptConsoleMessage: {
913+ var msg = "[JS] (%1:%2) %3".arg(sourceId).arg(lineNumber).arg(message)
914+ if (level === Oxide.WebView.LogSeverityVerbose) {
915+ console.log(msg)
916+ } else if (level === Oxide.WebView.LogSeverityInfo) {
917+ console.info(msg)
918+ } else if (level === Oxide.WebView.LogSeverityWarning) {
919+ console.warn(msg)
920+ } else if ((level === Oxide.WebView.LogSeverityError) ||
921+ (level === Oxide.WebView.LogSeverityErrorReport) ||
922+ (level === Oxide.WebView.LogSeverityFatal)) {
923+ console.error(msg)
924+ }
925 }
926 }
927
928
929=== modified file 'tests/autopilot/ubuntu_html5_container/__init__.py'
930--- tests/autopilot/ubuntu_html5_container/__init__.py 2014-12-08 18:08:39 +0000
931+++ tests/autopilot/ubuntu_html5_container/__init__.py 2015-01-09 00:53:11 +0000
932@@ -2,9 +2,7 @@
933 # Copyright 2014 Canonical
934 #
935 # This program is free software: you can redistribute it and/or modify it
936-# under the terms of the GNU Lesser General Public License version 3, as published
937-# by the Free Software Foundation.
938+# under the terms of the GNU Lesser General Public License version 3, as
939+# published by the Free Software Foundation.
940
941 """Tests for the Ubuntu HTML5 Launcher package """
942-
943-
944
945=== removed directory 'tests/autopilot/ubuntu_html5_container/emulators'
946=== removed file 'tests/autopilot/ubuntu_html5_container/emulators/__init__.py'
947--- tests/autopilot/ubuntu_html5_container/emulators/__init__.py 2014-12-08 18:08:39 +0000
948+++ tests/autopilot/ubuntu_html5_container/emulators/__init__.py 1970-01-01 00:00:00 +0000
949@@ -1,10 +0,0 @@
950-# -*- Mode: Python; coding: utf-8; indent-tabs-mode: nil; tab-width: 4 -*-
951-# Copyright 2014 Canonical
952-#
953-# This program is free software: you can redistribute it and/or modify it
954-# under the terms of the GNU Lesser General Public License version 3, as published
955-# by the Free Software Foundation.
956-
957-"""Tests for the Ubuntu HTML5 Launcher package """
958-
959-
960
961=== modified file 'tests/autopilot/ubuntu_html5_container/tests/__init__.py'
962--- tests/autopilot/ubuntu_html5_container/tests/__init__.py 2014-12-08 18:08:39 +0000
963+++ tests/autopilot/ubuntu_html5_container/tests/__init__.py 2015-01-09 00:53:11 +0000
964@@ -2,18 +2,22 @@
965 # Copyright 2014 Canonical
966 #
967 # This program is free software: you can redistribute it and/or modify it
968-# under the terms of the GNU Lesser General Public License version 3, as published
969-# by the Free Software Foundation.
970+# under the terms of the GNU Lesser General Public License version 3, as
971+# published by the Free Software Foundation.
972
973 """Tests for the Ubuntu HTML5 Launcher package """
974
975 import os
976 from autopilot.testcase import AutopilotTestCase
977
978+
979 LAUNCHER_EXEC_NAME = 'ubuntu-html5-app-launcher'
980
981-LOCAL_LAUNCHER_PATH = os.path.abspath("%s/%s" % (os.path.dirname(os.path.realpath(__file__))
982- , '../../../../src/ubuntu-html5-app-launcher/' + LAUNCHER_EXEC_NAME))
983+LOCAL_LAUNCHER_PATH = os.path.abspath(
984+ "{}/{}".format(
985+ os.path.dirname(os.path.realpath(__file__)),
986+ '../../../../src/ubuntu-html5-app-launcher/' + LAUNCHER_EXEC_NAME))
987+
988 INSTALLED_LAUNCHER_PATH = '/usr/bin/' + LAUNCHER_EXEC_NAME
989
990
991@@ -35,7 +39,8 @@
992
993 def launch_with_argument(self, args):
994 try:
995- self.app = self.launch_test_application(self.get_launcher_path(), args)
996- except Exception, e:
997+ self.app = self.launch_test_application(
998+ self.get_launcher_path(),
999+ args)
1000+ except Exception:
1001 pass
1002-
1003
1004=== modified file 'tests/autopilot/ubuntu_html5_container/tests/test_appLaunch.py'
1005--- tests/autopilot/ubuntu_html5_container/tests/test_appLaunch.py 2014-12-08 18:08:39 +0000
1006+++ tests/autopilot/ubuntu_html5_container/tests/test_appLaunch.py 2015-01-09 00:53:11 +0000
1007@@ -2,12 +2,12 @@
1008 # Copyright 2014 Canonical
1009 #
1010 # This program is free software: you can redistribute it and/or modify it
1011-# under the terms of the GNU Lesser General Public License version 3, as published
1012-# by the Free Software Foundation.
1013+# under the terms of the GNU Lesser General Public License version 3, as
1014+# published by the Free Software Foundation.
1015
1016 from __future__ import absolute_import
1017
1018-from testtools.matchers import Equals
1019+from testtools.matchers import NotEquals
1020
1021 from ubuntu_html5_container.tests import UbuntuHtml5LauncherTestCase
1022
1023@@ -16,7 +16,6 @@
1024 def setUp(self):
1025 super(UbuntuHtml5LauncherAppLaunchTestCase, self).setUp()
1026
1027- def test_launcherFailsWithNoWWW(self):
1028+ def test_launcher_succeeds_with_no_www(self):
1029 self.launch_with_argument('')
1030- self.assertThat(self.get_app(), Equals(None))
1031-
1032+ self.assertThat(self.get_app(), NotEquals(None))
1033
1034=== modified file 'tests/autopilot/ubuntu_html5_ui_toolkit/__init__.py'
1035--- tests/autopilot/ubuntu_html5_ui_toolkit/__init__.py 2014-12-08 18:08:39 +0000
1036+++ tests/autopilot/ubuntu_html5_ui_toolkit/__init__.py 2015-01-09 00:53:11 +0000
1037@@ -2,8 +2,7 @@
1038 # Copyright 2013 Canonical
1039 #
1040 # This program is free software: you can redistribute it and/or modify it
1041-# under the terms of the GNU Lesser General Public License version 3, as published
1042-# by the Free Software Foundation.
1043+# under the terms of the GNU Lesser General Public License version 3, as
1044+# published by the Free Software Foundation.
1045
1046 """Tests for the Ubuntu HTML5 UI SDK package """
1047-
1048
1049=== removed directory 'tests/autopilot/ubuntu_html5_ui_toolkit/emulators'
1050=== removed file 'tests/autopilot/ubuntu_html5_ui_toolkit/emulators/__init__.py'
1051--- tests/autopilot/ubuntu_html5_ui_toolkit/emulators/__init__.py 2014-12-08 18:08:39 +0000
1052+++ tests/autopilot/ubuntu_html5_ui_toolkit/emulators/__init__.py 1970-01-01 00:00:00 +0000
1053@@ -1,10 +0,0 @@
1054-# -*- Mode: Python; coding: utf-8; indent-tabs-mode: nil; tab-width: 4 -*-
1055-# Copyright 2013 Canonical
1056-#
1057-# This program is free software: you can redistribute it and/or modify it
1058-# under the terms of the GNU Lesser General Public License version 3, as published
1059-# by the Free Software Foundation.
1060-
1061-"""Tests for the Ubuntu HTML5 UI SDK package """
1062-
1063-
1064
1065=== modified file 'tests/autopilot/ubuntu_html5_ui_toolkit/tests/__init__.py'
1066--- tests/autopilot/ubuntu_html5_ui_toolkit/tests/__init__.py 2014-12-08 18:08:39 +0000
1067+++ tests/autopilot/ubuntu_html5_ui_toolkit/tests/__init__.py 2015-01-09 00:53:11 +0000
1068@@ -2,20 +2,20 @@
1069 # Copyright 2013 Canonical
1070 #
1071 # This program is free software: you can redistribute it and/or modify it
1072-# under the terms of the GNU Lesser General Public License version 3, as published
1073-# by the Free Software Foundation.
1074+# under the terms of the GNU Lesser General Public License version 3, as
1075+# published by the Free Software Foundation.
1076
1077 """Tests for the Ubuntu HTML5 package """
1078
1079 import os
1080 import json
1081-import BaseHTTPServer
1082+import http.server as http
1083 import threading
1084 import subprocess
1085
1086 HTTP_SERVER_PORT = 8383
1087
1088-from testtools.matchers import Contains, Equals, GreaterThan
1089+from testtools.matchers import Equals, GreaterThan
1090 from autopilot.matchers import Eventually
1091 from autopilot.testcase import AutopilotTestCase
1092 from autopilot.input import Mouse, Touch, Pointer
1093@@ -25,14 +25,17 @@
1094 # from autopilot.introspection.qt import QtIntrospectionTestMixin
1095
1096
1097-class RequestHandler(BaseHTTPServer.BaseHTTPRequestHandler):
1098- BASE_PATH_FOR_SERVED_APPS = {'rss-reader': "%s/%s" % (os.path.dirname(os.path.realpath(__file__)), '../../../../0.1/examples/apps/rss-reader')}
1099+class RequestHandler(http.BaseHTTPRequestHandler):
1100+ BASE_PATH_FOR_SERVED_APPS = {'rss-reader': "{}/{}".format(
1101+ os.path.dirname(os.path.realpath(__file__)),
1102+ '../../../../0.1/examples/apps/rss-reader')}
1103
1104 def get_served_filename(self, appname, filename):
1105 if len(filename) == 0 or filename == '/':
1106 filename = 'autopilot.html'
1107- print os.path.join(self.BASE_PATH_FOR_SERVED_APPS[appname], filename)
1108- return os.path.join(self.BASE_PATH_FOR_SERVED_APPS[appname], filename)
1109+ return os.path.join(
1110+ self.BASE_PATH_FOR_SERVED_APPS[appname],
1111+ filename)
1112
1113 def serve_file(self, filename):
1114 import mimetypes
1115@@ -51,7 +54,10 @@
1116 if self.path.startswith('/rss-reader'):
1117 filename = self.path[len('/rss-reader'):]
1118 self.send_response(200)
1119- self.serve_file(self.get_served_filename('rss-reader', filename))
1120+ self.serve_file(
1121+ self.get_served_filename(
1122+ 'rss-reader',
1123+ filename))
1124 else:
1125 self.send_error(404)
1126
1127@@ -59,7 +65,9 @@
1128 class UbuntuHTML5HTTPServer(threading.Thread):
1129 def __init__(self, port):
1130 super(UbuntuHTML5HTTPServer, self).__init__()
1131- self.server = BaseHTTPServer.HTTPServer(("", port), RequestHandler)
1132+ self.server = http.BaseHTTPServer.HTTPServer(
1133+ ("", port),
1134+ RequestHandler)
1135 self.server.allow_reuse_address = True
1136
1137 def run(self):
1138@@ -71,15 +79,22 @@
1139
1140
1141 class UbuntuHTML5TestCaseBase(AutopilotTestCase):
1142- BROWSER_CONTAINER_PATH = "%s/%s" % (os.path.dirname(os.path.realpath(__file__)), '../../tools/qml/webview.qml')
1143- INSTALLED_BROWSER_CONTAINER_PATH = '/usr/share/ubuntu-html5-ui-toolkit/tests/tools/qml/webview.qml'
1144- arch = subprocess.check_output(
1145- ["dpkg-architecture", "-qDEB_HOST_MULTIARCH"]).strip()
1146- BROWSER_QML_APP_LAUNCHER = "/usr/lib/" + arch + "/qt5/bin/qmlscene"
1147+ BROWSER_CONTAINER_PATH = "{}/{}".format(
1148+ os.path.dirname(os.path.realpath(__file__)),
1149+ '../../tools/qml/webview.qml')
1150+ INSTALLED_BROWSER_CONTAINER_PATH = \
1151+ '/usr/share/ubuntu-html5-ui-toolkit/tests/tools/qml/webview.qml'
1152+ BROWSER_QML_APP_LAUNCHER = "/usr/lib/{}/qt5/bin/qmlscene".format(
1153+ subprocess.check_output(
1154+ ["dpkg-architecture", "-qDEB_HOST_MULTIARCH"]).strip().decode('utf-8'))
1155
1156 # TODO: fix version
1157- LOCAL_HTML_EXAMPLES_PATH = os.path.abspath("%s/%s" % (os.path.dirname(os.path.realpath(__file__)), '../../../../tests'))
1158- INSTALLED_HTML_EXAMPLES_PATH = '/usr/share/ubuntu-html5-ui-toolkit/tests/'
1159+ LOCAL_HTML_EXAMPLES_PATH = os.path.abspath(
1160+ "{}/{}".format(
1161+ os.path.dirname(os.path.realpath(__file__)),
1162+ '../../../../tests'))
1163+ INSTALLED_HTML_EXAMPLES_PATH = \
1164+ '/usr/share/ubuntu-html5-ui-toolkit/tests/'
1165
1166 APPS_SUBFOLDER_NAME = 'apps'
1167
1168@@ -106,16 +121,20 @@
1169 else:
1170 self.pointer = Pointer(Touch.create())
1171
1172- params = [self.BROWSER_QML_APP_LAUNCHER, self.get_browser_container_path()]
1173- if (platform.model() <> 'Desktop'):
1174- params.append('--desktop_file_hint=/usr/share/applications/unitywebappsqmllauncher.desktop')
1175+ params = [self.BROWSER_QML_APP_LAUNCHER,
1176+ self.get_browser_container_path()]
1177+ if (platform.model() != 'Desktop'):
1178+ params.append(
1179+ '--desktop_file_hint=/usr/share/" \
1180+ + "applications/unitywebappsqmllauncher.desktop')
1181
1182 self.app = self.launch_test_application(
1183 *params,
1184 app_type='qt')
1185
1186 self.webviewContainer = self.get_webviewContainer()
1187- self.watcher = self.webviewContainer.watch_signal('resultUpdated(QString)')
1188+ self.watcher = self.webviewContainer.watch_signal(
1189+ 'resultUpdated(QString)')
1190 super(UbuntuHTML5TestCaseBase, self).setUp()
1191
1192 def tearDown(self):
1193@@ -143,40 +162,60 @@
1194
1195 def assert_url_eventually_loaded(self, url):
1196 webview = self.get_webview()
1197- self.assertThat(webview.loadProgress, Eventually(Equals(100)))
1198- self.assertThat(webview.loading, Eventually(Equals(False)))
1199- self.assertThat(webview.url, Eventually(Equals(url)))
1200+ self.assertThat(
1201+ webview.loadProgress,
1202+ Eventually(Equals(100)))
1203+ self.assertThat(
1204+ webview.loading,
1205+ Eventually(Equals(False)))
1206+ self.assertThat(
1207+ webview.url,
1208+ Eventually(Equals(url)))
1209
1210 def click_dom_node_with_id(self, id):
1211 webview = self.get_webviewContainer()
1212 webview.slots.clickElementById(id)
1213- self.assertThat(lambda: self.watcher.num_emissions, Eventually(Equals(1)))
1214+ self.assertThat(
1215+ lambda: self.watcher.num_emissions,
1216+ Eventually(Equals(1)))
1217
1218 def click_any_dom_node_by_selector(self, selector):
1219 webview = self.get_webviewContainer()
1220 webview.slots.clickAnyElementBySelector(selector)
1221- self.assertThat(lambda: self.watcher.num_emissions, Eventually(Equals(1)))
1222+ self.assertThat(
1223+ lambda: self.watcher.num_emissions,
1224+ Eventually(Equals(1)))
1225
1226 def is_dom_node_visible(self, id):
1227 webview = self.get_webviewContainer()
1228 prev_emissions = self.watcher.num_emissions
1229 webview.slots.isNodeWithIdVisible(id)
1230- self.assertThat(lambda: self.watcher.num_emissions, Eventually(GreaterThan(prev_emissions)))
1231- return json.loads(webview.get_signal_emissions('resultUpdated(QString)')[-1][0])['result']
1232+ self.assertThat(
1233+ lambda: self.watcher.num_emissions,
1234+ Eventually(GreaterThan(prev_emissions)))
1235+ return json.loads(
1236+ webview.get_signal_emissions(
1237+ 'resultUpdated(QString)')[-1][0])['result']
1238
1239 def eval_expression_in_page_unsafe(self, expr):
1240 webview = self.get_webviewContainer()
1241 prev_emissions = self.watcher.num_emissions
1242- webview.slots.evalInPageUnsafe(expr)
1243- self.assertThat(lambda: self.watcher.num_emissions, Eventually(GreaterThan(prev_emissions)))
1244- return json.loads(webview.get_signal_emissions('resultUpdated(QString)')[-1][0])['result']
1245+ result = webview.slots.evalInPageUnsafe(expr)
1246+ self.assertThat(
1247+ lambda: self.watcher.num_emissions,
1248+ Eventually(GreaterThan(prev_emissions)))
1249+ return webview.get_signal_emissions('resultUpdated(QString)')[-1][0]
1250
1251 def get_dom_node_id_attribute(self, id, attribute):
1252 webview = self.get_webviewContainer()
1253 prev_emissions = self.watcher.num_emissions
1254 webview.slots.getAttributeForElementWithId(id, attribute)
1255- self.assertThat(lambda: self.watcher.num_emissions, Eventually(GreaterThan(prev_emissions)))
1256- return json.loads(webview.get_signal_emissions('resultUpdated(QString)')[-1][0])['result']
1257+ self.assertThat(
1258+ lambda: self.watcher.num_emissions,
1259+ Eventually(GreaterThan(prev_emissions)))
1260+ return json.loads(
1261+ webview.get_signal_emissions(
1262+ 'resultUpdated(QString)')[-1][0])['result']
1263
1264 def get_address_bar_action_button(self):
1265 addressbar = self.get_addressbar()
1266@@ -185,23 +224,29 @@
1267 def browse_to_url(self, url):
1268 import time
1269 addressbar = self.get_addressbar()
1270- self.assertThat(addressbar.activeFocus, Eventually(Equals(True)))
1271+ self.assertThat(
1272+ addressbar.activeFocus,
1273+ Eventually(Equals(True)))
1274
1275 self.keyboard.type(url, 0.001)
1276
1277 self.pointer.click_object(self.get_webview())
1278+
1279+ # XXX: very bad, but wont fix
1280 time.sleep(1)
1281
1282- button = self.get_address_bar_action_button();
1283+ button = self.get_address_bar_action_button()
1284 self.pointer.move_to_object(button)
1285 self.pointer.press()
1286+ # XXX: very bad, but wont fix
1287 time.sleep(1)
1288 self.pointer.release()
1289
1290- self.assert_url_eventually_loaded(url);
1291+ self.assert_url_eventually_loaded(url)
1292
1293 def browse_to_app(self, appname):
1294- appfilepath = os.path.abspath(self.BASE_PATH +
1295+ appfilepath = os.path.abspath(
1296+ self.BASE_PATH +
1297 '/data/html/' +
1298 self.APPS_SUBFOLDER_NAME +
1299 '/' +
1300@@ -213,7 +258,12 @@
1301 self.browse_to_url(APP_HTML_PATH)
1302
1303 def browse_to_test_html(self, html_filename):
1304- self.browse_to_url(self.create_file_url_from(os.path.abspath(self.BASE_PATH + '/data/html/' + html_filename)))
1305+ self.browse_to_url(
1306+ self.create_file_url_from(
1307+ os.path.abspath(
1308+ '{}/data/html/{}'.format(
1309+ self.BASE_PATH,
1310+ html_filename))))
1311
1312
1313 class UbuntuThemeWithHttpServerTestCaseBase(UbuntuHTML5TestCaseBase):
1314
1315=== modified file 'tests/autopilot/ubuntu_html5_ui_toolkit/tests/test_pagestack.py'
1316--- tests/autopilot/ubuntu_html5_ui_toolkit/tests/test_pagestack.py 2014-12-08 18:08:39 +0000
1317+++ tests/autopilot/ubuntu_html5_ui_toolkit/tests/test_pagestack.py 2015-01-09 00:53:11 +0000
1318@@ -2,17 +2,16 @@
1319 # Copyright 2013 Canonical
1320 #
1321 # This program is free software: you can redistribute it and/or modify it
1322-# under the terms of the GNU Lesser General Public License version 3, as published
1323-# by the Free Software Foundation.
1324+# under the terms of the GNU Lesser General Public License version 3, as
1325+# published by the Free Software Foundation.
1326
1327 from __future__ import absolute_import
1328
1329-import time
1330-
1331-from testtools.matchers import Contains, Equals
1332+from testtools.matchers import Equals
1333 from autopilot.matchers import Eventually
1334
1335-from ubuntu_html5_ui_toolkit.tests import UbuntuHTML5TestCaseBase, UbuntuThemeRemotePageTestCaseBase
1336+from ubuntu_html5_ui_toolkit.tests import UbuntuHTML5TestCaseBase
1337+
1338
1339 class UbuntuThemePageStackTestCase(UbuntuHTML5TestCaseBase):
1340
1341@@ -21,25 +20,54 @@
1342
1343 def test_pageLoadsWithNoPageStacks(self):
1344 self.browse_to_test_html('test-nopagestack-in-app.html')
1345- self.assertThat(self.eval_expression_in_page_unsafe('var UI = new UbuntuUI(); UI.init(); return "ok";'), Equals('ok'));
1346+ self.assertThat(
1347+ self.eval_expression_in_page_unsafe(
1348+ 'var UI = new UbuntuUI(); UI.init(); return "ok";'),
1349+ Equals('ok'))
1350
1351 def test_pageLoadsWithPageStacks(self):
1352 self.browse_to_test_html('test-pagestack-in-app.html')
1353- self.assertThat(self.eval_expression_in_page_unsafe('var UI = new UbuntuUI(); UI.init(); return "ok";'), Equals('ok'));
1354- self.assertThat(self.is_dom_node_visible('main'), Equals(True))
1355+ self.assertThat(
1356+ self.eval_expression_in_page_unsafe(
1357+ 'var UI = new UbuntuUI(); UI.init(); return "ok";'),
1358+ Equals('ok'))
1359+ self.assertThat(
1360+ self.is_dom_node_visible('main'),
1361+ Equals(True))
1362
1363 def test_pageChangeWithPageStackPush(self):
1364 self.browse_to_test_html('test-pagestack-in-app.html')
1365- self.assertThat(self.eval_expression_in_page_unsafe('var UI = new UbuntuUI(); UI.init(); UI.pagestack.push("results"); return "ok";'), Equals('ok'));
1366- self.assertThat(self.is_dom_node_visible('main'), Equals(False))
1367- self.assertThat(self.is_dom_node_visible('results'), Equals(True))
1368+ self.assertThat(
1369+ self.eval_expression_in_page_unsafe(
1370+ 'var UI = new UbuntuUI(); UI.init(); '
1371+ 'UI.pagestack.push("results"); return "ok";'),
1372+ Equals('ok'))
1373+ self.assertThat(
1374+ self.is_dom_node_visible('main'),
1375+ Equals(False))
1376+ self.assertThat(
1377+ self.is_dom_node_visible('results'),
1378+ Equals(True))
1379
1380 def test_pageChangeWithPageStackPopped(self):
1381 self.browse_to_test_html('test-pagestack-in-app.html')
1382- 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'));
1383- self.assertThat(self.is_dom_node_visible('main'), Equals(False))
1384- self.assertThat(self.is_dom_node_visible('results'), Equals(True))
1385- self.assertThat(self.is_dom_node_visible('article'), Equals(False))
1386+ self.assertThat(
1387+ self.eval_expression_in_page_unsafe(
1388+ 'var UI = new UbuntuUI(); UI.init(); '
1389+ 'UI.pagestack.push("main"); '
1390+ 'UI.pagestack.push("results"); '
1391+ 'UI.pagestack.push("article"); '
1392+ 'UI.pagestack.pop(); return "ok";'),
1393+ Equals('ok'))
1394+ self.assertThat(
1395+ self.is_dom_node_visible('main'),
1396+ Equals(False))
1397+ self.assertThat(
1398+ self.is_dom_node_visible('results'),
1399+ Equals(True))
1400+ self.assertThat(
1401+ self.is_dom_node_visible('article'),
1402+ Equals(False))
1403
1404 def test_pagePushWithProperties(self):
1405 self.browse_to_test_html('test-pagestack-in-app.html')
1406@@ -50,14 +78,22 @@
1407
1408 (new Page('results')).onactivated(
1409 function(properties) {
1410- document.getElementById('results').innerHTML = JSON.stringify(properties);
1411+ document.getElementById('results').innerHTML =
1412+ JSON.stringify(properties);
1413 });
1414
1415 ui.pagestack.push('results', 'WORKS');
1416 return 'ok';
1417 """
1418- self.assertThat(self.eval_expression_in_page_unsafe(expression), Equals('ok'));
1419- self.assertThat(lambda: self.is_dom_node_visible('results'), Eventually(Equals(True)))
1420- results_html_content = "return document.getElementById('results').innerHTML;"
1421- self.assertThat(self.eval_expression_in_page_unsafe(results_html_content), Equals('"WORKS"'));
1422-
1423+ self.assertThat(
1424+ self.eval_expression_in_page_unsafe(expression),
1425+ Equals('ok'))
1426+ self.assertThat(
1427+ lambda: self.is_dom_node_visible('results'),
1428+ Eventually(Equals(True)))
1429+ results_html_content = \
1430+ "return document.getElementById('results').innerHTML;"
1431+ self.assertThat(
1432+ self.eval_expression_in_page_unsafe(
1433+ results_html_content),
1434+ Equals('"WORKS"'))
1435
1436=== modified file 'tests/autopilot/ubuntu_html5_ui_toolkit/tests/test_rss_reader.py'
1437--- tests/autopilot/ubuntu_html5_ui_toolkit/tests/test_rss_reader.py 2014-12-08 18:08:39 +0000
1438+++ tests/autopilot/ubuntu_html5_ui_toolkit/tests/test_rss_reader.py 2015-01-09 00:53:11 +0000
1439@@ -2,17 +2,16 @@
1440 # Copyright 2013 Canonical
1441 #
1442 # This program is free software: you can redistribute it and/or modify it
1443-# under the terms of the GNU Lesser General Public License version 3, as published
1444-# by the Free Software Foundation.
1445+# under the terms of the GNU Lesser General Public License version 3, as
1446+# published by the Free Software Foundation.
1447
1448 from __future__ import absolute_import
1449
1450-import time
1451-
1452 from testtools.matchers import Contains, Equals
1453 from autopilot.matchers import Eventually
1454
1455-from ubuntu_html5_ui_toolkit.tests import UbuntuHTML5TestCaseBase, UbuntuThemeRemotePageTestCaseBase
1456+from ubuntu_html5_ui_toolkit.tests import UbuntuHTML5TestCaseBase
1457+
1458
1459 class UbuntuThemeRSSReaderTestCase(UbuntuHTML5TestCaseBase):
1460 def setUp(self):
1461@@ -29,6 +28,8 @@
1462
1463 def test_switchToFeedView(self):
1464 self.click_any_dom_node_by_selector('#yourfeeds li a')
1465- self.assertThat(lambda: self.is_dom_node_visible('main'), Eventually(Equals(False)))
1466+ self.assertThat(
1467+ lambda: self.is_dom_node_visible('main'),
1468+ Eventually(Equals(False)))
1469 self.assertThat(self.is_dom_node_visible('article'), Equals(False))
1470 self.assertThat(self.is_dom_node_visible('results'), Equals(True))
1471
1472=== modified file 'tests/autopilot/ubuntu_html5_ui_toolkit/tests/test_tabs.py'
1473--- tests/autopilot/ubuntu_html5_ui_toolkit/tests/test_tabs.py 2014-12-08 18:08:39 +0000
1474+++ tests/autopilot/ubuntu_html5_ui_toolkit/tests/test_tabs.py 2015-01-09 00:53:11 +0000
1475@@ -2,18 +2,17 @@
1476 # Copyright 2014 Canonical
1477 #
1478 # This program is free software: you can redistribute it and/or modify it
1479-# under the terms of the GNU Lesser General Public License version 3, as published
1480-# by the Free Software Foundation.
1481+# under the terms of the GNU Lesser General Public License version 3, as
1482+# published by the Free Software Foundation.
1483
1484 from __future__ import absolute_import
1485
1486-import time
1487-
1488-from testtools.matchers import Contains, Equals
1489+from testtools.matchers import Equals
1490 from autopilot.matchers import Eventually
1491
1492 from ubuntu_html5_ui_toolkit.tests import UbuntuHTML5TestCaseBase
1493
1494+
1495 class UbuntuUIToolkitTabsTestCase(UbuntuHTML5TestCaseBase):
1496
1497 def setUp(self):
1498@@ -21,11 +20,27 @@
1499
1500 def test_programaticTabSelectIndex(self):
1501 self.browse_to_test_html('test-tabs-in-app.html')
1502- self.assertThat(self.eval_expression_in_page_unsafe('var UI = new UbuntuUI(); UI.init(); UI.tabs.selectedTabIndex = 1; return "ok";'), Equals('ok'));
1503-
1504- self.assertThat(lambda: self.is_dom_node_visible('tab1'), Eventually(Equals(False)))
1505- self.assertThat(lambda: self.is_dom_node_visible('tab2'), Eventually(Equals(True)))
1506- self.assertThat(lambda: self.is_dom_node_visible('tab3'), Eventually(Equals(False)))
1507-
1508- self.assertThat(self.eval_expression_in_page_unsafe('var UI = new UbuntuUI(); UI.init(); return UI.tabs.selectedTabIndex = 1;'), Equals(1));
1509+ self.assertThat(
1510+ self.eval_expression_in_page_unsafe(
1511+ 'var UI = new UbuntuUI(); '
1512+ 'UI.init(); UI.tabs.selectedTabIndex = 1; '
1513+ 'return "ok";'),
1514+ Equals('ok'))
1515+
1516+ self.assertThat(
1517+ lambda: self.is_dom_node_visible('tab1'),
1518+ Eventually(Equals(False)))
1519+ self.assertThat(
1520+ lambda: self.is_dom_node_visible('tab2'),
1521+ Eventually(Equals(True)))
1522+ self.assertThat(
1523+ lambda: self.is_dom_node_visible('tab3'),
1524+ Eventually(Equals(False)))
1525+
1526+ self.assertThat(
1527+ self.eval_expression_in_page_unsafe(
1528+ 'var UI = new UbuntuUI(); '
1529+ 'UI.init(); '
1530+ 'return UI.tabs.selectedTabIndex;'),
1531+ Equals('1'))
1532

Subscribers

People subscribed via source and target branches