on xenial help sign in
Updated the notifications tests.
23211efLeo Arias
tests/autopilot/unity8/process_helpers.py+11
@@ -223,6 +223,17 @@ def stop_job(name):
223 raise
223 raise
224
224
225
225
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+
226def _get_unity_status():
237def _get_unity_status():
227 try:
238 try:
228 return get_job_status('unity8')
239 return get_job_status('unity8')
tests/autopilot/unity8/shell/emulators/main_window.py+8−16
@@ -25,7 +25,6 @@ from autopilot import input
25from unity8.shell import emulators
25from unity8.shell import emulators
26from unity8.shell.emulators.greeter import Greeter
26from unity8.shell.emulators.greeter import Greeter
27from unity8.shell.emulators.hud import Hud
27from unity8.shell.emulators.hud import Hud
28−from unity8.shell.emulators.dash import Dash
29from unity8.shell.emulators.launcher import Launcher
28from unity8.shell.emulators.launcher import Launcher
30
29
31logger = logging.getLogger(__name__)
30logger = logging.getLogger(__name__)
@@ -61,9 +60,6 @@ class QQuickView(emulators.UnityEmulatorBase):
61 def get_hud_edge_drag_area(self):
60 def get_hud_edge_drag_area(self):
62 return self.select_single(objectName="hudDragArea")
61 return self.select_single(objectName="hudDragArea")
63
62
64− def get_dash(self):
65− return self.select_single(Dash)
66−
67 def get_bottombar(self):
63 def get_bottombar(self):
68 return self.select_single("Bottombar")
64 return self.select_single("Bottombar")
69
65
@@ -111,23 +107,19 @@ class QQuickView(emulators.UnityEmulatorBase):
111 @autopilot_logging.log_action(logger.info)
107 @autopilot_logging.log_action(logger.info)
112 def show_dash_swiping(self):
108 def show_dash_swiping(self):
113 """Show the dash swiping from the left."""
109 """Show the dash swiping from the left."""
114− width = self.width
110+ x, y, width, height = self._get_shell().globalRect
115− height = self.height
116− start_x = 0
111+ start_x = x
117− start_y = height // 2
118− end_x = width
112+ end_x = x + width
119− end_y = start_y
113+ start_y = end_y = y + height // 2
120
114
121 self.pointing_device.drag(start_x, start_y, end_x, end_y)
115 self.pointing_device.drag(start_x, start_y, end_x, end_y)
116+
117+ def _get_shell(self):
122− return self.get_dash()
118+ return self.select_single('Shell')
123
119
124 def get_current_focused_app_id(self):
120 def get_current_focused_app_id(self):
125 """Return the id of the focused application."""
121 """Return the id of the focused application."""
126− return self.select_single('Shell').focusedApplicationId
122+ return self._get_shell().focusedApplicationId
127−
128− @autopilot_logging.log_action(logger.info)
129− def search(self, query):
130− self.get_dash().enter_search_query(query)
131
123
132 @autopilot_logging.log_action(logger.info)
124 @autopilot_logging.log_action(logger.info)
133 def enter_pin_code(self, code):
125 def enter_pin_code(self, code):
tests/autopilot/unity8/shell/tests/__init__.py+21−13
@@ -307,9 +307,14 @@ class UnityTestCase(AutopilotTestCase):
307
307
308 # Ensure that the dash is visible before we return:
308 # Ensure that the dash is visible before we return:
309 logger.debug("Unity started, waiting for it to be ready.")
309 logger.debug("Unity started, waiting for it to be ready.")
310− self.assertUnityReady()
310+ self.wait_for_unity()
311 logger.debug("Unity loaded and ready.")
311 logger.debug("Unity loaded and ready.")
312
312
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+
313 return app_proxy
318 return app_proxy
314
319
315 def _launch_unity_with_upstart(self, binary_path, args):
320 def _launch_unity_with_upstart(self, binary_path, args):
@@ -379,18 +384,10 @@ class UnityTestCase(AutopilotTestCase):
379 def _clear_proxy(self):
384 def _clear_proxy(self):
380 self._proxy = None
385 self._proxy = None
381
386
382− def assertUnityReady(self):
387+ def wait_for_unity(self):
383− dash = self.get_dash()
388+ greeter_content_loader = self.main_window.wait_select_single(
384− home_scope = dash.get_scope('clickscope')
389+ objectName='greeterContentLoader')
385−
390+ greeter_content_loader.progress.wait_for(1)
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−
394
391
395 def get_dash(self):
392 def get_dash(self):
396 pid = process_helpers.get_job_pid('unity8-dash')
393 pid = process_helpers.get_job_pid('unity8-dash')
@@ -439,6 +436,7 @@ class DashBaseTestCase(AutopilotTestCase):
439
436
440 self.dash_app = dash_helpers.DashApp(dash_proxy)
437 self.dash_app = dash_helpers.DashApp(dash_proxy)
441 self.dash = self.dash_app.dash
438 self.dash = self.dash_app.dash
439+ self.wait_for_dash()
442
440
443 def launch_dash(self, binary_path, variables):
441 def launch_dash(self, binary_path, variables):
444 launch_dash_app_fixture = fixture_setup.LaunchDashApp(
442 launch_dash_app_fixture = fixture_setup.LaunchDashApp(
@@ -446,6 +444,16 @@ class DashBaseTestCase(AutopilotTestCase):
446 self.useFixture(launch_dash_app_fixture)
444 self.useFixture(launch_dash_app_fixture)
447 return launch_dash_app_fixture.application_proxy
445 return launch_dash_app_fixture.application_proxy
448
446
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+
449 def should_simulate_device(self):
457 def should_simulate_device(self):
450 return (hasattr(self, 'app_width') and hasattr(self, 'app_height') and
458 return (hasattr(self, 'app_width') and hasattr(self, 'app_height') and
451 hasattr(self, 'grid_unit_px'))
459 hasattr(self, 'grid_unit_px'))
tests/autopilot/unity8/shell/tests/test_notifications.py+12−7
@@ -154,7 +154,7 @@ class InteractiveNotificationBase(NotificationsBase):
154 'Notification', objectName='notification1')
154 'Notification', objectName='notification1')
155 notification = get_notification()
155 notification = get_notification()
156
156
157− self.touch.tap_object(
157+ notification.pointing_device.click_object(
158 notification.select_single(objectName="interactiveArea")
158 notification.select_single(objectName="interactiveArea")
159 )
159 )
160
160
@@ -201,11 +201,14 @@ class InteractiveNotificationBase(NotificationsBase):
201 'Notification', objectName='notification1')
201 'Notification', objectName='notification1')
202 notification = get_notification()
202 notification = get_notification()
203 self._assert_notification(notification, summary, body, True, True, 1.0)
203 self._assert_notification(notification, summary, body, True, True, 1.0)
204− initial_height = notification.height
204+ notification.pointing_device.click_object(
205− self.touch.tap_object(notification.select_single(objectName="combobutton_dropdown"))
205+ notification.select_single(objectName="combobutton_dropdown"))
206+ self.assertThat(
206− self.assertThat(notification.select_single(objectName="button2").expanded, Eventually(Equals(True)))
207+ notification.select_single(objectName="button2").expanded,
208+ Eventually(Equals(True)))
207 time.sleep(2)
209 time.sleep(2)
210+ notification.pointing_device.click_object(
208− self.touch.tap_object(notification.select_single(objectName="button4"))
211+ notification.select_single(objectName="button4"))
209 self.assert_notification_action_id_was_called("action_decline_4")
212 self.assert_notification_action_id_was_called("action_decline_4")
210
213
211 def test_modal_sd_without_greeter(self):
214 def test_modal_sd_without_greeter(self):
@@ -249,7 +252,8 @@ class InteractiveNotificationBase(NotificationsBase):
249 notification = get_notification()
252 notification = get_notification()
250 self._assert_notification(
253 self._assert_notification(
251 notification, summary, body, True, False, 1.0)
254 notification, summary, body, True, False, 1.0)
255+ notification.pointing_device.click_object(
252− self.touch.tap_object(notification.select_single(objectName="button0"))
256+ notification.select_single(objectName="button0"))
253 self.assert_notification_action_id_was_called("action_accept")
257 self.assert_notification_action_id_was_called("action_accept")
254
258
255 def test_modal_sd_with_greeter(self):
259 def test_modal_sd_with_greeter(self):
@@ -291,7 +295,8 @@ class InteractiveNotificationBase(NotificationsBase):
291 notification = get_notification()
295 notification = get_notification()
292 self._assert_notification(
296 self._assert_notification(
293 notification, summary, body, True, False, 1.0)
297 notification, summary, body, True, False, 1.0)
298+ notification.pointing_device.click_object(
294− self.touch.tap_object(notification.select_single(objectName="button0"))
299+ notification.select_single(objectName="button0"))
295 self.assert_notification_action_id_was_called("action_accept")
300 self.assert_notification_action_id_was_called("action_accept")
296
301
297 def _create_interactive_notification(
302 def _create_interactive_notification(