@@ -188,9 +188,8 @@ Row {
188 name: "VisualQueueTest"
188 name: "VisualQueueTest"
189 when: windowShown
189 when: windowShown
191− function test_VisualSnapDecisionsQueue_data() {
191+ function fillMockModel () {
192− return [
192+ var n = {
194 tag: "Snap Decision 1",
193 tag: "Snap Decision 1",
195 type: Notification.SnapDecision,
194 type: Notification.SnapDecision,
196 hints: {"x-canonical-private-button-tint": "true"},
195 hints: {"x-canonical-private-button-tint": "true"},
@@ -203,8 +202,10 @@ Row {
203 { id: "decline_2_id", label: "Can't talk now, what's up?"},
202 { id: "decline_2_id", label: "Can't talk now, what's up?"},
204 { id: "decline_3_id", label: "I call you back."},
203 { id: "decline_3_id", label: "I call you back."},
205 { id: "decline_4_id", label: "Send custom message..."}]
204 { id: "decline_4_id", label: "Send custom message..."}]
208 tag: "Snap Decision 2",
209 tag: "Snap Decision 2",
209 type: Notification.SnapDecision,
210 type: Notification.SnapDecision,
210 hints: {"x-canonical-private-button-tint": "true",
211 hints: {"x-canonical-private-button-tint": "true",
@@ -215,8 +216,10 @@ Row {
215 secondaryIcon: "",
216 secondaryIcon: "",
216 actions: [{ id: "accept_id", label: "Accept"},
217 actions: [{ id: "accept_id", label: "Accept"},
217 { id: "reject_id", label: "Reject"}]
218 { id: "reject_id", label: "Reject"}]
220 tag: "Snap Decision 3",
223 tag: "Snap Decision 3",
221 type: Notification.SnapDecision,
224 type: Notification.SnapDecision,
222 hints: {"x-canonical-private-button-tint": "true",
225 hints: {"x-canonical-private-button-tint": "true",
@@ -227,8 +230,10 @@ Row {
227 secondaryIcon: "",
230 secondaryIcon: "",
228 actions: [{ id: "settings_id", label: "Settings..."},
231 actions: [{ id: "settings_id", label: "Settings..."},
229 { id: "cancel_id", label: "Cancel"}]
232 { id: "cancel_id", label: "Cancel"}]
232 tag: "Snap Decision 4",
237 tag: "Snap Decision 4",
233 type: Notification.SnapDecision,
238 type: Notification.SnapDecision,
234 hints: {"x-canonical-private-button-tint": "true",
239 hints: {"x-canonical-private-button-tint": "true",
@@ -239,8 +244,10 @@ Row {
239 secondaryIcon: "",
244 secondaryIcon: "",
240 actions: [{ id: "ok_reply", label: "Ok"},
245 actions: [{ id: "ok_reply", label: "Ok"},
241 { id: "snooze_id", label: "Snooze"}]
246 { id: "snooze_id", label: "Snooze"}]
244 tag: "Snap Decision 5",
251 tag: "Snap Decision 5",
245 type: Notification.SnapDecision,
252 type: Notification.SnapDecision,
246 hints: {"x-canonical-private-button-tint": "true"},
253 hints: {"x-canonical-private-button-tint": "true"},
@@ -251,57 +258,52 @@ Row {
251 actions: [{ id: "reply_id", label: "Reply"},
258 actions: [{ id: "reply_id", label: "Reply"},
252 { id: "ignore_id", label: "Ignore"}]
259 { id: "ignore_id", label: "Ignore"}]
254− ]
261+ mockModel.append(n)
257− function test_VisualSnapDecisionsQueue(data) {
264+ function test_VisualSnapDecisionsQueue() {
258 // populate model with some mock notifications
265 // populate model with some mock notifications
259− mockModel.append(data)
266+ fillMockModel();
261 // make sure the view is properly updated before going on
268 // make sure the view is properly updated before going on
262 waitForRendering(notifications);
269 waitForRendering(notifications);
264− if (mockModel.count > 5) {
265− var snap_decision = [findChild(notifications, "notification1"),
271+ var snap_decision = [findChild(notifications, "notification1"),
266− findChild(notifications, "notification2"),
272+ findChild(notifications, "notification2"),
267− findChild(notifications, "notification3"),
273+ findChild(notifications, "notification3"),
268− findChild(notifications, "notification4"),
274+ findChild(notifications, "notification4"),
269− findChild(notifications, "notification5")]
275+ findChild(notifications, "notification5")]
271− for (var index = 0; index < snap_decision.length; index++) {
277+ for (var index = 0; index < snap_decision.length; index++) {
272− verify(snap_decision[index] !== undefined, index + ". snap-decision wasn't found");
278+ verify(snap_decision[index] !== undefined, index + ". snap-decision wasn't found");
275− // check initial states once all five snap-decisions were appended to the model
281+ // check initial states once all five snap-decisions were appended to the model
276− compare(snap_decision[0].state, "expanded", "state of first snap-decision is not expanded");
282+ compare(snap_decision[0].state, "expanded", "state of first snap-decision is not expanded");
277− for (var index = 1; index < snap_decision.length; index++) {
283+ for (var index = 1; index < snap_decision.length; index++) {
278− compare(snap_decision[index].state, "contracted", "state of "+ index + ".snap-decision is not contracted");
284+ compare(snap_decision[index].state, "contracted", "state of "+ index + ".snap-decision is not contracted");
282 // click/tap on each snap-decision and verify only one is in expanded-state at any time
287 // click/tap on each snap-decision and verify only one is in expanded-state at any time
283− if (mockModel.count > 5) {
284− for (var index = 0; index < snap_decision.length; index++) {
288+ for (var index = 0; index < snap_decision.length; index++) {
285− mouseClick(snap_decision[index], snap_decision[index].width / 2, snap_decision[index].height / 2)
289+ mouseClick(snap_decision[index], snap_decision[index].width / 2, snap_decision[index].height / 2)
286− for (var kindex = 0; kindex < snap_decision.length; kindex++) {
290+ for (var kindex = 0; kindex < snap_decision.length; kindex++) {
287− if (kindex == index) {
291+ if (kindex == index) {
288− compare(snap_decision[kindex].state, "expanded", "state of "+ kindex + ".snap-decision is not expanded");
292+ compare(snap_decision[kindex].state, "expanded", "state of "+ kindex + ".snap-decision is not expanded");
289− } else {
293+ } else {
290− compare(snap_decision[kindex].state, "contracted", "state of "+ kindex + ".snap-decision is not contracted");
294+ compare(snap_decision[kindex].state, "contracted", "state of "+ kindex + ".snap-decision is not contracted");
296− // once all five snap-decisions are appended to the model remove top-most and verify one of the remaining ones is still getting expanded
299+ // remove top-most and verify one of the remaining ones is still getting expanded
297− if (mockModel.count > 5) {
298− // make first snap-decision expand
299− mouseClick(snap_decision[0], snap_decision[0].width / 2, snap_decision[0].height / 2);
301+ // make first snap-decision expand
302+ mouseClick(snap_decision[0], snap_decision[0].width / 2, snap_decision[0].height / 2);
301− for (var index = 1; index < snap_decision.length; index++) {
304+ for (var index = 1; index < snap_decision.length; index++) {
302− removeTopMostNotification();
305+ removeTopMostNotification();
303− compare(snap_decision[index].state, "expanded", "state of " + index + ". snap-decision is not expanded");
306+ compare(snap_decision[index].state, "expanded", "state of " + index + ". snap-decision is not expanded");