Merge lp:~uriboni/webbrowser-app/reset-focus-tab-change into lp:webbrowser-app

Proposed by Ugo Riboni
Status: Merged
Approved by: Olivier Tilloy
Approved revision: 1151
Merged at revision: 1161
Proposed branch: lp:~uriboni/webbrowser-app/reset-focus-tab-change
Merge into: lp:webbrowser-app
Diff against target: 85 lines (+57/-0)
2 files modified
src/app/webbrowser/Browser.qml (+1/-0)
tests/autopilot/webbrowser_app/tests/test_tabs.py (+56/-0)
To merge this branch: bzr merge lp:~uriboni/webbrowser-app/reset-focus-tab-change
Reviewer Review Type Date Requested Status
PS Jenkins bot continuous-integration Needs Fixing
Olivier Tilloy Approve
Riccardo Padovani (community) Approve
Review via email: mp+269083@code.launchpad.net

Commit message

Properly reset focus when the current tab changes (including as a result of closing tabs).

Description of the change

Properly reset focus on when the current tab changes (including as a result of closing tabs)

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
Riccardo Padovani (rpadovani) wrote :

lgtm, thanks for working on this :-)

review: Approve
Revision history for this message
Olivier Tilloy (osomon) wrote :

33 + if not self.main_window.wide:
34 + self.skipTest("Only on wide form factors")

This is not the correct check. "desktop" and wide are not equivalent. A tablet in landscape mode is a wide form factor, but it doesn’t necessarily have a physical keyboard plugged in. I am aware that this "desktop" form factor thing will break easily when we get to corner cases (tablet with a keyboard, or desktop with a touch screen, …), and this will need fixing, but for now this is what we use to identify a device that has a reasonably wide screen and a physical keyboard.

review: Needs Fixing
1149. By Ugo Riboni

Run the AP tests only on systems with a keyboard

1150. By Ugo Riboni

Merge changes from trunk

Revision history for this message
PS Jenkins bot (ps-jenkins) wrote :
review: Needs Fixing (continuous-integration)
1151. By Ugo Riboni

Merge changes from trunk

Revision history for this message
Olivier Tilloy (osomon) wrote :

Looks good to me now, thanks!

review: Approve
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
=== modified file 'src/app/webbrowser/Browser.qml'
--- src/app/webbrowser/Browser.qml 2015-08-27 14:02:05 +0000
+++ src/app/webbrowser/Browser.qml 2015-09-02 08:46:05 +0000
@@ -1463,6 +1463,7 @@
1463 if (tab) {1463 if (tab) {
1464 tab.load()1464 tab.load()
1465 }1465 }
1466 internal.resetFocus()
1466 }1467 }
1467 onCountChanged: {1468 onCountChanged: {
1468 if (tabsModel.count == 0) {1469 if (tabsModel.count == 0) {
14691470
=== modified file 'tests/autopilot/webbrowser_app/tests/test_tabs.py'
--- tests/autopilot/webbrowser_app/tests/test_tabs.py 2015-08-12 12:31:56 +0000
+++ tests/autopilot/webbrowser_app/tests/test_tabs.py 2015-09-02 08:46:05 +0000
@@ -18,6 +18,7 @@
18from autopilot.matchers import Eventually18from autopilot.matchers import Eventually
19from autopilot.platform import model19from autopilot.platform import model
2020
21import testtools
21import unittest22import unittest
2223
23from webbrowser_app.tests import StartOpenRemotePageTestCaseBase24from webbrowser_app.tests import StartOpenRemotePageTestCaseBase
@@ -131,6 +132,61 @@
131 self.check_current_tab(url)132 self.check_current_tab(url)
132133
133134
135@testtools.skipIf(model() != "Desktop", "on desktop only")
136class TestTabsFocus(StartOpenRemotePageTestCaseBase, TestTabsMixin):
137
138 def test_focus_on_switch(self):
139 """Test that switching between tabs correctly resets focus to the
140 webview if a page is loaded, and to the address bar if we are in
141 the new page view"""
142 address_bar = self.main_window.address_bar
143
144 self.main_window.press_key('Ctrl+T')
145 self.assertThat(address_bar.activeFocus, Eventually(Equals(True)))
146
147 self.main_window.press_key('Ctrl+Tab')
148 self.assertThat(address_bar.activeFocus, Eventually(Equals(False)))
149 webview = self.main_window.get_current_webview()
150 self.assertThat(webview.activeFocus, Eventually(Equals(True)))
151
152 self.main_window.press_key('Ctrl+Tab')
153 self.assertThat(address_bar.activeFocus, Eventually(Equals(True)))
154 webview = self.main_window.get_current_webview()
155 self.assertThat(webview.activeFocus, Eventually(Equals(False)))
156
157 def test_focus_on_close(self):
158 """Test that closing tabs correctly resets focus,
159 allowing keyboard shortcuts to work without interruption"""
160 address_bar = self.main_window.address_bar
161
162 self.main_window.press_key('Ctrl+T')
163 self.main_window.press_key('Ctrl+T')
164 url = self.base_url + "/test1"
165 self.main_window.go_to_url(url)
166 self.main_window.wait_until_page_loaded(url)
167
168 self.main_window.press_key('Ctrl+T')
169 url = self.base_url + "/test2"
170 self.main_window.go_to_url(url)
171 self.main_window.wait_until_page_loaded(url)
172 self.main_window.press_key('Ctrl+T')
173 self.main_window.press_key('Ctrl+T')
174
175 self.main_window.press_key('Ctrl+W')
176 self.assertThat(address_bar.activeFocus, Eventually(Equals(True)))
177
178 self.main_window.press_key('Ctrl+W')
179 webview = self.main_window.get_current_webview()
180 self.assertThat(webview.activeFocus, Eventually(Equals(True)))
181
182 self.main_window.press_key('Ctrl+W')
183 webview = self.main_window.get_current_webview()
184 self.assertThat(webview.activeFocus, Eventually(Equals(True)))
185
186 self.main_window.press_key('Ctrl+W')
187 self.assertThat(address_bar.activeFocus, Eventually(Equals(True)))
188
189
134class TestTabsManagement(StartOpenRemotePageTestCaseBase, TestTabsMixin):190class TestTabsManagement(StartOpenRemotePageTestCaseBase, TestTabsMixin):
135191
136 def test_open_target_blank_in_new_tab(self):192 def test_open_target_blank_in_new_tab(self):

Subscribers

People subscribed via source and target branches

to status/vote changes: