Skip to content

Commit

Permalink
Add tests
Browse files Browse the repository at this point in the history
  • Loading branch information
Mike Corsaro committed Nov 25, 2024
1 parent 3350648 commit 67478d5
Showing 1 changed file with 20 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -68,21 +68,35 @@ await CreateHandlerAndAddToWindow<IWindowHandler>(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);
var modalNavigationRootManager = modalPage
.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);
});
}

Expand Down Expand Up @@ -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);
}));
}
}
Expand Down

0 comments on commit 67478d5

Please sign in to comment.