|
|
@ -12,6 +12,7 @@ using OpenQA.Selenium.Interactions; |
|
|
using SixLabors.ImageSharp.PixelFormats; |
|
|
using SixLabors.ImageSharp.PixelFormats; |
|
|
using Xunit; |
|
|
using Xunit; |
|
|
using Xunit.Sdk; |
|
|
using Xunit.Sdk; |
|
|
|
|
|
using OpenQA.Selenium.Appium.Interfaces; |
|
|
|
|
|
|
|
|
namespace Avalonia.IntegrationTests.Appium |
|
|
namespace Avalonia.IntegrationTests.Appium |
|
|
{ |
|
|
{ |
|
|
@ -249,6 +250,36 @@ namespace Avalonia.IntegrationTests.Appium |
|
|
Assert.Equal(new Rgba32(255, 0, 0), centerColor); |
|
|
Assert.Equal(new Rgba32(255, 0, 0), centerColor); |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
[Theory] |
|
|
|
|
|
[InlineData(ShowWindowMode.NonOwned, true)] |
|
|
|
|
|
[InlineData(ShowWindowMode.Owned, true)] |
|
|
|
|
|
[InlineData(ShowWindowMode.Modal, true)] |
|
|
|
|
|
[InlineData(ShowWindowMode.NonOwned, false)] |
|
|
|
|
|
[InlineData(ShowWindowMode.Owned, false)] |
|
|
|
|
|
[InlineData(ShowWindowMode.Modal, false)] |
|
|
|
|
|
public void Window_Has_Disabled_Maximize_Button_When_CanResize_Is_False(ShowWindowMode mode, bool extendClientArea) |
|
|
|
|
|
{ |
|
|
|
|
|
using (OpenWindow(null, mode, WindowStartupLocation.Manual, canResize: false, extendClientArea: extendClientArea)) |
|
|
|
|
|
{ |
|
|
|
|
|
var secondaryWindow = GetWindow("SecondaryWindow"); |
|
|
|
|
|
AppiumWebElement? maximizeButton; |
|
|
|
|
|
|
|
|
|
|
|
if (RuntimeInformation.IsOSPlatform(OSPlatform.Windows)) |
|
|
|
|
|
{ |
|
|
|
|
|
var foo = _session.PageSource; |
|
|
|
|
|
maximizeButton = secondaryWindow.FindElementByXPath("//Button[@Name='Maximise']"); |
|
|
|
|
|
} |
|
|
|
|
|
else |
|
|
|
|
|
{ |
|
|
|
|
|
maximizeButton = mode == ShowWindowMode.NonOwned ? |
|
|
|
|
|
secondaryWindow.FindElementByAccessibilityId("_XCUI:FullScreenWindow") : |
|
|
|
|
|
secondaryWindow.FindElementByAccessibilityId("_XCUI:ZoomWindow"); |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
Assert.False(maximizeButton.Enabled); |
|
|
|
|
|
} |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
public static TheoryData<Size?, ShowWindowMode, WindowStartupLocation, bool> StartupLocationData() |
|
|
public static TheoryData<Size?, ShowWindowMode, WindowStartupLocation, bool> StartupLocationData() |
|
|
{ |
|
|
{ |
|
|
var sizes = new Size?[] { null, new Size(400, 300) }; |
|
|
var sizes = new Size?[] { null, new Size(400, 300) }; |
|
|
@ -333,7 +364,8 @@ namespace Avalonia.IntegrationTests.Appium |
|
|
ShowWindowMode mode, |
|
|
ShowWindowMode mode, |
|
|
WindowStartupLocation location = WindowStartupLocation.Manual, |
|
|
WindowStartupLocation location = WindowStartupLocation.Manual, |
|
|
WindowState state = Controls.WindowState.Normal, |
|
|
WindowState state = Controls.WindowState.Normal, |
|
|
bool canResize = true) |
|
|
bool canResize = true, |
|
|
|
|
|
bool extendClientArea = false) |
|
|
{ |
|
|
{ |
|
|
var sizeTextBox = _session.FindElementByAccessibilityId("ShowWindowSize"); |
|
|
var sizeTextBox = _session.FindElementByAccessibilityId("ShowWindowSize"); |
|
|
var modeComboBox = _session.FindElementByAccessibilityId("ShowWindowMode"); |
|
|
var modeComboBox = _session.FindElementByAccessibilityId("ShowWindowMode"); |
|
|
@ -341,7 +373,8 @@ namespace Avalonia.IntegrationTests.Appium |
|
|
var stateComboBox = _session.FindElementByAccessibilityId("ShowWindowState"); |
|
|
var stateComboBox = _session.FindElementByAccessibilityId("ShowWindowState"); |
|
|
var canResizeCheckBox = _session.FindElementByAccessibilityId("ShowWindowCanResize"); |
|
|
var canResizeCheckBox = _session.FindElementByAccessibilityId("ShowWindowCanResize"); |
|
|
var showButton = _session.FindElementByAccessibilityId("ShowWindow"); |
|
|
var showButton = _session.FindElementByAccessibilityId("ShowWindow"); |
|
|
|
|
|
var extendClientAreaCheckBox = _session.FindElementByAccessibilityId("ShowWindowExtendClientAreaToDecorationsHint"); |
|
|
|
|
|
|
|
|
if (size.HasValue) |
|
|
if (size.HasValue) |
|
|
sizeTextBox.SendKeys($"{size.Value.Width}, {size.Value.Height}"); |
|
|
sizeTextBox.SendKeys($"{size.Value.Width}, {size.Value.Height}"); |
|
|
|
|
|
|
|
|
@ -366,9 +399,27 @@ namespace Avalonia.IntegrationTests.Appium |
|
|
if (canResizeCheckBox.GetIsChecked() != canResize) |
|
|
if (canResizeCheckBox.GetIsChecked() != canResize) |
|
|
canResizeCheckBox.Click(); |
|
|
canResizeCheckBox.Click(); |
|
|
|
|
|
|
|
|
|
|
|
if (extendClientAreaCheckBox.GetIsChecked() != extendClientArea) |
|
|
|
|
|
extendClientAreaCheckBox.Click(); |
|
|
|
|
|
|
|
|
return showButton.OpenWindowWithClick(); |
|
|
return showButton.OpenWindowWithClick(); |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
private AppiumWebElement GetWindow(string identifier) |
|
|
|
|
|
{ |
|
|
|
|
|
if (RuntimeInformation.IsOSPlatform(OSPlatform.OSX)) |
|
|
|
|
|
{ |
|
|
|
|
|
// The Avalonia a11y tree currently exposes two nested Window elements, this is a bug and should be fixed
|
|
|
|
|
|
// but in the meantime use the `parent::' selector to return the parent "real" window.
|
|
|
|
|
|
return _session.FindElementByXPath( |
|
|
|
|
|
$"XCUIElementTypeWindow//*[@identifier='{identifier}']/parent::XCUIElementTypeWindow"); |
|
|
|
|
|
} |
|
|
|
|
|
else |
|
|
|
|
|
{ |
|
|
|
|
|
return _session.FindElementByXPath($"//Window[@AutomationId='{identifier}']"); |
|
|
|
|
|
} |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
private WindowInfo GetWindowInfo() |
|
|
private WindowInfo GetWindowInfo() |
|
|
{ |
|
|
{ |
|
|
PixelRect? ReadOwnerRect() |
|
|
PixelRect? ReadOwnerRect() |
|
|
|