@@ -21,6 +21,7 @@
2121
2222from __future__ import absolute_import
2323
24+from unity8 import shell
2425from unity8.process_helpers import unlock_unity
2526from unity8.shell.tests import UnityTestCase, _get_device_emulation_scenarios
2627
@@ -64,7 +65,8 @@ class NotificationsBase(UnityTestCase):
6465 if os.path.abspath(__file__).startswith('/usr/'):
6566 return '/usr/share/unity8/graphics/' + icon_name
6667 else:
67− return os.path.dirname(__file__) + "/../../../../../qml/graphics/" + icon_name
68+ return os.path.dirname(__file__) + (
69+ "/../../../../../qml/graphics/" + icon_name)
6870
6971 def _get_notifications_list(self):
7072 return self.main_window.select_single(
@@ -354,7 +356,7 @@ class EphemeralNotificationsTests(NotificationsBase):
354356 )
355357 ]
356358
357− notification = self._create_ephemeral_notification(
359+ notification = shell.create_ephemeral_notification(
358360 summary,
359361 body,
360362 icon_path,
@@ -391,7 +393,7 @@ class EphemeralNotificationsTests(NotificationsBase):
391393 )
392394 ]
393395
394− notification = self._create_ephemeral_notification(
396+ notification = shell.create_ephemeral_notification(
395397 summary,
396398 None,
397399 None,
@@ -433,7 +435,7 @@ class EphemeralNotificationsTests(NotificationsBase):
433435 body_critical = 'Dude, this is so urgent you have no idea :)'
434436 icon_path_critical = self._get_icon_path('avatars/anna_olsson.png')
435437
436− notification_normal = self._create_ephemeral_notification(
438+ notification_normal = shell.create_ephemeral_notification(
437439 summary_normal,
438440 body_normal,
439441 icon_path_normal,
@@ -441,7 +443,7 @@ class EphemeralNotificationsTests(NotificationsBase):
441443 )
442444 notification_normal.show()
443445
444− notification_low = self._create_ephemeral_notification(
446+ notification_low = shell.create_ephemeral_notification(
445447 summary_low,
446448 body_low,
447449 icon_path_low,
@@ -449,7 +451,7 @@ class EphemeralNotificationsTests(NotificationsBase):
449451 )
450452 notification_low.show()
451453
452− notification_critical = self._create_ephemeral_notification(
454+ notification_critical = shell.create_ephemeral_notification(
453455 summary_critical,
454456 body_critical,
455457 icon_path_critical,
@@ -510,7 +512,7 @@ class EphemeralNotificationsTests(NotificationsBase):
510512 summary = 'Summary-Body'
511513 body = 'This is a superfluous notification'
512514
513− notification = self._create_ephemeral_notification(summary, body)
515+ notification = shell.create_ephemeral_notification(summary, body)
514516 notification.show()
515517
516518 notification = notify_list.wait_select_single(
@@ -534,7 +536,7 @@ class EphemeralNotificationsTests(NotificationsBase):
534536
535537 summary = 'Summary-Only'
536538
537− notification = self._create_ephemeral_notification(summary)
539+ notification = shell.create_ephemeral_notification(summary)
538540 notification.show()
539541
540542 notification = notify_list.wait_select_single(
@@ -554,7 +556,7 @@ class EphemeralNotificationsTests(NotificationsBase):
554556 body = 'This is the original content of this notification-bubble.'
555557 icon_path = self._get_icon_path('avatars/funky.png')
556558
557− notification = self._create_ephemeral_notification(
559+ notification = shell.create_ephemeral_notification(
558560 summary,
559561 body,
560562 icon_path
@@ -594,7 +596,7 @@ class EphemeralNotificationsTests(NotificationsBase):
594596 icon_path = self._get_icon_path('avatars/anna_olsson.png')
595597 hint_icon = self._get_icon_path('applicationIcons/phone-app.png')
596598
597− notification = self._create_ephemeral_notification(
599+ notification = shell.create_ephemeral_notification(
598600 summary,
599601 body,
600602 icon_path
@@ -638,7 +640,7 @@ class EphemeralNotificationsTests(NotificationsBase):
638640 body = 'Hey Bro Coly!'
639641 icon_path = self._get_icon_path('avatars/amanda.png')
640642 body_sum = body
641− notification = self._create_ephemeral_notification(
643+ notification = shell.create_ephemeral_notification(
642644 summary,
643645 body,
644646 icon_path,
@@ -674,7 +676,7 @@ class EphemeralNotificationsTests(NotificationsBase):
674676 for new_body in bodies:
675677 body = new_body
676678 body_sum += '\n' + body
677− notification = self._create_ephemeral_notification(
679+ notification = shell.create_ephemeral_notification(
678680 summary,
679681 body,
680682 icon_path,
@@ -695,48 +697,3 @@ class EphemeralNotificationsTests(NotificationsBase):
695697 False,
696698 1.0
697699 )
698−
699− def _create_ephemeral_notification(
700− self,
701− summary="",
702− body="",
703− icon=None,
704− hints=[],
705− urgency="NORMAL"
706− ):
707− """Create an ephemeral (non-interactive) notification
708−
709− :param summary: Summary text for the notification
710− :param body: Body text to display in the notification
711− :param icon: Path string to the icon to use
712− :param hint_strings: List of tuples containing the 'name' and value
713− for setting the hint strings for the notification
714− :param urgency: Urgency string for the noticiation, either: 'LOW',
715− 'NORMAL', 'CRITICAL'
716−
717− """
718− logger.info(
719− "Creating ephemeral: summary(%s), body(%s), urgency(%r) "
720− "and Icon(%s)",
721− summary,
722− body,
723− urgency,
724− icon
725− )
726−
727− n = Notify.Notification.new(summary, body, icon)
728−
729− for hint in hints:
730− key, value = hint
731− n.set_hint_string(key, value)
732− logger.info("Adding hint to notification: (%s, %s)", key, value)
733− n.set_urgency(self._get_urgency(urgency))
734−
735− return n
736−
737− def _get_urgency(self, urgency):
738− """Translates urgency string to enum."""
739− _urgency_enums = {'LOW': Notify.Urgency.LOW,
740− 'NORMAL': Notify.Urgency.NORMAL,
741− 'CRITICAL': Notify.Urgency.CRITICAL}
742− return _urgency_enums.get(urgency.upper())