From 67478d585c04c6a2993974f5e73bdff461f1c881 Mon Sep 17 00:00:00 2001 From: Mike Corsaro Date: Mon, 25 Nov 2024 15:34:55 -0800 Subject: [PATCH] Add tests --- .../Elements/Modal/ModalTests.Windows.cs | 21 ++++++++++++++++++- 1 file changed, 20 insertions(+), 1 deletion(-) diff --git a/src/Controls/tests/DeviceTests/Elements/Modal/ModalTests.Windows.cs b/src/Controls/tests/DeviceTests/Elements/Modal/ModalTests.Windows.cs index 73d327797156..bc80b3b7cad9 100644 --- a/src/Controls/tests/DeviceTests/Elements/Modal/ModalTests.Windows.cs +++ b/src/Controls/tests/DeviceTests/Elements/Modal/ModalTests.Windows.cs @@ -68,6 +68,12 @@ await CreateHandlerAndAddToWindow(window, var rootView = handler.PlatformView.Content; ContentPage modalPage = new ContentPage(); + var previousPageNavigationRootManager = navPage.CurrentPage + .FindMauiContext() + .GetNavigationRootManager(); + + var previousWindowRootView = previousPageNavigationRootManager.RootView as WindowRootView; + await navPage.CurrentPage.Navigation.PushModalAsync(modalPage); await OnLoadedAsync(modalPage); @@ -75,14 +81,22 @@ await CreateHandlerAndAddToWindow(window, .FindMauiContext() .GetNavigationRootManager(); - var mauiWindow = (MauiWinUIWindow)handler.PlatformView; Assert.Equal("Original Title", mauiWindow.Title); Assert.Equal(modalNavigationRootManager.WindowTitle, mauiWindow.Title); + // Ensure previous page has hidden its titlebar + Assert.True(previousWindowRootView.AppTitleBarContainer.Visibility == UI.Xaml.Visibility.Collapsed); + Assert.True(previousWindowRootView.NavigationViewControl?.ButtonHolderGrid.Visibility == UI.Xaml.Visibility.Collapsed); + window.Title = "Update Title"; Assert.Equal("Update Title", mauiWindow.Title); Assert.Equal(modalNavigationRootManager.WindowTitle, mauiWindow.Title); + + // Ensure titlebar is visible after popping modal + var modalWindowRootView = modalNavigationRootManager.RootView as WindowRootView; + Assert.True(modalWindowRootView.AppTitleBarContainer.Visibility == UI.Xaml.Visibility.Visible); + Assert.True(modalWindowRootView.NavigationViewControl.ButtonHolderGrid.Visibility == UI.Xaml.Visibility.Visible); }); } @@ -130,6 +144,11 @@ await CreateHandlerAndAddToWindow(window, Assert.Equal(UpdatedTitle, mauiWindow.Title); Assert.Equal(UpdatedTitle, currentNavigationRootManager.WindowTitle); Assert.Equal(UpdatedTitle, modalNavigationRootManager.WindowTitle); + + // Ensure titlebar is visible after popping modal + var windowRootView = currentNavigationRootManager.RootView as WindowRootView; + Assert.True(windowRootView.AppTitleBarContainer.Visibility == UI.Xaml.Visibility.Visible); + Assert.True(windowRootView.NavigationViewControl.ButtonHolderGrid.Visibility == UI.Xaml.Visibility.Visible); })); } }