File tree Expand file tree Collapse file tree 2 files changed +18
-1
lines changed
main/java/com/example/jetcaster/core/player
test/kotlin/com/example/jetcaster/core/player Expand file tree Collapse file tree 2 files changed +18
-1
lines changed Original file line number Diff line number Diff line change @@ -127,7 +127,6 @@ class MockEpisodePlayer(
127127 }
128128
129129 next()
130- play()
131130 }
132131
133132 override fun pause () {
@@ -168,6 +167,7 @@ class MockEpisodePlayer(
168167 val nextEpisode = q[0 ]
169168 currentEpisode = nextEpisode
170169 queue.value = q - nextEpisode
170+ play()
171171 }
172172
173173 override fun previous () {
Original file line number Diff line number Diff line change @@ -24,6 +24,7 @@ import kotlinx.coroutines.test.advanceTimeBy
2424import kotlinx.coroutines.test.advanceUntilIdle
2525import kotlinx.coroutines.test.runTest
2626import org.junit.Assert.assertEquals
27+ import org.junit.Assert.assertTrue
2728import org.junit.Test
2829
2930@OptIn(ExperimentalCoroutinesApi ::class )
@@ -62,6 +63,22 @@ class MockEpisodePlayerTest {
6263 assertEquals(testEpisodes.first(), mockEpisodePlayer.currentEpisode)
6364 }
6465
66+ @Test
67+ fun whenNext_queueIsNotEmpty_autoPlaysNextEpisode () = runTest(testDispatcher) {
68+ val duration = Duration .ofSeconds(60 )
69+ val currEpisode = PlayerEpisode (
70+ uri = " currentEpisode" ,
71+ duration = duration
72+ )
73+ mockEpisodePlayer.currentEpisode = currEpisode
74+ testEpisodes.forEach { mockEpisodePlayer.addToQueue(it) }
75+
76+ mockEpisodePlayer.next()
77+ advanceTimeBy(100 )
78+
79+ assertTrue(mockEpisodePlayer.playerState.value.isPlaying)
80+ }
81+
6582 @Test
6683 fun whenNext_queueIsEmpty_doesNothing () {
6784 val episode = testEpisodes[0 ]
You can’t perform that action at this time.
0 commit comments