mirror of
https://github.com/Droid-Deck/DroidDeck.git
synced 2026-11-21 22:05:59 +00:00
Merge latest origin/main and resolve conflicts
This commit is contained in:
commit
8171bf20fd
581 files changed
+14773
-4227
No files matched your search
@@ -29,7 +29,6 @@ class BootMovieLibraryTest {
|
||||
|
||||
private fun movie(name: String) = File(movies, name).also { it.parentFile!!.mkdirs(); it.writeText("movie") }
|
||||
|
||||
/** A movie DroidDeck itself imported: kept in the library, copied into Steam's folder and noted in the list. */
|
||||
private fun imported(title: String, source: String = BootMovieLibrary.SOURCE_IMPORT, repo: String? = null): String {
|
||||
val staged = File(BootMovieLibrary.libraryDir(app), ".t-${System.nanoTime()}-${Thread.currentThread().id}.staged").also { it.parentFile!!.mkdirs(); it.writeText("movie") }
|
||||
return BootMovieLibrary.commit(app, staged, title, source, repo)!!
|
||||
@@ -258,11 +257,9 @@ class BootMovieLibraryTest {
|
||||
steamPicks("b.webm")
|
||||
assertTrue(BootMovie.syncFromSteam(app))
|
||||
assertEquals("file:b.webm", BootMovie.choice(app))
|
||||
// Picking another one here is not undone by the same Steam setting.
|
||||
BootMovie.select(app, "file:a.webm")
|
||||
assertFalse(BootMovie.syncFromSteam(app))
|
||||
assertEquals("file:a.webm", BootMovie.choice(app))
|
||||
// A new pick inside Steam is adopted again.
|
||||
movie("c.webm")
|
||||
steamPicks("c.webm")
|
||||
assertTrue(BootMovie.syncFromSteam(app))
|
||||
|
||||
@@ -55,11 +55,9 @@ class ComponentsNightlyCatalogTest {
|
||||
val nVkEc = item("DD-vkd3d-proton-arm64ec-3.0.1+455-nightly.wcp", "vkd3d", n)
|
||||
val pairs = ComponentsManager.nightlyPairs(listOf(dxvk, ec, gpl, fex, vk) + others + listOf(nDxvk, nEc, nGpl, nFex, nVk, nVkEc))
|
||||
assertEquals(mapOf(dxvk to nDxvk, ec to nEc, gpl to nGpl, fex to nFex, vk to nVk), pairs)
|
||||
// Two nightlies for one stable build: the newer one wins.
|
||||
val nDxvkNewer = item("DD-dxvk-3.1.1+154-nightly.wcp", "dxvk", n)
|
||||
assertEquals(mapOf(dxvk to nDxvkNewer), ComponentsManager.nightlyPairs(listOf(dxvk, nDxvkNewer, nDxvk)))
|
||||
assertEquals(mapOf(dxvk to nDxvkNewer), ComponentsManager.nightlyPairs(listOf(dxvk, nDxvk, nDxvkNewer)))
|
||||
// A nightly of a version with no stable build pairs with nothing.
|
||||
assertEquals(emptyMap<Any, Any>(), ComponentsManager.nightlyPairs(listOf(item("dxvk-3.1-linux.wcp", "dxvk", "Dxvk-Linux"), nDxvk)))
|
||||
}
|
||||
|
||||
|
||||
@@ -36,7 +36,6 @@ class ForcedPackageTest {
|
||||
ComponentsManager.unpackedCacheKey(filename)
|
||||
fail("Expected cache traversal name to be rejected: $filename")
|
||||
} catch (_: IllegalArgumentException) {
|
||||
// Expected: the derived path would be a dot segment.
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -16,12 +16,12 @@ class GameTelemetryTest {
|
||||
|
||||
@Test fun codemastersFloatsBecomeADash() {
|
||||
val data = packet(264) {
|
||||
putFloat(7 * 4, 25f) // m/s
|
||||
putFloat(7 * 4, 25f)
|
||||
putFloat(29 * 4, 0.8f)
|
||||
putFloat(31 * 4, 0.1f)
|
||||
putFloat(33 * 4, 3f)
|
||||
putFloat(36 * 4, 1f)
|
||||
putFloat(37 * 4, 650f) // rpm / 10
|
||||
putFloat(37 * 4, 650f)
|
||||
putFloat(63 * 4, 800f)
|
||||
putFloat(45 * 4, 30f)
|
||||
putFloat(46 * 4, 60f)
|
||||
@@ -35,7 +35,6 @@ class GameTelemetryTest {
|
||||
assertEquals(0.5f, t.fuel!!, 0.001f)
|
||||
}
|
||||
|
||||
// Values from a DiRT Showdown packet recorded on a Retroid Pocket Duo (extradata 3 still sends 152 bytes there).
|
||||
@Test fun codemastersShortPacketFromDirtShowdown() {
|
||||
val data = packet(152) {
|
||||
putFloat(1 * 4, 80.085f)
|
||||
@@ -124,7 +123,6 @@ class GameTelemetryTest {
|
||||
assertNull(GameTelemetry.parse(1234, ByteArray(400), 400))
|
||||
}
|
||||
|
||||
// DiRT Showdown's 38 floats already carry steering and both G-forces.
|
||||
@Test fun codemastersGForceAndSteering() {
|
||||
val data = packet(152) {
|
||||
putFloat(30 * 4, -0.5f)
|
||||
@@ -181,7 +179,6 @@ class GameTelemetryTest {
|
||||
assertEquals(GameTelemetry.DL_SHIFT or GameTelemetry.DL_ABS, t.lights)
|
||||
}
|
||||
|
||||
// BeamNG leaves some OutGauge fields at zero; those stay hidden.
|
||||
@Test fun outGaugeZeroFieldsStayHidden() {
|
||||
val t = GameTelemetry.parse(GameTelemetry.OUTGAUGE_PORT, packet(92) { put(10, 2) }, 92)!!
|
||||
assertNull(t.turboBar)
|
||||
|
||||
@@ -9,9 +9,7 @@ class GameThreadHintsTest {
|
||||
@Test fun `a thread joins above 60 percent and leaves under 15`() {
|
||||
assertEquals(emptySet<Int>(), GameThreadHints.pick(emptySet(), mapOf(1 to 0.55)))
|
||||
assertEquals(setOf(1), GameThreadHints.pick(emptySet(), mapOf(1 to 0.68)))
|
||||
// Faster where it was moved, or capped by the display, it stays boosted at 25%...
|
||||
assertEquals(setOf(1), GameThreadHints.pick(setOf(1), mapOf(1 to 0.25)))
|
||||
// ...and is let go once it idles.
|
||||
assertEquals(emptySet<Int>(), GameThreadHints.pick(setOf(1), mapOf(1 to 0.1)))
|
||||
}
|
||||
|
||||
@@ -28,8 +26,8 @@ class GameThreadHintsTest {
|
||||
assertTrue(GameThreadHints.holdsPace(119.0, 120.0))
|
||||
assertTrue(GameThreadHints.holdsPace(60.5, 120.0))
|
||||
assertTrue(GameThreadHints.holdsPace(30.0, 120.0))
|
||||
assertFalse(GameThreadHints.holdsPace(92.0, 120.0)) // falling behind: boost
|
||||
assertFalse(GameThreadHints.holdsPace(92.0, 120.0))
|
||||
assertFalse(GameThreadHints.holdsPace(105.0, 120.0))
|
||||
assertFalse(GameThreadHints.holdsPace(3.0, 120.0)) // headless or loading: boost
|
||||
assertFalse(GameThreadHints.holdsPace(3.0, 120.0))
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,114 @@
|
||||
package com.droiddeck.launcher.session
|
||||
|
||||
import java.io.File
|
||||
import org.junit.Assert.assertEquals
|
||||
import org.junit.Assert.assertFalse
|
||||
import org.junit.Assert.assertNull
|
||||
import org.junit.Assert.assertTrue
|
||||
import org.junit.Rule
|
||||
import org.junit.Test
|
||||
import org.junit.rules.TemporaryFolder
|
||||
|
||||
class GpuLayerLoadTest {
|
||||
@get:Rule val tmp = TemporaryFolder()
|
||||
private var now = 0L
|
||||
private fun load(dir: File) = GpuStatsComponent.LayerLoad(dir, clock = { now })
|
||||
private fun write(dir: File, pid: Int, busyNs: Long) = File(dir, "$pid").writeText("%20d %-32s\n".format(busyNs, "game"))
|
||||
|
||||
@Test fun busyTimeOfAllProcessesOverWallTime() {
|
||||
val dir = tmp.newFolder("gpu-load")
|
||||
val load = load(dir)
|
||||
write(dir, 100, 1_000_000_000L)
|
||||
write(dir, 200, 5_000_000_000L)
|
||||
now = 10_000_000_000L
|
||||
assertNull(load.percent())
|
||||
write(dir, 100, 1_300_000_000L)
|
||||
write(dir, 200, 5_100_000_000L)
|
||||
now += 1_000_000_000L
|
||||
assertEquals(40L, load.percent())
|
||||
}
|
||||
|
||||
@Test fun aNewProcessStartsFromItsOwnTotalAndAGoneOneStopsCounting() {
|
||||
val dir = tmp.newFolder("gpu-load")
|
||||
val load = load(dir)
|
||||
write(dir, 100, 2_000_000_000L)
|
||||
now = 1L
|
||||
load.percent()
|
||||
File(dir, "100").delete()
|
||||
write(dir, 300, 9_000_000_000L)
|
||||
now += 500_000_000L
|
||||
assertEquals(0L, load.percent())
|
||||
write(dir, 300, 9_250_000_000L)
|
||||
now += 500_000_000L
|
||||
assertEquals(50L, load.percent())
|
||||
}
|
||||
|
||||
@Test fun capsAtFullAndIgnoresOtherFiles() {
|
||||
val dir = tmp.newFolder("gpu-load")
|
||||
val load = load(dir)
|
||||
File(dir, "on").createNewFile()
|
||||
write(dir, 1, 0L)
|
||||
write(dir, 2, 0L)
|
||||
now = 1L
|
||||
load.percent()
|
||||
write(dir, 1, 900_000_000L)
|
||||
write(dir, 2, 900_000_000L)
|
||||
now += 1_000_000_000L
|
||||
assertEquals(100L, load.percent())
|
||||
}
|
||||
|
||||
@Test fun theOnFlagFollowsTheHudAndHidingDropsTheBaseline() {
|
||||
val dir = tmp.newFolder("gpu-load")
|
||||
val load = load(dir)
|
||||
load.wanted(true)
|
||||
assertTrue(File(dir, "on").exists())
|
||||
write(dir, 1, 100L)
|
||||
now = 1L
|
||||
load.percent()
|
||||
load.wanted(false)
|
||||
assertFalse(File(dir, "on").exists())
|
||||
load.wanted(true)
|
||||
now += 1_000L
|
||||
assertNull(load.percent())
|
||||
}
|
||||
|
||||
@Test fun theCompositorsOwnGpuTimeAddsToTheGames() {
|
||||
val dir = tmp.newFolder("gpu-load")
|
||||
var compositor: Long? = 7_000_000_000L
|
||||
val load = GpuStatsComponent.LayerLoad(dir, clock = { now }, extra = { compositor })
|
||||
write(dir, 100, 1_000_000_000L)
|
||||
now = 1L
|
||||
assertNull(load.percent())
|
||||
write(dir, 100, 1_600_000_000L)
|
||||
compositor = 7_150_000_000L
|
||||
now += 1_000_000_000L
|
||||
assertEquals(75L, load.percent())
|
||||
compositor = null
|
||||
write(dir, 100, 1_900_000_000L)
|
||||
now += 1_000_000_000L
|
||||
assertEquals(30L, load.percent())
|
||||
}
|
||||
|
||||
@Test fun onlyTheCompositorCountsWhenNoGameReportsYet() {
|
||||
val dir = File(tmp.root, "never-created")
|
||||
var compositor = 0L
|
||||
val load = GpuStatsComponent.LayerLoad(dir, clock = { now }, extra = { compositor })
|
||||
now = 1L
|
||||
load.percent()
|
||||
compositor = 200_000_000L
|
||||
now += 1_000_000_000L
|
||||
assertEquals(20L, load.percent())
|
||||
}
|
||||
|
||||
@Test fun compositorTimingFollowsTheHudOnlyOnChanges() {
|
||||
val dir = tmp.newFolder("gpu-load")
|
||||
val calls = mutableListOf<Boolean>()
|
||||
val load = GpuStatsComponent.LayerLoad(dir, clock = { now }, onWanted = { calls += it })
|
||||
load.wanted(true)
|
||||
load.wanted(true)
|
||||
load.wanted(false)
|
||||
load.wanted(true)
|
||||
load.clear()
|
||||
assertEquals(listOf(true, false, true, false), calls)
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,74 @@
|
||||
package com.droiddeck.launcher.session
|
||||
|
||||
import org.junit.Assert.assertEquals
|
||||
import org.junit.Assert.assertFalse
|
||||
import org.junit.Assert.assertNull
|
||||
import org.junit.Assert.assertTrue
|
||||
import org.junit.Test
|
||||
|
||||
class GpuMemstoreLoadTest {
|
||||
private var busy = 0L
|
||||
private var samples = 0L
|
||||
private var moves = 0L
|
||||
private var available = true
|
||||
private val load = GpuStatsComponent.MemstoreLoad { if (available) longArrayOf(busy, samples, moves) else null }
|
||||
|
||||
private fun tick(newSamples: Long, newBusy: Long, newMoves: Long = 1) {
|
||||
samples += newSamples
|
||||
busy += newBusy
|
||||
moves += newMoves
|
||||
}
|
||||
|
||||
@Test fun notTrustedUntilNewWorkIsSeen() {
|
||||
assertNull(load.percent())
|
||||
tick(500, 400, newMoves = 0)
|
||||
assertNull(load.percent())
|
||||
assertFalse(load.working)
|
||||
tick(500, 300)
|
||||
assertEquals(70L, load.percent())
|
||||
assertTrue(load.working)
|
||||
}
|
||||
|
||||
@Test fun givesUpWhenTheTimestampsNeverMove() {
|
||||
load.percent()
|
||||
repeat(10) {
|
||||
tick(500, 250, newMoves = 0)
|
||||
assertNull(load.percent())
|
||||
}
|
||||
assertTrue(load.failed)
|
||||
tick(500, 250)
|
||||
assertNull(load.percent())
|
||||
assertFalse(load.working)
|
||||
}
|
||||
|
||||
@Test fun averagesOverTheLastTwoReads() {
|
||||
load.percent()
|
||||
tick(500, 500)
|
||||
assertEquals(100L, load.percent())
|
||||
tick(500, 0)
|
||||
assertEquals(50L, load.percent())
|
||||
tick(500, 0, newMoves = 0)
|
||||
assertEquals(0L, load.percent())
|
||||
}
|
||||
|
||||
@Test fun pausingStartsANewWindow() {
|
||||
load.percent()
|
||||
tick(500, 500)
|
||||
load.percent()
|
||||
load.pause()
|
||||
tick(0, 0, newMoves = 0)
|
||||
assertNull(load.percent())
|
||||
tick(500, 100)
|
||||
assertEquals(20L, load.percent())
|
||||
}
|
||||
|
||||
@Test fun noReadingWithoutNewSamplesOrCounts() {
|
||||
load.percent()
|
||||
tick(500, 100)
|
||||
load.percent()
|
||||
assertNull(load.percent())
|
||||
available = false
|
||||
tick(500, 100)
|
||||
assertNull(load.percent())
|
||||
}
|
||||
}
|
||||
@@ -4,6 +4,8 @@ import org.junit.Assert.*
|
||||
import org.junit.Test
|
||||
|
||||
class SessionDisplayTest {
|
||||
private val scaledFollow = listOf("follow/1.5", "follow/2", "follow/2.5", "follow/3", "follow/4")
|
||||
|
||||
@Test fun portraitPresetsSwapTheOutputAndRetainTheResolutionCap() {
|
||||
assertEquals(720 to 1280, SessionDisplay.resolveChoice(1920 to 1080, "720p", portrait = true))
|
||||
assertEquals(900 to 1600, SessionDisplay.resolveChoice(1080 to 1920, "900p", portrait = true))
|
||||
@@ -40,13 +42,13 @@ class SessionDisplayTest {
|
||||
|
||||
@Test fun optionsListTheHeightsThePanelCanShowThenThePanel() {
|
||||
val thor = SessionDisplay.resolutionOptions(1920 to 1080)
|
||||
assertEquals(listOf("720p", "900p", SessionDisplay.MATCH_SCREEN, SessionDisplay.FOLLOW_SCREEN), thor)
|
||||
assertEquals(listOf("720p", "900p", SessionDisplay.MATCH_SCREEN, SessionDisplay.FOLLOW_SCREEN),
|
||||
assertEquals(listOf("720p", "900p", SessionDisplay.MATCH_SCREEN, SessionDisplay.FOLLOW_SCREEN) + scaledFollow, thor)
|
||||
assertEquals(listOf("720p", "900p", SessionDisplay.MATCH_SCREEN, SessionDisplay.FOLLOW_SCREEN) + scaledFollow,
|
||||
SessionDisplay.resolutionOptions(2400 to 1080))
|
||||
assertEquals(listOf("720p", "900p", "1080p", SessionDisplay.MATCH_SCREEN, SessionDisplay.FOLLOW_SCREEN),
|
||||
assertEquals(listOf("720p", "900p", "1080p", SessionDisplay.MATCH_SCREEN, SessionDisplay.FOLLOW_SCREEN) + scaledFollow,
|
||||
SessionDisplay.resolutionOptions(3120 to 1440))
|
||||
val small = SessionDisplay.resolutionOptions(1280 to 720)
|
||||
assertEquals(listOf(SessionDisplay.MATCH_SCREEN, SessionDisplay.FOLLOW_SCREEN), small)
|
||||
assertEquals(listOf(SessionDisplay.MATCH_SCREEN, SessionDisplay.FOLLOW_SCREEN) + scaledFollow, small)
|
||||
assertEquals(1280 to 720, SessionDisplay.resolveChoice(1280 to 720, SessionDisplay.MATCH_SCREEN))
|
||||
assertEquals(2560 to 1440, SessionDisplay.resolveChoice(2560 to 1440, SessionDisplay.MATCH_SCREEN))
|
||||
}
|
||||
@@ -105,6 +107,31 @@ class SessionDisplayTest {
|
||||
assertNull(SessionDisplay.followSize(640, 360))
|
||||
}
|
||||
|
||||
@Test fun scaledFollowDividesTheWindowAndStaysEven() {
|
||||
assertEquals(1260 to 540, SessionDisplay.resolveChoice(1080 to 2520, "follow/2"))
|
||||
assertEquals(540 to 1260, SessionDisplay.resolveChoice(2520 to 1080, "follow/2", portrait = true))
|
||||
assertEquals(1092 to 984, SessionDisplay.followSize(2185, 1969, scale = 2f))
|
||||
assertEquals(656 to 728, SessionDisplay.followSize(1968, 2184, scale = 3f))
|
||||
assertNull(SessionDisplay.followSize(640, 360, scale = 2f))
|
||||
assertEquals(720 to 1600, SessionDisplay.resolveChoice(2400 to 1080, "follow/1.5", portrait = true))
|
||||
assertEquals(1600 to 720, SessionDisplay.resolveChoice(1080 to 2400, "follow/1.5"))
|
||||
assertNull(SessionDisplay.followScale("follow/1.0"))
|
||||
}
|
||||
|
||||
@Test fun onlyKnownFollowChoicesCountAsFollow() {
|
||||
assertEquals(1f, SessionDisplay.followScale(SessionDisplay.FOLLOW_SCREEN))
|
||||
assertEquals(3f, SessionDisplay.followScale("follow/3"))
|
||||
assertEquals(1.3f, SessionDisplay.followScale("follow/1.3"))
|
||||
assertEquals(1.3f, SessionDisplay.followScale("follow/1.26"))
|
||||
assertEquals("follow/1.3", SessionDisplay.followScaled(1.3f))
|
||||
assertEquals("follow/2", SessionDisplay.followScaled(2f))
|
||||
assertNull(SessionDisplay.followScale("follow/1"))
|
||||
assertNull(SessionDisplay.followScale("follow/x"))
|
||||
assertNull(SessionDisplay.followScale("follow/9"))
|
||||
assertNull(SessionDisplay.followScale("720p"))
|
||||
assertFalse(SessionDisplay.isFollow(SessionDisplay.MATCH_SCREEN))
|
||||
}
|
||||
|
||||
@Test fun aPhoneCanFollowTheShortGameAreaAboveItsControls() {
|
||||
assertNull(SessionDisplay.followSize(720, 404))
|
||||
assertEquals(720 to 404, SessionDisplay.followSize(720, 404, controlsBelow = true))
|
||||
|
||||
@@ -27,7 +27,6 @@ class SessionLogShareZipTest {
|
||||
val earlySecret = "early-sessionid-abcdef123456"
|
||||
val trailingSecret = "late-refresh-token-abcdef123456"
|
||||
try {
|
||||
// One long line exercises the streaming limit; the final ordinary line must still be redacted.
|
||||
raw.bufferedWriter().use { out ->
|
||||
out.write("sessionid=$earlySecret")
|
||||
val chunk = "x".repeat(8192)
|
||||
@@ -40,7 +39,6 @@ class SessionLogShareZipTest {
|
||||
ZipFile(zip).use { archive ->
|
||||
val entry = archive.getEntry("${session.name}/steam-42.log")!!
|
||||
archive.getInputStream(entry).use { input ->
|
||||
// Only inspect the bounded scrubbed prefix: the pre-fix raw archive is over 64 MiB.
|
||||
val expected = "${com.droiddeck.launcher.core.LogRedactor.OVERSIZED_LINE}\n"
|
||||
val prefix = ByteArray(expected.toByteArray(StandardCharsets.UTF_8).size)
|
||||
var offset = 0
|
||||
@@ -74,7 +72,6 @@ class SessionLogShareZipTest {
|
||||
"Authorization: Bearer abc.def.ghi\n" +
|
||||
"kept: EResult 5, app 1086940, steamapps/common/Game\n"
|
||||
)
|
||||
// StoreLogFiles.prune, started by App.onCreate, deletes a stores log named for a day over a week old.
|
||||
val storesLog = "stores-" + SimpleDateFormat("yyyy-MM-dd", Locale.US).format(Date()) + ".log"
|
||||
File(logs, "stores").apply { mkdirs() }.resolve(storesLog).writeText("epic: f_token=zzzzzzzz12 window 32\n")
|
||||
File(logs, SessionPaths.TOOLS_DIR).apply { mkdirs() }.resolve("flatpak-install.log").writeText("== install\nCookie: steamLoginSecure=76561198000000000%7C%7Ceyabc\n")
|
||||
|
||||
@@ -5,16 +5,30 @@ import org.junit.Test
|
||||
|
||||
class StatsLayoutTest {
|
||||
@Test fun unknownIdsFallBackToTheDefaults() {
|
||||
assertEquals(StatsStrip.PANEL, StatsStrip.from(null))
|
||||
assertEquals(StatsStrip.LINE, StatsStrip.from(null))
|
||||
assertEquals(StatsStrip.LINE, StatsStrip.from("gone"))
|
||||
assertEquals(StatsStrip.PANEL, StatsStrip.from("panel"))
|
||||
assertEquals(StatsStrip.RINGS, StatsStrip.from("rings"))
|
||||
assertEquals(StatsDash.AUTO, StatsDash.from("gone"))
|
||||
assertEquals(StatsDash.TRACE, StatsDash.from("trace"))
|
||||
}
|
||||
|
||||
@Test fun tappingTheStripCyclesThroughEveryStyle() {
|
||||
assertEquals(StatsStrip.PANEL, StatsStrip.LINE.next())
|
||||
assertEquals(StatsStrip.TILES, StatsStrip.PANEL.next())
|
||||
assertEquals(StatsStrip.RINGS, StatsStrip.TILES.next())
|
||||
assertEquals(StatsStrip.PANEL, StatsStrip.RINGS.next())
|
||||
assertEquals(StatsStrip.LINE, StatsStrip.RINGS.next())
|
||||
}
|
||||
|
||||
@Test fun stripNumbersStartWithEverythingButTheGpuTemperature() {
|
||||
assertEquals(StripMetric.entries.toSet() - StripMetric.GPU_TEMP, StripMetric.parse(null))
|
||||
}
|
||||
|
||||
@Test fun stripNumbersSurviveSavingAndSkipUnknownIds() {
|
||||
val picked = setOf(StripMetric.GPU, StripMetric.RAM, StripMetric.CLOCK)
|
||||
assertEquals(picked, StripMetric.parse(StripMetric.encode(picked)))
|
||||
assertEquals(setOf(StripMetric.CPU), StripMetric.parse("cpu,gone, "))
|
||||
assertEquals(emptySet<StripMetric>(), StripMetric.parse(""))
|
||||
}
|
||||
|
||||
@Test fun autoPicksTheDashByTheGamesFormat() {
|
||||
|
||||
@@ -0,0 +1,73 @@
|
||||
package com.droiddeck.launcher.session
|
||||
|
||||
import com.droiddeck.launcher.frontend.AddedGames
|
||||
import com.droiddeck.launcher.frontend.Library
|
||||
import java.io.File
|
||||
import org.junit.Assert.*
|
||||
import org.junit.Rule
|
||||
import org.junit.Test
|
||||
import org.junit.rules.TemporaryFolder
|
||||
import org.junit.runner.RunWith
|
||||
import org.robolectric.RobolectricTestRunner
|
||||
import org.robolectric.RuntimeEnvironment
|
||||
import org.robolectric.annotation.Config
|
||||
|
||||
@RunWith(RobolectricTestRunner::class)
|
||||
@Config(sdk = [33])
|
||||
class SteamLibrariesTest {
|
||||
private val app get() = RuntimeEnvironment.getApplication()
|
||||
@get:Rule val tmp = TemporaryFolder()
|
||||
|
||||
private fun added(path: String, label: String = File(path).name): SteamLibraries.Entry =
|
||||
(SteamLibraries.add(app, path, label) as SteamLibraries.AddResult.Added).entry
|
||||
|
||||
@Test fun addedLibrariesGetStableMountsThatSurviveRenameAndRemoval() {
|
||||
SessionPrefs.setGameStorage(app, SessionPrefs.GAME_STORAGE_OFF, "")
|
||||
val docs = added(tmp.newFolder("Documents").path, "Docs")
|
||||
val usb = added(tmp.newFolder("USB").path)
|
||||
assertEquals(listOf("/mnt/droiddeck-lib/1", "/mnt/droiddeck-lib/2"), SteamLibraries.list(app).map { it.guest })
|
||||
assertTrue(File(docs.path, "steamapps").isDirectory)
|
||||
|
||||
SteamLibraries.rename(app, docs.id, "My \"Docs\"")
|
||||
assertEquals("My Docs", SteamLibraries.list(app).first().label)
|
||||
assertEquals("/mnt/droiddeck-lib/1", SteamLibraries.list(app).first().guest)
|
||||
|
||||
SteamLibraries.remove(app, docs.id)
|
||||
assertEquals(listOf(usb.id), SteamLibraries.list(app).map { it.id })
|
||||
assertTrue(File(docs.path, "steamapps").isDirectory)
|
||||
assertEquals("3", added(tmp.newFolder("Again").path).id)
|
||||
}
|
||||
|
||||
@Test fun overlappingFoldersAndAFifthLibraryAreRefused() {
|
||||
SessionPrefs.setGameStorage(app, SessionPrefs.GAME_STORAGE_OFF, "")
|
||||
val games = tmp.newFolder("Games")
|
||||
added(games.path)
|
||||
assertTrue(SteamLibraries.add(app, games.path) is SteamLibraries.AddResult.Refused)
|
||||
assertTrue(SteamLibraries.add(app, File(games, "inner").apply { mkdirs() }.path) is SteamLibraries.AddResult.Refused)
|
||||
repeat(SteamLibraries.MAX - 1) { added(tmp.newFolder("L$it").path) }
|
||||
assertTrue(SteamLibraries.add(app, tmp.newFolder("Full").path) is SteamLibraries.AddResult.Refused)
|
||||
}
|
||||
|
||||
@Test fun addedLibrariesAreListedMappedAndKeepGamesFoldersFromDoubling() {
|
||||
val pc = tmp.newFolder("PC")
|
||||
File(pc, "steamapps").mkdirs()
|
||||
File(pc, "steamapps/appmanifest_220.acf").writeText("x")
|
||||
SessionPrefs.setAddedGamesDirs(app, listOf(pc.path))
|
||||
val lib = added(pc.path, "PC")
|
||||
assertTrue(GameStorage.gamesFolderLibraries(app).isEmpty())
|
||||
assertEquals(1, Library.steamLibraries(app, "arm64").count { it.first == pc })
|
||||
assertTrue(Library.steamLibraries(app, "x86_64").any { it.first == File(pc, GameStorage.X64_CARD_DIR) })
|
||||
assertEquals(File(pc, "steamapps/common"), AddedGames.hostPath(app, "${lib.guest}/steamapps/common"))
|
||||
val docs = added(tmp.newFolder("Documents").path)
|
||||
assertEquals("${docs.guest}/steamapps", AddedGames.guestPath(app, File(docs.path, "steamapps")))
|
||||
val nested = File(pc, "Other").apply { mkdirs() }
|
||||
SteamLibraries.remove(app, lib.id)
|
||||
assertTrue(SteamLibraries.add(app, nested.path) is SteamLibraries.AddResult.Refused)
|
||||
}
|
||||
|
||||
@Test fun unreadableOrInvalidEntriesAreDropped() {
|
||||
assertTrue(SteamLibraries.parse("{oops").isEmpty())
|
||||
assertEquals(listOf("2"), SteamLibraries.parse("""[{"id":"../x","path":"/a"},{"id":"2","path":"/b","label":""}]""").map { it.id })
|
||||
assertEquals("b", SteamLibraries.parse("""[{"id":"2","path":"/b","label":""}]""").single().label)
|
||||
}
|
||||
}
|
||||
@@ -7,7 +7,6 @@ import org.junit.Test
|
||||
class SteamWebLoginTest {
|
||||
private fun hex(s: String) = ByteArray(s.length / 2) { s.substring(it * 2, it * 2 + 2).toInt(16).toByte() }
|
||||
|
||||
// Made with: openssl enc -aes-128-cbc -K <PBKDF2-SHA1("peanuts","saltysalt",1)> -iv <16 spaces>, prefixed "v10".
|
||||
@Test fun chromiumV10ValuesDecrypt() {
|
||||
val encrypted = hex("7631300b9cf0a6eee9cf1aaac601b85ca37cf9fe9e67078564f0e05835ae2aa3d9b0ab")
|
||||
assertEquals("0123456789abcdef01234567", SteamWebLogin.decrypt(encrypted, hostHashed = false))
|
||||
|
||||
@@ -12,7 +12,6 @@ import java.io.File
|
||||
class TelemetryOutputTest {
|
||||
@get:Rule val tmp = TemporaryFolder()
|
||||
|
||||
// DiRT Showdown's own line, as found in its prefix on the Retroid Pocket Duo.
|
||||
private val showdown = "<?xml version=\"1.0\" encoding=\"UTF-8\" ?>\n<hardware_settings_config>\n" +
|
||||
"\t<audio mono=\"false\" />\n\t<motion enabled=\"true\" ip=\"dbox\" port=\"20777\" delay=\"1\" extradata=\"0\" />\n" +
|
||||
"</hardware_settings_config>\n"
|
||||
|
||||
Reference in new issue
Block a user