Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -127,7 +127,6 @@ class MockEpisodePlayer(
}

next()
play()
}

override fun pause() {
Expand Down Expand Up @@ -168,6 +167,7 @@ class MockEpisodePlayer(
val nextEpisode = q[0]
currentEpisode = nextEpisode
queue.value = q - nextEpisode
play()
}

override fun previous() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ import kotlinx.coroutines.test.advanceTimeBy
import kotlinx.coroutines.test.advanceUntilIdle
import kotlinx.coroutines.test.runTest
import org.junit.Assert.assertEquals
import org.junit.Assert.assertTrue
import org.junit.Test

@OptIn(ExperimentalCoroutinesApi::class)
Expand Down Expand Up @@ -62,6 +63,22 @@ class MockEpisodePlayerTest {
assertEquals(testEpisodes.first(), mockEpisodePlayer.currentEpisode)
}

@Test
fun whenNext_queueIsNotEmpty_autoPlaysNextEpisode() = runTest(testDispatcher) {
val duration = Duration.ofSeconds(60)
val currEpisode = PlayerEpisode(
uri = "currentEpisode",
duration = duration
)
mockEpisodePlayer.currentEpisode = currEpisode
testEpisodes.forEach { mockEpisodePlayer.addToQueue(it) }

mockEpisodePlayer.next()
advanceTimeBy(100)

assertTrue(mockEpisodePlayer.playerState.value.isPlaying)
}

@Test
fun whenNext_queueIsEmpty_doesNothing() {
val episode = testEpisodes[0]
Expand Down