on xenial help sign in
Use unity-shipped TestCase.
commit4b9f0c7e2b71bdaac4fdc8b5dd9e1b2699e5b78d authorMichał Sawicz <michal.sawicz@canonical.com> dateThu 5 Dec 2013, 16:05 (13 years ago) parent3bbd428
2 files changed+4−34
tests/qmltests/Dash/tst_Card.qml+2−17 tests/qmltests/Dash/tst_CardHeader.qml+2−17
tests/qmltests/Dash/tst_Card.qml+2−17
@@ -1,6 +1,7 @@
11import QtQuick 2.0
22import QtTest 1.0
33import Ubuntu.Components 0.1
4+import Unity.Test 0.1 as UT
45import "../../../Dash"
56import "CardHelpers.js" as Helpers
67
@@ -155,7 +156,7 @@ Rectangle {
155156 }
156157 }
157158
158− TestCase {
159+ UT.UnityTestCase {
159160 id: testCase
160161
161162 when: windowShown
@@ -165,22 +166,6 @@ Rectangle {
165166 property Item artImage: findChild(card, "artImage")
166167 property Item summary: findChild(card, "summaryLabel")
167168
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−
184169 function initTestCase() {
185170 verify(testCase.header !== undefined, "Couldn't find header object.");
186171 }
tests/qmltests/Dash/tst_CardHeader.qml+2−17
@@ -1,6 +1,7 @@
11import QtQuick 2.0
22import QtTest 1.0
33import Ubuntu.Components 0.1
4+import Unity.Test 0.1 as UT
45import "../../../Dash"
56
67
@@ -20,27 +21,11 @@ Rectangle {
2021 opacity: 0.5
2122 }
2223
23− TestCase {
24+ UT.UnityTestCase {
2425 id: testCase
2526
2627 when: windowShown
2728
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−
4429 property Item avatar: findChild(cardHeader, "avatarShape")
4530 property Item titleLabel: findChild(cardHeader, "titleLabel")
4631 property Item subtitleLabel: findChild(cardHeader, "subtitleLabel")