using System.Windows; using System.Windows.Automation; using System.Windows.Controls; using System.Windows.Input; using System.Windows.Media; using Titano.App.Infrastructure; using Titano.App.Sections; using Titano.App.Server; using Titano.App.Settings; using Titano.App.Shell; using Titano.App.Tests.Windows; using Titano.Core.Localization; using Titano.Testing; namespace Titano.App.Tests.Settings; /// /// Settings, the first-run dialog and the reading direction on the capture sample: values other screens set, labels and /// paths that survive long translations and right-to-left text, keyboard focus and the questions before forgetting. /// [WindowsOnly] [Serial] [Timeout(300_000)] public sealed class SettingsScreenSmokeTests { [Test] public Task SettingsShowCurrentValuesAndNeverCutLabelsOrRows() => ScreenHost.RunAsync(async () => { await using var app = await ScreenSmokeTests.SampleApp.StartAsync(); var shell = app.Shell; await app.Sample.FillAsync(); await shell.Services.Server.RestoreAsync(); var settings = shell.Settings; // The open archive and the server connected to were set after Settings was built: it shows them when opened. shell.Navigate(SectionKey.Settings); Assert.Equal(@"D:\TitanoArchive", settings.ArchiveRoot.Text); Assert.Equal("https://nas.local:8443", settings.DefaultServer.Text); Assert.False(settings.ArchiveRoot.IsDirty || settings.DefaultServer.IsDirty, "values loaded, not edits"); // The section list shows where keyboard focus is. await app.ExpectAsync("settings-general"); Assert.True(app.FindAll().Where(i => i.DataContext is SettingsPageItem).All(i => i.FocusVisualStyle is not null), "sections have a focus ring"); // At the minimum window width the cache folder row stays one line: Clear beside the path, not under it. settings.Page = SettingsPage.Storage; await app.ExpectAsync("settings-storage"); var window = Window.GetWindow(app.FindAll().First(v => v.IsVisible)); var width = window.Width; window.Width = 1200; window.UpdateLayout(); var cache = Field(app, Loc.L("Settings.Storage.Folder")); var clear = app.FindAll