Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -6113,4 +6113,58 @@ public class SubclassOfObservableCollection : ObservableCollection<string>
{
}
}

// Repro tests for https://github.com/unoplatform/uno/issues/2136
Comment thread
MartinZikmund marked this conversation as resolved.
Resolved
[TestClass]
[RunsOnUIThread]
public class Given_ItemsStackPanel_Stretch
{
[TestMethod]
[GitHubWorkItem("https://github.com/unoplatform/uno/issues/2136")]
[PlatformCondition(ConditionMode.Exclude, RuntimeTestPlatforms.NativeWinUI)]
#if __APPLE_UIKIT__
[Ignore("Disable all listview tests until crash is resolved https://github.com/unoplatform/uno/issues/17101")]
#endif
public async Task When_ListView_ItemsStackPanel_Children_Are_Stretched_To_Full_Width()
{
const double ContainerWidth = 300;

var sut = new ListView
{
Width = ContainerWidth,
Height = 400,
ItemsSource = new[] { "Item 1", "Item 2", "Item 3" },
ItemTemplate = XamlHelper.LoadXaml<DataTemplate>("""
<DataTemplate>
<Border Height="50" Background="Blue" HorizontalAlignment="Stretch">
<TextBlock Text="{Binding}" VerticalAlignment="Center" HorizontalAlignment="Center" />
</Border>
</DataTemplate>
"""),
};

await UITestHelper.Load(sut, x => x.IsLoaded);
await UITestHelper.WaitForIdle();
await UITestHelper.WaitFor(() => sut.ItemsPanelRoot?.ActualWidth > 0, timeoutMS: 3000);

var panel = sut.ItemsPanelRoot;
Assert.IsNotNull(panel, "ItemsPanelRoot should not be null.");

// #2136 is specific to ItemsStackPanel, so fail loudly if the default panel ever changes.
Assert.IsInstanceOfType(panel, typeof(ItemsStackPanel),
$"Expected the default ListView ItemsPanel to be an ItemsStackPanel, but got {panel.GetType().Name}.");

Assert.AreEqual(ContainerWidth, panel.ActualWidth, 2d,
$"Expected ItemsPanelRoot to have ActualWidth={ContainerWidth}, but got {panel.ActualWidth}.");

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.");
Comment thread
MartinZikmund marked this conversation as resolved.
Resolved
await UITestHelper.WaitFor(() => container.ActualWidth > 0, timeoutMS: 3000);

// The regression is items failing to fill the panel, so measure the container against the panel itself.
Assert.AreEqual(panel.ActualWidth, container.ActualWidth, 2d,
$"Expected ListViewItem to be stretched to the panel width ({panel.ActualWidth}px), but got {container.ActualWidth}.");
}
}
}
Loading