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

Proposed by Olivier Tilloy
Status: Merged
Merged at revision: 1472
Proposed branch: lp:~osomon/webbrowser-app/zoomFactor
Merge into: lp:webbrowser-app
Diff against target: 146 lines (+86/-3)
3 files modified
debian/control (+1/-1)
src/app/webbrowser/Browser.qml (+36/-1)
tests/autopilot/webbrowser_app/tests/test_keyboard.py (+49/-1)
To merge this branch: bzr merge lp:~osomon/webbrowser-app/zoomFactor
Reviewer Review Type Date Requested Status
system-apps-ci-bot continuous-integration Needs Fixing
PS Jenkins bot continuous-integration Needs Fixing
Ubuntu Phablet Team Pending
Review via email: mp+292637@code.launchpad.net

Commit message

Keyboard shortcuts for zoom factor:
 - Ctrl+Plus: zoom in
 - Ctrl+Minus: zoom out
 - Ctrl+0: reset zoom factor to 100%

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

FAILED: Continuous integration, rev:1429
https://jenkins.canonical.com/system-apps/job/lp-webbrowser-app-ci/462/
Executed test runs:
    FAILURE: https://jenkins.canonical.com/system-apps/job/build/464/console
    SUCCESS: https://jenkins.canonical.com/system-apps/job/build-0-fetch/464
    SUCCESS: https://jenkins.canonical.com/system-apps/job/build-1-sourcepkg/release=vivid+overlay/463
    SUCCESS: https://jenkins.canonical.com/system-apps/job/build-1-sourcepkg/release=xenial/463
    SUCCESS: https://jenkins.canonical.com/system-apps/job/build-2-binpkg/arch=amd64,release=vivid+overlay/470
        deb: https://jenkins.canonical.com/system-apps/job/build-2-binpkg/arch=amd64,release=vivid+overlay/470/artifact/output/*zip*/output.zip
    FAILURE: https://jenkins.canonical.com/system-apps/job/build-2-binpkg/arch=amd64,release=xenial/470/console
    SUCCESS: https://jenkins.canonical.com/system-apps/job/build-2-binpkg/arch=armhf,release=vivid+overlay/470
        deb: https://jenkins.canonical.com/system-apps/job/build-2-binpkg/arch=armhf,release=vivid+overlay/470/artifact/output/*zip*/output.zip
    SUCCESS: https://jenkins.canonical.com/system-apps/job/build-2-binpkg/arch=armhf,release=xenial/470
        deb: https://jenkins.canonical.com/system-apps/job/build-2-binpkg/arch=armhf,release=xenial/470/artifact/output/*zip*/output.zip
    SUCCESS: https://jenkins.canonical.com/system-apps/job/build-2-binpkg/arch=i386,release=vivid+overlay/470
        deb: https://jenkins.canonical.com/system-apps/job/build-2-binpkg/arch=i386,release=vivid+overlay/470/artifact/output/*zip*/output.zip
    SUCCESS: https://jenkins.canonical.com/system-apps/job/build-2-binpkg/arch=i386,release=xenial/470
        deb: https://jenkins.canonical.com/system-apps/job/build-2-binpkg/arch=i386,release=xenial/470/artifact/output/*zip*/output.zip

Click here to trigger a rebuild:
https://jenkins.canonical.com/system-apps/job/lp-webbrowser-app-ci/462/rebuild

review: Needs Fixing (continuous-integration)
lp:~osomon/webbrowser-app/zoomFactor updated
1430. By Olivier Tilloy

Merge the latest changes from trunk and resolve a minor conflict.

Revision history for this message
system-apps-ci-bot (system-apps-ci-bot) wrote :
review: Needs Fixing (continuous-integration)
lp:~osomon/webbrowser-app/zoomFactor updated
1431. By Olivier Tilloy

Merge the latest changes from trunk and resolve a couple of minor conflicts.

Revision history for this message
system-apps-ci-bot (system-apps-ci-bot) 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 'debian/control'
2--- debian/control 2016-05-19 18:39:19 +0000
3+++ debian/control 2016-05-23 15:50:35 +0000
4@@ -45,7 +45,7 @@
5 Depends: ${misc:Depends},
6 ${shlibs:Depends},
7 fonts-liberation,
8- liboxideqt-qmlplugin (>= 1.12),
9+ liboxideqt-qmlplugin (>= 1.15),
10 libqt5sql5-sqlite,
11 qml-module-qt-labs-folderlistmodel,
12 qml-module-qt-labs-settings,
13
14=== modified file 'src/app/webbrowser/Browser.qml'
15--- src/app/webbrowser/Browser.qml 2016-05-19 18:39:30 +0000
16+++ src/app/webbrowser/Browser.qml 2016-05-23 15:50:35 +0000
17@@ -19,7 +19,7 @@
18 import QtQuick 2.4
19 import QtQuick.Window 2.2
20 import Qt.labs.settings 1.0
21-import com.canonical.Oxide 1.12 as Oxide
22+import com.canonical.Oxide 1.15 as Oxide
23 import Ubuntu.Components 1.3
24 import Ubuntu.Components.Popups 1.3
25 import Unity.InputInfo 0.1
26@@ -1457,6 +1457,18 @@
27 readonly property bool hasMouse: (miceModel.count + touchPadModel.count) > 0
28 readonly property bool hasTouchScreen: touchScreenModel.count > 0
29
30+ // Ref: https://code.google.com/p/chromium/codesearch#chromium/src/components/ui/zoom/page_zoom_constants.cc
31+ readonly property var zoomFactors: [0.25, 0.333, 0.5, 0.666, 0.75, 0.9, 1.0,
32+ 1.1, 1.25, 1.5, 1.75, 2.0, 2.5, 3.0, 4.0, 5.0]
33+ function changeZoomFactor(offset) {
34+ for (var i = 0; i < zoomFactors.length; ++i) {
35+ if (Math.abs(zoomFactors[i] - currentWebview.zoomFactor) <= 0.001) {
36+ currentWebview.zoomFactor = zoomFactors[i + offset]
37+ return
38+ }
39+ }
40+ }
41+
42 function getOpenPages() {
43 var urls = []
44 for (var i = 0; i < tabsModel.count; i++) {
45@@ -2114,6 +2126,29 @@
46 onActivated: currentWebview.findController.previous()
47 }
48
49+ // Ctrl+Plus: zoom in
50+ Shortcut {
51+ sequence: StandardKey.ZoomIn
52+ enabled: currentWebview &&
53+ ((currentWebview.maximumZoomFactor - currentWebview.zoomFactor) > 0.001)
54+ onActivated: internal.changeZoomFactor(1)
55+ }
56+
57+ // Ctrl+Minus: zoom out
58+ Shortcut {
59+ sequence: StandardKey.ZoomOut
60+ enabled: currentWebview &&
61+ ((currentWebview.zoomFactor - currentWebview.minimumZoomFactor) > 0.001)
62+ onActivated: internal.changeZoomFactor(-1)
63+ }
64+
65+ // Ctrl+0: reset zoom factor to 1.0
66+ Shortcut {
67+ sequence: "Ctrl+0"
68+ enabled: currentWebview && (currentWebview.zoomFactor != 1.0)
69+ onActivated: currentWebview.zoomFactor = 1.0
70+ }
71+
72 Loader {
73 id: contentHandlerLoader
74 source: "../ContentHandler.qml"
75
76=== modified file 'tests/autopilot/webbrowser_app/tests/test_keyboard.py'
77--- tests/autopilot/webbrowser_app/tests/test_keyboard.py 2016-05-05 10:09:48 +0000
78+++ tests/autopilot/webbrowser_app/tests/test_keyboard.py 2016-05-23 15:50:35 +0000
79@@ -19,7 +19,7 @@
80 import time
81 import testtools
82
83-from testtools.matchers import Equals, NotEquals, GreaterThan
84+from testtools.matchers import Equals, Mismatch, NotEquals, GreaterThan
85 from autopilot.matchers import Eventually
86 from autopilot.platform import model
87
88@@ -57,6 +57,19 @@
89 connection.close()
90
91
92+class AlmostEquals(object):
93+
94+ def __init__(self, expected):
95+ self.expected = expected
96+
97+ def match(self, actual):
98+ if round(actual - self.expected, 3) == 0:
99+ return None
100+ else:
101+ msg = "{} is not almost equal to {}"
102+ return Mismatch(msg.format(actual, self.expected))
103+
104+
105 @testtools.skipIf(model() != "Desktop", "on desktop only")
106 class TestKeyboard(PrepopulatedDatabaseTestCaseBase):
107
108@@ -524,3 +537,38 @@
109 self.main_window.press_key('Ctrl+t')
110 self.address_bar.activeFocus.wait_for(True)
111 self.assertThat(self.address_bar.text, Eventually(Equals("")))
112+
113+ def test_zoom_in_and_out(self):
114+ webview = self.main_window.get_current_webview()
115+ self.assertThat(webview.zoomFactor, Eventually(AlmostEquals(1.0)))
116+
117+ zooms = [1.1, 1.25, 1.5, 1.75, 2.0, 2.5, 3.0, 4.0, 5.0]
118+ for zoom in zooms:
119+ self.main_window.press_key('Ctrl+plus')
120+ self.assertThat(webview.zoomFactor, Eventually(AlmostEquals(zoom)))
121+
122+ self.main_window.press_key('Ctrl+0')
123+ self.assertThat(webview.zoomFactor, Eventually(AlmostEquals(1.0)))
124+
125+ zooms = [0.9, 0.75, 0.666, 0.5, 0.333, 0.25]
126+ for zoom in zooms:
127+ self.main_window.press_key('Ctrl+minus')
128+ self.assertThat(webview.zoomFactor, Eventually(AlmostEquals(zoom)))
129+
130+ self.main_window.press_key('Ctrl+0')
131+ self.assertThat(webview.zoomFactor, Eventually(AlmostEquals(1.0)))
132+
133+ def test_zoom_affects_domain(self):
134+ webview = self.main_window.get_current_webview()
135+ self.assertThat(webview.zoomFactor, Eventually(AlmostEquals(1.0)))
136+
137+ self.open_tabs(1)
138+ self.check_tab_number(1)
139+ self.main_window.press_key('Ctrl+plus')
140+ webview = self.main_window.get_current_webview()
141+ self.assertThat(webview.zoomFactor, Eventually(AlmostEquals(1.1)))
142+
143+ self.main_window.press_key('Ctrl+Tab')
144+ self.check_tab_number(0)
145+ webview = self.main_window.get_current_webview()
146+ self.assertThat(webview.zoomFactor, Eventually(AlmostEquals(1.1)))

Subscribers

People subscribed via source and target branches

to status/vote changes: