address second review: shuffle cache invalidation, locking, ended latch

This commit is contained in:
austinried
2026-10-04 00:29:55 +00:00
parent 2c333195ef
commit b2f654e10f
7 changed files with 78 additions and 34 deletions
@@ -321,7 +321,7 @@ class QueueRepositoryTest {
(0 until snapshot.size).mapNotNull { repository.itemAt(snapshot, it)?.song?.id }
@Test
fun aStaleShuffleOrderIsDroppedWhenTheQueueLengthChanges() =
fun aStaleShuffleOrderIsIgnoredWhenTheQueueLengthChanges() =
runTest {
seedLibrary()
repository.replace(listOf(repository.albumEntry(1, "al1")))
@@ -331,7 +331,6 @@ class QueueRepositoryTest {
db.libraryDao().upsertSongs(listOf(song("s6", "al1", track = 4, album = "First Album")))
assertFalse(repository.snapshot().shuffled)
assertFalse(repository.modes().shuffle)
}
private suspend fun seedLibrary() {
@@ -819,6 +819,27 @@ class PlaybackControllerTest {
)
}
@Test
fun repeatAllLoopsAfterEndingWithRepeatOff() {
seedAlbum(2, sourceId = 1)
controller.playAlbum(1, "al1", 0)
await { controller.state.value.isPlaying }
handle.finish()
handle.emitEvents()
await { !controller.state.value.isPlaying }
controller.togglePlayPause()
await { controller.state.value.isPlaying }
controller.cycleRepeat()
assertEquals(RepeatMode.All, controller.state.value.repeat)
handle.finish()
handle.emitEvents()
await { controller.state.value.isPlaying }
}
private fun seedAlbum(
count: Int,
sourceId: Long,