Browse Source

Adjust integrational tests to work on 11.1 branch

release/11.1.3
Max Katz 2 years ago
parent
commit
bd0d0b9b11
  1. 6
      samples/IntegrationTestApp/IntegrationTestApp.csproj
  2. 1
      samples/IntegrationTestApp/MainWindow.axaml
  3. 5
      samples/IntegrationTestApp/MainWindow.axaml.cs
  4. 19
      samples/IntegrationTestApp/Pages/PointerPage.axaml
  5. 47
      samples/IntegrationTestApp/Pages/PointerPage.axaml.cs
  6. 19
      samples/IntegrationTestApp/Pages/ScreensPage.axaml
  7. 32
      samples/IntegrationTestApp/Pages/ScreensPage.axaml.cs
  8. 1
      samples/IntegrationTestApp/Pages/WindowPage.axaml
  9. 17
      samples/IntegrationTestApp/Pages/WindowPage.axaml.cs
  10. 7
      samples/IntegrationTestApp/ShowWindowTest.axaml.cs
  11. 6
      tests/Avalonia.IntegrationTests.Appium/WindowTests.cs
  12. 2
      tests/Avalonia.IntegrationTests.Appium/WindowTests_MacOS.cs

6
samples/IntegrationTestApp/IntegrationTestApp.csproj

@ -4,6 +4,7 @@
<TargetFramework>$(AvsCurrentTargetFramework)</TargetFramework>
<Nullable>enable</Nullable>
<NoWarn>$(NoWarn);AVP1012</NoWarn>
<IncludeAvaloniaGenerators>true</IncludeAvaloniaGenerators>
</PropertyGroup>
<PropertyGroup>
@ -25,13 +26,12 @@
<ProjectReference Include="..\..\src\Avalonia.Diagnostics\Avalonia.Diagnostics.csproj" />
<ProjectReference Include="..\..\src\Avalonia.Themes.Fluent\Avalonia.Themes.Fluent.csproj" />
<ProjectReference Include="..\..\src\Avalonia.Fonts.Inter\Avalonia.Fonts.Inter.csproj" />
</ItemGroup>
<ProjectReference Include="..\MiniMvvm\MiniMvvm.csproj" />
</ItemGroup>
<Import Project="..\..\build\BuildTargets.targets" />
<Import Project="..\..\build\SampleApp.props" />
<Import Project="..\..\build\ReferenceCoreLibraries.props" />
<Import Project="..\..\build\SourceGenerators.props" />
</Project>

1
samples/IntegrationTestApp/MainWindow.axaml

@ -5,7 +5,6 @@
xmlns:vm="using:IntegrationTestApp.ViewModels"
mc:Ignorable="d" d:DesignWidth="800" d:DesignHeight="450"
x:Class="IntegrationTestApp.MainWindow"
Name="MainWindow"
Icon="/Assets/icon.ico"
Title="IntegrationTestApp"
x:DataType="vm:MainWindowViewModel">

5
samples/IntegrationTestApp/MainWindow.axaml.cs

@ -6,7 +6,7 @@ using IntegrationTestApp.ViewModels;
namespace IntegrationTestApp
{
public class MainWindow : Window
public partial class MainWindow : Window
{
public MainWindow()
{
@ -23,7 +23,6 @@ namespace IntegrationTestApp
private void InitializeViewMenu(IEnumerable<Page> pages)
{
var mainTabs = this.Get<TabControl>("MainTabs");
var viewMenu = (NativeMenuItem?)NativeMenu.GetMenu(this)?.Items[1];
foreach (var page in pages)
@ -64,9 +63,7 @@ namespace IntegrationTestApp
new("Gestures", () => new GesturesPage()),
new("ListBox", () => new ListBoxPage()),
new("Menu", () => new MenuPage()),
new("Pointer", () => new PointerPage()),
new("RadioButton", () => new RadioButtonPage()),
new("Screens", () => new ScreensPage()),
new("ScrollBar", () => new ScrollBarPage()),
new("Slider", () => new SliderPage()),
new("Window Decorations", () => new WindowDecorationsPage()),

19
samples/IntegrationTestApp/Pages/PointerPage.axaml

@ -1,19 +0,0 @@
<UserControl xmlns="https://github.com/avaloniaui"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
mc:Ignorable="d" d:DesignWidth="800" d:DesignHeight="450"
x:Class="IntegrationTestApp.Pages.PointerPage">
<StackPanel>
<!-- Trigger with PointerPressed rather using a Button so we have access to the pointer. -->
<Border Name="PointerPageShowDialog"
Background="{DynamicResource ButtonBackground}"
HorizontalAlignment="Left"
Padding="{DynamicResource ButtonPadding}"
AutomationProperties.AccessibilityView="Control"
PointerPressed="PointerPageShowDialog_PointerPressed">
<TextBlock>Show Dialog</TextBlock>
</Border>
<TextBlock Name="PointerCaptureStatus"/>
</StackPanel>
</UserControl>

47
samples/IntegrationTestApp/Pages/PointerPage.axaml.cs

@ -1,47 +0,0 @@
using Avalonia;
using Avalonia.Controls;
using Avalonia.Input;
namespace IntegrationTestApp.Pages;
public partial class PointerPage : UserControl
{
public PointerPage()
{
InitializeComponent();
}
private void PointerPageShowDialog_PointerPressed(object? sender, PointerPressedEventArgs e)
{
void CaptureLost(object? sender, PointerCaptureLostEventArgs e)
{
PointerCaptureStatus.Text = "None";
((Control)sender!).PointerCaptureLost -= CaptureLost;
}
var window = TopLevel.GetTopLevel(this) as Window ??
throw new AvaloniaInternalException("PointerPage is not attached to a Window.");
var captured = e.Pointer.Captured as Control;
if (captured is not null)
{
captured.PointerCaptureLost += CaptureLost;
}
PointerCaptureStatus.Text = captured?.ToString() ?? "None";
var dialog = new Window
{
Width = 200,
Height = 200,
};
dialog.Content = new Button
{
Content = "Close",
Command = new DelegateCommand(() => dialog.Close()),
};
dialog.ShowDialog(window);
}
}

19
samples/IntegrationTestApp/Pages/ScreensPage.axaml

@ -1,19 +0,0 @@
<UserControl xmlns="https://github.com/avaloniaui"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
mc:Ignorable="d" d:DesignWidth="800" d:DesignHeight="450"
x:Class="IntegrationTestApp.Pages.ScreensPage">
<StackPanel Spacing="4">
<Button Name="ScreenRefresh"
Content="Refresh"
Click="ScreenRefresh_Click"/>
<TextBox Name="ScreenName" Watermark="DisplayName" UseFloatingWatermark="true" />
<TextBox Name="ScreenHandle" Watermark="Handle" UseFloatingWatermark="true" />
<TextBox Name="ScreenScaling" Watermark="Scaling" UseFloatingWatermark="true" />
<TextBox Name="ScreenBounds" Watermark="Bounds" UseFloatingWatermark="true" />
<TextBox Name="ScreenWorkArea" Watermark="WorkArea" UseFloatingWatermark="true" />
<TextBox Name="ScreenOrientation" Watermark="Orientation" UseFloatingWatermark="true" />
<TextBox Name="ScreenSameReference" Watermark="Is same reference" UseFloatingWatermark="true" />
</StackPanel>
</UserControl>

32
samples/IntegrationTestApp/Pages/ScreensPage.axaml.cs

@ -1,32 +0,0 @@
using System.Globalization;
using Avalonia;
using Avalonia.Controls;
using Avalonia.Interactivity;
using Avalonia.Platform;
namespace IntegrationTestApp.Pages;
public partial class ScreensPage : UserControl
{
private Screen? _lastScreen;
public ScreensPage()
{
InitializeComponent();
}
private void ScreenRefresh_Click(object? sender, RoutedEventArgs e)
{
var window = TopLevel.GetTopLevel(this) as Window ??
throw new AvaloniaInternalException("ScreensPage is not attached to a Window.");
var lastScreen = _lastScreen;
var screen = _lastScreen = window.Screens.ScreenFromWindow(window);
ScreenName.Text = screen?.DisplayName;
ScreenHandle.Text = screen?.TryGetPlatformHandle()?.ToString();
ScreenBounds.Text = screen?.Bounds.ToString();
ScreenWorkArea.Text = screen?.WorkingArea.ToString();
ScreenScaling.Text = screen?.Scaling.ToString(CultureInfo.InvariantCulture);
ScreenOrientation.Text = screen?.CurrentOrientation.ToString();
ScreenSameReference.Text = ReferenceEquals(lastScreen, screen).ToString();
}
}

1
samples/IntegrationTestApp/Pages/WindowPage.axaml

@ -35,7 +35,6 @@
<Button Name="EnterFullscreen" Click="EnterFullscreen_Click">Enter Fullscreen</Button>
<Button Name="ExitFullscreen" Click="ExitFullscreen_Click">Exit Fullscreen</Button>
<Button Name="RestoreAll" Click="RestoreAll_Click">Restore All</Button>
<Button Name="ShowTopmostWindow" Click="ShowTopmostWindow_Click">Show Topmost Window</Button>
</StackPanel>
<StackPanel Grid.Column="2">
<Button Name="ShowTransparentWindow" Click="ShowTransparentWindow_Click">Transparent Window</Button>

17
samples/IntegrationTestApp/Pages/WindowPage.axaml.cs

@ -179,21 +179,4 @@ public partial class WindowPage : UserControl
window.WindowState = WindowState.Normal;
}
}
private void ShowTopmostWindow_Click(object? sender, RoutedEventArgs e)
{
var mainWindow = new TopmostWindowTest("OwnerWindow")
{
Topmost = true,
Title = "Owner Window"
};
var ownedWindow = new TopmostWindowTest("OwnedWindow")
{
WindowStartupLocation = WindowStartupLocation.CenterOwner,
Title = "Owned Window"
};
mainWindow.Show();
ownedWindow.Show(mainWindow);
}
}

7
samples/IntegrationTestApp/ShowWindowTest.axaml.cs

@ -25,7 +25,7 @@ namespace IntegrationTestApp
}
}
public class ShowWindowTest : Window
public partial class ShowWindowTest : Window
{
private readonly DispatcherTimer? _timer;
private readonly TextBox? _orderTextBox;
@ -44,11 +44,6 @@ namespace IntegrationTestApp
_timer.Start();
}
}
private void InitializeComponent()
{
AvaloniaXamlLoader.Load(this);
}
protected override void OnOpened(EventArgs e)
{

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

@ -262,7 +262,7 @@ namespace Avalonia.IntegrationTests.Appium
{
using (OpenWindow(null, mode, WindowStartupLocation.Manual, canResize: false, extendClientArea: extendClientArea))
{
var secondaryWindow = Session.GetWindowById("SecondaryWindow");
var secondaryWindow = GetWindow("SecondaryWindow");
AppiumWebElement? maximizeButton;
if (RuntimeInformation.IsOSPlatform(OSPlatform.Windows))
@ -413,12 +413,12 @@ namespace Avalonia.IntegrationTests.Appium
{
// 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(
return Session.FindElementByXPath(
$"XCUIElementTypeWindow//*[@identifier='{identifier}']/parent::XCUIElementTypeWindow");
}
else
{
return _session.FindElementByXPath($"//Window[@AutomationId='{identifier}']");
return Session.FindElementByXPath($"//Window[@AutomationId='{identifier}']");
}
}

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

@ -423,7 +423,7 @@ namespace Avalonia.IntegrationTests.Appium
private AppiumWebElement GetWindow(string identifier)
{
return Session.GetWindowById(identifier);
return GetWindow(identifier);
}
private int GetWindowOrder(string identifier)

Loading…
Cancel
Save