Browse Source

Run check for disabled maximize button on Windows.

And also check with client-side decorations.
pull/10851/head
Steven Kirk 3 years ago
parent
commit
f8a8c4ab1f
  1. 9
      src/Avalonia.Themes.Fluent/Controls/CaptionButtons.xaml
  2. 55
      tests/Avalonia.IntegrationTests.Appium/WindowTests.cs
  3. 16
      tests/Avalonia.IntegrationTests.Appium/WindowTests_MacOS.cs

9
src/Avalonia.Themes.Fluent/Controls/CaptionButtons.xaml

@ -48,7 +48,8 @@
</Viewbox>
</Button>
<Button x:Name="PART_MinimiseButton"
Theme="{StaticResource FluentCaptionButton}">
Theme="{StaticResource FluentCaptionButton}"
AutomationProperties.Name="Minimise">
<Viewbox Width="11" Margin="2">
<Path Stretch="UniformToFill"
Fill="{TemplateBinding Foreground}"
@ -56,7 +57,8 @@
</Viewbox>
</Button>
<Button x:Name="PART_RestoreButton"
Theme="{StaticResource FluentCaptionButton}">
Theme="{StaticResource FluentCaptionButton}"
AutomationProperties.Name="Maximise">
<Viewbox Width="11" Margin="2">
<Viewbox.RenderTransform>
<RotateTransform Angle="-90" />
@ -70,7 +72,8 @@
<Button x:Name="PART_CloseButton"
Background="#ffe81123"
BorderBrush="#fff1707a"
Theme="{StaticResource FluentCaptionButton}">
Theme="{StaticResource FluentCaptionButton}"
AutomationProperties.Name="Close">
<Viewbox Width="11" Margin="2">
<Path Stretch="UniformToFill"
Fill="{TemplateBinding Foreground}"

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

@ -12,6 +12,7 @@ using OpenQA.Selenium.Interactions;
using SixLabors.ImageSharp.PixelFormats;
using Xunit;
using Xunit.Sdk;
using OpenQA.Selenium.Appium.Interfaces;
namespace Avalonia.IntegrationTests.Appium
{
@ -249,6 +250,36 @@ namespace Avalonia.IntegrationTests.Appium
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()
{
var sizes = new Size?[] { null, new Size(400, 300) };
@ -333,7 +364,8 @@ namespace Avalonia.IntegrationTests.Appium
ShowWindowMode mode,
WindowStartupLocation location = WindowStartupLocation.Manual,
WindowState state = Controls.WindowState.Normal,
bool canResize = true)
bool canResize = true,
bool extendClientArea = false)
{
var sizeTextBox = _session.FindElementByAccessibilityId("ShowWindowSize");
var modeComboBox = _session.FindElementByAccessibilityId("ShowWindowMode");
@ -341,7 +373,8 @@ namespace Avalonia.IntegrationTests.Appium
var stateComboBox = _session.FindElementByAccessibilityId("ShowWindowState");
var canResizeCheckBox = _session.FindElementByAccessibilityId("ShowWindowCanResize");
var showButton = _session.FindElementByAccessibilityId("ShowWindow");
var extendClientAreaCheckBox = _session.FindElementByAccessibilityId("ShowWindowExtendClientAreaToDecorationsHint");
if (size.HasValue)
sizeTextBox.SendKeys($"{size.Value.Width}, {size.Value.Height}");
@ -366,9 +399,27 @@ namespace Avalonia.IntegrationTests.Appium
if (canResizeCheckBox.GetIsChecked() != canResize)
canResizeCheckBox.Click();
if (extendClientAreaCheckBox.GetIsChecked() != extendClientArea)
extendClientAreaCheckBox.Click();
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()
{
PixelRect? ReadOwnerRect()

16
tests/Avalonia.IntegrationTests.Appium/WindowTests_MacOS.cs

@ -336,22 +336,6 @@ namespace Avalonia.IntegrationTests.Appium
secondaryWindow.FindElementByAccessibilityId("_XCUI:CloseWindow").Click();
}
[PlatformTheory(TestPlatforms.MacOS)]
[InlineData(ShowWindowMode.NonOwned)]
[InlineData(ShowWindowMode.Owned)]
[InlineData(ShowWindowMode.Modal)]
public void Window_Has_Disabled_Zoom_Button_When_CanResize_Is_False(ShowWindowMode mode)
{
using (OpenWindow(null, mode, WindowStartupLocation.Manual, canResize: false))
{
var secondaryWindow = GetWindow("SecondaryWindow");
var zoomButton = mode == ShowWindowMode.NonOwned ?
secondaryWindow.FindElementByAccessibilityId("_XCUI:FullScreenWindow") :
secondaryWindow.FindElementByAccessibilityId("_XCUI:ZoomWindow");
Assert.False(zoomButton.Enabled);
}
}
[PlatformFact(TestPlatforms.MacOS)]
public void Toggling_SystemDecorations_Should_Preserve_ExtendClientArea()
{

Loading…
Cancel
Save