Back to index

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

List of all members.

Public Member Functions

def start_keynav_with_cleanup_cancel
def safe_quit_keynav
def test_launcher_keynav_initiate
def test_launcher_keynav_cancel
def test_launcher_keynav_cancel_resume_focus
def test_launcher_keynav_starts_at_index_zero
def test_launcher_keynav_forward
def test_launcher_keynav_prev_works
def test_launcher_keynav_cycling_forward
def test_launcher_keynav_cycling_backward
def test_launcher_keynav_can_open_and_close_quicklist
def test_launcher_keynav_mode_toggles
def test_launcher_keynav_activate_keep_focus
def test_launcher_keynav_expo_focus
def test_launcher_keynav_expo_exit_on_esc
def test_launcher_keynav_alt_tab_quits
def test_launcher_keynav_alt_grave_quits
def test_launcher_keynav_cancel_doesnt_activate_icon
def test_alt_f1_closes_dash
def test_alt_f1_closes_hud
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

Test the launcher key navigation

Definition at line 21 of file test_keynav.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 34 of file test_keynav.py.

00034 
00035     def safe_quit_keynav(self):
00036         """Quit the keynav mode if it's engaged."""
00037         if self.launcher.key_nav_is_active:
00038             self.launcher_instance.key_nav_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 keynav 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 24 of file test_keynav.py.

00024 
00025     def start_keynav_with_cleanup_cancel(self):
00026         """Start keynav mode safely.
00027 
00028         This adds a cleanup action that cancels keynav mode at the end of the
00029         test if it's still running (but does nothing otherwise).
00030 
00031         """
00032         self.launcher_instance.key_nav_start()
00033         self.addCleanup(self.safe_quit_keynav)

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

Pressing Alt+F1 when the Dash is open must close the Dash and start keynav.

Definition at line 184 of file test_keynav.py.

00184 
00185     def test_alt_f1_closes_dash(self):
00186         """Pressing Alt+F1 when the Dash is open must close the Dash and start keynav."""
00187         self.dash.ensure_visible()
00188 
00189         self.start_keynav_with_cleanup_cancel()
00190 
00191         self.assertThat(self.dash.visible, Equals(False))
00192         self.assertThat(self.launcher.key_nav_is_active, Equals(True))

Here is the call graph for this function:

Pressing Alt+F1 when the HUD is open must close the HUD and start keynav.

Definition at line 193 of file test_keynav.py.

00193 
00194     def test_alt_f1_closes_hud(self):
00195         """Pressing Alt+F1 when the HUD is open must close the HUD and start keynav."""
00196         self.hud.ensure_visible()
00197 
00198         self.start_keynav_with_cleanup_cancel()
00199 
00200         self.assertThat(self.hud.visible, Equals(False))
00201         self.assertThat(self.launcher.key_nav_is_active, Equals(True))

Here is the call graph for this function:

Activating a running launcher icon must focus it.

Definition at line 128 of file test_keynav.py.

00128 
00129     def test_launcher_keynav_activate_keep_focus(self):
00130         """Activating a running launcher icon must focus it."""
00131         calc = self.start_app("Calculator")
00132         mahjongg = self.start_app("Mahjongg")
00133         self.assertTrue(mahjongg.is_active)
00134         self.assertFalse(calc.is_active)
00135 
00136         self.start_keynav_with_cleanup_cancel()
00137 
00138         self.launcher_instance.keyboard_select_icon(tooltip_text=calc.name)
00139         self.launcher_instance.key_nav_activate()
00140 
00141         self.assertTrue(calc.is_active)
00142         self.assertFalse(mahjongg.is_active)

Here is the call graph for this function:

Tests that alt+` exits keynav mode.

Definition at line 171 of file test_keynav.py.

00171 
00172     def test_launcher_keynav_alt_grave_quits(self):
00173         """Tests that alt+` exits keynav mode."""
00174         self.start_keynav_with_cleanup_cancel()
00175         # Can't use switcher emulat here since the switcher won't appear.
00176         self.keybinding("switcher/reveal_details")
00177         self.assertThat(self.launcher.key_nav_is_active, Eventually(Equals(False)))

Here is the call graph for this function:

Tests that alt+tab exits keynav mode.

Definition at line 163 of file test_keynav.py.

00163 
00164     def test_launcher_keynav_alt_tab_quits(self):
00165         """Tests that alt+tab exits keynav mode."""
00166         self.start_keynav_with_cleanup_cancel()
00167 
00168         self.keybinding("switcher/reveal_normal")
00169         self.addCleanup(self.switcher.terminate)
00170         self.assertThat(self.launcher.key_nav_is_active, Eventually(Equals(False)))

Here is the call graph for this function:

Tests that we can open and close a quicklist from keynav mode.

Definition at line 110 of file test_keynav.py.

00110 
00111     def test_launcher_keynav_can_open_and_close_quicklist(self):
00112         """Tests that we can open and close a quicklist from keynav mode."""
00113         self.start_keynav_with_cleanup_cancel()
00114         self.launcher_instance.key_nav_next()
00115         self.launcher_instance.key_nav_enter_quicklist()
00116         self.assertThat(self.launcher_instance.quicklist_open, Eventually(Equals(True)))
00117         self.launcher_instance.key_nav_exit_quicklist()
00118         self.assertThat(self.launcher_instance.quicklist_open, Eventually(Equals(False)))
00119         self.assertThat(self.launcher.key_nav_is_active, Eventually(Equals(True)))
00120         self.assertThat(self.launcher.key_nav_is_grabbed, Eventually(Equals(True)))

Here is the call graph for this function:

Test that we can exit keynav mode.

Definition at line 45 of file test_keynav.py.

00045 
00046     def test_launcher_keynav_cancel(self):
00047         """Test that we can exit keynav mode."""
00048         self.launcher_instance.key_nav_start()
00049         self.launcher_instance.key_nav_cancel()
00050         self.assertThat(self.launcher.key_nav_is_active, Eventually(Equals(False)))
00051         self.assertThat(self.launcher.key_nav_is_grabbed, Eventually(Equals(False)))

This tests when canceling keynav the current icon doesnt activate.

Definition at line 178 of file test_keynav.py.

00178 
00179     def test_launcher_keynav_cancel_doesnt_activate_icon(self):
00180         """This tests when canceling keynav the current icon doesnt activate."""
00181         self.start_keynav_with_cleanup_cancel()
00182         self.keyboard.press_and_release("Escape")
00183         self.assertThat(self.dash.visible, Eventually(Equals(False)))

Here is the call graph for this function:

Test that ending the launcher keynav resume the focus.

Definition at line 52 of file test_keynav.py.

00052 
00053     def test_launcher_keynav_cancel_resume_focus(self):
00054         """Test that ending the launcher keynav resume the focus."""
00055         calc = self.start_app("Calculator")
00056         self.assertTrue(calc.is_active)
00057 
00058         self.start_keynav_with_cleanup_cancel()
00059         self.assertFalse(calc.is_active)
00060 
00061         self.launcher_instance.key_nav_cancel()
00062         self.assertTrue(calc.is_active)

Here is the call graph for this function:

Launcher keynav must loop through icons when cycling backwards

Definition at line 103 of file test_keynav.py.

00103 
00104     def test_launcher_keynav_cycling_backward(self):
00105         """Launcher keynav must loop through icons when cycling backwards"""
00106         self.start_keynav_with_cleanup_cancel()
00107         self.launcher_instance.key_nav_prev()
00108         # FIXME We can't directly check for self.launcher.num_launcher_icons - 1
00109         self.assertThat(self.launcher.key_nav_selection, Eventually(GreaterThan(1)))

Here is the call graph for this function:

Launcher keynav must loop through icons when cycling forwards

Definition at line 88 of file test_keynav.py.

00088 
00089     def test_launcher_keynav_cycling_forward(self):
00090         """Launcher keynav must loop through icons when cycling forwards"""
00091         self.start_keynav_with_cleanup_cancel()
00092         prev_icon = 0
00093         for icon in range(1, self.launcher.model.num_launcher_icons()):
00094             self.launcher_instance.key_nav_next()
00095             # FIXME We can't directly check for selection/icon number equalty
00096             # since the launcher model also contains "hidden" icons that aren't
00097             # shown, so the selection index can increment by more than 1.
00098             self.assertThat(self.launcher.key_nav_selection, Eventually(GreaterThan(prev_icon)))
00099             prev_icon = self.launcher.key_nav_selection
00100 
00101         self.launcher_instance.key_nav_next()
00102         self.assertThat(self.launcher.key_nav_selection, Eventually(Equals(0)))

Here is the call graph for this function:

Esc should quit expo when entering it from KeyNav.

Definition at line 153 of file test_keynav.py.

00153 
00154     def test_launcher_keynav_expo_exit_on_esc(self):
00155         """Esc should quit expo when entering it from KeyNav."""
00156         self.start_keynav_with_cleanup_cancel()
00157 
00158         self.launcher_instance.keyboard_select_icon(tooltip_text="Workspace Switcher")
00159         self.launcher_instance.key_nav_activate()
00160 
00161         self.keyboard.press_and_release("Escape")
00162         self.assertThat(self.window_manager.expo_active, Eventually(Equals(False)))

Here is the call graph for this function:

When entering expo mode from KeyNav the Desktop must get focus.

Definition at line 143 of file test_keynav.py.

00143 
00144     def test_launcher_keynav_expo_focus(self):
00145         """When entering expo mode from KeyNav the Desktop must get focus."""
00146         self.start_keynav_with_cleanup_cancel()
00147 
00148         self.launcher_instance.keyboard_select_icon(tooltip_text="Workspace Switcher")
00149         self.launcher_instance.key_nav_activate()
00150         self.addCleanup(self.keybinding, "expo/cancel")
00151 
00152         self.assertThat(self.panels.get_active_panel().title, Eventually(Equals("Ubuntu Desktop")))

Here is the call graph for this function:

Must be able to move forwards while in keynav mode.

Definition at line 68 of file test_keynav.py.

00068 
00069     def test_launcher_keynav_forward(self):
00070         """Must be able to move forwards while in keynav mode."""
00071         self.start_keynav_with_cleanup_cancel()
00072         self.launcher_instance.key_nav_next()
00073         # The launcher model has hidden items, so the keynav indexes do not
00074         # increase by 1 each time. This test was failing because the 2nd icon
00075         # had an index of 2, not 1 as expected. The best we can do here is to
00076         # make sure that the index has increased. This opens us to the
00077         # possibility that the launcher really is skipping forward more than one
00078         # icon at a time, but we can't do much about that.
00079         self.assertThat(self.launcher.key_nav_selection, Eventually(GreaterThan(0)))

Here is the call graph for this function:

Tests we can initiate keyboard navigation on the launcher.

Definition at line 39 of file test_keynav.py.

00039 
00040     def test_launcher_keynav_initiate(self):
00041         """Tests we can initiate keyboard navigation on the launcher."""
00042         self.start_keynav_with_cleanup_cancel()
00043         self.assertThat(self.launcher.key_nav_is_active, Eventually(Equals(True)))
00044         self.assertThat(self.launcher.key_nav_is_grabbed, Eventually(Equals(True)))

Here is the call graph for this function:

Tests that keynav mode toggles with Alt+F1.

Definition at line 121 of file test_keynav.py.

00121 
00122     def test_launcher_keynav_mode_toggles(self):
00123         """Tests that keynav mode toggles with Alt+F1."""
00124         # was initiated in setup.
00125         self.start_keynav_with_cleanup_cancel()
00126         self.keybinding("launcher/keynav")
00127         self.assertThat(self.launcher.key_nav_is_active, Eventually(Equals(False)))

Here is the call graph for this function:

Must be able to move backwards while in keynav mode.

Definition at line 80 of file test_keynav.py.

00080 
00081     def test_launcher_keynav_prev_works(self):
00082         """Must be able to move backwards while in keynav mode."""
00083         self.start_keynav_with_cleanup_cancel()
00084         self.launcher_instance.key_nav_next()
00085         self.assertThat(self.launcher.key_nav_selection, Eventually(GreaterThan(0)))
00086         self.launcher_instance.key_nav_prev()
00087         self.assertThat(self.launcher.key_nav_selection, Eventually(Equals(0)))

Here is the call graph for this function:

Test keynav mode starts at index 0.

Definition at line 63 of file test_keynav.py.

00063 
00064     def test_launcher_keynav_starts_at_index_zero(self):
00065         """Test keynav mode starts at index 0."""
00066         self.start_keynav_with_cleanup_cancel()
00067         self.assertThat(self.launcher.key_nav_selection, Eventually(Equals(0)))

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: