Skip to content

Commit

Permalink
Don't use a tuple for window chrome buttons.
Browse files Browse the repository at this point in the history
Return a record so that we can add extra elements more easily.
  • Loading branch information
grokys committed Mar 13, 2023

Verified

This commit was created on GitHub.com and signed with GitHub’s verified signature. The key has expired.
1 parent 9845dfa commit d46eb22
Showing 2 changed files with 9 additions and 4 deletions.
9 changes: 7 additions & 2 deletions tests/Avalonia.IntegrationTests.Appium/ElementExtensions.cs
Original file line number Diff line number Diff line change
@@ -11,19 +11,24 @@

namespace Avalonia.IntegrationTests.Appium
{
public record class WindowChrome(
AppiumWebElement Close,
AppiumWebElement Minimize,
AppiumWebElement Maximize);

internal static class ElementExtensions
{
public static IReadOnlyList<AppiumWebElement> GetChildren(this AppiumWebElement element) =>
element.FindElementsByXPath("*/*");

public static (AppiumWebElement close, AppiumWebElement minimize, AppiumWebElement maximize) GetChromeButtons(this AppiumWebElement window)
public static WindowChrome GetChromeButtons(this AppiumWebElement window)
{
if (RuntimeInformation.IsOSPlatform(OSPlatform.OSX))
{
var closeButton = window.FindElementByXPath("//XCUIElementTypeButton[1]");
var fullscreenButton = window.FindElementByXPath("//XCUIElementTypeButton[2]");
var minimizeButton = window.FindElementByXPath("//XCUIElementTypeButton[3]");
return (closeButton, minimizeButton, fullscreenButton);
return new(closeButton, minimizeButton, fullscreenButton);
}

throw new NotSupportedException("GetChromeButtons not supported on this platform.");
4 changes: 2 additions & 2 deletions tests/Avalonia.IntegrationTests.Appium/WindowTests_MacOS.cs
Original file line number Diff line number Diff line change
@@ -85,7 +85,7 @@ public void WindowOrder_Modal_Dialog_Stays_InFront_Of_Parent_When_In_Fullscreen(
var mainWindow = GetWindow("MainWindow");
var buttons = mainWindow.GetChromeButtons();

buttons.maximize.Click();
buttons.Maximize.Click();

Thread.Sleep(500);

@@ -332,7 +332,7 @@ public void Hidden_Child_Window_Is_Not_Reshown_When_Parent_Clicked()

// Close the window manually.
secondaryWindow = GetWindow("SecondaryWindow");
secondaryWindow.GetChromeButtons().close.Click();
secondaryWindow.GetChromeButtons().Close.Click();
}

[PlatformTheory(TestPlatforms.MacOS)]

0 comments on commit d46eb22

Please sign in to comment.