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
 unity_geometry_args
 
 grid_size
 
- Static Public Attributes inherited from unity8.shell.tests.test_notifications.NotificationsBase
tuple scenarios
 

Detailed Description

Collection of test for Interactive tests including snap decisions.

Definition at line 112 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 377 of file test_notifications.py.

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

Definition at line 120 of file test_notifications.py.

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

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

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

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

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