Merge branch 'fix/ingest-upload': uploads into API-made sequences, damaged frames repaired, positions follow inserts, cardEvent
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_012iLMBNwBE2GnphAsu4cjaC
This commit is contained in:
29 files changed
+1546
-80
No files matched your search
@@ -121,6 +121,52 @@ public sealed class ProjectSettingsTests
|
||||
public void ProjectMustBeAnObject() =>
|
||||
Assert.Throws<System.Text.Json.JsonException>(() => ProjectSettings.FromJson("[1, 2]"));
|
||||
|
||||
[Test]
|
||||
public void FramePositionsFollowInsertedFramesAndOtherMembersStay()
|
||||
{
|
||||
var project = new ProjectSettings
|
||||
{
|
||||
ExcludedFrames = [3, 7, 40],
|
||||
HeroFrame = 2,
|
||||
Camera = new CameraSettings { Keyframes = [new CameraKey(0, 0.5, 0.5, 1, 0), new CameraKey(7, 0.4, 0.5, 1.5, 0)] },
|
||||
Exposure = new ExposureSettings { DeflickerWindow = new Auto<int>().WithManual(41) },
|
||||
};
|
||||
// Two frames inserted before position 3 and one before position 7; 40 is no frame of the old list and stays.
|
||||
var moves = new Dictionary<int, int> { [0] = 0, [1] = 1, [2] = 4, [3] = 5, [4] = 6, [5] = 7, [6] = 8, [7] = 10 };
|
||||
|
||||
var moved = ProjectSettings.FromJson(Assert.NotNull(ProjectSettings.MoveFramePositions(project.ToJson(), moves)));
|
||||
|
||||
Assert.SequenceEqual([5, 10, 40], moved.ExcludedFrames);
|
||||
Assert.Equal(4, moved.HeroFrame);
|
||||
Assert.SequenceEqual([0, 10], moved.Camera.Keyframes.Select(k => k.Frame));
|
||||
Assert.Equal((0.4, 1.5), (moved.Camera.Keyframes[1].CenterX, moved.Camera.Keyframes[1].Zoom));
|
||||
Assert.Equal(41, moved.Exposure.DeflickerWindow.Manual);
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void MovingPositionsEditsTheJsonInPlace()
|
||||
{
|
||||
const string project = """{ "ExcludedFrames": [1, 2], "heroFrame": null, "futureOption": { "keep": [1, 2] }, "camera": { "keyframes": [ { "frame": 1.5 } ] } }""";
|
||||
|
||||
var moved = Assert.NotNull(ProjectSettings.MoveFramePositions(project, new Dictionary<int, int> { [1] = 3 }));
|
||||
|
||||
var json = System.Text.Json.Nodes.JsonNode.Parse(moved)!;
|
||||
Assert.SequenceEqual([3, 2], json["ExcludedFrames"]!.AsArray().Select(n => n!.GetValue<int>()));
|
||||
Assert.Equal("""{"keep":[1,2]}""", json["futureOption"]!.ToJsonString());
|
||||
Assert.Null(json["heroFrame"]);
|
||||
Assert.Equal(1.5, json["camera"]!["keyframes"]![0]!["frame"]!.GetValue<double>());
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void NothingToMoveGivesNoNewProject()
|
||||
{
|
||||
Assert.Null(ProjectSettings.MoveFramePositions(new ProjectSettings { ExcludedFrames = [1] }.ToJson(), new Dictionary<int, int>()));
|
||||
Assert.Null(ProjectSettings.MoveFramePositions(new ProjectSettings { ExcludedFrames = [1] }.ToJson(), new Dictionary<int, int> { [2] = 3, [1] = 1 }));
|
||||
Assert.Null(ProjectSettings.MoveFramePositions("not json", new Dictionary<int, int> { [1] = 2 }));
|
||||
Assert.Null(ProjectSettings.MoveFramePositions("[1, 2]", new Dictionary<int, int> { [1] = 2 }));
|
||||
Assert.Null(ProjectSettings.MoveFramePositions("""{ "heroFrame": 1, "HeroFrame": 1 }""", new Dictionary<int, int> { [1] = 2 }));
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void BuiltInPresetIdsAreUnique() =>
|
||||
Assert.Equal(ExportPresets.BuiltIn.Count, ExportPresets.BuiltIn.Select(p => p.Id).Distinct().Count());
|
||||
|
||||
Reference in new issue
Block a user