Skip to content

Commit

Permalink
Fix exception when adding items to an emptied queue
Browse files Browse the repository at this point in the history
  • Loading branch information
DRSchlaubi committed Mar 15, 2024
1 parent 2b49e14 commit a0a1774
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 1 deletion.
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.5.13-SNAPSHOT"
version = "3.5.14-SNAPSHOT"
}
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,7 @@ class Queue(private var tracksList: MutableList<QueuedTrack> = mutableListOf())

fun poll(): QueuedTrack {
val queuedTrack = tracksList[order.poll()]
nextIndex = nextIndex.coerceAtMost(order.size)
return queuedTrack
}

Expand Down
10 changes: 10 additions & 0 deletions music/player/src/test/kotlin/QueueTest.kt
Original file line number Diff line number Diff line change
Expand Up @@ -145,6 +145,16 @@ class QueueTest {
queue.moveQueuedEntry(5, 7, swap = false)
assertEquals(tracks[5], queue.tracks[6])
}

@Test
fun `check queue after queue ran through`() {
val queue = makeMockQueue()
repeat(queue.tracks.size) { queue.poll() }
val track = mockTrack(1)
queue.addTracks(track)

assertEquals(track, queue.poll())
}
}

private fun makeMockQueue() = Queue(MutableList(10, ::mockTrack))
Expand Down

1 comment on commit a0a1774

@SoneNiko
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

👍

Please sign in to comment.