Merge lp:~osomon/webbrowser-app/keyboard-shortcut-fixes into lp:webbrowser-app

Proposed by Olivier Tilloy
Status: Merged
Approved by: Olivier Tilloy
Approved revision: 1297
Merged at revision: 1297
Proposed branch: lp:~osomon/webbrowser-app/keyboard-shortcut-fixes
Merge into: lp:webbrowser-app
Diff against target: 159 lines (+92/-6)
4 files modified
src/app/webbrowser/Browser.qml (+14/-2)
src/app/webbrowser/HistoryViewWide.qml (+2/-4)
tests/autopilot/webbrowser_app/emulators/browser.py (+3/-0)
tests/autopilot/webbrowser_app/tests/test_keyboard.py (+73/-0)
To merge this branch: bzr merge lp:~osomon/webbrowser-app/keyboard-shortcut-fixes
Reviewer Review Type Date Requested Status
PS Jenkins bot continuous-integration Approve
Ubuntu Phablet Team Pending
Review via email: mp+279566@code.launchpad.net

Commit message

Fix multiple keyboard focus/shortcut issues.

To post a comment you must log in.
Revision history for this message
PS Jenkins bot (ps-jenkins) wrote :
review: Approve (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-11-26 11:59:33 +0000
3+++ src/app/webbrowser/Browser.qml 2015-12-04 10:53:31 +0000
4@@ -572,7 +572,7 @@
5 Keys.onDownPressed: {
6 if (suggestionsList.count) suggestionsList.focus = true
7 else if (newTabViewLoader.status == Loader.Ready) {
8- newTabViewLoader.focus = true
9+ newTabViewLoader.forceActiveFocus()
10 }
11 }
12
13@@ -753,6 +753,13 @@
14
15 Keys.onEscapePressed: bookmarksViewLoader.active = false
16
17+ onActiveChanged: {
18+ if (active) {
19+ chrome.findInPageMode = false
20+ forceActiveFocus()
21+ }
22+ }
23+
24 Connections {
25 target: bookmarksViewLoader.item
26
27@@ -806,7 +813,12 @@
28
29 Keys.onEscapePressed: historyViewLoader.active = false
30
31- onActiveChanged: if (active) chrome.findInPageMode = false
32+ onActiveChanged: {
33+ if (active) {
34+ chrome.findInPageMode = false
35+ forceActiveFocus()
36+ }
37+ }
38
39 Component {
40 id: historyViewComponent
41
42=== modified file 'src/app/webbrowser/HistoryViewWide.qml'
43--- src/app/webbrowser/HistoryViewWide.qml 2015-10-15 19:09:59 +0000
44+++ src/app/webbrowser/HistoryViewWide.qml 2015-12-04 10:53:31 +0000
45@@ -45,10 +45,8 @@
46 Keys.onPressed: {
47 if (event.modifiers === Qt.ControlModifier && event.key === Qt.Key_F) {
48 if (searchMode) searchQuery.focus = true
49- else {
50- if (!selectMode) searchMode = true
51- else event.accepted = true
52- }
53+ else if (!selectMode) searchMode = true
54+ event.accepted = true
55 }
56 }
57 Keys.onDeletePressed: {
58
59=== modified file 'tests/autopilot/webbrowser_app/emulators/browser.py'
60--- tests/autopilot/webbrowser_app/emulators/browser.py 2015-11-26 13:42:12 +0000
61+++ tests/autopilot/webbrowser_app/emulators/browser.py 2015-12-04 10:53:31 +0000
62@@ -523,6 +523,9 @@
63 return sorted(self.select_many("UrlDelegate"),
64 key=lambda item: item.globalRect.y)
65
66+ def get_search_field(self):
67+ return self.select_single(objectName="searchQuery")
68+
69
70 class ExpandedHistoryView(uitk.UbuntuUIToolkitCustomProxyObjectBase):
71
72
73=== modified file 'tests/autopilot/webbrowser_app/tests/test_keyboard.py'
74--- tests/autopilot/webbrowser_app/tests/test_keyboard.py 2015-11-11 16:03:56 +0000
75+++ tests/autopilot/webbrowser_app/tests/test_keyboard.py 2015-12-04 10:53:31 +0000
76@@ -345,6 +345,61 @@
77 new_tab_view = self.main_window.get_new_tab_view()
78 self.assertThat(new_tab_view.visible, Eventually(Equals(True)))
79
80+ def test_search_in_history(self):
81+ if not self.main_window.wide:
82+ self.skipTest("Only on wide form factors")
83+
84+ self.assertThat(self.main_window.get_history_view(), Equals(None))
85+ self.main_window.press_key('Ctrl+h')
86+ self.assertThat(lambda: self.main_window.get_history_view(),
87+ Eventually(NotEquals(None)))
88+ history_view = self.main_window.get_history_view()
89+
90+ self.main_window.press_key('Ctrl+f')
91+ self.assertThat(history_view.searchMode, Eventually(Equals(True)))
92+ search_field = history_view.get_search_field()
93+ self.assertThat(search_field.visible, Equals(True))
94+ self.assertThat(search_field.activeFocus, Eventually(Equals(True)))
95+
96+ self.main_window.press_key('Escape')
97+ self.assertThat(history_view.searchMode, Eventually(Equals(False)))
98+ self.assertThat(search_field.visible, Equals(False))
99+
100+ self.main_window.press_key('Escape')
101+ history_view.wait_until_destroyed()
102+
103+ def test_open_history_exits_findinpage(self):
104+ address_bar = self.main_window.chrome.address_bar
105+ self.main_window.press_key('Ctrl+f')
106+ self.assertThat(address_bar.findInPageMode, Eventually(Equals(True)))
107+ self.assertThat(address_bar.activeFocus, Eventually(Equals(True)))
108+
109+ self.main_window.press_key('Ctrl+h')
110+ self.assertThat(lambda: self.main_window.get_history_view(),
111+ Eventually(NotEquals(None)))
112+ history_view = self.main_window.get_history_view()
113+ self.assertThat(address_bar.findInPageMode, Eventually(Equals(False)))
114+ self.assertThat(address_bar.activeFocus, Eventually(Equals(False)))
115+
116+ self.main_window.press_key('Escape')
117+ history_view.wait_until_destroyed()
118+
119+ def test_open_bookmarks_exits_findinpage(self):
120+ address_bar = self.main_window.chrome.address_bar
121+ self.main_window.press_key('Ctrl+f')
122+ self.assertThat(address_bar.findInPageMode, Eventually(Equals(True)))
123+ self.assertThat(address_bar.activeFocus, Eventually(Equals(True)))
124+
125+ self.main_window.press_key('Ctrl+Shift+o')
126+ self.assertThat(lambda: self.main_window.get_bookmarks_view(),
127+ Eventually(NotEquals(None)))
128+ bookmarks_view = self.main_window.get_bookmarks_view()
129+ self.assertThat(address_bar.findInPageMode, Eventually(Equals(False)))
130+ self.assertThat(address_bar.activeFocus, Eventually(Equals(False)))
131+
132+ self.main_window.press_key('Escape')
133+ bookmarks_view.wait_until_destroyed()
134+
135 def test_escape_settings(self):
136 settings = self.open_settings()
137 self.main_window.press_key('Escape')
138@@ -364,3 +419,21 @@
139 self.open_new_tab()
140 self.main_window.press_key('Ctrl+f')
141 self.assertThat(address_bar.findInPageMode, Equals(False))
142+
143+ def test_navigate_between_address_bar_and_new_tab_view(self):
144+ if not self.main_window.wide:
145+ self.skipTest("Only on wide form factors")
146+
147+ address_bar = self.main_window.chrome.address_bar
148+
149+ self.main_window.press_key('Ctrl+t')
150+ new_tab_view = self.main_window.get_new_tab_view()
151+ self.assertThat(address_bar.activeFocus, Eventually(Equals(True)))
152+
153+ self.main_window.press_key('Down')
154+ self.assertThat(address_bar.activeFocus, Eventually(Equals(False)))
155+ self.assertThat(new_tab_view.activeFocus, Eventually(Equals(True)))
156+
157+ self.main_window.press_key('Up')
158+ self.assertThat(new_tab_view.activeFocus, Eventually(Equals(False)))
159+ self.assertThat(address_bar.activeFocus, Eventually(Equals(True)))

Subscribers

People subscribed via source and target branches

to status/vote changes: