Skip to content

Commit

Permalink
test: Add tbi vs cp container test
Browse files Browse the repository at this point in the history
  • Loading branch information
eriklimakc committed Oct 14, 2024
1 parent 1c4ecec commit 8b35f42
Showing 1 changed file with 35 additions and 0 deletions.
35 changes: 35 additions & 0 deletions src/Uno.Toolkit.RuntimeTests/Tests/TabBarTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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<DataTemplate>(@"
<DataTemplate>
<utu:TabBarItem Content=""{Binding Name}"" IsSelectable=""{Binding IsSelectable}"" />
</DataTemplate>
");

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()
{
Expand Down

0 comments on commit 8b35f42

Please sign in to comment.