on xenial help sign in
Add tests for CardTool.
7b9114bMichał Sawicz
tests/qmltests/Dash/tst_CardTool.qml+17−6
@@ -84,6 +84,10 @@ Rectangle {
84 "name": "Art, header, summary - large",
84 "name": "Art, header, summary - large",
85 "layout": { "template": { "card-size": "large" }, "components": JSON.parse(fullMapping) }
85 "layout": { "template": { "card-size": "large" }, "components": JSON.parse(fullMapping) }
86 },
86 },
87+ {
88+ "name": "Art, header, summary - horizontal",
89+ "layout": { "template": { "card-layout": "horizontal" }, "components": JSON.parse(fullMapping) }
90+ },
87 {
91 {
88 "name": "Header title only",
92 "name": "Header title only",
89 "layout": { "components": { "title": "title" } }
93 "layout": { "components": { "title": "title" } }
@@ -126,6 +130,7 @@ Rectangle {
126 }
130 }
127
131
128 Card {
132 Card {
133+ id: card
129 template: cardTool.template;
134 template: cardTool.template;
130 components: cardTool.components;
135 components: cardTool.components;
131 cardData: Helpers.mapData(dataArea.text, components, dataError)
136 cardData: Helpers.mapData(dataArea.text, components, dataError)
@@ -244,12 +249,14 @@ Rectangle {
244
249
245 function test_card_size_data() {
250 function test_card_size_data() {
246 return [
251 return [
247− { tag: "Medium", width: units.gu(18.5), height: undefined, index: 0 },
252+ { tag: "Medium", width: units.gu(18.5), height: function() { return card.height }, index: 0 },
248− { tag: "Small", width: units.gu(12), height: undefined, index: 1 },
253+ { tag: "Small", width: units.gu(12), height: function() { return card.height }, index: 1 },
249− { tag: "Large", width: units.gu(38), height: undefined, index: 2 },
254+ { tag: "Large", width: units.gu(38), height: function() { return card.height }, index: 2 },
250− { tag: "Horizontal", width: units.gu(38), height: undefined, index: 3 },
255+ { tag: "Horizontal", width: units.gu(38), height: function() { return card.height }, index: 3 },
256+ { tag: "OrganicGrid", width: undefined, height: undefined, index: 0, layout_index: 1},
251 { tag: "Journal", width: undefined, height: units.gu(20), size: 20, index: 0, layout_index: 2 },
257 { tag: "Journal", width: undefined, height: units.gu(20), size: 20, index: 0, layout_index: 2 },
252 { tag: "OversizedJournal", width: undefined, height: units.gu(18.5), size: 40, index: 0, layout_index: 2 },
258 { tag: "OversizedJournal", width: undefined, height: units.gu(18.5), size: 40, index: 0, layout_index: 2 },
259+ { tag: "VerticalJournal", width: units.gu(18.5), height: undefined, index: 0, layout_index: 3 },
253 ]
260 ]
254 }
261 }
255
262
@@ -265,11 +272,15 @@ Rectangle {
265 }
272 }
266
273
267 if (data.hasOwnProperty("width")) {
274 if (data.hasOwnProperty("width")) {
275+ if (typeof data.width === "function") {
276+ tryCompareFunction(function() { return cardTool.cardWidth === data.width() }, true);
268− tryCompare(cardTool, "cardWidth", data.width);
277+ } else tryCompare(cardTool, "cardWidth", data.width);
269 }
278 }
270
279
271 if (data.hasOwnProperty("height")) {
280 if (data.hasOwnProperty("height")) {
281+ if (typeof data.height === "function") {
282+ tryCompareFunction(function() { return cardTool.cardHeight === data.height() }, true);
272− tryCompare(cardTool, "cardHeight", data.height);
283+ } else tryCompare(cardTool, "cardHeight", data.height);
273 }
284 }
274 }
285 }
275 }
286 }