Native Android client for Spotify, built with Jetpack Compose
Kotlin ad-freeadblockandroidjetpack-composekotlinlyricsmusic-playermusic-videomyspotispotifyspotify-adblockerspotify-clientspotify-connectspotui
Queue: a dropped order no longer jumps back, and the edge scroll eases up
kota-zo6dd468359e3f
diff --git a/base/app/src/main/java/com/music/spotui/di/SongPlayer.kt b/base/app/src/main/java/com/music/spotui/di/SongPlayer.ktindex 3211c1d5..d0cf4d46 100644--- a/base/app/src/main/java/com/music/spotui/di/SongPlayer.kt+++ b/base/app/src/main/java/com/music/spotui/di/SongPlayer.kt@@ -910,6 +910,9 @@ object SongPlayer {apiQueue = q// While a downloaded or local file plays, the queue shown is the local player's.if (q == null || LocalPlayer.active.value) return+ // A move is under way: its steps are not shown, the order dropped stays (see [queueMove]).+ if (queueMovesInFlight.get() > 0) return+ if (SystemClock.elapsedRealtime() < staleUntil && order(q) in staleOrders) returnfun items(list: List<app.myspoti.api.NowPlaying>) = list.filter { it.uri.startsWith("spotify:track:") || it.uri.startsWith("spotify:episode:") }.map { QueueItem(songOf(it), it.uri, it.uid.orEmpty(), "") }@@ -2980,6 +2983,56 @@ object SongPlayer {return (up.firstOrNull { it.first.toString() == item.uid } ?: up.firstOrNull())?.first}+ /**+ * Queue moves sent to Spotify and not done yet. Spotify shows a move late and in steps (the song+ * out of one part, queued at the end, then placed), and showing them took the song back to where+ * it was before it reached the place it was dropped at. So while a move is under way its reports+ * are held and the order the user dropped ([showQueueOrder]) stays; the last move to finish shows+ * the queue as Spotify has it then, and for [STALE_MS] after, a late report of an order from+ * before the moves is ignored.+ */+ private val queueMovesInFlight = java.util.concurrent.atomic.AtomicInteger()+ private val staleOrders = java.util.Collections.synchronizedSet(HashSet<Pair<List<String>, List<String>>>())+ @Volatile private var staleUntil = 0L+ private const val STALE_MS = 1_500L++ private fun order(q: app.myspoti.api.Queue) = q.queued.map { it.uri } to q.nextUp.map { it.uri }++ /** Shows [queued] / [nextUp] at once: the order a drop made, kept while the move that makes it so runs. */+ fun showQueueOrder(queued: List<QueueItem>, nextUp: List<QueueItem>) {+ if (LocalPlayer.active.value) return+ val shown = _queue.value+ if (shown.queued == queued && shown.nextUp == nextUp) return+ if (queueMovesInFlight.get() == 0) staleOrders.clear()+ staleOrders += shown.queued.map { it.uri } to shown.nextUp.map { it.uri }+ _queue.value = shown.copy(queued = queued, nextUp = nextUp)+ }++ /** A move of a Spotify queue row, run as [queueCommand]; see [queueMovesInFlight]. */+ private fun queueMove(block: suspend () -> Unit) {+ queueMovesInFlight.incrementAndGet()+ queueCommand {+ try {+ block()+ } finally {+ if (queueMovesInFlight.decrementAndGet() == 0) {+ staleUntil = SystemClock.elapsedRealtime() + STALE_MS+ api.player.queue.value?.let { staleOrders -= order(it) }+ main.post { if (acceptsSessionUpdates()) applyQueue(api.player.queue.value ?: apiQueue) }+ }+ }+ }+ }++ /** Whether [q] shows [uri] right before / after [target], in either part. */+ private fun placed(q: app.myspoti.api.Queue, uri: String, target: String, after: Boolean): Boolean =+ listOf(q.queued, q.nextUp).any { part ->+ val uris = part.map { it.uri }+ val i = uris.indexOf(uri)+ val t = uris.indexOf(target)+ i >= 0 && t >= 0 && i == (if (after) t + 1 else t - 1)+ }+/** Move [item] just before / after [target]; a Spotify row stays in its section (see [moveIntoQueue]), a local one goes into [target]'s. */fun reorder(item: QueueItem, target: QueueItem, after: Boolean) {if (item.provider == LOCAL) {@@ -2989,12 +3042,12 @@ object SongPlayer {return}// Read when the edit runs, after the ones before it: never a row id that has gone stale.- queueCommand {- val a = liveItem(item) ?: return@queueCommand- val b = liveItem(target) ?: return@queueCommand- val before = api.player.queue.value+ queueMove {+ val a = liveItem(item) ?: return@queueMove+ val b = liveItem(target) ?: return@queueMoveapi.player.moveInQueue(a, b, after)- awaitQueue { it !== before }+ // Done once Spotify shows it in place, not at its first report: that one may still be of the old order.+ awaitQueue { placed(it, a.uri, b.uri, after) }}}@@ -3012,18 +3065,20 @@ object SongPlayer {LocalPlayer.moveIntoQueue(from, target?.let { localIndex(it) ?: return }, after)return}- queueCommand {- val a = liveItem(item) ?: return@queueCommand+ queueMove {+ val a = liveItem(item) ?: return@queueMoveval first = apiQueue?.queued?.firstOrNull()api.player.removeFromQueue(listOf(a))awaitQueue { q -> q.nextUp.none { it.uid == a.uid } }api.player.addToQueue(listOf(a.uri))- val added = awaitQueue { q -> q.queued.any { it.uri == a.uri } }?.queued?.lastOrNull { it.uri == a.uri } ?: return@queueCommand+ val added = awaitQueue { q -> q.queued.any { it.uri == a.uri } }?.queued?.lastOrNull { it.uri == a.uri } ?: return@queueMove// Queued at the end: moved to the place it was dropped (the front when no target).- val t = target?.let(::apiItem) ?: first?.takeIf { it.uid != added.uid } ?: return@queueCommand- val before = api.player.queue.value- api.player.moveInQueue(added, t, if (target == null) false else after)- awaitQueue { it !== before }+ val t = target?.let(::apiItem) ?: first?.takeIf { it.uid != added.uid } ?: return@queueMove+ val placeAfter = if (target == null) false else after+ // Already there (dropped last in the queue): nothing to move.+ if (api.player.queue.value?.let { placed(it, added.uri, t.uri, placeAfter) } == true) return@queueMove+ api.player.moveInQueue(added, t, placeAfter)+ awaitQueue { placed(it, added.uri, t.uri, placeAfter) }}}diff --git a/base/app/src/main/java/com/music/spotui/ui/components/PlayerSheets.kt b/base/app/src/main/java/com/music/spotui/ui/components/PlayerSheets.ktindex effc3e5f..8db6f85e 100644--- a/base/app/src/main/java/com/music/spotui/ui/components/PlayerSheets.kt+++ b/base/app/src/main/java/com/music/spotui/ui/components/PlayerSheets.kt@@ -624,30 +624,11 @@ private fun PillButton(label: String, onClick: () -> Unit) {private val QueueHeaderHeight = 48.dp-/** Strip at each end of the list where a drag starts scrolling it. */-private val QueueEdgeZone = 72.dp+/** Strip at each end of the list where a held row starts scrolling it. */+private val QueueEdgeZone = 48.dp-/** Scroll distance per frame at the very edge; it fades to 0 at the zone's inner border. */-private val QueueEdgeMaxStep = 14.dp--/**- * Pixels to scroll this frame for a drag whose row centre is at [pointerY] (viewport- * space): negative near the top edge, positive near the bottom, 0 in the middle. The- * speed ramps up as the row gets closer to the edge, so a song crosses a long queue fast.- */-internal fun queueEdgeScrollStep(- pointerY: Float,- viewportTop: Float,- viewportBottom: Float,- edgePx: Float,- maxStepPx: Float,-): Float {- if (viewportBottom <= viewportTop || edgePx <= 0f) return 0f- val up = ((viewportTop + edgePx) - pointerY) / edgePx- if (up > 0f) return -maxStepPx * up.coerceIn(0f, 1f)- val down = (pointerY - (viewportBottom - edgePx)) / edgePx- return if (down > 0f) maxStepPx * down.coerceIn(0f, 1f) else 0f-}+/** Scroll speed at the very edge, a second: about six rows. See [QueueDragMath.edgeSpeed] for the curve. */+private val QueueEdgeSpeed = 360.dp/*** Top of the queue block in viewport pixels (negative once scrolled past the top).@@ -706,7 +687,7 @@ private fun QueueList(val rowPx = with(density) { QueueRowHeight.toPx() }val headerPx = with(density) { QueueHeaderHeight.toPx() }val edgePx = with(density) { QueueEdgeZone.toPx() }- val maxStepPx = with(density) { QueueEdgeMaxStep.toPx() }+ val edgeSpeedPx = with(density) { QueueEdgeSpeed.toPx() }var queued by remember(q.queued) { mutableStateOf(q.queued) }var nextUp by remember(q.nextUp) { mutableStateOf(q.nextUp) }@@ -746,15 +727,13 @@ private fun QueueList()}- /** Pixels to scroll this frame: negative near the top edge, positive near the bottom. */- fun edgeScrollStep(pointerY: Float): Float {+ /** Pixels a second to scroll for the held row's top at [rowTop]: negative near the top edge, positive near the bottom. */+ fun edgeScrollSpeed(rowTop: Float): Float {val info = listState.layoutInfo- return queueEdgeScrollStep(- pointerY,- info.viewportStartOffset.toFloat(),- info.viewportEndOffset.toFloat(),- edgePx,- maxStepPx,+ return com.music.spotui.ui.immersive.lyrics.QueueDragMath.edgeSpeed(+ rowTop, rowTop + rowPx,+ info.viewportStartOffset.toFloat(), info.viewportEndOffset.toFloat(),+ edgePx, edgeSpeedPx,)}@@ -767,14 +746,18 @@ private fun QueueList(}}- /** Scrolls the list once per frame while the dragged row stays in an edge zone. */+ /** Scrolls the list, paced by the clock rather than by frames, while the dragged row stays in an edge zone. */fun startAutoScroll(itemIndex: Int) {autoScrollJob?.cancel()autoScrollJob = scope.launch {+ var previous = withFrameNanos { it }while (isActive) {- val top = queueBlockTop()- val pointerY = top + topOf(itemIndex) + dragOffset + rowPx / 2- val step = edgeScrollStep(pointerY)+ val now = withFrameNanos { it }+ // A dropped frame paid back in full lands as a lurch, so it is not.+ val seconds = ((now - previous) / 1_000_000_000f).coerceAtMost(1f / 30f)+ previous = now+ val rowTop = queueBlockTop() + topOf(itemIndex) + dragOffset+ val step = edgeScrollSpeed(rowTop) * secondsif (step != 0f) {val moved = listState.scrollBy(step)if (moved != 0f) {@@ -785,7 +768,6 @@ private fun QueueList(syncHoveredSlot(itemIndex)}}- withFrameNanos { }}}}@@ -800,12 +782,15 @@ private fun QueueList(val nextHeaderMid = if (nextHeaderIndex >= 0) topOf(nextHeaderIndex) + headerPx / 2 else Float.MAX_VALUE// Either way across the line: a song moved up into the queue can be taken back down.val toQueue = centerY < nextHeaderMid+ // A queued Spotify song cannot go back into "next from" (Spotify has no such move).+ if (!toQueue && fromQueued && item.provider != SongPlayer.LOCAL) returnif (toQueue) {val others = queued - itemif (others.isEmpty()) {if (!fromQueued) {// Empty queue: becomes the first queued track.nextUp = nextUp - item; queued = listOf(item)+ SongPlayer.showQueueOrder(queued, nextUp)SongPlayer.moveToQueueFront(item)}return@@ -816,8 +801,9 @@ private fun QueueList(if (newQueued == queued) returnif (!fromQueued) nextUp = nextUp - itemqueued = newQueued- if (slot < others.size) SongPlayer.reorder(item, others[slot], after = false)- else SongPlayer.reorder(item, others[slot - 1], after = true)+ SongPlayer.showQueueOrder(queued, nextUp)+ val (target, after) = if (slot < others.size) others[slot] to false else others[slot - 1] to true+ if (fromQueued) SongPlayer.reorder(item, target, after) else SongPlayer.moveIntoQueue(item, target, after)} else {val others = nextUp - itemif (others.isEmpty()) return@@ -827,6 +813,7 @@ private fun QueueList(if (newNext == nextUp) returnif (fromQueued) queued = queued - itemnextUp = newNext+ SongPlayer.showQueueOrder(queued, nextUp)if (slot < others.size) SongPlayer.reorder(item, others[slot], after = false)else SongPlayer.reorder(item, others[slot - 1], after = true)}@@ -874,6 +861,24 @@ private fun QueueList(is QEntry.Row -> {val item = e.itemval isDragged = dragging == item+ // The gesture below outlives this composition (keyed by the song only): it calls the+ // latest of these, so it works on the rows as they are now, not as at its first frame.+ val onDragStartNow by androidx.compose.runtime.rememberUpdatedState {+ dragging = item; dragOffset = 0f; lastSlot = index+ haptic.performHapticFeedback(androidx.compose.ui.hapticfeedback.HapticFeedbackType.LongPress)+ startAutoScroll(index)+ }+ val onDragEndNow by androidx.compose.runtime.rememberUpdatedState {+ stopAutoScroll()+ val center = topOf(index) + dragOffset + rowPx / 2+ drop(item, e.queued, center)+ haptic.performHapticFeedback(androidx.compose.ui.hapticfeedback.HapticFeedbackType.GestureEnd)+ dragging = null; dragOffset = 0f+ }+ val onDragNow by androidx.compose.runtime.rememberUpdatedState { dy: Float ->+ dragOffset += dy+ syncHoveredSlot(index)+ }Box(modifier = Modifier.graphicsLayer { translationY = if (isDragged) dragOffset else 0f }@@ -906,26 +911,15 @@ private fun QueueList(.size(28.dp).pointerInput(item.uid + item.uri) {detectDragGestures(- onDragStart = {- dragging = item; dragOffset = 0f; lastSlot = index- haptic.performHapticFeedback(androidx.compose.ui.hapticfeedback.HapticFeedbackType.LongPress)- startAutoScroll(index)- },- onDragEnd = {- stopAutoScroll()- val center = topOf(entries.indexOf(e)) + dragOffset + rowPx / 2- drop(item, e.queued, center)- haptic.performHapticFeedback(androidx.compose.ui.hapticfeedback.HapticFeedbackType.GestureEnd)- dragging = null; dragOffset = 0f- },+ onDragStart = { onDragStartNow() },+ onDragEnd = { onDragEndNow() },onDragCancel = {stopAutoScroll()dragging = null; dragOffset = 0f},) { change, amount ->change.consume()- dragOffset += amount.y- syncHoveredSlot(index)+ onDragNow(amount.y)}},)diff --git a/base/app/src/main/java/com/music/spotui/ui/immersive/lyrics/ImmersiveQueuePanel.kt b/base/app/src/main/java/com/music/spotui/ui/immersive/lyrics/ImmersiveQueuePanel.ktindex f1071363..4dde6752 100644--- a/base/app/src/main/java/com/music/spotui/ui/immersive/lyrics/ImmersiveQueuePanel.kt+++ b/base/app/src/main/java/com/music/spotui/ui/immersive/lyrics/ImmersiveQueuePanel.kt@@ -180,13 +180,21 @@ fun ImmersiveQueuePanel(modifier: Modifier = Modifier, contentPadding: PaddingVaval topPad = contentPadding.calculateTopPadding() + 8.dpval bottomPad = contentPadding.calculateBottomPadding() + 24.dp// A speed, not a jump: the list's height every 100 ms was dozens of songs flying by (seen in a recording).- val speed = with(LocalDensity.current) { 700.dp.toPx() }+ // It grows with how far into the edge zone the finger is (QueueDragMath.edgePace): slow at the+ // zone's border, to stop on a row, about eight rows a second at the very edge.+ val density = LocalDensity.current+ val maxSpeed = with(density) { 480.dp.toPx() }+ val edgeZone = with(density) { 72.dp.toPx() }+ val topPadPx = with(density) { (contentPadding.calculateTopPadding() + 8.dp).toPx() }+ val bottomPadPx = with(density) { (contentPadding.calculateBottomPadding() + 24.dp).toPx() }// The list scrolls toward an edge only once the finger has gone that way: a row taken near the// bottom of the screen made the list run at once, the finger not having moved (reported).val gate = remember { EdgeScrollGate() }gate.slop = with(LocalDensity.current) { 20.dp.toPx() }// A speed of 0 holds the scroll (the scroller then moves by nothing until the gate opens).- val scroller = rememberScroller(listState, { if (gate.allows()) speed else 0f })+ val scroller = rememberScroller(listState, {+ if (gate.allows()) QueueDragMath.edgePace(gate.y, topPadPx, gate.height - bottomPadPx, edgeZone, maxSpeed) else 0f+ })val reorder = rememberReorderableLazyListState(listState,scrollThresholdPadding = PaddingValues(top = topPad, bottom = bottomPad),@@ -233,6 +241,8 @@ fun ImmersiveQueuePanel(modifier: Modifier = Modifier, contentPadding: PaddingVa)settling = falseLogbook.log("queue order: set (${row.item.uri}: $move)")+ // The engine shows the dropped order at once and holds Spotify's reports until the move is done.+ SongPlayer.showQueueOrder(queuedNew.map { it.item }, nextNew.map { it.item })call()}diff --git a/base/app/src/main/java/com/music/spotui/ui/immersive/lyrics/QueueDragMath.kt b/base/app/src/main/java/com/music/spotui/ui/immersive/lyrics/QueueDragMath.ktindex ab89bc2a..c93a59cd 100644--- a/base/app/src/main/java/com/music/spotui/ui/immersive/lyrics/QueueDragMath.kt+++ b/base/app/src/main/java/com/music/spotui/ui/immersive/lyrics/QueueDragMath.kt@@ -141,4 +141,40 @@ internal object QueueDragMath {const val GRACE_MS = 1_500L/** The longest the engine is waited for. */const val MAX_MS = 10_000L++ /** Share of the full speed the list scrolls at as the finger enters an edge zone, so it visibly moves at once. */+ private const val EDGE_FLOOR = 0.2f++ /**+ * Pixels a second to scroll the list at for a finger at [y], in a list whose clear part spans+ * [start]..[end] (0 when the finger is clear of both [zone]s). It starts at [EDGE_FLOOR] of+ * [maxSpeed] at the zone's inner border and eases up (quadratic, so the first half of the zone+ * stays slow enough to stop on a row) to the full speed at the edge, and goes no faster past it.+ */+ fun edgePace(y: Float, start: Float, end: Float, zone: Float, maxSpeed: Float): Float {+ if (zone <= 0f || end - start < 2 * zone) return 0f+ val depth = maxOf((start + zone) - y, y - (end - zone))+ if (depth <= 0f) return 0f+ val t = (depth / zone).coerceAtMost(1f)+ return maxSpeed * (EDGE_FLOOR + (1f - EDGE_FLOOR) * t * t)+ }++ /**+ * The same pace for a held row spanning [top]..[bottom] (the queue sheet, which knows where its row+ * is drawn), signed: negative towards the start, positive towards the end. A viewport too short to+ * hold the row clear of both zones scrolls neither way.+ */+ fun edgeSpeed(top: Float, bottom: Float, start: Float, end: Float, zone: Float, maxSpeed: Float): Float {+ if (zone <= 0f || end <= start) return 0f+ val intoStart = (start + zone) - top+ val intoEnd = bottom - (end - zone)+ val reach = when {+ intoStart > 0f && intoEnd <= 0f -> -intoStart+ intoEnd > 0f && intoStart <= 0f -> intoEnd+ else -> return 0f+ }+ val t = (kotlin.math.abs(reach) / zone).coerceAtMost(1f)+ val pace = maxSpeed * (EDGE_FLOOR + (1f - EDGE_FLOOR) * t * t)+ return if (reach < 0f) -pace else pace+ }}diff --git a/base/app/src/test/java/com/music/spotui/ui/components/QueueEdgeScrollTest.kt b/base/app/src/test/java/com/music/spotui/ui/components/QueueEdgeScrollTest.ktindex a0f8de8d..ae3c70ea 100644--- a/base/app/src/test/java/com/music/spotui/ui/components/QueueEdgeScrollTest.kt+++ b/base/app/src/test/java/com/music/spotui/ui/components/QueueEdgeScrollTest.kt@@ -1,55 +1,11 @@package com.music.spotui.ui.componentsimport org.junit.Assert.assertEquals-import org.junit.Assert.assertTrueimport org.junit.Test/** The queue drag auto-scroll: direction and ramp of the per-frame scroll step. */+/** Where the queue block sits in the sheet's list, which the drag's auto-scroll reads. */class QueueEdgeScrollTest {- private val top = 200f- private val bottom = 1400f // 1200 px viewport, as on a phone in dp-ish units- private val zone = 72f- private val maxStep = 14f-- private fun step(pointerY: Float) = queueEdgeScrollStep(pointerY, top, bottom, zone, maxStep)-- @Test fun middleOfTheListDoesNotScroll() {- assertEquals(0f, step((top + bottom) / 2), 0f)- assertEquals(0f, step(top + zone), 0f) // inner border of the top zone- assertEquals(0f, step(bottom - zone), 0f) // inner border of the bottom zone- }-- @Test fun nearTheTopScrollsUpAndNearTheBottomScrollsDown() {- assertTrue(step(top + 10f) < 0f)- assertTrue(step(bottom - 10f) > 0f)- }-- @Test fun speedGrowsTowardsTheEdge() {- val shallow = step(top + zone / 2)- val deep = step(top + 1f)- assertTrue("deeper in the top zone must scroll faster", deep < shallow)- assertEquals(-maxStep, step(top), 0f)- assertEquals(maxStep, step(bottom), 0f)- }-- @Test fun speedIsCappedOutsideTheViewport() {- // A row dragged past the ends (already scrolled to the boundary) must not accelerate.- assertEquals(-maxStep, step(top - 500f), 0f)- assertEquals(maxStep, step(bottom + 500f), 0f)- }-- @Test fun zonesAreSymmetric() {- for (d in listOf(1f, 20f, 50f, 71f)) {- assertEquals(-step(top + d), step(bottom - d), 0.0001f)- }- }-- @Test fun aDegenerateViewportNeverScrolls() {- assertEquals(0f, queueEdgeScrollStep(top, top, top, zone, maxStep), 0f)- assertEquals(0f, queueEdgeScrollStep(top, bottom, top, zone, maxStep), 0f)- assertEquals(0f, queueEdgeScrollStep(top, top, bottom, 0f, maxStep), 0f)- }-@Test fun queueBlockOffsetFollowsTheListScroll() {val row = 64f// At rest: the queue block starts one row below the current track.diff --git a/base/app/src/test/java/com/music/spotui/ui/immersive/lyrics/QueueDragMathTest.kt b/base/app/src/test/java/com/music/spotui/ui/immersive/lyrics/QueueDragMathTest.ktindex 6bf53500..471f2202 100644--- a/base/app/src/test/java/com/music/spotui/ui/immersive/lyrics/QueueDragMathTest.kt+++ b/base/app/src/test/java/com/music/spotui/ui/immersive/lyrics/QueueDragMathTest.kt@@ -195,4 +195,37 @@ class QueueDragMathTest {assertTrue(move().report(listOf("x"), listOf("y"), "other", 1) is QueueDragMath.Verdict.Drop)}+ // ── Edge scroll pace: a clear part from 0 to 1000 px, 50 px zones, 1000 px/s at the edge ──++ private fun pace(y: Float) = QueueDragMath.edgePace(y, 0f, 1000f, 50f, 1000f)++ @Test fun aFingerClearOfTheZonesScrollsNothing() {+ assertEquals(0f, pace(500f), 0f)+ assertEquals(0f, pace(50f), 0f)+ assertEquals(0f, pace(950f), 0f)+ }++ @Test fun thePaceStartsLowAndEasesUpToTheFullSpeedAtTheEdge() {+ assertTrue(pace(49f) in 200f..210f)+ assertTrue(pace(25f) < 500f)+ assertTrue(pace(10f) > pace(30f))+ assertEquals(1000f, pace(0f), 0.01f)+ assertEquals(1000f, pace(1000f), 0.01f)+ assertEquals(pace(20f), pace(980f), 0.001f)+ }++ @Test fun pastTheEdgeItGoesNoFasterAndATinyListNeverScrolls() {+ assertEquals(1000f, pace(-300f), 0.01f)+ assertEquals(1000f, pace(1300f), 0.01f)+ assertEquals(0f, QueueDragMath.edgePace(10f, 0f, 80f, 50f, 1000f), 0f)+ }++ @Test fun aHeldRowScrollsBySignedPace() {+ val speed = { top: Float -> QueueDragMath.edgeSpeed(top, top + 100f, 0f, 1000f, 50f, 1000f) }+ assertEquals(0f, speed(450f), 0f)+ assertEquals(-1000f, speed(0f), 0.01f)+ assertEquals(1000f, speed(900f), 0.01f)+ assertTrue(speed(49f) <= -200f)+ assertEquals(0f, QueueDragMath.edgeSpeed(0f, 100f, 0f, 120f, 50f, 1000f), 0f)+ }}