test(app): editor history, saver retry, merge, preview re-solve and capture scenes
- Tests for undo after adopted changes, run ending, saver retries and stop, the local source refusing unsaved writes, re-solves without decoding and equal to a fresh preparation, 1:1 pictures, waveform, crop margins and the values of the Optimise toast; the Windows smoke test checks Render, Batch, the waveform, 1:1, the window title and the hidden idle job bar. - The capture sample has a manual value and camera keyframes; the capture adds the overlays, the waveform, the Optimise toast and Export.html's tool state. - Crop margins live in a WPF-free class; a discarded change stops retrying. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_012iLMBNwBE2GnphAsu4cjaC
This commit is contained in:
15 files changed
+462
-53
No files matched your search
@@ -103,6 +103,84 @@ public sealed class PreviewRendererTests
|
||||
Assert.Equal(decodes, source.Decodes);
|
||||
}
|
||||
|
||||
[Test]
|
||||
public async Task SolveSettingsReuseTheMeasurementsWithoutDecoding()
|
||||
{
|
||||
var (renderer, source) = Create();
|
||||
var project = Sunset();
|
||||
await renderer.PrepareAsync(project, CancellationToken.None);
|
||||
var decodes = source.Decodes;
|
||||
Assert.Greater(decodes, 0, "stabilisation and colour are measured once");
|
||||
foreach (var strength in new[] { 0.3, 0.6, 0.9 })
|
||||
{
|
||||
var changed = project with { Exposure = project.Exposure with { DeflickerStrength = project.Exposure.DeflickerStrength.WithManual(strength), TransitionLength = project.Exposure.TransitionLength.WithManual(6) } };
|
||||
await renderer.PrepareAsync(changed, CancellationToken.None);
|
||||
}
|
||||
Assert.Equal(decodes, source.Decodes, "a strength or transition change re-solves from the measured series");
|
||||
}
|
||||
|
||||
[Test]
|
||||
public async Task AReSolveMatchesAFreshPreparation()
|
||||
{
|
||||
var (warm, _) = Create();
|
||||
var project = Sunset();
|
||||
await warm.PrepareAsync(project, CancellationToken.None);
|
||||
var changed = project with { Exposure = project.Exposure with { DeflickerStrength = project.Exposure.DeflickerStrength.WithManual(0.5), ExposureOffsetEv = 0.3 } };
|
||||
var resolved = await warm.PrepareAsync(changed, CancellationToken.None);
|
||||
var (cold, _) = Create();
|
||||
var fresh = await cold.PrepareAsync(changed, CancellationToken.None);
|
||||
|
||||
Assert.Equal(fresh.ExposureEv.Length, resolved.ExposureEv.Length);
|
||||
for (var i = 0; i < fresh.ExposureEv.Length; i++) Assert.Approximately(fresh.ExposureEv[i], resolved.ExposureEv[i], 1e-9, $"frame {i}");
|
||||
Assert.NotNull(resolved.WhiteBalance);
|
||||
for (var i = 0; i < fresh.WhiteBalance!.Length; i++) Assert.Equal(fresh.WhiteBalance[i], resolved.WhiteBalance![i]);
|
||||
Assert.Equal(fresh.StabilizationZoom, resolved.StabilizationZoom);
|
||||
Assert.NotNull(resolved.Stabilization);
|
||||
Assert.SequenceEqual(fresh.Stabilization!, resolved.Stabilization!);
|
||||
}
|
||||
|
||||
[Test]
|
||||
public async Task ActualSizeRendersTheSourcePixels()
|
||||
{
|
||||
var (renderer, _) = Create();
|
||||
var edge = int.Max(EditorFixture.Sunset.Options.Width, EditorFixture.Sunset.Options.Height);
|
||||
using var frame = await renderer.RenderAsync(new PreviewRequest(3, new ProjectSettings(), edge, PreviewFraming.Source, Vectors: true), null,
|
||||
CancellationToken.None);
|
||||
Assert.Equal(EditorFixture.Sunset.Options.Width, frame!.Corrected.Width, "one picture pixel per source pixel");
|
||||
Assert.Equal(EditorFixture.Sunset.Options.Height, frame.Corrected.Height);
|
||||
Assert.NotEmpty(frame.Vectors);
|
||||
Assert.True(frame.Vectors.All(v => v.X < frame.Corrected.Width && v.Y < frame.Corrected.Height), "vectors in picture pixels");
|
||||
}
|
||||
|
||||
[Test]
|
||||
public async Task TheWaveformIsMeasuredOnRequest()
|
||||
{
|
||||
var (renderer, _) = Create();
|
||||
using var plain = await renderer.RenderAsync(new PreviewRequest(3, new ProjectSettings(), 64, PreviewFraming.Output), null, CancellationToken.None);
|
||||
Assert.Null(plain!.Waveform);
|
||||
using var frame = await renderer.RenderAsync(new PreviewRequest(3, new ProjectSettings(), 64, PreviewFraming.Output, Waveform: true), null,
|
||||
CancellationToken.None);
|
||||
var waveform = Assert.NotNull(frame!.Waveform);
|
||||
Assert.Equal(frame.Corrected.Width, waveform.Columns);
|
||||
Assert.True(waveform.Density.Any(d => d > 0));
|
||||
}
|
||||
|
||||
/// <summary>A sunset project as the advisor leaves it: deflicker, holy grail, white balance and stabilisation on.</summary>
|
||||
private static ProjectSettings Sunset()
|
||||
{
|
||||
var p = new ProjectSettings();
|
||||
return p with
|
||||
{
|
||||
Exposure = p.Exposure with
|
||||
{
|
||||
Deflicker = p.Exposure.Deflicker.WithManual(true),
|
||||
HolyGrail = p.Exposure.HolyGrail.WithManual(true),
|
||||
WhiteBalanceSmoothing = p.Exposure.WhiteBalanceSmoothing.WithManual(true),
|
||||
},
|
||||
Motion = p.Motion with { Stabilize = p.Motion.Stabilize.WithManual(true) },
|
||||
};
|
||||
}
|
||||
|
||||
private static double LogMean(ImageBuffer image)
|
||||
{
|
||||
double sum = 0;
|
||||
|
||||
Reference in new issue
Block a user