Merge lp:~unity-team/unity/unity.hud-signal-956878 into lp:unity

Proposed by Jay Taoko
Status: Merged
Approved by: Jay Taoko
Approved revision: no longer in the source branch.
Merged at revision: 2136
Proposed branch: lp:~unity-team/unity/unity.hud-signal-956878
Merge into: lp:unity
Diff against target: 167 lines (+62/-8)
6 files modified
manual-tests/Hud.txt (+12/-0)
plugins/unityshell/src/HudView.cpp (+6/-2)
plugins/unityshell/src/HudView.h (+1/-0)
tests/autopilot/autopilot/emulators/bamf.py (+8/-2)
tests/autopilot/autopilot/tests/__init__.py (+6/-3)
tests/autopilot/autopilot/tests/test_hud.py (+29/-1)
To merge this branch: bzr merge lp:~unity-team/unity/unity.hud-signal-956878
Reviewer Review Type Date Requested Status
Gord Allott (community) Approve
Alex Launi (community) Needs Fixing
Review via email: mp+98215@code.launchpad.net

Commit message

* Fix for bug #956878:
The hud is designed such that the first valid option is always selected. When the activated signal is detected early in hud::View::FindKeyFocusArea, the selected button signal is emitted, and the text entry is still selected as the focus area. Therefore, the hud should not reacted to the search_bar_->activated signal since it alreacdy acted in hud::View::FindKeyFocusArea.

Description of the change

* Fix for bug #956878:
The hud is designed such that the first valid option is always selected. When the activated signal is detected early in hud::View::FindKeyFocusArea, the selected button signal is emitted, and the text entry is still selected as the focus area. Therefore, the hud should not reacted to the search_bar_->activated signal since it alreacdy acted in hud::View::FindKeyFocusArea.

To post a comment you must log in.
Revision history for this message
Alex Launi (alexlauni) wrote :

As discussed on IRC, please write an autopilot test for this.

review: Needs Fixing
Revision history for this message
Gord Allott (gordallott) wrote :

+1

review: Approve
Revision history for this message
Unity Merger (unity-merger) wrote :

No commit message specified.

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'manual-tests/Hud.txt'
2--- manual-tests/Hud.txt 2012-02-12 18:23:18 +0000
3+++ manual-tests/Hud.txt 2012-03-20 14:03:20 +0000
4@@ -56,3 +56,15 @@
5 After pressing escape in step three, the text "test" should be removed from the hud search
6 After step four, the hud should dismiss itself and not be present.
7
8+Hud Sending Undo
9+----------------
10+This test ensure that the undo action is properly handle in a text editor.
11+
12+#. Open GEdit and start a new document
13+#. Type "0 1"
14+#. Tap Alt
15+#. Type "undo"
16+#. Press and release the Enter Key
17+
18+Outcome
19+ After pressing the Enter key the text in GEdit should be "0 "
20
21=== modified file 'plugins/unityshell/src/HudView.cpp'
22--- plugins/unityshell/src/HudView.cpp 2012-03-16 16:43:15 +0000
23+++ plugins/unityshell/src/HudView.cpp 2012-03-20 14:03:20 +0000
24@@ -64,6 +64,7 @@
25 , current_height_(0)
26 , timeline_need_more_draw_(false)
27 , selected_button_(0)
28+ , activated_signal_sent_(false)
29 {
30 renderer_.SetOwner(this);
31 renderer_.need_redraw.connect([this] () {
32@@ -80,7 +81,8 @@
33
34 search_bar_->activated.connect ([&]()
35 {
36- search_activated.emit(search_bar_->search_string);
37+ if (!activated_signal_sent_)
38+ search_activated.emit(search_bar_->search_string);
39 });
40
41 search_bar_->text_entry()->SetLoseKeyFocusOnKeyNavDirectionUp(false);
42@@ -608,8 +610,9 @@
43 return search_bar_->text_entry();
44 }
45
46- if (direction == nux::KEY_NAV_ENTER)
47+ if (event_type == nux::NUX_KEYDOWN && direction == nux::KEY_NAV_ENTER)
48 {
49+ activated_signal_sent_ = false;
50 // The "Enter" key has been received and the text entry has the key focus.
51 // If one of the button has the fake_focus, we get it to emit the query_activated signal.
52 if (!buttons_.empty())
53@@ -620,6 +623,7 @@
54 if ((*it)->fake_focused)
55 {
56 query_activated.emit((*it)->GetQuery());
57+ activated_signal_sent_ = true;
58 }
59 }
60 }
61
62=== modified file 'plugins/unityshell/src/HudView.h'
63--- plugins/unityshell/src/HudView.h 2012-03-02 02:00:18 +0000
64+++ plugins/unityshell/src/HudView.h 2012-03-20 14:03:20 +0000
65@@ -118,6 +118,7 @@
66 int current_height_;
67 bool timeline_need_more_draw_;
68 int selected_button_;
69+ bool activated_signal_sent_;
70 };
71
72
73
74=== modified file 'tests/autopilot/autopilot/emulators/bamf.py'
75--- tests/autopilot/autopilot/emulators/bamf.py 2012-03-12 05:09:01 +0000
76+++ tests/autopilot/autopilot/emulators/bamf.py 2012-03-20 14:03:20 +0000
77@@ -131,15 +131,21 @@
78
79 return found_app[0]
80
81- def launch_application(self, desktop_file, wait=True):
82+ def launch_application(self, desktop_file, files=[], wait=True):
83 """Launch an application by specifying a desktop file.
84
85+ `files` is a list of files to pass to the application. Not all apps support this.
86+
87+ If `wait` is True, this method will block until the application has launched.
88+
89 Returns the Gobject process object. if wait is True (the default),
90 this method will not return until an instance of this application
91 appears in the BAMF application list.
92 """
93+ if type(files) is not list:
94+ raise TypeError("files must be a list.")
95 proc = gio.unix.DesktopAppInfo(desktop_file)
96- proc.launch()
97+ proc.launch_uris(files)
98 if wait:
99 self.wait_until_application_is_running(desktop_file, -1)
100 return proc
101
102=== modified file 'tests/autopilot/autopilot/tests/__init__.py'
103--- tests/autopilot/autopilot/tests/__init__.py 2012-03-14 20:16:38 +0000
104+++ tests/autopilot/autopilot/tests/__init__.py 2012-03-20 14:03:20 +0000
105@@ -209,11 +209,14 @@
106 self.addCleanup(Keyboard.cleanup)
107 self.addCleanup(Mouse.cleanup)
108
109- def start_app(self, app_name):
110- """Start one of the known apps, and kill it on tear down."""
111+ def start_app(self, app_name, files=[]):
112+ """Start one of the known apps, and kill it on tear down.
113+
114+ if files is specified, start the application with the specified files.
115+ """
116 logger.info("Starting application '%s'", app_name)
117 app = self.KNOWN_APPS[app_name]
118- self.bamf.launch_application(app['desktop-file'])
119+ self.bamf.launch_application(app['desktop-file'], files)
120 self.addCleanup(call, ["killall", app['process-name']])
121
122 def close_all_app(self, app_name):
123
124=== modified file 'tests/autopilot/autopilot/tests/test_hud.py'
125--- tests/autopilot/autopilot/tests/test_hud.py 2012-03-19 02:29:19 +0000
126+++ tests/autopilot/autopilot/tests/test_hud.py 2012-03-20 14:03:20 +0000
127@@ -11,7 +11,7 @@
128
129 from autopilot.emulators.unity.hud import HudController
130 from autopilot.tests import AutopilotTestCase
131-
132+from os import remove
133
134 class HudTests(AutopilotTestCase):
135
136@@ -172,3 +172,31 @@
137
138 self.assertEqual(calc.is_active, True)
139
140+ def test_gedit_undo(self):
141+ """Test undo in gedit"""
142+ """Type "0 1" into gedit."""
143+ """Activate the Hud, type "undo" then enter."""
144+ """Save the file in gedit and close gedit."""
145+ """Read the saved file. The content should be "0 "."""
146+
147+ self.addCleanup(remove, '/tmp/autopilot_gedit_undo_test_temp_file.txt')
148+ self.start_app('Text Editor', files=['/tmp/autopilot_gedit_undo_test_temp_file.txt'])
149+
150+ sleep(1)
151+ self.keyboard.type("0")
152+ self.keyboard.type(" ")
153+ self.keyboard.type("1")
154+
155+ self.hud.toggle_reveal()
156+ sleep(1)
157+
158+ self.keyboard.type("undo")
159+ self.keyboard.press_and_release('Return')
160+ sleep(1)
161+
162+ self.keyboard.press_and_release("Ctrl+s")
163+ sleep(1)
164+
165+ contents = open("/tmp/autopilot_gedit_undo_test_temp_file.txt").read().strip('\n')
166+ self.assertEqual("0 ", contents)
167+