diff options
author | Jason McDonald <jason.mcdonald@nokia.com> | 2012-02-29 15:43:42 +1000 |
---|---|---|
committer | Qt by Nokia <qt-info@nokia.com> | 2012-03-08 05:31:40 +0100 |
commit | d81b065bb3cea85a98f2299354d05ce440032f1f (patch) | |
tree | 1b6a25357b1f11fd3088357697adcbc18f5ddc30 /src/testlib/qtest_gui.h | |
parent | 0eb95222acbd73713a934f0e1d2b291e858ec471 (diff) |
testlib: Improve verbose and XPASS output
Previously, verbose (-v2) and XPASS test output showed all QCOMPAREs as
"COMPARE()", making it impossible to see what was compared and difficult
to match the output to the source of a test containing many calls to
QCOMPARE.
This commit changes testlib's internal compare_helper API so that string
representations of the compared expressions are always passed to
QTestResult::compare() when available, and can thus be shown in the
verbose and XPASS output. The XPASS output has also been changed to
state explicitly that the comparison succeeded unexpectedly, bringing it
in line with the XPASS output resulting from a call to QVERIFY.
This commit also changes all calls to compare_helper() to call the
eight-argument version of the function, which simplifies much of the
calling code. The now obsolete four-argument version of
compare_helper() has been changed to output a warning that it is
obsolete. It will be removed once other modules have had some time to
catch up.
The improved XPASS and verbose output is demonstrated by the expectfail
and verbose2 selftests.
Change-Id: I8baa46d5dd30e6c43b26f366c34dc5b64aab5f7c
Reviewed-by: Rohan McGovern <rohan.mcgovern@nokia.com>
Diffstat (limited to 'src/testlib/qtest_gui.h')
-rw-r--r-- | src/testlib/qtest_gui.h | 20 |
1 files changed, 9 insertions, 11 deletions
diff --git a/src/testlib/qtest_gui.h b/src/testlib/qtest_gui.h index d39e943926..3067c35e02 100644 --- a/src/testlib/qtest_gui.h +++ b/src/testlib/qtest_gui.h @@ -102,29 +102,27 @@ inline bool qCompare(QImage const &t1, QImage const &t2, qsnprintf(msg, 1024, "Compared QImages differ.\n" " Actual (%s).isNull() : %d\n" " Expected (%s).isNull(): %d", actual, t1Null, expected, t2Null); - return compare_helper(false, msg, file, line); + return compare_helper(false, msg, 0, 0, actual, expected, file, line); } if (t1Null && t2Null) - return compare_helper(true, "COMPARE()", file, line); + return compare_helper(true, 0, 0, 0, actual, expected, file, line); if (t1.width() != t2.width() || t2.height() != t2.height()) { qsnprintf(msg, 1024, "Compared QImages differ in size.\n" " Actual (%s) : %dx%d\n" " Expected (%s): %dx%d", actual, t1.width(), t1.height(), expected, t2.width(), t2.height()); - return compare_helper(false, msg, file, line); + return compare_helper(false, msg, 0, 0, actual, expected, file, line); } if (t1.format() != t2.format()) { qsnprintf(msg, 1024, "Compared QImages differ in format.\n" " Actual (%s) : %d\n" " Expected (%s): %d", actual, t1.format(), expected, t2.format()); - return compare_helper(false, msg, file, line); + return compare_helper(false, msg, 0, 0, actual, expected, file, line); } - return (t1 == t2) - ? compare_helper(true, "COMPARE()", file, line) - : compare_helper(false, "Compared values are not the same", - toString(t1), toString(t2), actual, expected, file, line); + return compare_helper(t1 == t2, "Compared values are not the same", + toString(t1), toString(t2), actual, expected, file, line); } #ifndef QTEST_NO_SPECIALIZATIONS @@ -141,17 +139,17 @@ inline bool qCompare(QPixmap const &t1, QPixmap const &t2, const char *actual, c qsnprintf(msg, 1024, "Compared QPixmaps differ.\n" " Actual (%s).isNull() : %d\n" " Expected (%s).isNull(): %d", actual, t1Null, expected, t2Null); - return compare_helper(false, msg, file, line); + return compare_helper(false, msg, 0, 0, actual, expected, file, line); } if (t1Null && t2Null) - return compare_helper(true, "COMPARE()", file, line); + return compare_helper(true, 0, 0, 0, actual, expected, file, line); if (t1.width() != t2.width() || t2.height() != t2.height()) { qsnprintf(msg, 1024, "Compared QPixmaps differ in size.\n" " Actual (%s) : %dx%d\n" " Expected (%s): %dx%d", actual, t1.width(), t1.height(), expected, t2.width(), t2.height()); - return compare_helper(false, msg, file, line); + return compare_helper(false, msg, 0, 0, actual, expected, file, line); } return qCompare(t1.toImage(), t2.toImage(), actual, expected, file, line); } |