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/phone-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 on a phone should not block input to the greeter beneath it.

Definition at line 256 of file test_notifications.py.

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

Definition at line 214 of file test_notifications.py.

216  """A snap-decision on a phone should block input to shell beneath it when there's no greeter."""
217  unity_proxy = self.launch_unity()
218  unlock_unity(unity_proxy)
219 
220  summary = "Incoming file"
221  body = "Frank would like to send you the file: essay.pdf"
222  icon_path = "sync-idle"
223  hints = [
224  ("x-canonical-snap-decisions", "true"),
225  ("x-canonical-non-shaped-icon", "true"),
226  ]
227 
228  actions = [
229  ('action_accept', 'Accept'),
230  ('action_decline_1', 'Decline'),
231  ]
232 
234  summary,
235  body,
236  icon_path,
237  "NORMAL",
238  actions,
239  hints
240  )
241 
242  # verify that we cannot reveal the launcher (no longer interact with the shell)
243  time.sleep(1)
244  self.main_window.show_dash_swiping()
245  launcher = self.main_window.get_launcher()
246  self.assertThat(launcher.shown, Eventually(Equals(False)))
247 
248  # verify and interact with the triggered snap-decision notification
249  notify_list = self._get_notifications_list()
250  get_notification = lambda: notify_list.wait_select_single(
251  'Notification', objectName='notification1')
252  notification = get_notification()
253  self._assert_notification(notification, summary, body, True, False, 1.0)
254  self.touch.tap_object(notification.select_single(objectName="button0"))
255  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/phone-app.png')
177  ),
178  ("x-canonical-snap-decisions", "true"),
179  ]
180 
181  actions = [
182  ('action_accept', 'Accept'),
183  ('action_decline_1', 'Decline'),
184  ('action_decline_2', '"Can\'t talk now, what\'s up?"'),
185  ('action_decline_3', '"I call you back."'),
186  ('action_decline_4', 'Send custom message...'),
187  ]
188 
190  summary,
191  body,
192  icon_path,
193  "NORMAL",
194  actions,
195  hints
196  )
197 
198  notify_list = self._get_notifications_list()
199  get_notification = lambda: notify_list.wait_select_single(
200  'Notification', objectName='notification1')
201  notification = get_notification()
202  self._assert_notification(notification, summary, body, True, True, 1.0)
203  initial_height = notification.height
204  self.touch.tap_object(notification.select_single(objectName="button1"))
205  self.assertThat(
206  notification.height,
207  Eventually(Equals(initial_height +
208  3 * notification.select_single(
209  objectName="buttonColumn").spacing +
210  3 * notification.select_single(
211  objectName="button4").height)))
212  self.touch.tap_object(notification.select_single(objectName="button4"))
213  self.assert_notification_action_id_was_called("action_decline_4")

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