def test_icon_summary(self): """Notification must display the expected summary and secondary icon.""" self.launch_unity() unlock_unity() notify_list = self._get_notifications_list() summary = "Upload of image completed" icon_path = self._get_icon_path('applicationIcons/facebook.png') hints = [] notification = shell.create_ephemeral_notification( summary, None, icon_path, hints, "NORMAL", ) notification.show() notification = lambda: notify_list.wait_select_single( 'Notification', objectName='notification0') self._assert_notification( notification(), summary, None, True, False, 1.0 )
def test_icon_summary_body(self): """Notification must display the expected summary and body text.""" self.launch_unity() unlock_unity() notify_list = self._get_notifications_list() summary = "Icon-Summary-Body" body = "Hey pal, what's up with the party next weekend? Will you " \ "join me and Anna?" icon_path = self._get_icon_path('avatars/anna_olsson.png') hints = [ ("x-canonical-secondary-icon", "message") ] notification = shell.create_ephemeral_notification( summary, body, icon_path, hints, "NORMAL", ) notification.show() notification = lambda: notify_list.wait_select_single( 'Notification', objectName='notification0') self._assert_notification( notification(), summary, body, True, True, 1.0, )
def test_summary_only(self): """Notification must display only the expected summary-text.""" self.launch_unity() unlock_unity() notify_list = self._get_notifications_list() summary = 'Summary-Only' notification = shell.create_ephemeral_notification(summary) notification.show() notification = notify_list.wait_select_single( 'Notification', objectName='notification0') self._assert_notification(notification, summary, '', False, False, 1.0)
def test_update_notification_layout_change(self): """Notification must allow updating its contents and layout while being displayed.""" self.launch_unity() unlock_unity() notify_list = self._get_notifications_list() summary = 'Initial layout' body = 'This bubble uses the icon-title-body layout with a ' \ 'secondary icon.' icon_path = self._get_icon_path('avatars/anna_olsson.png') hint_icon = 'dialer' notification = shell.create_ephemeral_notification( summary, body, icon_path ) notification.set_hint_string( 'x-canonical-secondary-icon', hint_icon ) notification.show() get_notification = lambda: notify_list.wait_select_single( 'Notification', objectName='notification0') self._assert_notification( get_notification(), summary, body, True, True, 1.0 ) notification.clear_hints() summary = 'Updated layout' body = 'After the update we now have a bubble using the title-body ' \ 'layout.' notification.update(summary, body, None) notification.show() self.assertThat(get_notification, Eventually(NotEquals(None))) self._assert_notification( get_notification(), summary, body, False, False, 1.0)
def test_notification_helper(self): """ use the create notification script to get a notification dialog. Check that the arguments passed to the script match the fields. """ self.launch_unity() unlock_unity() summary = 'Helper summary' body = 'Helper body' notification = shell.create_ephemeral_notification(summary, body) notification.show() notification_data = self.main_window.wait_for_notification() self.assertThat(notification_data['summary'], Eventually(Equals(summary))) self.assertThat(notification_data['body'], Eventually(Equals(body)))
def test_update_notification_same_layout(self): """Notification must allow updating its contents while being displayed.""" self.launch_unity() unlock_unity() notify_list = self._get_notifications_list() summary = 'Initial notification' body = 'This is the original content of this notification-bubble.' icon_path = self._get_icon_path('avatars/funky.png') notification = shell.create_ephemeral_notification( summary, body, icon_path ) notification.show() get_notification = lambda: notify_list.wait_select_single( 'Notification', summary=summary) self._assert_notification( get_notification(), summary, body, True, False, 1.0 ) summary = 'Updated notification' body = 'Here the same bubble with new title- and body-text, even ' \ 'the icon can be changed on the update.' icon_path = self._get_icon_path('avatars/amanda.png') notification.update(summary, body, icon_path) notification.show() self._assert_notification( get_notification(), summary, body, True, False, 1.0)
def test_summary_and_body(self): """Notification must display the expected summary- and body-text.""" self.launch_unity() unlock_unity() notify_list = self._get_notifications_list() summary = 'Summary-Body' body = 'This is a superfluous notification' notification = shell.create_ephemeral_notification(summary, body) notification.show() notification = notify_list.wait_select_single( 'Notification', objectName='notification0') self._assert_notification( notification, summary, body, False, False, 1.0 )
def test_urgency_order(self): """Notifications must be displayed in order according to their urgency.""" self.launch_unity() unlock_unity() notify_list = self._get_notifications_list() summary_low = 'Low Urgency' body_low = "No, I'd rather see paint dry, pal *yawn*" icon_path_low = self._get_icon_path('avatars/amanda.png') summary_normal = 'Normal Urgency' body_normal = "Hey pal, what's up with the party next weekend? Will " \ "you join me and Anna?" icon_path_normal = self._get_icon_path('avatars/funky.png') summary_critical = 'Critical Urgency' body_critical = 'Dude, this is so urgent you have no idea :)' icon_path_critical = self._get_icon_path('avatars/anna_olsson.png') notification_normal = shell.create_ephemeral_notification( summary_normal, body_normal, icon_path_normal, urgency="NORMAL" ) notification_normal.show() notification_low = shell.create_ephemeral_notification( summary_low, body_low, icon_path_low, urgency="LOW" ) notification_low.show() notification_critical = shell.create_ephemeral_notification( summary_critical, body_critical, icon_path_critical, urgency="CRITICAL" ) notification_critical.show() get_notification = lambda: notify_list.wait_select_single( 'Notification', summary=summary_critical ) notification = get_notification() self._assert_notification( notification, summary_critical, body_critical, True, False, 1.0 ) get_normal_notification = lambda: notify_list.wait_select_single( 'Notification', summary=summary_normal ) notification = get_normal_notification() self._assert_notification( notification, summary_normal, body_normal, True, False, 1.0 ) get_low_notification = lambda: notify_list.wait_select_single( 'Notification', summary=summary_low ) notification = get_low_notification() self._assert_notification( notification, summary_low, body_low, True, False, 1.0 )