Back to index

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

List of all members.

Public Member Functions

def setUp
def test_no_initial_values
def test_check_a_values
def test_up_down_arrows
def test_no_reset_selected_button
def test_slow_tap_not_reveal_hud
def test_alt_f4_doesnt_show_hud
def test_reveal_hud_with_no_apps
def test_restore_focus
def test_gedit_undo
def test_hud_to_dash_has_key_focus
def test_dash_to_hud_has_key_focus
def test_hud_closes_on_workspace_switch
def test_hud_closes_on_spread
def test_hud_closes_click_outside_geo_shrunk
def test_hud_closes_click_outside_geo
def test_alt_f4_close_hud
def tearDown
def get_num_active_launcher_icons
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

 hud_monitor

Detailed Description

Definition at line 59 of file test_hud.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 51 of file test_hud.py.

00051 
00052     def get_num_active_launcher_icons(self):
00053         num_active = 0
00054         for icon in self.launcher.model.get_launcher_icons():
00055             if icon.active and icon.visible:
00056                 num_active += 1
00057         return num_active
00058 

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

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.test_hud.HudTestsBase.

Definition at line 61 of file test_hud.py.

00061 
00062     def setUp(self):
00063         super(HudBehaviorTests, self).setUp()
00064 
00065         self.hud_monitor = self.screen_geo.get_primary_monitor()
00066         self.screen_geo.move_mouse_to_monitor(self.hud_monitor)

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

def unity.tests.test_hud.HudTestsBase.tearDown (   self) [inherited]

Definition at line 47 of file test_hud.py.

00047 
00048     def tearDown(self):
00049         self.hud.ensure_hidden()
00050         super(HudTestsBase, self).tearDown()

Hud must close on alt+F4.

Definition at line 251 of file test_hud.py.

00251 
00252     def test_alt_f4_close_hud(self):
00253         """Hud must close on alt+F4."""
00254         self.hud.ensure_visible()
00255         self.keyboard.press_and_release("Alt+F4")
00256         self.assertThat(self.hud.visible, Eventually(Equals(False)))
00257 

Definition at line 127 of file test_hud.py.

00127 
00128     def test_alt_f4_doesnt_show_hud(self):
00129         self.start_app('Calculator')
00130         sleep(1)
00131         # Do a very fast Alt+F4
00132         self.keyboard.press_and_release("Alt+F4", 0.05)
00133         sleep(1)
00134         self.assertFalse(self.hud.visible)

Definition at line 72 of file test_hud.py.

00072 
00073     def test_check_a_values(self):
00074         self.hud.ensure_visible()
00075         self.keyboard.type('a')
00076         self.assertThat(self.hud.search_string, Eventually(Equals('a')))
00077         self.assertThat(self.hud.num_buttons, Eventually(Equals(5)))
00078         self.assertThat(self.hud.selected_button, Eventually(Equals(1)))

When switching from the dash to the hud you don't lose key focus.

Definition at line 202 of file test_hud.py.

00202 
00203     def test_dash_to_hud_has_key_focus(self):
00204         """When switching from the dash to the hud you don't lose key focus."""
00205         self.dash.ensure_visible()
00206         self.hud.ensure_visible()
00207         self.keyboard.type('focus2')
00208         self.assertThat(self.hud.search_string, Eventually(Equals('focus2')))

Test that the 'undo' action in the Hud works with GEdit.

Definition at line 170 of file test_hud.py.

00170 
00171     def test_gedit_undo(self):
00172         """Test that the 'undo' action in the Hud works with GEdit."""
00173 
00174         self.addCleanup(remove, '/tmp/autopilot_gedit_undo_test_temp_file.txt')
00175         self.start_app('Text Editor', files=['/tmp/autopilot_gedit_undo_test_temp_file.txt'], locale='C')
00176 
00177         self.keyboard.type("0")
00178         self.keyboard.type(" ")
00179         self.keyboard.type("1")
00180 
00181         self.hud.ensure_visible()
00182 
00183         self.keyboard.type("undo")
00184         hud_query_check = lambda: self.hud.selected_hud_button.label_no_formatting
00185         self.assertThat(hud_query_check,
00186                         Eventually(Equals("Edit > Undo")))
00187         self.keyboard.press_and_release('Return')
00188         self.assertThat(self.hud.visible, Eventually(Equals(False)))
00189         self.keyboard.press_and_release("Ctrl+s")
00190         sleep(1)
00191 
00192         contents = open("/tmp/autopilot_gedit_undo_test_temp_file.txt").read().strip('\n')
00193         self.assertEqual("0 ", contents)

Clicking outside of the hud will make it close.

Definition at line 239 of file test_hud.py.

00239 
00240     def test_hud_closes_click_outside_geo(self):
00241         """Clicking outside of the hud will make it close."""
00242 
00243         self.hud.ensure_visible()
00244         self.keyboard.type("Test")
00245 
00246         (x,y,w,h) = self.hud.view.geometry
00247         self.mouse.move(w/2, h+50)
00248         self.mouse.click()
00249 
00250         self.assertThat(self.hud.visible, Eventually(Equals(False)))

Clicking outside the hud when it is shurnk will make it close.
Shurnk is when the hud has no results and is much smaller then normal.

Definition at line 226 of file test_hud.py.

00226 
00227     def test_hud_closes_click_outside_geo_shrunk(self):
00228         """
00229         Clicking outside the hud when it is shurnk will make it close.
00230         Shurnk is when the hud has no results and is much smaller then normal.
00231         """
00232 
00233         self.hud.ensure_visible()
00234         (x,y,w,h) = self.hud.view.geometry
00235         self.mouse.move(w/2, h-50)
00236         self.mouse.click()
00237 
00238         self.assertThat(self.hud.visible, Eventually(Equals(False)))

This test shows that when the spread is initiated, the hud closes.

Definition at line 218 of file test_hud.py.

00218 
00219     def test_hud_closes_on_spread(self):
00220         """This test shows that when the spread is initiated, the hud closes."""
00221         self.hud.ensure_visible()
00222         self.addCleanup(self.keybinding, "spread/cancel")
00223         self.keybinding("spread/start")
00224         self.assertThat(self.window_manager.scale_active, Eventually(Equals(True)))
00225         self.assertThat(self.hud.visible, Eventually(Equals(False)))

This test shows that when you switch to another workspace the hud closes.

Definition at line 209 of file test_hud.py.

00209 
00210     def test_hud_closes_on_workspace_switch(self):
00211         """This test shows that when you switch to another workspace the hud closes."""
00212         initial_workspace = self.workspace.current_workspace
00213         self.addCleanup(self.workspace.switch_to, initial_workspace)
00214         self.hud.ensure_visible()
00215         self.workspace.switch_to(1)
00216         self.workspace.switch_to(2)
00217         self.assertThat(self.hud.visible, Eventually(Equals(False)))

When switching from the hud to the dash you don't lose key focus.

Definition at line 194 of file test_hud.py.

00194 
00195     def test_hud_to_dash_has_key_focus(self):
00196         """When switching from the hud to the dash you don't lose key focus."""
00197         self.hud.ensure_visible()
00198         self.dash.ensure_visible()
00199         self.addCleanup(self.dash.ensure_hidden)
00200         self.keyboard.type('focus1')
00201         self.assertThat(self.dash.search_string, Eventually(Equals('focus1')))

Definition at line 67 of file test_hud.py.

00067 
00068     def test_no_initial_values(self):
00069         self.hud.ensure_visible()
00070         self.assertThat(self.hud.num_buttons, Equals(0))
00071         self.assertThat(self.hud.selected_button, Equals(0))

Hud must not change selected button when results update over time.

Definition at line 106 of file test_hud.py.

00106 
00107     def test_no_reset_selected_button(self):
00108         """Hud must not change selected button when results update over time."""
00109         # TODO - this test doesn't test anything. Onmy system the results never update.
00110         # ideally we'd send artificial results to the hud from the test.
00111         self.hud.ensure_visible()
00112         self.keyboard.type('is')
00113         self.assertThat(self.hud.search_string, Eventually(Equals('is')))
00114         self.keyboard.press_and_release('Down')
00115         self.assertThat(self.hud.selected_button, Eventually(Equals(2)))
00116         # long sleep to let the service send updated results
00117         sleep(10)
00118         self.assertThat(self.hud.selected_button, Equals(2))

Ensures that once the hud is dismissed, the same application
that was focused before hud invocation is refocused.

Definition at line 147 of file test_hud.py.

00147 
00148     def test_restore_focus(self):
00149         """Ensures that once the hud is dismissed, the same application
00150         that was focused before hud invocation is refocused.
00151         """
00152         calc = self.start_app("Calculator")
00153 
00154         # first ensure that the application has started and is focused
00155         self.assertEqual(calc.is_active, True)
00156 
00157         self.hud.ensure_visible()
00158         self.hud.ensure_hidden()
00159 
00160         # again ensure that the application we started is focused
00161         self.assertEqual(calc.is_active, True)
00162 
00163         self.hud.ensure_visible()
00164         self.hud.ensure_hidden()
00165         # why do we do this: ???
00166         self.keyboard.press_and_release('Return')
00167         sleep(1)
00168 
00169         self.assertEqual(calc.is_active, True)

Hud must show even with no visible applications.

This used to cause unity to crash (hence the lack of assertion in this test).

Definition at line 135 of file test_hud.py.

00135 
00136     def test_reveal_hud_with_no_apps(self):
00137         """Hud must show even with no visible applications.
00138 
00139         This used to cause unity to crash (hence the lack of assertion in this test).
00140 
00141         """
00142         self.window_manager.enter_show_desktop()
00143         self.addCleanup(self.window_manager.leave_show_desktop)
00144 
00145         self.hud.ensure_visible()
00146         self.hud.ensure_hidden()

A slow tap must not reveal the HUD.

Definition at line 119 of file test_hud.py.

00119 
00120     def test_slow_tap_not_reveal_hud(self):
00121         """A slow tap must not reveal the HUD."""
00122         self.keybinding("hud/reveal", 0.3)
00123         # need a long sleep to ensure that we test after the hud controller has
00124         # seen the keypress.
00125         sleep(5)
00126         self.assertThat(self.hud.visible, Equals(False))

Definition at line 79 of file test_hud.py.

00079 
00080     def test_up_down_arrows(self):
00081         self.hud.ensure_visible()
00082         self.keyboard.type('a')
00083         self.assertThat(self.hud.search_string, Eventually(Equals('a')))
00084         self.keyboard.press_and_release('Down')
00085         self.assertThat(self.hud.selected_button, Eventually(Equals(2)))
00086         self.keyboard.press_and_release('Down')
00087         self.assertThat(self.hud.selected_button, Eventually(Equals(3)))
00088         self.keyboard.press_and_release('Down')
00089         self.assertThat(self.hud.selected_button, Eventually(Equals(4)))
00090         self.keyboard.press_and_release('Down')
00091         self.assertThat(self.hud.selected_button, Eventually(Equals(5)))
00092         # Down again stays on 5.
00093         self.keyboard.press_and_release('Down')
00094         self.assertThat(self.hud.selected_button, Eventually(Equals(5)))
00095         self.keyboard.press_and_release('Up')
00096         self.assertThat(self.hud.selected_button, Eventually(Equals(4)))
00097         self.keyboard.press_and_release('Up')
00098         self.assertThat(self.hud.selected_button, Eventually(Equals(3)))
00099         self.keyboard.press_and_release('Up')
00100         self.assertThat(self.hud.selected_button, Eventually(Equals(2)))
00101         self.keyboard.press_and_release('Up')
00102         self.assertThat(self.hud.selected_button, Eventually(Equals(1)))
00103         # Up again stays on 1.
00104         self.keyboard.press_and_release('Up')
00105         self.assertThat(self.hud.selected_button, Eventually(Equals(1)))

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 64 of file test_hud.py.


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