Back to index

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

List of all members.

Public Member Functions

def open_quicklist_for_icon
def test_quicklist_actions
def test_quicklist_application_item_focus_last_active_window
def test_quicklist_application_item_initiate_spread
def test_quicklist_item_triggered_closes_dash
def setUp
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

Static Public Attributes

list scenarios

Detailed Description

Tests for quicklist actions.

Definition at line 22 of file test_quicklist.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

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

Open the quicklist for the given launcher icon.

Returns the quicklist that was opened.

Definition at line 29 of file test_quicklist.py.

00029 
00030     def open_quicklist_for_icon(self, launcher_icon):
00031         """Open the quicklist for the given launcher icon.
00032 
00033         Returns the quicklist that was opened.
00034 
00035         """
00036         launcher = self.launcher.get_launcher_for_monitor(0)
00037         launcher.click_launcher_icon(launcher_icon, button=3)
00038         self.addCleanup(self.keyboard.press_and_release, "Escape")
00039         for i in range(10):
00040             ql = launcher_icon.get_quicklist()
00041             if ql:
00042                 return ql
00043             sleep(1)

Here is the caller 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.UnityTestCase.setUp (   self) [inherited]

Reimplemented in unity.tests.test_panel.PanelCrossMonitorsTests, unity.tests.test_dash.DashBorderTests, unity.tests.test_dash.DashLensBarTests, unity.tests.test_hud.HudVisualTests, unity.tests.test_hud.HudLockedLauncherInteractionsTests, unity.tests.test_hud.HudLauncherInteractionsTests, unity.tests.test_switcher.SwitcherDetailsTests, unity.tests.test_panel.PanelWindowButtonsTests, unity.tests.test_ibus.IBusTestsAnthyIgnore, unity.tests.test_ibus.IBusTestsPinyinIgnore, unity.tests.test_ibus.IBusTestsAnthy, unity.tests.test_quicklist.QuicklistKeyNavigationTests, unity.tests.test_ibus.IBusTestsHangul, unity.tests.test_dash.DashMultiKeyTests, unity.tests.test_ibus.IBusTestsPinyin, unity.tests.test_hud.HudBehaviorTests, unity.tests.test_hud.HudTestsBase, unity.tests.test_panel.PanelTestsBase, unity.tests.launcher.LauncherTestCase, unity.tests.test_switcher.SwitcherTests, unity.tests.launcher.test_capture.LauncherCaptureTests, unity.tests.test_ibus.IBusTests, unity.tests.launcher.test_icon_behavior.LauncherIconsTests, unity.tests.launcher.test_reveal.LauncherRevealTests, unity.tests.launcher.test_shortcut.LauncherShortcutTests, unity.tests.test_shortcut_hint.BaseShortcutHintTests, unity.tests.test_command_lens.CommandLensSearchTests, unity.tests.test_dash.DashTestCase, unity.tests.test_home_lens.HomeLensSearchTests, and unity.tests.test_showdesktop.ShowDesktopTests.

Definition at line 46 of file __init__.py.

00046 
00047     def setUp(self):
00048         super(UnityTestCase, self).setUp()
00049         self._setUpUnityLogging()
00050         self._initial_workspace_num = self.workspace.current_workspace
00051         self.addCleanup(self.check_test_behavior)
00052         #
00053         # Setting this here since the show desktop feature seems to be a bit
00054         # ropey. Once it's been proven to work reliably we can remove this line:
00055         self.set_unity_log_level("unity.plugin", "DEBUG")

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

Test that all actions present in the destop file are shown in the quicklist.

Definition at line 44 of file test_quicklist.py.

00044 
00045     def test_quicklist_actions(self):
00046         """Test that all actions present in the destop file are shown in the quicklist."""
00047         self.start_app(self.app_name)
00048 
00049         # load the desktop file from disk:
00050         desktop_id = self.KNOWN_APPS[self.app_name]['desktop-file']
00051         desktop_file = os.path.join('/usr/share/applications', desktop_id)
00052         de = DesktopEntry(desktop_file)
00053         # get the launcher icon from the launcher:
00054         launcher_icon = self.launcher.model.get_icon_by_desktop_id(desktop_id)
00055         self.assertThat(launcher_icon, NotEquals(None))
00056 
00057         # open the icon quicklist, and get all the text labels:
00058         ql = self.open_quicklist_for_icon(launcher_icon)
00059         ql_item_texts = [i.text for i in ql.items if type(i) is QuicklistMenuItemLabel]
00060 
00061         # iterate over all the actions from the desktop file, make sure they're
00062         # present in the quicklist texts.
00063         # FIXME, this doesn't work using a locale other than English.
00064         actions = de.getActions()
00065         for action in actions:
00066             key = 'Desktop Action ' + action
00067             self.assertThat(de.content, Contains(key))
00068             name = de.content[key]['Name']
00069             self.assertThat(ql_item_texts, Contains(name))

Here is the call graph for this function:

This tests shows that when you activate a quicklist application item
only the last focused instance of that application is rasied.

This is tested by opening 2 Mahjongg and a Calculator.
Then we activate the Calculator quicklist item.
Then we actiavte the Mahjongg launcher icon.

Definition at line 70 of file test_quicklist.py.

00070 
00071     def test_quicklist_application_item_focus_last_active_window(self):
00072         """This tests shows that when you activate a quicklist application item
00073         only the last focused instance of that application is rasied.
00074 
00075         This is tested by opening 2 Mahjongg and a Calculator.
00076         Then we activate the Calculator quicklist item.
00077         Then we actiavte the Mahjongg launcher icon.
00078         """
00079         mah_win1 = self.start_app_window("Mahjongg")
00080         calc_win = self.start_app_window("Calculator")
00081         mah_win2 = self.start_app_window("Mahjongg")
00082 
00083         self.assertVisibleWindowStack([mah_win2, calc_win, mah_win1])
00084 
00085         mahj_icon = self.launcher.model.get_icon_by_desktop_id(
00086             mah_win1.application.desktop_file)
00087         calc_icon = self.launcher.model.get_icon_by_desktop_id(
00088             calc_win.application.desktop_file)
00089 
00090         calc_ql = self.open_quicklist_for_icon(calc_icon)
00091         calc_ql.get_quicklist_application_item(calc_win.application.name).mouse_click()
00092 
00093         self.assertProperty(calc_win, is_focused=True)
00094         self.assertVisibleWindowStack([calc_win, mah_win2, mah_win1])
00095 
00096         mahj_ql = self.open_quicklist_for_icon(mahj_icon)
00097         mahj_ql.get_quicklist_application_item(mah_win1.application.name).mouse_click()
00098 
00099         self.assertProperty(mah_win2, is_focused=True)
00100         self.assertVisibleWindowStack([mah_win2, calc_win, mah_win1])

Here is the call graph for this function:

This tests shows that when you activate a quicklist application item
when an application window is focused, the spread is initiated.

Definition at line 101 of file test_quicklist.py.

00101 
00102     def test_quicklist_application_item_initiate_spread(self):
00103         """This tests shows that when you activate a quicklist application item
00104         when an application window is focused, the spread is initiated.
00105         """
00106         calc_win1 = self.start_app_window("Calculator")
00107         calc_win2 = self.start_app_window("Calculator")
00108         calc_app = calc_win1.application
00109 
00110         self.assertVisibleWindowStack([calc_win2, calc_win1])
00111         self.assertProperty(calc_win2, is_focused=True)
00112 
00113         calc_icon = self.launcher.model.get_icon_by_desktop_id(calc_app.desktop_file)
00114 
00115         calc_ql = self.open_quicklist_for_icon(calc_icon)
00116         app_item = calc_ql.get_quicklist_application_item(calc_app.name)
00117 
00118         self.addCleanup(self.keybinding, "spread/cancel")
00119         app_item.mouse_click()
00120         self.assertThat(self.window_manager.scale_active, Eventually(Equals(True)))
00121         self.assertThat(self.window_manager.scale_active_for_group, Eventually(Equals(True)))

Here is the call graph for this function:

When any quicklist item is triggered it must close the dash.

Definition at line 122 of file test_quicklist.py.

00122 
00123     def test_quicklist_item_triggered_closes_dash(self):
00124         """When any quicklist item is triggered it must close the dash."""
00125 
00126         calc_win = self.start_app_window("Calculator")
00127         self.assertProperty(calc_win, is_focused=True)
00128 
00129         self.dash.ensure_visible()
00130 
00131         calc_icon = self.launcher.model.get_icon_by_desktop_id(
00132             calc_win.application.desktop_file)
00133         self.open_quicklist_for_icon(calc_icon)
00134 
00135         self.keyboard.press_and_release("Down")
00136         self.keyboard.press_and_release("Enter")
00137         self.assertThat(self.dash.visible, Eventually(Equals(False)))
00138 

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

Initial value:
[
        ('remmina', {'app_name': 'Remmina'}),
    ]

Definition at line 25 of file test_quicklist.py.


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