Browse Source

Trying to fix flaky window decorations tests. (#16597)

Toggling the window decorations can cause the window to be moved off screen, causing integration test failures. Until this bug is fixed, detect this and move the window to the screen origin. See #11411.
pull/16604/head
Steven Kirk 2 years ago
committed by GitHub
parent
commit
c71fa11e73
No known key found for this signature in database GPG Key ID: B5690EEEBB952194
  1. 19
      samples/IntegrationTestApp/MainWindow.axaml.cs

19
samples/IntegrationTestApp/MainWindow.axaml.cs

@ -1,4 +1,6 @@
using System;
using System.Collections.Generic;
using Avalonia;
using Avalonia.Controls;
using IntegrationTestApp.Models;
using IntegrationTestApp.Pages;
@ -20,6 +22,7 @@ namespace IntegrationTestApp
DataContext = viewModel;
AppOverlayPopups.Text = Program.OverlayPopups ? "Overlay Popups" : "Native Popups";
PositionChanged += OnPositionChanged;
}
private MainWindowViewModel? ViewModel => (MainWindowViewModel?)DataContext;
@ -53,6 +56,22 @@ namespace IntegrationTestApp
PagerContent.Child = page.CreateContent();
}
private void OnPositionChanged(object? sender, PixelPointEventArgs e)
{
// HACK: Toggling the window decorations can cause the window to be moved off screen,
// causing test failures. Until this bug is fixed, detect this and move the window
// to the screen origin. See #11411.
if (Screens.ScreenFromWindow(this) is { } screen)
{
var bounds = new PixelRect(
e.Point,
PixelSize.FromSize(ClientSize, DesktopScaling));
if (!screen.WorkingArea.Contains(bounds))
Position = screen.WorkingArea.Position;
}
}
private static IEnumerable<Page> CreatePages()
{
return

Loading…
Cancel
Save