From 01714ef0c5ee80544e3799ae2a66d9a611c9d71f Mon Sep 17 00:00:00 2001 From: Friedemann Kleint Date: Mon, 17 Feb 2014 14:19:44 +0100 Subject: [PATCH] Use QVERIFY2 for elapsed time in tst_QMediaPlayerBackend::seekPauseSeek(). The test has been observed to fail sometimes, try to obtain values. Change-Id: Id0374b7ad3d593c099500e771bc4d8cc50f26651 Reviewed-by: Yoann Lopes --- .../qmediaplayerbackend/tst_qmediaplayerbackend.cpp | 16 ++++++++++------ 1 file changed, 10 insertions(+), 6 deletions(-) diff --git a/tests/auto/integration/qmediaplayerbackend/tst_qmediaplayerbackend.cpp b/tests/auto/integration/qmediaplayerbackend/tst_qmediaplayerbackend.cpp index e5b115b..380e344 100644 --- a/tests/auto/integration/qmediaplayerbackend/tst_qmediaplayerbackend.cpp +++ b/tests/auto/integration/qmediaplayerbackend/tst_qmediaplayerbackend.cpp @@ -630,8 +630,9 @@ void tst_QMediaPlayerBackend::seekPauseSeek() QVERIFY(surface->m_frameList.isEmpty()); // frame must not appear until we call pause() or play() positionSpy.clear(); - player.setPosition((qint64)7000); - QTRY_VERIFY(!positionSpy.isEmpty() && qAbs(player.position() - (qint64)7000) < (qint64)500); + qint64 position = 7000; + player.setPosition(position); + QTRY_VERIFY(!positionSpy.isEmpty() && qAbs(player.position() - position) < (qint64)500); QCOMPARE(player.state(), QMediaPlayer::StoppedState); QTest::qWait(250); // wait a bit to ensure the frame is not rendered QVERIFY(surface->m_frameList.isEmpty()); // still no frame, we must call pause() or play() to see a frame @@ -642,7 +643,8 @@ void tst_QMediaPlayerBackend::seekPauseSeek() { QVideoFrame frame = surface->m_frameList.back(); - QVERIFY(qAbs(frame.startTime() - (qint64)7000) < (qint64)500); + const qint64 elapsed = frame.startTime() - position; + QVERIFY2(qAbs(elapsed) < (qint64)500, QByteArray::number(elapsed).constData()); QCOMPARE(frame.width(), 160); QCOMPARE(frame.height(), 120); @@ -657,14 +659,16 @@ void tst_QMediaPlayerBackend::seekPauseSeek() } positionSpy.clear(); - player.setPosition((qint64)12000); - QTRY_VERIFY(!positionSpy.isEmpty() && qAbs(player.position() - (qint64)12000) < (qint64)500); + position = 12000; + player.setPosition(position); + QTRY_VERIFY(!positionSpy.isEmpty() && qAbs(player.position() - position) < (qint64)500); QCOMPARE(player.state(), QMediaPlayer::PausedState); QCOMPARE(surface->m_frameList.size(), 2); { QVideoFrame frame = surface->m_frameList.back(); - QVERIFY(qAbs(frame.startTime() - (qint64)12000) < (qint64)500); + const qint64 elapsed = frame.startTime() - position; + QVERIFY2(qAbs(elapsed) < (qint64)500, QByteArray::number(elapsed).constData()); QCOMPARE(frame.width(), 160); QCOMPARE(frame.height(), 120); -- 2.7.4