Back to index

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

List of all members.

Public Member Functions

def setUp
def launch_test_apps
def test_showdesktop_hides_apps
def test_showdesktop_unhides_apps
def test_unhide_single_app
def test_showdesktop_switcher
def check_test_behavior
def dash
def hud
def launcher
def panels
def switcher
def window_manager
def workspace
def set_unity_log_level
def assertNumberWinsIsEventually

Detailed Description

Test the 'Show Desktop' functionality.

Definition at line 17 of file test_showdesktop.py.


Member Function Documentation

def unity.tests.UnityTestCase.assertNumberWinsIsEventually (   self,
  app,
  num 
) [inherited]
Asserts that 'app' eventually has 'num' wins. Waits up to 10 seconds.

Definition at line 196 of file __init__.py.

00196 
00197     def assertNumberWinsIsEventually(self, app, num):
00198         """Asserts that 'app' eventually has 'num' wins. Waits up to 10 seconds."""
00199 
00200         self.assertThat(lambda: len(app.get_windows()), Eventually(Equals(num)))

Here is the caller graph for this function:

Fail the test if it did something naughty.

This includes leaving the dash or the hud open, changing the current
workspace, or leaving the system in show_desktop mode.

Definition at line 56 of file __init__.py.

00056 
00057     def check_test_behavior(self):
00058         """Fail the test if it did something naughty.
00059 
00060         This includes leaving the dash or the hud open, changing the current
00061         workspace, or leaving the system in show_desktop mode.
00062 
00063         """
00064         well_behaved = True
00065         reasons = []
00066         log.info("Checking system state for badly behaving test...")
00067 
00068         # Have we switched workspace?
00069         if self.workspace.current_workspace != self._initial_workspace_num:
00070             well_behaved = False
00071             reasons.append("The test changed the active workspace from %d to %d." \
00072                 % (self._initial_workspace_num, self.workspace.current_workspace))
00073             log.warning("Test changed the active workspace, changing it back...")
00074             self.workspace.switch_to(self._initial_workspace_num)
00075         # Have we left the dash open?
00076         if self.dash.visible:
00077             well_behaved = False
00078             reasons.append("The test left the dash open.")
00079             log.warning("Test left the dash open, closing it...")
00080             self.dash.ensure_hidden()
00081         # ... or the hud?
00082         if self.hud.visible:
00083             well_behaved = False
00084             reasons.append("The test left the hud open.")
00085             log.warning("Test left the hud open, closing it...")
00086             self.hud.ensure_hidden()
00087         # Are we in show desktop mode?
00088         if self.window_manager.showdesktop_active:
00089             well_behaved = False
00090             reasons.append("The test left the system in show_desktop mode.")
00091             log.warning("Test left the system in show desktop mode, exiting it...")
00092             self.window_manager.leave_show_desktop()
00093         for launcher in self.launcher.get_launchers():
00094             if launcher.in_keynav_mode:
00095                 well_behaved = False
00096                 reasons.append("The test left the launcher keynav mode enabled.")
00097                 log.warning("Test left the launcher in keynav mode, exiting it...")
00098                 launcher.key_nav_cancel()
00099             if launcher.in_switcher_mode:
00100                 well_behaved = False
00101                 reasons.append("The test left the launcher in switcher mode.")
00102                 log.warning("Test left the launcher in switcher mode, exiting it...")
00103                 launcher.switcher_cancel()
00104 
00105         if not well_behaved:
00106             self.fail("/n".join(reasons))
00107         else:
00108             log.info("Test was well behaved.")

def unity.tests.UnityTestCase.dash (   self) [inherited]

Definition at line 110 of file __init__.py.

00110 
00111     def dash(self):
00112         if not getattr(self, '__dash', None):
00113             self.__dash = Dash()
00114         return self.__dash

def unity.tests.UnityTestCase.hud (   self) [inherited]

Definition at line 116 of file __init__.py.

00116 
00117     def hud(self):
00118         if not getattr(self, '__hud', None):
00119             self.__hud = Hud();
00120         return self.__hud

Launch character map and calculator apps.

Definition at line 27 of file test_showdesktop.py.

00027 
00028     def launch_test_apps(self):
00029         """Launch character map and calculator apps."""
00030         self.start_app('Character Map', locale='C')
00031         self.start_app('Calculator', locale='C')
00032         sleep(1)

Here is the caller graph for this function:

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.UnityTestCase.

Definition at line 20 of file test_showdesktop.py.

00020 
00021     def setUp(self):
00022         super(ShowDesktopTests, self).setUp()
00023         self.set_unity_log_level("unity.plugin", "DEBUG")
00024         # we need this to let the unity models update after we shutdown apps
00025         # before we start the next test.
00026         sleep(2)

Here is the call graph for this function:

def unity.tests.UnityTestCase.switcher (   self) [inherited]

Definition at line 134 of file __init__.py.

00134 
00135     def switcher(self):
00136         if not getattr(self, '__switcher', None):
00137             self.__switcher = Switcher()
00138         return self.__switcher

Show Desktop keyboard shortcut must hide applications.

Definition at line 33 of file test_showdesktop.py.

00033 
00034     def test_showdesktop_hides_apps(self):
00035         """Show Desktop keyboard shortcut must hide applications."""
00036         self.launch_test_apps()
00037 
00038         # show desktop, verify all windows are hidden:
00039         self.window_manager.enter_show_desktop()
00040         self.addCleanup(self.window_manager.leave_show_desktop)
00041 
00042         open_wins = self.bamf.get_open_windows()
00043         self.assertGreaterEqual(len(open_wins), 2)
00044         for win in open_wins:
00045             self.assertTrue(win.is_valid)
00046             self.assertTrue(win.is_hidden, "Window '%s' is not hidden after show desktop activated." % (win.title))

Here is the call graph for this function:

Show desktop item in switcher should hide all hidden apps.

Definition at line 104 of file test_showdesktop.py.

00104 
00105     def test_showdesktop_switcher(self):
00106         """Show desktop item in switcher should hide all hidden apps."""
00107         self.launch_test_apps()
00108 
00109         # show desktop, verify all windows are hidden:
00110         self.switcher.initiate()
00111         sleep(0.5)
00112         found = False
00113         switcher_model = self.switcher.controller.model
00114         for i in switcher_model.icons:
00115             current_icon = self.switcher.current_icon
00116             self.assertIsNotNone(current_icon)
00117             if isinstance(current_icon, DesktopLauncherIcon):
00118                 found = True
00119                 break
00120             self.switcher.previous_icon()
00121             sleep(0.25)
00122         self.assertTrue(found, "Could not find 'Show Desktop' entry in switcher.")
00123         self.addCleanup(self.window_manager.leave_show_desktop)
00124 
00125         self.switcher.select()
00126 
00127         sleep(3)
00128         open_wins = self.bamf.get_open_windows()
00129         self.assertGreaterEqual(len(open_wins), 2)
00130         for win in open_wins:
00131             self.assertTrue(win.is_valid)
00132             self.assertTrue(win.is_hidden, "Window '%s' is not hidden after show desktop activated." % (win.title))

Here is the call graph for this function:

Show desktop shortcut must re-show all hidden apps.

Definition at line 47 of file test_showdesktop.py.

00047 
00048     def test_showdesktop_unhides_apps(self):
00049         """Show desktop shortcut must re-show all hidden apps."""
00050         self.launch_test_apps()
00051 
00052         # show desktop, verify all windows are hidden:
00053         self.window_manager.enter_show_desktop()
00054         self.addCleanup(self.window_manager.leave_show_desktop)
00055 
00056         open_wins = self.bamf.get_open_windows()
00057         self.assertGreaterEqual(len(open_wins), 2)
00058         for win in open_wins:
00059             self.assertTrue(win.is_valid)
00060             self.assertTrue(win.is_hidden, "Window '%s' is not hidden after show desktop activated." % (win.title))
00061 
00062         # un-show desktop, verify all windows are shown:
00063         self.window_manager.leave_show_desktop()
00064 
00065         for win in self.bamf.get_open_windows():
00066             self.assertTrue(win.is_valid)
00067             self.assertFalse(win.is_hidden, "Window '%s' is shown after show desktop deactivated." % (win.title))

Here is the call graph for this function:

Un-hide a single app from launcher after hiding all apps.

Definition at line 68 of file test_showdesktop.py.

00068 
00069     def test_unhide_single_app(self):
00070         """Un-hide a single app from launcher after hiding all apps."""
00071         self.launch_test_apps()
00072 
00073         # show desktop, verify all windows are hidden:
00074         self.window_manager.enter_show_desktop()
00075         self.addCleanup(self.window_manager.leave_show_desktop)
00076 
00077         open_wins = self.bamf.get_open_windows()
00078         self.assertGreaterEqual(len(open_wins), 2)
00079         for win in open_wins:
00080             self.assertTrue(win.is_valid)
00081             self.assertTrue(win.is_hidden, "Window '%s' is not hidden after show desktop activated." % (win.title))
00082 
00083         # We'll un-minimise the character map - find it's launcherIcon in the launcher:
00084         charmap_icon = self.launcher.model.get_icon_by_desktop_id("gucharmap.desktop")
00085         if charmap_icon:
00086             self.launcher.get_launcher_for_monitor(0).click_launcher_icon(charmap_icon)
00087         else:
00088             self.fail("Could not find launcher icon in launcher.")
00089 
00090         sleep(3)
00091         for win in self.bamf.get_open_windows():
00092             if win.is_valid:
00093                 if win.title == 'Character Map':
00094                     self.assertFalse(win.is_hidden, "Character map did not un-hide from launcher.")
00095                 else:
00096                     self.assertTrue(win.is_hidden, "Window '%s' should still be hidden." % (win.title))
00097 
00098         # hide desktop - now all windows should be visible:
00099         self.window_manager.leave_show_desktop()
00100 
00101         for win in self.bamf.get_open_windows():
00102             if win.is_valid:
00103                 self.assertFalse(win.is_hidden, "Window '%s' is not shown after show desktop deactivated." % (win.title))

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


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