Commit 9b162f98 authored by Lev Zelenskiy's avatar Lev Zelenskiy Committed by Qt by Nokia
Browse files

Added integration test for subsequent playback to media player backend.


Change-Id: If060dd78e595b52bbb1c0fb65ede7c84ced873b0
Reviewed-by: default avatarMichael Goddard <michael.goddard@nokia.com>
Reviewed-by: default avatarJonas Rabbe <jonas.rabbe@nokia.com>
parent 02124e8d
dev 5.10 5.11 5.12 5.12.1 5.12.10 5.12.11 5.12.12 5.12.2 5.12.3 5.12.4 5.12.5 5.12.6 5.12.7 5.12.8 5.12.9 5.13 5.13.0 5.13.1 5.13.2 5.14 5.14.0 5.14.1 5.14.2 5.15 5.15.0 5.15.1 5.15.2 5.3 5.4 5.5 5.6 5.7 5.8 5.9 5.9.8 6.2 6.2.0 6.2.1 6.2.2 old/5.0 old/5.1 old/5.2 wip/cmake wip/qt6 v5.15.0-alpha1 v5.14.1 v5.14.0 v5.14.0-rc2 v5.14.0-rc1 v5.14.0-beta3 v5.14.0-beta2 v5.14.0-beta1 v5.14.0-alpha1 v5.13.2 v5.13.1 v5.13.0 v5.13.0-rc3 v5.13.0-rc2 v5.13.0-rc1 v5.13.0-beta4 v5.13.0-beta3 v5.13.0-beta2 v5.13.0-beta1 v5.13.0-alpha1 v5.12.7 v5.12.6 v5.12.5 v5.12.4 v5.12.3 v5.12.2 v5.12.1 v5.12.0 v5.12.0-rc2 v5.12.0-rc1 v5.12.0-beta4 v5.12.0-beta3 v5.12.0-beta2 v5.12.0-beta1 v5.12.0-alpha1 v5.11.3 v5.11.2 v5.11.1 v5.11.0 v5.11.0-rc2 v5.11.0-rc1 v5.11.0-beta4 v5.11.0-beta3 v5.11.0-beta2 v5.11.0-beta1 v5.11.0-alpha1 v5.10.1 v5.10.0 v5.10.0-rc3 v5.10.0-rc2 v5.10.0-rc1 v5.10.0-beta4 v5.10.0-beta3 v5.10.0-beta2 v5.10.0-beta1 v5.10.0-alpha1 v5.9.9 v5.9.8 v5.9.7 v5.9.6 v5.9.5 v5.9.4 v5.9.3 v5.9.2 v5.9.1 v5.9.0 v5.9.0-rc2 v5.9.0-rc1 v5.9.0-beta4 v5.9.0-beta3 v5.9.0-beta2 v5.9.0-beta1 v5.9.0-alpha1 v5.8.0 v5.8.0-rc1 v5.8.0-beta1 v5.8.0-alpha1 v5.7.1 v5.7.0 v5.7.0-rc1 v5.7.0-beta1 v5.7.0-alpha1 v5.6.3 v5.6.2 v5.6.1 v5.6.1-1 v5.6.0 v5.6.0-rc1 v5.6.0-beta1 v5.6.0-alpha1 v5.5.1 v5.5.0 v5.5.0-rc1 v5.5.0-beta1 v5.5.0-alpha1 v5.4.2 v5.4.1 v5.4.0 v5.4.0-rc1 v5.4.0-beta1 v5.4.0-alpha1 v5.3.2 v5.3.1 v5.3.0 v5.3.0-rc1 v5.3.0-beta1 v5.3.0-alpha1 v5.2.1 v5.2.0 v5.2.0-rc1 v5.2.0-beta1 v5.2.0-alpha1 v5.1.1 v5.1.0 v5.1.0-rc2 v5.1.0-rc1 v5.1.0-beta1 v5.1.0-alpha1 v5.0.2 v5.0.1 v5.0.0 v5.0.0-rc2 v5.0.0-rc1 v5.0.0-beta2 v5.0.0-beta1
No related merge requests found
Showing with 96 additions and 18 deletions
File added
File added
...@@ -79,13 +79,18 @@ private slots: ...@@ -79,13 +79,18 @@ private slots:
void volumeAcrossFiles(); void volumeAcrossFiles();
void initialVolume(); void initialVolume();
void seekPauseSeek(); void seekPauseSeek();
void subsequentPlayback();
void probes(); void probes();
void playlist(); void playlist();
private: private:
QMediaContent selectVideoFile(const QStringList& mediaCandidates);
QMediaContent selectSoundFile(const QStringList& mediaCandidates);
//one second local wav file //one second local wav file
QMediaContent localWavFile; QMediaContent localWavFile;
QMediaContent localVideoFile; QMediaContent localVideoFile;
QMediaContent localCompressedSoundFile;
}; };
/* /*
...@@ -131,17 +136,8 @@ void tst_QMediaPlayerBackend::init() ...@@ -131,17 +136,8 @@ void tst_QMediaPlayerBackend::init()
{ {
} }
void tst_QMediaPlayerBackend::initTestCase() QMediaContent tst_QMediaPlayerBackend::selectVideoFile(const QStringList& mediaCandidates)
{ {
const QString testFileName = QFINDTESTDATA("testdata/test.wav");
QFileInfo wavFile(testFileName);
QVERIFY(wavFile.exists());
localWavFile = QMediaContent(QUrl::fromLocalFile(wavFile.absoluteFilePath()));
qRegisterMetaType<QMediaContent>();
// select supported video format // select supported video format
QMediaPlayer player; QMediaPlayer player;
TestVideoSurface *surface = new TestVideoSurface; TestVideoSurface *surface = new TestVideoSurface;
...@@ -149,13 +145,10 @@ void tst_QMediaPlayerBackend::initTestCase() ...@@ -149,13 +145,10 @@ void tst_QMediaPlayerBackend::initTestCase()
QSignalSpy errorSpy(&player, SIGNAL(error(QMediaPlayer::Error))); QSignalSpy errorSpy(&player, SIGNAL(error(QMediaPlayer::Error)));
QStringList mediaCandidates;
mediaCandidates << QFINDTESTDATA("testdata/colors.ogv");
mediaCandidates << QFINDTESTDATA("testdata/colors.mp4");
foreach (QString s, mediaCandidates) { foreach (QString s, mediaCandidates) {
QFileInfo videoFile(s); QFileInfo videoFile(s);
QVERIFY(videoFile.exists()); if (!videoFile.exists())
continue;
QMediaContent media = QMediaContent(QUrl::fromLocalFile(videoFile.absoluteFilePath())); QMediaContent media = QMediaContent(QUrl::fromLocalFile(videoFile.absoluteFilePath()));
player.setMedia(media); player.setMedia(media);
player.pause(); player.pause();
...@@ -165,11 +158,61 @@ void tst_QMediaPlayerBackend::initTestCase() ...@@ -165,11 +158,61 @@ void tst_QMediaPlayerBackend::initTestCase()
} }
if (!surface->m_frameList.isEmpty() && errorSpy.isEmpty()) { if (!surface->m_frameList.isEmpty() && errorSpy.isEmpty()) {
localVideoFile = media; return media;
break;
} }
errorSpy.clear(); errorSpy.clear();
} }
return QMediaContent();
}
QMediaContent tst_QMediaPlayerBackend::selectSoundFile(const QStringList& mediaCandidates)
{
QMediaPlayer player;
QSignalSpy errorSpy(&player, SIGNAL(error(QMediaPlayer::Error)));
foreach (QString s, mediaCandidates) {
QFileInfo soundFile(s);
if (!soundFile.exists())
continue;
QMediaContent media = QMediaContent(QUrl::fromLocalFile(soundFile.absoluteFilePath()));
player.setMedia(media);
player.play();
for (int i = 0; i < 2000 && player.mediaStatus() != QMediaPlayer::BufferedMedia && errorSpy.isEmpty(); i+=50) {
QTest::qWait(50);
}
if (player.mediaStatus() == QMediaPlayer::BufferedMedia && errorSpy.isEmpty()) {
return media;
}
errorSpy.clear();
}
return QMediaContent();
}
void tst_QMediaPlayerBackend::initTestCase()
{
const QString testFileName = QFINDTESTDATA("testdata/test.wav");
QFileInfo wavFile(testFileName);
QVERIFY(wavFile.exists());
localWavFile = QMediaContent(QUrl::fromLocalFile(wavFile.absoluteFilePath()));
qRegisterMetaType<QMediaContent>();
QStringList mediaCandidates;
mediaCandidates << QFINDTESTDATA("testdata/colors.ogv");
mediaCandidates << QFINDTESTDATA("testdata/colors.mp4");
localVideoFile = selectVideoFile(mediaCandidates);
mediaCandidates.clear();
mediaCandidates << QFINDTESTDATA("testdata/nokia-tune.mkv");
mediaCandidates << QFINDTESTDATA("testdata/nokia-tune.mp3");
localCompressedSoundFile = selectSoundFile(mediaCandidates);
} }
void tst_QMediaPlayerBackend::cleanup() void tst_QMediaPlayerBackend::cleanup()
...@@ -350,7 +393,7 @@ void tst_QMediaPlayerBackend::processEOS() ...@@ -350,7 +393,7 @@ void tst_QMediaPlayerBackend::processEOS()
QTRY_VERIFY(player.position() < 100); QTRY_VERIFY(player.position() < 100);
QCOMPARE(player.state(), QMediaPlayer::PlayingState); QCOMPARE(player.state(), QMediaPlayer::PlayingState);
QCOMPARE(player.mediaStatus(), QMediaPlayer::BufferedMedia); QTRY_COMPARE(player.mediaStatus(), QMediaPlayer::BufferedMedia);
QCOMPARE(stateSpy.count(), 1); QCOMPARE(stateSpy.count(), 1);
QCOMPARE(stateSpy.last()[0].value<QMediaPlayer::State>(), QMediaPlayer::PlayingState); QCOMPARE(stateSpy.last()[0].value<QMediaPlayer::State>(), QMediaPlayer::PlayingState);
...@@ -623,6 +666,41 @@ void tst_QMediaPlayerBackend::seekPauseSeek() ...@@ -623,6 +666,41 @@ void tst_QMediaPlayerBackend::seekPauseSeek()
} }
} }
void tst_QMediaPlayerBackend::subsequentPlayback()
{
if (localCompressedSoundFile.isNull())
QSKIP("Sound format is not supported");
QMediaPlayer player;
player.setMedia(localCompressedSoundFile);
player.play();
QCOMPARE(player.error(), QMediaPlayer::NoError);
QTRY_COMPARE(player.state(), QMediaPlayer::PlayingState);
QTRY_COMPARE_WITH_TIMEOUT(player.mediaStatus(), QMediaPlayer::EndOfMedia, 15000);
QCOMPARE(player.state(), QMediaPlayer::StoppedState);
// Could differ by up to 1 compressed frame length
QVERIFY(qAbs(player.position() - player.duration()) < 100);
QVERIFY(player.position() > 0);
player.play();
QTRY_COMPARE(player.state(), QMediaPlayer::PlayingState);
QTRY_VERIFY_WITH_TIMEOUT(player.position() > 2000 && player.position() < 5000, 10000);
player.pause();
QCOMPARE(player.state(), QMediaPlayer::PausedState);
// make sure position does not "jump" closer to the end of the file
QVERIFY(player.position() > 2000 && player.position() < 5000);
// try to seek back to zero
player.setPosition(0);
QTRY_COMPARE(player.position(), qint64(0));
player.play();
QCOMPARE(player.state(), QMediaPlayer::PlayingState);
QTRY_VERIFY_WITH_TIMEOUT(player.position() > 2000 && player.position() < 5000, 10000);
player.pause();
QCOMPARE(player.state(), QMediaPlayer::PausedState);
QVERIFY(player.position() > 2000 && player.position() < 5000);
}
void tst_QMediaPlayerBackend::probes() void tst_QMediaPlayerBackend::probes()
{ {
if (localVideoFile.isNull()) if (localVideoFile.isNull())
......
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