CI / Build and test (push) Successful in 9m41s
CI / Windows tests and installer (push) Skipped
CI / YAML check (push) Successful in 9s
Release / Build, test and publish (push) Successful in 14m49s
CI / PostgreSQL 16 integration (push) Successful in 8m51s
CI / PostgreSQL 17 integration (push) Successful in 9m48s
CI / Docker image (push) Successful in 54s
Release / Server image (push) Successful in 1m39s
Owner review 1 R3, R8, R9. A grouped Export step and Render menu; encoding, playback (reverse, boomerang, loops, fades, hold) and still frames; one videos library on the desktop and the server with a verified trash and copies to a videos folder. Closes #21 Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Co-authored-by: Alberto Balbo <alberto.balbo.96@gmail.com>
145 lines
7.3 KiB
C#
145 lines
7.3 KiB
C#
using System.Windows;
|
||
using System.Windows.Controls;
|
||
using System.Windows.Media;
|
||
using System.Windows.Threading;
|
||
using Chronos.App.Infrastructure;
|
||
using Chronos.App.Tests.Windows;
|
||
using Chronos.Core.Localization;
|
||
using Chronos.Core.Render;
|
||
using Chronos.Testing;
|
||
using Chronos.Ui.Visuals;
|
||
|
||
namespace Chronos.App.Tests.Editor;
|
||
|
||
/// <summary>
|
||
/// The editor's header in the real main window at the 1200 px minimum (owner review 1, R3, decision 1): "Render ▾" keeps one
|
||
/// width whatever the preset in every language, and its menu shows the presets as two-line entries with the current one checked.
|
||
/// </summary>
|
||
[WindowsOnly]
|
||
[Serial]
|
||
[Timeout(300_000)]
|
||
public sealed class RenderHeaderTests
|
||
{
|
||
private static readonly string[] Presets = ["1080p-h264", "8k-hevc10-archive", "gif-preview", "tiff16-sequence", "vertical-1080x1920"];
|
||
|
||
[Test]
|
||
public Task TheHeaderKeepsItsWidthWhateverThePresetInEveryLanguage() => ScreenHost.RunAsync(async () =>
|
||
{
|
||
await using var app = await ScreenSmokeTests.SampleApp.StartAsync();
|
||
app.Window.Width = 1200;
|
||
app.Window.Height = 788;
|
||
var id = await app.Sample.FillEditorAsync();
|
||
app.Shell.OpenSequence(id);
|
||
await app.Shell.Sequence.OpenAsync(id);
|
||
var editor = Assert.NotNull(app.Shell.Sequence.Editor);
|
||
try
|
||
{
|
||
foreach (var language in Languages.Shipped)
|
||
{
|
||
UiLanguage.Apply(language);
|
||
var widths = new List<double>();
|
||
foreach (var preset in Presets)
|
||
{
|
||
editor.SelectPresetCommand.Execute(preset);
|
||
await CheckedAsync(editor, preset, app.Window);
|
||
var button = RenderButton(app.Window);
|
||
Assert.Equal(Loc.L("Editor.RenderButton"), button.Content, $"{language}: no preset name on the button");
|
||
var right = button.TranslatePoint(new Point(button.ActualWidth, 0), app.Window).X;
|
||
var left = button.TranslatePoint(new Point(0, 0), app.Window).X;
|
||
Assert.True(Math.Min(left, right) >= 0 && Math.Max(left, right) <= app.Window.ActualWidth,
|
||
$"{language}, {preset}: Render spans {Math.Min(left, right):0}–{Math.Max(left, right):0} px in a {app.Window.ActualWidth:0} px window");
|
||
widths.Add(Math.Round(button.ActualWidth, 1));
|
||
}
|
||
Assert.True(widths.Max() - widths.Min() < 0.5, $"{language}: Render is {string.Join(", ", widths)} px wide across the presets");
|
||
}
|
||
}
|
||
finally
|
||
{
|
||
UiLanguage.Apply("en");
|
||
await app.Shell.Sequence.CloseAsync();
|
||
}
|
||
});
|
||
|
||
[Test]
|
||
public Task TheRenderMenuShowsTwoLinePresetsWithTheCurrentOneChecked() => ScreenHost.RunAsync(async () =>
|
||
{
|
||
await using var app = await ScreenSmokeTests.SampleApp.StartAsync();
|
||
app.Window.Width = 1200;
|
||
app.Window.Height = 788;
|
||
var id = await app.Sample.FillEditorAsync();
|
||
app.Shell.OpenSequence(id);
|
||
await app.Shell.Sequence.OpenAsync(id);
|
||
var editor = Assert.NotNull(app.Shell.Sequence.Editor);
|
||
try
|
||
{
|
||
editor.SelectPresetCommand.Execute("1080p-h264");
|
||
await CheckedAsync(editor, "1080p-h264", app.Window);
|
||
var button = RenderButton(app.Window);
|
||
button.IsDropDownOpen = true;
|
||
await SettleAsync(app.Window);
|
||
var menu = Assert.NotNull(button.Menu);
|
||
Assert.True(menu.IsOpen);
|
||
var items = menu.Items.OfType<Control>().ToList();
|
||
var current = items.OfType<MenuItem>().Single(m => m.IsChecked);
|
||
Assert.Equal("preset:1080p-h264", ((RenderMenuItem)current.Header).Id);
|
||
Assert.Equal(Loc.L("Export.Preset.1080pShare"), System.Windows.Automation.AutomationProperties.GetName(current));
|
||
Assert.True(current.ActualHeight >= 32, $"a preset entry has a details line ({current.ActualHeight:0} px)");
|
||
var lines = Find<TextBlock>(current).Where(t => t.IsVisible).Select(t => t.Text).ToList();
|
||
Assert.Contains(Loc.L("Export.Preset.1080pShare"), lines);
|
||
Assert.Contains(lines, l => l.Contains("1920×1080", StringComparison.Ordinal));
|
||
Assert.True(items.OfType<Separator>().Any(), "the commands sit under a separator");
|
||
var frame = items.OfType<MenuItem>().Single(m => m.Header is RenderMenuItem { Id: "frame" });
|
||
Assert.Equal(RenderRules.StillCodecs.Count, frame.Items.Count);
|
||
var untipped = items.OfType<MenuItem>().Where(m => m.Header is RenderMenuItem { Kind: not RenderMenuItemKind.Header } && m.ToolTip is not string { Length: > 0 });
|
||
Assert.False(untipped.Any(), "every entry but a title has a tooltip: " + string.Join(", ", untipped.Select(m => ((RenderMenuItem)m.Header).Id)));
|
||
Assert.True(items.OfType<MenuItem>().Where(m => m.Header is RenderMenuItem { Kind: RenderMenuItemKind.Header }).All(m => !m.Focusable && !m.IsHitTestVisible),
|
||
"a title is not an entry");
|
||
|
||
// Another preset chosen: the menu, made again when it opens, checks that one.
|
||
((MenuItem)items.Single(i => i is MenuItem { Header: RenderMenuItem { Id: "preset:1080p-h264" } })).Command.Execute("8k-hevc10-archive");
|
||
button.IsDropDownOpen = false;
|
||
await CheckedAsync(editor, "8k-hevc10-archive", app.Window);
|
||
button.IsDropDownOpen = true;
|
||
await SettleAsync(app.Window);
|
||
Assert.Equal("preset:8k-hevc10-archive", ((RenderMenuItem)menu.Items.OfType<MenuItem>().Single(m => m.IsChecked).Header).Id);
|
||
button.IsDropDownOpen = false;
|
||
}
|
||
finally
|
||
{
|
||
await app.Shell.Sequence.CloseAsync();
|
||
}
|
||
});
|
||
|
||
private static SplitButton RenderButton(Window window) => Find<SplitButton>(window).Single(b => b.Name == "RenderButton" && b.IsVisible);
|
||
|
||
/// <summary>Waits until the editor's plan has the preset (it is made off the UI thread), then lets the layout settle.</summary>
|
||
private static async Task CheckedAsync(Chronos.App.Editor.EditorViewModel editor, string preset, Window window)
|
||
{
|
||
for (var i = 0; i < 400 && !editor.RenderMenuItems.SelectMany(m => m.Flatten()).Any(m => m.IsChecked && m.Id == "preset:" + preset); i++) await Task.Delay(10);
|
||
Assert.True(editor.RenderMenuItems.SelectMany(m => m.Flatten()).Any(m => m.IsChecked && m.Id == "preset:" + preset), $"{preset} is the current preset");
|
||
await SettleAsync(window);
|
||
}
|
||
|
||
private static async Task SettleAsync(Window window)
|
||
{
|
||
window.UpdateLayout();
|
||
await window.Dispatcher.InvokeAsync(() => { }, DispatcherPriority.ApplicationIdle);
|
||
await Task.Delay(30);
|
||
await window.Dispatcher.InvokeAsync(() => { }, DispatcherPriority.ApplicationIdle);
|
||
window.UpdateLayout();
|
||
}
|
||
|
||
private static List<T> Find<T>(DependencyObject root)
|
||
where T : DependencyObject
|
||
{
|
||
var found = new List<T>();
|
||
var stack = new Stack<DependencyObject>([root]);
|
||
while (stack.TryPop(out var node))
|
||
{
|
||
if (node is T match) found.Add(match);
|
||
for (var i = 0; i < VisualTreeHelper.GetChildrenCount(node); i++) stack.Push(VisualTreeHelper.GetChild(node, i));
|
||
}
|
||
return found;
|
||
}
|
||
}
|