The plugin's mounted panel (bottom bar, sidebar, adjust column or
backdrop), the last mounted when it has several, or null. See
TestHost.mounted.
The interface language the test host plays (plugin.i18n.locale), "en"
by default. Set it before startPlugin (or pass its locale
option): the plugin's catalog for it is read from the package's
locales/ then, and the menus (FakeCommand.display), OSD
messages, dialog texts, settings page and panel titles show its
translations, the way the player shows them.
The player's own texts (core actions' messages and menus, its refusals) are
English, or the player's Simplified Chinese for "zh-Hans". While locale
was never set they stay in Chinese; set locale to test what a user sees
now.
The test starts the plugin with a Chinese interface and checks the
menu path its Blur item shows. The locale option sets
host.locale before activation, so the plugin's locales/zh-Hans.po
is loaded; the built-in menu @video shows in the player's own words
(视频), the item's title in the plugin's translation.
const { host, stop } = await startPlugin(activate, { directory, locale: "zh-Hans" });
assert.deepEqual(host.command("blur").display.path, ["视频", "模糊…"]);
await stop();
The interface language of this run (plugin.i18n.locale): the runner
passes the player's VESTRA_LOCALE, the test host its locale.
Bindings declared by more than one command, each as
[binding, winner, ...ignored] (command ids; core actions as
host/<id>). Empty when there are none.
The plugin's bottom-bar buttons (CommandOptions.button) as the player
shows them: at most one, the first declared (BAR_BUTTON_LIMITS; a
later one stays a menu item only). Empty once the command is disposed.
Whether one is in the strip or its » menu is the player's business
(the room and the other plugins' buttons).
The test finds the plugin's Store button, clicks it and checks that the
Store window opened. barButtons lists the buttons of the plugin's
commands declared with button, as the bar shows them; click() runs
the command like its menu item and waits until the host is idle, and
rejects while the command is disabled or busy.
const [button] = host.barButtons; // one button per plugin
assert.equal(button?.icon, "store");
await button?.click();
assert.equal(host.window("store").visible, true);
Every host error the plugin logged (expected or not), oldest first: errors with a code that nothing in the plugin handled.
The test asserts that the plugin left no refusal to its log. The list
keeps every host error the plugin did not handle, also those the test
expected with expectError, so it is empty only when none came.
assert.deepEqual(host.loggedErrors.map((error) => error.code), []);
Why the player would keep this plugin running while nothing uses it (lazy
activation), one line per reason: an event it listens to that is not one
the player wakes it for (with what listens and where it was added), its
panel in the bottom bar or the backdrop, its open windows (these as the
player's log says them), and its sidebar tab while that is the current tab.
The player counts the current tab as busy work, not as something live: it
keeps the plugin running only while the tab is shown, and a sidebar panel
in a background tab is no reason at all (the plugin may go to standby;
showing the tab starts it again). Empty: the player may stop it while idle
and start it again on its next use. A state stream (player.stream)
shows as a listener of source.state; filter chains, producer streams,
jobs and the like (which also keep a plugin running) are not listed.
The test fails if the plugin keeps running for no reason after it
starts, and names the reason (a stream opened in activate, say:
open it only while something shows the state). The
player stops such a plugin while nothing uses it and starts it again
on its next use, so it costs no process meanwhile.
assert.deepEqual(host.keepsRunning, []);
The trigger conditions the player keeps for this plugin
(plugin.trigger().firesOn), in the wire form, with their sequence
numbers and whether each holds now. They stay through
TestHost.park; TestHost.upgrade clears the unnamed ones.
The test host's wall clock (Unix milliseconds), which when.time
conditions read. It starts at the real time; it moves only with
TestHost.advance, or when a test sets it.
Set the clock to value (Unix milliseconds). Only the clock moves:
the kept conditions see the new time at their next evaluation, on
TestHost.advance or a state the test pushes.
The plugin is in standby (TestHost.park) and not started again yet.
A fresh in-memory player: nothing open, no plugin, the player's core
actions registered. Preset what the plugin reads during activation, then
pass it to startPlugin as host.
Press button index of the newest OSD message, as the user does: its
command runs as if picked from a menu, and settles. A disabled or busy
command does nothing, as in the player.
0 or 1.
The test checks the button the plugin put on its newest message, then
presses it as the user would: the plugin's reveal command runs.
assert.deepEqual(host.osdActions.at(-1), [
{ title: "Show in Folder", command: "reveal" },
]);
await host.pressOsdAction(0); // runs the plugin's `reveal` command
Read the plugin's translations for TestHost.locale from a
package directory, as the player would (locales/<locale>.json of a
built package, else the source locales/<locale>.po); startPlugin
does this. None for English; a missing file means none; a broken .po
throws.
The package directory (holding locales/).
A text of the plugin as the player shows it: translated with the
plugin's catalog (TestHost.loadCatalog), then formatted with
args when given.
English source text or template.
Optionalargs: TemplateArgs
Values for its placeholders.
The shown text.
The test expects the text a Chinese user sees for a template the plugin
shows. translate looks the English source up in the plugin's catalog
for host.locale and fills in the arguments, the way the player does.
assert.equal(host.translate("Speed {}×", [2]), "倍速 2×");
Simulate another plugin (or the user) saving the interface language:
pushes appearance.changed.
"system" or a locale.
The plugin hears that the saved interface language changed. The host
pushes appearance.changed, which a plugin that listens to it sees in
appearance.language; this run's
language does not change.
void plugin.appearance.language; // read once: the SDK then follows it
plugin.player.on("appearance.changed", () => {}); // subscribes to appearance events
host.setLanguage("fr");
await host.settle();
assert.equal(plugin.appearance.language, "fr");
Simulate another plugin publishing its timeline ranges (or clearing
them with []); pushes timeline.changed when the plugin subscribed.
The other plugin's manifest id.
All its ranges.
The plugin under test sees a range another plugin put on the seek bar:
setTimelineRanges stores that plugin's ranges and pushes
timeline.changed, and settle() lets it arrive.
host.setTimelineRanges("community.clips", [
{ start: 40, end: 52.5, style: "selection", title: "Clip" },
]);
await host.settle();
assert.equal(plugin.timeline.ranges[0]?.plugin, "community.clips");
Simulate another plugin publishing its timeline layer (or clearing it
with []); pushes timeline.changed when the plugin subscribed.
The other plugin's manifest id.
Its whole layer.
The plugin under test sees two chapter marks another plugin put on the
timeline. setTimelineLayer stores that plugin's whole layer and pushes
timeline.changed; while the plugin listens to it the SDK keeps
marks current from that event, and settle()
lets it arrive.
host.setTimelineLayer("community.chapters", [
{ time: 0, kind: "chapter", title: "Intro" },
{ time: 95, kind: "chapter", title: "Part 1" },
]); // replaces that plugin's whole layer; [] would clear it
await host.settle();
assert.equal(plugin.timeline.marks.length, 2);
The file an image property shows, or null when the value is not a
runtime image. View properties hold images in their wire form; this
reads the path back.
The test checks that the Cover window's image comes from the plugin's
data directory. An image property holds the SDK's wire form of
plugin.ui.image(path), not a path; imagePath reads the path back.
assert.equal(
host.imagePath(host.window("cover").props["cover"]),
join(plugin.dataDirectory, "cover.png"),
);
Drop files like the player: on a panel with an onDrop listener the
whole list goes there; otherwise (and on the video area) each path goes
to the first provider of its extension (folder for existing
directories), one call per provider with all of its paths.
Files nobody takes are ignored. Resolves once the host is idle again.
The dropped paths, in the order the file manager gives.
target: "video" (default) or "panel"; at: the
drop point in panel coordinates (default { x: 0, y: 0 });
modifiers: keys held (default all false).
The first drop lands on the video area: each extension belongs to the
provider that registered it first, and each provider gets one call with
all of its paths. The second lands on the panel at a point, with Alt
held, and the panel's onDrop gets the whole list. drop resolves
once the host is idle.
await host.drop(["/media/a.srt", "/media/b.mkv"]); // on the video area
// On the panel, 10 px from its left and 48 px from its top, Alt held.
await host.drop(["/media/list.m3u"], {
target: "panel",
at: { x: 10, y: 48 },
modifiers: { alt: true },
});
Simulate another plugin switching the palette: updates
TestHost.appearance and pushes appearance.changed.
The plugin hears the palette change. The host updates appearance and
pushes appearance.changed to a plugin that listens.
const themes: string[] = [];
plugin.player.on("appearance.changed", ({ theme }) => themes.push(theme)); // subscribes
host.setAppearance("vestra-light");
await host.settle();
assert.deepEqual(themes, ["vestra-light"]);
One settings page by id. Throws when it was never registered.
The page's settings category.
The page title.
The page order within its category.
The .slint file (package-relative).
The exported component the SDK found.
The exported global (the page's bridge) the SDK found.
The page's properties by Slint (kebab-case) name.
The test sets the step on the General page and checks the page shows
it. emit fires the page's callback as the user's input would; the
plugin's handler stores the value and its bind function sends it back
as a property, which settle() waits for.
const page = host.settingsPage("general");
page.emit("setStep", 10);
await host.settle();
assert.equal(page.props["step"], 10);
Simulate the backdrop's effective changing (false: a video frame
appeared; true: there is none again); pushed to the plugin.
The plugin's backdrop hears that a video frame now covers it. false
means a picture appeared; the change is pushed like the player's
window.state.
host.setBackdropEffective(false);
await host.settle();
assert.equal(plugin.panels.backdrop.state?.effective, false);
Simulate another plugin mounting a panel, before or after the plugin
under test, as the player handles it: in the sidebar it is another tab
(after the existing ones; the first panel's tab is current); the bottom
bar and the backdrop take one panel, so the plugin's own mount there
then rejects with conflict (not an activation failure, as in the
player). Pushed as a window.state change.
The position.
The other plugin's manifest id.
title: its tab label (default: plugin).
The sidebar ends up with two tabs: the playlist, mounted first, and the
plugin's own panel after it. mountOther before startPlugin mounts
another plugin's panel as the player would, so the plugin's mount
during activation becomes the second tab (in the bottom bar or the
backdrop it would be refused with conflict instead).
const host = new TestHost();
host.mountOther("sidebar", "vestra.playlist", { title: "播放列表" });
await startPlugin(activate, { host, directory });
assert.equal(host.layout.sidebar?.panels?.length, 2);
Simulate another plugin's panel going away (TestHost.mountOther): when its tab was current, the next tab (else the previous one) is.
The other plugin's sidebar tab disappears and the plugin's own tab becomes current. When the removed tab was current, the next tab (else the previous one) becomes current, as in the player.
host.unmountOther("vestra.playlist");
await host.settle();
assert.equal(host.layout.sidebar?.panels?.length, 1);
Simulate the user clicking a sidebar tab: plugin's panel (the plugin
under test's manifestId, or one of TestHost.mountOther)
becomes the current tab. Pushed as a window.state change.
The user switches the sidebar to the playlist; the plugin's panel is in
a background tab now. The change is pushed as window.state.
host.selectTab("vestra.playlist");
await host.settle();
assert.notEqual(host.layout.sidebar?.owner, 1); // the plugin under test is owner 1
Simulate another plugin taking the display layer first (the plugin's
video.view() then fails with conflict), or, with null, releasing
it (values reset to the defaults).
The plugin's video.view() fails with conflict because another plugin
took the display layer first. null releases it again.
host.setVideoViewOwner("someone.zoom");
const view = plugin.video.view();
view.set({ zoom: 2 });
await host.settle();
assert.equal(view.status.state, "failed");
Simulate another plugin owning the render options (the plugin's
video.render() then fails with conflict), or, with null, releasing
them (values reset to the defaults).
The plugin's render options report conflict while another plugin owns
them; null releases them and resets the values to the defaults.
host.setVideoRenderOwner("someone.hdr");
const render = plugin.video.render();
render.set({ toneMapping: "bt.2390" });
await host.settle();
assert.equal(render.status.state, "failed");
What the player pushes when mpv cannot compile a shader (code failed) or
switches to software rendering (unsupported, which also sets
videoRender.gpu to false and rendering.reason to window-fallback with
message). Pushed only when this plugin is the owner. previous-crash is
a shortcut that only sets the handle's status and reaches onError: the
real player never pushes it, it refuses the set request itself. To test
that, set TestHost.previousCrash.
The plugin's render options report failed, as when mpv rejects a
shader. The host pushes the failure only while this plugin owns the
render options, which its first accepted set made it; the SDK updates
the handle's status when the push arrives, so the test settles first.
const render = plugin.video.render();
render.set({ toneMapping: "bt.2390" }); // makes the plugin the owner
await host.settle();
host.failVideoRender("failed", "shader compile failed: ERROR: 0:39: ...");
await host.settle();
assert.equal(render.status.state, "failed");
What the player pushes to a shader handle when mpv cannot compile a
shader (code failed; the player cannot tell whose shader failed, so
every handle with shaders hears it) or the player switches to software
rendering (unsupported; use TestHost.failVideoRender, which
also tells the handles). Pushed only to a handle that holds shaders.
code (default failed) is the error code pushed. previous-crash is a
shortcut that only sets the handle's status and reaches onError: the real
player never pushes it, it refuses the set request itself after
an abnormal end. To test that, set TestHost.previousCrash.
The plugin's shader handle reports failed, as when mpv rejects a
shader. The host pushes the failure only to a handle that holds
shaders, which its accepted set made it; the SDK updates the
handle's status when the push arrives, so the test settles first.
const file = join(plugin.dataDirectory, "sharpen.glsl");
writeFileSync(file, "//!HOOK MAIN\n");
const shaders = plugin.video.shaders("sharpen");
shaders.set([file]); // the handle now holds a shader
await host.settle();
host.failVideoShaders("sharpen", "shader compile failed: ERROR: 0:3: ...");
await host.settle();
assert.equal(shaders.status.state, "failed");
The list resolvers.fileTypes carries: the extensions of this
plugin's file resolvers and of TestHost.otherResolvers, sorted,
each once.
Push resolvers.fileTypes when TestHost.fileTypes changed:
called after this plugin's resolvers come and go; call it yourself
after changing TestHost.otherResolvers (another plugin started
or stopped).
Another plugin starts and adds .ch8; the plugin under test, which
listens with player.on("resolvers.fileTypes"), then hears it.
Changing otherResolvers alone pushes nothing: updateFileTypes sends
the new list as the player does when a plugin starts or stops, and
settle() lets the listener run.
const heard: string[][] = [];
// A listener of the event: each list the player sends.
plugin.player.on("resolvers.fileTypes", ({ fileTypes }) => heard.push(fileTypes));
// Another plugin starts with a resolver for .ch8 files.
host.otherResolvers.push({ owner: "example.emulator", extensions: ["ch8"] });
host.updateFileTypes();
await host.settle();
assert.deepEqual(heard, [["ch8"]]);
Simulate mpv changing a property: store the value and send it to the
plugin if it observes the property (plugin.mpv.observe).
The property, as mpv names it.
Its new value.
The plugin's listener hears the value the test gives the property.
setMpvProperty stores it and sends the mpv.property event that
the player sends to an observer; settle lets it arrive.
const seen: unknown[] = [];
plugin.mpv.observe("estimated-vf-fps", (fps) => seen.push(fps));
await host.settle();
host.setMpvProperty("estimated-vf-fps", 59.94);
await host.settle();
assert.deepEqual(seen, [null, 59.94]); // no value at first, then the change
Make the upscaler's reason decoding with cause, with the player's
message, and set upscaling.hwdecCurrent to match (d3d11va-copy, no,
nvdec). plugins are named for copy-back only, as the player does.
Returns the reason; call TestHost.upscalingChanged to tell a
listening plugin.
The plugin's window explains why upscaling waits. The test fakes the copy-back cause that Picture Adjustments' filters cause and checks that the window names the plugin.
host.upscalingDecoding("copy-back", [{ id: "vestra.video", name: "Picture Adjustments" }]);
host.upscalingChanged();
await host.settle();
assert.match(String(host.window("upscale").props.blocker), /Picture Adjustments/);
Send video.upscaling.changed with the state TestHost.upscaling
describes now (without enabled), as the player does when it changes; a
plugin listening with plugin.video.upscaling.onChange receives it.
Nothing reaches a plugin that does not listen.
The window resized: the test changes the area and the factor, sends the change, and checks that the plugin's window shows the new factor.
host.upscaling.area = { width: 2560, height: 1440 };
host.upscaling.factor = 1.33; // 1080p in a 1440p area
host.upscalingChanged(); // as the player after the resize settled
await host.settle();
assert.equal(host.window("upscale").props.factor, "×1.33");
Send video.motion.changed with the state TestHost.motion
describes now (without mode), and then the one of
TestHost.nvidiaMotion, as the player does when they change; a
plugin listening with plugin.video.motion(engine).onChange receives
its engine's. Nothing reaches a plugin that does not listen.
Simulate the user activating the palette's lead row: Enter (keep:
Shift+Enter) with query typed, or Enter on the status row
(status). Mints a ticket, sends the palette.lead event, waits until
the host is idle and returns the ticket.
Like the player, commands.run takes the ticket until
PaletteLead.done or 120 s after its last run, at most 30 runs, 4 a
second, and 120 runs a minute per plugin (limit). A command declared
destructive (and the player's host/stop and host/quit, and the
Settings and Reset menus) is confirmed first: the answer comes from
TestHost.dialogAnswers ({ confirmed: false, checked: false }
is Don't Run, confirmed: true Run, with checked: true Run and
"Don't ask again", which runs like Run since every command a test host
lists is built in). A run with then (since 1.7.16) takes one answer
for its whole plan and remembers an approved plan for the ticket, as
the player does ("@vestra-player/sdk"!CommandRunOptions.then). Each run adds the
command's title (and · step/of) to TestHost.osd.
What the user typed.
keep: Shift+Enter; status: the status row.
The ticket of this user action.
The user asks the plugin to stop playback and declines the
confirmation. builtin lets the plugin hold the lead; the ticket
minted here is what its listener passes to commands.run, and the
queued answer declines the player's alert for host/stop. One answer
covers a request whose first run names the rest of its plan in then.
import assert from "node:assert/strict";
import { startPlugin } from "@vestra-player/sdk/testing";
import activate from "../main.ts";
const { host, stop } = await startPlugin(activate, {
directory: new URL("..", import.meta.url),
builtin: true, // as a plugin built into the player
});
host.dialogAnswers.push({ confirmed: false, checked: false }); // Don't Run
await host.runPaletteLead("stop playback");
assert.deepEqual(host.coreRuns, []); // declined: nothing ran
await stop();
One of the 14 core actions (play-pause, stop, seek-forward, ...)
that the test host registers like the player, as host/<id>. Throws for
an unknown id. run() executes it like its menu item: a disabled
action rejects with command, as in the player (plugin.host.run
rejects with unavailable instead); otherwise it runs with the
player's checks and writes its on-screen text to TestHost.osd.
The test pauses playback the way the Space key does and checks that the
host recorded it. Core actions belong to the player (host/<id>);
run() applies the player's checks, so a source must be ready first,
and every run is appended to coreRuns.
host.setSource({ phase: "ready", duration: 100, position: 10 });
await host.coreAction("play-pause").run();
assert.equal(host.source.paused, true);
assert.deepEqual(host.coreRuns, ["play-pause"]);
Replace the host's behaviour for one wire method until TestHost.reset. The handler receives the request parameters and returns the reply (or a promise of it).
Throw a HostError to simulate a definite refusal (the plugin's
call rejects with that code); throw a plain Error to simulate a lost
reply (the SDK then runs its recovery path). Method names are protocol
names, e.g. "clipboard.writeText", "secrets.get",
"system.openPath", "audio.addTrack"; see TestHost.sent to
find the one a call uses.
The wire method name.
Produces the reply from the request parameters.
The plugin's Open Folder command meets a missing folder and must tell
the user. handle replaces the host's answer to one wire method; the
HostError it throws reaches the plugin as a rejection with code
missing, like the player's refusal. reset restores the default
behaviour for the rest of the test.
host.handle("system.openPath", () => {
throw new HostError("missing", "no such file");
});
await host.command("open-folder").run(); // the plugin catches `missing`
assert.deepEqual(host.osd, ["Folder not found"]);
host.reset("system.openPath");
Restore the default behaviour of a method replaced with TestHost.handle.
The first write fails, the second succeeds. reset removes the handler
that handle installed, so the method is answered by the test host
again.
host.handle("clipboard.writeText", () => {
throw new HostError("failed", "denied");
});
await assert.rejects(plugin.clipboard.writeText("x"));
host.reset("clipboard.writeText");
await plugin.clipboard.writeText("x"); // the default handler again
Deliver a host event to the plugin. Like the player, subscription-based
events (source.state, playback.backend, window.state,
timeline.changed, appearance.changed) are delivered only when the
plugin subscribed (something of it listens). Most tests use the
higher-level helpers (setSource, setMainWindow, ...) instead.
The wire event name.
The event payload (wire-level shape).
The test pushes a window.state event after changing layout by hand.
Like the player, the host delivers it only when the plugin subscribed;
most tests use setSource, setMainWindow and the other helpers
instead.
host.emit("window.state", {}); // no facts: the SDK reads window.state again
await host.settle();
Change the source facts and broadcast them, as if the player's state
changed (the user paused, playback reached the end, a file finished
loading). Any phase other than empty also turns on the source
capabilities (pause, seek, rate, ...) unless the patch sets them.
After phase: "ended", a seek (a plugin's, a core step seek) returns
to ready and plays on (paused: false), as in the player; it stays
paused when the end was reached while paused or by a frame step. A
seek at or past the end (the smaller of position and duration,
0.5 ms slack) goes nowhere: accepted, still ended and paused.
phase: "loading" makes a mounted backdrop effective, like the player.
Wire-level source fields, e.g. phase, position,
duration, paused, audioTracks.
The plugin sees a one-minute source become ready, then end on its own.
setSource changes the host's source facts and broadcasts them like
the player's events; the SDK updates player.state when the event
arrives, so the test settles before reading it.
host.setSource({ phase: "ready", duration: 60, position: 0 });
await host.settle();
assert.equal(plugin.player.state.phase, "ready");
host.setSource({ phase: "ended", terminalReason: "natural" });
await host.settle();
Simulate the user changing the main window (resizing, maximizing or
restoring it, entering or leaving fullscreen, closing the
picture-in-picture window) and broadcast it. maximized reads false
while fullscreen. Like the player, entering fullscreen collapses an
attached, visible sidebar (effective: false, reason: "fullscreen") and
leaving fullscreen docks it again.
The plugin sees the main window fullscreen at 1920×1080, then learns
that picture-in-picture is available, then sees the window leave
fullscreen maximized. setMainWindow changes the
host's window facts and broadcasts them as the player does when the
user resizes or toggles fullscreen; entering fullscreen also collapses
an attached sidebar.
host.setMainWindow({ fullscreen: true, videoArea: { width: 1920, height: 1080 } });
await host.settle();
assert.equal(plugin.window.state.fullscreen, true);
host.setMainWindow({ pictureInPicture: { supported: true, active: false } });
// Leaving fullscreen into a maximized window: `maximized` reads true again.
host.setMainWindow({ fullscreen: false, maximized: true });
await host.settle();
assert.equal(plugin.window.state.maximized, true);
The pointer reached the right edge in fullscreen (true) or left the
popped-out columns (false): the attached sidebar and the adjust column,
those switched on, pop out or collapse (reference §6.3). No effect outside
fullscreen, or on a column switched off or floating.
The pointer reaches the right edge in fullscreen and the attached sidebar pops out over the video. Outside fullscreen, or with the sidebar hidden or floating, nothing happens.
host.setMainWindow({ fullscreen: true });
host.popSidebar(true);
await host.settle();
Simulate another plugin (or the user) opening a source: a new
sourceId, then the given phase. Calls the plugin made against the old
state now fail with stale.
The source stamp advances exactly as in the player: a new generation
and a new intent, also when source is the path already open (the
user opened the same file again). Call it after startPlugin to test
what the user does while the plugin runs: a file opened after
activation, another file, the same one again. A control the plugin
then makes with the state it read before (player.setRate,
seek, step, …) is refused with stale, as in the player. The
user's own pause, seek or speed change is a core action
(coreAction("play-pause").run()): a new intent, which makes an older
state stale too. setSource changes the facts only.
The path or URL.
The phase to end in (default "ready").
A state the plugin captured before stops being current once another
file opens. openElsewhere gives the source a new sourceId, so
isCurrent turns false. Promise-returning calls made with
ifCurrent: before then reject with stale; calls that return nothing
drop the write silently instead (TimelineLayer.set with ifCurrent).
const before = plugin.player.state;
host.openElsewhere("/media/other.mp4");
await host.settle();
assert.equal(plugin.player.isCurrent(before), false);
Simulate a generated stream failing in the player (its audio device
lost, its frame connection broken), like the player: the source fails
with message (phase: "error") and the producer is retired at once.
The stream's onStop listeners get a stream error with message.
The producer, from TestHost.producers.
The player's failure text.
The plugin's stream stops with an error, as when the player loses its
audio device. failStream puts the source into error with the
message and retires the producer at once; the stream's onStop
listeners get a stream error carrying the message.
const [producer] = host.producers.values();
host.failStream(producer!.id, "producer transport closed");
Press a binding like the host's table would: panel-focus bindings first
when panel is true, then global ones; within a scope the earliest
registration first (the player's own commands before the plugin's), as the
conflict rule orders them. A disabled command lets the key pass to the next
command bound to it: the one it shadowed, then the global
scope. The first enabled one runs; press resolves after it ran ("ran").
When only disabled commands hold the key, the first of them decides, as in
the player: with a reason it shows the reason on the OSD and eats the key
("reason", see host.osd); without one the key goes on to the focused
control ("passed", nothing runs). Unlike the player, which only logs a
key that reaches a busy command, press then rejects, so a test notices.
Rejects when nothing is bound. Bindings use the reference syntax
("Space", "Ctrl+O", "Mouse:WheelUp"), and user overrides in
bindings.overlay apply.
What the key did: "ran", "reason" or "passed".
Ctrl+B runs whatever is bound globally; Delete is pressed while the
plugin's panel has focus, so panel bindings are tried first. press
follows the player's binding table and resolves with what happened:
"ran", "reason" (a disabled command showed why) or "passed".
await host.press("Ctrl+B"); // a global binding
await host.press("Delete", { panel: true }); // while the panel has focus
Change the keys of one of the plugin's commands, or of one of the player's
core commands by its host/<id>, as the user does in Keyboard Shortcuts:
inputs replaces its keys ([] clears them, as Ignore Default Shortcuts
does for every default), null gives it its own defaults back. It writes
bindings.overlay, and the plugin hears it as
from the player: bindings.changed and, when what plugin.commands.keys
reads changed, commands.keys.
The view showed W for Brightness −; after the user moves it to
Shift+W, it shows the new key. rebind changes the overlay and
pushes the new labels, and settle lets the binding run again. The
test host is a Mac unless systemInfo.os says otherwise, hence ⇧W.
host.rebind("brightness.down", ["Shift+W"]);
await host.settle();
assert.equal(host.window("picture").props["brightness-down"], "⇧W");
The Markdown document a value holds (its wire form read back), or
null when the value is not one. images maps each remote address to
the downloaded file. Pass a whole property value or a field of one: a
document nested in rows is read the same way.
The test checks the Markdown source of the first chat message. Rows
hold the document in its wire form, as plugin.ui.markdown produced
it; markdown reads it back, nested in a row or not.
const rows = host.window("chat").props["messages"] as { body: Json }[];
assert.equal(host.markdown(rows[0]!.body)?.text, "**Hello**");
Replace the plugin list and push packages.changed (another plugin
started, stopped, was installed or removed).
The plugin's manifest id.
Its version, null when unknown.
Where it was loaded from.
Its run state.
Why it failed (state: "failed").
The package directory.
Optionalbuiltin?: booleanShipped with the player: uninstall and install are unsupported.
Optionalsource?: PackageSource | nullWhere it was installed from.
OptionaldataDirectory?: string | nullIts data directory.
The plugin's store window hears that a plugin is running now. The list
replaces packages and is pushed as packages.changed, which the
plugin's packages.onChange listeners receive.
host.setPackages([...host.packages]); // edit a copy, then push it
await host.settle();
Simulate another plugin calling player.next() / previous(): the host
asks this plugin's sequence provider. Rejects with unavailable when
there is no provider or its flag is false.
The plugin's command with this local id. Throws when it is not registered (never added, or disposed).
The test checks that Export becomes enabled once a file is ready. The
record is updated as the plugin sends new state; read it after
settle().
host.setSource({ phase: "ready", duration: 60 });
await host.settle();
assert.equal(host.command("export").state.enabled, true); // throws if not registered
The plugin's tool window with this id (by default the file name without
extension: ui/picture.slint → picture). Throws when it was never
opened with show().
The Picture window's Reset callback runs and the brightness returns to
0. The window is found by its id (the .slint file name by default);
emit fires the callback the plugin bound, and settle() waits for
the property the handler wrote.
host.window("picture").emit("reset");
await host.settle();
assert.equal(host.window("picture").props["brightness"], 0);
The plugin's mounted panel (bottom bar, sidebar, adjust column or
backdrop): the one in slot, or without it the only one (a plugin mounts
one panel per slot; with several, name the slot). Throws when there is
none. Its props use Slint (kebab-case) names; emit fires a callback on
the panel's global.
Optionalslot: "bottom" | "sidebar" | "adjust" | "backdrop"The test checks the panel sits in the sidebar and selects its third
row. emit fires a callback on the panel's global as a click would;
the plugin's handler runs, and settle() waits for what it sent.
const panel = host.mounted();
assert.equal(panel.slot, "sidebar");
panel.emit("select", 2);
await host.settle();
The parameters of every request of one wire method, oldest first.
The test checks the last OSD request the plugin sent, before
translation. sent lists the parameters of every request of one wire
method, oldest first; host.osd holds the texts as shown instead.
assert.deepEqual(host.sent("osd.show").at(-1), { text: "Saved" });
Wait until no request is in flight (and the SDK's follow-up passes ran),
and at least ms milliseconds have passed so that timers due by then
fired. Call it after every action that makes the plugin talk to the host,
before asserting.
It only waits for host calls. Work the plugin does on its own (reading
or parsing a file, a child process, a network request) is not waited
for: on a loaded machine it can finish after settle() returns. Poll
the result you assert on instead (second example).
settle() does not wait for the SDK's once-a-second full update pass.
After setSource (or another player state change) only the bindings that
read a changed field of plugin.player.state run again; state the plugin
changed outside a handler without plugin.update() shows only in the next
full pass. Have the plugin call plugin.update() after such a change, or
wait settle(1000).
Extra time to wait, for debounces and timers (default 0).
The plugin's store writes its file 300 ms after the last save, so
the test waits 400 ms before it checks what the plugin did next.
settle(ms) returns when no request is in flight and at least ms
have passed, so the store's timer has fired. The file write itself is
the plugin's own work, which settle does not wait for: a test that
reads the file calls await store.flush() instead.
const store = plugin.storage.json("prefs", { defaults: { step: 5 } });
store.save({ step: 10 });
await host.settle(400); // past storage.json's 300 ms debounce
The plugin reads and parses a file before it shows a status; settle
does not wait for that (it only waits for host requests), so the test
polls the property it asserts on, 20 ms at a time, for up to 2 seconds.
const importWindow = host.window("import");
importWindow.emit("load-file"); // the plugin reads and parses the file itself
for (let i = 0; i < 100 && importWindow.props["status-text"] !== expected; i++)
await host.settle(20);
assert.equal(importWindow.props["status-text"], expected);
Error (rejects) The plugin logged a host error the test did
not expect (TestHost.strictErrors, SDK 1.11.2); the message
names it and says how to expect it (TestHost.expectError).
Expect the plugin to log one host error with code (each call
expects one more). An expected error does not fail the test; one that
never comes fails stop() (under TestHost.strictErrors).
The error's code, e.g. "stale".
The plugin read the state once and sets the speed with its old copy; after the user opened another file the player refuses the control.
host.openElsewhere("/media/other.mp4");
host.expectError("stale");
await host.command("rate-2").run();
assert.equal(host.loggedErrors.at(-1)?.code, "stale");
Close the fake stream servers and delete the host's temporary
directories. stop() from startPlugin calls it. It never
throws: a directory that a closing file handle still holds (Windows:
ENOTEMPTY, EBUSY, EPERM) is retried for about 1.5 s, then left
for the system to clean, with a warning on the console.
A test that made a host but failed before startPlugin removes the
host's temporary directories itself. stop() from startPlugin calls
close for you otherwise.
const host = new TestHost();
try {
// … preset the host; the test fails here …
} finally {
host.close(); // deletes the host's temporary data
}
Move the clock by ms milliseconds and, while the source plays
(phase ready, not paused), the position by rate × ms. Each
position boundary and time bound a kept condition waits for is passed
in its order: an enter or leave runs with the clock and the position
where the player would call it, and the test does not wait. The new
position is then pushed as source.state.
The source plays from 0, and the plugin's position condition has a
lead of 2 s before a range at 10 s. Advancing 8 s of clock plays 8 s
of media, so the trigger's enter runs on the way, at 8 s.
host.setSource({ phase: "ready", duration: 60, position: 0 });
// … the plugin gave when.position.in([{ start: 10, end: 12 }], { lead: 2 })
await host.advance(8_000); // its enter ran at 8 s
The player puts the plugin in standby: it is stopped (reason
idle); its trigger conditions and the wake events it listens to are
kept. A condition that flips, or a wake event, starts it again
(activate() runs anew) and delivers what waited, in order; the
conditions given again by activate() change nothing.
Error without a code (rejects) The plugin was not started
with startPlugin.
The test puts a plugin that armed one trigger in standby, as the player does when nothing uses it, and checks that the player still keeps the condition that will start the plugin again.
await host.park(); // stopped with reason "idle"
assert.equal(host.parked, true);
assert.equal(host.triggers.length, 1);
Another version replaces the plugin: it is stopped (reason
upgrade), the conditions of its unnamed triggers are cleared, the
named ones kept, and it starts again with activate (the new
version's code; default: the same). A name the new version does not
declare is dropped when it starts.
Optionalactivate: (plugin: Plugin) => unknownError without a code (rejects) The plugin was not started
with startPlugin.
The test arms the plugin's sleep timer from its command, replaces the
plugin with the same code as a new version, and checks that the
player still keeps the condition of the trigger named sleep.
await host.command("in45").run();
await host.upgrade(); // the same activate, as the new version
assert.ok(host.triggers.some((kept) => kept.trigger === "sleep"));
ReadonlycallsEvery request the plugin sent, in order: { method, params }.
Wire-level; prefer TestHost.sent for one method.
ReadonlysubscriptionsThe host events the plugin subscribed to.
ReadonlylisteningThe subscribed events the plugin really listens to: a listener
(player.on, an onChange and the like) or a stream. The SDK's own
copies of the state are left out, and a binding that reads a state
subscribes nothing.
Empty means the player may stop the plugin while nothing uses it
(unless it holds something else: a window, a panel, a filter…).
ReadonlylisteningWhy the plugin listens to each event of TestHost.listening:
every listener and stream, as the player's log says them (a listener added at main.ts:12, a stream opened at main.ts:20), in the order
they came. A binding's or command field's read of the event's state is
listed beside them (with "— use plugin.when" where a condition exists);
it is never a reason on its own.
The player's source facts (phase, position, duration, paused, rate, audio tracks, loop, ...). Wire-level shape; change it with TestHost.setSource, which also broadcasts it.
ReadonlywindowsTool windows by id (see TestHost.window).
ReadonlypanelsThe plugin's mounted panels by slot, in mount order (one panel per slot). See TestHost.mounted.
ReadonlycommandsThe plugin's commands by local id (see TestHost.command).
ReadonlycoreThe player's 14 core actions (host/<id>), kept apart from the plugin's commands.
ReadonlylayoutBoth panel positions as the player reports them (null while no panel
is mounted there). You may change a slot directly and then call
host.emit("window.state", {}) to simulate a change made elsewhere.
The bottom bar position: preferred, effective, reason,
detached, owner and panels (its one panel).
The sidebar position: preferred, effective, reason, detached;
panels are its tabs in order ({ owner, plugin, title }), owner
the current tab's (the plugin under test is owner 1).
The adjust column, like the sidebar but never detached. It starts
hidden (preferred: false, reason: "userHidden"), as the player's does
until the user opens it.
With the plugin's panel in the sidebar, toggling the sidebar records
that the user prefers it hidden. toggle() reads the slot from the
player, asks for the opposite of its preferred flag and resolves once
the player answered, so the host's layout already shows the new value.
assert.equal(host.layout.sidebar?.preferred, true);
await plugin.panels.sidebar.toggle();
assert.equal(host.layout.sidebar?.preferred, false);
ReadonlyosdEvery osd.show text as the player shows it (translated with the
plugin's catalog and formatted with its args), newest last. The
template and args the plugin sent are in host.sent("osd.show").
ReadonlyosdThe action buttons of each osd.show message, in step with osd (index
for index): each button's title as shown and its command; [] for a
message without actions.
The button title as shown, in the plugin's locale.
The local id of the plugin's command the button runs.
The text of this plugin's osd panel as shown, null when hidden.
The saved interface language (plugin.appearance.language), changed by
appearance.setLanguage or TestHost.setLanguage.
ReadonlyconfirmEvery dialogs.confirm as the player shows it: its texts translated
(message and detail formatted with args), newest last. The options
the plugin sent are in TestHost.confirms.
The question.
Optionaldetail?: stringThe text under it, if any.
The confirm button.
The cancel button (the player's "Cancel" by default).
Optionalcheckbox?: stringThe checkbox, if any.
ReadonlyfileEvery file dialog (openFile, openFiles, openDirectory,
saveFile) as the player shows it: the title translated, a text file
name translated, newest last. The options the plugin sent are in
host.sent("dialogs.open").
The sequence provider's flags, null without a provider.
The provider's canNext, as last evaluated.
The provider's canPrevious, as last evaluated.
What player.stats() returns. Fields added in later rounds may be left
out; the SDK fills them with null.
The plugin's player.stats() now reports a 1920×1080 H.264 stream at
24 fps. The host answers stats() with this object as it stands, so a
test sets it before the plugin asks; fields it leaves out come back as
null from the SDK.
host.stats = {
...host.stats, // keep the other fields
video: { codec: "h264", width: 1920, height: 1080, fps: 24 },
} as typeof host.stats;
ReadonlysubtitleEvery subtitles.load: its options and bytes, newest last.
The format option ("srt" by default).
The title option, null when omitted.
The select option ("primary" by default).
The uploaded file bytes.
ReadonlyclipboardThe fake system clipboard. Preset text to test readText;
writeText replaces it and writeImage appends the image path.
The clipboard's text, null when it holds none.
Paths given to clipboard.writeImage, newest last.
The effective power.preventSleep mode.
ReadonlytoolsThe fake ffmpeg / ffprobe behind plugin.tools. A tool without a
handler is not found (available() is false, run() rejects with
unavailable).
Every run: the tool name and its arguments, newest last.
Make tool available and answer each run with handler(args). Return
{ stdout?, stderr? } (a string stdout is UTF-8 encoded), or throw a
HostError to fail the run with that code. A later call
replaces the handler.
The plugin's Probe command gets an empty stream list from ffprobe, and
any ffmpeg run fails as it would on a broken file. handle makes the
tool available and answers each tools.run with the handler's result;
a thrown HostError makes the run reject with that code. calls
records every run with its arguments.
host.tools.handle("ffprobe", (args) => {
assert.ok(args.includes("-show_streams")); // what the plugin asked for
return { stdout: JSON.stringify({ streams: [] }) }; // a file with no streams
});
// Every ffmpeg run rejects with code `failed`.
host.tools.handle("ffmpeg", () => {
throw new HostError("failed", "Invalid data found when processing input");
});
await host.command("probe").run();
assert.equal(host.tools.calls[0]?.tool, "ffprobe");
ReadonlysystemPaths given to system.reveal / system.openPath, newest last; inject
failures with host.handle("system.openPath", …).
Paths given to system.reveal, newest last.
Paths given to system.openPath, newest last.
system.openUrl addresses, newest last.
ReadonlymenusEvery panel.showMenu, newest last.
Command ids, null for a separator.
at.x, in window coordinates.
at.y, in window coordinates.
ReadonlytimelineTimeline layers by plugin id (this plugin's is manifestId) and the
merged list plugin.timeline.marks reads. A new source clears them.
Each plugin's layer by plugin id; layers with no marks are absent.
Every layer merged, sorted by time, with the publishing plugin's id.
Each plugin's ranges by plugin id; layers without ranges are absent.
Every layer's ranges merged, sorted by start, with the plugin's id.
ReadonlyimagesRuntime images written to views (plugin.ui.image,
plugin.ui.remoteImage), whole values and images nested in rows, newest
last. The SDK refuses images of released scopes before anything is sent.
The test host does not read the files, so it does not check the player's
per-view budget (IMAGE_LIMITS.viewBytes).
The image file's path, as given to ui.image.
The SDK's reference number for that ImageRef.
OptionalmaxSide?: numberIts maxSide option, when given.
Readonlydropdrops.provide registrations of this plugin, in order (id is the SDK's).
The SDK's provider id.
The extensions it takes (lower case, "folder" for directories).
The panel has an onDrop listener.
The palette (plugin.appearance.theme); setAppearance changes it elsewhere.
ReadonlysettingsSettings pages by id (plugin.settings.page), every show (page id or
null), and the page the options window shows.
Registered pages by page id.
Every settings.show(pageId): the page id, null when omitted.
The page the options window shows, null before any show.
Whether the options window is open.
The backdrop: who mounted it and whether it shows (panels.backdrop.state).
The manifest id of the plugin that mounted it.
Whether it shows now (no video frame). true when mounted.
ReadonlyvideoThe display layer (plugin.video.view()): who owns it (this plugin is
manifestId) and the values the player holds.
The owning plugin's manifest id, null while nobody owns it.
The values the player holds.
ReadonlyvideoThe render options (plugin.video.render()): who owns them, the values
the player holds, and whether it renders on the GPU (gpu: false is
software rendering, where every set fails with unsupported).
The owning plugin's manifest id, null while nobody owns them.
The values the player holds.
true: GPU rendering; false: software rendering (unsupported).
plugin.app.system() reports it as rendering.
ReadonlyvideoThe shader channel (plugin.video.shaders(id)): the lists the player holds
for this plugin's handles by id (the real paths, after following links),
and how many shaders other plugins hold, which count against
VIDEO_PROCESSING_LIMITS.shaders (limit). Files must be under
TestHost.fileRoots; under software rendering
(videoRender.gpu = false) a non-empty list fails with unsupported.
This plugin's lists by handle id; a cleared handle has none.
Shaders other plugins hold (0–16).
Where the plugin's own files may be: its package directory and its
data directory (startPlugin sets both when the list is still
empty). lut3d files and shader-channel files outside them fail with
invalid, as in the player.
Play a run after an abnormal end with plugin shaders on: while set, a
non-empty video.shaders list and a render options set with a non-empty
shaders list are refused with previous-crash and this message; clearing
still works. null (default): shaders apply.
The plugin's shader handle turns failed with previous-crash, as
in the player after a crash while plugin shaders were drawing. The
player refuses the list itself (and shows its own OSD line), so the
plugin should report it once and not set the list again.
host.previousCrash = "plugin shaders are off for this start";
const file = join(plugin.dataDirectory, "sharpen.glsl");
writeFileSync(file, "//!HOOK MAIN\n");
const shaders = plugin.video.shaders("sharpen");
shaders.set([file]); // refused: the previous run ended abnormally
await host.settle();
assert.equal(shaders.status.state, "failed");
ReadonlyprocessingThe player's processing (filter) state. Wire-level; may change in minor
versions. resources holds each video.filter / audio.filter chain the
plugin applied, keyed by the SDK's resource id.
Increases with every accepted change.
Set a stage here to simulate a blocked backend (backend-uncertain).
Applied chains by resource id; an empty chain removes its entry, as in the player.
Outcomes of processing operations, for the SDK's recovery queries.
After the plugin set its picture chain, the test reads the one chain
the host holds and compares its nodes. resources keeps each applied
video.filter / audio.filter chain by the SDK's resource id, after
the host validated it with the player's value ranges.
const [chain] = [...host.processing.resources.values()];
assert.deepEqual(chain?.nodes, [{ kind: "hue", degrees: 30 }]);
The player's subtitle state: tracks, selection, style layers, fonts and
loaded resources. Wire-level shape (may change in minor versions); add
tracks to subtitles.tracks (entries may carry codec, text,
streamIndex) to simulate a source's subtitles.
ReadonlyuploadsSubtitle uploads in progress, by upload id. Wire-level.
ReadonlysnapshotsSnapshots taken with media.capture, by snapshot id. Wire-level.
ReadonlyexportsEvery jobs.start request (kind, destination, quality, …),
newest last: a snapshot's (snapshotId) or, since 1.7.8, an export of
remembered files' parts (parts), whose job runs half way through its
middle part (progress.part), then completes (a copy's destination gets
the extension of its container).
ReadonlymediaLocal files as the fake player knows them, by path, for
plugin.media.sources and exports of their parts. A file not listed is a 1080p 30 fps
H.264 file with AAC stereo 48 kHz sound, as long as the current
source. Set status to missing or changed to stand for a moved or
rewritten file; video: null or audio: null for a file without one.
The plugin's list gets a part of a 4K file, then one of a 1080p file:
the check then says size and the job has to re-encode.
host.mediaFiles.set("/media/b.mp4", {
duration: 30,
video: { codec: "h264", width: 1920, height: 818, fps: 30, pixelFormat: "yuv420p" },
});
host.setSource({ phase: "ready", source: "/media/b.mp4", duration: 30 });
ReadonlysourceEvery plugin.media.sources.open the plugin made (its token and
start, 0 for the beginning), newest last. Each opens the token's path
as an ordinary open: source becomes that path, position the start.
The token opened.
Seconds it started at.
ReadonlysourceThe plugin's source references (plugin.media.sources) by token: the
path each stands for. locate takes its answer from
TestHost.dialogAnswers. Wire-level.
ReadonlyjobsExport jobs by job id. Each state query advances a job one step
(queued → running → completed; cancelling → cancelled).
A running clip reports half its progress; a finished clip's
outcome has start and end (a stream copy starts 1 s before the
snapshot time, as if snapped to a keyframe, and its destination gets
the extension of its container: .mkv for container: "mkv", else
.mp4). Wire-level.
Set it to make every running export end failed with this error on
its next state query, as the player reports one (unsupported for a
stream copy it cannot make, export-failed otherwise); null (the
default) completes them.
The outcome.error.code.
The outcome.error.message.
openStream's transport: a local stream (a Unix socket on macOS and
Linux, a named pipe on Windows) or, with "tcp", loopback TCP where the
plugin must send the token first, as the player on Windows answers.
Set it before the plugin calls openStream.
ReadonlyproducersGenerated streams (player.openStream) by producer id: the fake player
end of each frame connection. Wire-level beyond the
FakeProducer fields.
ReadonlyresolversRegistered source resolvers (resolvers.add) by id: their declarations.
ReadonlyotherResolvers other plugins hold, as resolvers.add declares them plus the
holder's id: a registration of this plugin that claims one of their
extensions (or scheme + host pairs) is refused with conflict, which
does not fail activation, like the player.
The manifest id of the plugin holding them (shown in the refusal).
Optionalextensions?: string[]File extensions it resolves (a file resolver), lower case, no dot.
Optionalschemes?: string[]URL schemes it resolves (a web resolver), with hosts.
Optionalhosts?: string[]Exact host names it resolves (a web resolver), with schemes.
The plugin starts in a player where another plugin already resolves
.ch8 files. Pushed before startPlugin, the entry makes the plugin's
own resolver for .ch8 fail with conflict during activation, which
(as in the player) does not fail the activation.
const host = new TestHost();
host.otherResolvers.push({ owner: "example.emulator", extensions: ["ch8"] });
ReadonlyresolutionsFile opens waiting for this plugin's file resolver (extensions), by
request id: the path and how it was opened. Opening a matching path
(player.open, TestHost.openElsewhere) sends
source.resolveRequest; the answer selects the stream, fails the open
or, once the source changed, is stale. Any later source change
cancels it (source.resolveCancel). Web resolvers are not simulated:
emit source.resolveRequest yourself.
ReadonlydialogAnswers for dialogs.open (paths, null = cancelled) and
dialogs.confirm ({ confirmed, checked }), consumed in order. A
dialog with no queued answer, or with the wrong kind, fails the request
(as a lost reply).
For openFile / openDirectory / saveFile queue a one-path array;
for openFiles any number of paths.
The user clicked the confirm button.
The checkbox state.
The plugin's Open command gets a picked file, then a cancelled file dialog, then a confirmed question. All answers share one queue, taken from the front in the order the plugin opens dialogs of any kind: if the next queued answer is missing or of the wrong kind, the dialog fails like a lost reply, so queue them in the order the plugin asks.
host.dialogAnswers.push(["/media/movie.mkv"]); // openFile picks it
host.dialogAnswers.push(null); // the next file dialog is cancelled
host.dialogAnswers.push({ confirmed: true, checked: false }); // confirm
await host.command("open").run();
ReadonlyconfirmsEvery dialogs.confirm request (its options), newest last.
ReadonlymainThe main window as the player would show it. Change it with
setMainWindow (the user resized or maximized it, entered fullscreen,
closed the picture-in-picture window); onTop, cursorAutoHide and
pictureInPicture.active record the plugin's window.set… calls.
pictureInPicture.supported: false stands for Windows and Linux.
Whether the main window is fullscreen.
Whether the main window is maximized (default false). Like the
player, window.state reports false while fullscreen and this
value again after leaving it.
The video area in logical points (default 780×609).
Width in logical points.
Height in logical points.
The effective window.setAlwaysOnTop value.
The effective window.setCursorAutoHide mode.
Picture-in-picture: supported (preset) and active.
Set to false to simulate Windows or Linux.
Whether the picture-in-picture window shows the video.
ReadonlympvThe mpv pass-through (plugin.mpv), without an mpv: commands are
the commands the plugin sent, in order (they do nothing else);
properties is what get answers and set writes (a property not in
it fails backend, "mpv: property not found"); labels are the
owners of filter labels by "vf/<label>" or "af/<label>" (preset
another plugin's id to test conflict); observed are the properties
the plugin observes. The player's refusals apply (refused,
invalid, the limit of 64 observed properties), from the same table
as the player's.
The commands the plugin sent, in order, as their arrays.
Property values by name: what get answers and set writes.
The owner (a plugin id) of each filter label, by "vf/<label>" or "af/<label>".
The properties the plugin observes now.
ReadonlysecretsThe player's secret store for this plugin: name → value. Preset entries
to simulate stored secrets; inject failures with
host.handle("secrets.get", ...). Like the player, secrets.set of a
new name fails limit once 256 names are stored.
Readonlysessionplugin.storage.session: key → value, as the player keeps them. Preset
entries to simulate values an earlier run of the plugin stored in the
same player session, or pass startPlugin(..., { sessionStorage }).
Like the player, a key is 1–1024 bytes, a set that would make the
entries larger than 1 MiB (keys, values as compact JSON and
SESSION_STORAGE_LIMITS.entryBytes per key) fails limit, and an
object's properties are stored sorted, as the player hands them back.
What plugin.app.system() reports. Its rendering follows
videoRender.gpu ("gpu" or
"software"), so one switch covers the render options and the fact;
its renderingReason is rendering.reason.
What plugin.app reports. Set it before startPlugin: the plugin
receives it once at start-up.
The player version.
The short git hash of the build, null when unknown.
Component versions.
libmpv's mpv-version.
{ ffmpeg: <version> }.
The Slint version.
Optionaltemporary?: booleantrue to run as a temporary window
(AppInfo.temporary):
the plugin sees it, and secrets.set, secrets.delete,
packages.install, packages.uninstall and packages.setEnabled
are refused with unavailable, as in the player.
ReadonlyrenderingThe player's rendering choice behind plugin.rendering. The mode drawing
now is videoRender.gpu, as for
plugin.app.system(); the rest is preset here and changed by the plugin's
calls, as the player would:
setPreference saves preference and never changes the mode. It
refuses "gpu" while gpu.available is false: with unsupported
when gpu.reason.code is no-gpu-backend or headless, otherwise
with unavailable, the reason's message in both cases."software" for the "software" choice, else
software with gpu.reason while the GPU is not available, else the
GPU (code preference for a "gpu" choice, default for
"auto"). restartPending compares that with startedWith.restartPlayer counts in restarts and leaves the plugin running
(call stop() yourself); a second one rejects with busy, as a
restart is then under way.Inject other refusals (failed for an unwritable settings file or a
new process that could not start) with host.handle("rendering.setPreference", …)
or host.handle("rendering.restart", …). The defaults are a macOS
player on the GPU: "auto", available, started on the GPU.
Why the mode drawing now is what it is (RenderingState.reason, SystemInfo.renderingReason).
The saved choice: "auto", "gpu" or "software".
The mode this run started with; restartPending compares the next start's mode with it.
Whether the plugin may choose "gpu", and why not (null while available).
false: setPreference("gpu") is refused.
Why the GPU cannot be chosen; null while it can.
Accepted restartPlayer calls.
The plugin's GPU menu item is greyed out with the player's reason when
the GPU cannot be chosen. The host is preset before the plugin starts,
because the plugin reads the state while activating; software
rendering is videoRender.gpu = false, and gpu says why the GPU
cannot be chosen.
import assert from "node:assert/strict";
import { startPlugin, TestHost } from "@vestra-player/sdk/testing";
import activate from "../main.ts";
const host = new TestHost();
host.videoRender.gpu = false; // software draws now (Linux)
host.rendering.startedWith = "software";
host.rendering.reason = { code: "no-gpu-backend", message: "this player has no GPU renderer on Linux yet" };
host.rendering.gpu = { available: false, reason: host.rendering.reason };
const { stop } = await startPlugin(activate, {
directory: new URL("..", import.meta.url),
host,
});
const item = host.command("gpu-rendering");
assert.equal(item.state.enabled, false);
assert.equal(item.state.reason, "this player has no GPU renderer on Linux yet");
await stop();
ReadonlyupscalingThe GPU's video upscaler behind plugin.video.upscaling, answered as the
player would:
state() and set(true) set checked (the player's one GPU check; a
plugin that should not wake the GPU while it starts can assert it is
still false) and report available from reason (null: it
works), this plugin's enabled, and requested with factor while
enabled, available and factor is above 1.set(true) refuses with unsupported and the reason's message while
reason is set, unless its code is decoding, or rendering with
renderingStarting (GPU rendering still starting): those can pass
during the run, so the player keeps the request. Nothing changes when
it refuses.set(false) always succeeds and does not check the GPU: before any
check it reports available: false with the reason unchecked.Inject other answers with host.handle("video.upscaling.set", …). The
defaults are a player where upscaling works and a 1080p video shown
full screen on a 4K display (factor 2), whatever systemInfo says.
Why upscaling does not work; null while it does.
Whether this plugin has upscaling on (set); a test may preset it.
The factor the player would request; null or at most 1: the video needs no upscaling.
Whether the plugin made the player check the GPU (state, set(true)).
GPU rendering is still starting: a rendering reason then lets set(true) keep the request.
The video's size the state reports; null: no video.
The video area the state reports; null: none.
The rendering GPU's name the state reports.
mpv's decoder the state reports; null: no video.
The plugin's upscaling item is greyed out with the player's reason after
the user first picks it. Starting the plugin checks nothing (checked
stays false, so no GPU wakes up); the first pick reads the state, and
set(true) would reject with unsupported, as in the player.
import assert from "node:assert/strict";
import { startPlugin, TestHost } from "@vestra-player/sdk/testing";
import activate from "../main.ts";
const host = new TestHost();
host.upscaling.reason = { code: "no-gpu", message: "no NVIDIA GPU" };
const { stop } = await startPlugin(activate, {
directory: new URL("..", import.meta.url),
host,
});
assert.equal(host.upscaling.checked, false); // starting woke no GPU
const item = host.command("upscaling");
await item.run(); // the first pick checks the GPU
assert.equal(item.state.enabled, false); // greyed out
assert.equal(item.state.reason, "no NVIDIA GPU"); // the player's message
await stop();
ReadonlymotionMotion smoothing behind plugin.video.motion, answered as the player
would:
state() and set() report this plugin's mode, the reasons
double and display (null: that mode works) and active: the
mode while its reason is null and sourceFps is known, else
off; while active, searchMode (performance with
performance) and outputFps (outputFps, or twice sourceFps).set(mode) refuses with unsupported and the reason's message while
that mode's reason is platform, no-gpu, runtime, filter or
rendering (unless renderingStarting): those hold for the run. The
others can pass, so the player keeps the request. off always
succeeds; an unknown mode is invalid.Inject other answers with host.handle("video.motion.set", …). The
defaults are a player where both modes work on a 24 fps video and a
60 Hz display.
This plugin's mode (set); a test may preset it.
Why Double Frame Rate does not work; null while it does.
Why Match Display does not work; null while it does.
GPU rendering is still starting: a rendering reason then lets set keep the request.
The converter's input rate (MotionState.sourceFps); null: not known yet (nothing is active).
The measured output rate while active; null: twice sourceFps.
The faster motion search (the player's first fallback step).
The display's refresh rate.
The converting GPU's name; null: none.
Match Display needs GPU rendering: the plugin greys it with the player's reason, and Double waits for a rate that fits.
host.motion.display = { code: "rendering", message: "Match Display needs GPU rendering" };
host.motion.double = { code: "rate", message: "24 fps doubled is 48 fps on a 60 Hz display" };
host.motionChanged();
await host.settle();
assert.equal(host.motion.mode, "off");
ReadonlynvidiaNVIDIA's engine behind plugin.video.motion("nvidia"): the same model
as TestHost.motion (AMD's), its own state, answered the same
way. The defaults are a player where both modes work on a 24 fps video
and a 60 Hz display, converting on an RTX 4070 Laptop GPU. One
converter at a time, as the player: the first engine set to a mode (or
preset to one, amd first) holds it while its mode is not off, and
the other engine's modes report other-engine, in the player's order:
a model's own run-long, renderer, upscaling or doubling reason
comes first, its failed, overload, rate, format or size after.
A test of "another plugin holds AMD's converter" sets
host.motion.mode.
This plugin's mode (set); a test may preset it.
Why Double Frame Rate does not work; null while it does.
Why Match Display does not work; null while it does.
GPU rendering is still starting: a rendering reason then lets set keep the request.
The converter's input rate (MotionState.sourceFps); null: not known yet (nothing is active).
The measured output rate while active; null: twice sourceFps.
The faster motion search (the player's first fallback step).
The display's refresh rate.
The converting GPU's name; null: none.
The same reason on both modes is what the player answers there: the
plugin shows it and keeps the mode off, since no-gpu holds for the run.
const reason = { code: "no-gpu", message: "no NVIDIA GPU" };
host.nvidiaMotion.double = reason;
host.nvidiaMotion.display = reason;
What player.chapters() lists while media is ready.
The chapter title, null without one.
Start time in seconds.
Readonlydataplugin.dataDirectory: a fresh empty temporary directory, removed with
the host on stop(). plugin.storage.json reads and writes real files
here. Pass startPlugin(..., { dataDirectory }) to use another one.
The manifest id of the plugin under test (set by startPlugin;
"test.plugin" by default).
The player.setStepSeek value in effect (default 5).
The player.setStepSeek keyframes in effect (default false).
Test data: the keyframe times (seconds, ascending) of the current
source, for keyframe step seeks. null (the default): none modelled,
and step seeks are exact even with stepSeekKeyframes.
With keyframe step seeks on, Forward from 0:12 lands on the keyframe at
0:20, not at 0:17, and the OSD says so. keyframes gives the source's
keyframe times; setStepSeek turns on keyframe steps of 5 s, and the
core action seek-forward seeks to the first keyframe at or after
the target, as the player does.
host.setSource({ phase: "ready", duration: 45, position: 12 });
host.keyframes = [0, 10, 20, 30, 40];
await plugin.player.setStepSeek({ seconds: 5, keyframes: true });
await plugin.host.run("seek-forward"); // target 17 s, next keyframe 20 s
assert.equal(host.source.position, 20);
assert.equal(host.osd.at(-1), "Forward 5 s: 00:20 / 00:45");
ReadonlycoreEvery step seek the core ran (seek-backward / seek-forward, from a
key, the menu or host.run), newest last: the step, whether it went to
a keyframe, and where it landed.
seek-backward or seek-forward.
The step: host.run's seconds, else setStepSeek's.
It landed on a keyframe (stepSeekKeyframes and keyframes modelled).
The new position.
ReadonlyseeksEvery seek a plugin submitted (player.seek, Scrub.seek), newest
last, with the mode it asked for. The test host lands on the exact
target either way (the player lands a keyframes seek on the last
keyframe at or before it); the core's step seeks are in coreSeeks.
The target.
Scrub.seek(seconds, { keyframes: true }).
ReadonlystepsEvery player.step and core frame step, newest last. The position does
not move, except a step back after the end: like the player, a seek
that stays paused, one frame back (stats fps, else 30) for a frame,
to the last keyframe before the position
(none modelled: 1 ms back) for a keyframe. A keyframe step forward
after the end goes nowhere.
"frame" or "keyframe".
"backward" or "forward".
ReadonlycoreEvery core action run (host.run, a core command, a pressed core binding), newest last.
The plugin is built into the player (startPlugin's builtin). Only
then does the host answer the built-in-only requests
(commands.list, commands.run, palette.lead.*); otherwise they
fail with builtin-only, as in the player.
The palette's lead row as the plugin last set it (palette.lead.set,
wire form), null without one. Wire-level.
ReadonlyopenedEvery temporary window a built-in plugin opened with app.openWindow,
oldest first: the files and the process id answered
(App.openWindow). No
process starts. A
plugin that is not built in is refused with builtin-only, as in the
player; the files are checked as the player does (invalid,
missing).
The files, as the plugin gave them.
The process id answered (made up: no process starts).
ReadonlybindingsThe binding overlay plugin.bindings.set writes ("<plugin>/<command>"
to inputs; preset it to simulate saved overrides). press honours it.
"<plugin>/<command>" → the user's inputs for it.
What packages.list reports; setEnabled, uninstall and install
update it. builtin, source and dataDirectory are optional here
(default false, null, null).
The plugin's manifest id.
Its version, null when unknown.
Where it was loaded from.
Its run state.
Why it failed (state: "failed").
The package directory.
Optionalbuiltin?: booleanShipped with the player: uninstall and install are unsupported.
Optionalsource?: PackageSource | nullWhere it was installed from.
OptionaldataDirectory?: string | nullIts data directory.
ReadonlypackageEvery packages.setEnabled / uninstall / install, newest last.
Which call.
The target plugin id.
Optionalenabled?: booleansetEnabled's value, or install's enabled option when given.
OptionalremoveData?: booleanuninstall's removeData option.
Optionalsource?: PackageSourceinstall's source ({ kind: "file" } when not given).
Optionalreplace?: booleaninstall's replace option.
ReadonlycandidatesPackages validate and validateArchive accept: path (directory or .vxp
file) → its manifest. Other paths fail with missing. install adds or
upgrades the entry in TestHost.packages following the player's
source rules: the same source upgrades, another source needs replace
(conflict otherwise), a built-in id is unsupported. The installed
entry's state follows
"@vestra-player/sdk"!InstallOptions.enabled: a first install runs,
an update of a disabled entry stays disabled unless enabled is
true, and enabled: false installs it disabled.
The plugin can validate and install /downloads/someone.demo-1.0.0.vxp
as if the file existed. The host accepts only paths listed here (others
fail with missing) and returns this manifest from validate; an
install then follows the player's source rules.
host.candidates.set("/downloads/someone.demo-1.0.0.vxp", {
id: "someone.demo", version: "1.0.0", apiVersion: "vestra/1",
entry: "main.js",
});
Which install rule packages.install plays. true (default): an update
or reinstall keeps a disabled plugin disabled unless the plugin passes
"@vestra-player/sdk"!InstallOptions.enabled. false: every
install runs the plugin and enabled is ignored (it is still checked and
recorded in TestHost.packageCalls).
ReadonlyremoteRemote images (plugin.ui.markdown, plugin.ui.remoteImage): address
→ a local PNG or JPEG file served for it, or null for a failing
download. Nothing is fetched from the network in tests; unknown
addresses fail.
What player.audioDevices() lists. setAudioDevice updates
host.source.audioOutput.
The device id, e.g. coreaudio/<UID>.
The system's name for it.
Whether a host error the plugin logged fails the test (default true).
A host error is a refusal or failure with a code (stale, invalid,
disabled, …) that nothing in the plugin handled: no try/catch
around the call and no plugin.onError listener, so the player would
only write it to its log. The next TestHost.settle (so also
command(…).run()) rejects with it, or else stop(); the message
names the error and how to expect it. A test that means it calls
TestHost.expectError first. Set false to only log host
errors, as before SDK 1.11.2. TestHost.loggedErrors lists them
either way.
The user opens another file, then runs a command that controls the
old one with a state the plugin read before: the player refuses it with
stale, and the plugin leaves the refusal to its log. The test says so
before it runs the command; without expectError the run rejects.
host.openElsewhere("/media/other.mp4");
host.expectError("stale");
await host.command("rate-2").run();
An in-memory fake Vestra Player for plugin tests.
The plugin under test talks to it over the real wire protocol (the host is the plugin's transport), so everything the SDK does runs unchanged. The host answers each request with simplified player behaviour, records what the plugin did, and lets the test act as the user or another plugin.
Members fall into a few groups:
(id).run(), TestHost.press, TestHost.window(id).emit(...), TestHost.mounted().emit(...), TestHost.drop, TestHost.step, TestHost.dialogAnswers.Usually created by startPlugin. Create one yourself only to preset data that the plugin reads during activation (
app,appearance,secrets, ...), then pass it asstartPlugin(activate, { host }).Fields that mirror player state at the wire level (
source,subtitles,processing,snapshots,jobs,producers,uploads,resolvers,calls) use the protocol's shapes. They are fine for assertions but are not part of the plugin API: their shape may change in minor versions.Example: Preset the player, then react to another plugin's file
The test starts the plugin in a player with the dark theme, opens a file the way another plugin would, and checks the plugin's panel title. A host created first can be preset with data the plugin reads during activation;
startPluginthen uses it.openElsewherechanges the source and broadcasts it, the plugin's listener updates its panel, andsettle()waits for those requests before the assertion.Remarks
An in-memory player that speaks the real wire protocol, so the SDK's own logic runs as it does in the player; only the player side is simulated (no decoding, no Slint, no windows). Make one per test, preset it if the plugin reads something during activation, start the plugin with startPlugin, drive it,
settle(), and assert on what it recorded.See
Test a plugin
Since
1.0.0