Back to index

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

List of all members.

Public Member Functions

def setUp
def test_initially_hidden
def test_hud_is_on_right_monitor
def test_hud_geometries
def test_hud_is_locked_to_launcher
def test_hud_icon_is_shown
def test_hud_icon_shows_the_focused_application_emblem
def test_hud_icon_shows_the_ubuntu_emblem_on_empty_desktop
def test_switch_dash_hud_does_not_break_the_focused_application_emblem
def test_switch_hud_dash_does_not_break_the_focused_application_emblem
def test_dash_hud_only_uses_icon_from_current_desktop
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_is_primary
 hud_locked

Static Public Attributes

list launcher_modes
list launcher_screen
tuple scenarios = multiply_scenarios(_make_monitor_scenarios(), launcher_modes, launcher_screen)

Detailed Description

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

00379 
00380     def setUp(self):
00381         super(HudVisualTests, self).setUp()
00382         self.screen_geo.move_mouse_to_monitor(self.hud_monitor)
00383         self.set_unity_option('launcher_hide_mode', int(self.launcher_autohide))
00384         self.set_unity_option('num_launchers', int(self.launcher_primary_only))
00385         self.hud_monitor_is_primary = (self.screen_geo.get_primary_monitor() == self.hud_monitor)
00386         self.hud_locked = (not self.launcher_autohide and (not self.launcher_primary_only or self.hud_monitor_is_primary))
00387         sleep(0.5)

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()

Switching from the dash to Hud must pick an icon from applications
from the current desktop. As the Hud must go through the entire window
stack to find the top most window.

Definition at line 477 of file test_hud.py.

00477 
00478     def test_dash_hud_only_uses_icon_from_current_desktop(self):
00479         """
00480         Switching from the dash to Hud must pick an icon from applications
00481         from the current desktop. As the Hud must go through the entire window
00482         stack to find the top most window.
00483         """
00484         initial_workspace = self.workspace.current_workspace
00485         self.addCleanup(self.workspace.switch_to, initial_workspace)
00486         self.workspace.switch_to(0)
00487         calc = self.start_app("Calculator")
00488         self.assertTrue(calc.is_active)
00489         self.workspace.switch_to(2)
00490         self.dash.ensure_visible()
00491         self.hud.ensure_visible()
00492 
00493         self.assertThat(self.hud.icon.icon_name, Eventually(EndsWith("launcher_bfb.png")))
00494 

Tests the HUD geometries for the given monitor and status.

Definition at line 397 of file test_hud.py.

00397 
00398     def test_hud_geometries(self):
00399         """Tests the HUD geometries for the given monitor and status."""
00400         self.hud.ensure_visible()
00401         monitor_geo = self.screen_geo.get_monitor_geometry(self.hud_monitor)
00402         monitor_x = monitor_geo[0]
00403         monitor_w = monitor_geo[2]
00404         hud_x = self.hud.geometry[0]
00405         hud_w = self.hud.geometry[2]
00406 
00407         if self.hud_locked:
00408             self.assertThat(hud_x, GreaterThan(monitor_x))
00409             self.assertThat(hud_x, LessThan(monitor_x + monitor_w))
00410             self.assertThat(hud_w, Equals(monitor_x + monitor_w - hud_x))
00411         else:
00412             self.assertThat(hud_x, Equals(monitor_x))
00413             self.assertThat(hud_w, Equals(monitor_w))

Tests that the correct HUD icon is shown.

Definition at line 419 of file test_hud.py.

00419 
00420     def test_hud_icon_is_shown(self):
00421         """Tests that the correct HUD icon is shown."""
00422         self.hud.ensure_visible()
00423         hud_launcher_icon = self.hud.get_launcher_icon()
00424         hud_embedded_icon = self.hud.get_embedded_icon()
00425 
00426         if self.hud.is_locked_launcher:
00427             self.assertThat(hud_launcher_icon.visible, Eventually(Equals(True)))
00428             self.assertTrue(hud_launcher_icon.is_on_monitor(self.hud_monitor))
00429             self.assertTrue(hud_launcher_icon.active)
00430             self.assertThat(hud_launcher_icon.monitor, Equals(self.hud_monitor))
00431             self.assertFalse(hud_launcher_icon.desaturated)
00432             self.assertThat(hud_embedded_icon, Equals(None))
00433         else:
00434             self.assertThat(hud_launcher_icon.visible, Eventually(Equals(False)))
00435             self.assertFalse(hud_launcher_icon.active)
00436             # the embedded icon has no visible property.
00437             self.assertThat(hud_embedded_icon, NotEquals(None))

Tests that the correct HUD icon is shown.

Definition at line 438 of file test_hud.py.

00438 
00439     def test_hud_icon_shows_the_focused_application_emblem(self):
00440         """Tests that the correct HUD icon is shown."""
00441         self.close_all_app("Calculator")
00442         calc = self.start_app("Calculator")
00443         self.assertTrue(calc.is_active)
00444         self.hud.ensure_visible()
00445 
00446         self.assertThat(self.hud.icon.icon_name, Eventually(Equals(calc.icon)))

When in 'show desktop' mode the hud icon must be the BFB icon.

Definition at line 447 of file test_hud.py.

00447 
00448     def test_hud_icon_shows_the_ubuntu_emblem_on_empty_desktop(self):
00449         """When in 'show desktop' mode the hud icon must be the BFB icon."""
00450         self.window_manager.enter_show_desktop()
00451         self.addCleanup(self.window_manager.leave_show_desktop)
00452         self.hud.ensure_visible()
00453 
00454         self.assertThat(self.hud.icon.icon_name, Eventually(EndsWith("launcher_bfb.png")))

Tests if the HUD is locked to launcher as we expect or not.

Definition at line 414 of file test_hud.py.

00414 
00415     def test_hud_is_locked_to_launcher(self):
00416         """Tests if the HUD is locked to launcher as we expect or not."""
00417         self.hud.ensure_visible()
00418         self.assertThat(self.hud.is_locked_launcher, Eventually(Equals(self.hud_locked)))

HUD must be drawn on the monitor where the mouse is.

Definition at line 391 of file test_hud.py.

00391 
00392     def test_hud_is_on_right_monitor(self):
00393         """HUD must be drawn on the monitor where the mouse is."""
00394         self.hud.ensure_visible()
00395         self.assertThat(self.hud.monitor, Eventually(Equals(self.hud_monitor)))
00396         self.assertTrue(self.screen_geo.is_rect_on_monitor(self.hud.monitor, self.hud.geometry))

Definition at line 388 of file test_hud.py.

00388 
00389     def test_initially_hidden(self):
00390         self.assertFalse(self.hud.visible)

Switching from Dash to HUD must still show the correct HUD icon.

Definition at line 455 of file test_hud.py.

00455 
00456     def test_switch_dash_hud_does_not_break_the_focused_application_emblem(self):
00457         """Switching from Dash to HUD must still show the correct HUD icon."""
00458         self.close_all_app("Calculator")
00459         calc = self.start_app("Calculator")
00460         self.assertTrue(calc.is_active)
00461 
00462         self.dash.ensure_visible()
00463         self.hud.ensure_visible()
00464 
00465         self.assertThat(self.hud.icon.icon_name, Eventually(Equals(calc.icon)))

Switching from HUD to Dash and back must still show the correct HUD icon.

Definition at line 466 of file test_hud.py.

00466 
00467     def test_switch_hud_dash_does_not_break_the_focused_application_emblem(self):
00468         """Switching from HUD to Dash and back must still show the correct HUD icon."""
00469         self.close_all_app("Calculator")
00470         calc = self.start_app("Calculator")
00471         self.assertTrue(calc.is_active)
00472 
00473         self.hud.ensure_visible()
00474         self.dash.ensure_visible()
00475         self.hud.ensure_visible()
00476         self.assertThat(self.hud.icon.icon_name, Eventually(Equals(calc.icon)))

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

Definition at line 384 of file test_hud.py.

Initial value:
[('Launcher autohide', {'launcher_autohide': False}),
                      ('Launcher never hide', {'launcher_autohide': True})]

Definition at line 371 of file test_hud.py.

Initial value:
[('Launcher on primary monitor', {'launcher_primary_only': False}),
                       ('Launcher on all monitors', {'launcher_primary_only': True})]

Definition at line 374 of file test_hud.py.

Definition at line 377 of file test_hud.py.


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