on xenial help sign in
Some fixes for the tst_card, more to come
commitb198f9b3e30bfa333a9c664d83515cf1a5641637 authorAlbert Astals <albert.astals@canonical.com> dateFri 2 May 2014, 18:46 (12 years ago) parent5932bfe
3 files changed+13−27
plugins/Dash/CardCreator.js+1 plugins/Dash/CardCreatorCache.qml−1 tests/qmltests/Dash/tst_Card.qml+12−26
plugins/Dash/CardCreator.js+1
@@ -112,6 +112,7 @@ function createCardComponent(parent, template, components) {
112112 visible: status == Loader.Ready; \
113113 sourceComponent: UbuntuShape { \
114114 id: artShape; \
115+ objectName: "artShape"; \
115116 radius: "medium"; \
116117 readonly property real aspect: components !== undefined ? components["art"]["aspect-ratio"] : 1; \
117118 readonly property bool aspectSmallerThanImageAspect: aspect < image.aspect; \
plugins/Dash/CardCreatorCache.qml−1
@@ -16,7 +16,6 @@ QtObject {
1616 var allString = tString + cString;
1717 var component = cache[allString];
1818 if (component === undefined) {
19− console.log("Create", tString, cString);
2019 component = CardCreator.createCardComponent(root, template, components);
2120 cache[allString] = component;
2221 }
tests/qmltests/Dash/tst_Card.qml+12−26
@@ -186,30 +186,14 @@ Rectangle {
186186
187187 when: windowShown
188188
189− property Item header: findChild(card, "cardHeader")
190− property Item headerLoader: findChild(card, "cardHeaderLoader")
191− property Item title: findChild(header, "titleLabel")
192− property Item art: findChild(card, "artShape")
189+ property var headerRow: findChild(card, "outerRow")
190+ property var art: findChild(card, "artShape")
193191 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− }
207192
208193 function cleanup() {
209194 selector.selectedIndex = -1;
210195 }
211196
212−
213197 function test_header_binding_data() {
214198 return [
215199 { tag: "Mascot", property: "mascot", value: Qt.resolvedUrl("artwork/avatar.png"), index: 0 },
@@ -291,16 +275,17 @@ Rectangle {
291275 { tag: "Medium", width: units.gu(18.5), fill: Image.PreserveAspectCrop, index: 0 },
292276 { tag: "Small", width: units.gu(12), index: 1 },
293277 { tag: "Large", width: units.gu(38), index: 2 },
294− { tag: "Wide", height: units.gu(19), size: "large", index: 3 },
295− { tag: "Fit", height: units.gu(38), size: "large", width: units.gu(19), index: 4 },
296− { tag: "VerticalWidth", width: function() { return header.width }, index: 0 },
297− { tag: "HorizontalHeight", height: function() { return header.height }, index: 5 },
298− { tag: "HorizontalWidth", width: function() { return headerLoader.x }, index: 5 },
278+ { tag: "Wide", height: units.gu(18.5) / 2, size: "large", index: 3 },
279+ { tag: "Fit", height: units.gu(18.5), size: "large", width: units.gu(18.5) / 2, index: 4 },
280+ { tag: "VerticalWidth", width: function() { return headerRow.width + units.gu(1) * 2 }, index: 0 },
281+ { tag: "HorizontalHeight", height: function() { return headerRow.height + units.gu(1) * 2 }, index: 5 },
282+ { tag: "HorizontalWidth", width: function() { return headerRow.x - units.gu(1) }, index: 5 },
299283 ]
300284 }
301285
302286 function test_art_size(data) {
303287 selector.selectedIndex = data.index;
288+ tryCompareFunction(function() { return art !== null }, true);
304289
305290 if (data.hasOwnProperty("size")) {
306291 card.template['card-size'] = data.size;
@@ -331,15 +316,16 @@ Rectangle {
331316
332317 function test_art_layout_data() {
333318 return [
334− { tag: "Vertical", left: function() { return 0 }, index: 0},
335− { tag: "Horizontal", left: function() { return art.width }, index: 5 },
319+ { tag: "Vertical", left: function() { return units.gu(1); }, index: 0},
320+ { tag: "Horizontal", left: function() { return art.width + units.gu(1); }, index: 5 },
336321 ];
337322 }
338323
339324 function test_art_layout(data) {
340325 selector.selectedIndex = data.index;
326+ tryCompareFunction(function() { return art !== null }, true);
341327
342− tryCompare(testCase.headerLoader, "x", data.left());
328+ tryCompare(headerRow, "x", data.left());
343329 }
344330
345331 function test_header_layout_data() {