diff --git a/samples/IntegrationTestApp/MainWindow.axaml b/samples/IntegrationTestApp/MainWindow.axaml index ce41a8c121..ec49e4bb10 100644 --- a/samples/IntegrationTestApp/MainWindow.axaml +++ b/samples/IntegrationTestApp/MainWindow.axaml @@ -93,6 +93,19 @@ + + + + + + Tray Icon Clicked diff --git a/src/Avalonia.Themes.Fluent/Controls/ContextMenu.xaml b/src/Avalonia.Themes.Fluent/Controls/ContextMenu.xaml index c4a93ccb19..50f4844271 100644 --- a/src/Avalonia.Themes.Fluent/Controls/ContextMenu.xaml +++ b/src/Avalonia.Themes.Fluent/Controls/ContextMenu.xaml @@ -38,6 +38,7 @@ + diff --git a/src/Avalonia.Themes.Simple/Controls/ContextMenu.xaml b/src/Avalonia.Themes.Simple/Controls/ContextMenu.xaml index 215f4eec5a..5c8f799f94 100644 --- a/src/Avalonia.Themes.Simple/Controls/ContextMenu.xaml +++ b/src/Avalonia.Themes.Simple/Controls/ContextMenu.xaml @@ -6,6 +6,7 @@ + diff --git a/tests/Avalonia.IntegrationTests.Appium/ContextMenuTests.cs b/tests/Avalonia.IntegrationTests.Appium/ContextMenuTests.cs new file mode 100644 index 0000000000..416c480a42 --- /dev/null +++ b/tests/Avalonia.IntegrationTests.Appium/ContextMenuTests.cs @@ -0,0 +1,36 @@ +using System.Threading; +using OpenQA.Selenium; +using OpenQA.Selenium.Interactions; +using Xunit; + +namespace Avalonia.IntegrationTests.Appium +{ + [Collection("Default")] + public class ContextMenuTests + { + private readonly AppiumDriver _session; + + public ContextMenuTests(DefaultAppFixture fixture) + { + _session = fixture.Session; + + var tabs = _session.FindElementByAccessibilityId("MainTabs"); + var tab = tabs.FindElementByName("ContextMenu"); + tab.Click(); + } + + [PlatformFact(TestPlatforms.Windows)] + public void Select_First_Item_With_Down_Arrow_Key() + { + var control = _session.FindElementByAccessibilityId("ShowContextMenu"); + + new Actions(_session) + .ContextClick(control) + .SendKeys(Keys.ArrowDown) + .Perform(); + + var clickedMenuItem = _session.FindElementByAccessibilityId("ContextMenuItem1"); + Assert.True(clickedMenuItem.GetIsFocused()); + } + } +} diff --git a/tests/Avalonia.IntegrationTests.Appium/ElementExtensions.cs b/tests/Avalonia.IntegrationTests.Appium/ElementExtensions.cs index 217d3cc4fa..d9317e8e6a 100644 --- a/tests/Avalonia.IntegrationTests.Appium/ElementExtensions.cs +++ b/tests/Avalonia.IntegrationTests.Appium/ElementExtensions.cs @@ -91,8 +91,7 @@ namespace Avalonia.IntegrationTests.Appium { if (RuntimeInformation.IsOSPlatform(OSPlatform.Windows)) { - var active = element.WrappedDriver.SwitchTo().ActiveElement() as AppiumWebElement; - return element.Id == active?.Id; + return element.GetAttribute("HasKeyboardFocus") == "True"; } else {