align the swipe peek with the skip and harden its edges

Resolve previousItem/upcomingItem through the same offline download scan the transport uses, so the peeking art is the track the swipe will actually play. Clear a frozen strip when a fallback swipe fires, prefer the dragged direction over an opposite fling, and simplify the hand-back and ratio prefetch.
This commit is contained in:
austinried
2026-10-04 00:30:07 +00:00
parent 73add672e1
commit 88cd3764bf
5 changed files with 92 additions and 16 deletions
@@ -230,6 +230,36 @@ class PlaybackControllerTest {
}
}
@Test
fun offlinePreviousItemMatchesTheTrackPreviousSkipsTo() {
seedAlbum(5, sourceId = 1)
markDownloaded(1, "s1")
markDownloaded(1, "s4")
setOffline()
controller.playAlbum(1, "al1", 3)
await {
controller.state.value.item
?.id == "s4"
}
assertEquals("s1", runBlocking { controller.previousItem()?.id })
}
@Test
fun offlineUpcomingItemMatchesTheTrackNextPlays() {
seedAlbum(4, sourceId = 1)
markDownloaded(1, "s1")
markDownloaded(1, "s3")
setOffline()
controller.playAlbum(1, "al1", 0)
await {
controller.state.value.item
?.id == "s1"
}
assertEquals("s3", runBlocking { controller.upcomingItem()?.id })
}
@Test
fun advancingShiftsTheWindowAndKeepsItBounded() {
seedAlbum(100, sourceId = 1)
@@ -231,6 +231,30 @@ class NowPlayingTapsTest {
)
}
@Test
fun theSwipeActionPrefersTheDraggedDirectionOverAnOppositeFling() {
assertEquals(
SwipeAction.CommitPrevious,
swipeAction(offsetX = 300f, velocity = -2_000f, width = 1_000f, canGoNext = true, canGoPrevious = true),
)
assertEquals(
SwipeAction.CommitNext,
swipeAction(offsetX = -300f, velocity = 2_000f, width = 1_000f, canGoNext = true, canGoPrevious = true),
)
}
@Test
fun swipingLeftWithANeighbourRotatesTheStrip() {
render(nextArt = adjacentArt("s-next"))
composeRule.onNodeWithTag(NOW_PLAYING_NEXT_TAG, useUnmergedTree = true).assertExists()
composeRule.onNodeWithTag(NOW_PLAYING_COVER_TAG).performTouchInput { swipeLeft() }
composeRule.waitForIdle()
composeRule.onNodeWithTag(NOW_PLAYING_NEXT_TAG, useUnmergedTree = true).assertDoesNotExist()
composeRule.onNodeWithTag(NOW_PLAYING_PREVIOUS_TAG, useUnmergedTree = true).assertExists()
}
@Test
fun rotatingTheStripMovesTheNeighbourIntoTheCentre() {
val a = adjacentArt("a")