From 2fde6bd2c4613a67e6af1d2a09fd713a85202756 Mon Sep 17 00:00:00 2001 From: Ramez Ragaa Date: Thu, 7 Mar 2024 22:41:37 +0200 Subject: [PATCH] chore: fix more xLoad tests --- src/Uno.UI.Tests/Windows_UI_Xaml/Given_xLoad.cs | 9 ++++++--- .../xBindTests/Given_xBind_Binding.cs | 10 +++++++--- 2 files changed, 13 insertions(+), 6 deletions(-) diff --git a/src/Uno.UI.Tests/Windows_UI_Xaml/Given_xLoad.cs b/src/Uno.UI.Tests/Windows_UI_Xaml/Given_xLoad.cs index 19dceaa1156c..b8cbceb68d75 100644 --- a/src/Uno.UI.Tests/Windows_UI_Xaml/Given_xLoad.cs +++ b/src/Uno.UI.Tests/Windows_UI_Xaml/Given_xLoad.cs @@ -76,11 +76,12 @@ public void When_xLoad_Deferred_VisibilityBinding() Assert.IsNull(SUT.border7); + // Changing the visibility DOES NOT materialize the lazily-loaded element. SUT.DataContext = true; - - Assert.IsNotNull(SUT.border7); + Assert.IsNull(SUT.border7); var border = SUT.FindName("border7"); + Assert.IsNotNull(SUT.border7); Assert.AreEqual(SUT.border7, border); } @@ -96,12 +97,14 @@ public void When_xLoad_Deferred_VisibilityxBind() Assert.IsNull(SUT.border8); + // Changing the visibility DOES NOT materialize the lazily-loaded element. SUT.MyVisibility = true; SUT.Measure(new Size(42, 42)); - Assert.IsNotNull(SUT.border8); + Assert.IsNull(SUT.border8); var border1 = SUT.FindName("border8"); + Assert.IsNotNull(SUT.border8); Assert.AreEqual(SUT.border8, border1); } diff --git a/src/Uno.UI.Tests/Windows_UI_Xaml_Data/xBindTests/Given_xBind_Binding.cs b/src/Uno.UI.Tests/Windows_UI_Xaml_Data/xBindTests/Given_xBind_Binding.cs index b87de8985c59..7f4b28772021 100644 --- a/src/Uno.UI.Tests/Windows_UI_Xaml_Data/xBindTests/Given_xBind_Binding.cs +++ b/src/Uno.UI.Tests/Windows_UI_Xaml_Data/xBindTests/Given_xBind_Binding.cs @@ -951,14 +951,18 @@ public void When_xLoad_DataTemplate() // Changing the visibility DOES NOT materialize the lazily-loaded element. Assert.AreEqual(1, innerRoot.EnumerateAllChildren().OfType().Count()); + // Calling FindName on an element inside a lazy-loaded element won't materialize the lazy-loaded element var innerTextBlock = SUT.FindName("innerTextBlock") as TextBlock; - Assert.AreEqual(0, innerRoot.EnumerateAllChildren().OfType().Count()); - Assert.IsNotNull(innerTextBlock); - Assert.AreEqual(data.InnerText, innerTextBlock.Text); + Assert.AreEqual(1, innerRoot.EnumerateAllChildren().OfType().Count()); + Assert.IsNull(innerTextBlock); data.TopLevelVisiblity = false; var topLevelContent = SUT.FindName("topLevelContent") as FrameworkElement; + Assert.AreEqual(0, innerRoot.EnumerateAllChildren().OfType().Count()); + innerTextBlock = SUT.FindName("innerTextBlock") as TextBlock; + Assert.IsNotNull(innerTextBlock); + Assert.AreEqual(data.InnerText, innerTextBlock.Text); Assert.AreEqual(Visibility.Collapsed, topLevelContent.Visibility); }