Back to index

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

List of all members.

Public Member Functions

def test_only_menus_show_for_restored_window_on_mouse_in_window_btn_area
def test_only_menus_show_for_restored_window_on_mouse_in_menu_area
def test_only_menus_show_for_restored_window_on_mouse_in_grab_area
def test_hovering_over_indicators_does_not_show_app_menus
def test_menus_show_for_maximized_window_on_mouse_in_btn_area
def test_menus_show_for_maximized_window_on_mouse_in_menu_area
def test_menus_show_for_maximized_window_on_mouse_in_grab_area
def test_menus_and_btns_hidden_with_mouse_over_indicators
def test_hovering_indicators_open_menus
def setUp
def open_new_application_window
def move_window_to_panel_monitor
def mouse_open_indicator
def assert_win_buttons_in_overlay_mode
def assert_no_window_open_with_xid
def sleep_menu_settle_period
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

 panel

Static Public Attributes

tuple scenarios = _make_monitor_scenarios()
int panel_monitor = 0

Detailed Description

Tests with the mouse pointer hovering the panel area.

Definition at line 652 of file test_panel.py.


Member Function Documentation

Assert that Bamf doesn't know of any open windows with the given xid.

Definition at line 129 of file test_panel.py.

00129 
00130     def assert_no_window_open_with_xid(self, x_id):
00131         """Assert that Bamf doesn't know of any open windows with the given xid."""
00132         # We can't check text_win.closed since we've just destroyed the window.
00133         # Instead we make sure no window with it's x_id exists.
00134         refresh_fn = lambda: [w for w in self.bamf.get_open_windows() if w.x_id == x_id]
00135         self.assertThat(refresh_fn, Eventually(Equals([])))

Here is the caller graph for this function:

def unity.tests.test_panel.PanelTestsBase.assert_win_buttons_in_overlay_mode (   self,
  overlay_mode 
) [inherited]
Assert that there are three panel window buttons and all of them are
in the specified overlay mode.

Definition at line 116 of file test_panel.py.

00116 
00117     def assert_win_buttons_in_overlay_mode(self, overlay_mode):
00118         """Assert that there are three panel window buttons and all of them are
00119         in the specified overlay mode.
00120 
00121         """
00122         if type(overlay_mode) is not bool:
00123             raise TypeError("overlay_mode must be True or False")
00124 
00125         buttons = self.panel.window_buttons.get_buttons()
00126         self.assertThat(len(buttons), Equals(3))
00127         for button in buttons:
00128             self.assertThat(button.overlay_mode, Eventually(Equals(overlay_mode)))

Here is the caller graph for this function:

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.test_panel.PanelTestsBase.mouse_open_indicator (   self,
  indicator 
) [inherited]
This is an utility function that safely opens an indicator,
ensuring that it is closed at the end of the test and that the pointer
is moved outside the panel area (to make the panel hide the menus)

Definition at line 103 of file test_panel.py.

00103 
00104     def mouse_open_indicator(self, indicator):
00105         """This is an utility function that safely opens an indicator,
00106         ensuring that it is closed at the end of the test and that the pointer
00107         is moved outside the panel area (to make the panel hide the menus)
00108         """
00109         if not isinstance(indicator, IndicatorEntry):
00110             raise TypeError("Window must be a IndicatorEntry")
00111 
00112         indicator.mouse_click()
00113         self.addCleanup(self.panel.move_mouse_below_the_panel)
00114         self.addCleanup(self.keyboard.press_and_release, "Escape")
00115         self.assertThat(indicator.active, Eventually(Equals(True)))

Here is the caller graph for this function:

def unity.tests.test_panel.PanelTestsBase.move_window_to_panel_monitor (   self,
  window,
  restore_position = False 
) [inherited]
Drags a window to another monitor, eventually restoring it before

Definition at line 83 of file test_panel.py.

00083 
00084     def move_window_to_panel_monitor(self, window, restore_position=False):
00085         """Drags a window to another monitor, eventually restoring it before"""
00086         if not isinstance(window, BamfWindow):
00087             raise TypeError("Window must be a BamfWindow")
00088 
00089         if window.monitor == self.panel_monitor:
00090             return
00091 
00092         if window.is_maximized:
00093             self.keybinding("window/restore")
00094             self.addCleanup(self.keybinding, "window/maximize")
00095             sleep(.1)
00096 
00097         if restore_position:
00098             self.addCleanup(self.screen_geo.drag_window_to_monitor, window, window.monitor)
00099 
00100         self.screen_geo.drag_window_to_monitor(window, self.panel_monitor)
00101         sleep(.25)
00102         self.assertThat(window.monitor, Equals(self.panel_monitor))

Here is the caller graph for this function:

def unity.tests.test_panel.PanelTestsBase.open_new_application_window (   self,
  app_name,
  maximized = False,
  move_to_monitor = True 
) [inherited]
Opens a new instance of the requested application, ensuring that only
one window is opened.

Returns the opened BamfWindow

Definition at line 49 of file test_panel.py.

00049 
00050     def open_new_application_window(self, app_name, maximized=False, move_to_monitor=True):
00051         """Opens a new instance of the requested application, ensuring that only
00052         one window is opened.
00053 
00054         Returns the opened BamfWindow
00055 
00056         """
00057         self.close_all_app(app_name)
00058         app = self.start_app(app_name, locale="C")
00059 
00060         [app_win] = app.get_windows()
00061 
00062         app_win.set_focus()
00063         self.assertTrue(app.is_active)
00064         self.assertTrue(app_win.is_focused)
00065         self.assertThat(app.desktop_file, Equals(app_win.application.desktop_file))
00066 
00067         if move_to_monitor:
00068             self.move_window_to_panel_monitor(app_win)
00069 
00070         if maximized and not app_win.is_maximized:
00071             self.keybinding("window/maximize")
00072             self.addCleanup(self.keybinding, "window/restore")
00073         elif not maximized and app_win.is_maximized:
00074             self.keybinding("window/restore")
00075             self.addCleanup(self.keybinding, "window/maximize")
00076 
00077         app_win.set_focus()
00078         sleep(.25)
00079 
00080         self.assertThat(app_win.is_maximized, Equals(maximized))
00081 
00082         return app_win

Here is the call 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:

def unity.tests.test_panel.PanelTestsBase.setUp (   self) [inherited]

Reimplemented from unity.tests.UnityTestCase.

Reimplemented in unity.tests.test_panel.PanelCrossMonitorsTests, and unity.tests.test_panel.PanelWindowButtonsTests.

Definition at line 43 of file test_panel.py.

00043 
00044     def setUp(self):
00045         super(PanelTestsBase, self).setUp()
00046         self.panel = self.panels.get_panel_for_monitor(self.panel_monitor)
00047         self.panel.move_mouse_below_the_panel()
00048         self.addCleanup(self.panel.move_mouse_below_the_panel)

Sleep long enough for the menus to fade in and fade out again.

Definition at line 136 of file test_panel.py.

00136 
00137     def sleep_menu_settle_period(self):
00138         """Sleep long enough for the menus to fade in and fade out again."""
00139         sleep(self.panel.menus.fadein_duration / 1000.0)
00140         sleep(self.panel.menus.discovery_duration)
00141         sleep(self.panel.menus.fadeout_duration / 1000.0)
00142 

Here is the caller 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

Opening an indicator entry, and then hovering on other entries must
open them.

Definition at line 782 of file test_panel.py.

00782 
00783     def test_hovering_indicators_open_menus(self):
00784         """Opening an indicator entry, and then hovering on other entries must
00785         open them.
00786         """
00787         self.open_new_application_window("Text Editor")
00788         entries = self.panel.get_indicator_entries(include_hidden_menus=True)
00789 
00790         self.assertThat(len(entries), GreaterThan(0))
00791         self.mouse_open_indicator(entries[0])
00792 
00793         for entry in entries:
00794             entry.mouse_move_to()
00795             self.assertThat(entry.active, Eventually(Equals(True)))
00796             self.assertThat(entry.menu_y, Eventually(NotEquals(0)))
00797 

Here is the call graph for this function:

Hovering the mouse over the indicators must not show app menus.

Definition at line 702 of file test_panel.py.

00702 
00703     def test_hovering_over_indicators_does_not_show_app_menus(self):
00704         """Hovering the mouse over the indicators must not show app menus."""
00705         self.open_new_application_window("Calculator",
00706             maximized=False,
00707             move_to_monitor=True)
00708         self.sleep_menu_settle_period()
00709 
00710         self.panel.move_mouse_over_menus()
00711         # This assert is repeated from above, but we use it to make sure that
00712         # the menus are shown before we move over the indicators.
00713         self.assertThat(self.panel.menus_shown, Eventually(Equals(True)))
00714 
00715         self.panel.move_mouse_over_indicators()
00716 
00717         self.assertThat(self.panel.menus_shown, Eventually(Equals(False)))

Here is the call graph for this function:

Hovering the mouse over the indicators must hide the menus and window
buttons.

Definition at line 763 of file test_panel.py.

00763 
00764     def test_menus_and_btns_hidden_with_mouse_over_indicators(self):
00765         """Hovering the mouse over the indicators must hide the menus and window
00766         buttons.
00767         """
00768         self.open_new_application_window("Text Editor",
00769             maximized=True,
00770             move_to_monitor=True)
00771         self.sleep_menu_settle_period()
00772 
00773         self.panel.move_mouse_over_menus()
00774         # We use this assert to make sure that the menus are visible before we
00775         # move the mouse:
00776         self.assertThat(self.panel.window_buttons_shown, Eventually(Equals(True)))
00777 
00778         self.panel.move_mouse_over_indicators()
00779 
00780         self.assertThat(self.panel.window_buttons_shown, Eventually(Equals(False)))
00781         self.assertThat(self.panel.menus_shown, Eventually(Equals(False)))

Here is the call graph for this function:

Menus and window buttons must be shown when the mouse is in the window
button area for a maximised application.

Definition at line 718 of file test_panel.py.

00718 
00719     def test_menus_show_for_maximized_window_on_mouse_in_btn_area(self):
00720         """Menus and window buttons must be shown when the mouse is in the window
00721         button area for a maximised application.
00722         """
00723         self.open_new_application_window("Text Editor",
00724             maximized=True,
00725             move_to_monitor=True)
00726         self.sleep_menu_settle_period()
00727 
00728         self.panel.move_mouse_over_window_buttons()
00729 
00730         self.assertThat(self.panel.window_buttons_shown, Eventually(Equals(True)))
00731         self.assertThat(self.panel.menus_shown, Eventually(Equals(True)))

Here is the call graph for this function:

Menus and window buttons must be shown when the mouse is in the grab
area for a maximised application.

Definition at line 746 of file test_panel.py.

00746 
00747     def test_menus_show_for_maximized_window_on_mouse_in_grab_area(self):
00748         """Menus and window buttons must be shown when the mouse is in the grab
00749         area for a maximised application.
00750         """
00751         if self.panel.grab_area.width <= 0:
00752             self.skipTest("Grab area is too small to run this test!")
00753 
00754         self.open_new_application_window("Text Editor",
00755             maximized=True,
00756             move_to_monitor=True)
00757         self.sleep_menu_settle_period()
00758 
00759         self.panel.move_mouse_over_grab_area()
00760 
00761         self.assertThat(self.panel.window_buttons_shown, Eventually(Equals(True)))
00762         self.assertTrue(self.panel.menus_shown, Eventually(Equals(True)))

Here is the call graph for this function:

Menus and window buttons must be shown when the mouse is in the menu
area for a maximised application.

Definition at line 732 of file test_panel.py.

00732 
00733     def test_menus_show_for_maximized_window_on_mouse_in_menu_area(self):
00734         """Menus and window buttons must be shown when the mouse is in the menu
00735         area for a maximised application.
00736         """
00737         self.open_new_application_window("Text Editor",
00738             maximized=True,
00739             move_to_monitor=True)
00740         self.sleep_menu_settle_period()
00741 
00742         self.panel.move_mouse_over_menus()
00743 
00744         self.assertThat(self.panel.window_buttons_shown, Eventually(Equals(True)))
00745         self.assertThat(self.panel.menus_shown, Eventually(Equals(True)))

Here is the call graph for this function:

Restored windows should only show menus when the mouse is in the panel
grab area.

Definition at line 685 of file test_panel.py.

00685 
00686     def test_only_menus_show_for_restored_window_on_mouse_in_grab_area(self):
00687         """Restored windows should only show menus when the mouse is in the panel
00688         grab area.
00689         """
00690         self.open_new_application_window("Calculator",
00691             maximized=False,
00692             move_to_monitor=True)
00693         self.sleep_menu_settle_period()
00694 
00695         if self.panel.grab_area.width <= 0:
00696             self.skipTest("Grab area is too small to run test!")
00697 
00698         self.panel.move_mouse_over_grab_area()
00699 
00700         self.assertThat(self.panel.menus_shown, Eventually(Equals(True)))
00701         self.assertThat(self.panel.window_buttons_shown, Eventually(Equals(False)))

Here is the call graph for this function:

Restored windows should only show menus when the mouse is in the window
menu area.

Definition at line 671 of file test_panel.py.

00671 
00672     def test_only_menus_show_for_restored_window_on_mouse_in_menu_area(self):
00673         """Restored windows should only show menus when the mouse is in the window
00674         menu area.
00675         """
00676         self.open_new_application_window("Calculator",
00677             maximized=False,
00678             move_to_monitor=True)
00679         self.sleep_menu_settle_period()
00680 
00681         self.panel.move_mouse_over_menus()
00682 
00683         self.assertThat(self.panel.menus_shown, Eventually(Equals(True)))
00684         self.assertThat(self.panel.window_buttons_shown, Eventually(Equals(False)))

Here is the call graph for this function:

Restored windows should only show menus when the mouse is in the window
button area.

Definition at line 657 of file test_panel.py.

00657 
00658     def test_only_menus_show_for_restored_window_on_mouse_in_window_btn_area(self):
00659         """Restored windows should only show menus when the mouse is in the window
00660         button area.
00661         """
00662         self.open_new_application_window("Calculator",
00663             maximized=False,
00664             move_to_monitor=True)
00665         self.sleep_menu_settle_period()
00666 
00667         self.panel.move_mouse_over_window_buttons()
00668 
00669         self.assertThat(self.panel.menus_shown, Eventually(Equals(True)))
00670         self.assertThat(self.panel.window_buttons_shown, Eventually(Equals(False)))

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 45 of file test_panel.py.

Reimplemented in unity.tests.test_panel.PanelCrossMonitorsTests.

Definition at line 41 of file test_panel.py.

Definition at line 655 of file test_panel.py.


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