on xenial help sign in
Make code of test tighter.
commitac4b82196c2342032b6248a6911fc13b3d0e7561 authorMirco Müller <mirco.mueller@ubuntu.com> dateFri 7 Feb 2014, 13:03 (13 years ago) parent27d3afb
1 file changed+28−69
tests/qmltests/Notifications/tst_VisualQueue.qml+28−69
tests/qmltests/Notifications/tst_VisualQueue.qml+28−69
@@ -262,87 +262,46 @@ Row {
262262 waitForRendering(notifications);
263263
264264 if (mockModel.count > 5) {
265− var snap_decision_1 = findChild(notifications, "notification1")
266− var snap_decision_2 = findChild(notifications, "notification2")
267− var snap_decision_3 = findChild(notifications, "notification3")
268− var snap_decision_4 = findChild(notifications, "notification4")
269− var snap_decision_5 = findChild(notifications, "notification5")
270−
271− verify(snap_decision_1 !== undefined, "first snap-decision wasn't found");
272− verify(snap_decision_2 !== undefined, "second snap-decision wasn't found");
273− verify(snap_decision_3 !== undefined, "third snap-decision wasn't found");
274− verify(snap_decision_4 !== undefined, "fourth snap-decision wasn't found");
275− verify(snap_decision_5 !== undefined, "fifth snap-decision wasn't found");
265+ var snap_decision = [findChild(notifications, "notification1"),
266+ findChild(notifications, "notification2"),
267+ findChild(notifications, "notification3"),
268+ findChild(notifications, "notification4"),
269+ findChild(notifications, "notification5")]
270+
271+ for (var index = 0; index < snap_decision.length; index++) {
272+ verify(snap_decision[index] !== undefined, index + ". snap-decision wasn't found");
273+ }
276274
277275 // check initial states once all five snap-decisions were appended to the model
278− compare(snap_decision_1.state, "expanded", "state of first snap-decision is not expanded")
279− compare(snap_decision_2.state, "contracted", "state of second snap-decision is not contracted")
280− compare(snap_decision_3.state, "contracted", "state of third snap-decision is not contracted")
281− compare(snap_decision_4.state, "contracted", "state of fourth snap-decision is not contracted")
282− compare(snap_decision_5.state, "contracted", "state of fifth snap-decision is not contracted")
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+ }
283280 }
284281
285282 // click/tap on each snap-decision and verify only one is in expanded-state at any time
286283 if (mockModel.count > 5) {
287− mouseClick(snap_decision_1, snap_decision_1.width / 2, snap_decision_1.height / 2)
288− compare(snap_decision_1.state, "expanded", "state of first snap-decision is not expanded")
289− compare(snap_decision_2.state, "contracted", "state of second snap-decision is not contracted")
290− compare(snap_decision_3.state, "contracted", "state of third snap-decision is not contracted")
291− compare(snap_decision_4.state, "contracted", "state of fourth snap-decision is not contracted")
292− compare(snap_decision_5.state, "contracted", "state of fifth snap-decision is not contracted")
293−
294− mouseClick(snap_decision_2, snap_decision_2.width / 2, snap_decision_2.height / 2)
295− compare(snap_decision_2.state, "expanded", "state of second snap-decision is not expanded")
296− compare(snap_decision_1.state, "contracted", "state of first snap-decision is not contracted")
297− compare(snap_decision_3.state, "contracted", "state of third snap-decision is not contracted")
298− compare(snap_decision_4.state, "contracted", "state of fourth snap-decision is not contracted")
299− compare(snap_decision_5.state, "contracted", "state of fifth snap-decision is not contracted")
300−
301− mouseClick(snap_decision_3, snap_decision_3.width / 2, snap_decision_3.height / 2)
302− compare(snap_decision_3.state, "expanded", "state of third snap-decision is not expanded")
303− compare(snap_decision_1.state, "contracted", "state of first snap-decision is not contracted")
304− compare(snap_decision_2.state, "contracted", "state of second snap-decision is not contracted")
305− compare(snap_decision_4.state, "contracted", "state of fourth snap-decision is not contracted")
306− compare(snap_decision_5.state, "contracted", "state of fifth snap-decision is not contracted")
307−
308− mouseClick(snap_decision_4, snap_decision_4.width / 2, snap_decision_4.height / 2)
309− compare(snap_decision_4.state, "expanded", "state of fourth snap-decision is not expanded")
310− compare(snap_decision_1.state, "contracted", "state of first snap-decision is not contracted")
311− compare(snap_decision_2.state, "contracted", "state of second snap-decision is not contracted")
312− compare(snap_decision_3.state, "contracted", "state of third snap-decision is not contracted")
313− compare(snap_decision_5.state, "contracted", "state of fourth snap-decision is not contracted")
314−
315− mouseClick(snap_decision_5, snap_decision_5.width / 2, snap_decision_5.height / 2)
316− compare(snap_decision_5.state, "expanded", "state of fifth snap-decision is not expanded")
317− compare(snap_decision_1.state, "contracted", "state of first snap-decision is not contracted")
318− compare(snap_decision_2.state, "contracted", "state of second snap-decision is not contracted")
319− compare(snap_decision_3.state, "contracted", "state of third snap-decision is not contracted")
320− compare(snap_decision_4.state, "contracted", "state of fourth snap-decision is not contracted")
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+ }
292+ }
293+ }
321294 }
322295
323296 // once all five snap-decisions are appended to the model remove top-most and verify one of the remaining ones is still getting expanded
324297 if (mockModel.count > 5) {
325298 // make first snap-decision expand
326− mouseClick(snap_decision_1, snap_decision_1.width / 2, snap_decision_1.height / 2)
327−
328− // remove it
329− removeTopMostNotification()
330− compare(snap_decision_2.state, "expanded", "state of second snap-decision is not expanded")
331−
332− // remove next
333− removeTopMostNotification()
334− compare(snap_decision_3.state, "expanded", "state of second snap-decision is not expanded")
335−
336− // remove next
337− removeTopMostNotification()
338− compare(snap_decision_4.state, "expanded", "state of second snap-decision is not expanded")
339−
340− // remove next
341− removeTopMostNotification()
342− compare(snap_decision_5.state, "expanded", "state of second snap-decision is not expanded")
299+ mouseClick(snap_decision[0], snap_decision[0].width / 2, snap_decision[0].height / 2);
343300
344− // remove last
345− removeTopMostNotification()
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+ }
346305 }
347306 }
348307 }