summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorRhys Weatherley <rhys.weatherley@nokia.com>2010-10-01 14:49:30 +1000
committerRhys Weatherley <rhys.weatherley@nokia.com>2010-10-01 14:51:05 +1000
commitd6d4cacd5189a6f044b552811e23bf0f1d308e3d (patch)
tree73c23d33bbb99bab3dcd0e1ddeff4909ee5a76a1
parent05e733fd717525654bba6fe27c6a54f5a5bfd90c (diff)
Add the "when" property for controlling when a test case starts
-rw-r--r--QtTest/TestCase.qml17
-rw-r--r--QtTest/TestCaseBase.qml27
2 files changed, 35 insertions, 9 deletions
diff --git a/QtTest/TestCase.qml b/QtTest/TestCase.qml
index 6b81ca4..8e06716 100644
--- a/QtTest/TestCase.qml
+++ b/QtTest/TestCase.qml
@@ -3,12 +3,15 @@ import QtTest 1.0
TestCaseBase {
Component.onCompleted: {
- print("********* Start testing of " + name + " *********")
- var success = run()
- print("Totals: " + numPassed + " passed, " +
- numFailed + " failed, " +
- numSkipped + " skipped");
- print("********* Finished testing of " + name + " *********")
- Qt.quit() // XXX - how do we set the exit value?
+ prevWhen = when
+ if (when && !completed && !running) {
+ print("********* Start testing of " + name + " *********")
+ var success = run()
+ print("Totals: " + numPassed + " passed, " +
+ numFailed + " failed, " +
+ numSkipped + " skipped");
+ print("********* Finished testing of " + name + " *********")
+ Qt.quit() // XXX - how do we set the exit value?
+ }
}
}
diff --git a/QtTest/TestCaseBase.qml b/QtTest/TestCaseBase.qml
index 8775db9..eeafd98 100644
--- a/QtTest/TestCaseBase.qml
+++ b/QtTest/TestCaseBase.qml
@@ -3,15 +3,27 @@ import Qt 4.7
Item {
id: testCase
visible: false
+
+ // Name of the test case to prefix the function name in messages.
property string name
- property variant tests: []
+ // Set to true to start the test running.
+ property bool when: true
+
+ // Set to true once the test has completed.
+ property bool completed: false
+
+ // Set to true when the test is running but not yet complete.
+ property bool running: false
+
+ // Internal private state
property string currentTestCase
property int numPassed
property int numFailed
property int numSkipped
property bool expectingFail
property string expectFailMsg
+ property bool prevWhen: true
function fail(msg) {
if (!msg)
@@ -101,6 +113,7 @@ Item {
numPassed = 0
numFailed = 0
numSkipped = 0
+ running = true
for (var prop in testCase) {
if (prop.indexOf("test_") != 0)
continue
@@ -142,6 +155,16 @@ Item {
}
}
currentTestCase = ""
- return success;
+ running = false
+ completed = true
+ return success
+ }
+
+ onWhenChanged: {
+ if (when != prevWhen) {
+ prevWhen = when
+ if (when && !completed && !running)
+ run()
+ }
}
}