youpipe: host TV rail tabs as routes; fix compact detail pager height
- Commit
6c3a8520d6e315ad1b0322449cf11cc18df8f6c2- Author
- Vayun Mathur <[email protected]>
- When
- 2026-11-19 18:25 UTC (16 days ago)
- Parents
13d4371
TV: TvRailHost swapped six screens by a rememberSaveable Int in one TvRoute.Main(initialTab) entry, and TvSearchPage was rendered both by index and via the real TvRoute.Search. The tabs are now sibling routes hosted by the route-backed TvAppFrame (uniflix pattern), TvSearchPage only via TvRoute.Search, and every deep- link seed (subscriptions, history, downloads, settings) returns real routes. 84 TV unit tests pass. Phone: compact VideoDetailScreen passed DetailTabs unweighted into a wrap-height Column, so its HorizontalPager claimed full height and tab content overflowed; it now gets weight(1f). Also single-line Text truncations gained explicit ellipsis in this module. Verified: :youpipe compile + 84 TV tests; phone pager needs a device glance. D-pad focus semantics need a real TV.
Diff
youpipe/src/main/java/com/vayunmathur/youpipe/ui/DownloadedVideosPage.kt
diff --git a/youpipe/src/main/java/com/vayunmathur/youpipe/ui/DownloadedVideosPage.kt b/youpipe/src/main/java/com/vayunmathur/youpipe/ui/DownloadedVideosPage.ktindex 097169d24f..beb5c9fadf 100644--- a/youpipe/src/main/java/com/vayunmathur/youpipe/ui/DownloadedVideosPage.kt+++ b/youpipe/src/main/java/com/vayunmathur/youpipe/ui/DownloadedVideosPage.kt@@ -1,4 +1,5 @@ package com.vayunmathur.youpipe.ui+import androidx.compose.ui.text.style.TextOverflow import com.vayunmathur.youpipe.R import androidx.compose.foundation.ExperimentalFoundationApi@@ -141,7 +142,7 @@ fun DownloadedVideosPage(backStack: NavBackStack<Route>, youPipeViewModel: YouPi modifier = Modifier.size(80.dp, 45.dp).clip(RoundedCornerShape(8.dp)), ) },- content = { Text(status.videoInfo.name, maxLines = 1) },+ content = { Text(status.videoInfo.name, maxLines = 1, overflow = TextOverflow.Ellipsis) }, supportingContent = { Text("${(status.progress * 100).toInt()}%") }, trailingContent = { Row(verticalAlignment = Alignment.CenterVertically) {
youpipe/src/main/java/com/vayunmathur/youpipe/ui/VideoDetailScreen.kt
diff --git a/youpipe/src/main/java/com/vayunmathur/youpipe/ui/VideoDetailScreen.kt b/youpipe/src/main/java/com/vayunmathur/youpipe/ui/VideoDetailScreen.ktindex c5a4189d70..a43de5f6de 100644--- a/youpipe/src/main/java/com/vayunmathur/youpipe/ui/VideoDetailScreen.kt+++ b/youpipe/src/main/java/com/vayunmathur/youpipe/ui/VideoDetailScreen.kt@@ -82,7 +82,7 @@ fun VideoDetailScreen( VideoDetails(state, actions, titleSharedKey) if(!fullscreen) {- DetailTabs(state, actions, initialTab, withDescription = true)+ DetailTabs(state, actions, initialTab, withDescription = true, modifier = Modifier.weight(1f)) } } }@@ -102,6 +102,7 @@ internal fun DetailTabs( actions: VideoDetailActions, initialTab: Int, withDescription: Boolean,+ modifier: Modifier = Modifier, ) { val tabLabels = if (withDescription) { listOf(R.string.label_comments, R.string.label_related_videos, R.string.label_description)@@ -114,7 +115,7 @@ internal fun DetailTabs( ) val coroutineScope = rememberCoroutineScope() - Column {+ Column(modifier) { SecondaryTabRow(selectedTabIndex = pagerState.currentPage) { tabLabels.forEachIndexed { index, labelRes -> Tab(
youpipe/src/main/java/com/vayunmathur/youpipe/ui/VideoDetails.kt
diff --git a/youpipe/src/main/java/com/vayunmathur/youpipe/ui/VideoDetails.kt b/youpipe/src/main/java/com/vayunmathur/youpipe/ui/VideoDetails.ktindex 732f9a0c1d..3841a8d06b 100644--- a/youpipe/src/main/java/com/vayunmathur/youpipe/ui/VideoDetails.kt+++ b/youpipe/src/main/java/com/vayunmathur/youpipe/ui/VideoDetails.kt@@ -25,6 +25,7 @@ import androidx.compose.ui.draw.clip import androidx.compose.ui.platform.LocalContext import androidx.compose.ui.res.stringResource import androidx.compose.ui.text.style.TextAlign+import androidx.compose.ui.text.style.TextOverflow import androidx.compose.ui.unit.dp import androidx.compose.ui.window.Dialog import com.vayunmathur.library.image.ImageRequest@@ -219,6 +220,7 @@ private fun VideoQualityDropdown( modifier = Modifier.weight(1f), textAlign = TextAlign.Start, maxLines = 1,+ overflow = TextOverflow.Ellipsis, ) IconArrowDropDown() }@@ -257,6 +259,7 @@ private fun AudioLanguageDropdown( modifier = Modifier.weight(1f), textAlign = TextAlign.Start, maxLines = 1,+ overflow = TextOverflow.Ellipsis, ) IconArrowDropDown() }
youpipe/src/main/java/com/vayunmathur/youpipe/ui/tv/TvNavigation.kt
diff --git a/youpipe/src/main/java/com/vayunmathur/youpipe/ui/tv/TvNavigation.kt b/youpipe/src/main/java/com/vayunmathur/youpipe/ui/tv/TvNavigation.ktindex 37465dacbe..f119b27701 100644--- a/youpipe/src/main/java/com/vayunmathur/youpipe/ui/tv/TvNavigation.kt+++ b/youpipe/src/main/java/com/vayunmathur/youpipe/ui/tv/TvNavigation.kt@@ -1,19 +1,15 @@ package com.vayunmathur.youpipe.ui.tv import androidx.compose.runtime.Composable-import androidx.compose.runtime.getValue-import androidx.compose.runtime.mutableIntStateOf import androidx.compose.runtime.remember-import androidx.compose.runtime.saveable.rememberSaveable-import androidx.compose.runtime.setValue import androidx.compose.foundation.layout.Box import androidx.compose.foundation.layout.fillMaxSize import androidx.compose.ui.Modifier import androidx.compose.ui.input.key.onPreviewKeyEvent import androidx.compose.ui.res.stringResource import com.vayunmathur.library.tv.TvAppFrame-import com.vayunmathur.library.tv.TvDestination import com.vayunmathur.library.tv.TvIcon+import com.vayunmathur.library.tv.TvRouteDestination import com.vayunmathur.library.ui.IconHistory import com.vayunmathur.library.ui.IconHome import com.vayunmathur.library.ui.IconPhotoLibrary@@ -23,6 +19,7 @@ import com.vayunmathur.library.ui.IconSubscriptions import com.vayunmathur.library.ui.R as UiR import com.vayunmathur.library.util.MainNavigation import com.vayunmathur.library.util.NavBackStack+import com.vayunmathur.library.util.SiblingPage import com.vayunmathur.library.util.rememberNavBackStack import com.vayunmathur.youpipe.platform.DEFAULT_PAGE_ALL_SUBSCRIPTIONS import com.vayunmathur.youpipe.platform.DEFAULT_PAGE_DOWNLOADS@@ -34,16 +31,20 @@ import com.vayunmathur.youpipe.R import com.vayunmathur.youpipe.platform.YouPipeViewModel /**- * The TV navigation host: [rememberNavBackStack] + [MainNavigation] over [TvRoute], inside a- * [TvAppFrame] icon rail.+ * The TV navigation host: [rememberNavBackStack] + [MainNavigation] over [TvRoute]. *- * The rail (Search, Home, Subscriptions, History, Saved, Settings) owns the top-level- * destinations โ focus moves select, CENTER jumps into content, BACK from content returns to- * the rail. Detail routes (video, channel, feed, playlist, settings sub-pages, dialogs-as-pages)- * push above the frame; popping them returns to the rail screen underneath.+ * The six rail tabs are sibling [TvRoute]s hosted by the route-backed+ * [TvAppFrame]; selecting one resets the stack to that tab (SiblingPage+ * semantics). Detail routes (video, channel, feed, playlist, settings+ * sub-pages, dialogs-as-pages) push on top without the rail, so BACK from+ * them returns to the tab that opened them. Each tab entry keeps its own+ * screen, so focus and rememberSaveable state restore per tab.+ *+ * Search is only the [TvRoute.Search] sibling โ there is no direct-index+ * rendering of TvSearchPage inside a rail host anymore. */ @Composable-fun TvNavigation(ypvm: YouPipeViewModel, initialBackStack: List<TvRoute> = listOf(TvRoute.Main())) {+fun TvNavigation(ypvm: YouPipeViewModel, initialBackStack: List<TvRoute> = listOf(TvRoute.Home)) { val backStack = rememberNavBackStack(initialBackStack) // The remote map lives here, not in an Activity dispatchKeyEvent override: preview key // events reach this root before the focus system, so TvDpadInput claims a key only while@@ -55,8 +56,24 @@ fun TvNavigation(ypvm: YouPipeViewModel, initialBackStack: List<TvRoute> = listO .onPreviewKeyEvent { TvDpadInput.onKeyEvent(it.nativeKeyEvent) }, ) { MainNavigation(backStack) {- entry<TvRoute.Main> { TvRailHost(backStack, ypvm, it.initialTab) }- entry<TvRoute.Search> { TvSearchPage(backStack, ypvm) }+ entry<TvRoute.Search>(metadata = SiblingPage()) {+ TvTabFrame(backStack) { TvSearchPage(backStack, ypvm) }+ }+ entry<TvRoute.Home>(metadata = SiblingPage()) {+ TvTabFrame(backStack) { TvHomeFeedPage(backStack, ypvm) }+ }+ entry<TvRoute.Subscriptions>(metadata = SiblingPage()) {+ TvTabFrame(backStack) { TvSubscriptionsPage(backStack, ypvm) }+ }+ entry<TvRoute.History>(metadata = SiblingPage()) {+ TvTabFrame(backStack) { TvHistoryPage(backStack, ypvm) }+ }+ entry<TvRoute.Saved>(metadata = SiblingPage()) {+ TvTabFrame(backStack) { TvSavedPage(backStack, ypvm) }+ }+ entry<TvRoute.Settings>(metadata = SiblingPage()) {+ TvTabFrame(backStack) { TvSettingsPage(backStack, ypvm) }+ } entry<TvRoute.Video> { TvVideoPage(backStack, ypvm, it.videoID) } entry<TvRoute.VideoPlayerRoute> { TvPlayerPage(backStack, ypvm, it.videoID) } entry<TvRoute.Channel> { TvChannelPage(backStack, ypvm, it.channelID) }@@ -77,63 +94,54 @@ fun TvNavigation(ypvm: YouPipeViewModel, initialBackStack: List<TvRoute> = listO /** * Map a persisted default-page key to the TV initial backstack, mirroring the phone- * [com.vayunmathur.youpipe.platform.defaultBackStack] mapping. Rail indices match [TvRailHost]:- * `all_subscriptions` seeds the Subscriptions root beneath the feed so BACK returns to the- * list instead of exiting.+ * [com.vayunmathur.youpipe.platform.defaultBackStack] mapping. The start entry is a+ * real sibling rail route; `all_subscriptions` seeds the Subscriptions root beneath+ * the feed so BACK returns to the list instead of exiting. */ fun tvDefaultBackStack(key: String?): List<TvRoute> = when (key) {- DEFAULT_PAGE_SUBSCRIPTIONS -> listOf(TvRoute.Main(TV_RAIL_SUBSCRIPTIONS))+ DEFAULT_PAGE_SUBSCRIPTIONS -> listOf(TvRoute.Subscriptions) DEFAULT_PAGE_ALL_SUBSCRIPTIONS ->- listOf(TvRoute.Main(TV_RAIL_SUBSCRIPTIONS), TvRoute.SubscriptionFeed(null))- DEFAULT_PAGE_HISTORY -> listOf(TvRoute.Main(TV_RAIL_HISTORY))+ listOf(TvRoute.Subscriptions, TvRoute.SubscriptionFeed(null))+ DEFAULT_PAGE_HISTORY -> listOf(TvRoute.History) // Both the legacy "downloads" key and the new "saved" key open the Saved hub.- DEFAULT_PAGE_DOWNLOADS, DEFAULT_PAGE_SAVED -> listOf(TvRoute.Main(TV_RAIL_SAVED))- DEFAULT_PAGE_SETTINGS -> listOf(TvRoute.Main(TV_RAIL_SETTINGS))- else -> listOf(TvRoute.Main(TV_RAIL_HOME)) // home / unset / unknown+ DEFAULT_PAGE_DOWNLOADS, DEFAULT_PAGE_SAVED -> listOf(TvRoute.Saved)+ DEFAULT_PAGE_SETTINGS -> listOf(TvRoute.Settings)+ else -> listOf(TvRoute.Home) // home / unset / unknown } /**- * The six TV rail destinations inside [TvAppFrame]: Search is a destination (never a grid- * card), then Home, Subscriptions, History, Saved/Library, Settings.+ * One rail tab's frame: the route-backed [TvAppFrame] (rail appearance and+ * focus behaviour unchanged from the index-based frame) around [content].+ * Only composed while a tab is on top โ pushed pages get no rail.+ * BACK on a root tab returns to the rail; BACK from the rail exits. */ @Composable-private fun TvRailHost(- backStack: NavBackStack<TvRoute>,- ypvm: YouPipeViewModel,- initialTab: Int,-) {- var rail by rememberSaveable { mutableIntStateOf(initialTab.coerceIn(0, TV_RAIL_COUNT - 1)) }+private fun TvTabFrame(backStack: NavBackStack<TvRoute>, content: @Composable () -> Unit) {+ TvAppFrame(+ backStack = backStack,+ destinations = railDestinations(),+ // This frame is always the bottom of the TV stack: BACK from content returns to+ // the rail, and BACK from the rail exits (the activity finishes).+ backReturnsToRail = backStack.backStack.size <= 1,+ ) { content() }+}++@Composable+private fun railDestinations(): List<TvRouteDestination<TvRoute>> { val searchLabel = stringResource(UiR.string.search) val homeLabel = stringResource(UiR.string.home) val subsLabel = stringResource(R.string.title_subscriptions) val historyLabel = stringResource(R.string.title_history) val savedLabel = stringResource(UiR.string.saved) val settingsLabel = stringResource(UiR.string.settings)- val destinations = remember(searchLabel, homeLabel, subsLabel, historyLabel, savedLabel, settingsLabel) {+ return remember(searchLabel, homeLabel, subsLabel, historyLabel, savedLabel, settingsLabel) { listOf(- TvDestination(searchLabel) { TvIcon { IconSearch() } },- TvDestination(homeLabel) { TvIcon { IconHome() } },- TvDestination(subsLabel) { TvIcon { IconSubscriptions() } },- TvDestination(historyLabel) { TvIcon { IconHistory() } },- TvDestination(savedLabel) { TvIcon { IconPhotoLibrary() } },- TvDestination(settingsLabel) { TvIcon { IconSettings() } },+ TvRouteDestination(TvRoute.Search, searchLabel) { TvIcon { IconSearch() } },+ TvRouteDestination(TvRoute.Home, homeLabel) { TvIcon { IconHome() } },+ TvRouteDestination(TvRoute.Subscriptions, subsLabel) { TvIcon { IconSubscriptions() } },+ TvRouteDestination(TvRoute.History, historyLabel) { TvIcon { IconHistory() } },+ TvRouteDestination(TvRoute.Saved, savedLabel) { TvIcon { IconPhotoLibrary() } },+ TvRouteDestination(TvRoute.Settings, settingsLabel) { TvIcon { IconSettings() } }, ) }- TvAppFrame(- destinations = destinations,- selected = rail,- onSelect = { rail = it },- // This frame is always the bottom of the TV stack: BACK from content returns to- // the rail, and BACK from the rail exits (the activity finishes).- backReturnsToRail = backStack.backStack.size <= 1,- ) {- when (rail) {- TV_RAIL_SEARCH -> TvSearchPage(backStack, ypvm)- TV_RAIL_HOME -> TvHomeFeedPage(backStack, ypvm)- TV_RAIL_SUBSCRIPTIONS -> TvSubscriptionsPage(backStack, ypvm)- TV_RAIL_HISTORY -> TvHistoryPage(backStack, ypvm)- TV_RAIL_SAVED -> TvSavedPage(backStack, ypvm)- else -> TvSettingsPage(backStack, ypvm)- }- } }
youpipe/src/main/java/com/vayunmathur/youpipe/ui/tv/TvRoute.kt
diff --git a/youpipe/src/main/java/com/vayunmathur/youpipe/ui/tv/TvRoute.kt b/youpipe/src/main/java/com/vayunmathur/youpipe/ui/tv/TvRoute.ktindex 02a2a3e9af..d656213039 100644--- a/youpipe/src/main/java/com/vayunmathur/youpipe/ui/tv/TvRoute.kt+++ b/youpipe/src/main/java/com/vayunmathur/youpipe/ui/tv/TvRoute.kt@@ -11,16 +11,37 @@ import kotlinx.serialization.Serializable * destination can never leak into the phone back stack or vice versa. Dialogs (add-to-playlist, * create-playlist, create-category) are entries here rather than overlays, because a TV has no * bottom sheet to host them: each is a full D-pad-traversable list screen with its own focus.+ *+ * The six rail tabs are siblings: selecting one resets the back stack to that route+ * (see the route-backed TvAppFrame), so BACK, deep links and process restore see+ * the tab actually on screen. The old `Main(initialTab)` wrapper is gone;+ * [tvRouteForTab] turns a legacy tab index into the start sibling. */ @Serializable sealed interface TvRoute : NavKey {- /** The tab strip: home feed, subscriptions, history, saved, settings. No swipe, D-pad only. */+ /** Rail tab: search. A sibling route, opened via the rail (see TvRouteDestination). */ @Serializable- data class Main(val initialTab: Int = 0) : TvRoute+ data object Search : TvRoute - /** Explicit search screen: opened only from the home entry row's CENTER press, never autofocused. */+ /** Rail tab: home feed (the default start tab). */ @Serializable- data object Search : TvRoute+ data object Home : TvRoute++ /** Rail tab: subscriptions. */+ @Serializable+ data object Subscriptions : TvRoute++ /** Rail tab: watch history. */+ @Serializable+ data object History : TvRoute++ /** Rail tab: saved / library hub (playlists, watch later, downloads entry). */+ @Serializable+ data object Saved : TvRoute++ /** Rail tab: settings hub. */+ @Serializable+ data object Settings : TvRoute /** Details for one video: description, chapters, related, comments. Opened from the player. */ @Serializable@@ -79,7 +100,7 @@ sealed interface TvRoute : NavKey { data object ManageInterests : TvRoute } -/** Rail indices in [TvRailHost]: Search is a destination, then the five browse roots. */+/** Rail indices, matching the rail order. Kept for the legacy initialTab int. */ const val TV_RAIL_SEARCH = 0 const val TV_RAIL_HOME = 1 const val TV_RAIL_SUBSCRIPTIONS = 2@@ -87,3 +108,13 @@ const val TV_RAIL_HISTORY = 3 const val TV_RAIL_SAVED = 4 const val TV_RAIL_SETTINGS = 5 const val TV_RAIL_COUNT = 6++/** The sibling route for a legacy rail [tab] index, clamped to the rail range. */+internal fun tvRouteForTab(tab: Int): TvRoute = when (tab.coerceIn(TV_RAIL_SEARCH, TV_RAIL_SETTINGS)) {+ TV_RAIL_SEARCH -> TvRoute.Search+ TV_RAIL_HOME -> TvRoute.Home+ TV_RAIL_SUBSCRIPTIONS -> TvRoute.Subscriptions+ TV_RAIL_HISTORY -> TvRoute.History+ TV_RAIL_SAVED -> TvRoute.Saved+ else -> TvRoute.Settings+}
youpipe/src/test/java/com/vayunmathur/youpipe/ui/tv/TvBrowseDeepTest.kt
diff --git a/youpipe/src/test/java/com/vayunmathur/youpipe/ui/tv/TvBrowseDeepTest.kt b/youpipe/src/test/java/com/vayunmathur/youpipe/ui/tv/TvBrowseDeepTest.ktindex 2fe433c9f7..b3f775718a 100644--- a/youpipe/src/test/java/com/vayunmathur/youpipe/ui/tv/TvBrowseDeepTest.kt+++ b/youpipe/src/test/java/com/vayunmathur/youpipe/ui/tv/TvBrowseDeepTest.kt@@ -100,7 +100,7 @@ class TvBrowseDeepTest { clickNodeAt(count - 1) } private fun themed(content: @androidx.compose.runtime.Composable (NavBackStack<TvRoute>) -> Unit) {- rule.setContent { val bs = rememberNavBackStack<TvRoute>(TvRoute.Main(TV_RAIL_HOME)); stack = bs; MaTvTheme(TvAccent.Red) { content(bs) } }+ rule.setContent { val bs = rememberNavBackStack<TvRoute>(TvRoute.Home); stack = bs; MaTvTheme(TvAccent.Red) { content(bs) } } } private fun presetLoaded() { TvLoadedVideo.id = 77@@ -175,13 +175,13 @@ class TvBrowseDeepTest { assertEquals(TvRoute.VideoPlayerRoute(66), stack?.backStack?.lastOrNull()) } @Test fun tvDefaultBackStack_allKeys() {- assertEquals(listOf(TvRoute.Main(TV_RAIL_SUBSCRIPTIONS)), tvDefaultBackStack("subscriptions"))- assertEquals(listOf(TvRoute.Main(TV_RAIL_HISTORY)), tvDefaultBackStack("history"))- assertEquals(listOf(TvRoute.Main(TV_RAIL_SAVED)), tvDefaultBackStack("downloads"))- assertEquals(listOf(TvRoute.Main(TV_RAIL_SAVED)), tvDefaultBackStack("saved"))- assertEquals(listOf(TvRoute.Main(TV_RAIL_SETTINGS)), tvDefaultBackStack("settings"))- assertEquals(listOf(TvRoute.Main(TV_RAIL_HOME)), tvDefaultBackStack(null))- assertEquals(listOf(TvRoute.Main(TV_RAIL_HOME)), tvDefaultBackStack("home"))+ assertEquals(listOf(TvRoute.Subscriptions), tvDefaultBackStack("subscriptions"))+ assertEquals(listOf(TvRoute.History), tvDefaultBackStack("history"))+ assertEquals(listOf(TvRoute.Saved), tvDefaultBackStack("downloads"))+ assertEquals(listOf(TvRoute.Saved), tvDefaultBackStack("saved"))+ assertEquals(listOf(TvRoute.Settings), tvDefaultBackStack("settings"))+ assertEquals(listOf(TvRoute.Home), tvDefaultBackStack(null))+ assertEquals(listOf(TvRoute.Home), tvDefaultBackStack("home")) } @Test fun tvSharedHelpers_subtitleAndDuration() { assertEquals(null, tvDurationBadge(-1)); assertEquals("10:00", tvDurationBadge(600))
youpipe/src/test/java/com/vayunmathur/youpipe/ui/tv/TvFeedDeepTest.kt
diff --git a/youpipe/src/test/java/com/vayunmathur/youpipe/ui/tv/TvFeedDeepTest.kt b/youpipe/src/test/java/com/vayunmathur/youpipe/ui/tv/TvFeedDeepTest.ktindex 011a0f9f68..a39d55f853 100644--- a/youpipe/src/test/java/com/vayunmathur/youpipe/ui/tv/TvFeedDeepTest.kt+++ b/youpipe/src/test/java/com/vayunmathur/youpipe/ui/tv/TvFeedDeepTest.kt@@ -65,7 +65,7 @@ class TvFeedDeepTest { @AfterTest fun tearDown() { TvLoadedVideo.id = null; Thread.sleep(100) } private fun awaitText(t: String) = rule.waitUntilExactlyOneExists(hasText(t), 15_000) private fun themed(content: @androidx.compose.runtime.Composable (NavBackStack<TvRoute>) -> Unit) {- rule.setContent { val bs = rememberNavBackStack<TvRoute>(TvRoute.Main(TV_RAIL_HOME)); stack = bs; MaTvTheme(TvAccent.Red) { content(bs) } }+ rule.setContent { val bs = rememberNavBackStack<TvRoute>(TvRoute.Home); stack = bs; MaTvTheme(TvAccent.Red) { content(bs) } } } private fun clickFirstCard() { val count = rule.onAllNodes(hasClickAction()).fetchSemanticsNodes().size
youpipe/src/test/java/com/vayunmathur/youpipe/ui/tv/TvPagesDeep2Test.kt
diff --git a/youpipe/src/test/java/com/vayunmathur/youpipe/ui/tv/TvPagesDeep2Test.kt b/youpipe/src/test/java/com/vayunmathur/youpipe/ui/tv/TvPagesDeep2Test.ktindex a9b2feac73..1cafffd189 100644--- a/youpipe/src/test/java/com/vayunmathur/youpipe/ui/tv/TvPagesDeep2Test.kt+++ b/youpipe/src/test/java/com/vayunmathur/youpipe/ui/tv/TvPagesDeep2Test.kt@@ -71,7 +71,7 @@ class TvPagesDeep2Test { if (a != null) assertTrue(a.invoke() == true, "click $t") else node.performClick() } private fun themed(content: @androidx.compose.runtime.Composable (NavBackStack<TvRoute>) -> Unit) {- rule.setContent { val bs = rememberNavBackStack<TvRoute>(TvRoute.Main(TV_RAIL_HOME)); stack = bs; MaTvTheme(TvAccent.Red) { content(bs) } }+ rule.setContent { val bs = rememberNavBackStack<TvRoute>(TvRoute.Home); stack = bs; MaTvTheme(TvAccent.Red) { content(bs) } } } private fun awaitDb(cond: () -> Boolean) { val d = System.currentTimeMillis() + 8_000@@ -89,14 +89,14 @@ class TvPagesDeep2Test { vm.videoStateMutable.value = YouPipeViewModel.VideoState(data = VideoData("Watched One", 100, 55, Instant.fromEpochSeconds(1_600_000_000), "", "Seeded Chan", "UCseed", "", "desc")) themed { bs -> bs.add(TvRoute.AddToPlaylist(55)); TvAddToPlaylistPage(bs, vm, 55) } awaitText("Music Mix"); clickText("Music Mix"); clickText("Cancel")- rule.waitUntil(5_000) { stack?.backStack?.lastOrNull() == TvRoute.Main(TV_RAIL_HOME) }+ rule.waitUntil(5_000) { stack?.backStack?.lastOrNull() == TvRoute.Home } assertTrue(runBlocking { db.playlistItemDao().getAllFlow().first() }.none { it.videoItem.videoID == 55L }) } @Test fun addToPlaylist_noVideoData_showsCloseAndPops() { vm.videoStateMutable.value = YouPipeViewModel.VideoState() themed { bs -> bs.add(TvRoute.AddToPlaylist(55)); TvAddToPlaylistPage(bs, vm, 55) } awaitText("Close"); clickText("Close")- rule.waitUntil(5_000) { stack?.backStack?.lastOrNull() == TvRoute.Main(TV_RAIL_HOME) }+ rule.waitUntil(5_000) { stack?.backStack?.lastOrNull() == TvRoute.Home } } @Test fun dataSettings_clearHistory_emptiesDb() { themed { _ -> TvDataSettingsPage(vm) }@@ -124,7 +124,7 @@ class TvPagesDeep2Test { rule.onNode(hasSetTextAction()).performTextInput("Road Trip") clickText("New playlist") awaitDb { runBlocking { db.playlistDao().getAll() }.any { it.name == "Road Trip" } }- rule.waitUntil(5_000) { stack?.backStack?.lastOrNull() == TvRoute.Main(TV_RAIL_HOME) }+ rule.waitUntil(5_000) { stack?.backStack?.lastOrNull() == TvRoute.Home } } @Test fun createCategory_typeNameAndCreate_persists() { themed { bs -> TvCreateCategoryPage(bs, vm, null) }@@ -144,6 +144,6 @@ class TvPagesDeep2Test { @Test fun subscriptions_categoryRow_showsSeededChannel() { themed { bs -> TvSubscriptionsPage(bs, vm) } awaitText("Seeded Chan"); awaitText("News")- assertEquals(TvRoute.Main(TV_RAIL_HOME), stack?.backStack?.lastOrNull())+ assertEquals(TvRoute.Home, stack?.backStack?.lastOrNull()) } }
youpipe/src/test/java/com/vayunmathur/youpipe/ui/tv/TvPagesTest.kt
diff --git a/youpipe/src/test/java/com/vayunmathur/youpipe/ui/tv/TvPagesTest.kt b/youpipe/src/test/java/com/vayunmathur/youpipe/ui/tv/TvPagesTest.ktindex c2e652b579..814a3c1ace 100644--- a/youpipe/src/test/java/com/vayunmathur/youpipe/ui/tv/TvPagesTest.kt+++ b/youpipe/src/test/java/com/vayunmathur/youpipe/ui/tv/TvPagesTest.kt@@ -135,7 +135,7 @@ class TvPagesTest { private fun themed(content: @androidx.compose.runtime.Composable (NavBackStack<TvRoute>) -> Unit) { rule.setContent {- val backStack = rememberNavBackStack<TvRoute>(TvRoute.Main(TV_RAIL_HOME))+ val backStack = rememberNavBackStack<TvRoute>(TvRoute.Home) stack = backStack MaTvTheme(TvAccent.Red) { content(backStack) } }@@ -316,7 +316,7 @@ class TvPagesTest { themed { bs -> TvChannelPage(bs, vm, "UCunknown123") } // Channel load fails offline: page must settle without crashing or navigating. rule.waitForIdle()- assertEquals(TvRoute.Main(TV_RAIL_HOME), stack?.backStack?.lastOrNull())+ assertEquals(TvRoute.Home, stack?.backStack?.lastOrNull()) } @Test@@ -430,10 +430,10 @@ class TvPagesTest { assertEquals("0:00", formatTvElapsed(0)) assertEquals("1:05", formatTvElapsed(65_000)) // tvDefaultBackStack maps persisted keys to rail destinations.- assertEquals(listOf(TvRoute.Main(TV_RAIL_HISTORY)), tvDefaultBackStack("history"))- assertEquals(listOf(TvRoute.Main(TV_RAIL_HOME)), tvDefaultBackStack("nonsense"))+ assertEquals(listOf(TvRoute.History), tvDefaultBackStack("history"))+ assertEquals(listOf(TvRoute.Home), tvDefaultBackStack("nonsense")) assertEquals(- listOf(TvRoute.Main(TV_RAIL_SUBSCRIPTIONS), TvRoute.SubscriptionFeed(null)),+ listOf(TvRoute.Subscriptions, TvRoute.SubscriptionFeed(null)), tvDefaultBackStack("all_subscriptions"), ) }
youpipe/src/test/java/com/vayunmathur/youpipe/ui/tv/TvPlayerDeepTest.kt
diff --git a/youpipe/src/test/java/com/vayunmathur/youpipe/ui/tv/TvPlayerDeepTest.kt b/youpipe/src/test/java/com/vayunmathur/youpipe/ui/tv/TvPlayerDeepTest.ktindex 767f5e4a30..910a95c481 100644--- a/youpipe/src/test/java/com/vayunmathur/youpipe/ui/tv/TvPlayerDeepTest.kt+++ b/youpipe/src/test/java/com/vayunmathur/youpipe/ui/tv/TvPlayerDeepTest.kt@@ -167,7 +167,7 @@ class TvPlayerDeepTest { videoStreams = streams, audioStreams = audios, subtitles = subs, segments = chapters, relatedVideos = listOf(info)) rule.setContent { MaTvTheme(TvAccent.Red) {- val bs = rememberNavBackStack<TvRoute>(TvRoute.Main(TV_RAIL_HOME)); stack = bs+ val bs = rememberNavBackStack<TvRoute>(TvRoute.Home); stack = bs TvPlayerPage(bs, vm, 77) } } awaitText("Deep Video")@@ -183,7 +183,7 @@ class TvPlayerDeepTest { val c = chrome({ details++ }, { channel++ }, { sub++ }, { wl++ }, { save++ }, { relatedId = it }) c.onDetails(); c.onChannel(); c.onToggleSubscribe(); c.onWatchLater(); c.onSaveToPlaylist(); c.onPlayRelated(99) assertEquals(listOf(1, 1, 1, 1, 1), listOf(details, channel, sub, wl, save)); assertEquals(99L, relatedId)- rule.setContent { val bs = rememberNavBackStack<TvRoute>(TvRoute.Main(TV_RAIL_HOME)); stack = bs }+ rule.setContent { val bs = rememberNavBackStack<TvRoute>(TvRoute.Home); stack = bs } rule.waitForIdle() stack!!.playVideo(42); assertEquals(TvRoute.VideoPlayerRoute(42), stack!!.backStack.last()) // From details of same video: pops back to existing player instead of stacking.@@ -197,7 +197,7 @@ class TvPlayerDeepTest { @Test fun rememberChrome_subscribeToggleAndWatchLater_withSeededVm() { var captured: TvPlayerChrome? = null rule.setContent { MaTvTheme(TvAccent.Red) {- val bs = rememberNavBackStack<TvRoute>(TvRoute.Main(TV_RAIL_HOME)); stack = bs+ val bs = rememberNavBackStack<TvRoute>(TvRoute.Home); stack = bs val data = VideoData("Deep Video", 900, 120, Instant.fromEpochSeconds(1_600_000_000), "", "Seeded Chan", "UCseed", "", "desc") captured = rememberTvPlayerChrome(bs, vm, 55, data, listOf(info)) androidx.tv.material3.Text(captured!!.byline)
youpipe/src/test/java/com/vayunmathur/youpipe/ui/tv/TvSearchChannelDeepTest.kt
diff --git a/youpipe/src/test/java/com/vayunmathur/youpipe/ui/tv/TvSearchChannelDeepTest.kt b/youpipe/src/test/java/com/vayunmathur/youpipe/ui/tv/TvSearchChannelDeepTest.ktindex 277f761c59..94b28b38ee 100644--- a/youpipe/src/test/java/com/vayunmathur/youpipe/ui/tv/TvSearchChannelDeepTest.kt+++ b/youpipe/src/test/java/com/vayunmathur/youpipe/ui/tv/TvSearchChannelDeepTest.kt@@ -67,7 +67,7 @@ class TvSearchChannelDeepTest { if (a != null) assertTrue(a.invoke() == true, "click $t") else node.performClick() } private fun themed(content: @androidx.compose.runtime.Composable (NavBackStack<TvRoute>) -> Unit) {- rule.setContent { val bs = rememberNavBackStack<TvRoute>(TvRoute.Main(TV_RAIL_HOME)); stack = bs; MaTvTheme(TvAccent.Red) { content(bs) } }+ rule.setContent { val bs = rememberNavBackStack<TvRoute>(TvRoute.Home); stack = bs; MaTvTheme(TvAccent.Red) { content(bs) } } } @Test fun search_resultsGrid_showsChannelsAndVideos_andChannelOpens() {
youpipe/src/test/java/com/vayunmathur/youpipe/ui/tv/TvSearchDownloadsDeepTest.kt
diff --git a/youpipe/src/test/java/com/vayunmathur/youpipe/ui/tv/TvSearchDownloadsDeepTest.kt b/youpipe/src/test/java/com/vayunmathur/youpipe/ui/tv/TvSearchDownloadsDeepTest.ktindex 4bfeb3e42b..1de81a82aa 100644--- a/youpipe/src/test/java/com/vayunmathur/youpipe/ui/tv/TvSearchDownloadsDeepTest.kt+++ b/youpipe/src/test/java/com/vayunmathur/youpipe/ui/tv/TvSearchDownloadsDeepTest.kt@@ -62,7 +62,7 @@ class TvSearchDownloadsDeepTest { if (a != null) assertTrue(a.invoke() == true, "click $t") else node.performClick() } private fun themed(content: @androidx.compose.runtime.Composable (NavBackStack<TvRoute>) -> Unit) {- rule.setContent { val bs = rememberNavBackStack<TvRoute>(TvRoute.Main(TV_RAIL_HOME)); stack = bs; MaTvTheme(TvAccent.Red) { content(bs) } }+ rule.setContent { val bs = rememberNavBackStack<TvRoute>(TvRoute.Home); stack = bs; MaTvTheme(TvAccent.Red) { content(bs) } } } @Test fun downloads_longPressSelectsAndDeleteRemoves() {