Browse Source

Merge pull request #8612 from AvaloniaUI/fixes/flaky-menu-integration-tests

Trying to fix flaky menu integration tests on win32.
composition/license
Max Katz 4 years ago
committed by GitHub
parent
commit
c89421cb0d
No known key found for this signature in database GPG Key ID: 4AEE18F83AFDEB23
  1. 22
      tests/Avalonia.IntegrationTests.Appium/MenuTests.cs

22
tests/Avalonia.IntegrationTests.Appium/MenuTests.cs

@ -60,6 +60,8 @@ namespace Avalonia.IntegrationTests.Appium
[PlatformFact(TestPlatforms.Windows)]
public void Select_Child_With_Alt_Arrow_Keys()
{
MovePointerOutOfTheWay();
new Actions(_session)
.KeyDown(Keys.Alt).KeyUp(Keys.Alt)
.SendKeys(Keys.Down + Keys.Enter)
@ -72,6 +74,8 @@ namespace Avalonia.IntegrationTests.Appium
[PlatformFact(TestPlatforms.Windows)]
public void Select_Grandchild_With_Alt_Arrow_Keys()
{
MovePointerOutOfTheWay();
new Actions(_session)
.KeyDown(Keys.Alt).KeyUp(Keys.Alt)
.SendKeys(Keys.Down + Keys.Down + Keys.Right + Keys.Enter)
@ -84,6 +88,8 @@ namespace Avalonia.IntegrationTests.Appium
[PlatformFact(TestPlatforms.Windows)]
public void Select_Child_With_Alt_Access_Keys()
{
MovePointerOutOfTheWay();
new Actions(_session)
.KeyDown(Keys.Alt).KeyUp(Keys.Alt)
.SendKeys("rc")
@ -96,6 +102,8 @@ namespace Avalonia.IntegrationTests.Appium
[PlatformFact(TestPlatforms.Windows)]
public void Select_Grandchild_With_Alt_Access_Keys()
{
MovePointerOutOfTheWay();
new Actions(_session)
.KeyDown(Keys.Alt).KeyUp(Keys.Alt)
.SendKeys("rhg")
@ -111,6 +119,8 @@ namespace Avalonia.IntegrationTests.Appium
var rootMenuItem = _session.FindElementByAccessibilityId("RootMenuItem");
rootMenuItem.SendClick();
MovePointerOutOfTheWay();
new Actions(_session)
.SendKeys(Keys.Down + Keys.Enter)
.Perform();
@ -125,6 +135,8 @@ namespace Avalonia.IntegrationTests.Appium
var rootMenuItem = _session.FindElementByAccessibilityId("RootMenuItem");
rootMenuItem.SendClick();
MovePointerOutOfTheWay();
new Actions(_session)
.SendKeys(Keys.Down + Keys.Down + Keys.Right + Keys.Enter)
.Perform();
@ -159,5 +171,15 @@ namespace Avalonia.IntegrationTests.Appium
Assert.True(textBox.GetIsFocused());
}
private void MovePointerOutOfTheWay()
{
// Move the pointer to the menu tab item so that it's not over the menu in preparation
// for key press tests. This prevents the mouse accidentially selecting the wrong item
// by hovering.
var tabs = _session.FindElementByAccessibilityId("MainTabs");
var tab = tabs.FindElementByName("Menu");
tab.MovePointerOver();
}
}
}

Loading…
Cancel
Save