using Avalonia.Controls; using Avalonia.Controls.Primitives; using Avalonia.Media.Imaging; using Avalonia.Threading; using Avalonia.VisualTree; using FluentAvalonia.UI.Controls; using FluentAvalonia.UI.Windowing; using Microsoft.Extensions.DependencyInjection; using StabilityMatrix.Avalonia; using StabilityMatrix.Avalonia.Controls; using StabilityMatrix.Avalonia.Languages; using StabilityMatrix.Avalonia.ViewModels; using StabilityMatrix.Avalonia.ViewModels.Dialogs; using StabilityMatrix.Avalonia.Views; using StabilityMatrix.Avalonia.Views.Dialogs; using StabilityMatrix.UITests.Extensions; namespace StabilityMatrix.UITests; public class TestBase { internal static IServiceProvider Services => App.Services; internal static (AppWindow, MainWindowViewModel)? currentMainWindow; internal virtual VerifySettings Settings { get { var settings = new VerifySettings(); settings.IgnoreMembers( vm => vm.Pages, vm => vm.FooterPages, vm => vm.CurrentPage ); settings.IgnoreMember(vm => vm.CurrentVersionText); settings.DisableDiff(); return settings; } } internal static (AppWindow, MainWindowViewModel) GetMainWindow() { if (currentMainWindow is not null) { return currentMainWindow.Value; } var window = Services.GetRequiredService(); var viewModel = Services.GetRequiredService(); window.DataContext = viewModel; window.Width = 1400; window.Height = 900; App.VisualRoot = window; App.StorageProvider = window.StorageProvider; App.Clipboard = window.Clipboard ?? throw new NullReferenceException("Clipboard is null"); currentMainWindow = (window, viewModel); return currentMainWindow.Value; } internal static async Task DoInitialSetup() { var (window, _) = GetMainWindow(); if (!window.IsVisible) { window.Show(); await Task.Delay(300); Dispatcher.UIThread.RunJobs(); } try { var dialog = await WaitHelper.WaitForNotNullAsync(() => GetWindowDialog(window)); if (dialog.Content is SelectDataDirectoryDialog selectDataDirectoryDialog) { // Click continue button var continueButton = selectDataDirectoryDialog .GetVisualDescendants() .OfType