Browse Source

Handle fullscreen windows better on mac.

pull/9221/head
Steven Kirk 4 years ago
parent
commit
d413fbbb8e
  1. 17
      tests/Avalonia.IntegrationTests.Appium/ElementExtensions.cs
  2. 5
      tests/Avalonia.IntegrationTests.Appium/WindowTests.cs

17
tests/Avalonia.IntegrationTests.Appium/ElementExtensions.cs

@ -3,6 +3,7 @@ using System.Collections.Generic;
using System.Linq;
using System.Reactive.Disposables;
using System.Runtime.InteropServices;
using System.Threading;
using OpenQA.Selenium;
using OpenQA.Selenium.Appium;
using OpenQA.Selenium.Interactions;
@ -110,24 +111,30 @@ namespace Avalonia.IntegrationTests.Appium
{
var oldWindows = session.FindElements(By.XPath("/XCUIElementTypeApplication/XCUIElementTypeWindow"));
var oldWindowTitles = oldWindows.ToDictionary(x => x.Text);
element.Click();
// Wait for animations to run.
Thread.Sleep(1000);
var newWindows = session.FindElements(By.XPath("/XCUIElementTypeApplication/XCUIElementTypeWindow"));
var newWindowTitles = newWindows.ToDictionary(x => x.Text);
var newWindowTitle = Assert.Single(newWindowTitles.Keys.Except(oldWindowTitles.Keys));
var newWindow = (AppiumWebElement)newWindowTitles[newWindowTitle];
return Disposable.Create(() =>
{
// TODO: We should be able to use Cmd+W here but Avalonia apps don't seem to have this shortcut
// set up by default.
var (close, _, _) = newWindow.GetChromeButtons();
var windows = session.FindElements(By.XPath("/XCUIElementTypeApplication/XCUIElementTypeWindow"));
var text = windows.Select(x => x.Text).ToList();
var newWindow = session.FindElements(By.XPath("/XCUIElementTypeApplication/XCUIElementTypeWindow"))
.First(x => x.Text == newWindowTitle);
var (close, _, _) = ((AppiumWebElement)newWindow).GetChromeButtons();
close!.Click();
});
}
}
public static void SendClick(this AppiumWebElement element)
{
// The Click() method seems to correspond to accessibilityPerformPress on macOS but certain controls

5
tests/Avalonia.IntegrationTests.Appium/WindowTests.cs

@ -89,6 +89,11 @@ namespace Avalonia.IntegrationTests.Appium
{
_session.FindElementByAccessibilityId("WindowState").SendClick();
_session.FindElementByName("Normal").SendClick();
// Wait for animations to run.
if (RuntimeInformation.IsOSPlatform(OSPlatform.OSX))
Thread.Sleep(1000);
} catch { /* Ignore errors in cleanup */ }
}
}

Loading…
Cancel
Save