All Classes Functions Properties
unity8.shell.tests.test_notifications.InteractiveNotificationBase Class Reference
Inheritance diagram for unity8.shell.tests.test_notifications.InteractiveNotificationBase:
[legend]
Collaboration diagram for unity8.shell.tests.test_notifications.InteractiveNotificationBase:
[legend]

## Public Member Functions

def | setUp
def | test_interactive
def | test_sd_incoming_call
def | assert_notification_action_id_was_called
Public Member Functions inherited from unity8.shell.tests.UnityTestCase
def | setUpClass
def | setUp
def | launch_unity
def | patch_lightdm_mock
def | assertUnityReady
def | get_dash
def | main_window

## Additional Inherited Members

Public Attributes inherited from unity8.shell.tests.UnityTestCase
| touch
| unity_geometry_args
| grid_size
Static Public Attributes inherited from unity8.shell.tests.test_notifications.NotificationsBase
tuple | scenarios = _get_device_emulation_scenarios('Nexus4')

## Detailed Description

    Collection of test for Interactive tests including snap decisions.

Definition at line 115 of file test_notifications.py.

## Member Function Documentation

def unity8.shell.tests.test_notifications.InteractiveNotificationBase.assert_notification_action_id_was_called | ( |  | self,
|  |  | action_id,
|  |  | timeout = `10`
| ) |  |

    Assert that the interactive notification callback of id *action_id*
    was called.

    :raises AssertionError: If no interactive notification has actually
        been created.
    :raises AssertionError: When *action_id* does not match the actual
        returned.
    :raises AssertionError: If no callback was called at all.

Definition at line 294 of file test_notifications.py.

def assert_notification_action_id_was_called(self, action_id, timeout=10):
"""Assert that the interactive notification callback of id *action_id*
was called.
:raises AssertionError: If no interactive notification has actually
been created.
:raises AssertionError: When *action_id* does not match the actual
returned.
:raises AssertionError: If no callback was called at all.
"""
if self._notify_proc is None:
raise AssertionError("No interactive notification was created.")
for i in range(timeout):
self._notify_proc.poll()
if self._notify_proc.returncode is not None:
output = self._notify_proc.communicate()
actual_action_id = output[0].strip("\n")
if actual_action_id != action_id:
raise AssertionError(
"action id '%s' does not match actual returned '%s'"
% (action_id, actual_action_id)
)
else:
return
time.sleep(1)
os.killpg(self._notify_proc.pid, signal.SIGTERM)
self._notify_proc = None
raise AssertionError(
"No callback was called, killing interactivenotification script"
)
unity8.shell.tests.test_notifications.InteractiveNotificationBase.assert_notification_action_id_was_called
def assert_notification_action_id_was_called
Definition: test_notifications.py:294
unity8.shell.tests.test_notifications.InteractiveNotificationBase._notify_proc
_notify_proc
Definition: test_notifications.py:121

def unity8.shell.tests.test_notifications.InteractiveNotificationBase.test_interactive | ( |  | self | ) |

    Interactive notification must react upon click on itself.

Definition at line 123 of file test_notifications.py.

def test_interactive(self):
"""Interactive notification must react upon click on itself."""
unity_proxy = self.launch_unity()
unlock_unity(unity_proxy)
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",
self._get_icon_path('applicationIcons/phone-app.png')
)
]
self._create_interactive_notification(
summary,
body,
icon_path,
"NORMAL",
actions,
hints,
)
get_notification = lambda: notify_list.wait_select_single(
'Notification', objectName='notification1')
notification = get_notification()
self.touch.tap_object(
notification.select_single(objectName="interactiveArea")
)
self.assert_notification_action_id_was_called('action_id')
unity8.shell.tests.test_notifications.NotificationsBase._get_notifications_list
def _get_notifications_list
Definition: test_notifications.py:69
unity8.shell.tests.test_notifications.InteractiveNotificationBase.test_interactive
def test_interactive
Definition: test_notifications.py:123
unity8.shell.tests.test_notifications.InteractiveNotificationBase.assert_notification_action_id_was_called
def assert_notification_action_id_was_called
Definition: test_notifications.py:294
unity8.shell.tests.test_notifications.InteractiveNotificationBase._create_interactive_notification
def _create_interactive_notification
Definition: test_notifications.py:220
unity8.shell.tests.test_notifications.NotificationsBase._get_icon_path
def _get_icon_path
Definition: test_notifications.py:51
unity8.shell.tests.UnityTestCase.launch_unity
def launch_unity
Definition: __init__.py:252

def unity8.shell.tests.test_notifications.InteractiveNotificationBase.test_sd_incoming_call | ( |  | self | ) |

    Rejecting a call should make notification expand and
        offer more options.

Definition at line 161 of file test_notifications.py.

def test_sd_incoming_call(self):
"""Rejecting a call should make notification expand and
offer more options."""
unity_proxy = self.launch_unity()
unlock_unity(unity_proxy)
summary = "Incoming call"
body = "Frank Zappa\n+44 (0)7736 027340"
icon_path = self._get_icon_path('avatars/anna_olsson.png')
hints = [
(
"x-canonical-secondary-icon",
self._get_icon_path('applicationIcons/phone-app.png')
),
("x-canonical-snap-decisions", "true"),
]
actions = [
('action_accept', 'Accept'),
('action_decline_1', 'Decline'),
('action_decline_2', '"Can\'t talk now, what\'s up?"'),
('action_decline_3', '"I call you back."'),
('action_decline_4', 'Send custom message...'),
]
self._create_interactive_notification(
summary,
body,
icon_path,
"NORMAL",
actions,
hints
)
notify_list = self._get_notifications_list()
get_notification = lambda: notify_list.wait_select_single(
'Notification', objectName='notification1')
notification = get_notification()
self._assert_notification(notification, summary, body, True, True, 1.0)
initial_height = notification.height
self.touch.tap_object(notification.select_single(objectName="button1"))
self.assertThat(
notification.height,
Eventually(Equals(initial_height +
3 * notification.select_single(
objectName="buttonColumn").spacing +
3 * notification.select_single(
objectName="button4").height)))
self.touch.tap_object(notification.select_single(objectName="button4"))
self.assert_notification_action_id_was_called("action_decline_4")
unity8.shell.tests.test_notifications.NotificationsBase._get_notifications_list
def _get_notifications_list
Definition: test_notifications.py:69
unity8.shell.tests.test_notifications.NotificationsBase._assert_notification
def _assert_notification
Definition: test_notifications.py:83
unity8.shell.tests.test_notifications.InteractiveNotificationBase.assert_notification_action_id_was_called
def assert_notification_action_id_was_called
Definition: test_notifications.py:294
unity8.shell.tests.test_notifications.InteractiveNotificationBase._create_interactive_notification
def _create_interactive_notification
Definition: test_notifications.py:220
unity8.shell.tests.test_notifications.InteractiveNotificationBase.test_sd_incoming_call
def test_sd_incoming_call
Definition: test_notifications.py:161
unity8.shell.tests.test_notifications.NotificationsBase._get_icon_path
def _get_icon_path
Definition: test_notifications.py:51
unity8.shell.tests.UnityTestCase.launch_unity
def launch_unity
Definition: __init__.py:252

The documentation for this class was generated from the following file:

- tests/autopilot/unity8/shell/tests/test_notifications.py