on xenial help sign in
Added test for clicked
commitc2f0f79c60a89748d1f4765577fcce82a4fa6b76 authorAndrea Cimitan <andrea.cimitan@gmail.com> dateFri 15 Jan 2016, 17:47 (11 years ago) parenta6678c0
1 file changed+31−4
tests/qmltests/Dash/tst_Card.qml+31−4
tests/qmltests/Dash/tst_Card.qml+31−4
@@ -206,6 +206,11 @@ Rectangle {
206206 }
207207 }
208208
209+ SignalSpy {
210+ id: signalSpy
211+ signalName: "clicked"
212+ }
213+
209214 UT.UnityTestCase {
210215 id: testCase
211216 name: "Card"
@@ -268,10 +273,10 @@ Rectangle {
268273 { tag: "Wide", width: units.gu(18), index: 0 },
269274 { tag: "Horizontal", width: units.gu(38), index: 5 },
270275 // Make sure card ends with header when there's no summary
271− { tag: "NoSummary", height: function() { var cardToolRow = findChild(cardTool, "socialAttributesRow");
272− return cardToolRow.y + cardToolRow.height + units.gu(1) }, index: 6 },
273− { tag: "HorizontalNoSummary", height: function() { var cardToolRow = findChild(cardTool, "socialAttributesRow");
274− return cardToolRow.y + cardToolRow.height + units.gu(1) },
276+ { tag: "NoSummary", height: function() { var socialAttributesRow = findChild(cardTool, "socialAttributesRow");
277+ return socialAttributesRow.y + socialAttributesRow.height + units.gu(1) }, index: 6 },
278+ { tag: "HorizontalNoSummary", height: function() { var socialAttributesRow = findChild(cardTool, "socialAttributesRow");
279+ return socialAttributesRow.y + socialAttributesRow.height + units.gu(1) },
275280 card_layout: "horizontal", index: 6 },
276281 ]
277282 }
@@ -621,5 +626,27 @@ Rectangle {
621626 verify((card.width - titleToCard.x - titleToCard.width) === units.gu(1));
622627 }
623628 }
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+ }
624651 }
625652}