mirror of
https://github.com/austinried/subtracks.git
synced 2026-11-10 15:11:58 +01:00
library: cover starred/downloaded shuffle in tests, dedupe list predicate
This commit is contained in:
@@ -2413,6 +2413,40 @@ class PlaybackControllerTest {
|
||||
assertEquals(setOf("r1", "r2"), handle.items.map { it.id }.toSet())
|
||||
}
|
||||
|
||||
@Test
|
||||
fun shuffleStarredPlaysOnlyStarredSongs() {
|
||||
seedStarred()
|
||||
|
||||
controller.shuffleStarred(1)
|
||||
await { controller.state.value.item != null && controller.state.value.shuffle }
|
||||
|
||||
assertTrue(controller.state.value.shuffle)
|
||||
assertEquals(
|
||||
QueueKind.Starred,
|
||||
controller.state.value.context
|
||||
?.kind,
|
||||
)
|
||||
assertEquals(setOf("t1", "t2"), handle.items.map { it.id }.toSet())
|
||||
}
|
||||
|
||||
@Test
|
||||
fun shuffleDownloadedPlaysOnlyDownloadedSongs() {
|
||||
seedAlbum(3, sourceId = 1)
|
||||
markDownloaded(1, "s1")
|
||||
markDownloaded(1, "s3")
|
||||
|
||||
controller.shuffleDownloaded(1)
|
||||
await { controller.state.value.item != null && controller.state.value.shuffle }
|
||||
|
||||
assertTrue(controller.state.value.shuffle)
|
||||
assertEquals(
|
||||
QueueKind.Downloaded,
|
||||
controller.state.value.context
|
||||
?.kind,
|
||||
)
|
||||
assertEquals(setOf("s1", "s3"), handle.items.map { it.id }.toSet())
|
||||
}
|
||||
|
||||
@Test
|
||||
fun artistQueueRowsFollowTheFlatShuffleIdOrder() {
|
||||
seedArtist()
|
||||
@@ -3142,6 +3176,19 @@ class PlaybackControllerTest {
|
||||
}
|
||||
}
|
||||
|
||||
private fun seedStarred() {
|
||||
runBlocking {
|
||||
db.sourcesDao().upsertSource(Source(1, "source 1", "http://localhost:1", true, 1))
|
||||
db.libraryDao().upsertSongs(
|
||||
listOf(
|
||||
Song(1, "t1", "al1", "ar1", "Star 1", "Album", "Artist", 100, 1, 1, 1_700_000_000L, null),
|
||||
Song(1, "t2", "al1", "ar1", "Star 2", "Album", "Artist", 100, 2, 1, 1_700_000_000L, null),
|
||||
Song(1, "n1", "al1", "ar1", "Plain 1", "Album", "Artist", 100, 3, 1, null, null),
|
||||
),
|
||||
)
|
||||
}
|
||||
}
|
||||
|
||||
private fun seedAlbumTracks(
|
||||
albumId: String,
|
||||
count: Int,
|
||||
|
||||
Reference in New Issue
Block a user