Merge lp:~mzanetti/ubuntu-sdk-tutorials/use-ubuntutestcase into lp:ubuntu-sdk-tutorials

Proposed by Michael Zanetti
Status: Merged
Merged at revision: 122
Proposed branch: lp:~mzanetti/ubuntu-sdk-tutorials/use-ubuntutestcase
Merge into: lp:ubuntu-sdk-tutorials
Diff against target: 110 lines (+12/-26)
3 files modified
getting-started/CurrencyConverter/tests/qmltests/helpers.js (+0/-14)
getting-started/CurrencyConverter/tests/qmltests/tst_CurrencyConverter.qml (+9/-9)
getting-started/CurrencyConverter/tests/qmltests/tst_convert.qml (+3/-3)
To merge this branch: bzr merge lp:~mzanetti/ubuntu-sdk-tutorials/use-ubuntutestcase
Reviewer Review Type Date Requested Status
Nicholas Skaggs Approve
Review via email: mp+209455@code.launchpad.net

Commit message

drop helpers.js in favor of UbuntuTestCase

To post a comment you must log in.
Revision history for this message
Nicholas Skaggs (nskaggs) :
review: Approve

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== removed file 'getting-started/CurrencyConverter/tests/qmltests/helpers.js'
2--- getting-started/CurrencyConverter/tests/qmltests/helpers.js 2013-06-27 20:13:51 +0000
3+++ getting-started/CurrencyConverter/tests/qmltests/helpers.js 1970-01-01 00:00:00 +0000
4@@ -1,14 +0,0 @@
5-.pragma library
6-
7-// Find an object with the given name recursively, starting
8-// at the given object "obj"
9-function findChild(obj,objectName) {
10- for (var i in obj.children) {
11- var child = obj.children[i];
12- if (child.objectName === objectName) return child;
13- var subChild = findChild(child,objectName);
14- if (subChild !== undefined) return subChild;
15- }
16- return undefined;
17-}
18-
19
20=== modified file 'getting-started/CurrencyConverter/tests/qmltests/tst_CurrencyConverter.qml'
21--- getting-started/CurrencyConverter/tests/qmltests/tst_CurrencyConverter.qml 2013-06-27 20:53:37 +0000
22+++ getting-started/CurrencyConverter/tests/qmltests/tst_CurrencyConverter.qml 2014-03-05 13:40:43 +0000
23@@ -1,7 +1,7 @@
24 import QtQuick 2.0
25 import Ubuntu.Components 0.1 // we need units.gu() here
26-import QtTest 1.0 // for TestCase
27-import "helpers.js" as Helpers
28+import QtTest 1.0 // for TestCase, compare() etc
29+import Ubuntu.Test 0.1 // for UbuntuTestCase, findChild() etc
30 import "../../"
31
32 // Part 2 (read tst_currency.qml first if you haven't)
33@@ -26,7 +26,7 @@
34
35
36 // Here comes the TestCase
37- TestCase {
38+ UbuntuTestCase {
39 id: currentyConverterTest
40 name: "CurrencyConverter"
41
42@@ -41,15 +41,15 @@
43 // get the activity indicator and wait for it to stop running.
44 // As we wait for everything to be built up with "when: windowShowd" above,
45 // we can safely assume loading has started already.
46- var activityIndicator = Helpers.findChild(currencyConverter, "activityIndicator")
47+ var activityIndicator = findChild(currencyConverter, "activityIndicator")
48 tryCompare(activityIndicator, "running", false)
49 }
50
51
52 // Lets test if the clear button works
53 function test_clearButton() {
54- var inputFrom = Helpers.findChild(currencyConverter, "inputFrom")
55- var inputTo = Helpers.findChild(currencyConverter, "inputTo")
56+ var inputFrom = findChild(currencyConverter, "inputFrom")
57+ var inputTo = findChild(currencyConverter, "inputTo")
58
59 // Click in the middle of the inputFrom TextField to focus it
60 mouseClick(inputFrom, inputFrom.width / 2, inputFrom.height / 2)
61@@ -60,7 +60,7 @@
62 // Now the field should contain the value 0.05 because 0.0 is already in there in the beginning
63 tryCompare(inputFrom, "text", "0.05", "Input field \"From:\" does does not contain the value 0.05")
64
65- var clearBtn = Helpers.findChild(currencyConverter, "clearBtn")
66+ var clearBtn = findChild(currencyConverter, "clearBtn")
67 mouseClick(clearBtn, clearBtn.width / 2, clearBtn.height / 2)
68
69 // Now the field should be set back to "0.0"
70@@ -82,8 +82,8 @@
71 // The test function will be called for each data set and "data" contains
72 // one row of the set.
73 function test_convert(data) {
74- var inputFrom = Helpers.findChild(currencyConverter, "inputFrom")
75- var inputTo = Helpers.findChild(currencyConverter, "inputTo")
76+ var inputFrom = findChild(currencyConverter, "inputFrom")
77+ var inputTo = findChild(currencyConverter, "inputTo")
78
79 // Click in the middle of the inputFrom TextField to focus it
80 mouseClick(inputFrom, inputFrom.width / 2, inputFrom.height / 2)
81
82=== modified file 'getting-started/CurrencyConverter/tests/qmltests/tst_convert.qml'
83--- getting-started/CurrencyConverter/tests/qmltests/tst_convert.qml 2013-06-27 20:57:19 +0000
84+++ getting-started/CurrencyConverter/tests/qmltests/tst_convert.qml 2014-03-05 13:40:43 +0000
85@@ -1,6 +1,6 @@
86 import QtQuick 2.0
87 import QtTest 1.0
88-import "helpers.js" as Helpers
89+import Ubuntu.Test 0.1
90 import "../.."
91 import QtQuick.XmlListModel 2.0
92
93@@ -11,7 +11,7 @@
94 // You can run this test with:
95 // qmltestrunner -input tst_convert.qml
96
97-TestCase {
98+UbuntuTestCase {
99 name: "convert"
100
101 // The element we want to test. As we are not painting
102@@ -27,7 +27,7 @@
103 // Get the activityIndicator from the page and wait for it start running.
104 // That means, the rates are being downloaded from the internet."
105 // tryCompare() waits for up to 5 seconds for it to happen
106- var activityIndicator = Helpers.findChild(currencyConverter, "activityIndicator")
107+ var activityIndicator = findChild(currencyConverter, "activityIndicator")
108 tryCompare(activityIndicator, "running", true)
109
110 // Now that we know that the rates are being downloaded, wait for the activityIndicator to stop.

Subscribers

People subscribed via source and target branches