Skip to main content

Crate frus_test

Crate frus_test 

Source
Expand description

frus-test — the framework’s test tooling (§13 of the design notes).

Three levels, from the least integrated to the most:

  1. Pure update: nothing to supply — the Elm architecture makes state testable with neither GPU nor window (assert_eq! on the struct after a message). This crate plays no part.
  2. Scene and widget snapshots: render_scene and render_widget render offscreen, through the same pipeline as the window, and return a Snapshot that can be queried pixel by pixel.
  3. Goldens: Snapshot::assert_golden compares against a reference PNG on disk. When it is missing, it is created — read it over, then commit it; FRUS_UPDATE_GOLDENS=1 regenerates it.
  4. A frame loop: Stage holds the retained state and steps it the way the shell does, for the widgets whose picture is a gesture in flight — a swipe half-done, a pull past the top, a page between two pages — rather than a function of their arguments.

Goldens depend on the rasteriser, text antialiasing varying from one GPU to another, so generate and compare them in the same environment — here, llvmpipe under WSL, which is deterministic. With no GPU adapter the render functions return None and the tests skip cleanly.

Structs§

Snapshot
A rendered frame: sRGB RGBA bytes, origin at the top left.
Stage
A frame-by-frame harness: the retained state the shell holds, plus a way to step it forward the way the shell’s loop does.

Functions§

render_scene
Renders a Scene offscreen on a clear background. None with no GPU.
render_widget
Builds and renders a widget tree the way the shell would: layout through taffy, then painting with the given theme, on a theme.background background, in a virtual width×height window. The retained state is neutral: no hover, no focus, scroll at zero. None with no GPU.