Skip to content

Commit

Permalink
test: add tests for ElementStub changes
Browse files Browse the repository at this point in the history
  • Loading branch information
ramezgerges committed Mar 4, 2024
1 parent a3139e7 commit 40c93e9
Show file tree
Hide file tree
Showing 4 changed files with 60 additions and 0 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
<Page x:Class="Uno.UI.RuntimeTests.Tests.Windows_UI_Xaml.Controls.xLoad_Visibility"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:local="using:Uno.UI.RuntimeTests.Tests.Windows_UI_Xaml.Controls"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
mc:Ignorable="d">

<Border x:Name="LazyLoadedBorder" x:Load="False" Visibility="Visible">
<TextBlock Text="Content created when it becomes visible" />
</Border>
</Page>
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
using Microsoft.UI.Xaml.Controls;

// The Blank Page item template is documented at https://go.microsoft.com/fwlink/?LinkId=234238

namespace Uno.UI.RuntimeTests.Tests.Windows_UI_Xaml.Controls
{
/// <summary>
/// An empty page that can be used on its own or navigated to within a Frame.
/// </summary>
public sealed partial class xLoad_Visibility : Page
{
public xLoad_Visibility()
{
this.InitializeComponent();
}
}
}
12 changes: 12 additions & 0 deletions src/Uno.UI.RuntimeTests/Tests/Windows_UI_Xaml/Given_xLoad.cs
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
#if !WINAPPSDK
using System;
using System.Diagnostics;
using System.Linq;
using System.Threading.Tasks;
using Microsoft.VisualStudio.TestTools.UnitTesting;
using Private.Infrastructure;
Expand Down Expand Up @@ -446,6 +447,17 @@ private async Task AssertIsNullAsync<T>(Func<T> getter, TimeSpan? timeout = null

Assert.IsNull(getter());
}

[TestMethod]
public async Task When_xLoad_Visibility_Set()
{
var SUT = new xLoad_Visibility();
TestServices.WindowHelper.WindowContent = SUT;
await TestServices.WindowHelper.WaitForIdle();

Assert.AreEqual(1, SUT.GetChildren().Count(c => c is ElementStub));
Assert.AreEqual(0, SUT.GetChildren().Count(c => c is Border));
}
}
}
#endif
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@
using Microsoft.UI.Xaml.Media;
using FluentAssertions;
using Uno.Extensions;
using Uno.UI.RuntimeTests.Tests.Windows_UI_Xaml.Controls;
using static Private.Infrastructure.TestServices;

namespace Uno.UI.RuntimeTests.Tests.Windows_UI_Xaml_Media
Expand Down Expand Up @@ -149,6 +150,24 @@ public async Task When_HitTestTranslatedElement()
#if !UNO_HAS_MANAGED_POINTERS
[Ignore("Root visual tree elements are not configured properly to use managed hit testing.")]
#endif
#if __MACOS__
[Ignore("Currently fails on macOS, part of #9282 epic")]
#endif
public async Task When_ElementStub_Not_Counted()
{
var SUT = new xLoad_Visibility();
WindowHelper.WindowContent = SUT;
await WindowHelper.WaitForIdle();

Assert.AreEqual(0, VisualTreeHelper.GetChildrenCount(SUT));
Assert.IsNull(VisualTreeHelper.GetChild(SUT, 0));
}

[TestMethod]
[RunsOnUIThread]
#if !UNO_HAS_MANAGED_POINTERS
[Ignore("Root visual tree elements are not configured properly to use managed hit testing.")]
#endif
#if __MACOS__
[Ignore("Currently fails on macOS, part of #9282 epic")]
#endif
Expand Down

0 comments on commit 40c93e9

Please sign in to comment.