on xenial help sign in
Fix card tests on the phone
1f2ef0bAlbert Astals Cid
plugins/Dash/CardCreator.js+10−4
@@ -61,6 +61,7 @@ var kBackgroundLoaderCode = 'Loader {\n\
61// %1 is used as anchors of artShapeHolder
61// %1 is used as anchors of artShapeHolder
62// %2 is used as image width
62// %2 is used as image width
63// %3 is used as image height
63// %3 is used as image height
64+// %4 is injected as code to artImage
64var kArtShapeHolderCode = 'Item { \n\
65var kArtShapeHolderCode = 'Item { \n\
65 id: artShapeHolder; \n\
66 id: artShapeHolder; \n\
66 height: root.fixedArtShapeSize.height > 0 ? root.fixedArtShapeSize.height : artShapeLoader.height; \n\
67 height: root.fixedArtShapeSize.height > 0 ? root.fixedArtShapeSize.height : artShapeLoader.height; \n\
@@ -131,6 +132,7 @@ var kArtShapeHolderCode = 'Item { \n\
131 asynchronous: root.asynchronous; \n\
132 asynchronous: root.asynchronous; \n\
132 width: %2; \n\
133 width: %2; \n\
133 height: %3; \n\
134 height: %3; \n\
135+ %4 \n\
134 } \n\
136 } \n\
135 } \n\
137 } \n\
136 } \n\
138 } \n\
@@ -242,6 +244,7 @@ var kMascotShapeLoaderCode = 'Loader { \n\
242
244
243// %1 is used as anchors of mascotImage
245// %1 is used as anchors of mascotImage
244// %2 is used as visible of mascotImage
246// %2 is used as visible of mascotImage
247+// %3 is injected as code to mascotImage
245var kMascotImageCode = 'CroppedImageMinimumSourceSize { \n\
248var kMascotImageCode = 'CroppedImageMinimumSourceSize { \n\
246 id: mascotImage; \n\
249 id: mascotImage; \n\
247 objectName: "mascotImage"; \n\
250 objectName: "mascotImage"; \n\
@@ -252,6 +255,7 @@ var kMascotImageCode = 'CroppedImageMinimumSourceSize { \n\
252 horizontalAlignment: Image.AlignHCenter; \n\
255 horizontalAlignment: Image.AlignHCenter; \n\
253 verticalAlignment: Image.AlignVCenter; \n\
256 verticalAlignment: Image.AlignVCenter; \n\
254 visible: %2; \n\
257 visible: %2; \n\
258+ %3 \n\
255 }\n';
259 }\n';
256
260
257// %1 is used as anchors of titleLabel
261// %1 is used as anchors of titleLabel
@@ -456,11 +460,12 @@ function cardString(template, components) {
456 heightCode = 'width / artShape.aspect';
460 heightCode = 'width / artShape.aspect';
457 }
461 }
458
462
459− code += kArtShapeHolderCode.arg(artAnchors).arg(widthCode).arg(heightCode);
460 var fallback = components["art"] && components["art"]["fallback"] || "";
463 var fallback = components["art"] && components["art"]["fallback"] || "";
464+ var fallbackCode = "";
461 if (fallback !== "") {
465 if (fallback !== "") {
462− code += 'Connections { target: artShapeLoader.item ? artShapeLoader.item.image : null; onStatusChanged: if (artShapeLoader.item.image.status === Image.Error) artShapeLoader.item.image.source = "%1"; } \n'.arg(fallback);
466+ fallbackCode += 'onStatusChanged: if (status === Image.Error) source = "%1";'.arg(fallback);
463 }
467 }
468+ code += kArtShapeHolderCode.arg(artAnchors).arg(widthCode).arg(heightCode).arg(fallbackCode);
464 } else {
469 } else {
465 code += 'readonly property size artShapeSize: Qt.size(-1, -1);\n'
470 code += 'readonly property size artShapeSize: Qt.size(-1, -1);\n'
466 }
471 }
@@ -552,11 +557,12 @@ function cardString(template, components) {
552 }
557 }
553
558
554 var mascotImageVisible = useMascotShape ? 'false' : 'showHeader';
559 var mascotImageVisible = useMascotShape ? 'false' : 'showHeader';
555− mascotCode = kMascotImageCode.arg(mascotAnchors).arg(mascotImageVisible);
556 var fallback = components["mascot"] && components["mascot"]["fallback"] || "";
560 var fallback = components["mascot"] && components["mascot"]["fallback"] || "";
561+ var fallbackCode = "";
557 if (fallback !== "") {
562 if (fallback !== "") {
558− code += 'Connections { target: mascotImage; onStatusChanged: if (mascotImage.status === Image.Error) mascotImage.source = "%1"; } \n'.arg(fallback);
563+ fallbackCode += 'onStatusChanged: if (status === Image.Error) source = "%1";'.arg(fallback);
559 }
564 }
565+ mascotCode = kMascotImageCode.arg(mascotAnchors).arg(mascotImageVisible).arg(fallbackCode);
560 }
566 }
561
567
562 var summaryColorWithBackground = 'backgroundLoader.active && backgroundLoader.item && root.scopeStyle ? root.scopeStyle.getTextColor(backgroundLoader.item.luminance) : (backgroundLoader.item && backgroundLoader.item.luminance > 0.7 ? theme.palette.normal.baseText : "white")';
568 var summaryColorWithBackground = 'backgroundLoader.active && backgroundLoader.item && root.scopeStyle ? root.scopeStyle.getTextColor(backgroundLoader.item.luminance) : (backgroundLoader.item && backgroundLoader.item.luminance > 0.7 ? theme.palette.normal.baseText : "white")';
tests/qmltests/Dash/tst_Card.qml+1
@@ -232,6 +232,7 @@ Rectangle {
232 function init() {
232 function init() {
233 cardTool.components = Qt.binding(function() { return Helpers.update(JSON.parse(Helpers.defaultLayout), Helpers.tryParse(layoutArea.text, layoutError))['components']; });
233 cardTool.components = Qt.binding(function() { return Helpers.update(JSON.parse(Helpers.defaultLayout), Helpers.tryParse(layoutArea.text, layoutError))['components']; });
234 loader.visible = true;
234 loader.visible = true;
235+ waitForRendering(card);
235 }
236 }
236
237
237 function cleanup() {
238 function cleanup() {