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/>.
20import "../../../qml/Notifications"
21import Ubuntu.Components 1.3
23import Unity.Notifications 1.0
32 function invokeAction(actionId) {
33 mockModel.actionInvoked(actionId)
41 signal actionInvoked(string actionId)
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: "../../tests/graphics/avatars/funky.png",
70 secondaryIcon: "../../tests/graphics/applicationIcons/dialer-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: "../../tests/graphics/avatars/amanda.png",
113 secondaryIcon: "../../tests/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
139 id: clickThroughCatcher
155 id: interactiveControls
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 notifications.forceLayout();
197 waitForRendering(notifications);
199 var snap_decision = [findChild(notifications, "notification1"),
200 findChild(notifications, "notification2"),
201 findChild(notifications, "notification3"),
202 findChild(notifications, "notification4"),
203 findChild(notifications, "notification5")]
205 for (var index = 0; index < snap_decision.length; index++) {
206 verify(snap_decision[index] !== undefined, index + ". snap-decision wasn't found");
209 // check initial states once all five snap-decisions were appended to the model
210 compare(snap_decision[0].state, "expanded", "state of first snap-decision is not expanded");
211 for (var index = 1; index < snap_decision.length; index++) {
212 compare(snap_decision[index].state, "contracted", "state of "+ index + ".snap-decision is not contracted");
215 // click/tap on each snap-decision and verify only one is in expanded-state at any time
216 for (var index = 0; index < snap_decision.length; index++) {
217 mouseClick(snap_decision[index])
218 for (var kindex = 0; kindex < snap_decision.length; kindex++) {
219 if (kindex == index) {
220 compare(snap_decision[kindex].state, "expanded", "state of "+ kindex + ".snap-decision is not expanded");
222 compare(snap_decision[kindex].state, "contracted", "state of "+ kindex + ".snap-decision is not contracted");
227 // remove top-most and verify one of the remaining ones is still getting expanded
229 // make first snap-decision expand
230 mouseClick(snap_decision[0]);
232 for (var index = 1; index < snap_decision.length; index++) {
233 removeTopMostNotification();
234 compare(snap_decision[index].state, "expanded", "state of " + index + ". snap-decision is not expanded");
keysesc to close
- j k
- move down, up
- enter
- open
- esc
- back, or up a level
- 1 2 3 4
- readme, files, commits, refs
- /
- filter
- y
- copy the clone command
- c
- compare the chosen commit with another (or shift-click both)
- ?
- show or hide this list