mirror of
https://github.com/Droid-Deck/DroidDeck.git
synced 2026-11-19 04:46:08 +00:00
Merge branch 'main' into fix/steam-client-download
# Conflicts: # tools/linuxfs/overlay/usr/local/bin/droiddeck-steam-install # tools/tests/test_steam_install.py
This commit is contained in:
commit
2d9d4dbeb0
155 files changed
+6161
-993
No files matched your search
@@ -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))
|
||||
}
|
||||
}
|
||||
@@ -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)
|
||||
|
||||
@@ -13,9 +13,33 @@ class SyncBackendTest {
|
||||
private val context: Context = RuntimeEnvironment.getApplication()
|
||||
|
||||
@Test
|
||||
fun aFreshInstallStartsOnEsync() {
|
||||
assertEquals(SessionPrefs.SYNC_ESYNC, SessionPrefs.syncBackend(context))
|
||||
fun aFreshInstallStartsOnNtsync() {
|
||||
assertEquals(SessionPrefs.SYNC_NTSYNC, SessionPrefs.syncBackend(context))
|
||||
assertEquals(false, SessionPrefs.fsyncFirst(context))
|
||||
SessionPrefs.applyNtsyncDefault(context)
|
||||
assertEquals(SessionPrefs.SYNC_NTSYNC, SessionPrefs.syncBackend(context))
|
||||
}
|
||||
|
||||
@Test
|
||||
fun anEarlierChoiceMovesToNtsyncOnce() {
|
||||
for (earlier in listOf(SessionPrefs.SYNC_ESYNC, SessionPrefs.SYNC_FSYNC, SessionPrefs.SYNC_WINESERVER)) {
|
||||
context.getSharedPreferences("session", Context.MODE_PRIVATE).edit().clear().commit()
|
||||
SessionPrefs.setSyncBackend(context, earlier)
|
||||
SessionPrefs.applyNtsyncDefault(context)
|
||||
assertEquals(SessionPrefs.SYNC_NTSYNC, SessionPrefs.syncBackend(context))
|
||||
}
|
||||
}
|
||||
|
||||
@Test
|
||||
fun aChoiceMadeAfterTheMoveIsKept() {
|
||||
SessionPrefs.setSyncBackend(context, SessionPrefs.SYNC_ESYNC)
|
||||
SessionPrefs.applyNtsyncDefault(context)
|
||||
SessionPrefs.setSyncBackend(context, SessionPrefs.SYNC_ESYNC)
|
||||
SessionPrefs.applyNtsyncDefault(context)
|
||||
assertEquals(SessionPrefs.SYNC_ESYNC, SessionPrefs.syncBackend(context))
|
||||
SessionPrefs.setSyncBackend(context, SessionPrefs.SYNC_WINESERVER)
|
||||
SessionPrefs.applyNtsyncDefault(context)
|
||||
assertEquals(SessionPrefs.SYNC_WINESERVER, SessionPrefs.syncBackend(context))
|
||||
}
|
||||
|
||||
@Test
|
||||
@@ -34,6 +58,7 @@ class SyncBackendTest {
|
||||
|
||||
@Test
|
||||
fun pickingATabTurnsSyncBackOn() {
|
||||
SessionPrefs.setFastSync(context, false)
|
||||
SessionPrefs.setSyncFallback(context, false)
|
||||
SessionPrefs.setFsyncFirst(context, false)
|
||||
assertEquals(SessionPrefs.SYNC_WINESERVER, SessionPrefs.syncBackend(context))
|
||||
|
||||
@@ -0,0 +1,55 @@
|
||||
package com.droiddeck.launcher.session
|
||||
|
||||
import android.content.Context
|
||||
import com.droiddeck.launcher.gpu.TpUbwcHint
|
||||
import org.junit.Assert.assertEquals
|
||||
import org.junit.Assert.assertFalse
|
||||
import org.junit.Assert.assertTrue
|
||||
import org.junit.Before
|
||||
import org.junit.Test
|
||||
import org.junit.runner.RunWith
|
||||
import org.robolectric.RobolectricTestRunner
|
||||
import org.robolectric.RuntimeEnvironment
|
||||
import org.robolectric.annotation.Config
|
||||
import org.robolectric.util.ReflectionHelpers
|
||||
|
||||
@RunWith(RobolectricTestRunner::class)
|
||||
@Config(sdk = [28], manifest = Config.NONE)
|
||||
class TpUbwcPrefsTest {
|
||||
private val context: Context get() = RuntimeEnvironment.getApplication()
|
||||
|
||||
@Before fun reset() {
|
||||
ReflectionHelpers.setStaticField(TpUbwcHint::class.java, "resolved", false)
|
||||
ReflectionHelpers.setStaticField(TpUbwcHint::class.java, "cached", null)
|
||||
ReflectionHelpers.setStaticField(TpUbwcHint::class.java, "activeMode", null)
|
||||
context.getSharedPreferences("session", Context.MODE_PRIVATE).edit().clear().commit()
|
||||
}
|
||||
|
||||
@Test fun missingOrInvalidChoiceUsesAuto() {
|
||||
assertEquals(SessionPrefs.TP_UBWC_AUTO, SessionPrefs.tpUbwcMode(context))
|
||||
context.getSharedPreferences("session", Context.MODE_PRIVATE).edit().putString("tpUbwcMode", "invalid").commit()
|
||||
assertEquals(SessionPrefs.TP_UBWC_AUTO, SessionPrefs.tpUbwcMode(context))
|
||||
}
|
||||
|
||||
@Test fun overrideIsStoredWithoutChangingDriverChoices() {
|
||||
SessionPrefs.setAndroidDriver(context, "display")
|
||||
SessionPrefs.setLinuxDriver(context, "runtime")
|
||||
for (mode in listOf(SessionPrefs.TP_UBWC_ON, SessionPrefs.TP_UBWC_OFF, SessionPrefs.TP_UBWC_AUTO)) {
|
||||
SessionPrefs.setTpUbwcMode(context, mode)
|
||||
assertEquals(mode, SessionPrefs.tpUbwcMode(context))
|
||||
assertEquals("display", SessionPrefs.androidDriver(context))
|
||||
assertEquals("runtime", SessionPrefs.linuxDriver(context))
|
||||
}
|
||||
}
|
||||
|
||||
@Test fun changingTheSavedChoiceKeepsTheProcessChoiceUntilRestart() {
|
||||
SessionPrefs.setTpUbwcMode(context, SessionPrefs.TP_UBWC_ON)
|
||||
val initial = TpUbwcHint.forThisDevice(context)
|
||||
SessionPrefs.setTpUbwcMode(context, SessionPrefs.TP_UBWC_OFF)
|
||||
assertTrue(TpUbwcHint.restartRequired(context))
|
||||
assertEquals(SessionPrefs.TP_UBWC_ON, TpUbwcHint.activeMode)
|
||||
assertEquals(initial, TpUbwcHint.forThisDevice(context))
|
||||
SessionPrefs.setTpUbwcMode(context, SessionPrefs.TP_UBWC_ON)
|
||||
assertFalse(TpUbwcHint.restartRequired(context))
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user