diff options
author | Christian Strømme <christian.stromme@qt.io> | 2019-03-14 10:23:58 +0100 |
---|---|---|
committer | Aapo Keskimolo <aapo.keskimolo@qt.io> | 2019-03-20 17:28:53 +0000 |
commit | e3c0ab60efae81a63e28e5507f5dc777aa13e753 (patch) | |
tree | 0fd4572519668fc752c7322b0c91619bf6268b30 /tests | |
parent | b7df8c5e2bd9feb1090b649ce5f3daeb9dbd0b75 (diff) |
Fix EOS logic in the animator
The logic was broken and in some cases we would not detect that we
reached the end e.g, when the local time was equal to the duration,
in this case we ended up in a no-op situation and the slide state would
not change and the timeChangeCallback would never be called,
which meant that visibility wasn't updated as expected.
Fixes: QT3DS-3080
Change-Id: Ic6dcfd08ef13a18b769cf5eea3113ec31b776d95
Reviewed-by: Janne Kangas <janne.kangas@qt.io>
Reviewed-by: Miikka Heikkinen <miikka.heikkinen@qt.io>
Diffstat (limited to 'tests')
-rw-r--r-- | tests/auto/slideplayer/tst_q3dsslideplayer.cpp | 43 |
1 files changed, 43 insertions, 0 deletions
diff --git a/tests/auto/slideplayer/tst_q3dsslideplayer.cpp b/tests/auto/slideplayer/tst_q3dsslideplayer.cpp index e0ee1f3..85e033e 100644 --- a/tests/auto/slideplayer/tst_q3dsslideplayer.cpp +++ b/tests/auto/slideplayer/tst_q3dsslideplayer.cpp @@ -216,6 +216,49 @@ void tst_Q3DSSlidePlayer::tst_playModes() QCOMPARE(slideChangedSpy.count(), 0); QCOMPARE(player->slideDeck()->currentSlide(), m_stopAtEnd); + // STOP AT END (Already at the end, +rate) + // The player is now in paused state (StopAtEnd), changing the state to Playing should move it + // back into paused state (StopAtEnd). + stateChangeSpy.clear(); + slideChangedSpy.clear(); + + QCOMPARE(player->position(), player->duration()); + + player->play(); + QTRY_COMPARE(player->state(), Q3DSSlidePlayer::PlayerState::Playing); + QTRY_COMPARE(player->state(), Q3DSSlidePlayer::PlayerState::Paused); + + // paused -> playing -> paused + QCOMPARE(stateChangeSpy.count(), 2); + QCOMPARE(slideChangedSpy.count(), 0); + QCOMPARE(player->position(), player->duration()); + QCOMPARE(player->slideDeck()->currentSlide(), m_stopAtEnd); + + // STOP AT END (Already at the end(start), -rate) + // Seek to the start and set the rate to a negative value, changing the state to Playing should + // move it back into paused state (StopAtEnd). + stateChangeSpy.clear(); + slideChangedSpy.clear(); + + player->seek(0.0f); + player->setPlaybackRate(-0.5f); + QCOMPARE(player->playbackRate(), -0.5f); + QCOMPARE(player->position(), 0.0f); + + player->play(); + QTRY_COMPARE(player->state(), Q3DSSlidePlayer::PlayerState::Playing); + QTRY_COMPARE(player->state(), Q3DSSlidePlayer::PlayerState::Paused); + + // paused -> playing -> paused + QCOMPARE(stateChangeSpy.count(), 2); + QCOMPARE(slideChangedSpy.count(), 0); + QCOMPARE(player->position(), 0.0f); + QCOMPARE(player->slideDeck()->currentSlide(), m_stopAtEnd); + + // Reset the playback rate!!! + player->setPlaybackRate(1.0f); + QCOMPARE(player->playbackRate(), 1.0f); + // PLAY TO PREVIOUS player->stop(); QTRY_COMPARE(player->state(), Q3DSSlidePlayer::PlayerState::Stopped); |