aboutsummaryrefslogtreecommitdiffstats
path: root/src/imports/testlib/TestCase.qml
diff options
context:
space:
mode:
authorCharles Yin <charles.yin@nokia.com>2011-07-20 11:28:26 +1000
committerQt by Nokia <qt-info@nokia.com>2011-07-20 05:36:02 +0200
commit29cf717366623bceb4d4e3009600cfa538529c10 (patch)
tree0a82d6887057a21c4ac1bde69e9fb3e46f5d53d3 /src/imports/testlib/TestCase.qml
parenta1867e5c6229e171b0fac3e57b96295221f2ea0a (diff)
fix qmltest bugs
Change-Id: If814516b1094b85fba46e215b44e1a2b582179c5 Reviewed-on: http://codereview.qt.nokia.com/1858 Reviewed-by: Qt Sanity Bot <qt_sanity_bot@ovi.com> Reviewed-by: Charles Yin <charles.yin@nokia.com>
Diffstat (limited to 'src/imports/testlib/TestCase.qml')
-rw-r--r--src/imports/testlib/TestCase.qml13
1 files changed, 7 insertions, 6 deletions
diff --git a/src/imports/testlib/TestCase.qml b/src/imports/testlib/TestCase.qml
index 22fd5b66bb..1a222a6138 100644
--- a/src/imports/testlib/TestCase.qml
+++ b/src/imports/testlib/TestCase.qml
@@ -145,6 +145,7 @@ Item {
if ("mapFromItem" in o && "mapToItem" in o) {
return "declarativeitem"; // @todo improve detection of declarative items
} else if ("x" in o && "y" in o && "z" in o) {
+ console.log("typeof debug:" + o);
return "vector3d"; // Qt3D vector
}
return "object";
@@ -162,18 +163,17 @@ Item {
// Author: Philippe Rathé <prathe@gmail.com>
function qtest_compareInternal(act, exp) {
var success = false;
-
if (act === exp) {
success = true; // catch the most you can
} else if (act === null || exp === null || typeof act === "undefined" || typeof exp === "undefined") {
success = false; // don't lose time with error prone cases
} else {
var typeExp = qtest_typeof(exp), typeAct = qtest_typeof(act)
-
if (typeExp !== typeAct) {
// allow object vs string comparison (e.g. for colors)
// else break on different types
- if ((typeExp === "string" && typeAct === "object") || (typeExp === "object" && typeAct === "string")) {
+ if ((typeExp === "string" && (typeAct === "object") || typeAct == "declarativeitem")
+ || ((typeExp === "object" || typeExp == "declarativeitem") && typeAct === "string")) {
success = (act == exp)
}
} else if (typeExp === "string" || typeExp === "boolean" || typeExp === "number" ||
@@ -227,7 +227,6 @@ Item {
for (i in act) { // be strict: don't ensures hasOwnProperty and go deep
aProperties.push(i); // collect act's properties
-
if (!qtest_compareInternal(act[i], exp[i])) {
eq = false;
break;
@@ -258,7 +257,7 @@ Item {
}
function qtest_formatValue(value) {
- if (typeof value == "object") {
+ if (qtest_typeof(value) == "object") {
if ("x" in value && "y" in value && "z" in value) {
return "Qt.vector3d(" + value.x + ", " +
value.y + ", " + value.z + ")"
@@ -275,6 +274,7 @@ Item {
function compare(actual, expected, msg) {
var act = qtest_formatValue(actual)
var exp = qtest_formatValue(expected)
+
var success = qtest_compareInternal(actual, expected)
if (msg === undefined) {
if (success)
@@ -282,8 +282,9 @@ Item {
else
msg = "Compared values are not the same"
}
- if (!qtest_results.compare(success, msg, act, exp, util.callerFile(), util.callerLine()))
+ if (!qtest_results.compare(success, msg, act, exp, util.callerFile(), util.callerLine())) {
throw new Error("QtQuickTest::fail")
+ }
}
function tryCompare(obj, prop, value, timeout) {