diff --git a/src/SamplesApp/UITests.Shared/Microsoft_UI_Windowing/SingleWindowClose.xaml b/src/SamplesApp/UITests.Shared/Microsoft_UI_Windowing/SingleWindowClose.xaml new file mode 100644 index 0000000000..0d0c1726a2 --- /dev/null +++ b/src/SamplesApp/UITests.Shared/Microsoft_UI_Windowing/SingleWindowClose.xaml @@ -0,0 +1,16 @@ + + + + + + diff --git a/src/SamplesApp/UITests.Shared/Microsoft_UI_Windowing/SingleWindowClose.xaml.cs b/src/SamplesApp/UITests.Shared/Microsoft_UI_Windowing/SingleWindowClose.xaml.cs new file mode 100644 index 0000000000..28814d4936 --- /dev/null +++ b/src/SamplesApp/UITests.Shared/Microsoft_UI_Windowing/SingleWindowClose.xaml.cs @@ -0,0 +1,35 @@ +using System; +using System.Threading.Tasks; +using Microsoft.UI.Windowing; +using Microsoft.UI.Xaml; +using Microsoft.UI.Xaml.Controls; +using SamplesApp; +using Uno.Disposables; +using Uno.UI.Common; +using Uno.UI.Samples.Controls; +using Uno.UI.Samples.UITests.Helpers; +using Windows.Graphics; + +#if !WINDOWS_UWP && !WINAPPSDK +using Uno.UI.Xaml; +using Uno.UI.Xaml.Controls; +using WinUICoreServices = Uno.UI.Xaml.Core.CoreServices; +#endif + +namespace UITests.Microsoft_UI_Windowing; + +[Sample( + "Windowing", + IsManualTest = true, + Description = + "- On Android and iOS, try to back out of this app to the main screen and reopen the app via its icon. " + + "You should see the Samples app UI load normally - not a blank screen and the app should also not crash. \r\n" + + "- On Android and iOS, try to back out of this app and then activate it by opening an URI like uno-samples-test:something. " + + "You should see the Samples app UI load normally - not a blank screen and the app should also not crash. ")] +public sealed partial class SingleWindowClose : Page +{ + public SingleWindowClose() + { + this.InitializeComponent(); + } +} diff --git a/src/SamplesApp/UITests.Shared/UITests.Shared.projitems b/src/SamplesApp/UITests.Shared/UITests.Shared.projitems index be9dd1c0e3..64187ccf22 100644 --- a/src/SamplesApp/UITests.Shared/UITests.Shared.projitems +++ b/src/SamplesApp/UITests.Shared/UITests.Shared.projitems @@ -42,6 +42,10 @@ Designer MSBuild:Compile + + Designer + MSBuild:Compile + Designer MSBuild:Compile @@ -5496,6 +5500,9 @@ AppWindowClosing.xaml + + SingleWindowClose.xaml + OverlappedPresenterTests.xaml @@ -9834,4 +9841,4 @@ - + \ No newline at end of file diff --git a/src/Uno.UI/UI/Xaml/Window/Implementations/BaseWindowImplementation.cs b/src/Uno.UI/UI/Xaml/Window/Implementations/BaseWindowImplementation.cs index bd64a80fb2..54c2eb8614 100644 --- a/src/Uno.UI/UI/Xaml/Window/Implementations/BaseWindowImplementation.cs +++ b/src/Uno.UI/UI/Xaml/Window/Implementations/BaseWindowImplementation.cs @@ -80,7 +80,7 @@ internal abstract class BaseWindowImplementation : IWindowImplementation public virtual void Activate() { - if (_isClosed) + if (NativeWindowFactory.SupportsMultipleWindows && _isClosed) { throw new InvalidOperationException("Cannot reactivate a closed window."); } @@ -318,10 +318,18 @@ internal abstract class BaseWindowImplementation : IWindowImplementation // Window.PrepareToClose(); - // set these to null before marking window as closed as they fail if called after m_bIsClosed is set - // because they check if window is closed already - Window.SetTitleBar(null); - Window.Content = null; + if (NativeWindowFactory.SupportsMultipleWindows) + { + // set these to null before marking window as closed as they fail if called after m_bIsClosed is set + // because they check if window is closed already + Window.SetTitleBar(null); + Window.Content = null; + } + else + { + // Just reset the window to not shown state so it can be reactivated + _wasShown = false; + } // _windowChrome.SetDesktopWindow(null); @@ -336,8 +344,11 @@ internal abstract class BaseWindowImplementation : IWindowImplementation RaiseWindowVisibilityChangedEvent(false); } - // Close native window, cleanup, and unregister from hwnd mapping from DXamlCore - Shutdown(); + if (NativeWindowFactory.SupportsMultipleWindows) + { + // Close native window, cleanup, and unregister from hwnd mapping from DXamlCore + Shutdown(); + } return true; }