@@ -188,9 +188,8 @@ Row {
188188 name: "VisualQueueTest"
189189 when: windowShown
190190
191− function test_VisualSnapDecisionsQueue_data() {
192− return [
193− {
191+ function fillMockModel () {
192+ var n = {
194193 tag: "Snap Decision 1",
195194 type: Notification.SnapDecision,
196195 hints: {"x-canonical-private-button-tint": "true"},
@@ -203,8 +202,10 @@ Row {
203202 { id: "decline_2_id", label: "Can't talk now, what's up?"},
204203 { id: "decline_3_id", label: "I call you back."},
205204 { id: "decline_4_id", label: "Send custom message..."}]
206− },
207− {
205+ }
206+ mockModel.append(n)
207+
208+ n = {
208209 tag: "Snap Decision 2",
209210 type: Notification.SnapDecision,
210211 hints: {"x-canonical-private-button-tint": "true",
@@ -215,8 +216,10 @@ Row {
215216 secondaryIcon: "",
216217 actions: [{ id: "accept_id", label: "Accept"},
217218 { id: "reject_id", label: "Reject"}]
218− },
219− {
219+ }
220+ mockModel.append(n)
221+
222+ n = {
220223 tag: "Snap Decision 3",
221224 type: Notification.SnapDecision,
222225 hints: {"x-canonical-private-button-tint": "true",
@@ -227,8 +230,10 @@ Row {
227230 secondaryIcon: "",
228231 actions: [{ id: "settings_id", label: "Settings..."},
229232 { id: "cancel_id", label: "Cancel"}]
230− },
231− {
233+ }
234+ mockModel.append(n)
235+
236+ n = {
232237 tag: "Snap Decision 4",
233238 type: Notification.SnapDecision,
234239 hints: {"x-canonical-private-button-tint": "true",
@@ -239,8 +244,10 @@ Row {
239244 secondaryIcon: "",
240245 actions: [{ id: "ok_reply", label: "Ok"},
241246 { id: "snooze_id", label: "Snooze"}]
242− },
243− {
247+ }
248+ mockModel.append(n)
249+
250+ n = {
244251 tag: "Snap Decision 5",
245252 type: Notification.SnapDecision,
246253 hints: {"x-canonical-private-button-tint": "true"},
@@ -251,57 +258,52 @@ Row {
251258 actions: [{ id: "reply_id", label: "Reply"},
252259 { id: "ignore_id", label: "Ignore"}]
253260 }
254− ]
261+ mockModel.append(n)
255262 }
256263
257− function test_VisualSnapDecisionsQueue(data) {
264+ function test_VisualSnapDecisionsQueue() {
258265 // populate model with some mock notifications
259− mockModel.append(data)
266+ fillMockModel();
260267
261268 // make sure the view is properly updated before going on
262269 waitForRendering(notifications);
263270
264− if (mockModel.count > 5) {
265− var snap_decision = [findChild(notifications, "notification1"),
266− findChild(notifications, "notification2"),
267− findChild(notifications, "notification3"),
268− findChild(notifications, "notification4"),
269− findChild(notifications, "notification5")]
271+ var snap_decision = [findChild(notifications, "notification1"),
272+ findChild(notifications, "notification2"),
273+ findChild(notifications, "notification3"),
274+ findChild(notifications, "notification4"),
275+ findChild(notifications, "notification5")]
270276
271− for (var index = 0; index < snap_decision.length; index++) {
272− verify(snap_decision[index] !== undefined, index + ". snap-decision wasn't found");
273− }
277+ for (var index = 0; index < snap_decision.length; index++) {
278+ verify(snap_decision[index] !== undefined, index + ". snap-decision wasn't found");
279+ }
274280
275− // 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");
277− for (var index = 1; index < snap_decision.length; index++) {
278− compare(snap_decision[index].state, "contracted", "state of "+ index + ".snap-decision is not contracted");
279− }
281+ // check initial states once all five snap-decisions were appended to the model
282+ compare(snap_decision[0].state, "expanded", "state of first snap-decision is not expanded");
283+ for (var index = 1; index < snap_decision.length; index++) {
284+ compare(snap_decision[index].state, "contracted", "state of "+ index + ".snap-decision is not contracted");
280285 }
281286
282287 // 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++) {
285− mouseClick(snap_decision[index], snap_decision[index].width / 2, snap_decision[index].height / 2)
286− for (var kindex = 0; kindex < snap_decision.length; kindex++) {
287− if (kindex == index) {
288− compare(snap_decision[kindex].state, "expanded", "state of "+ kindex + ".snap-decision is not expanded");
289− } else {
290− compare(snap_decision[kindex].state, "contracted", "state of "+ kindex + ".snap-decision is not contracted");
291− }
288+ for (var index = 0; index < snap_decision.length; index++) {
289+ mouseClick(snap_decision[index], snap_decision[index].width / 2, snap_decision[index].height / 2)
290+ for (var kindex = 0; kindex < snap_decision.length; kindex++) {
291+ if (kindex == index) {
292+ compare(snap_decision[kindex].state, "expanded", "state of "+ kindex + ".snap-decision is not expanded");
293+ } else {
294+ compare(snap_decision[kindex].state, "contracted", "state of "+ kindex + ".snap-decision is not contracted");
292295 }
293296 }
294297 }
295298
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
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);
299+ // remove top-most and verify one of the remaining ones is still getting expanded
300300
301− for (var index = 1; index < snap_decision.length; index++) {
302− removeTopMostNotification();
303− compare(snap_decision[index].state, "expanded", "state of " + index + ". snap-decision is not expanded");
304− }
301+ // make first snap-decision expand
302+ mouseClick(snap_decision[0], snap_decision[0].width / 2, snap_decision[0].height / 2);
303+
304+ for (var index = 1; index < snap_decision.length; index++) {
305+ removeTopMostNotification();
306+ compare(snap_decision[index].state, "expanded", "state of " + index + ". snap-decision is not expanded");
305307 }
306308 }
307309 }