@@ -0,0 +1,237 @@
2+ * Copyright (C) 2014 Canonical, Ltd.
4+ * This program is free software; you can redistribute it and/or modify
5+ * it under the terms of the GNU General Public License as published by
6+ * the Free Software Foundation; version 3.
8+ * This program is distributed in the hope that it will be useful,
9+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
10+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11+ * GNU General Public License for more details.
13+ * You should have received a copy of the GNU General Public License
14+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
20+import "../../../qml/Notifications"
21+import Ubuntu.Components 0.1
23+import Unity.Notifications 1.0
32+ function invokeAction(actionId) {
33+ mockModel.actionInvoked(actionId)
41+ signal actionInvoked(string actionId)
43+ function getRaw(id) {
44+ return mockNotification.createObject(mockModel)
47+ // add the default/PlaceHolder notification to the model
48+ Component.onCompleted: {
50+ type: Notification.PlaceHolder,
63+ function addSomeSnapDecisionNotifications() {
65+ type: Notification.SnapDecision,
66+ hints: {"x-canonical-private-button-tint": "true"},
67+ summary: "Incoming call",
68+ body: "Frank Zappa\n+44 (0)7736 027340",
69+ icon: "../graphics/avatars/funky.png",
70+ secondaryIcon: "../graphics/applicationIcons/phone-app.png",
71+ actions: [{ id: "pickup_id", label: "Pick up"},
72+ { id: "decline_1_id", label: "Decline"},
73+ { id: "decline_2_id", label: "Can't talk now, what's up?"},
74+ { id: "decline_3_id", label: "I call you back."},
75+ { id: "decline_4_id", label: "Send custom message..."}]
78+ type: Notification.SnapDecision,
79+ hints: {"x-canonical-private-button-tint": "true",
80+ "x-canonical-non-shaped-icon": "true"},
81+ summary: "Incoming file",
82+ body: "Frank would like to send you the file: essay.pdf.",
83+ icon: "image://theme/search",
84+ actions: [{ id: "accept_id", label: "Accept"},
85+ { id: "reject_id", label: "Reject"}]
88+ type: Notification.SnapDecision,
89+ hints: {"x-canonical-private-button-tint": "true",
90+ "x-canonical-non-shaped-icon": "true"},
91+ summary: "Authentication error",
92+ body: "Please authorise Ubuntu to access your Google account.",
93+ icon: "image://theme/search",
94+ actions: [{ id: "settings_id", label: "Settings..."},
95+ { id: "cancel_id", label: "Cancel"}]
98+ type: Notification.SnapDecision,
99+ hints: {"x-canonical-private-button-tint": "true",
100+ "x-canonical-non-shaped-icon": "true"},
101+ summary: "Morning alarm",
102+ body: "It's 6:30... time to get up!",
103+ icon: "image://theme/search",
104+ actions: [{ id: "ok_reply", label: "Ok"},
105+ { id: "snooze_id", label: "Snooze"}]
108+ type: Notification.SnapDecision,
109+ hints: {"x-canonical-private-button-tint": "true"},
110+ summary: "Jenny Sample",
111+ body: "Hey there! Have you been watching the latest episode of that TV-show I told you about last week?",
112+ icon: "../graphics/avatars/amanda.png",
113+ secondaryIcon: "../graphics/applicationIcons/messages-app.png",
114+ actions: [{ id: "reply_id", label: "Reply"},
115+ { id: "ignore_id", label: "Ignore"}]
121+ function clearNotifications() {
122+ // remove all but the first (PlaceHolder) notification
123+ mockModel.remove(1, mockModel.count - 1)
126+ function removeTopMostNotification() {
127+ // leave real/first (PlaceHolder) notification untouched
128+ if (mockModel.count > 1)
133+ id: notificationsRect
136+ height: units.gu(71)
139+ id: clickThroughCatcher
141+ anchors.fill: parent
149+ anchors.fill: parent
155+ id: interactiveControls
158+ height: units.gu(81)
162+ spacing: units.gu(1)
163+ anchors.fill: parent
164+ anchors.margins: units.gu(1)
168+ text: "add some snap-decisions"
169+ onClicked: addSomeSnapDecisionNotifications()
174+ text: "remove top-most notification"
175+ onClicked: removeTopMostNotification()
181+ onClicked: clearNotifications()
188+ name: "VisualQueueTest"
191+ function test_VisualSnapDecisionsQueue() {
192+ // populate model with some mock notifications
193+ addSomeSnapDecisionNotifications();
195+ // make sure the view is properly updated before going on
196+ waitForRendering(notifications);
198+ var snap_decision = [findChild(notifications, "notification1"),
199+ findChild(notifications, "notification2"),
200+ findChild(notifications, "notification3"),
201+ findChild(notifications, "notification4"),
202+ findChild(notifications, "notification5")]
204+ for (var index = 0; index < snap_decision.length; index++) {
205+ verify(snap_decision[index] !== undefined, index + ". snap-decision wasn't found");
208+ // check initial states once all five snap-decisions were appended to the model
209+ compare(snap_decision[0].state, "expanded", "state of first snap-decision is not expanded");
210+ for (var index = 1; index < snap_decision.length; index++) {
211+ compare(snap_decision[index].state, "contracted", "state of "+ index + ".snap-decision is not contracted");
214+ // click/tap on each snap-decision and verify only one is in expanded-state at any time
215+ for (var index = 0; index < snap_decision.length; index++) {
216+ mouseClick(snap_decision[index], snap_decision[index].width / 2, snap_decision[index].height / 2)
217+ for (var kindex = 0; kindex < snap_decision.length; kindex++) {
218+ if (kindex == index) {
219+ compare(snap_decision[kindex].state, "expanded", "state of "+ kindex + ".snap-decision is not expanded");
221+ compare(snap_decision[kindex].state, "contracted", "state of "+ kindex + ".snap-decision is not contracted");
226+ // remove top-most and verify one of the remaining ones is still getting expanded
228+ // make first snap-decision expand
229+ mouseClick(snap_decision[0], snap_decision[0].width / 2, snap_decision[0].height / 2);
231+ for (var index = 1; index < snap_decision.length; index++) {
232+ removeTopMostNotification();
233+ compare(snap_decision[index].state, "expanded", "state of " + index + ". snap-decision is not expanded");