summaryrefslogtreecommitdiff
path: root/tests
diff options
authorThomi Richards <thomi.richards@canonical.com>2012-04-19 08:50:16 +1200
committerThomi Richards <thomi.richards@canonical.com>2012-04-19 08:50:16 +1200
commit26d2fee49b743c2df43aad6aa9826e8fbde9f0ef (patch)
tree48b11a51b22cc34ee31b44b094ab2ab074f593d7 /tests
parentec4632c3ac82de2303f6cc6e08068d7892fec3b2 (diff)
parent21f6b92795e67c8bd78cd8f4fbddc1cc5a6fdf06 (diff)
Merged trunk, reso;lved conflicts.
(bzr r2220.6.8)
Diffstat (limited to 'tests')
-rw-r--r--tests/autopilot/autopilot/emulators/bamf.py13
-rw-r--r--tests/autopilot/autopilot/emulators/unity/dash.py1
-rw-r--r--tests/autopilot/autopilot/emulators/unity/icons.py4
-rw-r--r--tests/autopilot/autopilot/emulators/unity/launcher.py44
-rw-r--r--tests/autopilot/autopilot/emulators/unity/switcher.py3
-rw-r--r--tests/autopilot/autopilot/tests/__init__.py12
-rw-r--r--tests/autopilot/autopilot/tests/test_dash.py60
-rw-r--r--tests/autopilot/autopilot/tests/test_hud.py269
-rw-r--r--tests/autopilot/autopilot/tests/test_ibus.py126
-rw-r--r--tests/autopilot/autopilot/tests/test_launcher.py242
-rw-r--r--tests/autopilot/autopilot/tests/test_panel.py202
-rw-r--r--tests/autopilot/autopilot/tests/test_switcher.py70
-rw-r--r--tests/test-gesture-engine/CMakeLists.txt2
13 files changed, 587 insertions, 461 deletions
diff --git a/tests/autopilot/autopilot/emulators/bamf.py b/tests/autopilot/autopilot/emulators/bamf.py
index e2b67d85e..88553fbbd 100644
--- a/tests/autopilot/autopilot/emulators/bamf.py
+++ b/tests/autopilot/autopilot/emulators/bamf.py
@@ -81,12 +81,21 @@ class Bamf(object):
If user_visible_only is True (the default), only applications
visible to the user in the switcher will be returned.
+ The result is sorted to be in stacking order.
+
"""
+ # Get the stacking order from the root window.
+ root_win = _X_DISPLAY.screen().root
+ prop = root_win.get_full_property(
+ _X_DISPLAY.get_atom('_NET_CLIENT_LIST_STACKING'), X.AnyPropertyType)
+ stack = prop.value.tolist()
+
windows = [BamfWindow(w) for w in self.matcher_interface.WindowPaths()]
if user_visible_only:
- return filter(_filter_user_visible, windows)
- return windows
+ windows = filter(_filter_user_visible, windows)
+ # Now sort on stacking order.
+ return sorted(windows, key=lambda w: stack.index(w.x_id), reverse=True)
def wait_until_application_is_running(self, desktop_file, timeout):
"""Wait until a given application is running.
diff --git a/tests/autopilot/autopilot/emulators/unity/dash.py b/tests/autopilot/autopilot/emulators/unity/dash.py
index c30c38347..ed7a7d7cd 100644
--- a/tests/autopilot/autopilot/emulators/unity/dash.py
+++ b/tests/autopilot/autopilot/emulators/unity/dash.py
@@ -94,6 +94,7 @@ class Dash(KeybindingsHelper):
"""
self._keyboard.press_and_release("Ctrl+a")
self._keyboard.press_and_release("Delete")
+ self.search_string.wait_for("")
def reveal_application_lens(self, clear_search=True):
"""Reveal the application lense."""
diff --git a/tests/autopilot/autopilot/emulators/unity/icons.py b/tests/autopilot/autopilot/emulators/unity/icons.py
index 09ec6b707..75d58f328 100644
--- a/tests/autopilot/autopilot/emulators/unity/icons.py
+++ b/tests/autopilot/autopilot/emulators/unity/icons.py
@@ -40,10 +40,6 @@ class SimpleLauncherIcon(UnityIntrospectionObject):
return False
- def is_visible_on_monitor(self, monitor):
- """Returns True if the icon is visible in the defined monitor"""
- return self.visible and self.is_on_monitor(monitor)
-
class BFBLauncherIcon(SimpleLauncherIcon):
"""Represents the BFB button in the launcher."""
diff --git a/tests/autopilot/autopilot/emulators/unity/launcher.py b/tests/autopilot/autopilot/emulators/unity/launcher.py
index 4ea7ac097..f8a978414 100644
--- a/tests/autopilot/autopilot/emulators/unity/launcher.py
+++ b/tests/autopilot/autopilot/emulators/unity/launcher.py
@@ -9,6 +9,7 @@
import dbus
import logging
+from testtools.matchers import NotEquals
from time import sleep
from autopilot.emulators.dbus_handler import session_bus
@@ -40,9 +41,6 @@ class LauncherController(UnityIntrospectionObject):
assert(len(models) == 1)
return models[0]
- def key_nav_monitor(self):
- return self.key_nav_launcher_monitor
-
def add_launcher_item_from_position(self,name,icon,icon_x,icon_y,icon_size,desktop_file,aptdaemon_task):
""" Emulate a DBus call from Software Center to pin an icon to the launcher """
launcher_object = session_bus.get_object('com.canonical.Unity.Launcher',
@@ -92,6 +90,11 @@ class Launcher(UnityIntrospectionObject, KeybindingsHelper):
self.keybinding_release("launcher/switcher")
self.in_switcher_mode = False
+ def _get_controller(self):
+ """Get the launcher controller."""
+ [controller] = LauncherController.get_all_instances()
+ return controller
+
def move_mouse_to_right_of_launcher(self):
"""Places the mouse to the right of this launcher."""
self._screen.move_mouse_to_monitor(self.monitor)
@@ -127,84 +130,106 @@ class Launcher(UnityIntrospectionObject, KeybindingsHelper):
self._screen.move_mouse_to_monitor(self.monitor)
logger.debug("Revealing launcher with keyboard.")
self.keybinding_hold("launcher/reveal")
- sleep(1)
+ self.is_showing.wait_for(True)
def keyboard_unreveal_launcher(self):
"""Un-reveal this launcher using the keyboard."""
self._screen.move_mouse_to_monitor(self.monitor)
logger.debug("Un-revealing launcher with keyboard.")
self.keybinding_release("launcher/reveal")
- sleep(1)
+ # only wait if the launcher is set to autohide
+ if self.hidemode == 1:
+ self.is_showing.wait_for(False)
def key_nav_start(self):
"""Start keyboard navigation mode by pressing Alt+F1."""
self._screen.move_mouse_to_monitor(self.monitor)
logger.debug("Initiating launcher keyboard navigation with Alt+F1.")
self.keybinding("launcher/keynav")
+ self._get_controller().key_nav_is_active.wait_for(True)
self.in_keynav_mode = True
def key_nav_cancel(self):
"""End the key navigation."""
logger.debug("Cancelling keyboard navigation mode.")
self._perform_key_nav_exit_binding("launcher/keynav/exit")
+ self._get_controller().key_nav_is_active.wait_for(False)
def key_nav_activate(self):
"""Activates the selected launcher icon. In the current implementation
this also exits key navigation"""
logger.debug("Ending keyboard navigation mode, activating icon.")
self._perform_key_nav_exit_binding("launcher/keynav/activate")
+ self._get_controller().key_nav_is_active.wait_for(False)
def key_nav_next(self):
"""Moves the launcher keynav focus to the next launcher icon"""
logger.debug("Selecting next item in keyboard navigation mode.")
+ old_selection = self._get_controller().key_nav_selection
self._perform_key_nav_binding("launcher/keynav/next")
+ self._get_controller().key_nav_selection.wait_for(NotEquals(old_selection))
def key_nav_prev(self):
"""Moves the launcher keynav focus to the previous launcher icon"""
logger.debug("Selecting previous item in keyboard navigation mode.")
+ old_selection = self._get_controller().key_nav_selection
self._perform_key_nav_binding("launcher/keynav/prev")
+ self._get_controller().key_nav_selection.wait_for(NotEquals(old_selection))
def key_nav_enter_quicklist(self):
logger.debug("Opening quicklist for currently selected icon.")
self._perform_key_nav_binding("launcher/keynav/open-quicklist")
+ self.quicklist_open.wait_for(True)
def key_nav_exit_quicklist(self):
logger.debug("Closing quicklist for currently selected icon.")
self._perform_key_nav_binding("launcher/keynav/close-quicklist")
+ self.quicklist_open.wait_for(False)
def switcher_start(self):
"""Start the super+Tab switcher on this launcher."""
self._screen.move_mouse_to_monitor(self.monitor)
logger.debug("Starting Super+Tab switcher.")
self.keybinding_hold_part_then_tap("launcher/switcher")
+ self._get_controller().key_nav_is_active.wait_for(True)
self.in_switcher_mode = True
def switcher_cancel(self):
"""End the super+tab swithcer."""
logger.debug("Cancelling keyboard navigation mode.")
self._perform_switcher_exit_binding("launcher/switcher/exit")
+ self._get_controller().key_nav_is_active.wait_for(False)
def switcher_activate(self):
"""Activates the selected launcher icon. In the current implementation
this also exits the switcher"""
logger.debug("Ending keyboard navigation mode.")
self._perform_switcher_exit_binding("launcher/switcher")
+ self._get_controller().key_nav_is_active.wait_for(False)
def switcher_next(self):
logger.debug("Selecting next item in keyboard navigation mode.")
+ old_selection = self._get_controller().key_nav_selection
self._perform_switcher_binding("launcher/switcher/next")
+ self._get_controller().key_nav_selection.wait_for(NotEquals(old_selection))
def switcher_prev(self):
logger.debug("Selecting previous item in keyboard navigation mode.")
+ old_selection = self._get_controller().key_nav_selection
self._perform_switcher_binding("launcher/switcher/prev")
+ self._get_controller().key_nav_selection.wait_for(NotEquals(old_selection))
def switcher_up(self):
logger.debug("Selecting next item in keyboard navigation mode.")
+ old_selection = self._get_controller().key_nav_selection
self._perform_switcher_binding("launcher/switcher/up")
+ self._get_controller().key_nav_selection.wait_for(NotEquals(old_selection))
def switcher_down(self):
logger.debug("Selecting previous item in keyboard navigation mode.")
+ old_selection = self._get_controller().key_nav_selection
self._perform_switcher_binding("launcher/switcher/down")
+ self._get_controller().key_nav_selection.wait_for(NotEquals(old_selection))
def click_launcher_icon(self, icon, button=1):
"""Move the mouse over the launcher icon, and click it.
@@ -255,15 +280,6 @@ class Launcher(UnityIntrospectionObject, KeybindingsHelper):
pin_item = quicklist.get_quicklist_item_by_text('Unlock from Launcher')
quicklist.click_item(pin_item)
- def is_quicklist_open(self):
- return self.quicklist_open
-
- def is_showing(self):
- return not self.hidden
-
- def are_shortcuts_showing(self):
- return self.shortcuts_shown
-
@property
def geometry(self):
"""Returns a tuple of (x,y,w,h) for the current launcher."""
diff --git a/tests/autopilot/autopilot/emulators/unity/switcher.py b/tests/autopilot/autopilot/emulators/unity/switcher.py
index cc321c6a6..42f4a855e 100644
--- a/tests/autopilot/autopilot/emulators/unity/switcher.py
+++ b/tests/autopilot/autopilot/emulators/unity/switcher.py
@@ -157,6 +157,9 @@ class Switcher(KeybindingsHelper):
def get_is_visible(self):
return bool(self.__get_controller()['visible'])
+ def get_monitor(self):
+ return int(self.__get_controller()['monitor'])
+
def get_is_in_details_mode(self):
"""Return True if the SwitcherView is in details mode."""
return bool(self.__get_model()['detail-selection'])
diff --git a/tests/autopilot/autopilot/tests/__init__.py b/tests/autopilot/autopilot/tests/__init__.py
index 2b9c5080e..b158e3ed6 100644
--- a/tests/autopilot/autopilot/tests/__init__.py
+++ b/tests/autopilot/autopilot/tests/__init__.py
@@ -335,3 +335,15 @@ class AutopilotTestCase(VideoCapturedTestCase, KeybindingsHelper):
controllers = PanelController.get_all_instances()
self.assertThat(len(controllers), Equals(1))
return controllers[0]
+
+ def assertVisibleWindowStack(self, stack_start):
+ """Check that the visible window stack starts with the windows passed in.
+
+ The start_stack is an iterable of BamfWindow objects.
+ Minimised windows are skipped.
+
+ """
+ stack = [win for win in self.bamf.get_open_windows() if not win.is_hidden]
+ for pos, win in enumerate(stack_start):
+ self.assertThat(stack[pos].x_id, Equals(win.x_id),
+ "%r at %d does not equal %r" % (stack[pos], pos, win))
diff --git a/tests/autopilot/autopilot/tests/test_dash.py b/tests/autopilot/autopilot/tests/test_dash.py
index 678e3f440..09ed15dc2 100644
--- a/tests/autopilot/autopilot/tests/test_dash.py
+++ b/tests/autopilot/autopilot/tests/test_dash.py
@@ -178,6 +178,26 @@ class DashKeyNavTests(DashTestCase):
# Make sure that the category is highlighted.
self.assertTrue(category.header_is_highlighted)
+ def test_maintain_highlight(self):
+ # Get the geometry of that category header.
+ self.skipTest('Not implemented at all. Broken out of another test but not reworked')
+ mouse = Mouse()
+
+ x = category.header_x
+ y = category.header_y
+ w = category.header_width
+ h = category.header_height
+
+ # Move the mouse close the view, and press down.
+ mouse.move(x + w + 10,
+ y + h / 2,
+ True)
+ sleep(1)
+ self.keyboard.press_and_release("Down")
+ lens = self.dash.get_current_lens()
+ category = lens.get_focused_category()
+ self.assertEqual(category, None)
+
def test_control_tab_lens_cycle(self):
"""This test makes sure that Ctrl+Tab cycles lenses."""
self.dash.ensure_visible()
@@ -403,6 +423,7 @@ class DashLensResultsTests(DashTestCase):
activate_filter(True)
self.addCleanup(activate_filter)
+ sleep(1)
results_category = lens.get_category_by_name("Installed")
results = results_category.get_results()
self.assertIsNot(results, old_results)
@@ -448,3 +469,42 @@ class DashLensBarTests(DashTestCase):
app_icon.y + (app_icon.height / 2))
self.mouse.click()
self.assertThat(self.lensbar.active_lens, Eventually(Equals('applications.lens')))
+
+
+class DashBorderTests(DashTestCase):
+ """Tests that the dash border works well.
+ """
+ def setUp(self):
+ super(DashBorderTests, self).setUp()
+ self.dash.ensure_visible()
+
+ def test_click_right_border(self):
+ """Clicking on the right dash border should do nothing,
+ *NOT* close the dash.
+ """
+ if (self.dash.view.form_factor != "desktop"):
+ self.skip("Not in desktop form-factor.")
+
+ x = self.dash.view.x + self.dash.view.width + self.dash.view.right_border_width / 2;
+ y = self.dash.view.y + self.dash.view.height / 2;
+
+ self.mouse.move(x, y)
+ self.mouse.click()
+
+ self.assertThat(self.dash.visible, Eventually(Equals(True)))
+
+ def test_click_bottom_border(self):
+ """Clicking on the bottom dash border should do nothing,
+ *NOT* close the dash.
+ """
+ if (self.dash.view.form_factor != "desktop"):
+ self.skip("Not in desktop form-factor.")
+
+ x = self.dash.view.x + self.dash.view.width / 2;
+ y = self.dash.view.y + self.dash.view.height + self.dash.view.bottom_border_height / 2;
+
+ self.mouse.move(x, y)
+ self.mouse.click()
+
+ self.assertThat(self.dash.visible, Eventually(Equals(True)))
+
diff --git a/tests/autopilot/autopilot/tests/test_hud.py b/tests/autopilot/autopilot/tests/test_hud.py
index afe06da66..99aae979e 100644
--- a/tests/autopilot/autopilot/tests/test_hud.py
+++ b/tests/autopilot/autopilot/tests/test_hud.py
@@ -7,13 +7,21 @@
# under the terms of the GNU General Public License version 3, as published
# by the Free Software Foundation.
-from testtools.matchers import Equals, NotEquals, LessThan, GreaterThan
+from os import remove
+from testtools.matchers import (
+ Equals,
+ EndsWith,
+ GreaterThan,
+ LessThan,
+ NotEquals,
+ raises,
+ )
from time import sleep
-from autopilot.emulators.X11 import ScreenGeometry
from autopilot.emulators.unity.icons import HudLauncherIcon
+from autopilot.emulators.X11 import ScreenGeometry
from autopilot.tests import AutopilotTestCase, multiply_scenarios
-from os import remove, path
+
def _make_monitor_scenarios():
@@ -45,14 +53,6 @@ class HudTestsBase(AutopilotTestCase):
num_active += 1
return num_active
- def reveal_hud(self):
- self.hud.toggle_reveal()
- for counter in range(10):
- sleep(1)
- if self.hud.visible:
- break
- self.assertTrue(self.hud.visible, "HUD did not appear.")
-
class HudBehaviorTests(HudTestsBase):
@@ -63,60 +63,64 @@ class HudBehaviorTests(HudTestsBase):
self.screen_geo.move_mouse_to_monitor(self.hud_monitor)
def test_no_initial_values(self):
- self.reveal_hud()
+ self.hud.ensure_visible()
self.assertThat(self.hud.num_buttons, Equals(0))
self.assertThat(self.hud.selected_button, Equals(0))
def test_check_a_values(self):
- self.reveal_hud()
+ self.hud.ensure_visible()
self.keyboard.type('a')
- # Give the HUD a second to get values.
- sleep(1)
- self.assertThat(self.hud.num_buttons, Equals(5))
- self.assertThat(self.hud.selected_button, Equals(1))
+ self.hud.search_string.wait_for('a')
+ self.hud.num_buttons.wait_for(5)
+ self.hud.selected_button.wait_for(1)
def test_up_down_arrows(self):
- self.reveal_hud()
+ self.hud.ensure_visible()
self.keyboard.type('a')
- # Give the HUD a second to get values.
- sleep(1)
+ self.hud.search_string.wait_for('a')
self.keyboard.press_and_release('Down')
- self.assertThat(self.hud.selected_button, Equals(2))
+ self.hud.selected_button.wait_for(2)
self.keyboard.press_and_release('Down')
- self.assertThat(self.hud.selected_button, Equals(3))
+ self.hud.selected_button.wait_for(3)
self.keyboard.press_and_release('Down')
- self.assertThat(self.hud.selected_button, Equals(4))
+ self.hud.selected_button.wait_for(4)
self.keyboard.press_and_release('Down')
- self.assertThat(self.hud.selected_button, Equals(5))
+ self.hud.selected_button.wait_for(5)
# Down again stays on 5.
self.keyboard.press_and_release('Down')
- self.assertThat(self.hud.selected_button, Equals(5))
+ self.hud.selected_button.wait_for(5)
self.keyboard.press_and_release('Up')
- self.assertThat(self.hud.selected_button, Equals(4))
+ self.hud.selected_button.wait_for(4)
self.keyboard.press_and_release('Up')
- self.assertThat(self.hud.selected_button, Equals(3))
+ self.hud.selected_button.wait_for(3)
self.keyboard.press_and_release('Up')
- self.assertThat(self.hud.selected_button, Equals(2))
+ self.hud.selected_button.wait_for(2)
self.keyboard.press_and_release('Up')
- self.assertThat(self.hud.selected_button, Equals(1))
+ self.hud.selected_button.wait_for(1)
# Up again stays on 1.
self.keyboard.press_and_release('Up')
- self.assertThat(self.hud.selected_button, Equals(1))
+ self.hud.selected_button.wait_for(1)
def test_no_reset_selected_button(self):
- self.reveal_hud()
+ """Hud must not change selected button when results update over time."""
+ # TODO - this test doesn't test anything. Onmy system the results never update.
+ # ideally we'd send artificial results to the hud from the test.
+ self.hud.ensure_visible()
self.keyboard.type('is')
- sleep(1)
+ self.hud.search_string.wait_for('is')
self.keyboard.press_and_release('Down')
- self.assertThat(self.hud.selected_button, Equals(2))
- # long sleep to let the service send updated results
+ self.hud.selected_button.wait_for(2)
+ # long sleep to let the service send updated results
sleep(10)
self.assertThat(self.hud.selected_button, Equals(2))
def test_slow_tap_not_reveal_hud(self):
- self.hud.toggle_reveal(tap_delay=0.3)
- sleep(1)
- self.assertFalse(self.hud.visible)
+ """A slow tap must not reveal the HUD."""
+ # This raises AssertionError since toggle_hud does a wait_for to check
+ # that the hud opened or closed. Since it won't open or close when the
+ # tap delay is too long, we expect that in our test:
+ fn = lambda: self.hud.toggle_reveal(tap_delay=0.3)
+ self.assertThat(fn, raises(AssertionError))
def test_alt_f4_doesnt_show_hud(self):
self.start_app('Calculator')
@@ -127,71 +131,57 @@ class HudBehaviorTests(HudTestsBase):
self.assertFalse(self.hud.visible)
def test_reveal_hud_with_no_apps(self):
- """Hud must show even with no visible applications."""
+ """Hud must show even with no visible applications.
+
+ This used to cause unity to crash (hence the lack of assertion in this test).
+
+ """
self.keybinding("window/show_desktop")
self.addCleanup(self.keybinding, "window/show_desktop")
sleep(1)
- self.hud.toggle_reveal()
- sleep(1)
- self.assertTrue(self.hud.visible)
-
- self.hud.toggle_reveal()
- sleep(1)
- self.assertFalse(self.hud.visible)
+ self.hud.ensure_visible()
+ self.hud.ensure_hidden()
def test_restore_focus(self):
"""Ensures that once the hud is dismissed, the same application
- that was focused before hud invocation is refocused
+ that was focused before hud invocation is refocused.
"""
calc = self.start_app("Calculator")
# first ensure that the application has started and is focused
self.assertEqual(calc.is_active, True)
- self.hud.toggle_reveal()
- sleep(1)
- self.hud.toggle_reveal()
- sleep(1)
+ self.hud.ensure_visible()
+ self.hud.ensure_hidden()
# again ensure that the application we started is focused
self.assertEqual(calc.is_active, True)
- #test return
- self.hud.toggle_reveal()
- sleep(1)
-
- #test return
- self.hud.toggle_reveal()
- sleep(1)
+ self.hud.ensure_visible()
+ self.hud.ensure_hidden()
+ # why do we do this: ???
self.keyboard.press_and_release('Return')
sleep(1)
self.assertEqual(calc.is_active, True)
def test_gedit_undo(self):
- """Test undo in gedit"""
- """Type "0 1" into gedit."""
- """Activate the Hud, type "undo" then enter."""
- """Save the file in gedit and close gedit."""
- """Read the saved file. The content should be "0 "."""
+ """Test that the 'undo' action in the Hud works with GEdit."""
self.addCleanup(remove, '/tmp/autopilot_gedit_undo_test_temp_file.txt')
self.start_app('Text Editor', files=['/tmp/autopilot_gedit_undo_test_temp_file.txt'], locale='C')
- sleep(1)
self.keyboard.type("0")
self.keyboard.type(" ")
self.keyboard.type("1")
- self.hud.toggle_reveal()
- sleep(1)
+ self.hud.ensure_visible()
self.keyboard.type("undo")
- sleep(1)
+ self.hud.search_string.wait_for("undo")
self.keyboard.press_and_release('Return')
- sleep(.5)
-
+ self.hud.visible.wait_for(False)
self.keyboard.press_and_release("Ctrl+s")
sleep(1)
@@ -199,56 +189,51 @@ class HudBehaviorTests(HudTestsBase):
self.assertEqual("0 ", contents)
def test_disabled_alt_f1(self):
- """This test shows that Alt+F1 mode is disabled for the hud."""
- self.hud.toggle_reveal()
+ """Pressing Alt+F1 when the HUD is open must not start keyboard navigation mode."""
+ self.hud.ensure_visible()
launcher = self.launcher.get_launcher_for_monitor(0)
launcher.key_nav_start()
+ # we need a sleep here to ensure that the launcher has had time to start
+ # keynav before we check the key_nav_is_active attribute.
+ #
+ # Ideally we'd do 'key_nav_is_active.wait_for(True)' and expect a test
+ # failure.
+ sleep(1)
self.assertThat(self.launcher.key_nav_is_active, Equals(False))
def test_hud_to_dash_disabled_alt_f1(self):
"""When switching from the hud to the dash alt+f1 is disabled."""
- self.hud.toggle_reveal()
- sleep(1)
-
+ self.hud.ensure_visible()
self.dash.ensure_visible()
+ self.addCleanup(self.dash.ensure_hidden)
launcher = self.launcher.get_launcher_for_monitor(0)
launcher.key_nav_start()
-
- self.dash.ensure_hidden()
self.assertThat(self.launcher.key_nav_is_active, Equals(False))
def test_hud_to_dash_has_key_focus(self):
"""When switching from the hud to the dash you don't lose key focus."""
self.hud.ensure_visible()
- sleep(1)
-
self.dash.ensure_visible()
self.addCleanup(self.dash.ensure_hidden)
-
self.keyboard.type('focus1')
-
- self.assertEqual(self.dash.search_string, 'focus1')
+ self.dash.search_string.wait_for('focus1')
def test_dash_to_hud_has_key_focus(self):
"""When switching from the dash to the hud you don't lose key focus."""
self.dash.ensure_visible()
self.hud.ensure_visible()
- sleep(1)
-
self.keyboard.type('focus2')
-
- self.assertEqual(self.hud.search_string, 'focus2')
+ self.hud.search_string.wait_for('focus2')
def test_hud_closes_on_workspace_switch(self):
"""This test shows that when you switch to another workspace the hud closes."""
- self.hud.toggle_reveal()
- sleep(1)
-
+ self.hud.ensure_visible()
self.workspace.switch_to(1)
self.workspace.switch_to(2)
+ self.hud.visible.wait_for(False)
class HudLauncherInteractionsTests(HudTestsBase):
@@ -287,9 +272,7 @@ class HudLauncherInteractionsTests(HudTestsBase):
# reveal and hide hud several times over:
for i in range(3):
self.hud.ensure_visible()
- sleep(0.5)
self.hud.ensure_hidden()
- sleep(0.5)
# click application icons for running apps in the launcher:
icon = self.launcher.model.get_icon_by_desktop_id("gucharmap.desktop")
@@ -300,17 +283,13 @@ class HudLauncherInteractionsTests(HudTestsBase):
self.assertLessEqual(num_active, 1, "More than one launcher icon active after test has run!")
def test_hud_does_not_change_launcher_status(self):
- """Tests if the HUD reveal keeps the launcher in the status it was"""
+ """Opening the HUD must not change the launcher visibility."""
launcher = self.launcher.get_launcher_for_monitor(self.hud_monitor)
- launcher_shows_pre = launcher.is_showing()
- sleep(.25)
-
- self.reveal_hud()
- sleep(1)
-
- launcher_shows_post = launcher.is_showing()
+ launcher_shows_pre = launcher.is_showing
+ self.hud.ensure_visible()
+ launcher_shows_post = launcher.is_showing
self.assertThat(launcher_shows_pre, Equals(launcher_shows_post))
@@ -328,26 +307,26 @@ class HudLockedLauncherInteractionsTests(HudTestsBase):
sleep(0.5)
def test_hud_launcher_icon_hides_bfb(self):
- """Tests that the BFB icon is hidden when the HUD launcher icon is shown"""
+ """BFB icon must be hidden when the HUD launcher icon is shown."""
hud_icon = self.hud.get_launcher_icon()
bfb_icon = self.launcher.model.get_bfb_icon()
- self.assertTrue(bfb_icon.is_visible_on_monitor(self.hud_monitor))
- self.assertFalse(hud_icon.is_visible_on_monitor(self.hud_monitor))
- sleep(.25)
+ bfb_icon.visible.wait_for(True)
+ self.assertTrue(bfb_icon.is_on_monitor(self.hud_monitor))
+ hud_icon.visible.wait_for(False)
- self.reveal_hud()
- sleep(.5)
+ self.hud.ensure_visible()
- self.assertTrue(hud_icon.is_visible_on_monitor(self.hud_monitor))
- self.assertFalse(bfb_icon.is_visible_on_monitor(self.hud_monitor))
+ hud_icon.visible.wait_for(True)
+ self.assertTrue(hud_icon.is_on_monitor(self.hud_monitor))
+ # For some reason the BFB icon is always visible :-/
+ #bfb_icon.visible.wait_for(False)
def test_hud_desaturates_launcher_icons(self):
- """Tests that the launcher icons are desaturates when HUD is open"""
+ """Launcher icons must desaturate when the HUD is opened."""
- self.reveal_hud()
- sleep(.5)
+ self.hud.ensure_visible()
for icon in self.launcher.model.get_launcher_icons_for_monitor(self.hud_monitor):
if isinstance(icon, HudLauncherIcon):
@@ -379,14 +358,14 @@ class HudVisualTests(HudTestsBase):
self.assertFalse(self.hud.visible)
def test_hud_is_on_right_monitor(self):
- """Tests if the hud is shown and fits the monitor where it should be"""
- self.reveal_hud()
- self.assertThat(self.hud_monitor, Equals(self.hud.monitor))
+ """HUD must be drawn on the monitor where the mouse is."""
+ self.hud.ensure_visible()
+ self.hud.monitor.wait_for(self.hud_monitor)
self.assertTrue(self.screen_geo.is_rect_on_monitor(self.hud.monitor, self.hud.geometry))
def test_hud_geometries(self):
- """Tests the HUD geometries for the given monitor and status"""
- self.reveal_hud()
+ """Tests the HUD geometries for the given monitor and status."""
+ self.hud.ensure_visible()
monitor_geo = self.screen_geo.get_monitor_geometry(self.hud_monitor)
monitor_x = monitor_geo[0]
monitor_w = monitor_geo[2]
@@ -402,76 +381,68 @@ class HudVisualTests(HudTestsBase):
self.assertThat(hud_w, Equals(monitor_w))
def test_hud_is_locked_to_launcher(self):
- """Tests if the HUD is locked to launcher as we expect or not"""
- self.reveal_hud()
- sleep(.25)
-
- self.assertThat(self.hud.is_locked_launcher, Equals(self.hud_locked))
+ """Tests if the HUD is locked to launcher as we expect or not."""
+ self.hud.ensure_visible()
+ self.hud.is_locked_launcher.wait_for(self.hud_locked)
def test_hud_icon_is_shown(self):
- """Tests that the correct HUD icon is shown"""
- self.reveal_hud()
- sleep(.5)
-
+ """Tests that the correct HUD icon is shown."""
+ self.hud.ensure_visible()
hud_launcher_icon = self.hud.get_launcher_icon()
hud_embedded_icon = self.hud.get_embedded_icon()
if self.hud.is_locked_launcher:
- self.assertTrue(hud_launcher_icon.is_visible_on_monitor(self.hud_monitor))
+ hud_launcher_icon.visible.wait_for(True)
+ self.assertTrue(hud_launcher_icon.is_on_monitor(self.hud_monitor))
self.assertTrue(hud_launcher_icon.active)
self.assertThat(hud_launcher_icon.monitor, Equals(self.hud_monitor))
self.assertFalse(hud_launcher_icon.desaturated)
self.assertThat(hud_embedded_icon, Equals(None))
else:
- self.assertFalse(hud_launcher_icon.is_visible_on_monitor(self.hud_monitor))
+ hud_launcher_icon.visible.wait_for(False)
self.assertFalse(hud_launcher_icon.active)
+ # the embedded icon has no visible property.
self.assertThat(hud_embedded_icon, NotEquals(None))
def test_hud_icon_shows_the_focused_application_emblem(self):
- """Tests that the correct HUD icon is shown"""
+ """Tests that the correct HUD icon is shown."""
self.close_all_app("Calculator")
calc = self.start_app("Calculator")
self.assertTrue(calc.is_active)
+ self.hud.ensure_visible()
- self.reveal_hud()
- sleep(.5)
-
- self.assertThat(self.hud.icon.icon_name, Equals(calc.icon))
+ self.hud.icon.icon_name.wait_for(calc.icon)
def test_hud_icon_shows_the_ubuntu_emblem_on_empty_desktop(self):
+ """When in 'show desktop' mode the hud icon must be the BFB icon."""
self.keybinding("window/show_desktop")
self.addCleanup(self.keybinding, "window/show_desktop")
sleep(1)
+ self.hud.ensure_visible()
- self.reveal_hud()
- sleep(.5)
-
- self.assertThat(path.basename(self.hud.icon.icon_name), Equals("launcher_bfb.png"))
+ self.hud.icon.icon_name.wait_for(EndsWith("launcher_bfb.png"))
def test_switch_dash_hud_does_not_break_the_focused_application_emblem(self):
- """Tests that the correct HUD icon is shown when switching from Dash to HUD"""
+ """Switching from Dash to HUD must still show the correct HUD icon."""
self.close_all_app("Calculator")
calc = self.start_app("Calculator")
self.assertTrue(calc.is_active)
self.dash.ensure_visible()
- self.reveal_hud()
- sleep(.5)
+ self.hud.ensure_visible()
- self.assertThat(self.hud.icon.icon_name, Equals(calc.icon))
+ self.hud.icon.icon_name.wait_for(calc.icon)
def test_switch_hud_dash_does_not_break_the_focused_application_emblem(self):
- """Tests that the correct HUD icon is shown when switching from HUD to Dash and back"""
+ """Switching from HUD to Dash and back must still show the correct HUD icon."""
self.close_all_app("Calculator")
calc = self.start_app("Calculator")
self.assertTrue(calc.is_active)
- self.reveal_hud()
+ self.hud.ensure_visible()
self.dash.ensure_visible()
- self.reveal_hud()
- sleep(.5)
-
- self.assertThat(self.hud.icon.icon_name, Equals(calc.icon))
+ self.hud.ensure_visible()
+ self.hud.icon.icon_name.wait_for(calc.icon)
class HudAlternativeKeybindingTests(HudTestsBase):
@@ -481,19 +452,11 @@ class HudAlternativeKeybindingTests(HudTestsBase):
self.set_unity_option("show_hud", "<Super>h")
# Don't use reveal_hud, but be explicit in the keybindings.
self.keyboard.press_and_release("Super+h")
- for counter in range(10):
- sleep(1)
- if self.hud.visible:
- break
- self.assertTrue(self.hud.visible, "HUD did not appear.")
+ self.hud.visible.wait_for(True)
def test_ctrl_alt_h(self):
"""Test hud reveal on <Contrl><Alt>h."""
self.set_unity_option("show_hud", "<Control><Alt>h")
# Don't use reveal_hud, but be explicit in the keybindings.
self.keyboard.press_and_release("Ctrl+Alt+h")
- for counter in range(10):
- sleep(1)
- if self.hud.visible:
- break
- self.assertTrue(self.hud.visible, "HUD did not appear.")
+ self.hud.visible.wait_for(True)
diff --git a/tests/autopilot/autopilot/tests/test_ibus.py b/tests/autopilot/autopilot/tests/test_ibus.py
index 86dd839e7..66fad2d43 100644
--- a/tests/autopilot/autopilot/tests/test_ibus.py
+++ b/tests/autopilot/autopilot/tests/test_ibus.py
@@ -8,6 +8,7 @@
"""Tests to ensure unity is compatible with ibus input method."""
+from testtools.matchers import NotEquals
from time import sleep
from autopilot.emulators.ibus import (
@@ -44,6 +45,34 @@ class IBusTests(AutopilotTestCase):
# it would be nice to be able to tell if it's currently active or not.
self.keyboard.press_and_release('Ctrl+Space')
+ def do_dash_test_with_engine(self, engine_name):
+ self.activate_input_engine_or_skip(engine_name)
+ self.dash.ensure_visible()
+ self.addCleanup(self.dash.ensure_hidden)
+ sleep(0.5)
+ self.activate_ibus()
+ self.addCleanup(self.deactivate_ibus)
+ sleep(0.5)
+ self.keyboard.type(self.input)
+ commit_key = getattr(self, 'commit_key', None)
+ if commit_key:
+ self.keyboard.press_and_release(commit_key)
+ self.dash.search_string.wait_for(self.result)
+
+ def do_hud_test_with_engine(self, engine_name):
+ self.activate_input_engine_or_skip(engine_name)
+ self.hud.ensure_visible()
+ self.addCleanup(self.hud.ensure_hidden)
+ sleep(0.5)
+ self.activate_ibus()
+ self.addCleanup(self.deactivate_ibus)
+ sleep(0.5)
+ self.keyboard.type(self.input)
+ commit_key = getattr(self, 'commit_key', None)
+ if commit_key:
+ self.keyboard.press_and_release(commit_key)
+ self.hud.search_string.wait_for(self.result)
+
class IBusTestsPinyin(IBusTests):
"""Tests for the Pinyin(Chinese) input engine."""
@@ -57,30 +86,10 @@ class IBusTestsPinyin(IBusTests):
]
def test_simple_input_dash(self):
- self.activate_input_engine_or_skip("pinyin")
- self.dash.ensure_visible()
- sleep(0.5)
- self.activate_ibus()
- sleep(0.5)
- self.keyboard.type(self.input)
- dash_search_string = self.dash.search_string
- self.deactivate_ibus()
- self.dash.ensure_hidden()
-
- self.assertEqual(self.result, dash_search_string)
+ self.do_dash_test_with_engine("pinyin")
def test_simple_input_hud(self):
- self.activate_input_engine_or_skip("pinyin")
- self.hud.ensure_visible()
- sleep(0.5)
- self.activate_ibus()
- sleep(0.5)
- self.keyboard.type(self.input)
- hud_search_string = self.hud.search_string
- self.deactivate_ibus()
- self.hud.ensure_hidden()
-
- self.assertEqual(self.result, hud_search_string)
+ self.do_hud_test_with_engine("pinyin")
class IBusTestsHangul(IBusTests):
@@ -93,30 +102,10 @@ class IBusTestsHangul(IBusTests):
]
def test_simple_input_dash(self):
- self.activate_input_engine_or_skip("hangul")
- self.dash.ensure_visible()
- sleep(0.5)
- self.activate_ibus()
- sleep(0.5)
- self.keyboard.type(self.input)
- dash_search_string = self.dash.search_string
- self.deactivate_ibus()
- self.dash.ensure_hidden()
-
- self.assertEqual(self.result, dash_search_string)
+ self.do_dash_test_with_engine("hangul")
def test_simple_input_hud(self):
- self.activate_input_engine_or_skip("hangul")
- self.hud.ensure_visible()
- sleep(0.5)
- self.activate_ibus()
- sleep(0.5)
- self.keyboard.type(self.input)
- hud_search_string = self.hud.search_string
- self.deactivate_ibus()
- self.hud.ensure_hidden()
-
- self.assertEqual(self.result, hud_search_string)
+ self.do_hud_test_with_engine("hangul")
class IBusTestsAnthy(IBusTests):
@@ -135,32 +124,10 @@ class IBusTestsAnthy(IBusTests):
)
def test_simple_input_dash(self):
- self.activate_input_engine_or_skip("anthy")
- self.dash.ensure_visible()
- sleep(0.5)
- self.activate_ibus()
- sleep(0.5)
- self.keyboard.type(self.input)
- self.keyboard.press_and_release(self.commit_key)
- dash_search_string = self.dash.search_string
- self.deactivate_ibus()
- self.dash.ensure_hidden()
-
- self.assertEqual(self.result, dash_search_string)
+ self.do_dash_test_with_engine("anthy")
def test_simple_input_hud(self):
- self.activate_input_engine_or_skip("anthy")
- self.hud.ensure_visible()
- sleep(0.5)
- self.activate_ibus()
- sleep(0.5)
- self.keyboard.type(self.input)
- self.keyboard.press_and_release(self.commit_key)
- hud_search_string = self.hud.search_string
- self.deactivate_ibus()
- self.hud.ensure_hidden()
-
- self.assertEqual(self.result, hud_search_string)
+ self.do_hud_test_with_engine("anthy")
class IBusTestsPinyinIgnore(IBusTests):
@@ -169,21 +136,20 @@ class IBusTestsPinyinIgnore(IBusTests):
def test_ignore_key_events_on_dash(self):
self.activate_input_engine_or_skip("pinyin")
self.dash.ensure_visible()
+ self.addCleanup(self.dash.ensure_hidden)
sleep(0.5)
self.activate_ibus()
+ self.addCleanup(self.deactivate_ibus)
sleep(0.5)
self.keyboard.type("cipan")
self.keyboard.press_and_release("Tab")
self.keyboard.type(" ")
- dash_search_string = self.dash.get_searchbar().search_string
- self.deactivate_ibus()
- self.dash.ensure_hidden()
-
- self.assertNotEqual(" ", dash_search_string)
+ self.dash.search_string.wait_for(NotEquals(" "))
def test_ignore_key_events_on_hud(self):
self.activate_input_engine_or_skip("pinyin")
self.hud.ensure_visible()
+ self.addCleanup(self.hud.ensure_hidden)
sleep(0.5)
self.keyboard.type("a")
self.activate_ibus()
@@ -192,9 +158,7 @@ class IBusTestsPinyinIgnore(IBusTests):
old_selected = self.hud.selected_button
self.keyboard.press_and_release("Down")
new_selected = self.hud.selected_button
- self.deactivate_ibus()
- self.hud.ensure_hidden()
-
+
self.assertEqual(old_selected, new_selected)
@@ -204,30 +168,30 @@ class IBusTestsAnthyIgnore(IBusTests):
def test_ignore_key_events_on_dash(self):
self.activate_input_engine_or_skip("anthy")
self.dash.ensure_visible()
+ self.addCleanup(self.dash.ensure_hidden)
sleep(0.5)
self.activate_ibus()
+ self.addCleanup(self.deactivate_ibus)
sleep(0.5)
self.keyboard.type("shisutemu ")
self.keyboard.press_and_release("Tab")
self.keyboard.press_and_release("Ctrl+j")
- dash_search_string = self.dash.get_searchbar().search_string
- self.deactivate_ibus()
- self.dash.ensure_hidden()
+ dash_search_string = self.dash.search_string
self.assertNotEqual("", dash_search_string)
def test_ignore_key_events_on_hud(self):
self.activate_input_engine_or_skip("anthy")
self.hud.ensure_visible()
+ self.addCleanup(self.hud.ensure_hidden)
sleep(0.5)
self.keyboard.type("a")
self.activate_ibus()
+ self.addCleanup(self.deactivate_ibus)
sleep(0.5)
self.keyboard.type("hiduke")
old_selected = self.hud.selected_button
self.keyboard.press_and_release("Down")
new_selected = self.hud.selected_button
- self.deactivate_ibus()
- self.hud.ensure_hidden()
self.assertEqual(old_selected, new_selected)
diff --git a/tests/autopilot/autopilot/tests/test_launcher.py b/tests/autopilot/autopilot/tests/test_launcher.py
index 06b3f5b33..10cf3480e 100644
--- a/tests/autopilot/autopilot/tests/test_launcher.py
+++ b/tests/autopilot/autopilot/tests/test_launcher.py
@@ -11,9 +11,10 @@ import logging
from testtools.matchers import Equals, NotEquals, LessThan, GreaterThan
from time import sleep
-from autopilot.tests import AutopilotTestCase, multiply_scenarios
-from autopilot.emulators.X11 import ScreenGeometry
from autopilot.emulators.unity.icons import BFBLauncherIcon
+from autopilot.emulators.X11 import ScreenGeometry
+from autopilot.matchers import Eventually
+from autopilot.tests import AutopilotTestCase, multiply_scenarios
logger = logging.getLogger(__name__)
@@ -33,6 +34,7 @@ def _make_scenarios():
('launcher on all', {'only_primary': False})]
return multiply_scenarios(monitor_scenarios, launcher_mode_scenarios)
+
class LauncherTestCase(AutopilotTestCase):
"""A base class for all launcher tests that uses scenarios to run on
each launcher (for multi-monitor setups).
@@ -62,9 +64,10 @@ class LauncherTestCase(AutopilotTestCase):
"""Get the launcher for the current scenario."""
return self.launcher.get_launcher_for_monitor(self.launcher_monitor)
+
class LauncherSwitcherTests(LauncherTestCase):
""" Tests the functionality of the launcher's switcher capability"""
-
+
def setUp(self):
super(LauncherSwitcherTests, self).setUp()
self.launcher_instance.switcher_start()
@@ -78,10 +81,12 @@ class LauncherSwitcherTests(LauncherTestCase):
def test_launcher_switcher_cancel(self):
"""Test that ending the launcher switcher actually works."""
self.launcher_instance.switcher_cancel()
- self.assertThat(self.launcher.key_nav_is_active, Equals(False))
+ self.assertThat(self.launcher.key_nav_is_active, Eventually(Equals(False)))
def test_launcher_switcher_cancel_resume_focus(self):
"""Test that ending the launcher switcher resume the focus."""
+ # TODO either remove this test from the class or don't initiate the
+ # switcher in setup.
self.close_all_app("Calculator")
calc = self.start_app("Calculator")
self.assertTrue(calc.is_active)
@@ -96,58 +101,55 @@ class LauncherSwitcherTests(LauncherTestCase):
def test_launcher_switcher_starts_at_index_zero(self):
"""Test that starting the Launcher switcher puts the keyboard focus on item 0."""
- self.assertThat(self.launcher.key_nav_is_active, Equals(True))
- self.assertThat(self.launcher.key_nav_is_grabbed, Equals(False))
- self.assertThat(self.launcher.key_nav_selection, Equals(0))
+ self.assertThat(self.launcher.key_nav_is_active, Eventually(Equals(True)))
+ self.assertThat(self.launcher.key_nav_is_grabbed, Eventually(Equals(False)))
+ self.assertThat(self.launcher.key_nav_selection, Eventually(Equals(0)))
def test_launcher_switcher_next(self):
"""Moving to the next launcher item while switcher is activated must work."""
self.launcher_instance.switcher_next()
- sleep(0.5)
- logger.info("After next, keynav selection is %d", self.launcher.key_nav_selection)
# The launcher model has hidden items, so the keynav indexes do not
# increase by 1 each time. This test was failing because the 2nd icon
# had an index of 2, not 1 as expected. The best we can do here is to
# make sure that the index has increased. This opens us to the
# possibility that the launcher really is skipping forward more than one
# icon at a time, but we can't do much about that.
- self.assertThat(self.launcher.key_nav_selection, GreaterThan(0))
+ self.assertThat(self.launcher.key_nav_selection, Eventually(GreaterThan(0)))
def test_launcher_switcher_prev(self):
"""Moving to the previous launcher item while switcher is activated must work."""
self.launcher_instance.switcher_prev()
- self.assertThat(self.launcher.key_nav_selection, NotEquals(0))
+ self.assertThat(self.launcher.key_nav_selection, Eventually(NotEquals(0)))
def test_launcher_switcher_down(self):
"""Pressing the down arrow key while switcher is activated must work."""
self.launcher_instance.switcher_down()
- sleep(.25)
# The launcher model has hidden items, so the keynav indexes do not
# increase by 1 each time. This test was failing because the 2nd icon
# had an index of 2, not 1 as expected. The best we can do here is to
# make sure that the index has increased. This opens us to the
# possibility that the launcher really is skipping forward more than one
# icon at a time, but we can't do much about that.
- self.assertThat(self.launcher.key_nav_selection, GreaterThan(0))
+ self.assertThat(self.launcher.key_nav_selection, Eventually(GreaterThan(0)))
def test_launcher_switcher_up(self):
"""Pressing the up arrow key while switcher is activated must work."""
self.launcher_instance.switcher_up()
- self.assertThat(self.launcher.key_nav_selection, NotEquals(0))
+ self.assertThat(self.launcher.key_nav_selection, Eventually(NotEquals(0)))
def test_launcher_switcher_next_doesnt_show_shortcuts(self):
"""Moving forward in launcher switcher must not show launcher shortcuts."""
self.launcher_instance.switcher_next()
# sleep so that the shortcut timeout could be triggered
sleep(2)
- self.assertThat(self.launcher_instance.are_shortcuts_showing(), Equals(False))
+ self.assertThat(self.launcher_instance.shortcuts_shown, Eventually(Equals(False)))
def test_launcher_switcher_prev_doesnt_show_shortcuts(self):
"""Moving backward in launcher switcher must not show launcher shortcuts."""
self.launcher_instance.switcher_prev()
# sleep so that the shortcut timeout could be triggered
sleep(2)
- self.assertThat(self.launcher_instance.are_shortcuts_showing(), Equals(False))
+ self.assertThat(self.launcher_instance.shortcuts_shown, Eventually(Equals(False)))
def test_launcher_switcher_cycling_forward(self):
"""Launcher Switcher must loop through icons when cycling forwards"""
@@ -156,29 +158,24 @@ class LauncherSwitcherTests(LauncherTestCase):
logger.info("This launcher has %d icons", num_icons)
for icon in range(1, num_icons):
self.launcher_instance.switcher_next()
- sleep(.25)
# FIXME We can't directly check for selection/icon number equalty
# since the launcher model also contains "hidden" icons that aren't
# shown, so the selection index can increment by more than 1.
- self.assertThat(prev_icon, LessThan(self.launcher.key_nav_selection))
+ self.assertThat(self.launcher.key_nav_selection, Eventually(GreaterThan(prev_icon)))
prev_icon = self.launcher.key_nav_selection
- sleep(.5)
self.launcher_instance.switcher_next()
- self.assertThat(self.launcher.key_nav_selection, Equals(0))
+ self.assertThat(self.launcher.key_nav_selection, Eventually(Equals(0)))
def test_launcher_switcher_cycling_backward(self):
"""Launcher Switcher must loop through icons when cycling backwards"""
self.launcher_instance.switcher_prev()
# FIXME We can't directly check for self.launcher.num_launcher_icons - 1
- self.assertThat(self.launcher.key_nav_selection, GreaterThan(1))
+ self.assertThat(self.launcher.key_nav_selection, Eventually(GreaterThan(1)))
def test_launcher_switcher_activate_keep_focus(self):
- """Activating a running launcher icon should focus it"""
+ """Activating a running launcher icon should focus the application."""
calc = self.start_app("Calculator")
- sleep(.5)
-
- self.close_all_app("Mahjongg")
mahjongg = self.start_app("Mahjongg")
self.assertTrue(mahjongg.is_active)
self.assertFalse(calc.is_active)
@@ -210,7 +207,8 @@ class LauncherSwitcherTests(LauncherTestCase):
sleep(.25)
self.keyboard.press_and_release("Escape")
sleep(.25)
- self.assertThat(self.launcher.key_nav_is_active, Equals(False))
+ self.assertThat(self.launcher.key_nav_is_active, Eventually(Equals(False)))
+
class LauncherShortcutTests(LauncherTestCase):
def setUp(self):
@@ -224,36 +222,30 @@ class LauncherShortcutTests(LauncherTestCase):
def test_launcher_keyboard_reveal_shows_shortcut_hints(self):
"""Launcher icons must show shortcut hints after revealing with keyboard."""
- self.assertThat(self.launcher_instance.are_shortcuts_showing(), Equals(True))
+ self.assertThat(self.launcher_instance.shortcuts_shown, Eventually(Equals(True)))
def test_launcher_switcher_keeps_shorcuts(self):
"""Initiating launcher switcher after showing shortcuts must not hide shortcuts"""
- self.addCleanup(self.launcher_instance.switcher_cancel)
self.launcher_instance.switcher_start()
- sleep(.5)
+ self.addCleanup(self.launcher_instance.switcher_cancel)
- self.assertThat(self.launcher.key_nav_is_active, Equals(True))
- self.assertThat(self.launcher_instance.are_shortcuts_showing(), Equals(True))
+ self.assertThat(self.launcher.key_nav_is_active, Eventually(Equals(True)))
+ self.assertThat(self.launcher_instance.shortcuts_shown, Eventually(Equals(True)))
def test_launcher_switcher_next_keeps_shortcuts(self):
"""Launcher switcher next action must keep shortcuts after they've been shown."""
- self.addCleanup(self.launcher_instance.switcher_cancel)
self.launcher_instance.switcher_start()
- sleep(.5)
-
+ self.addCleanup(self.launcher_instance.switcher_cancel)
self.launcher_instance.switcher_next()
- sleep(.5)
- self.assertThat(self.launcher_instance.are_shortcuts_showing(), Equals(True))
+ self.assertThat(self.launcher_instance.shortcuts_shown, Eventually(Equals(True)))
def test_launcher_switcher_prev_keeps_shortcuts(self):
"""Launcher switcher prev action must keep shortcuts after they've been shown."""
- self.addCleanup(self.launcher_instance.switcher_cancel)
self.launcher_instance.switcher_start()
- sleep(.5)
-
+ self.addCleanup(self.launcher_instance.switcher_cancel)
self.launcher_instance.switcher_prev()
- sleep(.5)
- self.assertThat(self.launcher_instance.are_shortcuts_showing(), Equals(True))
+ self.assertThat(self.launcher_instance.shortcuts_shown, Eventually(Equals(True)))
+
class LauncherKeyNavTests(LauncherTestCase):
"""Test the launcher key navigation"""
@@ -268,99 +260,87 @@ class LauncherKeyNavTests(LauncherTestCase):
def test_launcher_keynav_initiate(self):
"""Tests we can initiate keyboard navigation on the launcher."""
- self.assertThat(self.launcher.key_nav_is_active, Equals(True))
- self.assertThat(self.launcher.key_nav_is_grabbed, Equals(True))
+ self.assertThat(self.launcher.key_nav_is_active, Eventually(Equals(True)))
+ self.assertThat(self.launcher.key_nav_is_grabbed, Eventually(Equals(True)))
def test_launcher_keynav_cancel(self):
"""Test that we can exit keynav mode."""
self.launcher_instance.key_nav_cancel()
- self.assertThat(self.launcher.key_nav_is_active, Equals(False))
- self.assertThat(self.launcher.key_nav_is_grabbed, Equals(False))
+ self.assertThat(self.launcher.key_nav_is_active, Eventually(Equals(False)))
+ self.assertThat(self.launcher.key_nav_is_grabbed, Eventually(Equals(False)))
def test_launcher_keynav_cancel_resume_focus(self):
"""Test that ending the launcher keynav resume the focus."""
- self.close_all_app("Calculator")
calc = self.start_app("Calculator")
self.assertTrue(calc.is_active)
self.launcher_instance.key_nav_start()
- sleep(.5)
self.assertFalse(calc.is_active)
self.launcher_instance.key_nav_cancel()
- sleep(.5)
self.assertTrue(calc.is_active)
def test_launcher_keynav_starts_at_index_zero(self):
"""Test keynav mode starts at index 0."""
- self.assertThat(self.launcher.key_nav_selection, Equals(0))
+ self.assertThat(self.launcher.key_nav_selection, Eventually(Equals(0)))
def test_launcher_keynav_forward(self):
"""Must be able to move forwards while in keynav mode."""
self.launcher_instance.key_nav_next()
- sleep(.5)
# The launcher model has hidden items, so the keynav indexes do not
# increase by 1 each time. This test was failing because the 2nd icon
# had an index of 2, not 1 as expected. The best we can do here is to
# make sure that the index has increased. This opens us to the
# possibility that the launcher really is skipping forward more than one
# icon at a time, but we can't do much about that.
- self.assertThat(self.launcher.key_nav_selection, GreaterThan(0))
+ self.assertThat(self.launcher.key_nav_selection, Eventually(GreaterThan(0)))
def test_launcher_keynav_prev_works(self):
"""Must be able to move backwards while in keynav mode."""
self.launcher_instance.key_nav_next()
- sleep(.5)
+ self.assertThat(self.launcher.key_nav_selection, Eventually(GreaterThan(0)))
self.launcher_instance.key_nav_prev()
- self.assertThat(self.launcher.key_nav_selection, Equals(0))
+ self.assertThat(self.launcher.key_nav_selection, Eventually(Equals(0)))
def test_launcher_keynav_cycling_forward(self):
"""Launcher keynav must loop through icons when cycling forwards"""
prev_icon = 0
for icon in range(1, self.launcher.model.num_launcher_icons()):
self.launcher_instance.key_nav_next()
- sleep(.25)
# FIXME We can't directly check for selection/icon number equalty
# since the launcher model also contains "hidden" icons that aren't
# shown, so the selection index can increment by more than 1.
- self.assertThat(prev_icon, LessThan(self.launcher.key_nav_selection))
+ self.assertThat(self.launcher.key_nav_selection, Eventually(GreaterThan(prev_icon)))
prev_icon = self.launcher.key_nav_selection
- sleep(.5)
self.launcher_instance.key_nav_next()
- self.assertThat(self.launcher.key_nav_selection, Equals(0))
+ self.assertThat(self.launcher.key_nav_selection, Eventually(Equals(0)))
def test_launcher_keynav_cycling_backward(self):
"""Launcher keynav must loop through icons when cycling backwards"""
self.launcher_instance.key_nav_prev()
# FIXME We can't directly check for self.launcher.num_launcher_icons - 1
- self.assertThat(self.launcher.key_nav_selection, GreaterThan(1))
-
+ self.assertThat(self.launcher.key_nav_selection, Eventually(GreaterThan(1)))
+
def test_launcher_keynav_can_open_and_close_quicklist(self):
"""Tests that we can open and close a quicklist from keynav mode."""
self.launcher_instance.key_nav_next()
- sleep(.5)
self.launcher_instance.key_nav_enter_quicklist()
- self.assertThat(self.launcher_instance.is_quicklist_open(), Equals(True))
- sleep(.5)
+ self.assertThat(self.launcher_instance.quicklist_open, Eventually(Equals(True)))
self.launcher_instance.key_nav_exit_quicklist()
- self.assertThat(self.launcher_instance.is_quicklist_open(), Equals(False))
- self.assertThat(self.launcher.key_nav_is_active, Equals(True))
- self.assertThat(self.launcher.key_nav_is_grabbed, Equals(True))
+ self.assertThat(self.launcher_instance.quicklist_open, Eventually(Equals(False)))
+ self.assertThat(self.launcher.key_nav_is_active, Eventually(Equals(True)))
+ self.assertThat(self.launcher.key_nav_is_grabbed, Eventually(Equals(True)))
def test_launcher_keynav_mode_toggles(self):
"""Tests that keynav mode toggles with Alt+F1."""
# was initiated in setup.
- self.launcher_instance.key_nav_start()
- sleep(0.25)
- self.assertThat(self.launcher.key_nav_is_active, Equals(False))
+ self.keybinding("launcher/keynav")
+ self.assertThat(self.launcher.key_nav_is_active, Eventually(Equals(False)))
def test_launcher_keynav_activate_keep_focus(self):
"""Activating a running launcher icon should focus it"""
calc = self.start_app("Calculator")
- sleep(.5)
-
- self.close_all_app("Mahjongg")
mahjongg = self.start_app("Mahjongg")
self.assertTrue(mahjongg.is_active)
self.assertFalse(calc.is_active)
@@ -388,23 +368,84 @@ class LauncherKeyNavTests(LauncherTestCase):
"""Tests that alt+tab exits keynav mode."""
self.switcher.initiate()
- sleep(1)
- self.switcher.stop()
-
- self.assertThat(self.launcher.key_nav_is_active, Equals(False))
+ self.addCleanup(self.switcher.terminate)
+ self.assertThat(self.launcher.key_nav_is_active, Eventually(Equals(False)))
def test_launcher_keynav_alt_grave_quits(self):
"""Tests that alt+` exits keynav mode."""
self.switcher.initiate_detail_mode()
+ self.addCleanup(self.switcher.terminate)
+ self.assertThat(self.launcher.key_nav_is_active, Eventually(Equals(False)))
+
+
+class LauncherIconsBehaviorTests(LauncherTestCase):
+ """Test the launcher icons interactions"""
+
+ def test_launcher_activate_last_focused_window(self):
+ """This tests shows that when you activate a launcher icon only the last
+ focused instance of that application is rasied.
+
+ This is tested by opening 2 Mahjongg and a Calculator.
+ Then we activate the Calculator launcher icon.
+ Then we actiavte the Mahjongg launcher icon.
+ Then we minimize the focused applications.
+ This should give focus to the next window on the stack.
+ Then we activate the Mahjongg launcher icon
+ This should bring to focus the non-minimized window.
+ If only 1 instance is raised then the Calculator gets the focus.
+ If ALL the instances are raised then the second Mahjongg gets the focus.
+
+ """
+ mahj = self.start_app("Mahjongg")
+ [mah_win1] = mahj.get_windows()
+ self.assertTrue(mah_win1.is_focused)
+
+ calc = self.start_app("Calculator")
+ [calc_win] = calc.get_windows()
+ self.assertTrue(calc_win.is_focused)
+
+ self.start_app("Mahjongg")
+ # Sleeping due to the start_app only waiting for the bamf model to be
+ # updated with the application. Since the app has already started,
+ # and we are just waiting on a second window, however a defined sleep
+ # here is likely to be problematic.
+ # TODO: fix bamf emulator to enable waiting for new windows.
sleep(1)
- self.switcher.stop()
+ [mah_win2] = [w for w in mahj.get_windows() if w.x_id != mah_win1.x_id]
+ self.assertTrue(mah_win2.is_focused)
+
+ self.assertVisibleWindowStack([mah_win2, calc_win, mah_win1])
- self.assertThat(self.launcher.key_nav_is_active, Equals(False))
+ mahj_icon = self.launcher.model.get_icon_by_desktop_id(mahj.desktop_file)
+ 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_win.is_focused)
+ self.assertVisibleWindowStack([calc_win, mah_win2, mah_win1])
+
+ self.launcher_instance.click_launcher_icon(mahj_icon)
+ sleep(1)
+ self.assertTrue(mah_win2.is_focused)
+ self.assertVisibleWindowStack([mah_win2, calc_win, mah_win1])
+
+ self.keybinding("window/minimize")
+ sleep(1)
+
+ self.assertTrue(mah_win2.is_hidden)
+ self.assertTrue(calc_win.is_focused)
+ self.assertVisibleWindowStack([calc_win, mah_win1])
+
+ self.launcher_instance.click_launcher_icon(mahj_icon)
+ sleep(1)
+ self.assertTrue(mah_win1.is_focused)
+ self.assertTrue(mah_win2.is_hidden)
+ self.assertVisibleWindowStack([mah_win1, calc_win])
class LauncherRevealTests(LauncherTestCase):
- """Test the launcher reveal bahavior when in autohide mode."""
+ """Test the launcher reveal behavior when in autohide mode."""
def setUp(self):
super(LauncherRevealTests, self).setUp()
@@ -412,26 +453,19 @@ class LauncherRevealTests(LauncherTestCase):
self.set_unity_option('launcher_capture_mouse', True)
self.set_unity_option('launcher_hide_mode', 1)
launcher = self.get_launcher()
- for counter in range(10):
- sleep(1)
- if launcher.hidemode == 1:
- break
- self.assertThat(launcher.hidemode, Equals(1),
- "Launcher did not enter auto-hide mode.")
+ self.assertThat(launcher.hidemode, Eventually(Equals(1)))
def test_launcher_keyboard_reveal_works(self):
"""Revealing launcher with keyboard must work."""
- self.addCleanup(self.launcher_instance.keyboard_unreveal_launcher)
-
self.launcher_instance.keyboard_reveal_launcher()
- sleep(0.5)
- self.assertThat(self.launcher_instance.is_showing(), Equals(True))
+ self.addCleanup(self.launcher_instance.keyboard_unreveal_launcher)
+ self.assertThat(self.launcher_instance.is_showing, Eventually(Equals(True)))
def test_reveal_on_mouse_to_edge(self):
"""Tests reveal of launchers by mouse pressure."""
self.launcher_instance.move_mouse_to_right_of_launcher()
self.launcher_instance.mouse_reveal_launcher()
- self.assertThat(self.launcher_instance.is_showing(), Equals(True))
+ self.assertThat(self.launcher_instance.is_showing, Eventually(Equals(True)))
def test_reveal_with_mouse_under_launcher(self):
"""Tests that the launcher hides properly if the
@@ -443,8 +477,7 @@ class LauncherRevealTests(LauncherTestCase):
self.keybinding_hold("launcher/reveal")
sleep(1)
self.keybinding_release("launcher/reveal")
- sleep(2)
- self.assertThat(self.launcher_instance.is_showing(), Equals(False))
+ self.assertThat(self.launcher_instance.is_showing, Eventually(Equals(False)))
def test_reveal_does_not_hide_again(self):
"""Tests reveal of launchers by mouse pressure to ensure it doesn't
@@ -452,8 +485,7 @@ class LauncherRevealTests(LauncherTestCase):
"""
self.launcher_instance.move_mouse_to_right_of_launcher()
self.launcher_instance.mouse_reveal_launcher()
- sleep(2)
- self.assertThat(self.launcher_instance.is_showing(), Equals(True))
+ self.assertThat(self.launcher_instance.is_showing, Eventually(Equals(True)))
def test_launcher_does_not_reveal_with_mouse_down(self):
"""Launcher must not reveal if have mouse button 1 down."""
@@ -462,7 +494,11 @@ class LauncherRevealTests(LauncherTestCase):
self.addCleanup(self.mouse.release, 1)
#FIXME: This is really bad API. it says reveal but it's expected to fail. bad bad bad!!
self.launcher_instance.mouse_reveal_launcher()
- self.assertThat(self.launcher_instance.is_showing(), Equals(False))
+ # Need a sleep here otherwise this test would pass even if the code failed.
+ # THis test needs to be rewritten...
+ sleep(5)
+ self.assertThat(self.launcher_instance.is_showing, Equals(False))
+
class LauncherVisualTests(LauncherTestCase):
"""Tests for visual aspects of the launcher (icon saturation etc.)."""
@@ -483,7 +519,7 @@ class LauncherVisualTests(LauncherTestCase):
self.keybinding_tap("launcher/switcher/next")
for icon in self.launcher.model.get_launcher_icons():
- self.assertFalse(icon.desaturated)
+ self.assertThat(icon.desaturated, Eventually(Equals(False)))
def test_opening_dash_desaturates_icons(self):
"""Opening the dash must desaturate all the launcher icons."""
@@ -492,9 +528,9 @@ class LauncherVisualTests(LauncherTestCase):
for icon in self.launcher.model.get_launcher_icons():
if isinstance(icon, BFBLauncherIcon):
- self.assertFalse(icon.desaturated)
+ self.assertThat(icon.desaturated, Eventually(Equals(False)))
else:
- self.assertTrue(icon.desaturated)
+ self.assertThat(icon.desaturated, Eventually(Equals(True)))
def test_opening_dash_with_mouse_over_launcher_keeps_icon_saturation(self):
"""Opening dash with mouse over launcher must not desaturate icons."""
@@ -505,7 +541,7 @@ class LauncherVisualTests(LauncherTestCase):
self.dash.ensure_visible()
self.addCleanup(self.dash.ensure_hidden)
for icon in self.launcher.model.get_launcher_icons():
- self.assertFalse(icon.desaturated)
+ self.assertThat(icon.desaturated, Eventually(Equals(False)))
def test_mouse_over_with_dash_open_desaturates_icons(self):
"""Moving mouse over launcher with dash open must saturate icons."""
@@ -517,7 +553,8 @@ class LauncherVisualTests(LauncherTestCase):
self.mouse.move(x + w/2, y + h/2)
sleep(.5)
for icon in self.launcher.model.get_launcher_icons():
- self.assertFalse(icon.desaturated)
+ self.assertThat(icon.desaturated, Eventually(Equals(False)))
+
class LauncherCaptureTests(AutopilotTestCase):
"""Test the launchers ability to capture/not capture the mouse."""
@@ -526,12 +563,7 @@ class LauncherCaptureTests(AutopilotTestCase):
def setHideMode(self, mode):
launcher = self.launcher.get_launcher_for_monitor(0)
- for counter in range(10):
- sleep(1)
- if launcher.hidemode == mode:
- break
- self.assertThat(launcher.hidemode, Equals(mode),
- "Launcher did not enter revealed mode.")
+ self.assertThat(launcher.hidemode, Eventually(Equals(mode)))
def leftMostMonitor(self):
x1, y1, width, height = self.screen_geo.get_monitor_geometry(0)
diff --git a/tests/autopilot/autopilot/tests/test_panel.py b/tests/autopilot/autopilot/tests/test_panel.py
index ebdeab3b8..e81c9a987 100644
--- a/tests/autopilot/autopilot/tests/test_panel.py
+++ b/tests/autopilot/autopilot/tests/test_panel.py
@@ -8,7 +8,7 @@
import logging
import os
-from testtools.matchers import Equals, NotEquals, LessThan, GreaterThan
+from testtools.matchers import Equals, GreaterThan, NotEquals
from time import sleep
from autopilot.emulators.X11 import ScreenGeometry
@@ -16,8 +16,10 @@ from autopilot.emulators.bamf import BamfWindow
from autopilot.emulators.unity.panel import IndicatorEntry
from autopilot.tests import AutopilotTestCase
+
logger = logging.getLogger(__name__)
+
def _make_monitor_scenarios():
num_monitors = ScreenGeometry().get_num_monitors()
scenarios = []
@@ -42,18 +44,16 @@ class PanelTestsBase(AutopilotTestCase):
self.addCleanup(self.panel.move_mouse_below_the_panel)
def open_new_application_window(self, app_name, maximized=False, move_to_monitor=True):
- """Opens a new instance of the requested application, ensuring
- that only one window is opened.
+ """Opens a new instance of the requested application, ensuring that only
+ one window is opened.
Returns the opened BamfWindow
-
+
"""
self.close_all_app(app_name)
app = self.start_app(app_name, locale="C")
- wins = app.get_windows()
- self.assertThat(len(wins), Equals(1))
- app_win = wins[0]
+ [app_win] = app.get_windows()
app_win.set_focus()
self.assertTrue(app.is_active)
@@ -92,7 +92,7 @@ class PanelTestsBase(AutopilotTestCase):
if restore_position:
self.addCleanup(self.screen_geo.drag_window_to_monitor, window, window.monitor)
-
+
self.screen_geo.drag_window_to_monitor(window, self.panel_monitor)
sleep(.25)
self.assertThat(window.monitor, Equals(self.panel_monitor))
@@ -117,7 +117,7 @@ class PanelTitleTests(PanelTestsBase):
scenarios = _make_monitor_scenarios()
def test_panel_title_on_empty_desktop(self):
- """Test that the title is set ot default when there are no windows shown"""
+ """With no windows shown, the panel must display the default title."""
self.keybinding("window/show_desktop")
# We need this sleep to give the time to showdesktop to properly resume
# the initial status without getting a false-negative result
@@ -128,14 +128,14 @@ class PanelTitleTests(PanelTestsBase):
self.assertTrue(self.panel.desktop_is_active)
def test_panel_title_with_restored_application(self):
- """Tests the title shown in the panel with a restored application"""
+ """Panel must display application name for a non-maximised application."""
calc_win = self.open_new_application_window("Calculator")
self.assertFalse(calc_win.is_maximized)
self.assertThat(self.panel.title, Equals(calc_win.application.name))
def test_panel_title_with_maximized_application(self):
- """Tests the title shown in the panel with a maximized application"""
+ """Panel must display application name for a maximised application."""
text_win = self.open_new_application_window("Text Editor", maximized=True)
self.assertTrue(text_win.is_maximized)
@@ -143,7 +143,7 @@ class PanelTitleTests(PanelTestsBase):
def test_panel_title_with_maximized_window_restored_child(self):
"""Tests the title shown in the panel when opening the restored child of
- a maximized application
+ a maximized application.
"""
text_win = self.open_new_application_window("Text Editor", maximized=True)
@@ -156,7 +156,7 @@ class PanelTitleTests(PanelTestsBase):
self.assertThat(self.panel.title, Equals(text_win.application.name))
def test_panel_title_switching_active_window(self):
- """Tests the title shown in the panel with a maximized application"""
+ """Tests the title shown in the panel with a maximized application."""
# Locked Launchers on all monitors
self.set_unity_option('num_launchers', 0)
self.set_unity_option('launcher_hide_mode', 0)
@@ -179,7 +179,8 @@ class PanelTitleTests(PanelTestsBase):
def test_panel_title_updates_on_maximized_window_title_changes(self):
"""Tests that the title of a maximized application updates with
- window title changes"""
+ window title changes.
+ """
text_win = self.open_new_application_window("Text Editor", maximized=True)
self.assertThat(self.panel.title, Equals(text_win.title))
@@ -210,7 +211,7 @@ class PanelWindowButtonsTests(PanelTestsBase):
self.set_unity_option('launcher_hide_mode', 0)
def test_window_buttons_dont_show_on_empty_desktop(self):
- """Tests that the window buttons are not shown on clean desktop"""
+ """Tests that the window buttons are not shown on clean desktop."""
# We need this sleep to give the time to showdesktop to properly resume
# the initial status without getting a false-negative result
self.addCleanup(sleep, 2)
@@ -222,8 +223,8 @@ class PanelWindowButtonsTests(PanelTestsBase):
self.assertFalse(self.panel.window_buttons_shown)
def test_window_buttons_dont_show_for_restored_window(self):
- """Tests that the window buttons are not shown for a restored window"""
- calc_win = self.open_new_application_window("Calculator")
+ """Tests that the window buttons are not shown for a restored window."""
+ self.open_new_application_window("Calculator")
self.assertFalse(self.panel.window_buttons_shown)
@@ -233,9 +234,9 @@ class PanelWindowButtonsTests(PanelTestsBase):
def test_window_buttons_dont_show_for_maximized_window_on_mouse_out(self):
"""Tests that the windows button arenot shown for a maximized window
- when the mouse is outside the panel
+ when the mouse is outside the panel.
"""
- text_win = self.open_new_application_window("Text Editor", maximized=True)
+ self.open_new_application_window("Text Editor", maximized=True)
sleep(self.panel.menus.discovery_duration)
sleep(self.panel.menus.discovery_fadein_duration / 1000.0)
@@ -244,9 +245,9 @@ class PanelWindowButtonsTests(PanelTestsBase):
def test_window_buttons_show_for_maximized_window_on_mouse_in(self):
"""Tests that the window buttons are shown when a maximized window
- is focused and the mouse is over the menu-view panel areas
+ is focused and the mouse is over the menu-view panel areas.
"""
- text_win = self.open_new_application_window("Text Editor", maximized=True)
+ self.open_new_application_window("Text Editor", maximized=True)
sleep(self.panel.menus.discovery_duration)
@@ -260,7 +261,7 @@ class PanelWindowButtonsTests(PanelTestsBase):
self.assertFalse(button.overlay_mode)
def test_window_buttons_show_with_dash(self):
- """Tests that the window buttons are shown when opening the dash"""
+ """Tests that the window buttons are shown when opening the dash."""
self.dash.ensure_visible()
self.addCleanup(self.dash.ensure_hidden)
sleep(.5)
@@ -272,7 +273,7 @@ class PanelWindowButtonsTests(PanelTestsBase):
self.assertTrue(button.overlay_mode)
def test_window_buttons_show_with_hud(self):
- """Tests that the window buttons are shown when opening the HUD"""
+ """Tests that the window buttons are shown when opening the HUD."""
self.hud.ensure_visible()
self.addCleanup(self.hud.ensure_hidden)
sleep(1)
@@ -284,7 +285,7 @@ class PanelWindowButtonsTests(PanelTestsBase):
self.assertTrue(button.overlay_mode)
def test_window_buttons_update_visual_state(self):
- """Tests that the window button updates its visual state"""
+ """Tests that the window button updates its visual state."""
self.hud.ensure_visible()
self.addCleanup(self.hud.ensure_hidden)
button = self.panel.window_buttons.close
@@ -304,7 +305,7 @@ class PanelWindowButtonsTests(PanelTestsBase):
def test_window_buttons_cancel(self):
"""Tests how the buttons ignore clicks when the mouse is pressed over
- them and released outside their area
+ them and released outside their area.
"""
self.hud.ensure_visible()
self.addCleanup(self.hud.ensure_hidden)
@@ -319,7 +320,7 @@ class PanelWindowButtonsTests(PanelTestsBase):
self.assertTrue(self.hud.visible)
def test_window_buttons_close_button_works_for_window(self):
- """Tests that the window button 'Close' actually closes a window"""
+ """Tests that the window button 'Close' actually closes a window."""
text_win = self.open_new_application_window("Text Editor", maximized=True, move_to_monitor=False)
self.move_window_to_panel_monitor(text_win, restore_position=False)
self.keybinding("window/maximize")
@@ -331,14 +332,17 @@ class PanelWindowButtonsTests(PanelTestsBase):
self.assertTrue(text_win.closed)
def test_window_buttons_close_follows_fitts_law(self):
- """Tests that the 'Close' button is conform to Fitts's Law. See bug #839690"""
+ """Tests that the 'Close' button is activated when clicking at 0,0.
+
+ See bug #839690
+ """
text_win = self.open_new_application_window("Text Editor", maximized=True, move_to_monitor=False)
self.move_window_to_panel_monitor(text_win, restore_position=False)
self.keybinding("window/maximize")
self.panel.move_mouse_over_window_buttons()
- screen = self.screen_geo.get_monitor_geometry(self.panel_monitor)
- self.mouse.move(screen[0], screen[1], rate=20, time_between_events=0.005)
+ screen_x, screen_y = self.screen_geo.get_monitor_geometry(self.panel_monitor)
+ self.mouse.move(screen_x, screen_y, rate=20, time_between_events=0.005)
sleep(.5)
self.mouse.click(press_duration=.1)
sleep(1)
@@ -346,7 +350,7 @@ class PanelWindowButtonsTests(PanelTestsBase):
self.assertTrue(text_win.closed)
def test_window_buttons_minimize_button_works_for_window(self):
- """Tests that the window button 'Minimize' actually minimizes a window"""
+ """Tests that the window button 'Minimize' actually minimizes a window."""
text_win = self.open_new_application_window("Text Editor", maximized=True)
self.panel.window_buttons.minimize.mouse_click()
@@ -359,7 +363,10 @@ class PanelWindowButtonsTests(PanelTestsBase):
launcher.click_launcher_icon(icon)
def test_window_buttons_minimize_follows_fitts_law(self):
- """Tests that the 'Minimize' button is conform to Fitts's Law. See bug #839690"""
+ """Tests that the 'Minimize' button is conform to Fitts's Law.
+
+ See bug #839690
+ """
text_win = self.open_new_application_window("Text Editor", maximized=True)
button = self.panel.window_buttons.minimize
@@ -377,7 +384,7 @@ class PanelWindowButtonsTests(PanelTestsBase):
launcher.click_launcher_icon(icon)
def test_window_buttons_unmaximize_button_works_for_window(self):
- """Tests that the window button 'Unmaximize' actually unmaximizes a window"""
+ """Tests that the window button 'Unmaximize' actually unmaximizes a window."""
text_win = self.open_new_application_window("Text Editor", maximized=True)
self.panel.window_buttons.unmaximize.mouse_click()
@@ -389,7 +396,10 @@ class PanelWindowButtonsTests(PanelTestsBase):
self.assertFalse(self.panel.window_buttons_shown)
def test_window_buttons_unmaximize_follows_fitts_law(self):
- """Tests that the 'Unmaximize' button is conform to Fitts's Law. See bug #839690"""
+ """Tests that the 'Unmaximize' button is conform to Fitts's Law.
+
+ See bug #839690
+ """
text_win = self.open_new_application_window("Text Editor", maximized=True)
button = self.panel.window_buttons.unmaximize
@@ -404,7 +414,7 @@ class PanelWindowButtonsTests(PanelTestsBase):
self.assertFalse(text_win.is_maximized)
def test_window_buttons_close_button_works_for_hud(self):
- """Tests that the window 'Close' actually closes the HUD"""
+ """Tests that the window 'Close' actually closes the HUD."""
self.hud.ensure_visible()
self.addCleanup(self.hud.ensure_hidden)
sleep(.5)
@@ -415,7 +425,7 @@ class PanelWindowButtonsTests(PanelTestsBase):
self.assertFalse(self.hud.visible)
def test_window_buttons_minimize_button_disabled_for_hud(self):
- """Tests that the window 'Minimize' does nothing to the HUD"""
+ """Tests that the window 'Minimize' does nothing to the HUD."""
self.hud.ensure_visible()
self.addCleanup(self.hud.ensure_hidden)
sleep(.5)
@@ -428,7 +438,7 @@ class PanelWindowButtonsTests(PanelTestsBase):
self.assertTrue(self.hud.visible)
def test_window_buttons_maximize_button_disabled_for_hud(self):
- """Tests that the window 'Maximize' does nothing to the HUD"""
+ """Tests that the window 'Maximize' does nothing to the HUD."""
self.hud.ensure_visible()
self.addCleanup(self.hud.ensure_hidden)
sleep(.5)
@@ -441,8 +451,8 @@ class PanelWindowButtonsTests(PanelTestsBase):
self.assertTrue(self.hud.visible)
def test_window_buttons_maximize_in_hud_does_not_change_dash_form_factor(self):
- """Tests that clicking on the disabled 'Maximize' window button of the
- HUD, really does nothing and don't touch the dash form factor.
+ """Clicking on the 'Maximize' button of the HUD must do nothing.
+
See bug #939054
"""
inital_form_factor = self.dash.view.form_factor
@@ -456,7 +466,7 @@ class PanelWindowButtonsTests(PanelTestsBase):
self.assertThat(self.dash.view.form_factor, Equals(inital_form_factor))
def test_window_buttons_close_button_works_for_dash(self):
- """Tests that the window 'Close' actually closes the Dash"""
+ """Tests that the window 'Close' actually closes the Dash."""
self.dash.ensure_visible()
self.addCleanup(self.dash.ensure_hidden)
sleep(.5)
@@ -467,7 +477,7 @@ class PanelWindowButtonsTests(PanelTestsBase):
self.assertFalse(self.dash.visible)
def test_window_buttons_minimize_button_disabled_for_dash(self):
- """Tests that the 'Minimize' button is disabled for the dash"""
+ """Tests that the 'Minimize' button is disabled for the dash."""
self.dash.ensure_visible()
self.addCleanup(self.dash.ensure_hidden)
sleep(.5)
@@ -480,8 +490,7 @@ class PanelWindowButtonsTests(PanelTestsBase):
self.assertTrue(self.dash.visible)
def test_window_buttons_maximization_buttons_works_for_dash(self):
- """Tests that the 'Maximize' and 'Unmaximize' buttons (when
- both enabled) work as expected"""
+ """'Maximize' and 'Restore' buttons (when both enabled) must work as expected."""
self.dash.ensure_visible()
self.addCleanup(self.panel.window_buttons.close.mouse_click)
sleep(.5)
@@ -564,7 +573,7 @@ class PanelWindowButtonsTests(PanelTestsBase):
def test_window_buttons_show_when_indicator_active_and_mouse_over_panel(self):
"""Tests that when an indicator is opened, and the mouse goes over the
- panel view, then the window buttons are revealed
+ panel view, then the window buttons are revealed.
"""
self.open_new_application_window("Text Editor", maximized=True)
sleep(self.panel.menus.fadein_duration / 1000.0)
@@ -601,7 +610,7 @@ class PanelWindowButtonsTests(PanelTestsBase):
class PanelHoveringTests(PanelTestsBase):
- """Tests with the mouse pointer hovering the panel area"""
+ """Tests with the mouse pointer hovering the panel area."""
scenarios = _make_monitor_scenarios()
@@ -665,8 +674,9 @@ class PanelHoveringTests(PanelTestsBase):
self.assertFalse(self.panel.menus_shown)
def test_hovering_indicators_open_menus(self):
- """This test checks that opening an indicator entry, and then
- hovering on all the others, opens them"""
+ """Opening an indicator entry, and then hovering on other entries must
+ open them.
+ """
self.open_new_application_window("Text Editor")
entries = self.panel.get_indicator_entries(include_hidden_menus=True)
@@ -679,12 +689,13 @@ class PanelHoveringTests(PanelTestsBase):
self.assertTrue(entry.active)
self.assertThat(entry.menu_y, NotEquals(0))
+
class PanelMenuTests(PanelTestsBase):
scenarios = _make_monitor_scenarios()
def test_menus_are_added_on_new_application(self):
- """Tests that menus are added when a new application is opened"""
+ """Tests that menus are added when a new application is opened."""
self.open_new_application_window("Calculator")
sleep(.5)
menu_entries = self.panel.menus.get_entries()
@@ -697,7 +708,7 @@ class PanelMenuTests(PanelTestsBase):
def test_menus_are_not_shown_if_the_application_has_no_menus(self):
"""Tests that if an application has no menus, then they are not
- shown or added
+ shown or added.
"""
old_env = os.environ["UBUNTU_MENUPROXY"]
os.putenv("UBUNTU_MENUPROXY", "")
@@ -712,7 +723,7 @@ class PanelMenuTests(PanelTestsBase):
self.assertThat(self.panel.title, Equals(calc_win.application.name))
def test_menus_shows_when_new_application_is_opened(self):
- """This tests the menu discovery feature on new application"""
+ """This tests the menu discovery feature on new application."""
self.open_new_application_window("Calculator")
sleep(self.panel.menus.fadein_duration / 1000.0)
@@ -725,7 +736,7 @@ class PanelMenuTests(PanelTestsBase):
self.assertFalse(self.panel.menus_shown)
def test_menus_dont_show_if_a_new_application_window_is_opened(self):
- """This tests the menu discovery feature on new window for a know application"""
+ """This tests the menu discovery feature on new window for a know application."""
self.open_new_application_window("Calculator")
sleep(self.panel.menus.fadein_duration / 1000.0)
@@ -739,8 +750,8 @@ class PanelMenuTests(PanelTestsBase):
self.assertFalse(self.panel.menus_shown)
def test_menus_dont_show_for_restored_window_on_mouse_out(self):
- """Tests that menus of a restored window are not shown when
- the mouse pointer is outside the panel menu area.
+ """Restored window menus must not show when the mouse is outside the
+ panel menu area.
"""
self.open_new_application_window("Calculator")
sleep(self.panel.menus.fadein_duration / 1000.0)
@@ -750,8 +761,8 @@ class PanelMenuTests(PanelTestsBase):
self.assertFalse(self.panel.menus_shown)
def test_menus_show_for_restored_window_on_mouse_in(self):
- """Tests that menus of a restored window are shown only when
- the mouse pointer is over the panel menu area.
+ """Restored window menus must show only when the mouse is over the panel
+ menu area.
"""
self.open_new_application_window("Calculator")
sleep(self.panel.menus.fadein_duration / 1000.0)
@@ -763,8 +774,8 @@ class PanelMenuTests(PanelTestsBase):
self.assertTrue(self.panel.menus_shown)
def test_menus_dont_show_for_maximized_window_on_mouse_out(self):
- """Tests that menus of a maximized window are not shown when
- the mouse pointer is outside the panel menu area.
+ """Maximized window menus must not show when the mouse is outside the
+ panel menu area.
"""
self.open_new_application_window("Text Editor", maximized=True)
sleep(self.panel.menus.fadein_duration / 1000.0)
@@ -774,8 +785,8 @@ class PanelMenuTests(PanelTestsBase):
self.assertFalse(self.panel.menus_shown)
def test_menus_show_for_maximized_window_on_mouse_in(self):
- """Tests that menus of a maximized window are shown only when
- the mouse pointer is over the panel menu area.
+ """Maximized window menus must only show when the mouse is over the
+ panel menu area.
"""
self.open_new_application_window("Text Editor", maximized=True)
sleep(self.panel.menus.fadein_duration / 1000.0)
@@ -787,7 +798,7 @@ class PanelMenuTests(PanelTestsBase):
self.assertTrue(self.panel.menus_shown)
def test_menus_dont_show_with_dash(self):
- """Tests that menus are not showing when opening the dash"""
+ """Tests that menus are not showing when opening the dash."""
self.dash.ensure_visible()
self.addCleanup(self.dash.ensure_hidden)
sleep(1)
@@ -795,7 +806,7 @@ class PanelMenuTests(PanelTestsBase):
self.assertFalse(self.panel.menus_shown)
def test_menus_dont_show_with_hud(self):
- """Tests that menus are not showing when opening the HUD"""
+ """Tests that menus are not showing when opening the HUD."""
self.hud.ensure_visible()
self.addCleanup(self.hud.ensure_hidden)
sleep(1)
@@ -803,9 +814,11 @@ class PanelMenuTests(PanelTestsBase):
self.assertFalse(self.panel.menus_shown)
def test_menus_show_after_closing_an_entry(self):
- """This test checks that opening a menu entry, and then
- hovering on all the others, opens them, plus we check that
- the menus are still drawn when closed"""
+ """Opening a menu entry, and then hovering on other entries must open them.
+
+ We also check that the menus are still drawn when closed.
+ """
+ # TODO - should be split into multiple tests.
self.open_new_application_window("Calculator")
entries = self.panel.menus.get_entries()
@@ -825,8 +838,8 @@ class PanelMenuTests(PanelTestsBase):
self.assertThat(last_entry.menu_y, Equals(0))
def test_menus_show_when_indicator_active_and_mouse_over_panel(self):
- """Tests that when an indicator is opened, and the mouse goes over the
- panel view, then the menus are revealed
+ """When an indicator is opened, and the mouse goes over the panel view,
+ the menus must be revealed.
"""
self.open_new_application_window("Calculator")
indicator = self.panel.indicators.get_indicator_by_name_hint("indicator-session-devices")
@@ -862,12 +875,12 @@ class PanelMenuTests(PanelTestsBase):
class PanelIndicatorEntriesTests(PanelTestsBase):
- """Tests for the indicator entries, including both menu and indicators"""
+ """Tests for the indicator entries, including both menu and indicators."""
scenarios = _make_monitor_scenarios()
def test_menu_opens_on_click(self):
- """Tests that clicking on a menu entry, opens a menu"""
+ """Tests that clicking on a menu entry, opens a menu."""
self.open_new_application_window("Calculator")
sleep(.5)
@@ -879,9 +892,7 @@ class PanelIndicatorEntriesTests(PanelTestsBase):
self.assertThat(menu_entry.menu_y, Equals(self.panel.height))
def test_menu_opens_closes_on_click(self):
- """Tests that clicking on a menu entry, opens a menu, reclicking
- on it closes it
- """
+ """Clicking on an open menu entru must close it again."""
self.open_new_application_window("Calculator")
menu_entry = self.panel.menus.get_entries()[0]
@@ -894,7 +905,7 @@ class PanelIndicatorEntriesTests(PanelTestsBase):
self.assertThat(menu_entry.menu_y, Equals(0))
def test_menu_closes_on_click_outside(self):
- """Tests that clicking outside the menu area, closes a menu"""
+ """Clicking outside an open menu must close it."""
self.open_new_application_window("Calculator")
menu_entry = self.panel.menus.get_entries()[0]
@@ -917,9 +928,7 @@ class PanelKeyNavigationTests(PanelTestsBase):
scenarios = _make_monitor_scenarios()
def test_panel_first_menu_show_works(self):
- """Tests that pressing the open-menus keybinding, the first indicator
- is actually opened
- """
+ """Pressing the open-menus keybinding must open the first indicator."""
self.open_new_application_window("Calculator")
sleep(1)
self.keybinding("panel/open_first_menu")
@@ -1006,7 +1015,7 @@ class PanelKeyNavigationTests(PanelTestsBase):
class PanelGrabAreaTests(PanelTestsBase):
- """Panel grab area tests"""
+ """Panel grab area tests."""
scenarios = _make_monitor_scenarios()
@@ -1016,7 +1025,7 @@ class PanelGrabAreaTests(PanelTestsBase):
sleep(.1)
def test_unmaximize_from_grab_area_works(self):
- """Tests that dragging a window down from the panel, unmaximize it"""
+ """Dragging a window down from the panel must unmaximize it."""
text_win = self.open_new_application_window("Text Editor", maximized=True)
self.move_mouse_over_grab_area()
@@ -1028,7 +1037,7 @@ class PanelGrabAreaTests(PanelTestsBase):
self.assertFalse(text_win.is_maximized)
def test_focus_the_maximized_window_works(self):
- """Tests that clicking on the grab area, put the maximized window to focus"""
+ """Clicking on the grab area must put a maximized window in focus."""
text_win = self.open_new_application_window("Text Editor", maximized=True)
sleep(.5)
self.open_new_application_window("Calculator")
@@ -1041,7 +1050,7 @@ class PanelGrabAreaTests(PanelTestsBase):
self.assertTrue(text_win.is_focused)
def test_lower_the_maximized_window_works(self):
- """Tests that middle-clicking on the panel grab area, lower the maximized window"""
+ """Middle-clicking on the panel grab area must lower a maximized window."""
calc_win = self.open_new_application_window("Calculator")
sleep(.5)
self.open_new_application_window("Text Editor", maximized=True)
@@ -1055,7 +1064,7 @@ class PanelGrabAreaTests(PanelTestsBase):
class PanelCrossMonitorsTests(PanelTestsBase):
- """Multimonitor only tests"""
+ """Multimonitor panel tests."""
def setUp(self):
super(PanelCrossMonitorsTests, self).setUp()
@@ -1063,7 +1072,7 @@ class PanelCrossMonitorsTests(PanelTestsBase):
self.skipTest("This test requires a multimonitor setup")
def test_panel_title_updates_moving_window(self):
- """Tests the title shown in the panel, moving a restored window around them"""
+ """Tests the title shown in the panel, moving a restored window around them."""
calc_win = self.open_new_application_window("Calculator")
prev_monitor = -1
@@ -1083,10 +1092,10 @@ class PanelCrossMonitorsTests(PanelTestsBase):
prev_monitor = monitor
def test_window_buttons_dont_show_for_maximized_window_on_mouse_in(self):
- """Test that window buttons are not showing when the mouse is hovering
- the panel in other monitors
+ """Window buttons must not show when the mouse is hovering the panel in
+ other monitors.
"""
- text_win = self.open_new_application_window("Text Editor", maximized=True)
+ self.open_new_application_window("Text Editor", maximized=True)
sleep(self.panel.menus.discovery_duration)
@@ -1101,8 +1110,8 @@ class PanelCrossMonitorsTests(PanelTestsBase):
self.assertFalse(panel.window_buttons_shown)
def test_window_buttons_dont_show_in_other_monitors_when_dash_is_open(self):
- """Test that window buttons are not showing in the panels other than
- the one where the dash is opened
+ """Window buttons must not show on the panels other than the one where
+ the dash is opened.
"""
self.dash.ensure_visible()
self.addCleanup(self.dash.ensure_hidden)
@@ -1116,8 +1125,8 @@ class PanelCrossMonitorsTests(PanelTestsBase):
self.assertFalse(panel.window_buttons_shown)
def test_window_buttons_dont_show_in_other_monitors_when_hud_is_open(self):
- """Test that window buttons are not showing in the panels other than
- the one where the dash is opened
+ """Window buttons must not show on the panels other than the one where
+ the hud is opened.
"""
self.hud.ensure_visible()
self.addCleanup(self.hud.ensure_hidden)
@@ -1131,13 +1140,13 @@ class PanelCrossMonitorsTests(PanelTestsBase):
self.assertFalse(panel.window_buttons_shown)
def test_window_buttons_close_inactive_when_clicked_in_another_monitor(self):
- """Tests that clicking on the panel area where the window buttons
- are does not affect the active maximized window in another monitor.
+ """Clicking the close button must not affect the active maximized window on another monitor.
+
See bug #865701
"""
text_win = self.open_new_application_window("Text Editor", maximized=True)
- for monitor in range(0, self.screen_geo.get_num_monitors()):
+ for monitor in range(self.screen_geo.get_num_monitors()):
panel = self.panels.get_panel_for_monitor(monitor)
if monitor != text_win.monitor:
@@ -1146,13 +1155,13 @@ class PanelCrossMonitorsTests(PanelTestsBase):
self.assertFalse(text_win.closed)
def test_window_buttons_minimize_inactive_when_clicked_in_another_monitor(self):
- """Tests that clicking on the panel area where the window buttons
- are does not affect the active maximized window in another monitor.
+ """Clicking the minimise button must not affect the active maximized window on another monitor.
+
See bug #865701
"""
text_win = self.open_new_application_window("Text Editor", maximized=True)
- for monitor in range(0, self.screen_geo.get_num_monitors()):
+ for monitor in range(self.screen_geo.get_num_monitors()):
panel = self.panels.get_panel_for_monitor(monitor)
if monitor != text_win.monitor:
@@ -1161,8 +1170,8 @@ class PanelCrossMonitorsTests(PanelTestsBase):
self.assertFalse(text_win.is_hidden)
def test_window_buttons_unmaximize_inactive_when_clicked_in_another_monitor(self):
- """Tests that clicking on the panel area where the window buttons
- are does not affect the active maximized window in another monitor.
+ """Clicking the restore button must not affect the active maximized window on another monitor.
+
See bug #865701
"""
text_win = self.open_new_application_window("Text Editor", maximized=True)
@@ -1176,8 +1185,7 @@ class PanelCrossMonitorsTests(PanelTestsBase):
self.assertTrue(text_win.is_maximized)
def test_hovering_indicators_on_multiple_monitors(self):
- """This test checks that opening an indicator entry, and then
- hovering on all the others, opens them"""
+ """Opening an indicator entry and then hovering others entries must open them."""
text_win = self.open_new_application_window("Text Editor")
panel = self.panels.get_panel_for_monitor(text_win.monitor)
indicator = panel.indicators.get_indicator_by_name_hint("indicator-session-devices")
diff --git a/tests/autopilot/autopilot/tests/test_switcher.py b/tests/autopilot/autopilot/tests/test_switcher.py
index 424325141..1fbd3b0f0 100644
--- a/tests/autopilot/autopilot/tests/test_switcher.py
+++ b/tests/autopilot/autopilot/tests/test_switcher.py
@@ -21,9 +21,9 @@ class SwitcherTests(AutopilotTestCase):
def setUp(self):
super(SwitcherTests, self).setUp()
- self.start_app('Character Map')
- self.start_app('Calculator')
- self.start_app('Mahjongg')
+ self.char_map = self.start_app('Character Map')
+ self.calc = self.start_app('Calculator')
+ self.mahjongg = self.start_app('Mahjongg')
def tearDown(self):
super(SwitcherTests, self).tearDown()
@@ -197,6 +197,69 @@ class SwitcherTests(AutopilotTestCase):
self.assertThat(self.switcher.get_is_visible(), Equals(False))
+ def test_switcher_appears_on_monitor_with_focused_window(self):
+ num_monitors = self.screen_geo.get_num_monitors()
+ if num_monitors == 1:
+ self.skip("No point testing this on one monitor")
+
+ [calc_win] = self.calc.get_windows()
+ for monitor in range(num_monitors):
+ self.screen_geo.drag_window_to_monitor(calc_win, monitor)
+ self.switcher.initiate()
+ sleep(1)
+ self.assertThat(self.switcher.get_monitor(), Equals(monitor))
+ self.switcher.terminate()
+
+
+class SwitcherWindowsManagementTests(AutopilotTestCase):
+ """Test the switcher window management."""
+
+ def test_switcher_raises_only_last_focused_window(self):
+ """Tests that when we do an alt+tab only the previously focused window
+ is raised.
+ This is tests by opening 2 Calculators and a Mahjongg.
+ Then we do a quick alt+tab twice.
+ Then we close the currently focused window.
+ """
+ self.close_all_app("Mahjongg")
+ self.close_all_app("Calculator")
+
+ mahj = self.start_app("Mahjongg")
+ [mah_win1] = mahj.get_windows()
+ self.assertTrue(mah_win1.is_focused)
+
+ calc = self.start_app("Calculator")
+ [calc_win] = calc.get_windows()
+ self.assertTrue(calc_win.is_focused)
+
+ self.start_app("Mahjongg")
+ # Sleeping due to the start_app only waiting for the bamf model to be
+ # updated with the application. Since the app has already started,
+ # and we are just waiting on a second window, however a defined sleep
+ # here is likely to be problematic.
+ # TODO: fix bamf emulator to enable waiting for new windows.
+ sleep(1)
+ [mah_win2] = [w for w in mahj.get_windows() if w.x_id != mah_win1.x_id]
+ self.assertTrue(mah_win2.is_focused)
+
+ self.assertVisibleWindowStack([mah_win2, calc_win, mah_win1])
+
+ self.keybinding("switcher/reveal_normal")
+ sleep(1)
+ self.assertTrue(calc_win.is_focused)
+ self.assertVisibleWindowStack([calc_win, mah_win2, mah_win1])
+
+ self.keybinding("switcher/reveal_normal")
+ sleep(1)
+ self.assertTrue(mah_win2.is_focused)
+ self.assertVisibleWindowStack([mah_win2, calc_win, mah_win1])
+
+ self.keybinding("window/close")
+ sleep(1)
+
+ self.assertTrue(calc_win.is_focused)
+ self.assertVisibleWindowStack([calc_win, mah_win1])
+
class SwitcherDetailsTests(AutopilotTestCase):
"""Test the details mode for the switcher."""
@@ -364,4 +427,3 @@ class SwitcherWorkspaceTests(AutopilotTestCase):
# current workspace and ask that one if it is hidden.
self.assertFalse(wins[0].is_hidden)
self.assertFalse(wins[1].is_hidden)
-
diff --git a/tests/test-gesture-engine/CMakeLists.txt b/tests/test-gesture-engine/CMakeLists.txt
index 3cfdf0a11..4405c9e80 100644
--- a/tests/test-gesture-engine/CMakeLists.txt
+++ b/tests/test-gesture-engine/CMakeLists.txt
@@ -34,7 +34,7 @@ if (GTEST_SRC_DIR)
)
target_link_libraries(test-gesture-engine gtest ${TEST_GESTURE_ENGINE_DEPS_LIBRARIES} -lcompiz_core)
add_test(UnityGTestGestureEngine test-gesture-engine)
- add_dependencies(test-gesture-engine gtest)
+ add_dependencies(test-gesture-engine gtest unity-core-${UNITY_API_VERSION})
add_custom_target (check-gesture-engine COMMAND ./test-gesture-engine DEPENDS test-gesture-engine)
endif (GTEST_SRC_DIR)