mirror of
https://github.com/Droid-Deck/DroidDeck.git
synced 2026-11-18 20:36:04 +00:00
feat: DroidDeck-Proton is downloaded, kept up to date and used by default (#1540)
This commit is contained in:
1 parent
2a69505199
commit
3fdc74051c
12 files changed
+389
-16
No files matched your search
@@ -88,7 +88,7 @@ class ProtonMenuAutoTest {
|
||||
fail("Proton work did not finish")
|
||||
}
|
||||
|
||||
@Test fun aCachedCheckUpdatesOnlyInstalledFamiliesAndKeepsOlderBuildsAndSelections() {
|
||||
@Test fun aCachedCheckUpdatesOnlyInstalledFamiliesAndReplacesOlderDroidDeckProton() {
|
||||
val older = install("DroidDeck-Proton-11-11.1")
|
||||
val request = File(root, "root/.local/share/droiddeck-compat/request.json").apply {
|
||||
parentFile!!.mkdirs()
|
||||
@@ -97,8 +97,8 @@ class ProtonMenuAutoTest {
|
||||
val before = request.readText()
|
||||
assertFalse(ProtonExtras.checkLatest(activity))
|
||||
menu.checkUpdates()
|
||||
waitUntil { menu.protonRows.singleOrNull { it.id == "droiddeck" }?.installed == "DroidDeck-Proton-11-12" && menu.protonBusyId == null }
|
||||
assertTrue(older.isDirectory)
|
||||
waitUntil { menu.protonRows.singleOrNull { it.id == "droiddeck" }?.installed == "DroidDeck-Proton-11-12" && menu.protonBusyId == null && !older.exists() }
|
||||
assertEquals(listOf("DroidDeck-Proton-11-12"), ProtonExtras.installedAll(activity, ProtonExtras.tools.first { it.id == "droiddeck" }))
|
||||
assertEquals(before, request.readText())
|
||||
assertTrue(ProtonExtras.installedAll(activity, ProtonExtras.tools.first { it.id == "ge" }).isEmpty())
|
||||
assertTrue(ProtonExtras.installedAll(activity, ProtonExtras.tools.first { it.id == "cachyos" }).isEmpty())
|
||||
@@ -128,7 +128,7 @@ class ProtonMenuAutoTest {
|
||||
|
||||
@Test fun aFailedUpdateDoesNotLoopOrBlockOtherInstalledFamilies() {
|
||||
val ge = install("GE-Proton11-11")
|
||||
val dd = install("DroidDeck-Proton-11-11.1")
|
||||
install("DroidDeck-Proton-11-11.1")
|
||||
menu.installer = { tool, _ ->
|
||||
attempts.add(tool.id)
|
||||
if (tool.id == "ge") throw IllegalStateException("download failed")
|
||||
@@ -138,10 +138,10 @@ class ProtonMenuAutoTest {
|
||||
menu.ensureAutoUpdates()
|
||||
waitUntil { menu.protonBusyId == null }
|
||||
menu.ensureAutoUpdates()
|
||||
shadowOf(Looper.getMainLooper()).idle()
|
||||
waitUntil { menu.protonBusyId == null }
|
||||
assertEquals(listOf("ge", "droiddeck"), attempts)
|
||||
assertTrue(ge.isDirectory)
|
||||
assertTrue(dd.isDirectory)
|
||||
assertEquals(listOf("DroidDeck-Proton-11-12"), ProtonExtras.installedAll(activity, ProtonExtras.tools.first { it.id == "droiddeck" }))
|
||||
assertNull(menu.protonStage)
|
||||
assertEquals(-1, menu.protonPercent)
|
||||
}
|
||||
@@ -184,6 +184,31 @@ class ProtonMenuAutoTest {
|
||||
assertEquals("DroidDeck-Proton-11-12", ProtonExtras.installed(activity, ProtonExtras.tools.first { it.id == "droiddeck" }))
|
||||
}
|
||||
|
||||
@Test fun droidDeckProtonIsInstalledWhenMissingUnlessTheUserRemovedIt() {
|
||||
menu.installer = { tool, _ -> attempts.add(tool.id); install("${tool.prefix}-11-12"); null }
|
||||
ProtonExtras.setDeclined(activity, true)
|
||||
menu.ensureAutoUpdates()
|
||||
assertNull(menu.protonBusyId)
|
||||
assertTrue(attempts.isEmpty())
|
||||
ProtonExtras.setDeclined(activity, false)
|
||||
menu.ensureAutoUpdates()
|
||||
waitUntil { menu.protonBusyId == null }
|
||||
assertEquals(listOf("droiddeck"), attempts)
|
||||
assertEquals("DroidDeck-Proton-11-12", ProtonExtras.installed(activity, ProtonExtras.tools.first { it.id == "droiddeck" }))
|
||||
assertTrue(ProtonExtras.installedAll(activity, ProtonExtras.tools.first { it.id == "ge" }).isEmpty())
|
||||
menu.removeProton("droiddeck")
|
||||
waitUntil { menu.protonBusyId == null }
|
||||
assertTrue(ProtonExtras.declined(activity))
|
||||
menu.installer = { _, _ -> "failed" }
|
||||
menu.installProton("droiddeck")
|
||||
waitUntil { menu.protonBusyId == null }
|
||||
assertTrue(ProtonExtras.declined(activity))
|
||||
menu.installer = { tool, _ -> install("${tool.prefix}-11-12"); null }
|
||||
menu.installProton("droiddeck")
|
||||
waitUntil { menu.protonBusyId == null }
|
||||
assertFalse(ProtonExtras.declined(activity))
|
||||
}
|
||||
|
||||
@Test fun aPendingAnimatedLaunchPreventsAnAutomaticInstall() {
|
||||
install("DroidDeck-Proton-11-11.1")
|
||||
val launcher = Robolectric.buildActivity(FrontEndActivity::class.java).get()
|
||||
|
||||
@@ -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")))
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user