Files
Chronos/tests/Chronos.Core.Tests/Render/OutputProgramTests.cs
T
Alby96andClaude Opus 5.5 d472dfdec1 feat: phase 5 groundwork (playback format 3, videos contracts, migration 0010, strings)
Lays down every contract the later parcels of owner review 1 phase 5 build on,
so they compile against shared types without touching each other's files.

- Settings format 3: export.playback (direction, loops, fades, hold), omitted
  at its default and member by member; RequiredFormat is 3 only while used.
- OutputProgram public API with a forward-only body; still-frame job
  parameters (StillFrame, StillPhoto) routed to format-3 nodes only.
- Render.Sha256/Kind, RenderCopy, RenderKind; JobKind.VideoCopy = 24.
- Migration 0010 (sqlite, postgres): renders.sha256/kind, ix_renders_created,
  render_copies without a foreign key.
- Videos protocol DTOs, client calls, ServerCapabilities.Videos (declared,
  not announced yet), ServerSettingsDto.VideosPath.
- IVideoLibrary with a NotImplemented stub registered on the server;
  TrashKind.Videos, VideoTrashNames, VideoErrors.
- en and it strings for the whole phase, five icons, decisions 1-22 and the
  open-question defaults; tests that used format 3 as "newer" now use 4.

Refs #21

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-05 01:48:33 +01:00

65 lines
2.5 KiB
C#

using Chronos.Core.Model;
using Chronos.Core.Project;
using Chronos.Core.Render;
using Chronos.Core.Video;
using Chronos.Testing;
namespace Chronos.Core.Tests.Render;
public sealed class OutputProgramTests
{
private static readonly Rational Fps25 = new(25, 1);
[Test]
public void TheDefaultPlaybackEmitsThePlanAsItIs()
{
var frames = Frames(3600, 3600, 7200);
foreach (var playback in new[] { null, new PlaybackSettings() })
{
var program = OutputProgram.Build(frames, playback, Fps25);
Assert.SequenceEqual([new ProgramEntry(0, 3600, 1), new ProgramEntry(1, 3600, 1), new ProgramEntry(2, 7200, 1)], program.Entries);
Assert.Equal((3, 14400L), (program.Count, program.Duration90k));
Assert.Approximately(0.16, program.DurationSeconds, 1e-12);
Assert.Equal(0, program.Warnings.Count);
}
Assert.Equal(0, OutputProgram.Build([], null, Fps25).Count);
}
[Test]
public void AnUnknownDirectionPlaysForwardWithAWarning()
{
var program = OutputProgram.Build(Frames(3600, 3600), new PlaybackSettings { Direction = "pingpong" }, Fps25);
Assert.SequenceEqual([0, 1], program.Entries.Select(e => e.PlanIndex));
Assert.Count(1, program.Warnings);
var warning = program.Warnings[0];
Assert.Equal(OutputProgram.DirectionUnknownWarning, warning.Key);
Assert.SequenceEqual(["pingpong"], warning.Args);
}
[Test]
public void ARateThatIsNotPositiveIsRefused() =>
Assert.Throws<ArgumentOutOfRangeException>(() => OutputProgram.Build(Frames(3600), null, new Rational(0, 1)));
[Test]
public void TheKindOfARenderFollowsItsColumnElseItsCodec()
{
Assert.Equal(RenderKind.Still, RenderKind.Of("still", "png-sequence"));
Assert.Equal(RenderKind.Sequence, RenderKind.Of(null, "png-sequence"));
Assert.Equal(RenderKind.Sequence, RenderKind.Of(null, "Tiff16Sequence"));
Assert.Equal(RenderKind.Video, RenderKind.Of(null, "h264"));
Assert.Equal(RenderKind.Video, RenderKind.Of(null, null));
}
private static PlannedFrame[] Frames(params long[] durations)
{
var frames = new PlannedFrame[durations.Length];
long start = 0;
for (var i = 0; i < durations.Length; i++)
{
frames[i] = new PlannedFrame(i, i, i, 0, start, durations[i], i, 1, 1, PlannedFrameFlags.None);
start += durations[i];
}
return frames;
}
}