on xenial help sign in
Fix tests on the phone

Convert Connections to a direct onStatusChanged code add a waitForRendering

commit610220f60b92b151d73f0227defc848b372efb2c authorAlbert Astals Cid <albert.astals@canonical.com> dateMon 11 Jan 2016, 17:51 (11 years ago) parentf5d8835
2 files changed+11−4
plugins/Dash/CardCreator.js+10−4 tests/qmltests/Dash/tst_Card.qml+1
plugins/Dash/CardCreator.js+10−4
@@ -61,6 +61,7 @@ var kBackgroundLoaderCode = 'Loader {\n\
6161// %1 is used as anchors of artShapeHolder
6262// %2 is used as image width
6363// %3 is used as image height
64+// %4 is injected as code to artImage
6465var kArtShapeHolderCode = 'Item { \n\
6566 id: artShapeHolder; \n\
6667 height: root.fixedArtShapeSize.height > 0 ? root.fixedArtShapeSize.height : artShapeLoader.height; \n\
@@ -131,6 +132,7 @@ var kArtShapeHolderCode = 'Item { \n\
131132 asynchronous: root.asynchronous; \n\
132133 width: %2; \n\
133134 height: %3; \n\
135+ %4 \n\
134136 } \n\
135137 } \n\
136138 } \n\
@@ -242,6 +244,7 @@ var kMascotShapeLoaderCode = 'Loader { \n\
242244
243245// %1 is used as anchors of mascotImage
244246// %2 is used as visible of mascotImage
247+// %3 is injected as code to mascotImage
245248var kMascotImageCode = 'CroppedImageMinimumSourceSize { \n\
246249 id: mascotImage; \n\
247250 objectName: "mascotImage"; \n\
@@ -252,6 +255,7 @@ var kMascotImageCode = 'CroppedImageMinimumSourceSize { \n\
252255 horizontalAlignment: Image.AlignHCenter; \n\
253256 verticalAlignment: Image.AlignVCenter; \n\
254257 visible: %2; \n\
258+ %3 \n\
255259 }\n';
256260
257261// %1 is used as anchors of titleLabel
@@ -456,11 +460,12 @@ function cardString(template, components) {
456460 heightCode = 'width / artShape.aspect';
457461 }
458462
459− code += kArtShapeHolderCode.arg(artAnchors).arg(widthCode).arg(heightCode);
460463 var fallback = components["art"] && components["art"]["fallback"] || "";
464+ var fallbackCode = "";
461465 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);
463467 }
468+ code += kArtShapeHolderCode.arg(artAnchors).arg(widthCode).arg(heightCode).arg(fallbackCode);
464469 } else {
465470 code += 'readonly property size artShapeSize: Qt.size(-1, -1);\n'
466471 }
@@ -552,11 +557,12 @@ function cardString(template, components) {
552557 }
553558
554559 var mascotImageVisible = useMascotShape ? 'false' : 'showHeader';
555− mascotCode = kMascotImageCode.arg(mascotAnchors).arg(mascotImageVisible);
556560 var fallback = components["mascot"] && components["mascot"]["fallback"] || "";
561+ var fallbackCode = "";
557562 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);
559564 }
565+ mascotCode = kMascotImageCode.arg(mascotAnchors).arg(mascotImageVisible).arg(fallbackCode);
560566 }
561567
562568 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 {
232232 function init() {
233233 cardTool.components = Qt.binding(function() { return Helpers.update(JSON.parse(Helpers.defaultLayout), Helpers.tryParse(layoutArea.text, layoutError))['components']; });
234234 loader.visible = true;
235+ waitForRendering(card);
235236 }
236237
237238 function cleanup() {