From 9e34d7636ffc537f30562f40fea5f7a7068d7af3 Mon Sep 17 00:00:00 2001 From: Altay Date: Sun, 15 Nov 2026 13:10:53 +0300 Subject: [PATCH 1/7] perf(mobile,tv): a page reaches the screen only once its row text is built --- .../io/putdotio/android/design/RowText.kt | 96 ++++++++++++------- .../io/putdotio/android/design/RowTextTest.kt | 13 ++- .../android/files/MobileFilesScreen.kt | 9 +- .../android/search/MobileSearchScreen.kt | 16 +++- .../android/trash/MobileTrashScreen.kt | 21 ++-- .../putdotio/android/MobileTrashScreenTest.kt | 18 ++++ .../putdotio/android/tv/files/TvFilesList.kt | 26 +++-- .../android/tv/files/TvFilesScreen.kt | 16 +++- .../android/tv/search/TvSearchResults.kt | 32 ++++++- .../putdotio/android/tv/trash/TvTrashList.kt | 30 +++--- .../android/tv/trash/TvTrashScreen.kt | 8 +- 11 files changed, 196 insertions(+), 89 deletions(-) diff --git a/core/design/src/main/kotlin/io/putdotio/android/design/RowText.kt b/core/design/src/main/kotlin/io/putdotio/android/design/RowText.kt index 897f567be..7b7f93fa1 100644 --- a/core/design/src/main/kotlin/io/putdotio/android/design/RowText.kt +++ b/core/design/src/main/kotlin/io/putdotio/android/design/RowText.kt @@ -2,14 +2,14 @@ package io.putdotio.android.design import androidx.compose.runtime.Composable import androidx.compose.runtime.LaunchedEffect +import androidx.compose.runtime.SideEffect import androidx.compose.runtime.Stable import androidx.compose.runtime.mutableIntStateOf +import androidx.compose.runtime.mutableStateOf +import androidx.compose.runtime.referentialEqualityPolicy import androidx.compose.runtime.remember -import androidx.compose.runtime.withFrameNanos +import androidx.compose.runtime.snapshots.Snapshot import java.util.concurrent.ConcurrentHashMap -import java.util.concurrent.atomic.AtomicBoolean -import java.util.concurrent.atomic.AtomicLong -import kotlinx.coroutines.Dispatchers import kotlinx.coroutines.currentCoroutineContext import kotlinx.coroutines.delay import kotlinx.coroutines.ensureActive @@ -22,37 +22,46 @@ public class RowText internal constructor( private val placeholder: V, private val build: (T) -> V, ) { - private class Entry(val item: T, val value: V, val refresh: Any?) + internal class Entry(val item: T, val value: V, val refresh: Any?) - @Volatile - private var entries = ConcurrentHashMap>() + private class Prepared( + val items: List, + val entries: Map>, + val previous: Map>, + ) - private val waiting = ConcurrentHashMap() + internal class Batch internal constructor( + internal val items: List, + internal val entries: Map>, + internal val changed: Boolean, + ) - private val prepared = mutableIntStateOf(0) + private val prepared = mutableStateOf?>(null, referentialEqualityPolicy()) - private val generation = AtomicLong() + private val waiting = ConcurrentHashMap() - private val stale = AtomicBoolean() + private val stale = mutableIntStateOf(0) public operator fun get(item: T): V { - prepared.intValue + stale.intValue val key = key(item) - val entry = entries[key]?.takeIf { it.item == item } ?: await(key, item) - return entry?.value ?: placeholder + val shown = Snapshot.withoutReadObservation { prepared.value } + val entry = shown?.entries?.get(key)?.takeIf { it.item == item } + ?: shown?.previous?.get(key)?.takeIf { it.item == item } + ?: return wait(key, item, shown) + return entry.value } - private fun await(key: Any, item: T): Entry? { + private fun wait(key: Any, item: T, shown: Prepared?): V { waiting[key] = item - val entry = entries[key] - if (entry?.item == item) waiting.remove(key, item) - return entry + return shown?.entries?.get(key)?.value ?: placeholder } - internal suspend fun prepare(items: List, refresh: Any?) { - val run = generation.incrementAndGet() - val known = entries - val built = ConcurrentHashMap>(items.size) + public fun isBuiltFor(items: List): Boolean = prepared.value?.items === items + + internal suspend fun prepare(items: List, refresh: Any?): Batch { + val known = Snapshot.withoutReadObservation { prepared.value }?.entries.orEmpty() + val built = HashMap>(items.size) var changed = false items.forEach { item -> currentCoroutineContext().ensureActive() @@ -60,17 +69,35 @@ public class RowText internal constructor( built[key(item)] = old?.takeIf { it.refresh == refresh } ?: Entry(item, build(item), refresh).also { if (old != null && old.value != it.value) changed = true } } - val context = currentCoroutineContext() - synchronized(generation) { - if (run != generation.get() || !context.isActive) return - entries = built - if (waiting.entries.removeIf { (key, item) -> built[key]?.item == item } || changed) stale.set(true) - } + return Batch(items, built, changed) + } + + internal fun show(batch: Batch) { + val previous = prepared.value?.entries.orEmpty() + prepared.value = Prepared(batch.items, batch.entries, previous) + val arrived = waiting.entries.removeIf { (key, item) -> batch.entries[key]?.item == item } + if (arrived || batch.changed) stale.intValue++ } +} + +private class Shown(var source: S?) - internal fun recomposeStaleRows() { - if (stale.getAndSet(false)) prepared.intValue++ +@Composable +public fun RowText.shown(source: S?, items: List, vararg keys: Any?): S? { + val last = remember(*keys) { Shown(null) } + val shown = when { + source == null -> null + isBuiltFor(items) -> source + else -> last.source } + SideEffect { last.source = shown } + return shown +} + +private class Identity(val value: Any) { + override fun equals(other: Any?): Boolean = other is Identity && other.value === value + + override fun hashCode(): Int = System.identityHashCode(value) } @Composable @@ -84,13 +111,12 @@ public fun rememberRowText( build: (T) -> V, ): RowText { val text = remember(*inputs) { RowText(key, placeholder, build) } - LaunchedEffect(text, items, refresh, everyMinute) { - text.recomposeStaleRows() + val dispatcher = LocalBuildDispatcher.current + LaunchedEffect(text, Identity(items), refresh, everyMinute, dispatcher) { while (isActive) { val minute = currentMinute() - withContext(Dispatchers.Default) { text.prepare(items, if (everyMinute) refresh to minute else refresh) } - withFrameNanos {} - text.recomposeStaleRows() + val batch = withContext(dispatcher) { text.prepare(items, if (everyMinute) refresh to minute else refresh) } + text.show(batch) if (!everyMinute) break if (currentMinute() == minute) delay(MINUTE_MILLIS - System.currentTimeMillis() % MINUTE_MILLIS) } diff --git a/core/design/src/test/kotlin/io/putdotio/android/design/RowTextTest.kt b/core/design/src/test/kotlin/io/putdotio/android/design/RowTextTest.kt index 7bd672e01..fed62df7c 100644 --- a/core/design/src/test/kotlin/io/putdotio/android/design/RowTextTest.kt +++ b/core/design/src/test/kotlin/io/putdotio/android/design/RowTextTest.kt @@ -27,7 +27,6 @@ class RowTextTest { invalidated = invalidated || changed.any { it in reads } } prepare() - text.recomposeStaleRows() Snapshot.sendApplyNotifications() observer.dispose() return invalidated @@ -38,30 +37,30 @@ class RowTextTest { assertEquals("", text[Row(1, "a")]) assertEquals(emptyList(), built) - assertTrue(recomposesRowsAfter { text.prepare(listOf(Row(1, "a"), Row(2, "b")), refresh = null) }) + assertTrue(recomposesRowsAfter { text.show(text.prepare(listOf(Row(1, "a"), Row(2, "b")), refresh = null)) }) assertEquals("a text", text[Row(1, "a")]) } @Test fun aChangedRowKeepsItsOldTextUntilTheNewTextIsBuilt() = runTest { - text.prepare(listOf(Row(1, "a")), refresh = null) + text.show(text.prepare(listOf(Row(1, "a")), refresh = null)) built.clear() assertEquals("a text", text[Row(1, "renamed")]) assertEquals(emptyList(), built) - text.prepare(listOf(Row(1, "renamed")), refresh = null) + text.show(text.prepare(listOf(Row(1, "renamed")), refresh = null)) assertEquals("renamed text", text[Row(1, "renamed")]) } @Test fun aRefreshRecomposesRowsOnlyWhenTheirTextChanges() = runTest { - text.prepare(listOf(Row(1, "a")), refresh = 1) + text.show(text.prepare(listOf(Row(1, "a")), refresh = 1)) - assertFalse(recomposesRowsAfter { text.prepare(listOf(Row(1, "a")), refresh = 2) }) + assertFalse(recomposesRowsAfter { text.show(text.prepare(listOf(Row(1, "a")), refresh = 2)) }) suffix = "later" - assertTrue(recomposesRowsAfter { text.prepare(listOf(Row(1, "a")), refresh = 3) }) + assertTrue(recomposesRowsAfter { text.show(text.prepare(listOf(Row(1, "a")), refresh = 3)) }) assertEquals("a later", text[Row(1, "a")]) } } diff --git a/mobile/src/main/kotlin/io/putdotio/android/files/MobileFilesScreen.kt b/mobile/src/main/kotlin/io/putdotio/android/files/MobileFilesScreen.kt index 3ce5ac235..803d527c5 100644 --- a/mobile/src/main/kotlin/io/putdotio/android/files/MobileFilesScreen.kt +++ b/mobile/src/main/kotlin/io/putdotio/android/files/MobileFilesScreen.kt @@ -70,6 +70,7 @@ import io.putdotio.android.LoadNextPageNow import io.putdotio.android.MobileInlineError import io.putdotio.android.RetryWhenOnline import io.putdotio.android.design.RowText +import io.putdotio.android.design.shown import io.putdotio.android.isUnreachable import io.putdotio.android.MobileErrorState import io.putdotio.android.MobileKeyCommand @@ -424,17 +425,19 @@ private fun MobileRefreshableFilesContent( is FilesContent.Ready -> { val rowText = rememberFilesRowText(content.items) val pinnedText = rememberFilesRowText(headers.pinned) + val shownContent = rowText.shown(content, content.items) ?: return@PullToRefreshBox + val shownHeaders = pinnedText.shown(headers, headers.pinned) ?: return@PullToRefreshBox // The depth tells a folder opened from Search apart from the same folder under it. A // header set that grew or shrank restarts the list from the row-relative viewport. key( state.stack.size, state.current.folder.id.value, state.current.viewportGeneration, - headers.itemCount, + shownHeaders.itemCount, ) { MobileFilesList( - content = content, - headers = headers, + content = shownContent, + headers = shownHeaders, onPlayEntry = { onPlayMedia(it.toFilesItem()) }, onRemoveEntry = hideStarted, rowText = rowText, diff --git a/mobile/src/main/kotlin/io/putdotio/android/search/MobileSearchScreen.kt b/mobile/src/main/kotlin/io/putdotio/android/search/MobileSearchScreen.kt index ec14cff30..7d48e5ab7 100644 --- a/mobile/src/main/kotlin/io/putdotio/android/search/MobileSearchScreen.kt +++ b/mobile/src/main/kotlin/io/putdotio/android/search/MobileSearchScreen.kt @@ -58,6 +58,8 @@ import io.putdotio.android.MobileRow import io.putdotio.android.MobileSectionLabel import io.putdotio.android.PutioFailure import io.putdotio.android.R +import io.putdotio.android.design.RowText +import io.putdotio.android.design.shown import io.putdotio.android.design.PutioEmptyGlyph import io.putdotio.android.design.PutioEmptyState import io.putdotio.android.design.putioMono @@ -391,10 +393,22 @@ private fun MobileSearchResults( onNextPage: () -> Unit, onRetry: () -> Unit, modifier: Modifier = Modifier, +) { + val rowText = rememberFilesRowText(content.items, dated = false) + MobileSearchResultList(rowText.shown(content, content.items) ?: return, rowText, rows, onNextPage, onRetry, modifier) +} + +@Composable +private fun MobileSearchResultList( + content: SearchContent.Ready, + rowText: RowText, + rows: MobileSearchRows, + onNextPage: () -> Unit, + onRetry: () -> Unit, + modifier: Modifier, ) { val (folders, files) = remember(content.items) { content.items.partition(FilesItem::isFolder) } val rootName = stringResource(R.string.mobile_destination_files) - val rowText = rememberFilesRowText(content.items, dated = false) val listState = rememberLazyListState() LoadNextPageNearEnd(listState, nextPage = content.paging as? SearchPaging.Available, onLoadNextPage = onNextPage) LazyColumn(state = listState, modifier = modifier.testTag(MOBILE_SEARCH_RESULTS_TAG)) { diff --git a/mobile/src/main/kotlin/io/putdotio/android/trash/MobileTrashScreen.kt b/mobile/src/main/kotlin/io/putdotio/android/trash/MobileTrashScreen.kt index 95c66a9b9..70c439c9a 100644 --- a/mobile/src/main/kotlin/io/putdotio/android/trash/MobileTrashScreen.kt +++ b/mobile/src/main/kotlin/io/putdotio/android/trash/MobileTrashScreen.kt @@ -21,6 +21,7 @@ import io.putdotio.android.MobileSelectionCheckbox import io.putdotio.android.MobileSelectionToolbarClearance import io.putdotio.android.design.RowText import io.putdotio.android.design.rememberRowText +import io.putdotio.android.design.shown import io.putdotio.android.files.FilesItemId import androidx.compose.foundation.layout.Arrangement import androidx.compose.foundation.layout.Column @@ -101,7 +102,10 @@ internal fun MobileTrashScreen( TrashSelectionEffects(state, selection) val sheetItem = (state.content as? TrashContent.Loaded)?.items?.firstOrNull { it.id.value == sheetItemId } val listState = rememberLazyListState() - val rowText = rememberTrashRowText((state.content as? TrashContent.Loaded)?.items.orEmpty()) + val loaded = state.content as? TrashContent.Loaded + val loadedItems = loaded?.items.orEmpty() + val rowText = rememberTrashRowText(loadedItems) + val shown = rowText.shown(loaded, loadedItems) val states = rememberUpdatedState(state) val checked = selected.takeIf { inSelection } val rowHandlers = remember(selection, checked, rowText) { @@ -117,7 +121,7 @@ internal fun MobileTrashScreen( ScrollToNewOutcome(state, listState) LoadNextPageNearEnd( listState = listState, - nextPage = state.nextPageCursor, + nextPage = state.nextPageCursor.takeIf { shown === loaded }, onLoadNextPage = { onEvent(TrashEvent.LoadNextPage) }, threshold = TRASH_PAGING_THRESHOLD, ) @@ -144,17 +148,14 @@ internal fun MobileTrashScreen( } } when (val content = state.content) { - TrashContent.Loading -> item(key = "loading") { - MobileLoadingState(stringResource(R.string.mobile_trash_loading)) - } is TrashContent.Error -> item(key = "error") { TrashReadFailure(content.failure) { onEvent(TrashEvent.Retry) } } - is TrashContent.Loaded -> loadedTrashItems( - content, - onEvent, - rowHandlers, - ) + TrashContent.Loading, is TrashContent.Loaded -> shown?.let { + loadedTrashItems(it, onEvent, rowHandlers) + } ?: item(key = "loading") { + MobileLoadingState(stringResource(R.string.mobile_trash_loading)) + } } } } diff --git a/mobile/src/test/kotlin/io/putdotio/android/MobileTrashScreenTest.kt b/mobile/src/test/kotlin/io/putdotio/android/MobileTrashScreenTest.kt index d187c158e..774932d4d 100644 --- a/mobile/src/test/kotlin/io/putdotio/android/MobileTrashScreenTest.kt +++ b/mobile/src/test/kotlin/io/putdotio/android/MobileTrashScreenTest.kt @@ -1,5 +1,6 @@ package io.putdotio.android +import androidx.compose.runtime.CompositionLocalProvider import androidx.compose.runtime.getValue import androidx.compose.runtime.mutableStateOf import androidx.compose.runtime.setValue @@ -16,6 +17,7 @@ import androidx.compose.ui.test.performScrollToNode import androidx.compose.ui.test.performTouchInput import androidx.compose.ui.test.swipeDown import androidx.test.ext.junit.runners.AndroidJUnit4 +import io.putdotio.android.design.LocalBuildDispatcher import io.putdotio.android.design.PutioTheme import io.putdotio.android.files.FilesCursor import io.putdotio.android.files.FilesItem @@ -38,6 +40,7 @@ import io.putdotio.android.trash.TrashState import io.putdotio.sdk.errors.PutioConfigurationException import io.putdotio.sdk.files.PutioFileType import java.time.LocalDate +import kotlinx.coroutines.test.StandardTestDispatcher import org.junit.Assert.assertEquals import org.junit.Rule import org.junit.Test @@ -55,6 +58,21 @@ class MobileTrashScreenTest { "2026-09-06T00:00:00Z", "2026-09-20") private val loaded = TrashContent.Loaded(listOf(item), null, 1, 12) + @Test + fun aLoadedPageComposesNoRowBeforeItsTextIsBuilt() { + val build = StandardTestDispatcher() + compose.setContent { + CompositionLocalProvider(LocalBuildDispatcher provides build) { + PutioTheme { MobileTrashScreen(TrashState(content = loaded), { true }) } + } + } + compose.onNodeWithText(item.name).assertDoesNotExist() + + compose.runOnIdle { build.scheduler.advanceUntilIdle() } + compose.onNodeWithTag(MOBILE_TRASH_LIST_TAG).performScrollToNode(hasText(item.name)) + compose.onNodeWithText(item.name).assertIsDisplayed() + } + @Test fun queuedAndUnknownResultsOfferOnlyReadRecoveryAndDisableTheStaleRow() { val events = mutableListOf() diff --git a/tv/src/main/kotlin/io/putdotio/android/tv/files/TvFilesList.kt b/tv/src/main/kotlin/io/putdotio/android/tv/files/TvFilesList.kt index 8ae6d3e35..e08493742 100644 --- a/tv/src/main/kotlin/io/putdotio/android/tv/files/TvFilesList.kt +++ b/tv/src/main/kotlin/io/putdotio/android/tv/files/TvFilesList.kt @@ -32,6 +32,7 @@ import androidx.compose.ui.focus.focusRestorer import androidx.compose.ui.focus.onFocusChanged import androidx.compose.ui.platform.LocalContext import androidx.compose.ui.platform.testTag +import io.putdotio.android.design.RowText import io.putdotio.android.design.rememberRowText import io.putdotio.android.files.FilesBrowserEvent import io.putdotio.android.files.FilesContent @@ -49,10 +50,25 @@ import kotlin.math.abs import kotlinx.coroutines.flow.filterNotNull import kotlinx.coroutines.flow.first +@Composable +internal fun rememberTvFilesRowText(items: List): RowText { + val context = LocalContext.current + return rememberRowText( + items, + context, + key = { it.id.value }, + placeholder = TvFilesRowText.Pending, + everyMinute = true, + ) { + it.rowText(context, TvFilesRowPlace.Listing, System.currentTimeMillis()) + } +} + @Composable internal fun TvFilesList( folderId: Long, content: FilesContent.Ready, + rowText: RowText, pagingEnabled: Boolean, focusMemory: MutableMap, paneHasFocus: State, @@ -175,16 +191,6 @@ internal fun TvFilesList( nearEnd = { listState.isNearEnd(content.items.lastIndex) }, ) val names = remember(content.items) { content.items.map { it.name } } - val context = LocalContext.current - val rowText = rememberRowText( - content.items, - context, - key = { it.id.value }, - placeholder = TvFilesRowText.Pending, - everyMinute = true, - ) { - it.rowText(context, TvFilesRowPlace.Listing, System.currentTimeMillis()) - } RevealOnlyHiddenRows(names) { LazyColumn( state = listState, diff --git a/tv/src/main/kotlin/io/putdotio/android/tv/files/TvFilesScreen.kt b/tv/src/main/kotlin/io/putdotio/android/tv/files/TvFilesScreen.kt index 5e9c2c249..470d0c5a4 100644 --- a/tv/src/main/kotlin/io/putdotio/android/tv/files/TvFilesScreen.kt +++ b/tv/src/main/kotlin/io/putdotio/android/tv/files/TvFilesScreen.kt @@ -49,6 +49,7 @@ import androidx.tv.material3.Icon import androidx.tv.material3.MaterialTheme import androidx.tv.material3.Text import io.putdotio.android.R +import io.putdotio.android.design.shown import io.putdotio.android.design.PutioEmptyGlyph import io.putdotio.android.design.RowText import io.putdotio.android.files.FilesBrowserEvent @@ -570,10 +571,15 @@ private fun TvFilesRows( modifier: Modifier = Modifier, ) { val folderId = current.folder.id.value - when (val content = current.content) { - is FilesContent.Ready -> TvFilesList( + val content = current.content + val ready = content as? FilesContent.Ready + val rowText = rememberTvFilesRowText(ready?.items.orEmpty()) + val shown = rowText.shown(ready, ready?.items.orEmpty(), folderId) + when { + shown != null -> TvFilesList( folderId = folderId, - content = content, + content = shown, + rowText = rowText, pagingEnabled = current.operation.canStartOperation, focusMemory = focusMemory, paneHasFocus = paneHasFocus, @@ -589,11 +595,11 @@ private fun TvFilesRows( onRowFocused = onRowFocused, rowsShowFocus = rowsShowFocus, ) - is FilesContent.Loading -> { + ready != null || content is FilesContent.Loading -> { LaunchedEffect(folderId) { if (paneHasFocus.value) skeletonFocus.requestFocus() } TvListSkeleton(modifier.focusRequester(skeletonFocus).focusable()) } - is FilesContent.Empty, is FilesContent.Failed -> Unit + else -> Unit } } diff --git a/tv/src/main/kotlin/io/putdotio/android/tv/search/TvSearchResults.kt b/tv/src/main/kotlin/io/putdotio/android/tv/search/TvSearchResults.kt index 1d6fce587..a5749b035 100644 --- a/tv/src/main/kotlin/io/putdotio/android/tv/search/TvSearchResults.kt +++ b/tv/src/main/kotlin/io/putdotio/android/tv/search/TvSearchResults.kt @@ -36,11 +36,14 @@ import androidx.tv.material3.MaterialTheme import androidx.tv.material3.Text import io.putdotio.android.R import io.putdotio.android.design.PutioTypeScale +import io.putdotio.android.design.RowText import io.putdotio.android.design.rememberRowText +import io.putdotio.android.design.shown import io.putdotio.android.files.FilesFolder import io.putdotio.android.files.FilesItem import io.putdotio.android.files.FilesItemId import io.putdotio.android.search.SearchPaging +import io.putdotio.android.tv.TvListSkeleton import io.putdotio.android.tv.ProvideMiddleCuts import io.putdotio.android.tv.TvAutoPaging import io.putdotio.android.tv.TvFocusedItem @@ -93,7 +96,6 @@ internal class TvSearchGroups(items: List) { } } -@OptIn(ExperimentalComposeUiApi::class) @Composable internal fun TvSearchResultList( groups: TvSearchGroups, @@ -106,13 +108,11 @@ internal fun TvSearchResultList( listFocus: FocusRequester, modifier: Modifier = Modifier, ) { - val items = groups.ordered - val names = remember(items) { items.map { it.name } } val context = LocalContext.current val currentRows by rememberUpdatedState(rows) val folders = rows.folderNames to rows.rootName val rowText = rememberRowText( - items, + groups.ordered, context, key = { it.id.value }, placeholder = TvFilesRowText.Pending, @@ -120,6 +120,30 @@ internal fun TvSearchResultList( ) { it.rowText(context, currentRows.place(it), System.currentTimeMillis()) } + val shown = rowText.shown(groups, groups.ordered) + if (shown == null) { + TvListSkeleton(modifier) + return + } + TvSearchResultRows(shown, rowText, paging, restoreRowId, rows, onNextPage, onRetry, owner, listFocus, modifier) +} + +@OptIn(ExperimentalComposeUiApi::class) +@Composable +private fun TvSearchResultRows( + groups: TvSearchGroups, + rowText: RowText, + paging: SearchPaging, + restoreRowId: Long?, + rows: TvSearchRows, + onNextPage: () -> Unit, + onRetry: () -> Unit, + owner: TvPaneFocusOwner, + listFocus: FocusRequester, + modifier: Modifier, +) { + val items = groups.ordered + val names = remember(items) { items.map { it.name } } val rowFocus = remember { TvItemRequesters() } val lastRow = remember { FocusRequester() } val pagingHeldFocus = remember { mutableStateOf(false) } diff --git a/tv/src/main/kotlin/io/putdotio/android/tv/trash/TvTrashList.kt b/tv/src/main/kotlin/io/putdotio/android/tv/trash/TvTrashList.kt index 91fbe6aa5..1a4c27ae0 100644 --- a/tv/src/main/kotlin/io/putdotio/android/tv/trash/TvTrashList.kt +++ b/tv/src/main/kotlin/io/putdotio/android/tv/trash/TvTrashList.kt @@ -29,6 +29,7 @@ import androidx.compose.ui.res.stringResource import androidx.compose.ui.text.AnnotatedString import io.putdotio.android.R import io.putdotio.android.design.fileTypeIconRes +import io.putdotio.android.design.RowText import io.putdotio.android.design.rememberRowText import io.putdotio.android.files.formatFileSize import io.putdotio.android.trash.TrashContent @@ -58,10 +59,27 @@ import kotlinx.coroutines.flow.first internal const val TV_TRASH_LIST_TAG = "tv-trash-list" internal const val TV_TRASH_ROW_TAG = "tv-trash-row" +@Composable +internal fun rememberTvTrashRowMeta(items: List): RowText { + val resources = LocalResources.current + val today = LocalTrashToday.current + val currentToday by rememberUpdatedState(today) + return rememberRowText( + items, + resources, + key = { it.id.value }, + placeholder = TvRowMeta.Pending, + refresh = today, + ) { + it.rowMeta(resources, currentToday) + } +} + @OptIn(ExperimentalComposeUiApi::class) @Composable internal fun TvTrashList( content: TrashContent.Loaded, + rowMeta: RowText, restoreRowId: Long?, onChoose: (TrashItem) -> Unit, onRowFocusChanged: (TrashItem, Boolean) -> Unit, @@ -72,18 +90,6 @@ internal fun TvTrashList( ) { val items = content.items val names = remember(items) { items.map { it.name } } - val resources = LocalResources.current - val today = LocalTrashToday.current - val currentToday by rememberUpdatedState(today) - val rowMeta = rememberRowText( - items, - resources, - key = { it.id.value }, - placeholder = TvRowMeta.Pending, - refresh = today, - ) { - it.rowMeta(resources, currentToday) - } val rows = remember { TrashRowFocus() } val pagingFocus = remember { FocusRequester() } val pagingHeldFocus = remember { mutableStateOf(false) } diff --git a/tv/src/main/kotlin/io/putdotio/android/tv/trash/TvTrashScreen.kt b/tv/src/main/kotlin/io/putdotio/android/tv/trash/TvTrashScreen.kt index 6952baf46..35396b207 100644 --- a/tv/src/main/kotlin/io/putdotio/android/tv/trash/TvTrashScreen.kt +++ b/tv/src/main/kotlin/io/putdotio/android/tv/trash/TvTrashScreen.kt @@ -45,6 +45,7 @@ import androidx.tv.material3.Icon import androidx.tv.material3.MaterialTheme import androidx.tv.material3.Text import io.putdotio.android.R +import io.putdotio.android.design.shown import io.putdotio.android.design.PutioEmptyGlyph import io.putdotio.android.design.PutioTypeScale import io.putdotio.android.trash.TrashContent @@ -255,11 +256,14 @@ private fun TvTrashListDetail( refreshFocus = focus.refresh, ) TvTrashNotices(state, onEvent, listFocus.owner) - if (loaded == null) { + val rowMeta = rememberTvTrashRowMeta(loaded?.items.orEmpty()) + val shown = rowMeta.shown(loaded, loaded?.items.orEmpty()) + if (shown == null) { TvListSkeleton() } else { TvTrashList( - content = loaded, + content = shown, + rowMeta = rowMeta, restoreRowId = restoreRowId, onChoose = { if (state.canRestore(it.id)) onEvent(TrashEvent.Restore(it.id)) }, onRowFocusChanged = { item, focused -> From 4f1dc555d6f076972067786fae3cc99bfb7eada7 Mon Sep 17 00:00:00 2001 From: Altay Date: Sun, 15 Nov 2026 13:14:39 +0300 Subject: [PATCH 2/7] test(mobile): build row text in step with composition --- .../kotlin/io/putdotio/android/AwaitText.kt | 9 +++ .../android/MobileAccountLargeTextTest.kt | 4 +- .../android/MobileAccountListDetailTest.kt | 2 +- .../android/MobileAccountScreenTest.kt | 6 +- .../android/MobileAdaptiveNavigationTest.kt | 4 +- .../android/MobileCastLocalNetworkTest.kt | 2 +- .../android/MobileCastPlaybackTest.kt | 16 ++--- .../android/MobileContentStateTest.kt | 4 +- .../android/MobileDownloadsScreenTest.kt | 30 ++++---- .../android/MobileFilesActionsSheetTest.kt | 18 ++--- .../putdotio/android/MobileFilesBarsTest.kt | 2 +- .../putdotio/android/MobileFilesCopyTest.kt | 14 ++-- .../putdotio/android/MobileFilesDeleteTest.kt | 20 +++--- .../android/MobileFilesListDetailTest.kt | 6 +- .../android/MobileFilesMoveLayoutTest.kt | 2 +- .../android/MobileFilesMoveNavigationTest.kt | 2 +- .../putdotio/android/MobileFilesMoveTest.kt | 28 ++++---- .../putdotio/android/MobileFilesRenameTest.kt | 10 +-- .../putdotio/android/MobileFilesScreenTest.kt | 62 ++++++++-------- .../android/MobileFilesSelectionTest.kt | 2 +- .../MobileInactiveAccountNoticeTest.kt | 6 +- .../putdotio/android/MobileItemDialogsTest.kt | 6 +- .../android/MobileKeyboardShortcutsTest.kt | 2 +- .../android/MobileLoggedInAppsTest.kt | 4 +- .../android/MobileMiddleCutTextLinesTest.kt | 2 +- .../android/MobileOriginalFallbackTest.kt | 2 +- .../MobilePlaybackConfigIntegrationTest.kt | 2 +- .../android/MobilePlaybackOptionsTest.kt | 24 +++---- .../android/MobilePlayerChromeTest.kt | 18 ++--- .../android/MobilePlayerScreenTest.kt | 70 +++++++++---------- .../MobileProductAnalyticsPromptTest.kt | 8 +-- .../putdotio/android/MobilePublicLinksTest.kt | 16 ++--- .../android/MobileResumePlaybackDialogTest.kt | 2 +- .../android/MobileRetryWhenOnlineTest.kt | 2 +- .../android/MobileSearchScreensLayoutTest.kt | 2 +- .../android/MobileSearchScreensTest.kt | 14 ++-- .../android/MobileShellDownloadsTest.kt | 2 +- .../android/MobileShellLinkActionsTest.kt | 2 +- .../io/putdotio/android/MobileShellTest.kt | 70 +++++++++---------- .../android/MobileShortWindowChromeTest.kt | 4 +- .../android/MobileSubtitleControlsTest.kt | 18 ++--- .../android/MobileTransferDropTest.kt | 2 +- .../android/MobileTransfersAddSheetTest.kt | 28 ++++---- .../android/MobileTransfersLayoutTest.kt | 8 +-- .../android/MobileTransfersScreenTest.kt | 10 +-- .../android/MobileTrashActionsScreenTest.kt | 10 +-- .../putdotio/android/MobileTrashLayoutTest.kt | 4 +- .../putdotio/android/MobileTrashScreenTest.kt | 26 +++---- .../MobileTrashSessionIntegrationTest.kt | 2 +- .../android/MobileWelcomeScreenTest.kt | 10 +-- .../files/MobileContinueWatchingRowTest.kt | 2 +- .../android/files/MobilePinnedSectionTest.kt | 6 +- .../playback/MobileConversionVlcTest.kt | 4 +- .../viewer/MobileFileViewerLayoutTest.kt | 2 +- .../viewer/MobileFileViewerPagingTest.kt | 2 +- .../viewer/MobileViewerLoadFailureTest.kt | 2 +- .../android/viewer/MobileViewerZoomTest.kt | 14 ++-- .../android/tv/files/TvFilesScreen.kt | 1 + .../android/tv/search/TvSearchResults.kt | 4 +- 59 files changed, 335 insertions(+), 321 deletions(-) diff --git a/mobile/src/test/kotlin/io/putdotio/android/AwaitText.kt b/mobile/src/test/kotlin/io/putdotio/android/AwaitText.kt index 340408a73..86b05fa7f 100644 --- a/mobile/src/test/kotlin/io/putdotio/android/AwaitText.kt +++ b/mobile/src/test/kotlin/io/putdotio/android/AwaitText.kt @@ -1,9 +1,18 @@ package io.putdotio.android +import androidx.compose.runtime.Composable +import androidx.compose.runtime.CompositionLocalProvider import androidx.compose.ui.test.junit4.ComposeContentTestRule import androidx.compose.ui.test.onAllNodesWithText +import io.putdotio.android.design.LocalBuildDispatcher +import kotlinx.coroutines.Dispatchers internal fun ComposeContentTestRule.awaitText(text: String, substring: Boolean = false) = waitUntil(30_000L) { onAllNodesWithText(text, substring = substring, useUnmergedTree = true).fetchSemanticsNodes().isNotEmpty() } + +/** [content] with row text built in step with composition, as the TV tests' `setTvContent` does. */ +internal fun ComposeContentTestRule.setBuiltContent(content: @Composable () -> Unit) { + setContent { CompositionLocalProvider(LocalBuildDispatcher provides Dispatchers.Unconfined, content = content) } +} diff --git a/mobile/src/test/kotlin/io/putdotio/android/MobileAccountLargeTextTest.kt b/mobile/src/test/kotlin/io/putdotio/android/MobileAccountLargeTextTest.kt index ef7cbd6fb..513a23a5c 100644 --- a/mobile/src/test/kotlin/io/putdotio/android/MobileAccountLargeTextTest.kt +++ b/mobile/src/test/kotlin/io/putdotio/android/MobileAccountLargeTextTest.kt @@ -84,7 +84,7 @@ class MobileAccountLargeTextTest { @Test fun privacyControlsPageKeepsStrictlyNecessaryReadableAndUntoggleable() { - compose.setContent { + compose.setBuiltContent { PutioTheme { MobilePrivacyControlsScreen(settingsState = readyAccountSettingsState(), onSettingsEvent = {}) } @@ -218,7 +218,7 @@ class MobileAccountLargeTextTest { settingsEvents: MutableList = mutableListOf(), configEvents: MutableList = mutableListOf(), ) { - compose.setContent { + compose.setBuiltContent { PutioTheme { MobileAccountScreen( account = MobileAccount(userId = 42, username = "proof", email = "proof@example.com"), diff --git a/mobile/src/test/kotlin/io/putdotio/android/MobileAccountListDetailTest.kt b/mobile/src/test/kotlin/io/putdotio/android/MobileAccountListDetailTest.kt index 64444bf03..0f5da90b6 100644 --- a/mobile/src/test/kotlin/io/putdotio/android/MobileAccountListDetailTest.kt +++ b/mobile/src/test/kotlin/io/putdotio/android/MobileAccountListDetailTest.kt @@ -35,7 +35,7 @@ class MobileAccountListDetailTest { fun crossingTheBreakpointKeepsTheOpenPagesState() { var wide by mutableStateOf(false) val panes = MobileAccountPanes(listTopBar = {}, pageTopBar = {}) - compose.setContent { + compose.setBuiltContent { PutioTheme { Box(Modifier.requiredSize(width = if (wide) 1184.dp else 600.dp, height = 700.dp)) { MobileAccountListDetail( diff --git a/mobile/src/test/kotlin/io/putdotio/android/MobileAccountScreenTest.kt b/mobile/src/test/kotlin/io/putdotio/android/MobileAccountScreenTest.kt index 217c7d129..edaae4eb0 100644 --- a/mobile/src/test/kotlin/io/putdotio/android/MobileAccountScreenTest.kt +++ b/mobile/src/test/kotlin/io/putdotio/android/MobileAccountScreenTest.kt @@ -844,7 +844,7 @@ class MobileAccountAboutTest { @Test fun appInfoCopiesSupportTextToTheClipboard() { - compose.setContent { PutioTheme { MobileAppInfoScreen(diagnostics(readyAndroidAppConfigState())) } } + compose.setBuiltContent { PutioTheme { MobileAppInfoScreen(diagnostics(readyAndroidAppConfigState())) } } compose.onNodeWithTag(MOBILE_APP_INFO_TAG).assertIsDisplayed() compose.onNodeWithText("Android API level").assertIsDisplayed() compose.onNodeWithText("Phone").assertIsDisplayed() @@ -873,7 +873,7 @@ class MobileAccountAboutTest { @Test fun copiedConfirmationResetsWhenTheSupportTextChanges() { var appConfigState by mutableStateOf(readyAndroidAppConfigState()) - compose.setContent { PutioTheme { MobileAppInfoScreen(diagnostics(appConfigState)) } } + compose.setBuiltContent { PutioTheme { MobileAppInfoScreen(diagnostics(appConfigState)) } } val clipboard = ApplicationProvider.getApplicationContext() .getSystemService(android.content.ClipboardManager::class.java) clipboard.clearPrimaryClip() @@ -913,7 +913,7 @@ class MobileAccountAboutTest { @Test fun appInfoReportsTheDeviceClassTheShellPassesIn() { - compose.setContent { + compose.setBuiltContent { PutioTheme { MobileAppInfoScreen(diagnostics(readyAndroidAppConfigState(), AppDiagnostics.DeviceClass.Tablet)) } diff --git a/mobile/src/test/kotlin/io/putdotio/android/MobileAdaptiveNavigationTest.kt b/mobile/src/test/kotlin/io/putdotio/android/MobileAdaptiveNavigationTest.kt index 124e1db52..8bcd54314 100644 --- a/mobile/src/test/kotlin/io/putdotio/android/MobileAdaptiveNavigationTest.kt +++ b/mobile/src/test/kotlin/io/putdotio/android/MobileAdaptiveNavigationTest.kt @@ -267,7 +267,7 @@ class MobileNavigationContainerTest { var layout by mutableStateOf(MobileNavigationLayout.Bar) var created = 0 var disposed = 0 - compose.setContent { + compose.setBuiltContent { PutioTheme { MobileNavigationContainer(layout, MobileDestination.Files, onDestination = {}) { DisposableEffect(Unit) { @@ -329,7 +329,7 @@ abstract class NavigationShellFixture(fontScale: Float) { playbackPlayerFactory: MobilePlayerFactory = NoAudioSessionFactory, ) { val files = navigationFiles(nested) - compose.setContent { + compose.setBuiltContent { backOwner = checkNotNull(LocalOnBackPressedDispatcherOwner.current) host = LocalView.current pixelsPerDp = LocalDensity.current.density diff --git a/mobile/src/test/kotlin/io/putdotio/android/MobileCastLocalNetworkTest.kt b/mobile/src/test/kotlin/io/putdotio/android/MobileCastLocalNetworkTest.kt index afea9ec17..1f4d87cc0 100644 --- a/mobile/src/test/kotlin/io/putdotio/android/MobileCastLocalNetworkTest.kt +++ b/mobile/src/test/kotlin/io/putdotio/android/MobileCastLocalNetworkTest.kt @@ -128,7 +128,7 @@ class MobileCastLocalNetworkTest { } private fun setButton() { - compose.setContent { + compose.setBuiltContent { CompositionLocalProvider( LocalActivityResultRegistryOwner provides object : ActivityResultRegistryOwner { override val activityResultRegistry = registry diff --git a/mobile/src/test/kotlin/io/putdotio/android/MobileCastPlaybackTest.kt b/mobile/src/test/kotlin/io/putdotio/android/MobileCastPlaybackTest.kt index 60e9d665d..1e516f84d 100644 --- a/mobile/src/test/kotlin/io/putdotio/android/MobileCastPlaybackTest.kt +++ b/mobile/src/test/kotlin/io/putdotio/android/MobileCastPlaybackTest.kt @@ -82,7 +82,7 @@ class MobileCastPlaybackTest { fun aScreenOnAVideoThatFinishesOnTheReceiverFollowsItToTheNextEpisode() { val account = EpisodesAccount() cast.autoplay.follow(SESSION, account) - compose.setContent { + compose.setBuiltContent { val state by playback.state.collectAsState() PutioTheme { MobilePlayerScreen( @@ -125,7 +125,7 @@ class MobileCastPlaybackTest { @Test fun aLookupThatFailsForAMomentCastsOnTryAgain() { var lookups = 0 - compose.setContent { + compose.setBuiltContent { val state by playback.state.collectAsState() PutioTheme { MobilePlayerScreen( @@ -159,7 +159,7 @@ class MobileCastPlaybackTest { @Test fun aReceiverThatFailsToLoadTheFileLoadsItAgainOnTryAgain() { - compose.setContent { + compose.setBuiltContent { val state by playback.state.collectAsState() PutioTheme { MobilePlayerScreen( @@ -188,7 +188,7 @@ class MobileCastPlaybackTest { @Test fun anHlsVideoAsksTheReceiverForThePlaylistSubtitleTheAccountSelects() { val hls = PlaybackController(Episode1, HlsEpisode, scope) - compose.setContent { + compose.setBuiltContent { val state by hls.state.collectAsState() PutioTheme { MobilePlayerScreen( @@ -228,7 +228,7 @@ class MobileCastPlaybackTest { } } try { - compose.setContent { + compose.setBuiltContent { val state by audio.state.collectAsState() PutioTheme { MobilePlayerScreen( @@ -262,7 +262,7 @@ class MobileCastPlaybackTest { fun aStreamedOriginalVideoWaitsForItsConversionInsteadOfReachingTheReceiver() { val repository = UnconvertedMkv() val original = PlaybackController(Mkv, repository, scope) - compose.setContent { + compose.setBuiltContent { val state by original.state.collectAsState() PutioTheme { MobilePlayerScreen( @@ -294,7 +294,7 @@ class MobileCastPlaybackTest { fun aDirectPlayOriginalWithNoConvertedCopyCastsAsStandard() { val repository = OriginalWithoutConvertedCopy() val original = PlaybackController(Mp4, repository, scope) - compose.setContent { + compose.setBuiltContent { val state by original.state.collectAsState() PutioTheme { MobilePlayerScreen( @@ -380,7 +380,7 @@ class MobileCastPlaybackTest { playerFactory: MobilePlayerFactory = NoLocalPlayer, castMedia: suspend (PlaybackSource?, String?) -> PlaybackRepositoryResult, ) { - compose.setContent { + compose.setBuiltContent { val state by playback.state.collectAsState() PutioTheme { MobilePlayerScreen( diff --git a/mobile/src/test/kotlin/io/putdotio/android/MobileContentStateTest.kt b/mobile/src/test/kotlin/io/putdotio/android/MobileContentStateTest.kt index 19efb274f..df35efaf6 100644 --- a/mobile/src/test/kotlin/io/putdotio/android/MobileContentStateTest.kt +++ b/mobile/src/test/kotlin/io/putdotio/android/MobileContentStateTest.kt @@ -37,7 +37,7 @@ class MobileContentStateTest { @Test fun loadingStateIsAnnounced() { - compose.setContent { MobileLoadingState(message = "Loading files") } + compose.setBuiltContent { MobileLoadingState(message = "Loading files") } compose.onAllNodesWithText("Loading files").assertCountEquals(1) compose.onAllNodesWithContentDescription("Loading files").assertCountEquals(0) @@ -49,7 +49,7 @@ class MobileContentStateTest { @Test fun largeFontInShortViewportKeepsAuthActionReachable() { var signedIn = false - compose.setContent { + compose.setBuiltContent { CompositionLocalProvider(LocalDensity provides Density(LocalDensity.current.density, fontScale = 2f)) { Box(Modifier.height(200.dp)) { MobileAuthMessageScreen( diff --git a/mobile/src/test/kotlin/io/putdotio/android/MobileDownloadsScreenTest.kt b/mobile/src/test/kotlin/io/putdotio/android/MobileDownloadsScreenTest.kt index d2d9453a3..f4866263c 100644 --- a/mobile/src/test/kotlin/io/putdotio/android/MobileDownloadsScreenTest.kt +++ b/mobile/src/test/kotlin/io/putdotio/android/MobileDownloadsScreenTest.kt @@ -67,7 +67,7 @@ class MobileDownloadsScreenTest { fun progressIsWatchedOnlyWhileTheScreenIsShown() { val events = mutableListOf() var shown by mutableStateOf(true) - compose.setContent { + compose.setBuiltContent { PutioTheme { if (shown) { MobileDownloadsScreen(DownloadsState(), onEvent = { events += it; true }, onPlay = {}) @@ -84,7 +84,7 @@ class MobileDownloadsScreenTest { @Test fun emptyDownloadsNamesTheDownloadFileAction() { - compose.setContent { PutioTheme { DownloadsTab(DownloadsState(), { true }) } } + compose.setBuiltContent { PutioTheme { DownloadsTab(DownloadsState(), { true }) } } compose.onNodeWithText("Nothing downloaded yet").assertIsDisplayed() compose.onNodeWithText("Open a video or audio file’s actions and choose Download.").assertIsDisplayed() @@ -102,7 +102,7 @@ class MobileDownloadsScreenTest { row(14L, "Lost", DownloadStatus.Missing, queuedAt = 5L), )) val events = mutableListOf() - compose.setContent { PutioTheme { DownloadsTab(state, { events += it; true }) } } + compose.setBuiltContent { PutioTheme { DownloadsTab(state, { events += it; true }) } } compose.onNodeWithText("Downloading").assertIsDisplayed() // An original's size is known; HLS shows its segment percentage, or bytes before its playlists are read. @@ -141,7 +141,7 @@ class MobileDownloadsScreenTest { row(12L, "Waiting.mkv", DownloadStatus.Queued, queuedAt = 3L), )) val events = mutableListOf() - compose.setContent { PutioTheme { DownloadsTab(state, { events += it; true }) } } + compose.setBuiltContent { PutioTheme { DownloadsTab(state, { events += it; true }) } } compose.onNodeWithText("Paused · 26%").assertIsDisplayed() compose.onNodeWithContentDescription("Pause download").performClick() @@ -164,7 +164,7 @@ class MobileDownloadsScreenTest { row(10L, "Tears.mkv", DownloadStatus.Paused(DownloadPauseReason.NETWORK, 310L, null, 1_200L)), )) val events = mutableListOf() - compose.setContent { PutioTheme { DownloadsTab(state, { events += it; true }) } } + compose.setBuiltContent { PutioTheme { DownloadsTab(state, { events += it; true }) } } compose.onNodeWithText("Waiting for network · 310 B of 1.2 kB").assertIsDisplayed() assertTrue(compose.onAllNodesWithContentDescription("Resume download").fetchSemanticsNodes().isEmpty()) @@ -179,7 +179,7 @@ class MobileDownloadsScreenTest { row(11L, "Gone.mkv", DownloadStatus.Missing), )) val events = mutableListOf() - compose.setContent { PutioTheme { DownloadsTab(state, { events += it; true }) } } + compose.setBuiltContent { PutioTheme { DownloadsTab(state, { events += it; true }) } } compose.onNodeWithText("Failed · Not enough storage").assertIsDisplayed() compose.onNodeWithContentDescription("Retry download").performClick() @@ -194,7 +194,7 @@ class MobileDownloadsScreenTest { fun notificationsOffShowsAWayToTurnThemOnAndOnShowsNothing() { var turnedOn = 0 var enabled by mutableStateOf(false) - compose.setContent { + compose.setBuiltContent { PutioTheme { MobileDownloadsScreen( DownloadsState(), @@ -220,7 +220,7 @@ class MobileDownloadsScreenTest { row(12L, "Leaving.mkv", DownloadStatus.Completed(1L)), )) val events = mutableListOf() - compose.setContent { PutioTheme { DownloadsTab(state, { events += it; true }) } } + compose.setBuiltContent { PutioTheme { DownloadsTab(state, { events += it; true }) } } compose.onNodeWithText("Sintel.mkv").performTouchInput { longClick() } compose.onNodeWithText("Tears.mkv").performClick() @@ -242,7 +242,7 @@ class MobileDownloadsScreenTest { row(11L, "Tears.mkv", DownloadStatus.Completed(1L)), )) val events = mutableListOf() - compose.setContent { PutioTheme { DownloadsTab(state, { events += it; true }) } } + compose.setBuiltContent { PutioTheme { DownloadsTab(state, { events += it; true }) } } compose.onNodeWithTag(MOBILE_DOWNLOADS_OVERFLOW_TAG).performClick() compose.onNodeWithTag(MOBILE_DOWNLOADS_SELECT_TAG).performClick() @@ -263,7 +263,7 @@ class MobileDownloadsScreenTest { fun aSelectionWhoseRowsAllLeaveEndsAndDoesNotReturnWithThem() { val sintel = row(10L, "Sintel.mkv", DownloadStatus.Completed(1L)) var state by mutableStateOf(DownloadsState().withEntries(listOf(sintel))) - compose.setContent { PutioTheme { DownloadsTab(state, { true }) } } + compose.setBuiltContent { PutioTheme { DownloadsTab(state, { true }) } } compose.onNodeWithText("Sintel.mkv").performTouchInput { longClick() } compose.onNodeWithText("1 selected").assertIsDisplayed() @@ -279,7 +279,7 @@ class MobileDownloadsScreenTest { fun aSheetWhoseRowLeavesDoesNotReopenWhenTheFileReturns() { val sintel = row(10L, "Sintel.mkv", DownloadStatus.Queued) var state by mutableStateOf(DownloadsState(focus = FilesItemId(10L)).withEntries(listOf(sintel))) - compose.setContent { + compose.setBuiltContent { PutioTheme { DownloadsTab(state) { event -> if (event == DownloadsEvent.FocusHandled) state = state.copy(focus = null) @@ -300,7 +300,7 @@ class MobileDownloadsScreenTest { fun aFocusDuringSelectionEndsTheSelectionAndOpensTheSheet() { val sintel = row(10L, "Sintel.mkv", DownloadStatus.Completed(1L)) var state by mutableStateOf(DownloadsState().withEntries(listOf(sintel))) - compose.setContent { + compose.setBuiltContent { PutioTheme { DownloadsTab(state) { event -> if (event == DownloadsEvent.FocusHandled) state = state.copy(focus = null) @@ -326,7 +326,7 @@ class MobileDownloadsScreenTest { var state by mutableStateOf(DownloadsState(focus = FilesItemId(10L)).withEntries(entries)) val events = mutableListOf() val played = mutableListOf() - compose.setContent { + compose.setBuiltContent { PutioTheme { MobileDownloadsScreen( state, @@ -374,7 +374,7 @@ class MobileDownloadsScreenTest { row(12L, "Done.mkv", DownloadStatus.Completed(1L), queuedAt = 3L), )) val events = mutableListOf() - compose.setContent { PutioTheme { DownloadsTab(state, { events += it; true }) } } + compose.setBuiltContent { PutioTheme { DownloadsTab(state, { events += it; true }) } } compose.onNodeWithText("Done.mkv").performTouchInput { longClick() } compose.onNodeWithTag(MOBILE_DOWNLOADS_SELECTION_PAUSE_TAG).assertDoesNotExist() @@ -402,7 +402,7 @@ class MobileDownloadsScreenTest { DownloadsState().withEntries(listOf(running, waiting, paused, done, offline, deleting)), ) val events = mutableListOf() - compose.setContent { PutioTheme { DownloadsTab(state, { events += it; true }) } } + compose.setBuiltContent { PutioTheme { DownloadsTab(state, { events += it; true }) } } compose.onNodeWithTag(MOBILE_DOWNLOADS_OVERFLOW_TAG).performClick() compose.onNodeWithTag(MOBILE_DOWNLOADS_PAUSE_OR_RESUME_ALL_TAG).assertTextContains("Pause all").performClick() diff --git a/mobile/src/test/kotlin/io/putdotio/android/MobileFilesActionsSheetTest.kt b/mobile/src/test/kotlin/io/putdotio/android/MobileFilesActionsSheetTest.kt index 468d608a1..79124e2ad 100644 --- a/mobile/src/test/kotlin/io/putdotio/android/MobileFilesActionsSheetTest.kt +++ b/mobile/src/test/kotlin/io/putdotio/android/MobileFilesActionsSheetTest.kt @@ -77,7 +77,7 @@ class MobileFilesActionsSheetTest { @Test fun aStartedVideoOffersResumeTheVideoRowsAndTheOwnerActions() { val chosen = mutableListOf() - compose.setContent { + compose.setBuiltContent { PutioTheme { MobileFilesActions( item = started, @@ -123,7 +123,7 @@ class MobileFilesActionsSheetTest { val note = started.copy(id = FilesItemId(9L), name = "notes.txt", type = PutioFileType.TEXT, playback = null) val song = started.copy(id = FilesItemId(10L), name = "song.mp3", type = PutioFileType.AUDIO, playback = null) var item by mutableStateOf(started) - compose.setContent { + compose.setBuiltContent { PutioTheme { key(item.id.value) { MobileFilesActions( @@ -155,7 +155,7 @@ class MobileFilesActionsSheetTest { var item by mutableStateOf(started) var setting by mutableStateOf(StreamingMethod.Hls) var status by mutableStateOf(null) - compose.setContent { + compose.setBuiltContent { PutioTheme { key(item.id.value, setting, status) { MobileFilesActions( @@ -200,7 +200,7 @@ class MobileFilesActionsSheetTest { fun aFileTheViewerShowsOpensThereFirstAndOffersOtherApps() { val chosen = mutableListOf() val note = started.copy(id = FilesItemId(8L), name = "notes.txt", type = PutioFileType.TEXT, playback = null) - compose.setContent { + compose.setBuiltContent { PutioTheme { MobileFilesActions( item = note, @@ -227,7 +227,7 @@ class MobileFilesActionsSheetTest { @Test fun theHandleCarryingTheSheetsActionsIsALabelledTouchTarget() { - compose.setContent { + compose.setBuiltContent { PutioTheme { MobileFilesActions( started, FilesFolder.Root.id, FilesFolderOperation.Idle, null, {}, {}, @@ -245,7 +245,7 @@ class MobileFilesActionsSheetTest { fun aFriendsFileKeepsTheTilesAndMakeACopyAndNamesTheSharer() { val shared = started.copy(id = FilesItemId(9L), name = "Caminandes - Llama Drama.mp4", isShared = true, playback = null) - compose.setContent { + compose.setBuiltContent { PutioTheme { MobileFilesActions( item = shared, @@ -282,7 +282,7 @@ class MobileFilesActionsSheetTest { @Test fun aSearchResultsSheetLeavesOutWhatActsOnAFolderListing() { var played = 0 - compose.setContent { + compose.setBuiltContent { PutioTheme { MobileSearchResultActionsHost( results = listOf(started), @@ -308,7 +308,7 @@ class MobileFilesActionsSheetTest { @Test fun aVideoPast95PercentReadsAsFinished() { var progress by mutableStateOf(FilesPlaybackProgress(startFromSeconds = 2_849.0, durationSeconds = 3_000.0)) - compose.setContent { + compose.setBuiltContent { PutioTheme { MobileFilesActions( item = started.copy(playback = progress), @@ -335,7 +335,7 @@ class MobileFilesActionsSheetTest { @Test fun renameSelectsTheNameUpToItsExtension() { - compose.setContent { + compose.setBuiltContent { PutioTheme { MobileFilesActions(started, FilesFolder.Root.id, FilesFolderOperation.Idle, null, {}, {}, confirmedTrashEnabled = true) diff --git a/mobile/src/test/kotlin/io/putdotio/android/MobileFilesBarsTest.kt b/mobile/src/test/kotlin/io/putdotio/android/MobileFilesBarsTest.kt index 61b0db1f4..c121baf08 100644 --- a/mobile/src/test/kotlin/io/putdotio/android/MobileFilesBarsTest.kt +++ b/mobile/src/test/kotlin/io/putdotio/android/MobileFilesBarsTest.kt @@ -180,7 +180,7 @@ class MobileFilesBarsTest { onFilesEvent: (FilesBrowserEvent) -> Unit = {}, settings: AccountSettingsState = readyAccountSettingsState(), ) { - setContent { + setBuiltContent { val configuration = Configuration(LocalConfiguration.current).apply { if (hardwareKeyboard) { keyboard = Configuration.KEYBOARD_QWERTY diff --git a/mobile/src/test/kotlin/io/putdotio/android/MobileFilesCopyTest.kt b/mobile/src/test/kotlin/io/putdotio/android/MobileFilesCopyTest.kt index a6ffedb21..c6e6cae83 100644 --- a/mobile/src/test/kotlin/io/putdotio/android/MobileFilesCopyTest.kt +++ b/mobile/src/test/kotlin/io/putdotio/android/MobileFilesCopyTest.kt @@ -79,7 +79,7 @@ class MobileFilesCopyTest { @Test fun sharedItemsOfferMakeACopyIntoAFolderPickedFromRoot() { val events = mutableListOf() - compose.setContent { + compose.setBuiltContent { PutioTheme { val state = loaded(listOf(sharedVideo, sharedFolder, friend, owned)) MobileFilesRoute(state, repository, events::add, {}, true, {}) @@ -122,7 +122,7 @@ class MobileFilesCopyTest { fun makeACopyOpensAtTheRememberedFolderUntilRememberIsTurnedOff() { val remembered = listOf(FilesFolder(destination.id, destination.name)) val store = InMemoryMoveTargetStore(FilesMoveTargetMemory(remember = true, lastTarget = remembered)) - compose.setContent { + compose.setBuiltContent { PutioTheme { MobileFilesRoute(loaded(listOf(sharedVideo)), repository, { true }, {}, true, {}, moveTargetStore = store) @@ -147,7 +147,7 @@ class MobileFilesCopyTest { @Test fun copyHereWithRememberOnRecordsTheFolderTheNextPickerOpensAt() { val store = InMemoryMoveTargetStore(FilesMoveTargetMemory(remember = true)) - compose.setContent { + compose.setBuiltContent { PutioTheme { MobileFilesRoute(loaded(listOf(sharedVideo)), repository, { true }, {}, true, {}, moveTargetStore = store) @@ -181,7 +181,7 @@ class MobileFilesCopyTest { ) var state by mutableStateOf(copying.state) val events = mutableListOf() - compose.setContent { + compose.setBuiltContent { PutioTheme { MobileFilesScreen( state, @@ -217,7 +217,7 @@ class MobileFilesCopyTest { ).state val opening = FilesBrowserReducer.reduce(running, FilesBrowserEvent.OpenFolder(sharedFolder.id)) var state by mutableStateOf(opening.state) - compose.setContent { PutioTheme { MobileFilesScreen(state, onEvent = {}, onPlayMedia = {}) } } + compose.setBuiltContent { PutioTheme { MobileFilesScreen(state, onEvent = {}, onPlayMedia = {}) } } compose.onNodeWithText("Copying “Harbor film.mp4” to Files…").assertIsDisplayed() @@ -239,7 +239,7 @@ class MobileFilesCopyTest { loaded(listOf(sharedVideo, sharedFolder)), FilesBrowserEvent.Copy(FilesFolder.Root.id, sharedVideo.id, FilesFolder.Root), ).state - compose.setContent { + compose.setBuiltContent { PutioTheme { MobileFilesScreen(running, onEvent = {}, onPlayMedia = {}, onCopyItem = {}) } } @@ -261,7 +261,7 @@ class MobileFilesCopyTest { ), ).state var state by mutableStateOf(limited) - compose.setContent { PutioTheme { MobileFilesScreen(state, onEvent = {}, onPlayMedia = {}) } } + compose.setBuiltContent { PutioTheme { MobileFilesScreen(state, onEvent = {}, onPlayMedia = {}) } } compose.onNodeWithText("Couldn’t copy “Harbor film.mp4” to Sample folder.").assertIsDisplayed() compose.onNodeWithText( diff --git a/mobile/src/test/kotlin/io/putdotio/android/MobileFilesDeleteTest.kt b/mobile/src/test/kotlin/io/putdotio/android/MobileFilesDeleteTest.kt index 92ba61b09..20f5e030f 100644 --- a/mobile/src/test/kotlin/io/putdotio/android/MobileFilesDeleteTest.kt +++ b/mobile/src/test/kotlin/io/putdotio/android/MobileFilesDeleteTest.kt @@ -53,7 +53,7 @@ class MobileFilesDeleteTest { @Test fun moveToTrashRunsAtOnceWithoutAConfirmation() { val events = mutableListOf() - compose.setContent { + compose.setBuiltContent { PutioTheme { MobileFilesScreen(loadedRoot(), events::add, {}, confirmedTrashEnabled = true) } } openAction("Move to trash") @@ -71,7 +71,7 @@ class MobileFilesDeleteTest { fun aTrashTapQueuedBeforeTrashTurnedOffReachedTheSheetSendsNothing() { val events = mutableListOf() var trash by mutableStateOf(true) - compose.setContent { + compose.setBuiltContent { PutioTheme { MobileFilesScreen(loadedRoot(), events::add, {}, confirmedTrashEnabled = trash) } } compose.onNodeWithContentDescription("Actions for été 東京.mkv").performClick() @@ -90,7 +90,7 @@ class MobileFilesDeleteTest { @Test fun permanentConfirmationIsExplicitAndQueuedClicksSubmitOnlyOnce() { val events = mutableListOf() - compose.setContent { + compose.setBuiltContent { PutioTheme { MobileFilesScreen(loadedRoot(), events::add, {}, confirmedTrashEnabled = false) } } openAction("Delete permanently") @@ -122,7 +122,7 @@ class MobileFilesDeleteTest { ))) var state by mutableStateOf(failedRename) val effects = mutableListOf() - compose.setContent { + compose.setBuiltContent { PutioTheme { MobileFilesScreen(state, { event -> val next = FilesBrowserReducer.reduce(state, event) @@ -157,7 +157,7 @@ class MobileFilesDeleteTest { @Test fun unknownTrashSettingsLeaveRenameAvailableButBlockDelete() { - compose.setContent { + compose.setBuiltContent { PutioTheme { MobileFilesScreen(loadedRoot(), {}, {}, confirmedTrashEnabled = null) } } compose.onNodeWithContentDescription("Actions for été 東京.mkv").performClick() @@ -171,7 +171,7 @@ class MobileFilesDeleteTest { fun trashTurningOnWithdrawsThePermanentConfirmation() { var trash by mutableStateOf(false) val events = mutableListOf() - compose.setContent { + compose.setBuiltContent { PutioTheme { MobileFilesScreen(loadedRoot(), events::add, {}, confirmedTrashEnabled = trash) } } openAction("Delete permanently") @@ -191,7 +191,7 @@ class MobileFilesDeleteTest { fun unconfirmedSettingsDiscardTheOldConfirmationEvenWhenModeReturns() { var trash by mutableStateOf(false) val events = mutableListOf() - compose.setContent { + compose.setBuiltContent { PutioTheme { MobileFilesScreen(loadedRoot(), events::add, {}, confirmedTrashEnabled = trash) } } openAction("Delete permanently") @@ -208,7 +208,7 @@ class MobileFilesDeleteTest { fun uncertainDeleteOffersReadOnlyStatusRecovery() { var state by mutableStateOf(loadedRoot()) val effects = mutableListOf() - compose.setContent { + compose.setBuiltContent { PutioTheme { MobileFilesScreen(state, { event -> val next = FilesBrowserReducer.reduce(state, event) @@ -261,7 +261,7 @@ class MobileFilesDeleteTest { ) val events = mutableListOf() val undone = mutableListOf() - compose.setContent { + compose.setBuiltContent { PutioTheme { MobileFilesScreen( state = state, @@ -321,7 +321,7 @@ class MobileFilesDeleteTest { loadedRoot(items).let { it.copyForTest(stack = listOf(it.current.copy(deleteOutcome = outcome))) } var state by mutableStateOf(withOutcome(listOf(folder))) val events = mutableListOf() - compose.setContent { + compose.setBuiltContent { PutioTheme { MobileFilesScreen(state, events::add, {}, confirmedTrashEnabled = true) } } val message = "This folder contains too many files. Delete it permanently?" diff --git a/mobile/src/test/kotlin/io/putdotio/android/MobileFilesListDetailTest.kt b/mobile/src/test/kotlin/io/putdotio/android/MobileFilesListDetailTest.kt index a33346b7f..860158d6c 100644 --- a/mobile/src/test/kotlin/io/putdotio/android/MobileFilesListDetailTest.kt +++ b/mobile/src/test/kotlin/io/putdotio/android/MobileFilesListDetailTest.kt @@ -237,7 +237,7 @@ class MobileFilesListDetailTest { @Test fun theShellTurnsFilesIntoListAndDetailAt840dpWithTheFolderBarOverTheList() { var width by mutableStateOf(839.dp) - compose.setContent { + compose.setBuiltContent { PutioTheme { Box(Modifier.requiredSize(width = width, height = 800.dp)) { MobileShell( @@ -268,7 +268,7 @@ class MobileFilesListDetailTest { @Test fun crossingTheBreakpointKeepsAnOpenActionsSheet() { var wide by mutableStateOf(false) - compose.setContent { + compose.setBuiltContent { PutioTheme { Box(Modifier.requiredSize(width = if (wide) 1184.dp else 600.dp, height = 700.dp)) { MobileFilesRoute( @@ -327,7 +327,7 @@ class MobileFilesListDetailTest { events: MutableList = mutableListOf(), linkedFile: FilesItemId? = null, ) { - compose.setContent { + compose.setBuiltContent { PutioTheme { CompositionLocalProvider(LocalMobileFileViewerIo provides Dispatchers.Unconfined) { Box(Modifier.requiredSize(width = width, height = 700.dp)) { diff --git a/mobile/src/test/kotlin/io/putdotio/android/MobileFilesMoveLayoutTest.kt b/mobile/src/test/kotlin/io/putdotio/android/MobileFilesMoveLayoutTest.kt index 68164827b..1d516e8d4 100644 --- a/mobile/src/test/kotlin/io/putdotio/android/MobileFilesMoveLayoutTest.kt +++ b/mobile/src/test/kotlin/io/putdotio/android/MobileFilesMoveLayoutTest.kt @@ -77,7 +77,7 @@ class MobileFilesMoveLayoutTest { val events = mutableListOf() var cancellations = 0 var confirmations = 0 - compose.setContent { + compose.setBuiltContent { PutioTheme { MobileFilesMoveDestination(state, events::add, onCancel = { cancellations += 1 }, onConfirm = { confirmations += 1 }) diff --git a/mobile/src/test/kotlin/io/putdotio/android/MobileFilesMoveNavigationTest.kt b/mobile/src/test/kotlin/io/putdotio/android/MobileFilesMoveNavigationTest.kt index 75b5f06e6..4b3448b6e 100644 --- a/mobile/src/test/kotlin/io/putdotio/android/MobileFilesMoveNavigationTest.kt +++ b/mobile/src/test/kotlin/io/putdotio/android/MobileFilesMoveNavigationTest.kt @@ -217,7 +217,7 @@ class MobileFilesMoveNavigationTest { } private fun mount(preview: RootMoveBackPreview, trashController: TrashController? = null) { - compose.setContent { + compose.setBuiltContent { val owner = checkNotNull(LocalOnBackPressedDispatcherOwner.current) DisposableEffect(owner) { backOwner = owner diff --git a/mobile/src/test/kotlin/io/putdotio/android/MobileFilesMoveTest.kt b/mobile/src/test/kotlin/io/putdotio/android/MobileFilesMoveTest.kt index 0d1b82168..3902b6394 100644 --- a/mobile/src/test/kotlin/io/putdotio/android/MobileFilesMoveTest.kt +++ b/mobile/src/test/kotlin/io/putdotio/android/MobileFilesMoveTest.kt @@ -74,7 +74,7 @@ class MobileFilesMoveTest { val events = mutableListOf() val initial = loadedRoot() val repository = destinationRepository() - compose.setContent { + compose.setBuiltContent { PutioTheme { MobileFilesRoute(initial, repository, events::add, {}, true, {}) } } openMove() @@ -98,7 +98,7 @@ class MobileFilesMoveTest { fun cancelInvalidatesAQueuedConfirmBeforeThePickerIsDisposed() { val events = mutableListOf() val repository = destinationRepository() - compose.setContent { + compose.setBuiltContent { PutioTheme { MobileFilesRoute(loadedRoot(), repository, events::add, {}, true, {}) } } openMove() @@ -118,7 +118,7 @@ class MobileFilesMoveTest { fun duplicateQueuedConfirmSendsOneMoveAndAFreshPickerCanBeOpened() { val events = mutableListOf() val repository = destinationRepository() - compose.setContent { + compose.setBuiltContent { PutioTheme { MobileFilesRoute(loadedRoot(), repository, events::add, {}, true, {}) } } openMove() @@ -159,7 +159,7 @@ class MobileFilesMoveTest { } } val events = mutableListOf() - compose.setContent { + compose.setBuiltContent { PutioTheme { MobileFilesRoute(loadedRoot(), repository, events::add, {}, true, {}) } } openMove() @@ -181,7 +181,7 @@ class MobileFilesMoveTest { override suspend fun loadMoveDestinations(folderId: FilesItemId, cursor: FilesCursor?) = PutioResult.Failure(putioRefusal(404, putioErrorBody(404, "not a folder")).toPutioFailure()) } - compose.setContent { + compose.setBuiltContent { PutioTheme { MobileFilesRoute(loadedRoot(), repository, { true }, {}, true, {}) } } openMove() @@ -200,7 +200,7 @@ class MobileFilesMoveTest { var state by mutableStateOf(reload( reloading.state, checkNotNull(reloading.effect).requestId, FilesPage(listOf(source), null), )) - compose.setContent { PutioTheme { MobileFilesScreen(state, {}, {}, confirmedTrashEnabled = true) } } + compose.setBuiltContent { PutioTheme { MobileFilesScreen(state, {}, {}, confirmedTrashEnabled = true) } } compose.onNodeWithText( "A file or folder named “${source.name}” already exists there. Choose another folder.", ).assertIsDisplayed() @@ -232,7 +232,7 @@ class MobileFilesMoveTest { checkNotNull(checking.effect).requestId, PutioResult.Success(source), )) val state = reload(reloading.state, checkNotNull(reloading.effect).requestId, FilesPage(listOf(source), null)) - compose.setContent { PutioTheme { MobileFilesScreen(state, {}, {}, confirmedTrashEnabled = true) } } + compose.setBuiltContent { PutioTheme { MobileFilesScreen(state, {}, {}, confirmedTrashEnabled = true) } } compose.onNodeWithText( "“${source.name}” is not in the selected folder. You can choose a destination again.", ).assertIsDisplayed() @@ -247,7 +247,7 @@ class MobileFilesMoveTest { checkNotNull(checking.effect).requestId, failure("offline read"), )).state) val effects = mutableListOf() - compose.setContent { + compose.setBuiltContent { PutioTheme { MobileFilesScreen(state, { event -> val next = FilesBrowserReducer.reduce(state, event) @@ -312,7 +312,7 @@ class MobileFilesMoveTest { } var repository by mutableStateOf(previousRepository) val events = mutableListOf() - compose.setContent { + compose.setBuiltContent { PutioTheme { MobileFilesRoute(loadedRoot(), repository, events::add, {}, true, {}) } } openMove() @@ -343,7 +343,7 @@ class MobileFilesMoveTest { fun rejectedConfirmationKeepsThePickerAndDestination() { var attempts = 0 val repository = destinationRepository() - compose.setContent { + compose.setBuiltContent { PutioTheme { MobileFilesRoute(loadedRoot(), repository, { event -> if (event is FilesBrowserEvent.Move) attempts += 1 @@ -368,7 +368,7 @@ class MobileFilesMoveTest { val loaded = reload(opened.state, checkNotNull(opened.effect).requestId, FilesPage(listOf(child), null)) var state by mutableStateOf(loaded) val repository = destinationRepository() - compose.setContent { + compose.setBuiltContent { PutioTheme { MobileFilesRoute(state, repository, { true }, {}, true, {}) } } openMove() @@ -400,7 +400,7 @@ class MobileFilesMoveTest { PutioFailure.AuthenticationRequired(PutioConfigurationException("Expired picker session")), ) } - compose.setContent { + compose.setBuiltContent { PutioTheme { MobileFilesRoute(loadedRoot(), repository, { true }, {}, true, { rejections += 1 }) } } openMove() @@ -427,7 +427,7 @@ class MobileFilesMoveTest { else -> error("Unexpected destination read") } } - compose.setContent { + compose.setBuiltContent { PutioTheme { MobileFilesRoute(loadedRoot(), repository, events::add, {}, true, { rejections += 1 @@ -461,7 +461,7 @@ class MobileFilesMoveTest { fun rememberTargetFolderIsOffByDefaultAndOnceOnReopensMoveAtTheChosenFolder() { val store = InMemoryMoveTargetStore() val events = mutableListOf() - compose.setContent { + compose.setBuiltContent { PutioTheme { MobileFilesRoute(loadedRoot(), destinationRepository(), events::add, {}, true, {}, moveTargetStore = store) diff --git a/mobile/src/test/kotlin/io/putdotio/android/MobileFilesRenameTest.kt b/mobile/src/test/kotlin/io/putdotio/android/MobileFilesRenameTest.kt index f6d9e6d13..4aeadd5d9 100644 --- a/mobile/src/test/kotlin/io/putdotio/android/MobileFilesRenameTest.kt +++ b/mobile/src/test/kotlin/io/putdotio/android/MobileFilesRenameTest.kt @@ -97,7 +97,7 @@ class MobileFilesRenameTest { } private fun showWithSortMenu(flow: RenameFlow) { - compose.setContent { + compose.setBuiltContent { PutioTheme { Column { MobileFilesSortMenu( @@ -160,7 +160,7 @@ class MobileFilesRenameTest { fun aQueuedRefreshCannotReplaceThePageWhileEditing() { var state by mutableStateOf(loadedRoot()) val effects = mutableListOf() - compose.setContent { + compose.setBuiltContent { PutioTheme { MobileFilesScreen(state, onEvent = { val transition = FilesBrowserReducer.reduce(state, it) @@ -199,7 +199,7 @@ class MobileFilesRenameTest { var state by mutableStateOf(loadedRoot()) var renameAccepted = true val effects = mutableListOf() - compose.setContent { + compose.setBuiltContent { PutioTheme { MobileFilesScreen(state, onEvent = { event -> val transition = FilesBrowserReducer.reduce(state, event) @@ -235,7 +235,7 @@ class MobileFilesRenameTest { @Test fun cancellingAFailedRenameRemovesItsRetry() { var state by mutableStateOf(failedRename()) - compose.setContent { + compose.setBuiltContent { PutioTheme { MobileFilesScreen( state, @@ -257,7 +257,7 @@ class MobileFilesRenameTest { @Test fun savingTheOriginalNameAfterFailureRemovesTheAbandonedRetry() { var state by mutableStateOf(failedRename()) - compose.setContent { + compose.setBuiltContent { PutioTheme { MobileFilesScreen( state, diff --git a/mobile/src/test/kotlin/io/putdotio/android/MobileFilesScreenTest.kt b/mobile/src/test/kotlin/io/putdotio/android/MobileFilesScreenTest.kt index 50173ce09..14a26fbdb 100644 --- a/mobile/src/test/kotlin/io/putdotio/android/MobileFilesScreenTest.kt +++ b/mobile/src/test/kotlin/io/putdotio/android/MobileFilesScreenTest.kt @@ -1,5 +1,7 @@ package io.putdotio.android +import kotlinx.coroutines.Dispatchers +import io.putdotio.android.design.LocalBuildDispatcher import androidx.compose.runtime.CompositionLocalProvider import androidx.compose.runtime.getValue import androidx.compose.runtime.mutableStateOf @@ -105,7 +107,7 @@ class MobileFilesScreenTest { fun landscapeActionSheetKeepsBottomActionReachableAtDoubleFontScale() { org.robolectric.RuntimeEnvironment.setFontScale(2f) val item = filesItem(7L, "Archive 東京 été ".repeat(16)) - compose.setContent { + compose.setBuiltContent { PutioTheme { MobileFilesActions( item, FilesItemId(0), FilesFolderOperation.Idle, null, {}, {}, @@ -130,7 +132,7 @@ class MobileFilesScreenTest { val sharedFolder = filesItem(12L, "Season 1", PutioFileType.FOLDER).copy(isShared = true) val sharedVideo = filesItem(13L, "clip.mkv", PutioFileType.VIDEO).copy(isShared = true) val owned = filesItem(14L, "mine.mkv", PutioFileType.VIDEO) - compose.setContent { + compose.setBuiltContent { PutioTheme { MobileFilesScreen( browserState( @@ -166,12 +168,14 @@ class MobileFilesScreenTest { var state by mutableStateOf(browserState(FilesContent.Ready(listOf(original, sentinel), FilesPaging.Complete))) val restoration = StateRestorationTester(compose) restoration.setContent { - PutioTheme { - MobileFilesScreen( - state, - onEvent = { state = FilesBrowserReducer.reduce(state, it).state }, - onPlayMedia = {}, - ) + CompositionLocalProvider(LocalBuildDispatcher provides Dispatchers.Unconfined) { + PutioTheme { + MobileFilesScreen( + state, + onEvent = { state = FilesBrowserReducer.reduce(state, it).state }, + onPlayMedia = {}, + ) + } } } compose.onNodeWithContentDescription("Actions for root").assertDoesNotExist() @@ -198,7 +202,7 @@ class MobileFilesScreenTest { val original = filesItem(7L, "old.mkv", PutioFileType.VIDEO) var state by mutableStateOf(browserState(FilesContent.Ready(listOf(original), FilesPaging.Complete))) val effects = mutableListOf() - compose.setContent { + compose.setBuiltContent { PutioTheme { MobileFilesScreen(state, onEvent = { val transition = FilesBrowserReducer.reduce(state, it) @@ -250,7 +254,7 @@ class MobileFilesScreenTest { val original = filesItem(7L, "folder", PutioFileType.FOLDER) var state by mutableStateOf(browserState(FilesContent.Ready(listOf(original), FilesPaging.Complete))) val renamed = mutableListOf() - compose.setContent { + compose.setBuiltContent { PutioTheme { MobileFilesScreen(state, onEvent = { val transition = FilesBrowserReducer.reduce(state, it) @@ -333,7 +337,7 @@ class MobileFilesScreenTest { browserState(FilesContent.Loading(FilesRequestId(1L))), ) val events = mutableListOf() - compose.setContent { + compose.setBuiltContent { PutioTheme { MobileFilesScreen(state = state, onEvent = events::add, onPlayMedia = {}) } @@ -391,7 +395,7 @@ class MobileFilesScreenTest { fun anEmptyFolderOffersToCreateAFolder() { var newFolderRequests = 0 val state = browserState(FilesContent.Empty(FilesPaging.Complete)) - compose.setContent { + compose.setBuiltContent { PutioTheme { MobileFilesScreen(state, onEvent = {}, onPlayMedia = {}, onNewFolder = { newFolderRequests++ }) } @@ -407,7 +411,7 @@ class MobileFilesScreenTest { val file = filesItem(1L, "movie.mkv").copy(createdAt = "2020-04-20T10:00:00") val folder = filesItem(2L, "Shows", PutioFileType.FOLDER).copy(createdAt = "2020-04-21T10:00:00") val state = browserState(FilesContent.Ready(listOf(file, folder), FilesPaging.Complete)) - compose.setContent { PutioTheme { MobileFilesScreen(state, onEvent = {}, onPlayMedia = {}) } } + compose.setBuiltContent { PutioTheme { MobileFilesScreen(state, onEvent = {}, onPlayMedia = {}) } } compose.awaitText("Apr 21, 2020") compose.onNode(hasText("movie.mkv") and hasText("Apr 20, 2020")).assertIsDisplayed() compose.onNode(hasText("Shows") and hasText("Apr 21, 2020")).assertIsDisplayed() @@ -425,7 +429,7 @@ class MobileFilesScreenTest { val plain = filesItem(4L, "plain.txt") val items = listOf(partly, finished, unknown, fresh, plain) val state = browserState(FilesContent.Ready(items, FilesPaging.Complete)) - compose.setContent { PutioTheme { MobileFilesScreen(state, onEvent = {}, onPlayMedia = {}) } } + compose.setBuiltContent { PutioTheme { MobileFilesScreen(state, onEvent = {}, onPlayMedia = {}) } } compose.awaitText("128 B") // Resumable shows no mark of its own, and never the finished eye. compose.onNode(hasText("partly.mkv") and hasText("128 B")).assertIsDisplayed() @@ -449,7 +453,7 @@ class MobileFilesScreenTest { "done.mkv" to DownloadStatus.Completed(128L), "gone.mkv" to DownloadStatus.Missing, ) - compose.setContent { + compose.setBuiltContent { PutioTheme { androidx.compose.foundation.layout.Column { rows.forEachIndexed { index, (name, status) -> @@ -480,7 +484,7 @@ class MobileFilesScreenTest { fun aLongNameKeepsItsFullNameForReaders() { val name = "Blue.Lights.S04E01.1080p.HDTV.H264-ORGANiC.Extended.Cut.Remastered.mkv" val file = filesItem(1L, name, PutioFileType.VIDEO) - compose.setContent { + compose.setBuiltContent { PutioTheme { androidx.compose.foundation.layout.Column(Modifier.width(320.dp)) { MobileFilesRow(file, NO_ROW_TEXT, downloadStatus = DownloadStatus.Completed(128L)) @@ -511,7 +515,7 @@ class MobileFilesListTest { val available = FilesContent.Ready(items, FilesPaging.Available(FilesCursor("next-page"))) var state by mutableStateOf(browserState(available)) val events = mutableListOf() - compose.setContent { + compose.setBuiltContent { PutioTheme { MobileFilesScreen(state = state, onEvent = events::add, onPlayMedia = {}) } @@ -558,7 +562,7 @@ class MobileFilesListTest { val short = listOf(filesItem(id = 1L, name = "Harbor film.mp4")) var state by mutableStateOf(browserState(FilesContent.Empty(FilesPaging.Available(FilesCursor("page-2"))))) val events = mutableListOf() - compose.setContent { + compose.setBuiltContent { PutioTheme { MobileFilesScreen(state = state, onEvent = events::add, onPlayMedia = {}) } @@ -611,7 +615,7 @@ class MobileFilesListTest { var latest = shown val viewports = MobileFilesViewports { latest.viewportOf(it) } var pinned by mutableStateOf(emptyList()) - compose.setContent { + compose.setBuiltContent { PutioTheme { CompositionLocalProvider(LocalMobileFilesViewports provides viewports) { MobileFilesScreen( @@ -647,7 +651,7 @@ class MobileFilesListTest { sort = FilesSort.NAME_ASCENDING, ), ) - compose.setContent { + compose.setBuiltContent { PutioTheme { MobileFilesScreen(state = state, onEvent = events::add, onPlayMedia = {}) } @@ -690,7 +694,7 @@ class MobileFilesListTest { ), ) val events = mutableListOf() - compose.setContent { + compose.setBuiltContent { PutioTheme { MobileFilesScreen(state = state, onEvent = events::add, onPlayMedia = {}) } @@ -737,7 +741,7 @@ class MobileFilesListTest { ) var state by mutableStateOf(browserState(ready)) val events = mutableListOf() - compose.setContent { + compose.setBuiltContent { PutioTheme { MobileFilesScreen(state = state, onEvent = events::add, onPlayMedia = {}) } @@ -788,7 +792,7 @@ class MobileFilesListTest { ), ), ) - compose.setContent { + compose.setBuiltContent { PutioTheme { MobileFilesScreen(state = state, onEvent = {}, onPlayMedia = {}) } @@ -820,7 +824,7 @@ class MobileFilesListTest { ) var state by mutableStateOf(browserState(content)) val events = mutableListOf() - compose.setContent { + compose.setBuiltContent { PutioTheme { MobileFilesScreen(state = state, onEvent = events::add, onPlayMedia = {}) } @@ -863,7 +867,7 @@ class MobileFilesListTest { phase = FilesFolderOperationPhase.RELOADING, ) val events = mutableListOf() - compose.setContent { + compose.setBuiltContent { PutioTheme { MobileFilesScreen( state = browserState(FilesContent.Ready(listOf(item), FilesPaging.Complete), operation = failed), @@ -886,7 +890,7 @@ class MobileFilesListTest { ) var state by mutableStateOf(browserState(content)) val events = mutableListOf() - compose.setContent { + compose.setBuiltContent { PutioTheme { MobileFilesScreen(state = state, onEvent = events::add, onPlayMedia = {}) } @@ -927,7 +931,7 @@ class MobileFilesListTest { ) var state by mutableStateOf(browserState(content)) val events = mutableListOf() - compose.setContent { + compose.setBuiltContent { PutioTheme { MobileFilesScreen(state = state, onEvent = events::add, onPlayMedia = {}) } @@ -966,7 +970,7 @@ class MobileFilesListTest { filesItem(40L, "Gone", PutioFileType.FOLDER), FilesOpenOrigin.SEARCH, )) var state by mutableStateOf(opened.state) - compose.setContent { + compose.setBuiltContent { PutioTheme { MobileFilesScreen( state = state, @@ -1000,7 +1004,7 @@ private fun ComposeContentTestRule.setFilesContent( onEvent: (FilesBrowserEvent) -> Unit, onPlayMedia: (FilesItem) -> Unit = {}, ) { - setContent { + setBuiltContent { PutioTheme { MobileFilesScreen(state = state, onEvent = onEvent, onPlayMedia = onPlayMedia) } diff --git a/mobile/src/test/kotlin/io/putdotio/android/MobileFilesSelectionTest.kt b/mobile/src/test/kotlin/io/putdotio/android/MobileFilesSelectionTest.kt index 4bf41eb7c..144f65d37 100644 --- a/mobile/src/test/kotlin/io/putdotio/android/MobileFilesSelectionTest.kt +++ b/mobile/src/test/kotlin/io/putdotio/android/MobileFilesSelectionTest.kt @@ -235,7 +235,7 @@ class MobileFilesSelectionTest { } private fun setShell(trashEnabled: Boolean = true) { - compose.setContent { + compose.setBuiltContent { val owner = checkNotNull(LocalOnBackPressedDispatcherOwner.current) SideEffect { backOwner = owner } PutioTheme { diff --git a/mobile/src/test/kotlin/io/putdotio/android/MobileInactiveAccountNoticeTest.kt b/mobile/src/test/kotlin/io/putdotio/android/MobileInactiveAccountNoticeTest.kt index fe63464e3..ada840a6f 100644 --- a/mobile/src/test/kotlin/io/putdotio/android/MobileInactiveAccountNoticeTest.kt +++ b/mobile/src/test/kotlin/io/putdotio/android/MobileInactiveAccountNoticeTest.kt @@ -34,7 +34,7 @@ class MobileInactiveAccountNoticeTest { @Test fun deactivatedAccountShowsWebCopyWithTheDeletionCountdown() { var days by mutableLongStateOf(14L) - compose.setContent { + compose.setBuiltContent { PutioTheme { MobileInactiveAccountNotice(InactiveAccountNotice.Deactivated(deletionIn(days))) } } @@ -50,7 +50,7 @@ class MobileInactiveAccountNoticeTest { @Test fun withoutADeletionDateOnlyTheTitleShows() { - compose.setContent { PutioTheme { MobileInactiveAccountNotice(InactiveAccountNotice.Deactivated(null)) } } + compose.setBuiltContent { PutioTheme { MobileInactiveAccountNotice(InactiveAccountNotice.Deactivated(null)) } } compose.onNodeWithText("Your account has been deactivated 😢").assertIsDisplayed() compose.onNodeWithText("Your files are still here", substring = true).assertDoesNotExist() @@ -59,7 +59,7 @@ class MobileInactiveAccountNoticeTest { @Test fun familyPlanMemberIsToldThePlanExpired() { - compose.setContent { PutioTheme { MobileInactiveAccountNotice(InactiveAccountNotice.FamilyPlanExpired) } } + compose.setBuiltContent { PutioTheme { MobileInactiveAccountNotice(InactiveAccountNotice.FamilyPlanExpired) } } compose.onNodeWithText("Your family plan is no longer active.").assertIsDisplayed() assertNoActionOrPaymentWording() diff --git a/mobile/src/test/kotlin/io/putdotio/android/MobileItemDialogsTest.kt b/mobile/src/test/kotlin/io/putdotio/android/MobileItemDialogsTest.kt index 179791337..edce05e12 100644 --- a/mobile/src/test/kotlin/io/putdotio/android/MobileItemDialogsTest.kt +++ b/mobile/src/test/kotlin/io/putdotio/android/MobileItemDialogsTest.kt @@ -69,7 +69,7 @@ class MobileItemDialogsTest { override suspend fun createFolder(parentId: FilesItemId, name: String): PutioResult = PutioResult.Success(created.copy(parentId = parentId, name = name)) } - compose.setContent { + compose.setBuiltContent { PutioTheme { MobileFilesMoveDestination( state = state, @@ -99,7 +99,7 @@ class MobileItemDialogsTest { MobileShareProgress.progress( MobileShareProgressState("Tears.of.Steel.2012.1080p.mkv", 456_000_000L, 1_200_000_000L), ) - compose.setContent { PutioTheme { MobileShareProgressDialog(onCancel = { cancelled++ }) } } + compose.setBuiltContent { PutioTheme { MobileShareProgressDialog(onCancel = { cancelled++ }) } } compose.onNodeWithText("Preparing to share").assertIsDisplayed() compose.onNodeWithText("Tears.of.Steel.2012.1080p.mkv downloads first, then the share sheet opens.") .assertIsDisplayed() @@ -122,7 +122,7 @@ class MobileItemDialogsTest { val item = trashItem() val events = mutableListOf() val state = TrashState(content = TrashContent.Loaded(listOf(item), null, 1, item.sizeBytes)) - compose.setContent { PutioTheme { MobileTrashScreen(state, { events += it; true }) } } + compose.setBuiltContent { PutioTheme { MobileTrashScreen(state, { events += it; true }) } } compose.onNodeWithContentDescription("Restore ${item.name}").performClick() compose.runOnIdle { assertEquals(listOf(TrashEvent.Restore(item.id)), events) } } diff --git a/mobile/src/test/kotlin/io/putdotio/android/MobileKeyboardShortcutsTest.kt b/mobile/src/test/kotlin/io/putdotio/android/MobileKeyboardShortcutsTest.kt index d62a00d3d..9fee2998c 100644 --- a/mobile/src/test/kotlin/io/putdotio/android/MobileKeyboardShortcutsTest.kt +++ b/mobile/src/test/kotlin/io/putdotio/android/MobileKeyboardShortcutsTest.kt @@ -226,7 +226,7 @@ class MobileKeyboardShortcutsTest { private fun setShell(filesState: FilesBrowserState = rootState(), trashEnabled: Boolean = true) { files = filesState - compose.setContent { + compose.setBuiltContent { PutioTheme { Box(Modifier.requiredSize(width = 900.dp, height = 700.dp)) { MobileShell( diff --git a/mobile/src/test/kotlin/io/putdotio/android/MobileLoggedInAppsTest.kt b/mobile/src/test/kotlin/io/putdotio/android/MobileLoggedInAppsTest.kt index 5d8261d52..6c19b8b20 100644 --- a/mobile/src/test/kotlin/io/putdotio/android/MobileLoggedInAppsTest.kt +++ b/mobile/src/test/kotlin/io/putdotio/android/MobileLoggedInAppsTest.kt @@ -141,7 +141,7 @@ class MobileLoggedInAppsTest { } private fun show(repository: FakeLoggedInAppsRepository) { - compose.setContent { + compose.setBuiltContent { val scope = rememberCoroutineScope() val controller = remember { LoggedInAppsController(repository, scope) } PutioTheme { MobileLoggedInAppsRoute(controller, onAuthenticationRequired = {}) } @@ -150,7 +150,7 @@ class MobileLoggedInAppsTest { } private fun showShell(repository: FakeLoggedInAppsRepository?) { - compose.setContent { + compose.setBuiltContent { PutioTheme { val scope = rememberCoroutineScope() MobileShell( diff --git a/mobile/src/test/kotlin/io/putdotio/android/MobileMiddleCutTextLinesTest.kt b/mobile/src/test/kotlin/io/putdotio/android/MobileMiddleCutTextLinesTest.kt index d745ec670..cd1cbf3c9 100644 --- a/mobile/src/test/kotlin/io/putdotio/android/MobileMiddleCutTextLinesTest.kt +++ b/mobile/src/test/kotlin/io/putdotio/android/MobileMiddleCutTextLinesTest.kt @@ -29,7 +29,7 @@ class MobileMiddleCutTextLinesTest { fun twoLinesWrapANameAndCutOnlyWhatStillDoesNotFit() { val fits = "FFTT Tree Rings October 23, 2026.mp3" val tooLong = "FFTT Tree Rings October 23, 2026, the long uncut interview with everyone who was there.mp3" - compose.setContent { + compose.setBuiltContent { PutioTheme { Column(Modifier.width(240.dp)) { MobileMiddleCutText(fits) diff --git a/mobile/src/test/kotlin/io/putdotio/android/MobileOriginalFallbackTest.kt b/mobile/src/test/kotlin/io/putdotio/android/MobileOriginalFallbackTest.kt index dfa857f3b..033fb5cb4 100644 --- a/mobile/src/test/kotlin/io/putdotio/android/MobileOriginalFallbackTest.kt +++ b/mobile/src/test/kotlin/io/putdotio/android/MobileOriginalFallbackTest.kt @@ -128,7 +128,7 @@ class MobileOriginalFallbackTest { } private fun setScreen() { - compose.setContent { + compose.setBuiltContent { PutioTheme { MobilePlayerScreen( state = state, diff --git a/mobile/src/test/kotlin/io/putdotio/android/MobilePlaybackConfigIntegrationTest.kt b/mobile/src/test/kotlin/io/putdotio/android/MobilePlaybackConfigIntegrationTest.kt index f31109ee5..084a35b38 100644 --- a/mobile/src/test/kotlin/io/putdotio/android/MobilePlaybackConfigIntegrationTest.kt +++ b/mobile/src/test/kotlin/io/putdotio/android/MobilePlaybackConfigIntegrationTest.kt @@ -73,7 +73,7 @@ class MobilePlaybackConfigIntegrationTest { withPlaybackConfigRootFixture { fixture -> var mounted by mutableStateOf(true) try { - compose.setContent { if (mounted) fixture.Content() } + compose.setBuiltContent { if (mounted) fixture.Content() } compose.waitUntil(5_000L) { compose.runOnIdle { fixture.confirmedFormat == StreamingMethod.Hls } } compose.waitUntil(5_000L) { compose.onAllNodesWithText("episode.mkv").fetchSemanticsNodes().isNotEmpty() diff --git a/mobile/src/test/kotlin/io/putdotio/android/MobilePlaybackOptionsTest.kt b/mobile/src/test/kotlin/io/putdotio/android/MobilePlaybackOptionsTest.kt index 8f5a64129..c946e18ff 100644 --- a/mobile/src/test/kotlin/io/putdotio/android/MobilePlaybackOptionsTest.kt +++ b/mobile/src/test/kotlin/io/putdotio/android/MobilePlaybackOptionsTest.kt @@ -102,7 +102,7 @@ class MobilePlaybackOptionsTest { @Test fun videoSpeedSheetStepsThroughThePresetsAndItsChipFollows() { val player = OptionsPlayer() - compose.setContent { + compose.setBuiltContent { PutioTheme { val options = rememberPlayerOptionsSnapshot(player) Column { @@ -133,7 +133,7 @@ class MobilePlaybackOptionsTest { @Test fun castSpeedSheetOffersOnlyTheSpeedsTheReceiverPlays() { val player = OptionsPlayer(remote = true) - compose.setContent { + compose.setBuiltContent { PutioTheme { Column { MobileSpeedSheetContent(player, rememberPlayerOptionsSnapshot(player)) } } @@ -158,7 +158,7 @@ class MobilePlaybackOptionsTest { val player = OptionsPlayer() val selections = mutableListOf() var done = 0 - compose.setContent { + compose.setBuiltContent { PutioTheme { val options = rememberPlayerOptionsSnapshot(player) Column { @@ -184,7 +184,7 @@ class MobilePlaybackOptionsTest { @Test fun nowPlayingSpeedChipOpensTheSameSpeedPresetsAsVideo() { val player = OptionsPlayer() - compose.setContent { PutioTheme { NowPlaying(player) } } + compose.setBuiltContent { PutioTheme { NowPlaying(player) } } compose.onNodeWithContentDescription("Playback speed 1×").performScrollTo().performClick() compose.onNodeWithTag(MOBILE_NOW_PLAYING_SHEET_TAG).assertIsDisplayed() @@ -200,7 +200,7 @@ class MobilePlaybackOptionsTest { fun nowPlayingOffersAudioTracksUnderMoreOnlyWhenThereIsAChoice() { var player by mutableStateOf(OptionsPlayer(singleAudioTrack = true)) val selections = mutableListOf() - compose.setContent { PutioTheme { NowPlaying(player, onAudioSelectionChanged = { selections += it }) } } + compose.setBuiltContent { PutioTheme { NowPlaying(player, onAudioSelectionChanged = { selections += it }) } } compose.onNodeWithContentDescription("More options").assertDoesNotExist() compose.onNodeWithContentDescription("Playback speed 1×").performScrollTo().assertIsEnabled() @@ -223,7 +223,7 @@ class MobilePlaybackOptionsTest { @Test fun sleepTimerChipStartsShowsAndCancelsTheTimer() { val timer = MobileSleepTimer(clock = { 0L }) - compose.setContent { PutioTheme { NowPlaying(OptionsPlayer(), sleepTimer = timer) } } + compose.setBuiltContent { PutioTheme { NowPlaying(OptionsPlayer(), sleepTimer = timer) } } compose.onNodeWithText("Sleep timer").performScrollTo().performClick() compose.onNode(hasText("Off") and isSelectable()).assertIsSelected() @@ -243,7 +243,7 @@ class MobilePlaybackOptionsTest { val next = PlaybackTarget(FilesItemId(43L), "FFTT Tree Rings October 30, 2026.mp3", AUDIO) var neighbours by mutableStateOf(PlaybackNeighbours()) val played = mutableListOf() - compose.setContent { PutioTheme { NowPlaying(OptionsPlayer(), neighbours, onPlay = { played += it }) } } + compose.setBuiltContent { PutioTheme { NowPlaying(OptionsPlayer(), neighbours, onPlay = { played += it }) } } compose.onNodeWithTag(MOBILE_AUDIO_PREVIOUS_TAG).assertIsNotEnabled() compose.onNodeWithTag(MOBILE_AUDIO_NEXT_TAG).assertIsNotEnabled() @@ -268,7 +268,7 @@ class MobilePlaybackOptionsTest { val player = OptionsPlayer( audioGroup = TrackGroup(format("a", "English"), format("b", "English"), format("c", "English (track 1)")), ) - compose.setContent { + compose.setBuiltContent { PutioTheme { val options = rememberPlayerOptionsSnapshot(player) MobileAudioSheetContent(player, options, {}, {}) @@ -289,7 +289,7 @@ class MobilePlaybackOptionsTest { val second = format("second") val player = OptionsPlayer(audioGroup = TrackGroup(first, second, format("third"))) var selection: AudioSelection = AudioSelection.Automatic - compose.setContent { + compose.setBuiltContent { PutioTheme { val options = rememberPlayerOptionsSnapshot(player) MobileAudioSheetContent(player, options, { selection = it }, {}) @@ -326,7 +326,7 @@ class MobilePlaybackOptionsTest { .build() val player = OptionsPlayer(audioGroup = TrackGroup(format, format)) var selection: AudioSelection = AudioSelection.Automatic - compose.setContent { + compose.setBuiltContent { PutioTheme { val options = rememberPlayerOptionsSnapshot(player) MobileAudioSheetContent(player, options, { selection = it }, {}) @@ -353,7 +353,7 @@ class MobilePlaybackOptionsTest { @Test fun unavailableCommandsDisableSpeedAndAudioChoices() { val player = OptionsPlayer(canChangeOptions = false) - compose.setContent { + compose.setBuiltContent { PutioTheme { val options = rememberPlayerOptionsSnapshot(player) Column { @@ -396,7 +396,7 @@ class MobilePlaybackOptionsTest { val player = OptionsPlayer() var keyboardEvents = 0 lateinit var inputMode: InputModeManager - compose.setContent { + compose.setBuiltContent { inputMode = LocalInputModeManager.current PutioTheme { PlaybackOption( diff --git a/mobile/src/test/kotlin/io/putdotio/android/MobilePlayerChromeTest.kt b/mobile/src/test/kotlin/io/putdotio/android/MobilePlayerChromeTest.kt index 0253260b7..7ace93550 100644 --- a/mobile/src/test/kotlin/io/putdotio/android/MobilePlayerChromeTest.kt +++ b/mobile/src/test/kotlin/io/putdotio/android/MobilePlayerChromeTest.kt @@ -73,7 +73,7 @@ class MobilePlayerChromeTest { fun accessibilityProgressActionSeeksOnceAndReportsTheNewPosition() { val player = readyPlayer() var scrubs = 0 - compose.setContent { + compose.setBuiltContent { PutioTheme { MobileProgressSlider(player, onScrub = { scrubs += 1 }) } } compose.onNodeWithTag(TIMELINE_TAG).performSemanticsAction(SemanticsActions.SetProgress) { setProgress -> @@ -91,7 +91,7 @@ class MobilePlayerChromeTest { fun shortVideoWindowKeepsAllControlsReachableAtDoubleFontScale() { val player = readyPlayer().apply { updateTracks(englishAudio()) } var pixelsPerDp = 1f - compose.setContent { + compose.setBuiltContent { val density = LocalDensity.current.density pixelsPerDp = density CompositionLocalProvider(LocalDensity provides Density(density, fontScale = 2f)) { @@ -149,7 +149,7 @@ class MobilePlayerChromeTest { val player = readyPlayer() val fold = 230.dp val fits = mutableListOf() - compose.setContent { + compose.setBuiltContent { PutioTheme { Box(Modifier.size(width = 320.dp, height = 460.dp)) { MobilePlayerChrome( @@ -184,7 +184,7 @@ class MobilePlayerChromeTest { fun aFoldTooLowForTheControlsSaysTheyDoNotFitIt() { val player = readyPlayer() val fits = mutableListOf() - compose.setContent { + compose.setBuiltContent { PutioTheme { Box(Modifier.size(width = 320.dp, height = 460.dp)) { MobilePlayerChrome( @@ -212,7 +212,7 @@ class MobilePlayerChromeTest { var scrubs = 0 lateinit var host: View lateinit var inputMode: InputModeManager - compose.setContent { + compose.setBuiltContent { host = LocalView.current inputMode = LocalInputModeManager.current PutioTheme { MobileProgressSlider(player, onScrub = { scrubs += 1 }) } @@ -245,7 +245,7 @@ class MobilePlayerChromeTest { val player = readyPlayer() var scrubs = 0 lateinit var inputMode: InputModeManager - compose.setContent { + compose.setBuiltContent { inputMode = LocalInputModeManager.current PutioTheme { MobileProgressSlider(player, onScrub = { scrubs += 1 }) } } @@ -269,7 +269,7 @@ class MobilePlayerChromeTest { val player = readyPlayer() lateinit var inputMode: InputModeManager lateinit var focusManager: FocusManager - compose.setContent { + compose.setBuiltContent { inputMode = LocalInputModeManager.current focusManager = LocalFocusManager.current PutioTheme { MobileProgressSlider(player) } @@ -296,7 +296,7 @@ class MobilePlayerChromeTest { val player = readyPlayer() var scrubs = 0 lateinit var inputMode: InputModeManager - compose.setContent { + compose.setBuiltContent { inputMode = LocalInputModeManager.current PutioTheme { MobileProgressSlider(player, onScrub = { scrubs += 1 }) } } @@ -330,7 +330,7 @@ class MobilePlayerChromeTest { fun unknownDurationDisablesScrubbingAndDoesNotReportAnInteraction() { val player = readyPlayer(durationMillis = 0L) var scrubs = 0 - compose.setContent { + compose.setBuiltContent { PutioTheme { MobileProgressSlider(player, onScrub = { scrubs += 1 }) } } diff --git a/mobile/src/test/kotlin/io/putdotio/android/MobilePlayerScreenTest.kt b/mobile/src/test/kotlin/io/putdotio/android/MobilePlayerScreenTest.kt index 20e058ee8..379338625 100644 --- a/mobile/src/test/kotlin/io/putdotio/android/MobilePlayerScreenTest.kt +++ b/mobile/src/test/kotlin/io/putdotio/android/MobilePlayerScreenTest.kt @@ -215,7 +215,7 @@ class MobilePlayerScreenTest { fun theWindowTurnsToLandscapeOnlyForALandscapeVideo() { val player = RecordingPlayer() var activity: Activity? = null - compose.setContent { + compose.setBuiltContent { activity = LocalActivity.current PutioTheme { MobilePlayerScreen( @@ -250,7 +250,7 @@ class MobilePlayerScreenTest { var visible by mutableStateOf(true) var cancellations = 0 var creations = 0 - compose.setContent { + compose.setBuiltContent { PutioTheme { if (visible) MobilePlayerScreen( state = pending, @@ -277,7 +277,7 @@ class MobilePlayerScreenTest { content = PlaybackContent.AwaitingResume((original.content as PlaybackContent.Ready).source), )) val players = mutableListOf() - compose.setContent { + compose.setBuiltContent { PutioTheme { MobilePlayerScreen( state = state, @@ -311,7 +311,7 @@ class MobilePlayerScreenTest { return 10_000L } } - compose.setContent { + compose.setBuiltContent { CompositionLocalProvider(LocalAccessibilityManager provides accessibility) { PutioTheme { MobilePlayerScreen( @@ -341,7 +341,7 @@ class MobilePlayerScreenTest { ) accessibility.setTouchExplorationEnabled(false) lateinit var playerContext: Context - compose.setContent { + compose.setBuiltContent { playerContext = androidx.compose.ui.platform.LocalContext.current PutioTheme { MobilePlayerScreen( @@ -376,7 +376,7 @@ class MobilePlayerScreenTest { var refreshes = 0 var backs = 0 compose.mainClock.autoAdvance = false - compose.setContent { + compose.setBuiltContent { PutioTheme { MobilePlayerScreen( state = state(PlaybackContent.Conversion(PlaybackConversionState.Converting(42.0))), @@ -402,7 +402,7 @@ class MobilePlayerScreenTest { fun aQueuedConversionSaysItIsWaitingAndCancelGoesBack() { var content by mutableStateOf(PlaybackContent.Conversion(PlaybackConversionState.Queued)) var backs = 0 - compose.setContent { + compose.setBuiltContent { PutioTheme { MobilePlayerScreen( state = state(content), @@ -430,7 +430,7 @@ class MobilePlayerScreenTest { var refreshes = 0 var retries = 0 compose.mainClock.autoAdvance = false - compose.setContent { + compose.setBuiltContent { PutioTheme { MobilePlayerScreen( state = state( @@ -462,7 +462,7 @@ class MobilePlayerScreenTest { PlaybackContent.Conversion(PlaybackConversionState.NotAvailable, PlaybackRequestId(2L)), ) var starts = 0 - compose.setContent { + compose.setBuiltContent { PutioTheme { MobilePlayerScreen( state = state(content), @@ -497,7 +497,7 @@ class MobilePlayerScreenTest { var content by mutableStateOf(rows.first().content) var retries = 0 var backs = 0 - compose.setContent { + compose.setBuiltContent { PutioTheme { MobilePlayerScreen( state = state(content), @@ -674,7 +674,7 @@ class MobilePlayerLifecycleTest { val playerFactory = MobilePlayerFactory { _, _ -> RecordingPlayer().also(players::add) } - compose.setContent { + compose.setBuiltContent { PutioTheme { MobilePlayerScreen( state = state(content.value).copyForTest(resumePositionMillis = 12_345L), @@ -705,7 +705,7 @@ class MobilePlayerLifecycleTest { null, PlaybackException.ERROR_CODE_TIMEOUT, ) - compose.setContent { + compose.setBuiltContent { CompositionLocalProvider(LocalLifecycleOwner provides lifecycleOwner) { PutioTheme { MobilePlayerScreen( @@ -760,7 +760,7 @@ class MobilePlayerLifecycleTest { fun playerRecreatesAfterCoalescedStopAndStartWithoutResume() { val lifecycleOwner = PlayerLifecycleOwner().apply { moveTo(Lifecycle.State.RESUMED) } val players = mutableListOf() - compose.setContent { + compose.setBuiltContent { CompositionLocalProvider(LocalLifecycleOwner provides lifecycleOwner) { PutioTheme { MobilePlayerScreen( @@ -796,7 +796,7 @@ class MobilePlayerLifecycleTest { lateinit var player: RecordingPlayer var autoplayEnabled by mutableStateOf(true) var endedCalls = 0 - compose.setContent { + compose.setBuiltContent { PutioTheme { MobilePlayerScreen( state = state( @@ -929,7 +929,7 @@ class MobilePlayerLifecycleTest { autoplay: () -> Boolean = { true }, onPlayer: (RecordingPlayer) -> Unit, ) { - compose.setContent { + compose.setBuiltContent { PutioTheme { MobilePlayerScreen( state = state(PlaybackContent.Ready(videoSource())), @@ -952,7 +952,7 @@ class MobilePlayerLifecycleTest { fun pausingVideoLetsTheScreenSleep() { lateinit var player: RecordingPlayer var hostView: View? = null - compose.setContent { + compose.setBuiltContent { PutioTheme { hostView = LocalView.current MobilePlayerScreen( @@ -988,7 +988,7 @@ class MobilePlayerSubtitleTest { fun accountSubtitlePolicyAppliesWhenSettingsBecomeReady() { val player = RecordingPlayer() var policy by mutableStateOf(null) - compose.setContent { + compose.setBuiltContent { PutioTheme { MobilePlayerScreen( state = state(PlaybackContent.Ready(videoSource())), @@ -1056,7 +1056,7 @@ class MobilePlayerSubtitleTest { player.trackSelectionParameters = player.trackSelectionParameters.buildUpon() .setPreferredTextLanguage("en").build() } - compose.setContent { + compose.setBuiltContent { PutioTheme { MobilePlayerScreen( state = state(PlaybackContent.Ready(videoSource())), @@ -1166,7 +1166,7 @@ class MobilePlayerSubtitleTest { fun hidingThatArrivesAfterAPickTurnsSubtitlesOffAndRemovesTheCaptionsPicker() { val player = RecordingPlayer() var policy by mutableStateOf(null) - compose.setContent { + compose.setBuiltContent { PutioTheme { MobilePlayerScreen( state = state(PlaybackContent.Ready(videoSource())), @@ -1330,7 +1330,7 @@ class MobilePlayerDoubleTapTest { @Test fun compactVideoScrollPreservesTapsAndConsumesControlGestures() { lateinit var player: RecordingPlayer - compose.setContent { + compose.setBuiltContent { CompositionLocalProvider(LocalDensity provides Density(LocalDensity.current.density, fontScale = 2f)) { PutioTheme { Box(Modifier.requiredSize(320.dp, 180.dp)) { @@ -1440,7 +1440,7 @@ class MobilePlayerDoubleTapTest { val player = RecordingPlayer(seekable = false) var timelineEventDelivered = false var updatedBeforeDoubleTap = false - compose.setContent { + compose.setBuiltContent { PutioTheme { Box(Modifier.fillMaxSize().pointerInput(Unit) { var releases = 0 @@ -1492,7 +1492,7 @@ class MobilePlayerDoubleTapTest { lateinit var host: View var leftInset = 0 var rightInset = 0 - compose.setContent { + compose.setBuiltContent { host = LocalView.current val density = androidx.compose.ui.platform.LocalDensity.current leftInset = WindowInsets.safeGestures.getLeft(density, LayoutDirection.Ltr) @@ -1539,7 +1539,7 @@ class MobilePlayerDoubleTapTest { @Test fun rtlSeekFeedbackStaysOnThePhysicalTappedSide() { val player = RecordingPlayer() - compose.setContent { + compose.setBuiltContent { CompositionLocalProvider(LocalLayoutDirection provides LayoutDirection.Rtl) { PutioTheme { MobilePlayerScreen( @@ -1638,7 +1638,7 @@ class MobilePlayerSeekTest { @Test fun fractionalSeekFeedbackAnnouncesTheBoundaryMovement() { var movement by mutableStateOf(500L) - compose.setContent { + compose.setBuiltContent { PutioTheme { MobileSeekFeedback( PendingSeek( @@ -1876,7 +1876,7 @@ class MobilePlayerSeekTest { return 5_000L } } - compose.setContent { + compose.setBuiltContent { CompositionLocalProvider(LocalAccessibilityManager provides accessibility) { PutioTheme { MobilePlayerScreen( @@ -1937,7 +1937,7 @@ class MobilePlayerSourceFreeSessionTest { ) session.trackSelectionParameters = selected var sourceRequests = 0 - compose.setContent { + compose.setBuiltContent { PutioTheme { MobilePlayerScreen( state = state(PlaybackContent.Session, AudioTarget), @@ -2040,7 +2040,7 @@ class MobilePlayerSourceFreeSessionTest { val initialMediaItems = session.mediaItemUpdates var content by mutableStateOf(PlaybackContent.Session) val positions = mutableListOf() - compose.setContent { + compose.setBuiltContent { PutioTheme { MobilePlayerScreen( state = state(content, AudioTarget), @@ -2073,7 +2073,7 @@ class MobilePlayerSourceFreeSessionTest { val failures = mutableListOf>() var sourceRequests = 0 var retries = 0 - compose.setContent { + compose.setBuiltContent { PutioTheme { MobilePlayerScreen( state = state(content, AudioTarget), @@ -2190,7 +2190,7 @@ class MobilePlayerAudioTest { val prepareCallsBefore = session.prepareCalls var closed = 0 var showPlayer by mutableStateOf(true) - compose.setContent { + compose.setBuiltContent { CompositionLocalProvider(LocalLifecycleOwner provides lifecycleOwner) { PutioTheme { if (showPlayer) { @@ -2237,7 +2237,7 @@ class MobilePlayerAudioTest { fun sessionAudioStartsEvenWhileTheScreenIsPausedBehindADialog() { val lifecycleOwner = PlayerLifecycleOwner().apply { moveTo(Lifecycle.State.STARTED) } val session = RecordingPlayer() - compose.setContent { + compose.setBuiltContent { CompositionLocalProvider(LocalLifecycleOwner provides lifecycleOwner) { PutioTheme { MobilePlayerScreen( @@ -2284,7 +2284,7 @@ class MobilePlayerAudioTest { session.setMediaItem(audioSource().toMediaItem("song.mp3", PlaybackMediaType.AUDIO), 10_000L) session.prepare() session.play() - compose.setContent { + compose.setBuiltContent { CompositionLocalProvider(LocalLifecycleOwner provides lifecycleOwner) { PutioTheme { MobilePlayerScreen( @@ -2446,7 +2446,7 @@ class MobilePlayerAudioTest { fun audioPlaybackNeverHoldsTheScreenAwake() { lateinit var player: RecordingPlayer var hostView: View? = null - compose.setContent { + compose.setBuiltContent { PutioTheme { hostView = LocalView.current MobilePlayerScreen( @@ -2470,7 +2470,7 @@ class MobilePlayerAudioTest { @Test fun audioLoadingAndFailureStatesUseAudioCopy() { var content by mutableStateOf(PlaybackContent.Loading(PlaybackRequestId(1L))) - compose.setContent { + compose.setBuiltContent { PutioTheme { MobilePlayerScreen( state = state(content, AudioTarget), @@ -2552,7 +2552,7 @@ class MobilePlayerKeyboardTest { val lifecycleOwner = PlayerLifecycleOwner().apply { moveTo(Lifecycle.State.RESUMED) } val players = mutableListOf() shadowOf(compose.activity).setInMultiWindowMode(true) - compose.setContent { + compose.setBuiltContent { CompositionLocalProvider(LocalLifecycleOwner provides lifecycleOwner) { PutioTheme { MobilePlayerScreen( @@ -2588,7 +2588,7 @@ class MobilePlayerKeyboardTest { val lifecycleOwner = PlayerLifecycleOwner().apply { moveTo(Lifecycle.State.RESUMED) } val players = mutableListOf() shadowOf(compose.activity).setInMultiWindowMode(true) - compose.setContent { + compose.setBuiltContent { CompositionLocalProvider(LocalLifecycleOwner provides lifecycleOwner) { PutioTheme { MobilePlayerScreen( diff --git a/mobile/src/test/kotlin/io/putdotio/android/MobileProductAnalyticsPromptTest.kt b/mobile/src/test/kotlin/io/putdotio/android/MobileProductAnalyticsPromptTest.kt index 7444ebf4f..00e1d682d 100644 --- a/mobile/src/test/kotlin/io/putdotio/android/MobileProductAnalyticsPromptTest.kt +++ b/mobile/src/test/kotlin/io/putdotio/android/MobileProductAnalyticsPromptTest.kt @@ -140,7 +140,7 @@ class MobileProductAnalyticsPromptTest { @Test fun aLaunchThatOpensALinkSkipsTheAsk() { - compose.setContent { + compose.setBuiltContent { PutioTheme { AskingHost( sessionId = MobileAuthSessionId(1L), @@ -162,7 +162,7 @@ class MobileProductAnalyticsPromptTest { assertEquals(MobileProductAnalyticsPromptMode.Forced, MobileProductAnalyticsPromptMode.of(true, true)) var mode by mutableStateOf(MobileProductAnalyticsPromptMode.Suppressed) - compose.setContent { + compose.setBuiltContent { PutioTheme { key(mode) { CompositionLocalProvider(LocalMobileProductAnalyticsPromptMode provides mode) { @@ -188,7 +188,7 @@ class MobileProductAnalyticsPromptTest { @Test fun theHostAsksWhileAnalyticsIsOffAndUnanswered() { - compose.setContent { + compose.setBuiltContent { PutioTheme { AskingHost( sessionId = MobileAuthSessionId(1L), @@ -205,7 +205,7 @@ class MobileProductAnalyticsPromptTest { private fun show(): List { val dismissed = mutableListOf() - compose.setContent { + compose.setBuiltContent { PutioTheme { MobileProductAnalyticsPrompt( settingsState = settings, diff --git a/mobile/src/test/kotlin/io/putdotio/android/MobilePublicLinksTest.kt b/mobile/src/test/kotlin/io/putdotio/android/MobilePublicLinksTest.kt index 2a87b904a..0cef90be6 100644 --- a/mobile/src/test/kotlin/io/putdotio/android/MobilePublicLinksTest.kt +++ b/mobile/src/test/kotlin/io/putdotio/android/MobilePublicLinksTest.kt @@ -84,7 +84,7 @@ class MobilePublicLinksTest { @Test fun onlyTheViewersOwnItemsOfferExclusiveAccess() { val items = listOf(video, folder, friendsFile, sharedRoot) - compose.setContent { FilesWithLinks(FakePublicLinksRepository(), items) } + compose.setBuiltContent { FilesWithLinks(FakePublicLinksRepository(), items) } compose.onNodeWithContentDescription("Actions for ${friendsFile.name}").performClick() compose.onNodeWithTag(MOBILE_FILES_PUBLIC_LINK_ACTION_TAG).assertDoesNotExist() @@ -102,7 +102,7 @@ class MobilePublicLinksTest { val existing = publicLink(id = 3L, fileId = video.id.value, token = "existing") val otherItem = publicLink(id = 4L, fileId = folder.id.value, token = "other") val repository = FakePublicLinksRepository(listOf(existing, otherItem)) - compose.setContent { FilesWithLinks(repository, listOf(video, folder)) } + compose.setBuiltContent { FilesWithLinks(repository, listOf(video, folder)) } openSheet(video) compose.onNodeWithTag(mobilePublicLinkCopyTag(existing.id)).assertIsDisplayed() @@ -130,7 +130,7 @@ class MobilePublicLinksTest { val revoked = publicLink(id = 3L, fileId = video.id.value) val kept = publicLink(id = 2L, fileId = video.id.value) val repository = FakePublicLinksRepository(listOf(kept, revoked)) - compose.setContent { FilesWithLinks(repository, listOf(video)) } + compose.setBuiltContent { FilesWithLinks(repository, listOf(video)) } openSheet(video) compose.onNodeWithTag(mobilePublicLinkRevokeTag(revoked.id)).performClick() @@ -154,7 +154,7 @@ class MobilePublicLinksTest { repository.onCreate = { PutioResult.Failure(refusal(403, "PUBLIC_SHARE_DAILY_TOTAL_LINK_COUNT_EXCEEDED", "Daily limit")) } - compose.setContent { FilesWithLinks(repository, listOf(video)) } + compose.setBuiltContent { FilesWithLinks(repository, listOf(video)) } openSheet(video) compose.onNodeWithTag(MOBILE_PUBLIC_LINK_CREATE_TAG).performClick() @@ -171,7 +171,7 @@ class MobilePublicLinksTest { val existing = publicLink(id = 3L, fileId = video.id.value, token = "existing") val repository = FakePublicLinksRepository(listOf(existing)) var announced = 0 - compose.setContent { + compose.setBuiltContent { FilesWithLinks(repository, listOf(video), MobileFilesItemActions(onLinkCopied = { announced++ })) } @@ -189,7 +189,7 @@ class MobilePublicLinksTest { fun createWaitsForTheItemsLinksToLoad() { val repository = FakePublicLinksRepository() repository.onList = { PutioResult.Failure(PutioFailure.NetworkUnavailable(IllegalStateException("offline"))) } - compose.setContent { FilesWithLinks(repository, listOf(video)) } + compose.setBuiltContent { FilesWithLinks(repository, listOf(video)) } openSheet(video) compose.onNodeWithText("Check your connection and try again.").assertIsDisplayed() @@ -206,7 +206,7 @@ class MobilePublicLinksTest { val first = publicLink(id = 3L, fileId = video.id.value, name = video.name) val second = publicLink(id = 4L, fileId = folder.id.value, name = folder.name, type = PutioFileType.FOLDER) val repository = FakePublicLinksRepository(listOf(first, second)) - compose.setContent { + compose.setBuiltContent { PutioTheme { WithLinks(repository) { MobilePublicLinksScreen(it) } } } @@ -227,7 +227,7 @@ class MobilePublicLinksTest { @Test fun accountOpensExclusiveAccessAsASubpageThatBackLeaves() { val repository = FakePublicLinksRepository(listOf(publicLink(id = 3L, name = video.name))) - compose.setContent { + compose.setBuiltContent { PutioTheme { val scope = rememberCoroutineScope() MobileShell( diff --git a/mobile/src/test/kotlin/io/putdotio/android/MobileResumePlaybackDialogTest.kt b/mobile/src/test/kotlin/io/putdotio/android/MobileResumePlaybackDialogTest.kt index 77dc893aa..e51f3ffba 100644 --- a/mobile/src/test/kotlin/io/putdotio/android/MobileResumePlaybackDialogTest.kt +++ b/mobile/src/test/kotlin/io/putdotio/android/MobileResumePlaybackDialogTest.kt @@ -34,7 +34,7 @@ class MobileResumePlaybackDialogTest { fun bothChoicesRemainReachableAtLargeFontInShortLandscape() { var resumed = 0 var restarted = 0 - compose.setContent { + compose.setBuiltContent { PutioTheme { MobileResumePlaybackDialog( startFromSeconds = 3723.0, diff --git a/mobile/src/test/kotlin/io/putdotio/android/MobileRetryWhenOnlineTest.kt b/mobile/src/test/kotlin/io/putdotio/android/MobileRetryWhenOnlineTest.kt index ef252e2ca..6f2509b86 100644 --- a/mobile/src/test/kotlin/io/putdotio/android/MobileRetryWhenOnlineTest.kt +++ b/mobile/src/test/kotlin/io/putdotio/android/MobileRetryWhenOnlineTest.kt @@ -57,7 +57,7 @@ class MobileRetryWhenOnlineTest { } private fun showRetry() { - compose.setContent { + compose.setBuiltContent { CompositionLocalProvider(LocalLifecycleOwner provides owner) { RetryWhenOnline(failure = "offline") { retries++ } } diff --git a/mobile/src/test/kotlin/io/putdotio/android/MobileSearchScreensLayoutTest.kt b/mobile/src/test/kotlin/io/putdotio/android/MobileSearchScreensLayoutTest.kt index 0e204e1e6..8dabe4e2a 100644 --- a/mobile/src/test/kotlin/io/putdotio/android/MobileSearchScreensLayoutTest.kt +++ b/mobile/src/test/kotlin/io/putdotio/android/MobileSearchScreensLayoutTest.kt @@ -162,7 +162,7 @@ class MobileSearchScreensLayoutTest { HistoryPaging.Complete, ), ) - compose.setContent { + compose.setBuiltContent { PutioTheme { Box(Modifier.fillMaxSize().testTag(VIEWPORT)) { if (history != null) { diff --git a/mobile/src/test/kotlin/io/putdotio/android/MobileSearchScreensTest.kt b/mobile/src/test/kotlin/io/putdotio/android/MobileSearchScreensTest.kt index 956526b89..8ddf1c908 100644 --- a/mobile/src/test/kotlin/io/putdotio/android/MobileSearchScreensTest.kt +++ b/mobile/src/test/kotlin/io/putdotio/android/MobileSearchScreensTest.kt @@ -124,7 +124,7 @@ class MobileSearchScreensTest { fun aTypeChipSearchesThatTypeAndNothingFoundAtAllDropsTheChips() { val chosen = mutableListOf() var search by mutableStateOf(searchState(SearchContent.Idle)) - compose.setContent { + compose.setBuiltContent { PutioTheme { MobileSearchScreen( searchState = search, @@ -162,7 +162,7 @@ class MobileSearchScreensTest { fun theBarSendsTypingUpTakesAQuerySetElsewhereAndClears() { val sent = mutableListOf() var replacement by mutableStateOf(null) - compose.setContent { + compose.setBuiltContent { PutioTheme { MobileSearchBar( query = "", @@ -309,7 +309,7 @@ class MobileSearchScreensTest { fun clearHistorySitsInTheOverflowAndWaitsWhileAClearRuns() { val events = mutableListOf() var clearing by mutableStateOf(HistoryClearing.Idle) - compose.setContent { PutioTheme { MobileHistoryOverflow(clearing, events::add) } } + compose.setBuiltContent { PutioTheme { MobileHistoryOverflow(clearing, events::add) } } compose.onNodeWithContentDescription("More options").performClick() compose.onNodeWithText("Clear history").performClick() @@ -392,7 +392,7 @@ class MobileSearchScreensTest { ) val events = mutableListOf() val build = StandardTestDispatcher() - compose.setContent { + compose.setBuiltContent { CompositionLocalProvider(LocalBuildDispatcher provides build) { PutioTheme { MobileHistoryScreen(historyState = history, onHistoryEvent = events::add, today = TODAY) @@ -443,7 +443,7 @@ class MobileSearchScreensTest { ) val events = mutableListOf() val build = StandardTestDispatcher() - compose.setContent { + compose.setBuiltContent { CompositionLocalProvider(LocalBuildDispatcher provides build) { PutioTheme { MobileHistoryScreen(historyState = history, onHistoryEvent = events::add, today = TODAY) @@ -548,7 +548,7 @@ class MobileSearchScreensTest { history: HistoryState, actions: MobileSearchHistoryActions = MobileSearchHistoryActions(), ) { - compose.setContent { + compose.setBuiltContent { PutioTheme { MobileHistoryScreen(historyState = history, onHistoryEvent = actions.onHistoryEvent, today = TODAY) } @@ -562,7 +562,7 @@ class MobileSearchScreensTest { actions: MobileSearchHistoryActions = MobileSearchHistoryActions(), folderNames: Map = emptyMap(), ) { - compose.setContent { + compose.setBuiltContent { PutioTheme { MobileSearchScreen( searchState = search, diff --git a/mobile/src/test/kotlin/io/putdotio/android/MobileShellDownloadsTest.kt b/mobile/src/test/kotlin/io/putdotio/android/MobileShellDownloadsTest.kt index 71a5d7166..10e8e28c9 100644 --- a/mobile/src/test/kotlin/io/putdotio/android/MobileShellDownloadsTest.kt +++ b/mobile/src/test/kotlin/io/putdotio/android/MobileShellDownloadsTest.kt @@ -161,7 +161,7 @@ class MobileShellDownloadsTest { showSubtitles: Boolean = true, ) { val controller = DownloadsController(store, engine, scope) - compose.setContent { + compose.setBuiltContent { PutioTheme { MobileShell( filesStates = rememberUpdatedState(filesState), diff --git a/mobile/src/test/kotlin/io/putdotio/android/MobileShellLinkActionsTest.kt b/mobile/src/test/kotlin/io/putdotio/android/MobileShellLinkActionsTest.kt index f9e84b6e9..5552658f7 100644 --- a/mobile/src/test/kotlin/io/putdotio/android/MobileShellLinkActionsTest.kt +++ b/mobile/src/test/kotlin/io/putdotio/android/MobileShellLinkActionsTest.kt @@ -136,7 +136,7 @@ class MobileShellLinkActionsTest { private fun setShell(draft: MobileTransferDraft = MobileTransferDraft()) { val controller = DownloadsController(store, FakeDownloadEngine(), scope) - compose.setContent { + compose.setBuiltContent { PutioTheme { MobileShell( filesStates = rememberUpdatedState(FilesBrowserReducer.start().state), diff --git a/mobile/src/test/kotlin/io/putdotio/android/MobileShellTest.kt b/mobile/src/test/kotlin/io/putdotio/android/MobileShellTest.kt index 21a95bdc9..68b25bc2d 100644 --- a/mobile/src/test/kotlin/io/putdotio/android/MobileShellTest.kt +++ b/mobile/src/test/kotlin/io/putdotio/android/MobileShellTest.kt @@ -193,7 +193,7 @@ class MobileShellTest { nextRequestValue = 2L, ) - compose.setContent { + compose.setBuiltContent { AuthoritativeSessionFailureEffect( shouldReject = settingsRequireSessionRejection( accountSettingsState = readyAccountSettingsState(), @@ -233,7 +233,7 @@ class MobileShellTest { @Test fun tabletWidthUsesNavigationRail() { - compose.setContent { + compose.setBuiltContent { PutioTheme { Box(modifier = Modifier.requiredSize(width = 700.dp, height = 500.dp)) { MobileShell( @@ -275,7 +275,7 @@ class MobileShellTest { } private fun showAppInfo() { - compose.setContent { + compose.setBuiltContent { PutioTheme { MobileShell( playbackPlayerFactory = NoAudioSessionFactory, @@ -301,7 +301,7 @@ class MobileShellTest { @Test fun phoneBarOffersShareOnFileRows() { val shared = mutableListOf() - compose.setContent { + compose.setBuiltContent { PutioTheme { Box(modifier = Modifier.requiredSize(width = 360.dp, height = 640.dp)) { MobileShell( @@ -365,7 +365,7 @@ class MobileShellTest { @Test fun compactPhoneShellBringsRecoverableFailureIntoView() { var settingsState by mutableStateOf(readyAccountSettingsState()) - compose.setContent { + compose.setBuiltContent { PutioTheme { Box(modifier = Modifier.requiredSize(width = 360.dp, height = 240.dp)) { MobileShell( @@ -423,7 +423,7 @@ class MobileShellTest { val currentEvents = mutableListOf() var useCurrentCallback by mutableStateOf(false) val item = shellResolvedFolder() - compose.setContent { + compose.setBuiltContent { PutioTheme { MobileShell( playbackPlayerFactory = NoAudioSessionFactory, @@ -469,7 +469,7 @@ class MobileShellTest { val retained = pendingShellDeleteState() val events = mutableListOf() val resolved = shellResolvedFolder() - compose.setContent { + compose.setBuiltContent { PutioTheme { MobileShell( playbackPlayerFactory = NoAudioSessionFactory, @@ -511,7 +511,7 @@ class MobileShellTest { @Test fun inactiveAccountNoticeStaysAboveEveryDestinationAndActiveAccountsShowNone() { var account by mutableStateOf(Account.copy(inactiveNotice = InactiveAccountNotice.Deactivated(null))) - compose.setContent { + compose.setBuiltContent { PutioTheme { MobileShell( playbackPlayerFactory = NoAudioSessionFactory, @@ -570,7 +570,7 @@ class MobileShellTest { fun historyOffHidesItsTabAndSendsHistoryToFiles() { val requests = MobileDeepLinkRequests.None var settings by mutableStateOf(readyAccountSettingsState()) - compose.setContent { + compose.setBuiltContent { PutioTheme { MobileShell( deepLinkRequests = requests, @@ -616,7 +616,7 @@ class MobileShellTest { mutation = AccountSettingsMutation.Idle, nextRequestValue = 2L, ) - compose.setContent { + compose.setBuiltContent { PutioTheme { MobileShell( deepLinkRequests = requests, @@ -658,7 +658,7 @@ class MobileShellTest { nextRequestValue = 2L, ), ) - compose.setContent { + compose.setBuiltContent { PutioTheme { MobileShell( deepLinkRequests = requests, @@ -763,7 +763,7 @@ class MobileShellShareTest { draft.receive(parseMobileSharedTransfer("https://example.invalid/shared")) var files by mutableStateOf(pendingShellDeleteState()) val events = mutableListOf() - compose.setContent { + compose.setBuiltContent { PutioTheme { MobileShell( transferDraft = draft, @@ -859,7 +859,7 @@ class MobileShellShareTest { events: MutableList, ) { var transfers by mutableStateOf(resolvingTransfersState()) - compose.setContent { + compose.setBuiltContent { PutioTheme { MobileShell( transferDraft = draft, @@ -895,7 +895,7 @@ class MobileShellShareTest { ), )) val events = mutableListOf() - compose.setContent { + compose.setBuiltContent { PutioTheme { MobileShell( transferDraft = draft, @@ -1004,7 +1004,7 @@ class MobileShellShareTest { override suspend fun activeAudio(context: Context): ActiveAudio? = resolved.await() } val events = mutableListOf() - compose.setContent { + compose.setBuiltContent { PutioTheme { MobileShell( transferDraft = draft, @@ -1057,7 +1057,7 @@ class MobileShellShareTest { override suspend fun activeAudio(context: Context) = ActiveAudio(FilesItemId(9L), "song.mp3") } - compose.setContent { + compose.setBuiltContent { PutioTheme { MobileShell( transferDraft = draft, @@ -1103,7 +1103,7 @@ class MobileShellFilesTest { val change = AccountSettingsChange(AccountSettingsKey.Trash, enabled = false) var settings by mutableStateOf(readyAccountSettingsState(preferences = original)) val events = mutableListOf() - compose.setContent { + compose.setBuiltContent { PutioTheme { MobileShell( playbackPlayerFactory = NoAudioSessionFactory, @@ -1240,7 +1240,7 @@ class MobileShellFilesTest { fun openFilesSortMenuClosesWhenLoadingStarts() { var filesState by mutableStateOf(readyFilesState(FilesSort.NAME_ASCENDING)) val events = mutableListOf() - compose.setContent { + compose.setBuiltContent { PutioTheme { MobileShell( playbackPlayerFactory = NoAudioSessionFactory, @@ -1283,7 +1283,7 @@ class MobileShellFilesTest { val events = mutableListOf() // Starts as a server value this app does not know; saving a known sort must still invalidate. var settingsState by mutableStateOf(readyAccountSettingsState(preferences = DefaultAccountSettingsPreferences)) - compose.setContent { + compose.setBuiltContent { PutioTheme { MobileShell( playbackPlayerFactory = NoAudioSessionFactory, @@ -1346,7 +1346,7 @@ class MobileShellFilesTest { val loaded = AccountSettingsEvent.LoadSucceeded(AccountSettingsRequestId(1L), DefaultAccountSettingsPreferences) var settingsState by mutableStateOf(reducer.reduce(reducer.start().state, loaded).state) val offline = AccountSettingsFailure.Putio(PutioFailure.Unexpected(IllegalStateException("offline"))) - compose.setContent { + compose.setBuiltContent { PutioTheme { MobileShell( playbackPlayerFactory = NoAudioSessionFactory, @@ -1404,7 +1404,7 @@ class MobileShellTransfersTest { fun transferFileAuthenticationFailureRejectsTheSession() { val events = mutableListOf() var rejections = 0 - compose.setContent { + compose.setBuiltContent { PutioTheme { MobileShell( playbackPlayerFactory = NoAudioSessionFactory, @@ -1445,7 +1445,7 @@ class MobileShellTransfersTest { val resolutionStarted = CompletableDeferred() val releaseResolution = CompletableDeferred() val resolvedItem = shellResolvedFolder() - compose.setContent { + compose.setBuiltContent { val events = if (sessionId == MobileAuthSessionId(1L)) firstEvents else secondEvents PutioTheme { MobileShell( @@ -1495,7 +1495,7 @@ class MobileShellTransfersTest { notice = TransferNotice.FilePreparing(TransferId(7L), TransfersRequestId(3L)), ), ) - compose.setContent { + compose.setBuiltContent { PutioTheme { MobileShell( playbackPlayerFactory = NoAudioSessionFactory, @@ -1531,7 +1531,7 @@ class MobileShellTransfersTest { val events = mutableListOf() val filesEvents = mutableListOf() val resolvedItem = shellResolvedFolder() - compose.setContent { + compose.setBuiltContent { PutioTheme { MobileShell( playbackPlayerFactory = NoAudioSessionFactory, @@ -1604,7 +1604,7 @@ class MobileShellTransfersTest { transfers: MutableState, events: MutableList, ) { - compose.setContent { + compose.setBuiltContent { PutioTheme { MobileShell( playbackPlayerFactory = NoAudioSessionFactory, @@ -1639,7 +1639,7 @@ class MobileShellTransfersTest { val firstEvents = mutableListOf() val secondEvents = mutableListOf() var sessionId by mutableStateOf(MobileAuthSessionId(1L)) - compose.setContent { + compose.setBuiltContent { val events = if (sessionId == MobileAuthSessionId(1L)) firstEvents else secondEvents PutioTheme { MobileShell( @@ -1679,7 +1679,7 @@ class MobileShellTransfersTest { fun transferVisibilityStopsAndRestartsWithTheHostLifecycle() { val events = mutableListOf() val lifecycleOwner = ShellLifecycleOwner() - compose.setContent { + compose.setBuiltContent { CompositionLocalProvider(LocalLifecycleOwner provides lifecycleOwner) { TransfersVisibilityEffect( sessionId = MobileAuthSessionId(1L), @@ -1783,7 +1783,7 @@ class MobileShellExternalOpenTest { } private fun showSearch() { - compose.setContent { + compose.setBuiltContent { PutioTheme { MobileShell( playbackPlayerFactory = NoAudioSessionFactory, @@ -1940,7 +1940,7 @@ class MobileShellPlaybackTest { } } var size by mutableStateOf(DpSize(411.dp, 914.dp)) - compose.setContent { + compose.setBuiltContent { PutioTheme { Box(modifier = Modifier.requiredSize(size)) { MobileShell( @@ -1985,7 +1985,7 @@ class MobileShellPlaybackTest { override suspend fun activeAudio(context: Context) = ActiveAudio(FilesItemId(9L), "song.mp3") } - compose.setContent { + compose.setBuiltContent { PutioTheme { Box(modifier = Modifier.requiredSize(width = width, height = height)) { MobileShell( @@ -2050,7 +2050,7 @@ class MobileShellPlaybackTest { val session = ListenerCountingPlayer(RecordingPlayer()) var closed = 0 var showShell by mutableStateOf(true) - compose.setContent { + compose.setBuiltContent { PutioTheme { if (showShell) { MobileShell( @@ -2101,7 +2101,7 @@ class MobileShellPlaybackTest { return Closeable { closes += 1 } } } - compose.setContent { + compose.setBuiltContent { CompositionLocalProvider( LocalLifecycleOwner provides lifecycleOwner, ) { @@ -2157,7 +2157,7 @@ class MobileShellPlaybackTest { return Closeable { closed += 1 } } } - compose.setContent { + compose.setBuiltContent { PutioTheme { if (showShell) { MobileShell( @@ -2483,7 +2483,7 @@ class MobileShellPlaybackTest { filesState: FilesBrowserState = videoFilesState(), nowPlayingRequests: NowPlayingRequests = NowPlayingRequests.None, ) { - setContent { + setBuiltContent { PutioTheme { MobileShell( nowPlayingRequests = nowPlayingRequests, @@ -2531,7 +2531,7 @@ private fun ComposeContentTestRule.setShell( onAppConfigEvent: (AndroidAppConfigEvent) -> Unit = {}, inputs: ShellInputs = ShellInputs(), ) { - setContent { + setBuiltContent { PutioTheme { MobileShell( transferDraft = inputs.transferDraft, diff --git a/mobile/src/test/kotlin/io/putdotio/android/MobileShortWindowChromeTest.kt b/mobile/src/test/kotlin/io/putdotio/android/MobileShortWindowChromeTest.kt index fc422dec8..a60397ca4 100644 --- a/mobile/src/test/kotlin/io/putdotio/android/MobileShortWindowChromeTest.kt +++ b/mobile/src/test/kotlin/io/putdotio/android/MobileShortWindowChromeTest.kt @@ -43,7 +43,7 @@ class MobileShortWindowChromeTest { @Test fun compactHeightTitleGivesWayToItsActionsInANarrowWindow() { - compose.setContent { + compose.setBuiltContent { PutioTheme { MobileTabTitle( title = "Downloads kept on this device", @@ -66,7 +66,7 @@ class MobileShortWindowChromeTest { @Test fun narrowShortMiniPlayerKeepsTheNameItsWidth() { - compose.setContent { + compose.setBuiltContent { PutioTheme { MobileNowPlayingBar( nowPlaying = NowPlaying( diff --git a/mobile/src/test/kotlin/io/putdotio/android/MobileSubtitleControlsTest.kt b/mobile/src/test/kotlin/io/putdotio/android/MobileSubtitleControlsTest.kt index edd31984e..c9f17599a 100644 --- a/mobile/src/test/kotlin/io/putdotio/android/MobileSubtitleControlsTest.kt +++ b/mobile/src/test/kotlin/io/putdotio/android/MobileSubtitleControlsTest.kt @@ -120,7 +120,7 @@ class MobileSubtitleControlsTest { fun emptySubtitleSheetExplainsItselfAndRetainsOff() { val player = RecordingPlayer() var selection: SubtitleSelection? = null - compose.setContent { + compose.setBuiltContent { SubtitleSheet(player, TrackSelectionParameters.Builder().build(), emptyList()) { selection = it } } @@ -146,7 +146,7 @@ class MobileSubtitleControlsTest { var selection: SubtitleSelection? = null val defaults = TrackSelectionParameters.Builder().setPreferredAudioLanguage("de").build() compose.runOnIdle { player.trackSelectionParameters = defaults } - compose.setContent { SubtitleSheet(player, defaults, sidecar) { selection = it } } + compose.setBuiltContent { SubtitleSheet(player, defaults, sidecar) { selection = it } } compose.onNodeWithText("No captions available").assertIsDisplayed() // Tracks arrive after the sheet is up. val group = sourcedSubtitleGroup() @@ -200,7 +200,7 @@ class MobileSubtitleControlsTest { startupPolicy = SubtitleStartupPolicy(showSubtitles = true, autoSelectSubtitles = false), ) } - compose.setContent { SubtitleSheet(player, defaults, emptyList()) {} } + compose.setBuiltContent { SubtitleSheet(player, defaults, emptyList()) {} } compose.onNodeWithContentDescription("Subtitles: Off").assertIsDisplayed() compose.onNode(hasText("Off") and isSelectable()).assertIsSelected() } @@ -209,7 +209,7 @@ class MobileSubtitleControlsTest { fun sizeAndTimingStepsByATenthAndResets() { var size by mutableStateOf(SubtitleTextSize.Medium) var offset by mutableStateOf(500L) - compose.setContent { + compose.setBuiltContent { PutioTheme { Column { MobileSubtitleAppearanceContent(size, offset, { size = it }, { offset = it }) @@ -297,7 +297,7 @@ class MobileSubtitleControlsTest { fun subtitleCuesWaitForVideoDimensionsAfterPlayerReplacement() { var aspectRatio by mutableStateOf(null) val cues = listOf(Cue.Builder().setText("A retained subtitle").build()) - compose.setContent { + compose.setBuiltContent { PutioTheme { SubtitleCueOverlay( cues = cues, @@ -330,7 +330,7 @@ class MobileSubtitleControlsTest { ) var bottomPadding by mutableStateOf(SubtitleView.DEFAULT_BOTTOM_PADDING_FRACTION) var cues by mutableStateOf(emptyList()) - compose.setContent { + compose.setBuiltContent { PutioTheme { SubtitleCueOverlay( cues = cues, @@ -370,7 +370,7 @@ class MobileSubtitleControlsTest { .setSize(0.5f) .setBitmapHeight(0.1f) .build() - compose.setContent { + compose.setBuiltContent { PutioTheme { SubtitleCueOverlay( cues = listOf(cue), @@ -391,7 +391,7 @@ class MobileSubtitleControlsTest { fun subtitleCueLayerDoesNotBlockUnderlyingPlayerTouches() { var taps = 0 var interactions = 0 - compose.setContent { + compose.setBuiltContent { PutioTheme { Box( Modifier @@ -429,7 +429,7 @@ class MobileSubtitleControlsTest { var pointerEvents = 0 var keyEvents = 0 lateinit var inputModeManager: InputModeManager - compose.setContent { + compose.setBuiltContent { inputModeManager = LocalInputModeManager.current PutioTheme { MobileSideSheetOption( diff --git a/mobile/src/test/kotlin/io/putdotio/android/MobileTransferDropTest.kt b/mobile/src/test/kotlin/io/putdotio/android/MobileTransferDropTest.kt index 43fde0f30..379e12e8f 100644 --- a/mobile/src/test/kotlin/io/putdotio/android/MobileTransferDropTest.kt +++ b/mobile/src/test/kotlin/io/putdotio/android/MobileTransferDropTest.kt @@ -124,7 +124,7 @@ class MobileTransferDropTest { } private fun setZone() { - compose.setContent { + compose.setBuiltContent { PutioTheme { MobileTransferDropZone( enabled = true, diff --git a/mobile/src/test/kotlin/io/putdotio/android/MobileTransfersAddSheetTest.kt b/mobile/src/test/kotlin/io/putdotio/android/MobileTransfersAddSheetTest.kt index 60503a2d4..9c23a87ff 100644 --- a/mobile/src/test/kotlin/io/putdotio/android/MobileTransfersAddSheetTest.kt +++ b/mobile/src/test/kotlin/io/putdotio/android/MobileTransfersAddSheetTest.kt @@ -84,7 +84,7 @@ class MobileTransfersAddSheetTest { val draft = MobileTransferDraft() draft.receive(parseMobileSharedTransfer("https://example.invalid/file?token=private-share-marker")) lateinit var registry: SaveableStateRegistry - compose.setContent { + compose.setBuiltContent { registry = requireNotNull(LocalSaveableStateRegistry.current) PutioTheme { MobileTransfersScreen(transfersTestState(TransfersContent.Empty), {}, draft = draft) } } @@ -101,7 +101,7 @@ class MobileTransfersAddSheetTest { val normalized = "https://example.invalid/first\nhttps://example.invalid/second" draft.receive(parseMobileSharedTransfer("https://example.invalid/first https://example.invalid/second")) val events = mutableListOf() - compose.setContent { + compose.setBuiltContent { PutioTheme { MobileTransfersScreen(transfersTestState(TransfersContent.Empty), events::add, draft = draft) } } assertAddInput(normalized) @@ -132,7 +132,7 @@ class MobileTransfersAddSheetTest { ) } val events = mutableListOf() - compose.setContent { + compose.setBuiltContent { PutioTheme { MobileTransfersScreen( transfersTestState(TransfersContent.Empty), @@ -166,7 +166,7 @@ class MobileTransfersAddSheetTest { val torrent = TorrentUpload("Harbor film.torrent", "d4:infod4:name6:Harboree".toByteArray()) draft.receive(MobileSharedTransfer(torrent = torrent)) val events = mutableListOf() - compose.setContent { + compose.setBuiltContent { PutioTheme { MobileTransfersScreen(transfersTestState(TransfersContent.Empty), events::add, draft = draft) } } compose.onNodeWithTag(MOBILE_TRANSFER_TORRENT_TAG).assertTextContains("Harbor film.torrent") @@ -183,7 +183,7 @@ class MobileTransfersAddSheetTest { fun refusedLinksReopenTheSheetAndOnlyStartedTransfersAreAnnounced() { val draft = MobileTransferDraft() var current by mutableStateOf(transfersTestState(TransfersContent.Empty)) - compose.setContent { PutioTheme { MobileTransfersScreen(current, {}, draft = draft) } } + compose.setBuiltContent { PutioTheme { MobileTransfersScreen(current, {}, draft = draft) } } compose.runOnIdle { draft.receive(parseMobileSharedTransfer("magnet:?xt=urn:btih:1 https://example.invalid/refused")) current = current.withRunningLinkAdd() @@ -214,7 +214,7 @@ class MobileTransfersAddSheetTest { draft.receive(parseMobileSharedTransfer("https://example.invalid/first")) val events = mutableListOf() var current by mutableStateOf(transfersTestState(TransfersContent.InitialLoading(TransfersRequestId(1)))) - compose.setContent { PutioTheme { MobileTransfersScreen(current, events::add, draft = draft) } } + compose.setBuiltContent { PutioTheme { MobileTransfersScreen(current, events::add, draft = draft) } } val blocked = listOf( current, transfersTestState(TransfersContent.Empty).copyForTest( @@ -249,7 +249,7 @@ class MobileTransfersAddSheetTest { ), )) val events = mutableListOf() - compose.setContent { + compose.setBuiltContent { PutioTheme { MobileTransfersScreen(current, { event -> events.add(event) @@ -271,7 +271,7 @@ class MobileTransfersAddSheetTest { val original = "https://example.invalid/first" draft.receive(parseMobileSharedTransfer(original)) val events = mutableListOf() - compose.setContent { + compose.setBuiltContent { PutioTheme { MobileTransfersScreen(transfersTestState(TransfersContent.Empty), events::add, draft = draft) } } compose.onNodeWithTag(MOBILE_TRANSFER_ADD_FIELD_TAG).performTextReplacement("x".repeat(16 * 1024 + 1)) @@ -293,7 +293,7 @@ class MobileTransfersAddSheetTest { val draft = MobileTransferDraft() var visible by mutableStateOf(true) var current by mutableStateOf(transfersTestState(TransfersContent.Empty)) - compose.setContent { + compose.setBuiltContent { PutioTheme { if (visible) MobileTransfersScreen(current, {}, draft = draft) } @@ -326,7 +326,7 @@ class MobileTransfersAddSheetTest { fun addSheetValidatesAndPreservesInputWhenTheApiRejectsIt() { var current by mutableStateOf(transfersTestState(TransfersContent.Empty)) val events = mutableListOf() - compose.setContent { + compose.setBuiltContent { PutioTheme { MobileTransfersScreen( state = current, @@ -389,7 +389,7 @@ class MobileTransfersAddSheetTest { @Test fun immediateAddSuccessClosesAndClearsTheSheet() { var current by mutableStateOf(transfersTestState(TransfersContent.Empty)) - compose.setContent { + compose.setBuiltContent { PutioTheme { MobileTransfersScreen( state = current, @@ -423,7 +423,7 @@ class MobileTransfersAddSheetTest { fun addDraftSurvivesToolbarChangesAndResetsWithTheSession() { var sessionId by mutableStateOf(MobileAuthSessionId(1L)) var current by mutableStateOf(transfersTestState(TransfersContent.Empty)) - compose.setContent { + compose.setBuiltContent { PutioTheme { MobileTransfersScreen(state = current, onEvent = {}, sessionId = sessionId) } @@ -457,7 +457,7 @@ class MobileTransfersAddSheetTest { val draft = MobileTransferDraft() draft.receive(MobileSharedTransfer("magnet:?xt=urn:btih:1\nhttps://example.invalid/page and prose")) val events = mutableListOf() - compose.setContent { + compose.setBuiltContent { PutioTheme { MobileTransfersScreen(transfersTestState(TransfersContent.Empty), events::add, draft = draft) } } compose.onNodeWithText("Line 2 isn’t a magnet or a file link.").assertIsDisplayed() @@ -479,7 +479,7 @@ class MobileTransfersAddSheetTest { .setPrimaryClip(ClipData.newPlainText("link", " magnet:?xt=urn:btih:pasted ")) val draft = MobileTransferDraft() draft.receive(MobileSharedTransfer("https://example.invalid/first")) - compose.setContent { + compose.setBuiltContent { PutioTheme { MobileTransfersScreen(transfersTestState(TransfersContent.Empty), {}, draft = draft) } } compose.onNodeWithTag(MOBILE_TRANSFER_PASTE_TAG).performClick() diff --git a/mobile/src/test/kotlin/io/putdotio/android/MobileTransfersLayoutTest.kt b/mobile/src/test/kotlin/io/putdotio/android/MobileTransfersLayoutTest.kt index acc5bb8b1..12e8b79f4 100644 --- a/mobile/src/test/kotlin/io/putdotio/android/MobileTransfersLayoutTest.kt +++ b/mobile/src/test/kotlin/io/putdotio/android/MobileTransfersLayoutTest.kt @@ -68,7 +68,7 @@ class MobileTransfersLayoutTest { @Test @Config(sdk = [35], qualifiers = "en-rUS-w1280dp-h800dp-land") fun anExpandedWindowSetsCardsSideBySide() { - compose.setContent { + compose.setBuiltContent { PutioTheme { MobileTransfersScreen( transfersState( @@ -92,7 +92,7 @@ class MobileTransfersLayoutTest { @Test fun largeFontOverflowKeepsItsActionsWhole() { - compose.setContent { + compose.setBuiltContent { PutioTheme { MobileTransfersOverflow( transfersState( @@ -142,7 +142,7 @@ class MobileTransfersLayoutTest { @Config(sdk = [35], qualifiers = "en-rUS-w640dp-h320dp-land") fun shortLargeFontSheetCanScrollFromInputToSubmit() { val events = mutableListOf() - compose.setContent { + compose.setBuiltContent { PutioTheme { MobileTransfersScreen(transfersState(content = TransfersContent.Empty), events::add) } } compose.onNodeWithText("Add transfer").performScrollTo().performClick() @@ -156,7 +156,7 @@ class MobileTransfersLayoutTest { fontScale: Float = 2f, onEvent: (TransfersEvent) -> Unit = {}, ) { - compose.setContent { + compose.setBuiltContent { CompositionLocalProvider(LocalDensity provides Density(LocalDensity.current.density, fontScale)) { PutioTheme { Box(modifier = Modifier.fillMaxSize().testTag("transfers-viewport")) { diff --git a/mobile/src/test/kotlin/io/putdotio/android/MobileTransfersScreenTest.kt b/mobile/src/test/kotlin/io/putdotio/android/MobileTransfersScreenTest.kt index 0567e31e5..3748efcb3 100644 --- a/mobile/src/test/kotlin/io/putdotio/android/MobileTransfersScreenTest.kt +++ b/mobile/src/test/kotlin/io/putdotio/android/MobileTransfersScreenTest.kt @@ -164,7 +164,7 @@ class MobileTransfersScreenTest { var current by mutableStateOf( transfersTestState(TransfersContent.Ready(listOf(completed), TransfersPaging.Complete)), ) - compose.setContent { + compose.setBuiltContent { PutioTheme { MobileTransfersOverflow(current, events::add, MobileAuthSessionId(1L)) } } compose.onNodeWithContentDescription("More options").performClick() @@ -343,7 +343,7 @@ class MobileTransfersScreenTest { val current = transfersTestState( TransfersContent.Ready(listOf(transferRow(1L, AppTransferStatus.Downloading)), TransfersPaging.Complete), ) - compose.setContent { + compose.setBuiltContent { PutioTheme { MobileTransfersScreen(state = current, onEvent = {}, sessionId = sessionId) } } @@ -360,7 +360,7 @@ class MobileTransfersScreenTest { fun theOverflowRefreshesAndClearsCompletedAfterAConfirmOnceTransfersAreListed() { val events = mutableListOf() var current by mutableStateOf(transfersTestState(TransfersContent.InitialLoading(TransfersRequestId(1L)))) - compose.setContent { + compose.setBuiltContent { PutioTheme { MobileTransfersOverflow(current, events::add, MobileAuthSessionId(1L)) } } compose.onNodeWithTag(MOBILE_TRANSFERS_OVERFLOW_TAG).assertDoesNotExist() @@ -599,11 +599,11 @@ class MobileTransfersScreenTest { } private fun setScreen(state: TransfersState, onEvent: (TransfersEvent) -> Unit) { - compose.setContent { PutioTheme { MobileTransfersScreen(state, onEvent) } } + compose.setBuiltContent { PutioTheme { MobileTransfersScreen(state, onEvent) } } } private fun setMutableScreen(state: () -> TransfersState, onEvent: (TransfersEvent) -> Unit) { - compose.setContent { PutioTheme { MobileTransfersScreen(state(), onEvent) } } + compose.setBuiltContent { PutioTheme { MobileTransfersScreen(state(), onEvent) } } } } diff --git a/mobile/src/test/kotlin/io/putdotio/android/MobileTrashActionsScreenTest.kt b/mobile/src/test/kotlin/io/putdotio/android/MobileTrashActionsScreenTest.kt index 104a4c8f6..4e7b64f35 100644 --- a/mobile/src/test/kotlin/io/putdotio/android/MobileTrashActionsScreenTest.kt +++ b/mobile/src/test/kotlin/io/putdotio/android/MobileTrashActionsScreenTest.kt @@ -70,7 +70,7 @@ class MobileTrashActionsScreenTest { fun rowSheetOffersRestoreAndPermanentDeleteAndDeleteNeedsItsOwnConfirmation() { val events = mutableListOf() var state by mutableStateOf(TrashState(content = loaded)) - compose.setContent { PutioTheme { TrashWithOverflow(state) { events += it; true } } } + compose.setBuiltContent { PutioTheme { TrashWithOverflow(state) { events += it; true } } } compose.onNodeWithContentDescription("Actions for ${item.name}").performClick() compose.onNodeWithTag(MOBILE_TRASH_ITEM_DELETE_TAG).performClick() compose.runOnIdle { assertEquals(listOf(TrashEvent.SelectDelete(item.id)), events) } @@ -94,7 +94,7 @@ class MobileTrashActionsScreenTest { fun restoreAllStartsAtOnceEmptyConfirmsAndBothStayDisabledOnKnownEmptyTrash() { val events = mutableListOf() var state by mutableStateOf(TrashState(content = loaded)) - compose.setContent { PutioTheme { TrashWithOverflow(state) { events += it; true } } } + compose.setBuiltContent { PutioTheme { TrashWithOverflow(state) { events += it; true } } } compose.trashMenuItem(MOBILE_TRASH_RESTORE_ALL_TAG).performClick() compose.trashMenuItem(MOBILE_TRASH_EMPTY_TAG).performClick() compose.runOnIdle { assertEquals(listOf(TrashEvent.RestoreAll, TrashEvent.SelectEmpty), events) } @@ -114,7 +114,7 @@ class MobileTrashActionsScreenTest { val events = mutableListOf() val state = TrashState(content = loaded, actionOutcome = TrashActionOutcome( TrashAction.DeleteItem(item), TrashActionSubmission.UNCERTAIN, TrashActionCheck.FAILED)) - compose.setContent { PutioTheme { TrashWithOverflow(state) { events += it; true } } } + compose.setBuiltContent { PutioTheme { TrashWithOverflow(state) { events += it; true } } } compose.onNodeWithTag(MOBILE_TRASH_LIST_TAG).performScrollToNode(hasTestTag(MOBILE_TRASH_ACTION_OUTCOME_TAG)) compose.onNodeWithText("“${item.name}” is still in trash.").assertIsDisplayed() compose.onNodeWithTag(MOBILE_TRASH_ACTION_CHECK_TAG).assertDoesNotExist() @@ -132,7 +132,7 @@ class MobileTrashActionsScreenTest { val events = mutableListOf() var state by mutableStateOf(TrashState(content = loaded, actionOutcome = TrashActionOutcome( TrashAction.DeleteItem(item), TrashActionSubmission.UNCERTAIN, TrashActionCheck.INCONCLUSIVE))) - compose.setContent { PutioTheme { TrashWithOverflow(state) { events += it; true } } } + compose.setBuiltContent { PutioTheme { TrashWithOverflow(state) { events += it; true } } } compose.onNodeWithTag(MOBILE_TRASH_LIST_TAG).performScrollToNode(hasTestTag(MOBILE_TRASH_ACTION_OUTCOME_TAG)) compose.onNodeWithText("“${item.name}” was not in the first page. Check trash again in a moment.") .assertIsDisplayed() @@ -165,7 +165,7 @@ class MobileTrashActionsScreenTest { val third = item.copy(id = FilesItemId(10), name = "third.txt") val rows = TrashContent.Loaded(listOf(item, second, third), null, 3, 36) var state by mutableStateOf(TrashState(content = rows)) - compose.setContent { PutioTheme { TrashWithOverflow(state) { events += it; true } } } + compose.setBuiltContent { PutioTheme { TrashWithOverflow(state) { events += it; true } } } compose.onNodeWithContentDescription("Restore ${second.name}").performTouchInput { longClick() } compose.onNodeWithTag(MOBILE_TRASH_SELECTION_BAR_TAG).assertDoesNotExist() compose.runOnIdle { events.clear() } diff --git a/mobile/src/test/kotlin/io/putdotio/android/MobileTrashLayoutTest.kt b/mobile/src/test/kotlin/io/putdotio/android/MobileTrashLayoutTest.kt index 3c9ddbef8..d251bb753 100644 --- a/mobile/src/test/kotlin/io/putdotio/android/MobileTrashLayoutTest.kt +++ b/mobile/src/test/kotlin/io/putdotio/android/MobileTrashLayoutTest.kt @@ -49,7 +49,7 @@ class MobileTrashLayoutTest { fun landscapeItemSheetKeepsRestoreAndDeleteReachableAtDoubleFontScale() { val item = TrashItem(FilesItemId(7), FilesItemId(8), "Archive 東京 été ".repeat(16), PutioFileType.FOLDER, 0) val events = mutableListOf() - compose.setContent { + compose.setBuiltContent { PutioTheme { MobileTrashItemSheet( item, TrashState(content = TrashContent.Loaded(listOf(item), null, 1, 0)), events::add, {}, @@ -75,7 +75,7 @@ class MobileTrashLayoutTest { private fun assertConfirmationFits() { val item = TrashItem(FilesItemId(7), FilesItemId(8), "Archive 東京 été ".repeat(16), PutioFileType.FOLDER, 0) val events = mutableListOf() - compose.setContent { + compose.setBuiltContent { PutioTheme { MobileTrashScreen(TrashState(content = TrashContent.Loaded(emptyList(), null, 0, 0), actionConfirmation = TrashAction.DeleteItem(item), actionConfirmationId = 1), events::add) diff --git a/mobile/src/test/kotlin/io/putdotio/android/MobileTrashScreenTest.kt b/mobile/src/test/kotlin/io/putdotio/android/MobileTrashScreenTest.kt index 774932d4d..f79e77624 100644 --- a/mobile/src/test/kotlin/io/putdotio/android/MobileTrashScreenTest.kt +++ b/mobile/src/test/kotlin/io/putdotio/android/MobileTrashScreenTest.kt @@ -61,7 +61,7 @@ class MobileTrashScreenTest { @Test fun aLoadedPageComposesNoRowBeforeItsTextIsBuilt() { val build = StandardTestDispatcher() - compose.setContent { + compose.setBuiltContent { CompositionLocalProvider(LocalBuildDispatcher provides build) { PutioTheme { MobileTrashScreen(TrashState(content = loaded), { true }) } } @@ -78,7 +78,7 @@ class MobileTrashScreenTest { val events = mutableListOf() var state by mutableStateOf(TrashState(content = loaded, restoreOutcome = TrashRestoreOutcome(item, TrashRestoreSubmission.ACKNOWLEDGED, TrashRestoreCheck.UNAVAILABLE))) - compose.setContent { PutioTheme { MobileTrashScreen(state, events::add) } } + compose.setBuiltContent { PutioTheme { MobileTrashScreen(state, events::add) } } compose.onNodeWithText("Restore started.").assertIsDisplayed() compose.onNodeWithTag(MOBILE_TRASH_CHECK_TAG).performClick() compose.onNodeWithTag(MOBILE_TRASH_LIST_TAG).performScrollToNode(hasText(item.name)) @@ -99,7 +99,7 @@ class MobileTrashScreenTest { """"status":"ERROR","status_code":400}""" val state = TrashState(content = loaded, restoreOutcome = TrashRestoreOutcome(item, TrashRestoreSubmission.REJECTED, submissionFailure = putioRefusal(400, body).toPutioFailure())) - compose.setContent { PutioTheme { MobileTrashScreen(state, { true }) } } + compose.setBuiltContent { PutioTheme { MobileTrashScreen(state, { true }) } } compose.onNodeWithText("This item is still moving to trash. You can try restoring it later.") .assertIsDisplayed() compose.onNodeWithText("Item is still being trashed").assertDoesNotExist() @@ -111,7 +111,7 @@ class MobileTrashScreenTest { TrashItem(FilesItemId(it.toLong()), FilesItemId(0), "item-$it.txt", PutioFileType.TEXT, 12) } var state by mutableStateOf(TrashState(content = TrashContent.Loaded(items, null, items.size, 144))) - compose.setContent { PutioTheme { MobileTrashScreen(state, { true }) } } + compose.setBuiltContent { PutioTheme { MobileTrashScreen(state, { true }) } } compose.onNodeWithTag(MOBILE_TRASH_LIST_TAG).performScrollToNode(hasText("item-12.txt")) compose.onNodeWithText("Trash uses", substring = true).assertIsNotDisplayed() compose.runOnIdle { @@ -137,7 +137,7 @@ class MobileTrashScreenTest { var state by mutableStateOf(TrashState(content = TrashContent.Loaded(items, null, items.size, 144), restoreOutcome = TrashRestoreOutcome(items[0], TrashRestoreSubmission.ACKNOWLEDGED, TrashRestoreCheck.AVAILABLE, resolvedItem = restored), restoredItemIds = setOf(items[0].id))) - compose.setContent { PutioTheme { MobileTrashScreen(state, { true }) } } + compose.setBuiltContent { PutioTheme { MobileTrashScreen(state, { true }) } } compose.onNodeWithTag(MOBILE_TRASH_LIST_TAG).performScrollToNode(hasText("item-12.txt")) compose.runOnIdle { state = state.copy(actionOutcome = TrashActionOutcome(TrashAction.DeleteItem(items[1]), @@ -154,7 +154,7 @@ class MobileTrashScreenTest { restoreOutcome = TrashRestoreOutcome(item, TrashRestoreSubmission.ACKNOWLEDGED, TrashRestoreCheck.AVAILABLE, resolvedItem = current), restoredItemIds = setOf(item.id)) val events = mutableListOf() - compose.setContent { PutioTheme { MobileTrashScreen(state, events::add) } } + compose.setBuiltContent { PutioTheme { MobileTrashScreen(state, events::add) } } compose.onNodeWithText("Available again: ${current.name}").assertIsDisplayed() compose.onNodeWithTag(MOBILE_TRASH_CHECK_TAG).assertDoesNotExist() compose.onNodeWithTag(MOBILE_TRASH_LIST_TAG).performScrollToNode(hasText("Try again")) @@ -166,7 +166,7 @@ class MobileTrashScreenTest { fun emptyIntermediatePageAsksForTheNextWithoutClaimingEmptyTrash() { val events = mutableListOf() val state = TrashState(content = TrashContent.Loaded(emptyList(), FilesCursor("next"), 7, 1234)) - compose.setContent { PutioTheme { MobileTrashScreen(state, events::add) } } + compose.setBuiltContent { PutioTheme { MobileTrashScreen(state, events::add) } } compose.onNodeWithText("Your trash is empty").assertDoesNotExist() compose.onNodeWithText("Files you move to trash stay here for 14 days.").assertDoesNotExist() compose.runOnIdle { assertEquals(listOf(TrashEvent.LoadNextPage), events) } @@ -179,7 +179,7 @@ class MobileTrashScreenTest { TrashItem(FilesItemId(it.toLong()), FilesItemId(0), "item-$it.txt", PutioFileType.TEXT, 12) } val state = TrashState(content = TrashContent.Loaded(items, FilesCursor("next"), 80, 960)) - compose.setContent { PutioTheme { MobileTrashScreen(state, events::add) } } + compose.setBuiltContent { PutioTheme { MobileTrashScreen(state, events::add) } } compose.onNodeWithTag(MOBILE_TRASH_LIST_TAG).performScrollToNode(hasText("item-20.txt")) compose.runOnIdle { assertEquals(emptyList(), events) } compose.onNodeWithTag(MOBILE_TRASH_LIST_TAG).performScrollToNode(hasText("item-36.txt")) @@ -193,7 +193,7 @@ class MobileTrashScreenTest { var state by mutableStateOf( TrashState(content = loaded.copy(nextCursor = FilesCursor("next")), actionOutcome = submitting), ) - compose.setContent { PutioTheme { MobileTrashScreen(state, events::add) } } + compose.setBuiltContent { PutioTheme { MobileTrashScreen(state, events::add) } } compose.runOnIdle { assertEquals(emptyList(), events) } compose.runOnIdle { state = state.copy(actionOutcome = submitting.copy(submission = TrashActionSubmission.ACKNOWLEDGED)) @@ -204,7 +204,7 @@ class MobileTrashScreenTest { @Test fun pullingTheListDownRefreshesTrash() { val events = mutableListOf() - compose.setContent { PutioTheme { MobileTrashScreen(TrashState(content = loaded), events::add) } } + compose.setBuiltContent { PutioTheme { MobileTrashScreen(TrashState(content = loaded), events::add) } } compose.onNodeWithTag(MOBILE_TRASH_LIST_TAG).performTouchInput { swipeDown() } compose.runOnIdle { assertEquals(listOf(TrashEvent.Refresh), events) } } @@ -212,7 +212,7 @@ class MobileTrashScreenTest { @Test fun trashStatesItsFourteenDayRetentionOnce() { var state by mutableStateOf(TrashState(content = TrashContent.Loaded(emptyList(), null, 0, 0))) - compose.setContent { PutioTheme { MobileTrashScreen(state, { true }) } } + compose.setBuiltContent { PutioTheme { MobileTrashScreen(state, { true }) } } compose.onNodeWithText("deleted items stay 14 days").assertDoesNotExist() compose.onNodeWithText("Your trash is empty").assertIsDisplayed() compose.onNodeWithText("Files you move to trash stay here for 14 days.").assertIsDisplayed() @@ -227,7 +227,7 @@ class MobileTrashScreenTest { val state = TrashState( content = loaded.copy(items = listOf(item.copy(expirationDate = "invalid", deletedAt = null))), ) - compose.setContent { PutioTheme { MobileTrashScreen(state, { true }) } } + compose.setBuiltContent { PutioTheme { MobileTrashScreen(state, { true }) } } compose.awaitText("12 B") compose.onNodeWithText("Gone", substring = true).assertDoesNotExist() } @@ -236,7 +236,7 @@ class MobileTrashScreenTest { fun anItemExpiringTomorrowSaysGoneTomorrow() { val tomorrow = LocalDate.now().plusDays(1).toString() val state = TrashState(content = loaded.copy(items = listOf(item.copy(expirationDate = tomorrow)))) - compose.setContent { PutioTheme { MobileTrashScreen(state, { true }) } } + compose.setBuiltContent { PutioTheme { MobileTrashScreen(state, { true }) } } compose.awaitText("Gone tomorrow") compose.onNodeWithText("Gone tomorrow").assertIsDisplayed() } diff --git a/mobile/src/test/kotlin/io/putdotio/android/MobileTrashSessionIntegrationTest.kt b/mobile/src/test/kotlin/io/putdotio/android/MobileTrashSessionIntegrationTest.kt index 594b974a6..7fa4d9eca 100644 --- a/mobile/src/test/kotlin/io/putdotio/android/MobileTrashSessionIntegrationTest.kt +++ b/mobile/src/test/kotlin/io/putdotio/android/MobileTrashSessionIntegrationTest.kt @@ -153,7 +153,7 @@ class MobileTrashSessionIntegrationTest { private fun whileMounted(fixture: TrashSessionRootFixture, block: () -> Unit) { var mounted by mutableStateOf(true) try { - compose.setContent { if (mounted) fixture.Content() } + compose.setBuiltContent { if (mounted) fixture.Content() } block() } finally { compose.runOnIdle { mounted = false } diff --git a/mobile/src/test/kotlin/io/putdotio/android/MobileWelcomeScreenTest.kt b/mobile/src/test/kotlin/io/putdotio/android/MobileWelcomeScreenTest.kt index 35f7e2143..31968f903 100644 --- a/mobile/src/test/kotlin/io/putdotio/android/MobileWelcomeScreenTest.kt +++ b/mobile/src/test/kotlin/io/putdotio/android/MobileWelcomeScreenTest.kt @@ -39,7 +39,7 @@ class MobileWelcomeScreenTest { private var actions = 0 private fun setSignedOut(canSignIn: Boolean = true, reason: () -> MobileSignedOutReason? = { null }) { - compose.setContent { + compose.setBuiltContent { PutioTheme { Surface { MobileSignedOutScreen(reason = reason(), canSignIn = canSignIn, onSignIn = { actions += 1 }) @@ -77,7 +77,7 @@ class MobileWelcomeScreenTest { @Test fun secureStorageFailureOffersTryAgainAboveResetAndSignIn() { var retries = 0 - compose.setContent { + compose.setBuiltContent { PutioTheme { Surface { MobileSignedOutScreen( @@ -111,7 +111,7 @@ class MobileWelcomeScreenTest { @Test fun missingAuthTabBrowserOffersChromeInsteadOfRetry() { var chromeRequests = 0 - compose.setContent { + compose.setBuiltContent { PutioTheme { Surface { MobileSignedOutScreen( @@ -136,7 +136,7 @@ class MobileWelcomeScreenTest { @Test fun deviceWithoutGooglePlayExplainsAndOffersOnlyTryAgain() { var chromeRequests = 0 - compose.setContent { + compose.setBuiltContent { PutioTheme { Surface { MobileSignedOutScreen( @@ -168,7 +168,7 @@ class MobileWelcomeScreenTest { @Test fun browserStepOffersOnlyCancel() { - compose.setContent { + compose.setBuiltContent { PutioTheme { Surface { MobileWelcomeScreen(content = MobileBrowserWelcomeContent, onAction = { actions += 1 }) diff --git a/mobile/src/test/kotlin/io/putdotio/android/files/MobileContinueWatchingRowTest.kt b/mobile/src/test/kotlin/io/putdotio/android/files/MobileContinueWatchingRowTest.kt index 1dde09bee..e84d20ad1 100644 --- a/mobile/src/test/kotlin/io/putdotio/android/files/MobileContinueWatchingRowTest.kt +++ b/mobile/src/test/kotlin/io/putdotio/android/files/MobileContinueWatchingRowTest.kt @@ -50,7 +50,7 @@ class MobileContinueWatchingRowTest { } private fun setRow() { - compose.setContent { + compose.setBuiltContent { PutioTheme { val pinnedRows = MobilePinnedRows(rememberFilesRowText(emptyList()), MobilePinnedActions(onOpen = {})) LazyColumn { diff --git a/mobile/src/test/kotlin/io/putdotio/android/files/MobilePinnedSectionTest.kt b/mobile/src/test/kotlin/io/putdotio/android/files/MobilePinnedSectionTest.kt index d365f30b8..d11990e7c 100644 --- a/mobile/src/test/kotlin/io/putdotio/android/files/MobilePinnedSectionTest.kt +++ b/mobile/src/test/kotlin/io/putdotio/android/files/MobilePinnedSectionTest.kt @@ -59,7 +59,7 @@ class MobilePinnedSectionTest { fun theSheetOffersPinOrUnpinByWhetherTheItemIsPinned() { val item = pins.first() val chosen = mutableListOf() - compose.setContent { + compose.setBuiltContent { PutioTheme { MobileFilesActions( item = item, @@ -83,7 +83,7 @@ class MobilePinnedSectionTest { @Test fun theSheetLeavesPinOutWhileThePinsAreUnknown() { - compose.setContent { + compose.setBuiltContent { PutioTheme { MobileFilesActions( item = pins.first(), @@ -101,7 +101,7 @@ class MobilePinnedSectionTest { } private fun setSection() { - compose.setContent { + compose.setBuiltContent { PutioTheme { val rowText = rememberFilesRowText(pins) LazyColumn { diff --git a/mobile/src/test/kotlin/io/putdotio/android/playback/MobileConversionVlcTest.kt b/mobile/src/test/kotlin/io/putdotio/android/playback/MobileConversionVlcTest.kt index 127f56711..6098304de 100644 --- a/mobile/src/test/kotlin/io/putdotio/android/playback/MobileConversionVlcTest.kt +++ b/mobile/src/test/kotlin/io/putdotio/android/playback/MobileConversionVlcTest.kt @@ -23,7 +23,7 @@ class MobileConversionVlcTest { @Test fun aRunningConversionOffersVlcBesideItsProgress() { var opened = 0 - compose.setContent { + compose.setBuiltContent { PutioTheme { MobileConversionState( PlaybackContent.Conversion(PlaybackConversionState.Converting(40.0)), @@ -42,7 +42,7 @@ class MobileConversionVlcTest { @Test fun withoutVlcTheConversionOffersNoHandoff() { - compose.setContent { + compose.setBuiltContent { PutioTheme { MobileConversionState( PlaybackContent.Conversion(PlaybackConversionState.Converting(40.0)), diff --git a/mobile/src/test/kotlin/io/putdotio/android/viewer/MobileFileViewerLayoutTest.kt b/mobile/src/test/kotlin/io/putdotio/android/viewer/MobileFileViewerLayoutTest.kt index c3f9c0078..cedc79ae7 100644 --- a/mobile/src/test/kotlin/io/putdotio/android/viewer/MobileFileViewerLayoutTest.kt +++ b/mobile/src/test/kotlin/io/putdotio/android/viewer/MobileFileViewerLayoutTest.kt @@ -28,7 +28,7 @@ class MobileFileViewerLayoutTest { fun thePagesKeepTheirHeightWhenThePositionLineComesAndGoes() { val first = image(1L) var files by mutableStateOf(listOf(first, image(2L))) - compose.setContent { + compose.setBuiltContent { PutioTheme { MobileFileViewerContent( files = files, diff --git a/mobile/src/test/kotlin/io/putdotio/android/viewer/MobileFileViewerPagingTest.kt b/mobile/src/test/kotlin/io/putdotio/android/viewer/MobileFileViewerPagingTest.kt index e15c3be59..96c10a3c9 100644 --- a/mobile/src/test/kotlin/io/putdotio/android/viewer/MobileFileViewerPagingTest.kt +++ b/mobile/src/test/kotlin/io/putdotio/android/viewer/MobileFileViewerPagingTest.kt @@ -67,7 +67,7 @@ class MobileFileViewerPagingTest { ): () -> Int { var files by mutableStateOf(initial) var read by mutableIntStateOf(0) - compose.setContent { + compose.setBuiltContent { PutioTheme { MobileFileViewerContent( files = files, diff --git a/mobile/src/test/kotlin/io/putdotio/android/viewer/MobileViewerLoadFailureTest.kt b/mobile/src/test/kotlin/io/putdotio/android/viewer/MobileViewerLoadFailureTest.kt index 99600b792..1e5861241 100644 --- a/mobile/src/test/kotlin/io/putdotio/android/viewer/MobileViewerLoadFailureTest.kt +++ b/mobile/src/test/kotlin/io/putdotio/android/viewer/MobileViewerLoadFailureTest.kt @@ -33,7 +33,7 @@ class MobileViewerLoadFailureTest { if (opens.getAndIncrement() == 0) DroppedStream() else "first line".byteInputStream() } var openedElsewhere = 0 - compose.setContent { + compose.setBuiltContent { PutioTheme { MobileTextPage(uri, onOpenWithAnotherApp = { openedElsewhere++ }) } } diff --git a/mobile/src/test/kotlin/io/putdotio/android/viewer/MobileViewerZoomTest.kt b/mobile/src/test/kotlin/io/putdotio/android/viewer/MobileViewerZoomTest.kt index 4e1f8f98f..d429e3970 100644 --- a/mobile/src/test/kotlin/io/putdotio/android/viewer/MobileViewerZoomTest.kt +++ b/mobile/src/test/kotlin/io/putdotio/android/viewer/MobileViewerZoomTest.kt @@ -33,7 +33,7 @@ class MobileViewerZoomTest { @Test fun aDoubleTapZoomsInAndASecondFitsAgain() { val zoom = MobileViewerZoom() - compose.setContent { Box(Modifier.fillMaxSize().viewerZoom(zoom).testTag(PAGE)) } + compose.setBuiltContent { Box(Modifier.fillMaxSize().viewerZoom(zoom).testTag(PAGE)) } compose.onNodeWithTag(PAGE).performTouchInput { doubleClick(center) } compose.runOnIdle { assertTrue(zoom.zoomed) } @@ -48,7 +48,7 @@ class MobileViewerZoomTest { @Test fun aDoubleTapThatJittersStillFitsAZoomedPage() { val zoom = MobileViewerZoom() - compose.setContent { Box(Modifier.fillMaxSize().viewerZoom(zoom).testTag(PAGE)) } + compose.setBuiltContent { Box(Modifier.fillMaxSize().viewerZoom(zoom).testTag(PAGE)) } compose.onNodeWithTag(PAGE).performTouchInput { doubleClick(center) } compose.runOnIdle { assertTrue(zoom.zoomed) } @@ -67,7 +67,7 @@ class MobileViewerZoomTest { @Test fun aPinchZoomsIn() { val zoom = MobileViewerZoom() - compose.setContent { Box(Modifier.fillMaxSize().viewerZoom(zoom).testTag(PAGE)) } + compose.setBuiltContent { Box(Modifier.fillMaxSize().viewerZoom(zoom).testTag(PAGE)) } compose.onNodeWithTag(PAGE).performTouchInput { pinch( @@ -84,7 +84,7 @@ class MobileViewerZoomTest { @Test fun oneFingerAtFitStillSwipesThePager() { lateinit var pager: PagerState - compose.setContent { + compose.setBuiltContent { pager = rememberPagerState { 2 } HorizontalPager(pager, Modifier.fillMaxSize().testTag(PAGE)) { Box(Modifier.fillMaxSize().viewerZoom(MobileViewerZoom())) @@ -112,7 +112,7 @@ class MobileViewerZoomTest { @Test fun aPinchKeepsTheContentUnderAStillFinger() { val zoom = MobileViewerZoom() - compose.setContent { Box(Modifier.fillMaxSize().viewerZoom(zoom).testTag(PAGE)) } + compose.setBuiltContent { Box(Modifier.fillMaxSize().viewerZoom(zoom).testTag(PAGE)) } val node = compose.onNodeWithTag(PAGE) val viewport = node.fetchSemanticsNode().size var still = Offset.Zero @@ -135,7 +135,7 @@ class MobileViewerZoomTest { @Test fun aZoomedPanMovesTheContentAsFarAsTheFinger() { val zoom = MobileViewerZoom() - compose.setContent { Box(Modifier.fillMaxSize().viewerZoom(zoom).testTag(PAGE)) } + compose.setBuiltContent { Box(Modifier.fillMaxSize().viewerZoom(zoom).testTag(PAGE)) } val node = compose.onNodeWithTag(PAGE) node.performTouchInput { doubleClick(center) } val start = compose.runOnIdle { zoom.offset } @@ -152,7 +152,7 @@ class MobileViewerZoomTest { @Test fun aPinchThatDropsToOneFingerKeepsPanning() { val zoom = MobileViewerZoom() - compose.setContent { Box(Modifier.fillMaxSize().viewerZoom(zoom).testTag(PAGE)) } + compose.setBuiltContent { Box(Modifier.fillMaxSize().viewerZoom(zoom).testTag(PAGE)) } val node = compose.onNodeWithTag(PAGE) var before = Offset.Zero diff --git a/tv/src/main/kotlin/io/putdotio/android/tv/files/TvFilesScreen.kt b/tv/src/main/kotlin/io/putdotio/android/tv/files/TvFilesScreen.kt index 470d0c5a4..f4689fb47 100644 --- a/tv/src/main/kotlin/io/putdotio/android/tv/files/TvFilesScreen.kt +++ b/tv/src/main/kotlin/io/putdotio/android/tv/files/TvFilesScreen.kt @@ -596,6 +596,7 @@ private fun TvFilesRows( rowsShowFocus = rowsShowFocus, ) ready != null || content is FilesContent.Loading -> { + if (ready != null) SideEffect { onEntryTarget(skeletonFocus) } LaunchedEffect(folderId) { if (paneHasFocus.value) skeletonFocus.requestFocus() } TvListSkeleton(modifier.focusRequester(skeletonFocus).focusable()) } diff --git a/tv/src/main/kotlin/io/putdotio/android/tv/search/TvSearchResults.kt b/tv/src/main/kotlin/io/putdotio/android/tv/search/TvSearchResults.kt index a5749b035..a0e057603 100644 --- a/tv/src/main/kotlin/io/putdotio/android/tv/search/TvSearchResults.kt +++ b/tv/src/main/kotlin/io/putdotio/android/tv/search/TvSearchResults.kt @@ -120,12 +120,12 @@ internal fun TvSearchResultList( ) { it.rowText(context, currentRows.place(it), System.currentTimeMillis()) } - val shown = rowText.shown(groups, groups.ordered) + val shown = rowText.shown(groups to paging, groups.ordered) if (shown == null) { TvListSkeleton(modifier) return } - TvSearchResultRows(shown, rowText, paging, restoreRowId, rows, onNextPage, onRetry, owner, listFocus, modifier) + TvSearchResultRows(shown.first, rowText, shown.second, restoreRowId, rows, onNextPage, onRetry, owner, listFocus, modifier) } @OptIn(ExperimentalComposeUiApi::class) From cefc3d64f5776379e4304a8138f6e7b867f84bc4 Mon Sep 17 00:00:00 2001 From: Altay Date: Sun, 15 Nov 2026 13:15:56 +0300 Subject: [PATCH 3/7] test(mobile): import the built-content helper in subpackages --- .../io/putdotio/android/files/MobileContinueWatchingRowTest.kt | 1 + .../kotlin/io/putdotio/android/files/MobilePinnedSectionTest.kt | 1 + .../io/putdotio/android/playback/MobileConversionVlcTest.kt | 1 + .../io/putdotio/android/viewer/MobileFileViewerLayoutTest.kt | 1 + .../io/putdotio/android/viewer/MobileFileViewerPagingTest.kt | 1 + .../io/putdotio/android/viewer/MobileViewerLoadFailureTest.kt | 1 + .../kotlin/io/putdotio/android/viewer/MobileViewerZoomTest.kt | 1 + 7 files changed, 7 insertions(+) diff --git a/mobile/src/test/kotlin/io/putdotio/android/files/MobileContinueWatchingRowTest.kt b/mobile/src/test/kotlin/io/putdotio/android/files/MobileContinueWatchingRowTest.kt index e84d20ad1..a308181b9 100644 --- a/mobile/src/test/kotlin/io/putdotio/android/files/MobileContinueWatchingRowTest.kt +++ b/mobile/src/test/kotlin/io/putdotio/android/files/MobileContinueWatchingRowTest.kt @@ -1,5 +1,6 @@ package io.putdotio.android.files +import io.putdotio.android.setBuiltContent import androidx.compose.foundation.lazy.LazyColumn import androidx.compose.ui.semantics.SemanticsActions import androidx.compose.ui.test.junit4.createComposeRule diff --git a/mobile/src/test/kotlin/io/putdotio/android/files/MobilePinnedSectionTest.kt b/mobile/src/test/kotlin/io/putdotio/android/files/MobilePinnedSectionTest.kt index d11990e7c..9251069d7 100644 --- a/mobile/src/test/kotlin/io/putdotio/android/files/MobilePinnedSectionTest.kt +++ b/mobile/src/test/kotlin/io/putdotio/android/files/MobilePinnedSectionTest.kt @@ -1,5 +1,6 @@ package io.putdotio.android.files +import io.putdotio.android.setBuiltContent import androidx.compose.foundation.lazy.LazyColumn import androidx.compose.ui.test.junit4.createComposeRule import androidx.compose.ui.test.onNodeWithContentDescription diff --git a/mobile/src/test/kotlin/io/putdotio/android/playback/MobileConversionVlcTest.kt b/mobile/src/test/kotlin/io/putdotio/android/playback/MobileConversionVlcTest.kt index 6098304de..7ffb287c0 100644 --- a/mobile/src/test/kotlin/io/putdotio/android/playback/MobileConversionVlcTest.kt +++ b/mobile/src/test/kotlin/io/putdotio/android/playback/MobileConversionVlcTest.kt @@ -1,5 +1,6 @@ package io.putdotio.android.playback +import io.putdotio.android.setBuiltContent import androidx.compose.ui.test.assertIsDisplayed import androidx.compose.ui.test.junit4.createComposeRule import androidx.compose.ui.test.onNodeWithText diff --git a/mobile/src/test/kotlin/io/putdotio/android/viewer/MobileFileViewerLayoutTest.kt b/mobile/src/test/kotlin/io/putdotio/android/viewer/MobileFileViewerLayoutTest.kt index cedc79ae7..9ad05cbce 100644 --- a/mobile/src/test/kotlin/io/putdotio/android/viewer/MobileFileViewerLayoutTest.kt +++ b/mobile/src/test/kotlin/io/putdotio/android/viewer/MobileFileViewerLayoutTest.kt @@ -1,5 +1,6 @@ package io.putdotio.android.viewer +import io.putdotio.android.setBuiltContent import android.net.Uri import androidx.compose.runtime.getValue import androidx.compose.runtime.mutableStateOf diff --git a/mobile/src/test/kotlin/io/putdotio/android/viewer/MobileFileViewerPagingTest.kt b/mobile/src/test/kotlin/io/putdotio/android/viewer/MobileFileViewerPagingTest.kt index 96c10a3c9..f0d33c78e 100644 --- a/mobile/src/test/kotlin/io/putdotio/android/viewer/MobileFileViewerPagingTest.kt +++ b/mobile/src/test/kotlin/io/putdotio/android/viewer/MobileFileViewerPagingTest.kt @@ -1,5 +1,6 @@ package io.putdotio.android.viewer +import io.putdotio.android.setBuiltContent import android.net.Uri import androidx.compose.runtime.getValue import androidx.compose.runtime.mutableIntStateOf diff --git a/mobile/src/test/kotlin/io/putdotio/android/viewer/MobileViewerLoadFailureTest.kt b/mobile/src/test/kotlin/io/putdotio/android/viewer/MobileViewerLoadFailureTest.kt index 1e5861241..211dcc630 100644 --- a/mobile/src/test/kotlin/io/putdotio/android/viewer/MobileViewerLoadFailureTest.kt +++ b/mobile/src/test/kotlin/io/putdotio/android/viewer/MobileViewerLoadFailureTest.kt @@ -1,5 +1,6 @@ package io.putdotio.android.viewer +import io.putdotio.android.setBuiltContent import android.net.Uri import androidx.activity.ComponentActivity import androidx.compose.ui.test.assertIsDisplayed diff --git a/mobile/src/test/kotlin/io/putdotio/android/viewer/MobileViewerZoomTest.kt b/mobile/src/test/kotlin/io/putdotio/android/viewer/MobileViewerZoomTest.kt index d429e3970..26c46cf9d 100644 --- a/mobile/src/test/kotlin/io/putdotio/android/viewer/MobileViewerZoomTest.kt +++ b/mobile/src/test/kotlin/io/putdotio/android/viewer/MobileViewerZoomTest.kt @@ -1,5 +1,6 @@ package io.putdotio.android.viewer +import io.putdotio.android.setBuiltContent import androidx.compose.foundation.layout.Box import androidx.compose.foundation.layout.fillMaxSize import androidx.compose.foundation.pager.HorizontalPager From 6d390293f384374df1c9aa01fa9fa92f6d86c7ad Mon Sep 17 00:00:00 2001 From: Altay Date: Sun, 15 Nov 2026 13:17:36 +0300 Subject: [PATCH 4/7] fix(mobile): a sort remounts Files at the page it built --- .../kotlin/io/putdotio/android/files/MobileFilesScreen.kt | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/mobile/src/main/kotlin/io/putdotio/android/files/MobileFilesScreen.kt b/mobile/src/main/kotlin/io/putdotio/android/files/MobileFilesScreen.kt index 803d527c5..cca02f94d 100644 --- a/mobile/src/main/kotlin/io/putdotio/android/files/MobileFilesScreen.kt +++ b/mobile/src/main/kotlin/io/putdotio/android/files/MobileFilesScreen.kt @@ -425,14 +425,16 @@ private fun MobileRefreshableFilesContent( is FilesContent.Ready -> { val rowText = rememberFilesRowText(content.items) val pinnedText = rememberFilesRowText(headers.pinned) - val shownContent = rowText.shown(content, content.items) ?: return@PullToRefreshBox + val (shownContent, shownGeneration) = + rowText.shown(content to state.current.viewportGeneration, content.items) + ?: return@PullToRefreshBox val shownHeaders = pinnedText.shown(headers, headers.pinned) ?: return@PullToRefreshBox // The depth tells a folder opened from Search apart from the same folder under it. A // header set that grew or shrank restarts the list from the row-relative viewport. key( state.stack.size, state.current.folder.id.value, - state.current.viewportGeneration, + shownGeneration, shownHeaders.itemCount, ) { MobileFilesList( From 28556ee19176c850142f39811b612b70032d8261 Mon Sep 17 00:00:00 2001 From: Altay Date: Sun, 15 Nov 2026 13:18:38 +0300 Subject: [PATCH 5/7] test(tv): the back-stack shell builds row text in step with composition --- .../io/putdotio/android/TvShellBackTest.kt | 35 +++++++++++-------- 1 file changed, 20 insertions(+), 15 deletions(-) diff --git a/tv/src/test/kotlin/io/putdotio/android/TvShellBackTest.kt b/tv/src/test/kotlin/io/putdotio/android/TvShellBackTest.kt index 7cfb5f922..580c19d50 100644 --- a/tv/src/test/kotlin/io/putdotio/android/TvShellBackTest.kt +++ b/tv/src/test/kotlin/io/putdotio/android/TvShellBackTest.kt @@ -1,5 +1,8 @@ package io.putdotio.android +import kotlinx.coroutines.Dispatchers +import io.putdotio.android.design.LocalBuildDispatcher +import androidx.compose.runtime.CompositionLocalProvider import androidx.activity.compose.BackHandler import androidx.compose.runtime.getValue import androidx.compose.runtime.mutableStateOf @@ -558,21 +561,23 @@ class TvShellBackTest { compose.setContent { // Registered first, so it stands in for the system leaving the app. BackHandler(onBack = onExit) - PutioTvTheme { - TvShell( - account = TvAccount(userId = 1, username = "user", email = "user@example.com"), - onSignOut = {}, - onFilesBack = onFilesBack.takeIf { files().canNavigateBack }, - filesPane = { paneFocus -> - TvFilesScreen( - state = files(), - onEvent = { true }, - onPlayMedia = {}, - modifier = Modifier.focusRequester(paneFocus), - focusMemory = memory, - ) - }, - ) + CompositionLocalProvider(LocalBuildDispatcher provides Dispatchers.Unconfined) { + PutioTvTheme { + TvShell( + account = TvAccount(userId = 1, username = "user", email = "user@example.com"), + onSignOut = {}, + onFilesBack = onFilesBack.takeIf { files().canNavigateBack }, + filesPane = { paneFocus -> + TvFilesScreen( + state = files(), + onEvent = { true }, + onPlayMedia = {}, + modifier = Modifier.focusRequester(paneFocus), + focusMemory = memory, + ) + }, + ) + } } } } From 7efb5ee8f7722c076d777687874e20f56deadb22 Mon Sep 17 00:00:00 2001 From: Altay Date: Sun, 15 Nov 2026 13:22:26 +0300 Subject: [PATCH 6/7] refactor(mobile,tv): the built-page gates fit detekt --- .../android/files/MobileFilesScreen.kt | 101 ++++++++++-------- .../android/search/MobileSearchScreen.kt | 3 +- .../android/tv/search/TvSearchResults.kt | 5 +- 3 files changed, 64 insertions(+), 45 deletions(-) diff --git a/mobile/src/main/kotlin/io/putdotio/android/files/MobileFilesScreen.kt b/mobile/src/main/kotlin/io/putdotio/android/files/MobileFilesScreen.kt index cca02f94d..7405d4d65 100644 --- a/mobile/src/main/kotlin/io/putdotio/android/files/MobileFilesScreen.kt +++ b/mobile/src/main/kotlin/io/putdotio/android/files/MobileFilesScreen.kt @@ -259,6 +259,18 @@ private fun MobileFilesCopyLine(state: FilesBrowserState, onEvent: (FilesBrowser } } +@Composable +private fun BuiltFilesPage( + page: Pair, + headers: MobileFilesHeaders, + rowText: RowText, + pinnedText: RowText, + content: @Composable (FilesContent.Ready, Long, MobileFilesHeaders) -> Unit, +) { + val (shownPage, shownGeneration) = rowText.shown(page, page.first.items) ?: return + content(shownPage, shownGeneration, pinnedText.shown(headers, headers.pinned) ?: return) +} + @Composable private fun MobileRefreshableFilesContent( state: FilesBrowserState, @@ -425,50 +437,53 @@ private fun MobileRefreshableFilesContent( is FilesContent.Ready -> { val rowText = rememberFilesRowText(content.items) val pinnedText = rememberFilesRowText(headers.pinned) - val (shownContent, shownGeneration) = - rowText.shown(content to state.current.viewportGeneration, content.items) - ?: return@PullToRefreshBox - val shownHeaders = pinnedText.shown(headers, headers.pinned) ?: return@PullToRefreshBox - // The depth tells a folder opened from Search apart from the same folder under it. A - // header set that grew or shrank restarts the list from the row-relative viewport. - key( - state.stack.size, - state.current.folder.id.value, - shownGeneration, - shownHeaders.itemCount, - ) { - MobileFilesList( - content = shownContent, - headers = shownHeaders, - onPlayEntry = { onPlayMedia(it.toFilesItem()) }, - onRemoveEntry = hideStarted, - rowText = rowText, - pinnedRows = MobilePinnedRows( - pinnedText, - itemActions.pinnedActions { item -> - openPinned(item, state.current, fileOpening, onEvent, onPlayMedia) + BuiltFilesPage( + content to state.current.viewportGeneration, + headers, + rowText, + pinnedText, + ) { shownContent, shownGeneration, shownHeaders -> + // The depth tells a folder opened from Search apart from the same folder under it. A + // header set that grew or shrank restarts the list from the row-relative viewport. + key( + state.stack.size, + state.current.folder.id.value, + shownGeneration, + shownHeaders.itemCount, + ) { + MobileFilesList( + content = shownContent, + headers = shownHeaders, + onPlayEntry = { onPlayMedia(it.toFilesItem()) }, + onRemoveEntry = hideStarted, + rowText = rowText, + pinnedRows = MobilePinnedRows( + pinnedText, + itemActions.pinnedActions { item -> + openPinned(item, state.current, fileOpening, onEvent, onPlayMedia) + }, + ), + revealItemId = state.current.revealItemId, + pagingEnabled = operation == FilesFolderOperation.Idle, + onEvent = onEvent, + onPlayMedia = onPlayMedia, + onActions = { selectedItemId = it.id.value }, + hasActions = { + it.hasMobileActions(onDownloadItem != null, onShareItem != null, onCopyItem != null) + }, + operation = operation, + downloads = downloads, + onItemFocusChanged = { id, focused -> + focusedItemId = focusedItemId.afterFocusChange(id.value, focused) }, - ), - revealItemId = state.current.revealItemId, - pagingEnabled = operation == FilesFolderOperation.Idle, - onEvent = onEvent, - onPlayMedia = onPlayMedia, - onActions = { selectedItemId = it.id.value }, - hasActions = { - it.hasMobileActions(onDownloadItem != null, onShareItem != null, onCopyItem != null) - }, - operation = operation, - downloads = downloads, - onItemFocusChanged = { id, focused -> - focusedItemId = focusedItemId.afterFocusChange(id.value, focused) - }, - fileDragOut = fileDragOut, - // A touch drag starts after the long press; it closes any sheet that press opened. - onDragStarted = dismissSelection, - fileOpening = fileOpening, - selection = selection.listSelection(state, toolbarClearance), - onStartSelection = selection.starter { currentState }, - ) + fileDragOut = fileDragOut, + // A touch drag starts after the long press; it closes any sheet that press opened. + onDragStarted = dismissSelection, + fileOpening = fileOpening, + selection = selection.listSelection(state, toolbarClearance), + onStartSelection = selection.starter { currentState }, + ) + } } } diff --git a/mobile/src/main/kotlin/io/putdotio/android/search/MobileSearchScreen.kt b/mobile/src/main/kotlin/io/putdotio/android/search/MobileSearchScreen.kt index 7d48e5ab7..a9fd66bba 100644 --- a/mobile/src/main/kotlin/io/putdotio/android/search/MobileSearchScreen.kt +++ b/mobile/src/main/kotlin/io/putdotio/android/search/MobileSearchScreen.kt @@ -395,7 +395,8 @@ private fun MobileSearchResults( modifier: Modifier = Modifier, ) { val rowText = rememberFilesRowText(content.items, dated = false) - MobileSearchResultList(rowText.shown(content, content.items) ?: return, rowText, rows, onNextPage, onRetry, modifier) + val shown = rowText.shown(content, content.items) ?: return + MobileSearchResultList(shown, rowText, rows, onNextPage, onRetry, modifier) } @Composable diff --git a/tv/src/main/kotlin/io/putdotio/android/tv/search/TvSearchResults.kt b/tv/src/main/kotlin/io/putdotio/android/tv/search/TvSearchResults.kt index a0e057603..723328cdc 100644 --- a/tv/src/main/kotlin/io/putdotio/android/tv/search/TvSearchResults.kt +++ b/tv/src/main/kotlin/io/putdotio/android/tv/search/TvSearchResults.kt @@ -125,7 +125,10 @@ internal fun TvSearchResultList( TvListSkeleton(modifier) return } - TvSearchResultRows(shown.first, rowText, shown.second, restoreRowId, rows, onNextPage, onRetry, owner, listFocus, modifier) + val (shownGroups, shownPaging) = shown + TvSearchResultRows( + shownGroups, rowText, shownPaging, restoreRowId, rows, onNextPage, onRetry, owner, listFocus, modifier, + ) } @OptIn(ExperimentalComposeUiApi::class) From 98004d1733f6cf317d3b45c544c420e1961d780d Mon Sep 17 00:00:00 2001 From: Altay Date: Sun, 15 Nov 2026 13:25:00 +0300 Subject: [PATCH 7/7] style(mobile): wrap the Files actions check --- .../kotlin/io/putdotio/android/files/MobileFilesScreen.kt | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/mobile/src/main/kotlin/io/putdotio/android/files/MobileFilesScreen.kt b/mobile/src/main/kotlin/io/putdotio/android/files/MobileFilesScreen.kt index 7405d4d65..159b8d36e 100644 --- a/mobile/src/main/kotlin/io/putdotio/android/files/MobileFilesScreen.kt +++ b/mobile/src/main/kotlin/io/putdotio/android/files/MobileFilesScreen.kt @@ -469,7 +469,11 @@ private fun MobileRefreshableFilesContent( onPlayMedia = onPlayMedia, onActions = { selectedItemId = it.id.value }, hasActions = { - it.hasMobileActions(onDownloadItem != null, onShareItem != null, onCopyItem != null) + it.hasMobileActions( + onDownloadItem != null, + onShareItem != null, + onCopyItem != null, + ) }, operation = operation, downloads = downloads,