From 494eafa612a88ca8edd8dfc128408ea651fa2a1e Mon Sep 17 00:00:00 2001 From: Val Doroshchuk Date: Wed, 11 Sep 2019 15:39:00 +0200 Subject: DirectShow: Fix tst_QMediaPlayerBackend::seekPauseSeek Fixed tests about start times. Since DirectShow can provide frames with negative start time, also from the beginning, also pixels can vary, e.g. (rgb) 255:0:0 would be 230:19:19 after decoding. Task-number: QTBUG-46368 Change-Id: I025f7cf9238ddf9ba2a04f63e3e54b77f3cceafe Reviewed-by: Ville Voutilainen --- .../qmediaplayerbackend/tst_qmediaplayerbackend.cpp | 20 ++++++++++++-------- 1 file changed, 12 insertions(+), 8 deletions(-) diff --git a/tests/auto/integration/qmediaplayerbackend/tst_qmediaplayerbackend.cpp b/tests/auto/integration/qmediaplayerbackend/tst_qmediaplayerbackend.cpp index 9d29025c8..df218be7f 100644 --- a/tests/auto/integration/qmediaplayerbackend/tst_qmediaplayerbackend.cpp +++ b/tests/auto/integration/qmediaplayerbackend/tst_qmediaplayerbackend.cpp @@ -791,16 +791,18 @@ void tst_QMediaPlayerBackend::seekPauseSeek() player.pause(); QTRY_COMPARE(player.state(), QMediaPlayer::PausedState); // it might take some time for the operation to be completed - QTRY_VERIFY(!surface->m_frameList.isEmpty()); // we must see a frame at position 7000 here + QTRY_VERIFY_WITH_TIMEOUT(!surface->m_frameList.isEmpty(), 10000); // we must see a frame at position 7000 here // Make sure that the frame has a timestamp before testing - not all backends provides this - if (surface->m_frameList.back().startTime() < 0) + if (!surface->m_frameList.back().isValid() || surface->m_frameList.back().startTime() < 0) QSKIP("No timestamp"); { QVideoFrame frame = surface->m_frameList.back(); +#if !QT_CONFIG(directshow) const qint64 elapsed = (frame.startTime() / 1000) - position; // frame.startTime() is microsecond, position is milliseconds. QVERIFY2(qAbs(elapsed) < (qint64)500, QByteArray::number(elapsed).constData()); +#endif QCOMPARE(frame.width(), 160); QCOMPARE(frame.height(), 120); @@ -808,9 +810,9 @@ void tst_QMediaPlayerBackend::seekPauseSeek() QVERIFY(frame.map(QAbstractVideoBuffer::ReadOnly)); QImage image(frame.bits(), frame.width(), frame.height(), QVideoFrame::imageFormatFromPixelFormat(frame.pixelFormat())); QVERIFY(!image.isNull()); - QVERIFY(qRed(image.pixel(0, 0)) >= 240); // conversion from YUV => RGB, that's why it's not 255 - QCOMPARE(qGreen(image.pixel(0, 0)), 0); - QCOMPARE(qBlue(image.pixel(0, 0)), 0); + QVERIFY(qRed(image.pixel(0, 0)) >= 230); // conversion from YUV => RGB, that's why it's not 255 + QVERIFY(qGreen(image.pixel(0, 0)) < 20); + QVERIFY(qBlue(image.pixel(0, 0)) < 20); frame.unmap(); } @@ -824,17 +826,19 @@ void tst_QMediaPlayerBackend::seekPauseSeek() { QVideoFrame frame = surface->m_frameList.back(); +#if !QT_CONFIG(directshow) const qint64 elapsed = (frame.startTime() / 1000) - position; QVERIFY2(qAbs(elapsed) < (qint64)500, QByteArray::number(elapsed).constData()); +#endif QCOMPARE(frame.width(), 160); QCOMPARE(frame.height(), 120); QVERIFY(frame.map(QAbstractVideoBuffer::ReadOnly)); QImage image(frame.bits(), frame.width(), frame.height(), QVideoFrame::imageFormatFromPixelFormat(frame.pixelFormat())); QVERIFY(!image.isNull()); - QCOMPARE(qRed(image.pixel(0, 0)), 0); - QVERIFY(qGreen(image.pixel(0, 0)) >= 240); - QCOMPARE(qBlue(image.pixel(0, 0)), 0); + QVERIFY(qRed(image.pixel(0, 0)) < 20); + QVERIFY(qGreen(image.pixel(0, 0)) >= 230); + QVERIFY(qBlue(image.pixel(0, 0)) < 20); frame.unmap(); } } -- cgit v1.2.3