using System.Collections.Specialized; using System.Globalization; using System.IO; using System.Net.Http; using System.Windows; using System.Windows.Controls; using System.Windows.Input; using System.Windows.Media; using System.Windows.Media.Imaging; using System.Windows.Threading; using Chronos.App.DesignTime; using Chronos.App.Editor; using Chronos.App.Infrastructure; using Chronos.App.Sections; using Chronos.App.Shell; using Chronos.App.Tests.Windows; using Chronos.Core.Advice; using Chronos.Core.Analysis; using Chronos.Core.Export; using Chronos.Core.Localization; using Chronos.Core.Model; using Chronos.Core.Project; using Chronos.Core.Render; using Chronos.Testing; using Chronos.Ui.Controls; using Chronos.Ui.Theming; using Chronos.Ui.Visuals; namespace Chronos.App.Tests.Editor; /// /// The sequence editor in the real main window, off screen at the minimum capture size, on the synthetic sunset of /// --capture (real JPEG frames, deep analysis, advised project): every section shows its measuring tool, its /// settings and preview pixels in both themes, and an edit goes through undo and redo. /// [WindowsOnly] [Serial] [Timeout(300_000)] public sealed class EditorSmokeTests { private static readonly AppTheme[] Themes = [AppTheme.Dark, AppTheme.Light]; /// Here rather than with the other texts: it switches the UI language, which only a serial class may do. [Test] public void AnOptimiseLinePointsFromTheOldValueToTheNewOneInEitherReadingDirection() { var change = new SettingChange(AdvisorParameters.DeflickerWindow, 21, 41, "reason", []); try { Loc.SetCulture(CultureInfo.GetCultureInfo("en")); Assert.Equal("Deflicker window: 21 frames → 41 frames", EditorText.Change(change)); Loc.SetCulture(CultureInfo.GetCultureInfo("ar")); Assert.Equal(Loc.L("Editor.Optimise.ChangeRtl", Loc.L("Editor.Exposure.Window"), Loc.Plural("Editor.Value.Frames", 21), Loc.Plural("Editor.Value.Frames", 41)), EditorText.Change(change), "Arabic reads the old value first, from the right"); Assert.Contains("←", EditorText.Change(change)); } finally { Loc.SetCulture(CultureInfo.GetCultureInfo("en")); } } [Test] public Task EverySectionOfTheEditorRendersInBothThemes() => 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()); var sample = SampleData.Configure(services); var shell = new ShellViewModel(services); var window = new MainWindow(shell) { WindowStartupLocation = WindowStartupLocation.Manual, Left = -20000, Top = -20000, Width = 1200, Height = 788, ShowActivated = false, ShowInTaskbar = false, }; window.Show(); try { 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); Assert.Equal(96, editor.FrameCount); Assert.NotNull(editor.Session.Content.Deep, "the sample is analysed"); Assert.True(editor.Session.Project.Exposure.Deflicker.HasAdvice, "the advice is in the project"); Assert.Equal("Harbour sunset", editor.Title); Assert.Equal("Chronos — Harbour sunset", shell.WindowTitle, "the window title follows the open sequence"); Assert.False(shell.IsJobBarVisible, "the idle job bar gives its height to the editor"); // The Render split button can be clicked once the plan exists (its command re-reads its state). Assert.True(await editor.WhenIdleAsync(TimeSpan.FromSeconds(60)), "the editor settled"); await SettleAsync(window); Assert.True(editor.CanRender, editor.RenderBlockedReason ?? "renderable"); var render = Find(window).Single(b => b.IsVisible); Assert.True(Find