71
36
"summary": "Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum."
74
property string fullMapping: '
78
"subtitle": "subtitle",
83
39
property var cardsModel: [
85
"name": "Art, header, summary - vertical",
86
"layout": { "components": JSON.parse(fullMapping) }
89
"name": "Art, header, summary - vertical, small",
90
"layout": { "template": { "card-size": "small" }, "components": JSON.parse(fullMapping) }
93
"name": "Art, header, summary - vertical, large",
94
"layout": { "template": { "card-size": "large" }, "components": JSON.parse(fullMapping) }
97
"name": "Art, header, summary - vertical, wide",
98
"layout": { "components": Helpers.update(JSON.parse(root.fullMapping), { "art": { "aspect-ratio": 2 } }) }
101
"name": "Art, title - vertical, fitted",
102
"layout": { "components": Helpers.update(JSON.parse(root.fullMapping), { "art": { "fill-mode": "fit" } }) }
41
"name": "Art, header, summary",
42
"layout": { "components": JSON.parse(Helpers.fullMapping) }
45
"name": "Art, header, summary - small",
46
"layout": { "template": { "card-size": "small" }, "components": JSON.parse(Helpers.fullMapping) }
49
"name": "Art, header, summary - large",
50
"layout": { "template": { "card-size": "large" }, "components": JSON.parse(Helpers.fullMapping) }
53
"name": "Art, header, summary - wide",
54
"layout": { "components": Helpers.update(JSON.parse(Helpers.fullMapping), { "art": { "aspect-ratio": 2 } }) }
57
"name": "Art, title - fitted",
58
"layout": { "components": Helpers.update(JSON.parse(Helpers.fullMapping), { "art": { "fill-mode": "fit" } }) }
105
61
"name": "Art, header, summary - horizontal",
106
62
"layout": { "template": { "card-layout": "horizontal" },
107
"components": JSON.parse(fullMapping) }
110
"name": "Art, header - vertical",
111
"layout": { "components": Helpers.update(JSON.parse(root.fullMapping), { "summary": undefined }) }
114
"name": "Header title only - horizontal",
115
"layout": { "template": { "card-layout": "horizontal" },
116
"components": { "title": "title" } }
63
"components": JSON.parse(Helpers.fullMapping) }
66
"name": "Art, header",
67
"layout": { "components": Helpers.update(JSON.parse(Helpers.fullMapping), { "summary": undefined }) }
70
"name": "Art, summary",
71
"layout": { "components": { "art": "art", "summary": "summary" } }
74
"name": "Header title only",
75
"layout": { "components": { "title": "title" } }
78
"name": "Art, header, summary - overlaid",
79
"layout": { "template": { "overlay": true },
80
"components": JSON.parse(Helpers.fullMapping) }
83
"name": "Art, header - grey background",
84
"layout": { "template": { "card-background": { "type": "color", "elements": ["grey"] } },
85
"components": JSON.parse(Helpers.fullMapping) }
88
"name": "Art, header - gradient background",
89
"layout": { "template": { "card-background": { "type": "gradient", "elements": ["grey", "white"] } },
90
"components": JSON.parse(Helpers.fullMapping) }
93
"name": "Art, header - image background",
94
"layout": { "template": { "card-background": Qt.resolvedUrl("artwork/checkers.png") },
95
"components": JSON.parse(Helpers.fullMapping) }
101
template: card.template
102
components: card.components
103
viewWidth: units.gu(48)
122
108
anchors { top: parent.top; left: parent.left; margins: units.gu(1) }
124
template: Helpers.update(JSON.parse(root.defaultLayout), Helpers.tryParse(layoutArea.text, layoutError))['template'];
125
components: Helpers.update(JSON.parse(root.defaultLayout), Helpers.tryParse(layoutArea.text, layoutError))['components'];
110
width: cardTool.cardWidth || implicitWidth
111
height: cardTool.cardHeight || implicitHeight
113
template: Helpers.update(JSON.parse(Helpers.defaultLayout), Helpers.tryParse(layoutArea.text, layoutError))['template'];
114
components: Helpers.update(JSON.parse(Helpers.defaultLayout), Helpers.tryParse(layoutArea.text, layoutError))['components'];
126
115
cardData: Helpers.mapData(dataArea.text, components, dataError)
193
182
when: windowShown
195
184
property Item header: findChild(card, "cardHeader")
185
property Item title: findChild(header, "titleLabel")
196
186
property Item art: findChild(card, "artShape")
197
187
property Item artImage: findChild(card, "artImage")
198
188
property Item summary: findChild(card, "summaryLabel")
189
property Item background: findChild(card, "background")
190
property Item backgroundImage: findChild(card, "backgroundImage")
200
192
function initTestCase() {
201
193
verify(typeof testCase.header === "object", "Couldn't find header object.");
202
194
verify(typeof testCase.art === "object", "Couldn't find art object.");
203
195
verify(typeof testCase.artImage === "object", "Couldn't find artImage object.");
204
196
verify(typeof testCase.summary === "object", "Couldn't find summary object.");
197
verify(typeof testCase.artImage === "object", "Couldn't find background object.");
198
verify(typeof testCase.summary === "object", "Couldn't find backgroundImage object.");
207
201
function cleanup() {
245
239
function test_card_size_data() {
247
241
{ tag: "Medium", width: units.gu(18.5), index: 0 },
248
{ tag: "Small", width: units.gu(12), size: "small", index: 0 },
249
{ tag: "Large", width: units.gu(38), size: "large", index: 0 },
242
{ tag: "Small", width: units.gu(12), index: 1 },
243
{ tag: "Large", width: units.gu(38), index: 2 },
250
244
{ tag: "Wide", width: units.gu(18.5), aspect: 0.5, index: 0 },
251
245
{ tag: "Horizontal", width: units.gu(38), index: 5 },
252
246
// Make sure card ends with header when there's no summary
356
353
tryCompareFunction(function() { return testCase.header.x === data.left() }, true);
356
function test_summary_layout_data() {
358
{ tag: "With header", top: function() { return header.y + header.height }, index: 0 },
359
{ tag: "Without header", top: function() { return art.y + art.height }, index: 7 },
363
function test_summary_layout(data) {
364
selector.selectedIndex = data.index;
366
tryCompareFunction(function() { return testCase.summary.y === data.top() }, true);
359
369
function test_art_visibility() {
360
selector.selectedIndex = 7
362
tryCompare(testCase.artImage, "source", "")
363
compare(testCase.art.visible, false)
364
compare(testCase.art.height, 0)
365
compare(testCase.art.width, 0)
370
selector.selectedIndex = 8;
372
tryCompare(testCase.artImage, "source", "");
373
compare(testCase.art.visible, false);
374
compare(testCase.art.height, 0);
375
compare(testCase.art.width, 0);
378
function test_background_data() {
380
{ tag: "Art and summary", visible: true, color: "#ffffff", index: 0 },
381
{ tag: "No Summary", visible: false, index: 6 },
382
{ tag: "Horizontal", visible: false, index: 5 },
383
{ tag: "Grey background", visible: true, color: "#808080", index: 10 },
384
{ tag: "Overriden Gradient background", visible: true, color: "#808080", gradientColor: "#ffffff",
385
background: {type: "color", elements: ["grey", "white"]}, index: 10 },
386
{ tag: "Overriden Image background", visible: true, image: Qt.resolvedUrl("artwork/checkers.png"),
387
background: Qt.resolvedUrl("artwork/checkers.png"), index: 10 },
388
{ tag: "Gradient background", visible: true, color: "#808080", gradientColor: "#ffffff", index: 11 },
389
{ tag: "Image background", visible: true, image: Qt.resolvedUrl("artwork/checkers.png"), index: 12 },
393
function test_background(data) {
394
selector.selectedIndex = data.index;
396
if (data.hasOwnProperty("background")) {
397
card.cardData["background"] = data.background;
398
card.cardDataChanged();
401
waitForRendering(card);
403
tryCompare(background, "visible", data.visible);
405
if (data.hasOwnProperty("color")) {
406
tryCompare(background, "color", data.color);
409
if (data.hasOwnProperty("gradientColor")) {
410
tryCompare(background, "gradientColor", data.gradientColor);
413
if (data.hasOwnProperty("image")) {
414
tryCompare(backgroundImage, "source", data.image);
418
function test_font_weights_data() {
420
{ tag: "Title only", index: 8, weight: Font.Normal },
421
{ tag: "Title, subtitle", index: 0, weight: Font.DemiBold },
425
function test_font_weights(data) {
426
selector.selectedIndex = data.index;
428
tryCompare(testCase.title.font, "weight", data.weight);