on xenial help sign in
Don't reserve space for mascot if no mascot is specified Fixes: 1319343
commitf604991501caa6f1ac7ab457675b04f93c04f38e authorAlbert Astals <albert.astals@canonical.com> dateTue 27 May 2014, 07:45 (12 years ago) parentae519219edb42b
2 files changed+15−7
qml/Dash/Previews/PreviewHeader.qml+3 tests/qmltests/Dash/Previews/tst_PreviewHeader.qml+12−7
qml/Dash/Previews/PreviewHeader.qml+3
@@ -56,6 +56,9 @@ PreviewWidget {
5656
5757 Loader {
5858 id: mascotShapeLoader
59+ objectName: "mascotShapeLoader"
60+ active: headerRoot.mascot != ""
61+ visible: active
5962
6063 anchors.verticalCenter: parent.verticalCenter
6164 // 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 {
5353 name: "PreviewHeaderTest"
5454 when: windowShown
5555
56− property Item mascot: findChild(previewHeader, "mascotShape")
56+ property Item mascotShapeLoader: findChild(previewHeader, "mascotShapeLoader")
5757 property Item outerRow: findChild(previewHeader, "outerRow")
5858 property Item column: findChild(previewHeader, "column")
5959
6060 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.");
6262 verify(typeof testCase.outerRow === "object", "Couldn't find outerRow object.");
6363 verify(typeof testCase.column === "object", "Couldn't find column object.");
6464
@@ -70,9 +70,9 @@ Rectangle {
7070
7171 function test_mascot_data() {
7272 return [
73− { tag: "Empty", source: "", visible: false },
74− { tag: "Invalid", source: "bad_path", visible: false },
75− { tag: "Valid", source: "../graphics/play_button.png", visible: true },
73+ { tag: "Empty", source: "", loaderVisible: false, visible: false },
74+ { tag: "Invalid", source: "bad_path", loaderVisible: true, visible: false },
75+ { tag: "Valid", source: "../graphics/play_button.png", loaderVisible: true, visible: true },
7676 ]
7777 }
7878
@@ -80,12 +80,17 @@ Rectangle {
8080 headerjson.mascot = data.source;
8181 previewHeader.widgetData = headerjson;
8282
83− tryCompare(testCase.mascot, "visible", data.visible);
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")
87+ tryCompare(mascot, "visible", data.visible);
88+ }
8489 }
8590
8691 function test_dimensions_data() {
8792 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" },
8994 { tag: "Header height", object: previewHeader, height: function() { return outerRow.height + outerRow.margins * 2 } },
9095 ]
9196 }