Back to index

unity  6.0.0
Public Member Functions
unity.tests.test_dash.DashKeyNavTests Class Reference
Inheritance diagram for unity.tests.test_dash.DashKeyNavTests:
Inheritance graph
[legend]
Collaboration diagram for unity.tests.test_dash.DashKeyNavTests:
Collaboration graph
[legend]

List of all members.

Public Member Functions

def test_lensbar_gets_keyfocus
def test_lensbar_focus_changes
def test_lensbar_enter_activation
def test_category_header_keynav
def test_control_tab_lens_cycle
def test_tab_cycle_category_headers
def test_tab_with_filter_bar
def setUp
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

Detailed Description

Test the unity Dash keyboard navigation.

Definition at line 151 of file test_dash.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.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.test_dash.DashTestCase.setUp (   self) [inherited]

Reimplemented from unity.tests.UnityTestCase.

Reimplemented in unity.tests.test_dash.DashBorderTests, unity.tests.test_dash.DashLensBarTests, and unity.tests.test_dash.DashMultiKeyTests.

Definition at line 21 of file test_dash.py.

00021 
00022     def setUp(self):
00023         super(DashTestCase, self).setUp()
00024         self.set_unity_log_level("unity.shell", "DEBUG")
00025         self.set_unity_log_level("unity.launcher", "DEBUG")
00026         self.dash.ensure_hidden()
00027         # On shutdown, ensure hidden too.  Also add a delay.  Cleanup is LIFO.
00028         self.addCleanup(self.dash.ensure_hidden)
00029         self.addCleanup(sleep, 1)
00030 

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

Tests that a category header gets focus when 'down' is pressed after the
dash is opened

OK important to note that this test only tests that A category is
focused, not the first and from doing this it seems that it's common
for a header other than the first to get focus.

Definition at line 198 of file test_dash.py.

00198 
00199     def test_category_header_keynav(self):
00200         """ Tests that a category header gets focus when 'down' is pressed after the
00201         dash is opened
00202 
00203         OK important to note that this test only tests that A category is
00204         focused, not the first and from doing this it seems that it's common
00205         for a header other than the first to get focus.
00206         """
00207         self.dash.ensure_visible()
00208         # Make sure that a category have the focus.
00209         self.keyboard.press_and_release("Down")
00210         lens = self.dash.get_current_lens()
00211         category = lens.get_focused_category()
00212         self.assertIsNot(category, None)
00213         # Make sure that the category is highlighted.
00214         self.assertTrue(category.header_is_highlighted)

This test makes sure that Ctrl+Tab cycles lenses.

Definition at line 215 of file test_dash.py.

00215 
00216     def test_control_tab_lens_cycle(self):
00217         """This test makes sure that Ctrl+Tab cycles lenses."""
00218         self.dash.ensure_visible()
00219 
00220         self.keyboard.press('Control')
00221         self.keyboard.press_and_release('Tab')
00222         self.keyboard.release('Control')
00223 
00224         lensbar = self.dash.view.get_lensbar()
00225         self.assertEqual(lensbar.active_lens, u'applications.lens')
00226 
00227         self.keyboard.press('Control')
00228         self.keyboard.press('Shift')
00229         self.keyboard.press_and_release('Tab')
00230         self.keyboard.release('Control')
00231         self.keyboard.release('Shift')
00232 
00233         self.assertThat(lensbar.active_lens, Eventually(Equals('home.lens')))

Must be able to activate LensBar icons that have focus with an Enter keypress.

Definition at line 180 of file test_dash.py.

00180 
00181     def test_lensbar_enter_activation(self):
00182         """Must be able to activate LensBar icons that have focus with an Enter keypress."""
00183         self.dash.ensure_visible()
00184 
00185         for i in range(self.dash.get_num_rows()):
00186             self.keyboard.press_and_release("Down")
00187         self.keyboard.press_and_release("Right");
00188         lensbar = self.dash.view.get_lensbar()
00189         focused_icon = lensbar.focused_lens_icon
00190         self.keyboard.press_and_release("Enter");
00191 
00192         self.assertThat(lensbar.active_lens, Eventually(Equals(focused_icon)))
00193 
00194         # lensbar should lose focus after activation.
00195         # TODO this should be a different test to make sure focus
00196         # returns to the correct place.
00197         self.assertThat(lensbar.focused_lens_icon, Eventually(Equals("")))

Lensbar focused icon should change with Left and Right keypresses.

Definition at line 164 of file test_dash.py.

00164 
00165     def test_lensbar_focus_changes(self):
00166         """Lensbar focused icon should change with Left and Right keypresses."""
00167         self.dash.ensure_visible()
00168 
00169         for i in range(self.dash.get_num_rows()):
00170             self.keyboard.press_and_release("Down")
00171         lensbar = self.dash.view.get_lensbar()
00172 
00173         current_focused_icon = lensbar.focused_lens_icon
00174 
00175         self.keyboard.press_and_release("Right");
00176         self.assertThat(lensbar.focused_lens_icon, Eventually(NotEquals(current_focused_icon)))
00177 
00178         self.keyboard.press_and_release("Left")
00179         self.assertThat(lensbar.focused_lens_icon, Eventually(Equals(current_focused_icon)))

Test that the lensbar gets key focus after using Down keypresses.

Definition at line 154 of file test_dash.py.

00154 
00155     def test_lensbar_gets_keyfocus(self):
00156         """Test that the lensbar gets key focus after using Down keypresses."""
00157         self.dash.ensure_visible()
00158 
00159         # Make sure that the lens bar can get the focus
00160         for i in range(self.dash.get_num_rows()):
00161             self.keyboard.press_and_release("Down")
00162         lensbar = self.dash.view.get_lensbar()
00163         self.assertThat(lensbar.focused_lens_icon, Eventually(NotEquals('')))

Makes sure that pressing tab cycles through the category headers

Definition at line 234 of file test_dash.py.

00234 
00235     def test_tab_cycle_category_headers(self):
00236         """ Makes sure that pressing tab cycles through the category headers"""
00237         self.dash.ensure_visible()
00238         lens = self.dash.get_current_lens()
00239 
00240         # Test that tab cycles through the categories.
00241         # + 1 is to cycle back to first header
00242         for i in range(lens.get_num_visible_categories() + 1):
00243             self.keyboard.press_and_release('Tab')
00244             category = lens.get_focused_category()
00245             self.assertIsNot(category, None)

This test makes sure that Tab works well with the filter bara.

Definition at line 246 of file test_dash.py.

00246 
00247     def test_tab_with_filter_bar(self):
00248         """ This test makes sure that Tab works well with the filter bara."""
00249         self.dash.reveal_application_lens()
00250         lens = self.dash.get_current_lens()
00251 
00252         # Tabs to last category
00253         for i in range(lens.get_num_visible_categories()):
00254             self.keyboard.press_and_release('Tab')
00255 
00256         self.keyboard.press_and_release('Tab')
00257         self.assertThat(self.dash.searchbar.expander_has_focus, Eventually(Equals(True)))
00258 
00259         filter_bar = lens.get_filterbar()
00260         if not self.dash.searchbar.showing_filters:
00261             self.keyboard.press_and_release('Enter')
00262             self.assertThat(self.dash.searchbar.showing_filters, Eventually(Equals(True)))
00263             self.addCleanup(filter_bar.ensure_collapsed)
00264 
00265         for i in range(filter_bar.get_num_filters()):
00266             self.keyboard.press_and_release('Tab')
00267             new_focused_filter = filter_bar.get_focused_filter()
00268             self.assertIsNotNone(new_focused_filter)
00269 
00270         # Ensure that tab cycles back to a category header
00271         self.keyboard.press_and_release('Tab')
00272         category = lens.get_focused_category()
00273         self.assertIsNot(category, None)
00274 

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


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