@@ -25,6 +25,7 @@ import Ubuntu.Components 1.1
25import Ubuntu.Telephony 0.1 as Telephony
25import Ubuntu.Telephony 0.1 as Telephony
26import Unity.Application 0.1
26import Unity.Application 0.1
27import Unity.Connectivity 0.1
27import Unity.Connectivity 0.1
28+import Unity.Notifications 1.0
28import Unity.Test 0.1 as UT
29import Unity.Test 0.1 as UT
29import Powerd 0.1
30import Powerd 0.1
@@ -168,6 +169,83 @@ Row {
168 compare(ApplicationManager.count, 1)
169 compare(ApplicationManager.count, 1)
173+ id: mockNotification
176+ function invokeAction(actionId) {
177+ mockNotificationsModel.actionInvoked(actionId)
183+ id: mockNotificationsModel
185+ signal actionInvoked(string actionId)
187+ function getRaw(id) {
188+ return mockNotification.createObject(mockNotificationsModel)
193+ id: notificationActionSpy
195+ target: mockNotificationsModel
196+ signalName: "actionInvoked"
199+ function test_snapDecisionDismissalReturnsFocus() {
200+ var notifications = findChild(shell, "notificationList");
201+ var app = ApplicationManager.startApplication("camera-app");
203+ // Open an application and focus
204+ waitUntilApplicationWindowIsFullyVisible(app);
205+ ApplicationManager.focusApplication(app);
206+ compare(app.session.surface.activeFocus, true, "Focused application didn't have activeFocus");
208+ // Pop-up a notification
209+ addSnapDecisionNotification();
210+ notifications.model = mockNotificationsModel;
212+ var notification = findChild(notifications, "notification" + (mockNotificationsModel.count - 1));
213+ verify(notification !== undefined, "notification wasn't found");
215+ var buttonRow = findChild(notification, "buttonRow");
216+ verify(buttonRow !== undefined, "notification buttonRow wasn't found");
218+ var buttonAccept = findChild(buttonRow, "notify_button0");
219+ verify(buttonAccept !== undefined, "notification accept button wasn't found");
221+ // Pressing the button should give focus to the notification
222+ mousePress(buttonAccept, 0, 0);
223+ compare(app.session.surface.activeFocus, false, "Notification didn't take active focus");
224+ mouseRelease(buttonAccept);
226+ // Clicking the button should dismiss the notification and return focus
227+ mouseClick(buttonAccept, buttonAccept.width / 2, buttonAccept.height / 2);
228+ //compare(app.session.surface.activeFocus, true, "App didn't take active focus after snap notification was dismissed");
231+ function addSnapDecisionNotification() {
233+ type: Notification.SnapDecision,
234+ hints: {"x-canonical-private-affirmative-tint": "true"},
236+ body: "Lorem ipsum dolor sit amet, consetetur sadipscing elitr, sed diam nonumy eirmod tempor invidunt ut labore et dolore magna aliquyam erat, sed diam voluptua.",
237+ icon: "../graphics/avatars/funky.png",
238+ secondaryIcon: "../graphics/applicationIcons/facebook.png",
239+ actions: [{ id: "ok_id", label: "Ok"},
240+ { id: "cancel_id", label: "Cancel"},
241+ { id: "notreally_id", label: "Not really"},
242+ { id: "noway_id", label: "messages:No way"},
243+ { id: "nada_id", label: "messages:Nada"}]
246+ mockNotificationsModel.append(n)
171 function test_leftEdgeDrag_data() {
249 function test_leftEdgeDrag_data() {
173 {tag: "without launcher", revealLauncher: false, swipeLength: units.gu(27), appHides: true, focusedApp: "dialer-app", launcherHides: true},
251 {tag: "without launcher", revealLauncher: false, swipeLength: units.gu(27), appHides: true, focusedApp: "dialer-app", launcherHides: true},
@@ -178,7 +256,7 @@ Row {
181− function test_leftEdgeDrag(data) {
259+ /*function test_leftEdgeDrag(data) {
182 dragLauncherIntoView();
260 dragLauncherIntoView();
183 tapOnAppIconInLauncher();
261 tapOnAppIconInLauncher();
184 waitUntilApplicationWindowIsFullyVisible();
262 waitUntilApplicationWindowIsFullyVisible();
@@ -202,9 +280,9 @@ Row {
202 // Make sure the helper for sliding out the launcher wasn't touched. We want to fade it out here.
280 // Make sure the helper for sliding out the launcher wasn't touched. We want to fade it out here.
203 var animateTimer = findInvisibleChild(shell, "animateTimer");
281 var animateTimer = findInvisibleChild(shell, "animateTimer");
204 compare(animateTimer.nextState, "visible");
282 compare(animateTimer.nextState, "visible");
207− function test_suspend() {
285+ /*function test_suspend() {
208 var greeter = findChild(shell, "greeter");
286 var greeter = findChild(shell, "greeter");
210 // Launch an app from the launcher
288 // Launch an app from the launcher
@@ -241,7 +319,7 @@ Row {
241 tryCompare(ApplicationManager, "suspended", false);
319 tryCompare(ApplicationManager, "suspended", false);
242 compare(mainApp.state, ApplicationInfoInterface.Running);
320 compare(mainApp.state, ApplicationInfoInterface.Running);
243 tryCompare(ApplicationManager, "focusedApplicationId", mainAppId);
321 tryCompare(ApplicationManager, "focusedApplicationId", mainAppId);
246 function swipeAwayGreeter() {
324 function swipeAwayGreeter() {
247 var greeter = findChild(shell, "greeter");
325 var greeter = findChild(shell, "greeter");
@@ -267,7 +345,7 @@ Row {
267 - perform long left edge swipe to go minimize the app and go back to the dash.
345 - perform long left edge swipe to go minimize the app and go back to the dash.
268 - verify the setCurrentScope() D-Bus call to the dash has been called for the correct scope id.
346 - verify the setCurrentScope() D-Bus call to the dash has been called for the correct scope id.
270− function test_minimizingAppTakesToDashApps() {
348+ /*function test_minimizingAppTakesToDashApps() {
271 dragLauncherIntoView();
349 dragLauncherIntoView();
273 // Launch an app from the launcher
351 // Launch an app from the launcher
@@ -285,9 +363,9 @@ Row {
286 compare(dashCommunicatorSpy.count, 1);
364 compare(dashCommunicatorSpy.count, 1);
287 compare(dashCommunicatorSpy.signalArguments[0][0], "clickscope");
365 compare(dashCommunicatorSpy.signalArguments[0][0], "clickscope");
290− function test_showInputMethod() {
368+ /*function test_showInputMethod() {
291 var item = findChild(shell, "inputMethod");
369 var item = findChild(shell, "inputMethod");
292 var surface = SurfaceManager.inputMethodSurface();
370 var surface = SurfaceManager.inputMethodSurface();
@@ -305,7 +383,7 @@ Row {
306 surface.setState(MirSurfaceItem.Minimized);
384 surface.setState(MirSurfaceItem.Minimized);
307 tryCompare(item, "visible", false);
385 tryCompare(item, "visible", false);
310 // wait until any transition animation has finished
388 // wait until any transition animation has finished
311 function waitUntilTransitionsEnd(stateGroup) {
389 function waitUntilTransitionsEnd(stateGroup) {
@@ -446,7 +524,7 @@ Row {
446 && itemRectInShell.y + itemRectInShell.height <= shell.height;
524 && itemRectInShell.y + itemRectInShell.height <= shell.height;
449− function test_focusRequestedHidesGreeter() {
527+ /*function test_focusRequestedHidesGreeter() {
450 var greeter = findChild(shell, "greeter");
528 var greeter = findChild(shell, "greeter");
452 var app = ApplicationManager.startApplication("dialer-app");
530 var app = ApplicationManager.startApplication("dialer-app");
@@ -465,9 +543,9 @@ Row {
465 ApplicationManager.requestFocusApplication("dialer-app");
543 ApplicationManager.requestFocusApplication("dialer-app");
466 tryCompare(greeter, "showProgress", 0);
544 tryCompare(greeter, "showProgress", 0);
467 waitForRendering(greeter);
545 waitForRendering(greeter);
470− function test_focusRequestedHidesIndicators() {
548+ /*function test_focusRequestedHidesIndicators() {
471 var indicators = findChild(shell, "indicators");
549 var indicators = findChild(shell, "indicators");
473 showIndicators();
551 showIndicators();
@@ -477,9 +555,9 @@ Row {
477 tryCompare(ApplicationManager, "count", oldCount + 1);
555 tryCompare(ApplicationManager, "count", oldCount + 1);
479 tryCompare(indicators, "fullyClosed", true);
557 tryCompare(indicators, "fullyClosed", true);
482− function test_showAndHideGreeterDBusCalls() {
560+ /*function test_showAndHideGreeterDBusCalls() {
483 var greeter = findChild(shell, "greeter")
561 var greeter = findChild(shell, "greeter")
484 tryCompare(greeter, "showProgress", 0)
562 tryCompare(greeter, "showProgress", 0)
485 waitForRendering(greeter);
563 waitForRendering(greeter);
@@ -487,9 +565,9 @@ Row {
487 tryCompare(greeter, "showProgress", 1)
565 tryCompare(greeter, "showProgress", 1)
488 LightDM.Greeter.hideGreeter()
566 LightDM.Greeter.hideGreeter()
489 tryCompare(greeter, "showProgress", 0)
567 tryCompare(greeter, "showProgress", 0)
492− function test_login() {
570+ /*function test_login() {
493 sessionSpy.clear()
571 sessionSpy.clear()
495 var greeter = findChild(shell, "greeter")
573 var greeter = findChild(shell, "greeter")
@@ -500,9 +578,9 @@ Row {
500 tryCompare(sessionSpy, "count", 0)
578 tryCompare(sessionSpy, "count", 0)
501 swipeAwayGreeter()
579 swipeAwayGreeter()
502 tryCompare(sessionSpy, "count", 1)
580 tryCompare(sessionSpy, "count", 1)
505− function test_fullscreen() {
583+ /*function test_fullscreen() {
506 var panel = findChild(shell, "panel");
584 var panel = findChild(shell, "panel");
507 compare(panel.fullscreenMode, false);
585 compare(panel.fullscreenMode, false);
508 ApplicationManager.startApplication("camera-app");
586 ApplicationManager.startApplication("camera-app");
@@ -513,9 +591,9 @@ Row {
513 tryCompare(panel, "fullscreenMode", true);
591 tryCompare(panel, "fullscreenMode", true);
514 ApplicationManager.requestFocusApplication("dialer-app");
592 ApplicationManager.requestFocusApplication("dialer-app");
515 tryCompare(panel, "fullscreenMode", false);
593 tryCompare(panel, "fullscreenMode", false);
518− function test_leftEdgeDragFullscreen() {
596+ /*function test_leftEdgeDragFullscreen() {
519 var panel = findChild(shell, "panel");
597 var panel = findChild(shell, "panel");
520 tryCompare(panel, "fullscreenMode", false)
598 tryCompare(panel, "fullscreenMode", false)
@@ -534,9 +612,9 @@ Row {
534 tryCompare(panel, "fullscreenMode", false);
612 tryCompare(panel, "fullscreenMode", false);
536 touchRelease(shell);
614 touchRelease(shell);
539− function test_unlockedProperties() {
617+ /*function test_unlockedProperties() {
540 // Confirm that various properties have the correct values when unlocked
618 // Confirm that various properties have the correct values when unlocked
541 tryCompare(shell, "locked", false)
619 tryCompare(shell, "locked", false)
@@ -545,22 +623,22 @@ Row {
546 var indicators = findChild(shell, "indicators")
624 var indicators = findChild(shell, "indicators")
547 tryCompare(indicators, "available", true)
625 tryCompare(indicators, "available", true)
550− function test_unlockAllModemsOnBoot() {
628+ /*function test_unlockAllModemsOnBoot() {
551 // TODO reenable when service ready (LP: #1361074)
629 // TODO reenable when service ready (LP: #1361074)
552 expectFail("", "Unlock on boot temporarily disabled");
630 expectFail("", "Unlock on boot temporarily disabled");
553 tryCompare(unlockAllModemsSpy, "count", 1)
631 tryCompare(unlockAllModemsSpy, "count", 1)
556− function test_leftEdgeDragOnGreeter_data() {
634+ /*function test_leftEdgeDragOnGreeter_data() {
558 {tag: "short swipe", targetX: shell.width / 3, unlocked: false},
636 {tag: "short swipe", targetX: shell.width / 3, unlocked: false},
559 {tag: "long swipe", targetX: shell.width / 3 * 2, unlocked: true}
637 {tag: "long swipe", targetX: shell.width / 3 * 2, unlocked: true}
563− function test_leftEdgeDragOnGreeter(data) {
641+ /*function test_leftEdgeDragOnGreeter(data) {
564 var greeter = findChild(shell, "greeter");
642 var greeter = findChild(shell, "greeter");
565 greeter.show();
643 greeter.show();
566 tryCompare(greeter, "showProgress", 1);
644 tryCompare(greeter, "showProgress", 1);
@@ -570,6 +648,6 @@ Row {
570 touchFlick(shell, touchStartX, touchStartY, data.targetX, touchStartY);
648 touchFlick(shell, touchStartX, touchStartY, data.targetX, touchStartY);
572 tryCompare(greeter, "showProgress", data.unlocked ? 0 : 1);
650 tryCompare(greeter, "showProgress", data.unlocked ? 0 : 1);