Merge lp:~osomon/webbrowser-app/sdk-generic-toolbar into lp:webbrowser-app

Proposed by Olivier Tilloy
Status: Merged
Approved by: Ugo Riboni
Approved revision: 125
Merged at revision: 124
Proposed branch: lp:~osomon/webbrowser-app/sdk-generic-toolbar
Merge into: lp:webbrowser-app
Diff against target: 392 lines (+71/-229)
5 files modified
src/Ubuntu/Browser/Browser.qml (+51/-48)
src/Ubuntu/Browser/Chrome.qml (+1/-1)
src/Ubuntu/Browser/RevealingBar.qml (+0/-112)
tests/autopilot/webbrowser_app/tests/__init__.py (+4/-26)
tests/autopilot/webbrowser_app/tests/test_toolbar.py (+15/-42)
To merge this branch: bzr merge lp:~osomon/webbrowser-app/sdk-generic-toolbar
Reviewer Review Type Date Requested Status
Ugo Riboni (community) Approve
PS Jenkins bot continuous-integration Approve
Review via email: mp+161956@code.launchpad.net

Commit message

Replace the custom RevealingBar component with the Panel from the UITK.

Description of the change

Note to the reviewer: this change depends on a version of the UITK that hasn’t been released yet (trunk revision 461), so it shouldn’t be approved until the UITK gets a newer release.

To post a comment you must log in.
Revision history for this message
PS Jenkins bot (ps-jenkins) wrote :
review: Approve (continuous-integration)
125. By Olivier Tilloy

Merge the latest changes from trunk.

Revision history for this message
PS Jenkins bot (ps-jenkins) wrote :
review: Approve (continuous-integration)
Revision history for this message
Ugo Riboni (uriboni) wrote :

Works as advertised and can't spot any issues in the code

review: Approve

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'src/Ubuntu/Browser/Browser.qml'
2--- src/Ubuntu/Browser/Browser.qml 2013-05-03 01:10:43 +0000
3+++ src/Ubuntu/Browser/Browser.qml 2013-05-03 17:23:25 +0000
4@@ -196,7 +196,7 @@
5
6 onActiveFocusChanged: {
7 if (activeFocus) {
8- revealingBar.hide()
9+ panel.opened = false
10 }
11 }
12
13@@ -295,11 +295,56 @@
14 align: Qt.AlignBottom
15 }
16
17- RevealingBar {
18- id: revealingBar
19- enabled: !browser.chromeless
20- contents: chromeLoader.item
21- anchors.bottom: shown ? osk.top : parent.bottom
22+ Panel {
23+ id: panel
24+
25+ locked: browser.chromeless
26+
27+ anchors {
28+ left: parent.left
29+ right: parent.right
30+ bottom: opened ? osk.top : parent.bottom
31+ }
32+ height: units.gu(8)
33+
34+ Loader {
35+ id: chromeLoader
36+
37+ active: !browser.chromeless
38+ source: "Chrome.qml"
39+
40+ anchors.fill: parent
41+
42+ Binding {
43+ target: chromeLoader.item
44+ property: "loading"
45+ value: webview.loading || (webview.progress == 0)
46+ }
47+
48+ Binding {
49+ target: chromeLoader.item
50+ property: "canGoBack"
51+ value: webview.canGoBack
52+ }
53+
54+ Binding {
55+ target: chromeLoader.item
56+ property: "canGoForward"
57+ value: webview.canGoForward
58+ }
59+
60+ Connections {
61+ target: chromeLoader.item
62+ onGoBackClicked: webview.goBack()
63+ onGoForwardClicked: webview.goForward()
64+ onUrlValidated: {
65+ browser.url = url
66+ webview.forceActiveFocus()
67+ }
68+ onRequestReload: webview.reload()
69+ onRequestStop: webview.stop()
70+ }
71+ }
72 }
73
74 ProgressBar {
75@@ -317,48 +362,6 @@
76 value: webview.loadProgress
77 }
78
79- Loader {
80- id: chromeLoader
81-
82- active: !browser.chromeless
83- source: "Chrome.qml"
84-
85- anchors.left: parent.left
86- anchors.right: parent.right
87-
88- height: units.gu(8)
89-
90- Binding {
91- target: chromeLoader.item
92- property: "loading"
93- value: webview.loading || (webview.progress == 0)
94- }
95-
96- Binding {
97- target: chromeLoader.item
98- property: "canGoBack"
99- value: webview.canGoBack
100- }
101-
102- Binding {
103- target: chromeLoader.item
104- property: "canGoForward"
105- value: webview.canGoForward
106- }
107-
108- Connections {
109- target: chromeLoader.item
110- onGoBackClicked: webview.goBack()
111- onGoForwardClicked: webview.goForward()
112- onUrlValidated: {
113- browser.url = url
114- webview.forceActiveFocus()
115- }
116- onRequestReload: webview.reload()
117- onRequestStop: webview.stop()
118- }
119- }
120-
121 KeyboardRectangle {
122 id: osk
123 }
124
125=== modified file 'src/Ubuntu/Browser/Chrome.qml'
126--- src/Ubuntu/Browser/Chrome.qml 2013-04-18 15:48:38 +0000
127+++ src/Ubuntu/Browser/Chrome.qml 2013-05-03 17:23:25 +0000
128@@ -94,7 +94,7 @@
129
130 Suggestions {
131 id: suggestions
132- visible: addressBar.focus && (count > 0)
133+ visible: addressBar.activeFocus && (count > 0)
134 anchors {
135 bottom: parent.top
136 horizontalCenter: parent.horizontalCenter
137
138=== removed file 'src/Ubuntu/Browser/RevealingBar.qml'
139--- src/Ubuntu/Browser/RevealingBar.qml 2013-03-08 10:53:16 +0000
140+++ src/Ubuntu/Browser/RevealingBar.qml 1970-01-01 00:00:00 +0000
141@@ -1,112 +0,0 @@
142-/*
143- * Copyright 2013 Canonical Ltd.
144- *
145- * This file is part of webbrowser-app.
146- *
147- * webbrowser-app is free software; you can redistribute it and/or modify
148- * it under the terms of the GNU General Public License as published by
149- * the Free Software Foundation; version 3.
150- *
151- * webbrowser-app is distributed in the hope that it will be useful,
152- * but WITHOUT ANY WARRANTY; without even the implied warranty of
153- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
154- * GNU General Public License for more details.
155- *
156- * You should have received a copy of the GNU General Public License
157- * along with this program. If not, see <http://www.gnu.org/licenses/>.
158- */
159-
160-import QtQuick 2.0
161-import Ubuntu.Components 0.1
162-
163-Item {
164- property bool shown: false
165- property bool locked: false
166- property Item contents: null
167- onContentsChanged: {
168- if (contents) {
169- contents.parent = bar
170- }
171- }
172-
173- anchors.left: parent.left
174- anchors.right: parent.right
175-
176- height: bar.height - bar.y
177-
178- function show() {
179- bar.y = 0
180- if (contents) {
181- contents.forceActiveFocus()
182- }
183- shown = true
184- }
185-
186- function hide() {
187- bar.y = bar.height
188- shown = false
189- }
190-
191- MouseArea {
192- anchors.left: parent.left
193- anchors.right: parent.right
194- anchors.bottom: parent.bottom
195- height: bar.height
196- enabled: !parent.locked
197-
198- drag.target: bar
199- drag.axis: Drag.YAxis
200- drag.minimumY: 0
201- drag.maximumY: height + bar.height
202-
203- propagateComposedEvents: true
204-
205- property int __pressedY
206- property int __lastY
207- property int __lastDrag
208-
209- onPressed: {
210- __pressedY = mouse.y
211- __lastY = __pressedY
212- __lastDrag = 0
213- }
214-
215- onPositionChanged: {
216- var drag = __lastY - mouse.y
217- __lastY = mouse.y
218- if (drag != 0 || __lastDrag == 0) {
219- __lastDrag = drag
220- }
221- }
222-
223- function __doneDragging() {
224- if (__lastDrag > 0) {
225- show()
226- } else if (__lastDrag < 0) {
227- hide()
228- } else if (shown) {
229- show()
230- } else {
231- hide()
232- }
233- }
234-
235- onReleased: __doneDragging()
236- onCanceled: __doneDragging()
237-
238- Item {
239- id: bar
240-
241- height: contents ? contents.height : 0
242- anchors.left: parent.left
243- anchors.right: parent.right
244- y: parent.height
245-
246- Behavior on y {
247- NumberAnimation {
248- duration: 150
249- }
250- }
251- }
252- }
253-}
254
255=== modified file 'tests/autopilot/webbrowser_app/tests/__init__.py'
256--- tests/autopilot/webbrowser_app/tests/__init__.py 2013-04-30 23:21:59 +0000
257+++ tests/autopilot/webbrowser_app/tests/__init__.py 2013-05-03 17:23:25 +0000
258@@ -98,44 +98,22 @@
259 self._temp_pages.append(path)
260 return "file://" + path
261
262- def swipe_chrome_up(self, distance):
263+ def reveal_chrome(self):
264+ distance = self.main_window.get_chrome().height
265 view = self.main_window.get_qml_view()
266 x_line = int(view.x + view.width * 0.5)
267 start_y = int(view.y + view.height - 1)
268 stop_y = int(start_y - distance)
269 self.mouse.drag(x_line, start_y, x_line, stop_y)
270
271- def swipe_chrome_down(self, distance):
272+ def hide_chrome(self):
273+ distance = self.main_window.get_chrome().height
274 view = self.main_window.get_qml_view()
275 x_line = int(view.x + view.width * 0.5)
276 start_y = int(self.main_window.get_chrome().globalRect[1])
277 stop_y = int(start_y + distance)
278 self.mouse.drag(x_line, start_y, x_line, stop_y)
279
280- def reveal_chrome(self):
281- self.swipe_chrome_up(self.main_window.get_chrome().height)
282-
283- def hide_chrome(self):
284- self.swipe_chrome_down(self.main_window.get_chrome().height)
285-
286- def assert_chrome_eventually_shown(self):
287- view = self.main_window.get_qml_view()
288- chrome = self.main_window.get_chrome()
289- expected_y = view.y + view.height - chrome.height
290- self.assertThat(lambda: chrome.globalRect[1],
291- Eventually(Equals(expected_y)))
292-
293- def assert_chrome_hidden(self):
294- view = self.main_window.get_qml_view()
295- chrome = self.main_window.get_chrome()
296- self.assertThat(chrome.globalRect[1], Equals(view.y + view.height))
297-
298- def assert_chrome_eventually_hidden(self):
299- view = self.main_window.get_qml_view()
300- chrome = self.main_window.get_chrome()
301- self.assertThat(lambda: chrome.globalRect[1],
302- Eventually(Equals(view.y + view.height)))
303-
304 def go_to_url(self, url):
305 self.reveal_chrome()
306 address_bar = self.main_window.get_address_bar()
307
308=== modified file 'tests/autopilot/webbrowser_app/tests/test_toolbar.py'
309--- tests/autopilot/webbrowser_app/tests/test_toolbar.py 2013-04-30 22:59:39 +0000
310+++ tests/autopilot/webbrowser_app/tests/test_toolbar.py 2013-05-03 17:23:25 +0000
311@@ -8,6 +8,9 @@
312
313 from __future__ import absolute_import
314
315+from testtools.matchers import Equals
316+from autopilot.matchers import Eventually
317+
318 from webbrowser_app.tests import BrowserTestCaseBase
319
320
321@@ -15,59 +18,29 @@
322
323 """Tests interaction with the toolbar."""
324
325+ def assert_chrome_eventually_hidden(self):
326+ view = self.main_window.get_qml_view()
327+ chrome = self.main_window.get_chrome()
328+ self.assertThat(lambda: chrome.globalRect[1],
329+ Eventually(Equals(view.y + view.height)))
330+
331 def test_reveal_chrome(self):
332- self.assert_chrome_hidden()
333+ view = self.main_window.get_qml_view()
334+ chrome = self.main_window.get_chrome()
335+ self.assertThat(chrome.globalRect[1], Equals(view.y + view.height))
336 self.reveal_chrome()
337- self.assert_chrome_eventually_shown()
338-
339- def test_reveal_chrome_with_partial_swipe(self):
340- self.assert_chrome_hidden()
341- self.swipe_chrome_up(10)
342- self.assert_chrome_eventually_shown()
343-
344- def test_reveal_chrome_with_long_swipe(self):
345- chrome = self.main_window.get_chrome()
346- self.assert_chrome_hidden()
347- self.swipe_chrome_up(chrome.height * 2)
348- self.assert_chrome_eventually_shown()
349+ expected_y = view.y + view.height - chrome.height
350+ self.assertThat(lambda: chrome.globalRect[1],
351+ Eventually(Equals(expected_y)))
352
353 def test_hide_chrome(self):
354 self.reveal_chrome()
355 self.hide_chrome()
356 self.assert_chrome_eventually_hidden()
357
358- def test_hide_chrome_with_partial_swipe(self):
359- self.reveal_chrome()
360- self.swipe_chrome_down(10)
361- self.assert_chrome_eventually_hidden()
362-
363- def test_hide_chrome_with_long_swipe(self):
364- chrome = self.main_window.get_chrome()
365- self.reveal_chrome()
366- self.swipe_chrome_down(chrome.height * 2)
367- self.assert_chrome_eventually_hidden()
368-
369 def test_unfocus_chrome_hides_it(self):
370 webview = self.main_window.get_web_view()
371 self.reveal_chrome()
372 self.mouse.move_to_object(webview)
373 self.mouse.click()
374 self.assert_chrome_eventually_hidden()
375-
376- def test_swipe_down_hidden_chrome_doesnt_reveal_it(self):
377- view = self.main_window.get_qml_view()
378- x_line = int(view.x + view.width * 0.5)
379- start_y = int(view.y + view.height - 1)
380- stop_y = start_y + 20
381- self.mouse.drag(x_line, start_y, x_line, stop_y)
382- self.assert_chrome_eventually_hidden()
383-
384- def test_swipe_shown_chrome_up_doesnt_hide_it(self):
385- view = self.main_window.get_qml_view()
386- chrome = self.main_window.get_chrome()
387- self.reveal_chrome()
388- x_line = int(view.x + view.width * 0.5)
389- start_y = int(chrome.globalRect[1])
390- stop_y = int(view.y - 1)
391- self.mouse.drag(x_line, start_y, x_line, stop_y)
392- self.assert_chrome_eventually_shown()

Subscribers

People subscribed via source and target branches

to status/vote changes: