on xenial help sign in
Fix cardtool test and make card creator output debugging info on errors.
8e00ae4Michał Sawicz
plugins/Dash/CardCreator.js+15−1
@@ -639,7 +639,10 @@ function cardString(template, components) {
639 implicitHeight += 'titleLabel.y + titleLabel.height + units.gu(1);\n';
639 implicitHeight += 'titleLabel.y + titleLabel.height + units.gu(1);\n';
640 } else if (hasArt) {
640 } else if (hasArt) {
641 implicitHeight += 'artShapeHolder.height;\n';
641 implicitHeight += 'artShapeHolder.height;\n';
642+ } else {
643+ implicitHeight = '';
642 }
644 }
645+
643 // Close the AbstractButton
646 // Close the AbstractButton
644 code += implicitHeight + '}\n';
647 code += implicitHeight + '}\n';
645
648
@@ -653,5 +656,16 @@ function createCardComponent(parent, template, components) {
653 var card = cardString(template, components);
656 var card = cardString(template, components);
654 var code = imports + 'Component {\n' + card + '}\n';
657 var code = imports + 'Component {\n' + card + '}\n';
655
658
659+ try {
656− return Qt.createQmlObject(code, parent, "createCardComponent");
660+ return Qt.createQmlObject(code, parent, "createCardComponent");
661+ } catch (e) {
662+ console.error("ERROR: Invalid component created.");
663+ console.error("Template:");
664+ console.error(JSON.stringify(template));
665+ console.error("Components:");
666+ console.error(JSON.stringify(components));
667+ console.error("Code:");
668+ console.error(code);
669+ throw e;
670+ }
657}
671}
tests/qmltests/Dash/tst_CardTool.qml+13−5
@@ -237,7 +237,7 @@ Rectangle {
237
237
238 UT.UnityTestCase {
238 UT.UnityTestCase {
239 id: testCase
239 id: testCase
240− name: "Card"
240+ name: "CardTool"
241
241
242 property var internalCard: findChild(cardTool, "cardToolCard")
242 property var internalCard: findChild(cardTool, "cardToolCard")
243
243
@@ -272,10 +272,18 @@ Rectangle {
272 { tag: "MediumCarousel", width: units.gu(22), height: units.gu(22), viewWidth: 84, index: 0, layout_index: 4},
272 { tag: "MediumCarousel", width: units.gu(22), height: units.gu(22), viewWidth: 84, index: 0, layout_index: 4},
273 { tag: "LargeCarousel", width: units.gu(26), height: units.gu(26), viewWidth: 140, index: 0, layout_index: 4},
273 { tag: "LargeCarousel", width: units.gu(26), height: units.gu(26), viewWidth: 140, index: 0, layout_index: 4},
274 { tag: "PortraitCarousel", width: units.gu(22), height: units.gu(44), viewWidth: 84, index: 10, layout_index: 4},
274 { tag: "PortraitCarousel", width: units.gu(22), height: units.gu(44), viewWidth: 84, index: 10, layout_index: 4},
275− { tag: "SmallHorizontalList", width: units.gu(18), height: units.gu(39.5), viewWidth: 30, index: 0, layout_index: 5},
275+ { tag: "SmallHorizontalList", width: units.gu(18),
276+ height: function() { return internalCard ? internalCard.height : 0 },
277+ viewWidth: 30, index: 0, layout_index: 5 },
276− { tag: "MediumHorizontalList", width: units.gu(22), height: units.gu(43.5), viewWidth: 84, index: 0, layout_index: 5},
278+ { tag: "MediumHorizontalList", width: units.gu(22),
279+ height: function() { return internalCard ? internalCard.height : 0 },
280+ viewWidth: 84, index: 0, layout_index: 5 },
277− { tag: "LargeHorizontalList", width: units.gu(26), height: units.gu(47.5), viewWidth: 140, index: 0, layout_index: 5},
281+ { tag: "LargeHorizontalList", width: units.gu(26),
282+ height: function() { return internalCard ? internalCard.height : 0 },
283+ viewWidth: 140, index: 0, layout_index: 5 },
278− { tag: "PortraitHorizontalList", width: units.gu(22), height: units.gu(65.5), viewWidth: 84, index: 10, layout_index: 5},
284+ { tag: "PortraitHorizontalList", width: units.gu(22),
285+ height: function() { return internalCard ? internalCard.height : 0 },
286+ viewWidth: 84, index: 10, layout_index: 5 },
279 ]
287 ]
280 }
288 }
281
289