Merge lp:~3v1n0/unity/hud-invalid-icon-fix into lp:unity

Proposed by Marco Trevisan (Treviño)
Status: Merged
Approved by: Thomi Richards
Approved revision: no longer in the source branch.
Merged at revision: 2212
Proposed branch: lp:~3v1n0/unity/hud-invalid-icon-fix
Merge into: lp:unity
Diff against target: 510 lines (+161/-79)
10 files modified
plugins/unityshell/src/HudController.cpp (+45/-5)
plugins/unityshell/src/HudIcon.cpp (+5/-6)
plugins/unityshell/src/HudLauncherIcon.cpp (+7/-4)
tests/autopilot/autopilot/emulators/unity/hud.py (+15/-2)
tests/autopilot/autopilot/emulators/unity/icons.py (+3/-1)
tests/autopilot/autopilot/keybindings.py (+1/-0)
tests/autopilot/autopilot/tests/__init__.py (+6/-0)
tests/autopilot/autopilot/tests/test_hud.py (+50/-31)
tests/autopilot/autopilot/tests/test_showdesktop.py (+18/-14)
tests/autopilot/autopilot/tests/test_switcher.py (+11/-16)
To merge this branch: bzr merge lp:~3v1n0/unity/hud-invalid-icon-fix
Reviewer Review Type Date Requested Status
Thomi Richards (community) Approve
John Lea (community) design Approve
Review via email: mp+100318@code.launchpad.net

Commit message

HudController: use the top-most valid window in the stack to fetch the icon, if an invalid window is focused

Description of the change

HudController: use the top-most valid window in the stack to fetch the icon, if an invalid window is focused

When the dash or any other unity window is focused, the HUD isn't able to get the icon from the currently focused window (this manifests with bug #932371), so we need to fallback to the top-most valid window in the stack.

Getting the list of windows by stack order from BAMF, we can easily get the top-most application and then retrieve its icon. Thanks to this switching from HUD to Dash and the other way around, works as expected.

In the case that no valid window is focused, we fallback to the Ubuntu icon.

This includes AP tests.

To post a comment you must log in.
Revision history for this message
Thomi Richards (thomir-deactivatedaccount) wrote :

Hi,

Great branch - a few small issues with the AP test though:

99 + self.keybinding("dash/reveal", 0.1)
100 + sleep(1)

Please use self.dash.ensure_visible() for this - it's safer, since it doesn't require you to sleep() after calling it.

105 + if self.hud.is_locked_launcher:
106 + hud_launcher_icon = self.get_hud_launcher_icon()
107 + self.assertThat(hud_launcher_icon.icon_name, Equals(calc.icon))
108 + else:
109 + hud_embedded_icon = self.hud.get_embedded_icon()
110 + self.assertThat(hud_embedded_icon.icon_name, Equals(calc.icon))

This seems to be something we're going to be doing a lot, so please just add a property to the Hud class that gets you the correct icon in all situations. THen these 6 lines become one:

self.assertThat(self.hud.icon.name, Equals(calc.icon))

... or something similar.

114 + self.start_app("Calculator")
115 + calctools = self.get_app_instances("Calculator")
116 + self.assertThat(len(calctools), GreaterThan(0))
117 + calc = calctools[0]
118 + self.assertTrue(calc.is_active)

This is ugly - and it's my fault. Please could you patch self.start_app(...) so it returns the BamfApplication instance? It shouldn't be hard to do, since we launch the application in the Bamf Emulator. THen you can replace all that code with this:

calc = self.start_app("Calculator")

Cheers,

review: Needs Fixing
Revision history for this message
John Lea (johnlea) wrote :

Thx, yes the bfb should be used.

review: Approve (design)
Revision history for this message
Marco Trevisan (Treviño) (3v1n0) wrote :

> Please use self.dash.ensure_visible() for this - it's safer, since it doesn't
> require you to sleep() after calling it.

Done.

> 105 + if self.hud.is_locked_launcher:
> 106 + hud_launcher_icon = self.get_hud_launcher_icon()
> 107 + self.assertThat(hud_launcher_icon.icon_name,
> Equals(calc.icon))
> 108 + else:
> 109 + hud_embedded_icon = self.hud.get_embedded_icon()
> 110 + self.assertThat(hud_embedded_icon.icon_name,
> Equals(calc.icon))
>
> This seems to be something we're going to be doing a lot, so please just add a
> property to the Hud class that gets you the correct icon in all situations.
> THen these 6 lines become one:
>
> self.assertThat(self.hud.icon.name, Equals(calc.icon))

Done.

> 114 + self.start_app("Calculator")
> 115 + calctools = self.get_app_instances("Calculator")
> 116 + self.assertThat(len(calctools), GreaterThan(0))
> 117 + calc = calctools[0]
> 118 + self.assertTrue(calc.is_active)
>
>
> This is ugly - and it's my fault. Please could you patch self.start_app(...)
> so it returns the BamfApplication instance? It shouldn't be hard to do, since
> we launch the application in the Bamf Emulator. THen you can replace all that
> code with this:
>
> calc = self.start_app("Calculator")

Done.

Revision history for this message
Thomi Richards (thomir-deactivatedaccount) wrote :

Awesome tests, thanks!

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/HudController.cpp'
2--- plugins/unityshell/src/HudController.cpp 2012-04-02 00:16:21 +0000
3+++ plugins/unityshell/src/HudController.cpp 2012-04-03 17:02:21 +0000
4@@ -274,11 +274,51 @@
5 view_->ShowEmbeddedIcon(!IsLockedToLauncher(monitor_index_));
6 view_->AboutToShow();
7
8- // we first want to grab the currently active window, luckly we can just ask the jason interface(bamf)
9- BamfMatcher* matcher = bamf_matcher_get_default();
10- glib::Object<BamfView> bamf_app((BamfView*)(bamf_matcher_get_active_application(matcher)), glib::AddRef());
11- glib::String view_icon(bamf_view_get_icon(bamf_app));
12- focused_app_icon_ = view_icon.Str();
13+ // We first want to grab the currently active window
14+ glib::Object<BamfMatcher> matcher(bamf_matcher_get_default());
15+ BamfWindow* active_win = bamf_matcher_get_active_window(matcher);
16+
17+ Window active_xid = bamf_window_get_xid(active_win);
18+ std::vector<Window> const& unity_xids = nux::XInputWindow::NativeHandleList();
19+
20+ // If the active window is an unity window, we must get the top-most valid window
21+ if (std::find(unity_xids.begin(), unity_xids.end(), active_xid) != unity_xids.end())
22+ {
23+ // Windows list stack for all the monitors
24+ GList *windows = bamf_matcher_get_window_stack_for_monitor(matcher, -1);
25+
26+ for (GList *l = windows; l; l = l->next)
27+ {
28+ if (!BAMF_IS_WINDOW(l->data))
29+ continue;
30+
31+ auto win = static_cast<BamfWindow*>(l->data);
32+ auto view = static_cast<BamfView*>(l->data);
33+ Window xid = bamf_window_get_xid(win);
34+
35+ if (bamf_view_user_visible(view) && bamf_window_get_window_type(win) != BAMF_WINDOW_DOCK &&
36+ std::find(unity_xids.begin(), unity_xids.end(), xid) == unity_xids.end())
37+ {
38+ active_win = win;
39+ active_xid = xid;
40+ }
41+ }
42+
43+ g_list_free(windows);
44+ }
45+
46+ BamfApplication* active_app = bamf_matcher_get_application_for_window(matcher, active_win);
47+
48+ if (BAMF_IS_VIEW(active_app))
49+ {
50+ auto active_view = reinterpret_cast<BamfView*>(active_app);
51+ glib::String view_icon(bamf_view_get_icon(active_view));
52+ focused_app_icon_ = view_icon.Str();
53+ }
54+ else
55+ {
56+ focused_app_icon_ = focused_app_icon_ = PKGDATADIR "/launcher_bfb.png";
57+ }
58
59 LOG_DEBUG(logger) << "Taking application icon: " << focused_app_icon_;
60 ubus.SendMessage(UBUS_HUD_ICON_CHANGED, g_variant_new_string(focused_app_icon_.c_str()));
61
62=== modified file 'plugins/unityshell/src/HudIcon.cpp'
63--- plugins/unityshell/src/HudIcon.cpp 2012-04-01 00:00:45 +0000
64+++ plugins/unityshell/src/HudIcon.cpp 2012-04-03 17:02:21 +0000
65@@ -80,9 +80,8 @@
66
67 std::string Icon::GetName() const
68 {
69- return "EmbeddedIcon";
70-}
71-
72-}
73-}
74-
75+ return "HudEmbeddedIcon";
76+}
77+
78+}
79+}
80
81=== modified file 'plugins/unityshell/src/HudLauncherIcon.cpp'
82--- plugins/unityshell/src/HudLauncherIcon.cpp 2012-03-28 18:03:24 +0000
83+++ plugins/unityshell/src/HudLauncherIcon.cpp 2012-04-03 17:02:21 +0000
84@@ -58,10 +58,13 @@
85 if (data_string)
86 hud_icon_name = data_string;
87 LOG_DEBUG(logger) << "Hud icon change: " << hud_icon_name;
88- if (!hud_icon_name.empty()
89- && hud_icon_name != icon_name())
90+ if (hud_icon_name != icon_name)
91 {
92- icon_name = hud_icon_name;
93+ if (hud_icon_name.empty())
94+ icon_name = PKGDATADIR"/launcher_bfb.png";
95+ else
96+ icon_name = hud_icon_name;
97+
98 EmitNeedsRedraw();
99 }
100 });
101@@ -91,7 +94,7 @@
102 g_variant_get(data, UBUS_OVERLAY_FORMAT_STRING,
103 &overlay_identity, &can_maximise, &overlay_monitor);
104
105- // If the hud is open, we show the HUD button iff we have a locked launcher
106+ // If the hud is open, we show the HUD button if we have a locked launcher
107 if (overlay_identity.Str() == "hud" &&
108 launcher_hide_mode_ == LAUNCHER_HIDE_NEVER)
109 {
110
111=== modified file 'tests/autopilot/autopilot/emulators/unity/hud.py'
112--- tests/autopilot/autopilot/emulators/unity/hud.py 2012-04-02 20:18:58 +0000
113+++ tests/autopilot/autopilot/emulators/unity/hud.py 2012-04-03 17:02:21 +0000
114@@ -9,7 +9,7 @@
115
116 from autopilot.emulators.unity import UnityIntrospectionObject
117 from autopilot.emulators.unity.dash import SearchBar
118-from autopilot.emulators.unity.icons import EmbeddedIcon
119+from autopilot.emulators.unity.icons import HudEmbeddedIcon, HudLauncherIcon
120 from autopilot.keybindings import KeybindingsHelper
121
122
123@@ -42,9 +42,22 @@
124 if (not view):
125 return None
126
127- icons = view.get_children_by_type(EmbeddedIcon)
128+ icons = view.get_children_by_type(HudEmbeddedIcon)
129 return icons[0] if icons else None
130
131+ def get_launcher_icon(self):
132+ """Returns the HUD launcher icon"""
133+ icons = HudLauncherIcon.get_all_instances()
134+ assert(len(icons) == 1)
135+ return icons[0]
136+
137+ @property
138+ def icon(self):
139+ if self.is_locked_launcher:
140+ return self.get_launcher_icon()
141+ else:
142+ return self.get_embedded_icon()
143+
144 @property
145 def view(self):
146 """Returns the HudView."""
147
148=== modified file 'tests/autopilot/autopilot/emulators/unity/icons.py'
149--- tests/autopilot/autopilot/emulators/unity/icons.py 2012-03-31 10:38:26 +0000
150+++ tests/autopilot/autopilot/emulators/unity/icons.py 2012-04-03 17:02:21 +0000
151@@ -69,10 +69,12 @@
152 class DesktopLauncherIcon(SimpleLauncherIcon):
153 """Represents an icon that may appear in the switcher."""
154
155+
156 class SoftwareCenterLauncherIcon(BamfLauncherIcon):
157 """Represents a launcher icon of a Software Center app."""
158
159-class EmbeddedIcon(SimpleLauncherIcon):
160+
161+class HudEmbeddedIcon(SimpleLauncherIcon):
162 """Proxy object for the hud embedded icon child of the view."""
163
164 @property
165
166=== modified file 'tests/autopilot/autopilot/keybindings.py'
167--- tests/autopilot/autopilot/keybindings.py 2012-04-02 01:46:10 +0000
168+++ tests/autopilot/autopilot/keybindings.py 2012-04-03 17:02:21 +0000
169@@ -90,6 +90,7 @@
170 "workspace/move_up": ("wall", "up_key"),
171 "workspace/move_down": ("wall", "down_key"),
172 # Window management
173+ "window/show_desktop" : ("core", "show_desktop_key"),
174 "window/minimize": ("core", "minimize_window_key"),
175 # expo plugin:
176 "expo/start": ("expo", "expo_key"),
177
178=== modified file 'tests/autopilot/autopilot/tests/__init__.py'
179--- tests/autopilot/autopilot/tests/__init__.py 2012-03-31 10:38:26 +0000
180+++ tests/autopilot/autopilot/tests/__init__.py 2012-04-03 17:02:21 +0000
181@@ -242,6 +242,9 @@
182
183 If files is specified, start the application with the specified files.
184 If locale is specified, the locale will be set when the application is launched.
185+
186+ The method returns the BamfApplication instance.
187+
188 """
189 if locale:
190 os.putenv("LC_ALL", locale)
191@@ -252,7 +255,10 @@
192
193 app = self.KNOWN_APPS[app_name]
194 self.bamf.launch_application(app['desktop-file'], files)
195+ apps = self.bamf.get_running_applications_by_desktop_file(app['desktop-file'])
196 self.addCleanup(call, ["killall", app['process-name']])
197+ self.assertThat(len(apps), Equals(1))
198+ return apps[0]
199
200 def close_all_app(self, app_name):
201 """Close all instances of the app_name."""
202
203=== modified file 'tests/autopilot/autopilot/tests/test_hud.py'
204--- tests/autopilot/autopilot/tests/test_hud.py 2012-04-02 20:18:58 +0000
205+++ tests/autopilot/autopilot/tests/test_hud.py 2012-04-03 17:02:21 +0000
206@@ -13,7 +13,7 @@
207 from autopilot.emulators.X11 import ScreenGeometry
208 from autopilot.emulators.unity.icons import HudLauncherIcon
209 from autopilot.tests import AutopilotTestCase, multiply_scenarios
210-from os import remove
211+from os import remove, path
212
213
214 def _make_monitor_scenarios():
215@@ -33,17 +33,11 @@
216
217 def setUp(self):
218 super(HudTestsBase, self).setUp()
219- sleep(0.25)
220
221 def tearDown(self):
222 self.hud.ensure_hidden()
223 super(HudTestsBase, self).tearDown()
224
225- def get_hud_launcher_icon(self):
226- icons = HudLauncherIcon.get_all_instances()
227- self.assertEqual(1, len(icons))
228- return icons[0]
229-
230 def get_num_active_launcher_icons(self):
231 num_active = 0
232 for icon in self.launcher.model.get_launcher_icons():
233@@ -124,8 +118,8 @@
234
235 def test_reveal_hud_with_no_apps(self):
236 """Hud must show even with no visible applications."""
237- self.keyboard.press_and_release("Ctrl+Alt+d")
238- self.addCleanup(self.keyboard.press_and_release, "Ctrl+Alt+d")
239+ self.keybinding("window/show_desktop")
240+ self.addCleanup(self.keybinding, "window/show_desktop")
241 sleep(1)
242
243 self.hud.toggle_reveal()
244@@ -140,10 +134,7 @@
245 """Ensures that once the hud is dismissed, the same application
246 that was focused before hud invocation is refocused
247 """
248- self.start_app("Calculator")
249- calc = self.get_app_instances("Calculator")
250- self.assertThat(len(calc), Equals(1))
251- calc = calc[0]
252+ calc = self.start_app("Calculator")
253
254 # first ensure that the application has started and is focused
255 self.assertEqual(calc.is_active, True)
256@@ -316,7 +307,7 @@
257 def test_hud_launcher_icon_hides_bfb(self):
258 """Tests that the BFB icon is hidden when the HUD launcher icon is shown"""
259
260- hud_icon = self.get_hud_launcher_icon()
261+ hud_icon = self.hud.get_launcher_icon()
262 bfb_icon = self.launcher.model.get_bfb_icon()
263
264 self.assertTrue(bfb_icon.is_visible_on_monitor(self.hud_monitor))
265@@ -400,7 +391,7 @@
266 self.hud.visible
267 sleep(.5)
268
269- hud_launcher_icon = self.get_hud_launcher_icon()
270+ hud_launcher_icon = self.hud.get_launcher_icon()
271 hud_embedded_icon = self.hud.get_embedded_icon()
272
273 if self.hud.is_locked_launcher:
274@@ -414,20 +405,48 @@
275 self.assertFalse(hud_launcher_icon.active)
276 self.assertThat(hud_embedded_icon, NotEquals(None))
277
278- def test_hud_icon_show_the_focused_application_emblem(self):
279+ def test_hud_icon_shows_the_focused_application_emblem(self):
280 """Tests that the correct HUD icon is shown"""
281- self.start_app("Calculator")
282- calctools = self.get_app_instances("Calculator")
283- self.assertThat(len(calctools), GreaterThan(0))
284- calc = calctools[0]
285- self.assertTrue(calc.is_active)
286-
287- self.reveal_hud()
288- sleep(.5)
289-
290- if self.hud.is_locked_launcher:
291- hud_launcher_icon = self.get_hud_launcher_icon()
292- self.assertThat(hud_launcher_icon.icon_name, Equals(calc.icon))
293- else:
294- hud_embedded_icon = self.hud.get_embedded_icon()
295- self.assertThat(hud_embedded_icon.icon_name, Equals(calc.icon))
296+ self.close_all_app("Calculator")
297+ calc = self.start_app("Calculator")
298+ self.assertTrue(calc.is_active)
299+
300+ self.reveal_hud()
301+ sleep(.5)
302+
303+ self.assertThat(self.hud.icon.icon_name, Equals(calc.icon))
304+
305+ def test_hud_icon_shows_the_ubuntu_emblem_on_empty_desktop(self):
306+ self.keybinding("window/show_desktop")
307+ self.addCleanup(self.keybinding, "window/show_desktop")
308+ sleep(1)
309+
310+ self.reveal_hud()
311+ sleep(.5)
312+
313+ self.assertThat(path.basename(self.hud.icon.icon_name), Equals("launcher_bfb.png"))
314+
315+ def test_switch_dash_hud_does_not_break_the_focused_application_emblem(self):
316+ """Tests that the correct HUD icon is shown when switching from Dash to HUD"""
317+ self.close_all_app("Calculator")
318+ calc = self.start_app("Calculator")
319+ self.assertTrue(calc.is_active)
320+
321+ self.dash.ensure_visible()
322+ self.reveal_hud()
323+ sleep(.5)
324+
325+ self.assertThat(self.hud.icon.icon_name, Equals(calc.icon))
326+
327+ def test_switch_hud_dash_does_not_break_the_focused_application_emblem(self):
328+ """Tests that the correct HUD icon is shown when switching from HUD to Dash and back"""
329+ self.close_all_app("Calculator")
330+ calc = self.start_app("Calculator")
331+ self.assertTrue(calc.is_active)
332+
333+ self.reveal_hud()
334+ self.dash.ensure_visible()
335+ self.reveal_hud()
336+ sleep(.5)
337+
338+ self.assertThat(self.hud.icon.icon_name, Equals(calc.icon))
339
340=== modified file 'tests/autopilot/autopilot/tests/test_showdesktop.py'
341--- tests/autopilot/autopilot/tests/test_showdesktop.py 2012-03-27 21:42:52 +0000
342+++ tests/autopilot/autopilot/tests/test_showdesktop.py 2012-04-03 17:02:21 +0000
343@@ -33,8 +33,8 @@
344 self.launch_test_apps()
345
346 # show desktop, verify all windows are hidden:
347- self.keyboard.press_and_release('Control+Alt+d')
348- self.addCleanup(self.keyboard.press_and_release, keys='Control+Alt+d')
349+ self.keybinding("window/show_desktop")
350+ self.addCleanup(self.keybinding, "window/show_desktop")
351 sleep(3)
352 open_wins = self.bamf.get_open_windows()
353 self.assertGreaterEqual(len(open_wins), 2)
354@@ -47,7 +47,8 @@
355 self.launch_test_apps()
356
357 # show desktop, verify all windows are hidden:
358- self.keyboard.press_and_release('Control+Alt+d')
359+ self.keybinding("window/show_desktop")
360+ self.addCleanup(self.keybinding, "window/show_desktop")
361 sleep(3)
362 open_wins = self.bamf.get_open_windows()
363 self.assertGreaterEqual(len(open_wins), 2)
364@@ -56,7 +57,8 @@
365 self.assertTrue(win.is_hidden, "Window '%s' is not hidden after show desktop activated." % (win.title))
366
367 # un-show desktop, verify all windows are shown:
368- self.keyboard.press_and_release('Control+Alt+d')
369+ self.keybinding("window/show_desktop")
370+ self.addCleanup(self.keybinding, "window/show_desktop")
371 sleep(3)
372 for win in self.bamf.get_open_windows():
373 self.assertTrue(win.is_valid)
374@@ -67,7 +69,9 @@
375 self.launch_test_apps()
376
377 # show desktop, verify all windows are hidden:
378- self.keyboard.press_and_release('Control+Alt+d')
379+ self.keybinding("window/show_desktop")
380+ self.addCleanup(self.keybinding, "window/show_desktop")
381+
382 sleep(3)
383 open_wins = self.bamf.get_open_windows()
384 self.assertGreaterEqual(len(open_wins), 2)
385@@ -91,7 +95,8 @@
386 self.assertTrue(win.is_hidden, "Window '%s' should still be hidden." % (win.title))
387
388 # hide desktop - now all windows should be visible:
389- self.keyboard.press_and_release('Control+Alt+d')
390+ self.keybinding("window/show_desktop")
391+ self.addCleanup(self.keybinding, "window/show_desktop")
392 sleep(3)
393 for win in self.bamf.get_open_windows():
394 if win.is_valid:
395@@ -102,21 +107,20 @@
396 self.launch_test_apps()
397
398 # show desktop, verify all windows are hidden:
399- switcher = Switcher()
400- switcher.initiate()
401+ self.switcher.initiate()
402 sleep(0.5)
403 found = False
404- for i in range(switcher.get_model_size()):
405- current_icon = switcher.current_icon
406+ for i in range(self.switcher.get_model_size()):
407+ current_icon = self.switcher.current_icon
408 self.assertIsNotNone(current_icon)
409 if isinstance(current_icon, DesktopLauncherIcon):
410 found = True
411 break
412- switcher.previous_icon()
413- sleep(0.5)
414+ self.switcher.previous_icon()
415+ sleep(0.25)
416 self.assertTrue(found, "Could not find 'Show Desktop' entry in switcher.")
417- switcher.stop()
418- self.addCleanup(self.keyboard.press_and_release, keys='Control+Alt+d')
419+ self.addCleanup(self.keybinding, "window/show_desktop")
420+ self.switcher.stop()
421
422 sleep(3)
423 open_wins = self.bamf.get_open_windows()
424
425=== modified file 'tests/autopilot/autopilot/tests/test_switcher.py'
426--- tests/autopilot/autopilot/tests/test_switcher.py 2012-04-02 20:18:58 +0000
427+++ tests/autopilot/autopilot/tests/test_switcher.py 2012-04-03 17:02:21 +0000
428@@ -290,29 +290,24 @@
429 class SwitcherWorkspaceTests(AutopilotTestCase):
430 """Test Switcher behavior with respect to multiple workspaces."""
431
432- def get_bamf_application(self, name):
433- apps = self.get_app_instances(name)
434- self.assertThat(len(apps), Equals(1))
435- return apps[0]
436-
437 def test_switcher_shows_current_workspace_only(self):
438 """Switcher must show apps from the current workspace only."""
439 self.close_all_app('Calculator')
440 self.close_all_app('Character Map')
441
442 self.workspace.switch_to(1)
443- self.start_app("Calculator")
444+ calc = self.start_app("Calculator")
445 sleep(1)
446 self.workspace.switch_to(2)
447- self.start_app("Character Map")
448+ char_map = self.start_app("Character Map")
449 sleep(1)
450
451 self.switcher.initiate()
452 sleep(1)
453 icon_names = [i.tooltip_text for i in self.switcher.get_switcher_icons()]
454 self.switcher.terminate()
455- self.assertThat(icon_names, Contains(self.get_bamf_application("Character Map").name))
456- self.assertThat(icon_names, Not(Contains(self.get_bamf_application("Calculator").name)))
457+ self.assertThat(icon_names, Contains(char_map.name))
458+ self.assertThat(icon_names, Not(Contains(calc.name)))
459
460 def test_switcher_all_mode_shows_all_apps(self):
461 """Test switcher 'show_all' mode shows apps from all workspaces."""
462@@ -320,18 +315,18 @@
463 self.close_all_app('Character Map')
464
465 self.workspace.switch_to(1)
466- self.start_app("Calculator")
467+ calc = self.start_app("Calculator")
468 sleep(1)
469 self.workspace.switch_to(2)
470- self.start_app("Character Map")
471+ char_map = self.start_app("Character Map")
472 sleep(1)
473
474 self.switcher.initiate_all_mode()
475 sleep(1)
476 icon_names = [i.tooltip_text for i in self.switcher.get_switcher_icons()]
477 self.switcher.terminate()
478- self.assertThat(icon_names, Contains(self.get_bamf_application("Calculator").name))
479- self.assertThat(icon_names, Contains(self.get_bamf_application("Character Map").name))
480+ self.assertThat(icon_names, Contains(calc.name))
481+ self.assertThat(icon_names, Contains(char_map.name))
482
483 def test_switcher_can_switch_to_minimised_window(self):
484 """Switcher must be able to switch to a minimised window when there's
485@@ -346,7 +341,7 @@
486 self.start_app("Mahjongg")
487
488 self.workspace.switch_to(3)
489- self.start_app("Mahjongg")
490+ mahjongg = self.start_app("Mahjongg")
491 sleep(1)
492 self.keybinding("window/minimize")
493 sleep(1)
494@@ -356,14 +351,14 @@
495
496 self.switcher.initiate()
497 sleep(1)
498- while self.switcher.current_icon.tooltip_text != self.get_bamf_application("Mahjongg").name:
499+ while self.switcher.current_icon.tooltip_text != mahjongg.name:
500 self.switcher.next_icon()
501 sleep(1)
502 self.switcher.stop()
503 sleep(1)
504
505 #get mahjongg windows - there should be two:
506- wins = self.get_bamf_application("Mahjongg").get_windows()
507+ wins = mahjongg.get_windows()
508 self.assertThat(len(wins), Equals(2))
509 # Ideally we should be able to find the instance that is on the
510 # current workspace and ask that one if it is hidden.