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
=== modified file 'src/Ubuntu/Browser/Browser.qml'
--- src/Ubuntu/Browser/Browser.qml 2013-05-03 01:10:43 +0000
+++ src/Ubuntu/Browser/Browser.qml 2013-05-03 17:23:25 +0000
@@ -196,7 +196,7 @@
196196
197 onActiveFocusChanged: {197 onActiveFocusChanged: {
198 if (activeFocus) {198 if (activeFocus) {
199 revealingBar.hide()199 panel.opened = false
200 }200 }
201 }201 }
202202
@@ -295,11 +295,56 @@
295 align: Qt.AlignBottom295 align: Qt.AlignBottom
296 }296 }
297297
298 RevealingBar {298 Panel {
299 id: revealingBar299 id: panel
300 enabled: !browser.chromeless300
301 contents: chromeLoader.item301 locked: browser.chromeless
302 anchors.bottom: shown ? osk.top : parent.bottom302
303 anchors {
304 left: parent.left
305 right: parent.right
306 bottom: opened ? osk.top : parent.bottom
307 }
308 height: units.gu(8)
309
310 Loader {
311 id: chromeLoader
312
313 active: !browser.chromeless
314 source: "Chrome.qml"
315
316 anchors.fill: parent
317
318 Binding {
319 target: chromeLoader.item
320 property: "loading"
321 value: webview.loading || (webview.progress == 0)
322 }
323
324 Binding {
325 target: chromeLoader.item
326 property: "canGoBack"
327 value: webview.canGoBack
328 }
329
330 Binding {
331 target: chromeLoader.item
332 property: "canGoForward"
333 value: webview.canGoForward
334 }
335
336 Connections {
337 target: chromeLoader.item
338 onGoBackClicked: webview.goBack()
339 onGoForwardClicked: webview.goForward()
340 onUrlValidated: {
341 browser.url = url
342 webview.forceActiveFocus()
343 }
344 onRequestReload: webview.reload()
345 onRequestStop: webview.stop()
346 }
347 }
303 }348 }
304349
305 ProgressBar {350 ProgressBar {
@@ -317,48 +362,6 @@
317 value: webview.loadProgress362 value: webview.loadProgress
318 }363 }
319364
320 Loader {
321 id: chromeLoader
322
323 active: !browser.chromeless
324 source: "Chrome.qml"
325
326 anchors.left: parent.left
327 anchors.right: parent.right
328
329 height: units.gu(8)
330
331 Binding {
332 target: chromeLoader.item
333 property: "loading"
334 value: webview.loading || (webview.progress == 0)
335 }
336
337 Binding {
338 target: chromeLoader.item
339 property: "canGoBack"
340 value: webview.canGoBack
341 }
342
343 Binding {
344 target: chromeLoader.item
345 property: "canGoForward"
346 value: webview.canGoForward
347 }
348
349 Connections {
350 target: chromeLoader.item
351 onGoBackClicked: webview.goBack()
352 onGoForwardClicked: webview.goForward()
353 onUrlValidated: {
354 browser.url = url
355 webview.forceActiveFocus()
356 }
357 onRequestReload: webview.reload()
358 onRequestStop: webview.stop()
359 }
360 }
361
362 KeyboardRectangle {365 KeyboardRectangle {
363 id: osk366 id: osk
364 }367 }
365368
=== modified file 'src/Ubuntu/Browser/Chrome.qml'
--- src/Ubuntu/Browser/Chrome.qml 2013-04-18 15:48:38 +0000
+++ src/Ubuntu/Browser/Chrome.qml 2013-05-03 17:23:25 +0000
@@ -94,7 +94,7 @@
9494
95 Suggestions {95 Suggestions {
96 id: suggestions96 id: suggestions
97 visible: addressBar.focus && (count > 0)97 visible: addressBar.activeFocus && (count > 0)
98 anchors {98 anchors {
99 bottom: parent.top99 bottom: parent.top
100 horizontalCenter: parent.horizontalCenter100 horizontalCenter: parent.horizontalCenter
101101
=== removed file 'src/Ubuntu/Browser/RevealingBar.qml'
--- src/Ubuntu/Browser/RevealingBar.qml 2013-03-08 10:53:16 +0000
+++ src/Ubuntu/Browser/RevealingBar.qml 1970-01-01 00:00:00 +0000
@@ -1,112 +0,0 @@
1/*
2 * Copyright 2013 Canonical Ltd.
3 *
4 * This file is part of webbrowser-app.
5 *
6 * webbrowser-app is free software; you can redistribute it and/or modify
7 * it under the terms of the GNU General Public License as published by
8 * the Free Software Foundation; version 3.
9 *
10 * webbrowser-app is distributed in the hope that it will be useful,
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 * GNU General Public License for more details.
14 *
15 * You should have received a copy of the GNU General Public License
16 * along with this program. If not, see <http://www.gnu.org/licenses/>.
17 */
18
19import QtQuick 2.0
20import Ubuntu.Components 0.1
21
22Item {
23 property bool shown: false
24 property bool locked: false
25 property Item contents: null
26 onContentsChanged: {
27 if (contents) {
28 contents.parent = bar
29 }
30 }
31
32 anchors.left: parent.left
33 anchors.right: parent.right
34
35 height: bar.height - bar.y
36
37 function show() {
38 bar.y = 0
39 if (contents) {
40 contents.forceActiveFocus()
41 }
42 shown = true
43 }
44
45 function hide() {
46 bar.y = bar.height
47 shown = false
48 }
49
50 MouseArea {
51 anchors.left: parent.left
52 anchors.right: parent.right
53 anchors.bottom: parent.bottom
54 height: bar.height
55 enabled: !parent.locked
56
57 drag.target: bar
58 drag.axis: Drag.YAxis
59 drag.minimumY: 0
60 drag.maximumY: height + bar.height
61
62 propagateComposedEvents: true
63
64 property int __pressedY
65 property int __lastY
66 property int __lastDrag
67
68 onPressed: {
69 __pressedY = mouse.y
70 __lastY = __pressedY
71 __lastDrag = 0
72 }
73
74 onPositionChanged: {
75 var drag = __lastY - mouse.y
76 __lastY = mouse.y
77 if (drag != 0 || __lastDrag == 0) {
78 __lastDrag = drag
79 }
80 }
81
82 function __doneDragging() {
83 if (__lastDrag > 0) {
84 show()
85 } else if (__lastDrag < 0) {
86 hide()
87 } else if (shown) {
88 show()
89 } else {
90 hide()
91 }
92 }
93
94 onReleased: __doneDragging()
95 onCanceled: __doneDragging()
96
97 Item {
98 id: bar
99
100 height: contents ? contents.height : 0
101 anchors.left: parent.left
102 anchors.right: parent.right
103 y: parent.height
104
105 Behavior on y {
106 NumberAnimation {
107 duration: 150
108 }
109 }
110 }
111 }
112}
1130
=== modified file 'tests/autopilot/webbrowser_app/tests/__init__.py'
--- tests/autopilot/webbrowser_app/tests/__init__.py 2013-04-30 23:21:59 +0000
+++ tests/autopilot/webbrowser_app/tests/__init__.py 2013-05-03 17:23:25 +0000
@@ -98,44 +98,22 @@
98 self._temp_pages.append(path)98 self._temp_pages.append(path)
99 return "file://" + path99 return "file://" + path
100100
101 def swipe_chrome_up(self, distance):101 def reveal_chrome(self):
102 distance = self.main_window.get_chrome().height
102 view = self.main_window.get_qml_view()103 view = self.main_window.get_qml_view()
103 x_line = int(view.x + view.width * 0.5)104 x_line = int(view.x + view.width * 0.5)
104 start_y = int(view.y + view.height - 1)105 start_y = int(view.y + view.height - 1)
105 stop_y = int(start_y - distance)106 stop_y = int(start_y - distance)
106 self.mouse.drag(x_line, start_y, x_line, stop_y)107 self.mouse.drag(x_line, start_y, x_line, stop_y)
107108
108 def swipe_chrome_down(self, distance):109 def hide_chrome(self):
110 distance = self.main_window.get_chrome().height
109 view = self.main_window.get_qml_view()111 view = self.main_window.get_qml_view()
110 x_line = int(view.x + view.width * 0.5)112 x_line = int(view.x + view.width * 0.5)
111 start_y = int(self.main_window.get_chrome().globalRect[1])113 start_y = int(self.main_window.get_chrome().globalRect[1])
112 stop_y = int(start_y + distance)114 stop_y = int(start_y + distance)
113 self.mouse.drag(x_line, start_y, x_line, stop_y)115 self.mouse.drag(x_line, start_y, x_line, stop_y)
114116
115 def reveal_chrome(self):
116 self.swipe_chrome_up(self.main_window.get_chrome().height)
117
118 def hide_chrome(self):
119 self.swipe_chrome_down(self.main_window.get_chrome().height)
120
121 def assert_chrome_eventually_shown(self):
122 view = self.main_window.get_qml_view()
123 chrome = self.main_window.get_chrome()
124 expected_y = view.y + view.height - chrome.height
125 self.assertThat(lambda: chrome.globalRect[1],
126 Eventually(Equals(expected_y)))
127
128 def assert_chrome_hidden(self):
129 view = self.main_window.get_qml_view()
130 chrome = self.main_window.get_chrome()
131 self.assertThat(chrome.globalRect[1], Equals(view.y + view.height))
132
133 def assert_chrome_eventually_hidden(self):
134 view = self.main_window.get_qml_view()
135 chrome = self.main_window.get_chrome()
136 self.assertThat(lambda: chrome.globalRect[1],
137 Eventually(Equals(view.y + view.height)))
138
139 def go_to_url(self, url):117 def go_to_url(self, url):
140 self.reveal_chrome()118 self.reveal_chrome()
141 address_bar = self.main_window.get_address_bar()119 address_bar = self.main_window.get_address_bar()
142120
=== modified file 'tests/autopilot/webbrowser_app/tests/test_toolbar.py'
--- tests/autopilot/webbrowser_app/tests/test_toolbar.py 2013-04-30 22:59:39 +0000
+++ tests/autopilot/webbrowser_app/tests/test_toolbar.py 2013-05-03 17:23:25 +0000
@@ -8,6 +8,9 @@
88
9from __future__ import absolute_import9from __future__ import absolute_import
1010
11from testtools.matchers import Equals
12from autopilot.matchers import Eventually
13
11from webbrowser_app.tests import BrowserTestCaseBase14from webbrowser_app.tests import BrowserTestCaseBase
1215
1316
@@ -15,59 +18,29 @@
1518
16 """Tests interaction with the toolbar."""19 """Tests interaction with the toolbar."""
1720
21 def assert_chrome_eventually_hidden(self):
22 view = self.main_window.get_qml_view()
23 chrome = self.main_window.get_chrome()
24 self.assertThat(lambda: chrome.globalRect[1],
25 Eventually(Equals(view.y + view.height)))
26
18 def test_reveal_chrome(self):27 def test_reveal_chrome(self):
19 self.assert_chrome_hidden()28 view = self.main_window.get_qml_view()
29 chrome = self.main_window.get_chrome()
30 self.assertThat(chrome.globalRect[1], Equals(view.y + view.height))
20 self.reveal_chrome()31 self.reveal_chrome()
21 self.assert_chrome_eventually_shown()32 expected_y = view.y + view.height - chrome.height
2233 self.assertThat(lambda: chrome.globalRect[1],
23 def test_reveal_chrome_with_partial_swipe(self):34 Eventually(Equals(expected_y)))
24 self.assert_chrome_hidden()
25 self.swipe_chrome_up(10)
26 self.assert_chrome_eventually_shown()
27
28 def test_reveal_chrome_with_long_swipe(self):
29 chrome = self.main_window.get_chrome()
30 self.assert_chrome_hidden()
31 self.swipe_chrome_up(chrome.height * 2)
32 self.assert_chrome_eventually_shown()
3335
34 def test_hide_chrome(self):36 def test_hide_chrome(self):
35 self.reveal_chrome()37 self.reveal_chrome()
36 self.hide_chrome()38 self.hide_chrome()
37 self.assert_chrome_eventually_hidden()39 self.assert_chrome_eventually_hidden()
3840
39 def test_hide_chrome_with_partial_swipe(self):
40 self.reveal_chrome()
41 self.swipe_chrome_down(10)
42 self.assert_chrome_eventually_hidden()
43
44 def test_hide_chrome_with_long_swipe(self):
45 chrome = self.main_window.get_chrome()
46 self.reveal_chrome()
47 self.swipe_chrome_down(chrome.height * 2)
48 self.assert_chrome_eventually_hidden()
49
50 def test_unfocus_chrome_hides_it(self):41 def test_unfocus_chrome_hides_it(self):
51 webview = self.main_window.get_web_view()42 webview = self.main_window.get_web_view()
52 self.reveal_chrome()43 self.reveal_chrome()
53 self.mouse.move_to_object(webview)44 self.mouse.move_to_object(webview)
54 self.mouse.click()45 self.mouse.click()
55 self.assert_chrome_eventually_hidden()46 self.assert_chrome_eventually_hidden()
56
57 def test_swipe_down_hidden_chrome_doesnt_reveal_it(self):
58 view = self.main_window.get_qml_view()
59 x_line = int(view.x + view.width * 0.5)
60 start_y = int(view.y + view.height - 1)
61 stop_y = start_y + 20
62 self.mouse.drag(x_line, start_y, x_line, stop_y)
63 self.assert_chrome_eventually_hidden()
64
65 def test_swipe_shown_chrome_up_doesnt_hide_it(self):
66 view = self.main_window.get_qml_view()
67 chrome = self.main_window.get_chrome()
68 self.reveal_chrome()
69 x_line = int(view.x + view.width * 0.5)
70 start_y = int(chrome.globalRect[1])
71 stop_y = int(view.y - 1)
72 self.mouse.drag(x_line, start_y, x_line, stop_y)
73 self.assert_chrome_eventually_shown()

Subscribers

People subscribed via source and target branches

to status/vote changes: