Merge lp:~osomon/webbrowser-app/fullscreen into lp:webbrowser-app

Proposed by Olivier Tilloy
Status: Merged
Merged at revision: 576
Proposed branch: lp:~osomon/webbrowser-app/fullscreen
Merge into: lp:webbrowser-app
Diff against target: 207 lines (+88/-11)
9 files modified
src/Ubuntu/Web/UbuntuWebView02.qml (+2/-0)
src/app/PanelLoader.qml (+10/-0)
src/app/webbrowser/webbrowser-app.qml (+3/-1)
src/app/webcontainer/webapp-container.qml (+3/-1)
tests/autopilot/webbrowser_app/emulators/browser.py (+3/-0)
tests/autopilot/webbrowser_app/tests/__init__.py (+0/-1)
tests/autopilot/webbrowser_app/tests/http_server.py (+14/-0)
tests/autopilot/webbrowser_app/tests/test_fullscreen.py (+51/-0)
tests/autopilot/webbrowser_app/tests/test_title.py (+2/-8)
To merge this branch: bzr merge lp:~osomon/webbrowser-app/fullscreen
Reviewer Review Type Date Requested Status
PS Jenkins bot continuous-integration Needs Fixing
Ubuntu Phablet Team Pending
Review via email: mp+222318@code.launchpad.net

Commit message

Honour fullscreen requests.

To post a comment you must log in.
Revision history for this message
PS Jenkins bot (ps-jenkins) wrote :
review: Needs Fixing (continuous-integration)

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'src/Ubuntu/Web/UbuntuWebView02.qml'
2--- src/Ubuntu/Web/UbuntuWebView02.qml 2014-06-09 10:44:22 +0000
3+++ src/Ubuntu/Web/UbuntuWebView02.qml 2014-06-11 11:12:28 +0000
4@@ -162,6 +162,8 @@
5 }
6 }
7
8+ onFullscreenRequested: _webview.fullscreen = fullscreen
9+
10 onJavaScriptConsoleMessage: {
11 var msg = "[JS] (%1:%2) %3".arg(sourceId).arg(lineNumber).arg(message)
12 if (level === Oxide.WebView.LogSeverityVerbose) {
13
14=== modified file 'src/app/PanelLoader.qml'
15--- src/app/PanelLoader.qml 2014-04-25 16:47:14 +0000
16+++ src/app/PanelLoader.qml 2014-06-11 11:12:28 +0000
17@@ -63,6 +63,7 @@
18 }
19 height: units.gu(8)
20
21+ locked: chromePanel.currentWebview ? chromePanel.currentWebview.fullscreen : false
22 Component.onCompleted: open()
23 onOpenedChanged: {
24 if (!opened) {
25@@ -144,4 +145,13 @@
26 }
27 }
28 }
29+
30+ Connections {
31+ target: chromePanel.currentWebview
32+ onFullscreenChanged: {
33+ if (chromePanel.currentWebview.fullscreen) {
34+ chromePanel.close()
35+ }
36+ }
37+ }
38 }
39
40=== modified file 'src/app/webbrowser/webbrowser-app.qml'
41--- src/app/webbrowser/webbrowser-app.qml 2014-04-15 09:20:01 +0000
42+++ src/app/webbrowser/webbrowser-app.qml 2014-06-11 11:12:28 +0000
43@@ -17,7 +17,7 @@
44 */
45
46 import QtQuick 2.0
47-import QtQuick.Window 2.0
48+import QtQuick.Window 2.1
49 import Ubuntu.Components 0.1
50
51 Window {
52@@ -47,6 +47,8 @@
53 Component.onCompleted: i18n.domain = "webbrowser-app"
54 }
55
56+ visibility: browser.currentWebview && browser.currentWebview.fullscreen ? Window.FullScreen : Window.AutomaticVisibility
57+
58 function newTab(url, setCurrent) {
59 return browser.openUrlInNewTab(url, setCurrent)
60 }
61
62=== modified file 'src/app/webcontainer/webapp-container.qml'
63--- src/app/webcontainer/webapp-container.qml 2014-05-30 12:37:26 +0000
64+++ src/app/webcontainer/webapp-container.qml 2014-06-11 11:12:28 +0000
65@@ -17,7 +17,7 @@
66 */
67
68 import QtQuick 2.0
69-import QtQuick.Window 2.0
70+import QtQuick.Window 2.1
71 import Ubuntu.Components 0.1
72 import Ubuntu.Components.Extras.Browser 0.2
73 import webcontainer.private 0.1
74@@ -84,6 +84,8 @@
75 }
76 }
77
78+ visibility: webappPageComponentLoader.item && webappPageComponentLoader.item.currentWebview.fullscreen ? Window.FullScreen : Window.AutomaticVisibility
79+
80 Loader {
81 id: accountsPageComponentLoader
82 anchors.fill: parent
83
84=== modified file 'tests/autopilot/webbrowser_app/emulators/browser.py'
85--- tests/autopilot/webbrowser_app/emulators/browser.py 2014-05-26 09:37:08 +0000
86+++ tests/autopilot/webbrowser_app/emulators/browser.py 2014-06-11 11:12:28 +0000
87@@ -27,6 +27,9 @@
88 An emulator class that makes it easy to interact with the webbrowser app.
89 """
90
91+ def get_window(self):
92+ return self.get_parent()
93+
94 def get_toolbar(self):
95 # Overridden since the browser doesn’t use the MainView’s Toolbar.
96 return self.select_single(Panel)
97
98=== modified file 'tests/autopilot/webbrowser_app/tests/__init__.py'
99--- tests/autopilot/webbrowser_app/tests/__init__.py 2014-05-26 09:37:08 +0000
100+++ tests/autopilot/webbrowser_app/tests/__init__.py 2014-06-11 11:12:28 +0000
101@@ -69,7 +69,6 @@
102 else:
103 self.app = self.launch_test_application(
104 "webbrowser-app",
105- "--fullscreen",
106 self.d_f,
107 *self.ARGS,
108 app_type='qt',
109
110=== modified file 'tests/autopilot/webbrowser_app/tests/http_server.py'
111--- tests/autopilot/webbrowser_app/tests/http_server.py 2014-05-22 07:25:36 +0000
112+++ tests/autopilot/webbrowser_app/tests/http_server.py 2014-06-11 11:12:28 +0000
113@@ -101,6 +101,20 @@
114 html += '<div style="height: 100%"></div></a>'
115 html += '</body></html>'
116 self.send_html(html)
117+ elif self.path == "/fullscreen":
118+ # craft a page that accepts clicks anywhere inside its window
119+ # to toggle fullscreen mode on/off
120+ self.send_response(200)
121+ html = '<html><body style="margin: 0">'
122+ html += '<a id="fullscreen"><div style="height: 100%"></div></a>'
123+ html += '</body><script>'
124+ html += 'document.getElementById("fullscreen").addEventListener('
125+ html += '"click", function(event) { '
126+ html += 'if (!document.webkitFullscreenElement) { '
127+ html += 'document.documentElement.webkitRequestFullscreen(); '
128+ html += '} else { document.webkitExitFullscreen(); } });'
129+ html += '</script></html>'
130+ self.send_html(html)
131 else:
132 self.send_error(404)
133
134
135=== added file 'tests/autopilot/webbrowser_app/tests/test_fullscreen.py'
136--- tests/autopilot/webbrowser_app/tests/test_fullscreen.py 1970-01-01 00:00:00 +0000
137+++ tests/autopilot/webbrowser_app/tests/test_fullscreen.py 2014-06-11 11:12:28 +0000
138@@ -0,0 +1,51 @@
139+# -*- Mode: Python; coding: utf-8; indent-tabs-mode: nil; tab-width: 4 -*-
140+#
141+# Copyright 2014 Canonical
142+#
143+# This program is free software: you can redistribute it and/or modify it
144+# under the terms of the GNU General Public License version 3, as published
145+# by the Free Software Foundation.
146+#
147+# This program is distributed in the hope that it will be useful,
148+# but WITHOUT ANY WARRANTY; without even the implied warranty of
149+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
150+# GNU General Public License for more details.
151+#
152+# You should have received a copy of the GNU General Public License
153+# along with this program. If not, see <http://www.gnu.org/licenses/>.
154+
155+from webbrowser_app.tests import StartOpenRemotePageTestCaseBase
156+
157+from testtools.matchers import Equals, LessThan
158+from autopilot.matchers import Eventually
159+
160+
161+class TestFullscreen(StartOpenRemotePageTestCaseBase):
162+
163+ # Ref: http://qt-project.org/doc/qt-5/qwindow.html#Visibility-enum
164+ QWINDOW_FULLSCREEN = 5
165+
166+ def assert_eventually_windowed(self):
167+ self.assertThat(self.main_window.get_current_webview().fullscreen,
168+ Eventually(Equals(False)))
169+ self.assertThat(self.main_window.get_window().visibility,
170+ Eventually(LessThan(self.QWINDOW_FULLSCREEN)))
171+
172+ def assert_eventually_fullscreen(self):
173+ self.assertThat(self.main_window.get_current_webview().fullscreen,
174+ Eventually(Equals(True)))
175+ self.assertThat(self.main_window.get_window().visibility,
176+ Eventually(Equals(self.QWINDOW_FULLSCREEN)))
177+
178+ def test_toggle_fullscreen(self):
179+ self.assert_eventually_windowed()
180+ url = self.base_url + "/fullscreen"
181+ self.go_to_url(url)
182+ self.assert_page_eventually_loaded(url)
183+ self.assert_eventually_windowed()
184+ webview = self.main_window.get_current_webview()
185+ self.pointing_device.click_object(webview)
186+ self.assert_eventually_fullscreen()
187+ webview = self.main_window.get_current_webview()
188+ self.pointing_device.click_object(webview)
189+ self.assert_eventually_windowed()
190
191=== modified file 'tests/autopilot/webbrowser_app/tests/test_title.py'
192--- tests/autopilot/webbrowser_app/tests/test_title.py 2014-04-24 10:09:42 +0000
193+++ tests/autopilot/webbrowser_app/tests/test_title.py 2014-06-11 11:12:28 +0000
194@@ -26,11 +26,5 @@
195
196 def test_window_title(self):
197 self.go_to_url(self.base_url + "/aleaiactaest")
198- #window = self.app.select_single("QQuickWindow")
199- # XXX: for some reason, autopilot finds two instances of QQuickWindow.
200- # One is the correct one, and the other one is not visible, its
201- # dimensions are 0×0, it has no title, its parent is the webbrowser-app
202- # object, and it has no children.
203- # See https://bugs.launchpad.net/bugs/1248620.
204- window = self.app.select_single("QQuickWindow", visible=True)
205- self.assertThat(window.title, Eventually(Contains("Alea Iacta Est")))
206+ self.assertThat(self.main_window.get_window().title,
207+ Eventually(Contains("Alea Iacta Est")))

Subscribers

People subscribed via source and target branches

to status/vote changes: