QTimer: use QTest::ingoreMessage() for negative internvals tests

Pick-to: 6.7 6.6 6.5
Change-Id: I87d095b748a7488a71b22710ab7ed72d9451c769
Reviewed-by: Ivan Solovev <ivan.solovev@qt.io>
bb10
Ahmad Samir 2024-02-14 22:03:38 +02:00
parent 039d51835f
commit 026e1e3fdb
1 changed files with 15 additions and 0 deletions

View File

@ -1291,13 +1291,20 @@ void tst_QTimer::bindToTimer()
timer.stop();
QVERIFY(!active);
auto ignoreMsg = [] {
QTest::ignoreMessage(QtWarningMsg,
"QObject::startTimer: Timers cannot have negative intervals");
};
// also test that using negative interval updates the binding correctly
timer.start(100);
QVERIFY(active);
ignoreMsg();
timer.setInterval(-100);
QVERIFY(!active);
timer.start(100);
QVERIFY(active);
ignoreMsg();
timer.start(-100);
QVERIFY(!active);
}
@ -1382,9 +1389,15 @@ void tst_QTimer::automatedBindingTests()
void tst_QTimer::negativeInterval()
{
auto ignoreMsg = [] {
QTest::ignoreMessage(QtWarningMsg,
"QObject::startTimer: Timers cannot have negative intervals");
};
QTimer timer;
// Starting with a negative interval does not change active state.
ignoreMsg();
timer.start(-100ms);
QVERIFY(!timer.isActive());
@ -1392,6 +1405,7 @@ void tst_QTimer::negativeInterval()
// the active state.
timer.start(100ms);
QVERIFY(timer.isActive());
ignoreMsg();
timer.setInterval(-100);
QVERIFY(!timer.isActive());
@ -1399,6 +1413,7 @@ void tst_QTimer::negativeInterval()
// and inactive state.
timer.start(100);
QVERIFY(timer.isActive());
ignoreMsg();
timer.start(-100ms);
QVERIFY(!timer.isActive());
}