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, kwargs)
 
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 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 374 of file test_notifications.py.

374  def assert_notification_action_id_was_called(self, action_id, timeout=10):
375  """Assert that the interactive notification callback of id *action_id*
376  was called.
377 
378  :raises AssertionError: If no interactive notification has actually
379  been created.
380  :raises AssertionError: When *action_id* does not match the actual
381  returned.
382  :raises AssertionError: If no callback was called at all.
383  """
384 
385  if self._notify_proc is None:
386  raise AssertionError("No interactive notification was created.")
387 
388  for i in range(timeout):
389  self._notify_proc.poll()
390  if self._notify_proc.returncode is not None:
391  output = self._notify_proc.communicate()
392  actual_action_id = output[0].strip("\n")
393  if actual_action_id != action_id:
394  raise AssertionError(
395  "action id '%s' does not match actual returned '%s'"
396  % (action_id, actual_action_id)
397  )
398  else:
399  return
400  time.sleep(1)
401 
402  os.killpg(self._notify_proc.pid, signal.SIGTERM)
403  self._notify_proc = None
404  raise AssertionError(
405  "No callback was called, killing interactivenotification script"
406  )
407 
408 
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.

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

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

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

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

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