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 setUp(self): super().setUp() if is_unity7_running(): self.useFixture(toolkit_fixtures.HideUnity7Launcher()) if model() != 'Desktop': # On the phone, we need unity to be running and unlocked. self.addCleanup(process_helpers.stop_job, 'unity8') process_helpers.restart_unity_with_testability() process_helpers.unlock_unity() self.ensure_dash_not_running() if self.qml_mock_enabled: self.environment['QML2_IMPORT_PATH'] = ( get_qml_import_path_with_mock()) if self.should_simulate_device(): # This sets the grid units, so it should be called before launching # the app. self.simulate_device() binary_path = get_binary_path('unity8-dash') dash_proxy = self.launch_dash(binary_path, self.environment) self.dash_app = dash_helpers.DashApp(dash_proxy) self.dash = self.dash_app.dash self.wait_for_dash()
def setUp(self): super().setUp() if is_unity7_running(): self.useFixture(toolkit_fixtures.HideUnity7Launcher()) if model() != 'Desktop': # On the phone, we need unity to be running and unlocked. self.addCleanup(process_helpers.stop_job, 'unity8') process_helpers.restart_unity_with_testability() process_helpers.unlock_unity() self.ensure_dash_not_running() if self.qml_mock_enabled: self.environment['QML2_IMPORT_PATH'] = ( get_qml_import_path_with_mock() ) if self.should_simulate_device(): # This sets the grid units, so it should be called before launching # the app. self.simulate_device() binary_path = get_binary_path('unity8-dash') dash_proxy = self.launch_dash(binary_path, self.environment) self.dash_app = dash_helpers.DashApp(dash_proxy) self.dash = self.dash_app.dash self.wait_for_dash()
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_interactive(self): """Interactive notification must react upon click on itself.""" self.launch_unity() unlock_unity() notify_list = self._get_notifications_list() summary = "Interactive notification" body = "This notification can be clicked on to trigger an action." icon_path = self._get_icon_path('avatars/anna_olsson.png') actions = [("action_id", "dummy")] hints = [ ("x-canonical-switch-to-application", "true"), ("x-canonical-secondary-icon", "dialer") ] self._create_interactive_notification( summary, body, icon_path, "NORMAL", actions, hints, ) get_notification = lambda: notify_list.wait_select_single( 'Notification', objectName='notification0') notification = get_notification() notification.pointing_device.click_object( notification.select_single(objectName="interactiveArea") ) self.assert_notification_action_id_was_called('action_id')
def test_rotation_with_webbrowser_app(self): """Do an orientation-change and verify that an app and the shell adapted correctly""" unity_with_sensors = fixture_setup.LaunchUnityWithFakeSensors() self.useFixture(unity_with_sensors) process_helpers.unlock_unity() fake_sensors = unity_with_sensors.fake_sensors o_proxy = unity_with_sensors.main_win.select_single('OrientedShell') self.shell_proxy = unity_with_sensors.main_win.select_single('Shell') # launch an application self.launch_upstart_application('webbrowser-app') unity_with_sensors.main_win.show_dash_from_launcher() unity_with_sensors.main_win.launch_application('webbrowser-app') # skip test early, if device doesn't support a certain orientation if not (self.shell_proxy.orientation & o_proxy.supportedOrientations): self.skipTest('unsupported orientation ' + self.action) self.assertThat( unity_with_sensors.main_win.get_current_focused_app_id(), Eventually(Equals('webbrowser-app'))) # get default orientation and angle self.orientation = self.shell_proxy.orientation self.angle = self.shell_proxy.orientationAngle # check if fake sensors affect orientation and angle fake_sensors.set_orientation(self.action) self.assertThat(o_proxy.physicalOrientation, Eventually(Equals(self.orientation), timeout=15)) self._assert_change_of_orientation_and_angle()
def test_fake_sensor(self): unity_with_sensors = fixture_setup.LaunchUnityWithFakeSensors() self.useFixture(unity_with_sensors) process_helpers.unlock_unity() fake_sensors = unity_with_sensors.fake_sensors o_proxy = unity_with_sensors.main_win.select_single('OrientedShell') fake_sensors.set_orientation(self.action) self.assertThat(o_proxy.physicalOrientation, Eventually(Equals(self.orientation), timeout=15))
def test_greeter_hides_on_app_focus(self): """Greeter should hide when an app is re-focused""" application_name = self.launch_fake_app() self.assert_current_focused_application(application_name) self.main_window.show_dash_swiping() self.assert_current_focused_application('unity8-dash') process_helpers.lock_unity() self.launch_upstart_application(application_name, [], _launcher.AlreadyLaunchedUpstartLauncher) greeter = self.main_window.get_greeter() greeter.wait_swiped_away() process_helpers.unlock_unity() self.assert_current_focused_application(application_name)
def test_modal_sd_without_greeter(self): """Snap-decision should block input to shell without greeter/lockscreen. """ self.launch_unity() unlock_unity() summary = "Incoming file" body = "Frank would like to send you the file: essay.pdf" icon_path = "sync-idle" hints = [ ("x-canonical-snap-decisions", "true"), ("x-canonical-non-shaped-icon", "true"), ("x-canonical-private-affirmative-tint", "true"), ("x-canonical-private-rejection-tint", "true"), ] actions = [ ('action_accept', 'Accept'), ('action_decline_1', 'Decline'), ] self._create_interactive_notification( summary, body, icon_path, "NORMAL", actions, hints ) # verify that we cannot reveal the launcher (no longer interact with # the shell) time.sleep(1) self.main_window.show_dash_swiping() self.assertThat( self.main_window.is_launcher_open, Eventually(Equals(False))) # verify and interact with the triggered snap-decision notification notify_list = self._get_notifications_list() get_notification = lambda: notify_list.wait_select_single( 'Notification', objectName='notification0') notification = get_notification() self._assert_notification( notification, summary, body, True, False, 1.0) notification.pointing_device.click_object( notification.select_single(objectName="notify_button0")) self.assert_notification_action_id_was_called("action_accept")
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_sd_one_over_two_layout(self): """Snap-decision with three actions should use one-over two button layout. """ self.launch_unity() unlock_unity() summary = "Theatre at Ferria Stadium" body = "at Ferria Stadium in Bilbao, Spain\n07578545317" hints = [ ("x-canonical-snap-decisions", "true"), ("x-canonical-non-shaped-icon", "true"), ("x-canonical-private-affirmative-tint", "true") ] actions = [ ('action_accept', 'Ok'), ('action_decline_1', 'Snooze'), ('action_decline_2', 'View'), ] self._create_interactive_notification( summary, body, None, "NORMAL", actions, hints ) # verify and interact with the triggered snap-decision notification notify_list = self._get_notifications_list() get_notification = lambda: notify_list.wait_select_single( 'Notification', objectName='notification0') notification = get_notification() self._assert_notification( notification, summary, body, False, False, 1.0) notification.pointing_device.click_object( notification.select_single(objectName="notify_oot_button0")) self.assert_notification_action_id_was_called("action_accept")
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 setUp(self): super().setUp() self._qml_mock_enabled = False self._data_dirs_mock_enabled = False self.launch_unity() process_helpers.unlock_unity()
def unlock_thread_worker(greeter): greeter.wait_swiped_away() process_helpers.unlock_unity() greeter.created.wait_for(False)
def setUp(self): super().setUp() self.launch_unity() process_helpers.unlock_unity()
def setUp(self): super().setUp() self.unity_proxy = self.launch_unity() process_helpers.unlock_unity()
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 )