on xenial help sign in
Added test for clicked
c2f0f79Andrea Cimitan
tests/qmltests/Dash/tst_Card.qml+31−4
@@ -206,6 +206,11 @@ Rectangle {
206 }
206 }
207 }
207 }
208
208
209+ SignalSpy {
210+ id: signalSpy
211+ signalName: "clicked"
212+ }
213+
209 UT.UnityTestCase {
214 UT.UnityTestCase {
210 id: testCase
215 id: testCase
211 name: "Card"
216 name: "Card"
@@ -268,10 +273,10 @@ Rectangle {
268 { tag: "Wide", width: units.gu(18), index: 0 },
273 { tag: "Wide", width: units.gu(18), index: 0 },
269 { tag: "Horizontal", width: units.gu(38), index: 5 },
274 { tag: "Horizontal", width: units.gu(38), index: 5 },
270 // Make sure card ends with header when there's no summary
275 // Make sure card ends with header when there's no summary
271− { tag: "NoSummary", height: function() { var cardToolRow = findChild(cardTool, "socialAttributesRow");
276+ { tag: "NoSummary", height: function() { var socialAttributesRow = findChild(cardTool, "socialAttributesRow");
272− return cardToolRow.y + cardToolRow.height + units.gu(1) }, index: 6 },
277+ return socialAttributesRow.y + socialAttributesRow.height + units.gu(1) }, index: 6 },
273− { tag: "HorizontalNoSummary", height: function() { var cardToolRow = findChild(cardTool, "socialAttributesRow");
278+ { tag: "HorizontalNoSummary", height: function() { var socialAttributesRow = findChild(cardTool, "socialAttributesRow");
274− return cardToolRow.y + cardToolRow.height + units.gu(1) },
279+ return socialAttributesRow.y + socialAttributesRow.height + units.gu(1) },
275 card_layout: "horizontal", index: 6 },
280 card_layout: "horizontal", index: 6 },
276 ]
281 ]
277 }
282 }
@@ -621,5 +626,27 @@ Rectangle {
621 verify((card.width - titleToCard.x - titleToCard.width) === units.gu(1));
626 verify((card.width - titleToCard.x - titleToCard.width) === units.gu(1));
622 }
627 }
623 }
628 }
629+
630+ function test_clicked() {
631+ selector.selectedIndex = 0;
632+ waitForRendering(card);
633+
634+ signalSpy.target = card;
635+ var socialAttributesRow = findChild(card, "socialAttributesRow");
636+ var delegate0 = findChild(socialAttributesRow, "delegate0");
637+ var icon0 = findChild(delegate0, "icon");
638+ var delegate1 = findChild(socialAttributesRow, "delegate1");
639+ var icon1 = findChild(delegate1, "icon");
640+
641+ compare(icon0.source, "image://theme/ok");
642+ mouseClick(delegate0, delegate0.height / 2, delegate0.height / 2);
643+ tryCompare(signalSpy, "count", 1);
644+ compare(icon0.source, "image://theme/undo");
645+
646+ compare(icon1.source, "image://theme/cancel");
647+ mouseClick(delegate1, delegate1.height / 2, delegate1.height / 2);
648+ tryCompare(signalSpy, "count", 2);
649+ compare(icon1.source, "image://theme/cancel");
650+ }
624 }
651 }
625}
652}