From ad0bc0dabfb7f996277d8effdb4d4a71c62d5e4d Mon Sep 17 00:00:00 2001 From: Max Katz Date: Mon, 8 Jul 2024 16:44:15 -0700 Subject: [PATCH] TrayIcon integration tests (#16154) * Add accessibility ID to the TrayPopupRoot on Windows * [Windows] Add left click and menu item click e2e tests for TrayIcon * [Windows] Add TrayIcon visibility toggle tests * Implement macOS tray icon tests * Make it easier to read tray icon logs * Try to handle win10 accessibility names * Try to upload PageSource * Set condition: always * Hopefully, it works on CI * Try to upload PageSource #2 * Fix win10, hopefully for the last time --- samples/IntegrationTestApp/App.axaml | 9 +- samples/IntegrationTestApp/App.axaml.cs | 12 +- samples/IntegrationTestApp/MainWindow.axaml | 8 + .../IntegrationTestApp/MainWindow.axaml.cs | 8 + src/Windows/Avalonia.Win32/TrayIconImpl.cs | 3 +- .../DefaultAppFixture.cs | 35 +++- .../OverlayPopupsAppFixture.cs | 8 +- .../TrayIconTests.cs | 152 ++++++++++++++++++ 8 files changed, 215 insertions(+), 20 deletions(-) create mode 100644 tests/Avalonia.IntegrationTests.Appium/TrayIconTests.cs diff --git a/samples/IntegrationTestApp/App.axaml b/samples/IntegrationTestApp/App.axaml index f23ce53dbe..60a2c56542 100644 --- a/samples/IntegrationTestApp/App.axaml +++ b/samples/IntegrationTestApp/App.axaml @@ -9,10 +9,15 @@ - + - + diff --git a/samples/IntegrationTestApp/App.axaml.cs b/samples/IntegrationTestApp/App.axaml.cs index 59f1185e17..c55f5fb392 100644 --- a/samples/IntegrationTestApp/App.axaml.cs +++ b/samples/IntegrationTestApp/App.axaml.cs @@ -4,18 +4,20 @@ using Avalonia; using Avalonia.Controls; using Avalonia.Controls.ApplicationLifetimes; using Avalonia.Markup.Xaml; +using Avalonia.Media; using MiniMvvm; namespace IntegrationTestApp { public class App : Application { + private MainWindow? _mainWindow; + public App() { - ShowWindowCommand = MiniCommand.Create(() => + TrayIconCommand = MiniCommand.Create(name => { - var window = new Window() { Title = "TrayIcon demo window" }; - window.Show(); + _mainWindow!.Get(name).IsChecked = true; }); DataContext = this; } @@ -29,12 +31,12 @@ namespace IntegrationTestApp { if (ApplicationLifetime is IClassicDesktopStyleApplicationLifetime desktop) { - desktop.MainWindow = new MainWindow(); + desktop.MainWindow = _mainWindow = new MainWindow(); } base.OnFrameworkInitializationCompleted(); } - public ICommand ShowWindowCommand { get; } + public ICommand TrayIconCommand { get; } } } diff --git a/samples/IntegrationTestApp/MainWindow.axaml b/samples/IntegrationTestApp/MainWindow.axaml index 62308ca0e1..275d5683f5 100644 --- a/samples/IntegrationTestApp/MainWindow.axaml +++ b/samples/IntegrationTestApp/MainWindow.axaml @@ -93,6 +93,14 @@ + + + Tray Icon Clicked + Tray Icon Menu Clicked +