Back to index

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

List of all members.

Public Member Functions

def setUp
def test_window_buttons_dont_show_on_empty_desktop
def test_window_buttons_dont_show_for_restored_window
def test_window_buttons_dont_show_for_restored_window_with_mouse_in_panel
def test_window_buttons_dont_show_for_maximized_window_on_mouse_out
def test_window_buttons_show_for_maximized_window_on_mouse_in
def test_window_buttons_show_with_dash
def test_window_buttons_show_with_hud
def test_window_buttons_update_visual_state
def test_window_buttons_cancel
def test_window_buttons_close_button_works_for_window
def test_window_buttons_close_follows_fitts_law
def test_window_buttons_minimize_button_works_for_window
def test_window_buttons_minimize_follows_fitts_law
def test_window_buttons_unmaximize_button_works_for_window
def test_window_buttons_unmaximize_follows_fitts_law
def test_window_buttons_close_button_works_for_hud
def test_minimize_button_disabled_for_hud
def test_minimize_button_does_nothing_for_hud
def test_maximize_button_disabled_for_hud
def test_maximize_button_does_nothing_for_hud
def test_hud_maximize_button_does_not_change_dash_form_factor
def test_window_buttons_close_button_works_for_dash
def test_minimize_button_disabled_for_dash
def test_minimize_button_does_nothing_for_dash
def test_window_buttons_maximization_buttons_works_for_dash
def test_minimize_button_disabled_for_non_minimizable_windows
def test_window_buttons_show_when_indicator_active_and_mouse_over_panel
def test_window_buttons_show_when_holding_show_menu_key
def test_window_buttons_cant_accept_keynav_focus
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

Definition at line 216 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:

Reimplemented from unity.tests.test_panel.PanelTestsBase.

Definition at line 220 of file test_panel.py.

00220 
00221     def setUp(self):
00222         super(PanelWindowButtonsTests, self).setUp()
00223         # Locked Launchers on all monitors
00224         self.set_unity_option('num_launchers', 0)
00225         self.set_unity_option('launcher_hide_mode', 0)

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

Clicking on the 'Maximize' button of the HUD must not change the dash
layout.

See bug #939054

Definition at line 470 of file test_panel.py.

00470 
00471     def test_hud_maximize_button_does_not_change_dash_form_factor(self):
00472         """Clicking on the 'Maximize' button of the HUD must not change the dash
00473         layout.
00474 
00475         See bug #939054
00476         """
00477         inital_form_factor = self.dash.view.form_factor
00478         self.hud.ensure_visible()
00479         # FIXME: When this bug is fixed:
00480         #
00481         # https://bugs.launchpad.net/ubuntu/+source/unity/+bug/1021087
00482         #
00483         # We can replace the following line with:
00484         # self.addCleanup(self.hud.ensure_hidden)
00485         self.addCleanup(self.panel.window_buttons.close.mouse_click)
00486 
00487         self.panel.window_buttons.maximize.mouse_click()
00488         # long sleep here to make sure that any change that might happen will
00489         # have already happened.
00490         sleep(5)
00491         self.assertThat(self.dash.view.form_factor, Equals(inital_form_factor))

Maximize button must be disabled for the HUD.

Definition at line 449 of file test_panel.py.

00449 
00450     def test_maximize_button_disabled_for_hud(self):
00451         """Maximize button must be disabled for the HUD."""
00452         self.hud.ensure_visible()
00453         self.addCleanup(self.hud.ensure_hidden)
00454 
00455         self.assertThat(self.panel.window_buttons.maximize.enabled, Eventually(Equals(False)))

Maximize button must not affect the Hud.

Definition at line 456 of file test_panel.py.

00456 
00457     def test_maximize_button_does_nothing_for_hud(self):
00458         """Maximize button must not affect the Hud."""
00459         self.hud.ensure_visible()
00460         # FIXME: When this bug is fixed:
00461         #
00462         # https://bugs.launchpad.net/ubuntu/+source/unity/+bug/1021087
00463         #
00464         # We can replace the following line with:
00465         # self.addCleanup(self.hud.ensure_hidden)
00466         self.addCleanup(self.panel.window_buttons.close.mouse_click)
00467         self.panel.window_buttons.maximize.mouse_click()
00468 
00469         self.assertThat(self.hud.visible, Eventually(Equals(True)))

Tests that the 'Minimize' button is disabled for the dash.

Definition at line 500 of file test_panel.py.

00500 
00501     def test_minimize_button_disabled_for_dash(self):
00502         """Tests that the 'Minimize' button is disabled for the dash."""
00503         self.dash.ensure_visible()
00504         self.addCleanup(self.dash.ensure_hidden)
00505 
00506         self.assertThat(self.panel.window_buttons.minimize.enabled, Eventually(Equals(False)))

Minimize button must be disabled for the HUD.

Definition at line 428 of file test_panel.py.

00428 
00429     def test_minimize_button_disabled_for_hud(self):
00430         """Minimize button must be disabled for the HUD."""
00431         self.hud.ensure_visible()
00432         self.addCleanup(self.hud.ensure_hidden)
00433 
00434         self.assertThat(self.panel.window_buttons.minimize.enabled, Eventually(Equals(False)))

Minimize button must be disabled for windows that don't support minimization.

Definition at line 583 of file test_panel.py.

00583 
00584     def test_minimize_button_disabled_for_non_minimizable_windows(self):
00585         """Minimize button must be disabled for windows that don't support minimization."""
00586         text_win = self.open_new_application_window("Text Editor",
00587             maximized=False,
00588             move_to_monitor=True)
00589 
00590         self.keyboard.press_and_release("Ctrl+S")
00591         self.addCleanup(self.keyboard.press_and_release, "Escape")
00592 
00593         wins = text_win.application.get_windows()
00594         self.assertThat(len(wins), Equals(2))
00595         [target_win] = [w for w in wins if w.x_id != text_win.x_id]
00596         self.move_window_to_panel_monitor(target_win, restore_position=False)
00597 
00598         self.keybinding("window/maximize")
00599         self.assertThat(lambda: target_win.is_maximized, Eventually(Equals(True)))
00600 
00601         self.assertThat(self.panel.window_buttons.close.enabled, Eventually(Equals(True)))
00602         self.assertThat(self.panel.window_buttons.minimize.enabled, Eventually(Equals(False)))

Here is the call graph for this function:

Tests that the 'Minimize' button is disabled for the dash.

Definition at line 507 of file test_panel.py.

00507 
00508     def test_minimize_button_does_nothing_for_dash(self):
00509         """Tests that the 'Minimize' button is disabled for the dash."""
00510         self.dash.ensure_visible()
00511         self.addCleanup(self.dash.ensure_hidden)
00512 
00513         self.panel.window_buttons.minimize.mouse_click()
00514         sleep(5)
00515         self.assertThat(self.dash.visible, Eventually(Equals(True)))

Minimize button must not affect the Hud.

Definition at line 435 of file test_panel.py.

00435 
00436     def test_minimize_button_does_nothing_for_hud(self):
00437         """Minimize button must not affect the Hud."""
00438         self.hud.ensure_visible()
00439         # FIXME: When this bug is fixed:
00440         #
00441         # https://bugs.launchpad.net/ubuntu/+source/unity/+bug/1021087
00442         #
00443         # We can replace the following line with:
00444         # self.addCleanup(self.hud.ensure_hidden)
00445         self.addCleanup(self.panel.window_buttons.close.mouse_click)
00446         self.panel.window_buttons.minimize.mouse_click()
00447 
00448         self.assertThat(self.hud.visible, Eventually(Equals(True)))

Window buttons must ignore clicks when the mouse released outside
their area.

Definition at line 308 of file test_panel.py.

00308 
00309     def test_window_buttons_cancel(self):
00310         """Window buttons must ignore clicks when the mouse released outside
00311         their area.
00312         """
00313         self.hud.ensure_visible()
00314         button = self.panel.window_buttons.close
00315 
00316         # FIXME: THere's a bug in unity that prevents us from doing:
00317         # self.addCleanup(self.hud.ensure_hidden)
00318         # SO we do this instead. The bug is:
00319         #
00320         # https://bugs.launchpad.net/ubuntu/+source/unity/+bug/1021087
00321         #
00322         # Once that's fixed the next two lines can be removed, and the one above
00323         # added instead.
00324         self.addCleanup(self.assertThat, self.hud.visible, Eventually(Equals(False)))
00325         self.addCleanup(button.mouse_click)
00326 
00327         button.mouse_move_to()
00328         self.mouse.press()
00329         self.assertThat(button.visual_state, Eventually(Equals("pressed")))
00330         self.panel.move_mouse_below_the_panel()
00331         self.mouse.release()
00332 
00333         self.assertThat(button.visual_state, Eventually(Equals("normal")))
00334         self.assertThat(self.hud.visible, Eventually(Equals(True)))

On a mouse down event over the window buttons
you must still be able to type into the Hud.

Definition at line 637 of file test_panel.py.

00637 
00638     def test_window_buttons_cant_accept_keynav_focus(self):
00639         """On a mouse down event over the window buttons
00640         you must still be able to type into the Hud.
00641 
00642         """
00643         self.hud.ensure_visible()
00644         self.addCleanup(self.hud.ensure_hidden)
00645 
00646         self.keyboard.type("Hello")
00647         self.panel.window_buttons.minimize.mouse_click()
00648         self.keyboard.type("World")
00649 
00650         self.assertThat(self.hud.search_string, Eventually(Equals("HelloWorld")))
00651 

Tests that the window 'Close' actually closes the Dash.

Definition at line 492 of file test_panel.py.

00492 
00493     def test_window_buttons_close_button_works_for_dash(self):
00494         """Tests that the window 'Close' actually closes the Dash."""
00495         self.dash.ensure_visible()
00496         self.addCleanup(self.dash.ensure_hidden)
00497         self.panel.window_buttons.close.mouse_click()
00498 
00499         self.assertThat(self.dash.visible, Eventually(Equals(False)))

Tests that the window 'Close' actually closes the HUD.

Definition at line 420 of file test_panel.py.

00420 
00421     def test_window_buttons_close_button_works_for_hud(self):
00422         """Tests that the window 'Close' actually closes the HUD."""
00423         self.hud.ensure_visible()
00424         self.addCleanup(self.hud.ensure_hidden)
00425 
00426         self.panel.window_buttons.close.mouse_click()
00427         self.assertThat(self.hud.visible, Eventually(Equals(False)))

Close window button must actually closes a window.

Definition at line 335 of file test_panel.py.

00335 
00336     def test_window_buttons_close_button_works_for_window(self):
00337         """Close window button must actually closes a window."""
00338         text_win = self.open_new_application_window("Text Editor",
00339             maximized=True,
00340             move_to_monitor=True)
00341         win_xid = text_win.x_id
00342 
00343         self.panel.window_buttons.close.mouse_click()
00344         self.assert_no_window_open_with_xid(win_xid)

Here is the call graph for this function:

Tests that the 'Close' button is activated when clicking at 0,0.

See bug #839690

Definition at line 345 of file test_panel.py.

00345 
00346     def test_window_buttons_close_follows_fitts_law(self):
00347         """Tests that the 'Close' button is activated when clicking at 0,0.
00348 
00349         See bug #839690
00350         """
00351         text_win = self.open_new_application_window("Text Editor",
00352             maximized=True,
00353             move_to_monitor=True)
00354         win_xid = text_win.x_id
00355 
00356         self.panel.move_mouse_over_window_buttons()
00357         screen_x, screen_y = self.screen_geo.get_monitor_geometry(self.panel_monitor)[:2]
00358         self.mouse.move(screen_x, screen_y)
00359         self.mouse.click()
00360 
00361         self.assert_no_window_open_with_xid(win_xid)

Here is the call graph for this function:

Window buttons must not show for a maximized window when the mouse is
outside the panel.

Definition at line 258 of file test_panel.py.

00258 
00259     def test_window_buttons_dont_show_for_maximized_window_on_mouse_out(self):
00260         """Window buttons must not show for a maximized window when the mouse is
00261         outside the panel.
00262         """
00263         self.open_new_application_window("Text Editor", maximized=True)
00264 
00265         self.assertThat(self.panel.window_buttons_shown, Eventually(Equals(False)))

Here is the call graph for this function:

Window buttons must not show for a restored window.

Definition at line 243 of file test_panel.py.

00243 
00244     def test_window_buttons_dont_show_for_restored_window(self):
00245         """Window buttons must not show for a restored window."""
00246         self.open_new_application_window("Calculator")
00247         self.panel.move_mouse_below_the_panel()
00248 
00249         self.assertThat(self.panel.window_buttons_shown, Eventually(Equals(False)))

Here is the call graph for this function:

Window buttons must not show for a restored window with the mouse in
the panel.

Definition at line 250 of file test_panel.py.

00250 
00251     def test_window_buttons_dont_show_for_restored_window_with_mouse_in_panel(self):
00252         """Window buttons must not show for a restored window with the mouse in
00253         the panel."""
00254         self.open_new_application_window("Calculator")
00255         self.panel.move_mouse_over_window_buttons()
00256 
00257         self.assertThat(self.panel.window_buttons_shown, Eventually(Equals(False)))

Here is the call graph for this function:

Tests that the window buttons are not shown on clean desktop.

Definition at line 226 of file test_panel.py.

00226 
00227     def test_window_buttons_dont_show_on_empty_desktop(self):
00228         """Tests that the window buttons are not shown on clean desktop."""
00229         # THis initially used Show Desktop mode, but it's very buggy from within
00230         # autopilot. We assume that workspace 2 is empty (which is safe for the
00231         # jenkins runs at least.)
00232         initial_workspace = self.workspace.current_workspace
00233         self.addCleanup(self.workspace.switch_to, initial_workspace)
00234 
00235         self.workspace.switch_to(2)
00236         self.assertThat(self.panel.window_buttons_shown, Eventually(Equals(False)))
00237 
00238         self.panel.move_mouse_over_window_buttons()
00239         # Sleep twice as long as the timeout, just to be sure. timeout is in
00240         # mS, we need seconds, hence the divide by 500.0
00241         sleep(self.panel.menus.fadein_duration / 500.0)
00242         self.assertThat(self.panel.window_buttons_shown, Eventually(Equals(False)))

'Maximize' and 'Restore' buttons (when both enabled) must work as expected.

Definition at line 516 of file test_panel.py.

00516 
00517     def test_window_buttons_maximization_buttons_works_for_dash(self):
00518         """'Maximize' and 'Restore' buttons (when both enabled) must work as expected."""
00519         # Mega-TODO:
00520         #
00521         # This test is terrible. The docstring is terrible. The test id is terrible.
00522         # Someone needs to split this into several smaller tests. However, I'm
00523         # not doing that in this branch. Consider this an invitation to split
00524         # this test out and make it suck less.
00525         #
00526         # For your sanity I have annotated it with comments.
00527         self.dash.ensure_visible()
00528         self.addCleanup(self.panel.window_buttons.close.mouse_click)
00529 
00530         unmaximize = self.panel.window_buttons.unmaximize
00531         maximize = self.panel.window_buttons.maximize
00532 
00533         # "netbook" means "dash is maximised"
00534         dash_maximised = (self.dash.view.form_factor == "netbook")
00535 
00536         # this if statement will trigger only when we're on very small screens,
00537         # where it doesn't make sense to have the dash anything other than
00538         # maximised.
00539         if dash_maximised and not unmaximize.enabled:
00540             unmaximize.mouse_click()
00541             # nice long sleep to make sure that any changes have time to process.
00542             sleep(5)
00543             self.assertThat(self.dash.view.form_factor, Equals("netbook"))
00544         else:
00545             # we are able to resize the dash.
00546             # maximise and unmaximise (restore) buttons are shown in the same place
00547             # but only one is shown at once:
00548             if maximize.visible:
00549                 active_button = maximize
00550                 inactive_button = unmaximize
00551             else:
00552                 active_button = unmaximize
00553                 inactive_button = maximize
00554 
00555             self.assertThat(active_button.visible, Eventually(Equals(True)))
00556             self.assertThat(active_button.sensitive, Eventually(Equals(True)))
00557             self.assertThat(active_button.enabled, Eventually(Equals(True)))
00558             self.assertThat(inactive_button.visible, Eventually(Equals(False)))
00559 
00560             self.addCleanup(inactive_button.mouse_click)
00561             active_button.mouse_click()
00562 
00563             self.assertThat(inactive_button.visible, Eventually(Equals(True)))
00564             self.assertThat(inactive_button.sensitive, Eventually(Equals(True)))
00565             self.assertThat(inactive_button.enabled, Eventually(Equals(True)))
00566             self.assertThat(active_button.visible, Eventually(Equals(False)))
00567 
00568             if dash_maximised:
00569                 self.assertThat(self.dash.view.form_factor, Eventually(Equals("desktop")))
00570             else:
00571                 self.assertThat(self.dash.view.form_factor, Eventually(Equals("netbook")))
00572 
00573             self.addCleanup(active_button.mouse_click)
00574             inactive_button.mouse_click()
00575 
00576             self.assertThat(active_button.visible, Eventually(Equals(True)))
00577             self.assertThat(inactive_button.visible, Eventually(Equals(False)))
00578 
00579             if dash_maximised:
00580                 self.assertThat(self.dash.view.form_factor, Eventually(Equals("netbook")))
00581             else:
00582                 self.assertThat(self.dash.view.form_factor, Eventually(Equals("desktop")))

Tests that the window button 'Minimize' actually minimizes a window.

Definition at line 362 of file test_panel.py.

00362 
00363     def test_window_buttons_minimize_button_works_for_window(self):
00364         """Tests that the window button 'Minimize' actually minimizes a window."""
00365         text_win = self.open_new_application_window("Text Editor",
00366             maximized=True,
00367             move_to_monitor=True)
00368 
00369         self.panel.window_buttons.minimize.mouse_click()
00370 
00371         self.assertThat(lambda: text_win.is_hidden, Eventually(Equals(True)))

Here is the call graph for this function:

Tests that the 'Minimize' button is conform to Fitts's Law.

See bug #839690

Definition at line 372 of file test_panel.py.

00372 
00373     def test_window_buttons_minimize_follows_fitts_law(self):
00374         """Tests that the 'Minimize' button is conform to Fitts's Law.
00375 
00376         See bug #839690
00377         """
00378         text_win = self.open_new_application_window("Text Editor",
00379             maximized=True,
00380             move_to_monitor=True)
00381 
00382         self.panel.move_mouse_over_window_buttons()
00383         button = self.panel.window_buttons.minimize
00384         target_x = button.x + button.width / 2
00385         target_y = self.screen_geo.get_monitor_geometry(self.panel_monitor)[1]
00386         self.mouse.move(target_x, target_y)
00387         self.mouse.click()
00388 
00389         self.assertThat(lambda: text_win.is_hidden, Eventually(Equals(True)))

Here is the call graph for this function:

Window buttons must show when a maximized window is focused and the
mouse is over the menu-view panel areas.

Definition at line 266 of file test_panel.py.

00266 
00267     def test_window_buttons_show_for_maximized_window_on_mouse_in(self):
00268         """Window buttons must show when a maximized window is focused and the
00269         mouse is over the menu-view panel areas.
00270 
00271         """
00272         self.open_new_application_window("Text Editor", maximized=True)
00273         self.panel.move_mouse_over_window_buttons()
00274 
00275         self.assertThat(self.panel.window_buttons_shown, Eventually(Equals(True)))
00276         self.assert_win_buttons_in_overlay_mode(False)

Here is the call graph for this function:

Window buttons must show when we press the show-menu keybinding.

Definition at line 621 of file test_panel.py.

00621 
00622     def test_window_buttons_show_when_holding_show_menu_key(self):
00623         """Window buttons must show when we press the show-menu keybinding."""
00624         self.open_new_application_window("Text Editor",
00625             maximized=True,
00626             move_to_monitor=True)
00627 
00628         self.assertThat(self.panel.window_buttons_shown, Eventually(Equals(False)))
00629 
00630         self.keybinding_hold("panel/show_menus")
00631         self.addCleanup(self.keybinding_release, "panel/show_menus")
00632 
00633         self.assertThat(self.panel.window_buttons_shown, Eventually(Equals(True)))
00634 
00635         self.keybinding_release("panel/show_menus")
00636         self.assertThat(self.panel.window_buttons_shown, Eventually(Equals(False)))

Here is the call graph for this function:

Window buttons must be shown when mouse is over panel area with an
indicator open.

Definition at line 603 of file test_panel.py.

00603 
00604     def test_window_buttons_show_when_indicator_active_and_mouse_over_panel(self):
00605         """Window buttons must be shown when mouse is over panel area with an
00606         indicator open.
00607         """
00608         self.open_new_application_window("Text Editor",
00609             maximized=True,
00610             move_to_monitor=True)
00611 
00612         indicator = self.panel.indicators.get_indicator_by_name_hint("indicator-session-devices")
00613         self.mouse_open_indicator(indicator)
00614         self.assertThat(self.panel.window_buttons_shown, Eventually(Equals(False)))
00615 
00616         self.panel.move_mouse_below_the_panel()
00617         self.assertThat(self.panel.window_buttons_shown, Eventually(Equals(False)))
00618 
00619         self.panel.move_mouse_over_grab_area()
00620         self.assertThat(self.panel.window_buttons_shown, Eventually(Equals(True)))

Here is the call graph for this function:

Window buttons must be shown when the dash is open.

Definition at line 277 of file test_panel.py.

00277 
00278     def test_window_buttons_show_with_dash(self):
00279         """Window buttons must be shown when the dash is open."""
00280         self.dash.ensure_visible()
00281         self.addCleanup(self.dash.ensure_hidden)
00282 
00283         self.assertThat(self.panel.window_buttons_shown, Eventually(Equals(True)))
00284         self.assert_win_buttons_in_overlay_mode(True)

Here is the call graph for this function:

Window buttons must be shown when the HUD is open.

Definition at line 285 of file test_panel.py.

00285 
00286     def test_window_buttons_show_with_hud(self):
00287         """Window buttons must be shown when the HUD is open."""
00288         self.hud.ensure_visible()
00289         self.addCleanup(self.hud.ensure_hidden)
00290 
00291         self.assertThat(self.panel.window_buttons_shown, Eventually(Equals(True)))
00292         self.assert_win_buttons_in_overlay_mode(True)

Here is the call graph for this function:

Tests that the window button 'Unmaximize' actually unmaximizes a window.

Definition at line 390 of file test_panel.py.

00390 
00391     def test_window_buttons_unmaximize_button_works_for_window(self):
00392         """Tests that the window button 'Unmaximize' actually unmaximizes a window."""
00393         text_win = self.open_new_application_window("Text Editor",
00394             maximized=True,
00395             move_to_monitor=True)
00396 
00397         self.panel.window_buttons.unmaximize.mouse_click()
00398 
00399         self.assertProperties(text_win, is_maximized=False, is_focused=True)
00400         self.assertThat(self.panel.window_buttons_shown, Eventually(Equals(False)))

Here is the call graph for this function:

Tests that the 'Unmaximize' button is conform to Fitts's Law.

See bug #839690

Definition at line 401 of file test_panel.py.

00401 
00402     def test_window_buttons_unmaximize_follows_fitts_law(self):
00403         """Tests that the 'Unmaximize' button is conform to Fitts's Law.
00404 
00405         See bug #839690
00406         """
00407         text_win = self.open_new_application_window("Text Editor",
00408             maximized=True,
00409             move_to_monitor=True)
00410 
00411         button = self.panel.window_buttons.unmaximize
00412         button.mouse_move_to()
00413         target_x = button.x + button.width / 2
00414         target_y = self.screen_geo.get_monitor_geometry(self.panel_monitor)[1]
00415         self.mouse.move(target_x, target_y)
00416         sleep(1)
00417         self.mouse.click()
00418 
00419         self.assertThat(lambda: text_win.is_maximized, Eventually(Equals(False)))

Here is the call graph for this function:

Window button must update its state in response to mouse events.

Definition at line 293 of file test_panel.py.

00293 
00294     def test_window_buttons_update_visual_state(self):
00295         """Window button must update its state in response to mouse events."""
00296         self.hud.ensure_visible()
00297         self.addCleanup(self.hud.ensure_hidden)
00298         button = self.panel.window_buttons.close
00299 
00300         self.assertThat(button.visual_state, Eventually(Equals("normal")))
00301 
00302         button.mouse_move_to()
00303         self.assertThat(button.visual_state, Eventually(Equals("prelight")))
00304 
00305         self.mouse.press()
00306         self.addCleanup(self.mouse.release)
00307         self.assertThat(button.visual_state, Eventually(Equals("pressed")))

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


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