on xenial help sign in
Add Autopilot Notification helper.

Approved by: Leo Arias, Allan LeSage, Albert Astals Cid

commitaf668d5cc29a5876a1250cbb815e1c1254d6c3aa authorYing-Chun Liu <paul.liu@canonical.com> dateTue 24 Feb 2015, 10:15 (12 years ago) parent0fbe561e59897b
3 files changed+37
tests/autopilot/unity8/shell/__init__.py+1 tests/autopilot/unity8/shell/emulators/main_window.py+17 tests/autopilot/unity8/shell/tests/test_notifications.py+19
tests/autopilot/unity8/shell/__init__.py+1
@@ -27,6 +27,7 @@ import logging
2727
2828logger = logging.getLogger(__name__)
2929
30+
3031def disable_qml_mocking(fn):
3132 """Simple decorator that disables the QML mocks from being loaded."""
3233 @wraps(fn)
tests/autopilot/unity8/shell/emulators/main_window.py+17
@@ -168,3 +168,20 @@ class QQuickView(emulators.UnityEmulatorBase):
168168 'PinPadButton',
169169 objectName='pinPadButton{}'.format(button_id)
170170 )
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):
701701 self.assertThat(get_notification, Eventually(NotEquals(None)))
702702 self._assert_notification(
703703 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)))