diff options
author | Andrei Golubev <andrei.golubev@qt.io> | 2021-12-02 14:09:44 +0100 |
---|---|---|
committer | Andrei Golubev <andrei.golubev@qt.io> | 2021-12-04 03:50:06 +0100 |
commit | ab287508d56a6735fc877ff0efa8da517e849ac3 (patch) | |
tree | 39fafb8429fb0995db86ac5907cb916be9b5ae4d /src/qmltest/quicktestresult.cpp | |
parent | e64c04b1409769118a9324f9c07a30a0bb81013a (diff) |
QML test lib: propagate failOnWarning() feature to QML
With efb283fb7f72e950c8ecf755b960a3c1b36b5507 in qtbase, we can now
fail a test if a particular warning is encountered. Let's also have this
functionality in QML as it seems useful there as well
[ChangeLog][QtQuickTest][TestCase] Added failOnWarning() for allowing to
fail a test if a particular warning is output during that test execution
Change-Id: I011ed119c318859a2bccd98f0d491904b10305e5
Reviewed-by: Mitch Curtis <mitch.curtis@qt.io>
Diffstat (limited to 'src/qmltest/quicktestresult.cpp')
-rw-r--r-- | src/qmltest/quicktestresult.cpp | 13 |
1 files changed, 12 insertions, 1 deletions
diff --git a/src/qmltest/quicktestresult.cpp b/src/qmltest/quicktestresult.cpp index 0853c26f51..e4ef4e68ae 100644 --- a/src/qmltest/quicktestresult.cpp +++ b/src/qmltest/quicktestresult.cpp @@ -645,13 +645,24 @@ void QuickTestResult::ignoreWarning(const QJSValue &message) { if (message.isRegExp()) { #if QT_CONFIG(regularexpression) - QTestLog::ignoreMessage(QtWarningMsg, message.toVariant().toRegularExpression()); + QTestLog::ignoreMessage(QtWarningMsg, qjsvalue_cast<QRegularExpression>(message)); #endif } else { QTestLog::ignoreMessage(QtWarningMsg, message.toString().toUtf8()); } } +void QuickTestResult::failOnWarning(const QJSValue &message) +{ + if (message.isRegExp()) { +#if QT_CONFIG(regularexpression) + QTestLog::failOnWarning(qjsvalue_cast<QRegularExpression>(message)); +#endif + } else { + QTestLog::failOnWarning(message.toString().toUtf8()); + } +} + void QuickTestResult::wait(int ms) { QTest::qWait(ms); |