on xenial help sign in
Use unity-shipped TestCase.
4b9f0c7Michał Sawicz
tests/qmltests/Dash/tst_Card.qml+2−17
@@ -1,6 +1,7 @@
1import QtQuick 2.0
1import QtQuick 2.0
2import QtTest 1.0
2import QtTest 1.0
3import Ubuntu.Components 0.1
3import Ubuntu.Components 0.1
4+import Unity.Test 0.1 as UT
4import "../../../Dash"
5import "../../../Dash"
5import "CardHelpers.js" as Helpers
6import "CardHelpers.js" as Helpers
6
7
@@ -155,7 +156,7 @@ Rectangle {
155 }
156 }
156 }
157 }
157
158
158− TestCase {
159+ UT.UnityTestCase {
159 id: testCase
160 id: testCase
160
161
161 when: windowShown
162 when: windowShown
@@ -165,22 +166,6 @@ Rectangle {
165 property Item artImage: findChild(card, "artImage")
166 property Item artImage: findChild(card, "artImage")
166 property Item summary: findChild(card, "summaryLabel")
167 property Item summary: findChild(card, "summaryLabel")
167
168
168− // Find an object with the given name in the children tree of "obj"
169− function findChild(obj,objectName) {
170− var childs = new Array(0);
171− childs.push(obj)
172− while (childs.length > 0) {
173− if (childs[0].objectName == objectName) {
174− return childs[0]
175− }
176− for (var i in childs[0].children) {
177− childs.push(childs[0].children[i])
178− }
179− childs.splice(0, 1);
180− }
181− return null;
182− }
183−
184 function initTestCase() {
169 function initTestCase() {
185 verify(testCase.header !== undefined, "Couldn't find header object.");
170 verify(testCase.header !== undefined, "Couldn't find header object.");
186 }
171 }
tests/qmltests/Dash/tst_CardHeader.qml+2−17
@@ -1,6 +1,7 @@
1import QtQuick 2.0
1import QtQuick 2.0
2import QtTest 1.0
2import QtTest 1.0
3import Ubuntu.Components 0.1
3import Ubuntu.Components 0.1
4+import Unity.Test 0.1 as UT
4import "../../../Dash"
5import "../../../Dash"
5
6
6
7
@@ -20,27 +21,11 @@ Rectangle {
20 opacity: 0.5
21 opacity: 0.5
21 }
22 }
22
23
23− TestCase {
24+ UT.UnityTestCase {
24 id: testCase
25 id: testCase
25
26
26 when: windowShown
27 when: windowShown
27
28
28− // Find an object with the given name in the children tree of "obj"
29− function findChild(obj,objectName) {
30− var childs = new Array(0);
31− childs.push(obj)
32− while (childs.length > 0) {
33− if (childs[0].objectName == objectName) {
34− return childs[0]
35− }
36− for (var i in childs[0].children) {
37− childs.push(childs[0].children[i])
38− }
39− childs.splice(0, 1);
40− }
41− return null;
42− }
43−
44 property Item avatar: findChild(cardHeader, "avatarShape")
29 property Item avatar: findChild(cardHeader, "avatarShape")
45 property Item titleLabel: findChild(cardHeader, "titleLabel")
30 property Item titleLabel: findChild(cardHeader, "titleLabel")
46 property Item subtitleLabel: findChild(cardHeader, "subtitleLabel")
31 property Item subtitleLabel: findChild(cardHeader, "subtitleLabel")