From 8b293a8fbb4e628557a9985bbc21e8e99fcb7ef9 Mon Sep 17 00:00:00 2001 From: Thomi Richards Date: Fri, 23 Nov 2012 12:01:38 +1300 Subject: Code cleanup - PEP8 fixes, removed a few lambda functions that were not needed. (bzr r2895.1.17) --- tests/autopilot/unity/tests/test_dash.py | 8 ++++---- tests/autopilot/unity/tests/test_hud.py | 2 ++ tests/autopilot/unity/tests/test_spread.py | 10 +++------- 3 files changed, 9 insertions(+), 11 deletions(-) (limited to 'tests') diff --git a/tests/autopilot/unity/tests/test_dash.py b/tests/autopilot/unity/tests/test_dash.py index 9f2c55f13..acf887197 100644 --- a/tests/autopilot/unity/tests/test_dash.py +++ b/tests/autopilot/unity/tests/test_dash.py @@ -117,9 +117,6 @@ class DashRevealWithSpreadTests(DashTestCase): apps. We use a place holder app so that it is activated as we require. """ - def setUp(self): - super(DashRevealWithSpreadTests, self).setUp() - self.start_placeholder_app() def start_placeholder_app(self): window_spec = { @@ -129,6 +126,7 @@ class DashRevealWithSpreadTests(DashTestCase): def test_dash_closes_on_spread(self): """This test shows that when the spread is initiated, the dash closes.""" + self.start_placeholder_app() self.dash.ensure_visible() self.addCleanup(self.keybinding, "spread/cancel") self.keybinding("spread/start") @@ -137,6 +135,7 @@ class DashRevealWithSpreadTests(DashTestCase): def test_dash_opens_when_in_spread(self): """This test shows the dash opens when in spread mode.""" + self.start_placeholder_app() self.keybinding("spread/start") self.assertThat(self.window_manager.scale_active, Eventually(Equals(True))) @@ -145,6 +144,7 @@ class DashRevealWithSpreadTests(DashTestCase): def test_command_lens_opens_when_in_spread(self): """This test shows the command lens opens when in spread mode.""" + self.start_placeholder_app() self.keybinding("spread/start") self.assertThat(self.window_manager.scale_active, Eventually(Equals(True))) @@ -153,6 +153,7 @@ class DashRevealWithSpreadTests(DashTestCase): def test_lens_opens_when_in_spread(self): """This test shows that any lens opens when in spread mode.""" + self.start_placeholder_app() self.keybinding("spread/start") self.assertThat(self.window_manager.scale_active, Eventually(Equals(True))) @@ -160,7 +161,6 @@ class DashRevealWithSpreadTests(DashTestCase): self.assertThat(self.dash.active_lens, Eventually(Equals('applications.lens'))) - class DashSearchInputTests(DashTestCase): """Test features involving input to the dash search""" diff --git a/tests/autopilot/unity/tests/test_hud.py b/tests/autopilot/unity/tests/test_hud.py index 4623990be..61cfa4748 100644 --- a/tests/autopilot/unity/tests/test_hud.py +++ b/tests/autopilot/unity/tests/test_hud.py @@ -222,6 +222,8 @@ class HudBehaviorTests(HudTestsBase): def test_hud_closes_on_spread(self): """This test shows that when the spread is initiated, the hud closes.""" + # Need at least one application open for the spread to work. + self.start_app_window("Calculator") self.hud.ensure_visible() self.addCleanup(self.keybinding, "spread/cancel") self.keybinding("spread/start") diff --git a/tests/autopilot/unity/tests/test_spread.py b/tests/autopilot/unity/tests/test_spread.py index f1e3fc3f0..89afcd74c 100644 --- a/tests/autopilot/unity/tests/test_spread.py +++ b/tests/autopilot/unity/tests/test_spread.py @@ -9,12 +9,10 @@ from __future__ import absolute_import from autopilot.matchers import Eventually -import logging -from time import sleep from testtools.matchers import Equals, NotEquals +from time import sleep from unity.tests import UnityTestCase -from unity.emulators.screen import Screen class SpreadTests(UnityTestCase): @@ -27,7 +25,7 @@ class SpreadTests(UnityTestCase): for i in range(num_windows): win = self.start_app_window(app_name) - if len(windows): + if windows: self.assertThat(win.application, Equals(windows[-1].application)) windows.append(win) @@ -43,11 +41,10 @@ class SpreadTests(UnityTestCase): sleep(1) self.assertThat(self.window_manager.scale_active, Eventually(Equals(True))) - def initiate_spread_for_application(self, desktop_id): """Initiate the Spread for windows of the given app""" icon = self.launcher.model.get_icon(desktop_id=desktop_id) - self.assertThat(lambda: icon, Eventually(NotEquals(None))) + self.assertThat(icon, NotEquals(None)) launcher = self.launcher.get_launcher_for_monitor(self.screen_geo.get_primary_monitor()) self.addCleanup(self.keybinding, "spread/cancel") @@ -64,7 +61,6 @@ class SpreadTests(UnityTestCase): refresh_fn = lambda: xid in [w.x_id for w in self.bamf.get_open_windows()] self.assertThat(refresh_fn, Eventually(Equals(False))) - def test_scale_application_windows(self): """Test if all the windows of an application are scaled when application spread is initiated""" [win1, win2] = self.start_test_application_windows("Calculator") -- cgit v1.2.3 From dac6a0e2119882a4b923882bce65b60ebf3895c4 Mon Sep 17 00:00:00 2001 From: Thomi Richards Date: Fri, 23 Nov 2012 12:02:14 +1300 Subject: Removed unneeded sleep (bzr r2895.1.18) --- tests/autopilot/unity/tests/test_spread.py | 1 - 1 file changed, 1 deletion(-) (limited to 'tests') diff --git a/tests/autopilot/unity/tests/test_spread.py b/tests/autopilot/unity/tests/test_spread.py index 89afcd74c..afff7dc0e 100644 --- a/tests/autopilot/unity/tests/test_spread.py +++ b/tests/autopilot/unity/tests/test_spread.py @@ -38,7 +38,6 @@ class SpreadTests(UnityTestCase): """Initiate the Spread for all windows""" self.addCleanup(self.keybinding, "spread/cancel") self.keybinding("spread/start") - sleep(1) self.assertThat(self.window_manager.scale_active, Eventually(Equals(True))) def initiate_spread_for_application(self, desktop_id): -- cgit v1.2.3 From 40092975d30abcf32f2c80f018e4b6a58a9603f7 Mon Sep 17 00:00:00 2001 From: Thomi Richards Date: Fri, 23 Nov 2012 14:35:39 +1300 Subject: Docstring fix. (bzr r2895.1.19) --- tests/autopilot/unity/tests/test_spread.py | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) (limited to 'tests') diff --git a/tests/autopilot/unity/tests/test_spread.py b/tests/autopilot/unity/tests/test_spread.py index afff7dc0e..9636b6de6 100644 --- a/tests/autopilot/unity/tests/test_spread.py +++ b/tests/autopilot/unity/tests/test_spread.py @@ -61,7 +61,10 @@ class SpreadTests(UnityTestCase): self.assertThat(refresh_fn, Eventually(Equals(False))) def test_scale_application_windows(self): - """Test if all the windows of an application are scaled when application spread is initiated""" + """All the windows of an application must be scaled when application + spread is initiated + + """ [win1, win2] = self.start_test_application_windows("Calculator") self.initiate_spread_for_application(win1.application.desktop_file) -- cgit v1.2.3 From 566c7742a08cb40830320e6e8c1a7bd97163aa92 Mon Sep 17 00:00:00 2001 From: Thomi Richards Date: Fri, 23 Nov 2012 15:05:14 +1300 Subject: Don't require dbus service at module import time. (bzr r2895.1.20) --- tests/autopilot/unity/tests/test_ibus.py | 16 +++++++++------- 1 file changed, 9 insertions(+), 7 deletions(-) (limited to 'tests') diff --git a/tests/autopilot/unity/tests/test_ibus.py b/tests/autopilot/unity/tests/test_ibus.py index 55fb49dc0..400807f97 100644 --- a/tests/autopilot/unity/tests/test_ibus.py +++ b/tests/autopilot/unity/tests/test_ibus.py @@ -92,22 +92,24 @@ class IBusTests(UnityTestCase): class IBusWidgetScenariodTests(IBusTests): """A class that includes scenarios for the hud and dash widgets.""" + # Use lambdas here so we don't require DBus service at module import time. scenarios = [ - ('dash', {'widget': Dash()}), - ('hud', {'widget': Hud()}) + ('dash', {'widget': lambda: Dash()}), + ('hud', {'widget': lambda: Hud()}) ] def do_ibus_test(self): """Do the basic IBus test on self.widget using self.input and self.result.""" - self.widget.ensure_visible() - self.addCleanup(self.widget.ensure_hidden) - self.activate_ibus(self.widget.searchbar) + widget = self.widget() + widget.ensure_visible() + self.addCleanup(widget.ensure_hidden) + self.activate_ibus(widget.searchbar) self.keyboard.type(self.input) commit_key = getattr(self, 'commit_key', None) if commit_key: self.keyboard.press_and_release(commit_key) - self.deactivate_ibus(self.widget.searchbar) - self.assertThat(self.widget.search_string, Eventually(Equals(self.result))) + self.deactivate_ibus(widget.searchbar) + self.assertThat(widget.search_string, Eventually(Equals(self.result))) -- cgit v1.2.3