[skip ci] video player button focus nudge
This commit is contained in:
1 parent
21c0900fac
commit
29dd94352e
9 files changed
+93
-4
No files matched your search
@@ -69,6 +69,19 @@ namespace Tests
|
||||
m.assertEqual(anim.control, "start")
|
||||
end function
|
||||
|
||||
@it("a nudge with an out-of-range focusedIndex is a safe no-op")
|
||||
function _()
|
||||
m.top.rowFocused = true
|
||||
m.top.focusedIndex = 5
|
||||
playAnim = m.top.findNode("PlayPauseButton").findNode("nudgeAnim")
|
||||
minimizeAnim = m.top.findNode("MinimizeButton").findNode("nudgeAnim")
|
||||
playAnim.control = "stop"
|
||||
minimizeAnim.control = "stop"
|
||||
m.top.nudge = true
|
||||
m.assertEqual(playAnim.control, "stop")
|
||||
m.assertEqual(minimizeAnim.control, "stop")
|
||||
end function
|
||||
|
||||
@describe("play/pause icon tracks the play state")
|
||||
|
||||
@it("shows the pause icon while playing, the play icon while paused")
|
||||
|
||||
@@ -18,7 +18,8 @@
|
||||
<field id="focusedIndex" type="integer" value="0" />
|
||||
<field id="playing" type="boolean" value="true" /> <!-- selects the play vs pause icon -->
|
||||
<field id="buttonCount" type="integer" value="0" /> <!-- read-only: set in Init from m.buttons -->
|
||||
<!-- pulse the focused button's scale nudge (a Left/Right that couldn't move focus). -->
|
||||
<!-- pulse the focused button's scale nudge (a press that couldn't move focus: Left/Right clamped at
|
||||
the row's ends, Up at the top tier). -->
|
||||
<field id="nudge" type="boolean" alwaysNotify="true" />
|
||||
</interface>
|
||||
<children>
|
||||
|
||||
@@ -2,6 +2,7 @@
|
||||
' INPUT fields, and asserts the rendered child fields: fill clip width, playhead translation, M:SS labels,
|
||||
' the raised handle while a transport is active, the glyph swap, and the live layout (Rewind live TV / offset
|
||||
' / ● LIVE swap). clippingRect reads back as {x,y,width,height} on the render thread.
|
||||
import "pkg:/source/utils/Locale.bs"
|
||||
|
||||
namespace Tests
|
||||
|
||||
@@ -198,7 +199,7 @@ namespace Tests
|
||||
m.assertEqual(m.top.findNode("remainingLabel").text, "")
|
||||
' the badge styling: red bullet + bold size-30 LIVE. blendColor reads back as a signed 32-bit int.
|
||||
m.AssertBlend(m.top.findNode("bullet").blendColor, &hD53E5AFF)
|
||||
m.assertEqual(m.top.findNode("liveLabel").text, Tr("LIVE"))
|
||||
m.assertEqual(m.top.findNode("liveLabel").text, Tr(Locale.RowCell.Live))
|
||||
' the badge is right-aligned to the track end whatever the language ("EN DIRECT" >> "LIVE").
|
||||
lbl = m.top.findNode("liveLabel")
|
||||
m.assertTrue(Abs((lbl.translation[0] + lbl.boundingRect().width) - 1144) < 2, "badge right edge pinned to the track end")
|
||||
|
||||
@@ -13,7 +13,8 @@
|
||||
<field id="focusedIconColor" type="color" value="#262626" />
|
||||
|
||||
<field id="focused" type="boolean" value="false" />
|
||||
<!-- pulse the scale nudge: confirms a press that didn't move focus (Left/Right at the row's end). -->
|
||||
<!-- pulse the scale nudge: confirms a press that didn't move focus (Left/Right at the row's end,
|
||||
Up at the top tier). -->
|
||||
<field id="nudge" type="boolean" alwaysNotify="true" />
|
||||
</interface>
|
||||
<children>
|
||||
|
||||
@@ -337,11 +337,15 @@ function OnKeyEvent(key as string, press as boolean) as boolean
|
||||
' BAR tier takes Up (back to the buttons) and lets the transport keys through. Rev/Fwd/Replay are not owned
|
||||
' by the buttons, so they fall through to the transport and move focus to the bar.
|
||||
if press and CanFocusInteract()
|
||||
' Up/Down move between the two tiers; a no-op at the ends is still consumed.
|
||||
' Up/Down move between the two tiers; a no-op at the ends is still consumed — Up at the top tier
|
||||
' (the buttons) pulses the focused button so the press visibly lands somewhere.
|
||||
if key = RemoteKeys.Up or key = RemoteKeys.Down
|
||||
newTarget = PlayerCoordinatorLogic.NextFocusTarget(m.focusTarget, key)
|
||||
if newTarget <> m.focusTarget
|
||||
SetFocusTarget(newTarget)
|
||||
else if m.focusTarget = PlayerCoordinatorLogic.FocusTarget.Buttons
|
||||
m.buttonRow.nudge = true
|
||||
ArmAutoHide()
|
||||
end if
|
||||
return true
|
||||
end if
|
||||
|
||||
@@ -37,6 +37,13 @@ function TestSetup() as void
|
||||
|
||||
Initialize() ' the real coordinator init body (m.transport, findNode children, timer observers, getHttpAgent)
|
||||
|
||||
' count ButtonRow nudge pulses (the field is a sticky alwaysNotify boolean, so the count — not the value —
|
||||
' is what tells the spec whether a given press pulsed). Scoped + unobserve-first: the suite node is shared
|
||||
' across tests, so a plain ObserveField here would stack one counter observer per TestSetup call.
|
||||
m.top.nudgeCount = 0
|
||||
m.buttonRow.unobserveFieldScoped("nudge")
|
||||
m.buttonRow.observeFieldScoped("nudge", FuncName(OnTestNudge))
|
||||
|
||||
container = createObject("roSGNode", "Node")
|
||||
container.addField("fullscreen", "boolean", false)
|
||||
container.fullscreen = true
|
||||
@@ -72,6 +79,10 @@ function TestSetup() as void
|
||||
OnNodeReady()
|
||||
end function
|
||||
|
||||
function OnTestNudge() as void
|
||||
m.top.nudgeCount += 1
|
||||
end function
|
||||
|
||||
' TestKey — drive a remote key through the REAL OnKeyEvent (scrub/scan/commit/etc).
|
||||
function TestKey(key as string, down as boolean) as boolean
|
||||
return OnKeyEvent(key, down)
|
||||
@@ -170,6 +181,7 @@ function TestSnapshot() as object
|
||||
chromeShown: (m.chromeMode = ChromeMode.Shown or m.chromeMode = ChromeMode.FadingIn)
|
||||
focusTarget: m.focusTarget
|
||||
focusedButton: m.focusedButton
|
||||
nudgeCount: m.top.nudgeCount
|
||||
forceLiveBadge: m.trickPlayBar.forceLiveBadge
|
||||
liveBadgeShown: m.trickPlayBar.findNode("liveLabel").visible
|
||||
barRemainingText: m.trickPlayBar.findNode("remainingLabel").text
|
||||
|
||||
@@ -40,6 +40,8 @@
|
||||
<field id="minRect" type="rect2D" value="[834,460,426,240]" />
|
||||
<field id="maxRect" type="rect2D" value="[0,0,1280,720]" />
|
||||
<field id="close" type="boolean" alwaysNotify="true" />
|
||||
<!-- test-only probe: how many times the coordinator pulsed ButtonRow.nudge (TestSetup observes it). -->
|
||||
<field id="nudgeCount" type="integer" />
|
||||
<!-- the Video-only method Initialize calls, plus the spec's drivers (callFunc reaches only interface funcs). -->
|
||||
<function name="getHttpAgent" />
|
||||
<function name="TestSetup" />
|
||||
|
||||
@@ -2,6 +2,7 @@
|
||||
' inert and spec-driven) through scripted device-state sequences the real Roku Video won't produce on command.
|
||||
' This is the harness that would have caught the reported wedge: the existing INV-D* are blind to it (during the
|
||||
' wedge state="buffering", so "transport => state<>playing" was SATISFIED). The NEW property is P-seam.
|
||||
import "pkg:/components/VideoPlayerDev/PlayerCoordinatorLogic.bs"
|
||||
import "pkg:/components/VideoPlayerDev/TransportController.bs"
|
||||
import "pkg:/components/VideoPlayerDev/VideoNode.bs"
|
||||
import "pkg:/source/utils/RemoteKeys.bs"
|
||||
@@ -214,6 +215,56 @@ namespace Tests
|
||||
m.assertEqual(m.Snap().focusedButton, 0, "a fresh reveal resets the highlight")
|
||||
end function
|
||||
|
||||
' Up at the top tier (the buttons) has nowhere to go; the press must still visibly land — it pulses
|
||||
' (nudges) the focused button instead of being swallowed.
|
||||
@it("Up at the buttons tier nudges the focused button instead of moving focus")
|
||||
function _()
|
||||
m.top.callFunc("TestKey", RemoteKeys.Up, true) ' reveal -> buttons tier
|
||||
before = m.Snap()
|
||||
m.assertEqual(before.focusTarget, PlayerCoordinatorLogic.FocusTarget.Buttons)
|
||||
m.assertEqual(before.nudgeCount, 0, "the reveal itself does not nudge")
|
||||
m.top.callFunc("TestKey", RemoteKeys.Up, true) ' nowhere to go up
|
||||
after = m.Snap()
|
||||
m.assertEqual(after.nudgeCount, 1, "the no-op Up pulsed the focused button")
|
||||
m.assertEqual(after.focusTarget, PlayerCoordinatorLogic.FocusTarget.Buttons, "focus stays on the buttons")
|
||||
m.assertEqual(after.focusedButton, before.focusedButton, "the highlight is untouched")
|
||||
end function
|
||||
|
||||
' A press that GOES somewhere must not nudge: Left/Right inside the row, Up/Down between the tiers.
|
||||
@it("a press that moves focus does not nudge")
|
||||
function _()
|
||||
m.top.callFunc("TestKey", RemoteKeys.Up, true) ' reveal -> buttons tier, play/pause
|
||||
m.top.callFunc("TestKey", RemoteKeys.Right, true) ' play/pause -> minimize
|
||||
m.top.callFunc("TestKey", RemoteKeys.Down, true) ' buttons -> bar
|
||||
m.top.callFunc("TestKey", RemoteKeys.Up, true) ' bar -> buttons
|
||||
m.top.callFunc("TestKey", RemoteKeys.Left, true) ' minimize -> play/pause
|
||||
m.assertEqual(m.Snap().nudgeCount, 0, "every press moved focus; none may pulse")
|
||||
end function
|
||||
|
||||
' Left/Right clamped at the row's ends pulse the focused button (the original nudge path, at the seam).
|
||||
@it("Left/Right clamped at the row ends nudge the focused button")
|
||||
function _()
|
||||
m.top.callFunc("TestKey", RemoteKeys.Up, true) ' reveal -> play/pause (leftmost)
|
||||
m.top.callFunc("TestKey", RemoteKeys.Left, true) ' clamped at the left end
|
||||
m.assertEqual(m.Snap().nudgeCount, 1)
|
||||
m.top.callFunc("TestKey", RemoteKeys.Right, true) ' -> minimize (rightmost)
|
||||
m.top.callFunc("TestKey", RemoteKeys.Right, true) ' clamped at the right end
|
||||
snap = m.Snap()
|
||||
m.assertEqual(snap.nudgeCount, 2)
|
||||
m.assertEqual(snap.focusedButton, 1, "the clamp held the highlight at the end")
|
||||
end function
|
||||
|
||||
' Down at the bar tier (the bottom) is also a no-op, but the bar is not a button: consumed, no nudge.
|
||||
@it("Down at the bar tier is consumed without a nudge")
|
||||
function _()
|
||||
m.top.callFunc("TestKey", RemoteKeys.Up, true) ' reveal -> buttons tier
|
||||
m.top.callFunc("TestKey", RemoteKeys.Down, true) ' buttons -> bar
|
||||
m.top.callFunc("TestKey", RemoteKeys.Down, true) ' nowhere to go down
|
||||
snap = m.Snap()
|
||||
m.assertEqual(snap.focusTarget, PlayerCoordinatorLogic.FocusTarget.Bar, "focus stays on the bar")
|
||||
m.assertEqual(snap.nudgeCount, 0)
|
||||
end function
|
||||
|
||||
' A keep-playing seek issued while PAUSED must preserve the pause: the device auto-resumes on any seek
|
||||
' (autoplayAfterSeek only governs rebuffer-resume per the Video docs), so the coordinator re-pauses on
|
||||
' the playing edge the auto-resume produces.
|
||||
|
||||
Reference in new issue
Block a user