Back to index

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

List of all members.

Public Member Functions

def setUp
def tearDown
def test_no_results
def test_results_category_appears
def test_result_category_actually_contains_results
def test_run_before_refresh
def test_ctrl_tab_switching
def test_ctrl_shift_tab_switching
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 command lense search bahavior.

Definition at line 18 of file test_command_lens.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

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 21 of file test_command_lens.py.

00021 
00022     def setUp(self):
00023         super(CommandLensSearchTests, self).setUp()

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

Definition at line 24 of file test_command_lens.py.

00024 
00025     def tearDown(self):
00026         self.dash.ensure_hidden()
00027         super(CommandLensSearchTests, self).tearDown()

Pressing Ctrl+Shift+Tab after launching command lens must switch to Video lens.

Definition at line 82 of file test_command_lens.py.

00082 
00083     def test_ctrl_shift_tab_switching(self):
00084         """Pressing Ctrl+Shift+Tab after launching command lens must switch to Video lens."""
00085         self.dash.reveal_command_lens()
00086         self.keybinding("dash/lens/prev")
00087         self.assertThat(self.dash.active_lens, Eventually(Equals("video.lens")))
Pressing Ctrl+Tab after launching command lens must switch to Home lens.

Definition at line 76 of file test_command_lens.py.

00076 
00077     def test_ctrl_tab_switching(self):
00078         """Pressing Ctrl+Tab after launching command lens must switch to Home lens."""
00079         self.dash.reveal_command_lens()
00080         self.keybinding("dash/lens/next")
00081         self.assertThat(self.dash.active_lens, Eventually(Equals("home.lens")))

An empty string should get no results.

Definition at line 28 of file test_command_lens.py.

00028 
00029     def test_no_results(self):
00030         """An empty string should get no results."""
00031         self.dash.reveal_command_lens()
00032         command_lens = self.dash.get_current_lens()
00033 
00034         if self.dash.search_string != "":
00035             self.keyboard.press_and_release("Delete")
00036 
00037         self.assertThat(self.dash.search_string, Eventually(Equals("")))
00038         results_category = command_lens.get_category_by_name("Results")
00039         self.assertThat(results_category.is_visible, Eventually(Equals(False)))

With a search string of 'a', the results category must contain some results.

Definition at line 50 of file test_command_lens.py.

00050 
00051     def test_result_category_actually_contains_results(self):
00052         """With a search string of 'a', the results category must contain some results."""
00053         self.dash.reveal_command_lens()
00054         command_lens = self.dash.get_current_lens()
00055         # lots of apps start with 'a'...
00056         self.keyboard.type("a")
00057         self.assertThat(self.dash.search_string, Eventually(Equals("a")))
00058         results_category = command_lens.get_category_by_name("Results")
00059         results = results_category.get_results()
00060         self.assertTrue(results)

Results category must appear when there are some results.

Definition at line 40 of file test_command_lens.py.

00040 
00041     def test_results_category_appears(self):
00042         """Results category must appear when there are some results."""
00043         self.dash.reveal_command_lens()
00044         command_lens = self.dash.get_current_lens()
00045         # lots of apps start with 'a'...
00046         self.keyboard.type("a")
00047         self.assertThat(self.dash.search_string, Eventually(Equals("a")))
00048         results_category = command_lens.get_category_by_name("Results")
00049         self.assertThat(results_category.is_visible, Eventually(Equals(True)))

Hitting enter before view has updated results must run the correct command.

Definition at line 61 of file test_command_lens.py.

00061 
00062     def test_run_before_refresh(self):
00063         """Hitting enter before view has updated results must run the correct command."""
00064         if self.app_is_running("Text Editor"):
00065             self.close_all_app("Text Editor")
00066             sleep(1)
00067 
00068         self.dash.reveal_command_lens()
00069         self.keyboard.type("g")
00070         sleep(1)
00071         self.keyboard.type("edit", 0.1)
00072         self.keyboard.press_and_release("Enter", 0.1)
00073         self.addCleanup(self.close_all_app,  "Text Editor")
00074         app_found = self.bamf.wait_until_application_is_running("gedit.desktop", 5)
00075         self.assertTrue(app_found)

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: