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