From b5bfa1d29d72c593ea6609bfdf3e6c61667b5024 Mon Sep 17 00:00:00 2001 From: FredApps Date: Fri, 20 Nov 2026 00:44:13 +0100 Subject: [PATCH] Verify focus lookup after replaying a recorded stop --- crates/ui-contract/src/testing/replay_trials.rs | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/crates/ui-contract/src/testing/replay_trials.rs b/crates/ui-contract/src/testing/replay_trials.rs index 83eb6fa477..4ffd1f52c3 100644 --- a/crates/ui-contract/src/testing/replay_trials.rs +++ b/crates/ui-contract/src/testing/replay_trials.rs @@ -90,6 +90,21 @@ fn a_transcript_with_one_changed_stop_compares_unequal() { assert_ne!(first.focus, changed.focus, "the second stop's keys changed"); } +#[trial] +fn replayed_focus_stops_keep_their_own_target() { + let mut frames = Frames::new(); + let parent = fixture::named_id("parent"); + let child = fixture::named_id("child"); + let recorded = record(&mut frames, |ctx| focus::register_stop(ctx, Stop::new(child, KeyUse::CODE))); + frames.frame(Vec::new(), |ui| { + let ctx = ui.ctx(); + let from = focus::stop_count(ctx); + focus::replay(ctx, &recorded.focus); + assert_eq!(focus::first_stop_inside(ctx, parent, from), Some(focus::FocusTarget::Id(child))); + assert_eq!(focus::first_stop_inside(ctx, child, from), None); + }); +} + /// Records `stops` run inside a record, with `entering` the first-pass flag of the layer scope it pushes, inside the /// scope `outer` when one is given. fn layer_scope_record(frames: &mut Frames, outer: Option, entering: bool) -> replay::Record {