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>
146 lines
7.3 KiB
C#
146 lines
7.3 KiB
C#
using Chronos.Core.Imaging;
|
|
using Chronos.Core.Windows.Codecs;
|
|
using Chronos.Core.Windows.Wic;
|
|
using Chronos.Testing;
|
|
|
|
namespace Chronos.Core.Windows.Tests.Codecs;
|
|
|
|
public sealed class CodecInventoryTests
|
|
{
|
|
private static readonly WicDecoderInfo Jpeg = Decoder("JPEG Decoder", Guid.NewGuid(), WicGuids.VendorMicrosoftBuiltIn, ".jpeg,.jpe,.jpg,.jfif,.exif");
|
|
private static readonly WicDecoderInfo InBoxDng = Decoder("DNG Decoder", Guid.NewGuid(), WicGuids.VendorMicrosoftBuiltIn, ".dng");
|
|
private static readonly WicDecoderInfo Raw = Decoder("Microsoft Raw Image Decoder", WicGuids.RawDecoder, WicGuids.VendorMicrosoft, ".arw,.cr2,.cr3,.dng,.nef,.raf");
|
|
private static readonly WicDecoderInfo Heif = Decoder("HEIF Decoder", WicGuids.HeifDecoder, WicGuids.VendorMicrosoft, ".heic,.heif,.hif");
|
|
private static readonly WicDecoderInfo Webp = Decoder("WebP Decoder", WicGuids.WebpDecoder, WicGuids.VendorMicrosoft, ".webp");
|
|
|
|
[Test]
|
|
[WindowsOnly]
|
|
public void DetectFindsTheBuiltInDecoders()
|
|
{
|
|
var inventory = CodecInventory.Detect();
|
|
Assert.NotEmpty(inventory.Decoders);
|
|
foreach (var format in new[] { ImageFileFormat.Jpeg, ImageFileFormat.Png, ImageFileFormat.Tiff })
|
|
{
|
|
var support = inventory.For(format);
|
|
Assert.True(support.IsNative, $"{format} should decode natively through WIC");
|
|
var decoder = Assert.NotNull(support.Decoder);
|
|
Assert.False(string.IsNullOrWhiteSpace(decoder.FriendlyName), $"{format} decoder has no name");
|
|
Assert.NotEqual(Guid.Empty, decoder.ContainerFormat);
|
|
Assert.Empty(support.MissingExtensions);
|
|
}
|
|
Assert.Equal(ImageFormatInfo.Known.Count, inventory.Formats.Count);
|
|
}
|
|
|
|
[Test]
|
|
public void RawNeedsTheRawImageExtension()
|
|
{
|
|
var inventory = Inventory([Jpeg, InBoxDng, Classified(Raw, rawExtensionInstalled: false)]);
|
|
var dng = inventory.For(ImageFileFormat.Dng);
|
|
Assert.False(dng.IsNative);
|
|
Assert.Equal<string?>("DNG Decoder", dng.Decoder?.FriendlyName);
|
|
Assert.SequenceEqual([StoreExtension.Get(StoreExtensionKind.RawImage)], dng.MissingExtensions);
|
|
Assert.False(inventory.IsNative(ImageFileFormat.Cr3));
|
|
Assert.Contains(StoreExtension.Get(StoreExtensionKind.RawImage), inventory.MissingExtensions);
|
|
}
|
|
|
|
[Test]
|
|
public void RawIsNativeThroughTheExtension()
|
|
{
|
|
var inventory = Inventory([Jpeg, InBoxDng, Classified(Raw, rawExtensionInstalled: true)]);
|
|
Assert.True(inventory.IsNative(ImageFileFormat.Dng));
|
|
Assert.Equal<StoreExtensionKind?>(StoreExtensionKind.RawImage, inventory.For(ImageFileFormat.Dng).Decoder?.Extension);
|
|
Assert.True(inventory.IsNative(ImageFileFormat.Cr3));
|
|
// Installed but without this extension registered: nothing to install, still not native.
|
|
var gpr = inventory.For(ImageFileFormat.Gpr);
|
|
Assert.False(gpr.IsNative);
|
|
Assert.Empty(gpr.MissingExtensions);
|
|
}
|
|
|
|
[Test]
|
|
public void HeifNeedsAnHevcDecoder()
|
|
{
|
|
var withoutHevc = Inventory([Jpeg, Classified(Heif)]).For(ImageFileFormat.Heif);
|
|
Assert.False(withoutHevc.IsNative);
|
|
Assert.SequenceEqual([StoreExtension.Get(StoreExtensionKind.HevcVideo)], withoutHevc.MissingExtensions);
|
|
|
|
Assert.True(Inventory([Jpeg, Classified(Heif)], hevc: true).IsNative(ImageFileFormat.Heif));
|
|
|
|
var nothing = Inventory([Jpeg]).For(ImageFileFormat.Heif);
|
|
Assert.SequenceEqual(
|
|
[StoreExtension.Get(StoreExtensionKind.HeifImage), StoreExtension.Get(StoreExtensionKind.HevcVideo)],
|
|
nothing.MissingExtensions);
|
|
}
|
|
|
|
[Test]
|
|
public void AvifUsesTheHeifDecoderWithAnAv1Decoder()
|
|
{
|
|
var withoutAv1 = Inventory([Classified(Heif)], hevc: true).For(ImageFileFormat.Avif);
|
|
Assert.False(withoutAv1.IsNative);
|
|
Assert.Equal<string?>("HEIF Decoder", withoutAv1.Decoder?.FriendlyName);
|
|
Assert.SequenceEqual([StoreExtension.Get(StoreExtensionKind.Av1Video)], withoutAv1.MissingExtensions);
|
|
|
|
Assert.True(Inventory([Classified(Heif)], av1: true).IsNative(ImageFileFormat.Avif));
|
|
}
|
|
|
|
[Test]
|
|
public void WebpNeedsTheWebpExtension()
|
|
{
|
|
Assert.SequenceEqual([StoreExtension.Get(StoreExtensionKind.WebpImage)], Inventory([Jpeg]).For(ImageFileFormat.WebP).MissingExtensions);
|
|
Assert.True(Inventory([Jpeg, Classified(Webp)]).IsNative(ImageFileFormat.WebP));
|
|
}
|
|
|
|
[Test]
|
|
public void BuiltInFormatsNeverAskForExtensions()
|
|
{
|
|
var inventory = Inventory([Jpeg]);
|
|
Assert.True(inventory.IsNative(ImageFileFormat.Jpeg));
|
|
Assert.False(inventory.IsNative(ImageFileFormat.Png));
|
|
Assert.Empty(inventory.For(ImageFileFormat.Png).MissingExtensions);
|
|
Assert.False(inventory.IsNative(ImageFileFormat.Unknown));
|
|
}
|
|
|
|
[Test]
|
|
public void ClassificationUsesClsidPackageAndVendor()
|
|
{
|
|
Assert.Null(CodecInventory.Classify(Raw, rawExtensionInstalled: false));
|
|
Assert.Equal<StoreExtensionKind?>(StoreExtensionKind.RawImage, CodecInventory.Classify(Raw, rawExtensionInstalled: true));
|
|
Assert.Equal<StoreExtensionKind?>(StoreExtensionKind.HeifImage, CodecInventory.Classify(Heif, false));
|
|
Assert.Equal<StoreExtensionKind?>(StoreExtensionKind.WebpImage, CodecInventory.Classify(Webp, false));
|
|
var avif = Decoder("AVIF Decoder", Guid.NewGuid(), WicGuids.VendorMicrosoft, ".avif");
|
|
Assert.Equal<StoreExtensionKind?>(StoreExtensionKind.Av1Video, CodecInventory.Classify(avif, false));
|
|
var thirdParty = Decoder("Other AVIF", Guid.NewGuid(), Guid.NewGuid(), ".avif");
|
|
Assert.Null(CodecInventory.Classify(thirdParty, false));
|
|
Assert.Null(CodecInventory.Classify(Jpeg, false));
|
|
}
|
|
|
|
[Test]
|
|
public void StoreLinksUseTheProductIds()
|
|
{
|
|
Assert.Equal(5, StoreExtension.All.Count);
|
|
var raw = StoreExtension.Get(StoreExtensionKind.RawImage);
|
|
Assert.Equal("ms-windows-store://pdp/?ProductId=9NCTDW2W1BH8", raw.StoreUri.AbsoluteUri);
|
|
Assert.Equal("https://apps.microsoft.com/detail/9nctdw2w1bh8", raw.WebUri.AbsoluteUri);
|
|
Assert.Equal("9PMMSR1CGPWG", StoreExtension.Get(StoreExtensionKind.HeifImage).ProductId);
|
|
Assert.Equal("9NMZLZ57R3T7", StoreExtension.Get(StoreExtensionKind.HevcVideo).ProductId);
|
|
Assert.Equal("9MVZQVXJBQ9V", StoreExtension.Get(StoreExtensionKind.Av1Video).ProductId);
|
|
Assert.Equal("9PG2DK419DRG", StoreExtension.Get(StoreExtensionKind.WebpImage).ProductId);
|
|
}
|
|
|
|
[Test]
|
|
public void ExtensionListsAreNormalised()
|
|
{
|
|
Assert.SequenceEqual(["jpg", "jpeg", "jfif"], WicDecoderInfo.ParseExtensions(".JPG, .jpeg;.jfif,,.jpg"));
|
|
Assert.True(Jpeg.Handles(".JPG"));
|
|
Assert.True(Jpeg.Handles("jfif"));
|
|
Assert.False(Jpeg.Handles("png"));
|
|
}
|
|
|
|
private static CodecInventory Inventory(WicDecoderInfo[] decoders, bool hevc = false, bool av1 = false) => new(decoders, hevc, av1);
|
|
|
|
private static WicDecoderInfo Classified(WicDecoderInfo decoder, bool rawExtensionInstalled = false) =>
|
|
decoder with { Extension = CodecInventory.Classify(decoder, rawExtensionInstalled) };
|
|
|
|
private static WicDecoderInfo Decoder(string name, Guid clsid, Guid vendor, string extensions) =>
|
|
new(name, clsid, Guid.NewGuid(), vendor, "1.0", WicDecoderInfo.ParseExtensions(extensions), null);
|
|
}
|