Back to index

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

List of all members.

Public Member Functions

def start_switcher_with_cleanup_cancel
def safe_quit_switcher
def test_launcher_switcher_cancel
def test_launcher_switcher_cancel_resume_focus
def test_launcher_switcher_starts_at_index_zero
def test_launcher_switcher_next
def test_launcher_switcher_prev
def test_launcher_switcher_down
def test_launcher_switcher_up
def test_launcher_switcher_next_doesnt_show_shortcuts
def test_launcher_switcher_prev_doesnt_show_shortcuts
def test_launcher_switcher_cycling_forward
def test_launcher_switcher_cycling_backward
def test_launcher_switcher_activate_keep_focus
def test_launcher_switcher_using_shorcuts
def setUp
def get_launcher
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

 screen_geo
 launcher_instance

Static Public Attributes

tuple scenarios = _make_scenarios()

Detailed Description

Tests the functionality of the launcher's switcher capability

Definition at line 24 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

Get the launcher for the current scenario.

Definition at line 57 of file __init__.py.

00057 
00058     def get_launcher(self):
00059         """Get the launcher for the current scenario."""
00060         return self.launcher.get_launcher_for_monitor(self.launcher_monitor)

Here is the caller graph for this function:

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

Quit the keynav mode if it's engaged.

Definition at line 37 of file test_switcher.py.

00037 
00038     def safe_quit_switcher(self):
00039         """Quit the keynav mode if it's engaged."""
00040         if self.launcher.key_nav_is_active:
00041             self.launcher_instance.switcher_cancel()

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:

def unity.tests.launcher.LauncherTestCase.setUp (   self) [inherited]

Reimplemented from unity.tests.UnityTestCase.

Reimplemented in unity.tests.launcher.test_icon_behavior.LauncherIconsTests, unity.tests.launcher.test_reveal.LauncherRevealTests, and unity.tests.launcher.test_shortcut.LauncherShortcutTests.

Definition at line 40 of file __init__.py.

00040 
00041     def setUp(self):
00042         super(LauncherTestCase, self).setUp()
00043         self.screen_geo = ScreenGeometry()
00044         self.set_unity_log_level("unity.launcher", "DEBUG")
00045         self.addCleanup(self.set_unity_log_level, "unity.launcher", "INFO")
00046 
00047         self.set_unity_option('num_launchers', int(self.only_primary))
00048         self.launcher_instance = self.get_launcher()
00049 
00050         if self.only_primary:
00051             try:
00052                 old_primary_screen = self.screen_geo.get_primary_monitor()
00053                 self.screen_geo.set_primary_monitor(self.launcher_monitor)
00054                 self.addCleanup(self.screen_geo.set_primary_monitor, old_primary_screen)
00055             except ScreenGeometry.BlacklistedDriverError:
00056                 self.skipTest("Impossible to set the monitor %d as primary" % self.launcher_monitor)

Start switcher mode safely.

This adds a cleanup action that cancels keynav mode at the end of the
test if it's still running (but does nothing otherwise).

Definition at line 27 of file test_switcher.py.

00027 
00028     def start_switcher_with_cleanup_cancel(self):
00029         """Start switcher mode safely.
00030 
00031         This adds a cleanup action that cancels keynav mode at the end of the
00032         test if it's still running (but does nothing otherwise).
00033 
00034         """
00035         self.launcher_instance.switcher_start()
00036         self.addCleanup(self.safe_quit_switcher)

Here is the call graph for this function:

Here is the caller 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

Activating a running launcher icon should focus the application.

Definition at line 146 of file test_switcher.py.

00146 
00147     def test_launcher_switcher_activate_keep_focus(self):
00148         """Activating a running launcher icon should focus the application."""
00149         calc = self.start_app("Calculator")
00150         mahjongg = self.start_app("Mahjongg")
00151         self.assertTrue(mahjongg.is_active)
00152         self.assertFalse(calc.is_active)
00153 
00154         self.start_switcher_with_cleanup_cancel()
00155 
00156         self.launcher_instance.keyboard_select_icon(tooltip_text=calc.name)
00157         self.launcher_instance.switcher_activate()
00158 
00159         self.assertThat(lambda: calc.is_active, Eventually(Equals(True)))
00160         self.assertThat(lambda: mahjongg.is_active, Eventually(Equals(False)))

Here is the call graph for this function:

Test that ending the launcher switcher actually works.

Definition at line 42 of file test_switcher.py.

00042 
00043     def test_launcher_switcher_cancel(self):
00044         """Test that ending the launcher switcher actually works."""
00045         self.launcher_instance.switcher_start()
00046         self.launcher_instance.switcher_cancel()
00047         self.assertThat(self.launcher.key_nav_is_active, Eventually(Equals(False)))

Test that ending the launcher switcher resume the focus.

Definition at line 48 of file test_switcher.py.

00048 
00049     def test_launcher_switcher_cancel_resume_focus(self):
00050         """Test that ending the launcher switcher resume the focus."""
00051         self.close_all_app("Calculator")
00052         calc = self.start_app("Calculator")
00053         self.assertTrue(calc.is_active)
00054 
00055         self.start_switcher_with_cleanup_cancel()
00056         sleep(.5)
00057         self.assertFalse(calc.is_active)
00058 
00059         self.launcher_instance.switcher_cancel()
00060         sleep(.5)
00061         self.assertTrue(calc.is_active)

Here is the call graph for this function:

Launcher Switcher must loop through icons when cycling backwards

Definition at line 139 of file test_switcher.py.

00139 
00140     def test_launcher_switcher_cycling_backward(self):
00141         """Launcher Switcher must loop through icons when cycling backwards"""
00142         self.start_switcher_with_cleanup_cancel()
00143         self.launcher_instance.switcher_prev()
00144         # FIXME We can't directly check for self.launcher.num_launcher_icons - 1
00145         self.assertThat(self.launcher.key_nav_selection, Eventually(GreaterThan(1)))

Here is the call graph for this function:

Launcher Switcher must loop through icons when cycling forwards

Definition at line 122 of file test_switcher.py.

00122 
00123     def test_launcher_switcher_cycling_forward(self):
00124         """Launcher Switcher must loop through icons when cycling forwards"""
00125         self.start_switcher_with_cleanup_cancel()
00126         prev_icon = 0
00127         num_icons = self.launcher.model.num_launcher_icons()
00128         logger.info("This launcher has %d icons", num_icons)
00129         for icon in range(1, num_icons):
00130             self.launcher_instance.switcher_next()
00131             # FIXME We can't directly check for selection/icon number equalty
00132             # since the launcher model also contains "hidden" icons that aren't
00133             # shown, so the selection index can increment by more than 1.
00134             self.assertThat(self.launcher.key_nav_selection, Eventually(GreaterThan(prev_icon)))
00135             prev_icon = self.launcher.key_nav_selection
00136 
00137         self.launcher_instance.switcher_next()
00138         self.assertThat(self.launcher.key_nav_selection, Eventually(Equals(0)))

Here is the call graph for this function:

Pressing the down arrow key while switcher is activated must work.

Definition at line 88 of file test_switcher.py.

00088 
00089     def test_launcher_switcher_down(self):
00090         """Pressing the down arrow key while switcher is activated must work."""
00091         self.start_switcher_with_cleanup_cancel()
00092         self.launcher_instance.switcher_down()
00093         # The launcher model has hidden items, so the keynav indexes do not
00094         # increase by 1 each time. This test was failing because the 2nd icon
00095         # had an index of 2, not 1 as expected. The best we can do here is to
00096         # make sure that the index has increased. This opens us to the
00097         # possibility that the launcher really is skipping forward more than one
00098         # icon at a time, but we can't do much about that.
00099         self.assertThat(self.launcher.key_nav_selection, Eventually(GreaterThan(0)))

Here is the call graph for this function:

Moving to the next launcher item while switcher is activated must work.

Definition at line 70 of file test_switcher.py.

00070 
00071     def test_launcher_switcher_next(self):
00072         """Moving to the next launcher item while switcher is activated must work."""
00073         self.start_switcher_with_cleanup_cancel()
00074         self.launcher_instance.switcher_next()
00075         # The launcher model has hidden items, so the keynav indexes do not
00076         # increase by 1 each time. This test was failing because the 2nd icon
00077         # had an index of 2, not 1 as expected. The best we can do here is to
00078         # make sure that the index has increased. This opens us to the
00079         # possibility that the launcher really is skipping forward more than one
00080         # icon at a time, but we can't do much about that.
00081         self.assertThat(self.launcher.key_nav_selection, Eventually(GreaterThan(0)))

Here is the call graph for this function:

Moving forward in launcher switcher must not show launcher shortcuts.

Definition at line 106 of file test_switcher.py.

00106 
00107     def test_launcher_switcher_next_doesnt_show_shortcuts(self):
00108         """Moving forward in launcher switcher must not show launcher shortcuts."""
00109         self.start_switcher_with_cleanup_cancel()
00110         self.launcher_instance.switcher_next()
00111         # sleep so that the shortcut timeout could be triggered
00112         sleep(2)
00113         self.assertThat(self.launcher_instance.shortcuts_shown, Eventually(Equals(False)))

Here is the call graph for this function:

Moving to the previous launcher item while switcher is activated must work.

Definition at line 82 of file test_switcher.py.

00082 
00083     def test_launcher_switcher_prev(self):
00084         """Moving to the previous launcher item while switcher is activated must work."""
00085         self.start_switcher_with_cleanup_cancel()
00086         self.launcher_instance.switcher_prev()
00087         self.assertThat(self.launcher.key_nav_selection, Eventually(NotEquals(0)))

Here is the call graph for this function:

Moving backward in launcher switcher must not show launcher shortcuts.

Definition at line 114 of file test_switcher.py.

00114 
00115     def test_launcher_switcher_prev_doesnt_show_shortcuts(self):
00116         """Moving backward in launcher switcher must not show launcher shortcuts."""
00117         self.start_switcher_with_cleanup_cancel()
00118         self.launcher_instance.switcher_prev()
00119         # sleep so that the shortcut timeout could be triggered
00120         sleep(2)
00121         self.assertThat(self.launcher_instance.shortcuts_shown, Eventually(Equals(False)))

Here is the call graph for this function:

Test that starting the Launcher switcher puts the keyboard focus on item 0.

Definition at line 62 of file test_switcher.py.

00062 
00063     def test_launcher_switcher_starts_at_index_zero(self):
00064         """Test that starting the Launcher switcher puts the keyboard focus on item 0."""
00065         self.start_switcher_with_cleanup_cancel()
00066 
00067         self.assertThat(self.launcher.key_nav_is_active, Eventually(Equals(True)))
00068         self.assertThat(self.launcher.key_nav_is_grabbed, Eventually(Equals(False)))
00069         self.assertThat(self.launcher.key_nav_selection, Eventually(Equals(0)))

Here is the call graph for this function:

Pressing the up arrow key while switcher is activated must work.

Definition at line 100 of file test_switcher.py.

00100 
00101     def test_launcher_switcher_up(self):
00102         """Pressing the up arrow key while switcher is activated must work."""
00103         self.start_switcher_with_cleanup_cancel()
00104         self.launcher_instance.switcher_up()
00105         self.assertThat(self.launcher.key_nav_selection, Eventually(NotEquals(0)))

Here is the call graph for this function:

Using some other shortcut while switcher is active must cancel switcher.

Definition at line 161 of file test_switcher.py.

00161 
00162     def test_launcher_switcher_using_shorcuts(self):
00163         """Using some other shortcut while switcher is active must cancel switcher."""
00164         self.start_switcher_with_cleanup_cancel()
00165         self.keyboard.press_and_release("s")
00166         sleep(.25)
00167         self.keyboard.press_and_release("Escape")
00168         sleep(.25)
00169         self.assertThat(self.launcher.key_nav_is_active, Eventually(Equals(False)))

Here is the call graph for this function:

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 47 of file __init__.py.

Definition at line 42 of file __init__.py.


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