diff options
| author | Marco Trevisan (Treviño) <mail@3v1n0.net> | 2012-04-26 04:53:18 +0200 |
|---|---|---|
| committer | Marco Trevisan (Treviño) <mail@3v1n0.net> | 2012-04-26 04:53:18 +0200 |
| commit | e8e80525d42055c5311dc84c93785f39421621cc (patch) | |
| tree | 806ac35698da9c367fc74b95608f4885296d3d4d | |
| parent | 9335faee325413767bc63ee08c6891384e0e6ef3 (diff) | |
autopilot, test_launcher: added test to check the launcher status after bamfdaemon killing
(bzr r2342.2.2)
| -rw-r--r-- | tests/autopilot/autopilot/emulators/bamf.py | 10 | ||||
| -rw-r--r-- | tests/autopilot/autopilot/tests/__init__.py | 8 | ||||
| -rw-r--r-- | tests/autopilot/autopilot/tests/test_launcher.py | 35 |
3 files changed, 51 insertions, 2 deletions
diff --git a/tests/autopilot/autopilot/emulators/bamf.py b/tests/autopilot/autopilot/emulators/bamf.py index 88553fbbd..b0901d50f 100644 --- a/tests/autopilot/autopilot/emulators/bamf.py +++ b/tests/autopilot/autopilot/emulators/bamf.py @@ -254,6 +254,16 @@ class BamfWindow(object): return self._x_win @property + def name(self): + """Get the window name. + + Note: This may change according to the current locale. If you want a unique + string to match windows against, use the x_id instead. + + """ + return self._view_iface.Name() + + @property def title(self): """Get the window title. diff --git a/tests/autopilot/autopilot/tests/__init__.py b/tests/autopilot/autopilot/tests/__init__.py index d472d562f..d23eb5e33 100644 --- a/tests/autopilot/autopilot/tests/__init__.py +++ b/tests/autopilot/autopilot/tests/__init__.py @@ -224,6 +224,10 @@ class AutopilotTestCase(VideoCapturedTestCase, KeybindingsHelper): 'desktop-file': 'remmina.desktop', 'process-name': 'remmina', }, + 'System Settings' : { + 'desktop-file': 'gnome-control-center.desktop', + 'process-name': 'gnome-control-center', + }, 'Text Editor' : { 'desktop-file': 'gedit.desktop', 'process-name': 'gedit', @@ -266,14 +270,14 @@ class AutopilotTestCase(VideoCapturedTestCase, KeybindingsHelper): app = self.KNOWN_APPS[app_name] self.bamf.launch_application(app['desktop-file'], files) apps = self.bamf.get_running_applications_by_desktop_file(app['desktop-file']) - self.addCleanup(call, ["killall", app['process-name']]) + self.addCleanup(call, ["pkill", "-f", app['process-name']]) self.assertThat(len(apps), Equals(1)) return apps[0] def close_all_app(self, app_name): """Close all instances of the app_name.""" app = self.KNOWN_APPS[app_name] - call(["killall", app['process-name']]) + self.addCleanup(call, ["pkill", "-f", app['process-name']]) super(LoggedTestCase, self).tearDown() def get_app_instances(self, app_name): diff --git a/tests/autopilot/autopilot/tests/test_launcher.py b/tests/autopilot/autopilot/tests/test_launcher.py index ed0518f5c..a10f9acc1 100644 --- a/tests/autopilot/autopilot/tests/test_launcher.py +++ b/tests/autopilot/autopilot/tests/test_launcher.py @@ -8,9 +8,12 @@ # by the Free Software Foundation. import logging +import os +from subprocess import call from testtools.matchers import Equals, NotEquals, LessThan, GreaterThan from time import sleep +from autopilot.emulators.bamf import Bamf from autopilot.emulators.unity.icons import BFBLauncherIcon from autopilot.emulators.X11 import ScreenGeometry from autopilot.matchers import Eventually @@ -568,6 +571,38 @@ class LauncherVisualTests(LauncherTestCase): for icon in self.launcher.model.get_launcher_icons(): self.assertThat(icon.desaturated, Eventually(Equals(False))) + def test_kill_bamfdaemon_does_not_duplicate_icons(self): + """Killing bamfdaemon should not duplicate any launcher icon.""" + self.start_app("Calculator") + self.start_app("System Settings") + os.spawnlp(os.P_NOWAIT, "xterm", "xterm", "-title", "Autopilot XTerm", "-e", "sh") + self.addCleanup(call, ["killall", "xterm"]) + + # FIXME bamf emulator should wait until a window is open + sleep(1) + [xterm_win] = [w for w in self.bamf.get_open_windows() if w.name == "Autopilot XTerm"] + self.assertTrue(xterm_win.is_focused) + + call(["pkill", "bamfdaemon"]) + sleep(1) + + # This should ensure that bamfdaemon is reloaded again + self.bamf = Bamf() + [calc] = self.get_app_instances("Calculator") + calc_icon = self.launcher.model.get_icon_by_desktop_id(calc.desktop_file) + self.launcher_instance.click_launcher_icon(calc_icon) + sleep(1) + self.assertTrue(calc.is_active) + + bamf_icons = self.launcher.model.get_bamf_launcher_icons() + for icon in bamf_icons: + if len(icon.desktop_file): + same_desktop = [i for i in bamf_icons if i.desktop_file == icon.desktop_file] + self.assertThat(len(same_desktop), Equals(1)) + + same_appid = [i for i in bamf_icons if i.application_id == icon.application_id] + self.assertThat(len(same_appid), Equals(1)) + class LauncherCaptureTests(AutopilotTestCase): """Test the launchers ability to capture/not capture the mouse.""" |
