|
|
@@ -26,28 +26,60 @@ namespace Avalonia.IntegrationTests.Appium
|
|
|
public void StartupLocation(PixelSize? size, ShowWindowMode mode, WindowStartupLocation location)
|
|
|
{
|
|
|
using var window = OpenWindow(size, mode, location);
|
|
|
- var clientSize = Size.Parse(_session.FindElementByAccessibilityId("ClientSize").Text);
|
|
|
- var frameSize = Size.Parse(_session.FindElementByAccessibilityId("FrameSize").Text);
|
|
|
- var position = PixelPoint.Parse(_session.FindElementByAccessibilityId("Position").Text);
|
|
|
- var screenRect = PixelRect.Parse(_session.FindElementByAccessibilityId("ScreenRect").Text);
|
|
|
- var scaling = double.Parse(_session.FindElementByAccessibilityId("Scaling").Text);
|
|
|
+ var info = GetWindowInfo();
|
|
|
|
|
|
- Assert.True(frameSize.Width >= clientSize.Width, "Expected frame width >= client width.");
|
|
|
- Assert.True(frameSize.Height > clientSize.Height, "Expected frame height > client height.");
|
|
|
+ Assert.True(info.FrameSize.Width >= info.ClientSize.Width, "Expected frame width >= client width.");
|
|
|
+ Assert.True(info.FrameSize.Height > info.ClientSize.Height, "Expected frame height > client height.");
|
|
|
|
|
|
- var frameRect = new PixelRect(position, PixelSize.FromSize(frameSize, scaling));
|
|
|
+ var frameRect = new PixelRect(info.Position, PixelSize.FromSize(info.FrameSize, info.Scaling));
|
|
|
|
|
|
switch (location)
|
|
|
{
|
|
|
case WindowStartupLocation.CenterScreen:
|
|
|
{
|
|
|
- var expected = screenRect.CenterRect(frameRect);
|
|
|
+ var expected = info.ScreenRect.CenterRect(frameRect);
|
|
|
AssertCloseEnough(expected.Position, frameRect.Position);
|
|
|
break;
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
-
|
|
|
+
|
|
|
+
|
|
|
+ [Theory]
|
|
|
+ [InlineData(ShowWindowMode.NonOwned)]
|
|
|
+ [InlineData(ShowWindowMode.Owned)]
|
|
|
+ [InlineData(ShowWindowMode.Modal)]
|
|
|
+ public void WindowState(ShowWindowMode mode)
|
|
|
+ {
|
|
|
+ using var window = OpenWindow(null, mode, WindowStartupLocation.Manual);
|
|
|
+ var windowState = _session.FindElementByAccessibilityId("WindowState");
|
|
|
+ var original = GetWindowInfo();
|
|
|
+
|
|
|
+ Assert.Equal("Normal", windowState.GetComboBoxValue());
|
|
|
+
|
|
|
+ windowState.Click();
|
|
|
+ _session.FindElementByName("Maximized").SendClick();
|
|
|
+ Assert.Equal("Maximized", windowState.GetComboBoxValue());
|
|
|
+
|
|
|
+ windowState.Click();
|
|
|
+ _session.FindElementByName("Normal").SendClick();
|
|
|
+
|
|
|
+ var current = GetWindowInfo();
|
|
|
+ Assert.Equal(original.Position, current.Position);
|
|
|
+ Assert.Equal(original.FrameSize, current.FrameSize);
|
|
|
+
|
|
|
+ windowState.Click();
|
|
|
+ _session.FindElementByName("Fullscreen").SendClick();
|
|
|
+ Assert.Equal("Fullscreen", windowState.GetComboBoxValue());
|
|
|
+
|
|
|
+ windowState.Click();
|
|
|
+ _session.FindElementByName("Normal").SendClick();
|
|
|
+
|
|
|
+ current = GetWindowInfo();
|
|
|
+ Assert.Equal(original.Position, current.Position);
|
|
|
+ Assert.Equal(original.FrameSize, current.FrameSize);
|
|
|
+ }
|
|
|
+
|
|
|
public static TheoryData<PixelSize?, ShowWindowMode, WindowStartupLocation> StartupLocationData()
|
|
|
{
|
|
|
var sizes = new PixelSize?[] { null, new PixelSize(400, 300) };
|
|
|
@@ -115,11 +147,29 @@ namespace Avalonia.IntegrationTests.Appium
|
|
|
return showButton.OpenWindowWithClick();
|
|
|
}
|
|
|
|
|
|
+ private WindowInfo GetWindowInfo()
|
|
|
+ {
|
|
|
+ return new(
|
|
|
+ Size.Parse(_session.FindElementByAccessibilityId("ClientSize").Text),
|
|
|
+ Size.Parse(_session.FindElementByAccessibilityId("FrameSize").Text),
|
|
|
+ PixelPoint.Parse(_session.FindElementByAccessibilityId("Position").Text),
|
|
|
+ PixelRect.Parse(_session.FindElementByAccessibilityId("ScreenRect").Text),
|
|
|
+ double.Parse(_session.FindElementByAccessibilityId("Scaling").Text));
|
|
|
+
|
|
|
+ }
|
|
|
+
|
|
|
public enum ShowWindowMode
|
|
|
{
|
|
|
NonOwned,
|
|
|
Owned,
|
|
|
Modal
|
|
|
}
|
|
|
+
|
|
|
+ private record WindowInfo(
|
|
|
+ Size ClientSize,
|
|
|
+ Size FrameSize,
|
|
|
+ PixelPoint Position,
|
|
|
+ PixelRect ScreenRect,
|
|
|
+ double Scaling);
|
|
|
}
|
|
|
}
|