Files
Alby96andClaude Opus 5.5 f2b58522b9
CI / Build and test (push) Successful in 8m14s
CI / Windows tests and installer (push) Skipped
CI / YAML check (push) Successful in 7s
Release / Build, test and publish (push) Successful in 13m19s
CI / PostgreSQL 16 integration (push) Successful in 4m49s
CI / PostgreSQL 17 integration (push) Successful in 5m28s
CI / Docker image (push) Successful in 53s
Release / Server image (push) Failing after 10s
refactor!: rename Titano to Chronos and move CI and releases to Gitea (#6)
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 and the system SQLite. 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; the
  throw-away server runs without durability) and pe-check.
- Timed tests take their budget from TestTiming (CHRONOS_TEST_TIME_FACTOR,
  3 on the shared runner; the weekly performance gates keep theirs).

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>
Co-authored-by: Alberto Balbo <alberto.balbo.96@gmail.com>
2026-10-23 12:45:18 +02:00

128 lines
5.1 KiB
C#

using Chronos.Core.Imaging;
using Chronos.Core.Metadata;
using Chronos.Core.Metadata.Bmff;
using Chronos.Core.Model;
using Chronos.Core.Tests.Metadata.Builders;
using Chronos.Testing;
using static Chronos.Core.Tests.Metadata.MetadataTestHelpers;
namespace Chronos.Core.Tests.Metadata;
public sealed class BmffTests
{
[Test]
public void Cr3()
{
var m = Read(Fixtures.Cr3(), "IMG_0001.CR3");
AssertNoFault(m);
Assert.Empty(m.Warnings);
Assert.Equal(ImageFileFormat.Cr3, m.Format);
Assert.Equal("Canon", m.Make);
Assert.Equal("Canon EOS R5", m.Model);
Assert.Equal(8, m.Orientation);
Assert.Equal((8352, 5586), (m.Width, m.Height));
Assert.Equal(14, m.BitsPerSample);
AssertPreviews(m, (8192, 5464, PreviewKind.FullSize), (1620, 1080, PreviewKind.Preview), (160, 120, PreviewKind.Thumbnail));
Assert.Equal(new DateTime(2024, 6, 1, 8, 0, 0, 500), m.CapturedAt);
Assert.Equal(-240, m.UtcOffsetMinutes);
Assert.Equal(TimestampSource.ExifOriginal, m.TimestampSource);
Assert.Approximately(0.01, m.ExposureTime!.Value, 1e-12);
Assert.Approximately(4, m.FNumber!.Value, 1e-12);
Assert.Equal(100, m.Iso);
Assert.Equal("0000098765", m.BodySerial);
Assert.Equal("RF24-105mm F4 L IS USM", m.LensModel);
Assert.Approximately(-9.26, m.Gps!.Longitude, 1e-9);
}
[Test]
public void Cr3FullSizeJpegIsTrackOneSample()
{
var bytes = Fixtures.Cr3(out var mdatStart);
var full = Read(bytes).Previews[0];
Assert.Equal(mdatStart + 8L, full.Offset);
Assert.Equal(0xFF, bytes[full.Offset]);
Assert.Equal(0xD9, bytes[full.Offset + full.Length - 1]);
}
[Theory]
[Case(false, false, 6, Name = "no transforms: Exif orientation applies")]
[Case(true, false, 8, Name = "irot 90° anticlockwise")]
[Case(true, true, 7, Name = "irot then imir left-right")]
[Case(false, true, 2, Name = "imir left-right only")]
public void HeifTransformsOverrideExifOrientation(bool rotate, bool mirror, int expected) =>
Assert.Equal(expected, Read(Fixtures.Heic(rotate, mirror), "IMG_0001.HEIC").Orientation);
[Test]
public void Heic()
{
var m = Read(Fixtures.Heic(), "IMG_0001.HEIC");
AssertNoFault(m);
Assert.Empty(m.Warnings);
Assert.Equal(ImageFileFormat.Heif, m.Format);
Assert.Equal((4032, 3024), (m.Width, m.Height));
Assert.Equal(10, m.BitsPerSample);
Assert.Equal(Fixtures.Make, m.Make);
Assert.Equal(Fixtures.Captured, m.CapturedAt);
Assert.Equal(400, m.Iso);
Assert.Equal(4, m.Rating);
Assert.Equal("Red", m.Label);
AssertPreviews(m, (160, 120, PreviewKind.Thumbnail));
}
[Test]
public void Avif()
{
var m = Read(Fixtures.Heic(major: "avif"), "a.avif");
Assert.Equal(ImageFileFormat.Avif, m.Format);
Assert.Equal((4032, 3024), (m.Width, m.Height));
Assert.Equal("Red", m.Label);
}
[Test]
public void WalksLargeSizeToEndAndUuidBoxes()
{
var guid = Guid.NewGuid();
byte[] large = [.. Box.U32(1), .. Box.Ascii("free"), .. Box.U64(20), 1, 2, 3, 4];
byte[] data = [.. Box.Make("ftyp", Box.Ascii("heic")), .. large, .. Box.Uuid(guid, [9, 9]), .. Box.U32(0), .. Box.Ascii("mdat"), 7, 7, 7];
var boxes = BmffReader.ReadChildren(new MemoryStream(data), 0, data.Length);
Assert.Equal(4, boxes.Count);
Assert.True(boxes[1].Is("free"));
Assert.Equal(16, boxes[1].HeaderSize);
Assert.Equal(20L, boxes[1].Size);
Assert.Equal(guid, boxes[2].UserType);
Assert.Equal(24, boxes[2].HeaderSize);
Assert.True(boxes[3].Is("mdat"));
Assert.Equal((long)data.Length, boxes[3].End);
}
[Test]
public void StopsAtMalformedAndClampsTruncatedBoxes()
{
var warnings = new List<string>();
byte[] truncated = [.. Box.Make("ftyp", Box.Ascii("heic")), .. Box.U32(1000), .. Box.Ascii("moov"), 0, 0];
var boxes = BmffReader.ReadChildren(new MemoryStream(truncated), 0, truncated.Length, warnings);
Assert.Equal(2, boxes.Count);
Assert.Equal((long)truncated.Length, boxes[1].End);
Assert.Contains("Box 'moov' at 12 runs past its container", warnings);
byte[] malformed = [.. Box.Make("ftyp", Box.Ascii("heic")), .. Box.U32(4), .. Box.Ascii("bad!"), .. Box.Make("free")];
Assert.Equal(1, BmffReader.ReadChildren(new MemoryStream(malformed), 0, malformed.Length).Count);
}
[Test]
public void FindPathIsDepthLimited()
{
var box = new BmffBox(FourCC.From("moov"), 0, 8, 8, Guid.Empty);
Assert.Throws<ArgumentException>(() => BmffReader.FindPath(new MemoryStream(new byte[8]), box, [.. Enumerable.Repeat("trak", BmffReader.MaxDepth + 1)]));
Assert.Null(BmffReader.FindPath(new MemoryStream(new byte[8]), box, "trak", "mdia"));
}
[Test]
public void FourCCRoundTrips()
{
Assert.Equal(0x66747970u, FourCC.From("ftyp"));
Assert.Equal("ftyp", FourCC.Format(0x66747970));
Assert.Equal("?abc", FourCC.Format(0x01616263));
}
}