From f7d1dc0eeeca42c07b42d3a851c52ccf84e946e5 Mon Sep 17 00:00:00 2001 From: Marc Mutz Date: Thu, 4 May 2023 11:23:44 +0200 Subject: [PATCH] tst_qthreadpool: expect a warning, cleaning up the test run Change-Id: Ie9944d05e7afe5740ed10eef39c2df9281985002 Reviewed-by: Allan Sandfeld Jensen --- tests/auto/corelib/thread/qthreadpool/tst_qthreadpool.cpp | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/tests/auto/corelib/thread/qthreadpool/tst_qthreadpool.cpp b/tests/auto/corelib/thread/qthreadpool/tst_qthreadpool.cpp index 0c4f11a0dc1..775dd85b863 100644 --- a/tests/auto/corelib/thread/qthreadpool/tst_qthreadpool.cpp +++ b/tests/auto/corelib/thread/qthreadpool/tst_qthreadpool.cpp @@ -1468,6 +1468,10 @@ void tst_QThreadPool::threadReuse() void tst_QThreadPool::nullFunctions() { + const auto expectWarning = [] { + QTest::ignoreMessage(QtMsgType::QtWarningMsg, + "Trying to create null QRunnable. This may stop working."); + }; // Note this is not necessarily testing intended behavior, only undocumented behavior. // If this is changed it should be noted in Behavioral Changes. FunctionPointer nullFunction = nullptr; @@ -1475,10 +1479,14 @@ void tst_QThreadPool::nullFunctions() { TestThreadPool manager; // should not crash: + expectWarning(); manager.start(nullFunction); + expectWarning(); manager.start(nullStdFunction); // should fail (and not leak): + expectWarning(); QVERIFY(!manager.tryStart(nullStdFunction)); + expectWarning(); QVERIFY(!manager.tryStart(nullFunction)); } }