on xenial help sign in
Fix right padding on overlay card

Approved by: Michael Zanetti, PS Jenkins bot

commit3f36d307a0c57769c40a51097bb283690bdb1974 authorAndrea Cimitan <andrea.cimitan@gmail.com> dateWed 27 Aug 2014, 15:34 (12 years ago) parentbd21e657ea7850
3 files changed+66−1
plugins/Dash/CardCreator.js+2 tests/plugins/Dash/cardcreator/5.res+2 tests/qmltests/Dash/tst_Card.qml+62−1
plugins/Dash/CardCreator.js+2
@@ -467,6 +467,8 @@ function cardString(template, components) {
467467 if (!touchdownOnArtShape) {
468468 extraRightAnchor = 'rightMargin: units.gu(1); \n';
469469 extraLeftAnchor = 'leftMargin: units.gu(1); \n';
470+ } else if (headerAsOverlay && !hasEmblem) {
471+ extraRightAnchor = 'rightMargin: units.gu(1); \n';
470472 }
471473
472474 if (hasMascot) {
tests/plugins/Dash/cardcreator/5.res+2
@@ -103,6 +103,7 @@ Label {
103103 id: titleLabel;
104104 objectName: "titleLabel";
105105 anchors { right: parent.right;
106+ rightMargin: units.gu(1);
106107 left: parent.left;
107108 leftMargin: units.gu(1);
108109 top: overlayLoader.top;
@@ -124,6 +125,7 @@ Label {
124125 objectName: "subtitleLabel";
125126 anchors { left: titleLabel.left;
126127 leftMargin: titleLabel.leftMargin;
128+ rightMargin: units.gu(1);
127129 right: titleLabel.right;
128130 top: titleLabel.bottom;
129131 }
tests/qmltests/Dash/tst_Card.qml+62−1
@@ -96,6 +96,11 @@ Rectangle {
9696 "layout": { "template": { "card-background": Qt.resolvedUrl("artwork/checkers.png") },
9797 "components": JSON.parse(Helpers.fullMapping) }
9898 },
99+ {
100+ "name": "Art, title - overlaid",
101+ "layout": { "template": { "overlay": true },
102+ "components": { "art": "art", "title": "title" } }
103+ },
99104 ]
100105
101106 CardTool {
@@ -217,6 +222,7 @@ Rectangle {
217222
218223 function test_card_binding(data) {
219224 selector.selectedIndex = data.index;
225+ waitForRendering(selector);
220226 waitForRendering(card);
221227
222228 tryCompareFunction(function() { return testCase[data.object] !== null }, true);
@@ -247,6 +253,8 @@ Rectangle {
247253
248254 function test_card_size(data) {
249255 selector.selectedIndex = data.index;
256+ waitForRendering(selector);
257+ waitForRendering(card);
250258
251259 if (data.hasOwnProperty("card_layout")) {
252260 cardTool.template['card-layout'] = data.card_layout;
@@ -279,6 +287,7 @@ Rectangle {
279287
280288 function test_art_size(data) {
281289 selector.selectedIndex = data.index;
290+ waitForRendering(selector);
282291 if (data.hasOwnProperty("size")) {
283292 cardTool.template['card-size'] = data.size;
284293 cardTool.templateChanged();
@@ -310,6 +319,7 @@ Rectangle {
310319
311320 function test_art_shape_fixed_size() {
312321 selector.selectedIndex = 6;
322+ waitForRendering(selector);
313323 card.fixedArtShapeSize = Qt.size( units.gu(8), units.gu(4) );
314324 waitForRendering(card);
315325 tryCompare(art, "width", units.gu(8));
@@ -326,6 +336,7 @@ Rectangle {
326336
327337 function test_art_layout(data) {
328338 selector.selectedIndex = data.index;
339+ waitForRendering(selector);
329340 waitForRendering(card);
330341
331342 tryCompare(headerRow, "x", data.left());
@@ -344,6 +355,7 @@ Rectangle {
344355
345356 function test_header_layout(data) {
346357 selector.selectedIndex = data.index;
358+ waitForRendering(selector);
347359 waitForRendering(card);
348360
349361 tryCompareFunction(function() { return testCase.headerRow.y === data.top() }, true);
@@ -359,7 +371,7 @@ Rectangle {
359371
360372 function test_summary_layout(data) {
361373 selector.selectedIndex = data.index;
362−
374+ waitForRendering(selector);
363375 waitForRendering(card);
364376
365377 tryCompareFunction(function() { return art.height > 0 && testCase.summary.y === data.top() }, true);
@@ -367,6 +379,8 @@ Rectangle {
367379
368380 function test_art_visibility() {
369381 selector.selectedIndex = 8;
382+ waitForRendering(selector);
383+ waitForRendering(card);
370384
371385 compare(testCase.artImage, null);
372386 compare(testCase.art, null);
@@ -389,6 +403,7 @@ Rectangle {
389403
390404 function test_background(data) {
391405 selector.selectedIndex = data.index;
406+ waitForRendering(selector);
392407
393408 if (data.hasOwnProperty("background")) {
394409 card.cardData["background"] = data.background;
@@ -425,6 +440,8 @@ Rectangle {
425440
426441 function test_font_weights(data) {
427442 selector.selectedIndex = data.index;
443+ waitForRendering(selector);
444+ waitForRendering(card);
428445
429446 tryCompare(testCase.title.font, "weight", data.weight);
430447 }
@@ -448,6 +465,7 @@ Rectangle {
448465
449466 function test_fontColor(data) {
450467 selector.selectedIndex = 10;
468+ waitForRendering(selector);
451469 waitForRendering(card);
452470
453471 background.color = data.tag;
@@ -470,6 +488,7 @@ Rectangle {
470488
471489 function test_emblemIcon(data) {
472490 selector.selectedIndex = data.index;
491+ waitForRendering(selector);
473492 waitForRendering(card);
474493
475494 var emblemIcon = findChild(card, "emblemIcon");
@@ -486,6 +505,7 @@ Rectangle {
486505
487506 function test_mascotShape(data) {
488507 selector.selectedIndex = data.index;
508+ waitForRendering(selector);
489509 waitForRendering(card);
490510
491511 var shape = findChild(card, "mascotShapeLoader");
@@ -496,6 +516,8 @@ Rectangle {
496516
497517 function test_touchdown_visibility() {
498518 selector.selectedIndex = 0;
519+ waitForRendering(selector);
520+ waitForRendering(card);
499521
500522 var touchdown = findChild(card, "touchdown");
501523
@@ -505,5 +527,44 @@ Rectangle {
505527 mouseRelease(card, card.width/2, card.height/2);
506528 compare(touchdown.visible, false);
507529 }
530+
531+ function test_paddings_data() {
532+ return [
533+ { tag: "Art and summary", index: 0 },
534+ { tag: "No Summary", index: 6 },
535+ { tag: "No header", index: 7 },
536+ { tag: "Header only", index: 8 },
537+ { tag: "Art, header, summary - overlaid", index: 9 },
538+ { tag: "Art, title - overlaid", index: 13 },
539+ ];
540+ }
541+
542+ function test_paddings(data) {
543+ selector.selectedIndex = data.index;
544+ waitForRendering(selector);
545+ waitForRendering(card);
546+
547+ if (title) var titleToCard = title.mapToItem(card, 0, 0, title.width, title.height);
548+
549+ // left margin
550+ if (mascotImage) {
551+ var mascotToCard = mascotImage.mapToItem(card, 0, 0, mascotImage.width, mascotImage.height);
552+ verify(mascotToCard.x === units.gu(1));
553+ if (title) {
554+ verify((titleToCard.x - mascotToCard.x - mascotToCard.width) === units.gu(1));
555+ }
556+ } else if (title) {
557+ verify(titleToCard.x === units.gu(1));
558+ }
559+
560+ // right margin
561+ var emblemIcon = findChild(card, "emblemIcon");
562+ if (emblemIcon) {
563+ var emblemToCard = emblemIcon.mapToItem(card, 0, 0, emblemIcon.width, emblemIcon.height);
564+ verify((card.width - emblemToCard.x - emblemToCard.width) === units.gu(1));
565+ } else if (title) {
566+ verify((card.width - titleToCard.x - titleToCard.width) === units.gu(1));
567+ }
568+ }
508569 }
509570}