mirror of
https://github.com/Droid-Deck/DroidDeck.git
synced 2026-11-20 05:16:01 +00:00
Merge main and retain unified input behavior
This commit is contained in:
commit
f44826ae3a
75 files changed
+2441
-160
No files matched your search
@@ -134,6 +134,19 @@ class ProtonMenuAutoTest {
|
||||
assertEquals(listOf("droiddeck"), attempts)
|
||||
}
|
||||
|
||||
@Test fun aFinishedInstallStartsTheComponentCheckAndAFailedOneDoesNot() {
|
||||
var checks = 0
|
||||
val watched = ProtonMenu(activity, Handler(Looper.getMainLooper()), onInstalled = { checks++ }) { idle }
|
||||
watched.installer = { tool, _ -> install("${tool.prefix}-11-12"); null }
|
||||
watched.installProton("droiddeck")
|
||||
waitUntil { watched.protonBusyId == null && checks == 1 }
|
||||
assertEquals(1, checks)
|
||||
watched.installer = { _, _ -> "failed" }
|
||||
watched.installProton("ge")
|
||||
waitUntil { watched.protonBusyId == null }
|
||||
assertEquals(1, checks)
|
||||
}
|
||||
|
||||
@Test fun aFailedUpdateDoesNotLoopOrBlockOtherInstalledFamilies() {
|
||||
val ge = install("GE-Proton11-11")
|
||||
install("DroidDeck-Proton-11-11.1")
|
||||
|
||||
@@ -122,10 +122,63 @@ class OnScreenControlsTest {
|
||||
assertTrue(view.takesTouchAt(450f, 480f))
|
||||
}
|
||||
|
||||
private fun touch(action: Int, vararg pointers: Pair<Int, Pair<Float, Float>>): Boolean {
|
||||
@Test fun aCancelledSecondFingerDoesNotArmAStickClick() {
|
||||
touch(MotionEvent.ACTION_DOWN, 7 to (800f to 250f))
|
||||
touch(MotionEvent.ACTION_POINTER_DOWN or (1 shl 8), 7 to (800f to 250f), 9 to (200f to 300f))
|
||||
touch(MotionEvent.ACTION_POINTER_UP or (1 shl 8), 7 to (800f to 250f), 9 to (200f to 300f), flags = MotionEvent.FLAG_CANCELED)
|
||||
touch(MotionEvent.ACTION_POINTER_DOWN or (1 shl 8), 7 to (800f to 250f), 9 to (200f to 300f))
|
||||
assertFalse(state().isDown(PadState.L3))
|
||||
touch(MotionEvent.ACTION_POINTER_UP or (1 shl 8), 7 to (800f to 250f), 9 to (200f to 300f))
|
||||
touch(MotionEvent.ACTION_POINTER_DOWN or (1 shl 8), 7 to (800f to 250f), 9 to (200f to 300f))
|
||||
assertTrue(state().isDown(PadState.L3))
|
||||
}
|
||||
|
||||
@Test fun movingTheStickAndTouchingItAgainDoesNotClickIt() {
|
||||
touch(MotionEvent.ACTION_DOWN, 1 to (200f to 300f))
|
||||
touch(MotionEvent.ACTION_MOVE, 1 to (250f to 300f))
|
||||
touch(MotionEvent.ACTION_UP, 1 to (250f to 300f))
|
||||
touch(MotionEvent.ACTION_DOWN, 1 to (200f to 300f))
|
||||
assertFalse(state().isDown(PadState.L3))
|
||||
}
|
||||
|
||||
@Test fun liftingFarFromTheTouchPointDoesNotArmAStickClick() {
|
||||
touch(MotionEvent.ACTION_DOWN, 1 to (200f to 300f))
|
||||
touch(MotionEvent.ACTION_UP, 1 to (250f to 300f))
|
||||
touch(MotionEvent.ACTION_DOWN, 1 to (200f to 300f))
|
||||
assertFalse(state().isDown(PadState.L3))
|
||||
}
|
||||
|
||||
@Test fun aLongHoldThenAQuickTouchDoesNotClickTheStick() {
|
||||
touch(MotionEvent.ACTION_DOWN, 1 to (200f to 300f))
|
||||
time += 600
|
||||
touch(MotionEvent.ACTION_UP, 1 to (200f to 300f))
|
||||
touch(MotionEvent.ACTION_DOWN, 1 to (200f to 300f))
|
||||
assertFalse(state().isDown(PadState.L3))
|
||||
}
|
||||
|
||||
@Test fun aFastDoubleTapClicksTheStickAndCanBeHeldWhileMoving() {
|
||||
touch(MotionEvent.ACTION_DOWN, 1 to (200f to 300f))
|
||||
touch(MotionEvent.ACTION_UP, 1 to (200f to 300f))
|
||||
touch(MotionEvent.ACTION_DOWN, 1 to (200f to 300f))
|
||||
touch(MotionEvent.ACTION_MOVE, 1 to (250f to 300f))
|
||||
assertTrue(state().isDown(PadState.L3))
|
||||
touch(MotionEvent.ACTION_UP, 1 to (250f to 300f))
|
||||
touch(MotionEvent.ACTION_DOWN, 1 to (200f to 300f))
|
||||
assertFalse(state().isDown(PadState.L3))
|
||||
}
|
||||
|
||||
@Test fun aSlowSecondTapDoesNotClickTheStick() {
|
||||
touch(MotionEvent.ACTION_DOWN, 1 to (200f to 300f))
|
||||
touch(MotionEvent.ACTION_UP, 1 to (200f to 300f))
|
||||
time += 400
|
||||
touch(MotionEvent.ACTION_DOWN, 1 to (200f to 300f))
|
||||
assertFalse(state().isDown(PadState.L3))
|
||||
}
|
||||
|
||||
private fun touch(action: Int, vararg pointers: Pair<Int, Pair<Float, Float>>, flags: Int = 0): Boolean {
|
||||
val properties = pointers.map { (id, _) -> MotionEvent.PointerProperties().apply { this.id = id; toolType = MotionEvent.TOOL_TYPE_FINGER } }.toTypedArray()
|
||||
val coords = pointers.map { (_, position) -> MotionEvent.PointerCoords().apply { x = position.first; y = position.second; pressure = 1f; size = 1f } }.toTypedArray()
|
||||
val event = MotionEvent.obtain(1000L, time++, action, pointers.size, properties, coords, 0, 0, 1f, 1f, 0, 0, 0, 0)
|
||||
val event = MotionEvent.obtain(1000L, time++, action, pointers.size, properties, coords, 0, 0, 1f, 1f, 0, 0, 0, flags)
|
||||
return try { view.dispatchTouchEvent(event) } finally { event.recycle() }
|
||||
}
|
||||
}
|
||||
@@ -210,6 +210,15 @@ class SessionInputPointerTest {
|
||||
assertEquals(listOf(Triple(3, 272, 1), Triple(3, 272, 0)), CompositorShadow.events)
|
||||
}
|
||||
|
||||
@Test fun wowFieldSelectionPreservesCtrlHeldByTheInputProfile() {
|
||||
output.key(29, true)
|
||||
ReflectionHelpers.callInstanceMethod<Unit>(activity, "selectGameField",
|
||||
ReflectionHelpers.ClassParameter.from(IntArray::class.java, intArrayOf(46)))
|
||||
assertEquals(listOf(29 to 1, 30 to 1, 30 to 0, 46 to 1, 46 to 0), CompositorShadow.keys)
|
||||
output.key(29, false)
|
||||
assertEquals(29 to 0, CompositorShadow.keys.last())
|
||||
}
|
||||
|
||||
@Test fun horizontalWheelFinishesBeforeRawMouseDestruction() {
|
||||
checkWheelTransition(horizontal = true, transition = "releaseEvdevMouse", marker = "destroy")
|
||||
}
|
||||
|
||||
@@ -17,8 +17,23 @@ class RuntimeAutoUpdateTest {
|
||||
assertTrue(RuntimeAutoUpdate.claim(context, "ubuntu-r1-rc1", "ubuntu-r1-rc2"))
|
||||
}
|
||||
|
||||
@Test fun noRuntimeOrTheSameOneIsLeftAlone() {
|
||||
@Test fun aFirstLaunchInstallsTheRuntimeByItself() {
|
||||
assertTrue(RuntimeAutoUpdate.claim(context, null, "ubuntu-r1-rc2"))
|
||||
}
|
||||
|
||||
@Test fun aRuntimeTheUserRemovedIsNotPutBack() {
|
||||
RuntimeAutoUpdate.seed(context)
|
||||
assertFalse(RuntimeAutoUpdate.claim(context, null, "ubuntu-r1-rc2"))
|
||||
assertTrue(RuntimeAutoUpdate.claim(context, "ubuntu-r1-rc1", "ubuntu-r1-rc2"))
|
||||
}
|
||||
|
||||
@Test fun aFailingFirstInstallStopsTryingAfterAFewLaunches() {
|
||||
repeat(RuntimeAutoUpdate.MAX_ATTEMPTS) { assertTrue(RuntimeAutoUpdate.claim(context, null, "ubuntu-r1-rc2", it * RuntimeAutoUpdate.RETRY_MS)) }
|
||||
assertFalse(RuntimeAutoUpdate.claim(context, null, "ubuntu-r1-rc2", 10 * RuntimeAutoUpdate.RETRY_MS))
|
||||
}
|
||||
|
||||
@Test fun theSameOrNoReleaseIsLeftAlone() {
|
||||
assertFalse(RuntimeAutoUpdate.claim(context, null, null))
|
||||
assertFalse(RuntimeAutoUpdate.claim(context, "ubuntu-r1-rc2", "ubuntu-r1-rc2"))
|
||||
assertFalse(RuntimeAutoUpdate.claim(context, "ubuntu-r1-rc1", null))
|
||||
assertFalse(RuntimeAutoUpdate.claim(context, "ubuntu-r1-rc1", ""))
|
||||
|
||||
@@ -0,0 +1,243 @@
|
||||
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 android.content.Context
|
||||
import androidx.test.core.app.ApplicationProvider
|
||||
import org.json.JSONArray
|
||||
import org.json.JSONObject
|
||||
import org.junit.Test
|
||||
import org.junit.runner.RunWith
|
||||
import org.robolectric.RobolectricTestRunner
|
||||
import java.io.File
|
||||
import java.nio.ByteBuffer
|
||||
import java.nio.ByteOrder
|
||||
import java.nio.file.Files
|
||||
|
||||
@RunWith(RobolectricTestRunner::class)
|
||||
class ComponentUpdatesTest {
|
||||
private fun item(file: String, comp: String, release: String = ComponentsManager.DD_NIGHTLY) =
|
||||
ComponentsManager.CatalogItem(file, comp, release, "https://github.com/Droid-Deck/DroidDeck-Components/releases/download/x/$file", 1, "sha256:" + "0".repeat(64))
|
||||
|
||||
private val catalog = listOf(
|
||||
item("DD-dxvk-3.1.1+188-nightly.wcp", "dxvk"),
|
||||
item("DD-dxvk-3.1.1+190-nightly.wcp", "dxvk"),
|
||||
item("DD-dxvk-arm64ec-3.1.1+188-nightly.wcp", "dxvk"),
|
||||
item("DD-dxvk-gplasync-3.1.1+190-nightly.wcp", "dxvk"),
|
||||
item("dxvk-3.1.1-linux.wcp", "dxvk", "Dxvk-Linux"),
|
||||
item("DD-vkd3d-proton-3.1+30-nightly.wcp", "vkd3d"),
|
||||
item("DD-vkd3d-proton-arm64ec-3.1+30-nightly.wcp", "vkd3d"),
|
||||
item("DD-FEXCore-2611+3-nightly.wcp", "fex"),
|
||||
)
|
||||
|
||||
@Test fun eachLineFollowsOnlyItsOwnPublishedFlavour() {
|
||||
assertEquals("DD-dxvk-3.1.1+190-nightly.wcp", ComponentUpdates.pick(catalog, ComponentUpdates.line("dxvk", false), emptySet())?.file)
|
||||
assertEquals("DD-dxvk-arm64ec-3.1.1+188-nightly.wcp", ComponentUpdates.pick(catalog, ComponentUpdates.line("dxvk", true), emptySet())?.file)
|
||||
assertEquals("DD-vkd3d-proton-arm64ec-3.1+30-nightly.wcp", ComponentUpdates.pick(catalog, ComponentUpdates.line("vkd3d", true), emptySet())?.file)
|
||||
assertEquals("DD-vkd3d-proton-3.1+30-nightly.wcp", ComponentUpdates.pick(catalog, ComponentUpdates.line("vkd3d", false), emptySet())?.file)
|
||||
assertEquals("DD-FEXCore-2611+3-nightly.wcp", ComponentUpdates.pick(catalog, ComponentUpdates.line("fex", true), emptySet())?.file)
|
||||
assertEquals("fex", ComponentUpdates.line("fex", false).key)
|
||||
}
|
||||
|
||||
@Test fun aBadBuildIsSkippedAndNothingElseIsPickedInItsPlace() {
|
||||
val plain = ComponentUpdates.line("dxvk", false)
|
||||
assertNull(ComponentUpdates.pick(catalog, plain, setOf("DD-dxvk-3.1.1+190-nightly.wcp")))
|
||||
assertEquals("DD-dxvk-3.1.1+190-nightly.wcp", ComponentUpdates.pick(catalog, plain, setOf("DD-dxvk-3.1.1+188-nightly.wcp"))?.file)
|
||||
assertEquals("DD-dxvk-3.1.1+190-nightly.wcp", ComponentUpdates.pick(catalog, plain, setOf("DD-vkd3d-proton-3.1+40-nightly.wcp"))?.file)
|
||||
assertNull(ComponentUpdates.pick(catalog, ComponentUpdates.line("fex", false), setOf("DD-FEXCore-2611+3-nightly.wcp")))
|
||||
assertNull(ComponentUpdates.pick(catalog.filter { it.release != ComponentsManager.DD_NIGHTLY }, plain, emptySet()))
|
||||
}
|
||||
|
||||
private fun pe(machine: Int, pe32plus: Boolean, hybrid: Boolean?): ByteArray {
|
||||
val b = ByteBuffer.allocate(0x800).order(ByteOrder.LITTLE_ENDIAN)
|
||||
b.put(0, 'M'.code.toByte()).put(1, 'Z'.code.toByte()).putInt(0x3c, 0x80)
|
||||
b.putInt(0x80, 0x4550).putShort(0x84, machine.toShort()).putShort(0x86, 1)
|
||||
val optional = 0x98
|
||||
val optionalSize = if (pe32plus) 240 else 224
|
||||
b.putShort(0x94, optionalSize.toShort())
|
||||
b.putShort(optional, if (pe32plus) 0x20b.toShort() else 0x10b.toShort())
|
||||
val section = optional + optionalSize
|
||||
b.putInt(section + 8, 0x1000).putInt(section + 12, 0x1000).putInt(section + 20, 0x400)
|
||||
if (hybrid != null && pe32plus) {
|
||||
b.putInt(optional + 112 + 10 * 8, 0x1100)
|
||||
b.putInt(0x500, 0x140)
|
||||
if (hybrid) b.putLong(0x500 + 0xC8, 0x180001000L)
|
||||
}
|
||||
return b.array()
|
||||
}
|
||||
|
||||
@Test fun arm64ecAndArm64xImagesAreToldApartFromPlainX64ByTheirHybridMetadata() {
|
||||
assertEquals(true, ComponentUpdates.arm64ec(pe(0xaa64, true, true)))
|
||||
assertEquals(true, ComponentUpdates.arm64ec(pe(0x8664, true, true)))
|
||||
assertEquals(false, ComponentUpdates.arm64ec(pe(0x8664, true, false)))
|
||||
assertEquals(false, ComponentUpdates.arm64ec(pe(0x8664, true, null)))
|
||||
assertEquals(false, ComponentUpdates.arm64ec(pe(0x14c, false, null)))
|
||||
assertNull(ComponentUpdates.arm64ec(ByteArray(16)))
|
||||
}
|
||||
|
||||
@Test fun onlyAHybridArm64ImageCountsAsArm64x() {
|
||||
assertTrue(ComponentUpdates.arm64x(pe(0xaa64, true, true)))
|
||||
assertFalse(ComponentUpdates.arm64x(pe(0x8664, true, true)))
|
||||
assertFalse(ComponentUpdates.arm64x(pe(0xaa64, true, false)))
|
||||
assertFalse(ComponentUpdates.arm64x(ByteArray(16)))
|
||||
}
|
||||
|
||||
@Test fun anArm64ecLineNeedsArm64xUnlessTheProtonsOwnBuildIsKnownNotToBe() {
|
||||
val ec = ComponentUpdates.line("dxvk", true)
|
||||
assertTrue(ComponentUpdates.needsArm64x(ec, listOf(true)))
|
||||
assertTrue(ComponentUpdates.needsArm64x(ec, listOf(null)))
|
||||
assertFalse(ComponentUpdates.needsArm64x(ec, listOf(false)))
|
||||
assertTrue(ComponentUpdates.needsArm64x(ec, listOf(false, true)))
|
||||
assertFalse(ComponentUpdates.needsArm64x(ec, listOf(false, false)))
|
||||
assertFalse(ComponentUpdates.needsArm64x(ComponentUpdates.line("dxvk", false), listOf(null)))
|
||||
assertFalse(ComponentUpdates.needsArm64x(ComponentUpdates.line("fex", false), listOf(null)))
|
||||
}
|
||||
|
||||
private val log = """
|
||||
[2026-11-05 20:00:00] Game process added : AppID 49520 "/root/.local/share/Steam/linuxarm64/steam-launch-wrapper -- /root/.local/share/Steam/steamrtarm64/reaper SteamLaunch AppId=49520 -- '/root/.local/share/Steam/compatibilitytools.d/DroidDeck-Proton 11-12.1'/droiddeck-proton-wrap waitforexitandrun 'Borderlands2.exe'"
|
||||
[2026-11-05 20:00:05] Game process updated : AppID 49520 "x"
|
||||
[2026-11-05 20:10:00] Game process removed: AppID 49520 "x"
|
||||
[2026-11-05 20:11:00] Game process added : AppID 413150 "/root/.local/share/Steam/steamapps/common/Proton - Experimental/proton waitforexitandrun 'Stardew Valley.exe'"
|
||||
[2026-11-05 20:11:12] Game process removed: AppID 413150 "x"
|
||||
[2026-11-05 20:12:00] Game process added : AppID 22380 "/usr/bin/true no tool here"
|
||||
[2026-11-05 20:12:02] Game process removed: AppID 22380 "x"
|
||||
""".trimIndent().lines().asSequence()
|
||||
|
||||
@Test fun launchesComeFromSteamsOwnProcessLinesWithTheirProtonAndDuration() {
|
||||
val runs = ComponentUpdates.launches(log, "")
|
||||
assertEquals(listOf(
|
||||
ComponentUpdates.Launch("49520", "DroidDeck-Proton 11-12.1", "2026-11-05 20:00:00", 600),
|
||||
ComponentUpdates.Launch("413150", "Proton - Experimental", "2026-11-05 20:11:00", 12),
|
||||
), runs)
|
||||
assertEquals(listOf("413150"), ComponentUpdates.launches(log, "2026-11-05 20:10:30").map { it.app })
|
||||
}
|
||||
|
||||
private fun run(app: String, start: String, seconds: Long) = ComponentUpdates.Launch(app, "DroidDeck-Proton 11-12.1", start, seconds)
|
||||
|
||||
private val trial = ComponentUpdates.Trial("new.wcp", ComponentUpdates.ORIGINAL, "2026-11-05 12:00:00", emptyMap(), emptyMap())
|
||||
|
||||
@Test fun aGameThatBootedOnThePreviousBuildAndTwiceFailsOnTheNewOneRollsTheLineBack() {
|
||||
val verdict = ComponentUpdates.judge(trial, listOf(
|
||||
run("100", "2026-11-05 10:00:00", 900),
|
||||
run("100", "2026-11-05 13:00:00", 4),
|
||||
run("100", "2026-11-05 13:05:00", 6),
|
||||
))
|
||||
assertTrue(verdict.rollBack)
|
||||
assertEquals(2, verdict.failed["100"])
|
||||
}
|
||||
|
||||
@Test fun oneFailedBootOrAGameThatNeverBootedBeforeDoesNotRollBack() {
|
||||
assertFalse(ComponentUpdates.judge(trial, listOf(run("100", "2026-11-05 10:00:00", 900), run("100", "2026-11-05 13:00:00", 4))).rollBack)
|
||||
assertFalse(ComponentUpdates.judge(trial, listOf(run("200", "2026-11-05 13:00:00", 4), run("200", "2026-11-05 13:05:00", 4))).rollBack)
|
||||
}
|
||||
|
||||
@Test fun aGameThatBootsOnTheNewBuildStopsCountingShortRunsAsFailures() {
|
||||
val verdict = ComponentUpdates.judge(trial, listOf(
|
||||
run("100", "2026-11-05 10:00:00", 900),
|
||||
run("100", "2026-11-05 13:00:00", 4),
|
||||
run("100", "2026-11-05 13:10:00", 1200),
|
||||
run("100", "2026-11-05 14:00:00", 4),
|
||||
))
|
||||
assertFalse(verdict.rollBack)
|
||||
assertEquals("new.wcp", verdict.booted["100"])
|
||||
assertNull(verdict.failed["100"])
|
||||
}
|
||||
|
||||
@Test fun bootsOnTheOriginalBeforeTheFirstUpdateLetTheFirstBuildRollBack() {
|
||||
val original = ComponentUpdates.Trial(ComponentUpdates.ORIGINAL, ComponentUpdates.ORIGINAL, "", emptyMap(), emptyMap())
|
||||
val before = ComponentUpdates.judge(original, listOf(run("100", "2026-11-05 10:00:00", 900), run("200", "2026-11-05 10:30:00", 3)))
|
||||
assertFalse(before.rollBack)
|
||||
assertEquals(mapOf("100" to ComponentUpdates.ORIGINAL), before.booted)
|
||||
val after = ComponentUpdates.judge(trial.copy(booted = before.booted), listOf(run("100", "2026-11-05 13:00:00", 4), run("100", "2026-11-05 13:05:00", 6)))
|
||||
assertTrue(after.rollBack)
|
||||
}
|
||||
|
||||
@Test fun aProtonUpdatedInPlaceIsReadFromItsOwnFilesAgain() {
|
||||
val context = ApplicationProvider.getApplicationContext<Context>()
|
||||
val dir = Files.createTempDirectory(context.cacheDir.toPath(), "proton").toFile()
|
||||
File(dir, "files/lib/wine/dxvk/aarch64-windows").apply { mkdirs() }.resolve("d3d11.dll").writeBytes(pe(0xaa64, true, true))
|
||||
val proton = ComponentsManager.Proton("Test-Proton", "Test Proton", dir, "/p", "Test-Proton-2", false)
|
||||
val state = File(context.filesDir, "components/state.json").apply { parentFile?.mkdirs() }
|
||||
fun active(version: String) = state.writeText(JSONObject().put("active", JSONObject().put("Test-Proton", JSONObject()
|
||||
.put("dxvk", JSONObject().put("file", "DD-dxvk-arm64ec-3.1.1+188-nightly.wcp").put("protonVersion", version)))).toString())
|
||||
|
||||
active("Test-Proton-1")
|
||||
assertEquals(true, ComponentsManager.arm64ec(context, proton, "dxvk"))
|
||||
active("Test-Proton-2")
|
||||
assertNull(ComponentsManager.arm64ec(context, proton, "dxvk"))
|
||||
}
|
||||
|
||||
@Test fun aFailedSaveKeepsTheLastGoodStateAndTheNextSaveReplacesItWhole() {
|
||||
val context = ApplicationProvider.getApplicationContext<Context>()
|
||||
val dir = File(context.filesDir, "components").apply { mkdirs() }
|
||||
val state = File(dir, "updates.json")
|
||||
val saved = JSONObject().put("checkedAt", System.currentTimeMillis()).put("lines", JSONObject().put("fex", JSONObject()
|
||||
.put("current", "DD-FEXCore-2611+3-nightly.wcp").put("bad", JSONArray().put("DD-FEXCore-2611+2-nightly.wcp")))).toString()
|
||||
state.writeText(saved)
|
||||
state.setWritable(false)
|
||||
dir.setWritable(false)
|
||||
try {
|
||||
org.junit.Assume.assumeFalse(state.canWrite() || dir.canWrite())
|
||||
ComponentUpdater.ensure(context, false)
|
||||
} finally {
|
||||
dir.setWritable(true)
|
||||
state.setWritable(true)
|
||||
}
|
||||
assertEquals(saved, state.readText())
|
||||
|
||||
ComponentUpdater.ensure(context, false)
|
||||
val fex = JSONObject(state.readText()).getJSONObject("lines").getJSONObject("fex")
|
||||
assertEquals("DD-FEXCore-2611+3-nightly.wcp", fex.getString("current"))
|
||||
assertEquals("DD-FEXCore-2611+2-nightly.wcp", fex.getJSONArray("bad").getString(0))
|
||||
assertFalse(state.readText() == saved)
|
||||
assertTrue(dir.list()!!.none { it.startsWith("updates.json.") })
|
||||
}
|
||||
|
||||
@Test fun aLineWithAnUnfinishedRollbackTakesNoNewerBuildUntilItIsApplied() {
|
||||
assertTrue(ComponentUpdater.rollingBack(JSONObject().put("restore", JSONObject().put("proton", "DD-dxvk-2.5.wcp"))))
|
||||
assertTrue(ComponentUpdater.rollingBack(JSONObject().put("pendingNote", "rolled back")))
|
||||
assertFalse(ComponentUpdater.rollingBack(JSONObject().put("restore", JSONObject()).put("current", "DD-dxvk-2.4.wcp")))
|
||||
}
|
||||
|
||||
@Test fun aRemovedProtonNoLongerHoldsItsLineInARollback() {
|
||||
val line = JSONObject().put("restore", JSONObject().put("gone", "DD-dxvk-2.5.wcp"))
|
||||
val state = JSONObject().put("lines", JSONObject().put("dxvk", line))
|
||||
ComponentUpdater.dropRemoved(state, emptyList())
|
||||
assertFalse(ComponentUpdater.rollingBack(line))
|
||||
}
|
||||
|
||||
@Test fun aTwoDigitNightlyBuildIsNewerThanASingleDigitOne() {
|
||||
val items = listOf(item("DD-FEXCore-2611+9-nightly.wcp", "fex"), item("DD-FEXCore-2611+10-nightly.wcp", "fex"))
|
||||
assertEquals("DD-FEXCore-2611+10-nightly.wcp", ComponentUpdates.pick(items, ComponentUpdates.line("fex", false), emptySet())?.file)
|
||||
assertNull(ComponentUpdates.pick(items, ComponentUpdates.line("fex", false), setOf("DD-FEXCore-2611+10-nightly.wcp")))
|
||||
}
|
||||
|
||||
@Test fun readsDuringSavesNeverLoseTheState() {
|
||||
val context = ApplicationProvider.getApplicationContext<Context>()
|
||||
val state = File(context.filesDir, "components/updates.json").apply { parentFile?.mkdirs() }
|
||||
state.writeText(JSONObject().put("checkedAt", System.currentTimeMillis()).put("lines", JSONObject().put("fex", JSONObject()
|
||||
.put("current", "DD-FEXCore-2611+3-nightly.wcp").put("bad", JSONArray().put("DD-FEXCore-2611+2-nightly.wcp")))).toString())
|
||||
val done = java.util.concurrent.atomic.AtomicBoolean(false)
|
||||
val reader = Thread {
|
||||
while (!done.get()) {
|
||||
ComponentUpdater.settle(context)
|
||||
ComponentUpdater.status(context, "fex")
|
||||
}
|
||||
}.apply { start() }
|
||||
try {
|
||||
repeat(400) { ComponentUpdater.ensure(context, false) }
|
||||
} finally {
|
||||
done.set(true)
|
||||
reader.join()
|
||||
}
|
||||
val fex = JSONObject(state.readText()).getJSONObject("lines").getJSONObject("fex")
|
||||
assertEquals("DD-FEXCore-2611+2-nightly.wcp", fex.getJSONArray("bad").getString(0))
|
||||
}
|
||||
|
||||
@Test fun onlyTheCurrentAndThePreviousBuildAndUserSelectionsAreKept() {
|
||||
assertEquals(setOf("b.wcp", "a.wcp", "mine.wcp"), ComponentUpdates.keep("b.wcp", "a.wcp", setOf("mine.wcp")))
|
||||
assertEquals(setOf("b.wcp"), ComponentUpdates.keep("b.wcp", ComponentUpdates.ORIGINAL, emptySet()))
|
||||
}
|
||||
}
|
||||
@@ -24,10 +24,4 @@ class PipPolicyTest {
|
||||
assertEquals(100 to 239, PipPolicy.aspect(1080, 5760))
|
||||
assertEquals(16 to 9, PipPolicy.aspect(0, 0))
|
||||
}
|
||||
|
||||
@Test fun pipOutputFitsTheResizedSurfaceWithoutChangingAspectRatio() {
|
||||
assertEquals(640 to 360, PipPolicy.outputSize(640, 480, 1920, 1080))
|
||||
assertEquals(480 to 270, PipPolicy.outputSize(480, 270, 1920, 1080))
|
||||
assertNull(PipPolicy.outputSize(0, 270, 1920, 1080))
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,21 @@
|
||||
package com.droiddeck.launcher.ui
|
||||
|
||||
import org.junit.Assert.assertFalse
|
||||
import org.junit.Assert.assertTrue
|
||||
import org.junit.Test
|
||||
|
||||
class WowChatTest {
|
||||
@Test
|
||||
fun everyWowClientMatches() {
|
||||
listOf("wow.exe", "Wow.exe", "wowclassic.exe", "wowclassict.exe", "wowb.exe", "wow-64.exe", "wow-arm64.exe", "wowt.exe").forEach {
|
||||
assertTrue(it, WowChat.isWow(it))
|
||||
}
|
||||
}
|
||||
|
||||
@Test
|
||||
fun otherProgramsAreUnaffected() {
|
||||
listOf(null, "", "battle.net.exe", "steam.exe", "notwow.exe", "wow.exe.bak", "wow", "cyberpunk2077.exe").forEach {
|
||||
assertFalse(it.toString(), WowChat.isWow(it))
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user