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
1=== modified file 'src/app/webbrowser/Browser.qml'
2--- src/app/webbrowser/Browser.qml 2015-08-27 14:02:05 +0000
3+++ src/app/webbrowser/Browser.qml 2015-09-02 08:46:05 +0000
4@@ -1463,6 +1463,7 @@
5 if (tab) {
6 tab.load()
7 }
8+ internal.resetFocus()
9 }
10 onCountChanged: {
11 if (tabsModel.count == 0) {
12
13=== modified file 'tests/autopilot/webbrowser_app/tests/test_tabs.py'
14--- tests/autopilot/webbrowser_app/tests/test_tabs.py 2015-08-12 12:31:56 +0000
15+++ tests/autopilot/webbrowser_app/tests/test_tabs.py 2015-09-02 08:46:05 +0000
16@@ -18,6 +18,7 @@
17 from autopilot.matchers import Eventually
18 from autopilot.platform import model
19
20+import testtools
21 import unittest
22
23 from webbrowser_app.tests import StartOpenRemotePageTestCaseBase
24@@ -131,6 +132,61 @@
25 self.check_current_tab(url)
26
27
28+@testtools.skipIf(model() != "Desktop", "on desktop only")
29+class TestTabsFocus(StartOpenRemotePageTestCaseBase, TestTabsMixin):
30+
31+ def test_focus_on_switch(self):
32+ """Test that switching between tabs correctly resets focus to the
33+ webview if a page is loaded, and to the address bar if we are in
34+ the new page view"""
35+ address_bar = self.main_window.address_bar
36+
37+ self.main_window.press_key('Ctrl+T')
38+ self.assertThat(address_bar.activeFocus, Eventually(Equals(True)))
39+
40+ self.main_window.press_key('Ctrl+Tab')
41+ self.assertThat(address_bar.activeFocus, Eventually(Equals(False)))
42+ webview = self.main_window.get_current_webview()
43+ self.assertThat(webview.activeFocus, Eventually(Equals(True)))
44+
45+ self.main_window.press_key('Ctrl+Tab')
46+ self.assertThat(address_bar.activeFocus, Eventually(Equals(True)))
47+ webview = self.main_window.get_current_webview()
48+ self.assertThat(webview.activeFocus, Eventually(Equals(False)))
49+
50+ def test_focus_on_close(self):
51+ """Test that closing tabs correctly resets focus,
52+ allowing keyboard shortcuts to work without interruption"""
53+ address_bar = self.main_window.address_bar
54+
55+ self.main_window.press_key('Ctrl+T')
56+ self.main_window.press_key('Ctrl+T')
57+ url = self.base_url + "/test1"
58+ self.main_window.go_to_url(url)
59+ self.main_window.wait_until_page_loaded(url)
60+
61+ self.main_window.press_key('Ctrl+T')
62+ url = self.base_url + "/test2"
63+ self.main_window.go_to_url(url)
64+ self.main_window.wait_until_page_loaded(url)
65+ self.main_window.press_key('Ctrl+T')
66+ self.main_window.press_key('Ctrl+T')
67+
68+ self.main_window.press_key('Ctrl+W')
69+ self.assertThat(address_bar.activeFocus, Eventually(Equals(True)))
70+
71+ self.main_window.press_key('Ctrl+W')
72+ webview = self.main_window.get_current_webview()
73+ self.assertThat(webview.activeFocus, Eventually(Equals(True)))
74+
75+ self.main_window.press_key('Ctrl+W')
76+ webview = self.main_window.get_current_webview()
77+ self.assertThat(webview.activeFocus, Eventually(Equals(True)))
78+
79+ self.main_window.press_key('Ctrl+W')
80+ self.assertThat(address_bar.activeFocus, Eventually(Equals(True)))
81+
82+
83 class TestTabsManagement(StartOpenRemotePageTestCaseBase, TestTabsMixin):
84
85 def test_open_target_blank_in_new_tab(self):

Subscribers

People subscribed via source and target branches

to status/vote changes: