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 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 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 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 379 of file test_notifications.py.

380  def assert_notification_action_id_was_called(self, action_id, timeout=10):
381  """Assert that the interactive notification callback of id *action_id*
382  was called.
383 
384  :raises AssertionError: If no interactive notification has actually
385  been created.
386  :raises AssertionError: When *action_id* does not match the actual
387  returned.
388  :raises AssertionError: If no callback was called at all.
389  """
390 
391  if self._notify_proc is None:
392  raise AssertionError("No interactive notification was created.")
393 
394  for i in range(timeout):
395  self._notify_proc.poll()
396  if self._notify_proc.returncode is not None:
397  output = self._notify_proc.communicate()
398  actual_action_id = output[0].strip("\n")
399  if actual_action_id != action_id:
400  raise AssertionError(
401  "action id '%s' does not match actual returned '%s'"
402  % (action_id, actual_action_id)
403  )
404  else:
405  return
406  time.sleep(1)
407 
408  os.killpg(self._notify_proc.pid, signal.SIGTERM)
409  self._notify_proc = None
410  raise AssertionError(
411  "No callback was called, killing interactivenotification script"
412  )
413 
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  (
140  "x-canonical-secondary-icon",
141  self._get_icon_path('applicationIcons/dialer-app.png')
142  )
143  ]
144 
146  summary,
147  body,
148  icon_path,
149  "NORMAL",
150  actions,
151  hints,
152  )
153 
154  get_notification = lambda: notify_list.wait_select_single(
155  'Notification', objectName='notification1')
156  notification = get_notification()
157 
158  self.touch.tap_object(
159  notification.select_single(objectName="interactiveArea")
160  )
161 
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 255 of file test_notifications.py.

256  def test_modal_sd_with_greeter(self):
257  """A snap-decision should not block input to the greeter beneath it."""
258  self.launch_unity()
259 
260  summary = "Incoming file"
261  body = "Frank would like to send you the file: essay.pdf"
262  icon_path = "sync-idle"
263  hints = [
264  ("x-canonical-snap-decisions", "true"),
265  ("x-canonical-non-shaped-icon", "true"),
266  ]
267 
268  actions = [
269  ('action_accept', 'Accept'),
270  ('action_decline_1', 'Decline'),
271  ]
272 
274  summary,
275  body,
276  icon_path,
277  "NORMAL",
278  actions,
279  hints
280  )
281 
282  # verify that we can swipe away the greeter (interact with the "shell")
283  time.sleep(1)
284  self.main_window.show_dash_swiping()
285  greeter = self.main_window.get_greeter()
286  self.assertThat(greeter.shown, Eventually(Equals(False)))
287 
288  # verify and interact with the triggered snap-decision notification
289  notify_list = self._get_notifications_list()
290  get_notification = lambda: notify_list.wait_select_single(
291  'Notification', objectName='notification1')
292  notification = get_notification()
294  notification, summary, body, True, False, 1.0)
295  self.touch.tap_object(notification.select_single(objectName="button0"))
296  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 211 of file test_notifications.py.

213  """Snap-decision should block input to shell without greeter."""
214  unity_proxy = self.launch_unity()
215  unlock_unity(unity_proxy)
216 
217  summary = "Incoming file"
218  body = "Frank would like to send you the file: essay.pdf"
219  icon_path = "sync-idle"
220  hints = [
221  ("x-canonical-snap-decisions", "true"),
222  ("x-canonical-non-shaped-icon", "true"),
223  ]
224 
225  actions = [
226  ('action_accept', 'Accept'),
227  ('action_decline_1', 'Decline'),
228  ]
229 
231  summary,
232  body,
233  icon_path,
234  "NORMAL",
235  actions,
236  hints
237  )
238 
239  # verify that we cannot reveal the launcher (no longer interact with
240  # the shell)
241  time.sleep(1)
242  self.main_window.show_dash_swiping()
243  launcher = self.main_window.get_launcher()
244  self.assertThat(launcher.shown, Eventually(Equals(False)))
245 
246  # verify and interact with the triggered snap-decision notification
247  notify_list = self._get_notifications_list()
248  get_notification = lambda: notify_list.wait_select_single(
249  'Notification', objectName='notification1')
250  notification = get_notification()
252  notification, summary, body, True, False, 1.0)
253  self.touch.tap_object(notification.select_single(objectName="button0"))
254  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 163 of file test_notifications.py.

164  def test_sd_incoming_call(self):
165  """Rejecting a call should make notification expand and
166  offer more options."""
167  unity_proxy = self.launch_unity()
168  unlock_unity(unity_proxy)
169 
170  summary = "Incoming call"
171  body = "Frank Zappa\n+44 (0)7736 027340"
172  icon_path = self._get_icon_path('avatars/anna_olsson.png')
173  hints = [
174  (
175  "x-canonical-secondary-icon",
176  self._get_icon_path('applicationIcons/dialer-app.png')
177  ),
178  ("x-canonical-snap-decisions", "true"),
179  ]
180 
181  actions = [
182  ('action_accept', 'Hold + Answer'),
183  ('action_decline_1', 'End + Answer'),
184  ('action_decline_2', 'Decline'),
185  ('action_decline_3', 'messages:I missed your call - can you call me now?'),
186  ('action_decline_4', 'messages:I\'m running late. I\'m on my way.'),
187  ('action_decline_5', 'messages:I\'m busy at the moment. I\'ll call later.'),
188  ('action_decline_6', 'edit:Custom'),
189  ]
190 
192  summary,
193  body,
194  icon_path,
195  "NORMAL",
196  actions,
197  hints
198  )
199 
200  notify_list = self._get_notifications_list()
201  get_notification = lambda: notify_list.wait_select_single(
202  'Notification', objectName='notification1')
203  notification = get_notification()
204  self._assert_notification(notification, summary, body, True, True, 1.0)
205  initial_height = notification.height
206  self.touch.tap_object(notification.select_single(objectName="combobutton_dropdown"))
207  self.assertThat(notification.select_single(objectName="button2").expanded, Eventually(Equals(True)))
208  time.sleep(2)
209  self.touch.tap_object(notification.select_single(objectName="button4"))
210  self.assert_notification_action_id_was_called("action_decline_4")

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