diff options
author | Albert Astals Cid <albert.astals@canonical.com> | 2013-08-02 12:44:32 +0200 |
---|---|---|
committer | The Qt Project <gerrit-noreply@qt-project.org> | 2013-08-05 12:00:35 +0200 |
commit | b96479032c3c0c02d9444efe90ccc5ea862d886c (patch) | |
tree | 5e3fdc7ecbcd32e3f776786b7f8a2e8b69fd11e5 /src/imports/testlib/TestCase.qml | |
parent | 45792359f25813af18b7416e4c18737ed4b20bff (diff) |
Allow passing a message to tryCompare
Also adds a check to make sure timeout is a number, for people
that are moving from compare() to tryCompare() and forget of the extra
timeout parameter
Change-Id: I54e56e2014c022e06622edebca1fd36172c75009
Reviewed-by: Yunqiao Yin <charles@mazymind.com>
Reviewed-by: Caroline Chao <caroline.chao@digia.com>
Diffstat (limited to 'src/imports/testlib/TestCase.qml')
-rw-r--r-- | src/imports/testlib/TestCase.qml | 11 |
1 files changed, 9 insertions, 2 deletions
diff --git a/src/imports/testlib/TestCase.qml b/src/imports/testlib/TestCase.qml index 0bec4cddf2..6e2c8e73ab 100644 --- a/src/imports/testlib/TestCase.qml +++ b/src/imports/testlib/TestCase.qml @@ -290,14 +290,21 @@ Item { return qtest_results.grabImage(item); } - function tryCompare(obj, prop, value, timeout) { + function tryCompare(obj, prop, value, timeout, msg) { if (arguments.length == 2) { qtest_results.fail("A value is required for tryCompare", util.callerFile(), util.callerLine()) throw new Error("QtQuickTest::fail") } + if (timeout !== undefined && typeof(timeout) != "number") { + qtest_results.fail("timeout should be a number", + util.callerFile(), util.callerLine()) + throw new Error("QtQuickTest::fail") + } if (!timeout) timeout = 5000 + if (msg === undefined) + msg = "property " + prop if (!qtest_compareInternal(obj[prop], value)) wait(0) var i = 0 @@ -309,7 +316,7 @@ Item { var act = qtest_results.stringify(actual) var exp = qtest_results.stringify(value) var success = qtest_compareInternal(actual, value) - if (!qtest_results.compare(success, "property " + prop, act, exp, util.callerFile(), util.callerLine())) + if (!qtest_results.compare(success, msg, act, exp, util.callerFile(), util.callerLine())) throw new Error("QtQuickTest::fail") } |