@@ -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,
@@ -434,7 +436,7 @@ class EphemeralNotificationsTests(NotificationsBase):
434436 body_critical = 'Dude, this is so urgent you have no idea :)'
435437 icon_path_critical = self._get_icon_path('avatars/anna_olsson.png')
436438
437− notification_normal = self._create_ephemeral_notification(
439+ notification_normal = shell.create_ephemeral_notification(
438440 summary_normal,
439441 body_normal,
440442 icon_path_normal,
@@ -442,7 +444,7 @@ class EphemeralNotificationsTests(NotificationsBase):
442444 )
443445 notification_normal.show()
444446
445− notification_low = self._create_ephemeral_notification(
447+ notification_low = shell.create_ephemeral_notification(
446448 summary_low,
447449 body_low,
448450 icon_path_low,
@@ -450,7 +452,7 @@ class EphemeralNotificationsTests(NotificationsBase):
450452 )
451453 notification_low.show()
452454
453− notification_critical = self._create_ephemeral_notification(
455+ notification_critical = shell.create_ephemeral_notification(
454456 summary_critical,
455457 body_critical,
456458 icon_path_critical,
@@ -511,7 +513,7 @@ class EphemeralNotificationsTests(NotificationsBase):
511513 summary = 'Summary-Body'
512514 body = 'This is a superfluous notification'
513515
514− notification = self._create_ephemeral_notification(summary, body)
516+ notification = shell.create_ephemeral_notification(summary, body)
515517 notification.show()
516518
517519 notification = notify_list.wait_select_single(
@@ -535,7 +537,7 @@ class EphemeralNotificationsTests(NotificationsBase):
535537
536538 summary = 'Summary-Only'
537539
538− notification = self._create_ephemeral_notification(summary)
540+ notification = shell.create_ephemeral_notification(summary)
539541 notification.show()
540542
541543 notification = notify_list.wait_select_single(
@@ -555,7 +557,7 @@ class EphemeralNotificationsTests(NotificationsBase):
555557 body = 'This is the original content of this notification-bubble.'
556558 icon_path = self._get_icon_path('avatars/funky.png')
557559
558− notification = self._create_ephemeral_notification(
560+ notification = shell.create_ephemeral_notification(
559561 summary,
560562 body,
561563 icon_path
@@ -595,7 +597,7 @@ class EphemeralNotificationsTests(NotificationsBase):
595597 icon_path = self._get_icon_path('avatars/anna_olsson.png')
596598 hint_icon = self._get_icon_path('applicationIcons/phone-app.png')
597599
598− notification = self._create_ephemeral_notification(
600+ notification = shell.create_ephemeral_notification(
599601 summary,
600602 body,
601603 icon_path
@@ -639,7 +641,7 @@ class EphemeralNotificationsTests(NotificationsBase):
639641 body = 'Hey Bro Coly!'
640642 icon_path = self._get_icon_path('avatars/amanda.png')
641643 body_sum = body
642− notification = self._create_ephemeral_notification(
644+ notification = shell.create_ephemeral_notification(
643645 summary,
644646 body,
645647 icon_path,
@@ -675,7 +677,7 @@ class EphemeralNotificationsTests(NotificationsBase):
675677 for new_body in bodies:
676678 body = new_body
677679 body_sum += '\n' + body
678− notification = self._create_ephemeral_notification(
680+ notification = shell.create_ephemeral_notification(
679681 summary,
680682 body,
681683 icon_path,
@@ -696,48 +698,3 @@ class EphemeralNotificationsTests(NotificationsBase):
696698 False,
697699 1.0
698700 )
699−
700− def _create_ephemeral_notification(
701− self,
702− summary="",
703− body="",
704− icon=None,
705− hints=[],
706− urgency="NORMAL"
707− ):
708− """Create an ephemeral (non-interactive) notification
709−
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'
717−
718− """
719− logger.info(
720− "Creating ephemeral: summary(%s), body(%s), urgency(%r) "
721− "and Icon(%s)",
722− summary,
723− body,
724− urgency,
725− icon
726− )
727−
728− n = Notify.Notification.new(summary, body, icon)
729−
730− for hint in hints:
731− key, value = hint
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))
735−
736− return n
737−
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())