feat(library): remember visibility and store order (#1591)

This commit is contained in:
Kurt Himebauch authored and GitHub committed 2026-10-26 07:44:07 -04:00
1 parent fbb334263c
commit 63d1e4d61d
6 files changed
+303 -21

No files matched your search

@@ -111,6 +111,12 @@ object SessionPrefs {
prefs(context).edit().putString("storesView", if (view in STORES_VIEWS) view else STORES_VIEWS.first()).apply()
}
fun libraryShowUninstalled(context: Context): Boolean = prefs(context).getBoolean("libraryShowUninstalled", false)
fun setLibraryShowUninstalled(context: Context, show: Boolean) {
prefs(context).edit().putBoolean("libraryShowUninstalled", show).apply()
}
fun storesTabOrder(context: Context): List<String> = idList(prefs(context).getString("storesTabOrder", null))
fun setStoresTabOrder(context: Context, order: List<String>) {
@@ -35,7 +35,7 @@ import androidx.compose.foundation.selection.selectable
import androidx.compose.foundation.shape.CircleShape
import androidx.compose.foundation.shape.RoundedCornerShape
import androidx.compose.material.icons.Icons
import androidx.compose.material.icons.filled.FilterList
import androidx.compose.material.icons.filled.FilterAlt
import androidx.compose.material.icons.filled.GridView
import androidx.compose.material.icons.filled.PlayArrow
import androidx.compose.material.icons.filled.Sort
@@ -86,6 +86,7 @@ import com.droiddeck.launcher.stores.CatalogItem
import com.droiddeck.launcher.stores.Store
import com.droiddeck.launcher.stores.StoreSizes
import com.droiddeck.launcher.stores.StoresState
import com.droiddeck.launcher.stores.arrangeStoreTabs
import com.droiddeck.launcher.stores.download.DownloadEntry
import com.droiddeck.launcher.stores.formatBytes
import com.droiddeck.launcher.stores.retainOrder
@@ -129,15 +130,21 @@ internal fun libraryEntries(
internal fun installedFirst(entries: List<LibraryEntry>): List<LibraryEntry> = entries.partition { it.installed }.let { (on, off) -> on + off }
internal const val LIBRARY_ALL = "all"
internal val LIBRARY_SOURCES = listOf(Library.SOURCE_STEAM) + Store.entries.map { it.id } + Library.ADDED
internal fun librarySources(entries: List<LibraryEntry>, order: List<String>): List<String> =
(listOf(Library.SOURCE_STEAM) + arrangeStoreTabs(order, emptySet()).map { it.store.id } + Library.ADDED)
.filter { source -> entries.any { it.source == source } }
/** Survives leaving the page, so Stores can open the Library on one store's owned games. */
internal object LibraryView {
var source by mutableStateOf(LIBRARY_ALL)
var query by mutableStateOf("")
var focusFirst = false
var ownedRequest by mutableIntStateOf(0)
private set
fun showOwned(store: Store) {
fun showOwned(context: android.content.Context, store: Store) {
SessionPrefs.setLibraryShowUninstalled(context, true)
ownedRequest++
source = store.id
query = ""
focusFirst = true
@@ -161,13 +168,20 @@ internal fun LibraryPage(s: FrontEndState, a: FrontEndActions, selected: String,
val cloudRows = rememberXboxCloudRows(s)
val all = remember(s.steamGames, cloudRows, owned, installedStore) { libraryEntries(s.steamGames + cloudRows, owned, installedStore) }
LaunchedEffect(Unit) { XboxLibraryFilter.load(ctx) }
val sources = LIBRARY_SOURCES.filter { src -> all.any { it.source == src } }
var showUninstalled by remember(LibraryView.ownedRequest) { mutableStateOf(SessionPrefs.libraryShowUninstalled(ctx)) }
val setShowUninstalled = { show: Boolean ->
showUninstalled = show
SessionPrefs.setLibraryShowUninstalled(ctx, show)
}
val sources = librarySources(all, SessionPrefs.storesTabOrder(ctx))
val source = LibraryView.source.takeIf { it == LIBRARY_ALL || it in sources } ?: LIBRARY_ALL
val q = LibraryView.query.trim().lowercase()
val xboxFilter = if (source == Store.XBOX.id) XboxLibraryFilter.current else XboxLibraryFilter.ALL
val candidates = all.filter {
val matching = all.filter {
(source == LIBRARY_ALL || it.source == source) && (q.isEmpty() || it.title.lowercase().contains(q)) && keepsXbox(xboxFilter, it)
}
val candidates = if (showUninstalled) matching else matching.filter { it.installed }
val hiddenUninstalled = if (showUninstalled) 0 else matching.count { !it.installed }
val sort = s.storesSort
val sizeSort = sort == "sizeAsc" || sort == "sizeDesc"
val installedAt = StoresState.installed.associate { it.key to it.sidecar.installedAt }
@@ -258,7 +272,7 @@ internal fun LibraryPage(s: FrontEndState, a: FrontEndActions, selected: String,
val detailScroll = rememberScrollState()
var cycled by remember { mutableIntStateOf(0) }
var gridFocused by remember { mutableStateOf(false) }
LaunchedEffect(source, sort) { grid.scrollToItem(0) }
LaunchedEffect(source, sort, showUninstalled) { grid.scrollToItem(0) }
LaunchedEffect(cycled) {
if (cycled == 0 || ff == null || inputMode.inputMode != androidx.compose.ui.input.InputMode.Keyboard) return@LaunchedEffect
focusWithinFrames({ gridFocused }) {
@@ -273,7 +287,9 @@ internal fun LibraryPage(s: FrontEndState, a: FrontEndActions, selected: String,
wrap = { key, content -> StoreTheme(GameRef.parse(key).let { r -> r.store ?: r.game(s.steamGames)?.source?.let { Store.byId(it) } }) { content() } },
grid = {
LibraryGrid(
s, a, grid, visible, split, all.size, sources, source, sizesPending, syncing,
s, a, grid, visible, split, visible.size, sources, source, sizesPending, syncing,
showUninstalled = showUninstalled.takeIf { stores }, onShowUninstalled = setShowUninstalled,
hiddenUninstalled = hiddenUninstalled,
onSource = { LibraryView.source = it },
onCycle = { step ->
val ids = listOf(LIBRARY_ALL) + sources
@@ -312,6 +328,7 @@ private fun LibraryEmpty(s: FrontEndState, a: FrontEndActions, modifier: Modifie
private fun LibraryGrid(
s: FrontEndState, a: FrontEndActions, grid: LazyGridState, visible: List<LibraryEntry>, split: Int, total: Int,
sources: List<String>, source: String, sizesPending: Boolean, syncing: List<Pair<Store, String>>,
showUninstalled: Boolean?, onShowUninstalled: (Boolean) -> Unit, hiddenUninstalled: Int,
onSource: (String) -> Unit, onCycle: (Int) -> Unit, onOpen: (String) -> Unit, onFocus: (Boolean) -> Unit, searchCleared: Boolean,
) {
val listMode = s.storesView == "list"
@@ -365,7 +382,9 @@ private fun LibraryGrid(
horizontalArrangement = Arrangement.spacedBy(10.dp), verticalArrangement = Arrangement.spacedBy(10.dp),
contentPadding = PaddingValues(top = 4.dp, bottom = 16.dp),
) {
item(key = "header", span = { GridItemSpan(maxLineSpan) }) { Rise(0) { LibraryHeader(s, a, total, searchCleared, xbox = source == Store.XBOX.id) } }
item(key = "header", span = { GridItemSpan(maxLineSpan) }) {
Rise(0) { LibraryHeader(s, a, total, searchCleared, source == Store.XBOX.id, showUninstalled, onShowUninstalled) }
}
item(key = "filters", span = { GridItemSpan(maxLineSpan) }) {
Rise(1) { LibraryFilters(sources, source, onSource) }
}
@@ -383,7 +402,13 @@ private fun LibraryGrid(
}
}
val empty = R.string.stores_nothing_matches
if (split == 0) libraryGrid(visible, empty, tile)
if (visible.isEmpty() && hiddenUninstalled > 0) item(key = "browse-owned", span = { GridItemSpan(maxLineSpan) }) {
Column(horizontalAlignment = Alignment.CenterHorizontally, verticalArrangement = Arrangement.spacedBy(12.dp), modifier = Modifier.fillMaxWidth().padding(vertical = 32.dp)) {
Text(stringResource(R.string.library_no_installed_matches), fontSize = 13.sp, color = MaterialTheme.colorScheme.onSurfaceVariant)
SecondaryButton(stringResource(R.string.library_browse_owned), modifier = Modifier.testTag("library-browse-owned")) { onShowUninstalled(true) }
}
}
else if (split == 0) libraryGrid(visible, empty, tile)
else {
item(key = "installed-label", span = { GridItemSpan(maxLineSpan) }) { SectionLabel(stringResource(R.string.stores_section_installed)) }
libraryGrid(visible.take(split), empty, tile)
@@ -403,7 +428,10 @@ private fun LazyGridScope.libraryGrid(entries: List<LibraryEntry>, empty: Int, t
}
@Composable
private fun LibraryHeader(s: FrontEndState, a: FrontEndActions, total: Int, searchCleared: Boolean, xbox: Boolean) {
private fun LibraryHeader(
s: FrontEndState, a: FrontEndActions, total: Int, searchCleared: Boolean, xbox: Boolean,
showUninstalled: Boolean?, onShowUninstalled: (Boolean) -> Unit,
) {
val colors = MaterialTheme.colorScheme
val narrow = LocalNarrowPane.current
ModeHeader(
@@ -418,7 +446,7 @@ private fun LibraryHeader(s: FrontEndState, a: FrontEndActions, total: Int, sear
}
},
) {
if (xbox) XboxFilterButton()
if (showUninstalled != null || xbox) LibraryFilterButton(showUninstalled, onShowUninstalled, xbox)
SortButton(s, a)
ViewButton(s, a)
GameFileFolderActions(s, a)
@@ -432,7 +460,7 @@ private fun LibraryFilters(sources: List<String>, source: String, onSource: (Str
if (sources.size < 2) return
Row(
horizontalArrangement = Arrangement.spacedBy(8.dp), verticalAlignment = Alignment.CenterVertically,
modifier = Modifier.fillMaxWidth().horizontalScroll(rememberScrollState()).padding(top = 4.dp, bottom = 2.dp),
modifier = Modifier.fillMaxWidth().padding(top = 4.dp, bottom = 2.dp).horizontalScroll(rememberScrollState()),
) {
SourceFilterChip(LIBRARY_ALL, stringResource(R.string.stores_tab_all), source == LIBRARY_ALL, dot = null) { onSource(LIBRARY_ALL) }
for (src in sources) {
@@ -629,24 +657,38 @@ private fun xboxFilterLabel(filter: String): String = when (filter) {
}
@Composable
private fun XboxFilterButton() {
private fun LibraryFilterButton(showUninstalled: Boolean?, onShowUninstalled: (Boolean) -> Unit, xbox: Boolean) {
val pal = LocalPalette.current
val ctx = LocalContext.current
val title = stringResource(R.string.xbox_filter_show)
val title = stringResource(R.string.library_filter)
val visibility = stringResource(if (showUninstalled == true) R.string.library_filter_all_owned else R.string.library_filter_installed)
val description = title + " · " + if (showUninstalled == null) xboxFilterLabel(XboxLibraryFilter.current) else visibility
val offset = if (showUninstalled == null) 0 else 2
var at by remember { mutableStateOf<Rect?>(null) }
Box(Modifier.onGloballyPositioned { at = it.boundsInRoot() }) {
HeaderIconButton(title + " · " + xboxFilterLabel(XboxLibraryFilter.current), Icons.Filled.FilterList, "xbox-filter") {
HeaderIconButton(description, Icons.Filled.FilterAlt, "library-filter") {
val from = at ?: return@HeaderIconButton
Steps.ask(StepAsk(
anchor = from, side = StepSide.Left, accent = pal.signal, pillCorner = 8.dp, items = XboxLibraryFilter.ALL_FILTERS.size,
handle = { Text(title, fontSize = 12.sp, fontWeight = FontWeight.SemiBold, color = pal.signal, maxLines = 1, overflow = TextOverflow.Ellipsis) },
anchor = from, side = StepSide.Left, accent = pal.signal, pillCorner = 8.dp, items = offset + if (xbox) XboxLibraryFilter.ALL_FILTERS.size else 0,
handle = { Icon(Icons.Filled.FilterAlt, null, tint = pal.signal, modifier = Modifier.size(18.dp)) },
) {
StepTitle(title)
StepList {
XboxLibraryFilter.ALL_FILTERS.forEachIndexed { i, filter ->
if (showUninstalled != null) listOf(false, true).forEachIndexed { i, show ->
StepChoice(
stringResource(if (show) R.string.library_filter_all_owned else R.string.library_filter_installed),
selected = show == showUninstalled, enabled = open,
modifier = Modifier.fillMaxWidth().stepItem(i).then(if (show == showUninstalled) Modifier.focusRequester(first) else Modifier),
) {
onShowUninstalled(show)
Steps.fold()
}
}
if (xbox && showUninstalled != null) Text(Store.XBOX.shortLabel, fontSize = 12.sp, color = MaterialTheme.colorScheme.onSurfaceVariant, modifier = Modifier.stepItem(offset).padding(start = 4.dp, top = 10.dp, bottom = 4.dp))
if (xbox) XboxLibraryFilter.ALL_FILTERS.forEachIndexed { i, filter ->
StepChoice(
xboxFilterLabel(filter), selected = filter == XboxLibraryFilter.current, enabled = open,
modifier = Modifier.fillMaxWidth().stepItem(i).then(if (filter == XboxLibraryFilter.current) Modifier.focusRequester(first) else Modifier),
modifier = Modifier.fillMaxWidth().stepItem(offset + i).then(if (showUninstalled == null && filter == XboxLibraryFilter.current) Modifier.focusRequester(first) else Modifier),
) {
XboxLibraryFilter.set(ctx, filter)
Steps.fold()
@@ -668,7 +710,7 @@ private fun SortButton(s: FrontEndState, a: FrontEndActions) {
val from = at ?: return@HeaderIconButton
Steps.ask(StepAsk(
anchor = from, side = StepSide.Left, accent = pal.signal, pillCorner = 8.dp, items = SessionPrefs.STORES_SORTS.size,
handle = { Text(title, fontSize = 12.sp, fontWeight = FontWeight.SemiBold, color = pal.signal, maxLines = 1, overflow = TextOverflow.Ellipsis) },
handle = { Icon(Icons.Filled.Sort, null, tint = pal.signal, modifier = Modifier.size(18.dp)) },
) {
StepTitle(title)
StepList {
@@ -947,7 +947,7 @@ private fun ProfileStrip(store: Store, owned: Int, loaded: Boolean, s: FrontEndS
}
Actions {
SmallTextButton(stringResource(R.string.stores_owned_in_library), key = "owned-in-library") {
LibraryView.showOwned(store)
LibraryView.showOwned(ctx, store)
show("games")
}
SmallTextButton(stringResource(R.string.stores_refresh)) { StoresState.open(ctx, store, force = true) }
+5
View File
@@ -3181,6 +3181,11 @@
<string name="epic_client_open">Open</string>
<string name="epic_client_install">Install</string>
<string name="library_filter_added">Added</string>
<string name="library_filter">Filter</string>
<string name="library_filter_installed">Installed only</string>
<string name="library_filter_all_owned">All owned games</string>
<string name="library_no_installed_matches">No installed games match these filters.</string>
<string name="library_browse_owned">Browse owned games</string>
<string name="game_tab_about">About</string>
<string name="game_tab_achievements_count" translatable="false">%1$s %2$d/%3$d</string>
<string name="game_tab_launch">Launch</string>
@@ -77,6 +77,16 @@ class LibraryEntriesTest {
assertEquals(listOf("b", "d", "a", "c"), installedFirst(entries).map { it.key })
}
@Test fun librarySourcesFollowTheConfiguredStoreOrderWithSteamFirstAndAddedLast() {
val entries = listOf("added", "gog", "steam", "epic", "xbox").map { LibraryEntry(it, it, it, null, null, true) }
assertEquals(listOf("steam", "xbox", "epic", "gog", "added"), librarySources(entries, listOf("xbox", "epic", "gog")))
}
@Test fun librarySourcesIgnoreUnknownAndDuplicateOrderEntriesAndAppendNewStores() {
val entries = listOf("epic", "gog", "battlenet").map { LibraryEntry(it, it, it, null, null, false) }
assertEquals(listOf("epic", "gog", "battlenet"), librarySources(entries, listOf("missing", "epic", "epic", "amazon")))
}
@Test fun gameKeysNameEitherAnAppOrAStoreProduct() {
GameRef.parse("app:440").let { assertEquals(440, it.appId); assertNull(it.store) }
GameRef.parse("app:-12").let { assertEquals(-12, it.appId) }
@@ -0,0 +1,219 @@
package com.droiddeck.launcher.ui
import androidx.compose.foundation.layout.Box
import androidx.compose.foundation.layout.fillMaxSize
import androidx.compose.runtime.CompositionLocalProvider
import androidx.compose.runtime.getValue
import androidx.compose.runtime.key
import androidx.compose.runtime.mutableIntStateOf
import androidx.compose.runtime.setValue
import androidx.compose.runtime.snapshots.Snapshot
import androidx.compose.ui.Modifier
import androidx.compose.ui.geometry.Offset
import androidx.compose.ui.test.assertIsDisplayed
import androidx.compose.ui.test.assertCountEquals
import androidx.compose.ui.test.onAllNodesWithText
import androidx.compose.ui.test.onNodeWithContentDescription
import androidx.compose.ui.test.onNodeWithTag
import androidx.compose.ui.test.onNodeWithText
import androidx.compose.ui.test.performClick
import com.droiddeck.launcher.frontend.Library
import com.droiddeck.launcher.session.SessionPrefs
import com.droiddeck.launcher.stores.CatalogItem
import com.droiddeck.launcher.stores.CredentialCipher
import com.droiddeck.launcher.stores.Store
import com.droiddeck.launcher.stores.StoreAccounts
import com.droiddeck.launcher.stores.StoresState
import com.droiddeck.launcher.stores.xbox.XboxLibraryFilter
import org.json.JSONObject
import org.junit.After
import org.junit.Assert.assertEquals
import org.junit.Assert.assertFalse
import org.junit.Assert.assertTrue
import org.junit.Before
import org.junit.Rule
import org.junit.Test
import org.junit.runner.RunWith
import org.robolectric.RobolectricTestRunner
import org.robolectric.RuntimeEnvironment
import org.robolectric.annotation.Config
import javax.crypto.spec.SecretKeySpec
@RunWith(RobolectricTestRunner::class)
@Config(sdk = [34], qualifiers = "w1200dp-h752dp-land", application = android.app.Application::class)
class LibraryVisibilityTest {
@get:Rule val compose = createRobolectricComposeRule()
private val ctx get() = RuntimeEnvironment.getApplication()
private var generation by mutableIntStateOf(0)
@Before fun prepare() {
StoreAccounts.keys = CredentialCipher.KeyProvider { SecretKeySpec(ByteArray(32) { 7 }, "AES") }
StoreAccounts.keystoreFailed = false
ctx.getSharedPreferences("session", 0).edit().clear().commit()
LibraryView.source = LIBRARY_ALL
LibraryView.query = ""
LibraryView.focusFirst = false
StoresState.library.clear()
StoresState.accounts.clear()
for (store in listOf(Store.GOG, Store.EPIC)) {
StoreAccounts.write(ctx, store, JSONObject().put("access_token", "test-only").put("display_name", "Library test"))
StoresState.accounts[store] = "Library test"
StoresState.library[store] = listOf(CatalogItem(store, "owned", "Uninstalled ${store.shortLabel}", null, owned = true, sizeBytes = 1024))
}
}
@After fun clear() {
Steps.drop()
XboxLibraryFilter.set(ctx, XboxLibraryFilter.ALL)
for (store in listOf(Store.GOG, Store.EPIC)) StoreAccounts.clear(ctx, store)
StoreAccounts.keys = CredentialCipher.Keystore
StoreAccounts.keystoreFailed = false
StoresState.library.clear()
StoresState.accounts.clear()
ctx.getSharedPreferences("session", 0).edit().clear().commit()
LibraryView.source = LIBRARY_ALL
LibraryView.query = ""
LibraryView.focusFirst = false
}
@Test fun uninstalledGamesAreHiddenUntilSelectedInTheFilterAndTheChoiceSurvivesReopeningLibrary() {
show()
compose.onNodeWithText("Installed Steam game").assertExists()
compose.onNodeWithText("Uninstalled GOG").assertDoesNotExist()
chooseVisibility(true)
compose.onNodeWithText("Uninstalled GOG").assertExists()
assertTrue(SessionPrefs.libraryShowUninstalled(ctx))
compose.runOnIdle { generation++; Snapshot.sendApplyNotifications() }
compose.mainClock.advanceTimeBy(2_000)
compose.onNodeWithText("Uninstalled GOG").assertExists()
chooseVisibility(false)
compose.onNodeWithText("Uninstalled GOG").assertDoesNotExist()
assertFalse(SessionPrefs.libraryShowUninstalled(ctx))
}
@Test fun theFilterExpandsBesideSortWithoutChangingTheSelectionOnOpen() {
show()
val filter = compose.onNodeWithContentDescription("Filter · Installed only")
val sort = compose.onNodeWithContentDescription("Sort")
assertTrue(filter.fetchSemanticsNode().boundsInRoot.right <= sort.fetchSemanticsNode().boundsInRoot.left)
filter.performClick()
compose.mainClock.advanceTimeBy(2_000)
compose.onNodeWithText("Installed only").assertIsDisplayed()
compose.onNodeWithText("All owned games").assertIsDisplayed()
compose.onAllNodesWithText("Filter").assertCountEquals(1)
compose.onNodeWithText("Uninstalled GOG").assertDoesNotExist()
assertFalse(SessionPrefs.libraryShowUninstalled(ctx))
compose.runOnIdle { Steps.fold(); Snapshot.sendApplyNotifications() }
compose.mainClock.advanceTimeBy(1_000)
sort.performClick()
compose.mainClock.advanceTimeBy(2_000)
compose.onAllNodesWithText("Sort").assertCountEquals(1)
compose.onNodeWithText("Recently played").assertIsDisplayed()
}
@Test fun theXboxAccessChoicesShareTheLibraryFilter() {
StoreAccounts.write(ctx, Store.XBOX, JSONObject().put("username", "Library test"))
StoresState.accounts[Store.XBOX] = "Library test"
StoresState.library[Store.XBOX] = listOf(CatalogItem(Store.XBOX, "owned", "Uninstalled Xbox", null, owned = true))
LibraryView.source = Store.XBOX.id
try {
show()
compose.onNodeWithContentDescription("Filter · Installed only").performClick()
compose.mainClock.advanceTimeBy(2_000)
compose.onNodeWithText("Installed only").assertIsDisplayed()
compose.onNodeWithText("All owned games").assertIsDisplayed()
compose.onNodeWithText("Game Pass").assertIsDisplayed().performClick()
compose.mainClock.advanceTimeBy(1_000)
assertEquals(XboxLibraryFilter.GAME_PASS, XboxLibraryFilter.current)
assertFalse(SessionPrefs.libraryShowUninstalled(ctx))
} finally {
StoreAccounts.clear(ctx, Store.XBOX)
}
}
@Test fun aSearchWithOnlyUninstalledMatchesOffersToRevealThem() {
LibraryView.query = "Uninstalled GOG"
show()
compose.onNodeWithText("Uninstalled GOG").assertDoesNotExist()
compose.onNodeWithTag("library-browse-owned").performClick()
compose.mainClock.advanceTimeBy(1_000)
compose.onNodeWithText("Uninstalled GOG").assertExists()
assertEquals("Uninstalled GOG", LibraryView.query)
}
@Test fun aHiddenStoreRemainsReachableInLibraryInItsConfiguredOrder() {
SessionPrefs.setStoresTabOrder(ctx, listOf("epic", "gog"))
SessionPrefs.setStoresTabHidden(ctx, setOf("gog"))
show()
val steam = compose.onNodeWithTag("library-source-steam").fetchSemanticsNode().boundsInRoot.left
val epic = compose.onNodeWithTag("library-source-epic").fetchSemanticsNode().boundsInRoot.left
val gog = compose.onNodeWithTag("library-source-gog").fetchSemanticsNode().boundsInRoot.left
assertTrue(steam < epic && epic < gog)
compose.onNodeWithTag("library-source-gog").performClick()
compose.mainClock.advanceTimeBy(1_000)
compose.onNodeWithTag("library-browse-owned").assertIsDisplayed().performClick()
compose.mainClock.advanceTimeBy(1_000)
compose.onNodeWithText("Uninstalled GOG").assertExists()
}
@Test fun theStoresOwnedGamesLinkRevealsOwnedGamesDespiteTheSavedInstalledOnlyView() {
assertFalse(SessionPrefs.libraryShowUninstalled(ctx))
LibraryView.showOwned(ctx, Store.GOG)
show()
compose.onNodeWithText("Uninstalled GOG").assertExists()
compose.onNodeWithText("Installed Steam game").assertDoesNotExist()
}
@Test fun theStoresOwnedGamesLinkUpdatesALibraryPageThatIsStillComposed() {
LibraryView.source = Store.GOG.id
show()
compose.onNodeWithText("Uninstalled GOG").assertDoesNotExist()
compose.runOnIdle { LibraryView.showOwned(ctx, Store.GOG); Snapshot.sendApplyNotifications() }
compose.mainClock.advanceTimeBy(1_000)
compose.onNodeWithText("Uninstalled GOG").assertExists()
}
private fun show() {
compose.mainClock.autoAdvance = false
compose.setContent { key(generation) {
DroidDeckTheme {
CompositionLocalProvider(LocalFrontFocus provides FrontFocus()) {
FocusGlideHost { Box(Modifier.fillMaxSize()) {
LibraryPage(state(), actions(), "games", {}, Modifier.fillMaxSize())
StepsLayer(Offset.Zero)
} }
}
}
} }
compose.mainClock.advanceTimeBy(2_000)
}
private fun chooseVisibility(show: Boolean) {
compose.onNodeWithContentDescription("Filter · " + if (SessionPrefs.libraryShowUninstalled(ctx)) "All owned games" else "Installed only")
.performClick()
compose.mainClock.advanceTimeBy(2_000)
assertTrue(Steps.open)
compose.onNodeWithText(if (show) "All owned games" else "Installed only")
.performClick()
compose.mainClock.advanceTimeBy(1_000)
assertEquals(show, SessionPrefs.libraryShowUninstalled(ctx))
}
private fun state() = FrontEndState(
installed = "r9", ready = true, available = null, busy = false, stage = "", percent = -1,
desktopInstalled = true, offlineAccount = null, offline = false, frameGenLabel = "",
romsDir = null, logsEnabled = false,
steamGames = listOf(Library.SteamGame(440, "Installed Steam game", null, "internal")),
emulators = emptyList(), running = null,
)
private fun 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 = { _, _ -> },
)
}