on xenial help sign in
Add Autopilot Notification helper.
af668d5Ying-Chun Liu
tests/autopilot/unity8/shell/__init__.py+1
@@ -27,6 +27,7 @@ import logging
27
27
28logger = logging.getLogger(__name__)
28logger = logging.getLogger(__name__)
29
29
30+
30def disable_qml_mocking(fn):
31def disable_qml_mocking(fn):
31 """Simple decorator that disables the QML mocks from being loaded."""
32 """Simple decorator that disables the QML mocks from being loaded."""
32 @wraps(fn)
33 @wraps(fn)
tests/autopilot/unity8/shell/emulators/main_window.py+17
@@ -168,3 +168,20 @@ class QQuickView(emulators.UnityEmulatorBase):
168 'PinPadButton',
168 'PinPadButton',
169 objectName='pinPadButton{}'.format(button_id)
169 objectName='pinPadButton{}'.format(button_id)
170 )
170 )
171+
172+ @autopilot_logging.log_action(logger.info)
173+ def wait_for_notification(self):
174+ """Wait for a notification dialog to appear.
175+
176+ :return: An object for the notification dialog data.
177+ :raise StateNotFoundError: if the timeout expires when the
178+ notification has not appeared.
179+
180+ """
181+ notify_list = self.select_single('Notifications',
182+ objectName='notificationList')
183+ visible_notification = notify_list.wait_select_single('Notification',
184+ visible=True)
185+ return {'summary': visible_notification.summary,
186+ 'body': visible_notification.body,
187+ 'iconSource': visible_notification.iconSource}
tests/autopilot/unity8/shell/tests/test_notifications.py+19
@@ -701,3 +701,22 @@ class EphemeralNotificationsTests(NotificationsBase):
701 self.assertThat(get_notification, Eventually(NotEquals(None)))
701 self.assertThat(get_notification, Eventually(NotEquals(None)))
702 self._assert_notification(
702 self._assert_notification(
703 get_notification(), summary, body, False, False, 1.0)
703 get_notification(), summary, body, False, False, 1.0)
704+
705+ def test_notification_helper(self):
706+ """ use the create notification script to get a notification dialog.
707+ Check that the arguments passed to the script match the fields. """
708+
709+ unity_proxy = self.launch_unity()
710+ unlock_unity(unity_proxy)
711+
712+ summary = 'Helper summary'
713+ body = 'Helper body'
714+
715+ notification = shell.create_ephemeral_notification(summary, body)
716+ notification.show()
717+
718+ notification_data = self.main_window.wait_for_notification()
719+
720+ self.assertThat(notification_data['summary'],
721+ Eventually(Equals(summary)))
722+ self.assertThat(notification_data['body'], Eventually(Equals(body)))