on xenial help sign in
Add test
64a7a7fAlbert Astals Cid
tests/qmltests/Dash/tst_CardCarousel.qml+24
@@ -70,6 +70,15 @@ Rectangle {
70
70
71 when: windowShown
71 when: windowShown
72
72
73+ function findScale(item) {
74+ var scale = 1;
75+ while (item) {
76+ scale = scale * item.scale;
77+ item = item.parent;
78+ }
79+ return scale;
80+ }
81+
73 function test_non_overlaid_header_layout() {
82 function test_non_overlaid_header_layout() {
74 // When the header is non overlaid
83 // When the header is non overlaid
75 // we grow down to accomodate the header but the y of the list is the same
84 // we grow down to accomodate the header but the y of the list is the same
@@ -83,5 +92,20 @@ Rectangle {
83 compare(listView.y, yPos);
92 compare(listView.y, yPos);
84 compare(cardCarousel.height, height + cTool.headerHeight);
93 compare(cardCarousel.height, height + cTool.headerHeight);
85 }
94 }
95+
96+ function test_item_fits_view_data() {
97+ return [
98+ {tag: "overlaid", template: overlaidTemplate},
99+ {tag: "nonOverlaid", template: nonOverlaidTemplate},
100+ ];
101+ }
102+
103+ function test_item_fits_view(data) {
104+ cTool.template = data.template;
105+ var delegate0 = findChild(cardCarousel, "carouselDelegate0");
106+ tryCompareFunction(function() { return delegate0.item != null; }, true);
107+ var scale = findScale(delegate0.item);
108+ verify(delegate0.item.implicitHeight * scale < cardCarousel.height);
109+ }
86 }
110 }
87}
111}