CI / Build and test (pull_request) Failing after 2m3s
CI / PostgreSQL 16 integration (pull_request) Skipped
CI / PostgreSQL 17 integration (pull_request) Skipped
CI / Docker image (pull_request) Skipped
CI / Windows tests and installer (pull_request) Skipped
CI / YAML check (pull_request) Successful in 4s
The owner renamed the product and moved the repository to the self-hosted Gitea (https://gitea.encke-hake.ts.net/BalboSoft/Chronos) for more control, and asked for Actions and a first automatic release with the server package and the Windows exe (docs/requests/2026-10-23-chronos-gitea.md). - Chronos everywhere: a byte-exact rename of contents and paths, then a per-language review of the forms the old name's ending had dictated. - Gitea instead of GitHub: the update check, licence, issue and support links read ChronosReleasesUrl; the update check takes the highest stable version, offers a pre-release build its final release and reports a repository it cannot see as a failed check. EULA, security policy and Gitea issue forms live at the repository root. - Gitea Actions for the Linux act_runner (.gitea/workflows): CI, release, nightly image and performance gates in the .NET SDK container with git checkout. The release cross-compiles the Windows programs, checks their icon, version and DPI manifest, packs installers and zips, publishes the Gitea release and pushes the server image (REGISTRY_TOKEN). Windows-only tests run in an opt-in job on a Windows runner (WINDOWS_RUNNER). - New Chronos.Tools commands: zip, gitea-release, postgres-ci (replaces the docker-exec script, which Gitea's service containers do not allow) and pe-check. BREAKING CHANGE: programs, settings, data folders, file types, environment variables and the Docker image use the new name; nothing is migrated from Titano, which never had a release. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
132 lines
5.6 KiB
C#
132 lines
5.6 KiB
C#
using Chronos.Core.Export;
|
||
using Chronos.Core.Project;
|
||
using Chronos.Core.Video;
|
||
using Chronos.Testing;
|
||
|
||
namespace Chronos.Core.Tests.Export;
|
||
|
||
public sealed class ExportResolverTests
|
||
{
|
||
private static ExportSettings Export(string preset, ExportOverrides? overrides = null) =>
|
||
new() { Preset = new Auto<string>().WithManual(preset), Overrides = overrides ?? new ExportOverrides() };
|
||
|
||
[Test]
|
||
public void EveryBuiltInPresetResolvesToItself()
|
||
{
|
||
foreach (var preset in ExportPresets.BuiltIn)
|
||
{
|
||
var resolved = ExportResolver.Resolve(Export(preset.Id));
|
||
Assert.Equal(preset.Id, resolved.PresetId);
|
||
Assert.False(resolved.IsCustom);
|
||
Assert.Equal(preset.NameKey, resolved.NameKey);
|
||
Assert.Equal(preset.Codec, resolved.Codec);
|
||
Assert.Empty(resolved.Warnings);
|
||
}
|
||
}
|
||
|
||
[Test]
|
||
public void EditingAValueMakesTheExportCustom()
|
||
{
|
||
var resolved = ExportResolver.Resolve(Export("4k-hevc", new ExportOverrides { BitRate = 50_000_000 }));
|
||
Assert.True(resolved.IsCustom);
|
||
Assert.Equal(ExportResolver.CustomId, resolved.PresetId);
|
||
Assert.Equal("4k-hevc", resolved.BasePresetId);
|
||
Assert.Null(resolved.NameKey);
|
||
Assert.Equal(50_000_000L, resolved.EffectiveBitRate(3840, 2160));
|
||
Assert.Equal(3840, resolved.Width);
|
||
}
|
||
|
||
[Test]
|
||
public void ValuesEqualToThePresetRestoreItsName()
|
||
{
|
||
var resolved = ExportResolver.Resolve(Export("1080p-h264", new ExportOverrides
|
||
{
|
||
Codec = "h.264",
|
||
Container = "mp4",
|
||
Width = 1920,
|
||
Height = 1080,
|
||
FrameRate = "30",
|
||
BitRate = 6_220_800, // the preset's 0.10 bpp at 1920×1080×30
|
||
GopFrames = 30,
|
||
Profile = "H264High",
|
||
RateControl = "vbr",
|
||
}));
|
||
Assert.Equal("1080p-h264", resolved.PresetId);
|
||
Assert.Empty(resolved.Warnings);
|
||
}
|
||
|
||
[Test]
|
||
public void ValuesEqualToAnotherPresetTakeItsName()
|
||
{
|
||
var resolved = ExportResolver.Resolve(Export("1080p-h264", new ExportOverrides { FrameRate = "60" }));
|
||
Assert.Equal("1080p60", resolved.PresetId);
|
||
Assert.Equal(60, resolved.GopFrames);
|
||
Assert.Equal("1080p-h264", resolved.BasePresetId);
|
||
}
|
||
|
||
[Test]
|
||
public void FractionalRatesAndGopFollowTheOverride()
|
||
{
|
||
var resolved = ExportResolver.Resolve(Export("4k-h264", new ExportOverrides { FrameRate = "24000/1001" }));
|
||
Assert.True(resolved.IsCustom);
|
||
Assert.Equal(Rational.Fps23976, resolved.FrameRate);
|
||
Assert.Equal(24, resolved.GopFrames);
|
||
var settings = resolved.ToEncodeSettings("x.mp4", 3840, 2160);
|
||
Assert.Equal(24, settings.GopLength);
|
||
Assert.Equal((long)Math.Round(0.10 * 3840 * 2160 * 24000 / 1001.0), settings.BitRate);
|
||
Assert.Equal(CodecProfile.H264High, settings.Profile);
|
||
}
|
||
|
||
[Test]
|
||
public void BadOverridesAreIgnoredWithWarnings()
|
||
{
|
||
var resolved = ExportResolver.Resolve(Export("1080p-h264", new ExportOverrides { Codec = "divx", FrameRate = "fast", Container = "avi", Profile = "ultra", RateControl = "magic" }));
|
||
Assert.Equal("1080p-h264", resolved.PresetId);
|
||
Assert.SequenceEqual(new[] { "Export.Warning.UnknownCodec", "Export.Warning.ContainerIgnored", "Export.Warning.UnknownProfile", "Export.Warning.UnknownFrameRate", "Export.Warning.UnknownRateControl" }, resolved.Warnings);
|
||
}
|
||
|
||
[Test]
|
||
public void UnknownOrCustomSelectionsStartFromTheDefaultPreset()
|
||
{
|
||
var unknown = ExportResolver.Resolve(Export("deleted-user-preset"));
|
||
Assert.Equal(ExportResolver.DefaultPresetId, unknown.PresetId);
|
||
Assert.Contains("Export.Warning.UnknownPreset", unknown.Warnings);
|
||
|
||
var custom = ExportResolver.Resolve(Export("custom", new ExportOverrides { Codec = "png", Width = 0, Height = 0, BitDepth = 16, FrameRate = "30", GopFrames = 30, BFrames = 0, Quality = 92 }));
|
||
Assert.Empty(custom.Warnings);
|
||
Assert.Equal(VideoCodec.PngSequence, custom.Codec);
|
||
Assert.True(custom.IsCustom);
|
||
|
||
var auto = ExportResolver.Resolve(new ExportSettings());
|
||
Assert.Equal(ExportResolver.DefaultPresetId, auto.PresetId);
|
||
}
|
||
|
||
[Test]
|
||
public void ChangingTheCodecResetsCodecSpecificValues()
|
||
{
|
||
var resolved = ExportResolver.Resolve(Export("1080p-h264", new ExportOverrides { Codec = "HEVC" }));
|
||
Assert.Equal(VideoCodec.Hevc, resolved.Codec);
|
||
Assert.Equal(CodecProfile.Auto, resolved.Profile);
|
||
Assert.Equal((long)Math.Round(0.07 * 1920 * 1080 * 30), resolved.EffectiveBitRate(1920, 1080));
|
||
Assert.True(resolved.IsCustom);
|
||
Assert.True(ExportResolver.TryParseCodec("TIFF-16", out var tiff) && tiff == VideoCodec.Tiff16Sequence);
|
||
Assert.False(ExportResolver.TryParseCodec("", out _));
|
||
}
|
||
|
||
[Test]
|
||
public void FrameRateTextRoundTrips()
|
||
{
|
||
Assert.True(FrameRateText.TryParse("30000/1001", out var ntsc));
|
||
Assert.Equal(Rational.Fps2997, ntsc);
|
||
Assert.True(FrameRateText.TryParse("29.97", out var decimalNtsc));
|
||
Assert.Equal(Rational.Fps2997, decimalNtsc);
|
||
Assert.True(FrameRateText.TryParse(" 25 ", out var pal));
|
||
Assert.Equal("25", FrameRateText.Format(pal));
|
||
Assert.Equal("24000/1001", FrameRateText.Format(Rational.Fps23976));
|
||
Assert.True(FrameRateText.AreEqual(new Rational(48000, 2002), Rational.Fps23976));
|
||
Assert.False(FrameRateText.TryParse("0", out _));
|
||
Assert.False(FrameRateText.TryParse("1/0", out _));
|
||
Assert.False(FrameRateText.TryParse(null, out _));
|
||
}
|
||
}
|