Back to index

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

List of all members.

Public Member Functions

def test_shortcut_hint_hide_using_unity_shortcuts
def test_shortcut_hint_hide_pressing_modifiers
def test_launcher_switcher_next_doesnt_show_shortcut_hint
def test_launcher_switcher_prev_doesnt_show_shortcut_hint
def test_launcher_icons_hints_show_with_shortcut_hint
def test_shortcut_hint_shows_with_launcher_icons_hints
def setUp
def skip_if_monitor_too_small
def get_shortcut_controller
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

 DEFAULT_WIDTH
 DEFAULT_HEIGHT
 shortcut_hint

Detailed Description

Test the shortcuthint interactions with other Unity parts.

Definition at line 96 of file test_shortcut_hint.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

Definition at line 50 of file test_shortcut_hint.py.

00050 
00051     def get_launcher(self):
00052         # We could parameterise this so all tests run on both monitors (if MM is
00053         # set up), but I think it's fine to just always use monitor primary monitor:
00054         monitor = self.screen_geo.get_primary_monitor()
00055         return self.launcher.get_launcher_for_monitor(monitor)
00056 

Here is the caller graph for this function:

Definition at line 45 of file test_shortcut_hint.py.

00045 
00046     def get_shortcut_controller(self):
00047         controllers = ShortcutController.get_all_instances()
00048         self.assertThat(len(controllers), Equals(1))
00049         return controllers[0]

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.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 22 of file test_shortcut_hint.py.

00022 
00023     def setUp(self):
00024         super(BaseShortcutHintTests, self).setUp()
00025 
00026         self.DEFAULT_WIDTH = 970;
00027         self.DEFAULT_HEIGHT = 680;
00028 
00029         self.shortcut_hint = self.get_shortcut_controller()
00030         self.set_unity_option('shortcut_overlay', True)
00031         self.skip_if_monitor_too_small()
00032         sleep(1)

Definition at line 33 of file test_shortcut_hint.py.

00033 
00034     def skip_if_monitor_too_small(self):
00035         monitor = self.screen_geo.get_primary_monitor()
00036         monitor_geo = self.screen_geo.get_monitor_geometry(monitor);
00037         monitor_w = monitor_geo[2];
00038         monitor_h = monitor_geo[3];
00039         launcher_width = self.launcher.get_launcher_for_monitor(monitor).geometry[2];
00040         panel_height = 24 # TODO get it from panel
00041 
00042         if ((monitor_w - launcher_width) <= self.DEFAULT_WIDTH or
00043             (monitor_h - panel_height) <= self.DEFAULT_HEIGHT):
00044             self.skipTest("This test requires a bigger screen, to show the ShortcutHint")

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

When the shortcut hint is shown also the launcer's icons hints should
be shown.

Definition at line 143 of file test_shortcut_hint.py.

00143 
00144     def test_launcher_icons_hints_show_with_shortcut_hint(self):
00145         """When the shortcut hint is shown also the launcer's icons hints should
00146         be shown.
00147 
00148         """
00149         launcher = self.get_launcher()
00150         self.shortcut_hint.ensure_visible()
00151         self.addCleanup(self.shortcut_hint.ensure_hidden)
00152 
00153         self.assertThat(self.shortcut_hint.visible, Equals(True))
00154         self.assertThat(launcher.shortcuts_shown, Equals(True))

Here is the call graph for this function:

Super+Tab switcher cycling forward must not show shortcut hint.

Definition at line 116 of file test_shortcut_hint.py.

00116 
00117     def test_launcher_switcher_next_doesnt_show_shortcut_hint(self):
00118         """Super+Tab switcher cycling forward must not show shortcut hint."""
00119         switcher_timeout = self.shortcut_hint.get_show_timeout()
00120         self.shortcut_hint.show()
00121         self.addCleanup(self.shortcut_hint.ensure_hidden)
00122 
00123         self.keybinding("launcher/switcher/next")
00124         self.keybinding("launcher/switcher/next")
00125         self.addCleanup(self.keyboard.press_and_release, "Escape")
00126         sleep(switcher_timeout * 2)
00127 
00128         self.assertThat(self.shortcut_hint.visible, Equals(False))

Super+Tab switcher cycling backwards must not show shortcut hint.

Definition at line 129 of file test_shortcut_hint.py.

00129 
00130     def test_launcher_switcher_prev_doesnt_show_shortcut_hint(self):
00131         """Super+Tab switcher cycling backwards must not show shortcut hint."""
00132         switcher_timeout = self.shortcut_hint.get_show_timeout()
00133         self.shortcut_hint.show()
00134         self.addCleanup(self.shortcut_hint.ensure_hidden)
00135 
00136         self.keybinding("launcher/switcher/next")
00137         self.addCleanup(self.keyboard.press_and_release, "Escape")
00138         self.keybinding("launcher/switcher/next")
00139         self.keybinding("launcher/switcher/prev")
00140         sleep(switcher_timeout * 2)
00141 
00142         self.assertThat(self.shortcut_hint.visible, Equals(False))

Pressing a modifer key must hide the shortcut hint.

Definition at line 107 of file test_shortcut_hint.py.

00107 
00108     def test_shortcut_hint_hide_pressing_modifiers(self):
00109         """Pressing a modifer key must hide the shortcut hint."""
00110         self.shortcut_hint.ensure_visible()
00111         self.addCleanup(self.shortcut_hint.ensure_hidden)
00112 
00113         self.keyboard.press('Control')
00114 
00115         self.assertThat(self.shortcut_hint.visible, Eventually(Equals(False)))

Unity shortcuts (like expo) must hide the shortcut hint.

Definition at line 99 of file test_shortcut_hint.py.

00099 
00100     def test_shortcut_hint_hide_using_unity_shortcuts(self):
00101         """Unity shortcuts (like expo) must hide the shortcut hint."""
00102         self.shortcut_hint.ensure_visible()
00103         self.addCleanup(self.shortcut_hint.ensure_hidden)
00104 
00105         self.keybinding_tap("expo/start")
00106         self.addCleanup(self.keybinding, "expo/cancel")

When the launcher icons hints are shown also the shortcut hint should
be shown.

Definition at line 155 of file test_shortcut_hint.py.

00155 
00156     def test_shortcut_hint_shows_with_launcher_icons_hints(self):
00157         """When the launcher icons hints are shown also the shortcut hint should
00158         be shown.
00159 
00160         """
00161         launcher = self.get_launcher()
00162         launcher.keyboard_reveal_launcher()
00163         self.addCleanup(launcher.keyboard_unreveal_launcher)
00164 
00165         self.assertThat(launcher.shortcuts_shown, Eventually(Equals(True)))
00166         self.assertThat(self.shortcut_hint.visible, Eventually(Equals(True)))

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 26 of file test_shortcut_hint.py.

Definition at line 25 of file test_shortcut_hint.py.

Definition at line 28 of file test_shortcut_hint.py.


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