feat: export panel and Render menu, playback options, videos library (owner review 1 phase 5) (#27)
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
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>
This commit was merged in pull request #27.
This commit is contained in:
1 parent
188b2c2e55
commit
728ffa35cb
729 files changed
+26954
-1652
No files matched your search
@@ -204,7 +204,7 @@ public sealed class CameraTabTests
|
||||
straighten.Value = -1.23;
|
||||
Assert.Equal(-1.2, session.Project.Camera.Straighten);
|
||||
Assert.Equal("−1.2°", straighten.DisplayValue);
|
||||
Assert.Equal(ProjectSettings.CurrentVersion, session.Project.RequiredFormat, "a straighten needs format 2");
|
||||
Assert.Equal(2, session.Project.RequiredFormat, "a straighten needs format 2");
|
||||
straighten.Value = 0.02;
|
||||
Assert.Equal(0.0, session.Project.Camera.Straighten);
|
||||
Assert.False(double.IsNegative(session.Project.Camera.Straighten), "never −0");
|
||||
@@ -232,7 +232,7 @@ public sealed class CameraTabTests
|
||||
filter.Selected = filter.Options.Single(o => Equals(o.Value, "sepia"));
|
||||
Assert.Equal(new LookSettings { Filter = "sepia" }.Filter, session.Project.Look?.Filter);
|
||||
Assert.Null(session.Project.Look!.Strength, "100 % is the default");
|
||||
Assert.Equal(ProjectSettings.CurrentVersion, session.Project.RequiredFormat);
|
||||
Assert.Equal(2, session.Project.RequiredFormat);
|
||||
Refresh(rows);
|
||||
Assert.True(strength.IsApplicable);
|
||||
Assert.Equal(1.0, strength.Value);
|
||||
|
||||
@@ -497,7 +497,7 @@ public sealed class EditorSessionTests
|
||||
var before = session.Project.ToJson();
|
||||
for (var i = 0; i < 4; i++) Assert.True(session.Orient(OrientationOp.RotateRight));
|
||||
Assert.Equal(before, session.Project.ToJson());
|
||||
Assert.Equal(ProjectSettings.CurrentVersion, session.Project.RequiredFormat, "a straighten needs format 2");
|
||||
Assert.Equal(2, session.Project.RequiredFormat, "a straighten needs format 2");
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -130,9 +130,9 @@ public sealed class EditorSmokeTests
|
||||
Assert.False(export.BatchCommand.CanExecute(null), "nothing ticked");
|
||||
var batchButton = Find<Button>(window).Single(b => ReferenceEquals(b.Command, export.BatchCommand));
|
||||
Assert.False(batchButton.IsEnabled);
|
||||
export.Cards.First(c => c.CanBatch).IsInBatch = true;
|
||||
export.Presets.First(c => c.CanBatch).IsInBatch = true;
|
||||
await SettleAsync(window);
|
||||
Assert.True(batchButton.IsEnabled, "ticking a card enables Batch…");
|
||||
Assert.True(batchButton.IsEnabled, "ticking a preset enables Batch…");
|
||||
editor.ShowVectors = false;
|
||||
|
||||
// The waveform of the Exposure tab is measured from the preview.
|
||||
@@ -685,9 +685,9 @@ public sealed class EditorSmokeTests
|
||||
Assert.NotEmpty(Find<CurveEditor>(view).Where(c => c.IsVisible && c.ActualHeight > 50));
|
||||
break;
|
||||
case ExportTab export:
|
||||
Assert.NotEmpty(export.Cards);
|
||||
Assert.NotEmpty(Find<Button>(view).Where(b => b.DataContext is PresetCard && b.IsVisible));
|
||||
Assert.True(export.Cards.Any(c => c.Estimate is not null), "estimates on the cards");
|
||||
Assert.NotEmpty(export.Presets);
|
||||
Assert.NotEmpty(Find<Button>(view).Where(b => b.DataContext is PresetRow && b.IsVisible));
|
||||
Assert.True(export.Presets.Any(c => c.EstimatedSize is not null), "estimates in the preset table");
|
||||
break;
|
||||
default:
|
||||
var chart = Find<SeriesChart>(view).Single(c => c.IsVisible);
|
||||
|
||||
@@ -0,0 +1,289 @@
|
||||
using System.Globalization;
|
||||
using System.Windows;
|
||||
using System.Windows.Controls;
|
||||
using System.Windows.Data;
|
||||
using System.Windows.Media;
|
||||
using Chronos.App.Editor;
|
||||
using Chronos.App.Shell;
|
||||
using Chronos.App.Tests.Windows;
|
||||
using Chronos.Core.Export;
|
||||
using Chronos.Core.Localization;
|
||||
using Chronos.Core.Project;
|
||||
using Chronos.Core.Video;
|
||||
using Chronos.Data.Processing;
|
||||
using Chronos.Testing;
|
||||
|
||||
namespace Chronos.App.Tests.Editor;
|
||||
|
||||
/// <summary>
|
||||
/// The Export step's Output panel (owner review 1, R3 and R8): what the advanced encoding rows offer per codec, the
|
||||
/// keyframe interval kept in seconds across a frame rate change, a standard resolution fitted to the chosen proportions,
|
||||
/// a playback that raises the settings format, the collapsed groups' summaries and open state, the preset table's
|
||||
/// groups, and the footer's Batch (n) and Videos (n).
|
||||
/// </summary>
|
||||
[Serial]
|
||||
public sealed class ExportTabTests
|
||||
{
|
||||
private static readonly Rational Fps24 = new(24, 1);
|
||||
private static readonly Rational Fps30 = new(30, 1);
|
||||
|
||||
private static ExportSettings Preset(string id)
|
||||
{
|
||||
var export = new ProjectSettings().Export;
|
||||
return export with { Preset = export.Preset.WithManual(id) };
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void RateControlBFramesAndProfileFollowTheCodecAndDepth()
|
||||
{
|
||||
Assert.True(ExportRules.HasRateControl(VideoCodec.H264));
|
||||
Assert.True(ExportRules.HasRateControl(VideoCodec.Hevc));
|
||||
Assert.Null(ExportRules.RateControlBlocked(VideoCodec.Av1));
|
||||
Assert.Null(ExportRules.KeyframesBlocked(VideoCodec.Hevc));
|
||||
foreach (var managed in new[] { VideoCodec.Mjpeg, VideoCodec.Gif, VideoCodec.Apng, VideoCodec.PngSequence, VideoCodec.JpegSequence })
|
||||
{
|
||||
Assert.False(ExportRules.HasRateControl(managed), $"{managed} has no rate control");
|
||||
Assert.NotNull(ExportRules.RateControlBlocked(managed), $"{managed}: the tooltip says why");
|
||||
Assert.Equal(Loc.L("Tooltips.Export.KeyframesNA", Loc.L("Export.Codec." + managed)), ExportRules.KeyframesBlocked(managed), $"{managed}: no keyframe interval");
|
||||
Assert.NotNull(ExportRules.BFramesBlocked(managed, CodecProfile.Auto), $"{managed} takes no B-frames");
|
||||
Assert.Empty(ExportRules.Profiles(managed, 8));
|
||||
Assert.NotNull(ExportRules.ProfileBlocked(managed, 8));
|
||||
}
|
||||
|
||||
Assert.NotNull(ExportRules.BFramesBlocked(VideoCodec.H264, CodecProfile.H264Baseline), "Baseline takes no B-frames");
|
||||
Assert.Null(ExportRules.BFramesBlocked(VideoCodec.H264, CodecProfile.H264High));
|
||||
Assert.Null(ExportRules.BFramesBlocked(VideoCodec.Hevc, CodecProfile.HevcMain10));
|
||||
|
||||
Assert.SequenceEqual([CodecProfile.H264Baseline, CodecProfile.H264Main, CodecProfile.H264High], ExportRules.Profiles(VideoCodec.H264, 8));
|
||||
Assert.Null(ExportRules.ProfileBlocked(VideoCodec.H264, 8), "H.264 offers three profiles");
|
||||
Assert.SequenceEqual([CodecProfile.HevcMain], ExportRules.Profiles(VideoCodec.Hevc, 8));
|
||||
Assert.SequenceEqual([CodecProfile.HevcMain10], ExportRules.Profiles(VideoCodec.Hevc, 10), "HEVC at 10 bits is Main 10");
|
||||
Assert.NotNull(ExportRules.ProfileBlocked(VideoCodec.Hevc, 10), "one profile: nothing to choose");
|
||||
Assert.SequenceEqual([CodecProfile.Av1Main], ExportRules.Profiles(VideoCodec.Av1, 10));
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void TheKeyframeIntervalKeepsItsSecondsWhenTheFrameRateChanges()
|
||||
{
|
||||
Assert.Equal(36, ExportRules.GopFrames(1.5, Fps24));
|
||||
Assert.Equal(1, ExportRules.GopFrames(0.01, Fps24), "at least one frame");
|
||||
Assert.Approximately(1.5, ExportRules.GopSeconds(36, Fps24), 1e-9);
|
||||
Assert.Equal(30, ExportRules.RescaleGop(24, Fps24, Fps30), "1 s at 24 fps is 1 s at 30 fps");
|
||||
Assert.Equal(60, ExportRules.RescaleGop(48, Fps24, Fps30));
|
||||
Assert.Approximately(1.0, ExportRules.NearestKeyframeSeconds(31, Fps30), 1e-9, "shown as the nearest offered interval");
|
||||
Assert.Approximately(10.0, ExportRules.NearestKeyframeSeconds(10_000, Fps30), 1e-9, "at most the longest offered");
|
||||
Assert.Equal(20, ExportRules.KeyframeSeconds.Count);
|
||||
Assert.Approximately(0.5, ExportRules.KeyframeSeconds[0], 1e-9);
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void AStandardResolutionIsTheLandscapeBoxTheChosenProportionsFitIn()
|
||||
{
|
||||
var uhd = ExportRules.StandardResolutions.Single(r => r.Key == "4k");
|
||||
Assert.Equal((3840, 2160), (uhd.Width, uhd.Height));
|
||||
Assert.Equal("Export.Resolution.Uhd4k", uhd.LabelKey);
|
||||
Assert.True(ExportRules.StandardResolutions.All(r => Loc.L(r.LabelKey) != r.LabelKey), "every label is a resource");
|
||||
|
||||
Assert.Equal(ExportTab.PresetResolution, ExportTab.ResolutionKey(new ExportOverrides()));
|
||||
Assert.Equal(ExportTab.SourceResolution, ExportTab.ResolutionKey(new ExportOverrides { Width = 0, Height = 0 }));
|
||||
Assert.Equal("4k", ExportTab.ResolutionKey(new ExportOverrides { Width = 3840, Height = 2160 }));
|
||||
Assert.Equal(ExportTab.CustomResolution, ExportTab.ResolutionKey(new ExportOverrides { Width = 3000, Height = 2000 }));
|
||||
Assert.Equal(ExportTab.CustomResolution, ExportTab.ResolutionKey(new ExportOverrides { Width = 3840, Height = 2160 }, custom: true));
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void APlaybackThatIsNotTheDefaultNeedsSettingsFormat3()
|
||||
{
|
||||
var project = new ProjectSettings();
|
||||
Assert.True(project.RequiredFormat < 3);
|
||||
var reverse = project with { Export = project.Export with { Playback = new PlaybackSettings { Direction = PlaybackDirection.Reverse } } };
|
||||
Assert.Equal(3, reverse.RequiredFormat);
|
||||
Assert.NotNull(ServerJobs.NeedsNewerServer(ProcessingJobs.RequiredFormat(reverse, reverse.Export, 96, 64), 2), "a format 2 server cannot render it");
|
||||
Assert.Null(ServerJobs.NeedsNewerServer(ProcessingJobs.RequiredFormat(project, project.Export, 96, 64), 2));
|
||||
var faded = project with { Export = project.Export with { Playback = new PlaybackSettings { FadeIn = 1 } } };
|
||||
Assert.Equal(3, faded.RequiredFormat);
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void TheCollapsedGroupsSummariseTheirValues()
|
||||
{
|
||||
Loc.SetCulture(CultureInfo.GetCultureInfo("en"));
|
||||
Assert.Equal("Forward · no fades", ExportSummaries.Playback(null));
|
||||
Assert.Equal("Boomerang · ×2 · fades 1 s / 1.5 s · hold 2 s", ExportSummaries.Playback(new PlaybackSettings
|
||||
{
|
||||
Direction = PlaybackDirection.Boomerang,
|
||||
Loops = 2,
|
||||
FadeIn = 1,
|
||||
FadeOut = 1.5,
|
||||
HoldEnd = 2,
|
||||
}));
|
||||
Assert.Equal("Reverse · no fades", ExportSummaries.Playback(new PlaybackSettings { Direction = PlaybackDirection.Reverse }));
|
||||
Assert.Equal("Forward", ExportSummaries.DirectionLabel("unknown"), "an unknown direction plays forward");
|
||||
|
||||
var h264 = ExportResolver.Resolve(Preset("1080p-h264"));
|
||||
var encoding = ExportSummaries.Encoding(h264, 40_000_000);
|
||||
Assert.True(encoding.StartsWith(Loc.L("Export.RateControl." + h264.RateControl) + " · ", StringComparison.Ordinal), encoding);
|
||||
Assert.Contains("GOP ", encoding);
|
||||
Assert.Contains("B " + h264.BFrames.ToString(CultureInfo.InvariantCulture), encoding);
|
||||
Assert.True(encoding.EndsWith("High", StringComparison.Ordinal), encoding);
|
||||
var png = ExportSummaries.Encoding(ExportResolver.Resolve(Preset("png-sequence")), 0);
|
||||
Assert.False(png.Contains("GOP", StringComparison.Ordinal), "an image sequence has no rate control");
|
||||
|
||||
Assert.Equal("clip.mp4 · " + Loc.L("Editor.Export.Sync"), ExportSummaries.File("clip.mp4", "Renders", sync: true));
|
||||
Assert.Equal("Renders", ExportSummaries.File(null, "Renders", sync: false));
|
||||
|
||||
var footer = ExportSummaries.Footer("clip.mp4", null, 42, 1260);
|
||||
Assert.True(footer.StartsWith("clip.mp4 · ", StringComparison.Ordinal), footer);
|
||||
Assert.True(footer.EndsWith(Loc.Plural("Export.Footer.Frames", 1260), StringComparison.Ordinal), footer);
|
||||
Assert.Equal(3, footer.Split(" · ").Length, "no size or time without an estimate");
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void AGroupsOpenStateIsKeptAndSavedByTheApp()
|
||||
{
|
||||
var states = new GroupStates();
|
||||
states.Set("export.encoding", true);
|
||||
var store = new Dictionary<string, bool>(StringComparer.Ordinal);
|
||||
var saves = 0;
|
||||
states.Bind(store, () => saves++);
|
||||
Assert.True(store["export.encoding"], "a toggle made before the settings were attached stays");
|
||||
Assert.True(states.IsExpanded("export.encoding", fallback: false));
|
||||
Assert.False(states.IsExpanded("export.playback", fallback: false), "never toggled: the default");
|
||||
states.Set("export.playback", true);
|
||||
Assert.Equal(1, saves);
|
||||
Assert.True(store["export.playback"]);
|
||||
states.Set("export.playback", true);
|
||||
Assert.Equal(1, saves, "no change, no save");
|
||||
|
||||
var key = "test." + Guid.NewGuid().ToString("N");
|
||||
var group = new SettingGroup(key, "Export.Group.Encoding", "Tooltips.Export.Group.Encoding", expandedByDefault: false);
|
||||
Assert.False(group.IsExpanded);
|
||||
group.ToggleCommand.Execute(null);
|
||||
Assert.True(group.IsExpanded);
|
||||
Assert.True(new SettingGroup(key, "Export.Group.Encoding", "Tooltips.Export.Group.Encoding", expandedByDefault: false).IsExpanded,
|
||||
"another editor opens it as it was left");
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void TheVideosLinkFiltersTheVideosSectionAndShowsIt()
|
||||
{
|
||||
var shown = new List<SectionKey>();
|
||||
Assert.False(VideosLink.Open([], shown.Add, Guid.NewGuid()), "no Videos section yet: nothing happens");
|
||||
var videos = new FakeVideos();
|
||||
var id = Guid.NewGuid();
|
||||
Assert.True(VideosLink.Open([videos], shown.Add, id));
|
||||
Assert.Equal(id, videos.Shown);
|
||||
Assert.SequenceEqual([SectionKey.Jobs], shown);
|
||||
videos.Dispose();
|
||||
}
|
||||
|
||||
/// <summary>The Output panel on the synthetic sunset at 9:16: resolution, keyframes, playback, footer and preset groups.</summary>
|
||||
[Test]
|
||||
[WindowsOnly]
|
||||
[Timeout(300_000)]
|
||||
public Task ThePanelWritesTheOverridesAndThePlaybackItShows() => ScreenHost.RunAsync(async () =>
|
||||
{
|
||||
Loc.SetCulture(CultureInfo.GetCultureInfo("en"));
|
||||
await using var app = await ScreenSmokeTests.SampleApp.StartAsync();
|
||||
var project = new ProjectSettings();
|
||||
project = project with
|
||||
{
|
||||
Camera = project.Camera with { Aspect = project.Camera.Aspect.WithManual("9:16") },
|
||||
Export = project.Export with { Preset = project.Export.Preset.WithManual("1080p-h264") },
|
||||
};
|
||||
var content = EditorFixture.Content(EditorFixture.Sunset, project);
|
||||
var editor = new EditorViewModel(app.Shell, new EditorSession(new FakeSequenceSource(EditorFixture.Sunset, content), content, []), [], EncoderHost.Client);
|
||||
await using (editor)
|
||||
{
|
||||
var export = editor.Tabs.OfType<ExportTab>().Single();
|
||||
Assert.True(await editor.WhenIdleAsync(TimeSpan.FromSeconds(60)));
|
||||
|
||||
// 4K UHD at 9:16: the landscape box in the overrides, the portrait size rendered.
|
||||
Assert.Equal(ExportTab.PresetResolution, export.SelectedResolution?.Value);
|
||||
export.SelectedResolution = export.Resolutions.Single(r => Equals(r.Value, "4k"));
|
||||
Assert.True(await editor.WhenIdleAsync(TimeSpan.FromSeconds(60)));
|
||||
Assert.Equal<(int?, int?)>((3840, 2160), (editor.Session.Project.Export.Overrides.Width, editor.Session.Project.Export.Overrides.Height));
|
||||
Assert.Equal("2160 × 3840", export.OutputSizeText);
|
||||
Assert.False(export.IsCustomResolution);
|
||||
export.SelectedResolution = export.Resolutions.Single(r => Equals(r.Value, ExportTab.CustomResolution));
|
||||
Assert.True(export.IsCustomResolution, "Custom shows Width × Height");
|
||||
|
||||
// Keyframes: 1 s at the preset's 30 fps, then 24 fps keeps 1 s.
|
||||
export.SelectedKeyframes = export.KeyframeChoices.Single(c => (double)c.Value == 1.0);
|
||||
Assert.Equal(30, editor.Session.Project.Export.Overrides.GopFrames);
|
||||
export.SelectedFrameRate = export.FrameRates.Single(c => FrameRateText.TryParse((string)c.Value, out var r) && FrameRateText.AreEqual(r, Fps24));
|
||||
Assert.Equal(24, editor.Session.Project.Export.Overrides.GopFrames, "the interval keeps its seconds");
|
||||
Assert.Approximately(1.0, (double)export.SelectedKeyframes!.Value, 1e-9);
|
||||
|
||||
// Baseline takes no B-frames.
|
||||
Assert.True(export.CanChooseProfile);
|
||||
export.SelectedProfile = export.ProfileChoices.Single(c => Equals(c.Value, CodecProfile.H264Baseline));
|
||||
Assert.Equal(0, editor.Session.Project.Export.Overrides.BFrames);
|
||||
Assert.False(export.CanChooseBFrames);
|
||||
|
||||
// A reverse playback raises the settings format; Reset writes none again.
|
||||
Assert.True(export.IsPlaybackDefault);
|
||||
export.SelectedDirection = export.Directions.Single(d => Equals(d.Value, PlaybackDirection.Reverse));
|
||||
Assert.Equal(PlaybackDirection.Reverse, editor.Session.Project.Export.Playback?.Direction);
|
||||
Assert.Equal(3, editor.Session.Project.RequiredFormat);
|
||||
Assert.False(export.IsPlaybackDefault);
|
||||
export.FadeIn = 1.5;
|
||||
Assert.Equal(1.5, editor.Session.Project.Export.Playback?.FadeIn);
|
||||
Assert.True(await editor.WhenIdleAsync(TimeSpan.FromSeconds(60)));
|
||||
Assert.Equal("Reverse · fades 1.5 s / 0 s", export.PlaybackGroup.Summary);
|
||||
export.ResetPlaybackCommand.Execute(null);
|
||||
Assert.Null(editor.Session.Project.Export.Playback);
|
||||
Assert.True(editor.Session.Project.RequiredFormat < 3);
|
||||
|
||||
// The preset table: every preset once, in the built-in order of the groups, one group open at least.
|
||||
Assert.Equal(export.Presets.Count, export.PresetGroups.Sum(g => g.Rows.Count));
|
||||
var order = ExportPresets.BuiltIn.Select(p => p.Group).Distinct(StringComparer.Ordinal).ToList();
|
||||
Assert.SequenceEqual(order.Where(g => export.PresetGroups.Any(p => p.Key == g)), export.PresetGroups.Select(g => g.Key));
|
||||
Assert.True(export.PresetGroups.Any(g => g.IsExpanded));
|
||||
var social = export.PresetGroups.Single(g => g.Key == "social");
|
||||
Assert.Equal($"Social ({export.Presets.Count(p => p.Group == "social")})", social.Header, "a sequence preset sits in its export preset's group");
|
||||
Assert.True(social.Rows.Count >= 3);
|
||||
|
||||
// The footer: Batch (n) counts the ticked presets, Videos (n) the renders.
|
||||
Assert.Equal("Batch (0)", export.BatchText);
|
||||
export.Presets.First(p => p.CanBatch).IsInBatch = true;
|
||||
Assert.Equal("Batch (1)", export.BatchText);
|
||||
Assert.Equal(Loc.L("Export.Footer.Videos", content.Renders.Count.ToString("N0", Loc.Culture)), export.VideosText);
|
||||
Assert.NotNull(export.FooterSummary);
|
||||
|
||||
// A library sequence saves its .chronos project file from the footer; a workspace project has it in its project ▾ menu.
|
||||
var panel = new ContentControl { Content = export };
|
||||
panel.Resources.MergedDictionaries.Add(new ResourceDictionary
|
||||
{
|
||||
Source = new Uri("pack://application:,,,/Chronos;component/Editor/EditorPanels.xaml", UriKind.Absolute),
|
||||
});
|
||||
panel.Measure(new Size(420, 4000));
|
||||
panel.Arrange(new Rect(0, 0, 420, 4000));
|
||||
panel.UpdateLayout();
|
||||
var save = Assert.NotNull(Descendants<Button>(panel).SingleOrDefault(b => ReferenceEquals(b.Command, export.SaveProjectCommand)));
|
||||
Assert.False(editor.HasProject);
|
||||
Assert.Equal(Visibility.Visible, save.Visibility);
|
||||
Assert.Equal("Editor.HasProject", BindingOperations.GetBinding(save, UIElement.VisibilityProperty)?.Path.Path);
|
||||
Assert.True(export.SaveProjectCommand.CanExecute(null));
|
||||
}
|
||||
});
|
||||
|
||||
private static IEnumerable<T> Descendants<T>(DependencyObject root)
|
||||
where T : DependencyObject
|
||||
{
|
||||
for (var i = 0; i < VisualTreeHelper.GetChildrenCount(root); i++)
|
||||
{
|
||||
var child = VisualTreeHelper.GetChild(root, i);
|
||||
if (child is T match) yield return match;
|
||||
foreach (var nested in Descendants<T>(child)) yield return nested;
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>A Videos section as the shell would hold it.</summary>
|
||||
private sealed class FakeVideos() : SectionViewModel(SectionKey.Jobs, "Icon.Jobs"), IVideosSection
|
||||
{
|
||||
public Guid? Shown { get; private set; }
|
||||
|
||||
public void ShowSequence(Guid? sequenceId) => Shown = sequenceId;
|
||||
}
|
||||
}
|
||||
@@ -117,7 +117,7 @@ public sealed class ProjectHistoryTests
|
||||
[Test]
|
||||
public void SettingsOfANewerChronosAdoptedDropTheStepsInsteadOfMergingThem()
|
||||
{
|
||||
var newer = ProjectSettings.FromJson("""{ "version": 3, "exposure": { "exposureOffsetEv": 1.5 }, "grade": { "look": "film" } }""", allowNewer: true);
|
||||
var newer = ProjectSettings.FromJson("""{ "version": 4, "exposure": { "exposureOffsetEv": 1.5 }, "grade": { "look": "film" } }""", allowNewer: true);
|
||||
// The workspace's merge throws as ProjectMerge does where both sides changed and one is a newer Chronos's.
|
||||
foreach (var merge in new Func<ProjectSettings, ProjectSettings, ProjectSettings, ProjectSettings>?[]
|
||||
{ null, (basis, ours, theirs) => ProjectMerge.MergeWithConflicts(basis, ours, theirs).Merged })
|
||||
|
||||
@@ -0,0 +1,144 @@
|
||||
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;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,301 @@
|
||||
using System.Text.Json;
|
||||
using Chronos.App.Editor;
|
||||
using Chronos.Core.Export;
|
||||
using Chronos.Core.Localization;
|
||||
using Chronos.Core.Model;
|
||||
using Chronos.Core.Project;
|
||||
using Chronos.Core.Render;
|
||||
using Chronos.Core.Video;
|
||||
using Chronos.Data.Archiving.Jobs;
|
||||
using Chronos.Protocol;
|
||||
using Chronos.Testing;
|
||||
using Chronos.Ui.Mvvm;
|
||||
using Chronos.Ui.Visuals;
|
||||
|
||||
namespace Chronos.App.Tests.Editor;
|
||||
|
||||
/// <summary>
|
||||
/// The editor's Render ▾ menu (owner review 1, R3, decisions 1, 2 and 12): grouped presets with the current one checked,
|
||||
/// recent presets from the render history, Save frame and why it waits, still jobs, the Render tooltip.
|
||||
/// </summary>
|
||||
public sealed class RenderMenuTests
|
||||
{
|
||||
private static readonly RelayCommand Select = new(_ => { });
|
||||
|
||||
[Test]
|
||||
public void TheMenuPutsTheCurrentTheRecommendedTheBatchAndTheRecentPresetsFirstAndGroupsTheRest()
|
||||
{
|
||||
var menu = RenderMenu.Build(new RenderMenuState
|
||||
{
|
||||
CurrentPresetId = "4k-hevc",
|
||||
BasePresetId = "4k-hevc",
|
||||
RecommendedPresetId = "4k-hevc10-archive",
|
||||
Batch = ["1080p-h264", "4k-hevc10-archive"],
|
||||
Recent = ["vertical-1080x1920", "1080p-h264", "gif-preview", "apng", "png-sequence"],
|
||||
Details = p => p.Id + " details",
|
||||
SelectPreset = Select,
|
||||
});
|
||||
|
||||
// The current preset, listed by no section, comes first and is the one checked.
|
||||
Assert.Equal("preset:4k-hevc", menu[0].Id);
|
||||
Assert.True(menu[0].IsChecked);
|
||||
Assert.Equal(Loc.L("Export.Preset.4kHevc"), menu[0].Label);
|
||||
Assert.Equal("4k-hevc details", menu[0].Details);
|
||||
Assert.Same(Select, menu[0].Command);
|
||||
Assert.Equal("4k-hevc", menu[0].CommandParameter);
|
||||
Assert.Count(1, menu.SelectMany(m => m.Flatten()).Where(m => m.IsChecked));
|
||||
|
||||
var top = menu.TakeWhile(m => m.Kind != RenderMenuItemKind.Submenu).ToList();
|
||||
Assert.SequenceEqual(
|
||||
[
|
||||
"preset:4k-hevc", Loc.L("Editor.RenderMenu.Recommended"), "preset:4k-hevc10-archive", Loc.L("Export.Footer.Batch", 2), "preset:1080p-h264",
|
||||
Loc.L("Editor.RenderMenu.Recent"), "preset:vertical-1080x1920", "preset:gif-preview", "preset:apng",
|
||||
], top.Select(m => m.Id ?? m.Label).ToList());
|
||||
Assert.True(top.Where(m => m.Kind == RenderMenuItemKind.Header).All(h => h.Command is null), "headers are titles");
|
||||
Assert.Contains(Loc.L("Tooltips.Editor.RenderMenu.Recommended"), top[2].ToolTip!);
|
||||
Assert.Contains(Loc.L("Tooltips.Editor.RenderMenu.Recent"), top[6].ToolTip!);
|
||||
|
||||
// Other presets ›: every preset not listed above, under its group's title, the groups in the Export step's order.
|
||||
var other = Assert.Contains(menu, m => m.Id == "other");
|
||||
Assert.Equal(RenderMenuItemKind.Submenu, other.Kind);
|
||||
var headers = other.Children.Where(c => c.Kind == RenderMenuItemKind.Header).Select(c => c.Label).ToList();
|
||||
Assert.SequenceEqual([.. new[] { "video", "social", "intermediate", "sequence" }.Select(RenderMenu.GroupLabel)], headers,
|
||||
"the Web group, both of its presets already listed above, has no title of its own");
|
||||
var listed = menu.SelectMany(m => m.Flatten()).Where(m => m.Kind == RenderMenuItemKind.Preset).Select(m => (string)m.CommandParameter!).ToList();
|
||||
Assert.Equal(ExportPresets.BuiltIn.Count, listed.Count, "every preset once");
|
||||
Assert.Equal(ExportPresets.BuiltIn.Count, listed.Distinct().Count());
|
||||
Assert.True(menu.SelectMany(m => m.Flatten()).All(m => m.Kind is RenderMenuItemKind.Header or RenderMenuItemKind.Separator || m.ToolTip is { Length: > 0 }),
|
||||
"every entry that does something has a tooltip");
|
||||
|
||||
// The lower part, in its order.
|
||||
Assert.SequenceEqual(["batch", "queue", "frame", "videos"], menu.SkipWhile(m => m.Kind != RenderMenuItemKind.Separator).Skip(1).Select(m => m.Id!).ToList());
|
||||
Assert.Equal(Loc.L("Editor.RenderMenu.Batch", 2), Assert.Contains(menu, m => m.Id == "batch").Label);
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void APresetAlreadyRecommendedIsNotListedAgainAndACustomExportChecksNone()
|
||||
{
|
||||
var menu = RenderMenu.Build(new RenderMenuState
|
||||
{
|
||||
CurrentPresetId = null,
|
||||
BasePresetId = "4k-hevc10-archive",
|
||||
RecommendedPresetId = "4k-hevc10-archive",
|
||||
Recent = ["4k-hevc10-archive"],
|
||||
});
|
||||
Assert.Equal(RenderMenuItemKind.Header, menu[0].Kind, "the base preset is the recommended one: no separate first entry");
|
||||
Assert.Count(1, menu.SelectMany(m => m.Flatten()).Where(m => m.Id == "preset:4k-hevc10-archive"));
|
||||
Assert.False(menu.SelectMany(m => m.Flatten()).Any(m => m.IsChecked), "Custom values match no preset");
|
||||
Assert.False(menu.Any(m => m.Label == Loc.L("Editor.RenderMenu.Recent")), "no recent preset left to show");
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void ThePresetDetailsFollowTheChosenProportions()
|
||||
{
|
||||
var portrait = new CameraSettings { Aspect = new Auto<string>().WithManual("9:16") };
|
||||
Assert.Equal(Loc.L("Editor.RenderMenu.Details", "2160×3840", Loc.L("Export.Codec.HevcMain10"), Loc.L("Editor.Value.Fps", "24")),
|
||||
RenderMenu.PresetDetails(new ExportSettings(), "4k-hevc10-archive", portrait, 6000, 4000));
|
||||
Assert.True(RenderMenu.PresetDetails(new ExportSettings(), "png-sequence", new CameraSettings(), 6000, 4000).StartsWith("6000×4000", StringComparison.Ordinal),
|
||||
"an image sequence keeps the source's size");
|
||||
Assert.True(RenderMenu.PresetDetails(new ExportSettings(), "png-sequence", new CameraSettings(), 0, 0).StartsWith(Loc.L("Export.Resolution.Source"), StringComparison.Ordinal));
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void RecentPresetsComeFromTheRenderHistoryNewestFirst()
|
||||
{
|
||||
var sequence = Guid.CreateVersion7();
|
||||
var settings = new ProjectSettings { Export = new ExportSettings { Preset = new Auto<string>().WithManual("4k-h264") } }.ToJson();
|
||||
var custom = new ProjectSettings { Export = new ExportSettings { Preset = new Auto<string>().WithManual("4k-h264"), Overrides = new ExportOverrides { BitRate = 1 } } }.ToJson();
|
||||
IReadOnlyList<Render> renders =
|
||||
[
|
||||
Render(sequence, "whatever", settings),
|
||||
Render(sequence, Loc.L("Export.Preset.Png"), null) with { Kind = RenderKind.Still },
|
||||
Render(sequence, Loc.L("Export.Preset.1080pShare"), null),
|
||||
Render(sequence, "Custom", custom),
|
||||
Render(sequence, Loc.L("Export.Preset.4kH264"), settings),
|
||||
Render(sequence, Loc.L("Export.Preset.Gif"), "{not json"),
|
||||
Render(sequence, Loc.L("Export.Preset.Vertical"), null),
|
||||
];
|
||||
Assert.SequenceEqual(["4k-h264", "1080p-h264", "gif-preview"], [.. RenderMenu.RecentPresets(renders)],
|
||||
"settings first, else the name; a saved frame, a custom export and a repeat do not count; three at most");
|
||||
Assert.Null(RenderMenu.PresetOf(Render(sequence, "Custom", custom)));
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void SaveFrameWaitsWithTheReason()
|
||||
{
|
||||
Assert.Equal(Loc.L("Tooltips.Export.StillReadOnly"), RenderMenu.SaveFrameBlockedReason(false, null, readOnly: true, hasFrame: true, true, null, null));
|
||||
Assert.Equal(Loc.L("Tooltips.Export.StillNeedsFrame"), RenderMenu.SaveFrameBlockedReason(false, null, false, hasFrame: false, true, null, null));
|
||||
Assert.Equal(Loc.L("Tooltips.Editor.Outdated", "Studio NAS"), RenderMenu.SaveFrameBlockedReason(outdated: true, "Studio NAS", true, false, true, null, null), "out of date first");
|
||||
var older = ServerJobs.StillNeedsNewerServer(serverFormat: 2);
|
||||
Assert.Equal(Loc.L("Tooltips.Server.NeedsNewerServer"), older);
|
||||
Assert.Null(ServerJobs.StillNeedsNewerServer(RenderRules.StillFormat), "a format-3 server takes still jobs");
|
||||
Assert.Equal(older, RenderMenu.SaveFrameBlockedReason(false, "Studio NAS", false, true, true, older, null));
|
||||
Assert.Equal(Loc.L("Tooltips.Editor.Render.NameError", "bad"), RenderMenu.SaveFrameBlockedReason(false, null, false, true, true, null, "bad"));
|
||||
Assert.Equal(Loc.L("Tooltips.Export.StillWorkspace"), RenderMenu.SaveFrameBlockedReason(false, null, false, true, sourceSavesFrames: false, null, null),
|
||||
"a source that renders elsewhere without still jobs of its own");
|
||||
Assert.Null(RenderMenu.SaveFrameBlockedReason(false, null, false, true, true, null, null));
|
||||
|
||||
// In the menu: Save frame › and its formats are disabled and say why.
|
||||
var menu = RenderMenu.Build(new RenderMenuState { SaveFrameBlocked = older });
|
||||
var frame = Assert.Contains(menu, m => m.Id == "frame");
|
||||
Assert.False(frame.IsEnabled);
|
||||
Assert.Equal(older, frame.ToolTip);
|
||||
Assert.SequenceEqual(["frame:pngsequence", "frame:jpegsequence", "frame:tiff16sequence"], [.. frame.Children.Select(c => c.Id!)]);
|
||||
Assert.True(frame.Children.All(c => !c.IsEnabled && c.ToolTip == older));
|
||||
Assert.SequenceEqual(["PNG", "JPEG", Loc.L("Export.Codec.Tiff16Sequence")], [.. frame.Children.Select(c => c.Label)]);
|
||||
|
||||
var ready = Assert.Contains(RenderMenu.Build(new RenderMenuState()), m => m.Id == "frame");
|
||||
Assert.True(ready.IsEnabled);
|
||||
Assert.Equal(VideoCodec.JpegSequence, ready.Children[1].CommandParameter);
|
||||
Assert.Equal(Loc.L("Tooltips.Editor.RenderMenu.SaveFormat", "JPEG"), ready.Children[1].ToolTip);
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void APlaybackExportNeedsAFormatThreeServer()
|
||||
{
|
||||
var playback = new ExportSettings { Playback = new PlaybackSettings { Direction = PlaybackDirection.Boomerang } };
|
||||
Assert.Equal(Loc.L("Tooltips.Server.NeedsNewerServer"), ServerJobs.RenderNeedsNewerServer(new ProjectSettings(), playback, 6000, 4000, serverFormat: 2));
|
||||
Assert.Null(ServerJobs.RenderNeedsNewerServer(new ProjectSettings(), playback, 6000, 4000, serverFormat: 3));
|
||||
Assert.Null(ServerJobs.RenderNeedsNewerServer(new ProjectSettings(), new ExportSettings(), 6000, 4000, serverFormat: 1), "no playback: format 1");
|
||||
// The format is read from the export rendered, not from the project's own export.
|
||||
Assert.NotNull(ServerJobs.RenderNeedsNewerServer(new ProjectSettings { Export = new ExportSettings() }, playback, 6000, 4000, serverFormat: 2));
|
||||
}
|
||||
|
||||
[Test]
|
||||
public async Task AStillJobCarriesTheFrameAndItsPhoto()
|
||||
{
|
||||
var content = EditorFixture.Content(EditorFixture.Sunset);
|
||||
content = content with { Frames = [.. content.Frames.Select((f, i) => f with { Sha256 = $"{i:X64}" })] };
|
||||
var source = new FakeSequenceSource(EditorFixture.Sunset, content);
|
||||
await using var session = new EditorSession(source, content, [], TimeSpan.FromMilliseconds(20));
|
||||
session.Edit(p => p with { Exposure = p.Exposure with { ExposureOffsetEv = 0.3 } });
|
||||
Assert.True(session.CanSaveFrames);
|
||||
|
||||
var export = session.Project.Export with { Playback = new PlaybackSettings { Direction = PlaybackDirection.Reverse }, Batch = ["1080p-h264"] };
|
||||
var request = Assert.Contains(Assert.NotNull(session.StillRequests(export, VideoCodec.PngSequence, 5)), _ => true);
|
||||
Assert.Equal(JobKind.Render, request.Kind);
|
||||
Assert.SequenceEqual([content.Sequence.Id], [.. request.Targets]);
|
||||
var parameters = Assert.NotNull(JsonSerializer.Deserialize(request.ParametersJson!, ProtocolJson.Default.RenderJobParameters));
|
||||
Assert.Equal(5, parameters.StillFrame);
|
||||
Assert.Equal($"{5:x64}", parameters.StillPhoto, "the photo's hash, lower case");
|
||||
Assert.True(parameters.IsStill);
|
||||
Assert.GreaterOrEqual(parameters.RequiredSettingsFormat, RenderRules.StillFormat, "an older node never claims it");
|
||||
Assert.Equal("pngsequence", parameters.Codec);
|
||||
Assert.Equal(0.3, ProjectSettings.FromJson(parameters.SettingsJson!).Exposure.ExposureOffsetEv, "the project as the editor holds it");
|
||||
Assert.Throws<ArgumentOutOfRangeException>(() => session.StillRequests(export, VideoCodec.PngSequence, content.Count));
|
||||
|
||||
// A server sequence: one job too.
|
||||
var remote = new FakeSequenceSource(EditorFixture.Sunset, content) { IsRemote = true };
|
||||
await using var remoteSession = new EditorSession(remote, content, [], TimeSpan.FromMilliseconds(20));
|
||||
Assert.Count(1, Assert.NotNull(remoteSession.StillRequests(export, VideoCodec.Tiff16Sequence, 0)));
|
||||
}
|
||||
|
||||
[Test]
|
||||
public async Task AWorkspaceProjectSavesNoFrameUntilItMakesItsOwnStillJobs()
|
||||
{
|
||||
var content = EditorFixture.Content(EditorFixture.Sunset);
|
||||
var fake = new FakeSequenceSource(EditorFixture.Sunset, content);
|
||||
await using (var session = new EditorSession(new HomeRenders(fake), content, [], TimeSpan.FromMilliseconds(20)))
|
||||
{
|
||||
Assert.False(session.CanSaveFrames);
|
||||
Assert.Null(session.StillRequests(session.Project.Export, VideoCodec.PngSequence, 0));
|
||||
}
|
||||
var stills = new HomeStills(fake);
|
||||
await using (var session = new EditorSession(stills, content, [], TimeSpan.FromMilliseconds(20)))
|
||||
{
|
||||
Assert.True(session.CanSaveFrames);
|
||||
Assert.Count(1, Assert.NotNull(session.StillRequests(session.Project.Export, VideoCodec.JpegSequence, 3)));
|
||||
Assert.Equal((VideoCodec.JpegSequence, 3), stills.Asked);
|
||||
}
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void TheRenderTooltipGivesThePresetTheSizeTheCodecAndTheEstimates()
|
||||
{
|
||||
var content = EditorFixture.Content(EditorFixture.Sunset);
|
||||
var plan = Assert.NotNull(new ExportPlanner(content, [], EncoderHost.Client).Plan(content.Project with
|
||||
{
|
||||
Export = new ExportSettings { Preset = new Auto<string>().WithManual("4k-hevc10-archive") },
|
||||
}));
|
||||
var tip = RenderMenu.RenderToolTip(plan, null, null);
|
||||
var (width, height) = plan.EncodedSize;
|
||||
Assert.Contains(plan.PresetName, tip);
|
||||
Assert.Contains(EditorText.Size(width, height), tip);
|
||||
Assert.Contains(Loc.L("Export.Codec.HevcMain10"), tip);
|
||||
Assert.Contains("Ctrl+R", tip);
|
||||
|
||||
var blocked = RenderMenu.RenderToolTip(plan, "Fix it first", "Studio NAS");
|
||||
Assert.True(blocked.StartsWith("Fix it first" + Environment.NewLine, StringComparison.Ordinal), "the reason comes first");
|
||||
Assert.False(blocked.Contains(Loc.L("Tooltips.Editor.RenderServer", "Studio NAS"), StringComparison.Ordinal));
|
||||
Assert.True(RenderMenu.RenderToolTip(plan, null, "Studio NAS").EndsWith(Loc.L("Tooltips.Editor.RenderServer", "Studio NAS"), StringComparison.Ordinal));
|
||||
Assert.Equal("Planning", RenderMenu.RenderToolTip(null, "Planning", null));
|
||||
}
|
||||
|
||||
private static Render Render(Guid sequence, string presetName, string? settings) => new()
|
||||
{
|
||||
Id = Guid.CreateVersion7(),
|
||||
SequenceId = sequence,
|
||||
PresetName = presetName,
|
||||
SettingsJson = settings,
|
||||
OutputPath = "C:/out/" + presetName,
|
||||
};
|
||||
|
||||
/// <summary>A source that renders at a home of its own (as a workspace project), delegating the rest.</summary>
|
||||
private class HomeRenders(FakeSequenceSource inner) : ISequenceSource, IProjectRenders
|
||||
{
|
||||
public bool IsRemote => inner.IsRemote;
|
||||
|
||||
public bool IsReadOnly => inner.IsReadOnly;
|
||||
|
||||
public bool IsOutdated => inner.IsOutdated;
|
||||
|
||||
public bool RendersLocally => false;
|
||||
|
||||
public event Action? ReadOnlyChanged
|
||||
{
|
||||
add => inner.ReadOnlyChanged += value;
|
||||
remove => inner.ReadOnlyChanged -= value;
|
||||
}
|
||||
|
||||
public event Action<Job>? JobChanged
|
||||
{
|
||||
add => inner.JobChanged += value;
|
||||
remove => inner.JobChanged -= value;
|
||||
}
|
||||
|
||||
public IReadOnlyList<ArchiveJobRequest> RenderRequests(Sequence sequence, ProjectSettings project, ExportSettings export, int sourceWidth, int sourceHeight) => [];
|
||||
|
||||
public Task<SequenceContent> LoadAsync(CancellationToken cancellationToken) => inner.LoadAsync(cancellationToken);
|
||||
|
||||
public Task<bool> FramesCurrentAsync(CancellationToken cancellationToken) => inner.FramesCurrentAsync(cancellationToken);
|
||||
|
||||
public ValueTask<Core.Imaging.ImageBuffer?> DecodeAsync(int index, int maxLongEdge, Core.Imaging.DecodePurpose purpose, CancellationToken cancellationToken) =>
|
||||
inner.DecodeAsync(index, maxLongEdge, purpose, cancellationToken);
|
||||
|
||||
public Task<ProjectSettings> SaveProjectAsync(ProjectSettings project, ProjectSettings basis, CancellationToken cancellationToken) =>
|
||||
inner.SaveProjectAsync(project, basis, cancellationToken);
|
||||
|
||||
public Task<Guid> SubmitAsync(ArchiveJobRequest request, CancellationToken cancellationToken) => inner.SubmitAsync(request, cancellationToken);
|
||||
|
||||
public Task<IReadOnlyList<Job>> ListJobsAsync(CancellationToken cancellationToken) => inner.ListJobsAsync(cancellationToken);
|
||||
|
||||
public Task CancelJobAsync(Guid jobId, CancellationToken cancellationToken) => inner.CancelJobAsync(jobId, cancellationToken);
|
||||
|
||||
public Task RetryJobAsync(Guid jobId, CancellationToken cancellationToken) => inner.RetryJobAsync(jobId, cancellationToken);
|
||||
|
||||
public ValueTask DisposeAsync() => inner.DisposeAsync();
|
||||
}
|
||||
|
||||
/// <summary>A home-rendering source that makes its own still jobs.</summary>
|
||||
private sealed class HomeStills(FakeSequenceSource inner) : HomeRenders(inner), IProjectStills
|
||||
{
|
||||
public (VideoCodec Codec, int Frame)? Asked { get; private set; }
|
||||
|
||||
public IReadOnlyList<ArchiveJobRequest> StillRequests(Sequence sequence, ProjectSettings project, ExportSettings export, VideoCodec codec, int frameIndex,
|
||||
string? photoSha256, int sourceWidth, int sourceHeight)
|
||||
{
|
||||
Asked = (codec, frameIndex);
|
||||
return [new ArchiveJobRequest(JobKind.Render, [sequence.Id], "still", null, JobPriority.User)];
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user