Owner review 1 asked for the Camera step to frame the picture the way the mockup does, so the step now offers Aspect, Rotation (icon buttons), Mirror and Flip switches, Straighten, Crop size, Crop X and Crop Y, and Reset framing. Cropping by margins is gone: the crop box is now held to the chosen aspect. - EditorSession gains Orient and ResetFraming. Edit and Optimise refit a box that was already held to the aspect whenever the aspect or the export box changes, and do it in the same undo step. A crop from an older project that was placed by offsets is left for the render to fit. - Straighten drives the preview's grid through the new SliderActivity attached behaviour, which a NumberRow switches on with ShowsGrid. - Exposure gains a Look group with Filter and Strength. A newer project's extra look data is kept as it is. - Export: Width and Height now edit the preset's own box, and a new Output size row shows the size after the chosen proportions are applied, marked Capped when the encoder shrinks it. ExportPlan carries OutputSize and EncodedSize. - New SwitchRow, IconActionsRow and GroupRow rows with their panel templates. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
83 lines
4.2 KiB
C#
83 lines
4.2 KiB
C#
using Chronos.App.Editor;
|
||
using Chronos.Core.Advice;
|
||
using Chronos.Core.Imaging;
|
||
using Chronos.Core.Localization;
|
||
using Chronos.Core.Project;
|
||
using Chronos.Data.Projects;
|
||
using Chronos.Testing;
|
||
|
||
namespace Chronos.App.Tests.Editor;
|
||
|
||
/// <summary>Composed texts of the editor (the conflict prompt among them, the Camera step's values) and the waveform monitor.</summary>
|
||
public sealed class EditorTextTests
|
||
{
|
||
static EditorTextTests() => _ = EditorFixture.Sunset;
|
||
|
||
[Test]
|
||
public void ColourTemperatureShowsToTheNearestTen()
|
||
{
|
||
Assert.Equal(5560.0, ExposureTab.RoundToTens(5557.2));
|
||
Assert.Equal(3200.0, ExposureTab.RoundToTens(3203.9));
|
||
Assert.Equal(12_000.0, ExposureTab.RoundToTens(11_998));
|
||
}
|
||
|
||
[Test]
|
||
public void OptimiseReportsValuesAsTheControlsShowThem()
|
||
{
|
||
Assert.Equal("Frame 0413", EditorText.Value(AdvisorParameters.Hero, 412), "1-based, four digits, like the Frames tab");
|
||
Assert.Equal("Source", EditorText.Value(AdvisorParameters.Aspect, "source"));
|
||
Assert.Equal("16:9", EditorText.Value(AdvisorParameters.Aspect, "16:9"));
|
||
Assert.Equal("24 fps", EditorText.Value(AdvisorParameters.FrameRate, "24"));
|
||
Assert.Equal("41 frames", EditorText.Value(AdvisorParameters.DeflickerWindow, 41));
|
||
Assert.Equal("0.80", EditorText.Value(AdvisorParameters.DeflickerStrength, 0.8));
|
||
Assert.Equal("Centred", EditorText.Value(AdvisorParameters.OffsetY, 0.0));
|
||
Assert.Equal("On", EditorText.Value(AdvisorParameters.Deflicker, true));
|
||
Assert.Equal("Horizon", EditorText.Value(AdvisorParameters.Regions, RegionMode.Horizon));
|
||
Assert.Equal("None", EditorText.Value(AdvisorParameters.Hero, null));
|
||
Assert.Equal("3 frames", EditorText.Value(AdvisorParameters.Excluded, new[] { 1, 2, 3 }));
|
||
}
|
||
|
||
[Test]
|
||
public void TheCameraRowsShowAnglesAndPlacementsAsTheMockupDoes()
|
||
{
|
||
Assert.Equal("−1.2°", CameraTab.Degrees(-1.2), "a minus sign, one decimal");
|
||
Assert.Equal("15.0°", CameraTab.Degrees(15));
|
||
Assert.Equal("0°", CameraTab.Degrees(0), "level reads as a whole number");
|
||
Assert.Equal("0°", CameraTab.Degrees(-0.0), "never a negative zero");
|
||
Assert.Equal("+0.40", EditorText.Placement(0.4));
|
||
Assert.Equal("−0.60", EditorText.Placement(-0.6));
|
||
Assert.Equal("Centred", EditorText.Placement(0));
|
||
}
|
||
|
||
[Test]
|
||
public void AFlatGreyPictureIsOneLineOfTheWaveform()
|
||
{
|
||
using var grey = new ImageBuffer(40, 10);
|
||
grey.Data.Fill((float)ColorSpace.SrgbToLinear(0.5));
|
||
var waveform = LumaWaveform.Measure(grey);
|
||
Assert.Equal(40, waveform.Columns);
|
||
Assert.Equal(LumaWaveform.Levels, waveform.Rows);
|
||
var lit = Enumerable.Range(0, waveform.Rows).Where(r => waveform.Density[r * waveform.Columns] > 0).ToList();
|
||
Assert.Equal(1, lit.Count, "one level");
|
||
Assert.LessOrEqual(Math.Abs(lit[0] - (LumaWaveform.Levels - 1) / 2.0), 1.0, "half grey sits halfway up");
|
||
Assert.Equal(255, waveform.Density[lit[0] * waveform.Columns], "every pixel of the column there");
|
||
}
|
||
|
||
[Test]
|
||
public void TheConflictPromptSaysWhatDiffersAndTakesTheServersValuesUnlessAsked()
|
||
{
|
||
var basis = new ProjectSettings();
|
||
var mine = basis with { Exposure = basis.Exposure with { ExposureOffsetEv = 0.5 }, HeroFrame = 3 };
|
||
var theirs = basis with { Exposure = basis.Exposure with { ExposureOffsetEv = 0.3 } };
|
||
var conflict = new ProjectConflictException("changed", theirs, ProjectMerge.Conflicts(basis, mine, theirs));
|
||
var request = EditorViewModel.ConflictRequest(conflict, "Harbour sunset", "Studio NAS");
|
||
|
||
Assert.Equal(Loc.L("Server.Conflict.Difference", Loc.L("Server.Setting.ExposureOffset"), 0.5.ToString("0.###", Loc.Culture),
|
||
0.3.ToString("0.###", Loc.Culture)), request.Detail, "only the setting both changed; the editor's value first");
|
||
Assert.Equal(Loc.L("Server.Sync.Action.TakeServer"), request.SafeText, "the safe default loses nothing: Ctrl+Z brings the editor's values back");
|
||
Assert.Equal(Loc.L("Server.Sync.Action.KeepMine"), request.ActionText);
|
||
Assert.True(request.IsDestructive, "Keep mine overwrites the server's values");
|
||
Assert.Contains("Studio NAS", request.Heading);
|
||
}
|
||
}
|