Repository navigation
testing: Driver, an interactive test driver behind the driver feature (#373, PR B) - #413
Merged
Merged
Conversation
…re (#373, PR B) eggshell's tests and its consumers each carry private copies of the same helpers: click a node by path, press a key and run N frames, type, drag, wait for a tooltip, read painted text. `testing::Driver` is that surface once, as the design note on #373 lays out and the user decided: - It wraps kittest's `Harness`: every event goes through the harness's queue and every frame through its step, so there is no second event pump, and `harness()` stays open for kittest's queries. - Targets: a typed `Path` (`d.path(K).at(..)`), a unique path suffix, role and name (through kittest), text, `Id`, a point. A miss fails with `Query::at`'s message; a pointer action fails on a point outside the window. - Actions: click, click_with, double_click, hover, drag, lift, carry_to, pointer_down/up, wheel, press (`Key`, `KeyboardShortcut` or `Chord`), type_text, select_all, tab_to, window_focus, hover/drop_files, resize, set_theme, focus, event. Each runs a frame per event, then the driver's `After` policy: settle by default, or a fixed frame count. - `settle` runs kittest's `run_ok` with the cap as `max_steps`, and fails naming the repaint causes; `advance(Duration)` waits on the clock. - Queries: the last frame drawn (`PlacedFrame`, kept through PR A's hand-off), `rect`/`find`/`exists`, `focused`, `painted()` with `PaintedText::fits`, and `text_findings()` (#374), which joins each painted text that does not fit to the node that shows it. - The report guard (#301): a driver checks on drop, unless the thread is already panicking, that the view reported nothing it did not claim with `expect_reported`; `Reports::Unchecked` opts out. Defaults are an app's, not kittest's: a 1/60 s step, full motion, a 2 s settle cap. `egui_kittest` moves out of the Linux-only table as an optional dependency; `driver` enables it, and eggshell's own tests enable it through a dev-dependency on the crate itself, so `cargo test` needs no flag. `screenshots` keeps its Linux gate. Deviations from the note: the constructor for a view that draws the whole frame is `Driver::whole_frame`, since `Driver::frame` is the query; `expect_reported` claims the problem for the driver's life rather than taking the report, because a misuse reported every frame would come back the next frame; `Focused::Widget` carries `within: Option<String>`, since a widget outside every node holds no path; `Driver::set_motion` is added for tests that switch motion off mid-run. No behaviour change to existing tests; new API only. Part of #373. Fixes #301. Fixes #374. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01PWiKKe8zfqGfVMCSC5L3up
… PaintedText::pos, galley borrowed from the frame A held drag, a move or a release may go past the window's edge, as a real one does; only a press must land on a point egui does not clip. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01PWiKKe8zfqGfVMCSC5L3up
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01PWiKKe8zfqGfVMCSC5L3up
…s egui's trait asks there Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01PWiKKe8zfqGfVMCSC5L3up
…nswers #408 landed with Placed::draw answering its PlacedFrame, and without the keep_frames / take_frame hand-over this branch was built on. The driver now stores the frame its draw closure answers: Driver::whole_frame's closure answers the frame its layout's draw answered, and Driver::new's does so for the view. LayoutState::scope, which only the hand-over used, is gone with it. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01LesfK54UWq1haPSEr9X22o
Owner
Author
|
Approved by the user on its tests, including the whole_frame closure returning the PlacedFrame after #408 (2026-11-19). GitHub's required checks pass on the branch merged with current main. Merging. |
This was referenced Nov 19, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Part of #373 (PR B of the split in the design note). Fixes #301. Fixes #374.
Built on #408 (PR A), now merged.
What
testing::Driver, behind a new opt-indriverfeature. It implements the note's §1, with the user's decisions on #373.Driver::new(app, view)takes a view.Driver::whole_frame(app, frame)takes a frame that draws itself. Its closure answers thePlacedFrameits layout'sPlaced::draw(..)answered, and the driver keeps it for its queries.size,theme,pixels_per_point,step(default 1/60 s),motion(defaultAnimation::Full),base_text,setup,after(defaultAfter::Settle),settle_within(default 2 s),reports(defaultReports::Guarded) andwith_harness.Harness: every event goes throughharness.event, and every frame throughstep/run_steps/run_ok.harness()andharness_mut()stay open.Path:d.path(K).at(..)hashes each key as the builder does and borrows nothing.Target::suffix: exactly one node must match, and a whole path wins over the paths it ends.Target::role(role, name), through kittest's query.Target::text, asQuery::text.Id, or a point.Query::at's message. A press outside the window panics with the target's rect.Afterpolicy:click,click_with,double_click,hover,drag,lift,carry_to,pointer_down/pointer_up,wheel;press(aKey,KeyboardShortcutorChord),type_text,select_all,tab_to;window_focus,hover_files/drop_files,resize,set_theme;focus,event.settleruns kittest'srun_ok, with the cap asmax_steps. Past the cap it panics with the repaint causes:did not settle within …; still repainting: [file:line …].try_settlereturnsUnsettled { frames, clock, causes }instead.advance(Duration)andframes(n)run frames.now()is the time since the driver was built.frame()is the lastPlacedFramedrawn, kept through testing: split a closure-free PlacedFrame out of Placed (#373, PR A) #408's hand-off.rect/find/existsanswer for a target.focused()returnsFocused::Node(path)orFocused::Widget { within }.painted()lists the texts drawn:text,all,shows,expect. EachPaintedTextgivesrect,clip,color,galley,pos,rows,elided,part_rectandfits.Reports::Guardeddriver asserts, when dropped, that the view reported nothing it did not claim. It skips the check while the thread is panicking.expect_reported(problem)returns the report and claims that problem for the driver's life.Reports::Uncheckedturns the check off.text_findings()(Text audit: Placed::text_findings() for wrapped, clipped or elided text #374). Each painted text that does notfit(it wraps, is elided, or overruns its clip), joined to the node that shows it. It reports and does not fail.#[track_caller]and carry#[expect(clippy::panic, reason = "an assertion fails the test")].find,try_*andexistsnever panic.Cargo
driver = ["dep:egui_kittest"].egui_kittestmoves out of the Linux-only table as an optional dependency.screenshotskeepsegui_kittest/wgpuand its Linux gate.driverthrough a dev-dependency on the crate itself (eggshell-ui = { path = ".", features = ["driver"] }), socargo testneeds no flag.Deviations from the note, each for a reason
Driver::whole_frame.Driver::frameis taken by the query, and Rust has no overloading.expect_reportedclaims the problem rather than taking the report. A misuse reported every frame comes back as a new report in the next frame, and a take would let it fail the guard.Focused::Widget { within: Option<String> }: a widget outside every node has no path.Driver::set_motion, for tests that switch motion off mid-run;Driver::layout(), for a test clipboard andtracked_layout_nodes;PaintedText::pos().Update after #408's rework
#408 merged with
Placed::draw(..)answering itsPlacedFrame, as the user asked, in place of thekeep_frames/take_framehand-over this PR was first built on. Main is merged in, and the driver follows:Driver::whole_frame's closure now answers the frame (FnMut(&mut Ui, &mut A, &mut LayoutState) -> PlacedFrame). Before, it answered nothing and the driver took the frame from the hand-over. This changes the approved API, for you to check. A whole-frame closure ends with its layout's.draw(app, ui).Driver::new's closure answers its view's frame the same way.Driver::frame's panic doc now says only "no frame drawn yet", which the first frame ofbuildrules out.LayoutState::scopegoes, because only the hand-over used it.pipeline.rs, was that accessor.Checks
tests/it/driver.rsproves each action through a real view:text_field, andselect_allreplaces the text;tab_toreaches a node;advanceand not aftersettle;settle, naming itsrequest_repaintcall site;Uncheckeddriver leaves reports to the test;text_findingsnames the wrapped label;part_rectworks.Drivershow a click and the advance-versus-settle rule for a tooltip.cargo xtask cibefore the merge: exit 0.test … ok|FAILED|ignoredlines before and after: only additions. No existing test changes outcome. Diff againstorigin/main:driver::*tests, all ok;testing::driver::Driverdoctests.cargo test --workspace --no-fail-fastthrough the build queue): 2316 outcomes, none failed. Against this branch before the merge, every difference comes from main:intent::testswith Core: one hover-intent machine for tooltips and hover cards (A of #376) #410;testing::keep_framesdoctest went with testing: split a closure-free PlacedFrame out of Placed (#373, PR A) #408's rework.New public docs are marked
TODO(prose)for your wording.No UI change, so there is nothing to try by hand.
🤖 Generated with Claude Code
https://claude.ai/code/session_01PWiKKe8zfqGfVMCSC5L3up