Unity 8
 All Classes Functions Properties
unity8.shell.tests.test_notifications.InteractiveNotificationBase Class Reference
Inheritance diagram for unity8.shell.tests.test_notifications.InteractiveNotificationBase:
Collaboration diagram for unity8.shell.tests.test_notifications.InteractiveNotificationBase:

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.

295  def assert_notification_action_id_was_called(self, action_id, timeout=10):
296  """Assert that the interactive notification callback of id *action_id*
297  was called.
298 
299  :raises AssertionError: If no interactive notification has actually
300  been created.
301  :raises AssertionError: When *action_id* does not match the actual
302  returned.
303  :raises AssertionError: If no callback was called at all.
304  """
305 
306  if self._notify_proc is None:
307  raise AssertionError("No interactive notification was created.")
308 
309  for i in range(timeout):
310  self._notify_proc.poll()
311  if self._notify_proc.returncode is not None:
312  output = self._notify_proc.communicate()
313  actual_action_id = output[0].strip("\n")
314  if actual_action_id != action_id:
315  raise AssertionError(
316  "action id '%s' does not match actual returned '%s'"
317  % (action_id, actual_action_id)
318  )
319  else:
320  return
321  time.sleep(1)
322 
323  os.killpg(self._notify_proc.pid, signal.SIGTERM)
324  self._notify_proc = None
325  raise AssertionError(
326  "No callback was called, killing interactivenotification script"
327  )
328 
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.

124  def test_interactive(self):
125  """Interactive notification must react upon click on itself."""
126  unity_proxy = self.launch_unity()
127  unlock_unity(unity_proxy)
128 
129  notify_list = self._get_notifications_list()
130 
131  summary = "Interactive notification"
132  body = "This notification can be clicked on to trigger an action."
133  icon_path = self._get_icon_path('avatars/anna_olsson.png')
134  actions = [("action_id", "dummy")]
135  hints = [
136  ("x-canonical-switch-to-application", "true"),
137  (
138  "x-canonical-secondary-icon",
139  self._get_icon_path('applicationIcons/phone-app.png')
140  )
141  ]
142 
144  summary,
145  body,
146  icon_path,
147  "NORMAL",
148  actions,
149  hints,
150  )
151 
152  get_notification = lambda: notify_list.wait_select_single(
153  'Notification', objectName='notification1')
154  notification = get_notification()
155 
156  self.touch.tap_object(
157  notification.select_single(objectName="interactiveArea")
158  )
159 
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.

162  def test_sd_incoming_call(self):
163  """Rejecting a call should make notification expand and
164  offer more options."""
165  unity_proxy = self.launch_unity()
166  unlock_unity(unity_proxy)
167 
168  summary = "Incoming call"
169  body = "Frank Zappa\n+44 (0)7736 027340"
170  icon_path = self._get_icon_path('avatars/anna_olsson.png')
171  hints = [
172  (
173  "x-canonical-secondary-icon",
174  self._get_icon_path('applicationIcons/phone-app.png')
175  ),
176  ("x-canonical-snap-decisions", "true"),
177  ]
178 
179  actions = [
180  ('action_accept', 'Accept'),
181  ('action_decline_1', 'Decline'),
182  ('action_decline_2', '"Can\'t talk now, what\'s up?"'),
183  ('action_decline_3', '"I call you back."'),
184  ('action_decline_4', 'Send custom message...'),
185  ]
186 
188  summary,
189  body,
190  icon_path,
191  "NORMAL",
192  actions,
193  hints
194  )
195 
196  notify_list = self._get_notifications_list()
197  get_notification = lambda: notify_list.wait_select_single(
198  'Notification', objectName='notification1')
199  notification = get_notification()
200  self._assert_notification(notification, summary, body, True, True, 1.0)
201  initial_height = notification.height
202  self.touch.tap_object(notification.select_single(objectName="button1"))
203  self.assertThat(
204  notification.height,
205  Eventually(Equals(initial_height +
206  3 * notification.select_single(
207  objectName="buttonColumn").spacing +
208  3 * notification.select_single(
209  objectName="button4").height)))
210  self.touch.tap_object(notification.select_single(objectName="button4"))
211  self.assert_notification_action_id_was_called("action_decline_4")

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