ExUnit helpers for renderer-independent application tests and deterministic GPUI interaction tests.
Ordinary tests use a lightweight GPUI.Test.Display:
use GPUI.Test, async: trueTests that exercise real operating-system windows opt in to an owned desktop session:
use GPUI.Test, desktop: trueDeterministic tests that need GPUI layout, focus, hit testing, or keyboard dispatch opt in to a supervised native UI:
use GPUI.Test, native: [size: {640, 480}]Native UI cases are skipped by ordinary ExUnit runs. Use the dedicated
deterministic native-test Mix task so the package is compiled for the
native_test target.
Both modes import one concise helper vocabulary; the first argument identifies whether an interaction targets a runtime or an interactive UI.
defmodule FocusTimerTest do
use GPUI.Test, async: true
test "advances from an OTP message" do
runtime = start_runtime!(FocusTimerApp, args: %{seconds: 2})
click(runtime, "start")
send_view(runtime, :tick)
assert %{remaining: 1, status: :running} = assigns(runtime)
end
endEvents are dispatched through GPUI.Test.Display, so the same
GPUI.Runtime polling boundary used by a real display is exercised without
loading GPUI or requiring desktop libraries.
Summary
Functions
Advances GPUI's deterministic clock by the given milliseconds.
Returns root-view assigns for a selected window.
Returns the rendered bounds for a stable element ID.
Dispatches a change event and returns the updated snapshot.
Clicks a stable element ID or logical point in an interactive deterministic UI.
Dispatches a click event and returns the updated snapshot.
Dispatches an application command and returns the updated snapshot.
Acknowledges deterministic copying of a selected code-viewer line.
Dispatches a normalized display event and returns handled events plus the new snapshot.
Cancels a deterministic display-side button file read.
Selects deterministic file bytes for a display-side button file read.
Moves native keyboard focus to a stable element ID.
Presses a semantic key in an interactive deterministic UI.
Delivers a deterministic source-backed virtual-list range request.
Dispatches a slider release event and returns the updated snapshot.
Renders a view directly with map or keyword assigns.
Renders a view into an interactive deterministic native UI.
Resizes the deterministic native viewport.
Scrolls a stable target by a bounded logical-pixel delta.
Dispatches a combobox search event and returns the updated snapshot.
Selects a controlled form value and returns the updated snapshot.
Delivers an OTP message to a root view and returns the updated snapshot.
Runs native UI work until GPUI is parked.
Returns a runtime snapshot, or passes an existing snapshot through.
Starts a supervised runtime backed by GPUI.Test.Display.
Dispatches an input submission with its current string value.
Dispatches a deterministic data-table cell selection.
Dispatches a deterministic sortable data-table header selection.
Returns the rendered tree for a selected window.
Types text into the focused native input.
Returns a window snapshot from a runtime or full snapshot.
Functions
@spec advance(GPUI.Test.UI.t(), non_neg_integer()) :: GPUI.Test.UI.t()
Advances GPUI's deterministic clock by the given milliseconds.
@spec assigns( GenServer.server() | GPUI.Snapshot.t(), :first | pos_integer() | String.t() ) :: map()
Returns root-view assigns for a selected window.
@spec bounds(GPUI.Test.UI.t(), String.t()) :: map()
Returns the rendered bounds for a stable element ID.
@spec change(GenServer.server(), String.t(), term(), keyword()) :: GPUI.Snapshot.t()
Dispatches a change event and returns the updated snapshot.
@spec click(GPUI.Test.UI.t(), String.t() | {number(), number()}) :: GPUI.Test.UI.t()
Clicks a stable element ID or logical point in an interactive deterministic UI.
@spec click(GenServer.server(), String.t(), keyword()) :: GPUI.Snapshot.t()
Dispatches a click event and returns the updated snapshot.
@spec command(GenServer.server(), String.t(), keyword()) :: GPUI.Snapshot.t()
Dispatches an application command and returns the updated snapshot.
@spec copy_selected_line(GenServer.server(), String.t(), keyword()) :: GPUI.Snapshot.t()
Acknowledges deterministic copying of a selected code-viewer line.
@spec dispatch(GenServer.server(), GPUI.Event.t() | map() | keyword()) :: {[map()], GPUI.Snapshot.t()}
Dispatches a normalized display event and returns handled events plus the new snapshot.
@spec file_cancel(GenServer.server(), String.t(), keyword()) :: GPUI.Snapshot.t()
Cancels a deterministic display-side button file read.
@spec file_select(GenServer.server(), String.t(), String.t(), binary(), keyword()) :: GPUI.Snapshot.t()
Selects deterministic file bytes for a display-side button file read.
@spec focus(GPUI.Test.UI.t(), String.t()) :: GPUI.Test.UI.t()
Moves native keyboard focus to a stable element ID.
@spec press(GPUI.Test.UI.t(), atom() | String.t()) :: GPUI.Test.UI.t()
Presses a semantic key in an interactive deterministic UI.
@spec range( GenServer.server(), String.t(), non_neg_integer(), non_neg_integer(), keyword() ) :: GPUI.Snapshot.t()
Delivers a deterministic source-backed virtual-list range request.
@spec release(GenServer.server(), String.t(), number(), keyword()) :: GPUI.Snapshot.t()
Dispatches a slider release event and returns the updated snapshot.
@spec render(module(), map() | keyword()) :: GPUI.Element.t()
Renders a view directly with map or keyword assigns.
@spec render(GPUI.Test.UI.t(), module(), map() | keyword()) :: GPUI.Test.UI.t()
Renders a view into an interactive deterministic native UI.
@spec resize( GPUI.Test.UI.t(), {number(), number()} ) :: GPUI.Test.UI.t()
Resizes the deterministic native viewport.
@spec scroll(GPUI.Test.UI.t(), String.t(), keyword()) :: GPUI.Test.UI.t()
Scrolls a stable target by a bounded logical-pixel delta.
@spec search(GenServer.server(), String.t(), String.t(), keyword()) :: GPUI.Snapshot.t()
Dispatches a combobox search event and returns the updated snapshot.
@spec select(GenServer.server(), String.t(), String.t() | nil, keyword()) :: GPUI.Snapshot.t()
Selects a controlled form value and returns the updated snapshot.
@spec send_view(GenServer.server(), term(), keyword()) :: GPUI.Snapshot.t()
Delivers an OTP message to a root view and returns the updated snapshot.
@spec settle(GPUI.Test.UI.t()) :: GPUI.Test.UI.t()
Runs native UI work until GPUI is parked.
@spec snapshot(GenServer.server() | GPUI.Snapshot.t()) :: GPUI.Snapshot.t()
Returns a runtime snapshot, or passes an existing snapshot through.
Starts a supervised runtime backed by GPUI.Test.Display.
@spec submit(GenServer.server(), String.t(), String.t(), keyword()) :: GPUI.Snapshot.t()
Dispatches an input submission with its current string value.
@spec table_cell_select( GenServer.server(), String.t(), String.t(), String.t(), keyword() ) :: GPUI.Snapshot.t()
Dispatches a deterministic data-table cell selection.
@spec table_sort(GenServer.server(), String.t(), String.t(), keyword()) :: GPUI.Snapshot.t()
Dispatches a deterministic sortable data-table header selection.
@spec tree( GenServer.server() | GPUI.Snapshot.t(), :first | pos_integer() | String.t() ) :: map()
Returns the rendered tree for a selected window.
@spec type(GPUI.Test.UI.t(), String.t()) :: GPUI.Test.UI.t()
Types text into the focused native input.
@spec window_snapshot( GenServer.server() | GPUI.Snapshot.t(), :first | pos_integer() | String.t() ) :: map()
Returns a window snapshot from a runtime or full snapshot.