Skip to content

test: Add regression test for #2136#22990

Open
MartinZikmund wants to merge 1 commit intomasterfrom
dev/mazi/repro/2136
Open

test: Add regression test for #2136#22990
MartinZikmund wants to merge 1 commit intomasterfrom
dev/mazi/repro/2136

Conversation

@MartinZikmund
Copy link
Copy Markdown
Member

Summary

Adds regression test for #2136.

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_ListViewBase.csWhen_ListView_ItemsStackPanel_Children_Are_Stretched_To_Full_Width

Notes

The issue was reported on WebAssembly. Runtime tests run on Skia only — the fix should be verified on native targets as well.

The test verifies that items inside a vertical ItemsStackPanel within a ListView stretch to fill the available width (300px container), checking both the panel root and individual ListViewItem containers.

Relates to #2136

Copilot AI review requested due to automatic review settings April 8, 2026 17:48
@MartinZikmund MartinZikmund enabled auto-merge April 8, 2026 17:50
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

Adds a new Uno.UI runtime test intended to prevent regressions related to #2136, focusing on ItemsStackPanel stretching behavior in a ListView.

Changes:

  • Introduces a new Given_ItemsStackPanel_Stretch test class with a regression test asserting full-width stretching for ItemsPanelRoot and the first ListViewItem container.

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

Comment on lines +5517 to +5520
// Get the items panel root - it should be an ItemsStackPanel
var panel = sut.ItemsPanelRoot;
Assert.IsNotNull(panel, "ItemsPanelRoot should not be null.");

Copy link

Copilot AI Apr 8, 2026

Choose a reason for hiding this comment

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

The test comment says the ItemsPanelRoot “should be an ItemsStackPanel”, but the code never verifies that (nor does it explicitly set ListView.ItemsPanel). If the default panel changes in the future, this test could still pass while no longer covering the intended regression; consider asserting the panel type (ItemsStackPanel) and/or setting an explicit ItemsPanelTemplate using ItemsStackPanel for the SUT.

Copilot uses AI. Check for mistakes.
Comment on lines +5516 to +5532

// Get the items panel root - it should be an ItemsStackPanel
var panel = sut.ItemsPanelRoot;
Assert.IsNotNull(panel, "ItemsPanelRoot should not be null.");

// The panel itself should be as wide as the container
Assert.AreEqual(ContainerWidth, panel.ActualWidth, 2d,
$"Expected ItemsPanelRoot to have ActualWidth={ContainerWidth}, but got {panel.ActualWidth}.");

// Check that the first visible container is stretched to the full width
await UITestHelper.WaitFor(() => sut.ContainerFromIndex(0) != null, timeoutMS: 3000);
var container = sut.ContainerFromIndex(0) as ListViewItem;
Assert.IsNotNull(container, "Expected container for index 0.");

Assert.AreEqual(ContainerWidth, container.ActualWidth, 2d,
$"Expected ListViewItem to be stretched to {ContainerWidth}px width, but got {container.ActualWidth}. " +
$"On WASM with ItemsStackPanel, items are not being stretched to fill the available width.");
Copy link

Copilot AI Apr 8, 2026

Choose a reason for hiding this comment

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

The width assertions use the constant 300px as the expected available width. Depending on default ListView template padding/border/scrollbar behavior, the ItemsPanelRoot and item containers may correctly stretch to the available width while still being slightly less than the control Width. To avoid false failures and improve cross-platform stability, derive the expected width from the actual arranged width (e.g., sut.ActualWidth / items presenter width) and wait until the element is measured (ActualWidth > 0) before asserting.

Suggested change
// Get the items panel root - it should be an ItemsStackPanel
var panel = sut.ItemsPanelRoot;
Assert.IsNotNull(panel, "ItemsPanelRoot should not be null.");
// The panel itself should be as wide as the container
Assert.AreEqual(ContainerWidth, panel.ActualWidth, 2d,
$"Expected ItemsPanelRoot to have ActualWidth={ContainerWidth}, but got {panel.ActualWidth}.");
// Check that the first visible container is stretched to the full width
await UITestHelper.WaitFor(() => sut.ContainerFromIndex(0) != null, timeoutMS: 3000);
var container = sut.ContainerFromIndex(0) as ListViewItem;
Assert.IsNotNull(container, "Expected container for index 0.");
Assert.AreEqual(ContainerWidth, container.ActualWidth, 2d,
$"Expected ListViewItem to be stretched to {ContainerWidth}px width, but got {container.ActualWidth}. " +
$"On WASM with ItemsStackPanel, items are not being stretched to fill the available width.");
await UITestHelper.WaitFor(() => sut.ActualWidth > 0, timeoutMS: 3000);
await UITestHelper.WaitFor(() => sut.ItemsPanelRoot?.ActualWidth > 0, timeoutMS: 3000);
// Get the items panel root - it should be an ItemsStackPanel
var panel = sut.ItemsPanelRoot;
Assert.IsNotNull(panel, "ItemsPanelRoot should not be null.");
var availableWidth = panel.ActualWidth;
Assert.IsTrue(availableWidth > 0,
$"Expected ItemsPanelRoot to be measured with a positive ActualWidth, but got {availableWidth}.");
// Check that the first visible container is stretched to the full available panel width
await UITestHelper.WaitFor(() => sut.ContainerFromIndex(0) is ListViewItem, timeoutMS: 3000);
var container = sut.ContainerFromIndex(0) as ListViewItem;
Assert.IsNotNull(container, "Expected container for index 0.");
await UITestHelper.WaitFor(() => container.ActualWidth > 0, timeoutMS: 3000);
Assert.AreEqual(availableWidth, container.ActualWidth, 2d,
$"Expected ListViewItem to be stretched to the available panel width ({availableWidth}px), but got {container.ActualWidth}. " +
$"ListView ActualWidth={sut.ActualWidth}, requested Width={ContainerWidth}, panel ActualWidth={panel.ActualWidth}.");

Copilot uses AI. Check for mistakes.
Comment on lines +5485 to +5493
// Repro tests for https://github.com/unoplatform/uno/issues/2136
[TestClass]
[RunsOnUIThread]
public class Given_ItemsStackPanel_Stretch
{
[TestMethod]
[GitHubWorkItem("https://github.com/unoplatform/uno/issues/2136")]
[PlatformCondition(ConditionMode.Exclude, RuntimeTestPlatforms.NativeWinUI)]
public async Task When_ListView_ItemsStackPanel_Children_Are_Stretched_To_Full_Width()
Copy link

Copilot AI Apr 8, 2026

Choose a reason for hiding this comment

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

On APPLE_UIKIT, this file currently disables the existing Given_ListViewBase tests via a class-level [Ignore] (issue #17101). The new top-level test class is not covered by that ignore, so it will start running on iOS even though ListView tests are intentionally disabled there; consider adding the same iOS Ignore/PlatformCondition exclusion here to avoid reintroducing the crash/failure mode.

Copilot uses AI. Check for mistakes.
@unodevops
Copy link
Copy Markdown
Contributor

🤖 Your WebAssembly Skia Sample App stage site is ready! Visit it here: https://unowasmprstaging.z20.web.core.windows.net/pr-22990/wasm-skia-net9/index.html

@unodevops
Copy link
Copy Markdown
Contributor

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

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.

3 participants