Unity 8
 All Classes Functions
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 test_sd_one_over_two_layout
 
def test_modal_sd_without_greeter
 
def test_modal_sd_with_greeter
 
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 wait_for_unity
 
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 117 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 424 of file test_notifications.py.

425  def assert_notification_action_id_was_called(self, action_id, timeout=10):
426  """Assert that the interactive notification callback of id *action_id*
427  was called.
428 
429  :raises AssertionError: If no interactive notification has actually
430  been created.
431  :raises AssertionError: When *action_id* does not match the actual
432  returned.
433  :raises AssertionError: If no callback was called at all.
434  """
435 
436  if self._notify_proc is None:
437  raise AssertionError("No interactive notification was created.")
438 
439  for i in range(timeout):
440  self._notify_proc.poll()
441  if self._notify_proc.returncode is not None:
442  output = self._notify_proc.communicate()
443  actual_action_id = output[0].strip("\n")
444  if actual_action_id != action_id:
445  raise AssertionError(
446  "action id '%s' does not match actual returned '%s'"
447  % (action_id, actual_action_id)
448  )
449  else:
450  return
451  time.sleep(1)
452 
453  os.killpg(self._notify_proc.pid, signal.SIGTERM)
454  self._notify_proc = None
455  raise AssertionError(
456  "No callback was called, killing interactivenotification script"
457  )
458 
def unity8.shell.tests.test_notifications.InteractiveNotificationBase.test_interactive (   self)
Interactive notification must react upon click on itself.

Definition at line 125 of file test_notifications.py.

126  def test_interactive(self):
127  """Interactive notification must react upon click on itself."""
128  unity_proxy = self.launch_unity()
129  unlock_unity(unity_proxy)
130 
131  notify_list = self._get_notifications_list()
132 
133  summary = "Interactive notification"
134  body = "This notification can be clicked on to trigger an action."
135  icon_path = self._get_icon_path('avatars/anna_olsson.png')
136  actions = [("action_id", "dummy")]
137  hints = [
138  ("x-canonical-switch-to-application", "true"),
139  ("x-canonical-secondary-icon","dialer")
140  ]
141 
143  summary,
144  body,
145  icon_path,
146  "NORMAL",
147  actions,
148  hints,
149  )
150 
151  get_notification = lambda: notify_list.wait_select_single(
152  'Notification', objectName='notification1')
153  notification = get_notification()
154 
155  notification.pointing_device.click_object(
156  notification.select_single(objectName="interactiveArea")
157  )
158 
def unity8.shell.tests.test_notifications.InteractiveNotificationBase.test_modal_sd_with_greeter (   self)
A snap-decision should not block input to the greeter beneath it.

Definition at line 297 of file test_notifications.py.

298  def test_modal_sd_with_greeter(self):
299  """A snap-decision should not block input to the greeter beneath it."""
300  self.launch_unity()
301 
302  summary = "Incoming file"
303  body = "Frank would like to send you the file: essay.pdf"
304  icon_path = "sync-idle"
305  hints = [
306  ("x-canonical-snap-decisions", "true"),
307  ("x-canonical-non-shaped-icon", "true"),
308  ("x-canonical-private-affirmative-tint", "true"),
309  ("x-canonical-private-rejection-tint", "true"),
310  ]
311 
312  actions = [
313  ('action_accept', 'Accept'),
314  ('action_decline_1', 'Decline'),
315  ]
316 
318  summary,
319  body,
320  icon_path,
321  "NORMAL",
322  actions,
323  hints
324  )
325 
326  # verify that we can swipe away the greeter (interact with the "shell")
327  time.sleep(1)
328  self.main_window.show_dash_swiping()
329  greeter = self.main_window.get_greeter()
330  self.assertThat(greeter.shown, Eventually(Equals(False)))
331 
332  # verify and interact with the triggered snap-decision notification
333  notify_list = self._get_notifications_list()
334  get_notification = lambda: notify_list.wait_select_single(
335  'Notification', objectName='notification1')
336  notification = get_notification()
338  notification, summary, body, True, False, 1.0)
339  notification.pointing_device.click_object(
340  notification.select_single(objectName="notify_button0"))
341  self.assert_notification_action_id_was_called("action_accept")
def unity8.shell.tests.test_notifications.InteractiveNotificationBase.test_modal_sd_without_greeter (   self)
Snap-decision should block input to shell without greeter.

Definition at line 250 of file test_notifications.py.

252  """Snap-decision should block input to shell without greeter."""
253  unity_proxy = self.launch_unity()
254  unlock_unity(unity_proxy)
255 
256  summary = "Incoming file"
257  body = "Frank would like to send you the file: essay.pdf"
258  icon_path = "sync-idle"
259  hints = [
260  ("x-canonical-snap-decisions", "true"),
261  ("x-canonical-non-shaped-icon", "true"),
262  ("x-canonical-private-affirmative-tint", "true"),
263  ("x-canonical-private-rejection-tint", "true"),
264  ]
265 
266  actions = [
267  ('action_accept', 'Accept'),
268  ('action_decline_1', 'Decline'),
269  ]
270 
272  summary,
273  body,
274  icon_path,
275  "NORMAL",
276  actions,
277  hints
278  )
279 
280  # verify that we cannot reveal the launcher (no longer interact with
281  # the shell)
282  time.sleep(1)
283  self.main_window.show_dash_swiping()
284  self.assertThat(
285  self.main_window.is_launcher_open, Eventually(Equals(False)))
286 
287  # verify and interact with the triggered snap-decision notification
288  notify_list = self._get_notifications_list()
289  get_notification = lambda: notify_list.wait_select_single(
290  'Notification', objectName='notification1')
291  notification = get_notification()
293  notification, summary, body, True, False, 1.0)
294  notification.pointing_device.click_object(
295  notification.select_single(objectName="notify_button0"))
296  self.assert_notification_action_id_was_called("action_accept")
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 160 of file test_notifications.py.

161  def test_sd_incoming_call(self):
162  """Rejecting a call should make notification expand and
163  offer more options."""
164  unity_proxy = self.launch_unity()
165  unlock_unity(unity_proxy)
166 
167  summary = "Incoming call"
168  body = "Frank Zappa\n+44 (0)7736 027340"
169  icon_path = self._get_icon_path('avatars/anna_olsson.png')
170  hints = [
171  ("x-canonical-secondary-icon", "incoming-call"),
172  ("x-canonical-snap-decisions", "true"),
173  ("x-canonical-private-affirmative-tint", "true"),
174  ("x-canonical-private-rejection-tint", "true"),
175  ]
176 
177  actions = [
178  ('action_accept', 'Hold + Answer'),
179  ('action_decline_1', 'End + Answer'),
180  ('action_decline_2', 'Decline'),
181  ('action_decline_3', 'message:I missed your call - can you call me now?'),
182  ('action_decline_4', 'message:I\'m running late. I\'m on my way.'),
183  ('action_decline_5', 'message:I\'m busy at the moment. I\'ll call later.'),
184  ('action_decline_6', 'edit:Custom'),
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  notification.pointing_device.click_object(
202  notification.select_single(objectName="combobutton_dropdown"))
203  self.assertThat(
204  notification.select_single(objectName="notify_button2").expanded,
205  Eventually(Equals(True)))
206  time.sleep(2)
207  notification.pointing_device.click_object(
208  notification.select_single(objectName="notify_button4"))
209  self.assert_notification_action_id_was_called("action_decline_4")
210 
def unity8.shell.tests.test_notifications.InteractiveNotificationBase.test_sd_one_over_two_layout (   self)
Snap-decision with three actions should use one-over two button layout.

Definition at line 211 of file test_notifications.py.

212  def test_sd_one_over_two_layout(self):
213  """Snap-decision with three actions should use one-over two button layout."""
214  unity_proxy = self.launch_unity()
215  unlock_unity(unity_proxy)
216 
217  summary = "Theatre at Ferria Stadium"
218  body = "at Ferria Stadium in Bilbao, Spain\n07578545317"
219  hints = [
220  ("x-canonical-snap-decisions", "true"),
221  ("x-canonical-non-shaped-icon", "true"),
222  ("x-canonical-private-affirmative-tint", "true")
223  ]
224 
225  actions = [
226  ('action_accept', 'Ok'),
227  ('action_decline_1', 'Snooze'),
228  ('action_decline_2', 'View'),
229  ]
230 
232  summary,
233  body,
234  None,
235  "NORMAL",
236  actions,
237  hints
238  )
239 
240  # verify and interact with the triggered snap-decision notification
241  notify_list = self._get_notifications_list()
242  get_notification = lambda: notify_list.wait_select_single(
243  'Notification', objectName='notification1')
244  notification = get_notification()
246  notification, summary, body, False, False, 1.0)
247  notification.pointing_device.click_object(
248  notification.select_single(objectName="notify_oot_button0"))
249  self.assert_notification_action_id_was_called("action_accept")

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