Repository navigation
bullseye::testing: headless layout, key-path queries and layout diff (#68) - #70
Merged
Merged
Conversation
…68) Unit tests could not read a computed layout without hand-building a context, hashing ids by hand and matching nodes between two layouts. Headless owns an egui Context, runs the prepare closures once, then one warm-up pass so fonts exist (set_fonts applies on the next pass), then each layout call is one pass that builds and lays out without drawing, at the given size, base text and theme. Placed::at / Query::at chain keys through the builder's own child_id, so ids cannot disagree; a missing node panics (track_caller) with the readable path and the nearest existing children. Query::text finds a unique text node by content via the placed primitives. Placed::diff matches identified nodes by id and anonymous ones by path and reports exact border-box differences, with None for a side that lacks the node. Always compiled (egui only, no new dependencies), no feature needed. No behaviour change to existing code; Placed.by_id becomes crate-visible. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01PWiKKe8zfqGfVMCSC5L3up
Covers parity with the support harness, id agreement with the builder, missing-node panics, text lookup, diff, prepare fonts and theme. The toggle-card test guards that choosing an item changes only its check; without flex_none on the w_px sample it reports the sample and the name as moved. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01PWiKKe8zfqGfVMCSC5L3up
…#68) Placed<A> does not borrow the Headless, so &mut self serves every test pattern, including laying out twice and diffing. The queued prepare closures and the warm flag become plain fields, drained on the first layout. Order is unchanged: theme set, prepare run, one warm-up pass. Adds a doc example on Headless itself. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01PWiKKe8zfqGfVMCSC5L3up
This was referenced Nov 10, 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.
Closes #68, requested by the user so CI can catch layout bugs like the reference shell's Lettering card. When chosen, its bold name and check overflowed the card, the
w_px(34)sample shrank (flex-shrink: 1), and the name moved left.Shape (decided in #68)
.at(key)only, with no macro (user's choice). It hashes with the builder's ownchild_id, so ids can't drift. It passes throughscopekeys.#[track_caller]panics name the requested path and the children that exist there..text(..)reads the text the layout already records. Zero or several matches panic and list the candidates.diffmatches identified nodes by id and anonymous nodes by path and occurrence. Rects compare exactly, because layout is exact and only drawing rounds.Headlessowns its eguiContext. On the firstlayoutit sets the theme, runs the queuedprepareclosures, and runs one warm-up pass so fonts set byprepareapply. Eachlayoutis one pass that builds and lays out.pub mod testingis always compiled and adds no dependencies, so downstream crates' tests can use it.Tests
tests/it/headless.rshas 14 tests:athashing matches the builder;try_at;textwith unique, zero and duplicate matches;diff: identical layouts, a changed node, pushed siblings, a node present in only one layout;preparefonts change measured widths;The regression,
choosing_a_card_changes_only_its_check, was verified to fail withoutflex_none()on the sample:With
flex_none(), only the check changes, in both directions. The test asserts its own precondition: the chosen card really overflows.This is test tooling with no UI change, so there's nothing to try. All goldens are unchanged, and
cargo xtask ciis green.🤖 Generated with Claude Code
https://claude.ai/code/session_01PWiKKe8zfqGfVMCSC5L3up