@@ -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(
@@ -354,7 +356,7 @@ class EphemeralNotificationsTests(NotificationsBase):
357− notification = self._create_ephemeral_notification(
359+ notification = shell.create_ephemeral_notification(
360 icon_path,
362 icon_path,
@@ -391,7 +393,7 @@ class EphemeralNotificationsTests(NotificationsBase):
394− notification = self._create_ephemeral_notification(
396+ notification = shell.create_ephemeral_notification(
@@ -403,7 +405,6 @@ class EphemeralNotificationsTests(NotificationsBase):
404 notification = lambda: notify_list.wait_select_single(
406 notification = lambda: notify_list.wait_select_single(
405 'Notification', objectName='notification1')
407 'Notification', objectName='notification1')
407 self._assert_notification(
408 self._assert_notification(
408 notification(),
409 notification(),
@@ -434,7 +435,7 @@ class EphemeralNotificationsTests(NotificationsBase):
434 body_critical = 'Dude, this is so urgent you have no idea :)'
435 body_critical = 'Dude, this is so urgent you have no idea :)'
435 icon_path_critical = self._get_icon_path('avatars/anna_olsson.png')
436 icon_path_critical = self._get_icon_path('avatars/anna_olsson.png')
437− notification_normal = self._create_ephemeral_notification(
438+ notification_normal = shell.create_ephemeral_notification(
438 summary_normal,
439 summary_normal,
439 body_normal,
440 body_normal,
440 icon_path_normal,
441 icon_path_normal,
@@ -442,7 +443,7 @@ class EphemeralNotificationsTests(NotificationsBase):
443 notification_normal.show()
444 notification_normal.show()
445− notification_low = self._create_ephemeral_notification(
446+ notification_low = shell.create_ephemeral_notification(
446 summary_low,
447 summary_low,
447 body_low,
448 body_low,
448 icon_path_low,
449 icon_path_low,
@@ -450,7 +451,7 @@ class EphemeralNotificationsTests(NotificationsBase):
451 notification_low.show()
452 notification_low.show()
453− notification_critical = self._create_ephemeral_notification(
454+ notification_critical = shell.create_ephemeral_notification(
454 summary_critical,
455 summary_critical,
455 body_critical,
456 body_critical,
456 icon_path_critical,
457 icon_path_critical,
@@ -511,7 +512,7 @@ class EphemeralNotificationsTests(NotificationsBase):
511 summary = 'Summary-Body'
512 summary = 'Summary-Body'
512 body = 'This is a superfluous notification'
513 body = 'This is a superfluous notification'
514− notification = self._create_ephemeral_notification(summary, body)
515+ notification = shell.create_ephemeral_notification(summary, body)
515 notification.show()
516 notification.show()
517 notification = notify_list.wait_select_single(
518 notification = notify_list.wait_select_single(
@@ -535,7 +536,7 @@ class EphemeralNotificationsTests(NotificationsBase):
536 summary = 'Summary-Only'
537 summary = 'Summary-Only'
538− notification = self._create_ephemeral_notification(summary)
539+ notification = shell.create_ephemeral_notification(summary)
539 notification.show()
540 notification.show()
541 notification = notify_list.wait_select_single(
542 notification = notify_list.wait_select_single(
@@ -555,7 +556,7 @@ class EphemeralNotificationsTests(NotificationsBase):
555 body = 'This is the original content of this notification-bubble.'
556 body = 'This is the original content of this notification-bubble.'
556 icon_path = self._get_icon_path('avatars/funky.png')
557 icon_path = self._get_icon_path('avatars/funky.png')
558− notification = self._create_ephemeral_notification(
559+ notification = shell.create_ephemeral_notification(
561 icon_path
562 icon_path
@@ -579,7 +580,7 @@ class EphemeralNotificationsTests(NotificationsBase):
579 icon_path = self._get_icon_path('avatars/amanda.png')
580 icon_path = self._get_icon_path('avatars/amanda.png')
580 notification.update(summary, body, icon_path)
581 notification.update(summary, body, icon_path)
581 notification.show()
582 notification.show()
582− self._assert_notification(get_notification(), summary, body)
583+ self._assert_notification(get_notification(), summary, body, True, False, 1.0)
584 def test_update_notification_layout_change(self):
585 def test_update_notification_layout_change(self):
585 """Notification must allow updating its contents and layout while
586 """Notification must allow updating its contents and layout while
@@ -595,7 +596,7 @@ class EphemeralNotificationsTests(NotificationsBase):
595 icon_path = self._get_icon_path('avatars/anna_olsson.png')
596 icon_path = self._get_icon_path('avatars/anna_olsson.png')
596 hint_icon = self._get_icon_path('applicationIcons/phone-app.png')
597 hint_icon = self._get_icon_path('applicationIcons/phone-app.png')
598− notification = self._create_ephemeral_notification(
599+ notification = shell.create_ephemeral_notification(
601 icon_path
602 icon_path
@@ -626,7 +627,7 @@ class EphemeralNotificationsTests(NotificationsBase):
626 notification.show()
627 notification.show()
628 self.assertThat(get_notification, Eventually(NotEquals(None)))
629 self.assertThat(get_notification, Eventually(NotEquals(None)))
629− self._assert_notification(get_notification(), summary, body, False)
630+ self._assert_notification(get_notification(), summary, body, False, False, 1.0)
631 def test_append_hint(self):
632 def test_append_hint(self):
632 """Notification has to accumulate body-text using append-hint."""
633 """Notification has to accumulate body-text using append-hint."""
@@ -639,7 +640,7 @@ class EphemeralNotificationsTests(NotificationsBase):
639 body = 'Hey Bro Coly!'
640 body = 'Hey Bro Coly!'
640 icon_path = self._get_icon_path('avatars/amanda.png')
641 icon_path = self._get_icon_path('avatars/amanda.png')
641 body_sum = body
642 body_sum = body
642− notification = self._create_ephemeral_notification(
643+ notification = shell.create_ephemeral_notification(
645 icon_path,
646 icon_path,
@@ -675,7 +676,7 @@ class EphemeralNotificationsTests(NotificationsBase):
675 for new_body in bodies:
676 for new_body in bodies:
676 body = new_body
677 body = new_body
677 body_sum += '\n' + body
678 body_sum += '\n' + body
678− notification = self._create_ephemeral_notification(
679+ notification = shell.create_ephemeral_notification(
681 icon_path,
682 icon_path,
@@ -696,48 +697,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())