Commit 586abbd9 authored by Yoann Lopes's avatar Yoann Lopes Committed by Liang Qi
Browse files

Make tst_QMediaObject::notifySignals() less flaky


Rather than expecting a certain amount of signals to be fired within
a fixed period, check that all the required signals are emitted and
that it doesn't take longer than expected. Use a margin of error to
take into account timers firing later because of high system load.

Change-Id: I7f77d32a9db3d09881eadbd0dfc6b70f62757d09
Reviewed-by: default avatarChristian Stromme <christian.stromme@qt.io>
Showing with 8 additions and 3 deletions
......@@ -288,14 +288,19 @@ void tst_QMediaObject::notifySignals()
QFETCH(int, count);
QtTestMediaObject object;
QSignalSpy spy(&object, SIGNAL(aChanged(int)));
object.setNotifyInterval(interval);
object.addPropertyWatch("a");
QSignalSpy spy(&object, SIGNAL(aChanged(int)));
QElapsedTimer timer;
timer.start();
QTestEventLoop::instance().enterLoop(1);
QTRY_COMPARE(spy.count(), count);
QCOMPARE(spy.count(), count);
qint64 elapsed = timer.elapsed();
int expectedElapsed = count * interval * 1.3; // give it some margin of error
QVERIFY2(elapsed < expectedElapsed, QString("elapsed: %1, expected: %2").arg(elapsed).arg(expectedElapsed).toLocal8Bit().constData());
}
void tst_QMediaObject::notifyInterval_data()
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment