mirror of
https://github.com/austinried/subtracks.git
synced 2026-11-10 15:11:58 +01:00
Compare commits
1
Commits
eb55858cc4
...
main
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
11276c2e1f |
@@ -1070,7 +1070,6 @@ class PlaybackController(
|
||||
}
|
||||
lastSavedPositionMs = savedPositionMs
|
||||
loadWindow(anchor.position, autoplay = false, startPositionMs = savedPositionMs)
|
||||
player?.takeIf { it.itemCount > 0 }?.ensurePrepared()
|
||||
}
|
||||
|
||||
private suspend fun stop() = startLock.withLock { stopLocked() }
|
||||
@@ -1452,7 +1451,7 @@ class PlaybackController(
|
||||
}
|
||||
|
||||
override fun onError(message: UiMessage) {
|
||||
if (player?.playWhenReady == true) showMessage(message)
|
||||
showMessage(message)
|
||||
refresh()
|
||||
}
|
||||
}
|
||||
|
||||
@@ -343,75 +343,18 @@ class PlaybackControllerTest {
|
||||
}
|
||||
|
||||
@Test
|
||||
fun restoringAPreviousQueuePreparesTheSessionWithoutPlaying() {
|
||||
seedAlbum(3, sourceId = 1)
|
||||
runBlocking { queues.replace(listOf(queues.albumEntry(1, "al1"))) }
|
||||
|
||||
controller.connect()
|
||||
await { handle.operations.contains("prepare") }
|
||||
|
||||
assertFalse(handle.operations.contains("play"))
|
||||
assertFalse(handle.isIdle)
|
||||
assertFalse(handle.playWhenReady)
|
||||
assertFalse(controller.state.value.isPlaying)
|
||||
}
|
||||
|
||||
@Test
|
||||
fun aPrepareFailureBeforePlaybackIsNotReported() {
|
||||
seedAlbum(3, sourceId = 1)
|
||||
runBlocking { queues.replace(listOf(queues.albumEntry(1, "al1"))) }
|
||||
|
||||
controller.connect()
|
||||
await { handle.operations.contains("prepare") }
|
||||
|
||||
handle.fail(UiMessage(R.string.playback_error_network))
|
||||
assertTrue(messages.isEmpty())
|
||||
|
||||
controller.togglePlayPause()
|
||||
await { handle.operations.contains("play") }
|
||||
handle.fail(UiMessage(R.string.playback_error_network))
|
||||
await { messages.isNotEmpty() }
|
||||
|
||||
assertEquals(1, messages.size)
|
||||
}
|
||||
|
||||
@Test
|
||||
fun restoringAnEmptyQueueDoesNotPrepare() {
|
||||
seedAlbum(3, sourceId = 1)
|
||||
|
||||
controller.connect()
|
||||
await { controller.ready.value }
|
||||
|
||||
assertTrue(handle.items.isEmpty())
|
||||
assertFalse(handle.operations.contains("prepare"))
|
||||
}
|
||||
|
||||
@Test
|
||||
fun restoringAnOfflineQueueWithoutDownloadsDoesNotPrepare() {
|
||||
seedAlbum(3, sourceId = 1)
|
||||
runBlocking { queues.replace(listOf(queues.albumEntry(1, "al1"))) }
|
||||
setOffline()
|
||||
|
||||
controller.connect()
|
||||
await { controller.ready.value }
|
||||
|
||||
assertTrue(handle.items.isEmpty())
|
||||
assertFalse(handle.operations.contains("prepare"))
|
||||
}
|
||||
|
||||
@Test
|
||||
fun togglingPlayOnARestoredQueuePlaysThePreparedWindow() {
|
||||
fun togglingPlayOnARestoredQueuePreparesBeforePlaying() {
|
||||
seedAlbum(5, sourceId = 1)
|
||||
runBlocking { queues.replace(listOf(queues.albumEntry(1, "al1"))) }
|
||||
|
||||
controller.connect()
|
||||
await { handle.operations.contains("prepare") }
|
||||
await { handle.items.isNotEmpty() }
|
||||
handle.operations.clear()
|
||||
|
||||
controller.togglePlayPause()
|
||||
await { handle.operations.contains("play") }
|
||||
|
||||
assertEquals(listOf("play"), handle.operations)
|
||||
assertEquals(listOf("prepare", "play"), handle.operations)
|
||||
}
|
||||
|
||||
@Test
|
||||
|
||||
Reference in New Issue
Block a user