diff options
author | Lev Zelenskiy <lev.zelenskiy@nokia.com> | 2012-03-22 17:10:19 +1000 |
---|---|---|
committer | Qt by Nokia <qt-info@nokia.com> | 2012-03-23 06:37:42 +0100 |
commit | ba43d50b31098b0e76d2c5797b997b1dcd3f3441 (patch) | |
tree | 0c9b98717dfd5141f2b4c811d3d84e26ac805892 /tests/auto/integration/qmediaplayerbackend | |
parent | 5d6494f2487e65154c1caedfa09bfd407546af72 (diff) |
Fixes to qmediaplayerbackend integration test: use ogg video on Linux.
Attempt to find supported video format before running tests.
Tests are skipped if no video format is supported by the system.
Change-Id: Iad5b26438b6407f0808e288c5e6184f220f30e36
Reviewed-by: Ling Hu <ling.hu@nokia.com>
Reviewed-by: Michael Goddard <michael.goddard@nokia.com>
Reviewed-by: Jonas Rabbe <jonas.rabbe@nokia.com>
Diffstat (limited to 'tests/auto/integration/qmediaplayerbackend')
-rw-r--r-- | tests/auto/integration/qmediaplayerbackend/testdata/colors.ogv | bin | 0 -> 12090 bytes | |||
-rw-r--r-- | tests/auto/integration/qmediaplayerbackend/tst_qmediaplayerbackend.cpp | 47 |
2 files changed, 38 insertions, 9 deletions
diff --git a/tests/auto/integration/qmediaplayerbackend/testdata/colors.ogv b/tests/auto/integration/qmediaplayerbackend/testdata/colors.ogv Binary files differnew file mode 100644 index 000000000..e18a5e88a --- /dev/null +++ b/tests/auto/integration/qmediaplayerbackend/testdata/colors.ogv diff --git a/tests/auto/integration/qmediaplayerbackend/tst_qmediaplayerbackend.cpp b/tests/auto/integration/qmediaplayerbackend/tst_qmediaplayerbackend.cpp index 7828555fc..d40dd2253 100644 --- a/tests/auto/integration/qmediaplayerbackend/tst_qmediaplayerbackend.cpp +++ b/tests/auto/integration/qmediaplayerbackend/tst_qmediaplayerbackend.cpp @@ -83,6 +83,7 @@ private slots: private: //one second local wav file QMediaContent localWavFile; + QMediaContent localVideoFile; }; /* @@ -138,6 +139,35 @@ void tst_QMediaPlayerBackend::initTestCase() localWavFile = QMediaContent(QUrl::fromLocalFile(wavFile.absoluteFilePath())); qRegisterMetaType<QMediaContent>(); + + // select supported video format + QMediaPlayer player; + TestVideoSurface *surface = new TestVideoSurface; + player.setVideoOutput(surface); + + QSignalSpy errorSpy(&player, SIGNAL(error(QMediaPlayer::Error))); + + QStringList mediaCandidates; + mediaCandidates << QFINDTESTDATA("testdata/colors.ogv"); + mediaCandidates << QFINDTESTDATA("testdata/colors.mp4"); + + foreach (QString s, mediaCandidates) { + QFileInfo videoFile(s); + QVERIFY(videoFile.exists()); + QMediaContent media = QMediaContent(QUrl::fromLocalFile(videoFile.absoluteFilePath())); + player.setMedia(media); + player.pause(); + + for (int i = 0; i < 2000 && surface->m_frameList.isEmpty() && errorSpy.isEmpty(); i+=50) { + QTest::qWait(50); + } + + if (!surface->m_frameList.isEmpty() && errorSpy.isEmpty()) { + localVideoFile = media; + break; + } + errorSpy.clear(); + } } void tst_QMediaPlayerBackend::cleanup() @@ -455,6 +485,9 @@ void tst_QMediaPlayerBackend::volumeAcrossFiles() void tst_QMediaPlayerBackend::seekPauseSeek() { + if (localVideoFile.isNull()) + QSKIP("Video format is not supported"); + QMediaPlayer player; QSignalSpy positionSpy(&player, SIGNAL(positionChanged(qint64))); @@ -462,11 +495,7 @@ void tst_QMediaPlayerBackend::seekPauseSeek() TestVideoSurface *surface = new TestVideoSurface; player.setVideoOutput(surface); - const QString testFileName = QFINDTESTDATA("testdata/colors.mp4"); - QFileInfo videoFile(testFileName); - QVERIFY(videoFile.exists()); - - player.setMedia(QUrl::fromLocalFile(videoFile.absoluteFilePath())); + player.setMedia(localVideoFile); QCOMPARE(player.state(), QMediaPlayer::StoppedState); QVERIFY(surface->m_frameList.isEmpty()); // frame must not appear until we call pause() or play() @@ -521,6 +550,9 @@ void tst_QMediaPlayerBackend::seekPauseSeek() void tst_QMediaPlayerBackend::probes() { + if (localVideoFile.isNull()) + QSKIP("Video format is not supported"); + QMediaPlayer *player = new QMediaPlayer; TestVideoSurface *surface = new TestVideoSurface; @@ -538,10 +570,7 @@ void tst_QMediaPlayerBackend::probes() QVERIFY(videoProbe->setSource(player)); QVERIFY(audioProbe->setSource(player)); - const QString testFileName = QFINDTESTDATA("testdata/colors.mp4"); - QFileInfo videoFile(testFileName); - QVERIFY(videoFile.exists()); - player->setMedia(QUrl::fromLocalFile(videoFile.absoluteFilePath())); + player->setMedia(localVideoFile); QTRY_COMPARE(player->mediaStatus(), QMediaPlayer::LoadedMedia); player->pause(); |