on xenial help sign in
Improve InitTestCase robustness and add trailing commas to reduce diffs later.
commit405f43bf5b602f3a2a5b6961ee49845fa7b2c9ce authorMichał Sawicz <michal.sawicz@canonical.com> dateMon 27 Jan 2014, 22:23 (13 years ago) parent971892c
3 files changed+16−12
qml/Dash/CardHeader.qml+2−1 tests/qmltests/Dash/tst_Card.qml+6−3 tests/qmltests/Dash/tst_CardHeader.qml+8−8
qml/Dash/CardHeader.qml+2−1
@@ -56,9 +56,9 @@ Item {
5656
5757 Label {
5858 id: titleLabel
59+ objectName: "titleLabel"
5960 anchors { left: parent.left; right: parent.right }
6061 elide: Text.ElideRight
61− objectName: "titleLabel"
6262 font.weight: Font.DemiBold
6363 wrapMode: Text.Wrap
6464 maximumLineCount: 2
@@ -66,6 +66,7 @@ Item {
6666
6767 Label {
6868 id: subtitleLabel
69+ objectName: "subtitleLabel"
6970 anchors { left: parent.left; right: parent.right }
7071 elide: Text.ElideRight
7172 visible: titleLabel.text && text
tests/qmltests/Dash/tst_Card.qml+6−3
@@ -193,7 +193,10 @@ Rectangle {
193193 property Item summary: findChild(card, "summaryLabel")
194194
195195 function initTestCase() {
196− verify(testCase.header !== undefined, "Couldn't find header object.");
196+ verify(typeof testCase.header === "object", "Couldn't find header object.");
197+ verify(typeof testCase.art === "object", "Couldn't find art object.");
198+ verify(typeof testCase.artImage === "object", "Couldn't find artImage object.");
199+ verify(typeof testCase.summary === "object", "Couldn't find summary object.");
197200 }
198201
199202 function cleanup() {
@@ -320,7 +323,7 @@ Rectangle {
320323 function test_art_layout_data() {
321324 return [
322325 { tag: "Vertical", left: function() { return 0 }, index: 0},
323− { tag: "Horizontal", left: function() { return art.width }, index: 5 }
326+ { tag: "Horizontal", left: function() { return art.width }, index: 5 },
324327 ];
325328 }
326329
@@ -335,7 +338,7 @@ Rectangle {
335338 { tag: "Vertical", top: function() { return art.y + art.height },
336339 left: function() { return art.x }, index: 0 },
337340 { tag: "Horizontal", top: function() { return art.y },
338− left: function() { return art.x + art.width }, index: 5 }
341+ left: function() { return art.x + art.width }, index: 5 },
339342 ]
340343 }
341344
tests/qmltests/Dash/tst_CardHeader.qml+8−8
@@ -52,11 +52,11 @@ Rectangle {
5252 property Item column: findChild(cardHeader, "column")
5353
5454 function initTestCase() {
55− verify(testCase.mascot !== undefined, "Couldn't find mascot object.");
56− verify(testCase.titleLabel !== undefined, "Couldn't find titleLabel object.");
57− verify(testCase.subtitleLabel !== undefined, "Couldn't find subtitleLabel object.");
58− verify(testCase.prices !== undefined, "Couldn't find prices object.");
59− verify(testCase.oldPriceLabel !== undefined, "Couldn't find oldPriceLabel object.");
55+ verify(typeof testCase.mascot === "object", "Couldn't find mascot object.");
56+ verify(typeof testCase.titleLabel === "object", "Couldn't find titleLabel object.");
57+ verify(typeof testCase.subtitleLabel === "object", "Couldn't find subtitleLabel object.");
58+ verify(typeof testCase.prices === "object", "Couldn't find prices object.");
59+ verify(typeof testCase.oldPriceLabel === "object", "Couldn't find oldPriceLabel object.");
6060 }
6161
6262 function cleanup() {
@@ -86,7 +86,7 @@ Rectangle {
8686 { tag: "Empty", visible: false },
8787 { tag: "Title only", title: "Foo", visible: true },
8888 { tag: "Subtitle only", subtitle: "Bar", visible: false },
89− { tag: "Both", title: "Foo", subtitle: "Bar", visible: true }
89+ { tag: "Both", title: "Foo", subtitle: "Bar", visible: true },
9090 ]
9191 }
9292
@@ -104,7 +104,7 @@ Rectangle {
104104 { tag: "Main and Alt", main: "$1.25", alt: "€1.00", visible: true },
105105 { tag: "Main and Old", main: "$1.25", old: "$2.00", visible: true, oldAlign: Text.AlignRight },
106106 { tag: "Alt and Old", alt: "€1.00", old: "$2.00", visible: false },
107− { tag: "All", main: "$1.25", alt: "€1.00", old: "$2.00", visible: true, oldAlign: Text.AlignHCenter }
107+ { tag: "All", main: "$1.25", alt: "€1.00", old: "$2.00", visible: true, oldAlign: Text.AlignHCenter },
108108 ]
109109 }
110110
@@ -122,7 +122,7 @@ Rectangle {
122122 return [
123123 { tag: "Column width", object: column, width: cardHeader.width - testCase.outerRow.spacing * 2 },
124124 { tag: "Column width", object: column, width: cardHeader.width - mascot.width - testCase.outerRow.spacing * 3, mascot: "artwork/avatar.png" },
125− { tag: "Header height", object: cardHeader, height: function() { return subtitleLabel.y + subtitleLabel.height + outerRow.spacing * 2 } }
125+ { tag: "Header height", object: cardHeader, height: function() { return subtitleLabel.y + subtitleLabel.height + outerRow.spacing * 2 } },
126126 ]
127127 }
128128