on xenial help sign in
Updated the notifications tests.
commit23211efc373460f59547ef1d7115c7ebb69b353b authorLeo Arias <leo.arias@canonical.com> dateWed 30 Jul 2014, 13:29 (12 years ago) parent2797093
4 files changed+52−36
tests/autopilot/unity8/process_helpers.py+11 tests/autopilot/unity8/shell/emulators/main_window.py+8−16 tests/autopilot/unity8/shell/tests/__init__.py+21−13 tests/autopilot/unity8/shell/tests/test_notifications.py+12−7
tests/autopilot/unity8/process_helpers.py+11
@@ -223,6 +223,17 @@ def stop_job(name):
223223 raise
224224
225225
226+def is_job_running(name):
227+ """Return True if the job is running. Otherwise, False.
228+
229+ :param str name: The name of the job.
230+ :raises JobError: if it's not possible to get the status of the job.
231+
232+ """
233+ status = get_job_status(name)
234+ return 'start/running' in status
235+
236+
226237def _get_unity_status():
227238 try:
228239 return get_job_status('unity8')
tests/autopilot/unity8/shell/emulators/main_window.py+8−16
@@ -25,7 +25,6 @@ from autopilot import input
2525from unity8.shell import emulators
2626from unity8.shell.emulators.greeter import Greeter
2727from unity8.shell.emulators.hud import Hud
28−from unity8.shell.emulators.dash import Dash
2928from unity8.shell.emulators.launcher import Launcher
3029
3130logger = logging.getLogger(__name__)
@@ -61,9 +60,6 @@ class QQuickView(emulators.UnityEmulatorBase):
6160 def get_hud_edge_drag_area(self):
6261 return self.select_single(objectName="hudDragArea")
6362
64− def get_dash(self):
65− return self.select_single(Dash)
66−
6763 def get_bottombar(self):
6864 return self.select_single("Bottombar")
6965
@@ -111,23 +107,19 @@ class QQuickView(emulators.UnityEmulatorBase):
111107 @autopilot_logging.log_action(logger.info)
112108 def show_dash_swiping(self):
113109 """Show the dash swiping from the left."""
114− width = self.width
115− height = self.height
116− start_x = 0
117− start_y = height // 2
118− end_x = width
119− end_y = start_y
110+ x, y, width, height = self._get_shell().globalRect
111+ start_x = x
112+ end_x = x + width
113+ start_y = end_y = y + height // 2
120114
121115 self.pointing_device.drag(start_x, start_y, end_x, end_y)
122− return self.get_dash()
116+
117+ def _get_shell(self):
118+ return self.select_single('Shell')
123119
124120 def get_current_focused_app_id(self):
125121 """Return the id of the focused application."""
126− return self.select_single('Shell').focusedApplicationId
127−
128− @autopilot_logging.log_action(logger.info)
129− def search(self, query):
130− self.get_dash().enter_search_query(query)
122+ return self._get_shell().focusedApplicationId
131123
132124 @autopilot_logging.log_action(logger.info)
133125 def enter_pin_code(self, code):
tests/autopilot/unity8/shell/tests/__init__.py+21−13
@@ -307,9 +307,14 @@ class UnityTestCase(AutopilotTestCase):
307307
308308 # Ensure that the dash is visible before we return:
309309 logger.debug("Unity started, waiting for it to be ready.")
310− self.assertUnityReady()
310+ self.wait_for_unity()
311311 logger.debug("Unity loaded and ready.")
312312
313+ if model() == 'Desktop':
314+ # On desktop, close the dash because it's opened in a separate
315+ # window and it gets on the way.
316+ process_helpers.stop_job('unity8-dash')
317+
313318 return app_proxy
314319
315320 def _launch_unity_with_upstart(self, binary_path, args):
@@ -379,18 +384,10 @@ class UnityTestCase(AutopilotTestCase):
379384 def _clear_proxy(self):
380385 self._proxy = None
381386
382− def assertUnityReady(self):
383− dash = self.get_dash()
384− home_scope = dash.get_scope('clickscope')
385−
386− # FIXME! There is a huge timeout here for when we're doing CI on
387− # VMs. See lp:1203715
388− self.assertThat(
389− home_scope.isLoaded,
390− Eventually(Equals(True), timeout=60)
391− )
392− self.assertThat(home_scope.isCurrent, Eventually(Equals(True)))
393−
387+ def wait_for_unity(self):
388+ greeter_content_loader = self.main_window.wait_select_single(
389+ objectName='greeterContentLoader')
390+ greeter_content_loader.progress.wait_for(1)
394391
395392 def get_dash(self):
396393 pid = process_helpers.get_job_pid('unity8-dash')
@@ -439,6 +436,7 @@ class DashBaseTestCase(AutopilotTestCase):
439436
440437 self.dash_app = dash_helpers.DashApp(dash_proxy)
441438 self.dash = self.dash_app.dash
439+ self.wait_for_dash()
442440
443441 def launch_dash(self, binary_path, variables):
444442 launch_dash_app_fixture = fixture_setup.LaunchDashApp(
@@ -446,6 +444,16 @@ class DashBaseTestCase(AutopilotTestCase):
446444 self.useFixture(launch_dash_app_fixture)
447445 return launch_dash_app_fixture.application_proxy
448446
447+ def wait_for_dash(self):
448+ home_scope = self.dash.get_scope('clickscope')
449+ # FIXME! There is a huge timeout here for when we're doing CI on
450+ # VMs. See lp:1203715
451+ self.assertThat(
452+ home_scope.isLoaded,
453+ Eventually(Equals(True), timeout=60)
454+ )
455+ self.assertThat(home_scope.isCurrent, Eventually(Equals(True)))
456+
449457 def should_simulate_device(self):
450458 return (hasattr(self, 'app_width') and hasattr(self, 'app_height') and
451459 hasattr(self, 'grid_unit_px'))
tests/autopilot/unity8/shell/tests/test_notifications.py+12−7
@@ -154,7 +154,7 @@ class InteractiveNotificationBase(NotificationsBase):
154154 'Notification', objectName='notification1')
155155 notification = get_notification()
156156
157− self.touch.tap_object(
157+ notification.pointing_device.click_object(
158158 notification.select_single(objectName="interactiveArea")
159159 )
160160
@@ -201,11 +201,14 @@ class InteractiveNotificationBase(NotificationsBase):
201201 'Notification', objectName='notification1')
202202 notification = get_notification()
203203 self._assert_notification(notification, summary, body, True, True, 1.0)
204− initial_height = notification.height
205− self.touch.tap_object(notification.select_single(objectName="combobutton_dropdown"))
206− self.assertThat(notification.select_single(objectName="button2").expanded, Eventually(Equals(True)))
204+ notification.pointing_device.click_object(
205+ notification.select_single(objectName="combobutton_dropdown"))
206+ self.assertThat(
207+ notification.select_single(objectName="button2").expanded,
208+ Eventually(Equals(True)))
207209 time.sleep(2)
208− self.touch.tap_object(notification.select_single(objectName="button4"))
210+ notification.pointing_device.click_object(
211+ notification.select_single(objectName="button4"))
209212 self.assert_notification_action_id_was_called("action_decline_4")
210213
211214 def test_modal_sd_without_greeter(self):
@@ -249,7 +252,8 @@ class InteractiveNotificationBase(NotificationsBase):
249252 notification = get_notification()
250253 self._assert_notification(
251254 notification, summary, body, True, False, 1.0)
252− self.touch.tap_object(notification.select_single(objectName="button0"))
255+ notification.pointing_device.click_object(
256+ notification.select_single(objectName="button0"))
253257 self.assert_notification_action_id_was_called("action_accept")
254258
255259 def test_modal_sd_with_greeter(self):
@@ -291,7 +295,8 @@ class InteractiveNotificationBase(NotificationsBase):
291295 notification = get_notification()
292296 self._assert_notification(
293297 notification, summary, body, True, False, 1.0)
294− self.touch.tap_object(notification.select_single(objectName="button0"))
298+ notification.pointing_device.click_object(
299+ notification.select_single(objectName="button0"))
295300 self.assert_notification_action_id_was_called("action_accept")
296301
297302 def _create_interactive_notification(