Merge pull request 'Fix system Back ownership for titles and Home' (#67) from fm/tv-back-title into fm/tv-round2
This commit is contained in:
commit
1dee89975e
27 changed files with 196 additions and 77 deletions
|
|
@ -53,6 +53,7 @@ dependencies {
|
|||
robolectricSdk("org.robolectric:android-all-instrumented:9-robolectric-4913185-2-i7")
|
||||
robolectricSdk("org.robolectric:android-all-instrumented:11-robolectric-6757853-i7")
|
||||
robolectricSdk("org.robolectric:android-all-instrumented:14-robolectric-10818077-i7")
|
||||
robolectricSdk("org.robolectric:android-all-instrumented:16-robolectric-13921718-i7")
|
||||
implementation(platform(libs.androidx.compose.bom))
|
||||
implementation(libs.androidx.compose.ui)
|
||||
implementation(libs.androidx.tv.material)
|
||||
|
|
|
|||
|
|
@ -32,14 +32,14 @@ import androidx.tv.material3.Text
|
|||
import org.justinvisser.wolfskin.design.WolfskinTokens.Color as C
|
||||
import org.justinvisser.wolfskin.design.WolfskinTokens.Layout as L
|
||||
|
||||
/** Screens and the shell interpret the same Android directional and activation keys. */
|
||||
/** Native Back belongs to the Activity dispatcher; Escape remains the local Back shortcut. */
|
||||
fun readShellKey(event: KeyEvent): ShellKey? = when (event.key) {
|
||||
Key.DirectionUp -> ShellKey.Up
|
||||
Key.DirectionDown -> ShellKey.Down
|
||||
Key.DirectionLeft -> ShellKey.Left
|
||||
Key.DirectionRight -> ShellKey.Right
|
||||
Key.DirectionCenter, Key.Enter, Key.NumPadEnter -> ShellKey.Ok
|
||||
Key.Back, Key.Escape -> ShellKey.Back
|
||||
Key.Escape -> ShellKey.Back
|
||||
else -> null
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -59,7 +59,7 @@ class DiscoverKeysTest {
|
|||
assertEquals(path.getInt("presses"), keys.length())
|
||||
launch()
|
||||
repeat(keys.length()) { index -> press(when (keys.getString(index)) {
|
||||
"OK" -> Key.DirectionCenter; "UP" -> Key.DirectionUp; "DOWN" -> Key.DirectionDown; "LEFT" -> Key.DirectionLeft; "RIGHT" -> Key.DirectionRight; else -> Key.Back
|
||||
"OK" -> Key.DirectionCenter; "UP" -> Key.DirectionUp; "DOWN" -> Key.DirectionDown; "LEFT" -> Key.DirectionLeft; "RIGHT" -> Key.DirectionRight; else -> Key.Escape
|
||||
}) }
|
||||
rule.waitForIdle()
|
||||
}
|
||||
|
|
@ -144,7 +144,7 @@ class DiscoverKeysTest {
|
|||
@Test fun closingAnUncertainReceiptNeverTurnsReopeningIntoAnotherPost() {
|
||||
operations.next = RequestPhase.NotConfirmed
|
||||
replay("Request a pick for yourself")
|
||||
press(Key.Back, Key.DirectionCenter)
|
||||
press(Key.Escape, Key.DirectionCenter)
|
||||
assertEquals(RequestPhase.NotConfirmed, (state.overlay as DiscoverOverlayState.Request).state.phase)
|
||||
operations.next = RequestPhase.Receipt
|
||||
press(Key.DirectionCenter)
|
||||
|
|
@ -173,7 +173,7 @@ class DiscoverKeysTest {
|
|||
press(Key.DirectionDown, Key.DirectionCenter)
|
||||
press(Key.DirectionCenter)
|
||||
assertEquals("shared", operations.sent.single().requester)
|
||||
press(Key.Back, Key.DirectionCenter)
|
||||
press(Key.Escape, Key.DirectionCenter)
|
||||
press(Key.DirectionDown, Key.DirectionCenter)
|
||||
press(Key.DirectionCenter)
|
||||
assertEquals(1, operations.sent.size)
|
||||
|
|
@ -260,7 +260,7 @@ class DiscoverKeysTest {
|
|||
val origin = shell.view
|
||||
state.openCollection(state.lanes.first { it.id == "pk-movie" })
|
||||
launch()
|
||||
press(Key.DirectionDown, Key.Back)
|
||||
press(Key.DirectionDown, Key.Escape)
|
||||
assertNull(state.collection)
|
||||
assertSame(origin, shell.view)
|
||||
assertEquals(3, shell.view.row)
|
||||
|
|
@ -289,9 +289,9 @@ class DiscoverKeysTest {
|
|||
val moved = state.column
|
||||
press(Key.DirectionCenter)
|
||||
assertNotNull("This round trip must open a title, not a service lane", state.title)
|
||||
press(Key.Back)
|
||||
press(Key.Escape)
|
||||
assertEquals(moved, state.column)
|
||||
press(Key.Back)
|
||||
press(Key.Escape)
|
||||
press(Key.DirectionLeft, Key.DirectionCenter)
|
||||
assertEquals("home", shell.route)
|
||||
press(Key.DirectionUp, Key.DirectionRight)
|
||||
|
|
|
|||
|
|
@ -219,7 +219,7 @@ class HomeKeysTest {
|
|||
val key = when (name) {
|
||||
"UP" -> Key.DirectionUp; "DOWN" -> Key.DirectionDown
|
||||
"LEFT" -> Key.DirectionLeft; "RIGHT" -> Key.DirectionRight
|
||||
"BACK" -> Key.Back; else -> Key.DirectionCenter
|
||||
"BACK" -> Key.Escape; else -> Key.DirectionCenter
|
||||
}
|
||||
rule.onNodeWithTag("wolfskin-shell").performKeyInput { pressKey(key) }
|
||||
}
|
||||
|
|
|
|||
|
|
@ -44,7 +44,7 @@ class HomeNavigationTest {
|
|||
mount()
|
||||
press(Key.DirectionDown)
|
||||
press(Key.DirectionCenter)
|
||||
press(Key.Back)
|
||||
press(Key.Escape)
|
||||
rule.runOnIdle { outgoing = null }
|
||||
rule.waitForIdle()
|
||||
rule.mainClock.autoAdvance = false
|
||||
|
|
@ -80,7 +80,7 @@ class HomeNavigationTest {
|
|||
press(Key.DirectionDown)
|
||||
press(Key.DirectionCenter)
|
||||
rule.onNodeWithTag("title-page").assertIsDisplayed()
|
||||
press(Key.Back)
|
||||
press(Key.Escape)
|
||||
rule.runOnIdle { outgoing = null }
|
||||
rule.waitForIdle()
|
||||
assertEquals(2, shell.view.row)
|
||||
|
|
@ -95,7 +95,7 @@ class HomeNavigationTest {
|
|||
val saved = shell.view
|
||||
press(Key.DirectionCenter)
|
||||
rule.onNodeWithTag("title-page").assertIsDisplayed()
|
||||
press(Key.Back)
|
||||
press(Key.Escape)
|
||||
assertSame(saved, shell.view)
|
||||
assertEquals(1, shell.view.row)
|
||||
walkDown(start = 1)
|
||||
|
|
|
|||
|
|
@ -46,7 +46,7 @@ class HomeRatingsUiTest {
|
|||
rule.onNodeWithText("7.8").assertDoesNotExist()
|
||||
rule.mainClock.advanceTimeBy(450)
|
||||
rule.onNodeWithText("7.8").assertExists()
|
||||
rule.onNodeWithTag("wolfskin-shell").performKeyInput { pressKey(Key.Back) }
|
||||
rule.onNodeWithTag("wolfskin-shell").performKeyInput { pressKey(Key.Escape) }
|
||||
rule.runOnIdle { assertTrue(shell.navFocused) }
|
||||
rule.mainClock.advanceTimeBy(32)
|
||||
rule.onNodeWithText("7.8").assertDoesNotExist()
|
||||
|
|
|
|||
|
|
@ -61,7 +61,7 @@ class HomeViewportTest {
|
|||
capture("viewport-${row.id}")
|
||||
press(Key.DirectionCenter)
|
||||
rule.onNodeWithTag("title-page").assertIsDisplayed()
|
||||
press(Key.Back)
|
||||
press(Key.Escape)
|
||||
assertVisible(shell, rows)
|
||||
}
|
||||
repeat(rows.lastIndex) { press(Key.DirectionUp); assertVisible(shell, rows) }
|
||||
|
|
|
|||
|
|
@ -77,7 +77,7 @@ class LibraryKeysTest {
|
|||
repeat(6) { press(Key.DirectionRight) }
|
||||
assertEquals(5, grid.index)
|
||||
assertFalse(grid.inRail)
|
||||
press(listOf(Key.DirectionDown, Key.Back))
|
||||
press(listOf(Key.DirectionDown, Key.Escape))
|
||||
assertTrue(shell.navFocused)
|
||||
assertEquals(11, grid.index)
|
||||
press(Key.DirectionDown)
|
||||
|
|
|
|||
|
|
@ -74,7 +74,7 @@ class MotionSurfaceTest {
|
|||
assertEquals("header", state.row)
|
||||
assertEquals(0, state.column)
|
||||
}
|
||||
rule.onRoot().performKeyInput { pressKey(Key.Back) }
|
||||
rule.onRoot().performKeyInput { pressKey(Key.Escape) }
|
||||
rule.runOnIdle { assertEquals(listOf(TitleAction.Pop), actions); assertFalse(shell.pickerVisible) }
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -41,7 +41,7 @@ class PickerNavigationTest {
|
|||
press(Key.DirectionDown)
|
||||
press(Key.DirectionCenter)
|
||||
assertEquals("settings", state.route)
|
||||
press(Key.Back)
|
||||
press(Key.Escape)
|
||||
assertTrue(state.pickerVisible)
|
||||
assertTrue(state.gearFocused)
|
||||
press(Key.DirectionUp)
|
||||
|
|
|
|||
|
|
@ -76,11 +76,11 @@ class RequestsKeysTest {
|
|||
send(Key.DirectionCenter)
|
||||
assertFalse(state.requestsVisible)
|
||||
assertTrue(state.route.startsWith("title/"))
|
||||
send(Key.Back)
|
||||
send(Key.Escape)
|
||||
rule.onNodeWithTag("coming-row-x6").assertExists()
|
||||
assertEquals("x6", state.requests.focusedId)
|
||||
assertTrue(state.requestsVisible)
|
||||
send(Key.Back)
|
||||
send(Key.Escape)
|
||||
assertFalse(state.requestsVisible)
|
||||
assertEquals("settings", state.route)
|
||||
assertEquals(0, state.settingsRow)
|
||||
|
|
@ -126,7 +126,7 @@ class RequestsKeysTest {
|
|||
mount(state)
|
||||
send(Key.DirectionCenter, Key.DirectionUp, Key.DirectionCenter)
|
||||
assertEquals("home", state.route)
|
||||
send(Key.Back)
|
||||
send(Key.Escape)
|
||||
assertFalse("Root Back must focus navigation, not reopen the abandoned sheet", state.requestsVisible)
|
||||
assertTrue(state.navFocused)
|
||||
}
|
||||
|
|
|
|||
|
|
@ -58,7 +58,7 @@ class ScreenEntryNavigationTest {
|
|||
val view = shell.view
|
||||
val before = position(route)
|
||||
rule.runOnIdle { shell.enterDestination("title/child"); childVisible = true }
|
||||
press(Key.Back)
|
||||
press(Key.Escape)
|
||||
rule.runOnIdle { outgoingVisible = false }
|
||||
rule.waitForIdle()
|
||||
assertSame(view, shell.view)
|
||||
|
|
|
|||
|
|
@ -47,7 +47,7 @@ class ShellKeysTest {
|
|||
}
|
||||
|
||||
@Test fun settingsBackBackInTenPresses() {
|
||||
replay(settings + listOf(Key.Back, Key.Back), 10)
|
||||
replay(settings + listOf(Key.Escape, Key.Escape), 10)
|
||||
assertEquals("home", state.route)
|
||||
assertFalse(state.pickerVisible)
|
||||
assertTrue(state.navFocused)
|
||||
|
|
@ -64,7 +64,7 @@ class ShellKeysTest {
|
|||
replay(listOf(Key.DirectionCenter), 1)
|
||||
val view = state.view
|
||||
rule.runOnIdle { view.row = 4; view.cards["row-4"] = 2 }
|
||||
rule.onNodeWithTag("wolfskin-shell").performKeyInput { pressKey(Key.Back); pressKey(Key.DirectionDown) }
|
||||
rule.onNodeWithTag("wolfskin-shell").performKeyInput { pressKey(Key.Escape); pressKey(Key.DirectionDown) }
|
||||
assertSame(view, state.view)
|
||||
assertEquals(4, state.view.row)
|
||||
assertEquals(2, state.view.cards["row-4"])
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue