Browse Source

Fix flaky menu integration tests.

Move the mouse pointer out of the way of the menu when running integration tests on menu keys.
pull/8612/head
Steven Kirk 4 years ago
parent
commit
fcef065908
  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