mirror of
https://github.com/Droid-Deck/DroidDeck.git
synced 2026-11-26 00:06:02 +00:00
fix(library): keep another program of a Steam install out of the Steam app's route (#2742)
* fix(library): keep another program of a Steam install out of the Steam app's route * fix(library): cover a Steam-edited target in the unrouted-program test and docs * fix(library): keep Steam-edited targets routed and release stale Spacewar imports for other programs * fix(library): keep Steam-edited targets adopted before the marker existed routed A saved executable and seen revision without the adoption marker are recognised from the Steam shortcut record (its target is the current executable and differs from the one the app asked for), and the marker is stored.
This commit is contained in:
1 parent
43ff1db06b
commit
46d42f9ca9
7 files changed
+170
-10
No files matched your search
@@ -297,6 +297,39 @@ class AddedExesTest {
|
||||
assertEquals(listOf(other.path), AddedGames.scan(app).map { it.exe.path })
|
||||
}
|
||||
|
||||
private fun routeEveryGameTo(steamApp: Int) {
|
||||
val config = File(SessionPrefs.activeSteamRoot(app), "userdata/123/config").apply { mkdirs() }
|
||||
val routes = org.json.JSONObject()
|
||||
AddedGames.scan(app).forEach { routes.put(it.appId.toString(), steamApp) }
|
||||
File(config, ".droiddeck-routes.json").writeText(routes.toString())
|
||||
}
|
||||
|
||||
@Test fun anotherProgramOfASteamInstallIsNotRoutedToTheSteamApp() {
|
||||
noGamesFolders()
|
||||
val main = onStorage("Games2/The Binding of Isaac Rebirth/isaac-ng.exe")
|
||||
val launcher = onStorage("Games2/The Binding of Isaac Rebirth/REPENTOGONLauncher.exe")
|
||||
AddedExes.put(app, AddedExes.Entry(main.parent!!, launcher.path))
|
||||
routeEveryGameTo(250900)
|
||||
val game = AddedGames.scan(app).single()
|
||||
assertEquals(launcher.path, game.exe.path)
|
||||
assertEquals(main.path, game.candidates.first().path)
|
||||
assertNull(game.steamAppId)
|
||||
assertTrue(!game.steamProgram)
|
||||
assertTrue(File(AddedGames.writeListing(app, listOf(game), emptyList()).path).readText().contains("\"route\":false"))
|
||||
}
|
||||
|
||||
@Test fun theSteamAppsOwnProgramStillRoutesToTheSteamApp() {
|
||||
noGamesFolders()
|
||||
val main = onStorage("Games2/The Binding of Isaac Rebirth/isaac-ng.exe")
|
||||
onStorage("Games2/The Binding of Isaac Rebirth/REPENTOGONLauncher.exe")
|
||||
AddedExes.put(app, AddedExes.Entry(main.parent!!, main.path))
|
||||
routeEveryGameTo(250900)
|
||||
val game = AddedGames.scan(app).single()
|
||||
assertEquals(250900, game.steamAppId)
|
||||
assertTrue(game.steamProgram)
|
||||
assertTrue(!File(AddedGames.writeListing(app, listOf(game), emptyList()).path).readText().contains("route"))
|
||||
}
|
||||
|
||||
@Test fun aDifferentGameWithANumberedNameIsNotTakenAsAnotherBuild() {
|
||||
noGamesFolders()
|
||||
val held = onStorage("Games2/id/Doom/Doom.exe")
|
||||
|
||||
@@ -47,6 +47,11 @@ class AddedGamesSteamEditsTest {
|
||||
.writeText(JSONObject().put("games", JSONObject().put(appId.toString(), game)).toString())
|
||||
}
|
||||
|
||||
private fun legacyAdoption(exe: File, seen: Int) {
|
||||
context.getSharedPreferences("session", Context.MODE_PRIVATE).edit()
|
||||
.putString("addedExe:${folder.path}", exe.path).putInt("addedExeSeen:${folder.path}", seen).commit()
|
||||
}
|
||||
|
||||
private fun scanned() = AddedGames.scan(context).single { it.folder == folder }
|
||||
|
||||
@Test fun aTargetChangedInSteamBecomesTheAppsChoiceOnce() {
|
||||
@@ -68,6 +73,65 @@ class AddedGamesSteamEditsTest {
|
||||
assertEquals(main.path, SessionPrefs.addedGameExe(context, folder.path))
|
||||
}
|
||||
|
||||
@Test fun aTargetChosenInSteamKeepsTheSteamAppsRouteBeforeAndAfterItIsAdopted() {
|
||||
val first = scanned()
|
||||
val routes = File(LinuxRuntime.rootDir(context), "root/.local/share/Steam/userdata/123/config/.droiddeck-routes.json")
|
||||
routes.writeText(JSONObject().put(first.appId.toString(), 250900).toString())
|
||||
assertEquals(250900, scanned().steamAppId)
|
||||
|
||||
record(first.appId, "/root/Games/PC/Example/Example.exe", "/root/Games/PC/Example/bin/Other.exe", 1)
|
||||
val adopted = scanned()
|
||||
assertEquals(other, adopted.exe)
|
||||
assertEquals(250900, adopted.steamAppId)
|
||||
assertTrue(adopted.steamProgram)
|
||||
|
||||
val later = scanned()
|
||||
assertEquals(other, later.exe)
|
||||
assertEquals(250900, later.steamAppId)
|
||||
assertTrue(later.steamProgram)
|
||||
}
|
||||
|
||||
@Test fun aTargetAdoptedBeforeTheMarkerExistedKeepsTheSteamAppsRoute() {
|
||||
val first = scanned()
|
||||
val routes = File(LinuxRuntime.rootDir(context), "root/.local/share/Steam/userdata/123/config/.droiddeck-routes.json")
|
||||
routes.writeText(JSONObject().put(first.appId.toString(), 250900).toString())
|
||||
record(first.appId, "/root/Games/PC/Example/Example.exe", "/root/Games/PC/Example/bin/Other.exe", 1)
|
||||
legacyAdoption(other, 1)
|
||||
assertNull(SessionPrefs.addedGameAdopted(context, folder.path, "Exe"))
|
||||
val legacy = scanned()
|
||||
assertEquals(other, legacy.exe)
|
||||
assertEquals(250900, legacy.steamAppId)
|
||||
assertTrue(legacy.steamProgram)
|
||||
assertEquals(other.path, SessionPrefs.addedGameAdopted(context, folder.path, "Exe"))
|
||||
}
|
||||
|
||||
@Test fun aProgramPickedInDroidDeckThatSteamNeverEditedStaysOutOfTheRoute() {
|
||||
val first = scanned()
|
||||
val routes = File(LinuxRuntime.rootDir(context), "root/.local/share/Steam/userdata/123/config/.droiddeck-routes.json")
|
||||
routes.writeText(JSONObject().put(first.appId.toString(), 250900).toString())
|
||||
record(first.appId, "/root/Games/PC/Example/Example.exe", "/root/Games/PC/Example/Example.exe", 1)
|
||||
legacyAdoption(other, 1)
|
||||
val picked = scanned()
|
||||
assertEquals(other, picked.exe)
|
||||
assertNull(picked.steamAppId)
|
||||
assertTrue(!picked.steamProgram)
|
||||
}
|
||||
|
||||
@Test fun aProgramChosenInDroidDeckAfterASteamEditLeavesTheSteamAppsRoute() {
|
||||
val first = scanned()
|
||||
val routes = File(LinuxRuntime.rootDir(context), "root/.local/share/Steam/userdata/123/config/.droiddeck-routes.json")
|
||||
routes.writeText(JSONObject().put(first.appId.toString(), 250900).toString())
|
||||
record(first.appId, "/root/Games/PC/Example/Example.exe", "/root/Games/PC/Example/bin/Other.exe", 1)
|
||||
assertEquals(other, scanned().exe)
|
||||
|
||||
val third = File(folder, "Third.exe").apply { writeBytes(ByteArray(4)) }
|
||||
SessionPrefs.setAddedGameExe(context, folder.path, third.path)
|
||||
val chosen = scanned()
|
||||
assertEquals(third, chosen.exe)
|
||||
assertNull(chosen.steamAppId)
|
||||
assertTrue(!chosen.steamProgram)
|
||||
}
|
||||
|
||||
@Test fun theListingTellsTheSessionWhichSteamEditTheAppHasTaken() {
|
||||
val first = scanned()
|
||||
record(first.appId, "/root/Games/PC/Example/Example.exe", "/root/Games/PC/Example/bin/Other.exe", 3)
|
||||
|
||||
Reference in new issue
Block a user