diff options
Diffstat (limited to 'tests/auto/integration/qmediaplayerbackend/tst_qmediaplayerbackend.cpp')
-rw-r--r-- | tests/auto/integration/qmediaplayerbackend/tst_qmediaplayerbackend.cpp | 48 |
1 files changed, 48 insertions, 0 deletions
diff --git a/tests/auto/integration/qmediaplayerbackend/tst_qmediaplayerbackend.cpp b/tests/auto/integration/qmediaplayerbackend/tst_qmediaplayerbackend.cpp index af4e2c275..ec520e901 100644 --- a/tests/auto/integration/qmediaplayerbackend/tst_qmediaplayerbackend.cpp +++ b/tests/auto/integration/qmediaplayerbackend/tst_qmediaplayerbackend.cpp @@ -78,8 +78,10 @@ private slots: void playlistObject(); void surfaceTest_data(); void surfaceTest(); + void multipleSurfaces(); void metadata(); void playerStateAtEOS(); + void playFromBuffer(); private: QMediaContent selectVideoFile(const QStringList& mediaCandidates); @@ -1389,6 +1391,33 @@ void tst_QMediaPlayerBackend::surfaceTest() QVERIFY2(surface.m_totalFrames >= 25, qPrintable(QString("Expected >= 25, got %1").arg(surface.m_totalFrames))); } +void tst_QMediaPlayerBackend::multipleSurfaces() +{ + if (localVideoFile.isNull()) + QSKIP("No supported video file"); + + QList<QVideoFrame::PixelFormat> formats1; + formats1 << QVideoFrame::Format_RGB32 + << QVideoFrame::Format_ARGB32; + QList<QVideoFrame::PixelFormat> formats2; + formats2 << QVideoFrame::Format_YUV420P + << QVideoFrame::Format_RGB32; + + TestVideoSurface surface1(false); + surface1.setSupportedFormats(formats1); + TestVideoSurface surface2(false); + surface2.setSupportedFormats(formats2); + + QMediaPlayer player; + player.setVideoOutput(QVector<QAbstractVideoSurface *>() << &surface1 << &surface2); + player.setMedia(localVideoFile); + player.play(); + QTRY_VERIFY(player.position() >= 1000); + QVERIFY2(surface1.m_totalFrames >= 25, qPrintable(QString("Expected >= 25, got %1").arg(surface1.m_totalFrames))); + QVERIFY2(surface2.m_totalFrames >= 25, qPrintable(QString("Expected >= 25, got %1").arg(surface2.m_totalFrames))); + QCOMPARE(surface1.m_totalFrames, surface2.m_totalFrames); +} + void tst_QMediaPlayerBackend::metadata() { if (localFileWithMetadata.isNull()) @@ -1444,6 +1473,25 @@ void tst_QMediaPlayerBackend::playerStateAtEOS() QVERIFY(endOfMediaReceived); } +void tst_QMediaPlayerBackend::playFromBuffer() +{ + if (localVideoFile.isNull()) + QSKIP("No supported video file"); + + TestVideoSurface surface(false); + QMediaPlayer player; + player.setVideoOutput(&surface); + QFile file(localVideoFile.request().url().toLocalFile()); + if (!file.open(QIODevice::ReadOnly)) + QSKIP("Could not open file"); + player.setMedia(localVideoFile, &file); + player.play(); + QTRY_VERIFY(player.position() >= 1000); + if (surface.error() == QAbstractVideoSurface::UnsupportedFormatError) + QSKIP("None of the pixel formats is supported by the backend"); + QVERIFY2(surface.m_totalFrames >= 25, qPrintable(QString("Expected >= 25, got %1").arg(surface.m_totalFrames))); +} + TestVideoSurface::TestVideoSurface(bool storeFrames): m_totalFrames(0), m_storeFrames(storeFrames) |