mirror of
https://github.com/Droid-Deck/DroidDeck.git
synced 2026-12-06 04:55:44 +00:00
Merge remote-tracking branch 'origin/main' into docs/bottom-screen-research
This commit is contained in:
commit
f7ef60917f
15 files changed
+225
-32
No files matched your search
@@ -126,6 +126,16 @@ object AgentSetup {
|
||||
Thread({ for ((step, command) in probes) probe(app, harness, step, command) }, "agent-checks").start()
|
||||
}
|
||||
|
||||
/** The last failed refresh ends the script: the installs after it would run from stale indexes and could report success. */
|
||||
internal fun installScript(harnessInstall: String) = "set -e; export DEBIAN_FRONTEND=noninteractive; " +
|
||||
"apt() { apt-get -o Acquire::Retries=5 -o Acquire::http::Timeout=30 \"\$@\"; }; " +
|
||||
"dpkg --configure -a || echo 'Some packages are not configured yet; repairing dependencies'; " +
|
||||
"for i in 1 2 3; do apt -o APT::Update::Error-Mode=any update -q && break; " +
|
||||
"[ \$i = 3 ] && { echo 'Some package sources could not be refreshed'; exit 1; }; " +
|
||||
"echo 'Some package sources could not be refreshed; retrying'; sleep 3; done; " +
|
||||
"apt -f install -y --fix-missing; " +
|
||||
"apt install -y --no-install-recommends git gh adb curl ca-certificates python3; $harnessInstall"
|
||||
|
||||
fun runsAsRoot(step: Step) = step == Step.INSTALL
|
||||
|
||||
/** Runs [step]'s action. [CONNECTION] is the app's own pairing flow, so the caller opens it. */
|
||||
@@ -140,12 +150,7 @@ object AgentSetup {
|
||||
val command = override ?: when (step) {
|
||||
Step.CONNECTION -> return
|
||||
Step.INSTALL -> {
|
||||
listOf("sh", "-c", "set -e; export DEBIAN_FRONTEND=noninteractive; " +
|
||||
"apt() { apt-get -o Acquire::Retries=5 -o Acquire::http::Timeout=30 \"\$@\"; }; " +
|
||||
"dpkg --configure -a || echo 'Some packages are not configured yet; repairing dependencies'; " +
|
||||
"for i in 1 2 3; do apt -o APT::Update::Error-Mode=any update -q && break; echo 'Some package sources could not be refreshed; retrying'; sleep 3; done; " +
|
||||
"apt -f install -y --fix-missing; " +
|
||||
"apt install -y --no-install-recommends git gh adb curl ca-certificates python3; ${harness.install}")
|
||||
listOf("sh", "-c", installScript(harness.install))
|
||||
}
|
||||
Step.SIGN_IN -> harness.signIn
|
||||
Step.GITHUB -> listOf("dd-gh-login")
|
||||
|
||||
@@ -5,7 +5,7 @@ import com.droiddeck.launcher.session.SessionPrefs
|
||||
|
||||
internal object DroidDeckHudConfig {
|
||||
val DEFAULTS: Map<String, String> = linkedMapOf(
|
||||
"hudSize" to "minimal", "hudLocked" to "1", "hudHold" to "collapse", "hudSnap" to "1", "hudScale" to "100", "hudDock" to "none", "hudOpacity" to "80", "hudColor" to "mid",
|
||||
"hudSize" to "minimal", "hudLocked" to "0", "hudHold" to "collapse", "hudSnap" to "1", "hudScale" to "100", "hudDock" to "none", "hudOpacity" to "80", "hudColor" to "mid",
|
||||
"hudOutline" to "40", "hudOutlineAccent" to "1",
|
||||
"showGpuModel" to "1", "showGPULoad" to "1", "showCPUUsage" to "1", "showCPULoad" to "1",
|
||||
"showPerCore" to "1", "showTemp" to "1", "showBatteryTemp" to "1", "showGpuTemp" to "0",
|
||||
|
||||
@@ -349,7 +349,7 @@ class DroidDeckHudView(context: Context) : View(context) {
|
||||
showProton = switchOn("showProton")
|
||||
showSession = switchOn("showSession")
|
||||
tempDisplay = HudMetrics.TempDisplay.from(cfg)
|
||||
lockController.setLocked(cfg.get("hudLocked", "1") == "1")
|
||||
lockController.setLocked(cfg.get("hudLocked", "0") == "1")
|
||||
lockController.setHoldLocks(cfg.get("hudHold", "collapse") == DroidDeckHudConfig.HOLD_LOCKS)
|
||||
dock = DroidDeckHudDock.from(cfg.get("hudDock", "none"))
|
||||
|
||||
|
||||
@@ -39,6 +39,10 @@ internal object BuildWatermarkSetting {
|
||||
throw error
|
||||
}
|
||||
}
|
||||
notifyChanged(context)
|
||||
}
|
||||
|
||||
fun notifyChanged(context: Context) {
|
||||
context.sendBroadcast(Intent(CHANGED).setPackage(context.packageName))
|
||||
}
|
||||
}
|
||||
@@ -26,6 +26,9 @@ object SessionPaths {
|
||||
@Volatile
|
||||
private var startedAt = 0L
|
||||
|
||||
@Volatile
|
||||
private var debugLogsContext: Context? = null
|
||||
|
||||
@Synchronized
|
||||
fun beginOrCurrent(context: Context, label: String? = null): File {
|
||||
dir?.let { if (it.isDirectory) return it }
|
||||
@@ -44,6 +47,7 @@ object SessionPaths {
|
||||
startedAt = System.currentTimeMillis()
|
||||
if (!made.isDirectory && !made.mkdirs()) Log.e(TAG, "could not create $made")
|
||||
dir = made
|
||||
debugLogsContext = if (SessionPrefs.gameDebugLogsEnabled(context)) context.applicationContext else null
|
||||
if (enhanced && !EnhancedDiagnostics.consumeInto(context, made)) {
|
||||
Log.e(TAG, "could not activate enhanced diagnostics for $made")
|
||||
}
|
||||
@@ -65,6 +69,9 @@ object SessionPaths {
|
||||
val taken = dir
|
||||
dir = null
|
||||
if (taken != null) ended = taken
|
||||
val expiring = debugLogsContext
|
||||
debugLogsContext = null
|
||||
if (taken != null && expiring != null) SessionPrefs.expireGameDebugLogs(expiring)
|
||||
return taken
|
||||
}
|
||||
|
||||
|
||||
@@ -1270,7 +1270,7 @@ object SessionPrefs {
|
||||
oldValue = logsEnabled(context),
|
||||
newValue = on,
|
||||
newEffective = gameDebugLogsEffective(context, on, gameDebugLogsEnabled(context)),
|
||||
)
|
||||
).also { if (it) BuildWatermarkSetting.notifyChanged(context) }
|
||||
}
|
||||
|
||||
fun gameDebugLogsEnabled(context: Context): Boolean =
|
||||
@@ -1283,7 +1283,13 @@ object SessionPrefs {
|
||||
oldValue = gameDebugLogsEnabled(context),
|
||||
newValue = on,
|
||||
newEffective = gameDebugLogsEffective(context, logsEnabled(context), on),
|
||||
)
|
||||
).also { if (it) BuildWatermarkSetting.notifyChanged(context) }
|
||||
}
|
||||
|
||||
/** The setting lasts for the session that started with it on; the next session's start republishes the environment. */
|
||||
internal fun expireGameDebugLogs(context: Context) {
|
||||
prefs(context).edit().putBoolean("gameDebugLogsEnabled", false).apply()
|
||||
runCatching { BuildWatermarkSetting.notifyChanged(context) }
|
||||
}
|
||||
|
||||
private fun setLogPreference(
|
||||
|
||||
@@ -81,10 +81,13 @@ object BuildWatermark {
|
||||
if (activity is QuestXrActivity) return
|
||||
val decor = activity.window.decorView as? ViewGroup ?: return
|
||||
decor.findViewWithTag<View>(TAG)?.let(decor::removeView)
|
||||
if (!com.droiddeck.launcher.session.SessionPrefs.buildWatermarkEnabled(activity)) return
|
||||
val lab = com.droiddeck.launcher.lab.LabOverlay.active?.let { "LAB | ${truncate(it.label)}" }
|
||||
val build = lineProvider().orEmpty()
|
||||
val content = (listOfNotNull(lab) + build).ifEmpty { return }
|
||||
val prefs = com.droiddeck.launcher.session.SessionPrefs
|
||||
val debugLogs = if (prefs.logsEnabled(activity) && prefs.gameDebugLogsEnabled(activity)) DEBUG_LOGS_LINE else null
|
||||
val build = if (prefs.buildWatermarkEnabled(activity)) {
|
||||
listOfNotNull(com.droiddeck.launcher.lab.LabOverlay.active?.let { "LAB | ${truncate(it.label)}" }) +
|
||||
lineProvider().orEmpty()
|
||||
} else emptyList()
|
||||
val content = (build + listOfNotNull(debugLogs)).ifEmpty { return }
|
||||
val margin = (8 * activity.resources.displayMetrics.density).toInt()
|
||||
decor.addView(
|
||||
MarkView(activity, content).apply { tag = TAG },
|
||||
@@ -96,6 +99,8 @@ object BuildWatermark {
|
||||
)
|
||||
}
|
||||
|
||||
internal const val DEBUG_LOGS_LINE = "GAME DEBUG LOGS ON | slows games"
|
||||
|
||||
private const val TAG = "build-watermark"
|
||||
|
||||
private class MarkView(context: Context, private val lines: List<String>) : View(context) {
|
||||
|
||||
@@ -374,7 +374,7 @@ internal fun LibraryPage(s: FrontEndState, a: FrontEndActions, selected: String,
|
||||
.map { it.store.id }.toSet()
|
||||
val sources = librarySources(
|
||||
all, storeTabs.map { it.store.id },
|
||||
listOfNotNull(Store.ITCH.id.takeIf { itchSignedIn && !soundMode }, Store.GAMEJOLT.id.takeIf { gameJoltSignedIn && !soundMode }, Library.ADDED.takeIf { stores }).toSet() + signInChips,
|
||||
listOfNotNull(Store.ITCH.id.takeIf { itchSignedIn && !soundMode }, Store.GAMEJOLT.id.takeIf { gameJoltSignedIn && !soundMode }, Library.ADDED.takeIf { stores }, Store.BATTLENET.id.takeIf { stores }).toSet() + signInChips,
|
||||
favorites, concealed,
|
||||
offStores = if (soundMode) emptySet() else storeTabs.filterNot { it.shown }.map { it.store.id }.toSet(),
|
||||
places = if (soundMode) DEFAULT_LIBRARY_PLACES else StoreTabsState.libraryPlaces,
|
||||
@@ -632,7 +632,8 @@ private fun LibraryGrid(
|
||||
// A search that matches nothing keeps the toolbar, so the search can still be cleared.
|
||||
val customEmpty = !soundMode && source == Library.ADDED && visible.isEmpty() && hiddenUninstalled == 0 && LibraryView.query.isBlank()
|
||||
val splash = !soundMode && (signInStore != null || customEmpty)
|
||||
val headerItems = (if (splash) 1 else 2) + (if (sizesPending) 1 else 0) + syncing.size
|
||||
val showHeader = !splash || source == Store.BATTLENET.id
|
||||
val headerItems = (if (showHeader) 2 else 1) + (if (sizesPending) 1 else 0) + syncing.size
|
||||
val expanded = showUninstalled == true
|
||||
val notInstalled = if (expanded) visible.count { !it.installed } else hiddenUninstalled
|
||||
val toggleAt = when {
|
||||
@@ -766,7 +767,7 @@ private fun LibraryGrid(
|
||||
Box(Modifier.onSizeChanged { chipsH = it.height }) { Rise(0) { if (soundMode) header() else filters() } }
|
||||
}
|
||||
val splashHeight = with(density) { (gridH - chipsH).toDp() - 28.dp }.coerceAtLeast(300.dp)
|
||||
if (!splash) item(key = if (soundMode) "filters" else "header", span = { GridItemSpan(maxLineSpan) }) { Rise(1) { if (soundMode) filters() else header() } }
|
||||
if (showHeader) item(key = if (soundMode) "filters" else "header", span = { GridItemSpan(maxLineSpan) }) { Rise(1) { if (soundMode) filters() else header() } }
|
||||
for ((store, line) in syncing) item(key = "sync-${store.id}", span = { GridItemSpan(maxLineSpan) }) {
|
||||
Column(verticalArrangement = Arrangement.spacedBy(4.dp), modifier = Modifier.fillMaxWidth()) {
|
||||
Text(store.shortLabel + " · " + line, fontSize = 12.sp, color = MaterialTheme.colorScheme.onSurfaceVariant, maxLines = 1, overflow = TextOverflow.Ellipsis)
|
||||
@@ -882,6 +883,12 @@ private fun LibraryHeader(
|
||||
clearSearchFocus = searchCleared, inlineWhenStacked = true,
|
||||
lead = soundLead,
|
||||
) {
|
||||
if (!soundMode && !s.shortcutPicker && source == Store.BATTLENET.id) {
|
||||
SecondaryButton(
|
||||
stringResource(R.string.bnet_open), enabled = !s.busy && DevPreview.library == LibraryPreview.OFF,
|
||||
compact = true, modifier = Modifier.testTag("library-battlenet-open"), onClick = a.onBattleNet,
|
||||
)
|
||||
}
|
||||
if (soundMode) HeaderIconButton(stringResource(R.string.soundtracks_saved), Icons.Filled.BookmarkBorder, "collections", onClick = onCollections)
|
||||
if (!soundMode && DeveloperTools.on && DevPreview.shortcuts) LibraryPreviewButton()
|
||||
DisplayButton()
|
||||
|
||||
@@ -27,7 +27,7 @@ internal object DeveloperTools {
|
||||
internal object NavTabs {
|
||||
const val MORE = "more"
|
||||
val ALL = listOf("steam", "desktop", "games", "downloads", "setup", "updates", "stores", "soundtracks", "components", "storage", "sync", "decky", "boot-movies", "android-apps", "agent")
|
||||
val DEFAULT_SHELVED = setOf("soundtracks", "components", "storage", "sync", "decky", "boot-movies", "agent")
|
||||
val DEFAULT_SHELVED = setOf("stores", "soundtracks", "components", "storage", "sync", "decky", "boot-movies", "agent")
|
||||
val DEFAULT_HIDDEN = setOf("android-apps", "agent")
|
||||
private val SHELVED_WHEN_NEW = setOf("storage", "sync", "decky", "boot-movies", "agent")
|
||||
private val OLD_ORDER = listOf("steam", "games", "soundtracks", "stores", "downloads", "desktop", "agent", "components", "android-apps", "storage", "sync", "setup", "updates")
|
||||
|
||||
@@ -966,7 +966,7 @@
|
||||
<string name="diagnostics_share_games">Games and compatibility</string>
|
||||
<string name="diagnostics_share_all">All bundles</string>
|
||||
<string name="setup_game_debug_logs">Game debug logs</string>
|
||||
<string name="setup_game_debug_logs_hint">Include Proton, Wine and graphics diagnostics on the next game launch. Can reduce performance and use more storage.</string>
|
||||
<string name="setup_game_debug_logs_hint">Include Proton, Wine and graphics diagnostics on the next game launch. Turns itself off when that session ends. Can reduce performance and use more storage.</string>
|
||||
<string name="setup_game_debug_logs_restart">Restart this session to save game debug logs</string>
|
||||
<string name="setup_logging_update_failed">Couldn\'t update logging. Check the switch and try again.</string>
|
||||
<string name="setup_agent_commands">Debugging tools</string>
|
||||
|
||||
@@ -0,0 +1,50 @@
|
||||
package com.droiddeck.launcher.agent
|
||||
|
||||
import java.io.File
|
||||
import org.junit.Assert.assertEquals
|
||||
import org.junit.Assert.assertTrue
|
||||
import org.junit.Assume.assumeTrue
|
||||
import org.junit.Rule
|
||||
import org.junit.Test
|
||||
import org.junit.rules.TemporaryFolder
|
||||
|
||||
class AgentSetupInstallScriptTest {
|
||||
@get:Rule val tmp = TemporaryFolder()
|
||||
|
||||
private fun run(updateSucceedsOnCall: Int): Pair<Int, List<String>> {
|
||||
val sh = listOf("/bin/sh", "/usr/bin/sh").firstOrNull { File(it).canExecute() }
|
||||
assumeTrue(sh != null)
|
||||
val bin = tmp.newFolder("bin")
|
||||
val calls = File(tmp.root, "calls")
|
||||
fun tool(name: String, body: String) = File(bin, name).apply { writeText("#!/bin/sh\n$body\n"); setExecutable(true) }
|
||||
tool("dpkg", "exit 0")
|
||||
tool("sleep", "exit 0")
|
||||
tool("apt-get", """
|
||||
echo "${'$'}*" >> '${calls.path}'
|
||||
case "${'$'}*" in
|
||||
*" update "*) n=${'$'}(grep -c ' update ' '${calls.path}'); [ "${'$'}n" -ge $updateSucceedsOnCall ] ;;
|
||||
*) exit 0 ;;
|
||||
esac
|
||||
""".trimIndent())
|
||||
val child = ProcessBuilder(sh, "-c", AgentSetup.installScript("echo harness-installed >> '${calls.path}'"))
|
||||
.apply { environment()["PATH"] = bin.path + File.pathSeparator + System.getenv("PATH") }
|
||||
.redirectErrorStream(true).start()
|
||||
child.inputStream.readBytes()
|
||||
val exit = child.waitFor()
|
||||
return exit to (if (calls.exists()) calls.readLines() else emptyList())
|
||||
}
|
||||
|
||||
@Test fun theInstallStopsWhenEveryUpdateAttemptFails() {
|
||||
val (exit, calls) = run(updateSucceedsOnCall = 99)
|
||||
assertTrue(exit != 0)
|
||||
assertEquals(3, calls.count { " update " in "$it " })
|
||||
assertTrue(calls.none { "install" in it })
|
||||
}
|
||||
|
||||
@Test fun theInstallContinuesWhenALaterUpdateAttemptSucceeds() {
|
||||
val (exit, calls) = run(updateSucceedsOnCall = 3)
|
||||
assertEquals(0, exit)
|
||||
assertTrue(calls.any { "install -y --no-install-recommends" in it })
|
||||
assertTrue("harness-installed" in calls.last())
|
||||
}
|
||||
}
|
||||
@@ -34,8 +34,8 @@ class DroidDeckHudPanelTest {
|
||||
assertEquals(DroidDeckHudSize.MINIMAL, DroidDeckHudSize.from(DroidDeckHudConfig.DEFAULTS["hudSize"]))
|
||||
}
|
||||
|
||||
@Test fun theHudStartsLocked() {
|
||||
assertEquals("1", DroidDeckHudConfig.DEFAULTS["hudLocked"])
|
||||
@Test fun theHudStartsUnlocked() {
|
||||
assertEquals("0", DroidDeckHudConfig.DEFAULTS["hudLocked"])
|
||||
}
|
||||
|
||||
@Test fun aLongPressCollapsesTheHudUnlessTheUserChoseToLockWithIt() {
|
||||
|
||||
@@ -0,0 +1,88 @@
|
||||
package com.droiddeck.launcher.session
|
||||
|
||||
import android.app.Activity
|
||||
import android.app.Application
|
||||
import android.content.Context
|
||||
import android.os.Looper
|
||||
import android.view.View
|
||||
import com.droiddeck.launcher.ui.BuildWatermark
|
||||
import org.junit.After
|
||||
import org.junit.Assert.assertFalse
|
||||
import org.junit.Assert.assertNotNull
|
||||
import org.junit.Assert.assertNull
|
||||
import org.junit.Assert.assertTrue
|
||||
import org.junit.Before
|
||||
import org.junit.Test
|
||||
import org.junit.runner.RunWith
|
||||
import org.robolectric.Robolectric
|
||||
import org.robolectric.RobolectricTestRunner
|
||||
import org.robolectric.RuntimeEnvironment
|
||||
import org.robolectric.Shadows.shadowOf
|
||||
import org.robolectric.annotation.Config
|
||||
import org.robolectric.annotation.ConscryptMode
|
||||
import org.robolectric.annotation.GraphicsMode
|
||||
import java.io.File
|
||||
|
||||
@RunWith(RobolectricTestRunner::class)
|
||||
@ConscryptMode(ConscryptMode.Mode.OFF)
|
||||
@GraphicsMode(GraphicsMode.Mode.LEGACY)
|
||||
@Config(sdk = [34], manifest = Config.NONE, application = Application::class)
|
||||
class GameDebugLogsExpiryTest {
|
||||
private val context get() = RuntimeEnvironment.getApplication()
|
||||
private val prefs get() = context.getSharedPreferences("session", Context.MODE_PRIVATE)
|
||||
|
||||
@Before fun reset() {
|
||||
SessionPaths.take()
|
||||
prefs.edit().clear().commit()
|
||||
listOf("build-watermark", "build-watermark.lock").forEach { File(context.filesDir, it).delete() }
|
||||
}
|
||||
|
||||
@After fun end() {
|
||||
SessionPaths.take()
|
||||
}
|
||||
|
||||
private fun setDebugLogs(on: Boolean) = prefs.edit().putBoolean("gameDebugLogsEnabled", on).commit()
|
||||
|
||||
@Test fun settingTurnsOffWhenTheSessionItStartedWithEnds() {
|
||||
setDebugLogs(true)
|
||||
SessionPaths.beginOrCurrent(context, "steam")
|
||||
assertTrue(SessionPrefs.gameDebugLogsEnabled(context))
|
||||
SessionPaths.take()
|
||||
assertFalse(SessionPrefs.gameDebugLogsEnabled(context))
|
||||
}
|
||||
|
||||
@Test fun settingStaysOnForTheSessionRunningWhenItWasEnabled() {
|
||||
SessionPaths.beginOrCurrent(context, "steam")
|
||||
setDebugLogs(true)
|
||||
SessionPaths.take()
|
||||
assertTrue(SessionPrefs.gameDebugLogsEnabled(context))
|
||||
SessionPaths.beginOrCurrent(context, "steam")
|
||||
SessionPaths.take()
|
||||
assertFalse(SessionPrefs.gameDebugLogsEnabled(context))
|
||||
}
|
||||
|
||||
@Test fun settingThatWasOffStaysOff() {
|
||||
SessionPaths.beginOrCurrent(context, "steam")
|
||||
SessionPaths.take()
|
||||
assertFalse(SessionPrefs.gameDebugLogsEnabled(context))
|
||||
}
|
||||
|
||||
@Test fun badgeShowsWhileOnEvenWithTheBuildWatermarkOff() {
|
||||
BuildWatermark.install(context)
|
||||
SessionPrefs.setBuildWatermarkEnabled(context, false)
|
||||
val activity = Robolectric.buildActivity(Activity::class.java).setup()
|
||||
try {
|
||||
assertNull(activity.get().window.decorView.findViewWithTag<View>("build-watermark"))
|
||||
setDebugLogs(true)
|
||||
BuildWatermarkSetting.notifyChanged(context)
|
||||
shadowOf(Looper.getMainLooper()).idle()
|
||||
assertNotNull(activity.get().window.decorView.findViewWithTag<View>("build-watermark"))
|
||||
SessionPaths.beginOrCurrent(context, "steam")
|
||||
SessionPaths.take()
|
||||
shadowOf(Looper.getMainLooper()).idle()
|
||||
assertNull(activity.get().window.decorView.findViewWithTag<View>("build-watermark"))
|
||||
} finally {
|
||||
activity.pause().stop().destroy()
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -11,6 +11,7 @@ import androidx.compose.runtime.snapshots.Snapshot
|
||||
import androidx.compose.ui.Modifier
|
||||
import androidx.compose.ui.geometry.Offset
|
||||
import androidx.compose.ui.test.assertIsDisplayed
|
||||
import androidx.compose.ui.test.assertIsNotEnabled
|
||||
import androidx.compose.ui.test.assertCountEquals
|
||||
import androidx.compose.ui.test.onAllNodesWithText
|
||||
import androidx.compose.ui.test.onNodeWithContentDescription
|
||||
@@ -195,13 +196,32 @@ class LibraryVisibilityTest {
|
||||
compose.onNodeWithText("Uninstalled GOG").assertExists()
|
||||
}
|
||||
|
||||
private fun show() {
|
||||
@Test fun battleNetHasAnOpenClientActionEvenWithoutInstalledGames() {
|
||||
var opened = 0
|
||||
show(actions(onBattleNet = { opened++ }))
|
||||
compose.onNodeWithTag("library-battlenet-open").assertDoesNotExist()
|
||||
compose.onNodeWithTag("library-source-battlenet").performClick()
|
||||
compose.mainClock.advanceTimeBy(1_000)
|
||||
compose.onNodeWithTag("library-battlenet-open").assertIsDisplayed().performClick()
|
||||
assertEquals(1, opened)
|
||||
compose.onNodeWithTag("library-source-steam").performClick()
|
||||
compose.mainClock.advanceTimeBy(1_000)
|
||||
compose.onNodeWithTag("library-battlenet-open").assertDoesNotExist()
|
||||
}
|
||||
|
||||
@Test fun battleNetOpenIsDisabledWhileBusy() {
|
||||
LibraryView.source = Store.BATTLENET.id
|
||||
show(frontState = state(busy = true))
|
||||
compose.onNodeWithTag("library-battlenet-open").assertIsNotEnabled()
|
||||
}
|
||||
|
||||
private fun show(frontActions: FrontEndActions = actions(), frontState: FrontEndState = state()) {
|
||||
compose.mainClock.autoAdvance = false
|
||||
compose.setContent { key(generation) {
|
||||
DroidDeckTheme {
|
||||
CompositionLocalProvider(LocalFrontFocus provides FrontFocus()) {
|
||||
FocusGlideHost { Box(Modifier.fillMaxSize()) {
|
||||
LibraryPage(state(), actions(), "games", {}, Modifier.fillMaxSize())
|
||||
LibraryPage(frontState, frontActions, "games", {}, Modifier.fillMaxSize())
|
||||
StepsLayer(Offset.Zero)
|
||||
} }
|
||||
}
|
||||
@@ -216,15 +236,16 @@ class LibraryVisibilityTest {
|
||||
assertEquals(show, SessionPrefs.libraryShowUninstalled(ctx))
|
||||
}
|
||||
|
||||
private fun state(games: List<Library.SteamGame> = listOf(Library.SteamGame(440, "Installed Steam game", null, "internal"))) = FrontEndState(
|
||||
installed = "r9", ready = true, available = null, busy = false, stage = "", percent = -1,
|
||||
private fun state(games: List<Library.SteamGame> = listOf(Library.SteamGame(440, "Installed Steam game", null, "internal")), busy: Boolean = false) = FrontEndState(
|
||||
installed = "r9", ready = true, available = null, busy = busy, stage = "", percent = -1,
|
||||
desktopInstalled = true, offlineAccount = null, offline = false, frameGenLabel = "",
|
||||
romsDir = null, logsEnabled = false,
|
||||
steamGames = games,
|
||||
emulators = emptyList(), running = null,
|
||||
)
|
||||
|
||||
private fun actions() = FrontEndActions(
|
||||
private fun actions(onBattleNet: () -> Unit = {}) = FrontEndActions(
|
||||
onBattleNet = onBattleNet,
|
||||
onPlay = {}, onPlayDesktopUi = {}, onSteamGame = {}, onDesktop = {}, onEmulator = {},
|
||||
onRom = {}, onResume = {}, onSteamSettings = {}, onDesktopSettings = {},
|
||||
onInstallPackage = {}, onRemovePackage = {}, onRuntime = {}, onFrameGenPick = {},
|
||||
|
||||
@@ -40,8 +40,8 @@ class NavTabsTest {
|
||||
}
|
||||
|
||||
@Test fun aFreshInstallShowsTheDefaultBarMoreAndHiddenTabs() {
|
||||
assertEquals(listOf("steam", "desktop", "games", "downloads", "setup", "updates", "stores", NavTabs.MORE), navigationKeys(state()))
|
||||
assertEquals(listOf("soundtracks", "components", "storage", "sync", "decky", "boot-movies"), NavTabs.more(state()))
|
||||
assertEquals(listOf("steam", "desktop", "games", "downloads", "setup", "updates", NavTabs.MORE), navigationKeys(state()))
|
||||
assertEquals(listOf("stores", "soundtracks", "components", "storage", "sync", "decky", "boot-movies"), NavTabs.more(state()))
|
||||
assertEquals(TabPlace.HIDDEN, NavTabs.place(state(), "android-apps"))
|
||||
assertEquals(TabPlace.HIDDEN, NavTabs.place(state(), "agent"))
|
||||
assertFalse(com.droiddeck.launcher.agent.AgentTab.shown)
|
||||
@@ -66,13 +66,13 @@ class NavTabsTest {
|
||||
@Test fun showingMusicOnceKeepsItShownAfterReload() {
|
||||
place("soundtracks", TabPlace.BAR)
|
||||
NavTabs.load(ctx)
|
||||
assertEquals(listOf("steam", "desktop", "games", "downloads", "setup", "updates", "stores", "soundtracks", NavTabs.MORE), navigationKeys(state()))
|
||||
assertEquals(listOf("steam", "desktop", "games", "downloads", "setup", "updates", "soundtracks", NavTabs.MORE), navigationKeys(state()))
|
||||
}
|
||||
|
||||
@Test fun shelvedTabsLeaveTheBarAndAddMoreAtTheEnd() {
|
||||
place("desktop", TabPlace.MORE)
|
||||
val s = state()
|
||||
assertEquals(listOf("desktop", "soundtracks", "components", "storage", "sync", "decky", "boot-movies"), NavTabs.more(s))
|
||||
assertEquals(listOf("desktop", "stores", "soundtracks", "components", "storage", "sync", "decky", "boot-movies"), NavTabs.more(s))
|
||||
assertEquals(NavTabs.MORE, navigationKeys(s).last())
|
||||
assertFalse("desktop" in navigationKeys(s))
|
||||
}
|
||||
@@ -85,14 +85,14 @@ class NavTabsTest {
|
||||
}
|
||||
|
||||
@Test fun resettingPutsBackTheDefaultLayout() {
|
||||
place("stores", TabPlace.MORE)
|
||||
place("stores", TabPlace.BAR)
|
||||
place("updates", TabPlace.HIDDEN)
|
||||
moveTab("downloads", -1)
|
||||
assertFalse(NavTabs.isDefault())
|
||||
NavTabs.reset(ctx)
|
||||
NavTabs.load(ctx)
|
||||
assertTrue(NavTabs.isDefault())
|
||||
assertEquals(listOf("steam", "desktop", "games", "downloads", "setup", "updates", "stores", NavTabs.MORE), navigationKeys(state()))
|
||||
assertEquals(listOf("steam", "desktop", "games", "downloads", "setup", "updates", NavTabs.MORE), navigationKeys(state()))
|
||||
}
|
||||
|
||||
@Test fun anOldLayoutKeepsWhatItsSwitchesShowed() {
|
||||
|
||||
Reference in new issue
Block a user