Skip to content

Commit

Permalink
test: Additional launch assertions for ContentIsland
Browse files Browse the repository at this point in the history
  • Loading branch information
MartinZikmund committed Apr 22, 2024
1 parent d2ce669 commit e356253
Show file tree
Hide file tree
Showing 5 changed files with 28 additions and 3 deletions.
1 change: 1 addition & 0 deletions src/SamplesApp/SamplesApp.Shared/MainPage.xaml.cs
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
using Microsoft.UI.Xaml;
using Microsoft.UI.Xaml.Controls;
using Microsoft.UI.Xaml.Navigation;
using Microsoft.VisualStudio.TestTools.UnitTesting;

namespace SamplesApp
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,12 @@ private void OnXamlRootChanged(XamlRoot sender, XamlRootChangedEventArgs args)

protected override Size MeasureOverride(Size availableSize)
{
Assert.IsTrue(IsLoaded, "The control should be loaded before the first measure.");
Assert.IsNotNull(XamlRoot, "Child should not be null.");
#if HAS_UNO
Assert.IsNotNull(XamlRoot?.VisualTree.ContentRoot.CompositionContent, "ContentIsland of the ContentRoot should have been set by now.");
#endif

if (_initialMeasure && availableSize == default)
{
_initialMeasure = false;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,10 @@
using System;
using System.Windows;
using System.Windows.Media;
using Windows.ApplicationModel.Core;
using Windows.Graphics.Display;
using Microsoft.UI.Windowing;
using Uno.UI.Runtime.Skia.Wpf.UI.Controls;
using Windows.ApplicationModel.Core;
using Windows.Graphics.Display;
using WpfApplication = global::System.Windows.Application;
using WpfWindow = global::System.Windows.Window;

Expand Down Expand Up @@ -41,7 +41,7 @@ private WpfWindow GetWindow()
// TODO: this is a ridiculous amount of indirection, find something better
if (!AppWindow.TryGetFromWindowId(_displayInformation.WindowId, out var appWindow) ||
Microsoft.UI.Xaml.Window.GetFromAppWindow(appWindow) is not { } window ||
UnoWpfWindow.GetWpfWindowFromWindow(window) is not { } wpfWindow)
UnoWpfWindow.GetFromWinUIWindow(window) is not { } wpfWindow)
{
throw new InvalidOperationException($"{nameof(WpfDisplayInformationExtension)} couldn't find a WPF window.");
}
Expand Down
1 change: 1 addition & 0 deletions src/Uno.UI.XamlHost.Skia.Wpf/UnoXamlHostBase.host.cs
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
using Uno.UI.Runtime.Skia.Wpf.Extensions;
using Uno.UI.Hosting;
using Uno.UI.Runtime.Skia.Wpf;
using Microsoft.UI.Content;

namespace Uno.UI.XamlHost.Skia.Wpf;

Expand Down
17 changes: 17 additions & 0 deletions src/Uno.UI/UI/Content/IContentIslandHost.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace Uno.UI.Content;

/// <summary>
/// Represents a hosting site for a ContentIsland.
/// </summary>
internal interface IContentIslandHost
{
float RasterizationScale { get; }

bool IsSiteVisible { get; }
}

0 comments on commit e356253

Please sign in to comment.