Merge lp:~3v1n0/unity/super-tab-arrows into lp:unity
- super-tab-arrows
- Merge into trunk
Proposed by
Marco Trevisan (Treviño)
Status: | Merged |
---|---|
Approved by: | Marco Trevisan (Treviño) |
Approved revision: | no longer in the source branch. |
Merged at revision: | 2106 |
Proposed branch: | lp:~3v1n0/unity/super-tab-arrows |
Merge into: | lp:unity |
Prerequisite: | lp:~3v1n0/unity/shortcut-hint-escaping |
Diff against target: |
593 lines (+209/-97) 4 files modified
plugins/unityshell/src/unityshell.cpp (+45/-2) tests/autopilot/autopilot/emulators/unity/launcher.py (+64/-24) tests/autopilot/autopilot/keybindings.py (+5/-2) tests/autopilot/autopilot/tests/test_launcher.py (+95/-69) |
To merge this branch: | bzr merge lp:~3v1n0/unity/super-tab-arrows |
Related bugs: |
Reviewer | Review Type | Date Requested | Status |
---|---|---|---|
Andrea Azzarone (community) | Approve | ||
Thomi Richards (community) | Approve | ||
Review via email: mp+96856@code.launchpad.net |
Commit message
Description of the change
Added support for Up/Down arrow keys to change the selected launcher icon when using the Super+Tab
This fixes the bug #950404
On the test sides, I've used autopilot to test this particular fix, also I've made some changes to the launcher emulator, to make it handle in a better way the Launcher key navigation and the Launcher Switcher as two different kinds of key navigation. This should avoid any confusion and cleans the code.
To post a comment you must log in.
Revision history for this message
Thomi Richards (thomir-deactivatedaccount) wrote : | # |
review:
Approve
Preview Diff
[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1 | === modified file 'plugins/unityshell/src/unityshell.cpp' |
2 | --- plugins/unityshell/src/unityshell.cpp 2012-03-10 00:19:22 +0000 |
3 | +++ plugins/unityshell/src/unityshell.cpp 2012-03-10 00:19:22 +0000 |
4 | @@ -876,7 +876,8 @@ |
5 | { |
6 | /* Create a new keybinding for the Escape key and the current modifiers, |
7 | * compiz will take of the ref-counting of the repeated actions */ |
8 | - CompAction::KeyBinding binding(9, modifiers); |
9 | + KeyCode escape = XKeysymToKeycode(screen->dpy(), XStringToKeysym("Escape")); |
10 | + CompAction::KeyBinding binding(escape, modifiers); |
11 | |
12 | CompActionPtr &escape_action = _escape_actions[target]; |
13 | escape_action = CompActionPtr(new CompAction()); |
14 | @@ -1347,12 +1348,28 @@ |
15 | KeySym key_sym; |
16 | char key_string[2]; |
17 | int result = XLookupString(&(event->xkey), key_string, 2, &key_sym, 0); |
18 | + |
19 | + if (launcher_controller_->KeyNavIsActive()) |
20 | + { |
21 | + if (key_sym == XK_Up) |
22 | + { |
23 | + launcher_controller_->KeyNavPrevious(); |
24 | + break; |
25 | + } |
26 | + else if (key_sym == XK_Down) |
27 | + { |
28 | + launcher_controller_->KeyNavNext(); |
29 | + break; |
30 | + } |
31 | + } |
32 | + |
33 | if (result > 0) |
34 | { |
35 | // NOTE: does this have the potential to do an invalid write? Perhaps |
36 | // we should just say "key_string[1] = 0" because that is the only |
37 | // thing that could possibly make sense here. |
38 | key_string[result] = 0; |
39 | + |
40 | if (super_keypressed_) |
41 | { |
42 | if (key_sym != XK_Escape || (key_sym == XK_Escape && !launcher_controller_->KeyNavIsActive())) |
43 | @@ -1764,8 +1781,22 @@ |
44 | { |
45 | if (!launcher_controller_->KeyNavIsActive()) |
46 | { |
47 | + int modifiers = action->key().modifiers(); |
48 | + |
49 | launcher_controller_->KeyNavActivate(); |
50 | - EnableCancelAction(CancelActionTarget::LAUNCHER_SWITCHER, true, action->key().modifiers()); |
51 | + |
52 | + EnableCancelAction(CancelActionTarget::LAUNCHER_SWITCHER, true, modifiers); |
53 | + |
54 | + KeyCode down_key = XKeysymToKeycode(screen->dpy(), XStringToKeysym("Down")); |
55 | + KeyCode up_key = XKeysymToKeycode(screen->dpy(), XStringToKeysym("Up")); |
56 | + |
57 | + CompAction down_action; |
58 | + down_action.setKey(CompAction::KeyBinding(down_key, modifiers)); |
59 | + screen->addAction(&down_action); |
60 | + |
61 | + CompAction up_action; |
62 | + up_action.setKey(CompAction::KeyBinding(up_key, modifiers)); |
63 | + screen->addAction(&up_action); |
64 | } |
65 | else |
66 | { |
67 | @@ -1787,6 +1818,18 @@ |
68 | launcher_controller_->KeyNavTerminate(accept_state); |
69 | |
70 | EnableCancelAction(CancelActionTarget::LAUNCHER_SWITCHER, false); |
71 | + |
72 | + KeyCode down_key = XKeysymToKeycode(screen->dpy(), XStringToKeysym("Down")); |
73 | + KeyCode up_key = XKeysymToKeycode(screen->dpy(), XStringToKeysym("Up")); |
74 | + |
75 | + CompAction down_action; |
76 | + down_action.setKey(CompAction::KeyBinding(down_key, action->key().modifiers())); |
77 | + screen->removeAction(&down_action); |
78 | + |
79 | + CompAction up_action; |
80 | + up_action.setKey(CompAction::KeyBinding(up_key, action->key().modifiers())); |
81 | + screen->removeAction(&up_action); |
82 | + |
83 | action->setState (action->state() & (unsigned)~(CompAction::StateTermKey)); |
84 | return true; |
85 | } |
86 | |
87 | === modified file 'tests/autopilot/autopilot/emulators/unity/launcher.py' |
88 | --- tests/autopilot/autopilot/emulators/unity/launcher.py 2012-03-08 03:51:28 +0000 |
89 | +++ tests/autopilot/autopilot/emulators/unity/launcher.py 2012-03-10 00:19:22 +0000 |
90 | @@ -47,6 +47,7 @@ |
91 | self.show_timeout = 1 |
92 | self.hide_timeout = 1 |
93 | self.in_keynav_mode = False |
94 | + self.in_switcher_mode = False |
95 | |
96 | self._mouse = Mouse() |
97 | self._screen = ScreenGeometry() |
98 | @@ -95,65 +96,104 @@ |
99 | self.keybinding_release("launcher/reveal") |
100 | sleep(1) |
101 | |
102 | - def grab_switcher(self): |
103 | + def key_nav_start(self): |
104 | """Start keyboard navigation mode by pressing Alt+F1.""" |
105 | self._screen.move_mouse_to_monitor(self.monitor) |
106 | logger.debug("Initiating launcher keyboard navigation with Alt+F1.") |
107 | self.keybinding("launcher/keynav") |
108 | self.in_keynav_mode = True |
109 | |
110 | - def switcher_enter_quicklist(self): |
111 | + def key_nav_end(self, cancel): |
112 | + """End the key navigation. |
113 | + |
114 | + If cancel is True, the currently selected icon will not be activated. |
115 | + |
116 | + """ |
117 | + if not self.in_keynav_mode: |
118 | + raise RuntimeError("Cannot end the key navigation when not in kaynav mode.") |
119 | + if cancel: |
120 | + logger.debug("Cancelling keyboard navigation mode.") |
121 | + self.keybinding("launcher/keynav/exit") |
122 | + else: |
123 | + logger.debug("Ending keyboard navigation mode, activating icon.") |
124 | + self.keybinding("launcher/keynav/activate") |
125 | + |
126 | + self.in_keynav_mode = False |
127 | + |
128 | + def key_nav_next(self): |
129 | + if not self.in_keynav_mode: |
130 | + raise RuntimeError("Cannot use the key navigation commands when not in kaynav mode.") |
131 | + logger.debug("Selecting next item in keyboard navigation mode.") |
132 | + self.keybinding("launcher/keynav/next") |
133 | + |
134 | + def key_nav_prev(self): |
135 | + if not self.in_keynav_mode: |
136 | + raise RuntimeError("Cannot use the key navigation commands when not in kaynav mode.") |
137 | + logger.debug("Selecting previous item in keyboard navigation mode.") |
138 | + self.keybinding("launcher/keynav/prev") |
139 | + |
140 | + def key_nav_enter_quicklist(self): |
141 | if not self.in_keynav_mode: |
142 | raise RuntimeError("Cannot open switcher quicklist while not in keynav mode.") |
143 | logger.debug("Opening quicklist for currently selected icon.") |
144 | self.keybinding("launcher/keynav/open-quicklist") |
145 | |
146 | - def switcher_exit_quicklist(self): |
147 | + def key_nav_exit_quicklist(self): |
148 | if not self.in_keynav_mode: |
149 | raise RuntimeError("Cannot close switcher quicklist while not in keynav mode.") |
150 | logger.debug("Closing quicklist for currently selected icon.") |
151 | self.keybinding("launcher/keynav/close-quicklist") |
152 | |
153 | - def start_switcher(self): |
154 | + def switcher_start(self): |
155 | """Start the super+Tab switcher on this launcher.""" |
156 | self._screen.move_mouse_to_monitor(self.monitor) |
157 | logger.debug("Starting Super+Tab switcher.") |
158 | self.keybinding_hold("launcher/switcher") |
159 | self.keybinding_tap("launcher/switcher") |
160 | - sleep(1) |
161 | + self.in_switcher_mode = True |
162 | |
163 | - def end_switcher(self, cancel): |
164 | - """End either the keynav mode or the super+tab swithcer. |
165 | + def switcher_end(self, cancel): |
166 | + """End the super+tab swithcer. |
167 | |
168 | If cancel is True, the currently selected icon will not be activated. |
169 | |
170 | """ |
171 | + if not self.in_switcher_mode: |
172 | + raise RuntimeError("Cannot end the launcher switcher when not in switcher mode.") |
173 | + |
174 | if cancel: |
175 | logger.debug("Cancelling keyboard navigation mode.") |
176 | - self.keybinding("launcher/keynav/exit") |
177 | - if not self.in_keynav_mode: |
178 | - self.keybinding_release("launcher/switcher") |
179 | + self.keybinding("launcher/switcher/exit") |
180 | + self.keybinding_release("launcher/switcher") |
181 | else: |
182 | logger.debug("Ending keyboard navigation mode.") |
183 | - if self.in_keynav_mode: |
184 | - self.keybinding("launcher/keynav/activate") |
185 | - else: |
186 | - self.keybinding_release("launcher/switcher") |
187 | - self.in_keynav_mode = False |
188 | + self.keybinding_release("launcher/switcher") |
189 | + |
190 | + self.in_switcher_mode = False |
191 | |
192 | def switcher_next(self): |
193 | + if not self.in_switcher_mode: |
194 | + raise RuntimeError("Cannot use the launcher switcher commands when not in switcher mode.") |
195 | logger.debug("Selecting next item in keyboard navigation mode.") |
196 | - if self.in_keynav_mode: |
197 | - self.keybinding("launcher/keynav/next") |
198 | - else: |
199 | - self.keybinding("launcher/switcher/next") |
200 | + self.keybinding("launcher/switcher/next") |
201 | |
202 | def switcher_prev(self): |
203 | - logger.debug("Selecting previous item in keyboard navigation mode.") |
204 | - if self.in_keynav_mode: |
205 | - self.keybinding("launcher/keynav/prev") |
206 | - else: |
207 | - self.keybinding("launcher/switcher/prev") |
208 | + if not self.in_switcher_mode: |
209 | + raise RuntimeError("Cannot use the launcher switcher commands when not in switcher mode.") |
210 | + logger.debug("Selecting previous item in keyboard navigation mode.") |
211 | + self.keybinding("launcher/switcher/prev") |
212 | + |
213 | + def switcher_up(self): |
214 | + if not self.in_switcher_mode: |
215 | + raise RuntimeError("Cannot use the launcher switcher commands when not in switcher mode.") |
216 | + logger.debug("Selecting next item in keyboard navigation mode.") |
217 | + self.keybinding("launcher/switcher/up") |
218 | + |
219 | + def switcher_down(self): |
220 | + if not self.in_switcher_mode: |
221 | + raise RuntimeError("Cannot use the launcher switcher commands when not in switcher mode.") |
222 | + logger.debug("Selecting previous item in keyboard navigation mode.") |
223 | + self.keybinding("launcher/switcher/down") |
224 | |
225 | def click_launcher_icon(self, icon, button=1): |
226 | """Move the mouse over the launcher icon, and click it. |
227 | |
228 | === modified file 'tests/autopilot/autopilot/keybindings.py' |
229 | --- tests/autopilot/autopilot/keybindings.py 2012-03-10 00:19:22 +0000 |
230 | +++ tests/autopilot/autopilot/keybindings.py 2012-03-10 00:19:22 +0000 |
231 | @@ -48,11 +48,14 @@ |
232 | "launcher/keynav/prev": "Up", |
233 | "launcher/keynav/activate": "Enter", |
234 | "launcher/keynav/exit": "Escape", |
235 | + "launcher/keynav/open-quicklist": "Right", |
236 | + "launcher/keynav/close-quicklist": "Left", |
237 | "launcher/switcher": ('unityshell', 'launcher_switcher_forward'), |
238 | + "launcher/switcher/exit": "Escape", |
239 | "launcher/switcher/next": "Tab", |
240 | "launcher/switcher/prev": "Shift+Tab", |
241 | - "launcher/keynav/open-quicklist": "Right", |
242 | - "launcher/keynav/close-quicklist": "Left", |
243 | + "launcher/switcher/down": "Down", |
244 | + "launcher/switcher/up": "Up", |
245 | # Dash: |
246 | "dash/reveal": "Super", |
247 | # Lenses |
248 | |
249 | === modified file 'tests/autopilot/autopilot/tests/test_launcher.py' |
250 | --- tests/autopilot/autopilot/tests/test_launcher.py 2012-03-10 00:19:22 +0000 |
251 | +++ tests/autopilot/autopilot/tests/test_launcher.py 2012-03-10 00:19:22 +0000 |
252 | @@ -8,7 +8,7 @@ |
253 | # by the Free Software Foundation. |
254 | |
255 | import logging |
256 | -from testtools.matchers import Equals, LessThan, GreaterThan |
257 | +from testtools.matchers import Equals, NotEquals, LessThan, GreaterThan |
258 | from time import sleep |
259 | |
260 | from autopilot.tests import AutopilotTestCase |
261 | @@ -51,8 +51,8 @@ |
262 | """Test that starting the Launcher switcher puts the keyboard focus on item 0.""" |
263 | sleep(.5) |
264 | launcher_instance = self.get_launcher() |
265 | - launcher_instance.start_switcher() |
266 | - self.addCleanup(launcher_instance.end_switcher, True) |
267 | + launcher_instance.switcher_start() |
268 | + self.addCleanup(launcher_instance.switcher_end, True) |
269 | sleep(.5) |
270 | |
271 | self.assertThat(self.launcher.key_nav_is_active, Equals(True)) |
272 | @@ -63,9 +63,9 @@ |
273 | """Test that ending the launcher switcher actually works.""" |
274 | sleep(.5) |
275 | launcher_instance = self.get_launcher() |
276 | - launcher_instance.start_switcher() |
277 | + launcher_instance.switcher_start() |
278 | sleep(.5) |
279 | - launcher_instance.end_switcher(cancel=True) |
280 | + launcher_instance.switcher_end(cancel=True) |
281 | sleep(.5) |
282 | self.assertThat(self.launcher.key_nav_is_active, Equals(False)) |
283 | |
284 | @@ -73,21 +73,21 @@ |
285 | """Test that ending the launcher switcher actually works.""" |
286 | sleep(.5) |
287 | launcher_instance = self.get_launcher() |
288 | - launcher_instance.start_switcher() |
289 | - self.addCleanup(launcher_instance.end_switcher, True) |
290 | + launcher_instance.switcher_start() |
291 | + self.addCleanup(launcher_instance.switcher_end, True) |
292 | sleep(.25) |
293 | - self.assertThat(self.launcher.key_nav_is_active(), Equals(True)) |
294 | + self.assertThat(self.launcher.key_nav_is_active, Equals(True)) |
295 | sleep(.25) |
296 | self.keyboard.press_and_release("Escape") |
297 | sleep(.25) |
298 | - self.assertThat(self.launcher.key_nav_is_active(), Equals(False)) |
299 | + self.assertThat(self.launcher.key_nav_is_active, Equals(False)) |
300 | |
301 | def test_launcher_switcher_next_works(self): |
302 | """Moving to the next launcher item while switcher is activated must work.""" |
303 | sleep(.5) |
304 | launcher_instance = self.get_launcher() |
305 | - launcher_instance.start_switcher() |
306 | - self.addCleanup(launcher_instance.end_switcher, True) |
307 | + launcher_instance.switcher_start() |
308 | + self.addCleanup(launcher_instance.switcher_end, True) |
309 | sleep(.5) |
310 | |
311 | launcher_instance.switcher_next() |
312 | @@ -98,21 +98,47 @@ |
313 | """Moving to the previous launcher item while switcher is activated must work.""" |
314 | sleep(.5) |
315 | launcher_instance = self.get_launcher() |
316 | - launcher_instance.start_switcher() |
317 | - self.addCleanup(launcher_instance.end_switcher, True) |
318 | - sleep(.5) |
319 | + launcher_instance.switcher_start() |
320 | + self.addCleanup(launcher_instance.switcher_end, True) |
321 | + sleep(.25) |
322 | + self.assertThat(self.launcher.key_nav_selection, Equals(0)) |
323 | |
324 | - launcher_instance.switcher_next() |
325 | - sleep(.5) |
326 | launcher_instance.switcher_prev() |
327 | - self.assertThat(self.launcher.key_nav_selection, Equals(0)) |
328 | + sleep(.25) |
329 | + self.assertThat(self.launcher.key_nav_selection, NotEquals(0)) |
330 | + |
331 | + def test_launcher_switcher_down_works(self): |
332 | + """Pressing the down arrow key while switcher is activated must work.""" |
333 | + sleep(.5) |
334 | + launcher_instance = self.get_launcher() |
335 | + launcher_instance.switcher_start() |
336 | + self.addCleanup(launcher_instance.switcher_end, True) |
337 | + sleep(.25) |
338 | + self.assertThat(self.launcher.key_nav_selection, Equals(0)) |
339 | + |
340 | + launcher_instance.switcher_down() |
341 | + sleep(.25) |
342 | + self.assertThat(self.launcher.key_nav_selection, Equals(1)) |
343 | + |
344 | + def test_launcher_switcher_up_works(self): |
345 | + """Pressing the up arrow key while switcher is activated must work.""" |
346 | + sleep(.5) |
347 | + launcher_instance = self.get_launcher() |
348 | + launcher_instance.switcher_start() |
349 | + self.addCleanup(launcher_instance.switcher_end, True) |
350 | + sleep(.25) |
351 | + self.assertThat(self.launcher.key_nav_selection, Equals(0)) |
352 | + |
353 | + launcher_instance.switcher_up() |
354 | + sleep(.25) |
355 | + self.assertThat(self.launcher.key_nav_selection, NotEquals(0)) |
356 | |
357 | def test_launcher_switcher_next_doesnt_show_shortcuts(self): |
358 | """Moving forward in launcher switcher must not show launcher shortcuts.""" |
359 | sleep(.5) |
360 | launcher_instance = self.get_launcher() |
361 | - launcher_instance.start_switcher() |
362 | - self.addCleanup(launcher_instance.end_switcher, True) |
363 | + launcher_instance.switcher_start() |
364 | + self.addCleanup(launcher_instance.switcher_end, True) |
365 | sleep(.5) |
366 | launcher_instance.switcher_next() |
367 | sleep(2) |
368 | @@ -122,8 +148,8 @@ |
369 | """Moving backward in launcher switcher must not show launcher shortcuts.""" |
370 | sleep(.5) |
371 | launcher_instance = self.get_launcher() |
372 | - launcher_instance.start_switcher() |
373 | - self.addCleanup(launcher_instance.end_switcher, True) |
374 | + launcher_instance.switcher_start() |
375 | + self.addCleanup(launcher_instance.switcher_end, True) |
376 | sleep(.5) |
377 | launcher_instance.switcher_next() |
378 | sleep(2) |
379 | @@ -136,8 +162,8 @@ |
380 | """Launcher Switcher must loop through icons when cycling forwards""" |
381 | sleep(.5) |
382 | launcher_instance = self.get_launcher() |
383 | - launcher_instance.start_switcher() |
384 | - self.addCleanup(launcher_instance.end_switcher, True) |
385 | + launcher_instance.switcher_start() |
386 | + self.addCleanup(launcher_instance.switcher_end, True) |
387 | sleep(.5) |
388 | |
389 | prev_icon = 0 |
390 | @@ -160,8 +186,8 @@ |
391 | """Launcher Switcher must loop through icons when cycling backwards""" |
392 | sleep(.5) |
393 | launcher_instance = self.get_launcher() |
394 | - launcher_instance.start_switcher() |
395 | - self.addCleanup(launcher_instance.end_switcher, True) |
396 | + launcher_instance.switcher_start() |
397 | + self.addCleanup(launcher_instance.switcher_end, True) |
398 | sleep(.5) |
399 | |
400 | launcher_instance.switcher_prev() |
401 | @@ -195,8 +221,8 @@ |
402 | self.addCleanup(launcher_instance.keyboard_unreveal_launcher) |
403 | sleep(1) |
404 | |
405 | - launcher_instance.start_switcher() |
406 | - self.addCleanup(launcher_instance.end_switcher, True) |
407 | + launcher_instance.switcher_start() |
408 | + self.addCleanup(launcher_instance.switcher_end, True) |
409 | sleep(.5) |
410 | |
411 | self.assertThat(self.launcher.key_nav_is_active, Equals(True)) |
412 | @@ -211,8 +237,8 @@ |
413 | self.addCleanup(launcher_instance.keyboard_unreveal_launcher) |
414 | sleep(1) |
415 | |
416 | - launcher_instance.start_switcher() |
417 | - self.addCleanup(launcher_instance.end_switcher, True) |
418 | + launcher_instance.switcher_start() |
419 | + self.addCleanup(launcher_instance.switcher_end, True) |
420 | sleep(.5) |
421 | |
422 | launcher_instance.switcher_next() |
423 | @@ -223,7 +249,7 @@ |
424 | sleep(.5) |
425 | self.assertThat(launcher_instance.are_shortcuts_showing(), Equals(True)) |
426 | |
427 | - def test_launcher_switcher_ungrabbed_using_shorcuts(self): |
428 | + def test_launcher_switcher_using_shorcuts(self): |
429 | """Using some other shortcut while switcher is active must cancel switcher.""" |
430 | sleep(.5) |
431 | |
432 | @@ -232,8 +258,8 @@ |
433 | launcher_instance.keyboard_reveal_launcher() |
434 | self.addCleanup(launcher_instance.keyboard_unreveal_launcher) |
435 | sleep(1) |
436 | - launcher_instance.start_switcher() |
437 | - self.addCleanup(launcher_instance.end_switcher, True) |
438 | + launcher_instance.switcher_start() |
439 | + self.addCleanup(launcher_instance.switcher_end, True) |
440 | sleep(.5) |
441 | |
442 | self.keyboard.press_and_release("s") |
443 | @@ -247,8 +273,8 @@ |
444 | """Tests we can initiate keyboard navigation on the launcher.""" |
445 | launcher_instance = self.get_launcher() |
446 | sleep(.5) |
447 | - launcher_instance.grab_switcher() |
448 | - self.addCleanup(launcher_instance.end_switcher, True) |
449 | + launcher_instance.key_nav_start() |
450 | + self.addCleanup(launcher_instance.key_nav_end, True) |
451 | sleep(.5) |
452 | |
453 | self.assertThat(self.launcher.key_nav_is_active, Equals(True)) |
454 | @@ -258,9 +284,9 @@ |
455 | """Test that we can exit keynav mode.""" |
456 | launcher_instance = self.get_launcher() |
457 | sleep(.5) |
458 | - launcher_instance.grab_switcher() |
459 | + launcher_instance.key_nav_start() |
460 | sleep(.5) |
461 | - launcher_instance.end_switcher(cancel=True) |
462 | + launcher_instance.key_nav_end(cancel=True) |
463 | self.assertThat(self.launcher.key_nav_is_active, Equals(False)) |
464 | self.assertThat(self.launcher.key_nav_is_grabbed, Equals(False)) |
465 | |
466 | @@ -268,8 +294,8 @@ |
467 | """Test keynav mode starts at index 0.""" |
468 | launcher_instance = self.get_launcher() |
469 | sleep(.5) |
470 | - launcher_instance.grab_switcher() |
471 | - self.addCleanup(launcher_instance.end_switcher, True) |
472 | + launcher_instance.key_nav_start() |
473 | + self.addCleanup(launcher_instance.key_nav_end, True) |
474 | sleep(.5) |
475 | |
476 | self.assertThat(self.launcher.key_nav_selection, Equals(0)) |
477 | @@ -278,10 +304,10 @@ |
478 | """Must be able to move forwards while in keynav mode.""" |
479 | launcher_instance = self.get_launcher() |
480 | sleep(.5) |
481 | - launcher_instance.grab_switcher() |
482 | - self.addCleanup(launcher_instance.end_switcher, True) |
483 | + launcher_instance.key_nav_start() |
484 | + self.addCleanup(launcher_instance.key_nav_end, True) |
485 | sleep(.5) |
486 | - launcher_instance.switcher_next() |
487 | + launcher_instance.key_nav_next() |
488 | sleep(.5) |
489 | self.assertThat(self.launcher.key_nav_selection, Equals(1)) |
490 | |
491 | @@ -289,12 +315,12 @@ |
492 | """Must be able to move backwards while in keynav mode.""" |
493 | launcher_instance = self.get_launcher() |
494 | sleep(.5) |
495 | - launcher_instance.grab_switcher() |
496 | - self.addCleanup(launcher_instance.end_switcher, True) |
497 | - sleep(.5) |
498 | - launcher_instance.switcher_next() |
499 | - sleep(.5) |
500 | - launcher_instance.switcher_prev() |
501 | + launcher_instance.key_nav_start() |
502 | + self.addCleanup(launcher_instance.key_nav_end, True) |
503 | + sleep(.5) |
504 | + launcher_instance.key_nav_next() |
505 | + sleep(.5) |
506 | + launcher_instance.key_nav_prev() |
507 | sleep(.5) |
508 | self.assertThat(self.launcher.key_nav_selection, Equals(0)) |
509 | |
510 | @@ -302,13 +328,13 @@ |
511 | """Launcher keynav must loop through icons when cycling forwards""" |
512 | launcher_instance = self.get_launcher() |
513 | sleep(.5) |
514 | - launcher_instance.grab_switcher() |
515 | - self.addCleanup(launcher_instance.end_switcher, True) |
516 | + launcher_instance.key_nav_start() |
517 | + self.addCleanup(launcher_instance.key_nav_end, True) |
518 | sleep(.25) |
519 | |
520 | prev_icon = 0 |
521 | for icon in range(1, self.launcher.model.num_launcher_icons()): |
522 | - launcher_instance.switcher_next() |
523 | + launcher_instance.key_nav_next() |
524 | sleep(.25) |
525 | # FIXME We can't directly check for selection/icon number equalty |
526 | # since the launcher model also contains "hidden" icons that aren't |
527 | @@ -317,18 +343,18 @@ |
528 | prev_icon = self.launcher.key_nav_selection |
529 | |
530 | sleep(.5) |
531 | - launcher_instance.switcher_next() |
532 | + launcher_instance.key_nav_next() |
533 | self.assertThat(self.launcher.key_nav_selection, Equals(0)) |
534 | |
535 | def test_launcher_keynav_cycling_backward(self): |
536 | """Launcher keynav must loop through icons when cycling backwards""" |
537 | launcher_instance = self.get_launcher() |
538 | sleep(.5) |
539 | - launcher_instance.grab_switcher() |
540 | - self.addCleanup(launcher_instance.end_switcher, True) |
541 | + launcher_instance.key_nav_start() |
542 | + self.addCleanup(launcher_instance.key_nav_end, True) |
543 | sleep(.25) |
544 | |
545 | - launcher_instance.switcher_prev() |
546 | + launcher_instance.key_nav_prev() |
547 | # FIXME We can't directly check for self.launcher.num_launcher_icons - 1 |
548 | self.assertThat(self.launcher.key_nav_selection, GreaterThan(1)) |
549 | |
550 | @@ -337,13 +363,13 @@ |
551 | launcher_instance = self.get_launcher() |
552 | launcher_instance.move_mouse_to_right_of_launcher() |
553 | sleep(.5) |
554 | - launcher_instance.grab_switcher() |
555 | - self.addCleanup(launcher_instance.end_switcher, True) |
556 | - sleep(.5) |
557 | - launcher_instance.switcher_next() |
558 | - sleep(.5) |
559 | - launcher_instance.switcher_enter_quicklist() |
560 | - self.addCleanup(launcher_instance.switcher_exit_quicklist) |
561 | + launcher_instance.key_nav_start() |
562 | + self.addCleanup(launcher_instance.key_nav_end, True) |
563 | + sleep(.5) |
564 | + launcher_instance.key_nav_next() |
565 | + sleep(.5) |
566 | + launcher_instance.key_nav_enter_quicklist() |
567 | + self.addCleanup(launcher_instance.key_nav_exit_quicklist) |
568 | sleep(.5) |
569 | self.assertThat(launcher_instance.is_quicklist_open(), Equals(True)) |
570 | |
571 | @@ -352,14 +378,14 @@ |
572 | launcher_instance = self.get_launcher() |
573 | launcher_instance.move_mouse_to_right_of_launcher() |
574 | sleep(.5) |
575 | - launcher_instance.grab_switcher() |
576 | - self.addCleanup(launcher_instance.end_switcher, True) |
577 | - sleep(.5) |
578 | - launcher_instance.switcher_next() |
579 | - sleep(.5) |
580 | - launcher_instance.switcher_enter_quicklist() |
581 | - sleep(.5) |
582 | - launcher_instance.switcher_exit_quicklist() |
583 | + launcher_instance.key_nav_start() |
584 | + self.addCleanup(launcher_instance.key_nav_end, True) |
585 | + sleep(.5) |
586 | + launcher_instance.key_nav_next() |
587 | + sleep(.5) |
588 | + launcher_instance.key_nav_enter_quicklist() |
589 | + sleep(.5) |
590 | + launcher_instance.key_nav_exit_quicklist() |
591 | |
592 | self.assertThat(launcher_instance.is_quicklist_open(), Equals(False)) |
593 | self.assertThat(self.launcher.key_nav_is_active, Equals(True)) |
Nice - I've been meaning to do something like this for aaaages. Cheers,