tst_qthreadpool: expect a warning, cleaning up the test run
Change-Id: Ie9944d05e7afe5740ed10eef39c2df9281985002 Reviewed-by: Allan Sandfeld Jensen <allan.jensen@qt.io>
This commit is contained in:
parent
a43ca591c1
commit
f7d1dc0eee
@ -1468,6 +1468,10 @@ void tst_QThreadPool::threadReuse()
|
|||||||
|
|
||||||
void tst_QThreadPool::nullFunctions()
|
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.
|
// Note this is not necessarily testing intended behavior, only undocumented behavior.
|
||||||
// If this is changed it should be noted in Behavioral Changes.
|
// If this is changed it should be noted in Behavioral Changes.
|
||||||
FunctionPointer nullFunction = nullptr;
|
FunctionPointer nullFunction = nullptr;
|
||||||
@ -1475,10 +1479,14 @@ void tst_QThreadPool::nullFunctions()
|
|||||||
{
|
{
|
||||||
TestThreadPool manager;
|
TestThreadPool manager;
|
||||||
// should not crash:
|
// should not crash:
|
||||||
|
expectWarning();
|
||||||
manager.start(nullFunction);
|
manager.start(nullFunction);
|
||||||
|
expectWarning();
|
||||||
manager.start(nullStdFunction);
|
manager.start(nullStdFunction);
|
||||||
// should fail (and not leak):
|
// should fail (and not leak):
|
||||||
|
expectWarning();
|
||||||
QVERIFY(!manager.tryStart(nullStdFunction));
|
QVERIFY(!manager.tryStart(nullStdFunction));
|
||||||
|
expectWarning();
|
||||||
QVERIFY(!manager.tryStart(nullFunction));
|
QVERIFY(!manager.tryStart(nullFunction));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user