From ba8ef84977a579120fe14d81c10a8a8a903d8ab3 Mon Sep 17 00:00:00 2001 From: Youssef1313 Date: Sat, 18 Jan 2025 10:22:55 +0100 Subject: [PATCH] chore: Fix build errors --- .../UnoIslandsSamplesApp.Skia.Wpf/MainWindow.xaml.cs | 10 +++++++++- .../Tests/Windows_Data/Pdf/Given_PdfDocument.cs | 12 ++++++------ 2 files changed, 15 insertions(+), 7 deletions(-) diff --git a/src/SamplesApp/UnoIslandsSamplesApp.Skia.Wpf/MainWindow.xaml.cs b/src/SamplesApp/UnoIslandsSamplesApp.Skia.Wpf/MainWindow.xaml.cs index 6a5e67d566d1..c298719e893d 100644 --- a/src/SamplesApp/UnoIslandsSamplesApp.Skia.Wpf/MainWindow.xaml.cs +++ b/src/SamplesApp/UnoIslandsSamplesApp.Skia.Wpf/MainWindow.xaml.cs @@ -1,4 +1,5 @@ using System.Windows; +using Microsoft.UI.Xaml; using Microsoft.VisualStudio.TestTools.UnitTesting; namespace UnoIslandsSamplesApp.Skia.Wpf @@ -9,13 +10,20 @@ public MainWindow() { this.InitializeComponent(); xamlHost.Loaded += XamlHost_Loaded; + xamlHost.Loaded += XamlHost_LoadedAsync; } - private async void XamlHost_Loaded(object sender, RoutedEventArgs e) + private void XamlHost_Loaded(object sender, RoutedEventArgs e) { #if HAS_UNO + // Assertion should NOT be in async void. + // DON'T move this to XamlHost_LoadedAsync. Assert.IsNotNull(xamlHost.Child.XamlRoot?.VisualTree.ContentRoot.CompositionContent, "ContentIsland of the ContentRoot should have been set by now."); #endif + } + + private async void XamlHost_LoadedAsync(object sender, RoutedEventArgs e) + { await SamplesApp.App.HandleRuntimeTests(string.Join(";", System.Environment.GetCommandLineArgs())); } } diff --git a/src/Uno.UI.RuntimeTests/Tests/Windows_Data/Pdf/Given_PdfDocument.cs b/src/Uno.UI.RuntimeTests/Tests/Windows_Data/Pdf/Given_PdfDocument.cs index 7e0ac63ef7bf..e5c289e24cde 100644 --- a/src/Uno.UI.RuntimeTests/Tests/Windows_Data/Pdf/Given_PdfDocument.cs +++ b/src/Uno.UI.RuntimeTests/Tests/Windows_Data/Pdf/Given_PdfDocument.cs @@ -127,7 +127,7 @@ public async Task When_LoadFromStreamAsync_With_Valid_Password() Assert.IsNotNull(stream, "Not valid stream"); #if __ANDROID__ - await Assert.ThrowsAsync(() => await PdfDocument.LoadFromStreamAsync(stream, PdfDocument_Password_Valid)); + await Assert.ThrowsAsync(async () => await PdfDocument.LoadFromStreamAsync(stream, PdfDocument_Password_Valid)); #else var pdfDocument = await PdfDocument.LoadFromStreamAsync(stream, PdfDocument_Password_Valid); await CheckDocumentAsync(pdfDocument, ReferencePageImage_ProtectedUri, hasPassword: true); @@ -141,9 +141,9 @@ public async Task When_LoadFromStreamAsync_With_Wrong_Password() Assert.IsNotNull(stream, "Not valid stream"); #if __ANDROID__ - await Assert.ThrowsAsync(() => await PdfDocument.LoadFromStreamAsync(stream, PdfDocument_Password_Invalid)); + await Assert.ThrowsAsync(async () => await PdfDocument.LoadFromStreamAsync(stream, PdfDocument_Password_Invalid)); #elif !HAS_UNO - await Assert.ThrowsAsync(() => await PdfDocument.LoadFromStreamAsync(stream, PdfDocument_Password_Invalid)); + await Assert.ThrowsAsync(async () => await PdfDocument.LoadFromStreamAsync(stream, PdfDocument_Password_Invalid)); #else var pdfDocument = await PdfDocument.LoadFromStreamAsync(stream, PdfDocument_Password_Valid); await CheckDocumentAsync(pdfDocument, ReferencePageImage_ProtectedUri, hasPassword: true); @@ -181,7 +181,7 @@ public async Task When_LoadFromFileAsync_Valid_Password() } #if __ANDROID__ - await Assert.ThrowsAsync(() => await PdfDocument.LoadFromStreamAsync(stream, PdfDocument_Password_Valid)); + await Assert.ThrowsAsync(async () => await PdfDocument.LoadFromStreamAsync(stream, PdfDocument_Password_Valid)); #else var pdfDocument = await PdfDocument.LoadFromFileAsync(file, PdfDocument_Password_Valid); await CheckDocumentAsync(pdfDocument, ReferencePageImage_ProtectedUri, hasPassword: true); @@ -202,9 +202,9 @@ public async Task When_LoadFromFileAsync_Wrong_Password() } #if __ANDROID__ - await Assert.ThrowsAsync(() => await PdfDocument.LoadFromFileAsync(file, PdfDocument_Password_Invalid)); + await Assert.ThrowsAsync(async () => await PdfDocument.LoadFromFileAsync(file, PdfDocument_Password_Invalid)); #elif !HAS_UNO - await Assert.ThrowsAsync(() => await PdfDocument.LoadFromFileAsync(file, PdfDocument_Password_Invalid)); + await Assert.ThrowsAsync(async () => await PdfDocument.LoadFromFileAsync(file, PdfDocument_Password_Invalid)); #else var pdfDocument = await PdfDocument.LoadFromFileAsync(file, PdfDocument_Password_Invalid); await CheckDocumentAsync(pdfDocument, ReferencePageImage_ProtectedUri, hasPassword: true);