Skip to content

Harden WPF/WinUI3 integration fixtures against CI readiness races#36

Merged
asklar merged 1 commit into
mainfrom
fix/harden-injection-test-fixtures
Jul 9, 2026
Merged

Harden WPF/WinUI3 integration fixtures against CI readiness races#36
asklar merged 1 commit into
mainfrom
fix/harden-injection-test-fixtures

Conversation

@asklar

@asklar asklar commented Jul 9, 2026

Copy link
Copy Markdown
Owner

Problem

WpfSampleFixture.DurableKeyContract failed on CI (it passed on #32's own CI run, so it's flaky):

integration_tests.cpp: Expected: (okButton) != (nullptr), actual: NULL
[  FAILED  ] WpfSampleFixture.DurableKeyContract

WPF/WinUI3 tree collection injects a managed walker and completes asynchronously (issue #27). The fixtures polled for readiness in SetUp, but their test bodies dumped the tree again and asserted directly — an individual dump can race and return an incomplete (Win32-only) tree on slow/CI machines, so the managed name properties (e.g. OkButton) are missing that run.

This surfaced as a red CI on PR #33, even though #33's Avalonia change is unrelated (its fixture already uses the robust pattern).

Fix

Add retry helpers and use them in the two vulnerable fixtures:

  • dump_ready_tree(...) — re-issues the dump until the framework subtree + expected named control are present.
  • query_element_until(...) / query_prop_until(...) — retry --query until it resolves.

WpfSampleFixture and WinUI3SampleFixture now retry each body dump/query until complete, then assert. Deterministic under CI.

Not affected: Avalonia fixture already captures a validated initialDump_ in SetUp; ComCtl targets a synchronous in-process HWND.

Validation

  • Full cmake --build build green.
  • lvt_integration_tests.exe --gtest_filter=WpfSampleFixture.*:WinUI3SampleFixture.* passes locally. (Local injection is reliable, so the flake only reproduces on CI; the fix is by-design + CI will confirm.)

Relates to #27.

WpfSampleFixture and WinUI3SampleFixture dumped the tree twice in the test body
and asserted directly on the result. Because WPF/WinUI3 tree collection injects a
walker and completes asynchronously (issue #27), an individual dump can race and
return an incomplete tree on slow/CI machines -- e.g. WpfSampleFixture.DurableKeyContract
intermittently failed on CI with `okButton == nullptr` (the managed WPF names were
missing that run), even though the fixture's SetUp readiness poll had succeeded.

Add retry helpers (dump_ready_tree / query_element_until / query_prop_until) that
re-issue the dump/query until the framework subtree (and the expected named control)
is present, then assert. Makes both fixtures deterministic under CI. The Avalonia
fixture already used the robust pattern (validated initialDump_ captured in SetUp),
and the ComCtl fixture targets a synchronous in-process HWND, so neither is affected.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
@asklar asklar merged commit 16e0855 into main Jul 9, 2026
1 check passed
@asklar asklar deleted the fix/harden-injection-test-fixtures branch July 9, 2026 06:19
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant