Unity 8
 All Classes Functions
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_one_over_two_layout
 
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 wait_for_unity
 
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 374 of file test_notifications.py.

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

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  ("x-canonical-secondary-icon","dialer")
140  ]
141 
143  summary,
144  body,
145  icon_path,
146  "NORMAL",
147  actions,
148  hints,
149  )
150 
151  get_notification = lambda: notify_list.wait_select_single(
152  'Notification', objectName='notification1')
153  notification = get_notification()
154 
155  notification.pointing_device.click_object(
156  notification.select_single(objectName="interactiveArea")
157  )
158 
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  def test_modal_sd_with_greeter(self):
248  """A snap-decision should block input to the greeter/lockscreen beneath it."""
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")
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.

201  """Snap-decision should block input to shell without greeter/lockscreen."""
202  unity_proxy = self.launch_unity()
203  unlock_unity(unity_proxy)
204 
205  summary = "Incoming file"
206  body = "Frank would like to send you the file: essay.pdf"
207  icon_path = "sync-idle"
208  hints = [
209  ("x-canonical-snap-decisions", "true"),
210  ("x-canonical-non-shaped-icon", "true"),
211  ("x-canonical-private-affirmative-tint", "true"),
212  ("x-canonical-private-rejection-tint", "true"),
213  ]
214 
215  actions = [
216  ('action_accept', 'Accept'),
217  ('action_decline_1', 'Decline'),
218  ]
219 
221  summary,
222  body,
223  icon_path,
224  "NORMAL",
225  actions,
226  hints
227  )
228 
229  # verify that we cannot reveal the launcher (no longer interact with
230  # the shell)
231  time.sleep(1)
232  self.main_window.show_dash_swiping()
233  self.assertThat(
234  self.main_window.is_launcher_open, Eventually(Equals(False)))
235 
236  # verify and interact with the triggered snap-decision notification
237  notify_list = self._get_notifications_list()
238  get_notification = lambda: notify_list.wait_select_single(
239  'Notification', objectName='notification1')
240  notification = get_notification()
242  notification, summary, body, True, False, 1.0)
243  notification.pointing_device.click_object(
244  notification.select_single(objectName="notify_button0"))
245  self.assert_notification_action_id_was_called("action_accept")
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  def test_sd_one_over_two_layout(self):
162  """Snap-decision with three actions should use one-over two button layout."""
163  unity_proxy = self.launch_unity()
164  unlock_unity(unity_proxy)
165 
166  summary = "Theatre at Ferria Stadium"
167  body = "at Ferria Stadium in Bilbao, Spain\n07578545317"
168  hints = [
169  ("x-canonical-snap-decisions", "true"),
170  ("x-canonical-non-shaped-icon", "true"),
171  ("x-canonical-private-affirmative-tint", "true")
172  ]
173 
174  actions = [
175  ('action_accept', 'Ok'),
176  ('action_decline_1', 'Snooze'),
177  ('action_decline_2', 'View'),
178  ]
179 
181  summary,
182  body,
183  None,
184  "NORMAL",
185  actions,
186  hints
187  )
188 
189  # verify and interact with the triggered snap-decision notification
190  notify_list = self._get_notifications_list()
191  get_notification = lambda: notify_list.wait_select_single(
192  'Notification', objectName='notification1')
193  notification = get_notification()
195  notification, summary, body, False, False, 1.0)
196  notification.pointing_device.click_object(
197  notification.select_single(objectName="notify_oot_button0"))
198  self.assert_notification_action_id_was_called("action_accept")

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