Back to index

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

List of all members.

Public Member Functions

def setUp
def open_quicklist_with_mouse
def open_quicklist_with_keyboard
def test_keynav_selects_first_item_when_unselected
def test_keynav_selects_first_item_when_selected
def test_keynav_next_selects_first_item_when_unselected
def test_keynav_selects_last_item_when_unselected
def test_keynav_selects_last_item_when_selected
def test_keynav_prev_selects_last_item_when_unselected
def test_launcher_keynav_selects_first_item
def test_keynav_next_selection_works
def test_keynav_prev_selection_works
def test_keynav_prev_is_cyclic
def test_keynav_next_is_cyclic
def test_keynav_mouse_interaction
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

 ql_app
 ql_launcher_icon
 ql_launcher
 quicklist

Detailed Description

Tests for the quicklist key navigation.

Definition at line 139 of file test_quicklist.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

Opens a quicklist using the keyboard.

Definition at line 162 of file test_quicklist.py.

00162 
00163     def open_quicklist_with_keyboard(self):
00164         """Opens a quicklist using the keyboard."""
00165         self.screen_geo.move_mouse_to_monitor(0)
00166         self.ql_launcher.key_nav_start()
00167         self.addCleanup(self.ql_launcher.key_nav_cancel)
00168 
00169         self.ql_launcher.keyboard_select_icon(tooltip_text=self.ql_app.name)
00170         self.keybinding("launcher/keynav/open-quicklist")
00171         self.addCleanup(self.keybinding, "launcher/keynav/close-quicklist")
00172 
00173         self.assertThat(self.ql_launcher_icon.get_quicklist, Eventually(NotEquals(None)))
00174         self.quicklist = self.ql_launcher_icon.get_quicklist()
00175         self.assertThat(lambda: self.quicklist.selected_item, Eventually(NotEquals(None)))

Here is the caller graph for this function:

Opens a quicklist with the mouse.

Definition at line 153 of file test_quicklist.py.

00153 
00154     def open_quicklist_with_mouse(self):
00155         """Opens a quicklist with the mouse."""
00156         self.ql_launcher.click_launcher_icon(self.ql_launcher_icon, button=3)
00157         self.addCleanup(self.keyboard.press_and_release, "Escape")
00158         self.quicklist = self.ql_launcher_icon.get_quicklist()
00159         self.assertThat(self.quicklist, NotEquals(None))
00160         self.quicklist.move_mouse_to_right()
00161         self.assertThat(self.quicklist.selected_item, Equals(None))

Here is the caller graph for this function:

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 142 of file test_quicklist.py.

00142 
00143     def setUp(self):
00144         super(QuicklistKeyNavigationTests, self).setUp()
00145 
00146         self.ql_app = self.start_app("Text Editor")
00147 
00148         self.ql_launcher_icon = self.launcher.model.get_icon_by_desktop_id(
00149             self.ql_app.desktop_file)
00150         self.assertThat(self.ql_launcher_icon, NotEquals(None))
00151 
00152         self.ql_launcher = self.launcher.get_launcher_for_monitor(0)

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

Tests that the interaction between key-navigation and mouse works as
expected. See bug #911561.

Definition at line 300 of file test_quicklist.py.

00300 
00301     def test_keynav_mouse_interaction(self):
00302         """Tests that the interaction between key-navigation and mouse works as
00303         expected. See bug #911561.
00304         """
00305         self.open_quicklist_with_mouse()
00306         mouse_item = self.quicklist.selectable_items[-1]
00307         mouse_item.mouse_move_to()
00308         self.assertThat(mouse_item.selected, Eventually(Equals(True)))
00309 
00310         self.keybinding("quicklist/keynav/prev")
00311         sleep(.1)
00312         self.keybinding("quicklist/keynav/prev")
00313 
00314         key_item = self.quicklist.selectable_items[-3]
00315         self.assertThat(key_item.selected, Eventually(Equals(True)))
00316         self.assertThat(self.quicklist.selected_item.id, Equals(key_item.id))
00317 
00318         # Moving the mouse horizontally doesn't change the selection
00319         self.mouse.move(mouse_item.x + mouse_item.width - 10, mouse_item.y + mouse_item.height / 2)
00320         self.assertThat(self.quicklist.selected_item.id, Equals(key_item.id))
00321 
00322         # Moving the mouse outside doesn't change the selection
00323         self.mouse.move(mouse_item.x + mouse_item.width + 50, mouse_item.y + mouse_item.height / 2)
00324         self.assertThat(self.quicklist.selected_item.id, Equals(key_item.id))
00325 
00326         # Moving the mouse to another entry, changes the selection
00327         mouse_item = self.quicklist.selectable_items[-2]
00328         mouse_item.mouse_move_to()
00329         self.assertThat(mouse_item.selected, Eventually(Equals(True)))
00330         self.assertThat(self.quicklist.selected_item.id, Equals(mouse_item.id))

Here is the call graph for this function:

Down key MUST select the first item, when the last one is selected.

Definition at line 287 of file test_quicklist.py.

00287 
00288     def test_keynav_next_is_cyclic(self):
00289         """Down key MUST select the first item, when the last one is selected."""
00290         self.open_quicklist_with_mouse()
00291 
00292         mouse_item = self.quicklist.selectable_items[-1]
00293         mouse_item.mouse_move_to()
00294         self.assertThat(mouse_item.selected, Eventually(Equals(True)))
00295 
00296         self.keybinding("quicklist/keynav/next")
00297         expected_item = self.quicklist.selectable_items[0]
00298         self.assertThat(expected_item.selected, Eventually(Equals(True)))
00299         self.assertThat(self.quicklist.selected_item.id, Equals(expected_item.id))

Here is the call graph for this function:

Down key MUST select the next valid item.

Definition at line 256 of file test_quicklist.py.

00256 
00257     def test_keynav_next_selection_works(self):
00258         """Down key MUST select the next valid item."""
00259         self.open_quicklist_with_mouse()
00260 
00261         for item in self.quicklist.selectable_items:
00262             self.keybinding("quicklist/keynav/next")
00263             self.assertThat(item.selected, Eventually(Equals(True)))
00264             self.assertThat(self.quicklist.selected_item.id, Equals(item.id))

Here is the call graph for this function:

Down key MUST select the first valid item when nothing is selected.

Definition at line 201 of file test_quicklist.py.

00201 
00202     def test_keynav_next_selects_first_item_when_unselected(self):
00203         """Down key MUST select the first valid item when nothing is selected."""
00204         self.open_quicklist_with_mouse()
00205 
00206         self.keybinding("quicklist/keynav/next")
00207 
00208         expected_item = self.quicklist.selectable_items[0]
00209         self.assertThat(expected_item.selected, Eventually(Equals(True)))
00210         self.assertThat(self.quicklist.selected_item.id, Equals(expected_item.id))

Here is the call graph for this function:

Up key MUST select the last item, when the first one is selected.

Definition at line 274 of file test_quicklist.py.

00274 
00275     def test_keynav_prev_is_cyclic(self):
00276         """Up key MUST select the last item, when the first one is selected."""
00277         self.open_quicklist_with_mouse()
00278 
00279         mouse_item = self.quicklist.selectable_items[0]
00280         mouse_item.mouse_move_to()
00281         self.assertThat(mouse_item.selected, Eventually(Equals(True)))
00282 
00283         self.keybinding("quicklist/keynav/prev")
00284         expected_item = self.quicklist.selectable_items[-1]
00285         self.assertThat(expected_item.selected, Eventually(Equals(True)))
00286         self.assertThat(self.quicklist.selected_item.id, Equals(expected_item.id))

Here is the call graph for this function:

Up key MUST select the previous valid item.

Definition at line 265 of file test_quicklist.py.

00265 
00266     def test_keynav_prev_selection_works(self):
00267         """Up key MUST select the previous valid item."""
00268         self.open_quicklist_with_mouse()
00269 
00270         for item in reversed(self.quicklist.selectable_items):
00271             self.keybinding("quicklist/keynav/prev")
00272             self.assertThat(item.selected, Eventually(Equals(True)))
00273             self.assertThat(self.quicklist.selected_item.id, Equals(item.id))

Here is the call graph for this function:

Up key MUST select the last valid item when nothing is selected.

Definition at line 236 of file test_quicklist.py.

00236 
00237     def test_keynav_prev_selects_last_item_when_unselected(self):
00238         """Up key MUST select the last valid item when nothing is selected."""
00239         self.open_quicklist_with_mouse()
00240 
00241         self.keybinding("quicklist/keynav/prev")
00242 
00243         expected_item = self.quicklist.selectable_items[-1]
00244         self.assertThat(expected_item.selected, Eventually(Equals(True)))
00245         self.assertThat(self.quicklist.selected_item.id, Equals(expected_item.id))

Here is the call graph for this function:

Home key MUST select the first selectable item in a quicklist when
another item is selected.

Definition at line 186 of file test_quicklist.py.

00186 
00187     def test_keynav_selects_first_item_when_selected(self):
00188         """Home key MUST select the first selectable item in a quicklist when
00189         another item is selected.
00190         """
00191         self.open_quicklist_with_mouse()
00192         mouse_item = self.quicklist.selectable_items[-1]
00193         mouse_item.mouse_move_to()
00194         self.assertThat(mouse_item.selected, Eventually(Equals(True)))
00195 
00196         self.keybinding("quicklist/keynav/first")
00197 
00198         expected_item = self.quicklist.selectable_items[0]
00199         self.assertThat(expected_item.selected, Eventually(Equals(True)))
00200         self.assertThat(self.quicklist.selected_item.id, Equals(expected_item.id))

Here is the call graph for this function:

Home key MUST select the first selectable item in a quicklist.

Definition at line 176 of file test_quicklist.py.

00176 
00177     def test_keynav_selects_first_item_when_unselected(self):
00178         """Home key MUST select the first selectable item in a quicklist."""
00179         self.open_quicklist_with_mouse()
00180 
00181         self.keybinding("quicklist/keynav/first")
00182 
00183         expected_item = self.quicklist.selectable_items[0]
00184         self.assertThat(expected_item.selected, Eventually(Equals(True)))
00185         self.assertThat(self.quicklist.selected_item.id, Equals(expected_item.id))

Here is the call graph for this function:

End key MUST select the last selectable item in a quicklist when
another item is selected.

Definition at line 221 of file test_quicklist.py.

00221 
00222     def test_keynav_selects_last_item_when_selected(self):
00223         """End key MUST select the last selectable item in a quicklist when
00224         another item is selected.
00225         """
00226         self.open_quicklist_with_mouse()
00227         mouse_item = self.quicklist.selectable_items[0]
00228         mouse_item.mouse_move_to()
00229         self.assertThat(mouse_item.selected, Eventually(Equals(True)))
00230 
00231         self.keybinding("quicklist/keynav/last")
00232 
00233         expected_item = self.quicklist.selectable_items[-1]
00234         self.assertThat(expected_item.selected, Eventually(Equals(True)))
00235         self.assertThat(self.quicklist.selected_item.id, Equals(expected_item.id))

Here is the call graph for this function:

End key MUST select the last selectable item in a quicklist.

Definition at line 211 of file test_quicklist.py.

00211 
00212     def test_keynav_selects_last_item_when_unselected(self):
00213         """End key MUST select the last selectable item in a quicklist."""
00214         self.open_quicklist_with_mouse()
00215 
00216         self.keybinding("quicklist/keynav/last")
00217 
00218         expected_item = self.quicklist.selectable_items[-1]
00219         self.assertThat(expected_item.selected, Eventually(Equals(True)))
00220         self.assertThat(self.quicklist.selected_item.id, Equals(expected_item.id))

Here is the call graph for this function:

The first selectable item of the quicklist must be selected when
opening the quicklist using the launcher key navigation.

Definition at line 246 of file test_quicklist.py.

00246 
00247     def test_launcher_keynav_selects_first_item(self):
00248         """The first selectable item of the quicklist must be selected when
00249         opening the quicklist using the launcher key navigation.
00250         """
00251         self.open_quicklist_with_keyboard()
00252 
00253         expected_item = self.quicklist.selectable_items[0]
00254         self.assertThat(expected_item.selected, Eventually(Equals(True)))
00255         self.assertThat(self.quicklist.selected_item.id, Equals(expected_item.id))

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 145 of file test_quicklist.py.

Definition at line 151 of file test_quicklist.py.

Definition at line 147 of file test_quicklist.py.

Definition at line 157 of file test_quicklist.py.


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