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
1=== modified file 'CMakeLists.txt'
2--- CMakeLists.txt 2014-02-06 22:51:33 +0000
3+++ CMakeLists.txt 2014-12-05 21:46:03 +0000
4@@ -26,5 +26,9 @@
5 add_custom_target(uninstall
6 COMMAND ${CMAKE_COMMAND} -P ${CMAKE_CURRENT_BINARY_DIR}/cmake_uninstall.cmake)
7
8+# make non compiled files (QML, JS, images, etc.) visible in QtCreator
9+file(GLOB_RECURSE NON_COMPILED_FILES *.qml *.js *.png *.py *.pot *.po *.qdoc *.qdocconf *.css *.html)
10+add_custom_target(NON_COMPILED_TARGET ALL SOURCES ${NON_COMPILED_FILES})
11+
12 add_subdirectory(src)
13 add_subdirectory(tests)
14
15=== modified file 'debian/control'
16--- debian/control 2014-09-22 21:12:32 +0000
17+++ debian/control 2014-12-05 21:46:03 +0000
18@@ -4,8 +4,7 @@
19 Maintainer: Michael Hall <mhall119@ubuntu.com>
20 Build-Depends: cmake (>= 2.8.9),
21 debhelper (>= 9),
22- libqt5webkit5-dev,
23- qml-module-qtwebkit,
24+ liboxideqt-qmlplugin (>= 1.2.0),
25 python (>= 2.7),
26 python-setuptools,
27 qt5-default,
28@@ -48,7 +47,7 @@
29 Package: ubuntu-html5-ui-toolkit-examples
30 Architecture: all
31 Depends: libjs-jquery,
32- qml-module-qtwebkit,
33+ liboxideqt-qmlplugin (>= 1.2.0),
34 qmlscene,
35 qtdeclarative5-qtquick2-plugin,
36 ubuntu-html5-ui-toolkit (= ${binary:Version}),
37@@ -66,7 +65,7 @@
38 libautopilot-qt (>= 1.4),
39 libjs-jquery,
40 libqt5test5,
41- qml-module-qtwebkit,
42+ liboxideqt-qmlplugin (>= 1.2.0),
43 python-xlib,
44 qmlscene,
45 qtdeclarative5-qtquick2-plugin,
46@@ -84,7 +83,7 @@
47 Package: ubuntu-html5-container
48 Architecture: any
49 Multi-Arch: foreign
50-Depends: qml-module-qtwebkit,
51+Depends: liboxideqt-qmlplugin (>= 1.3.5),
52 qmlscene,
53 qtdeclarative5-cordova-2.8-plugin,
54 qtdeclarative5-qtquick2-plugin,
55@@ -102,7 +101,7 @@
56 Architecture: all
57 Depends: libautopilot-qt (>= 1.4),
58 libqt5test5,
59- qml-module-qtwebkit,
60+ liboxideqt-qmlplugin (>= 1.2.0),
61 qtdeclarative5-qtquick2-plugin,
62 ubuntu-html5-container (>= ${binary:Version}),
63 ${misc:Depends},
64
65=== modified file 'src/plugin/Ubuntu/WebApps/CordovaLoader.qml'
66--- src/plugin/Ubuntu/WebApps/CordovaLoader.qml 2014-02-10 16:15:29 +0000
67+++ src/plugin/Ubuntu/WebApps/CordovaLoader.qml 2014-12-05 21:46:03 +0000
68@@ -23,6 +23,11 @@
69
70 property string htmlIndexDirectory
71
72+ // Remote Inspector Properties
73+ property string remoteInspectorEnabled
74+ property string remoteInspectorPort
75+ property string remoteInspectorHost
76+
77 // Cordova plugin instance
78 property var cordovaInstance: null
79
80
81=== modified file 'src/plugin/Ubuntu/WebApps/UbuntuJavascriptBindings.qml'
82--- src/plugin/Ubuntu/WebApps/UbuntuJavascriptBindings.qml 2014-02-10 17:58:49 +0000
83+++ src/plugin/Ubuntu/WebApps/UbuntuJavascriptBindings.qml 2014-12-05 21:46:03 +0000
84@@ -25,11 +25,13 @@
85
86 property var bindingMainWebview: null
87
88+ signal ready()
89+
90 /*!
91 \internal
92 */
93 function getUnityWebappsProxies() {
94- return UnityWebAppsUtils.makeProxiesForQtWebViewBindee(bindingMainWebview);
95+ return UnityWebAppsUtils.makeProxiesForWebViewBindee(bindingMainWebview);
96 }
97
98 /*!
99@@ -53,6 +55,8 @@
100 bindee: root
101 injectExtraUbuntuApis: true
102 requiresInit: false
103+
104+ onUserScriptsInjected: root.ready()
105 }
106 }
107 }
108
109=== modified file 'src/plugin/Ubuntu/WebApps/WebAppContainer.qml'
110--- src/plugin/Ubuntu/WebApps/WebAppContainer.qml 2014-03-29 15:04:02 +0000
111+++ src/plugin/Ubuntu/WebApps/WebAppContainer.qml 2014-12-05 21:46:03 +0000
112@@ -18,7 +18,6 @@
113
114 import QtQuick 2.0
115 import Ubuntu.Components 0.1
116-import Ubuntu.Components.Extras.Browser 0.1
117
118
119 /*!
120@@ -30,17 +29,31 @@
121 MainView {
122 id: root
123 objectName: "root"
124+
125 anchorToKeyboard: true
126 automaticOrientation: true
127
128 /*!
129 \preliminary
130+ The property defines if oxide is to be used as the webengine backend.
131+ */
132+ property bool oxide: true
133+
134+ /*!
135+ \preliminary
136 The property holds the path to the filesystem location where the 'index.html'
137 file can be found (root of the HTML5 application).
138
139 The path is absolute or relative to the current dir.
140 */
141- property alias htmlIndexDirectory: cordovaWebviewProvider.htmlIndexDirectory
142+ property string htmlIndexDirectory: ""
143+
144+ /*!
145+ \preliminary
146+ The properties hold whether the remote debugging interface should be enabled for the
147+ Web View. The host ip and port for accessing the remote interface should be provided.
148+ */
149+ property bool remoteInspectorEnabled: false
150
151 Page {
152 id: mainPage
153@@ -49,41 +62,6 @@
154 /*!
155 \internal
156 */
157- CordovaLoader {
158- id: cordovaWebviewProvider
159- anchors.fill: parent
160- onCreationError: {
161- mainPage._onCordovaCreationError();
162- }
163- onCreated: {
164- bindings.bindingMainWebview = Qt.binding(function() {
165- return cordovaInstance.mainWebview;
166- });
167- }
168- }
169-
170- /*!
171- \internal
172- */
173- function _onCordovaCreationError() {
174- mainPage._fallbackToWebview();
175- }
176-
177- /*!
178- \internal
179- */
180- function _fallbackToWebview() {
181- console.debug('Falling back on the plain Webview backend.')
182-
183- webviewFallbackComponentLoader.sourceComponent = Qt.binding(function() {
184- return root.htmlIndexDirectory.length !== 0
185- ? webviewFallbackComponent : null;
186- });
187- }
188-
189- /*!
190- \internal
191- */
192 function _getAppStartupIndexFileUri() {
193 return 'file://' + root.htmlIndexDirectory + '/index.html';
194 }
195@@ -92,38 +70,19 @@
196 \internal
197 */
198 Loader {
199- id: webviewFallbackComponentLoader
200+ id: webviewComponentLoader
201 anchors.fill: parent
202 onLoaded: {
203 bindings.bindingMainWebview = item;
204 }
205 }
206
207- /*!
208- \internal
209- */
210- Component {
211- id: webviewFallbackComponent
212- UbuntuWebView {
213- url: mainPage._getAppStartupIndexFileUri()
214-
215- experimental.preferences.localStorageEnabled: true
216- experimental.preferences.offlineWebApplicationCacheEnabled: true
217- experimental.preferences.universalAccessFromFileURLsAllowed: true
218- experimental.preferences.webGLEnabled: true
219-
220- experimental.databaseQuotaDialog: Item {
221- Timer {
222- interval: 1
223- running: true
224- onTriggered: {
225- model.accept(model.expectedUsage)
226- }
227- }
228- }
229- // port in QTWEBKIT_INSPECTOR_SERVER enviroment variable
230- experimental.preferences.developerExtrasEnabled: true
231- }
232+ Component.onCompleted: {
233+ var webview = oxide ?
234+ Qt.resolvedUrl("WebViewOxide.qml")
235+ : Qt.resolvedUrl("WebViewWebkit.qml");
236+ webviewComponentLoader.setSource(webview, {
237+ remoteInspectorEnabled: root.remoteInspectorEnabled});
238 }
239
240 /*!
241@@ -131,6 +90,10 @@
242 */
243 UbuntuJavascriptBindings {
244 id: bindings
245+ onReady: {
246+ webviewComponentLoader.item.url =
247+ mainPage._getAppStartupIndexFileUri();
248+ }
249 }
250 }
251 }
252
253=== modified file 'src/ubuntu-html5-app-launcher/main.cpp'
254--- src/ubuntu-html5-app-launcher/main.cpp 2014-04-03 13:57:30 +0000
255+++ src/ubuntu-html5-app-launcher/main.cpp 2014-12-05 21:46:03 +0000
256@@ -56,6 +56,33 @@
257 }
258 }
259
260+static QString currentArchitecturePathName()
261+{
262+#if defined(Q_PROCESSOR_X86_32)
263+ return QLatin1String("i386-linux-gnu");
264+#elif defined(Q_PROCESSOR_X86_64)
265+ return QLatin1String("x86_64-linux-gnu");
266+#elif defined(Q_PROCESSOR_ARM)
267+ return QLatin1String("arm-linux-gnueabihf");
268+#else
269+#error Unable to determine target architecture
270+#endif
271+}
272+
273+static bool canUseOxide()
274+{
275+ // Use a runtime hint to transparently know if oxide
276+ // can be used as a backend without the user/dev having
277+ // to update its app or change something in the Exec args.
278+ // Version 1.1 of ubuntu apparmor policy allows this file to
279+ // be accessed whereas v1.0 only knows about qtwebkit.
280+ QString oxideHintLocation =
281+ QString("/usr/lib/%1/oxide-qt/oxide-renderer")
282+ .arg(currentArchitecturePathName());
283+
284+ return QFile(oxideHintLocation).open(QIODevice::ReadOnly);
285+}
286+
287 } // namespace
288
289
290@@ -142,6 +169,10 @@
291 QString wwwfolderArg;
292 bool maximized = false;
293
294+ QString remoteInspectorHost = "";
295+ QString remoteInspectorPort = QString::number(REMOTE_INSPECTOR_PORT);
296+ bool remoteInspectorEnabled = false;
297+
298 QStringList arguments = app.arguments();
299 arguments.pop_front();
300
301@@ -149,7 +180,7 @@
302 {
303 if (argument.contains(WWW_LOCATION_ARG_HEADER))
304 {
305- wwwfolderArg = argument.right(argument.count() - WWW_LOCATION_ARG_HEADER.count());
306+ wwwfolderArg = argument.split(WWW_LOCATION_ARG_HEADER)[1];
307 }
308 else
309 if (argument.contains(MAXIMIZED_ARG_HEADER))
310@@ -159,20 +190,16 @@
311 else
312 if (argument.contains(INSPECTOR))
313 {
314- QString host;
315+ remoteInspectorEnabled = true;
316 Q_FOREACH(QHostAddress address, QNetworkInterface::allAddresses()) {
317 if (!address.isLoopback() && (address.protocol() == QAbstractSocket::IPv4Protocol)) {
318- host = address.toString();
319+ remoteInspectorHost = address.toString();
320 break;
321 }
322 }
323- QString server;
324- if (host.isEmpty()) {
325- server = QString::number(REMOTE_INSPECTOR_PORT);
326- } else {
327- server = QString("%1:%2").arg(host, QString::number(REMOTE_INSPECTOR_PORT));
328+ if (argument.startsWith(INSPECTOR + "=")) {
329+ remoteInspectorPort = argument.split(INSPECTOR + "=")[1];
330 }
331- qputenv("QTWEBKIT_INSPECTOR_SERVER", server.toUtf8());
332 }
333 else
334 {
335@@ -188,7 +215,6 @@
336 }
337
338 QFileInfo wwwFolder(wwwfolderArg);
339-
340 if (wwwFolder.isRelative())
341 {
342 wwwFolder.makeAbsolute();
343@@ -218,6 +244,17 @@
344 setUpQmlImportPathIfNecessary(plugin_path);
345
346 QQuickView view;
347+ QQmlEngine* engine = view.engine();
348+ engine->rootContext()->setContextProperty("withOxide", canUseOxide());
349+
350+ if (remoteInspectorEnabled) {
351+ qputenv("UBUNTU_WEBVIEW_DEVTOOLS_HOST", remoteInspectorHost.toUtf8());
352+ qputenv("UBUNTU_WEBVIEW_DEVTOOLS_PORT", remoteInspectorPort.toUtf8());
353+ }
354+
355+ engine->rootContext()->setContextProperty("inspector", remoteInspectorEnabled);
356+ engine->rootContext()->setContextProperty("wwwFolder", wwwFolder.absoluteFilePath());
357+
358 view.setSource(QUrl::fromLocalFile(Webapp::Config::getContainerMainQmlPath()
359 + "/main.qml"));
360 if (view.status() != QQuickView::Ready)
361@@ -225,7 +262,6 @@
362 qCritical() << "Main application component cannot be loaded.";
363 return EXIT_FAILURE;
364 }
365- view.rootObject()->setProperty("htmlIndexDirectory", wwwFolder.canonicalFilePath());
366
367 view.setTitle(QCoreApplication::applicationName());
368 view.setResizeMode(QQuickView::SizeRootObjectToView);
369
370=== modified file 'src/ubuntu-html5-app-launcher/main.qml'
371--- src/ubuntu-html5-app-launcher/main.qml 2014-02-10 16:15:29 +0000
372+++ src/ubuntu-html5-app-launcher/main.qml 2014-12-05 21:46:03 +0000
373@@ -23,5 +23,8 @@
374 WebAppContainer {
375 width: units.gu(100)
376 height: units.gu(75)
377+
378+ oxide: withOxide
379+ remoteInspectorEnabled: inspector
380+ htmlIndexDirectory: wwwFolder
381 }
382-
383
384=== modified file 'tests/autopilot/tools/qml/webview.qml'
385--- tests/autopilot/tools/qml/webview.qml 2014-04-03 17:15:24 +0000
386+++ tests/autopilot/tools/qml/webview.qml 2014-12-05 21:46:03 +0000
387@@ -17,8 +17,8 @@
388 */
389
390 import QtQuick 2.0
391-import QtWebKit 3.0
392-import QtWebKit.experimental 1.0
393+import QtTest 1.0
394+import com.canonical.Oxide 1.0 as Oxide
395
396 Item {
397 id: root
398@@ -31,6 +31,8 @@
399
400 signal resultUpdated(string message)
401
402+ TestResult { id: qtest_testResult }
403+
404 function __gentid() {
405 return Math.random() + '';
406 }
407@@ -64,23 +66,21 @@
408 var tid = __gentid();
409 var statement = 'document.getElementById("' + id + '").click();';
410
411- webview.experimental.evaluateJavaScript(__wrapJsCommands(statement),
412- function(result) { root.resultUpdated(root.__createResult(result)); });
413+ var result = webview.evaluateCode(statement, true);
414+ root.resultUpdated(root.__createResult(result, tid));
415 }
416
417 function evalInPageUnsafe(expr) {
418- var tid = __gentid();
419-
420- webview.experimental.evaluateJavaScript(__wrapJsCommands(expr),
421- function(result) { root.resultUpdated(root.__createResult(result)); });
422+ var result = webview.evaluateCode(expr, true);
423+ root.resultUpdated(result.toString())
424 }
425
426 function clickAnyElementBySelector(selector) {
427 var tid = __gentid();
428 var statement = 'document.querySelectorAll("' + selector + '")[0].click();';
429
430- webview.experimental.evaluateJavaScript(__wrapJsCommands(statement),
431- function(result) { root.resultUpdated(root.__createResult(result)); });
432+ var result = webview.evaluateCode(statement, true);
433+ root.resultUpdated(root.__createResult(result, tid));
434 }
435
436 function elementWithIdHasAttribute(id,attribute,value) {
437@@ -95,13 +95,13 @@
438 statement += hasAttributeWithIdFunc;
439 statement += "; return __hasAttributeWithId(id,attribute,value); "
440
441- webview.experimental.evaluateJavaScript(__wrapJsCommands(statement),
442- function(result) { root.resultUpdated(root.__createResult(result, tid)); });
443+ var result = webview.evaluateCode(statement, true);
444+ root.resultUpdated(root.__createResult(result, tid));
445 }
446
447 function isNodeWithIdVisible(id) {
448 var tid = __gentid();
449- var isNodeWithIdVisibleFunc = '
450+ var isNodeWithIdVisibleFunc = '
451 function __isNodeWithIdVisible() {
452 try { return document.getElementById(id).style.display !== "none"; } catch (e) { return e.toString(); };
453 return false;
454@@ -110,14 +110,15 @@
455 var statement = __setupClosedVariables({'id': id});
456 statement += isNodeWithIdVisibleFunc;
457 statement += "; return __isNodeWithIdVisible(id); "
458- webview.experimental.evaluateJavaScript(__wrapJsCommands(statement),
459- function(result) { root.resultUpdated(root.__createResult(result, tid)); });
460+
461+ var result = webview.evaluateCode(statement, true);
462+ root.resultUpdated(root.__createResult(result, tid));
463 }
464
465 function getAttributeForElementWithId(id,attribute) {
466 var tid = __gentid();
467 var getAttributeWithIdFunc = '
468- function __getAttributeWithId() {
469+ function __getAttributeWithId() {
470 try { var value = document.querySelector("#" + id).getAttribute(attribute); return value || ""; } catch (e) { return e.toString(); };
471 return "";
472 };';
473@@ -126,11 +127,11 @@
474 statement += getAttributeWithIdFunc;
475 statement += "; return __getAttributeWithId(); "
476
477- webview.experimental.evaluateJavaScript(__wrapJsCommands(statement),
478- function(result) { root.resultUpdated(root.__createResult(result, tid)); });
479+ var result = webview.evaluateCode(statement, true);
480+ root.resultUpdated(root.__createResult(result, tid));
481 }
482
483- WebView {
484+ Oxide.WebView {
485 objectName: "webview"
486 id: webview
487
488@@ -146,12 +147,77 @@
489 left: parent.left
490 }
491
492- experimental.userScripts: []
493- experimental.preferences.navigatorQtObjectEnabled: true
494- experimental.preferences.developerExtrasEnabled: true
495-
496- experimental.userAgent: {
497- 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"
498+ preferences.localStorageEnabled: true
499+ preferences.appCacheEnabled: true
500+
501+ function evaluateCode(code, wrap) {
502+ var value = webview._waitForResult(
503+ webview.rootFrame.sendMessage(
504+ "oxide://main-world",
505+ "EVALUATE-CODE",
506+ { code: code,
507+ wrap: wrap === undefined ? false : wrap }));
508+ return value ? value.result : undefined;
509+ }
510+
511+ function _waitForResult(req, timeout) {
512+ var result;
513+ var error;
514+ req.onreply = function(response) {
515+ result = response;
516+ error = 0;
517+ };
518+ req.onerror = function(error_code, msg) {
519+ result = msg;
520+ error = error_code;
521+ };
522+ webview._waitFor(function() { return error !== undefined; },
523+ timeout);
524+
525+ if (error > 0) {
526+ console.error('Error:' + error + ', result:' + result)
527+ } else if (error === 0) {
528+ return result;
529+ } else {
530+ throw new Error("Message call timed out");
531+ }
532+ }
533+
534+ function _waitFor(predicate, timeout) {
535+ timeout = timeout || 5000000;
536+ var end = Date.now() + timeout;
537+ var i = Date.now();
538+ while (i < end && !predicate()) {
539+ qtest_testResult.wait(50);
540+ i = Date.now();
541+ }
542+ return predicate();
543+ }
544+
545+ context: Oxide.WebContext {
546+ userScripts: [
547+ Oxide.UserScript {
548+ context: "oxide://main-world"
549+ emulateGreasemonkey: true
550+ url: Qt.resolvedUrl("message-server.js")
551+ matchAllFrames: true
552+ }
553+ ]
554+ }
555+
556+ onJavaScriptConsoleMessage: {
557+ var msg = "[JS] (%1:%2) %3".arg(sourceId).arg(lineNumber).arg(message)
558+ if (level === Oxide.WebView.LogSeverityVerbose) {
559+ console.log(msg)
560+ } else if (level === Oxide.WebView.LogSeverityInfo) {
561+ console.info(msg)
562+ } else if (level === Oxide.WebView.LogSeverityWarning) {
563+ console.warn(msg)
564+ } else if ((level === Oxide.WebView.LogSeverityError) ||
565+ (level === Oxide.WebView.LogSeverityErrorReport) ||
566+ (level === Oxide.WebView.LogSeverityFatal)) {
567+ console.error(msg)
568+ }
569 }
570 }
571
572
573=== modified file 'tests/autopilot/ubuntu_html5_container/__init__.py'
574--- tests/autopilot/ubuntu_html5_container/__init__.py 2014-02-06 22:51:33 +0000
575+++ tests/autopilot/ubuntu_html5_container/__init__.py 2014-12-05 21:46:03 +0000
576@@ -2,9 +2,7 @@
577 # Copyright 2014 Canonical
578 #
579 # This program is free software: you can redistribute it and/or modify it
580-# under the terms of the GNU Lesser General Public License version 3, as published
581-# by the Free Software Foundation.
582+# under the terms of the GNU Lesser General Public License version 3, as
583+# published by the Free Software Foundation.
584
585 """Tests for the Ubuntu HTML5 Launcher package """
586-
587-
588
589=== removed directory 'tests/autopilot/ubuntu_html5_container/emulators'
590=== removed file 'tests/autopilot/ubuntu_html5_container/emulators/__init__.py'
591--- tests/autopilot/ubuntu_html5_container/emulators/__init__.py 2014-02-06 22:51:33 +0000
592+++ tests/autopilot/ubuntu_html5_container/emulators/__init__.py 1970-01-01 00:00:00 +0000
593@@ -1,10 +0,0 @@
594-# -*- Mode: Python; coding: utf-8; indent-tabs-mode: nil; tab-width: 4 -*-
595-# Copyright 2014 Canonical
596-#
597-# This program is free software: you can redistribute it and/or modify it
598-# under the terms of the GNU Lesser General Public License version 3, as published
599-# by the Free Software Foundation.
600-
601-"""Tests for the Ubuntu HTML5 Launcher package """
602-
603-
604
605=== modified file 'tests/autopilot/ubuntu_html5_container/tests/__init__.py'
606--- tests/autopilot/ubuntu_html5_container/tests/__init__.py 2014-02-06 22:51:33 +0000
607+++ tests/autopilot/ubuntu_html5_container/tests/__init__.py 2014-12-05 21:46:03 +0000
608@@ -2,18 +2,22 @@
609 # Copyright 2014 Canonical
610 #
611 # This program is free software: you can redistribute it and/or modify it
612-# under the terms of the GNU Lesser General Public License version 3, as published
613-# by the Free Software Foundation.
614+# under the terms of the GNU Lesser General Public License version 3, as
615+# published by the Free Software Foundation.
616
617 """Tests for the Ubuntu HTML5 Launcher package """
618
619 import os
620 from autopilot.testcase import AutopilotTestCase
621
622+
623 LAUNCHER_EXEC_NAME = 'ubuntu-html5-app-launcher'
624
625-LOCAL_LAUNCHER_PATH = os.path.abspath("%s/%s" % (os.path.dirname(os.path.realpath(__file__))
626- , '../../../../src/ubuntu-html5-app-launcher/' + LAUNCHER_EXEC_NAME))
627+LOCAL_LAUNCHER_PATH = os.path.abspath(
628+ "{}/{}".format(
629+ os.path.dirname(os.path.realpath(__file__)),
630+ '../../../../src/ubuntu-html5-app-launcher/' + LAUNCHER_EXEC_NAME))
631+
632 INSTALLED_LAUNCHER_PATH = '/usr/bin/' + LAUNCHER_EXEC_NAME
633
634
635@@ -35,7 +39,8 @@
636
637 def launch_with_argument(self, args):
638 try:
639- self.app = self.launch_test_application(self.get_launcher_path(), args)
640- except Exception, e:
641+ self.app = self.launch_test_application(
642+ self.get_launcher_path(),
643+ args)
644+ except Exception:
645 pass
646-
647
648=== modified file 'tests/autopilot/ubuntu_html5_container/tests/test_appLaunch.py'
649--- tests/autopilot/ubuntu_html5_container/tests/test_appLaunch.py 2014-02-06 22:51:33 +0000
650+++ tests/autopilot/ubuntu_html5_container/tests/test_appLaunch.py 2014-12-05 21:46:03 +0000
651@@ -2,12 +2,12 @@
652 # Copyright 2014 Canonical
653 #
654 # This program is free software: you can redistribute it and/or modify it
655-# under the terms of the GNU Lesser General Public License version 3, as published
656-# by the Free Software Foundation.
657+# under the terms of the GNU Lesser General Public License version 3, as
658+# published by the Free Software Foundation.
659
660 from __future__ import absolute_import
661
662-from testtools.matchers import Equals
663+from testtools.matchers import NotEquals
664
665 from ubuntu_html5_container.tests import UbuntuHtml5LauncherTestCase
666
667@@ -16,7 +16,6 @@
668 def setUp(self):
669 super(UbuntuHtml5LauncherAppLaunchTestCase, self).setUp()
670
671- def test_launcherFailsWithNoWWW(self):
672+ def test_launcher_succeeds_with_no_www(self):
673 self.launch_with_argument('')
674- self.assertThat(self.get_app(), Equals(None))
675-
676+ self.assertThat(self.get_app(), NotEquals(None))
677
678=== modified file 'tests/autopilot/ubuntu_html5_ui_toolkit/__init__.py'
679--- tests/autopilot/ubuntu_html5_ui_toolkit/__init__.py 2014-01-28 18:25:08 +0000
680+++ tests/autopilot/ubuntu_html5_ui_toolkit/__init__.py 2014-12-05 21:46:03 +0000
681@@ -2,8 +2,7 @@
682 # Copyright 2013 Canonical
683 #
684 # This program is free software: you can redistribute it and/or modify it
685-# under the terms of the GNU Lesser General Public License version 3, as published
686-# by the Free Software Foundation.
687+# under the terms of the GNU Lesser General Public License version 3, as
688+# published by the Free Software Foundation.
689
690 """Tests for the Ubuntu HTML5 UI SDK package """
691-
692
693=== removed directory 'tests/autopilot/ubuntu_html5_ui_toolkit/emulators'
694=== removed file 'tests/autopilot/ubuntu_html5_ui_toolkit/emulators/__init__.py'
695--- tests/autopilot/ubuntu_html5_ui_toolkit/emulators/__init__.py 2014-01-28 18:25:08 +0000
696+++ tests/autopilot/ubuntu_html5_ui_toolkit/emulators/__init__.py 1970-01-01 00:00:00 +0000
697@@ -1,10 +0,0 @@
698-# -*- Mode: Python; coding: utf-8; indent-tabs-mode: nil; tab-width: 4 -*-
699-# Copyright 2013 Canonical
700-#
701-# This program is free software: you can redistribute it and/or modify it
702-# under the terms of the GNU Lesser General Public License version 3, as published
703-# by the Free Software Foundation.
704-
705-"""Tests for the Ubuntu HTML5 UI SDK package """
706-
707-
708
709=== modified file 'tests/autopilot/ubuntu_html5_ui_toolkit/tests/__init__.py'
710--- tests/autopilot/ubuntu_html5_ui_toolkit/tests/__init__.py 2014-02-11 12:11:48 +0000
711+++ tests/autopilot/ubuntu_html5_ui_toolkit/tests/__init__.py 2014-12-05 21:46:03 +0000
712@@ -2,20 +2,20 @@
713 # Copyright 2013 Canonical
714 #
715 # This program is free software: you can redistribute it and/or modify it
716-# under the terms of the GNU Lesser General Public License version 3, as published
717-# by the Free Software Foundation.
718+# under the terms of the GNU Lesser General Public License version 3, as
719+# published by the Free Software Foundation.
720
721 """Tests for the Ubuntu HTML5 package """
722
723 import os
724 import json
725-import BaseHTTPServer
726+import http.server as http
727 import threading
728 import subprocess
729
730 HTTP_SERVER_PORT = 8383
731
732-from testtools.matchers import Contains, Equals, GreaterThan
733+from testtools.matchers import Equals, GreaterThan
734 from autopilot.matchers import Eventually
735 from autopilot.testcase import AutopilotTestCase
736 from autopilot.input import Mouse, Touch, Pointer
737@@ -25,14 +25,17 @@
738 # from autopilot.introspection.qt import QtIntrospectionTestMixin
739
740
741-class RequestHandler(BaseHTTPServer.BaseHTTPRequestHandler):
742- BASE_PATH_FOR_SERVED_APPS = {'rss-reader': "%s/%s" % (os.path.dirname(os.path.realpath(__file__)), '../../../../0.1/examples/apps/rss-reader')}
743+class RequestHandler(http.BaseHTTPRequestHandler):
744+ BASE_PATH_FOR_SERVED_APPS = {'rss-reader': "{}/{}".format(
745+ os.path.dirname(os.path.realpath(__file__)),
746+ '../../../../0.1/examples/apps/rss-reader')}
747
748 def get_served_filename(self, appname, filename):
749 if len(filename) == 0 or filename == '/':
750 filename = 'autopilot.html'
751- print os.path.join(self.BASE_PATH_FOR_SERVED_APPS[appname], filename)
752- return os.path.join(self.BASE_PATH_FOR_SERVED_APPS[appname], filename)
753+ return os.path.join(
754+ self.BASE_PATH_FOR_SERVED_APPS[appname],
755+ filename)
756
757 def serve_file(self, filename):
758 import mimetypes
759@@ -51,7 +54,10 @@
760 if self.path.startswith('/rss-reader'):
761 filename = self.path[len('/rss-reader'):]
762 self.send_response(200)
763- self.serve_file(self.get_served_filename('rss-reader', filename))
764+ self.serve_file(
765+ self.get_served_filename(
766+ 'rss-reader',
767+ filename))
768 else:
769 self.send_error(404)
770
771@@ -59,7 +65,9 @@
772 class UbuntuHTML5HTTPServer(threading.Thread):
773 def __init__(self, port):
774 super(UbuntuHTML5HTTPServer, self).__init__()
775- self.server = BaseHTTPServer.HTTPServer(("", port), RequestHandler)
776+ self.server = http.BaseHTTPServer.HTTPServer(
777+ ("", port),
778+ RequestHandler)
779 self.server.allow_reuse_address = True
780
781 def run(self):
782@@ -71,15 +79,22 @@
783
784
785 class UbuntuHTML5TestCaseBase(AutopilotTestCase):
786- BROWSER_CONTAINER_PATH = "%s/%s" % (os.path.dirname(os.path.realpath(__file__)), '../../tools/qml/webview.qml')
787- INSTALLED_BROWSER_CONTAINER_PATH = '/usr/share/ubuntu-html5-ui-toolkit/tests/tools/qml/webview.qml'
788- arch = subprocess.check_output(
789- ["dpkg-architecture", "-qDEB_HOST_MULTIARCH"]).strip()
790- BROWSER_QML_APP_LAUNCHER = "/usr/lib/" + arch + "/qt5/bin/qmlscene"
791+ BROWSER_CONTAINER_PATH = "{}/{}".format(
792+ os.path.dirname(os.path.realpath(__file__)),
793+ '../../tools/qml/webview.qml')
794+ INSTALLED_BROWSER_CONTAINER_PATH = \
795+ '/usr/share/ubuntu-html5-ui-toolkit/tests/tools/qml/webview.qml'
796+ BROWSER_QML_APP_LAUNCHER = "/usr/lib/{}/qt5/bin/qmlscene".format(
797+ subprocess.check_output(
798+ ["dpkg-architecture", "-qDEB_HOST_MULTIARCH"]).strip().decode('utf-8'))
799
800 # TODO: fix version
801- LOCAL_HTML_EXAMPLES_PATH = os.path.abspath("%s/%s" % (os.path.dirname(os.path.realpath(__file__)), '../../../../tests'))
802- INSTALLED_HTML_EXAMPLES_PATH = '/usr/share/ubuntu-html5-ui-toolkit/tests/'
803+ LOCAL_HTML_EXAMPLES_PATH = os.path.abspath(
804+ "{}/{}".format(
805+ os.path.dirname(os.path.realpath(__file__)),
806+ '../../../../tests'))
807+ INSTALLED_HTML_EXAMPLES_PATH = \
808+ '/usr/share/ubuntu-html5-ui-toolkit/tests/'
809
810 APPS_SUBFOLDER_NAME = 'apps'
811
812@@ -106,16 +121,20 @@
813 else:
814 self.pointer = Pointer(Touch.create())
815
816- params = [self.BROWSER_QML_APP_LAUNCHER, self.get_browser_container_path()]
817- if (platform.model() <> 'Desktop'):
818- params.append('--desktop_file_hint=/usr/share/applications/unitywebappsqmllauncher.desktop')
819+ params = [self.BROWSER_QML_APP_LAUNCHER,
820+ self.get_browser_container_path()]
821+ if (platform.model() != 'Desktop'):
822+ params.append(
823+ '--desktop_file_hint=/usr/share/" \
824+ + "applications/unitywebappsqmllauncher.desktop')
825
826 self.app = self.launch_test_application(
827 *params,
828 app_type='qt')
829
830 self.webviewContainer = self.get_webviewContainer()
831- self.watcher = self.webviewContainer.watch_signal('resultUpdated(QString)')
832+ self.watcher = self.webviewContainer.watch_signal(
833+ 'resultUpdated(QString)')
834 super(UbuntuHTML5TestCaseBase, self).setUp()
835
836 def tearDown(self):
837@@ -143,40 +162,60 @@
838
839 def assert_url_eventually_loaded(self, url):
840 webview = self.get_webview()
841- self.assertThat(webview.loadProgress, Eventually(Equals(100)))
842- self.assertThat(webview.loading, Eventually(Equals(False)))
843- self.assertThat(webview.url, Eventually(Equals(url)))
844+ self.assertThat(
845+ webview.loadProgress,
846+ Eventually(Equals(100)))
847+ self.assertThat(
848+ webview.loading,
849+ Eventually(Equals(False)))
850+ self.assertThat(
851+ webview.url,
852+ Eventually(Equals(url)))
853
854 def click_dom_node_with_id(self, id):
855 webview = self.get_webviewContainer()
856 webview.slots.clickElementById(id)
857- self.assertThat(lambda: self.watcher.num_emissions, Eventually(Equals(1)))
858+ self.assertThat(
859+ lambda: self.watcher.num_emissions,
860+ Eventually(Equals(1)))
861
862 def click_any_dom_node_by_selector(self, selector):
863 webview = self.get_webviewContainer()
864 webview.slots.clickAnyElementBySelector(selector)
865- self.assertThat(lambda: self.watcher.num_emissions, Eventually(Equals(1)))
866+ self.assertThat(
867+ lambda: self.watcher.num_emissions,
868+ Eventually(Equals(1)))
869
870 def is_dom_node_visible(self, id):
871 webview = self.get_webviewContainer()
872 prev_emissions = self.watcher.num_emissions
873 webview.slots.isNodeWithIdVisible(id)
874- self.assertThat(lambda: self.watcher.num_emissions, Eventually(GreaterThan(prev_emissions)))
875- return json.loads(webview.get_signal_emissions('resultUpdated(QString)')[-1][0])['result']
876+ self.assertThat(
877+ lambda: self.watcher.num_emissions,
878+ Eventually(GreaterThan(prev_emissions)))
879+ return json.loads(
880+ webview.get_signal_emissions(
881+ 'resultUpdated(QString)')[-1][0])['result']
882
883 def eval_expression_in_page_unsafe(self, expr):
884 webview = self.get_webviewContainer()
885 prev_emissions = self.watcher.num_emissions
886- webview.slots.evalInPageUnsafe(expr)
887- self.assertThat(lambda: self.watcher.num_emissions, Eventually(GreaterThan(prev_emissions)))
888- return json.loads(webview.get_signal_emissions('resultUpdated(QString)')[-1][0])['result']
889+ result = webview.slots.evalInPageUnsafe(expr)
890+ self.assertThat(
891+ lambda: self.watcher.num_emissions,
892+ Eventually(GreaterThan(prev_emissions)))
893+ return webview.get_signal_emissions('resultUpdated(QString)')[-1][0]
894
895 def get_dom_node_id_attribute(self, id, attribute):
896 webview = self.get_webviewContainer()
897 prev_emissions = self.watcher.num_emissions
898 webview.slots.getAttributeForElementWithId(id, attribute)
899- self.assertThat(lambda: self.watcher.num_emissions, Eventually(GreaterThan(prev_emissions)))
900- return json.loads(webview.get_signal_emissions('resultUpdated(QString)')[-1][0])['result']
901+ self.assertThat(
902+ lambda: self.watcher.num_emissions,
903+ Eventually(GreaterThan(prev_emissions)))
904+ return json.loads(
905+ webview.get_signal_emissions(
906+ 'resultUpdated(QString)')[-1][0])['result']
907
908 def get_address_bar_action_button(self):
909 addressbar = self.get_addressbar()
910@@ -185,23 +224,29 @@
911 def browse_to_url(self, url):
912 import time
913 addressbar = self.get_addressbar()
914- self.assertThat(addressbar.activeFocus, Eventually(Equals(True)))
915+ self.assertThat(
916+ addressbar.activeFocus,
917+ Eventually(Equals(True)))
918
919 self.keyboard.type(url, 0.001)
920
921 self.pointer.click_object(self.get_webview())
922+
923+ # XXX: very bad, but wont fix
924 time.sleep(1)
925
926- button = self.get_address_bar_action_button();
927+ button = self.get_address_bar_action_button()
928 self.pointer.move_to_object(button)
929 self.pointer.press()
930+ # XXX: very bad, but wont fix
931 time.sleep(1)
932 self.pointer.release()
933
934- self.assert_url_eventually_loaded(url);
935+ self.assert_url_eventually_loaded(url)
936
937 def browse_to_app(self, appname):
938- appfilepath = os.path.abspath(self.BASE_PATH +
939+ appfilepath = os.path.abspath(
940+ self.BASE_PATH +
941 '/data/html/' +
942 self.APPS_SUBFOLDER_NAME +
943 '/' +
944@@ -213,7 +258,12 @@
945 self.browse_to_url(APP_HTML_PATH)
946
947 def browse_to_test_html(self, html_filename):
948- self.browse_to_url(self.create_file_url_from(os.path.abspath(self.BASE_PATH + '/data/html/' + html_filename)))
949+ self.browse_to_url(
950+ self.create_file_url_from(
951+ os.path.abspath(
952+ '{}/data/html/{}'.format(
953+ self.BASE_PATH,
954+ html_filename))))
955
956
957 class UbuntuThemeWithHttpServerTestCaseBase(UbuntuHTML5TestCaseBase):
958
959=== modified file 'tests/autopilot/ubuntu_html5_ui_toolkit/tests/test_pagestack.py'
960--- tests/autopilot/ubuntu_html5_ui_toolkit/tests/test_pagestack.py 2014-03-05 16:21:16 +0000
961+++ tests/autopilot/ubuntu_html5_ui_toolkit/tests/test_pagestack.py 2014-12-05 21:46:03 +0000
962@@ -2,17 +2,16 @@
963 # Copyright 2013 Canonical
964 #
965 # This program is free software: you can redistribute it and/or modify it
966-# under the terms of the GNU Lesser General Public License version 3, as published
967-# by the Free Software Foundation.
968+# under the terms of the GNU Lesser General Public License version 3, as
969+# published by the Free Software Foundation.
970
971 from __future__ import absolute_import
972
973-import time
974-
975-from testtools.matchers import Contains, Equals
976+from testtools.matchers import Equals
977 from autopilot.matchers import Eventually
978
979-from ubuntu_html5_ui_toolkit.tests import UbuntuHTML5TestCaseBase, UbuntuThemeRemotePageTestCaseBase
980+from ubuntu_html5_ui_toolkit.tests import UbuntuHTML5TestCaseBase
981+
982
983 class UbuntuThemePageStackTestCase(UbuntuHTML5TestCaseBase):
984
985@@ -21,25 +20,54 @@
986
987 def test_pageLoadsWithNoPageStacks(self):
988 self.browse_to_test_html('test-nopagestack-in-app.html')
989- self.assertThat(self.eval_expression_in_page_unsafe('var UI = new UbuntuUI(); UI.init(); return "ok";'), Equals('ok'));
990+ self.assertThat(
991+ self.eval_expression_in_page_unsafe(
992+ 'var UI = new UbuntuUI(); UI.init(); return "ok";'),
993+ Equals('ok'))
994
995 def test_pageLoadsWithPageStacks(self):
996 self.browse_to_test_html('test-pagestack-in-app.html')
997- self.assertThat(self.eval_expression_in_page_unsafe('var UI = new UbuntuUI(); UI.init(); return "ok";'), Equals('ok'));
998- self.assertThat(self.is_dom_node_visible('main'), Equals(True))
999+ self.assertThat(
1000+ self.eval_expression_in_page_unsafe(
1001+ 'var UI = new UbuntuUI(); UI.init(); return "ok";'),
1002+ Equals('ok'))
1003+ self.assertThat(
1004+ self.is_dom_node_visible('main'),
1005+ Equals(True))
1006
1007 def test_pageChangeWithPageStackPush(self):
1008 self.browse_to_test_html('test-pagestack-in-app.html')
1009- self.assertThat(self.eval_expression_in_page_unsafe('var UI = new UbuntuUI(); UI.init(); UI.pagestack.push("results"); return "ok";'), Equals('ok'));
1010- self.assertThat(self.is_dom_node_visible('main'), Equals(False))
1011- self.assertThat(self.is_dom_node_visible('results'), Equals(True))
1012+ self.assertThat(
1013+ self.eval_expression_in_page_unsafe(
1014+ 'var UI = new UbuntuUI(); UI.init(); '
1015+ 'UI.pagestack.push("results"); return "ok";'),
1016+ Equals('ok'))
1017+ self.assertThat(
1018+ self.is_dom_node_visible('main'),
1019+ Equals(False))
1020+ self.assertThat(
1021+ self.is_dom_node_visible('results'),
1022+ Equals(True))
1023
1024 def test_pageChangeWithPageStackPopped(self):
1025 self.browse_to_test_html('test-pagestack-in-app.html')
1026- 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'));
1027- self.assertThat(self.is_dom_node_visible('main'), Equals(False))
1028- self.assertThat(self.is_dom_node_visible('results'), Equals(True))
1029- self.assertThat(self.is_dom_node_visible('article'), Equals(False))
1030+ self.assertThat(
1031+ self.eval_expression_in_page_unsafe(
1032+ 'var UI = new UbuntuUI(); UI.init(); '
1033+ 'UI.pagestack.push("main"); '
1034+ 'UI.pagestack.push("results"); '
1035+ 'UI.pagestack.push("article"); '
1036+ 'UI.pagestack.pop(); return "ok";'),
1037+ Equals('ok'))
1038+ self.assertThat(
1039+ self.is_dom_node_visible('main'),
1040+ Equals(False))
1041+ self.assertThat(
1042+ self.is_dom_node_visible('results'),
1043+ Equals(True))
1044+ self.assertThat(
1045+ self.is_dom_node_visible('article'),
1046+ Equals(False))
1047
1048 def test_pagePushWithProperties(self):
1049 self.browse_to_test_html('test-pagestack-in-app.html')
1050@@ -50,14 +78,22 @@
1051
1052 (new Page('results')).onactivated(
1053 function(properties) {
1054- document.getElementById('results').innerHTML = JSON.stringify(properties);
1055+ document.getElementById('results').innerHTML =
1056+ JSON.stringify(properties);
1057 });
1058
1059 ui.pagestack.push('results', 'WORKS');
1060 return 'ok';
1061 """
1062- self.assertThat(self.eval_expression_in_page_unsafe(expression), Equals('ok'));
1063- self.assertThat(lambda: self.is_dom_node_visible('results'), Eventually(Equals(True)))
1064- results_html_content = "return document.getElementById('results').innerHTML;"
1065- self.assertThat(self.eval_expression_in_page_unsafe(results_html_content), Equals('"WORKS"'));
1066-
1067+ self.assertThat(
1068+ self.eval_expression_in_page_unsafe(expression),
1069+ Equals('ok'))
1070+ self.assertThat(
1071+ lambda: self.is_dom_node_visible('results'),
1072+ Eventually(Equals(True)))
1073+ results_html_content = \
1074+ "return document.getElementById('results').innerHTML;"
1075+ self.assertThat(
1076+ self.eval_expression_in_page_unsafe(
1077+ results_html_content),
1078+ Equals('"WORKS"'))
1079
1080=== modified file 'tests/autopilot/ubuntu_html5_ui_toolkit/tests/test_rss_reader.py'
1081--- tests/autopilot/ubuntu_html5_ui_toolkit/tests/test_rss_reader.py 2014-01-27 21:34:44 +0000
1082+++ tests/autopilot/ubuntu_html5_ui_toolkit/tests/test_rss_reader.py 2014-12-05 21:46:03 +0000
1083@@ -2,17 +2,16 @@
1084 # Copyright 2013 Canonical
1085 #
1086 # This program is free software: you can redistribute it and/or modify it
1087-# under the terms of the GNU Lesser General Public License version 3, as published
1088-# by the Free Software Foundation.
1089+# under the terms of the GNU Lesser General Public License version 3, as
1090+# published by the Free Software Foundation.
1091
1092 from __future__ import absolute_import
1093
1094-import time
1095-
1096 from testtools.matchers import Contains, Equals
1097 from autopilot.matchers import Eventually
1098
1099-from ubuntu_html5_ui_toolkit.tests import UbuntuHTML5TestCaseBase, UbuntuThemeRemotePageTestCaseBase
1100+from ubuntu_html5_ui_toolkit.tests import UbuntuHTML5TestCaseBase
1101+
1102
1103 class UbuntuThemeRSSReaderTestCase(UbuntuHTML5TestCaseBase):
1104 def setUp(self):
1105@@ -29,6 +28,8 @@
1106
1107 def test_switchToFeedView(self):
1108 self.click_any_dom_node_by_selector('#yourfeeds li a')
1109- self.assertThat(lambda: self.is_dom_node_visible('main'), Eventually(Equals(False)))
1110+ self.assertThat(
1111+ lambda: self.is_dom_node_visible('main'),
1112+ Eventually(Equals(False)))
1113 self.assertThat(self.is_dom_node_visible('article'), Equals(False))
1114 self.assertThat(self.is_dom_node_visible('results'), Equals(True))
1115
1116=== modified file 'tests/autopilot/ubuntu_html5_ui_toolkit/tests/test_tabs.py'
1117--- tests/autopilot/ubuntu_html5_ui_toolkit/tests/test_tabs.py 2014-03-05 20:06:49 +0000
1118+++ tests/autopilot/ubuntu_html5_ui_toolkit/tests/test_tabs.py 2014-12-05 21:46:03 +0000
1119@@ -2,18 +2,17 @@
1120 # Copyright 2014 Canonical
1121 #
1122 # This program is free software: you can redistribute it and/or modify it
1123-# under the terms of the GNU Lesser General Public License version 3, as published
1124-# by the Free Software Foundation.
1125+# under the terms of the GNU Lesser General Public License version 3, as
1126+# published by the Free Software Foundation.
1127
1128 from __future__ import absolute_import
1129
1130-import time
1131-
1132-from testtools.matchers import Contains, Equals
1133+from testtools.matchers import Equals
1134 from autopilot.matchers import Eventually
1135
1136 from ubuntu_html5_ui_toolkit.tests import UbuntuHTML5TestCaseBase
1137
1138+
1139 class UbuntuUIToolkitTabsTestCase(UbuntuHTML5TestCaseBase):
1140
1141 def setUp(self):
1142@@ -21,11 +20,27 @@
1143
1144 def test_programaticTabSelectIndex(self):
1145 self.browse_to_test_html('test-tabs-in-app.html')
1146- self.assertThat(self.eval_expression_in_page_unsafe('var UI = new UbuntuUI(); UI.init(); UI.tabs.selectedTabIndex = 1; return "ok";'), Equals('ok'));
1147-
1148- self.assertThat(lambda: self.is_dom_node_visible('tab1'), Eventually(Equals(False)))
1149- self.assertThat(lambda: self.is_dom_node_visible('tab2'), Eventually(Equals(True)))
1150- self.assertThat(lambda: self.is_dom_node_visible('tab3'), Eventually(Equals(False)))
1151-
1152- self.assertThat(self.eval_expression_in_page_unsafe('var UI = new UbuntuUI(); UI.init(); return UI.tabs.selectedTabIndex = 1;'), Equals(1));
1153+ self.assertThat(
1154+ self.eval_expression_in_page_unsafe(
1155+ 'var UI = new UbuntuUI(); '
1156+ 'UI.init(); UI.tabs.selectedTabIndex = 1; '
1157+ 'return "ok";'),
1158+ Equals('ok'))
1159+
1160+ self.assertThat(
1161+ lambda: self.is_dom_node_visible('tab1'),
1162+ Eventually(Equals(False)))
1163+ self.assertThat(
1164+ lambda: self.is_dom_node_visible('tab2'),
1165+ Eventually(Equals(True)))
1166+ self.assertThat(
1167+ lambda: self.is_dom_node_visible('tab3'),
1168+ Eventually(Equals(False)))
1169+
1170+ self.assertThat(
1171+ self.eval_expression_in_page_unsafe(
1172+ 'var UI = new UbuntuUI(); '
1173+ 'UI.init(); '
1174+ 'return UI.tabs.selectedTabIndex;'),
1175+ Equals('1'))
1176

Subscribers

People subscribed via source and target branches