Back to index

unity  6.0.0
Public Member Functions | Public Attributes
unity.tests.test_switcher.SwitcherTests Class Reference
Inheritance diagram for unity.tests.test_switcher.SwitcherTests:
Inheritance graph
[legend]
Collaboration diagram for unity.tests.test_switcher.SwitcherTests:
Collaboration graph
[legend]

List of all members.

Public Member Functions

def setUp
def tearDown
def test_witcher_starts_in_normal_mode
def test_first_detail_mode_has_correct_label
def test_switcher_move_next
def test_switcher_move_prev
def test_switcher_scroll_next
def test_switcher_scroll_prev
def test_switcher_scroll_next_ignores_fast_events
def test_switcher_scroll_prev_ignores_fast_events
def test_switcher_arrow_key_does_not_init
def test_lazy_switcher_initiate
def test_switcher_cancel
def test_lazy_switcher_cancel
def test_switcher_appears_on_monitor_with_focused_window
def test_switcher_alt_f4_is_disabled
def set_timeout_setting
def check_test_behavior
def dash
def hud
def launcher
def panels
def switcher
def window_manager
def workspace
def set_unity_log_level
def assertNumberWinsIsEventually

Public Attributes

 char_map
 calc
 mahjongg

Detailed Description

Test the switcher.

Definition at line 29 of file test_switcher.py.


Member Function Documentation

def unity.tests.UnityTestCase.assertNumberWinsIsEventually (   self,
  app,
  num 
) [inherited]
Asserts that 'app' eventually has 'num' wins. Waits up to 10 seconds.

Definition at line 196 of file __init__.py.

00196 
00197     def assertNumberWinsIsEventually(self, app, num):
00198         """Asserts that 'app' eventually has 'num' wins. Waits up to 10 seconds."""
00199 
00200         self.assertThat(lambda: len(app.get_windows()), Eventually(Equals(num)))

Here is the caller graph for this function:

Fail the test if it did something naughty.

This includes leaving the dash or the hud open, changing the current
workspace, or leaving the system in show_desktop mode.

Definition at line 56 of file __init__.py.

00056 
00057     def check_test_behavior(self):
00058         """Fail the test if it did something naughty.
00059 
00060         This includes leaving the dash or the hud open, changing the current
00061         workspace, or leaving the system in show_desktop mode.
00062 
00063         """
00064         well_behaved = True
00065         reasons = []
00066         log.info("Checking system state for badly behaving test...")
00067 
00068         # Have we switched workspace?
00069         if self.workspace.current_workspace != self._initial_workspace_num:
00070             well_behaved = False
00071             reasons.append("The test changed the active workspace from %d to %d." \
00072                 % (self._initial_workspace_num, self.workspace.current_workspace))
00073             log.warning("Test changed the active workspace, changing it back...")
00074             self.workspace.switch_to(self._initial_workspace_num)
00075         # Have we left the dash open?
00076         if self.dash.visible:
00077             well_behaved = False
00078             reasons.append("The test left the dash open.")
00079             log.warning("Test left the dash open, closing it...")
00080             self.dash.ensure_hidden()
00081         # ... or the hud?
00082         if self.hud.visible:
00083             well_behaved = False
00084             reasons.append("The test left the hud open.")
00085             log.warning("Test left the hud open, closing it...")
00086             self.hud.ensure_hidden()
00087         # Are we in show desktop mode?
00088         if self.window_manager.showdesktop_active:
00089             well_behaved = False
00090             reasons.append("The test left the system in show_desktop mode.")
00091             log.warning("Test left the system in show desktop mode, exiting it...")
00092             self.window_manager.leave_show_desktop()
00093         for launcher in self.launcher.get_launchers():
00094             if launcher.in_keynav_mode:
00095                 well_behaved = False
00096                 reasons.append("The test left the launcher keynav mode enabled.")
00097                 log.warning("Test left the launcher in keynav mode, exiting it...")
00098                 launcher.key_nav_cancel()
00099             if launcher.in_switcher_mode:
00100                 well_behaved = False
00101                 reasons.append("The test left the launcher in switcher mode.")
00102                 log.warning("Test left the launcher in switcher mode, exiting it...")
00103                 launcher.switcher_cancel()
00104 
00105         if not well_behaved:
00106             self.fail("/n".join(reasons))
00107         else:
00108             log.info("Test was well behaved.")

def unity.tests.UnityTestCase.dash (   self) [inherited]

Definition at line 110 of file __init__.py.

00110 
00111     def dash(self):
00112         if not getattr(self, '__dash', None):
00113             self.__dash = Dash()
00114         return self.__dash

def unity.tests.UnityTestCase.hud (   self) [inherited]

Definition at line 116 of file __init__.py.

00116 
00117     def hud(self):
00118         if not getattr(self, '__hud', None):
00119             self.__hud = Hud();
00120         return self.__hud

def unity.tests.UnityTestCase.launcher (   self) [inherited]

Definition at line 122 of file __init__.py.

00122 
00123     def launcher(self):
00124         if not getattr(self, '__launcher', None):
00125             self.__launcher = self._get_launcher_controller()
00126         return self.__launcher

def unity.tests.UnityTestCase.panels (   self) [inherited]

Definition at line 128 of file __init__.py.

00128 
00129     def panels(self):
00130         if not getattr(self, '__panels', None):
00131             self.__panels = self._get_panel_controller()
00132         return self.__panels

def unity.tests.test_switcher.SwitcherTestCase.set_timeout_setting (   self,
  state 
) [inherited]

Definition at line 22 of file test_switcher.py.

00022 
00023     def set_timeout_setting(self, state):
00024         if type(state) is not bool:
00025             raise TypeError("'state' must be boolean, not %r" % type(state))
00026         self.set_unity_option("alt_tab_timeout", state)
00027         sleep(1)
00028 

Here is the caller graph for this function:

def unity.tests.UnityTestCase.set_unity_log_level (   self,
  component,
  level 
) [inherited]
Set the unity log level for 'component' to 'level'.

Valid levels are: TRACE, DEBUG, INFO, WARNING and ERROR.

Components are dotted unity component names. The empty string specifies
the root logging component.

Definition at line 183 of file __init__.py.

00183 
00184     def set_unity_log_level(self, component, level):
00185         """Set the unity log level for 'component' to 'level'.
00186 
00187         Valid levels are: TRACE, DEBUG, INFO, WARNING and ERROR.
00188 
00189         Components are dotted unity component names. The empty string specifies
00190         the root logging component.
00191         """
00192         valid_levels = ('TRACE', 'DEBUG', 'INFO', 'WARN', 'WARNING', 'ERROR')
00193         if level not in valid_levels:
00194             raise ValueError("Log level '%s' must be one of: %r" % (level, valid_levels))
00195         set_log_severity(component, level)

Here is the call graph for this function:

Here is the caller graph for this function:

Reimplemented from unity.tests.UnityTestCase.

Definition at line 32 of file test_switcher.py.

00032 
00033     def setUp(self):
00034         super(SwitcherTests, self).setUp()
00035         self.set_timeout_setting(False)
00036         self.char_map = self.start_app('Character Map')
00037         self.calc = self.start_app('Calculator')
00038         self.mahjongg = self.start_app('Mahjongg')

Here is the call graph for this function:

def unity.tests.UnityTestCase.switcher (   self) [inherited]

Definition at line 134 of file __init__.py.

00134 
00135     def switcher(self):
00136         if not getattr(self, '__switcher', None):
00137             self.__switcher = Switcher()
00138         return self.__switcher

Definition at line 39 of file test_switcher.py.

00039 
00040     def tearDown(self):
00041         super(SwitcherTests, self).tearDown()

Starting switcher in details mode must show the focused window title.

Definition at line 51 of file test_switcher.py.

00051 
00052     def test_first_detail_mode_has_correct_label(self):
00053         """Starting switcher in details mode must show the focused window title."""
00054         app = self.start_app("Text Editor")
00055         sleep(1)
00056 
00057         [title] = [w.title for w in app.get_windows() if w.is_focused]
00058         self.switcher.initiate(SwitcherMode.DETAIL)
00059         self.addCleanup(self.switcher.terminate)
00060 
00061         self.assertThat(self.switcher.controller.view.label, Eventually(Equals(title)))

Definition at line 167 of file test_switcher.py.

00167 
00168     def test_lazy_switcher_cancel(self):
00169         self.keybinding_hold("switcher/reveal_normal")
00170         self.addCleanup(self.keybinding_release, "switcher/reveal_normal")
00171         self.assertThat(self.switcher.visible, Eventually(Equals(False)))
00172         self.keybinding_tap("switcher/reveal_normal")
00173         self.assertThat(self.switcher.visible, Eventually(Equals(True)))
00174         self.switcher.cancel()
00175         self.assertThat(self.switcher.visible, Eventually(Equals(False)))

Definition at line 150 of file test_switcher.py.

00150 
00151     def test_lazy_switcher_initiate(self):
00152         self.keybinding_hold("switcher/reveal_normal")
00153         self.addCleanup(self.keybinding_release, "switcher/reveal_normal")
00154         self.assertThat(self.switcher.visible, Eventually(Equals(False)))
00155 
00156         self.keybinding_tap("switcher/reveal_normal")
00157         self.addCleanup(self.keybinding, "switcher/cancel")
00158         self.assertThat(self.switcher.visible, Eventually(Equals(True)))

Tests that alt+f4 does not work while switcher is active.

Definition at line 193 of file test_switcher.py.

00193 
00194     def test_switcher_alt_f4_is_disabled(self):
00195         """Tests that alt+f4 does not work while switcher is active."""
00196 
00197         app = self.start_app("Text Editor")
00198         sleep(1)
00199 
00200         self.switcher.initiate(SwitcherMode.DETAIL)
00201         self.addCleanup(self.switcher.terminate)
00202 
00203         self.keyboard.press_and_release("Alt+F4")
00204         [win] = [w for w in app.get_windows()]
00205 
00206         # Need the sleep to allow the window time to close, for jenkins!
00207         sleep(10)
00208         self.assertThat(win.is_valid, Equals(True))
00209 

Tests that the switches appears on the correct monitor.

This is defined as the monitor with a focused window.

Definition at line 176 of file test_switcher.py.

00176 
00177     def test_switcher_appears_on_monitor_with_focused_window(self):
00178         """Tests that the switches appears on the correct monitor.
00179 
00180         This is defined as the monitor with a focused window.
00181 
00182         """
00183         num_monitors = self.screen_geo.get_num_monitors()
00184         if num_monitors == 1:
00185             self.skip("No point testing this on one monitor")
00186 
00187         [calc_win] = self.calc.get_windows()
00188         for monitor in range(num_monitors):
00189             self.screen_geo.drag_window_to_monitor(calc_win, monitor)
00190             self.switcher.initiate()
00191             self.addCleanup(self.switcher.terminate)
00192             self.assertThat(self.switcher.controller.monitor, Eventually(Equals(monitor)))

Ensure that Alt+Right does not initiate switcher.

Regression test for LP:??????

Definition at line 139 of file test_switcher.py.

00139 
00140     def test_switcher_arrow_key_does_not_init(self):
00141         """Ensure that Alt+Right does not initiate switcher.
00142 
00143         Regression test for LP:??????
00144 
00145         """
00146         self.keyboard.press('Alt')
00147         self.addCleanup(self.keyboard.release, 'Alt')
00148         self.keyboard.press_and_release('Right')
00149         self.assertThat(self.switcher.visible, Equals(False))

Definition at line 159 of file test_switcher.py.

00159 
00160     def test_switcher_cancel(self):
00161         self.switcher.initiate()
00162         self.addCleanup(self.switcher.terminate)
00163 
00164         self.assertThat(self.switcher.visible, Eventually(Equals(True)))
00165         self.switcher.cancel()
00166         self.assertThat(self.switcher.visible, Eventually(Equals(False)))

Test that pressing the next icon binding moves to the next icon

Definition at line 62 of file test_switcher.py.

00062 
00063     def test_switcher_move_next(self):
00064         """Test that pressing the next icon binding moves to the next icon"""
00065         self.switcher.initiate()
00066         self.addCleanup(self.switcher.terminate)
00067 
00068         start = self.switcher.selection_index
00069         self.switcher.next_icon()
00070         self.assertThat(self.switcher.selection_index, Equals(start + 1))

Test that pressing the previous icon binding moves to the previous icon

Definition at line 71 of file test_switcher.py.

00071 
00072     def test_switcher_move_prev(self):
00073         """Test that pressing the previous icon binding moves to the previous icon"""
00074         self.switcher.initiate()
00075         self.addCleanup(self.switcher.terminate)
00076 
00077         start = self.switcher.selection_index
00078         self.switcher.previous_icon()
00079         self.assertThat(self.switcher.selection_index, Equals(start - 1))

Test that scrolling the mouse wheel down moves to the next icon

Definition at line 80 of file test_switcher.py.

00080 
00081     def test_switcher_scroll_next(self):
00082         """Test that scrolling the mouse wheel down moves to the next icon"""
00083         self.switcher.initiate()
00084         self.addCleanup(self.switcher.terminate)
00085 
00086         start = self.switcher.selection_index
00087         self.switcher.next_via_mouse()
00088 
00089         self.assertThat(self.switcher.selection_index, Equals(start + 1))

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.

Definition at line 103 of file test_switcher.py.

00103 
00104     def test_switcher_scroll_next_ignores_fast_events(self):
00105         """Ensures that smoothing is working correctly for next icon scrolling.
00106 
00107         Only the first event in a rapid fire string of events should be acted upon.
00108         The rest ignored.
00109 
00110         """
00111         self.switcher.initiate()
00112         self.addCleanup(self.switcher.terminate)
00113 
00114         # Quickly repeated events should be ignored (except the first)
00115         start = self.switcher.selection_index
00116         self.switcher.next_via_mouse()
00117         self.switcher.next_via_mouse()
00118         self.switcher.next_via_mouse()
00119 
00120         self.assertThat(self.switcher.selection_index, Equals(start + 1))

Test that scrolling the mouse wheel up moves to the previous icon

Definition at line 90 of file test_switcher.py.

00090 
00091     def test_switcher_scroll_prev(self):
00092         """Test that scrolling the mouse wheel up moves to the previous icon"""
00093         self.switcher.initiate()
00094         self.addCleanup(self.switcher.terminate)
00095 
00096         start = self.switcher.selection_index
00097         self.switcher.previous_via_mouse()
00098 
00099         end = self.switcher.selection_index
00100         self.assertThat(end, Equals(start - 1))
00101 
00102         self.switcher.terminate()

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.

Definition at line 121 of file test_switcher.py.

00121 
00122     def test_switcher_scroll_prev_ignores_fast_events(self):
00123         """Ensures that smoothing is working correctly for previous icon scrolling.
00124 
00125         Only the first event in a rapid fire string of events should be acted upon.
00126         The rest ignored.
00127 
00128         """
00129         self.switcher.initiate()
00130         self.addCleanup(self.switcher.terminate)
00131 
00132         # Quickly repeatead events should be ignored (except the first)
00133         start = self.switcher.selection_index
00134         self.switcher.previous_via_mouse()
00135         self.switcher.previous_via_mouse()
00136         self.switcher.previous_via_mouse()
00137 
00138         self.assertThat(self.switcher.selection_index, Equals(start - 1))

Switcher must start in normal (i.e.- not details) mode.

Definition at line 42 of file test_switcher.py.

00042 
00043     def test_witcher_starts_in_normal_mode(self):
00044         """Switcher must start in normal (i.e.- not details) mode."""
00045         self.start_app("Character Map")
00046         sleep(1)
00047 
00048         self.switcher.initiate()
00049         self.addCleanup(self.switcher.terminate)
00050         self.assertThat(self.switcher.mode, Equals(SwitcherMode.NORMAL))

def unity.tests.UnityTestCase.window_manager (   self) [inherited]

Definition at line 140 of file __init__.py.

00140 
00141     def window_manager(self):
00142         if not getattr(self, '__window_manager', None):
00143             self.__window_manager = self._get_window_manager()
00144         return self.__window_manager

def unity.tests.UnityTestCase.workspace (   self) [inherited]

Definition at line 146 of file __init__.py.

00146 
00147     def workspace(self):
00148         if not getattr(self, '__workspace', None):
00149             self.__workspace = WorkspaceManager()
00150         return self.__workspace


Member Data Documentation

Definition at line 36 of file test_switcher.py.

Definition at line 35 of file test_switcher.py.

Definition at line 37 of file test_switcher.py.


The documentation for this class was generated from the following file: