Skip to content

Commit

Permalink
chore: fix more xLoad tests
Browse files Browse the repository at this point in the history
  • Loading branch information
ramezgerges committed Mar 9, 2024
1 parent 4f045f0 commit 2fde6bd
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 6 deletions.
9 changes: 6 additions & 3 deletions src/Uno.UI.Tests/Windows_UI_Xaml/Given_xLoad.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}

Expand All @@ -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);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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<ElementStub>().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<ElementStub>().Count());
Assert.IsNotNull(innerTextBlock);
Assert.AreEqual(data.InnerText, innerTextBlock.Text);
Assert.AreEqual(1, innerRoot.EnumerateAllChildren().OfType<ElementStub>().Count());
Assert.IsNull(innerTextBlock);

data.TopLevelVisiblity = false;

var topLevelContent = SUT.FindName("topLevelContent") as FrameworkElement;
Assert.AreEqual(0, innerRoot.EnumerateAllChildren().OfType<ElementStub>().Count());
innerTextBlock = SUT.FindName("innerTextBlock") as TextBlock;
Assert.IsNotNull(innerTextBlock);
Assert.AreEqual(data.InnerText, innerTextBlock.Text);
Assert.AreEqual(Visibility.Collapsed, topLevelContent.Visibility);
}

Expand Down

0 comments on commit 2fde6bd

Please sign in to comment.