using Titano.App.DesignTime; using Titano.App.Infrastructure; using Titano.App.Shell; using Titano.Testing; using Titano.Ui.Theming; namespace Titano.App.Tests.Windows; /// What the shell stops when the app exits (App.OnExit disposes it before the services). [WindowsOnly] [Serial] [Timeout(120_000)] public sealed class ShellLifetimeTests { private sealed class NoDialogs : IAppDialogs { public string? PickFolder(string title, string? initialFolder = null) => null; public string? PickJsonFile(string title) => null; public bool Confirm(ConfirmRequest request) => false; public bool SignIn(string server, string? username, Func> signIn) => false; } /// DESK-7: the open editor goes with the shell, before the engine and the index under it. [Test] public Task DisposingTheShellClosesTheOpenEditor() => ScreenHost.RunAsync(async () => { var environment = AppEnvironment.ForCapture(); UiLanguage.Apply("en"); ThemeManager.Apply(AppTheme.Dark); var services = new AppServices(environment, new AppSettings { Language = "en", FirstRunCompleted = true }, () => { }, new NoDialogs()); try { var sample = SampleData.Configure(services); var shell = new ShellViewModel(services); await sample.OpenEmptyAsync(); await shell.StartAsync(); var id = await sample.FillEditorAsync(); shell.OpenSequence(id); await shell.Sequence.OpenAsync(id); var editor = Assert.NotNull(shell.Sequence.Editor); editor.PlayCommand.Execute(null); Assert.True(editor.IsPlaying, "the editor plays"); shell.Dispose(); Assert.False(editor.IsPlaying, "the editor's player stopped with the shell"); } finally { await services.DisposeAsync(); environment.DeleteCaptureData(); } }); }