Skip to content

test: Add regression test for #11914 - #23007

Merged
MartinZikmund merged 3 commits into
masterfrom
dev/mazi/repro/11914
Jul 15, 2026
Merged

MartinZikmund merged 3 commits into
masterfrom
dev/mazi/repro/11914

Conversation

@MartinZikmund

Copy link
Copy Markdown
Member

Summary

Adds regression test(s) for #11914.

The reported issue appears to be potentially fixed — the test(s) pass on current master (Skia target).

Test(s) added

  • src/Uno.UI.RuntimeTests/Tests/Windows_UI_Xaml_Controls/Given_Pivot.cs → When_Pivot_LoadedWithItemsSource_Then_FirstItemContentIsVisible
  • src/Uno.UI.RuntimeTests/Tests/Windows_UI_Xaml_Controls/Given_Pivot.cs → When_Pivot_LoadedWithInlineItems_Then_FirstItemContentVisible

Notes

The issue was reported on Android. Runtime tests run on Skia only — the fix should be verified on native Android targets as well. The bug was in the native Android path (NativePivotPresenter + ViewPager/FragmentPagerAdapter), which is not exercised by the Skia runtime test runner.

Relates to #11914

Copilot AI review requested due to automatic review settings April 10, 2026 08:22

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Adds runtime regression coverage around Pivot initial selection/content materialization to help guard against regressions related to issue #11914 (“Pivot content is not set at once”).

Changes:

  • Add a runtime test validating that, when Pivot.ItemsSource is set, the first item’s content is present immediately after initial load.
  • Add a runtime test validating the same behavior when PivotItems are added inline via Pivot.Items.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

@unodevops

Copy link
Copy Markdown
Contributor

@unodevops

Copy link
Copy Markdown
Contributor

⚠️⚠️ The build 206548 has failed on Uno.UI - CI.

@github-actions

Copy link
Copy Markdown
Contributor

This PR is stale because it has been open 60 days with no activity. Remove stale label or comment or it will be closed in 10 days.

@github-actions github-actions Bot added the stale This item has been marked as stale and will be closed if there is no activity. label Jun 10, 2026
@github-actions

Copy link
Copy Markdown
Contributor

This PR was closed because it has been stalled for 10 days with no activity.

@github-actions github-actions Bot closed this Jun 21, 2026
@MartinZikmund MartinZikmund removed the stale This item has been marked as stale and will be closed if there is no activity. label Jun 22, 2026
@MartinZikmund MartinZikmund reopened this Jun 22, 2026
@github-actions

github-actions Bot commented Jun 22, 2026 •

Copy link
Copy Markdown
Contributor

Claude finished @MartinZikmund's task in 2m 59s —— View job


Review complete

  • Gather context
  • Read changed file
  • Post inline review comments
  • Update summary

Summary

The two new Given_Pivot regression tests for #11914 are well-structured and cover both ItemsSource and inline-Items initialization paths. The [GitHubWorkItem] annotation is correct, and naming follows the When_<Scenario>_Then_<Result> convention. The approach matches the intent of the bug (content not materialized on first load).

Findings: 3 issues (2 medium, 1 minor)

Medium — test flakiness (same pattern in both tests, 4 comments total):

  • ContainerFromIndex(0) is called synchronously right after UITestHelper.Load without any waiting. The existing Check_Binding test in the same file already handles this with WaitFor (line 58). Use WindowHelper.WaitForNonNull(() => SUT.ContainerFromIndex(0) as PivotItem).
  • FindFirstChild<ContentPresenter>() and contentPresenter.Content are likewise asserted without waiting for template application / binding propagation. An extra WaitForNonNull + WaitFor(() => contentPresenter.Content is not null) pair is needed to keep assertions from racing on a slow machine or CI.

Minor — naming inconsistency (1 comment):

  • Second test method is Then_FirstItemContentVisible (missing Is); first test is Then_FirstItemContentIsVisible. Align to Then_FirstItemContentIsVisible.

Cross-cutting note: The PR description correctly flags that the underlying bug (#11914) is Android-specific (NativePivotPresenter / ViewPager) and these Skia-target tests can't reproduce it. The tests still add value as non-regression coverage for the Skia path, but the actual Android fix/verification would require running Uno.UI.RuntimeTests against a native Android target.

@unodevops

Copy link
Copy Markdown
Contributor

@unodevops

Copy link
Copy Markdown
Contributor

⚠️⚠️ The build 219312 has failed on Uno.UI - CI.

@MartinZikmund
MartinZikmund force-pushed the dev/mazi/repro/11914 branch from f72e1d1 to 15177f6 Compare July 13, 2026 08:45
@github-actions

github-actions Bot commented Jul 13, 2026 •

Copy link
Copy Markdown
Contributor

Claude finished @MartinZikmund's task in 1m 39s —— View job


Review complete

  • Gather context
  • Read changed file
  • Post inline review comments
  • Update summary

Summary

The two new Given_Pivot regression tests for #11914 are well-structured and cover both ItemsSource and inline-Items initialization paths. The [GitHubWorkItem] annotation is correct, naming follows When_<Scenario>_Then_<Result>, and UITestHelper.Load is used appropriately.

Findings: 5 issues (4 medium, 1 minor)

Medium — test flakiness (both tests, 4 inline comments):

  • ContainerFromIndex(0) is called synchronously right after UITestHelper.Load without waiting. The existing Check_Binding test in the same file already handles this with WaitFor (line 58). Both call sites need await WindowHelper.WaitForNonNull(() => SUT.ContainerFromIndex(0) as PivotItem).
  • FindFirstChild<ContentPresenter>() and contentPresenter.Content are asserted without waiting for template application / binding propagation. Both call sites need a WaitForNonNull + WaitFor(() => contentPresenter!.Content is not null) pair.

Minor — naming inconsistency (1 inline comment):

  • Second test method is Then_FirstItemContentVisible (missing Is); first test is Then_FirstItemContentIsVisible. Align to Then_FirstItemContentIsVisible.

Cross-cutting note: The PR description correctly flags that the underlying bug (#11914) is Android-specific (NativePivotPresenter / ViewPager) and these Skia-target tests cannot reproduce it. The tests still add value as non-regression coverage for the Skia path, but the actual Android fix/verification requires running against a native Android target.

@unodevops

Copy link
Copy Markdown
Contributor

Wait for the Pivot container and its ContentPresenter to materialize before
asserting, and align the second test's name with the first. The content
assertions themselves stay immediate: #11914 is about the content not being
set at once on initial load.

Co-Authored-By: Claude Opus 4.8 (1M context) <[email protected]>
Claude-Session: https://claude.ai/code/session_01GKBgQoAmRmaFoXXZr93iLB
@github-actions

github-actions Bot commented Jul 14, 2026 •

Copy link
Copy Markdown
Contributor

Claude finished @MartinZikmund's task in 3m 41s —— View job


Review complete

  • Gather context
  • Read changed file
  • Check git diff vs origin/master
  • Post inline review comments
  • Update summary

Summary

The hardening commit (54d7522) successfully addressed all three issues from the previous reviews:

  • ✅ ContainerFromIndex(0) now uses WaitForNonNull in both tests
  • ✅ FindFirstChild<ContentPresenter>() now uses WaitForNonNull in both tests
  • ✅ Naming inconsistency resolved — both tests now end with Then_FirstItemContentIsVisible

The intentional no-wait assertions on contentPresenter.Content are correct by design: the test is specifically guarding that the ContentPresenter has its Content set immediately after load, which is exactly what #11914 was about. The explanatory comments make this clear.

Findings: 1 minor

One remaining flakiness risk: in When_Pivot_LoadedWithInlineItems_Then_FirstItemContentIsVisible (line 197), FindFirstChild<TextBlock>() is called synchronously after the no-wait Content assertion. Unlike Content, which is a property set at binding time, visual children of ContentPresenter are populated during a layout pass — which may not have fired yet. This assertion is not part of the intentional "no-wait" contract and should use WaitForNonNull for robustness.

Cross-cutting note (unchanged from prior reviews): The bug (#11914) is in the native Android path (NativePivotPresenter/ViewPager). These Skia-target tests add non-regression value for the Skia path but cannot catch an Android-specific regression.

@MartinZikmund

MartinZikmund commented Jul 14, 2026 •

Copy link
Copy Markdown
Member Author

PR review follow-up

Pushed commit b9edaf106130d68ed2b1164c9e8804937806a0e3 addressing the remaining open thread.

Fixed (1)

file:line reviewer point what changed
Given_Pivot.cs:197 FindFirstChild<TextBlock>() is called synchronously right after the intentional no-wait Content assertion; the ContentPresenter may not have completed a layout pass to materialise its visual children, so this can return null on a slow/CI machine. Wrapped the TextBlock lookup in WindowHelper.WaitForNonNull(...) with a diagnostic message. This is consistent with the container / ContentPresenter lookups already hardened in this PR: visual-tree materialization is asynchronous scaffolding, not what #11914 regressed on (that is the contentPresenter.Content property check on line 195, which stays an immediate Should().NotBeNull no-wait assert). The redundant tb.Should().NotBeNull(...) was dropped since WaitForNonNull already throws AssertFailedException on timeout — matching the style used for the other two lookups. The TextBlock.Text value assertion is preserved.

No change needed (0)

Needs @MartinZikmund input (0)


All changes were reviewed by inspection only — no local build/test was run (per rate/disk constraints). Azure Pipelines CI is the validation gate.

@unodevops

Copy link
Copy Markdown
Contributor

@github-actions

github-actions Bot commented Jul 15, 2026 •

Copy link
Copy Markdown
Contributor

Claude finished @MartinZikmund's task in 3m 50s —— View job


Review complete

  • Gather context
  • Read changed file and git diff
  • Review against AGENTS.md rules
  • Post inline review comments
  • Update summary

Summary

The three hardening commits (15177f60 → 54d7522d → b9edaf10) have addressed all issues raised across the previous four review rounds:

  • ✅ ContainerFromIndex(0) now uses WaitForNonNull in both tests
  • ✅ FindFirstChild<ContentPresenter>() now uses WaitForNonNull in both tests
  • ✅ FindFirstChild<TextBlock>() now uses WaitForNonNull (latest commit)
  • ✅ Naming aligned (Then_FirstItemContentIsVisible) in both tests
  • ✅ The intentional no-wait assertions on contentPresenter.Content are correctly documented and justified (they guard the [Droid] Pivot content is not set at once #11914 regression directly)

Findings: 1 minor

The container.Content.Should().NotBeNull(...) assertion on line 160 (test 1 only) is trivially true: when ItemsSource holds PivotItem objects, ContainerFromIndex(0) returns the source item itself (same object reference), and its Content was explicitly set to a TextBlock before loading. It can never fail and adds no regression coverage — the meaningful assertion is contentPresenter.Content.Should().NotBeNull(...) immediately below it.

Cross-cutting note (unchanged): #11914 is in the native Android path (NativePivotPresenter/ViewPager). These Skia-target tests add non-regression coverage for the Skia path but cannot reproduce the original Android regression.

@unodevops

Copy link
Copy Markdown
Contributor

@MartinZikmund
MartinZikmund merged commit 3c02722 into master Jul 15, 2026
47 checks passed
@MartinZikmund
MartinZikmund deleted the dev/mazi/repro/11914 branch July 15, 2026 13:26
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.

4 participants