From 8b35f42129395a581f4c3d8fddabd5e502423dbf Mon Sep 17 00:00:00 2001 From: eriklimakc Date: Mon, 14 Oct 2024 17:22:52 +0100 Subject: [PATCH] test: Add tbi vs cp container test --- .../Tests/TabBarTests.cs | 35 +++++++++++++++++++ 1 file changed, 35 insertions(+) diff --git a/src/Uno.Toolkit.RuntimeTests/Tests/TabBarTests.cs b/src/Uno.Toolkit.RuntimeTests/Tests/TabBarTests.cs index 06d218027..217ecc9fe 100644 --- a/src/Uno.Toolkit.RuntimeTests/Tests/TabBarTests.cs +++ b/src/Uno.Toolkit.RuntimeTests/Tests/TabBarTests.cs @@ -427,6 +427,41 @@ public async Task Verify_SelectedIndex_Not_Set_Unnecessarily() //Assert.IsNull(SUT.GetBindingExpression(TabBar.SelectedIndexProperty)); } + [TestMethod] + public async Task Verify_ItemTemplated_Has_No_Nested_TabBarItem() + { + var source = new[] + { + new TestRecord("True", true), + new TestRecord("False", false), + new TestRecord("True", true) + }; + + var dt = XamlHelper.LoadXaml(@" + + + + "); + + var SUT = new TabBar + { + Style = (Style)Application.Current.Resources["TopTabBarStyle"], + ItemsSource = source, + ItemTemplate = dt, + SelectedIndex = 0 + }; + + await UnitTestUIContentHelperEx.SetContentAndWait(SUT); + + // Ensure the container is a `ContentPresenter` and not a `TabBarItem` + var container = SUT.ContainerFromItem(SUT.SelectedItem); + Assert.IsInstanceOfType(container, typeof(ContentPresenter)); + + // Ensure the inner container is a `TabBarItem` + var selectedItem = SUT.GetInnerContainer(container); + Assert.IsInstanceOfType(selectedItem, typeof(TabBarItem)); + } + [TestMethod] public async Task Verify_ItemTemplated_Disabled_Not_Selectable() {