aboutsummaryrefslogtreecommitdiffstats
path: root/src/imports/testlib
diff options
context:
space:
mode:
authorRobin Burchell <robin.burchell@crimson.no>2017-01-12 10:52:02 +0100
committerLiang Qi <liang.qi@qt.io>2018-04-09 17:25:42 +0000
commitf257be627cc9de4fdec430e2fe8f6ac3b6827070 (patch)
tree4a1a07adf994c4f7a448fa2fae51ec7703a0340a /src/imports/testlib
parent61b7f5a0c1280d93d00c74e393c8244be626168c (diff)
testlib: Support regular expression ignores in ignoreMessage
This is a feature C++ has that the QML side lacked. [ChangeLog][Qt Quick Test][TestCase] ignoreWarning now supports ignoring regular expressions as well as strings. Task-number: QTBUG-47111 Change-Id: If3b7b78365e60f1d8d276050ba7e00fac43400e1 Reviewed-by: Kari Oikarinen <kari.oikarinen@qt.io> Reviewed-by: Simon Hausmann <simon.hausmann@qt.io>
Diffstat (limited to 'src/imports/testlib')
-rw-r--r--src/imports/testlib/TestCase.qml18
1 files changed, 18 insertions, 0 deletions
diff --git a/src/imports/testlib/TestCase.qml b/src/imports/testlib/TestCase.qml
index 8e9b016444..e1dee1e74d 100644
--- a/src/imports/testlib/TestCase.qml
+++ b/src/imports/testlib/TestCase.qml
@@ -1084,6 +1084,24 @@ Item {
does not occur, then the test will fail. Similar to
\c{QTest::ignoreMessage(QtWarningMsg, message)} in C++.
+ Since Qt 5.12, \a message can be either a string, or a regular
+ expression providing a pattern of messages to ignore.
+
+ For example, the following snippet will ignore a string warning message:
+ \qml
+ ignoreWarning("Something sort of bad happened")
+ \endqml
+
+ And the following snippet will ignore a regular expression matching a
+ number of possible warning messages:
+ \qml
+ ignoreWarning(new RegExp("[0-9]+ bad things happened"))
+ \endqml
+
+ \note Despite being a JavaScript RegExp object, it will not be
+ interpreted as such; instead, the pattern will be passed to
+ \l QRegularExpression.
+
\sa warn()
*/
function ignoreWarning(msg) {