feat: DroidDeck-Proton is downloaded, kept up to date and used by default (#1540)

This commit is contained in:
MaxsTechReview authored and GitHub committed 2026-10-25 10:09:22 -04:00
1 parent 2a69505199
commit 3fdc74051c
12 files changed
+389 -16

No files matched your search

@@ -0,0 +1,30 @@
package com.droiddeck.launcher.session
import org.json.JSONObject
import org.junit.Assert.assertEquals
import org.junit.Test
import org.junit.runner.RunWith
import org.robolectric.RobolectricTestRunner
@RunWith(RobolectricTestRunner::class)
class ComponentsCarryOverTest {
@Test
fun swappedPackagesFollowTheBuildThatReplacesTheirProton() {
val state = JSONObject("""
{"active": {"DroidDeck-Proton_11-11.2": {
"dxvk": {"file": "dxvk-2.7.wcp", "label": "2.7", "protonVersion": "11-11.2"},
"vkd3d": {"file": "original 11-11.1", "label": "Original from 11-11.1"},
"fex": {"file": "gone.wcp", "label": "old"}}},
"queued": {"DroidDeck-Proton_11-11.2": {
"vkd3d": {"kind": "package", "file": "vkd3d-3.0.wcp", "label": "3.0"},
"fex": {"kind": "original", "protonVersion": "11-11.1", "label": "Original 11-11.1"}}}}
""".trimIndent())
val carried = ComponentsManager.carried(state, "DroidDeck-Proton_11-11.2") { it != "gone.wcp" }
assertEquals(setOf("dxvk", "vkd3d"), carried.keys)
assertEquals("package", carried.getValue("dxvk").getString("kind"))
assertEquals("dxvk-2.7.wcp", carried.getValue("dxvk").getString("file"))
assertEquals("2.7", carried.getValue("dxvk").getString("label"))
assertEquals("vkd3d-3.0.wcp", carried.getValue("vkd3d").getString("file"))
assertEquals(emptyMap<String, JSONObject>(), ComponentsManager.carried(state, "GE-Proton11-7") { true })
}
}
@@ -103,4 +103,28 @@ class ProtonDefaultTest {
assertNull(ProtonDefault.gameSelectedId(context, "42", listOf(proton("GE-Proton11-7", false))))
assertEquals(ProtonDefault.GameChoice(false, "GE-Proton9-1"), ProtonDefault.parseGames(file.readText())["42"])
}
@Test
fun aReplacedBuildsPerGamePicksMoveToTheNewest() {
val old = ProtonDefault.GameChoice(false, "DroidDeck-Proton 11-11.2")
val ge = ProtonDefault.GameChoice(false, "GE-Proton11-7")
val valve = ProtonDefault.GameChoice(true, "DroidDeck-Proton 11-11.2")
val moved = ProtonDefault.movedGames(mapOf("42" to old, "43" to ge, "44" to null, "45" to valve), setOf("DroidDeck-Proton 11-11.2"), "DroidDeck-Proton 11-11.4")
assertEquals(mapOf("42" to ProtonDefault.GameChoice(false, "DroidDeck-Proton 11-11.4"), "43" to ge, "44" to null, "45" to valve), moved)
assertNull(ProtonDefault.movedGames(mapOf("43" to ge, "44" to null), setOf("DroidDeck-Proton 11-11.2"), "DroidDeck-Proton 11-11.4"))
}
@Test
fun movingPicksRewritesTheGamesFile() {
val context = RuntimeEnvironment.getApplication()
val file = File(LinuxRuntime.rootDir(context), "root/.local/share/droiddeck-compat/games.json")
file.parentFile?.deleteRecursively()
ProtonDefault.requestGame(context, "42", proton("DroidDeck-Proton 11-11.2", false))
ProtonDefault.requestGame(context, "43", null)
ProtonDefault.moveGames(context, setOf("DroidDeck-Proton 11-11.2"), "DroidDeck-Proton 11-11.4")
val games = ProtonDefault.parseGames(file.readText())
assertEquals(ProtonDefault.GameChoice(false, "DroidDeck-Proton 11-11.4"), games["42"])
assertTrue(games.containsKey("43"))
assertNull(games["43"])
}
}
@@ -198,4 +198,35 @@ class ProtonExtrasTest {
ComponentsManager.forgetProton(context, kept.name)
assertTrue(File(originals, "GE-Proton11-8/GE-Proton11-8/dxvk.wcp").isFile)
}
@Test
fun anUpdateKeepsTheUsersProtonSettingsFile() {
val context = RuntimeEnvironment.getApplication()
val tools = File(LinuxRuntime.rootDir(context), "root/.local/share/Steam/compatibilitytools.d")
tools.deleteRecursively()
File(installTool(tools, "DroidDeck-Proton 11-11.1"), "user_settings.py").writeText("old")
File(installTool(tools, "DroidDeck-Proton 11-11.4"), "user_settings.py").writeText("mine")
installTool(tools, "DroidDeck-Proton 11-11.5")
ProtonExtras.tidy(context)
assertEquals(listOf("DroidDeck-Proton 11-11.5"), ProtonExtras.installedAll(context, tool("droiddeck")))
assertEquals("mine", File(tools, "DroidDeck-Proton 11-11.5/user_settings.py").readText())
}
@Test
fun droidDeckProtonIsFetchedWhenMissingUnlessTheUserRemovedIt() {
val context = RuntimeEnvironment.getApplication()
val tools = File(LinuxRuntime.rootDir(context), "root/.local/share/Steam/compatibilitytools.d")
tools.deleteRecursively()
File(context.filesDir, "proton-latest.json").writeText(
"""{"droiddeck":{"tag":"DroidDeck-Proton-11-11.4","at":1},"ge":{"tag":"GE-Proton11-7","at":1}}""")
ProtonExtras.setDeclined(context, false)
assertEquals("DroidDeck-Proton-11-11.4", ProtonExtras.missing(context, tool("droiddeck")))
assertNull(ProtonExtras.missing(context, tool("ge")))
ProtonExtras.setDeclined(context, true)
assertNull(ProtonExtras.missing(context, tool("droiddeck")))
ProtonExtras.setDeclined(context, false)
installTool(tools, "DroidDeck-Proton 11-11.2")
assertNull(ProtonExtras.missing(context, tool("droiddeck")))
assertEquals("DroidDeck-Proton-11-11.4", ProtonExtras.update(context, tool("droiddeck")))
}
}