on xenial help sign in
Some fixes for the tst_card, more to come
b198f9bAlbert Astals
plugins/Dash/CardCreator.js+1
@@ -112,6 +112,7 @@ function createCardComponent(parent, template, components) {
112 visible: status == Loader.Ready; \
112 visible: status == Loader.Ready; \
113 sourceComponent: UbuntuShape { \
113 sourceComponent: UbuntuShape { \
114 id: artShape; \
114 id: artShape; \
115+ objectName: "artShape"; \
115 radius: "medium"; \
116 radius: "medium"; \
116 readonly property real aspect: components !== undefined ? components["art"]["aspect-ratio"] : 1; \
117 readonly property real aspect: components !== undefined ? components["art"]["aspect-ratio"] : 1; \
117 readonly property bool aspectSmallerThanImageAspect: aspect < image.aspect; \
118 readonly property bool aspectSmallerThanImageAspect: aspect < image.aspect; \
plugins/Dash/CardCreatorCache.qml−1
@@ -16,7 +16,6 @@ QtObject {
16 var allString = tString + cString;
16 var allString = tString + cString;
17 var component = cache[allString];
17 var component = cache[allString];
18 if (component === undefined) {
18 if (component === undefined) {
19− console.log("Create", tString, cString);
20 component = CardCreator.createCardComponent(root, template, components);
19 component = CardCreator.createCardComponent(root, template, components);
21 cache[allString] = component;
20 cache[allString] = component;
22 }
21 }
tests/qmltests/Dash/tst_Card.qml+12−26
@@ -186,30 +186,14 @@ Rectangle {
186
186
187 when: windowShown
187 when: windowShown
188
188
189− property Item header: findChild(card, "cardHeader")
189+ property var headerRow: findChild(card, "outerRow")
190− property Item headerLoader: findChild(card, "cardHeaderLoader")
191− property Item title: findChild(header, "titleLabel")
192− property Item art: findChild(card, "artShape")
190+ property var art: findChild(card, "artShape")
193 property Item artImage: findChild(card, "artImage")
191 property Item artImage: findChild(card, "artImage")
194− property Item summary: findChild(card, "summaryLabel")
195− property Item background: findChild(card, "background")
196− property Item backgroundLoader: findChild(card, "backgroundLoader")
197− property Item backgroundImage: findChild(card, "backgroundImage")
198−
199− function initTestCase() {
200− verify(typeof testCase.header === "object", "Couldn't find header object.");
201− verify(typeof testCase.art === "object", "Couldn't find art object.");
202− verify(typeof testCase.artImage === "object", "Couldn't find artImage object.");
203− verify(typeof testCase.summary === "object", "Couldn't find summary object.");
204− verify(typeof testCase.artImage === "object", "Couldn't find background object.");
205− verify(typeof testCase.summary === "object", "Couldn't find backgroundImage object.");
206− }
207
192
208 function cleanup() {
193 function cleanup() {
209 selector.selectedIndex = -1;
194 selector.selectedIndex = -1;
210 }
195 }
211
196
212−
213 function test_header_binding_data() {
197 function test_header_binding_data() {
214 return [
198 return [
215 { tag: "Mascot", property: "mascot", value: Qt.resolvedUrl("artwork/avatar.png"), index: 0 },
199 { tag: "Mascot", property: "mascot", value: Qt.resolvedUrl("artwork/avatar.png"), index: 0 },
@@ -291,16 +275,17 @@ Rectangle {
291 { tag: "Medium", width: units.gu(18.5), fill: Image.PreserveAspectCrop, index: 0 },
275 { tag: "Medium", width: units.gu(18.5), fill: Image.PreserveAspectCrop, index: 0 },
292 { tag: "Small", width: units.gu(12), index: 1 },
276 { tag: "Small", width: units.gu(12), index: 1 },
293 { tag: "Large", width: units.gu(38), index: 2 },
277 { tag: "Large", width: units.gu(38), index: 2 },
294− { tag: "Wide", height: units.gu(19), size: "large", index: 3 },
278+ { tag: "Wide", height: units.gu(18.5) / 2, size: "large", index: 3 },
295− { tag: "Fit", height: units.gu(38), size: "large", width: units.gu(19), index: 4 },
279+ { tag: "Fit", height: units.gu(18.5), size: "large", width: units.gu(18.5) / 2, index: 4 },
296− { tag: "VerticalWidth", width: function() { return header.width }, index: 0 },
280+ { tag: "VerticalWidth", width: function() { return headerRow.width + units.gu(1) * 2 }, index: 0 },
297− { tag: "HorizontalHeight", height: function() { return header.height }, index: 5 },
281+ { tag: "HorizontalHeight", height: function() { return headerRow.height + units.gu(1) * 2 }, index: 5 },
298− { tag: "HorizontalWidth", width: function() { return headerLoader.x }, index: 5 },
282+ { tag: "HorizontalWidth", width: function() { return headerRow.x - units.gu(1) }, index: 5 },
299 ]
283 ]
300 }
284 }
301
285
302 function test_art_size(data) {
286 function test_art_size(data) {
303 selector.selectedIndex = data.index;
287 selector.selectedIndex = data.index;
288+ tryCompareFunction(function() { return art !== null }, true);
304
289
305 if (data.hasOwnProperty("size")) {
290 if (data.hasOwnProperty("size")) {
306 card.template['card-size'] = data.size;
291 card.template['card-size'] = data.size;
@@ -331,15 +316,16 @@ Rectangle {
331
316
332 function test_art_layout_data() {
317 function test_art_layout_data() {
333 return [
318 return [
334− { tag: "Vertical", left: function() { return 0 }, index: 0},
319+ { tag: "Vertical", left: function() { return units.gu(1); }, index: 0},
335− { tag: "Horizontal", left: function() { return art.width }, index: 5 },
320+ { tag: "Horizontal", left: function() { return art.width + units.gu(1); }, index: 5 },
336 ];
321 ];
337 }
322 }
338
323
339 function test_art_layout(data) {
324 function test_art_layout(data) {
340 selector.selectedIndex = data.index;
325 selector.selectedIndex = data.index;
326+ tryCompareFunction(function() { return art !== null }, true);
341
327
342− tryCompare(testCase.headerLoader, "x", data.left());
328+ tryCompare(headerRow, "x", data.left());
343 }
329 }
344
330
345 function test_header_layout_data() {
331 function test_header_layout_data() {