Unity 8
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 (self)
 
def test_interactive (self)
 
def test_sd_one_over_two_layout (self)
 
def test_modal_sd_without_greeter (self)
 
def test_modal_sd_with_greeter (self)
 
def assert_notification_action_id_was_called
 
- Public Member Functions inherited from unity8.shell.tests.UnityTestCase
def setUpClass (cls)
 
def setUp (self)
 
def launch_unity (self, mode="full-greeter", args)
 
def patch_lightdm_mock (self)
 
def wait_for_unity (self)
 
def get_dash (self)
 
def main_window (self)
 

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

366  def assert_notification_action_id_was_called(self, action_id, timeout=10):
367  """Assert that the interactive notification callback of id *action_id*
368  was called.
369 
370  :raises AssertionError: If no interactive notification has actually
371  been created.
372  :raises AssertionError: When *action_id* does not match the actual
373  returned.
374  :raises AssertionError: If no callback was called at all.
375  """
376 
377  if self._notify_proc is None:
378  raise AssertionError("No interactive notification was created.")
379 
380  for i in range(timeout):
381  self._notify_proc.poll()
382  if self._notify_proc.returncode is not None:
383  output = self._notify_proc.communicate()
384  actual_action_id = output[0].strip("\n")
385  if actual_action_id != action_id:
386  raise AssertionError(
387  "action id '%s' does not match actual returned '%s'"
388  % (action_id, actual_action_id)
389  )
390  else:
391  return
392  time.sleep(1)
393 
394  os.killpg(self._notify_proc.pid, signal.SIGTERM)
395  self._notify_proc = None
396  raise AssertionError(
397  "No callback was called, killing interactivenotification script"
398  )
399 
400 
def unity8.shell.tests.test_notifications.InteractiveNotificationBase.test_interactive (   self)
Interactive notification must react upon click on itself.

Definition at line 117 of file test_notifications.py.

117  def test_interactive(self):
118  """Interactive notification must react upon click on itself."""
119  unity_proxy = self.launch_unity()
120  unlock_unity(unity_proxy)
121 
122  notify_list = self._get_notifications_list()
123 
124  summary = "Interactive notification"
125  body = "This notification can be clicked on to trigger an action."
126  icon_path = self._get_icon_path('avatars/anna_olsson.png')
127  actions = [("action_id", "dummy")]
128  hints = [
129  ("x-canonical-switch-to-application", "true"),
130  ("x-canonical-secondary-icon","dialer")
131  ]
132 
134  summary,
135  body,
136  icon_path,
137  "NORMAL",
138  actions,
139  hints,
140  )
141 
142  get_notification = lambda: notify_list.wait_select_single(
143  'Notification', objectName='notification1')
144  notification = get_notification()
145 
146  notification.pointing_device.click_object(
147  notification.select_single(objectName="interactiveArea")
148  )
149 
151 
def launch_unity(self, mode="full-greeter", args)
Definition: __init__.py:255
def unity8.shell.tests.test_notifications.InteractiveNotificationBase.test_modal_sd_with_greeter (   self)
A snap-decision should block input to the greeter/lockscreen beneath it.

Definition at line 238 of file test_notifications.py.

239  """A snap-decision should block input to the greeter/lockscreen beneath it."""
240  self.launch_unity()
241 
242  summary = "Incoming file"
243  body = "Frank would like to send you the file: essay.pdf"
244  icon_path = "sync-idle"
245  hints = [
246  ("x-canonical-snap-decisions", "true"),
247  ("x-canonical-non-shaped-icon", "true"),
248  ("x-canonical-private-affirmative-tint", "true"),
249  ("x-canonical-private-rejection-tint", "true"),
250  ]
251 
252  actions = [
253  ('action_accept', 'Accept'),
254  ('action_decline_1', 'Decline'),
255  ]
256 
258  summary,
259  body,
260  icon_path,
261  "NORMAL",
262  actions,
263  hints
264  )
265 
266  # verify that we cannot reveal the launcher (no longer interact with
267  # the shell)
268  time.sleep(1)
269  self.main_window.show_dash_swiping()
270  self.assertThat(
271  self.main_window.is_launcher_open, Eventually(Equals(False)))
272 
273  # verify and interact with the triggered snap-decision notification
274  notify_list = self._get_notifications_list()
275  get_notification = lambda: notify_list.wait_select_single(
276  'Notification', objectName='notification1')
277  notification = get_notification()
279  notification, summary, body, True, False, 1.0)
280  notification.pointing_device.click_object(
281  notification.select_single(objectName="notify_button0"))
282  self.assert_notification_action_id_was_called("action_accept")
283 
def launch_unity(self, mode="full-greeter", args)
Definition: __init__.py:255
def unity8.shell.tests.test_notifications.InteractiveNotificationBase.test_modal_sd_without_greeter (   self)
Snap-decision should block input to shell without greeter/lockscreen.

Definition at line 191 of file test_notifications.py.

192  """Snap-decision should block input to shell without greeter/lockscreen."""
193  unity_proxy = self.launch_unity()
194  unlock_unity(unity_proxy)
195 
196  summary = "Incoming file"
197  body = "Frank would like to send you the file: essay.pdf"
198  icon_path = "sync-idle"
199  hints = [
200  ("x-canonical-snap-decisions", "true"),
201  ("x-canonical-non-shaped-icon", "true"),
202  ("x-canonical-private-affirmative-tint", "true"),
203  ("x-canonical-private-rejection-tint", "true"),
204  ]
205 
206  actions = [
207  ('action_accept', 'Accept'),
208  ('action_decline_1', 'Decline'),
209  ]
210 
212  summary,
213  body,
214  icon_path,
215  "NORMAL",
216  actions,
217  hints
218  )
219 
220  # verify that we cannot reveal the launcher (no longer interact with
221  # the shell)
222  time.sleep(1)
223  self.main_window.show_dash_swiping()
224  self.assertThat(
225  self.main_window.is_launcher_open, Eventually(Equals(False)))
226 
227  # verify and interact with the triggered snap-decision notification
228  notify_list = self._get_notifications_list()
229  get_notification = lambda: notify_list.wait_select_single(
230  'Notification', objectName='notification1')
231  notification = get_notification()
233  notification, summary, body, True, False, 1.0)
234  notification.pointing_device.click_object(
235  notification.select_single(objectName="notify_button0"))
236  self.assert_notification_action_id_was_called("action_accept")
237 
def launch_unity(self, mode="full-greeter", args)
Definition: __init__.py:255
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 152 of file test_notifications.py.

153  """Snap-decision with three actions should use one-over two button layout."""
154  unity_proxy = self.launch_unity()
155  unlock_unity(unity_proxy)
156 
157  summary = "Theatre at Ferria Stadium"
158  body = "at Ferria Stadium in Bilbao, Spain\n07578545317"
159  hints = [
160  ("x-canonical-snap-decisions", "true"),
161  ("x-canonical-non-shaped-icon", "true"),
162  ("x-canonical-private-affirmative-tint", "true")
163  ]
164 
165  actions = [
166  ('action_accept', 'Ok'),
167  ('action_decline_1', 'Snooze'),
168  ('action_decline_2', 'View'),
169  ]
170 
172  summary,
173  body,
174  None,
175  "NORMAL",
176  actions,
177  hints
178  )
179 
180  # verify and interact with the triggered snap-decision notification
181  notify_list = self._get_notifications_list()
182  get_notification = lambda: notify_list.wait_select_single(
183  'Notification', objectName='notification1')
184  notification = get_notification()
186  notification, summary, body, False, False, 1.0)
187  notification.pointing_device.click_object(
188  notification.select_single(objectName="notify_oot_button0"))
189  self.assert_notification_action_id_was_called("action_accept")
190 
def launch_unity(self, mode="full-greeter", args)
Definition: __init__.py:255

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