summaryrefslogtreecommitdiff
path: root/tests
diff options
authorThomi Richards <thomi.richards@canonical.com>2012-11-23 03:14:32 +0000
committerTarmac <>2012-11-23 03:14:32 +0000
commit6c65c68f5ca1e015a5c9661295d335f3e181f694 (patch)
treef04984de92fa50169bcdd11eed611d6cb336d5aa /tests
parentc71ac9d8174a75ca7e0312e898c43eabad8729b4 (diff)
parent566c7742a08cb40830320e6e8c1a7bd97163aa92 (diff)
Lots of autopilot fixes.
Approved by Christopher Lee. (bzr r2926)
Diffstat (limited to 'tests')
-rw-r--r--tests/autopilot/unity/tests/test_dash.py8
-rw-r--r--tests/autopilot/unity/tests/test_hud.py2
-rw-r--r--tests/autopilot/unity/tests/test_ibus.py16
-rw-r--r--tests/autopilot/unity/tests/test_spread.py16
4 files changed, 22 insertions, 20 deletions
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_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)))
diff --git a/tests/autopilot/unity/tests/test_spread.py b/tests/autopilot/unity/tests/test_spread.py
index f1e3fc3f0..9636b6de6 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)
@@ -40,14 +38,12 @@ 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):
"""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,9 +60,11 @@ 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"""
+ """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)