mirror of
https://github.com/Droid-Deck/DroidDeck.git
synced 2026-11-19 04:46:08 +00:00
Merge remote-tracking branch 'upstream/main' into feat/itch-browse
This commit is contained in:
77 files changed
+2048
-303
No files matched your search
@@ -1,42 +0,0 @@
|
||||
package com.droiddeck.launcher.core
|
||||
|
||||
import org.junit.Assert.*
|
||||
import org.junit.Test
|
||||
|
||||
class CpuAllocationDefaultsTest {
|
||||
private val thor = (0..7).associateWith { when (it) { in 0..2 -> 2.016; in 3..6 -> 2.8032; else -> 3.1872 } }
|
||||
|
||||
@Test fun gen2UsesTheFourMiddleCoresAndOnePrime() {
|
||||
for (model in listOf("SM8550", "QCS8550", "sm8550-ac")) {
|
||||
assertEquals(CpuAllocationDefaults.Allocation("7", "3,4,5,6"), CpuAllocationDefaults.forDevice(model, "", thor))
|
||||
}
|
||||
assertEquals(CpuAllocationDefaults.Allocation("7", "3,4,5,6"), CpuAllocationDefaults.forDevice("", "kalama", thor))
|
||||
}
|
||||
|
||||
@Test fun coreNumbersAndClockVariantsAreDetectedInsteadOfHardcoded() {
|
||||
val reordered = mapOf(0 to 3.36, 1 to 2.0, 2 to 2.0, 3 to 2.0, 4 to 2.8, 5 to 2.8, 6 to 2.8, 7 to 2.8)
|
||||
assertEquals(CpuAllocationDefaults.Allocation("0", "4,5,6,7"), CpuAllocationDefaults.forDevice("SM8550-AC", "kalama", reordered))
|
||||
}
|
||||
|
||||
@Test fun anotherOrUnknownChipDoesNotAcquireThisDefault() {
|
||||
assertNull(CpuAllocationDefaults.forDevice("SM8650", "pineapple", thor))
|
||||
assertNull(CpuAllocationDefaults.forDevice("SM8650", "kalama", thor))
|
||||
assertNull(CpuAllocationDefaults.forDevice("", "", thor))
|
||||
}
|
||||
|
||||
@Test fun missingOrUnexpectedTopologyKeepsTheSchedulerDefault() {
|
||||
assertNull(CpuAllocationDefaults.forDevice("SM8550", "kalama", thor - 7))
|
||||
assertNull(CpuAllocationDefaults.forDevice("SM8550", "kalama", thor + (7 to null)))
|
||||
assertNull(CpuAllocationDefaults.forDevice("SM8550", "kalama", thor + (7 to 0.0)))
|
||||
assertNull(CpuAllocationDefaults.forDevice("SM8550", "kalama", thor + (7 to Double.NaN)))
|
||||
assertNull(CpuAllocationDefaults.forDevice("SM8550", "kalama", (0..7).associateWith { 2.8 }))
|
||||
}
|
||||
|
||||
@Test fun allCoreGamesUndoTheClientsInheritedRestriction() {
|
||||
val all = CpuCores.listOrAll("")
|
||||
assertEquals(all, CpuCores.gameLaunchList("", clientPinned = true))
|
||||
assertEquals(all, CpuCores.gameLaunchList(all, clientPinned = true))
|
||||
assertEquals("", CpuCores.gameLaunchList("", clientPinned = false))
|
||||
assertEquals("0", CpuCores.gameLaunchList("0", clientPinned = true))
|
||||
}
|
||||
}
|
||||
@@ -1,5 +1,6 @@
|
||||
package com.droiddeck.launcher.frontend
|
||||
|
||||
import com.droiddeck.launcher.BuildConfig
|
||||
import com.droiddeck.launcher.stores.CredentialCipher
|
||||
import org.json.JSONArray
|
||||
import org.json.JSONObject
|
||||
@@ -92,8 +93,9 @@ class AddedGameArtLookupTest {
|
||||
assertEquals("build", SteamGridDb.pick("", "build"))
|
||||
assertEquals("build", SteamGridDb.pick(" ", "build"))
|
||||
assertEquals("", SteamGridDb.pick("", ""))
|
||||
assertEquals("", SteamGridDb.builtInKey())
|
||||
assertEquals("", SteamGridDb.key(app))
|
||||
val builtIn = SteamGridDb.builtInKey()
|
||||
assertTrue(builtIn == BuildConfig.SGDB_API_KEY)
|
||||
assertTrue(SteamGridDb.key(app) == builtIn.trim())
|
||||
}
|
||||
|
||||
@Test fun theUsersKeyIsSealedOnDiskAndClears() {
|
||||
@@ -106,7 +108,7 @@ class AddedGameArtLookupTest {
|
||||
assertEquals("abcdef0123456789secretkey", SteamGridDb.key(app))
|
||||
SteamGridDb.setUserKey(app, "")
|
||||
assertFalse(file.exists())
|
||||
assertEquals("", SteamGridDb.key(app))
|
||||
assertTrue(SteamGridDb.key(app) == SteamGridDb.builtInKey().trim())
|
||||
}
|
||||
|
||||
@Test fun aFailedLookupIsNotRememberedAsNoMatch() {
|
||||
|
||||
@@ -0,0 +1,43 @@
|
||||
package com.droiddeck.launcher.frontend
|
||||
|
||||
import java.io.File
|
||||
import org.junit.Assert.assertEquals
|
||||
import org.junit.Assert.assertNull
|
||||
import org.junit.Rule
|
||||
import org.junit.Test
|
||||
import org.junit.rules.TemporaryFolder
|
||||
|
||||
class AddedGamesAccountTest {
|
||||
@get:Rule val tmp = TemporaryFolder()
|
||||
|
||||
private fun steamRoot(vararg blocks: Pair<Long, Map<String, String>>): File = tmp.newFolder("Steam").also { root ->
|
||||
File(root, "config").mkdirs()
|
||||
File(root, "userdata/123/config").mkdirs()
|
||||
File(root, "userdata/456/config").mkdirs()
|
||||
val body = blocks.joinToString("") { (account, keys) ->
|
||||
"\t\"${76561197960265728L + account}\"\n\t{\n" + keys.entries.joinToString("") { "\t\t\"${it.key}\"\t\t\"${it.value}\"\n" } + "\t}\n"
|
||||
}
|
||||
File(root, "config/loginusers.vdf").writeText("\"users\"\n{\n$body}\n")
|
||||
}
|
||||
|
||||
@Test fun theAccountMarkedMostRecentIsUsed() {
|
||||
val root = steamRoot(123L to mapOf("MostRecent" to "1", "AutoLogin" to "0", "timestamp" to "100"),
|
||||
456L to mapOf("MostRecent" to "0", "AutoLogin" to "1", "timestamp" to "200"))
|
||||
assertEquals(File(root, "userdata/123/config"), AddedGames.accountConfig(root))
|
||||
}
|
||||
|
||||
@Test fun withoutMostRecentTheAccountThatSignsInIsUsed() {
|
||||
val root = steamRoot(123L to mapOf("AutoLogin" to "1", "timestamp" to "100"), 456L to mapOf("AutoLogin" to "0", "timestamp" to "200"))
|
||||
assertEquals(File(root, "userdata/123/config"), AddedGames.accountConfig(root))
|
||||
}
|
||||
|
||||
@Test fun withoutEitherMarkTheAccountUsedLastIsUsed() {
|
||||
val root = steamRoot(456L to mapOf("AutoLogin" to "0", "timestamp" to "100"), 123L to mapOf("AutoLogin" to "0", "timestamp" to "200"))
|
||||
assertEquals(File(root, "userdata/123/config"), AddedGames.accountConfig(root))
|
||||
}
|
||||
|
||||
@Test fun twoAccountsWithoutAnyMarkGiveNoAccount() {
|
||||
val root = steamRoot(123L to mapOf("AccountName" to "a"), 456L to mapOf("AccountName" to "b"))
|
||||
assertNull(AddedGames.accountConfig(root))
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,21 @@
|
||||
package com.droiddeck.launcher.runtime
|
||||
|
||||
import org.junit.Assert.assertEquals
|
||||
import org.junit.Assert.assertNotEquals
|
||||
import org.junit.Test
|
||||
|
||||
class SeededMacTest {
|
||||
@Test
|
||||
fun theAndroidIdSeedsAStableLocalMac() {
|
||||
val mac = LinuxNetworkLinkComponent.seededMac { "0123456789abcdef" }
|
||||
assertEquals(mac, LinuxNetworkLinkComponent.seededMac { "0123456789abcdef" })
|
||||
assertNotEquals(mac, LinuxNetworkLinkComponent.seededMac { null })
|
||||
assertEquals(0x02, mac.substringBefore(':').toInt(16) and 0x03)
|
||||
}
|
||||
|
||||
@Test
|
||||
fun aRomThatThrowsOnTheAndroidIdReadFallsBackToTheDefaultSeed() {
|
||||
val mac = LinuxNetworkLinkComponent.seededMac { throw IllegalArgumentException("Illegal char: - at offset 8") }
|
||||
assertEquals(LinuxNetworkLinkComponent.seededMac { null }, mac)
|
||||
}
|
||||
}
|
||||
@@ -178,17 +178,39 @@ class BootMovieLibraryTest {
|
||||
assertNull(SessionFiles.startupMoviePath(BootMovieLibrary.steamConfig(app)))
|
||||
}
|
||||
|
||||
@Test fun onlyTheThreeStartupMoviesOfSteamAreListed() {
|
||||
listOf("deck_startup", "oled_startup", "startup_machine", "controller_generic_thumbstick_move").forEach {
|
||||
@Test fun onlyTheStartupMoviesOfSteamAreListed() {
|
||||
listOf("deck_startup", "oled_startup", "startup_machine", "steam_os_startup", "controller_generic_thumbstick_move").forEach {
|
||||
File(BootMovieLibrary.steamRoot(app), "steamui/movies/$it.webm").also { f -> f.parentFile!!.mkdirs(); f.writeText("movie") }
|
||||
}
|
||||
val ids = BootMovieLibrary.list(app).map { it.id }.filter { it.startsWith("steam:") }
|
||||
assertEquals(
|
||||
listOf("steam:/movies/deck_startup.webm", "steam:/movies/oled_startup.webm", "steam:/movies/startup_machine.webm"),
|
||||
listOf(
|
||||
"steam:/movies/deck_startup.webm", "steam:/movies/oled_startup.webm", "steam:/movies/startup_machine.webm",
|
||||
"steam:/movies/steam_os_startup.webm",
|
||||
),
|
||||
ids.sorted(),
|
||||
)
|
||||
}
|
||||
|
||||
@Test fun steamsDefaultPickIsTakenOverAsItsOwnStartupMovie() {
|
||||
val native = File(BootMovieLibrary.steamRoot(app), "steamui/movies/steam_os_startup.webm").also { it.parentFile!!.mkdirs(); it.writeText("movie") }
|
||||
movie("a.webm")
|
||||
steamPicksAt(SessionFiles.BOOT_MOVIE_PATH)
|
||||
BootMovie.select(app, "file:a.webm")
|
||||
steamPicksAt("")
|
||||
assertTrue(BootMovie.syncFromSteam(app))
|
||||
assertEquals("steam:/movies/steam_os_startup.webm", BootMovie.choice(app))
|
||||
assertEquals(native, BootMovie.currentFile(app))
|
||||
assertFalse(BootMovie.syncFromSteam(app))
|
||||
}
|
||||
|
||||
@Test fun anEmptySteamPickThatWasNeverSeenChangesNothing() {
|
||||
File(BootMovieLibrary.steamRoot(app), "steamui/movies/steam_os_startup.webm").also { it.parentFile!!.mkdirs(); it.writeText("movie") }
|
||||
steamPicksAt("")
|
||||
assertFalse(BootMovie.syncFromSteam(app))
|
||||
assertEquals(BootMovie.DROIDDECK_30, BootMovie.choice(app))
|
||||
}
|
||||
|
||||
@Test fun aMovieBoughtInThePointsShopIsListedAndAdopted() {
|
||||
val file = File(BootMovieLibrary.steamRoot(app), "appcache/startupmovies/Bought.webm").also { it.parentFile!!.mkdirs(); it.writeText("movie") }
|
||||
val entry = BootMovieLibrary.list(app).first { it.id == "steam:/appcache/startupmovies/Bought.webm" }
|
||||
|
||||
@@ -0,0 +1,32 @@
|
||||
package com.droiddeck.launcher.session
|
||||
|
||||
import org.json.JSONObject
|
||||
import org.junit.Assert.assertFalse
|
||||
import org.junit.Assert.assertTrue
|
||||
import org.junit.Test
|
||||
import org.junit.runner.RunWith
|
||||
import org.robolectric.RobolectricTestRunner
|
||||
import java.io.File
|
||||
|
||||
@RunWith(RobolectricTestRunner::class)
|
||||
class ComponentsSelectionTest {
|
||||
private val proton = ComponentsManager.Proton("DroidDeck-Proton_11-11.1", "DroidDeck-Proton 11-11.1", File("/p"), "/p", "DroidDeck-Proton-11-11.1", false)
|
||||
private val entry = JSONObject().put("file", "dxvk-low-latency-arm64ec-3.1.1-2-linux.wcp").put("protonVersion", "DroidDeck-Proton-11-11.1")
|
||||
|
||||
@Test
|
||||
fun `a package swapped into an installed Proton is in use`() {
|
||||
assertTrue(ComponentsManager.liveSelection("active", entry, proton))
|
||||
assertTrue(ComponentsManager.liveSelection("queued", JSONObject().put("file", "x.wcp"), proton))
|
||||
}
|
||||
|
||||
@Test
|
||||
fun `a package left on a removed Proton is not in use`() {
|
||||
assertFalse(ComponentsManager.liveSelection("active", entry, null))
|
||||
assertFalse(ComponentsManager.liveSelection("queued", entry, null))
|
||||
}
|
||||
|
||||
@Test
|
||||
fun `a package from before a Proton update is not in use`() {
|
||||
assertFalse(ComponentsManager.liveSelection("active", JSONObject(entry.toString()).put("protonVersion", "DroidDeck-Proton-11-9.1"), proton))
|
||||
}
|
||||
}
|
||||
@@ -1,7 +1,6 @@
|
||||
package com.droiddeck.launcher.session
|
||||
|
||||
import android.content.Context
|
||||
import com.droiddeck.launcher.core.CpuAllocationDefaults
|
||||
import org.junit.Assert.*
|
||||
import org.junit.Before
|
||||
import org.junit.Test
|
||||
@@ -14,36 +13,22 @@ import org.robolectric.annotation.Config
|
||||
@Config(sdk = [33])
|
||||
class CoreAllocationPrefsTest {
|
||||
private val app get() = RuntimeEnvironment.getApplication()
|
||||
private val defaults = CpuAllocationDefaults.Allocation("7", "3,4,5,6")
|
||||
private val saved get() = app.getSharedPreferences("session", Context.MODE_PRIVATE)
|
||||
|
||||
@Before fun clear() { saved.edit().clear().commit() }
|
||||
|
||||
@Test fun absentPreferencesUseTheDeviceDefaultWithoutWritingIt() {
|
||||
assertEquals(SessionPrefs.CoreAllocation(true, "7", "3,4,5,6"), SessionPrefs.coreAllocation(app, defaults))
|
||||
assertTrue(saved.all.isEmpty())
|
||||
assertEquals(SessionPrefs.CoreAllocation(false, "", ""), SessionPrefs.coreAllocation(app, null))
|
||||
@Test fun absentPreferencesLeaveEveryCoreToTheScheduler() {
|
||||
assertFalse(SessionPrefs.clientCpusOverride(app))
|
||||
assertEquals("", SessionPrefs.clientCpus(app))
|
||||
assertEquals("", SessionPrefs.gameCpus(app))
|
||||
}
|
||||
|
||||
@Test fun explicitDisableAndAllCoreChoicesSurviveAnUpdate() {
|
||||
saved.edit().putBoolean("clientCpusOverride", false).putString("clientCpus", "").putString("gameCpus", "").commit()
|
||||
assertEquals(SessionPrefs.CoreAllocation(false, "", ""), SessionPrefs.coreAllocation(app, defaults))
|
||||
}
|
||||
|
||||
@Test fun existingCustomMasksArePreserved() {
|
||||
saved.edit().putBoolean("clientCpusOverride", true).putString("clientCpus", "0,1").putString("gameCpus", "2,7").commit()
|
||||
assertEquals(SessionPrefs.CoreAllocation(true, "0,1", "2,7"), SessionPrefs.coreAllocation(app, defaults))
|
||||
}
|
||||
|
||||
@Test fun anOldClientMaskIsNotEnabledWithoutAnOverrideChoice() {
|
||||
saved.edit().putString("clientCpus", "0,1").commit()
|
||||
assertEquals(SessionPrefs.CoreAllocation(false, "0,1", "3,4,5,6"), SessionPrefs.coreAllocation(app, defaults))
|
||||
}
|
||||
|
||||
@Test fun changingOneChoiceDoesNotReplaceTheOtherDefaults() {
|
||||
SessionPrefs.setGameCpus(app, "0,1,2,3,4,5,6,7")
|
||||
assertEquals(SessionPrefs.CoreAllocation(true, "7", "0,1,2,3,4,5,6,7"), SessionPrefs.coreAllocation(app, defaults))
|
||||
SessionPrefs.setClientCpusOverride(app, false)
|
||||
assertEquals(SessionPrefs.CoreAllocation(false, "7", "0,1,2,3,4,5,6,7"), SessionPrefs.coreAllocation(app, defaults))
|
||||
@Test fun savedChoicesAreKept() {
|
||||
SessionPrefs.setClientCpusOverride(app, true)
|
||||
SessionPrefs.setClientCpus(app, "7")
|
||||
SessionPrefs.setGameCpus(app, "3,4,5,6")
|
||||
assertTrue(SessionPrefs.clientCpusOverride(app))
|
||||
assertEquals("7", SessionPrefs.clientCpus(app))
|
||||
assertEquals("3,4,5,6", SessionPrefs.gameCpus(app))
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,36 @@
|
||||
package com.droiddeck.launcher.session
|
||||
|
||||
import org.junit.Assert.assertEquals
|
||||
import org.junit.Assert.assertNull
|
||||
import org.junit.Test
|
||||
|
||||
class LoadingStateTest {
|
||||
@Test fun clientDownloadCountsMegabytesWhenTheRuntimeSaysThem() {
|
||||
assertEquals(
|
||||
"45 / 360 MB" to 12,
|
||||
LoadingState.clientDownload("== STEP 17:38:20 downloading Steam: bins_linuxarm64_linuxarm64 (2/17), 45 of 360 MB"),
|
||||
)
|
||||
}
|
||||
|
||||
@Test fun aStalledDownloadStillShowsWhereItIs() {
|
||||
assertEquals(
|
||||
"45 / 360 MB" to 12,
|
||||
LoadingState.clientDownload(
|
||||
"== STEP 17:39:20 downloading Steam: bins_linuxarm64_linuxarm64 (2/17), 45 of 360 MB" +
|
||||
" - interrupted (curl exit 28), trying again in 5 s",
|
||||
),
|
||||
)
|
||||
}
|
||||
|
||||
@Test fun anOlderRuntimeShowsThePartAndItsNumber() {
|
||||
assertEquals(
|
||||
"bins_linuxarm64_linuxarm64" to 11,
|
||||
LoadingState.clientDownload("== STEP 17:38:17 downloading Steam: bins_linuxarm64_linuxarm64 (2/17)"),
|
||||
)
|
||||
assertEquals("a_all" to 50, LoadingState.clientDownload("== STEP 00:00:00 downloading Steam: a_all (1/2), 0 of 0 MB"))
|
||||
}
|
||||
|
||||
@Test fun otherStepsAreNotClientDownloads() {
|
||||
assertNull(LoadingState.clientDownload("== STEP 17:38:14 checking the Steam client (a first run downloads it)"))
|
||||
}
|
||||
}
|
||||
@@ -20,7 +20,7 @@ class OrientationTest {
|
||||
}
|
||||
|
||||
@Test fun landscapeChoicesPersistGloballyAndCanRestoreAutomaticRotation() {
|
||||
assertEquals(ActivityInfo.SCREEN_ORIENTATION_LANDSCAPE, SessionPrefs.orientation(context))
|
||||
assertEquals(ActivityInfo.SCREEN_ORIENTATION_SENSOR_LANDSCAPE, SessionPrefs.orientation(context))
|
||||
for (value in listOf(
|
||||
ActivityInfo.SCREEN_ORIENTATION_LANDSCAPE,
|
||||
ActivityInfo.SCREEN_ORIENTATION_REVERSE_LANDSCAPE,
|
||||
@@ -34,7 +34,7 @@ class OrientationTest {
|
||||
@Test fun invalidStoredOrientationFallsBackAndInvalidChoicePreservesTheSavedValue() {
|
||||
val prefs = context.getSharedPreferences("session", Context.MODE_PRIVATE)
|
||||
prefs.edit().putInt("orientation", ActivityInfo.SCREEN_ORIENTATION_PORTRAIT).commit()
|
||||
assertEquals(ActivityInfo.SCREEN_ORIENTATION_LANDSCAPE, SessionPrefs.orientation(context))
|
||||
assertEquals(ActivityInfo.SCREEN_ORIENTATION_SENSOR_LANDSCAPE, SessionPrefs.orientation(context))
|
||||
SessionPrefs.setOrientation(context, ActivityInfo.SCREEN_ORIENTATION_REVERSE_LANDSCAPE)
|
||||
assertThrows(IllegalArgumentException::class.java) {
|
||||
SessionPrefs.setOrientation(context, ActivityInfo.SCREEN_ORIENTATION_PORTRAIT)
|
||||
|
||||
@@ -101,6 +101,28 @@ class SteamDownloadMonitorTest {
|
||||
}
|
||||
}
|
||||
|
||||
@Test fun aLongLogIsFollowedFromWhereTheLastPollStopped() {
|
||||
val root = Files.createTempDirectory("droiddeck-steam-download-").toFile()
|
||||
try {
|
||||
val contentLog = File(root, "root/.local/share/Steam/logs/content_log.txt").apply {
|
||||
check(parentFile?.mkdirs() != false)
|
||||
writeText(buildString {
|
||||
repeat(5_000) { append("[2026-10-06 14:40:00] Detected write gap 64 MB in file \"data_$it.dat\"\r\n") }
|
||||
append("[2026-10-06 14:44:17] AppID 44 App update changed : Running Update,Downloading,\r\n")
|
||||
})
|
||||
}
|
||||
val monitor = SteamDownloadMonitor()
|
||||
|
||||
assertTrue(monitor.poll(root, now = 1_000L))
|
||||
contentLog.appendText("[2026-10-06 14:45:03] AppID 44 App update changed : None\r\n")
|
||||
assertFalse(monitor.poll(root, now = 2_000L))
|
||||
contentLog.appendText("[2026-10-06 14:46:00] AppID 45 App update changed : Running Update,Downloading,\r\n")
|
||||
assertTrue(monitor.poll(root, now = 3_000L))
|
||||
} finally {
|
||||
root.deleteRecursively()
|
||||
}
|
||||
}
|
||||
|
||||
@Test fun theOtherClientsLogIsReadFromItsStart() {
|
||||
val root = Files.createTempDirectory("droiddeck-steam-download-").toFile()
|
||||
try {
|
||||
@@ -203,6 +225,38 @@ class SteamDownloadMonitorTest {
|
||||
}
|
||||
}
|
||||
|
||||
@Test fun theClientIsPendingUntilItIsInstalledAndStamped() {
|
||||
val root = Files.createTempDirectory("droiddeck-steam-client-").toFile()
|
||||
try {
|
||||
val steam = File(root, "root/.local/share/Steam")
|
||||
assertTrue(SteamDownloadMonitor.clientInstallPending(root))
|
||||
File(steam, "steamrtarm64").mkdirs()
|
||||
File(steam, "steamrtarm64/steam").writeText("client")
|
||||
assertTrue(SteamDownloadMonitor.clientInstallPending(root))
|
||||
File(steam, "package").mkdirs()
|
||||
File(steam, "package/droiddeck-installed").writeText("1791686101\n")
|
||||
assertFalse(SteamDownloadMonitor.clientInstallPending(root))
|
||||
} finally {
|
||||
root.deleteRecursively()
|
||||
}
|
||||
}
|
||||
|
||||
@Test fun anOlderStampCountsAndARepairRequestIsPending() {
|
||||
val root = Files.createTempDirectory("droiddeck-steam-client-").toFile()
|
||||
try {
|
||||
val steam = File(root, "root/.local/share/Steam")
|
||||
File(steam, "steamrtarm64").mkdirs()
|
||||
File(steam, "steamrtarm64/steam").writeText("client")
|
||||
File(steam, "package").mkdirs()
|
||||
File(steam, "package/bannerlator-installed").writeText("1\n")
|
||||
assertFalse(SteamDownloadMonitor.clientInstallPending(root))
|
||||
File(root, "root/.bl-steam-repair").writeText("1\n")
|
||||
assertTrue(SteamDownloadMonitor.clientInstallPending(root))
|
||||
} finally {
|
||||
root.deleteRecursively()
|
||||
}
|
||||
}
|
||||
|
||||
private fun manifest(root: File, appId: String, downloaded: Long, total: Long, flags: Int): File {
|
||||
val file = File(root, "steamapps/appmanifest_$appId.acf")
|
||||
check(file.parentFile?.mkdirs() != false)
|
||||
|
||||
@@ -38,6 +38,43 @@ class StoreInstallRootTest {
|
||||
assertEquals(1, StoreInstallRoot.targets(app).size)
|
||||
}
|
||||
|
||||
@Test fun externalStoreInstallPathsMapIntoTheirGuestMountWithoutPrefixCollisions() {
|
||||
val cardRoot = File(app.filesDir, "card/Games").apply { mkdirs() }
|
||||
val guestRoot = "/mnt/droiddeck-stores/card"
|
||||
val roots = listOf(cardRoot to guestRoot)
|
||||
|
||||
assertEquals("$guestRoot/Stores/Xbox/Doom", StoreInstallRoot.externalGuestPath(
|
||||
File(cardRoot, "Stores/Xbox/Doom"), roots))
|
||||
assertEquals(null, StoreInstallRoot.externalGuestPath(
|
||||
File(cardRoot.parentFile, "Games-old/Stores/Xbox/Doom"), roots))
|
||||
}
|
||||
|
||||
@Test fun xodusMapsTheSelectedSteamLibraryOnAnExternalVolume() {
|
||||
val library = File(app.filesDir, "card/steam").apply { mkdirs() }
|
||||
val storeRoot = File(library, "Games").apply { mkdirs() }
|
||||
SessionPrefs.setGameStorage(app, library.path, "Card")
|
||||
|
||||
val xodusRoot = StoreInstallRoot.externalRootsForXodus(app).single { it.first.absolutePath == storeRoot.absolutePath }
|
||||
val gameFolder = File(storeRoot, "Xbox/Doom")
|
||||
assertEquals("${xodusRoot.second}/Xbox/Doom", StoreInstallRoot.guestPathForXodus(app, gameFolder))
|
||||
|
||||
val bindSpecs = StoreInstallRoot.externalBindSpecsForXodus(app)
|
||||
assertTrue(bindSpecs.contains("${storeRoot.path}:${xodusRoot.second}"))
|
||||
assertTrue(File(LinuxRuntime.rootDir(app), xodusRoot.second.removePrefix("/")).isDirectory)
|
||||
}
|
||||
|
||||
@Test fun externalStoreBindsCreateGuestTargetsAndSkipUnavailableVolumes() {
|
||||
val host = File(app.filesDir, "card/Games").apply { mkdirs() }
|
||||
val guestRoot = "/mnt/droiddeck-stores/card"
|
||||
val guestFs = File(app.filesDir, "linuxfs").apply { mkdirs() }
|
||||
val missing = File(app.filesDir, "missing/Games")
|
||||
|
||||
assertEquals(listOf("${host.path}:$guestRoot"), StoreInstallRoot.externalBindSpecs(
|
||||
listOf(host to guestRoot, missing to "/mnt/droiddeck-stores/missing"), guestFs))
|
||||
assertTrue(File(guestFs, "mnt/droiddeck-stores/card").isDirectory)
|
||||
assertFalse(File(guestFs, "mnt/droiddeck-stores/missing").exists())
|
||||
}
|
||||
|
||||
@Test fun anExistingInstallWinsOverAFreshFolderUnderTheChosenRoot() {
|
||||
SessionPrefs.setGameStorage(app, SessionPrefs.GAME_STORAGE_OFF, "")
|
||||
val existing = File(StoreInstallRoot.storeDir(StoreInstallRoot.internalRoot(app), Store.GOG), "Old Name").apply { mkdirs() }
|
||||
|
||||
@@ -285,6 +285,28 @@ class EpicClientTest {
|
||||
assertTrue(EpicClient.loopback("http://localhost:5/launcher/authorized?code=1"))
|
||||
}
|
||||
|
||||
@Test fun theManifestLaunchCommandJoinsTheGameArguments() {
|
||||
val store = com.droiddeck.launcher.stores.Store.EPIC
|
||||
val epicArgs = listOf("-EpicPortal", "-epicapp=Fig", "-epicenv=Prod")
|
||||
val installed = com.droiddeck.launcher.stores.StoreGameSidecar(store, "Fig", "Fig Game", exe = "Fig.exe", args = epicArgs)
|
||||
val first = EpicClientLibrary.withLaunchArgs(installed, listOf("-PCStore=EGS"))
|
||||
assertEquals(epicArgs + "-PCStore=EGS", first.args)
|
||||
assertTrue(EpicClientLibrary.withLaunchArgs(first, listOf("-PCStore=EGS")) === first)
|
||||
val updated = EpicClientLibrary.withLaunchArgs(first, listOf("-PCStore=EGS", "-log=a b.txt"))
|
||||
assertEquals(epicArgs + listOf("-PCStore=EGS", "-log=a b.txt"), updated.args)
|
||||
val dropped = EpicClientLibrary.withLaunchArgs(updated, emptyList())
|
||||
assertEquals(epicArgs, dropped.args)
|
||||
assertFalse(dropped.extra.containsKey("launchArgs"))
|
||||
val reinstalled = first.copy(args = epicArgs)
|
||||
assertEquals(epicArgs + "-PCStore=EGS", EpicClientLibrary.withLaunchArgs(reinstalled, listOf("-PCStore=EGS")).args)
|
||||
assertTrue(EpicClientLibrary.withLaunchArgs(installed, emptyList()) === installed)
|
||||
val own = installed.copy(args = epicArgs + "-PCStore=EGS")
|
||||
assertTrue(EpicClientLibrary.withLaunchArgs(own, listOf("-PCStore=EGS")) === own)
|
||||
val ownUpdated = EpicClientLibrary.withLaunchArgs(own, listOf("-PCStore=EGS", "-log=a b.txt"))
|
||||
assertEquals(epicArgs + listOf("-PCStore=EGS", "-log=a b.txt"), ownUpdated.args)
|
||||
assertEquals(epicArgs + "-PCStore=EGS", EpicClientLibrary.withLaunchArgs(ownUpdated, emptyList()).args)
|
||||
}
|
||||
|
||||
@Test fun itemsDescribeTheInstallForTheLauncher() {
|
||||
val install = EpicClientLibrary.Install(
|
||||
"Fig", "ns1", "item1", "Fig Game", "1.0.5", "Binaries/Win64/Fig.exe", "/root/Games/Stores/Epic/Fig Game",
|
||||
|
||||
Reference in new issue
Block a user