Back buton behaviour on video player

This commit is contained in:
Brahim Hadriche committed 2026-07-04 20:46:05 -04:00
1 parent 5b8b69ba7b
commit fa90d8d2fd
12 files changed
+298 -39

No files matched your search

@@ -70,6 +70,45 @@ namespace Tests
m.assertEqual(PlayerCoordinatorLogic.OkActionInIdle("paused", true, true), PlayerCoordinatorLogic.OkAction.ToggleChrome)
end function
' =========================================================================================
' BackActionFor — the Back ladder (P-total over transportMode x chromeMode)
' =========================================================================================
@describe("BackActionFor")
@it("the Back decision is DEFINED and correct over the FULL axis cross-product (transportMode x chromeMode)")
function _()
modes = [TransportController.Mode.Idle, TransportController.Mode.Scrub, TransportController.Mode.Scan, TransportController.Mode.LiveDvr]
chromeModes = [ChromeMode.Hidden, ChromeMode.FadingIn, ChromeMode.Shown, ChromeMode.FadingOut]
for each mode in modes
for each chrome in chromeModes
expected = PlayerCoordinatorLogic.BackAction.CancelTransport
if mode = TransportController.Mode.Idle
if chrome = ChromeMode.Shown or chrome = ChromeMode.FadingIn
expected = PlayerCoordinatorLogic.BackAction.DismissChrome
else if chrome = ChromeMode.FadingOut
expected = PlayerCoordinatorLogic.BackAction.None
else
expected = PlayerCoordinatorLogic.BackAction.Close
end if
end if
got = PlayerCoordinatorLogic.BackActionFor(mode, chrome)
m.assertEqual(got, expected, "mode=" + mode.ToStr() + " chromeMode=" + chrome.ToStr())
end for
end for
end function
@it("any active transport outranks the chrome (cancel wins even while the chrome is shown)")
function _()
m.assertEqual(PlayerCoordinatorLogic.BackActionFor(TransportController.Mode.Scrub, ChromeMode.Shown), PlayerCoordinatorLogic.BackAction.CancelTransport)
m.assertEqual(PlayerCoordinatorLogic.BackActionFor(TransportController.Mode.LiveDvr, ChromeMode.Shown), PlayerCoordinatorLogic.BackAction.CancelTransport)
end function
@it("only a FULLY hidden chrome closes: a chrome mid fade-out consumes the press and lets the fade finish")
function _()
m.assertEqual(PlayerCoordinatorLogic.BackActionFor(TransportController.Mode.Idle, ChromeMode.FadingOut), PlayerCoordinatorLogic.BackAction.None)
m.assertEqual(PlayerCoordinatorLogic.BackActionFor(TransportController.Mode.Idle, ChromeMode.Hidden), PlayerCoordinatorLogic.BackAction.Close)
end function
' =========================================================================================
' ShouldShowBuffering — mid-stream spinner gate (firstFrame AND idle AND fullscreen)
' =========================================================================================
@@ -150,17 +150,37 @@ namespace Tests
m.assertEqual(m.t.cursorMs, 64000)
end function
@it("cancel (Back) resets to idle and pulses exit, emitting no seek")
@it("ResetTransport (Minimize and the other involuntary resets) resets to idle, emitting no seek/resume/exit")
function _()
m.t.HandleCommand(TransportController.Command.Right)
m.t.TakeVideoIntent() ' drain the freeze
seqBefore = m.t.exitSeq
m.t.Cancel()
m.t.ResetTransport()
m.assertEqual(m.t.transportMode, TransportController.Mode.Idle)
m.assertEqual(m.t.exitSeq, seqBefore + 1)
m.assertInvalid(m.t.TakeVideoIntent())
end function
@it("CancelTransport (Back) on VOD resets to idle and emits NOTHING: the device stays where the freeze put it")
function _()
m.t.HandleCommand(TransportController.Command.Right)
m.t.TakeVideoIntent() ' drain the freeze
m.t.CancelTransport()
m.assertEqual(m.t.transportMode, TransportController.Mode.Idle)
m.assertInvalid(m.t.TakeVideoIntent())
end function
@it("CancelTransport (Back) on LIVE resets to idle and emits a RESUME with no seek (playback continues from the frozen playhead)")
function _()
t = m.Live()
t.HandleCommand(TransportController.Command.Left)
m.assertEqual(t.transportMode, TransportController.Mode.LiveDvr)
t.TakeVideoIntent() ' drain the freeze
t.CancelTransport()
m.assertEqual(t.transportMode, TransportController.Mode.Idle)
intent = t.TakeVideoIntent()
m.assertEqual(intent.control, TransportController.Control.Resume)
m.assertFalse(intent.hasSeek, "no seek: the playhead stays where the freeze left it, still behind the edge")
end function
' =========================================================================================
' SCAN (VOD Fwd/Rev) — free-run / ladder / wrap / flip / commit / clamp / keyUp no-op
' =========================================================================================
@@ -277,7 +277,7 @@ namespace Tests
' CONTINUOUS — equivalence-classed by the guard predicates (cursor/edge/duration compares), not enumerated.
continuous = ["cursorMs", "positionMs", "durationMs", "edgeMs", "liveOffsetMs", "storyboardStepMs", "replayTargetMs", "dvrWindowMs", "liveMinGapMs", "liveMinCandidateMs"]
' OUTPUT / IO scratch — drained by the coordinator, not state the FSM branches on.
io = ["videoIntent", "intentSeq", "commitSeq", "exitSeq", "finishSeq", "timerCmdAction", "timerCmdId", "timerCmdDelayMs", "timerCmdRepeat"]
io = ["videoIntent", "intentSeq", "commitSeq", "finishSeq", "timerCmdAction", "timerCmdId", "timerCmdDelayMs", "timerCmdRepeat"]
accounted = {}
for each name in axes : accounted[name] = "axis" : end for