Skip to content

Commit

Permalink
Remove unused Player.startPlayback() extension
Browse files Browse the repository at this point in the history
  • Loading branch information
MGaetan89 committed Jan 30, 2024
1 parent 5392154 commit d3c475c
Show file tree
Hide file tree
Showing 2 changed files with 0 additions and 82 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -7,26 +7,6 @@ package ch.srgssr.pillarbox.player.extension
import androidx.media3.common.MediaItem
import androidx.media3.common.Player

/**
* Resume playback
*/
fun Player.startPlayback() {
when (playbackState) {
Player.STATE_IDLE -> {
prepare()
}

Player.STATE_ENDED -> {
seekToDefaultPosition()
}

else -> {
// Nothing
}
}
play()
}

/**
* Get a snapshot of the current media items
*/
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,73 +8,11 @@ import androidx.media3.common.MediaItem
import androidx.media3.common.PlaybackParameters
import androidx.media3.common.Player
import io.mockk.every
import io.mockk.justRun
import io.mockk.mockk
import io.mockk.verifySequence
import kotlin.test.Test
import kotlin.test.assertEquals

class PlayerTest {
@Test
fun `startPlayback with player buffering`() {
val player = mockk<Player> {
every { playbackState } returns Player.STATE_BUFFERING
justRun { play() }
}
player.startPlayback()

verifySequence {
player.playbackState
player.play()
}
}

@Test
fun `startPlayback with player ended`() {
val player = mockk<Player> {
every { playbackState } returns Player.STATE_ENDED
justRun { seekToDefaultPosition() }
justRun { play() }
}
player.startPlayback()

verifySequence {
player.playbackState
player.seekToDefaultPosition()
player.play()
}
}

@Test
fun `startPlayback with player idle`() {
val player = mockk<Player> {
every { playbackState } returns Player.STATE_IDLE
justRun { prepare() }
justRun { play() }
}
player.startPlayback()

verifySequence {
player.playbackState
player.prepare()
player.play()
}
}

@Test
fun `startPlayback with player ready`() {
val player = mockk<Player> {
every { playbackState } returns Player.STATE_READY
justRun { play() }
}
player.startPlayback()

verifySequence {
player.playbackState
player.play()
}
}

@Test
fun `getCurrentMediaItems without any items`() {
val player = mockk<Player> {
Expand Down

0 comments on commit d3c475c

Please sign in to comment.