diff options
| author | Thomi Richards <thomi.richards@canonical.com> | 2012-07-11 12:48:24 +1200 |
|---|---|---|
| committer | Thomi Richards <thomi.richards@canonical.com> | 2012-07-11 12:48:24 +1200 |
| commit | a3883b8ca9d98aa0822634a2d744abeeaec8fed2 (patch) | |
| tree | 0427d8995aa25ba64d6b6f2d63b5921666b0cd33 /tests/autopilot | |
| parent | f110e110e4d03360c9995cd7bbf8e51fc336c266 (diff) | |
Removed a bunch of methods that weren't being used in the launcher model, and updated lots of places in the code where we were using get_icon_by_desktop_id and replaced it with get_icon(...) calls, as this is safer.
(bzr r2487.1.3)
Diffstat (limited to 'tests/autopilot')
| -rw-r--r-- | tests/autopilot/unity/emulators/launcher.py | 42 | ||||
| -rw-r--r-- | tests/autopilot/unity/tests/launcher/test_icon_behavior.py | 28 | ||||
| -rw-r--r-- | tests/autopilot/unity/tests/launcher/test_reveal.py | 4 | ||||
| -rw-r--r-- | tests/autopilot/unity/tests/test_hud.py | 2 | ||||
| -rw-r--r-- | tests/autopilot/unity/tests/test_panel.py | 2 | ||||
| -rw-r--r-- | tests/autopilot/unity/tests/test_quicklist.py | 16 | ||||
| -rw-r--r-- | tests/autopilot/unity/tests/test_showdesktop.py | 2 |
7 files changed, 29 insertions, 67 deletions
diff --git a/tests/autopilot/unity/emulators/launcher.py b/tests/autopilot/unity/emulators/launcher.py index 425ca9049..50d9f0672 100644 --- a/tests/autopilot/unity/emulators/launcher.py +++ b/tests/autopilot/unity/emulators/launcher.py @@ -458,48 +458,6 @@ class LauncherModel(UnityIntrospectionObject): return icons - def get_icon_by_tooltip_text(self, tooltip_text): - """Get a launcher icon given it's tooltip text. - - Returns None if there is no icon with the specified text. - """ - for icon in self.get_launcher_icons(): - if icon.tooltip_text == tooltip_text: - return icon - return None - - def get_icon_by_desktop_id(self, desktop_id): - """Gets a launcher icon with the specified desktop id. - - Returns None if there is no such launcher icon. - """ - icons = self.get_children_by_type(SimpleLauncherIcon, desktop_id=desktop_id) - if len(icons): - return icons[0] - - return None - - def get_icon_by_window_xid(self, xid): - """Gets a launcher icon that controls the specified window xid.""" - icons = [i for i in self.get_children_by_type(SimpleLauncherIcon) if i.xids.contains(xid)] - if (len(icons)): - return icons[0] - - return None - - def get_icons_by_filter(self, **kwargs): - """Get a list of icons that satisfy the given filters. - - For example: - - >>> get_icons_by_filter(tooltip_text="My Application") - ... [...] - - Returns an empty list if no icons matched the filter. - - """ - return self.get_children_by_type(SimpleLauncherIcon, **kwargs) - def get_icon(self, **kwargs): """Get a launcher icon from the model according to some filters. diff --git a/tests/autopilot/unity/tests/launcher/test_icon_behavior.py b/tests/autopilot/unity/tests/launcher/test_icon_behavior.py index d7cdc96b5..f214b3a08 100644 --- a/tests/autopilot/unity/tests/launcher/test_icon_behavior.py +++ b/tests/autopilot/unity/tests/launcher/test_icon_behavior.py @@ -15,6 +15,7 @@ import logging from testtools.matchers import Equals, NotEquals from time import sleep +from unity.emulators.icons import BamfLauncherIcon from unity.emulators.launcher import IconDragType from unity.tests.launcher import LauncherTestCase, _make_scenarios @@ -51,8 +52,7 @@ class LauncherIconsTests(LauncherTestCase): def test_shift_click_opens_new_application_instance(self): """Shift+Clicking MUST open a new instance of an already-running application.""" app = self.start_app("Calculator") - desktop_id = app.desktop_file - icon = self.launcher.model.get_icon_by_desktop_id(desktop_id) + icon = self.launcher.model.get_icon(desktop_id=app.desktop_file) launcher_instance = self.launcher.get_launcher_for_monitor(0) self.keyboard.press("Shift") @@ -72,10 +72,10 @@ class LauncherIconsTests(LauncherTestCase): self.assertVisibleWindowStack([mah_win2, calc_win, mah_win1]) - mahj_icon = self.launcher.model.get_icon_by_desktop_id( - mah_win2.application.desktop_file) - calc_icon = self.launcher.model.get_icon_by_desktop_id( - calc_win.application.desktop_file) + mahj_icon = self.launcher.model.get_icon( + desktop_id=mah_win2.application.desktop_file) + calc_icon = self.launcher.model.get_icon( + desktop_id=calc_win.application.desktop_file) self.launcher_instance.click_launcher_icon(calc_icon) self.assertProperty(calc_win, is_focused=True) @@ -107,7 +107,7 @@ class LauncherIconsTests(LauncherTestCase): self.assertVisibleWindowStack([calc_win2, calc_win1]) self.assertProperty(calc_win2, is_focused=True) - calc_icon = self.launcher.model.get_icon_by_desktop_id(calc_app.desktop_file) + calc_icon = self.launcher.model.get_icon(desktop_id=calc_app.desktop_file) self.addCleanup(self.keybinding, "spread/cancel") self.launcher_instance.click_launcher_icon(calc_icon) @@ -118,14 +118,14 @@ class LauncherIconsTests(LauncherTestCase): """Icons must stay on launcher when an application is quickly closed/reopened.""" calc = self.start_app("Calculator") desktop_file = calc.desktop_file - calc_icon = self.launcher.model.get_icon_by_desktop_id(desktop_file) + calc_icon = self.launcher.model.get_icon(desktop_id=desktop_file) self.assertThat(calc_icon.visible, Eventually(Equals(True))) self.close_all_app("Calculator") calc = self.start_app("Calculator") sleep(2) - calc_icon = self.launcher.model.get_icon_by_desktop_id(desktop_file) + calc_icon = self.launcher.model.get_icon(desktop_id=desktop_file) self.assertThat(calc_icon, NotEquals(None)) self.assertThat(calc_icon.visible, Eventually(Equals(True))) @@ -141,7 +141,11 @@ class LauncherDragIconsBehavior(LauncherTestCase): def ensure_calc_icon_not_in_launcher(self): """Wait until the launcher model updates and removes the calc icon.""" - refresh_fn = lambda: self.launcher.model.get_icon_by_desktop_id("gcalctool.desktop") + # Normally we'd use get_icon(desktop_id="...") but we're expecting it to + # not exist, and we don't want to wait for 10 seconds, so we do this + # the old fashioned way. + refresh_fn = lambda: self.launcher.model.get_children_by_type( + BamfLauncherIcon, desktop_id="gcalctool.desktop") self.assertThat(refresh_fn, Eventually(Equals(None))) def test_can_drag_icon_below_bfb(self): @@ -149,7 +153,7 @@ class LauncherDragIconsBehavior(LauncherTestCase): self.ensure_calc_icon_not_in_launcher() calc = self.start_app("Calculator") - calc_icon = self.launcher.model.get_icon_by_desktop_id(calc.desktop_file) + calc_icon = self.launcher.model.get_icon(desktop_id=calc.desktop_file) bfb_icon_position = 0 self.launcher_instance.drag_icon_to_position(calc_icon, @@ -164,7 +168,7 @@ class LauncherDragIconsBehavior(LauncherTestCase): self.ensure_calc_icon_not_in_launcher() calc = self.start_app("Calculator") - calc_icon = self.launcher.model.get_icon_by_desktop_id(calc.desktop_file) + calc_icon = self.launcher.model.get_icon(desktop_id=calc.desktop_file) # Move a known icon to the top as it needs to be more than 2 icon # spaces away for this test to actually do anything diff --git a/tests/autopilot/unity/tests/launcher/test_reveal.py b/tests/autopilot/unity/tests/launcher/test_reveal.py index 745424b3d..00cad97a5 100644 --- a/tests/autopilot/unity/tests/launcher/test_reveal.py +++ b/tests/autopilot/unity/tests/launcher/test_reveal.py @@ -79,9 +79,9 @@ class LauncherRevealTests(LauncherTestCase): self.skip("There are already more than 9 icons in the launcher") desktop_file = self.KNOWN_APPS['Calculator']['desktop-file'] - if self.launcher.model.get_icon_by_desktop_id(desktop_file) != None: + if self.launcher.model.get_icon(desktop_id=desktop_file) != None: self.skip("Calculator icon is already on the launcher.") self.start_app('Calculator') - icon = self.launcher.model.get_icon_by_desktop_id(desktop_file) + icon = self.launcher.model.get_icon(desktop_id=desktop_file) self.assertThat(icon.shortcut, GreaterThan(0)) diff --git a/tests/autopilot/unity/tests/test_hud.py b/tests/autopilot/unity/tests/test_hud.py index 6a989387b..9411184a0 100644 --- a/tests/autopilot/unity/tests/test_hud.py +++ b/tests/autopilot/unity/tests/test_hud.py @@ -303,7 +303,7 @@ class HudLauncherInteractionsTests(HudTestsBase): self.hud.ensure_hidden() # click application icons for running apps in the launcher: - icon = self.launcher.model.get_icon_by_desktop_id("gucharmap.desktop") + icon = self.launcher.model.get_icon(desktop_id="gucharmap.desktop") launcher.click_launcher_icon(icon) # see how many apps are marked as being active: diff --git a/tests/autopilot/unity/tests/test_panel.py b/tests/autopilot/unity/tests/test_panel.py index ebc81c063..abbb77641 100644 --- a/tests/autopilot/unity/tests/test_panel.py +++ b/tests/autopilot/unity/tests/test_panel.py @@ -189,7 +189,7 @@ class PanelTitleTests(PanelTestsBase): text_win = self.open_new_application_window("Text Editor", maximized=True) self.open_new_application_window("Calculator", maximized=False) - icon = self.launcher.model.get_icon_by_desktop_id(text_win.application.desktop_file) + icon = self.launcher.model.get_icon(desktop_id=text_win.application.desktop_file) launcher = self.launcher.get_launcher_for_monitor(self.panel_monitor) launcher.click_launcher_icon(icon) diff --git a/tests/autopilot/unity/tests/test_quicklist.py b/tests/autopilot/unity/tests/test_quicklist.py index 6ac069cc1..b1d9c3bd8 100644 --- a/tests/autopilot/unity/tests/test_quicklist.py +++ b/tests/autopilot/unity/tests/test_quicklist.py @@ -47,7 +47,7 @@ class QuicklistActionTests(UnityTestCase): desktop_file = os.path.join('/usr/share/applications', desktop_id) de = DesktopEntry(desktop_file) # get the launcher icon from the launcher: - launcher_icon = self.launcher.model.get_icon_by_desktop_id(desktop_id) + launcher_icon = self.launcher.model.get_icon(desktop_id=desktop_id) self.assertThat(launcher_icon, NotEquals(None)) # open the icon quicklist, and get all the text labels: @@ -78,10 +78,10 @@ class QuicklistActionTests(UnityTestCase): self.assertVisibleWindowStack([mah_win2, calc_win, mah_win1]) - mahj_icon = self.launcher.model.get_icon_by_desktop_id( - mah_win1.application.desktop_file) - calc_icon = self.launcher.model.get_icon_by_desktop_id( - calc_win.application.desktop_file) + mahj_icon = self.launcher.model.get_icon( + desktop_id=mah_win1.application.desktop_file) + calc_icon = self.launcher.model.get_icon( + desktop_id=calc_win.application.desktop_file) calc_ql = self.open_quicklist_for_icon(calc_icon) calc_ql.get_quicklist_application_item(calc_win.application.name).mouse_click() @@ -106,7 +106,7 @@ class QuicklistActionTests(UnityTestCase): self.assertVisibleWindowStack([calc_win2, calc_win1]) self.assertProperty(calc_win2, is_focused=True) - calc_icon = self.launcher.model.get_icon_by_desktop_id(calc_app.desktop_file) + calc_icon = self.launcher.model.get_icon(desktop_id=calc_app.desktop_file) calc_ql = self.open_quicklist_for_icon(calc_icon) app_item = calc_ql.get_quicklist_application_item(calc_app.name) @@ -124,8 +124,8 @@ class QuicklistActionTests(UnityTestCase): self.dash.ensure_visible() - calc_icon = self.launcher.model.get_icon_by_desktop_id( - calc_win.application.desktop_file) + calc_icon = self.launcher.model.get_icon( + desktop_id=calc_win.application.desktop_file) self.open_quicklist_for_icon(calc_icon) self.keyboard.press_and_release("Down") diff --git a/tests/autopilot/unity/tests/test_showdesktop.py b/tests/autopilot/unity/tests/test_showdesktop.py index 54eca88a8..254bd6e7c 100644 --- a/tests/autopilot/unity/tests/test_showdesktop.py +++ b/tests/autopilot/unity/tests/test_showdesktop.py @@ -80,7 +80,7 @@ class ShowDesktopTests(UnityTestCase): self.assertTrue(win.is_hidden, "Window '%s' is not hidden after show desktop activated." % (win.title)) # We'll un-minimise the character map - find it's launcherIcon in the launcher: - charmap_icon = self.launcher.model.get_icon_by_desktop_id("gucharmap.desktop") + charmap_icon = self.launcher.model.get_icon(desktop_id="gucharmap.desktop") if charmap_icon: self.launcher.get_launcher_for_monitor(0).click_launcher_icon(charmap_icon) else: |
