Dev player rewrite (#883)
This commit is contained in:
1 parent
8c11272b92
commit
1ba454cdab
80 files changed
+8405
-921
No files matched your search
@@ -0,0 +1,158 @@
|
||||
' TEST-ONLY. Imports the REAL coordinator handlers and runs them against a faked (Group) device. Init() is the
|
||||
' per-component one-liner (calls the shared Initialize); OnNodeReady is invoked by TestSetup with stub deps (no
|
||||
' AutoBind). The spec drives the device via the Test* interface functions (callFunc reaches only interface funcs).
|
||||
import "pkg:/components/VideoPlayerDev/VideoPlayerDev.bs"
|
||||
|
||||
function Init()
|
||||
' intentionally empty: Initialize runs in TestSetup (at test time, when the global logger is ready), NOT at
|
||||
' Rooibos node-creation time where the logger global isn't set up yet.
|
||||
end function
|
||||
|
||||
' getHttpAgent — Initialize does `m.top.getHttpAgent().AddHeader(...)`; a Group has no such method. No-op stub.
|
||||
function getHttpAgent() as object
|
||||
return {
|
||||
AddHeader: function(name as string, value as string)
|
||||
end function
|
||||
}
|
||||
end function
|
||||
|
||||
' TestSetup — stand up the deps the coordinator's OnNodeReady needs (no AutoBind), then run it so the device
|
||||
' observers (state/position/duration) and the SponsorBlock/error controllers are wired exactly as in production.
|
||||
function TestSetup() as void
|
||||
' the coordinator logs; the logger-plugin reads m.global.logger.logLevel on every Log* call. The test app doesn't
|
||||
' always set that global (it isn't in an isolated/@only run), so ensure it exists before any coordinator code.
|
||||
if m.global.logger = invalid
|
||||
m.global.addField("logger", "node", false)
|
||||
m.global.logger = CreateObject("roSGNode", "Logger")
|
||||
end if
|
||||
|
||||
' ReportVideoError -> LogTelemetryEvent writes m.global.telemetry.LogEvent; stub it so the error path runs.
|
||||
if m.global.telemetry = invalid
|
||||
m.global.addField("telemetry", "node", false)
|
||||
telemetry = CreateObject("roSGNode", "Node")
|
||||
telemetry.addField("LogEvent", "assocarray", false)
|
||||
telemetry.addField("LogWarn", "string", false)
|
||||
m.global.telemetry = telemetry
|
||||
end if
|
||||
|
||||
Initialize() ' the real coordinator init body (m.transport, findNode children, timer observers, getHttpAgent)
|
||||
|
||||
container = createObject("roSGNode", "Node")
|
||||
container.addField("fullscreen", "boolean", false)
|
||||
container.fullscreen = true
|
||||
m.top.container = container
|
||||
|
||||
m.top.jobQueue = createObject("roSGNode", "Node")
|
||||
m.top.notifications = createObject("roSGNode", "Node")
|
||||
m.top.preferences = createObject("roSGNode", "Node")
|
||||
m.top.invidious = createObject("roSGNode", "Node")
|
||||
' the queue stub carries the fields the finish/close paths touch (VideoQueueUtils.PlayNext reads hasNext;
|
||||
' ClosePlayer writes closePlayer — the spec asserts it).
|
||||
videoQueue = createObject("roSGNode", "Node")
|
||||
videoQueue.addField("hasNext", "boolean", false)
|
||||
videoQueue.addField("closePlayer", "boolean", false)
|
||||
m.top.videoQueue = videoQueue
|
||||
m.top.loungeService = createObject("roSGNode", "Node")
|
||||
m.top.appController = createObject("roSGNode", "Node")
|
||||
m.top.webServer = createObject("roSGNode", "Node")
|
||||
m.top.innertube = createObject("roSGNode", "Node")
|
||||
|
||||
' AutoBind aliases bound interface fields onto m.<name>; do it manually here (coordinator + Lounge read m.*).
|
||||
m.container = m.top.container
|
||||
m.jobQueue = m.top.jobQueue
|
||||
m.preferences = m.top.preferences
|
||||
m.invidious = m.top.invidious
|
||||
m.videoQueue = m.top.videoQueue
|
||||
m.loungeService = m.top.loungeService
|
||||
m.notifications = m.top.notifications
|
||||
m.appController = m.top.appController
|
||||
m.webServer = m.top.webServer
|
||||
m.innertube = m.top.innertube
|
||||
|
||||
OnNodeReady()
|
||||
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)
|
||||
end function
|
||||
|
||||
' TestSetState — set the faked device state; alwaysNotify fires the REAL OnVideoState observer.
|
||||
function TestSetState(newState as string) as void
|
||||
m.top.state = newState
|
||||
end function
|
||||
|
||||
' TestSetControl — set the faked device control externally (simulates a Lounge/phone command) -> fires the
|
||||
' REAL OnControlChange observer.
|
||||
function TestSetControl(value as string) as void
|
||||
m.top.control = value
|
||||
end function
|
||||
|
||||
' TestPlaybackErrorDialog — seed the error fields, drive OnVideoError down the dialog path, return the dialog's
|
||||
' message + title.
|
||||
function TestPlaybackErrorDialog(errorFields as object) as object
|
||||
content = CreateObject("roSGNode", "ContentNode")
|
||||
content.addField("videoId", "string", false)
|
||||
content.addField("playletStreamUrls", "array", false)
|
||||
content.addField("playletStreamUrlIndex", "integer", false)
|
||||
content.setFields({
|
||||
videoId: errorFields.videoId
|
||||
url: "http://stream"
|
||||
playletStreamUrls: []
|
||||
playletStreamUrlIndex: 0
|
||||
})
|
||||
m.top.content = content
|
||||
|
||||
m.top.errorMsg = errorFields.errorMsg
|
||||
m.top.errorCode = errorFields.errorCode
|
||||
m.top.errorStr = errorFields.errorStr
|
||||
m.top.errorInfo = errorFields.errorInfo
|
||||
|
||||
OnVideoError()
|
||||
|
||||
dialog = m.errorDialogNode
|
||||
if dialog = invalid
|
||||
return { message: "<no dialog shown>", title: "" }
|
||||
end if
|
||||
message = dialog.message
|
||||
if type(message) = "roArray"
|
||||
message = message.Join(Chr(10)) ' ShowTimedDialogButtons tokenizes the body into a per-line array
|
||||
end if
|
||||
result = { message: message, title: dialog.title }
|
||||
|
||||
' tear down without firing the close-response (it hits the stub videoQueue).
|
||||
dialog.unobserveFieldScoped("wasClosed")
|
||||
m.top.getScene().dialog = invalid
|
||||
m.errorDialogNode = invalid
|
||||
return result
|
||||
end function
|
||||
|
||||
' TestCoordinatorFields — every non-function key on the coordinator's m, for the unmodeled-axis meta-test
|
||||
' (the coordinator twin of the brain's reflection test). Call AFTER TestSetup so Initialize/OnNodeReady have
|
||||
' populated m. The ONLY filtering here is the two DYNAMICALLY-named runtime families ("__delay_<uuid>" and
|
||||
' "__promises__promise-<uuid>"), which cannot be pinned by name; everything else — node infrastructure,
|
||||
' Rooibos members, library memos, stable "__" keys like __globalstubs — is returned and pinned EXPLICITLY by
|
||||
' the spec's catalog, so an unexpected newcomer surfaces as a conscious classification, never a silent filter.
|
||||
function TestCoordinatorFields() as object
|
||||
keys = []
|
||||
for each key in m
|
||||
if type(m[key]) <> "Function" and type(m[key]) <> "roFunction" and Left(key, 8) <> "__delay_" and Left(key, 20) <> "__promises__promise-"
|
||||
keys.Push(key)
|
||||
end if
|
||||
end for
|
||||
return keys
|
||||
end function
|
||||
|
||||
' TestSnapshot — read the seam state the spec asserts on (brain + the device control the coordinator wrote).
|
||||
function TestSnapshot() as object
|
||||
return {
|
||||
transportMode: m.transport.transportMode
|
||||
seekSettling: m.transport.seekSettling
|
||||
control: m.top.control
|
||||
autoplay: m.top.autoplayAfterSeek
|
||||
bifVisible: m.bifDisplay.visible
|
||||
chromeShown: (m.chromeMode = ChromeMode.Shown or m.chromeMode = ChromeMode.FadingIn)
|
||||
focusTarget: m.focusTarget
|
||||
focusedButton: m.focusedButton
|
||||
}
|
||||
end function
|
||||
@@ -0,0 +1,90 @@
|
||||
<component name="VideoPlayerDevMock" extends="Group">
|
||||
<!-- TEST-ONLY (under tests/ -> excluded from the lib build). A controllable stand-in for the coordinator: it
|
||||
extends Group (NOT Video), so the device fields (state/control/seek/autoplayAfterSeek) are INERT — the
|
||||
spec drives `state` to simulate ANY device behaviour (incl. adversarial: buffering<->paused, spurious
|
||||
playing) and inspects control/seek. It imports the REAL coordinator (VideoPlayerDev.bs), so the
|
||||
actual OnVideoState/ApplyTransport/EnforceTransportFreeze run; only the device is faked. Children mirror
|
||||
VideoPlayerDev so Initialize's findNode()s resolve. getHttpAgent + the Test* drivers are in the .bs. -->
|
||||
<interface>
|
||||
<!-- device (Video) fields the coordinator reads/writes; inert on a Group, driven by the spec. -->
|
||||
<field id="state" type="string" value="none" alwaysNotify="true" />
|
||||
<field id="control" type="string" />
|
||||
<field id="seek" type="float" alwaysNotify="true" />
|
||||
<field id="position" type="float" alwaysNotify="true" />
|
||||
<field id="duration" type="float" />
|
||||
<field id="autoplayAfterSeek" type="boolean" value="true" />
|
||||
<field id="content" type="node" />
|
||||
<field id="thumbnailTiles" type="assocarray" />
|
||||
<field id="playbackSpeed" type="float" value="1.0" />
|
||||
<field id="enableUI" type="boolean" value="true" />
|
||||
<field id="asyncStopSemantics" type="boolean" />
|
||||
<field id="notificationInterval" type="float" />
|
||||
<field id="width" type="float" />
|
||||
<field id="height" type="float" />
|
||||
<field id="errorCode" type="integer" />
|
||||
<field id="errorMsg" type="string" />
|
||||
<field id="errorStr" type="string" />
|
||||
<field id="errorInfo" type="assocarray" />
|
||||
<!-- AutoBind deps + layout (set by TestSetup; NOT bound). -->
|
||||
<field id="appController" type="node" />
|
||||
<field id="jobQueue" type="node" />
|
||||
<field id="container" type="node" />
|
||||
<field id="notifications" type="node" />
|
||||
<field id="videoQueue" type="node" />
|
||||
<field id="preferences" type="node" />
|
||||
<field id="innertube" type="node" />
|
||||
<field id="invidious" type="node" />
|
||||
<field id="webServer" type="node" />
|
||||
<field id="loungeService" type="node" />
|
||||
<field id="previousPlayer" type="node" />
|
||||
<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" />
|
||||
<!-- the Video-only method Initialize calls, plus the spec's drivers (callFunc reaches only interface funcs). -->
|
||||
<function name="getHttpAgent" />
|
||||
<function name="TestSetup" />
|
||||
<function name="TestKey" />
|
||||
<function name="TestSetState" />
|
||||
<function name="TestSnapshot" />
|
||||
<function name="TestSetControl" />
|
||||
<function name="TestPlaybackErrorDialog" />
|
||||
<function name="TestCoordinatorFields" />
|
||||
</interface>
|
||||
<children>
|
||||
<Timer id="autoHide" duration="5" repeat="false" />
|
||||
<Timer id="transportTimer" duration="0.6" repeat="false" />
|
||||
<Timer id="liveBadgeHold" duration="1.6" repeat="false" />
|
||||
<Timer id="fullScreenHintTimer" duration="1" repeat="false" />
|
||||
<Timer id="liveEdgeClock" duration="1" repeat="true" />
|
||||
<Animation id="chromeFadeIn" duration="0.5" easeFunction="linear">
|
||||
<FloatFieldInterpolator id="chromeFadeInInterp" key="[0.0, 1.0]" keyValue="[0.0, 1.0]" fieldToInterp="Chrome.opacity" />
|
||||
</Animation>
|
||||
<Animation id="chromeFadeOut" duration="0.3" easeFunction="linear">
|
||||
<FloatFieldInterpolator id="chromeFadeOutInterp" key="[0.0, 1.0]" keyValue="[1.0, 0.0]" fieldToInterp="Chrome.opacity" />
|
||||
</Animation>
|
||||
<!-- The PiP minimize animation, mirrored so OnFullScreenChange is runnable at the seam. The
|
||||
interpolators target the root "VideoPlayer" id, which doesn't exist here — starting the anim just
|
||||
logs "Failed to update interpolator field" warnings, which is harmless in tests. -->
|
||||
<Animation id="minimize" duration="0.3" easeFunction="outcubic" optional="true">
|
||||
<FloatFieldInterpolator id="widthInterpolator" key="[0.0, 0.5, 1.0]" keyValue="[1280, 853, 426]" fieldToInterp="VideoPlayer.width" />
|
||||
<FloatFieldInterpolator id="heightInterpolator" key="[0.0, 0.5, 1.0]" keyValue="[720, 480, 240]" fieldToInterp="VideoPlayer.height" />
|
||||
<Vector2DFieldInterpolator id="translationInterpolator" key="[0.0, 0.5, 1.0]" keyValue="[[0,0],[417,230],[834,460]]" fieldToInterp="VideoPlayer.translation" />
|
||||
</Animation>
|
||||
<Rectangle id="fullScreenHint" height="26" color="0x000000" opacity="0.8" visible="false">
|
||||
<Label id="fullScreenHintLabel" height="26" />
|
||||
</Rectangle>
|
||||
<Group id="Chrome" opacity="0" visible="false">
|
||||
<Poster id="pauseGradient" width="1280" height="720" />
|
||||
<BifDisplay id="bifDisplay" />
|
||||
<Group id="titleArea">
|
||||
<Label id="titleLabel" />
|
||||
<Label id="secondaryTitleLabel" />
|
||||
<Clock id="clock" />
|
||||
</Group>
|
||||
<TrickPlayBar id="trickPlayBar" />
|
||||
<ButtonRow id="buttonRow" />
|
||||
</Group>
|
||||
<LoadBufferSpinner id="spinner" />
|
||||
<LargePause id="largePause" />
|
||||
</children>
|
||||
</component>
|
||||
@@ -0,0 +1,306 @@
|
||||
' Device-seam conformance: drives the REAL coordinator (via VideoPlayerDevMock — a Group whose device fields are
|
||||
' 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/TransportController.bs"
|
||||
import "pkg:/components/VideoPlayerDev/VideoNode.bs"
|
||||
import "pkg:/source/utils/RemoteKeys.bs"
|
||||
|
||||
namespace Tests
|
||||
|
||||
@SGNode("VideoPlayerDevMock")
|
||||
@suite
|
||||
class VideoPlayerDevSeamTests extends Rooibos.BaseTestSuite
|
||||
|
||||
protected override function beforeEach()
|
||||
m.top.callFunc("TestSetup")
|
||||
' first frame: one state->playing opens the brain's ready-gate (transport input accepted).
|
||||
m.top.callFunc("TestSetState", VideoState.Playing)
|
||||
end function
|
||||
|
||||
function Snap() as object
|
||||
return m.top.callFunc("TestSnapshot")
|
||||
end function
|
||||
|
||||
@describe("device seam")
|
||||
|
||||
@it("mock stands up the real coordinator (Init + OnNodeReady ran against the faked device)")
|
||||
function _()
|
||||
snap = m.Snap()
|
||||
m.assertEqual(snap.transportMode, TransportController.Mode.Idle)
|
||||
m.assertFalse(snap.seekSettling)
|
||||
end function
|
||||
|
||||
' P-SEAM: the coordinator must NOT pause the device while a play-through seek it issued is still settling.
|
||||
' This is the wedge's root: the old code slammed control=pause on the in-flight seek -> buffering<->paused
|
||||
' forever. It fails on the old code at the "rescrub while settling" step; passes on the new (deferred).
|
||||
@it("commit -> immediate re-scrub does NOT pause the still-settling seek; freezes cleanly only once it reaches playing")
|
||||
function _()
|
||||
' enter scrub (normal freeze: no seek in flight yet).
|
||||
m.top.callFunc("TestKey", RemoteKeys.Left, true)
|
||||
m.top.callFunc("TestKey", RemoteKeys.Left, false)
|
||||
m.top.callFunc("TestSetState", VideoState.Paused) ' the scrub froze the device
|
||||
mid = m.Snap()
|
||||
m.assertEqual(mid.transportMode, TransportController.Mode.Scrub)
|
||||
m.assertEqual(mid.control, VideoControl.Pause) ' a normal scrub DOES freeze (no settling seek)
|
||||
|
||||
' commit -> the brain emits resume+seek and marks seekSettling (a play-through seek is now in flight).
|
||||
m.top.callFunc("TestKey", RemoteKeys.Ok, true)
|
||||
afterCommit = m.Snap()
|
||||
m.assertTrue(afterCommit.seekSettling, "commit must mark a play-through seek settling")
|
||||
m.assertEqual(afterCommit.transportMode, TransportController.Mode.Idle)
|
||||
|
||||
' the device is still resolving the seek...
|
||||
m.top.callFunc("TestSetState", VideoState.Buffering)
|
||||
|
||||
' ...and the user IMMEDIATELY re-scrubs. THE PROPERTY: the coordinator must DEFER the freeze, NOT pause.
|
||||
m.top.callFunc("TestKey", RemoteKeys.Left, true)
|
||||
settling = m.Snap()
|
||||
m.assertEqual(settling.transportMode, TransportController.Mode.Scrub)
|
||||
m.assertTrue(settling.seekSettling, "the seek is still in flight")
|
||||
m.assertNotEqual(settling.control, VideoControl.Pause, "P-SEAM VIOLATION: paused the device mid-seek (the wedge) — the freeze was not deferred")
|
||||
|
||||
' the seek finally lands -> the device reaches playing -> now the guard freezes cleanly.
|
||||
m.top.callFunc("TestSetState", VideoState.Playing)
|
||||
settled = m.Snap()
|
||||
m.assertFalse(settled.seekSettling, "reaching playing clears the settling flag")
|
||||
m.assertEqual(settled.control, VideoControl.Pause, "after the seek settles, the transport freezes the playing video")
|
||||
end function
|
||||
|
||||
' P-TOTAL at the seam: a transport must hold INV-D1 across EVERY device state, including the ones the real
|
||||
' device rarely produces. Only a PLAYING device under a transport gets re-paused; nothing else is touched.
|
||||
@it("under a transport, only a playing device is re-frozen; every other device state is a safe no-op")
|
||||
function _()
|
||||
' get into a frozen scrub.
|
||||
m.top.callFunc("TestKey", RemoteKeys.Left, true)
|
||||
m.top.callFunc("TestKey", RemoteKeys.Left, false)
|
||||
states = [VideoState.Buffering, VideoState.Paused, VideoState.Playing, VideoState.None, VideoState.Stopping, VideoState.Stopped]
|
||||
for each s in states
|
||||
m.top.callFunc("TestSetState", s)
|
||||
snap = m.Snap()
|
||||
m.assertEqual(snap.transportMode, TransportController.Mode.Scrub, "still scrubbing through device state " + s)
|
||||
if s = VideoState.Playing
|
||||
m.assertEqual(snap.control, VideoControl.Pause, "a playing device under a transport is re-frozen (INV-D1)")
|
||||
end if
|
||||
end for
|
||||
end function
|
||||
|
||||
' An external resume (the linked phone via Lounge) under an active transport must TAKE OVER: VPD never
|
||||
' resumes under a transport itself, so a resume here is the phone's. It cancels the scrub and plays.
|
||||
@it("an external Lounge resume under a transport takes over: cancels the scrub and lets it play")
|
||||
function _()
|
||||
' enter scrub -> the brain freezes the device (control=pause).
|
||||
m.top.callFunc("TestKey", RemoteKeys.Left, true)
|
||||
m.top.callFunc("TestKey", RemoteKeys.Left, false)
|
||||
m.top.callFunc("TestSetState", VideoState.Paused)
|
||||
mid = m.Snap()
|
||||
m.assertEqual(mid.transportMode, TransportController.Mode.Scrub)
|
||||
m.assertEqual(mid.control, VideoControl.Pause)
|
||||
|
||||
' the phone seeks + resumes: Lounge sets control=resume directly on the player node.
|
||||
m.top.callFunc("TestSetControl", VideoControl.Resume)
|
||||
after = m.Snap()
|
||||
m.assertEqual(after.transportMode, TransportController.Mode.Idle, "the external resume cancels the transport")
|
||||
m.assertEqual(after.control, VideoControl.Resume, "the video plays (the phone action wins)")
|
||||
m.assertTrue(after.autoplay, "autoplay restored so a settling seek won't re-freeze the takeover")
|
||||
end function
|
||||
|
||||
@it("the error dialog displays every captured error field, not just the category")
|
||||
function _()
|
||||
' Real Roku Video error captured on device (an http stream failure, 502 manifest).
|
||||
errStr = "reader pick stream error:HTTP error:Transfer error: HTTP response code said error response code:(502):502:extra:content_id:24:err_clip_idx:0:etype:buffer:program_id:"
|
||||
snap = m.top.callFunc("TestPlaybackErrorDialog", {
|
||||
videoId: "dQw4w9WgXcQ"
|
||||
errorMsg: "There was an error in the HTTP response. This could mean that malformed HTTP headers or an HTTP error code was returned."
|
||||
errorCode: -1
|
||||
errorStr: errStr
|
||||
' the stream list is exhausted (no next url) -> dialog, not retry.
|
||||
errorInfo: { category: "http", source: "buffer:reader", clipid: 24, ignored: false, dbgmsg: errStr }
|
||||
})
|
||||
|
||||
body = snap.message
|
||||
m.assertTrue(body.Instr("errorMsg: There was an error in the HTTP response") >= 0, "dialog dropped errorMsg")
|
||||
m.assertTrue(body.Instr("errorCode: -1") >= 0, "dialog dropped errorCode")
|
||||
m.assertTrue(body.Instr("errorStr: reader pick stream error") >= 0, "dialog dropped errorStr")
|
||||
m.assertTrue(body.Instr("category: http") >= 0, "dialog dropped errorInfo.category")
|
||||
m.assertTrue(body.Instr("source: buffer:reader") >= 0, "dialog dropped errorInfo.source")
|
||||
m.assertTrue(body.Instr("clipid: 24") >= 0, "dialog dropped errorInfo.clipid")
|
||||
m.assertTrue(body.Instr("ignored: false") >= 0, "dialog dropped errorInfo.ignored")
|
||||
m.assertTrue(body.Instr("dbgmsg: reader pick stream error") >= 0, "dialog dropped errorInfo.dbgmsg")
|
||||
m.assertTrue(snap.title.Instr("dQw4w9WgXcQ") >= 0, "dialog title dropped the videoId")
|
||||
end function
|
||||
|
||||
' Up/Down reveal the chrome when it is hidden in idle (they otherwise do nothing).
|
||||
@it("Up reveals the chrome when it is hidden in idle")
|
||||
function _()
|
||||
m.assertFalse(m.Snap().chromeShown) ' starts hidden after setup
|
||||
m.top.callFunc("TestKey", RemoteKeys.Up, true)
|
||||
m.assertTrue(m.Snap().chromeShown, "Up revealed the chrome")
|
||||
end function
|
||||
|
||||
' The button tier remembers its highlighted button across a buttons->bar->buttons round-trip; only a
|
||||
' fresh reveal (the row was hidden) resets the highlight to play/pause.
|
||||
@it("the button tier keeps its focused button across a bar round-trip; a fresh reveal resets it")
|
||||
function _()
|
||||
m.top.callFunc("TestKey", RemoteKeys.Up, true) ' reveal -> buttons tier, play/pause focused
|
||||
snap = m.Snap()
|
||||
m.assertTrue(snap.chromeShown)
|
||||
m.assertEqual(snap.focusedButton, 0)
|
||||
' highlight minimize, drop to the bar, come back up: still minimize.
|
||||
m.top.callFunc("TestKey", RemoteKeys.Right, true)
|
||||
m.assertEqual(m.Snap().focusedButton, 1)
|
||||
m.top.callFunc("TestKey", RemoteKeys.Down, true)
|
||||
m.top.callFunc("TestKey", RemoteKeys.Up, true)
|
||||
m.assertEqual(m.Snap().focusedButton, 1, "the highlight survives the round-trip")
|
||||
' hide the chrome (scrub from the bar tier, then commit) -> the NEXT reveal starts at play/pause.
|
||||
m.top.callFunc("TestKey", RemoteKeys.Down, true)
|
||||
m.top.callFunc("TestKey", RemoteKeys.Left, true)
|
||||
m.top.callFunc("TestKey", RemoteKeys.Left, false)
|
||||
m.top.callFunc("TestKey", RemoteKeys.Ok, true) ' commit -> chrome hides
|
||||
m.assertFalse(m.Snap().chromeShown)
|
||||
m.top.callFunc("TestKey", RemoteKeys.Up, true) ' fresh reveal
|
||||
m.assertEqual(m.Snap().focusedButton, 0, "a fresh reveal resets the highlight")
|
||||
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.
|
||||
@it("a keep-playing seek issued while paused re-pauses when the device auto-resumes")
|
||||
function _()
|
||||
' pause from idle.
|
||||
m.top.callFunc("TestKey", RemoteKeys.Play, true)
|
||||
m.top.callFunc("TestSetState", VideoState.Paused)
|
||||
m.assertEqual(m.Snap().control, VideoControl.Pause)
|
||||
' InstantReplay from paused idle = a keep-playing seek (no control, just a seek).
|
||||
m.top.callFunc("TestKey", RemoteKeys.Replay, true)
|
||||
' scrub the control to a neutral value so the assertion below can only pass via the re-pause.
|
||||
m.top.callFunc("TestSetControl", VideoControl.None)
|
||||
' the seek lands and the device auto-resumes...
|
||||
m.top.callFunc("TestSetState", VideoState.Playing)
|
||||
' ...and the coordinator restores the pause.
|
||||
m.assertEqual(m.Snap().control, VideoControl.Pause, "the paused state survives the keep-playing seek")
|
||||
end function
|
||||
|
||||
' Committing a scrub at the very end finishes playback (PlayNext/close) instead of seeking into the
|
||||
' last instants and fighting the device's EOF auto-resume (the residual re-pause loop).
|
||||
@it("a commit at the end of content finishes playback instead of seeking")
|
||||
function _()
|
||||
m.top.duration = 100
|
||||
m.top.position = 95
|
||||
' two Right presses: snap 95s -> 94s grid, then 96s -> 98s = duration - epsilon -> at the end.
|
||||
m.top.callFunc("TestKey", RemoteKeys.Right, true)
|
||||
m.top.callFunc("TestKey", RemoteKeys.Right, false)
|
||||
m.top.callFunc("TestKey", RemoteKeys.Right, true)
|
||||
m.top.callFunc("TestKey", RemoteKeys.Right, false)
|
||||
m.assertEqual(m.Snap().transportMode, TransportController.Mode.Scrub)
|
||||
m.top.callFunc("TestKey", RemoteKeys.Ok, true) ' commit at the end -> finish
|
||||
after = m.Snap()
|
||||
m.assertEqual(after.transportMode, TransportController.Mode.Idle)
|
||||
m.assertTrue(m.top.videoQueue.closePlayer, "no next video -> the finish closed the player")
|
||||
end function
|
||||
|
||||
' Play always means play/pause: it must NOT activate whatever button happens to be highlighted.
|
||||
@it("Play toggles play/pause even while a non-play button is highlighted")
|
||||
function _()
|
||||
m.top.callFunc("TestKey", RemoteKeys.Up, true) ' reveal -> buttons tier
|
||||
m.top.callFunc("TestKey", RemoteKeys.Right, true) ' highlight minimize
|
||||
m.assertEqual(m.Snap().focusedButton, 1)
|
||||
m.top.callFunc("TestKey", RemoteKeys.Play, true) ' must pause, not minimize
|
||||
snap = m.Snap()
|
||||
m.assertEqual(snap.control, VideoControl.Pause, "Play paused the (playing) video")
|
||||
m.assertEqual(snap.focusedButton, 1, "the highlight is untouched")
|
||||
end function
|
||||
|
||||
' The coordinator twin of the brain's unmodeled-axis meta-test: every m.* field on the coordinator must
|
||||
' be consciously classified here. A NEW coordinator field fails this until someone decides what it is —
|
||||
' a state axis needs transition coverage, a flag needs its consuming path tested.
|
||||
@it("every coordinator m.* field is consciously classified (no unmodeled coordinator axis)")
|
||||
function _()
|
||||
classified = {}
|
||||
' bound deps (AutoBind interface aliases) + the test stub's own copies.
|
||||
for each name in ["container", "jobQueue", "preferences", "invidious", "videoQueue", "loungeService", "notifications", "appController", "webServer", "innertube"]
|
||||
classified[name] = "dep"
|
||||
end for
|
||||
' controllers (plain .bs class instances).
|
||||
for each name in ["transport", "sponsorblock"]
|
||||
classified[name] = "controller"
|
||||
end for
|
||||
' cached child nodes / timers / animations / reusable helpers (structure, not state).
|
||||
for each name in ["chrome", "titleLabel", "secondaryTitleLabel", "clock", "bifDisplay", "trickPlayBar", "spinner", "largePause", "buttonRow", "fullScreenHint", "autoHide", "transportTimer", "liveBadgeHold", "liveEdgeClock", "fullScreenHintTimer", "chromeFadeIn", "chromeFadeOut", "minimize", "nowDateTime"]
|
||||
classified[name] = "node"
|
||||
end for
|
||||
' in-flight job handles.
|
||||
for each name in ["videoContentJob", "sponsorBlockSegmentsJob", "markVideoWatchedJob"]
|
||||
classified[name] = "job"
|
||||
end for
|
||||
' STATE AXES — discrete coordinator state; each needs its transitions covered by a seam test.
|
||||
for each name in ["chromeMode", "focusTarget", "focusedButton", "armedTimerId"]
|
||||
classified[name] = "axis"
|
||||
end for
|
||||
' flags / scratch — one-shot latches and counters with a single consuming path.
|
||||
for each name in ["onCloseCalled", "ignoreNextFinished", "videoPlayedSuccessfully", "firstFrameSeen", "showFullScreenHint", "repauseAfterSeek", "seekToPercent", "watchTimeMarker", "reportWatchTime", "errorDialogNode", "lastCommitSeq", "lastExitSeq", "lastFinishSeq", "liveAstSeconds", "liveFallbackEdgeMs", "liveFallbackAtSeconds"]
|
||||
classified[name] = "flag"
|
||||
end for
|
||||
' NOT coordinator state — node-scope + test-environment entries, pinned EXPLICITLY (no hidden
|
||||
' filtering) so an unexpected newcomer (a Rooibos upgrade, a new library memo) fails this test and
|
||||
' demands a conscious classification. Presence is optional: these depend on the environment and on
|
||||
' which tests ran before this one (e.g. DialogUtils' memo appears only after the error-dialog test).
|
||||
for each name in ["top", "global", "testrunner", "testsuite", "scene", "_devicedisplaywidth", "__globalstubs", "__promises__deviceinfo"]
|
||||
classified[name] = "infra"
|
||||
end for
|
||||
|
||||
keys = m.top.callFunc("TestCoordinatorFields")
|
||||
m.assertTrue(keys.Count() >= 30, "reflection found only " + keys.Count().ToStr() + " fields — the walk may be vacuous")
|
||||
unknown = []
|
||||
for each key in keys
|
||||
if not classified.DoesExist(key)
|
||||
unknown.Push(key)
|
||||
end if
|
||||
end for
|
||||
m.assertTrue(unknown.Count() = 0, "UNMODELED coordinator field(s) " + FormatJson(unknown) + " — classify them in this meta-test (axis fields need transition coverage)")
|
||||
' reverse: no classified COORDINATOR field has rotted away (infra entries are optional-presence).
|
||||
seen = {}
|
||||
for each key in keys
|
||||
seen[key] = true
|
||||
end for
|
||||
for each name in classified
|
||||
if classified[name] <> "infra"
|
||||
m.assertTrue(seen.DoesExist(name), "stale classified field '" + name + "' is no longer on the coordinator")
|
||||
end if
|
||||
end for
|
||||
end function
|
||||
|
||||
' The PiP-toggle-after-close crash (captured on device): OnClose drops m.sponsorblock, so a leaked
|
||||
' container observer makes the next fullscreen flip crash OnFullScreenChange (&hf3 on SetVisible). The
|
||||
' fix is unobserve-on-close + the onCloseCalled guard; a regression CRASHES this test. Kept LAST in the
|
||||
' suite: OnClose detaches the node from its parent.
|
||||
@it("a closed player ignores container fullscreen flips (the PiP-toggle-after-close crash)")
|
||||
function _()
|
||||
container = m.top.container
|
||||
' sanity: pre-close the observer is live — a minimize hides all player UI.
|
||||
m.top.callFunc("TestKey", RemoteKeys.Up, true) ' reveal the chrome
|
||||
m.assertTrue(m.Snap().chromeShown)
|
||||
container.fullscreen = false
|
||||
m.assertFalse(m.Snap().chromeShown, "minimize hides the chrome now")
|
||||
container.fullscreen = true
|
||||
' close the player (what the queue does when replacing the video), then throw every signal a dead
|
||||
' player might still receive at it: fullscreen flips (the * key), device edges from the async stop,
|
||||
' a stray control/seek write, late thumbnails, a second close. OnClose unobserves them all.
|
||||
m.top.close = true
|
||||
container.fullscreen = false
|
||||
container.fullscreen = true
|
||||
m.top.callFunc("TestSetState", VideoState.Buffering)
|
||||
m.top.callFunc("TestSetState", VideoState.Playing)
|
||||
m.top.callFunc("TestSetState", VideoState.Stopped)
|
||||
m.top.callFunc("TestSetControl", VideoControl.Resume)
|
||||
m.top.position = 12.0
|
||||
m.top.duration = 99.0
|
||||
m.top.seek = 5.0
|
||||
m.top.thumbnailTiles = { x: [{ htiles: 1 }] }
|
||||
m.top.close = true
|
||||
m.assertTrue(true, "no crash: the closed player ignored all post-close traffic")
|
||||
end function
|
||||
|
||||
end class
|
||||
|
||||
end namespace
|
||||
Reference in new issue
Block a user