mirror of
https://github.com/Droid-Deck/DroidDeck.git
synced 2026-11-24 23:36:04 +00:00
fix(onboarding): a smoother first run, from the child-process setting to the Steam sign-in (#3114)
The child-process fix always uses the guided pairing flow, Finish setup opens the setting directly and queues the Steam launch, the Play button carries the first-run progress, the setup bar weighs each download by its real size, and the Steam client packages download over four connections and unpack one at a time under a flock.
This commit is contained in:
1 parent
46ec222fa5
commit
39debda0b0
67 files changed
+1151
-2078
No files matched your search
@@ -7,11 +7,14 @@ import com.droiddeck.launcher.session.Onboarding.Step
|
||||
import org.junit.Assert.assertEquals
|
||||
import org.junit.Assert.assertFalse
|
||||
import org.junit.Assert.assertTrue
|
||||
import org.junit.Before
|
||||
import org.junit.Test
|
||||
|
||||
class OnboardingTest {
|
||||
private val none = Facts(runtime = false, proton = false, steam = false)
|
||||
|
||||
@Before fun fresh() = Onboarding.resetProgress()
|
||||
|
||||
@Test fun everythingReadyShowsNothing() {
|
||||
val rows = Onboarding.rows(emptyMap(), emptyMap(), Facts())
|
||||
assertFalse(Onboarding.pending(rows))
|
||||
@@ -31,7 +34,33 @@ class OnboardingTest {
|
||||
|
||||
@Test fun overallWeighsDownloadsBySize() {
|
||||
val rows = Onboarding.rows(mapOf(Step.RUNTIME to Progress("x", 50)), emptyMap(), Facts(runtime = false))
|
||||
assertEquals(30 + 15 + 25, Onboarding.overall(rows))
|
||||
assertEquals(10 + 30 + 50, Onboarding.overall(rows))
|
||||
}
|
||||
|
||||
@Test fun overallNeverGoesBackwardsWhileStepsHandOver() {
|
||||
val prefetched = Onboarding.rows(mapOf(Step.PROTON to Progress("x", 100)), emptyMap(), Facts(runtime = true, proton = false, steam = false))
|
||||
val before = Onboarding.overall(prefetched)
|
||||
val handover = Onboarding.rows(mapOf(Step.STEAM to Progress("y", 4)), emptyMap(), Facts(runtime = true, proton = false, steam = false))
|
||||
assertTrue(Onboarding.overall(handover) >= before)
|
||||
val installing = Onboarding.rows(mapOf(Step.PROTON to Progress("z", 0), Step.STEAM to Progress("y", 4)), emptyMap(), Facts(runtime = true, proton = false, steam = false))
|
||||
assertTrue(Onboarding.overall(installing) >= before)
|
||||
}
|
||||
|
||||
@Test fun overallStartsOverOnceEverythingIsReady() {
|
||||
Onboarding.overall(Onboarding.rows(mapOf(Step.RUNTIME to Progress("x", 90)), emptyMap(), Facts(runtime = false)))
|
||||
assertEquals(100, Onboarding.overall(Onboarding.rows(emptyMap(), emptyMap(), Facts())))
|
||||
val again = Onboarding.rows(mapOf(Step.RUNTIME to Progress("x", 10)), emptyMap(), Facts(runtime = false))
|
||||
assertEquals(2 + 30 + 50, Onboarding.overall(again))
|
||||
}
|
||||
|
||||
@Test fun settlingWithEverythingReadyStartsTheNextAttemptFromZero() {
|
||||
Onboarding.overall(Onboarding.rows(mapOf(Step.RUNTIME to Progress("x", 90)), emptyMap(), Facts(runtime = false)))
|
||||
Onboarding.active.value = emptyMap()
|
||||
Onboarding.failed.value = emptyMap()
|
||||
Onboarding.facts.value = Facts()
|
||||
Onboarding.settle()
|
||||
val again = Onboarding.rows(mapOf(Step.RUNTIME to Progress("x", 10)), emptyMap(), Facts(runtime = false))
|
||||
assertEquals(2 + 30 + 50, Onboarding.overall(again))
|
||||
}
|
||||
|
||||
@Test fun reportingClearsAPriorFailure() {
|
||||
|
||||
@@ -0,0 +1,116 @@
|
||||
package com.droiddeck.launcher.session
|
||||
|
||||
import org.junit.Assert.assertEquals
|
||||
import org.junit.Assert.assertNull
|
||||
import org.junit.Test
|
||||
|
||||
class QueuedLaunchRunnerTest {
|
||||
private class Clock {
|
||||
var now = 0L
|
||||
private class Task(val at: Long, val run: Runnable)
|
||||
private val tasks = mutableListOf<Task>()
|
||||
fun schedule(delay: Long, run: Runnable) { tasks += Task(now + delay, run) }
|
||||
fun cancel(run: Runnable) { tasks.removeAll { it.run === run } }
|
||||
/** Moves time forward and runs what is due, as the main thread would. */
|
||||
fun advance(ms: Long) {
|
||||
val end = now + ms
|
||||
while (true) {
|
||||
val next = tasks.filter { it.at <= end }.minByOrNull { it.at } ?: break
|
||||
tasks.remove(next)
|
||||
now = maxOf(now, next.at)
|
||||
next.run.run()
|
||||
}
|
||||
now = end
|
||||
}
|
||||
}
|
||||
|
||||
private class Owner(clock: Clock, queue: QueuedLaunch<String>, val state: State) {
|
||||
class State { var blocked = true; var busy = false }
|
||||
val started = mutableListOf<String>()
|
||||
val runner = QueuedLaunchRunner(
|
||||
queue = queue, now = { clock.now }, blocked = { state.blocked }, busy = { state.busy },
|
||||
schedule = clock::schedule, unschedule = clock::cancel, start = { started += it }, retryMs = 2_000,
|
||||
)
|
||||
}
|
||||
|
||||
private val minute = 60_000L
|
||||
|
||||
@Test fun aLaunchWaitsWhileTheSettingBlocksItAndStartsOnceItDoesNot() {
|
||||
val clock = Clock()
|
||||
val owner = Owner(clock, QueuedLaunch<String>(15 * minute).also { it.queue("steam", 0) }, Owner.State())
|
||||
owner.runner.poke()
|
||||
clock.advance(5_000)
|
||||
assertEquals(emptyList<String>(), owner.started)
|
||||
owner.state.blocked = false
|
||||
owner.runner.poke()
|
||||
clock.advance(1)
|
||||
assertEquals(listOf("steam"), owner.started)
|
||||
}
|
||||
|
||||
@Test fun aBusyRuntimeIsRetriedEveryTwoSecondsUntilItIsFree() {
|
||||
val clock = Clock()
|
||||
val state = Owner.State().apply { blocked = false; busy = true }
|
||||
val owner = Owner(clock, QueuedLaunch<String>(15 * minute).also { it.queue("steam", 0) }, state)
|
||||
owner.runner.poke()
|
||||
clock.advance(7_000)
|
||||
assertEquals(emptyList<String>(), owner.started)
|
||||
state.busy = false
|
||||
clock.advance(2_001)
|
||||
assertEquals(listOf("steam"), owner.started)
|
||||
clock.advance(10_000)
|
||||
assertEquals(listOf("steam"), owner.started)
|
||||
}
|
||||
|
||||
@Test fun aLaunchThatWaitsPastItsLifetimeIsNeverStarted() {
|
||||
val clock = Clock()
|
||||
val state = Owner.State().apply { blocked = false; busy = true }
|
||||
val owner = Owner(clock, QueuedLaunch<String>(15 * minute).also { it.queue("steam", 0) }, state)
|
||||
owner.runner.poke()
|
||||
clock.advance(16 * minute)
|
||||
state.busy = false
|
||||
clock.advance(10_000)
|
||||
assertEquals(emptyList<String>(), owner.started)
|
||||
}
|
||||
|
||||
@Test fun onlyTheRestoredOwnerStartsAfterTheFirstOneIsDestroyedMidRetry() {
|
||||
val clock = Clock()
|
||||
val state = Owner.State().apply { blocked = false; busy = true }
|
||||
val firstQueue = QueuedLaunch<String>(15 * minute).also { it.queue("steam", 0) }
|
||||
val first = Owner(clock, firstQueue, state)
|
||||
first.runner.poke()
|
||||
clock.advance(3_000)
|
||||
|
||||
val saved = firstQueue.launch
|
||||
val savedAt = firstQueue.queuedAt
|
||||
first.runner.destroy()
|
||||
val secondQueue = QueuedLaunch<String>(15 * minute).also { it.restore(saved, savedAt, clock.now) }
|
||||
val second = Owner(clock, secondQueue, state)
|
||||
second.runner.poke()
|
||||
|
||||
state.busy = false
|
||||
clock.advance(10_000)
|
||||
assertEquals(emptyList<String>(), first.started)
|
||||
assertEquals(listOf("steam"), second.started)
|
||||
assertNull(firstQueue.launch)
|
||||
}
|
||||
|
||||
@Test fun aDestroyedOwnerNeverStartsEvenIfItsRetryWasAlreadyDue() {
|
||||
val clock = Clock()
|
||||
val state = Owner.State().apply { blocked = false }
|
||||
val owner = Owner(clock, QueuedLaunch<String>(15 * minute).also { it.queue("steam", 0) }, state)
|
||||
owner.runner.poke()
|
||||
owner.runner.destroy()
|
||||
clock.advance(10_000)
|
||||
assertEquals(emptyList<String>(), owner.started)
|
||||
}
|
||||
|
||||
@Test fun pokingTwiceBeforeTheFirstAttemptStartsTheLaunchOnce() {
|
||||
val clock = Clock()
|
||||
val state = Owner.State().apply { blocked = false }
|
||||
val owner = Owner(clock, QueuedLaunch<String>(15 * minute).also { it.queue("steam", 0) }, state)
|
||||
owner.runner.poke()
|
||||
owner.runner.poke()
|
||||
clock.advance(1)
|
||||
assertEquals(listOf("steam"), owner.started)
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,49 @@
|
||||
package com.droiddeck.launcher.session
|
||||
|
||||
import org.junit.Assert.assertEquals
|
||||
import org.junit.Assert.assertNull
|
||||
import org.junit.Assert.assertSame
|
||||
import org.junit.Test
|
||||
|
||||
class QueuedLaunchTest {
|
||||
private val minute = 60_000L
|
||||
|
||||
@Test fun aQueuedLaunchIsWantedUntilItsLifetimeEnds() {
|
||||
val queue = QueuedLaunch<String>(15 * minute)
|
||||
queue.queue("steam", now = 100)
|
||||
assertEquals("steam", queue.current(100 + 14 * minute))
|
||||
assertNull(queue.current(100 + 16 * minute))
|
||||
assertNull(queue.launch)
|
||||
}
|
||||
|
||||
@Test fun aRestoredLaunchKeepsTheTimeItWasQueued() {
|
||||
val queue = QueuedLaunch<String>(15 * minute)
|
||||
queue.restore("steam", queuedAt = 0, now = 14 * minute)
|
||||
assertEquals("steam", queue.current(14 * minute))
|
||||
assertEquals(0L, queue.queuedAt)
|
||||
assertNull(queue.current(16 * minute))
|
||||
}
|
||||
|
||||
@Test fun aLaunchRestoredAfterItsLifetimeIsDropped() {
|
||||
val queue = QueuedLaunch<String>(15 * minute)
|
||||
queue.restore("steam", queuedAt = 0, now = 20 * minute)
|
||||
assertNull(queue.launch)
|
||||
}
|
||||
|
||||
@Test fun aLaunchRestoredWithoutAValidTimeIsDropped() {
|
||||
val queue = QueuedLaunch<String>(15 * minute)
|
||||
queue.restore("steam", queuedAt = 0, now = -1)
|
||||
assertNull(queue.launch)
|
||||
queue.restore(null, queuedAt = 5, now = 10)
|
||||
assertNull(queue.launch)
|
||||
}
|
||||
|
||||
@Test fun clearingForgetsTheLaunchSoAnOldCallbackDoesNotMatchIt() {
|
||||
val queue = QueuedLaunch<Any>(15 * minute)
|
||||
val launch = Any()
|
||||
queue.queue(launch, now = 0)
|
||||
assertSame(launch, queue.current(1))
|
||||
queue.clear()
|
||||
assertNull(queue.current(1))
|
||||
}
|
||||
}
|
||||
@@ -298,7 +298,7 @@ class CurseLinkTabTest {
|
||||
onInstallPackage = {}, onRemovePackage = {}, onRuntime = {}, onFrameGenPick = {},
|
||||
onImportLossless = {}, onProtons = {}, onComponents = {}, onPerformance = {},
|
||||
onRoms = {}, onFiles = {}, onLogs = {}, onOffline = {},
|
||||
onWirelessAdbPair = { _, _, _, _ -> }, onWirelessAdbApply = { _, _, _, _ -> },
|
||||
|
||||
onSetPhantomProcessLimit = { _, _ -> },
|
||||
)
|
||||
|
||||
|
||||
@@ -87,7 +87,7 @@ class DesktopUninstallTest {
|
||||
onSteamSettings = {}, onDesktopSettings = {}, onInstallPackage = {}, onRemovePackage = {},
|
||||
onRuntime = {}, onFrameGenPick = {}, onImportLossless = {}, onProtons = {}, onComponents = {},
|
||||
onPerformance = {}, onRoms = {}, onFiles = {}, onLogs = {}, onOffline = {},
|
||||
onWirelessAdbPair = { _, _, _, _ -> }, onWirelessAdbApply = { _, _, _, _ -> },
|
||||
|
||||
onSetPhantomProcessLimit = { _, _ -> }, onRemoveDesktop = { removals++ },
|
||||
), Modifier.fillMaxSize(), onSelect = {})
|
||||
StepsLayer(Offset.Zero)
|
||||
|
||||
@@ -67,7 +67,7 @@ class FlathubFocusTest {
|
||||
onInstallPackage = {}, onRemovePackage = {}, onRuntime = {}, onFrameGenPick = {},
|
||||
onImportLossless = {}, onProtons = {}, onComponents = {}, onPerformance = {},
|
||||
onRoms = {}, onFiles = {}, onLogs = {}, onOffline = {},
|
||||
onWirelessAdbPair = { _, _, _, _ -> }, onWirelessAdbApply = { _, _, _, _ -> },
|
||||
|
||||
onSetPhantomProcessLimit = { _, _ -> },
|
||||
))
|
||||
}
|
||||
|
||||
@@ -58,7 +58,7 @@ class GamesClientTagTest {
|
||||
onInstallPackage = {}, onRemovePackage = {}, onRuntime = {}, onFrameGenPick = {},
|
||||
onImportLossless = {}, onProtons = {}, onComponents = {}, onPerformance = {},
|
||||
onRoms = {}, onFiles = {}, onLogs = {}, onOffline = {},
|
||||
onWirelessAdbPair = { _, _, _, _ -> }, onWirelessAdbApply = { _, _, _, _ -> },
|
||||
|
||||
onSetPhantomProcessLimit = { _, _ -> },
|
||||
), selected = "games", onSelect = {}, modifier = Modifier.fillMaxSize())
|
||||
}
|
||||
|
||||
@@ -142,7 +142,7 @@ class GlobalGlassesSettingsTest {
|
||||
onInstallPackage = {}, onRemovePackage = {}, onRuntime = {}, onFrameGenPick = {},
|
||||
onImportLossless = {}, onProtons = {}, onComponents = {}, onPerformance = {},
|
||||
onRoms = {}, onFiles = {}, onLogs = {}, onOffline = {},
|
||||
onWirelessAdbPair = { _, _, _, _ -> }, onWirelessAdbApply = { _, _, _, _ -> },
|
||||
|
||||
onSetPhantomProcessLimit = { _, _ -> },
|
||||
), onOpenDeveloperOptions = {}, onRequestWirelessAdb = {}, onPairWirelessDebugging = {})
|
||||
}
|
||||
|
||||
@@ -100,7 +100,7 @@ class InputUiLayoutTest {
|
||||
onInstallPackage = {}, onRemovePackage = {}, onRuntime = {}, onFrameGenPick = {},
|
||||
onImportLossless = {}, onProtons = {}, onComponents = {}, onPerformance = {},
|
||||
onRoms = {}, onFiles = {}, onLogs = {}, onOffline = {},
|
||||
onWirelessAdbPair = { _, _, _, _ -> }, onWirelessAdbApply = { _, _, _, _ -> },
|
||||
|
||||
onSetPhantomProcessLimit = { _, _ -> }, controller = ControllerActions({}),
|
||||
), onOpenDeveloperOptions = {}, onRequestWirelessAdb = {}, onPairWirelessDebugging = {})
|
||||
}
|
||||
|
||||
@@ -66,7 +66,7 @@ class LaunchSettingsComponentsTest {
|
||||
onImportLossless = {}, onProtons = {}, onComponents = { defaultOpens++ },
|
||||
onGameComponents = { openedGame = it }, onPerformance = {},
|
||||
onRoms = {}, onFiles = {}, onLogs = {}, onOffline = {},
|
||||
onWirelessAdbPair = { _, _, _, _ -> }, onWirelessAdbApply = { _, _, _, _ -> },
|
||||
|
||||
onSetPhantomProcessLimit = { _, _ -> },
|
||||
),
|
||||
rememberMenuHost(),
|
||||
|
||||
@@ -230,7 +230,7 @@ class LibraryVisibilityTest {
|
||||
onInstallPackage = {}, onRemovePackage = {}, onRuntime = {}, onFrameGenPick = {},
|
||||
onImportLossless = {}, onProtons = {}, onComponents = {}, onPerformance = {},
|
||||
onRoms = {}, onFiles = {}, onLogs = {}, onOffline = {},
|
||||
onWirelessAdbPair = { _, _, _, _ -> }, onWirelessAdbApply = { _, _, _, _ -> },
|
||||
|
||||
onSetPhantomProcessLimit = { _, _ -> },
|
||||
)
|
||||
}
|
||||
@@ -262,7 +262,7 @@ class NavTabsTest {
|
||||
onSteamSettings = {}, onDesktopSettings = {}, onInstallPackage = {}, onRemovePackage = {},
|
||||
onRuntime = {}, onFrameGenPick = {}, onImportLossless = {}, onProtons = {}, onComponents = {},
|
||||
onPerformance = {}, onRoms = {}, onFiles = {}, onLogs = {}, onOffline = {},
|
||||
onWirelessAdbPair = { _, _, _, _ -> }, onWirelessAdbApply = { _, _, _, _ -> },
|
||||
|
||||
onSetPhantomProcessLimit = { _, _ -> }, onRemoveDesktop = {},
|
||||
)
|
||||
}
|
||||
@@ -94,7 +94,7 @@ class NavigationSelectionTest {
|
||||
onInstallPackage = {}, onRemovePackage = {}, onRuntime = {}, onFrameGenPick = {},
|
||||
onImportLossless = {}, onProtons = {}, onComponents = {}, onPerformance = {},
|
||||
onRoms = {}, onFiles = {}, onLogs = {}, onOffline = {},
|
||||
onWirelessAdbPair = { _, _, _, _ -> }, onWirelessAdbApply = { _, _, _, _ -> },
|
||||
|
||||
onSetPhantomProcessLimit = { _, _ -> },
|
||||
)
|
||||
}
|
||||
@@ -152,7 +152,7 @@ class PortraitLayoutTest {
|
||||
onInstallPackage = {}, onRemovePackage = {}, onRuntime = {}, onFrameGenPick = {},
|
||||
onImportLossless = {}, onProtons = {}, onComponents = {}, onPerformance = {},
|
||||
onRoms = {}, onFiles = {}, onLogs = {}, onOffline = {},
|
||||
onWirelessAdbPair = { _, _, _, _ -> }, onWirelessAdbApply = { _, _, _, _ -> },
|
||||
|
||||
onSetPhantomProcessLimit = { _, _ -> },
|
||||
)
|
||||
}
|
||||
@@ -101,7 +101,7 @@ class SteamHomeHeadsetTest {
|
||||
onInstallPackage = {}, onRemovePackage = {}, onRuntime = {}, onFrameGenPick = {},
|
||||
onImportLossless = {}, onProtons = {}, onComponents = {}, onPerformance = {},
|
||||
onRoms = {}, onFiles = {}, onLogs = {}, onOffline = {},
|
||||
onWirelessAdbPair = { _, _, _, _ -> }, onWirelessAdbApply = { _, _, _, _ -> },
|
||||
|
||||
onSetPhantomProcessLimit = { _, _ -> },
|
||||
), Modifier.fillMaxSize())
|
||||
}
|
||||
|
||||
@@ -145,7 +145,7 @@ class StoreRestorationTest {
|
||||
onInstallPackage = {}, onRemovePackage = {}, onRuntime = {}, onFrameGenPick = {},
|
||||
onImportLossless = {}, onProtons = {}, onComponents = {}, onPerformance = {},
|
||||
onRoms = {}, onFiles = {}, onLogs = {}, onOffline = {},
|
||||
onWirelessAdbPair = { _, _, _, _ -> }, onWirelessAdbApply = { _, _, _, _ -> },
|
||||
|
||||
onSetPhantomProcessLimit = { _, _ -> },
|
||||
)
|
||||
}
|
||||
Reference in new issue
Block a user