diff options
author | Yoann Lopes <yoann.lopes@digia.com> | 2014-02-20 19:42:20 +0100 |
---|---|---|
committer | The Qt Project <gerrit-noreply@qt-project.org> | 2014-02-25 15:00:44 +0100 |
commit | d964388b38ec4762e315d86aacb779604bcdca1b (patch) | |
tree | d774d576c66db43cdd91cb0ebee6fbd052c17012 /tests | |
parent | 92323612d01e9bd6438fb9da0dd810c6dad045a3 (diff) | |
download | qtmultimedia-d964388b38ec4762e315d86aacb779604bcdca1b.tar.gz |
QSoundEffect: fix changing the loop count while playing.v5.3.0-alpha1
The running count was not updated with the new value.
Auto-test added and documentation updated to be more clear about this
behavior.
Task-number: QTBUG-36643
Change-Id: I29e98ca4679f950a75133b21873738bcb72d23d4
Reviewed-by: Christian Stromme <christian.stromme@digia.com>
Diffstat (limited to 'tests')
-rw-r--r-- | tests/auto/integration/qsoundeffect/tst_qsoundeffect.cpp | 76 |
1 files changed, 73 insertions, 3 deletions
diff --git a/tests/auto/integration/qsoundeffect/tst_qsoundeffect.cpp b/tests/auto/integration/qsoundeffect/tst_qsoundeffect.cpp index d113d595a..c56b08dfd 100644 --- a/tests/auto/integration/qsoundeffect/tst_qsoundeffect.cpp +++ b/tests/auto/integration/qsoundeffect/tst_qsoundeffect.cpp @@ -152,16 +152,86 @@ void tst_QSoundEffect::testLooping() sound->setLoopCount(5); sound->setVolume(0.1f); - QCOMPARE(sound->loopCount(),5); - QCOMPARE(readSignal_Count.count(),1); + QCOMPARE(sound->loopCount(), 5); + QCOMPARE(readSignal_Count.count(), 1); + QCOMPARE(sound->loopsRemaining(), 0); + QCOMPARE(readSignal_Remaining.count(), 0); sound->play(); + QCOMPARE(sound->loopsRemaining(), 5); + QCOMPARE(readSignal_Remaining.count(), 1); // test.wav is about 200ms, wait until it has finished playing 5 times QTestEventLoop::instance().enterLoop(3); QTRY_COMPARE(sound->loopsRemaining(), 0); - QCOMPARE(readSignal_Remaining.count(),5); + QVERIFY(readSignal_Remaining.count() >= 6); + QTRY_VERIFY(!sound->isPlaying()); + + // QTBUG-36643 (setting the loop count while playing should work) + { + readSignal_Count.clear(); + readSignal_Remaining.clear(); + + sound->setLoopCount(30); + QCOMPARE(sound->loopCount(), 30); + QCOMPARE(readSignal_Count.count(), 1); + QCOMPARE(sound->loopsRemaining(), 0); + QCOMPARE(readSignal_Remaining.count(), 0); + + sound->play(); + QCOMPARE(sound->loopsRemaining(), 30); + QCOMPARE(readSignal_Remaining.count(), 1); + + // wait for the sound to be played several times + QTRY_COMPARE(sound->loopsRemaining(), 20); + QVERIFY(readSignal_Remaining.count() >= 10); + readSignal_Count.clear(); + readSignal_Remaining.clear(); + + // change the loop count while playing + sound->setLoopCount(5); + QCOMPARE(sound->loopCount(), 5); + QCOMPARE(readSignal_Count.count(), 1); + QCOMPARE(sound->loopsRemaining(), 5); + QCOMPARE(readSignal_Remaining.count(), 1); + + // wait for all the loops to be completed + QTRY_COMPARE(sound->loopsRemaining(), 0); + QVERIFY(readSignal_Remaining.count() >= 6); + QTRY_VERIFY(!sound->isPlaying()); + } + + { + readSignal_Count.clear(); + readSignal_Remaining.clear(); + + sound->setLoopCount(QSoundEffect::Infinite); + QCOMPARE(sound->loopCount(), int(QSoundEffect::Infinite)); + QCOMPARE(readSignal_Count.count(), 1); + QCOMPARE(sound->loopsRemaining(), 0); + QCOMPARE(readSignal_Remaining.count(), 0); + + sound->play(); + QCOMPARE(sound->loopsRemaining(), int(QSoundEffect::Infinite)); + QCOMPARE(readSignal_Remaining.count(), 1); + + QTest::qWait(1500); + QVERIFY(sound->isPlaying()); + readSignal_Count.clear(); + readSignal_Remaining.clear(); + + // Setting the loop count to 0 should play it one last time + sound->setLoopCount(0); + QCOMPARE(sound->loopCount(), 1); + QCOMPARE(readSignal_Count.count(), 1); + QCOMPARE(sound->loopsRemaining(), 1); + QCOMPARE(readSignal_Remaining.count(), 1); + + QTRY_COMPARE(sound->loopsRemaining(), 0); + QVERIFY(readSignal_Remaining.count() >= 2); + QTRY_VERIFY(!sound->isPlaying()); + } } void tst_QSoundEffect::testVolume() |