on xenial help sign in
Merged with prerequisite.
1d7fa53Leo Arias
tests/autopilot/unity8/shell/emulators/launcher.py+4−20
@@ -35,36 +35,20 @@ class Launcher(emulators.UnityEmulatorBase):
35 def show(self):
35 def show(self):
36 """Show the launcher swiping it to the right."""
36 """Show the launcher swiping it to the right."""
37 if not self.shown:
37 if not self.shown:
38− self._swipe_launcher('right')
38+ self._swipe_to_show_launcher()
39 self.shown.wait_for(True)
39 self.shown.wait_for(True)
40 else:
40 else:
41 logger.debug('The launcher is already opened.')
41 logger.debug('The launcher is already opened.')
42
42
43− def _swipe_launcher(self, direction):
43+ def _swipe_to_show_launcher(self):
44 view = self.get_root_instance().select_single('QQuickView')
44 view = self.get_root_instance().select_single('QQuickView')
45 start_y = stop_y = view.y + view.height // 2
45 start_y = stop_y = view.y + view.height // 2
46
46
47− left = view.x + 1
47+ start_x = view.x + 1
48− right = left + self.panelWidth - 1
48+ stop_x = start_x + self.panelWidth - 1
49−
50− if direction == 'right':
51− start_x = left
52− stop_x = right
53− elif direction == 'left':
54− start_x = right
55− stop_x = left
56
49
57 self.pointing_device.drag(start_x, start_y, stop_x, stop_y)
50 self.pointing_device.drag(start_x, start_y, stop_x, stop_y)
58
51
59− @autopilot.logging.log_action(logger.debug)
60− def hide(self):
61− """Hide the launcher swiping it to the left."""
62− if self.shown:
63− self._swipe_launcher('left')
64− self.shown.wait_for(False)
65− else:
66− logger.debug('The launcher is already closed.')
67−
68 @autopilot.logging.log_action(logger.debug)
52 @autopilot.logging.log_action(logger.debug)
69 def click_dash_icon(self):
53 def click_dash_icon(self):
70 if self.shown:
54 if self.shown:
tests/autopilot/unity8/shell/emulators/main_window.py−5
@@ -153,11 +153,6 @@ class QQuickView(emulators.UnityEmulatorBase):
153 def _get_launcher(self):
153 def _get_launcher(self):
154 return self.select_single(Launcher)
154 return self.select_single(Launcher)
155
155
156− @autopilot_logging.log_action(logger.info)
157− def close_launcher(self):
158− launcher = self._get_launcher()
159− launcher.hide()
160−
161 def is_launcher_open(self):
156 def is_launcher_open(self):
162 return self._get_launcher().shown
157 return self._get_launcher().shown
163
158
tests/autopilot/unity8/shell/tests/test_emulators.py+1−58
@@ -34,10 +34,7 @@ except ImportError:
34
34
35from unity8 import process_helpers
35from unity8 import process_helpers
36from unity8.shell import emulators, fixture_setup, tests
36from unity8.shell import emulators, fixture_setup, tests
37−from unity8.shell.emulators import (
37+from unity8.shell.emulators import dash as dash_emulators
38− dash as dash_emulators,
39− launcher as launcher_emulator
40−)
41
38
42
39
43class MainWindowTestCase(tests.UnityTestCase):
40class MainWindowTestCase(tests.UnityTestCase):
@@ -55,24 +52,6 @@ class MainWindowTestCase(tests.UnityTestCase):
55 self.assertEqual(text_field.text, 'Test')
52 self.assertEqual(text_field.text, 'Test')
56 self.assertEqual(text_field.state, 'idle')
53 self.assertEqual(text_field.state, 'idle')
57
54
58− def test_open_launcher_must_return_launcher_custom_proxy_object(self):
59− launcher = self.main_window.open_launcher()
60− self.assertIsInstance(launcher, launcher_emulator.Launcher)
61−
62− def test_open_launcher_must_open_it(self):
63− # Make sure that the launcher is closed.
64− self.main_window.close_launcher()
65− self.main_window.open_launcher()
66−
67− self.assertTrue(self.main_window.is_launcher_open())
68−
69− def test_close_launcher_must_close_it(self):
70− # Make sure that the launcher is open.
71− self.main_window.open_launcher()
72− self.main_window.close_launcher()
73−
74− self.assertFalse(self.main_window.is_launcher_open())
75−
76
55
77class DashBaseTestCase(tests.UnityTestCase):
56class DashBaseTestCase(tests.UnityTestCase):
78
57
@@ -219,39 +198,3 @@ class DashAppsEmulatorTestCase(DashBaseTestCase):
219 return filtergrid.collapsedRowCount * filtergrid.columns
198 return filtergrid.collapsedRowCount * filtergrid.columns
220 else:
199 else:
221 return filtergrid.uncollapsedRowCount * filtergrid.columns
200 return filtergrid.uncollapsedRowCount * filtergrid.columns
222−
223−
224−class LauncherTestCase(tests.UnityTestCase):
225−
226− scenarios = tests._get_device_emulation_scenarios()
227−
228− def setUp(self):
229− super(LauncherTestCase, self).setUp()
230− unity_proxy = self.launch_unity()
231− process_helpers.unlock_unity(unity_proxy)
232−
233− def test_show_launcher_with_launcher_open_must_do_nothing(self):
234− launcher = self.main_window.open_launcher()
235− with mock.patch.object(launcher.pointing_device, 'drag') as mock_drag:
236− launcher.show()
237−
238− self.assertFalse(mock_drag.called)
239−
240− def test_hide_launcher_with_launcher_closed_must_do_nothing(self):
241− launcher = self.main_window.open_launcher()
242− launcher.hide()
243− with mock.patch.object(launcher.pointing_device, 'drag') as mock_drag:
244− launcher.hide()
245−
246− self.assertFalse(mock_drag.called)
247−
248− def test_click_dash_icon_with_launcher_closed_must_raise_exception(self):
249− launcher = self.main_window.open_launcher()
250− launcher.hide()
251−
252− exception = self.assertRaises(
253− emulators.UnityEmulatorException,
254− launcher.click_dash_icon)
255−
256− self.assertEqual(
257− 'The launcher is closed.', str(exception))