From d77b18f7a0c480fd694b2b53960e3c86062e49cd Mon Sep 17 00:00:00 2001 From: Shane Neuville Date: Fri, 1 Mar 2024 16:39:43 -0600 Subject: [PATCH] Bump the windowsappsdk group with 3 updates (#20460) * Bump the windowsappsdk group with 3 updates * Cache the current pane display mode change in shell for flyout behavior to fix test crash * - fixed restart logic on winui * Update Versions.props --------- Co-authored-by: Mike Corsaro --- Directory.Build.targets | 2 +- eng/Versions.props | 2 +- .../tests/UITests/Tests/Issues/Issue17490.cs | 1 + .../Platform/Windows/MauiNavigationView.cs | 31 +++++++++++++++++++ .../Windows/NavigationViewExtensions.cs | 20 +----------- .../Actions/AppiumLifecycleActions.cs | 13 ++++++-- src/TestUtils/src/UITest.NUnit/UITestBase.cs | 11 +++++-- 7 files changed, 55 insertions(+), 25 deletions(-) diff --git a/Directory.Build.targets b/Directory.Build.targets index 5feebecca537..2224ef7b3fd5 100644 --- a/Directory.Build.targets +++ b/Directory.Build.targets @@ -70,7 +70,7 @@ - + 8.0.0 - 1.3.230724000 + 1.5.240227000 10.0.22621.756 1.0.5.1 diff --git a/src/Controls/tests/UITests/Tests/Issues/Issue17490.cs b/src/Controls/tests/UITests/Tests/Issues/Issue17490.cs index 5a1eee49bb30..34168cedd3e1 100644 --- a/src/Controls/tests/UITests/Tests/Issues/Issue17490.cs +++ b/src/Controls/tests/UITests/Tests/Issues/Issue17490.cs @@ -13,6 +13,7 @@ public Issue17490(TestDevice device) : base(device) public override string Issue => "Crash using Pinvoke.SetParent to create Window as Child"; [Test] + [Ignore("This broke with WinAPPSDK 1.4 and we currently don't have an alternative https://github.com/dotnet/maui/issues/20253")] [Category(UITestCategories.Window)] public void AppDoesntCrashWhenOpeningWinUIWindowParentedToCurrentWindow() { diff --git a/src/Core/src/Platform/Windows/MauiNavigationView.cs b/src/Core/src/Platform/Windows/MauiNavigationView.cs index 05732d78f68c..73f68a1be578 100644 --- a/src/Core/src/Platform/Windows/MauiNavigationView.cs +++ b/src/Core/src/Platform/Windows/MauiNavigationView.cs @@ -18,6 +18,8 @@ namespace Microsoft.Maui.Platform [Microsoft.UI.Xaml.Data.Bindable] public partial class MauiNavigationView : NavigationView { + private int _currentFlyoutBehavior = -1; + internal StackPanel? TopNavArea { get; private set; } internal ItemsRepeater? TopNavMenuItemsHost { get; private set; } internal Grid? PaneContentGrid { get; private set; } @@ -159,6 +161,35 @@ private protected virtual void OnApplyTemplateCore() { } + internal void UpdatePaneDisplayModeFromFlyoutBehavior(FlyoutBehavior flyoutBehavior) + { + if (_currentFlyoutBehavior == (int)flyoutBehavior) + { + return; + } + + _currentFlyoutBehavior = (int)flyoutBehavior; + switch (flyoutBehavior) + { + case FlyoutBehavior.Flyout: + IsPaneToggleButtonVisible = true; + // Workaround for + // https://github.com/microsoft/microsoft-ui-xaml/issues/6493 + PaneDisplayMode = NavigationViewPaneDisplayMode.LeftCompact; + PaneDisplayMode = NavigationViewPaneDisplayMode.LeftMinimal; + break; + case FlyoutBehavior.Locked: + PaneDisplayMode = NavigationViewPaneDisplayMode.Left; + IsPaneToggleButtonVisible = false; + break; + case FlyoutBehavior.Disabled: + PaneDisplayMode = NavigationViewPaneDisplayMode.LeftMinimal; + IsPaneToggleButtonVisible = false; + IsPaneOpen = false; + break; + } + } + #region Toolbar internal static readonly DependencyProperty ToolbarProperty = DependencyProperty.Register(nameof(Toolbar), typeof(UIElement), typeof(MauiNavigationView), diff --git a/src/Core/src/Platform/Windows/NavigationViewExtensions.cs b/src/Core/src/Platform/Windows/NavigationViewExtensions.cs index 896cb8e3b97d..1c9831e9fb1d 100644 --- a/src/Core/src/Platform/Windows/NavigationViewExtensions.cs +++ b/src/Core/src/Platform/Windows/NavigationViewExtensions.cs @@ -243,25 +243,7 @@ public static void UpdateFlyoutVerticalScrollMode(this MauiNavigationView naviga public static void UpdateFlyoutBehavior(this MauiNavigationView navigationView, IFlyoutView flyoutView) { - switch (flyoutView.FlyoutBehavior) - { - case FlyoutBehavior.Flyout: - navigationView.IsPaneToggleButtonVisible = true; - // Workaround for - // https://github.com/microsoft/microsoft-ui-xaml/issues/6493 - navigationView.PaneDisplayMode = NavigationViewPaneDisplayMode.LeftCompact; - navigationView.PaneDisplayMode = NavigationViewPaneDisplayMode.LeftMinimal; - break; - case FlyoutBehavior.Locked: - navigationView.PaneDisplayMode = NavigationViewPaneDisplayMode.Left; - navigationView.IsPaneToggleButtonVisible = false; - break; - case FlyoutBehavior.Disabled: - navigationView.PaneDisplayMode = NavigationViewPaneDisplayMode.LeftMinimal; - navigationView.IsPaneToggleButtonVisible = false; - navigationView.IsPaneOpen = false; - break; - } + navigationView.UpdatePaneDisplayModeFromFlyoutBehavior(flyoutView.FlyoutBehavior); } public static void UpdateFlyoutWidth(this MauiNavigationView navigationView, IFlyoutView flyoutView) diff --git a/src/TestUtils/src/UITest.Appium/Actions/AppiumLifecycleActions.cs b/src/TestUtils/src/UITest.Appium/Actions/AppiumLifecycleActions.cs index 6e7a6d743ff6..09a297a98656 100644 --- a/src/TestUtils/src/UITest.Appium/Actions/AppiumLifecycleActions.cs +++ b/src/TestUtils/src/UITest.Appium/Actions/AppiumLifecycleActions.cs @@ -1,4 +1,5 @@ using OpenQA.Selenium.Appium.Android; +using OpenQA.Selenium.Appium.Windows; using UITest.Core; namespace UITest.Appium @@ -63,7 +64,14 @@ CommandResponse ForegroundApp(IDictionary parameters) if (_app?.Driver is null) return CommandResponse.FailedEmptyResponse; - _app.Driver.ActivateApp(_app.GetAppId()); + if (_app.Driver is WindowsDriver wd) + { + wd.SwitchTo().Window(wd.WindowHandles.First()); + } + else + { + _app.Driver.ActivateApp(_app.GetAppId()); + } return CommandResponse.SuccessEmptyResponse; } @@ -113,7 +121,8 @@ CommandResponse CloseApp(IDictionary parameters) if (_app?.Driver is null) return CommandResponse.FailedEmptyResponse; - _app.Driver.CloseApp(); + if(_app.AppState != ApplicationState.NotRunning) + _app.Driver.CloseApp(); return CommandResponse.SuccessEmptyResponse; } diff --git a/src/TestUtils/src/UITest.NUnit/UITestBase.cs b/src/TestUtils/src/UITest.NUnit/UITestBase.cs index 055e0029d89e..8c2600accb51 100644 --- a/src/TestUtils/src/UITest.NUnit/UITestBase.cs +++ b/src/TestUtils/src/UITest.NUnit/UITestBase.cs @@ -104,7 +104,9 @@ public void OneTimeTearDown() outcome.Site == ResultState.SetUpFailure.Site) { SaveDeviceDiagnosticInfo(); - SaveUIDiagnosticInfo(); + + if (App.AppState != ApplicationState.NotRunning) + SaveUIDiagnosticInfo(); } FixtureTeardown(); @@ -131,8 +133,11 @@ void SaveDeviceDiagnosticInfo([CallerMemberName] string? note = null) } } - protected void SaveUIDiagnosticInfo([CallerMemberName] string? note = null) + protected bool SaveUIDiagnosticInfo([CallerMemberName] string? note = null) { + if (App.AppState == ApplicationState.NotRunning) + return false; + var screenshotPath = GetGeneratedFilePath("ScreenShot.png", note); if (screenshotPath is not null) { @@ -148,6 +153,8 @@ protected void SaveUIDiagnosticInfo([CallerMemberName] string? note = null) AddTestAttachment(pageSourcePath, Path.GetFileName(pageSourcePath)); } + + return true; } string? GetGeneratedFilePath(string filename, string? note = null)