You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
testing::Driver: an interactive test driver (click, drag, type, press, settle) #373
From a consumer's widget review: its rig (338 lines, 26 tests) runs the real view through egui frames with click(path_suffix), drag, type_text, press(chord), key, select_all and window_focus, reads back nodes by path suffix and painted text by content (painted, shows, fits), and settle()s across animations.
eggshell's own tests/it files (interaction, commands, blur_cause, dnd_*, choices, hit_route…) each carry private copies of these helpers.
Proposal: a public testing::Driver covering that surface, then migrate eggshell's own tests onto it (removing the duplicates) and offer it to consumers. It builds on Headless, Placed queries and Placed::menu_open.
Read against origin/main at 62fc13a (after #375). This is a note only: no code and no PR. The consumer is not named.
0. The survey: what the driver replaces
tests/it/support/mod.rs (704 lines): the shared rig
Item
Line
What it does
Rig<A>
142
The harness state: app, LayoutState, view fn, Bar companion, Page, ReducedMotion, and the last frame copied out as nodes: Vec<(String, Rect)> and ids: Vec<(String, Id)> (277–285), plus an observe hook
Six constructors for one builder. Every frame applies shadcn and full_motion, runs prepare, paints the page, shows the bar, then builds, lays out and draws. The step is 0.05 s and the accessibility check is on
FrameRig, frame_harness, frame_harness_scaled
540, 546, 556
The same for a view that draws the whole frame itself (scroll areas, dnd). It steps at 1/60 s and turns record on
full_motion
129
Restores animation_time, which kittest sets to zero
past_bar
76
Focuses the bar's last Tab stop
rect_of, id_of
295, 306
Look up an exact readable path in the copied list. They panic
hover_over
316
hover_at, then 3 frames
press_and_release
321
A primary press, a frame, a release, a frame
click_node
383
rect_of centre, hover_over, press_and_release
hover_node
361
Hovers a node's centre
press, release
491, 504
Press (or release) on a node, then 12 frames
drag
334
Hover 3 frames, drag_at, then the midpoint, to and drop_at, one frame each, then 3 frames
rest_for_tooltip
369
Steps until the clock passes tooltip delay plus enter (loop capped at 10 000), then 4 frames
focused_node, focused_path
391, 403
What has focus: the deepest node whose focus_within holds, or the node path, or <widget>
Focus by clicking:prims.rs:97, modal.rs:205 (asserts the precondition). Focus by request:hit_route.rs:471 (request_focus, asserts the precondition).
Type.Event::Text, then N frames:
3 frames: form_demo.rs:48, hello.rs:34.
Other counts: prims.rs:92 runs 2, slider_header.rs:99 runs 4.
Click a field and type: hello.rs:282 and form_demo.rs:54 (fill).
Click, then assert focus and typed text: blur_cause.rs:84 (typing), field_focus.rs:63 (typing), commands.rs:279 (start_typing).
Drag and lift. "Lift" is press, then +6 and +12 past the threshold, with no release. Its copies:
y offsets with 2 frames: dnd_gallery.rs:103, dnd_reorder.rs:66.
y offsets with 3 frames: dnd_preview.rs:135, layout_dnd.rs:75.
x offsets: dnd_zones.rs:70.
dnd_gallery.rs:953 (lift_from).
Drags that end in drop_at: dnd_handle.rs:167 (press_and_move) with dnd_handle.rs:180 (release), splitter.rs:125/135, and overlay.rs:513 (drag, a copy of support::drag).
overlay_input.rs:521 (window_focus(bool)) sets input.focused, sends WindowFocused and asserts the precondition. blur_cause.rs:100 (blur_the_window) only sends the event.
Harness constructors. 122 private functions in 80 files (1,368 lines) wrap support::harness*. Most add size, base text, a first run_steps(2..4), and sometimes a style prepare. 16 files build their own Harness::builder(): overlay.rs (World), interaction.rs, blur_cause.rs, select.rs, snapshots.rs, draw.rs and others.
Size. In all there are 276 helper functions and about 2,500 lines:
Kind
Helpers
Lines
Harness constructors
122
1,368
Key, chord and Tab
32
214
Click, hover and pointer
29
194
Painted text
23
215
Node lookup
21
142
Drag and lift
13
124
Window, wheel and touch
12
111
Type
10
67
Settle and wait
14
75
The call sites:
click_node 311, rect_of 650, focused_path 133
run_steps 1,074, key_press 211, hover_at 138
harness.state().app 710
#[test] functions: 1,618
What the survey shows:
No one in eggshell settles. Every "settle" runs a fixed number of frames, and the counts are 3, 4, 5, 6, 8, 10 or 12, depending on who wrote the file.
Rig copies the frame out as (path, rect) and (path, id) lists because Placed::draw(self) consumes the frame. So has, rect_of, the suffix finds and the focus lookups are all written against that copy and not against Query.
The consumer's rig (338 lines, 26 tests), mapped to the driver
Rig
Driver
click(path_suffix)
click(Target::suffix(..)), or click(d.path(K).at(..)) with typed keys
drag(from, to)
drag(from, to)
type_text
type_text
press(chord), key
press(impl Into<Press>), which takes a Key, a KeyboardShortcut or a Chord
1a. The prerequisite: a frame that outlives its draw
Placed<A> holds two kinds of thing. Its query data (nodes, by_id, prims, roots, root, the kept handle and the ctx) has no closures. Its draw, drag, dismiss and window closures do. draw(self, ..) drops both.
The query data moves into a new public type, testing::PlacedFrame:
Placed<A> holds a PlacedFrame beside its closures.
Every query that Placed has today (at, try_at, overlay(s), expect_overlay, menu_open(_with), diff, overflowing, node, rect, nodes, shell) is defined once on PlacedFrame. Placed<A> forwards to it.
Query<'p> already reads only nodes, prims and by_id, so it is unchanged.
When a driver asks for it, draw moves the frame into the LayoutState's kept slot instead of dropping it. Nothing is cloned, and a normal frame pays nothing.
This removes the reason Rig keeps its own copy. Headless, the driver and a frame-drawing closure then answer through the same Query.
1b. Construction
// eggshell_ui::testing, behind the `driver` feature (see Q1)use std::time::Duration;use egui_kittest::{Harness,HarnessBuilder};pubstructDriver<A:'static>{/* Harness<'static, Stage<A>>, After, settle cap, Reports */}/// The harness state: the app, its LayoutState and how a frame is drawn. Opaque.pubstructStage<A>{/* .. */}impl<A:'static>Driver<A>{/// The driver builds, lays out and draws `view` of `app` each frame, as an app's root does.pubfnnew(app:A,view:implfor<'f>FnMut(&mutBuilder<'_,'f,A>,&'fA) + 'static,) -> DriverBuilder<A>;/// For a view that draws the whole frame itself (scroll areas, dnd frames, a bar beside it)./// The driver still reads the frame through the LayoutState it passes in.pubfnframe(app:A,frame:implFnMut(&mut egui::Ui,&mutA,&mutLayoutState) + 'static,) -> DriverBuilder<A>;}impl<A:'static>DriverBuilder<A>{pubfnsize(self,size: egui::Vec2) -> Self;// default 800×600pubfntheme(self,theme: egui::Theme) -> Self;pubfnpixels_per_point(self,scale:PixelsPerPoint) -> Self;pubfnstep(self,step:Duration) -> Self;// the clock; default 1/60 s (Q4)pubfnmotion(self,motion:Animation) -> Self;// Animation::Full (default) | Reduced (Q5)pubfnbase_text(self,base:TextStyle) -> Self;pubfnsetup(self,setup:implFnOnce(&egui::Context) + 'static) -> Self;// style, fonts, record()pubfnafter(self,after:After) -> Self;// After::Settle (default) | Frames(n) (Q2)pubfnsettle_within(self,cap:Duration) -> Self;// default 2 s of clockpubfnreports(self,reports:Reports) -> Self;// Reports::Guarded (default) | Unchecked (§4)/// Start from a preconfigured kittest builder: `testing::screenshot::builder(scale, theme)?`.pubfnwith_harness(self,builder:HarnessBuilder<Stage<A>>) -> Self;/// Builds the harness through `HarnessBuilder::build_ui_state`, runs the first frame and settles.pubfnbuild(self) -> Driver<A>;}pubenumAnimation{Full,Reduced}pubenumAfter{Settle,Frames(usize)}pubenumReports{Guarded,Unchecked}pubenumWindowFocus{Focused,Blurred}
The clock. egui moves input.time forward by predicted_dt each frame, and kittest sets predicted_dt to its step_dt, so frame n is at n × step on every run. The driver takes a Duration and converts it to kittest's f32 seconds only where it calls with_step_dt. It never calls try_run_realtime, which would sleep.
The defaults match how an app runs rather than kittest's defaults. kittest zeroes animation_time, which eggshell reads as reduced motion. Its 0.25 s step breaks double clicks. Its max_steps of 4 panics on any transition.
1c. Addressing a node
pubenumTarget{Path(Path),// typed keys from the root: d.path(Part::Card).at(Part::Save)Suffix(String),// the readable path ends with this; exactly one node must matchRole(egui::accesskit::Role,String),// resolved through kittest's get_by_role_and_labelText(String),// the one node whose text is this, as Query::textId(egui::Id),Point(egui::Pos2),}implFrom<Path>forTarget,From<egui::Pos2>forTarget,From<egui::Id>forTarget;implTarget{pubfnsuffix(s:&str) -> Self;pubfnrole(r:Role,name:&str) -> Self;pubfntext(t:&str) -> Self;}/// An owned key path. The driver knows its layout's root id, so each `at` hashes its key with/// `child_id` straight away, exactly as `Query::at` does. It does not borrow the frame,/// so `d.click(d.path(K))` compiles.pubstructPath{/* steps: Vec<(readable, Id)> */}impl<A>Driver<A>{pubfnpath<K:Key>(&self,key:K) -> Path;}implPath{pubfnat<K:Key>(self,key:K) -> Path;}
A target is resolved against the last frame when the action runs.
A miss panics. The message is Query::at's: the path asked for, then what exists below the deepest step found. A path walks the frame through Query, so the message is the same text.
Target::Role reuses kittest's AccessKit query and its "more than one match" panic. It does not search the AccessKit tree a second time.
A pointer action asserts its precondition: the point it would press is inside the window. A node scrolled or placed off screen fails with its rect. It is never clicked at a point that egui clips.
1d. Actions
Each action queues its events with kittest's own methods (hover_at, drag_at, drop_at, event, key_press_modifiers). It runs one frame per event through harness.step(), then applies the driver's After policy. Every action returns &mut Self, so actions chain.
impl<A:'static>Driver<A>{// timepubfnframes(&mutself,n:usize) -> &mutSelf;pubfnadvance(&mutself,by:Duration) -> &mutSelf;// ceil(by / step) frames: tooltip delays, toast dwellpubfnsettle(&mutself) -> &mutSelf;// panics past the cap; see 1fpubfntry_settle(&mutself) -> Result<Settled,Unsettled>;pubfnnow(&self) -> Duration;// clock time since build// pointer: the gestures eggshell's support already uses, so migrated tests send the same eventspubfnhover(&mutself,at:implInto<Target>) -> &mutSelf;pubfnclick(&mutself,at:implInto<Target>) -> &mutSelf;// = support::click_nodepubfnclick_with(&mutself,at:implInto<Target>,button:PointerButton,modifiers:Modifiers) -> &mutSelf;pubfndouble_click(&mutself,at:implInto<Target>) -> &mutSelf;// two clicks inside egui's windowpubfnpress(&mutself,keys:implInto<Press>) -> &mutSelf;// Key | KeyboardShortcut | Chordpubfnpointer_down(&mutself,at:implInto<Target>) -> &mutSelf;// = support::press without its framespubfnpointer_up(&mutself,at:implInto<Target>) -> &mutSelf;pubfndrag(&mutself,from:implInto<Target>,to:implInto<Target>) -> &mutSelf;// = support::dragpubfnlift(&mutself,from:implInto<Target>,past:Vec2) -> &mutSelf;// press and carry `past`, in two moves; no releasepubfncarry_to(&mutself,to:implInto<Target>) -> &mutSelf;pubfnwheel(&mutself,at:implInto<Target>,delta:Vec2) -> &mutSelf;// keyboardpubfntype_text(&mutself,text:&str) -> &mutSelf;pubfnselect_all(&mutself) -> &mutSelf;// press(Modifiers::COMMAND + A)pubfntab_to(&mutself,target:implInto<Target>) -> &mutSelf;// Tab until focus is there; panics after one lap of Tab stops// window and platformpubfnwindow_focus(&mutself,focus:WindowFocus) -> &mutSelf;// sets input.focused and sends WindowFocusedpubfnhover_files(&mutself,files:&[std::path::PathBuf]) -> &mutSelf;pubfndrop_files(&mutself,files:&[std::path::PathBuf]) -> &mutSelf;pubfnresize(&mutself,size:Vec2) -> &mutSelf;pubfnset_theme(&mutself,theme: egui::Theme) -> &mutSelf;pubfnfocus(&mutself,target:implInto<Target>) -> &mutSelf;// a programmatic focus request, as hit_route.rs:471pubfnevent(&mutself,event: egui::Event) -> &mutSelf;// the escape hatch, through the same queue// the apppubfnapp(&self) -> &A;pubfnapp_mut(&mutself) -> &mutA;// the next frame sees the changepubfnshell(&self) -> Shell;pubfnctx(&self) -> &egui::Context;pubfnharness(&self) -> &Harness<'static,Stage<A>>;// kittest queries, screenshot::renderpubfnharness_mut(&mutself) -> &mutHarness<'static,Stage<A>>;}
press takes Into<Press>. A Chord refuses a bare Esc or Enter on purpose (commands.rs:150), and tests press those keys constantly, so press also takes a plain Key and KeyboardShortcut. The type system stays honest: it does not invent chords.
1e. Queries
impl<A:'static>Driver<A>{pubfnframe(&self) -> &PlacedFrame;// at / try_at / text / overlay / expect_overlay / menu_open / overflowing / diffpubfnrect(&self,target:implInto<Target>) -> Rect;// panics with candidatespubfnfind(&self,target:implInto<Target>) -> Option<Rect>;pubfnexists(&self,target:implInto<Target>) -> bool;pubfnfocused(&self) -> Option<Focused>;// Focused::Node(path) | Focused::Widget { within: path }pubfnpainted(&self) -> Painted<'_>;// the last output's shapes, groups flattenedpubfnreports(&self) -> Vec<Report>;pubfnexpect_reported(&mutself,problem:Problem) -> Report;// panics if absent; takes it so the guard passes}impl<'d>Painted<'d>{pubfntexts(&self) -> implIterator<Item = PaintedText<'d>>;pubfntext(&self,text:&str) -> Option<PaintedText<'d>>;// the first in paint orderpubfnall(&self,text:&str) -> Vec<PaintedText<'d>>;pubfnshows(&self,text:&str) -> bool;pubfnexpect(&self,text:&str) -> PaintedText<'d>;// panics, listing what was painted}pubstructPaintedText<'d>{/* galley, pos, clip rect, colour */}implPaintedText<'_>{pubfntext(&self) -> &str;pubfnrect(&self) -> Rect;pubfnclip(&self) -> Rect;pubfncolor(&self) -> Color32;pubfngalley(&self) -> &egui::Galley;pubfnrows(&self) -> usize;pubfnelided(&self) -> bool;pubfnpart_rect(&self,part:&str) -> Option<Rect>;// support::part_rect/// One row, not elided, and inside its clip rect: the consumer's `fits`, and #374's predicate.pubfnfits(&self) -> bool;}
Assertions or Option. There is one rule, the one Query already follows:
A plain name (rect, expect, expect_reported, an action on a missing target, settle) is an assertion helper. It panics with #[track_caller] and #[expect(clippy::panic, reason = "an assertion fails the test")], and its message lists the candidates.
find, try_*, text and exists return Option or bool and never panic.
Nothing outside testing panics.
1f. settle with a cap
settle runs frames until nothing asks for an immediate repaint. It stops there or at the cap, whichever comes first.
It reuses kittest's own loop. The driver builds its harness with with_max_steps(cap / step) and calls harness.run_ok(). That call never steps past max_steps (kittest's run, by contrast, runs extra diagnostic frames before it panics).
When run_ok returns None, try_settle returns an error:
The error carries ctx.repaint_causes(). settle panics with:
did not settle within 2s (120 frames of 16.7ms); still repainting: [eggshell_ui::transition at src/transition.rs:…]
So a spinner that animates forever fails in two seconds of clock, saying where the repaint comes from. It never loops.
kittest counts only immediate repaints. A tooltip delay or a toast dwell asks for repaint_after and so ends a settle early. Those waits use advance(Duration), which is what rest_for_tooltip, tooltips::wait and notify::wait do today. The docs say so, with a doctest.
2. How it relates to kittest's Harness
It wraps kittest. It does not sit beside kittest or replace it.
The driver owns a Harness<'static, Stage<A>> built through HarnessBuilder::build_ui_state.
Every event goes through kittest's queue, and every frame through harness.step() / run_steps / run_ok. The driver never calls ctx.run or begin_pass itself, so there is no second event pump.
harness() and harness_mut() stay open, so these keep working unchanged on a driver: kittest's Queryable (get_by_role_and_label(..).click()), the accessibility check, testing::screenshot::render, and kittest's snapshot API.
Headless stays as it is, for layout without input. It and the driver now share PlacedFrame and Query, so a layout test and a behaviour test ask the same questions in the same words.
"Beside" was rejected. Free functions or an extension trait on Harness cannot own the policy (After, the cap, the report guard), cannot hold the frame, and leave every caller to remember full_motion and the step.
"Replace" was rejected. It would reproduce kittest's AccessKit tree and event handling.
The feature.egui_kittest is optional today and Linux-only (screenshots). The driver needs it on every native target and without wgpu, so:
driver = ["dep:egui_kittest"] is added, and the egui_kittest dependency moves out of the Linux-only table.
screenshots keeps egui_kittest/wgpu and its Linux gate.
eggshell's own tests/it enables driver through a dev-dependency on itself (eggshell-ui = { path = ".", features = ["driver"] }). So cargo test needs no flag.
3. Migrating eggshell's own tests
The rule: test outcomes do not change.
Each PR records cargo test --workspace before and after, as the sorted test … ok|FAILED|ignored lines, and diffs them. The diff must be empty.
The 1,618 test names are untouched.
How it stays behaviour-preserving:
The driver's gestures are defined to be eggshell's existing ones. click is support::click_node: a 3-frame hover, press, a frame, release, a frame. drag is support::drag, and lift is the dnd lift.
So a migrated call sends the same events in the same frames.
Each file's private trailing count becomes that file's After::Frames(n). settle (until quiet) is not substituted for a fixed count in the migration.
Where one file used two counts (owned_number: Tab 2, press 8; splitter: Tab 2, press 3), the odd one keeps an explicit .frames(n).
Turning the fixed counts into settle() is a later, separate change. Each test it flips is listed there.
support/mod.rs keeps only what is eggshell-specific:
The things around the view: Bar, Page, Companion and the shadcn apply. They become one support::driver(size, base_text, app, view) -> DriverBuilder<A> built on Driver::frame. The bar's last stop is kept in a shared cell, so past_bar keeps working.
sweep and the rect, ring and mesh paint queries (box_at, ring_at, fill_of, textured, turn).
last_drawn and layout_rect.
What goes away:
From support/mod.rs: the six harness* constructors, both frame_harness*, Rig/FrameRig with their nodes/ids copies, rect_of, id_of, hover_over, hover_node, press_and_release, click_node, press, release, drag, rest_for_tooltip, focused_node, focused_path, full_motion, shapes/flatten/flatten_all, and galley_of/galleys_of/placed_galleys/text_color/part_rect. They move into the driver or Painted.
From the test files, every copy listed in §0, except the domain helpers: open_file, lap, highlighted and others, which are one-line compositions of driver calls and stay as named steps of their file.
Size, estimated from the survey:
About 150 of the 276 helpers and about 1,100 of their 2,500 lines go. The constructors shrink to one support::driver(..) call plus their real setup.
support/mod.rs goes from 704 lines to about 250.
The call sites change mechanically: harness.state().app becomes d.app(), click_node(&mut harness, P) becomes d.click(Target::suffix(P)), and rect_of becomes d.rect(..).
Net about −1,500 lines in tests/it, against about +900 in the library (including its own tests).
Left alone:
snapshots.rs, because its goldens are pixels and regenerating one is an acceptance step.
screenshot.rs, overlay.rs's World/Layers (raw egui areas, not a layout), draw.rs, contract.rs and the fuzz harness. They test below the driver.
Any of them can adopt it later, file by file.
Two behaviour risks are flagged now:
blur_cause.rs:100 sends WindowFocused(false) without setting input.focused. The driver's window_focus sets both, as overlay_input.rs:521 does. If the blur_cause tests change outcome, that file keeps d.event(WindowFocused(false)).
interaction.rs:82 clicks with drag_at/drop_at, not PointerButton events. It keeps that sequence through pointer_down/pointer_up if click's events change any of its outcomes.
A Driver built with Reports::Guarded, the default, runs assert_no_reports when it is dropped. It checks std::thread::panicking() first, so a failing test is not turned into an abort.
A test that expects a report claims it with d.expect_reported(Problem::X), which takes the matching reports. That needs a crate-internal take_reported(ctx, problem) beside take_reports. A test that does not care about reports builds its driver with Reports::Unchecked.
The guard does not check after each settle, as the consumer's rig does. A report raised by a click would then fail the test before the test could claim it.
Drop runs at the end of every test, which gives the same coverage.
Today, 24 tests call assert_no_reports by hand, and those calls go away.
The audit needs what was painted: an overrun of the clip, or text shaved under a point, is only known from the output's clip rects. So it builds on Painted, not on Placed.
Wrap and elision are known from layout too, so the layout-only subset can also answer for Headless.
The proposal is Driver::text_findings() -> Vec<TextFinding>, which joins each PaintedText to its node in PlacedFrame, with PaintedText::fits() as the one predicate. The consumer's fits and the audit then cannot disagree.
PlacedFrame split out of Placed. Its queries are defined once and Placed forwards. draw hands the frame to the LayoutState on request
~250 lines moved, +60
Unchanged; no test changes
B
testing::Driver behind driver: Target/Path, actions, queries, Painted/PaintedText, settle/advance, the report guard. Doctests, plus tests/it/driver.rs, which proves each action through a real view: a click increments, a drag moves a splitter, typing reaches a text_field, select_all, a blur closes a menu, a tooltip opens after advance and not after settle, a forever-spinner fails settle with its cause, a missing target panics with its candidates
~600 lib + ~300 tests
New API only
C
support rebuilt on the driver (reports Unchecked), and the files named in #373 migrated: interaction, commands, blur_cause, choices, hit_route, focus, numbers, owned, owned_choice, owned_number, prims, form_demo, hello, value_widgets, toggle_group, swatch_picker, splitter, slider_header, table, vlist_nav
The rest, mostly constructor swaps, and the old support constructors deleted
−600 / +400
Outcomes unchanged (diffed)
F
The report guard on for eggshell's own tests. Every test that then fails is listed with its report and either fixed or given expect_reported
small
An intended behaviour change, enumerated
#374 follows B and can run in parallel with C to E.
Breaking changes: none.
The public methods of Placed keep their signatures, and draw is unchanged.
driver is an added feature. Moving egui_kittest out of the Linux-only table changes no default build.
This touches no UI, so there is nothing for you to try by hand. The consumer's 338-line rig can move onto the driver once B is released.
Questions
Feature or always on? One choice is an opt-in driver feature that a consumer enables in its dev-dependencies. The other is making egui_kittest a plain dependency, so testing::Driver is always there. Recommendation: the driver feature. It keeps kittest and accesskit_consumer out of release builds. It is the same shape as screenshots.
What runs after an action? One choice is a policy on the driver (After::Settle by default, After::Frames(n) to change it). The other is explicit chaining at each call (d.click(x).settle()), with actions running only their event frames. Recommendation: the policy. The consumer's rig settles implicitly, and every eggshell helper embeds a count. Explicit chaining makes "forgot to settle" a silent mid-state read.
The report guard (testing: a harness guard that asserts no reports on drop #301) on by default in the driver, with expect_reported / Reports::Unchecked to opt out, and turned on for eggshell's own tests in its own PR (F). Recommendation: yes, to both.
The default step.Recommendation: 1/60 s, a real frame, at which double clicks work. kittest's 0.25 s breaks double clicks, and the rig's 0.05 s is arbitrary. eggshell's own tests pass the rig's 0.05 s explicitly to keep outcomes.
The default motion.Recommendation: Animation::Full, as an app runs and as the rig does. kittest's zero means reduced motion.
Path-suffix strings. The consumer addresses nodes by suffix. Recommendation: offer Target::suffix with uniqueness enforced, but use typed d.path(K).at(..) in the docs and in eggshell's own new tests. Suffixes are what the migration maps rect_of("…") onto.
The name of the closure-free frame.Recommendation: PlacedFrame. The alternatives are Frame, which reads as egui::Frame in egui code, and Scene.
Activity
samitbasu commentedon Nov 18, 2026
Design note:
testing::DriverRead against
origin/mainat 62fc13a (after #375). This is a note only: no code and no PR. The consumer is not named.0. The survey: what the driver replaces
tests/it/support/mod.rs(704 lines): the shared rigRig<A>LayoutState, view fn,Barcompanion,Page,ReducedMotion, and the last frame copied out asnodes: Vec<(String, Rect)>andids: Vec<(String, Id)>(277–285), plus anobservehookharness,harness_prepared,harness_stepped,harness_scaled_stepped,harness_scaled,harness_timedfull_motion, runsprepare, paints the page, shows the bar, then builds, lays out and draws. The step is 0.05 s and the accessibility check is onFrameRig,frame_harness,frame_harness_scaledrecordonfull_motionanimation_time, which kittest sets to zeropast_barrect_of,id_ofhover_overhover_at, then 3 framespress_and_releaseclick_noderect_ofcentre,hover_over,press_and_releasehover_nodepress,releasedragdrag_at, then the midpoint,toanddrop_at, one frame each, then 3 framesrest_for_tooltipfocused_node,focused_pathfocus_withinholds, or the node path, or<widget>shapes,flatten,flatten_allgalley_of,galleys_of,placed_galleys,text_color,part_rect,section_offill_of,box_at,ring_at,textured,turnsweeplast_drawn,layout_rectPrivate copies in the test files
Each one is a
kittestprimitive followed by a hard-coded number of frames. The numbers differ from file to file.choices.rs:134,commands.rs:270(with modifiers),mount.rs:225(with modifiers),numbers.rs:45.settle:menu.rs:123,select.rs:134.modal.rs:46(press_key, viasettle).overlay_input.rs:922.owned_number.rs:115andvlist_nav.rs:85run 8,slider_header.rs:104runs 6,splitter.rs:151runs 3 (with modifiers),swatch_picker.rs:37runs 5,table.rs:160runs 3.choices.rs:139,menu.rs:421,modal.rs:215,numbers.rs:34,overlay_input.rs:803,owned_choice.rs:113,owned_number.rs:104,select.rs:159,splitter.rs:140.table.rs:179(tab_in),modal.rs:418(tab_into),swatch_picker.rs:42(tab_to_trigger),focus.rs:56andmodal.rs:541(tab),form_demo.rs:61(tab_stops).settlethat runs a fixed number of frames. None of them waits for quiet:menu.rs:119,select.rs:130.modal.rs:36,table.rs:156.overlay_input.rs:342runs 4,ports.rs:26runs 3,chat_shell_demo.rs:663runs 10,tooltips.rs:1153runs delay plus grace.tooltips.rs:74(wait(Duration)) and the in-flightnotify.rs:111(Extras: notify, transient toasts and a persistent notice stack #382) both turn aDurationinto frames.tooltips.rs:465(run_while_repainting) steps while a repaint is requested, up to a time limit.owned.rs:89(move_away) moves the pointer off, then runs 12 frames.hover_overpluspress_and_releaseplus N frames:interaction.rs:82takes(x, y)and usesdrag_at/drop_at.mount.rs:863andmount.rs:869(click_onby path suffix).modal.rs:40andoverlay_input.rs:346(click_at), then settle.overlay_input.rs:1259andoverlay.rs:498run no hover frames.owned_choice.rs:607,toggle_group.rs:105(by label),value_widgets.rs:79(click_nodeplus 12 frames).menu.rs:152(secondary_click),slider_header.rs:232(click_twiceapart: Duration),owned.rs:559(press_at, press only),interaction.rs:76(hover).prims.rs:97,modal.rs:205(asserts the precondition). Focus by request:hit_route.rs:471(request_focus, asserts the precondition).Event::Text, then N frames:form_demo.rs:48,hello.rs:34.prims.rs:92runs 2,slider_header.rs:99runs 4.hello.rs:282andform_demo.rs:54(fill).blur_cause.rs:84(typing),field_focus.rs:63(typing),commands.rs:279(start_typing).dnd_gallery.rs:103,dnd_reorder.rs:66.dnd_preview.rs:135,layout_dnd.rs:75.dnd_zones.rs:70.dnd_gallery.rs:953(lift_from).drop_at:dnd_handle.rs:167(press_and_move) withdnd_handle.rs:180(release),splitter.rs:125/135, andoverlay.rs:513(drag, a copy ofsupport::drag).dnd_gallery.rs:115(pointer_to),dnd_reorder.rs:78(move_to_row).overlay_input.rs:521(window_focus(bool)) setsinput.focused, sendsWindowFocusedand asserts the precondition.blur_cause.rs:100(blur_the_window) only sends the event.modal.rs:51,mount.rs:1030,chat_shell_demo.rs:969.hit_route.rs:192,markdown.rs:270.dnd_gallery.rs:147/157anddnd_zones.rs:81/91(hover_files/drop_files, two identical copies).Rig::nodes.has:menu.rs:128,select.rs:139,overlay.rs:1213,clipboard_example.rs:37,collapsible.rs:119.mount.rs:852(rect_at, unique) anddnd_zones.rs:47(find, through the continuity timeline).notify.rsshown.rect,centreandrow_recthelpers.tooltips.rs:100(painted) andowned_number.rs:587(shows) are the same function. Others:hello.rs:39(painted_text, all texts),prims.rs:456,widgets.rs:90.tooltips.rs:546(galley_of, a third copy),spans.rs:106.tooltips.rs:88/1146/1302(is_shown,tip_painted,is_shown_in).support::harness*. Most add size, base text, a firstrun_steps(2..4), and sometimes a styleprepare. 16 files build their ownHarness::builder():overlay.rs(World),interaction.rs,blur_cause.rs,select.rs,snapshots.rs,draw.rsand others.Size. In all there are 276 helper functions and about 2,500 lines:
The call sites:
click_node311,rect_of650,focused_path133run_steps1,074,key_press211,hover_at138harness.state().app710#[test]functions: 1,618What the survey shows:
Rigcopies the frame out as(path, rect)and(path, id)lists becausePlaced::draw(self)consumes the frame. Sohas,rect_of, the suffix finds and the focus lookups are all written against that copy and not againstQuery.The consumer's rig (338 lines, 26 tests), mapped to the driver
click(path_suffix)click(Target::suffix(..)), orclick(d.path(K).at(..))with typed keysdrag(from, to)drag(from, to)type_texttype_textpress(chord),keypress(impl Into<Press>), which takes aKey, aKeyboardShortcutor aChordselect_allselect_all()window_focus(bool)window_focus(WindowFocus::Blurred)rect(Target),find(Target),frame().at(..)painted,shows,fitspainted().text(..),painted().shows(..),PaintedText::fits()settle()settle(), with a cap1. The
DriverAPI1a. The prerequisite: a frame that outlives its draw
Placed<A>holds two kinds of thing. Its query data (nodes,by_id, prims, roots, root, the kept handle and the ctx) has no closures. Its draw, drag, dismiss and window closures do.draw(self, ..)drops both.The query data moves into a new public type,
testing::PlacedFrame:Placed<A>holds aPlacedFramebeside its closures.Placedhas today (at,try_at,overlay(s),expect_overlay,menu_open(_with),diff,overflowing,node,rect,nodes,shell) is defined once onPlacedFrame.Placed<A>forwards to it.Query<'p>already reads only nodes, prims andby_id, so it is unchanged.When a driver asks for it,
drawmoves the frame into theLayoutState's kept slot instead of dropping it. Nothing is cloned, and a normal frame pays nothing.This removes the reason
Rigkeeps its own copy.Headless, the driver and a frame-drawing closure then answer through the sameQuery.1b. Construction
The clock. egui moves
input.timeforward bypredicted_dteach frame, and kittest setspredicted_dtto itsstep_dt, so frame n is at n × step on every run. The driver takes aDurationand converts it to kittest'sf32seconds only where it callswith_step_dt. It never callstry_run_realtime, which would sleep.The defaults match how an app runs rather than kittest's defaults. kittest zeroes
animation_time, which eggshell reads as reduced motion. Its 0.25 s step breaks double clicks. Itsmax_stepsof 4 panics on any transition.1c. Addressing a node
A target is resolved against the last frame when the action runs.
Query::at's: the path asked for, then what exists below the deepest step found. A path walks the frame throughQuery, so the message is the same text.Target::Rolereuses kittest's AccessKit query and its "more than one match" panic. It does not search the AccessKit tree a second time.1d. Actions
Each action queues its events with kittest's own methods (
hover_at,drag_at,drop_at,event,key_press_modifiers). It runs one frame per event throughharness.step(), then applies the driver'sAfterpolicy. Every action returns&mut Self, so actions chain.presstakesInto<Press>. AChordrefuses a bare Esc or Enter on purpose (commands.rs:150), and tests press those keys constantly, sopressalso takes a plainKeyandKeyboardShortcut. The type system stays honest: it does not invent chords.1e. Queries
Assertions or
Option. There is one rule, the oneQueryalready follows:rect,expect,expect_reported, an action on a missing target,settle) is an assertion helper. It panics with#[track_caller]and#[expect(clippy::panic, reason = "an assertion fails the test")], and its message lists the candidates.find,try_*,textandexistsreturnOptionorbooland never panic.testingpanics.1f.
settlewith a capsettleruns frames until nothing asks for an immediate repaint. It stops there or at the cap, whichever comes first.It reuses kittest's own loop. The driver builds its harness with
with_max_steps(cap / step)and callsharness.run_ok(). That call never steps pastmax_steps(kittest'srun, by contrast, runs extra diagnostic frames before it panics).When
run_okreturnsNone,try_settlereturns an error:The error carries
ctx.repaint_causes().settlepanics with:So a spinner that animates forever fails in two seconds of clock, saying where the repaint comes from. It never loops.
kittest counts only immediate repaints. A tooltip delay or a toast dwell asks for
repaint_afterand so ends a settle early. Those waits useadvance(Duration), which is whatrest_for_tooltip,tooltips::waitandnotify::waitdo today. The docs say so, with a doctest.2. How it relates to kittest's
HarnessIt wraps kittest. It does not sit beside kittest or replace it.
Harness<'static, Stage<A>>built throughHarnessBuilder::build_ui_state.harness.step()/run_steps/run_ok. The driver never callsctx.runorbegin_passitself, so there is no second event pump.harness()andharness_mut()stay open, so these keep working unchanged on a driver: kittest'sQueryable(get_by_role_and_label(..).click()), the accessibility check,testing::screenshot::render, and kittest's snapshot API.Headlessstays as it is, for layout without input. It and the driver now sharePlacedFrameandQuery, so a layout test and a behaviour test ask the same questions in the same words."Beside" was rejected. Free functions or an extension trait on
Harnesscannot own the policy (After, the cap, the report guard), cannot hold the frame, and leave every caller to rememberfull_motionand the step."Replace" was rejected. It would reproduce kittest's AccessKit tree and event handling.
The feature.
egui_kittestis optional today and Linux-only (screenshots). The driver needs it on every native target and without wgpu, so:driver = ["dep:egui_kittest"]is added, and theegui_kittestdependency moves out of the Linux-only table.screenshotskeepsegui_kittest/wgpuand its Linux gate.tests/itenablesdriverthrough a dev-dependency on itself (eggshell-ui = { path = ".", features = ["driver"] }). Socargo testneeds no flag.3. Migrating eggshell's own tests
The rule: test outcomes do not change.
cargo test --workspacebefore and after, as the sortedtest … ok|FAILED|ignoredlines, and diffs them. The diff must be empty.How it stays behaviour-preserving:
clickissupport::click_node: a 3-frame hover, press, a frame, release, a frame.dragissupport::drag, andliftis the dnd lift.After::Frames(n).settle(until quiet) is not substituted for a fixed count in the migration.owned_number: Tab 2, press 8;splitter: Tab 2, press 3), the odd one keeps an explicit.frames(n).settle()is a later, separate change. Each test it flips is listed there.support/mod.rskeeps only what is eggshell-specific:Bar,Page,Companionand the shadcn apply. They become onesupport::driver(size, base_text, app, view) -> DriverBuilder<A>built onDriver::frame. The bar's last stop is kept in a shared cell, sopast_barkeeps working.sweepand the rect, ring and mesh paint queries (box_at,ring_at,fill_of,textured,turn).last_drawnandlayout_rect.What goes away:
support/mod.rs: the sixharness*constructors, bothframe_harness*,Rig/FrameRigwith theirnodes/idscopies,rect_of,id_of,hover_over,hover_node,press_and_release,click_node,press,release,drag,rest_for_tooltip,focused_node,focused_path,full_motion,shapes/flatten/flatten_all, andgalley_of/galleys_of/placed_galleys/text_color/part_rect. They move into the driver orPainted.open_file,lap,highlightedand others, which are one-line compositions of driver calls and stay as named steps of their file.Size, estimated from the survey:
support::driver(..)call plus their real setup.support/mod.rsgoes from 704 lines to about 250.harness.state().appbecomesd.app(),click_node(&mut harness, P)becomesd.click(Target::suffix(P)), andrect_ofbecomesd.rect(..).tests/it, against about +900 in the library (including its own tests).Left alone:
snapshots.rs, because its goldens are pixels and regenerating one is an acceptance step.screenshot.rs,overlay.rs'sWorld/Layers(raw egui areas, not a layout),draw.rs,contract.rsand thefuzzharness. They test below the driver.Two behaviour risks are flagged now:
blur_cause.rs:100sendsWindowFocused(false)without settinginput.focused. The driver'swindow_focussets both, asoverlay_input.rs:521does. If the blur_cause tests change outcome, that file keepsd.event(WindowFocused(false)).interaction.rs:82clicks withdrag_at/drop_at, notPointerButtonevents. It keeps that sequence throughpointer_down/pointer_upifclick's events change any of its outcomes.4. What builds on it
#301, the report guard.
Driverbuilt withReports::Guarded, the default, runsassert_no_reportswhen it is dropped. It checksstd::thread::panicking()first, so a failing test is not turned into an abort.d.expect_reported(Problem::X), which takes the matching reports. That needs a crate-internaltake_reported(ctx, problem)besidetake_reports. A test that does not care about reports builds its driver withReports::Unchecked.assert_no_reportsby hand, and those calls go away.#374, the text audit.
Painted, not onPlaced.Headless.Driver::text_findings() -> Vec<TextFinding>, which joins eachPaintedTextto its node inPlacedFrame, withPaintedText::fits()as the one predicate. The consumer'sfitsand the audit then cannot disagree.for theme { for size { d.set_theme(t).resize(s).settle(); findings.extend(d.text_findings()) } }. It reports and does not fail, as Text audit: Placed::text_findings() for wrapped, clipped or elided text #374 says.5. The PR split
PlacedFramesplit out ofPlaced. Its queries are defined once andPlacedforwards.drawhands the frame to theLayoutStateon requesttesting::Driverbehinddriver:Target/Path, actions, queries,Painted/PaintedText,settle/advance, the report guard. Doctests, plustests/it/driver.rs, which proves each action through a real view: a click increments, a drag moves a splitter, typing reaches atext_field,select_all, a blur closes a menu, a tooltip opens afteradvanceand not aftersettle, a forever-spinner failssettlewith its cause, a missing target panics with its candidatessupportrebuilt on the driver (reportsUnchecked), and the files named in #373 migrated: interaction, commands, blur_cause, choices, hit_route, focus, numbers, owned, owned_choice, owned_number, prims, form_demo, hello, value_widgets, toggle_group, swatch_picker, splitter, slider_header, table, vlist_navsupportconstructors deletedexpect_reported#374 follows B and can run in parallel with C to E.
Breaking changes: none.
Placedkeep their signatures, anddrawis unchanged.driveris an added feature. Movingegui_kittestout of the Linux-only table changes no default build.This touches no UI, so there is nothing for you to try by hand. The consumer's 338-line rig can move onto the driver once B is released.
Questions
driverfeature that a consumer enables in its dev-dependencies. The other is makingegui_kittesta plain dependency, sotesting::Driveris always there. Recommendation: thedriverfeature. It keeps kittest and accesskit_consumer out of release builds. It is the same shape asscreenshots.After::Settleby default,After::Frames(n)to change it). The other is explicit chaining at each call (d.click(x).settle()), with actions running only their event frames. Recommendation: the policy. The consumer's rig settles implicitly, and every eggshell helper embeds a count. Explicit chaining makes "forgot to settle" a silent mid-state read.expect_reported/Reports::Uncheckedto opt out, and turned on for eggshell's own tests in its own PR (F). Recommendation: yes, to both.Animation::Full, as an app runs and as the rig does. kittest's zero means reduced motion.Placed::text_findings(). Recommendation:Driver::text_findings(), because clip overruns are only known from paint, with a layout-only subset onPlacedforHeadless.Target::suffixwith uniqueness enforced, but use typedd.path(K).at(..)in the docs and in eggshell's own new tests. Suffixes are what the migration mapsrect_of("…")onto.PlacedFrame. The alternatives areFrame, which reads asegui::Framein egui code, andScene.samitbasu commentedon Nov 18, 2026
Decisions (user, 2026-11-18):
driverfeature; eggshell's tests enable it via a dev-dependency.advance(Duration).PlacedFramefirst; a 1/60 s step; full motion;Driver::text_findings()for Text audit: Placed::text_findings() for wrapped, clipped or elided text #374; unique path-suffix targets, with typed paths documented first; migration with test outcomes diffed before and after.Merge pull request #408 from samitbasu/driver-373a
Merge pull request #413 from samitbasu/driver-373b
Merge pull request #429 from samitbasu/driver-373c
Merge pull request #430 from samitbasu/driver-373d
Merge pull request #431 from samitbasu/driver-373e
Merge pull request #437 from samitbasu/driver-373f