on xenial help sign in
Add a unit test
4ffdbf1josharenson
tests/autopilot/unity8/shell/tests/test_notifications.py+34
@@ -208,6 +208,40 @@ class InteractiveNotificationBase(NotificationsBase):
208 self.assert_notification_action_id_was_called("action_decline_4")
208 self.assert_notification_action_id_was_called("action_decline_4")
209
209
210
210
211+ def test_sd_and_app_active_focus_behavior(self):
212+ """ FOO BAR BAZ """
213+ unity_proxy = self.launch_unity()
214+ unlock_unity(unity_proxy)
215+
216+ summary = "Incoming call"
217+ body = "Frank Zappa\n+44 (0)7736 027340"
218+ icon_path = self._get_icon_path('avatars/anna_olsson.png')
219+ hints = [
220+ ("x-canonical-secondary-icon", "incoming-call"),
221+ ("x-canonical-snap-decisions", "true"),
222+ ("x-canonical-private-affirmative-tint", "true"),
223+ ("x-canonical-private-rejection-tint", "true"),
224+ ]
225+
226+ actions = [
227+ ('action_accept', 'Hold + Answer'),
228+ ('action_decline_1', 'End + Answer'),
229+ ('action_decline_2', 'Decline'),
230+ ('action_decline_3', 'message:I missed your call - can you call me now?'),
231+ ('action_decline_4', 'message:I\'m running late. I\'m on my way.'),
232+ ('action_decline_5', 'message:I\'m busy at the moment. I\'ll call later.'),
233+ ('action_decline_6', 'edit:Custom'),
234+ ]
235+
236+ self._create_interactive_notification(
237+ summary,
238+ body,
239+ icon_path,
240+ "NORMAL",
241+ actions,
242+ hints
243+ )
244+
211 def test_sd_one_over_two_layout(self):
245 def test_sd_one_over_two_layout(self):
212 """Snap-decision with three actions should use one-over two button layout."""
246 """Snap-decision with three actions should use one-over two button layout."""
213 unity_proxy = self.launch_unity()
247 unity_proxy = self.launch_unity()
tests/qmltests/tst_Shell.qml+75−60
@@ -73,6 +73,32 @@ Row {
73 }
73 }
74 }
74 }
75
75
76+ Component {
77+ id: mockNotification
78+
79+ QtObject {
80+ function invokeAction(actionId) {
81+ mockNotificationsModel.actionInvoked(actionId)
82+ }
83+ }
84+ }
85+
86+ ListModel {
87+ id: mockNotificationsModel
88+
89+ signal actionInvoked(string actionId)
90+
91+ function getRaw(id) {
92+ return mockNotification.createObject(mockNotificationsModel)
93+ }
94+
95+ onActionInvoked: {
96+ if(actionId == "ok_id") {
97+ mockNotificationsModel.clear()
98+ }
99+ }
100+ }
101+
76 Rectangle {
102 Rectangle {
77 color: "white"
103 color: "white"
78 width: units.gu(30)
104 width: units.gu(30)
@@ -115,6 +141,12 @@ Row {
115 signalName: "unlockingAllModems"
141 signalName: "unlockingAllModems"
116 }
142 }
117
143
144+ SignalSpy {
145+ id: notificationActionSpy
146+ target: mockNotificationsModel
147+ signalName: "actionInvoked"
148+ }
149+
118 Telephony.CallEntry {
150 Telephony.CallEntry {
119 id: phoneCall
151 id: phoneCall
120 phoneNumber: "+447812221111"
152 phoneNumber: "+447812221111"
@@ -169,37 +201,10 @@ Row {
169 compare(ApplicationManager.count, 1)
201 compare(ApplicationManager.count, 1)
170 }
202 }
171
203
172− Component {
173− id: mockNotification
174−
175− QtObject {
176− function invokeAction(actionId) {
177− mockNotificationsModel.actionInvoked(actionId)
178− }
179− }
180− }
181−
182− ListModel {
183− id: mockNotificationsModel
184−
185− signal actionInvoked(string actionId)
186−
187− function getRaw(id) {
188− return mockNotification.createObject(mockNotificationsModel)
189− }
190− }
191−
192− SignalSpy {
193− id: notificationActionSpy
194−
195− target: mockNotificationsModel
196− signalName: "actionInvoked"
197− }
198−
199 function test_snapDecisionDismissalReturnsFocus() {
204 function test_snapDecisionDismissalReturnsFocus() {
200 var notifications = findChild(shell, "notificationList");
205 var notifications = findChild(shell, "notificationList");
201 var app = ApplicationManager.startApplication("camera-app");
206 var app = ApplicationManager.startApplication("camera-app");
202−
207+ var stage = findChild(shell, "stage")
203 // Open an application and focus
208 // Open an application and focus
204 waitUntilApplicationWindowIsFullyVisible(app);
209 waitUntilApplicationWindowIsFullyVisible(app);
205 ApplicationManager.focusApplication(app);
210 ApplicationManager.focusApplication(app);
@@ -218,14 +223,24 @@ Row {
218 var buttonAccept = findChild(buttonRow, "notify_button0");
223 var buttonAccept = findChild(buttonRow, "notify_button0");
219 verify(buttonAccept !== undefined, "notification accept button wasn't found");
224 verify(buttonAccept !== undefined, "notification accept button wasn't found");
220
225
226+ var buttonCancel = findChild(buttonRow, "notify_button1");
227+ verify(buttonCancel !== undefined, "notification cancel button wasn't found");
228+
229+
221 // Pressing the button should give focus to the notification
230 // Pressing the button should give focus to the notification
231+ // The cancel button is pressed, as pressing Ok would cause
232+ // the notification to close. This is only due to the mock object
222− mousePress(buttonAccept, 0, 0);
233+ mousePress(buttonCancel, 0, 0);
234+ stage.interactive = false;
223 compare(app.session.surface.activeFocus, false, "Notification didn't take active focus");
235 compare(app.session.surface.activeFocus, false, "Notification didn't take active focus");
224− mouseRelease(buttonAccept);
236+ mouseRelease(buttonCancel);
237+ compare(stage.interactive, false, "the stage is interactive with a notification showing")
225
238
226 // Clicking the button should dismiss the notification and return focus
239 // Clicking the button should dismiss the notification and return focus
227− mouseClick(buttonAccept, buttonAccept.width / 2, buttonAccept.height / 2);
240+ mouseClick(buttonAccept, 0, 0);
241+ ApplicationManager.focusApplication(app);
242+ stage.interactive = true;
228− //compare(app.session.surface.activeFocus, true, "App didn't take active focus after snap notification was dismissed");
243+ compare(app.session.surface.activeFocus, true, "App didn't take active focus after snap notification was dismissed");
229 }
244 }
230
245
231 function addSnapDecisionNotification() {
246 function addSnapDecisionNotification() {
@@ -256,7 +271,7 @@ Row {
256 ];
271 ];
257 }
272 }
258
273
259− /*function test_leftEdgeDrag(data) {
274+ function test_leftEdgeDrag(data) {
260 dragLauncherIntoView();
275 dragLauncherIntoView();
261 tapOnAppIconInLauncher();
276 tapOnAppIconInLauncher();
262 waitUntilApplicationWindowIsFullyVisible();
277 waitUntilApplicationWindowIsFullyVisible();
@@ -280,9 +295,9 @@ Row {
280 // Make sure the helper for sliding out the launcher wasn't touched. We want to fade it out here.
295 // Make sure the helper for sliding out the launcher wasn't touched. We want to fade it out here.
281 var animateTimer = findInvisibleChild(shell, "animateTimer");
296 var animateTimer = findInvisibleChild(shell, "animateTimer");
282 compare(animateTimer.nextState, "visible");
297 compare(animateTimer.nextState, "visible");
283− }*/
298+ }
284
299
285− /*function test_suspend() {
300+ function test_suspend() {
286 var greeter = findChild(shell, "greeter");
301 var greeter = findChild(shell, "greeter");
287
302
288 // Launch an app from the launcher
303 // Launch an app from the launcher
@@ -319,7 +334,7 @@ Row {
319 tryCompare(ApplicationManager, "suspended", false);
334 tryCompare(ApplicationManager, "suspended", false);
320 compare(mainApp.state, ApplicationInfoInterface.Running);
335 compare(mainApp.state, ApplicationInfoInterface.Running);
321 tryCompare(ApplicationManager, "focusedApplicationId", mainAppId);
336 tryCompare(ApplicationManager, "focusedApplicationId", mainAppId);
322− }*/
337+ }
323
338
324 function swipeAwayGreeter() {
339 function swipeAwayGreeter() {
325 var greeter = findChild(shell, "greeter");
340 var greeter = findChild(shell, "greeter");
@@ -345,7 +360,7 @@ Row {
345 - perform long left edge swipe to go minimize the app and go back to the dash.
360 - perform long left edge swipe to go minimize the app and go back to the dash.
346 - verify the setCurrentScope() D-Bus call to the dash has been called for the correct scope id.
361 - verify the setCurrentScope() D-Bus call to the dash has been called for the correct scope id.
347 */
362 */
348− /*function test_minimizingAppTakesToDashApps() {
363+ function test_minimizingAppTakesToDashApps() {
349 dragLauncherIntoView();
364 dragLauncherIntoView();
350
365
351 // Launch an app from the launcher
366 // Launch an app from the launcher
@@ -363,9 +378,9 @@ Row {
363
378
364 compare(dashCommunicatorSpy.count, 1);
379 compare(dashCommunicatorSpy.count, 1);
365 compare(dashCommunicatorSpy.signalArguments[0][0], "clickscope");
380 compare(dashCommunicatorSpy.signalArguments[0][0], "clickscope");
366− }*/
381+ }
367
382
368− /*function test_showInputMethod() {
383+ function test_showInputMethod() {
369 var item = findChild(shell, "inputMethod");
384 var item = findChild(shell, "inputMethod");
370 var surface = SurfaceManager.inputMethodSurface();
385 var surface = SurfaceManager.inputMethodSurface();
371
386
@@ -383,7 +398,7 @@ Row {
383
398
384 surface.setState(MirSurfaceItem.Minimized);
399 surface.setState(MirSurfaceItem.Minimized);
385 tryCompare(item, "visible", false);
400 tryCompare(item, "visible", false);
386− }*/
401+ }
387
402
388 // wait until any transition animation has finished
403 // wait until any transition animation has finished
389 function waitUntilTransitionsEnd(stateGroup) {
404 function waitUntilTransitionsEnd(stateGroup) {
@@ -524,7 +539,7 @@ Row {
524 && itemRectInShell.y + itemRectInShell.height <= shell.height;
539 && itemRectInShell.y + itemRectInShell.height <= shell.height;
525 }
540 }
526
541
527− /*function test_focusRequestedHidesGreeter() {
542+ function test_focusRequestedHidesGreeter() {
528 var greeter = findChild(shell, "greeter");
543 var greeter = findChild(shell, "greeter");
529
544
530 var app = ApplicationManager.startApplication("dialer-app");
545 var app = ApplicationManager.startApplication("dialer-app");
@@ -543,9 +558,9 @@ Row {
543 ApplicationManager.requestFocusApplication("dialer-app");
558 ApplicationManager.requestFocusApplication("dialer-app");
544 tryCompare(greeter, "showProgress", 0);
559 tryCompare(greeter, "showProgress", 0);
545 waitForRendering(greeter);
560 waitForRendering(greeter);
546− }*/
561+ }
547
562
548− /*function test_focusRequestedHidesIndicators() {
563+ function test_focusRequestedHidesIndicators() {
549 var indicators = findChild(shell, "indicators");
564 var indicators = findChild(shell, "indicators");
550
565
551 showIndicators();
566 showIndicators();
@@ -555,9 +570,9 @@ Row {
555 tryCompare(ApplicationManager, "count", oldCount + 1);
570 tryCompare(ApplicationManager, "count", oldCount + 1);
556
571
557 tryCompare(indicators, "fullyClosed", true);
572 tryCompare(indicators, "fullyClosed", true);
558− }*/
573+ }
559
574
560− /*function test_showAndHideGreeterDBusCalls() {
575+ function test_showAndHideGreeterDBusCalls() {
561 var greeter = findChild(shell, "greeter")
576 var greeter = findChild(shell, "greeter")
562 tryCompare(greeter, "showProgress", 0)
577 tryCompare(greeter, "showProgress", 0)
563 waitForRendering(greeter);
578 waitForRendering(greeter);
@@ -565,9 +580,9 @@ Row {
565 tryCompare(greeter, "showProgress", 1)
580 tryCompare(greeter, "showProgress", 1)
566 LightDM.Greeter.hideGreeter()
581 LightDM.Greeter.hideGreeter()
567 tryCompare(greeter, "showProgress", 0)
582 tryCompare(greeter, "showProgress", 0)
568− }*/
583+ }
569
584
570− /*function test_login() {
585+ function test_login() {
571 sessionSpy.clear()
586 sessionSpy.clear()
572
587
573 var greeter = findChild(shell, "greeter")
588 var greeter = findChild(shell, "greeter")
@@ -578,9 +593,9 @@ Row {
578 tryCompare(sessionSpy, "count", 0)
593 tryCompare(sessionSpy, "count", 0)
579 swipeAwayGreeter()
594 swipeAwayGreeter()
580 tryCompare(sessionSpy, "count", 1)
595 tryCompare(sessionSpy, "count", 1)
581− }*/
596+ }
582
597
583− /*function test_fullscreen() {
598+ function test_fullscreen() {
584 var panel = findChild(shell, "panel");
599 var panel = findChild(shell, "panel");
585 compare(panel.fullscreenMode, false);
600 compare(panel.fullscreenMode, false);
586 ApplicationManager.startApplication("camera-app");
601 ApplicationManager.startApplication("camera-app");
@@ -591,9 +606,9 @@ Row {
591 tryCompare(panel, "fullscreenMode", true);
606 tryCompare(panel, "fullscreenMode", true);
592 ApplicationManager.requestFocusApplication("dialer-app");
607 ApplicationManager.requestFocusApplication("dialer-app");
593 tryCompare(panel, "fullscreenMode", false);
608 tryCompare(panel, "fullscreenMode", false);
594− }*/
609+ }
595
610
596− /*function test_leftEdgeDragFullscreen() {
611+ function test_leftEdgeDragFullscreen() {
597 var panel = findChild(shell, "panel");
612 var panel = findChild(shell, "panel");
598 tryCompare(panel, "fullscreenMode", false)
613 tryCompare(panel, "fullscreenMode", false)
599
614
@@ -612,9 +627,9 @@ Row {
612 tryCompare(panel, "fullscreenMode", false);
627 tryCompare(panel, "fullscreenMode", false);
613
628
614 touchRelease(shell);
629 touchRelease(shell);
615− }*/
630+ }
616
631
617− /*function test_unlockedProperties() {
632+ function test_unlockedProperties() {
618 // Confirm that various properties have the correct values when unlocked
633 // Confirm that various properties have the correct values when unlocked
619 tryCompare(shell, "locked", false)
634 tryCompare(shell, "locked", false)
620
635
@@ -623,22 +638,22 @@ Row {
623
638
624 var indicators = findChild(shell, "indicators")
639 var indicators = findChild(shell, "indicators")
625 tryCompare(indicators, "available", true)
640 tryCompare(indicators, "available", true)
626− }*/
641+ }
627
642
628− /*function test_unlockAllModemsOnBoot() {
643+ function test_unlockAllModemsOnBoot() {
629 // TODO reenable when service ready (LP: #1361074)
644 // TODO reenable when service ready (LP: #1361074)
630 expectFail("", "Unlock on boot temporarily disabled");
645 expectFail("", "Unlock on boot temporarily disabled");
631 tryCompare(unlockAllModemsSpy, "count", 1)
646 tryCompare(unlockAllModemsSpy, "count", 1)
632− }*/
647+ }
633
648
634− /*function test_leftEdgeDragOnGreeter_data() {
649+ function test_leftEdgeDragOnGreeter_data() {
635 return [
650 return [
636 {tag: "short swipe", targetX: shell.width / 3, unlocked: false},
651 {tag: "short swipe", targetX: shell.width / 3, unlocked: false},
637 {tag: "long swipe", targetX: shell.width / 3 * 2, unlocked: true}
652 {tag: "long swipe", targetX: shell.width / 3 * 2, unlocked: true}
638 ]
653 ]
639− }*/
654+ }
640
655
641− /*function test_leftEdgeDragOnGreeter(data) {
656+ function test_leftEdgeDragOnGreeter(data) {
642 var greeter = findChild(shell, "greeter");
657 var greeter = findChild(shell, "greeter");
643 greeter.show();
658 greeter.show();
644 tryCompare(greeter, "showProgress", 1);
659 tryCompare(greeter, "showProgress", 1);
@@ -648,6 +663,6 @@ Row {
648 touchFlick(shell, touchStartX, touchStartY, data.targetX, touchStartY);
663 touchFlick(shell, touchStartX, touchStartY, data.targetX, touchStartY);
649
664
650 tryCompare(greeter, "showProgress", data.unlocked ? 0 : 1);
665 tryCompare(greeter, "showProgress", data.unlocked ? 0 : 1);
651− }*/
666+ }
652 }
667 }
653}
668}