Merge lp:~stolowski/unity-2d/dash-hud-esc-handling-fix into lp:unity-2d

Proposed by Paweł Stołowski
Status: Merged
Approved by: Albert Astals Cid
Approved revision: 1033
Merged at revision: 1035
Proposed branch: lp:~stolowski/unity-2d/dash-hud-esc-handling-fix
Merge into: lp:unity-2d
Diff against target: 143 lines (+111/-0)
3 files modified
shell/common/SearchEntry.qml (+6/-0)
tests/dash/dash-tests.rb (+53/-0)
tests/hud/hud_show_hide_tests.rb (+52/-0)
To merge this branch: bzr merge lp:~stolowski/unity-2d/dash-hud-esc-handling-fix
Reviewer Review Type Date Requested Status
Albert Astals Cid (community) Approve
Review via email: mp+100569@code.launchpad.net

Commit message

[dash][hud] Hitting Escape clears search query first. Hitting Escape with empty search query closes Dash/Hud. This makes Esc behavior consistent with Unity.

Description of the change

[dash][hud] Hitting Escape clears search query first. Hitting Escape with empty search query closes Dash/Hud. This makes Esc behavior consistent with Unity.
  - Modified SearchEntry keyboard handling to clear input text on Escape and accept key event.
  - Modified Dash and Hud keyboard handling to close the view only if search query is empty.

To post a comment you must log in.
Revision history for this message
Albert Astals Cid (aacid) wrote :

Seems to me you don't need all the extra code in Shell.qml nor Hud.qml since you are already eating the event and it won't get propagated unless the text is already "", no?

review: Needs Fixing
1033. By Paweł Stołowski

The chnages to Shell and Hud qml are not needed since SearchEntry accepts Esc key event if search text was not empty. Removed.

Revision history for this message
Albert Astals Cid (aacid) wrote :

Works great :-)

review: Approve

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'shell/common/SearchEntry.qml'
2--- shell/common/SearchEntry.qml 2012-03-13 11:24:33 +0000
3+++ shell/common/SearchEntry.qml 2012-04-03 10:19:19 +0000
4@@ -114,6 +114,12 @@
5 activateFirstResult()
6 event.accepted = true;
7 }
8+ if (event.key == Qt.Key_Escape) {
9+ if (searchInput.text != "") {
10+ searchInput.text = ""
11+ event.accepted = true;
12+ }
13+ }
14 }
15
16 Component {
17
18=== modified file 'tests/dash/dash-tests.rb'
19--- tests/dash/dash-tests.rb 2012-03-20 18:01:52 +0000
20+++ tests/dash/dash-tests.rb 2012-04-03 10:19:19 +0000
21@@ -381,6 +381,59 @@
22 end
23
24 # Test case objectives:
25+ # * Check that Esc clears dash search entry first, tapping Esc for the 2nd time closes dash
26+ # Pre-conditions
27+ # * Desktop with no running applications
28+ # Test steps
29+ # * Verify dash is not showing
30+ # * Press Super
31+ # * Verify dash is showing
32+ # * Type search query
33+ # * Verify dash search entry is populated
34+ # * Press Esc
35+ # * Verify dash search entry is cleared
36+ # * Verify dash is still showing
37+ # * Press Esc
38+ # * Verify dash is not showing
39+ # Post-conditions
40+ # * None
41+ # References
42+ # * https://bugs.launchpad.net/unity-2d/+bug/966121
43+ test "Esc clears dash search query first, then closes dash" do
44+ verify_equal("false", TIMEOUT, 'There should not be a Dash declarative view on startup') {
45+ @app.Dash()['active']
46+ }
47+
48+ XDo::Keyboard.super
49+ verify_equal("true", TIMEOUT, 'There should be a Dash declarative view after pressing Super') {
50+ @app.Dash()['active']
51+ }
52+
53+ # type search string
54+ XDo::Keyboard.a
55+ XDo::Keyboard.b
56+ XDo::Keyboard.c
57+
58+ verify_equal('abc', TIMEOUT, 'Search query should be populated') {
59+ @app.Dash().QDeclarativeItem.SearchEntry()['searchQuery']
60+ }
61+
62+ XDo::Keyboard.escape
63+ verify_equal("true", TIMEOUT, 'Dash should still be visible') {
64+ @app.Dash()['active']
65+ }
66+
67+ verify_equal('', TIMEOUT, 'Search query should be empty') {
68+ @app.Dash().QDeclarativeItem.SearchEntry()['searchQuery']
69+ }
70+
71+ XDo::Keyboard.escape
72+ verify_equal("false", TIMEOUT, 'There should not be a Dash declarative') {
73+ @app.Dash()['active']
74+ }
75+ end
76+
77+ # Test case objectives:
78 # * Check navigation to and in lens bar
79 # Pre-conditions
80 # Test steps
81
82=== modified file 'tests/hud/hud_show_hide_tests.rb'
83--- tests/hud/hud_show_hide_tests.rb 2012-04-01 09:26:54 +0000
84+++ tests/hud/hud_show_hide_tests.rb 2012-04-03 10:19:19 +0000
85@@ -128,6 +128,58 @@
86 end
87
88 # Test case objectives:
89+ # * Check Escape key clears search query first, then closes HUD
90+ # Pre-conditions
91+ # * None
92+ # Test steps
93+ # * Check HUD closed
94+ # * Tap the Alt key
95+ # * Check HUD open
96+ # * Type search string
97+ # * Verify that search string appears in the HUD
98+ # * Tap Escape key
99+ # * Verify that search string was cleared
100+ # * Tap Escape key
101+ # * Check that HUD was closed
102+ # Post-conditions
103+ # * None
104+ # References
105+ # * https://bugs.launchpad.net/unity-2d/+bug/966121
106+ test "Esc clears HUD search query, then hides HUD" do
107+ verify_not(1, 'HUD should be hidden at startup') {
108+ @app.Hud()
109+ }
110+
111+ XDo::Keyboard.alt
112+ verify_equal('true', TIMEOUT, 'HUD should be visible, as the Alt key was tapped') {
113+ @app.Hud()['active']
114+ }
115+
116+ # type search string
117+ XDo::Keyboard.a
118+ XDo::Keyboard.b
119+ XDo::Keyboard.c
120+
121+ verify_equal('abc', TIMEOUT, 'HUD search text should be "abc"') {
122+ @app.Hud().SearchEntry()['searchQuery']
123+ }
124+
125+ XDo::Keyboard.escape
126+ verify_equal('true', TIMEOUT, 'HUD should still be visible') {
127+ @app.Hud()['active']
128+ }
129+
130+ verify_equal('', TIMEOUT, 'HUD search text should be empty') {
131+ @app.Hud().SearchEntry()['searchQuery']
132+ }
133+
134+ XDo::Keyboard.escape
135+ verify_not(1, 'HUD should be hidden, as the Escape key should dismiss it') {
136+ @app.Hud()
137+ }
138+ end
139+
140+ # Test case objectives:
141 # * Check Alt+F4 key closes HUD
142 # Pre-conditions
143 # * None

Subscribers

People subscribed via source and target branches