summaryrefslogtreecommitdiff
path: root/tests
diff options
authorThomi Richards <thomi.richards@canonical.com>2012-04-18 13:37:34 +1200
committerThomi Richards <thomi.richards@canonical.com>2012-04-18 13:37:34 +1200
commit560eb04562ed07fd99ffe4b049fdadd94c5a4da4 (patch)
tree911af8962dfde5bfdc5baaca14e448daf4d0cd2d /tests
parent4067ba116e204500b7c8832b223391deb0eb2ce9 (diff)
parent9028f20ae86eb79649fbf5587322253c3f9e0e3b (diff)
Merged home-lens-tests-to-wait_for-feature into hud-tests-to-wait_for-feature.
(bzr r2220.7.5)
Diffstat (limited to 'tests')
-rw-r--r--tests/autopilot/autopilot/matchers/__init__.py2
-rw-r--r--tests/autopilot/autopilot/tests/test_command_lens.py16
-rw-r--r--tests/autopilot/autopilot/tests/test_dash.py69
-rw-r--r--tests/autopilot/autopilot/tests/test_home_lens.py4
4 files changed, 48 insertions, 43 deletions
diff --git a/tests/autopilot/autopilot/matchers/__init__.py b/tests/autopilot/autopilot/matchers/__init__.py
index d879b87e1..7f946139d 100644
--- a/tests/autopilot/autopilot/matchers/__init__.py
+++ b/tests/autopilot/autopilot/matchers/__init__.py
@@ -23,7 +23,7 @@ class Eventually(Matcher):
def match(self, value):
wait_fun = getattr(value, 'wait_for', None)
- if not wait_fun:
+ if wait_fun is None:
raise TypeError("Eventually can only be used against autopilot attributes that have a wait_for funtion.")
value.wait_for(self.matcher)
diff --git a/tests/autopilot/autopilot/tests/test_command_lens.py b/tests/autopilot/autopilot/tests/test_command_lens.py
index 126234fe3..276848a54 100644
--- a/tests/autopilot/autopilot/tests/test_command_lens.py
+++ b/tests/autopilot/autopilot/tests/test_command_lens.py
@@ -6,9 +6,11 @@
# under the terms of the GNU General Public License version 3, as published
# by the Free Software Foundation.
+from testtools.matchers import Equals
from time import sleep
from autopilot.tests import AutopilotTestCase
+from autopilot.matchers import Eventually
class CommandLensSearchTests(AutopilotTestCase):
@@ -29,9 +31,9 @@ class CommandLensSearchTests(AutopilotTestCase):
if self.dash.search_string != "":
self.keyboard.press_and_release("Delete")
- self.dash.search_string.wait_for("")
+ self.assertThat(self.dash.search_string, Eventually(Equals("")))
results_category = command_lens.get_category_by_name("Results")
- results_category.is_visible.wait_for(True)
+ self.assertThat(results_category.is_visible, Eventually(Equals(True)))
def test_results_category_appears(self):
"""Results category must appear when there are some results."""
@@ -39,9 +41,9 @@ class CommandLensSearchTests(AutopilotTestCase):
command_lens = self.dash.get_current_lens()
# lots of apps start with 'a'...
self.keyboard.type("a")
- self.dash.search_string.wait_for("a")
+ self.assertThat(self.dash.search_string, Eventually(Equals("a")))
results_category = command_lens.get_category_by_name("Results")
- results_category.is_visible.wait_for(True)
+ self.assertThat(results_category.is_visible, Eventually(Equals(True)))
def test_result_category_actually_contains_results(self):
"""With a search string of 'a', the results category must contain some results."""
@@ -49,7 +51,7 @@ class CommandLensSearchTests(AutopilotTestCase):
command_lens = self.dash.get_current_lens()
# lots of apps start with 'a'...
self.keyboard.type("a")
- self.dash.search_string.wait_for("a")
+ self.assertThat(self.dash.search_string, Eventually(Equals("a")))
results_category = command_lens.get_category_by_name("Results")
results = results_category.get_results()
self.assertTrue(results)
@@ -73,10 +75,10 @@ class CommandLensSearchTests(AutopilotTestCase):
"""Pressing Ctrl+Tab after launching command lens must switch to Home lens."""
self.dash.reveal_command_lens()
self.keybinding("dash/lens/next")
- self.dash.active_lens.wait_for("home.lens")
+ self.assertThat(self.dash.active_lens, Eventually(Equals("home.lens")))
def test_ctrl_shift_tab_switching(self):
"""Pressing Ctrl+Shift+Tab after launching command lens must switch to Video lens."""
self.dash.reveal_command_lens()
self.keybinding("dash/lens/prev")
- self.dash.active_lens.wait_for("video.lens")
+ self.assertThat(self.dash.active_lens, Eventually(Equals("video.lens")))
diff --git a/tests/autopilot/autopilot/tests/test_dash.py b/tests/autopilot/autopilot/tests/test_dash.py
index a2295370d..678e3f440 100644
--- a/tests/autopilot/autopilot/tests/test_dash.py
+++ b/tests/autopilot/autopilot/tests/test_dash.py
@@ -11,6 +11,7 @@ from time import sleep
from gtk import Clipboard
from testtools.matchers import Equals, NotEquals
+from autopilot.matchers import Eventually
from autopilot.tests import AutopilotTestCase
@@ -36,35 +37,35 @@ class DashRevealTests(DashTestCase):
def test_application_lens_shortcut(self):
"""Application lense must reveal when Super+a is pressed."""
self.dash.reveal_application_lens()
- self.dash.active_lens.wait_for('applications.lens')
+ self.assertThat(self.dash.active_lens, Eventually(Equals('applications.lens')))
def test_music_lens_shortcut(self):
"""Music lense must reveal when Super+w is pressed."""
self.dash.reveal_music_lens()
- self.dash.active_lens.wait_for('music.lens')
+ self.assertThat(self.dash.active_lens, Eventually(Equals('music.lens')))
def test_file_lens_shortcut(self):
"""File lense must reveal when Super+f is pressed."""
self.dash.reveal_file_lens()
- self.dash.active_lens.wait_for('files.lens')
+ self.assertThat(self.dash.active_lens, Eventually(Equals('files.lens')))
def test_command_lens_shortcut(self):
"""Run Command lens must reveat on alt+F2."""
self.dash.reveal_command_lens()
- self.dash.active_lens.wait_for('commands.lens')
+ self.assertThat(self.dash.active_lens, Eventually(Equals('commands.lens')))
def test_alt_f4_close_dash(self):
"""Dash must close on alt+F4."""
self.dash.ensure_visible()
self.keyboard.press_and_release("Alt+F4")
- self.dash.visible.wait_for(False)
+ self.assertThat(self.dash.visible, Eventually(Equals(False)))
class DashSearchInputTests(DashTestCase):
"""Test features involving input to the dash search"""
def assertSearchText(self, text):
- self.dash.search_string.wait_for(text)
+ self.assertThat(self.dash.search_string, Eventually(Equals(text)))
def test_search_keyboard_focus(self):
"""Dash must put keyboard focus on the search bar at all times."""
@@ -124,7 +125,7 @@ class DashKeyNavTests(DashTestCase):
for i in range(self.dash.get_num_rows()):
self.keyboard.press_and_release("Down")
lensbar = self.dash.view.get_lensbar()
- lensbar.focused_lens_icon.wait_for(NotEquals(''))
+ self.assertThat(lensbar.focused_lens_icon, Eventually(NotEquals('')))
def test_lensbar_focus_changes(self):
"""Lensbar focused icon should change with Left and Right keypresses."""
@@ -137,10 +138,10 @@ class DashKeyNavTests(DashTestCase):
current_focused_icon = lensbar.focused_lens_icon
self.keyboard.press_and_release("Right");
- lensbar.focused_lens_icon.wait_for(NotEquals(current_focused_icon))
+ self.assertThat(lensbar.focused_lens_icon, Eventually(NotEquals(current_focused_icon)))
self.keyboard.press_and_release("Left")
- lensbar.focused_lens_icon.wait_for(current_focused_icon)
+ self.assertThat(lensbar.focused_lens_icon, Eventually(Equals(current_focused_icon)))
def test_lensbar_enter_activation(self):
"""Must be able to activate LensBar icons that have focus with an Enter keypress."""
@@ -153,12 +154,12 @@ class DashKeyNavTests(DashTestCase):
focused_icon = lensbar.focused_lens_icon
self.keyboard.press_and_release("Enter");
- lensbar.active_lens.wait_for(focused_icon)
+ self.assertThat(lensbar.active_lens, Eventually(Equals(focused_icon)))
# lensbar should lose focus after activation.
# TODO this should be a different test to make sure focus
# returns to the correct place.
- lensbar.focused_lens_icon.wait_for("")
+ self.assertThat(lensbar.focused_lens_icon, Eventually(Equals("")))
def test_category_header_keynav(self):
""" Tests that a category header gets focus when 'down' is pressed after the
@@ -194,7 +195,7 @@ class DashKeyNavTests(DashTestCase):
self.keyboard.release('Control')
self.keyboard.release('Shift')
- lensbar.active_lens.wait_for('home.lens')
+ self.assertThat(lensbar.active_lens, Eventually(Equals('home.lens')))
def test_tab_cycle_category_headers(self):
""" Makes sure that pressing tab cycles through the category headers"""
@@ -219,12 +220,12 @@ class DashKeyNavTests(DashTestCase):
self.keyboard.press_and_release('Tab')
searchbar = self.dash.get_searchbar()
- searchbar.expander_has_focus.wait_for(True)
+ self.assertThat(searchbar.expander_has_focus, Eventually(Equals(True)))
filter_bar = lens.get_filterbar()
if not searchbar.showing_filters:
self.keyboard.press_and_release('Enter')
- searchbar.showing_filters.wait_for(True)
+ self.assertThat(searchbar.showing_filters, Eventually(Equals(True)))
self.addCleanup(filter_bar.ensure_collapsed)
for i in range(filter_bar.get_num_filters()):
@@ -255,35 +256,35 @@ class DashClipboardTests(DashTestCase):
self.dash.ensure_visible()
self.keyboard.type("SelectAll")
- self.dash.search_string.wait_for("SelectAll")
+ self.assertThat(self.dash.search_string, Eventually(Equals("SelectAll")))
self.keyboard.press_and_release("Ctrl+a")
self.keyboard.press_and_release("Delete")
- self.dash.search_string.wait_for('')
+ self.assertThat(self.dash.search_string, Eventually(Equals('')))
def test_ctrl_c(self):
""" This test if ctrl+c copies text into the clipboard """
self.dash.ensure_visible()
self.keyboard.type("Copy")
- self.dash.search_string.wait_for("Copy")
+ self.assertThat(self.dash.search_string, Eventually(Equals("Copy")))
self.keyboard.press_and_release("Ctrl+a")
self.keyboard.press_and_release("Ctrl+c")
cb = Clipboard(selection="CLIPBOARD")
- self.dash.search_string.wait_for(cb.wait_for_text())
+ self.assertThat(self.dash.search_string, Eventually(Equals(cb.wait_for_text())))
def test_ctrl_x(self):
""" This test if ctrl+x deletes all text and copys it """
self.dash.ensure_visible()
self.keyboard.type("Cut")
- self.dash.search_string.wait_for("Cut")
+ self.assertThat(self.dash.search_string, Eventually(Equals("Cut")))
self.keyboard.press_and_release("Ctrl+a")
self.keyboard.press_and_release("Ctrl+x")
- self.dash.search_string.wait_for("")
+ self.assertThat(self.dash.search_string, Eventually(Equals("")))
cb = Clipboard(selection="CLIPBOARD")
self.assertEqual(cb.wait_for_text(), u'Cut')
@@ -293,28 +294,28 @@ class DashClipboardTests(DashTestCase):
self.dash.ensure_visible()
self.keyboard.type("CopyPaste")
- self.dash.search_string.wait_for("CopyPaste")
+ self.assertThat(self.dash.search_string, Eventually(Equals("CopyPaste")))
self.keyboard.press_and_release("Ctrl+a")
self.keyboard.press_and_release("Ctrl+c")
self.keyboard.press_and_release("Ctrl+v")
self.keyboard.press_and_release("Ctrl+v")
- self.dash.search_string.wait_for('CopyPasteCopyPaste')
+ self.assertThat(self.dash.search_string, Eventually(Equals('CopyPasteCopyPaste')))
def test_ctrl_x_v(self):
""" This test if ctrl+x and ctrl+v cuts and pastes text"""
self.dash.ensure_visible()
self.keyboard.type("CutPaste")
- self.dash.search_string.wait_for("CutPaste")
+ self.assertThat(self.dash.search_string, Eventually(Equals("CutPaste")))
self.keyboard.press_and_release("Ctrl+a")
self.keyboard.press_and_release("Ctrl+x")
self.keyboard.press_and_release("Ctrl+v")
self.keyboard.press_and_release("Ctrl+v")
- self.dash.search_string.wait_for('CutPasteCutPaste')
+ self.assertThat(self.dash.search_string, Eventually(Equals('CutPasteCutPaste')))
class DashKeyboardFocusTests(DashTestCase):
@@ -332,7 +333,7 @@ class DashKeyboardFocusTests(DashTestCase):
filter_bar.ensure_expanded()
self.addCleanup(filter_bar.ensure_collapsed)
self.keyboard.type(" world")
- self.dash.search_string.wait_for("hello world")
+ self.assertThat(self.dash.search_string, Eventually(Equals("hello world")))
class DashLensResultsTests(DashTestCase):
@@ -342,30 +343,30 @@ class DashLensResultsTests(DashTestCase):
"""This tests a message is not shown when there is no text."""
self.dash.reveal_application_lens()
lens = self.dash.get_current_lens()
- lens.no_results_active.wait_for(False)
+ self.assertThat(lens.no_results_active, Eventually(Equals(False)))
def test_results_message(self):
"""This test no mesage will be shown when results are there."""
self.dash.reveal_application_lens()
self.keyboard.type("Terminal")
- self.dash.search_string.wait_for("Terminal")
+ self.assertThat(self.dash.search_string, Eventually(Equals("Terminal")))
lens = self.dash.get_current_lens()
- lens.no_results_active.wait_for(False)
+ self.assertThat(lens.no_results_active, Eventually(Equals(False)))
def test_no_results_message(self):
"""This test shows a message will appear in the lens."""
self.dash.reveal_application_lens()
self.keyboard.type("qwerlkjzvxc")
- self.dash.search_string.wait_for("qwerlkjzvxc")
+ self.assertThat(self.dash.search_string, Eventually(Equals("qwerlkjzvxc")))
lens = self.dash.get_current_lens()
- lens.no_results_active.wait_for(True)
+ self.assertThat(lens.no_results_active, Eventually(Equals(True)))
def test_results_update_on_filter_changed(self):
"""This test makes sure the results change when filters change."""
self.dash.reveal_application_lens()
lens = self.dash.get_current_lens()
self.keyboard.type(" ")
- self.dash.search_string.wait_for(" ")
+ self.assertThat(self.dash.search_string, Eventually(Equals(" ")))
results_category = lens.get_category_by_name("Installed")
old_results = results_category.get_results()
@@ -379,12 +380,12 @@ class DashLensResultsTests(DashTestCase):
self.keyboard.press_and_release('Tab')
searchbar = self.dash.get_searchbar()
- searchbar.expander_has_focus.wait_for(True)
+ self.assertThat(searchbar.expander_has_focus, Eventually(Equals(True)))
filter_bar = lens.get_filterbar()
if not searchbar.showing_filters:
self.keyboard.press_and_release('Enter')
- searchbar.showing_filters.wait_for(True)
+ self.assertThat(searchbar.showing_filters, Eventually(Equals(True)))
if add_cleanup:
self.addCleanup(filter_bar.ensure_collapsed)
@@ -446,4 +447,4 @@ class DashLensBarTests(DashTestCase):
self.mouse.move(app_icon.x + (app_icon.width / 2),
app_icon.y + (app_icon.height / 2))
self.mouse.click()
- self.lensbar.active_lens.wait_for('applications.lens')
+ self.assertThat(self.lensbar.active_lens, Eventually(Equals('applications.lens')))
diff --git a/tests/autopilot/autopilot/tests/test_home_lens.py b/tests/autopilot/autopilot/tests/test_home_lens.py
index cb61caf1c..4509a3664 100644
--- a/tests/autopilot/autopilot/tests/test_home_lens.py
+++ b/tests/autopilot/autopilot/tests/test_home_lens.py
@@ -6,8 +6,10 @@
# under the terms of the GNU General Public License version 3, as published
# by the Free Software Foundation.
+from testtools.matchers import Equals
from time import sleep
+from autopilot.matchers import Eventually
from autopilot.tests import AutopilotTestCase
@@ -30,7 +32,7 @@ class HomeLensSearchTests(AutopilotTestCase):
kb = self.keyboard
self.dash.ensure_visible()
kb.type("g")
- self.dash.search_string.wait_for("g")
+ self.assertThat(self.dash.search_string, Eventually(Equals("g")))
kb.type("edit", 0.1)
kb.press_and_release("Enter", 0.1)
self.addCleanup(self.close_all_app, "Text Editor")