@vestra-player/sdk - v1.11.3
    Preparing search index...

    A tool window as the test host keeps it: the record of a plugin.windows.create(...) window after its first show(). Get one with TestHost.window.

    The test opens the plugin's Picture window, moves its brightness control and checks that the plugin wrote the value back. emit fires a Slint callback as if the user used the control; the plugin's on handler runs and sets properties, which reach the host as requests, so settle() waits for them before props is read.

    await host.command("open-picture").run(); // the plugin calls pictureWindow.show()
    const picture = host.window("picture");
    assert.equal(picture.visible, true);
    picture.emit("adjust", "brightness", 40); // fire a Slint callback
    await host.settle();
    assert.equal(picture.props["brightness"], 40);

    A record, not a window: no Slint file is compiled and nothing is drawn. props holds what the plugin wrote, by Slint name; emit fires a callback the way the user's input would; userClose closes it the way the title-bar button would.

    1.0.0

    interface FakeWindow {
        file: string;
        visible: boolean;
        props: Record<string, Json>;
        callbacks: string[];
        emit(callback: string, ...args: Json[]): void;
        userClose(): void;
    }
    Index
    • Fire a Slint callback as if the user triggered it in the window. The name may be kebab-case or camelCase; args are the callback arguments. Follow it with await host.settle() before asserting.

      Parameters

      • callback: string
      • ...args: Json[]

      Returns void

      The test types "cat" into the window's search box and checks the plugin's results. emit delivers the Slint callback search-changed with its argument to the plugin's on handler; settle() waits for the properties the handler wrote.

      const search = host.window("search");
      search.emit("searchChanged", "cat"); // camelCase or kebab-case
      await host.settle();
      assert.ok((search.props["results"] as unknown[]).length > 0);

      1.0.0

    • The user closes the window with its title-bar button: the window closes and the plugin's window.onClose listeners run (unlike the plugin's own close()).

      Returns void

      The test closes the plugin's window with its title-bar button and checks that the plugin stopped its timer. Unlike the plugin's own close(), userClose runs the plugin's onClose listeners.

      host.window("clock").userClose();
      await host.settle();
      assert.equal(host.window("clock").visible, false);

      1.0.0

    file: string

    The .slint file the window was created from (package-relative).

    visible: boolean

    Whether the window is shown (show()) or hidden (hide()).

    props: Record<string, Json>

    The properties the plugin wrote, by their Slint (kebab-case) names: canMark is stored as can-mark. Runtime images appear in their wire form; read the path with TestHost.imagePath.

    callbacks: string[]

    The Slint callback names (kebab-case) the plugin bound with on().