Skip to content

Commit 3037116

Browse files
fix(selftest): pump-until guard for GotFocus_FiresOnA (#182)
The fixed two-pump guard added in #152 (and the same shape applied in #139/#149 for TabView/RadioButtons/PasswordBox) still flaked at ~0.3% across a 1000x sweep — 2 hits in 651 runs, both on `GotFocus_FiresOnA`. The number of dispatcher ticks before programmatic Focus() raises GotFocus isn't bounded, so any fixed pump count is a guess. Replace the fixed pumps with a pump-until-counter-updates loop, capped at 10 iterations (~200ms) to fail fast if the event genuinely never fires. Applied to both focus transitions in the fixture. Co-authored-by: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
1 parent 939d7ab commit 3037116

1 file changed

Lines changed: 8 additions & 7 deletions

File tree

tests/Reactor.AppTests.Host/SelfTest/Fixtures/PointerModifierFixtures.cs

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -127,16 +127,17 @@ public override async Task RunAsync()
127127
H.Check("GotLostFocus_ControlsFound", tbA is not null && tbB is not null);
128128

129129
tbA?.Focus(FocusState.Programmatic);
130-
// GotFocus can be raised via the dispatcher rather than synchronously
131-
// in Focus() (same shape as the TabView/RadioButtons/PasswordBox flake
132-
// fixed in #139/#149). Pump twice so the queued event lands.
133-
await Harness.Render();
134-
await Harness.Render();
130+
// GotFocus is raised via the dispatcher, and the number of ticks
131+
// before it lands isn't bounded — a fixed two-pump guard (#152)
132+
// still flaked at ~0.3% across a 1000x sweep. Pump until the
133+
// counter updates instead of guessing a count.
134+
for (int i = 0; i < 10 && gotA == 0; i++)
135+
await Harness.Render();
135136
H.Check("GotFocus_FiresOnA", gotA == 1 && lostA == 0);
136137

137138
tbB?.Focus(FocusState.Programmatic);
138-
await Harness.Render();
139-
await Harness.Render();
139+
for (int i = 0; i < 10 && gotB == 0; i++)
140+
await Harness.Render();
140141
H.Check("LostFocus_FiresOnA", lostA == 1);
141142
H.Check("GotFocus_FiresOnB", gotB == 1);
142143
}

0 commit comments

Comments
 (0)