mirror of
https://github.com/Droid-Deck/DroidDeck.git
synced 2026-11-18 20:36:04 +00:00
Merge current main into PR #1301
This commit is contained in:
commit
848f13d6a4
55 files changed
+1842
-192
No files matched your search
@@ -40,6 +40,33 @@ class SessionDisplayTest {
|
||||
assertEquals(864, SessionDisplay.unfoldedGameHeight(1920, 1080))
|
||||
}
|
||||
|
||||
private fun unfoldedWanted(
|
||||
enabled: Boolean = true,
|
||||
controller: Boolean = false,
|
||||
keepWithController: Boolean = false,
|
||||
foldable: Boolean = true,
|
||||
steamDeckPad: Boolean = true,
|
||||
pip: Boolean = false,
|
||||
smallestWidthDp: Int = 700,
|
||||
) = SessionDisplay.unfoldedControlsWanted(enabled, foldable, controller, keepWithController, steamDeckPad, pip,
|
||||
2448, 1848, smallestWidthDp)
|
||||
|
||||
@Test fun unfoldedControlsHideForAControllerUnlessKeptWithOne() {
|
||||
assertTrue(unfoldedWanted())
|
||||
assertFalse(unfoldedWanted(controller = true))
|
||||
assertTrue(unfoldedWanted(controller = true, keepWithController = true))
|
||||
assertTrue(unfoldedWanted(keepWithController = true))
|
||||
}
|
||||
|
||||
@Test fun keepingUnfoldedControlsWithAControllerLeavesTheOtherConditions() {
|
||||
assertFalse(unfoldedWanted(enabled = false, controller = true, keepWithController = true))
|
||||
assertFalse(unfoldedWanted(foldable = false, keepWithController = true))
|
||||
assertFalse(unfoldedWanted(steamDeckPad = false, keepWithController = true))
|
||||
assertFalse(unfoldedWanted(pip = true, keepWithController = true))
|
||||
assertFalse(unfoldedWanted(smallestWidthDp = 599, keepWithController = true))
|
||||
assertFalse(SessionDisplay.unfoldedControlsWanted(true, true, true, true, true, false, 0, 1848, 700))
|
||||
}
|
||||
|
||||
|
||||
@Test fun followScreenKeepsTheWindowShapeAndSkipsTinyWindows() {
|
||||
assertEquals(2520 to 1080, SessionDisplay.resolveChoice(1080 to 2520, SessionDisplay.FOLLOW_SCREEN))
|
||||
|
||||
@@ -0,0 +1,27 @@
|
||||
package com.droiddeck.launcher.session
|
||||
|
||||
import org.junit.Assert.assertFalse
|
||||
import org.junit.Assert.assertTrue
|
||||
import org.junit.Test
|
||||
|
||||
class SessionVisibilityPolicyTest {
|
||||
@Test fun handsetScreenStateControlsActivityOnDefaultDisplay() {
|
||||
assertFalse(SessionVisibilityPolicy.isHidden(true, true, true, false))
|
||||
assertTrue(SessionVisibilityPolicy.isHidden(true, false, true, true))
|
||||
}
|
||||
|
||||
@Test fun externalDisplayStateControlsActivityIndependentlyOfHandset() {
|
||||
assertFalse(SessionVisibilityPolicy.isHidden(true, false, false, true))
|
||||
assertTrue(SessionVisibilityPolicy.isHidden(true, true, false, false))
|
||||
}
|
||||
|
||||
@Test fun missingActivityDisplayIsHiddenUntilActivityMoves() {
|
||||
assertTrue(SessionVisibilityPolicy.isHidden(true, true, false, false))
|
||||
assertFalse(SessionVisibilityPolicy.isHidden(true, true, true, false))
|
||||
}
|
||||
|
||||
@Test fun stoppedActivityIsHiddenButVisibleXrKeepsSessionVisible() {
|
||||
assertTrue(SessionVisibilityPolicy.isHidden(false, true, true, true))
|
||||
assertFalse(SessionVisibilityPolicy.isHidden(false, false, true, false, xrActivityVisible = true))
|
||||
}
|
||||
}
|
||||
@@ -27,6 +27,7 @@ class SettingsResetTest {
|
||||
|
||||
@Test fun settingsGoBackToTheirDefaults() {
|
||||
SessionPrefs.setTheme(app, "ocean")
|
||||
SessionPrefs.setUnfoldedControlsWithController(app, true)
|
||||
SessionPrefs.setNoXalia(app, false)
|
||||
SessionPrefs.setFpsLimit(app, SessionService.MODE_STEAM, 30)
|
||||
SessionPrefs.setHdr(app, SessionService.MODE_DESKTOP, true)
|
||||
@@ -45,6 +46,7 @@ class SettingsResetTest {
|
||||
assertTrue(SettingsReset.resetAll(app, gameProfiles = false))
|
||||
|
||||
assertEquals("graphite", SessionPrefs.theme(app))
|
||||
assertFalse(SessionPrefs.unfoldedControlsWithController(app))
|
||||
assertTrue(SessionPrefs.noXalia(app))
|
||||
assertEquals(0, SessionPrefs.fpsLimit(app, SessionService.MODE_STEAM))
|
||||
assertFalse(SessionPrefs.hdr(app, SessionService.MODE_DESKTOP))
|
||||
|
||||
@@ -0,0 +1,100 @@
|
||||
package com.droiddeck.launcher.ui
|
||||
|
||||
import androidx.compose.runtime.mutableIntStateOf
|
||||
import androidx.compose.runtime.mutableStateOf
|
||||
import androidx.compose.ui.Modifier
|
||||
import androidx.compose.ui.semantics.Role
|
||||
import androidx.compose.ui.semantics.SemanticsProperties
|
||||
import androidx.compose.ui.test.*
|
||||
import androidx.compose.foundation.layout.size
|
||||
import androidx.compose.ui.unit.dp
|
||||
import org.junit.Rule
|
||||
import org.junit.Before
|
||||
import org.junit.Test
|
||||
import org.junit.runner.RunWith
|
||||
import org.robolectric.RobolectricTestRunner
|
||||
import org.robolectric.annotation.Config
|
||||
|
||||
@RunWith(RobolectricTestRunner::class)
|
||||
@Config(sdk = [28])
|
||||
class NavigationSelectionTest {
|
||||
@get:Rule val compose = createRobolectricComposeRule()
|
||||
|
||||
@Before fun controlAnimationFrames() {
|
||||
compose.mainClock.autoAdvance = false
|
||||
}
|
||||
|
||||
@Test fun tabStripAnnouncesSelectionAndUpdatesAfterClick() {
|
||||
val selected = mutableIntStateOf(0)
|
||||
compose.setContent { DroidDeckTheme { TabStrip(listOf("First", "Second"), selected.intValue, { selected.intValue = it }) } }
|
||||
verify("First", "Second")
|
||||
}
|
||||
|
||||
@Test fun sheetChipsAnnounceSelectionAndUpdateAfterClick() {
|
||||
val selected = mutableIntStateOf(0)
|
||||
compose.setContent { DroidDeckTheme { SheetChips(listOf("First", "Second"), selected.intValue) { selected.intValue = it } } }
|
||||
verify("First", "Second")
|
||||
}
|
||||
|
||||
@Test fun segmentedTabsHaveOneTabRoleAndAnnounceTheirGroup() {
|
||||
val selected = mutableIntStateOf(0)
|
||||
compose.setContent { DroidDeckTheme { SegmentedTabs(listOf(0 to "First", 1 to "Second"), selected.intValue) { selected.intValue = it } } }
|
||||
verify("First", "Second")
|
||||
}
|
||||
|
||||
@Test fun sideRailExposesSelectionEvenWhenOnlyIconsAreVisible() {
|
||||
val selected = mutableStateOf("steam")
|
||||
Hops.railPreview = null
|
||||
compose.setContent {
|
||||
DroidDeckTheme {
|
||||
SideRail(FrontEndState(
|
||||
installed = "r9", ready = true, available = null, busy = false, stage = "", percent = -1,
|
||||
desktopInstalled = true, offlineAccount = null, offline = false, frameGenLabel = "",
|
||||
romsDir = null, logsEnabled = false, steamGames = emptyList(), emulators = emptyList(), running = null,
|
||||
), selected.value, { selected.value = it }, {}, actions, Modifier.size(300.dp, 600.dp))
|
||||
}
|
||||
}
|
||||
compose.mainClock.advanceTimeBy(1_000)
|
||||
val steam = compose.onNodeWithTag("rail-steam")
|
||||
val games = compose.onNodeWithTag("rail-games")
|
||||
assertTab(steam, true)
|
||||
assertTab(games, false)
|
||||
games.performClick()
|
||||
compose.mainClock.advanceTimeBy(1_000)
|
||||
assertTab(steam, false)
|
||||
assertTab(games, true)
|
||||
assertGroup()
|
||||
}
|
||||
|
||||
private fun verify(first: String, second: String) {
|
||||
compose.mainClock.advanceTimeBy(1_000)
|
||||
val a = compose.onNodeWithText(first)
|
||||
val b = compose.onNodeWithText(second)
|
||||
assertTab(a, true)
|
||||
assertTab(b, false)
|
||||
b.performClick()
|
||||
compose.mainClock.advanceTimeBy(1_000)
|
||||
assertTab(a, false)
|
||||
assertTab(b, true)
|
||||
assertGroup()
|
||||
}
|
||||
|
||||
private fun assertTab(node: SemanticsNodeInteraction, selected: Boolean) {
|
||||
node.assert(SemanticsMatcher.expectValue(SemanticsProperties.Role, Role.Tab)).assertHasClickAction()
|
||||
if (selected) node.assertIsSelected() else node.assertIsNotSelected()
|
||||
}
|
||||
|
||||
private fun assertGroup() {
|
||||
compose.onAllNodes(SemanticsMatcher.keyIsDefined(SemanticsProperties.SelectableGroup)).assertCountEquals(1)
|
||||
}
|
||||
|
||||
private val actions = FrontEndActions(
|
||||
onPlay = {}, onPlayDesktopUi = {}, onSteamGame = {}, onDesktop = {}, onEmulator = {},
|
||||
onRom = {}, onResume = {}, onSteamSettings = {}, onDesktopSettings = {},
|
||||
onInstallPackage = {}, onRemovePackage = {}, onRuntime = {}, onFrameGenPick = {},
|
||||
onImportLossless = {}, onProtons = {}, onComponents = {}, onPerformance = {},
|
||||
onRoms = {}, onFiles = {}, onLogs = {}, onOffline = {},
|
||||
onWirelessAdbPair = { _, _, _, _ -> }, onWirelessAdbApply = { _, _, _, _ -> },
|
||||
onSetPhantomProcessLimit = { _, _ -> },
|
||||
)
|
||||
}
|
||||
Reference in new issue
Block a user