using Avalonia; using Avalonia.Controls; using Avalonia.Headless; using Avalonia.Input; using Avalonia.Threading; using Avalonia.VisualTree; using DodoSSH.Client.App.Views; using DodoSSH.Client.Session; using DodoSSH.Client.Session.Tests; using DodoSSH.Client.Shell.ViewModels; using DodoSSH.Client.Ssh; using DodoSSH.Client.Storage; using DodoSSH.Client.Terminal; namespace DodoSSH.Client.App.Layout.Tests; /// /// The keyboard on the questions the window asks over itself: where it is when one appears, and what Escape /// answers. /// /// /// They used to appear with the keyboard wherever it had been, Escape did nothing, and Tab walked the page /// behind them. The answer they are given here is always the harmless one — see /// — and that is what each test pins: not merely that focus moved, but which button it moved to. /// public sealed class ConfirmationKeyboardTests { private static CancellationToken Token => TestContext.Current.CancellationToken; [Fact] public async Task TheSignOutQuestion_TakesTheKeyboardOnCancel_AndEscapeSaysNo() { using var caches = await EnrolledAsync(); await using var workspace = WholeWindow.Workspace(); await using var shell = WholeWindow.Shell(caches, workspace); await shell.StartAsync(Token); await LayoutHarness.OnTheUiThreadAsync( () => WholeWindow.Show(shell, window => { shell.SignOutCommand.Execute(null); Dispatcher.UIThread.RunJobs(); var card = window.GetVisualDescendants().OfType().Single(card => card.IsEffectivelyVisible); window.FocusManager!.GetFocusedElement().ShouldBeSameAs(card.FindControl