summaryrefslogtreecommitdiff
path: root/tests
diff options
context:
space:
mode:
authorLiang Qi <liang.qi@qt.io>2016-08-17 10:48:30 +0200
committerLiang Qi <liang.qi@qt.io>2016-08-17 10:48:30 +0200
commitb4f2dc4f62b2cb4bd9c43de56bbfd0024404c190 (patch)
treeb4a71b9a45b1c1c3adf21cdc49de68f9c86b1e9c /tests
parent393602150d1f3eec25252aa40045f9e24ae5329b (diff)
parent820205e604a5f281238c23464638fdff72b969d1 (diff)
downloadqtmultimedia-b4f2dc4f62b2cb4bd9c43de56bbfd0024404c190.tar.gz
Merge remote-tracking branch 'origin/5.7' into dev
Change-Id: Ib8d05d6e21c7beb19f618cd1edc52d248b1e43b8
Diffstat (limited to 'tests')
-rw-r--r--tests/auto/integration/qmediaplayerbackend/tst_qmediaplayerbackend.cpp27
-rw-r--r--tests/auto/unit/qmediaobject/tst_qmediaobject.cpp11
2 files changed, 35 insertions, 3 deletions
diff --git a/tests/auto/integration/qmediaplayerbackend/tst_qmediaplayerbackend.cpp b/tests/auto/integration/qmediaplayerbackend/tst_qmediaplayerbackend.cpp
index dfa1bf254..1f1df9aac 100644
--- a/tests/auto/integration/qmediaplayerbackend/tst_qmediaplayerbackend.cpp
+++ b/tests/auto/integration/qmediaplayerbackend/tst_qmediaplayerbackend.cpp
@@ -331,6 +331,33 @@ void tst_QMediaPlayerBackend::playPauseStop()
QSignalSpy stateSpy(&player, SIGNAL(stateChanged(QMediaPlayer::State)));
QSignalSpy statusSpy(&player, SIGNAL(mediaStatusChanged(QMediaPlayer::MediaStatus)));
QSignalSpy positionSpy(&player, SIGNAL(positionChanged(qint64)));
+ QSignalSpy errorSpy(&player, SIGNAL(error(QMediaPlayer::Error)));
+
+ // Check play() without a media
+ player.play();
+
+ QCOMPARE(player.state(), QMediaPlayer::StoppedState);
+ QCOMPARE(player.mediaStatus(), QMediaPlayer::NoMedia);
+ QCOMPARE(player.error(), QMediaPlayer::NoError);
+ QCOMPARE(player.position(), 0);
+ QCOMPARE(stateSpy.count(), 0);
+ QCOMPARE(statusSpy.count(), 0);
+ QCOMPARE(positionSpy.count(), 0);
+ QCOMPARE(errorSpy.count(), 0);
+
+ // Check pause() without a media
+ player.pause();
+
+ QCOMPARE(player.state(), QMediaPlayer::StoppedState);
+ QCOMPARE(player.mediaStatus(), QMediaPlayer::NoMedia);
+ QCOMPARE(player.error(), QMediaPlayer::NoError);
+ QCOMPARE(player.position(), 0);
+ QCOMPARE(stateSpy.count(), 0);
+ QCOMPARE(statusSpy.count(), 0);
+ QCOMPARE(positionSpy.count(), 0);
+ QCOMPARE(errorSpy.count(), 0);
+
+ // The rest is with a valid media
player.setMedia(localWavFile);
diff --git a/tests/auto/unit/qmediaobject/tst_qmediaobject.cpp b/tests/auto/unit/qmediaobject/tst_qmediaobject.cpp
index 31775249a..0548d1e1a 100644
--- a/tests/auto/unit/qmediaobject/tst_qmediaobject.cpp
+++ b/tests/auto/unit/qmediaobject/tst_qmediaobject.cpp
@@ -288,14 +288,19 @@ void tst_QMediaObject::notifySignals()
QFETCH(int, count);
QtTestMediaObject object;
+ QSignalSpy spy(&object, SIGNAL(aChanged(int)));
+
object.setNotifyInterval(interval);
object.addPropertyWatch("a");
- QSignalSpy spy(&object, SIGNAL(aChanged(int)));
+ QElapsedTimer timer;
+ timer.start();
- QTestEventLoop::instance().enterLoop(1);
+ QTRY_COMPARE(spy.count(), count);
- QCOMPARE(spy.count(), count);
+ qint64 elapsed = timer.elapsed();
+ int expectedElapsed = count * interval * 1.3; // give it some margin of error
+ QVERIFY2(elapsed < expectedElapsed, QString("elapsed: %1, expected: %2").arg(elapsed).arg(expectedElapsed).toLocal8Bit().constData());
}
void tst_QMediaObject::notifyInterval_data()