Skip to content

Commit

Permalink
chore: update GetFirstDescendent with name based filtering
Browse files Browse the repository at this point in the history
  • Loading branch information
vatsashah45 committed Oct 14, 2024
1 parent cda836c commit 52c1d64
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 6 deletions.
10 changes: 5 additions & 5 deletions src/Uno.Toolkit.RuntimeTests/Tests/AncestorBindingTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ public async Task Ancestor_TopLevel_PageBinding()
var setup = new AncestorBindingTest();
await UnitTestUIContentHelperEx.SetContentAndWait(setup);

var sut = setup.GetFirstDescendant<TextBlock>() ?? throw new Exception("Failed to find TopLevelTextBlock");
var sut = setup.GetFirstDescendant<TextBlock>(x => x.Name == "TopLevelTextBlock") ?? throw new Exception("Failed to find TopLevelTextBlock");
Assert.AreEqual(sut.Text, setup.Tag);
}

Expand All @@ -40,9 +40,9 @@ public async Task Ancestor_Nested_PageBinding()
var setup = new AncestorBindingTest();
await UnitTestUIContentHelperEx.SetContentAndWait(setup);

var lv = setup.GetFirstDescendant<ListView>() ?? throw new Exception("Failed to find TopLevelListView");
var lv = setup.GetFirstDescendant<ListView>(x => x.Name == "TopLevelListView") ?? throw new Exception("Failed to find TopLevelListView");
var container = lv.ContainerFromIndex(0);
var sut = (container as FrameworkElement)?.GetFirstDescendant<TextBlock>() ?? throw new Exception("Failed to find NestedLvTextBlock1");
var sut = (container as FrameworkElement)?.GetFirstDescendant<TextBlock>(x => x.Name == "NestedLvTextBlock1") ?? throw new Exception("Failed to find NestedLvTextBlock1");

Assert.AreEqual(sut.Text, setup.Tag);
}
Expand All @@ -53,9 +53,9 @@ public async Task Ancestor_Nested_LvBinding()
var setup = new AncestorBindingTest();
await UnitTestUIContentHelperEx.SetContentAndWait(setup);

var lv = setup.GetFirstDescendant<ListView>() ?? throw new Exception("Failed to find TopLevelListView");
var lv = setup.GetFirstDescendant<ListView>(x => x.Name == "TopLevelListView") ?? throw new Exception("Failed to find TopLevelListView");
var container = lv.ContainerFromIndex(0);
var sut = (container as FrameworkElement)?.GetFirstDescendant<TextBlock>() ?? throw new Exception("Failed to find NestedLvTextBlock2");
var sut = (container as FrameworkElement)?.GetFirstDescendant<TextBlock>(x => x.Name == "NestedLvTextBlock2") ?? throw new Exception("Failed to find NestedLvTextBlock2");
Assert.AreEqual(sut.Text, lv.Tag);
}
}
2 changes: 1 addition & 1 deletion src/Uno.Toolkit.RuntimeTests/Tests/DrawerTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ await Task.Run(async () =>
await UIHelper.WaitForIdle();
await UnitTestUIContentHelperEx.WaitFor(() => drawer.AnimationStoryboard?.GetCurrentState() == ClockState.Stopped);

var lightDismissOverlay = drawer.GetFirstDescendant<Border>() ??
var lightDismissOverlay = drawer.GetFirstDescendant<Border>(x => x.Name == DrawerControl.TemplateParts.LightDismissOverlayName) ??
throw new Exception($"Failed to find {DrawerControl.TemplateParts.LightDismissOverlayName}");

await UnitTestUIContentHelperEx.WaitFor(
Expand Down

0 comments on commit 52c1d64

Please sign in to comment.