diff options
| author | Alex Launi <alex.launi@canonical.com> | 2012-04-26 15:05:11 -0400 |
|---|---|---|
| committer | Alex Launi <alex.launi@canonical.com> | 2012-04-26 15:05:11 -0400 |
| commit | 1cf6258c47c285e734f639c6d7aeb41e28bcc0df (patch) | |
| tree | aa63cd5e62b8957cc0652b8bda0fbc1ad7abdfa8 /tests | |
| parent | 4ebade7b03970c68d96818829d3a2a5fc88bbad2 (diff) | |
update from merge comments
(bzr r2317.4.4)
Diffstat (limited to 'tests')
| -rw-r--r-- | tests/autopilot/autopilot/emulators/unity/switcher.py | 76 | ||||
| -rw-r--r-- | tests/autopilot/autopilot/tests/test_switcher.py | 68 |
2 files changed, 54 insertions, 90 deletions
diff --git a/tests/autopilot/autopilot/emulators/unity/switcher.py b/tests/autopilot/autopilot/emulators/unity/switcher.py index f74f81db9..5b34bc6f4 100644 --- a/tests/autopilot/autopilot/emulators/unity/switcher.py +++ b/tests/autopilot/autopilot/emulators/unity/switcher.py @@ -21,12 +21,20 @@ from autopilot.emulators.unity.icons import * logger = logging.getLogger(__name__) class SwitcherMode(): + """Define the possible modes the switcher can be in""" NORMAL = 0 ALL = 1 DETAIL = 2 class Switcher(KeybindingsHelper): + """A class for interacting with the switcher. + + Abstracts out switcher implementation, and makes the necessary functionality available + to consumer code. + + """ + def __init__(self): super(Switcher, self).__init__() self._mouse = Mouse() @@ -50,23 +58,17 @@ class Switcher(KeybindingsHelper): @property def current_icon(self): - """The currently selected switcher icon - - """ + """The currently selected switcher icon""" return self.icons[self.selection_index] @property def selection_index(self): - """The index of the currently selected icon - - """ + """The index of the currently selected icon""" return self.controller.model.selection_index @property def mode(self): - """Returns the SwitcherMode that the switcher is currently in - - """ + """Returns the SwitcherMode that the switcher is currently in.""" if not self.visible: return None if self.controller.model.detail_selection and not self.controller.model.only_detail_on_viewport: @@ -79,9 +81,7 @@ class Switcher(KeybindingsHelper): return SwitcherMode.NORMAL def initiate(self, mode=SwitcherMode.NORMAL): - """Initiates the switcher in designated mode. Defaults to NORMAL - - """ + """Initiates the switcher in designated mode. Defaults to NORMAL""" if mode == SwitcherMode.NORMAL: logger.debug("Initiating switcher with Alt+Tab") self.keybinding_hold_part_then_tap("switcher/reveal_normal") @@ -96,16 +96,12 @@ class Switcher(KeybindingsHelper): self.controller.model.only_detail_on_viewport.wait_for(False) def next_icon(self): - """Move to the next icon. - - """ + """Move to the next icon.""" logger.debug("Selecting next item in switcher.") self.keybinding("switcher/next") def previous_icon(self): - """Move to the previous icon. - - """ + """Move to the previous icon.""" logger.debug("Selecting previous item in switcher.") self.keybinding("switcher/prev") @@ -119,73 +115,55 @@ class Switcher(KeybindingsHelper): self.controller.visible.wait_for(False) def terminate(self): - """Stop switcher without activating the selected icon. - - """ + """Stop switcher without activating the selected icon.""" logger.debug("Terminating switcher.") self.keybinding("switcher/cancel") self.keybinding_release("switcher/reveal_normal") self.controller.visible.wait_for(False) def select(self): - """Stop switcher and activate the selected icon. - - """ + """Stop switcher and activate the selected icon.""" logger.debug("Stopping switcher") self.keybinding_release("switcher/reveal_normal") self.controller.visible.wait_for(False) def next_via_mouse(self): - """Move to the next icon using the mouse scroll wheel. - - """ + """Move to the next icon using the mouse scroll wheel.""" logger.debug("Selecting next item in switcher with mouse scroll wheel.") self._mouse.press(6) self._mouse.release(6) def previous_via_mouse(self): - """Move to the previous icon using the mouse scroll wheel. - - """ + """Move to the previous icon using the mouse scroll wheel.""" logger.debug("Selecting previous item in switcher with mouse scroll wheel.") self._mouse.press(7) self._mouse.release(7) def show_details(self): - """Show detail mode. - - """ + """Show detail mode.""" logger.debug("Showing details view.") self.keybinding("switcher/detail_start") self.controller.model.detail_selection.wait_for(True) def hide_details(self): - """Hide detail mode. - - """ + """Hide detail mode.""" logger.debug("Hiding details view.") self.keybinding("switcher/detail_stop") self.controller.model.detail_selection.wait_for(False) def next_detail(self): - """Move to next detail in the switcher. - - """ + """Move to next detail in the switcher.""" logger.debug("Selecting next item in details mode.") self.keybinding("switcher/detail_next") def previous_detail(self): - """Move to the previous detail in the switcher. - - """ + """Move to the previous detail in the switcher.""" logger.debug("Selecting previous item in details mode.") self.keybinding("switcher/detail_prev") class SwitcherController(UnityIntrospectionObject): - """An emulator class for interacting with the switcher controller. - - """ + """An emulator class for interacting with the switcher controller.""" @property def view(self): @@ -197,15 +175,11 @@ class SwitcherController(UnityIntrospectionObject): class SwitcherView(UnityIntrospectionObject): - """An emulator class for interacting with with SwitcherView. - - """ + """An emulator class for interacting with with SwitcherView.""" class SwitcherModel(UnityIntrospectionObject): - """An emulator class for interacting with the SwitcherModel. - - """ + """An emulator class for interacting with the SwitcherModel.""" @property def icons(self): diff --git a/tests/autopilot/autopilot/tests/test_switcher.py b/tests/autopilot/autopilot/tests/test_switcher.py index d0a29d126..ec1c92644 100644 --- a/tests/autopilot/autopilot/tests/test_switcher.py +++ b/tests/autopilot/autopilot/tests/test_switcher.py @@ -7,10 +7,11 @@ # by the Free Software Foundation. import logging -from testtools.matchers import Equals, NotEquals, Contains, Not +from testtools.matchers import Equals, Contains, Not from time import sleep from autopilot.matchers import Eventually +#from autopilot.emulators.window import Window from autopilot.emulators.unity.switcher import SwitcherMode from autopilot.tests import AutopilotTestCase @@ -21,10 +22,9 @@ class SwitcherTestCase(AutopilotTestCase): self.set_unity_option("alt_tab_timeout", value) sleep(1) -class SwitcherTests(SwitcherTestCase): - """Test the switcher. - """ +class SwitcherTests(SwitcherTestCase): + """Test the switcher.""" def set_timeout_setting(self, value): self.set_unity_option("alt_tab_timeout", value) sleep(1) @@ -39,10 +39,12 @@ class SwitcherTests(SwitcherTestCase): def tearDown(self): super(SwitcherTests, self).tearDown() - def test_witcher_starts_in_normal_mode(self): - """Switcher must start in normal (i.e.- not details) mode. + def test_nothing(self): + pass + #Window() - """ + def test_witcher_starts_in_normal_mode(self): + """Switcher must start in normal (i.e.- not details) mode.""" self.start_app("Character Map") sleep(1) @@ -51,9 +53,7 @@ class SwitcherTests(SwitcherTestCase): self.assertThat(self.switcher.mode, Equals(SwitcherMode.NORMAL)) def test_switcher_move_next(self): - """Test that pressing the next icon binding moves to the next icon - - """ + """Test that pressing the next icon binding moves to the next icon""" self.switcher.initiate() self.addCleanup(self.switcher.terminate) @@ -62,9 +62,7 @@ class SwitcherTests(SwitcherTestCase): self.assertThat(self.switcher.selection_index, Equals(start + 1)) def test_switcher_move_prev(self): - """Test that pressing the previous icon binding moves to the previous icon - - """ + """Test that pressing the previous icon binding moves to the previous icon""" self.switcher.initiate() self.addCleanup(self.switcher.terminate) @@ -73,9 +71,7 @@ class SwitcherTests(SwitcherTestCase): self.assertThat(self.switcher.selection_index, Equals(start - 1)) def test_switcher_scroll_next(self): - """Test that scrolling the mouse wheel down moves to the next icon - - """ + """Test that scrolling the mouse wheel down moves to the next icon""" self.switcher.initiate() self.addCleanup(self.switcher.terminate) @@ -85,9 +81,7 @@ class SwitcherTests(SwitcherTestCase): self.assertThat(self.switcher.selection_index, Equals(start + 1)) def test_switcher_scroll_prev(self): - """Test that scrolling the mouse wheel up moves to the previous icon - - """ + """Test that scrolling the mouse wheel up moves to the previous icon""" self.switcher.initiate() self.addCleanup(self.switcher.terminate) @@ -101,6 +95,7 @@ class SwitcherTests(SwitcherTestCase): def test_switcher_scroll_next_ignores_fast_events(self): """Ensures that smoothing is working correctly for next icon scrolling. + Only the first event in a rapid fire string of events should be acted upon. The rest ignored. @@ -118,6 +113,7 @@ class SwitcherTests(SwitcherTestCase): def test_switcher_scroll_prev_ignores_fast_events(self): """Ensures that smoothing is working correctly for previous icon scrolling. + Only the first event in a rapid fire string of events should be acted upon. The rest ignored. @@ -135,6 +131,7 @@ class SwitcherTests(SwitcherTestCase): def test_switcher_arrow_key_does_not_init(self): """Ensure that Alt+Right does not initiate switcher. + Regression test for LP:?????? """ @@ -171,6 +168,7 @@ class SwitcherTests(SwitcherTestCase): def test_switcher_appears_on_monitor_with_focused_window(self): """Tests that the switches appears on the correct monitor. + This is defined as the monitor with a focused window. """ @@ -187,13 +185,11 @@ class SwitcherTests(SwitcherTestCase): class SwitcherWindowsManagementTests(SwitcherTestCase): - """Test the switcher window management. - - """ + """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. + """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. @@ -243,17 +239,13 @@ class SwitcherWindowsManagementTests(SwitcherTestCase): class SwitcherDetailsTests(SwitcherTestCase): - """Test the details mode for the switcher. - - """ + """Test the details mode for the switcher.""" def setUp(self): super(SwitcherDetailsTests, self).setUp() self.set_timeout_setting(True) def test_details_mode_on_delay(self): - """Test that details mode activates on a timeout... - - """ + """Test that details mode activates on a timeout.""" #FIXME: Setup self.close_all_app('Character Map') self.workspace.switch_to(1) @@ -276,6 +268,7 @@ class SwitcherDetailsTests(SwitcherTestCase): def test_no_details_for_apps_on_different_workspace(self): """Tests that details mode does not initiates when there are multiple windows + of an application spread across different workspaces. Regression test for LP:933406. @@ -303,6 +296,7 @@ class SwitcherDetailsTests(SwitcherTestCase): class SwitcherDetailsModeTests(SwitcherTestCase): """Tests for the details mode of the switcher. + Tests for initiation with both grave (`) and Down arrow. """ @@ -324,6 +318,7 @@ class SwitcherDetailsModeTests(SwitcherTestCase): def test_next_icon_from_last_detail_works(self): """Pressing next while showing last switcher item in details mode + must select first item in the model in non-details mode. """ @@ -339,14 +334,10 @@ class SwitcherDetailsModeTests(SwitcherTestCase): class SwitcherWorkspaceTests(SwitcherTestCase): - """Test Switcher behavior with respect to multiple workspaces. - - """ + """Test Switcher behavior with respect to multiple workspaces.""" def test_switcher_shows_current_workspace_only(self): - """Switcher must show apps from the current workspace only. - - """ + """Switcher must show apps from the current workspace only.""" #FIXME: SETUP self.close_all_app('Calculator') self.close_all_app('Character Map') @@ -367,9 +358,7 @@ class SwitcherWorkspaceTests(SwitcherTestCase): self.assertThat(icon_names, Not(Contains(calc.name))) def test_switcher_all_mode_shows_all_apps(self): - """Test switcher 'show_all' mode shows apps from all workspaces. - - """ + """Test switcher 'show_all' mode shows apps from all workspaces.""" self.close_all_app('Calculator') self.close_all_app('Character Map') @@ -391,6 +380,7 @@ class SwitcherWorkspaceTests(SwitcherTestCase): def test_switcher_can_switch_to_minimised_window(self): """Switcher must be able to switch to a minimised window when there's + another instance of the same application on a different workspace. """ |
