提交 794ad251 编写于 作者: M Martin Zikmund

fix: Correctly run FullWindow tests in context of Uno Island

上级 bd216e44
......@@ -656,6 +656,10 @@ namespace SamplesApp
public void AssertIssue8641NativeOverlayInitialized()
{
#if __SKIA__
if (Uno.UI.Xaml.Core.CoreServices.Instance.InitializationType == Uno.UI.Xaml.Core.InitializationType.IslandsOnly)
{
return;
}
// Temporarily add a TextBox to the current page's content to verify native overlay is available
Frame rootFrame = Windows.UI.Xaml.Window.Current.Content as Frame;
var textBox = new TextBox();
......
......@@ -87,6 +87,13 @@ namespace Uno.UI.Samples.Tests
Private.Infrastructure.TestServices.WindowHelper.CurrentTestWindow =
Windows.UI.Xaml.Window.Current;
Private.Infrastructure.TestServices.WindowHelper.IsXamlIsland =
#if HAS_UNO
Uno.UI.Xaml.Core.CoreServices.Instance.InitializationType == Xaml.Core.InitializationType.IslandsOnly;
#else
false;
#endif
DataContext = null;
SampleChooserViewModel.Instance.SampleChanging += OnSampleChanging;
......
......@@ -7,6 +7,8 @@ using System.Runtime.CompilerServices;
using Windows.UI.Xaml.Media;
using Windows.UI.Xaml.Tests.Enterprise;
using Windows.UI.Core;
using Uno.Helpers;
using MUXControlsTestApp.Utilities;
#if NETFX_CORE
using Uno.UI.Extensions;
#elif __IOS__
......@@ -28,6 +30,8 @@ namespace Private.Infrastructure
public static XamlRoot XamlRoot { get; set; }
public static bool IsXamlIsland { get; set; }
public static Windows.UI.Xaml.Window CurrentTestWindow
{
get
......@@ -46,14 +50,21 @@ namespace Private.Infrastructure
public static UIElement WindowContent
{
get => UseActualWindowRoot
? CurrentTestWindow.Content
? (IsXamlIsland ? GetXamlIslandRootContentControl().Content as UIElement : CurrentTestWindow.Content)
: EmbeddedTestRoot.getContent?.Invoke();
internal set
{
if (UseActualWindowRoot)
{
if (IsXamlIsland)
{
GetXamlIslandRootContentControl().Content = value;
}
else
{
CurrentTestWindow.Content = value;
}
}
else if (EmbeddedTestRoot.setContent is { } setter)
{
setter(value);
......@@ -65,16 +76,41 @@ namespace Private.Infrastructure
}
}
private static ContentControl GetXamlIslandRootContentControl()
{
var islandContentRoot = EmbeddedTestRoot.control.XamlRoot.Content;
if (islandContentRoot is not ContentControl contentControl)
{
contentControl = VisualTreeUtils.FindVisualChildByType<ContentControl>(islandContentRoot);
}
return contentControl;
}
public static void SaveOriginalWindowContent()
{
if (IsXamlIsland)
{
_originalWindowContent = GetXamlIslandRootContentControl().Content as UIElement;
}
else
{
_originalWindowContent = CurrentTestWindow.Content;
}
}
public static void RestoreOriginalWindowContent()
{
if (_originalWindowContent != null)
{
if (IsXamlIsland)
{
GetXamlIslandRootContentControl().Content = _originalWindowContent;
}
else
{
CurrentTestWindow.Content = _originalWindowContent;
}
_originalWindowContent = null;
}
}
......
......@@ -12,6 +12,11 @@ namespace Uno.UI.RuntimeTests.Tests.Windows_UI_Xaml
[RunsOnUIThread]
public async Task When_Loaded_Matches_Window_Root()
{
if (TestServices.WindowHelper.IsXamlIsland)
{
return;
}
var border = new Border();
var completionSource = new TaskCompletionSource<XamlRoot>();
border.Loaded += (s, e) =>
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册