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

126 lines
6.0 KiB
C#

using Chronos.Core.Imaging;
using Chronos.Core.Metadata;
using Chronos.Core.Metadata.Tiff;
using Chronos.Core.Tests.Metadata.Builders;
using Chronos.Testing;
using static Chronos.Core.Tests.Metadata.MetadataTestHelpers;
namespace Chronos.Core.Tests.Metadata;
/// <summary>
/// MakerNote fields of BRIEF §9 beyond identity: the vendor exposure mode (when Exif has no ExposureProgram), the
/// intervalometer hint and the reduced-size RAW flag, from synthetic vendor IFDs.
/// </summary>
public sealed class MakerNoteTests
{
/// <summary>A JPEG whose Exif lacks ExposureProgram and carries <paramref name="makerNote"/> after <paramref name="prefix"/>.</summary>
private static FrameMetadata Jpeg(string make, string model, byte[] prefix, IfdSpec makerNote, bool relativeToTiff = true, bool keepProgram = false)
{
var exif = Fixtures.ExifIfd(identity: false).Embedded(TiffTags.MakerNote, prefix, makerNote, relativeToTiff, littleEndian: true);
if (!keepProgram) exif.Without(TiffTags.ExposureProgram);
var m = Read(new JpegBuilder().Exif(TiffFile.Build(Fixtures.Ifd0(make, model, 1).Child(TiffTags.ExifIfd, exif))).Build(64, 48));
AssertNoFault(m);
return m;
}
/// <summary>A CR2 ("CR" header block) with only IFD0, the Exif IFD and a Canon MakerNote.</summary>
private static FrameMetadata Cr2(ushort[] cameraSettings)
{
var makerNote = new IfdSpec().Short(0x0001, cameraSettings);
var exif = Fixtures.ExifIfd(identity: false).Without(TiffTags.ExposureProgram)
.Embedded(TiffTags.MakerNote, [], makerNote, relativeToTiff: true, littleEndian: true);
var ifd0 = Fixtures.Ifd0("Canon", "Canon EOS 5D Mark IV", 1).Child(TiffTags.ExifIfd, exif);
var m = Read(TiffFile.Build(ifd0, true, headerExtra: [(byte)'C', (byte)'R', 2, 0, 0, 0, 0, 0]), "IMG_0001.CR2");
AssertNoFault(m);
return m;
}
private static ushort[] CanonSettings(ushort exposureMode, ushort sRawQuality) =>
[.. Enumerable.Range(0, 48).Select(i => (ushort)(i switch { 20 => exposureMode, 46 => sRawQuality, _ => 0 }))];
[Theory]
[Case(1, 2)]
[Case(2, 4)]
[Case(3, 3)]
[Case(4, 1)]
[Case(5, 5)]
[Case(7, 1)]
[Case(8, 2)]
public void CanonExposureModeFillsTheExposureProgram(int canonMode, int exposureProgram)
{
var m = Jpeg("Canon", "Canon EOS R6", [], new IfdSpec().Short(0x0001, CanonSettings((ushort)canonMode, 0)));
Assert.Equal(exposureProgram, m.ExposureProgram);
// Not a RAW: the sRAW field says nothing about a JPEG.
Assert.Null(m.RawSize);
}
[Test]
public void CanonEasyModeLeavesTheProgramUnknownAndExifWins()
{
Assert.Null(Jpeg("Canon", "Canon EOS R6", [], new IfdSpec().Short(0x0001, CanonSettings(0, 0))).ExposureProgram);
// The fixture's Exif says aperture priority (3); the MakerNote's manual mode does not override it.
Assert.Equal(3, Jpeg("Canon", "Canon EOS R6", [], new IfdSpec().Short(0x0001, CanonSettings(4, 0)), keepProgram: true).ExposureProgram);
}
[Theory]
[Case(0, RawSize.Full)]
[Case(1, RawSize.Medium)]
[Case(2, RawSize.Small)]
public void CanonSRawQualityGivesTheRawSize(int quality, RawSize expected)
{
var m = Cr2(CanonSettings(3, (ushort)quality));
Assert.Equal(ImageFileFormat.Cr2, m.Format);
Assert.Equal(expected, m.RawSize);
Assert.Equal(3, m.ExposureProgram);
// Bodies whose settings stop before the sRAW field record no size.
Assert.Null(Cr2([.. CanonSettings(3, (ushort)quality).Take(40)]).RawSize);
}
[Test]
public void NikonRawSizeComesFromImageSizeRawOrTheSmallNefCompression()
{
static FrameMetadata Nikon(IfdSpec ifd) => Jpeg("NIKON CORPORATION", "NIKON Z 8", [], ifd);
Assert.Equal(RawSize.Medium, Nikon(new IfdSpec().Short(0x003E, 2)).RawSize);
Assert.Equal(RawSize.Small, Nikon(new IfdSpec().Short(0x003E, 3)).RawSize);
Assert.Equal(RawSize.Full, Nikon(new IfdSpec().Short(0x003E, 1).Short(0x0093, 3)).RawSize);
Assert.Equal(RawSize.Small, Nikon(new IfdSpec().Short(0x0093, 8)).RawSize);
Assert.Null(Nikon(new IfdSpec().Short(0x0093, 3)).RawSize);
// Nikon keeps interval shooting in its encrypted ShotInfo only.
Assert.Null(Nikon(new IfdSpec().Short(0x003E, 1)).IntervalShooting);
}
[Test]
public void OlympusFujifilmAndSonyExposureModes()
{
var olympus = Jpeg("OLYMPUS", "E-M1MarkIII", [.. "OLYMP\0"u8, 1, 0], new IfdSpec().Child(0x2020, new IfdSpec().Short(0x0200, 4)));
Assert.Equal(4, olympus.ExposureProgram);
var fuji = Jpeg("FUJIFILM", "X-T5", [.. "FUJIFILM"u8, 12, 0, 0, 0], new IfdSpec().Short(0x1031, 0x300), relativeToTiff: false);
Assert.Equal(1, fuji.ExposureProgram);
var fujiAperture = Jpeg("FUJIFILM", "X-T5", [.. "FUJIFILM"u8, 12, 0, 0, 0], new IfdSpec().Short(0x1031, 0x100), relativeToTiff: false);
Assert.Equal(3, fujiAperture.ExposureProgram);
var sony = Jpeg("SONY", "ILCE-7M4", [.. "SONY DSC \0\0\0"u8], new IfdSpec().Short(0xB041, 8));
Assert.Equal(4, sony.ExposureProgram);
var sonyAuto = Jpeg("SONY", "ILCE-7M4", [.. "SONY DSC \0\0\0"u8], new IfdSpec().Short(0xB041, 6));
Assert.Null(sonyAuto.ExposureProgram);
}
[Theory]
[Case(1, true)]
[Case(0, false)]
[Case(2, false)]
[Case(3, false)]
public void PanasonicTimerRecordingIsTheIntervalometerHint(int timerRecording, bool expected)
{
var m = Jpeg("Panasonic", "DC-GH6", [.. "Panasonic\0\0\0"u8], new IfdSpec().Short(0x001F, 11).Short(0x0096, (ushort)timerRecording));
Assert.Equal(expected, m.IntervalShooting);
Assert.Equal(1, m.ExposureProgram);
}
[Test]
public void WithoutTheTagsNothingIsGuessed()
{
var m = Jpeg("Panasonic", "DC-GH6", [.. "Panasonic\0\0\0"u8], new IfdSpec().Short(0x001A, 2));
Assert.Equal(((bool?)null, (RawSize?)null, (int?)null), (m.IntervalShooting, m.RawSize, m.ExposureProgram));
}
}