mirror of
https://github.com/austinried/subtracks.git
synced 2026-11-10 15:11:58 +01:00
play the songs list from the songs tab
This commit is contained in:
@@ -6,6 +6,7 @@ import androidx.sqlite.driver.bundled.BundledSQLiteDriver
|
||||
import androidx.test.core.app.ApplicationProvider
|
||||
import androidx.test.ext.junit.runners.AndroidJUnit4
|
||||
import com.subtracks.data.db.SubtracksDatabase
|
||||
import com.subtracks.data.model.Album
|
||||
import com.subtracks.data.model.PlaylistSong
|
||||
import com.subtracks.data.model.QueueEntry
|
||||
import com.subtracks.data.model.QueueKind
|
||||
@@ -70,6 +71,19 @@ class QueueRepositoryTest {
|
||||
assertEquals(listOf("s2", "s3"), resolveAll(snapshot))
|
||||
}
|
||||
|
||||
@Test
|
||||
fun theSongsEntryResolvesTheWholeLibraryInListOrder() =
|
||||
runTest {
|
||||
seedLibrary()
|
||||
db.libraryDao().upsertAlbums(listOf(album("al0", "Zeroth Album", "Aardvark")))
|
||||
db.libraryDao().upsertSongs(listOf(song("s0", "al0", track = 1, album = "Zeroth Album")))
|
||||
|
||||
val snapshot = repository.snapshotAfter(listOf(repository.songsEntry(1)))
|
||||
|
||||
assertEquals(6, snapshot.size)
|
||||
assertEquals(listOf("s0", "s1", "s2", "s3", "s4", "s5"), resolveAll(snapshot))
|
||||
}
|
||||
|
||||
@Test
|
||||
fun windowSpansEntryBoundaries() =
|
||||
runTest {
|
||||
@@ -226,28 +240,55 @@ class QueueRepositoryTest {
|
||||
db.sourcesDao().upsertSource(
|
||||
Source(id = 1, name = "test", address = "http://localhost", isActive = true, createdAt = 0),
|
||||
)
|
||||
db.libraryDao().upsertAlbums(
|
||||
listOf(
|
||||
album("al1", "First Album", "Artist One"),
|
||||
album("al2", "Second Album", "Artist Two"),
|
||||
),
|
||||
)
|
||||
db.libraryDao().upsertSongs(
|
||||
listOf(
|
||||
song("s1", "al1", track = 1),
|
||||
song("s2", "al1", track = 2),
|
||||
song("s3", "al1", track = 3),
|
||||
song("s4", "al2", track = 1),
|
||||
song("s5", "al2", track = 2),
|
||||
song("s1", "al1", track = 1, album = "First Album"),
|
||||
song("s2", "al1", track = 2, album = "First Album"),
|
||||
song("s3", "al1", track = 3, album = "First Album"),
|
||||
song("s4", "al2", track = 1, album = "Second Album"),
|
||||
song("s5", "al2", track = 2, album = "Second Album"),
|
||||
),
|
||||
)
|
||||
}
|
||||
|
||||
private fun album(
|
||||
id: String,
|
||||
name: String,
|
||||
albumArtist: String,
|
||||
) = Album(
|
||||
sourceId = 1,
|
||||
id = id,
|
||||
artistId = "ar1",
|
||||
name = name,
|
||||
albumArtist = albumArtist,
|
||||
created = 0,
|
||||
coverArt = null,
|
||||
genre = null,
|
||||
year = null,
|
||||
starred = null,
|
||||
songCount = 1,
|
||||
frequentRank = null,
|
||||
recentRank = null,
|
||||
)
|
||||
|
||||
private fun song(
|
||||
id: String,
|
||||
albumId: String,
|
||||
track: Long,
|
||||
album: String = "Album",
|
||||
) = Song(
|
||||
sourceId = 1,
|
||||
id = id,
|
||||
albumId = albumId,
|
||||
artistId = "ar1",
|
||||
title = "Song $id",
|
||||
album = "Album",
|
||||
album = album,
|
||||
artist = "Artist",
|
||||
duration = 100,
|
||||
track = track,
|
||||
|
||||
@@ -70,6 +70,19 @@ class PlaybackControllerTest {
|
||||
assertEquals(listOf("prepare", "play"), handle.operations.takeLast(2))
|
||||
}
|
||||
|
||||
@Test
|
||||
fun playingTheSongsListQueuesTheWholeLibrary() {
|
||||
seedAlbum(60, sourceId = 1)
|
||||
|
||||
controller.playSongs(1, 30)
|
||||
await { handle.operations.contains("play") }
|
||||
|
||||
assertEquals(51, handle.itemCount)
|
||||
assertEquals(QueueContext(QueueKind.Songs, ""), controller.state.value.context)
|
||||
assertTrue(controller.state.value.hasNext)
|
||||
assertTrue(controller.state.value.hasPrevious)
|
||||
}
|
||||
|
||||
@Test
|
||||
fun advancingShiftsTheWindowAndKeepsItBounded() {
|
||||
seedAlbum(100, sourceId = 1)
|
||||
|
||||
@@ -248,6 +248,7 @@ class AppScreenshotTest {
|
||||
coverArt = { id, _ -> id?.let { CoverArtRef(it, "test:$it") } },
|
||||
onAlbumClick = {},
|
||||
onPlaylistClick = {},
|
||||
onSongClick = {},
|
||||
onSync = {},
|
||||
onOpenSettings = {},
|
||||
)
|
||||
|
||||
@@ -50,6 +50,7 @@ class LibraryScreenTest {
|
||||
coverArt = { _, _ -> null },
|
||||
onAlbumClick = {},
|
||||
onPlaylistClick = {},
|
||||
onSongClick = {},
|
||||
onSync = {},
|
||||
onOpenSettings = {},
|
||||
)
|
||||
|
||||
Reference in New Issue
Block a user