Lomiri
lomiri.shell.tests.test_notifications.InteractiveNotificationBase Class Reference
Inheritance diagram for lomiri.shell.tests.test_notifications.InteractiveNotificationBase:
Collaboration diagram for lomiri.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 (self, action_id, timeout=10)
 
- Public Member Functions inherited from lomiri.shell.tests.LomiriTestCase
def setUpClass (cls)
 
def setUp (self)
 
def launch_lomiri (self, mode="full-greeter", *args)
 
def patch_lightdm_mock (self)
 
def wait_for_lomiri (self)
 
def get_dash (self)
 
def main_window (self)
 

Additional Inherited Members

- Public Attributes inherited from lomiri.shell.tests.LomiriTestCase
 lomiri_geometry_args
 
 grid_size
 
- Static Public Attributes inherited from lomiri.shell.tests.test_notifications.NotificationsBase
 scenarios
 

Detailed Description

Collection of test for Interactive tests including snap decisions.

Definition at line 112 of file test_notifications.py.

Member Function Documentation

◆ assert_notification_action_id_was_called()

def lomiri.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

◆ setUp()

def lomiri.shell.tests.test_notifications.InteractiveNotificationBase.setUp (   self)

Reimplemented from lomiri.shell.tests.LomiriTestCase.

Definition at line 115 of file test_notifications.py.

115 def setUp(self):
116 super().setUp()
117 # Need to keep track when we launch the notification script.
118 self._notify_proc = None
119

◆ test_interactive()

def lomiri.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_lomiri()
123 unlock_lomiri()
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-lomiri-switch-to-application", "true"),
133 ("x-lomiri-secondary-icon", "dialer")
134 ]
135
136 self._create_interactive_notification(
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='notification0')
147 notification = get_notification()
148
149 notification.pointing_device.click_object(
150 notification.select_single(objectName="interactiveArea")
151 )
152
153 self.assert_notification_action_id_was_called('action_id')
154

◆ test_modal_sd_with_greeter()

def lomiri.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.

245 def test_modal_sd_with_greeter(self):
246 """A snap-decision should block input to the
247 greeter/lockscreen beneath it.
248 """
249 self.launch_lomiri()
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-lomiri-snap-decisions", "true"),
256 ("x-lomiri-non-shaped-icon", "true"),
257 ("x-lomiri-private-affirmative-tint", "true"),
258 ("x-lomiri-private-rejection-tint", "true"),
259 ]
260
261 actions = [
262 ('action_accept', 'Accept'),
263 ('action_decline_1', 'Decline'),
264 ]
265
266 self._create_interactive_notification(
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='notification0')
286 notification = get_notification()
287 self._assert_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

◆ test_modal_sd_without_greeter()

def lomiri.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.

196 def test_modal_sd_without_greeter(self):
197 """Snap-decision should block input to shell
198 without greeter/lockscreen.
199 """
200 self.launch_lomiri()
201 unlock_lomiri()
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-lomiri-snap-decisions", "true"),
208 ("x-lomiri-non-shaped-icon", "true"),
209 ("x-lomiri-private-affirmative-tint", "true"),
210 ("x-lomiri-private-rejection-tint", "true"),
211 ]
212
213 actions = [
214 ('action_accept', 'Accept'),
215 ('action_decline_1', 'Decline'),
216 ]
217
218 self._create_interactive_notification(
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='notification0')
238 notification = get_notification()
239 self._assert_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

◆ test_sd_one_over_two_layout()

def lomiri.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.

155 def test_sd_one_over_two_layout(self):
156 """Snap-decision with three actions should use
157 one-over two button layout.
158 """
159 self.launch_lomiri()
160 unlock_lomiri()
161
162 summary = "Theatre at Ferria Stadium"
163 body = "at Ferria Stadium in Bilbao, Spain\n07578545317"
164 hints = [
165 ("x-lomiri-snap-decisions", "true"),
166 ("x-lomiri-non-shaped-icon", "true"),
167 ("x-lomiri-private-affirmative-tint", "true")
168 ]
169
170 actions = [
171 ('action_accept', 'Ok'),
172 ('action_decline_1', 'Snooze'),
173 ('action_decline_2', 'View'),
174 ]
175
176 self._create_interactive_notification(
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='notification0')
189 notification = get_notification()
190 self._assert_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

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