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

191 lines
8.0 KiB
C#

using Chronos.Core.Imaging;
using Chronos.Core.Metadata;
using Chronos.Core.Metadata.Tiff;
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;
/// <summary>TIFF-based RAWs: main-image selection across IFDs/SubIFDs, embedded previews and MakerNote fallbacks.</summary>
public sealed class RawContainerTests
{
[Test]
public void Cr2()
{
var m = Read(Fixtures.Cr2(), "IMG_0001.CR2");
AssertNoFault(m);
Assert.Equal(ImageFileFormat.Cr2, m.Format);
Assert.Equal("Canon", m.Make);
Assert.Equal((6720, 4480), (m.Width, m.Height));
Assert.Equal(14, m.BitsPerSample);
AssertPreviews(m, (6720, 4480, PreviewKind.FullSize), (160, 120, PreviewKind.Thumbnail));
Assert.Equal("0000123456", m.BodySerial);
Assert.Equal("EF24-70mm f/2.8L II USM", m.LensModel);
Assert.Equal(true, m.ImageStabilization);
Assert.Equal(5200, m.ColorTemperature);
Assert.Equal(Fixtures.Captured, m.CapturedAt);
Assert.Equal(1, m.Orientation);
}
[Test]
public void Nef()
{
var m = Read(Fixtures.Nef(), "DSC_0001.NEF");
AssertNoFault(m);
Assert.Equal(ImageFileFormat.Nef, m.Format);
Assert.Equal("NIKON CORPORATION", m.Make);
Assert.Equal((8288, 5520), (m.Width, m.Height));
Assert.Equal(14, m.BitsPerSample);
AssertPreviews(m, (8256, 5504, PreviewKind.FullSize));
Assert.Equal("3001234", m.BodySerial);
Assert.Equal(12345L, m.ShutterCount);
Assert.Equal("24-70mm f/2.8", m.LensModel);
Assert.Equal(true, m.ImageStabilization);
Assert.Equal(64, m.Iso);
}
[Test]
public void Dng()
{
var m = Read(Fixtures.Dng(), "PXL_0001.dng");
AssertNoFault(m);
Assert.Equal(ImageFileFormat.Dng, m.Format);
Assert.Equal((4032, 3024), (m.Width, m.Height));
Assert.Equal(16, m.BitsPerSample);
AssertPreviews(m, (1024, 768, PreviewKind.Preview));
Assert.Equal("DNGSER1", m.BodySerial);
Assert.Equal("Pixel 8", m.Model);
}
[Test]
public void Arw()
{
var m = Read(Fixtures.Arw(), "DSC00001.ARW");
AssertNoFault(m);
Assert.Equal(ImageFileFormat.Arw, m.Format);
Assert.Equal((6048, 4024), (m.Width, m.Height));
Assert.Equal(12, m.BitsPerSample);
AssertPreviews(m, (1616, 1080, PreviewKind.Preview));
Assert.Equal("24-70mm F2.8", m.LensModel);
Assert.Equal(5600, m.ColorTemperature);
Assert.Equal(true, m.ImageStabilization);
}
[Test]
public void Orf()
{
var m = Read(Fixtures.Orf(), "P0000001.ORF");
AssertNoFault(m);
Assert.Equal(ImageFileFormat.Orf, m.Format);
Assert.Equal((5240, 3912), (m.Width, m.Height));
Assert.Equal(12, m.BitsPerSample);
AssertPreviews(m, (3200, 2400, PreviewKind.Preview));
Assert.Equal("BHX123", m.BodySerial);
Assert.Equal("M.Zuiko 12-40mm F2.8", m.LensModel);
Assert.Equal(true, m.ImageStabilization);
}
[Test]
public void Rw2()
{
var m = Read(Fixtures.Rw2(), "P1000001.RW2");
AssertNoFault(m);
Assert.Equal(ImageFileFormat.Rw2, m.Format);
Assert.Equal("Panasonic", m.Make);
Assert.Equal("DC-GH6", m.Model);
Assert.Equal((5776, 4344), (m.Width, m.Height));
Assert.Equal(12, m.BitsPerSample);
Assert.Equal(800, m.Iso);
AssertPreviews(m, (1920, 1440, PreviewKind.Preview), (160, 120, PreviewKind.Thumbnail));
Assert.Equal("F541504040123", m.BodySerial);
Assert.Equal("LUMIX G VARIO 12-60mm", m.LensModel);
Assert.Equal(true, m.ImageStabilization);
Assert.Equal(5000, m.ColorTemperature);
Assert.Equal(TimestampSource.ExifOriginal, m.TimestampSource);
Assert.Equal(1, m.Orientation);
}
[Test]
public void StandardTagsBeatMakerNote()
{
var makerNote = new IfdSpec().Long(0x000C, 42).Ascii(0x0095, "MakerNote Lens");
var exif = Fixtures.ExifIfd().Embedded(TiffTags.MakerNote, [], makerNote, relativeToTiff: true, littleEndian: true);
var tiff = TiffFile.Build(Fixtures.Ifd0("Canon", "Canon EOS R6").Child(TiffTags.ExifIfd, exif));
var m = Read(new JpegBuilder().Exif(tiff).Build(64, 48));
Assert.Equal("SN123", m.BodySerial);
Assert.Equal("TestLens 35mm", m.LensModel);
}
[Theory]
[Case("Canon EOS-1D X Mark III", "042000")]
[Case("Canon EOS R6", "0000042000")]
public void FormatsCanonSerialByModel(string model, string expected)
{
var makerNote = new IfdSpec().Long(0x000C, 42000);
var exif = Fixtures.ExifIfd(identity: false).Embedded(TiffTags.MakerNote, [], makerNote, relativeToTiff: true, littleEndian: false);
var tiff = TiffFile.Build(Fixtures.Ifd0("Canon", model).Child(TiffTags.ExifIfd, exif), littleEndian: false);
Assert.Equal(expected, Read(new JpegBuilder().Exif(tiff).Build(64, 48)).BodySerial);
}
[Test]
public void ReadsHeaderlessNikonMakerNote()
{
var nikon = new IfdSpec().Ascii(0x001D, "TYPE2").Long(0x00A7, 7);
var exif = Fixtures.ExifIfd(identity: false).Embedded(TiffTags.MakerNote, [], nikon, relativeToTiff: true, littleEndian: true);
var tiff = TiffFile.Build(Fixtures.Ifd0("NIKON", "E5700").Child(TiffTags.ExifIfd, exif));
var m = Read(new JpegBuilder().Exif(tiff).Build(64, 48));
Assert.Equal("TYPE2", m.BodySerial);
Assert.Equal(7L, m.ShutterCount);
}
[Test]
public void ReadsLegacyOlympusAndFujifilmMakerNotes()
{
var olympus = new IfdSpec().Child(0x2010, new IfdSpec().Ascii(0x0101, "OLD-SN"));
var exif = Fixtures.ExifIfd(identity: false).Embedded(TiffTags.MakerNote, [.. "OLYMP\0"u8, 1, 0], olympus, relativeToTiff: true, littleEndian: true);
var m = Read(new JpegBuilder().Exif(TiffFile.Build(Fixtures.Ifd0("OLYMPUS", "E-1").Child(TiffTags.ExifIfd, exif))).Build(64, 48));
Assert.Equal("OLD-SN", m.BodySerial);
var fuji = new IfdSpec().Short(0x1422, 0, 0, 0);
exif = Fixtures.ExifIfd(identity: false).Embedded(TiffTags.MakerNote, [.. "FUJIFILM"u8, 12, 0, 0, 0], fuji, relativeToTiff: false, littleEndian: true);
m = Read(new JpegBuilder().Exif(TiffFile.Build(Fixtures.Ifd0("FUJIFILM", "X100V").Child(TiffTags.ExifIfd, exif), littleEndian: false)).Build(64, 48));
Assert.Equal(false, m.ImageStabilization);
}
[Test]
public void MakerNoteOutsideFileIsReported()
{
var exif = Fixtures.ExifIfd(identity: false).Undefined(TiffTags.MakerNote, new byte[64]);
var tiff = TiffFile.Build(Fixtures.Ifd0("Canon", "Canon EOS R6").Child(TiffTags.ExifIfd, exif));
var cut = tiff.AsSpan(0, tiff.Length - 40).ToArray();
var m = Read(cut, "a.tif");
AssertNoFault(m);
Assert.Contains("MakerNote outside the file", m.Warnings);
}
[Test]
public void SubIfdLoopsAreBroken()
{
// IFD0's SubIFDs entry points back at IFD0 itself.
var tiff = TiffFile.Build(new IfdSpec().Ascii(TiffTags.Make, "Loop").Long(TiffTags.ImageWidth, 10).Long(TiffTags.ImageLength, 10).Long(TiffTags.SubIfds, 8));
var m = Read(tiff, "loop.tif");
AssertNoFault(m);
Assert.Equal((10, 10), (m.Width, m.Height));
Assert.Contains("IFD loop at 8", m.Warnings);
}
[Test]
public void PlainTiffUsesLargestFullResolutionIfd()
{
var reduced = new IfdSpec().Long(TiffTags.NewSubfileType, 1).Long(TiffTags.ImageWidth, 9000).Long(TiffTags.ImageLength, 9000);
var ifd0 = new IfdSpec().Long(TiffTags.ImageWidth, 3000).Long(TiffTags.ImageLength, 2000).Short(TiffTags.BitsPerSample, 16, 16, 16);
ifd0.Next = reduced;
var m = Read(TiffFile.Build(ifd0, littleEndian: false), "scan.tif");
Assert.Equal(ImageFileFormat.Tiff, m.Format);
Assert.Equal((3000, 2000), (m.Width, m.Height));
Assert.Equal(16, m.BitsPerSample);
}
}