@@ -21,6 +21,7 @@
22from __future__ import absolute_import
22from __future__ import absolute_import
24+from unity8 import shell
24from unity8.process_helpers import unlock_unity
25from unity8.process_helpers import unlock_unity
25from unity8.shell.tests import UnityTestCase, _get_device_emulation_scenarios
26from unity8.shell.tests import UnityTestCase, _get_device_emulation_scenarios
@@ -64,7 +65,8 @@ class NotificationsBase(UnityTestCase):
64 if os.path.abspath(__file__).startswith('/usr/'):
65 if os.path.abspath(__file__).startswith('/usr/'):
65 return '/usr/share/unity8/graphics/' + icon_name
66 return '/usr/share/unity8/graphics/' + icon_name
67− return os.path.dirname(__file__) + "/../../../../../qml/graphics/" + icon_name
68+ return os.path.dirname(__file__) + (
69+ "/../../../../../qml/graphics/" + icon_name)
69 def _get_notifications_list(self):
71 def _get_notifications_list(self):
70 return self.main_window.select_single(
72 return self.main_window.select_single(
@@ -196,7 +198,7 @@ class InteractiveNotificationBase(NotificationsBase):
196 get_notification = lambda: notify_list.wait_select_single(
198 get_notification = lambda: notify_list.wait_select_single(
197 'Notification', objectName='notification1')
199 'Notification', objectName='notification1')
198 notification = get_notification()
200 notification = get_notification()
199− self._assert_notification(notification, None, None, True, True, 1.0)
201+ self._assert_notification(notification, summary, body, True, True, 1.0)
200 initial_height = notification.height
202 initial_height = notification.height
201 self.touch.tap_object(notification.select_single(objectName="button1"))
203 self.touch.tap_object(notification.select_single(objectName="button1"))
202 self.assertThat(
204 self.assertThat(
@@ -209,6 +211,89 @@ class InteractiveNotificationBase(NotificationsBase):
209 self.touch.tap_object(notification.select_single(objectName="button4"))
211 self.touch.tap_object(notification.select_single(objectName="button4"))
210 self.assert_notification_action_id_was_called("action_decline_4")
212 self.assert_notification_action_id_was_called("action_decline_4")
214+ def test_modal_sd_without_greeter (self):
215+ """A snap-decision on a phone should block input to shell beneath it when there's no greeter."""
216+ unity_proxy = self.launch_unity()
217+ unlock_unity(unity_proxy)
219+ summary = "Incoming file"
220+ body = "Frank would like to send you the file: essay.pdf"
221+ icon_path = "sync-idle"
223+ ("x-canonical-snap-decisions", "true"),
224+ ("x-canonical-non-shaped-icon", "true"),
228+ ('action_accept', 'Accept'),
229+ ('action_decline_1', 'Decline'),
232+ self._create_interactive_notification(
241+ # verify that we cannot reveal the launcher (no longer interact with the shell)
243+ self.main_window.show_dash_swiping()
244+ launcher = self.main_window.get_launcher()
245+ self.assertThat(launcher.shown, Eventually(Equals(False)))
247+ # verify and interact with the triggered snap-decision notification
248+ notify_list = self._get_notifications_list()
249+ get_notification = lambda: notify_list.wait_select_single(
250+ 'Notification', objectName='notification1')
251+ notification = get_notification()
252+ self._assert_notification(notification, summary, body, True, False, 1.0)
253+ self.touch.tap_object(notification.select_single(objectName="button0"))
254+ self.assert_notification_action_id_was_called("action_accept")
256+ def test_modal_sd_with_greeter (self):
257+ """A snap-decision on a phone should not block input to the greeter beneath it."""
258+ unity_proxy = self.launch_unity()
260+ summary = "Incoming file"
261+ body = "Frank would like to send you the file: essay.pdf"
262+ icon_path = "sync-idle"
264+ ("x-canonical-snap-decisions", "true"),
265+ ("x-canonical-non-shaped-icon", "true"),
269+ ('action_accept', 'Accept'),
270+ ('action_decline_1', 'Decline'),
273+ self._create_interactive_notification(
282+ # verify that we can swipe away the greeter (interact with the "shell")
284+ self.main_window.show_dash_swiping()
285+ greeter = self.main_window.get_greeter()
286+ self.assertThat(greeter.shown, Eventually(Equals(False)))
288+ # verify and interact with the triggered snap-decision notification
289+ notify_list = self._get_notifications_list()
290+ get_notification = lambda: notify_list.wait_select_single(
291+ 'Notification', objectName='notification1')
292+ notification = get_notification()
293+ self._assert_notification(notification, summary, body, True, False, 1.0)
294+ self.touch.tap_object(notification.select_single(objectName="button0"))
295+ self.assert_notification_action_id_was_called("action_accept")
212 def _create_interactive_notification(
297 def _create_interactive_notification(
214 summary="",
299 summary="",
@@ -354,7 +439,7 @@ class EphemeralNotificationsTests(NotificationsBase):
357− notification = self._create_ephemeral_notification(
442+ notification = shell.create_ephemeral_notification(
360 icon_path,
445 icon_path,
@@ -391,7 +476,7 @@ class EphemeralNotificationsTests(NotificationsBase):
394− notification = self._create_ephemeral_notification(
479+ notification = shell.create_ephemeral_notification(
@@ -403,7 +488,6 @@ class EphemeralNotificationsTests(NotificationsBase):
404 notification = lambda: notify_list.wait_select_single(
489 notification = lambda: notify_list.wait_select_single(
405 'Notification', objectName='notification1')
490 'Notification', objectName='notification1')
407 self._assert_notification(
491 self._assert_notification(
408 notification(),
492 notification(),
@@ -434,7 +518,7 @@ class EphemeralNotificationsTests(NotificationsBase):
434 body_critical = 'Dude, this is so urgent you have no idea :)'
518 body_critical = 'Dude, this is so urgent you have no idea :)'
435 icon_path_critical = self._get_icon_path('avatars/anna_olsson.png')
519 icon_path_critical = self._get_icon_path('avatars/anna_olsson.png')
437− notification_normal = self._create_ephemeral_notification(
521+ notification_normal = shell.create_ephemeral_notification(
438 summary_normal,
522 summary_normal,
439 body_normal,
523 body_normal,
440 icon_path_normal,
524 icon_path_normal,
@@ -442,7 +526,7 @@ class EphemeralNotificationsTests(NotificationsBase):
443 notification_normal.show()
527 notification_normal.show()
445− notification_low = self._create_ephemeral_notification(
529+ notification_low = shell.create_ephemeral_notification(
446 summary_low,
530 summary_low,
447 body_low,
531 body_low,
448 icon_path_low,
532 icon_path_low,
@@ -450,7 +534,7 @@ class EphemeralNotificationsTests(NotificationsBase):
451 notification_low.show()
535 notification_low.show()
453− notification_critical = self._create_ephemeral_notification(
537+ notification_critical = shell.create_ephemeral_notification(
454 summary_critical,
538 summary_critical,
455 body_critical,
539 body_critical,
456 icon_path_critical,
540 icon_path_critical,
@@ -511,7 +595,7 @@ class EphemeralNotificationsTests(NotificationsBase):
511 summary = 'Summary-Body'
595 summary = 'Summary-Body'
512 body = 'This is a superfluous notification'
596 body = 'This is a superfluous notification'
514− notification = self._create_ephemeral_notification(summary, body)
598+ notification = shell.create_ephemeral_notification(summary, body)
515 notification.show()
599 notification.show()
517 notification = notify_list.wait_select_single(
601 notification = notify_list.wait_select_single(
@@ -535,7 +619,7 @@ class EphemeralNotificationsTests(NotificationsBase):
536 summary = 'Summary-Only'
620 summary = 'Summary-Only'
538− notification = self._create_ephemeral_notification(summary)
622+ notification = shell.create_ephemeral_notification(summary)
539 notification.show()
623 notification.show()
541 notification = notify_list.wait_select_single(
625 notification = notify_list.wait_select_single(
@@ -555,7 +639,7 @@ class EphemeralNotificationsTests(NotificationsBase):
555 body = 'This is the original content of this notification-bubble.'
639 body = 'This is the original content of this notification-bubble.'
556 icon_path = self._get_icon_path('avatars/funky.png')
640 icon_path = self._get_icon_path('avatars/funky.png')
558− notification = self._create_ephemeral_notification(
642+ notification = shell.create_ephemeral_notification(
561 icon_path
645 icon_path
@@ -579,7 +663,7 @@ class EphemeralNotificationsTests(NotificationsBase):
579 icon_path = self._get_icon_path('avatars/amanda.png')
663 icon_path = self._get_icon_path('avatars/amanda.png')
580 notification.update(summary, body, icon_path)
664 notification.update(summary, body, icon_path)
581 notification.show()
665 notification.show()
582− self._assert_notification(get_notification(), summary, body)
666+ self._assert_notification(get_notification(), summary, body, True, False, 1.0)
584 def test_update_notification_layout_change(self):
668 def test_update_notification_layout_change(self):
585 """Notification must allow updating its contents and layout while
669 """Notification must allow updating its contents and layout while
@@ -595,7 +679,7 @@ class EphemeralNotificationsTests(NotificationsBase):
595 icon_path = self._get_icon_path('avatars/anna_olsson.png')
679 icon_path = self._get_icon_path('avatars/anna_olsson.png')
596 hint_icon = self._get_icon_path('applicationIcons/phone-app.png')
680 hint_icon = self._get_icon_path('applicationIcons/phone-app.png')
598− notification = self._create_ephemeral_notification(
682+ notification = shell.create_ephemeral_notification(
601 icon_path
685 icon_path
@@ -626,7 +710,7 @@ class EphemeralNotificationsTests(NotificationsBase):
626 notification.show()
710 notification.show()
628 self.assertThat(get_notification, Eventually(NotEquals(None)))
712 self.assertThat(get_notification, Eventually(NotEquals(None)))
629− self._assert_notification(get_notification(), summary, body, False)
713+ self._assert_notification(get_notification(), summary, body, False, False, 1.0)
631 def test_append_hint(self):
715 def test_append_hint(self):
632 """Notification has to accumulate body-text using append-hint."""
716 """Notification has to accumulate body-text using append-hint."""
@@ -639,7 +723,7 @@ class EphemeralNotificationsTests(NotificationsBase):
639 body = 'Hey Bro Coly!'
723 body = 'Hey Bro Coly!'
640 icon_path = self._get_icon_path('avatars/amanda.png')
724 icon_path = self._get_icon_path('avatars/amanda.png')
641 body_sum = body
725 body_sum = body
642− notification = self._create_ephemeral_notification(
726+ notification = shell.create_ephemeral_notification(
645 icon_path,
729 icon_path,
@@ -675,7 +759,7 @@ class EphemeralNotificationsTests(NotificationsBase):
675 for new_body in bodies:
759 for new_body in bodies:
676 body = new_body
760 body = new_body
677 body_sum += '\n' + body
761 body_sum += '\n' + body
678− notification = self._create_ephemeral_notification(
762+ notification = shell.create_ephemeral_notification(
681 icon_path,
765 icon_path,
@@ -696,48 +780,3 @@ class EphemeralNotificationsTests(NotificationsBase):
700− def _create_ephemeral_notification(
708− """Create an ephemeral (non-interactive) notification
710− :param summary: Summary text for the notification
711− :param body: Body text to display in the notification
712− :param icon: Path string to the icon to use
713− :param hint_strings: List of tuples containing the 'name' and value
714− for setting the hint strings for the notification
715− :param urgency: Urgency string for the noticiation, either: 'LOW',
716− 'NORMAL', 'CRITICAL'
720− "Creating ephemeral: summary(%s), body(%s), urgency(%r) "
728− n = Notify.Notification.new(summary, body, icon)
732− n.set_hint_string(key, value)
733− logger.info("Adding hint to notification: (%s, %s)", key, value)
734− n.set_urgency(self._get_urgency(urgency))
738− def _get_urgency(self, urgency):
739− """Translates urgency string to enum."""
740− _urgency_enums = {'LOW': Notify.Urgency.LOW,
741− 'NORMAL': Notify.Urgency.NORMAL,
742− 'CRITICAL': Notify.Urgency.CRITICAL}
743− return _urgency_enums.get(urgency.upper())