Skip to content

Commit

Permalink
Fix exception when queuing tracks whilst shuffle is enabled
Browse files Browse the repository at this point in the history
  • Loading branch information
DRSchlaubi committed Jun 29, 2024
1 parent 77f0d57 commit a26fe8b
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 2 deletions.
2 changes: 1 addition & 1 deletion music/build.gradle.kts
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
subprojects {
version = "3.8.4-SNAPSHOT"
version = "3.8.5-SNAPSHOT"
}
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ class Queue(private var tracksList: MutableList<QueuedTrack> = mutableListOf())

fun poll(): QueuedTrack {
val queuedTrack = tracksList[order.poll()]
nextIndex--
nextIndex = (nextIndex - 1).coerceAtLeast(0)
if (order.isEmpty()) {
shuffle = false
}
Expand Down
11 changes: 11 additions & 0 deletions music/player/src/test/kotlin/QueueTest.kt
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,17 @@ class QueueTest {
assertEquals(mockTrack, queue.poll())
}

@Test
fun `test queue works whilst shuffle is playing`() {
val queue = makeMockQueue()
queue.shuffle = true
queue.poll()
val mockTrack = mockTrack(11)
queue.addTracks(mockTrack)

assertEquals(mockTrack, queue.poll())
}

@Test
fun `test un-shuffle after queue`() {
val queue = makeMockQueue()
Expand Down

0 comments on commit a26fe8b

Please sign in to comment.