on xenial help sign in
Do not hold space for the mascot image if there is no mascot image
a485c92Albert Astals
qml/Dash/Previews/PreviewHeader.qml+3
@@ -56,6 +56,9 @@ PreviewWidget {
56
56
57 Loader {
57 Loader {
58 id: mascotShapeLoader
58 id: mascotShapeLoader
59+ objectName: "mascotShapeLoader"
60+ active: headerRoot.mascot != ""
61+ visible: active
59
62
60 anchors.verticalCenter: parent.verticalCenter
63 anchors.verticalCenter: parent.verticalCenter
61 // TODO karni: Icon aspect-ratio is 8:7.5. Revisit these values to avoid fraction of pixels.
64 // TODO karni: Icon aspect-ratio is 8:7.5. Revisit these values to avoid fraction of pixels.
tests/qmltests/Dash/Previews/tst_PreviewHeader.qml+12−7
@@ -53,12 +53,12 @@ Rectangle {
53 name: "PreviewHeaderTest"
53 name: "PreviewHeaderTest"
54 when: windowShown
54 when: windowShown
55
55
56− property Item mascot: findChild(previewHeader, "mascotShape")
56+ property Item mascotShapeLoader: findChild(previewHeader, "mascotShapeLoader")
57 property Item outerRow: findChild(previewHeader, "outerRow")
57 property Item outerRow: findChild(previewHeader, "outerRow")
58 property Item column: findChild(previewHeader, "column")
58 property Item column: findChild(previewHeader, "column")
59
59
60 function initTestCase() {
60 function initTestCase() {
61− verify(typeof testCase.mascot === "object", "Couldn't find mascot object.");
61+ verify(typeof testCase.mascotShapeLoader === "object", "Couldn't find mascot loader object.");
62 verify(typeof testCase.outerRow === "object", "Couldn't find outerRow object.");
62 verify(typeof testCase.outerRow === "object", "Couldn't find outerRow object.");
63 verify(typeof testCase.column === "object", "Couldn't find column object.");
63 verify(typeof testCase.column === "object", "Couldn't find column object.");
64
64
@@ -70,9 +70,9 @@ Rectangle {
70
70
71 function test_mascot_data() {
71 function test_mascot_data() {
72 return [
72 return [
73− { tag: "Empty", source: "", visible: false },
73+ { tag: "Empty", source: "", loaderVisible: false, visible: false },
74− { tag: "Invalid", source: "bad_path", visible: false },
74+ { tag: "Invalid", source: "bad_path", loaderVisible: true, visible: false },
75− { tag: "Valid", source: "../graphics/play_button.png", visible: true },
75+ { tag: "Valid", source: "../graphics/play_button.png", loaderVisible: true, visible: true },
76 ]
76 ]
77 }
77 }
78
78
@@ -80,12 +80,17 @@ Rectangle {
80 headerjson.mascot = data.source;
80 headerjson.mascot = data.source;
81 previewHeader.widgetData = headerjson;
81 previewHeader.widgetData = headerjson;
82
82
83+ tryCompare(testCase.mascotShapeLoader, "visible", data.loaderVisible);
84+ if (data.loaderVisible) {
85+ tryCompareFunction(function() { return findChild(previewHeader, "mascotShape") != null }, true);
86+ var mascot = findChild(previewHeader, "mascotShape")
83− tryCompare(testCase.mascot, "visible", data.visible);
87+ tryCompare(mascot, "visible", data.visible);
88+ }
84 }
89 }
85
90
86 function test_dimensions_data() {
91 function test_dimensions_data() {
87 return [
92 return [
88− { tag: "Column width with mascot", object: column, width: previewHeader.width - mascot.width - outerRow.margins * 3, mascot: "artwork/avatar.png" },
93+ { tag: "Column width with mascot", object: column, width: previewHeader.width - mascotShapeLoader.width - outerRow.margins * 3, mascot: "artwork/avatar.png" },
89 { tag: "Header height", object: previewHeader, height: function() { return outerRow.height + outerRow.margins * 2 } },
94 { tag: "Header height", object: previewHeader, height: function() { return outerRow.height + outerRow.margins * 2 } },
90 ]
95 ]
91 }
96 }