From d5b86cd36f4c37335589bd5fc3809b47e3bc1944 Mon Sep 17 00:00:00 2001 From: Charles Yin Date: Thu, 20 Oct 2011 15:27:37 +1000 Subject: [PATCH] Add file and lineno parameters to warn() method Change-Id: I1ddfd4793a26a16bf85b72c50d84080cd0b26a87 Reviewed-by: Michael Brasser --- src/imports/testlib/TestCase.qml | 13 +++++++------ src/qmltest/quicktestresult.cpp | 4 ++-- src/qmltest/quicktestresult_p.h | 2 +- 3 files changed, 10 insertions(+), 9 deletions(-) diff --git a/src/imports/testlib/TestCase.qml b/src/imports/testlib/TestCase.qml index fd04c78..432f96c 100644 --- a/src/imports/testlib/TestCase.qml +++ b/src/imports/testlib/TestCase.qml @@ -271,8 +271,8 @@ Item { } function compare(actual, expected, msg) { - var act = qtest_formatValue(actual) - var exp = qtest_formatValue(expected) + var act = testCase.qtest_formatValue(actual) + var exp = testCase.qtest_formatValue(expected) var success = qtest_compareInternal(actual, expected) if (msg === undefined) { @@ -297,8 +297,8 @@ Item { i += 50 } var actual = obj[prop] - var act = qtest_formatValue(actual) - var exp = qtest_formatValue(value) + var act = testCase.qtest_formatValue(actual) + var exp = testCase.qtest_formatValue(value) var success = qtest_compareInternal(actual, value) if (!qtest_results.compare(success, "property " + prop, act, exp, util.callerFile(), util.callerLine())) throw new Error("QtQuickTest::fail") @@ -348,7 +348,7 @@ Item { function warn(msg) { if (msg === undefined) msg = "" - qtest_results.warn(msg); + qtest_results.warn(msg, util.callerFile(), util.callerLine()); } function ignoreWarning(msg) { @@ -619,7 +619,8 @@ Item { qtest_results.dataTag = "" } if (!haveData) - qtest_results.warn("no data supplied for " + prop + "() by " + datafunc + "()") + qtest_results.warn("no data supplied for " + prop + "() by " + datafunc + "()" + , util.callerFile(), util.callerLine()); qtest_results.clearTestTable() } } else if (isBenchmark) { diff --git a/src/qmltest/quicktestresult.cpp b/src/qmltest/quicktestresult.cpp index 1924be0..7d8080f 100644 --- a/src/qmltest/quicktestresult.cpp +++ b/src/qmltest/quicktestresult.cpp @@ -430,9 +430,9 @@ bool QuickTestResult::expectFailContinue QTest::Continue, qtest_fixFile(file).toLatin1().constData(), line); } -void QuickTestResult::warn(const QString &message) +void QuickTestResult::warn(const QString &message, const QString &file, int line) { - QTestLog::warn(message.toLatin1().constData(), 0, 0); + QTestLog::warn(message.toLatin1().constData(), qtest_fixFile(file).toLatin1().constData(), line); } void QuickTestResult::ignoreWarning(const QString &message) diff --git a/src/qmltest/quicktestresult_p.h b/src/qmltest/quicktestresult_p.h index 8707b56..fdadf9c 100644 --- a/src/qmltest/quicktestresult_p.h +++ b/src/qmltest/quicktestresult_p.h @@ -134,7 +134,7 @@ public Q_SLOTS: const QString &file, int line); bool expectFailContinue(const QString &tag, const QString &comment, const QString &file, int line); - void warn(const QString &message); + void warn(const QString &message, const QString &file, int line); void ignoreWarning(const QString &message); -- 1.7.2.5