Files
Chronos/tests/Chronos.Core.Windows.Tests/Wic/OrientationMapTests.cs
T
Alby96andClaude Opus 5.5 5f27a86406
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
refactor!: rename Titano to Chronos and move CI and releases to Gitea
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>
2026-10-23 11:34:48 +02:00

68 lines
2.2 KiB
C#

using Chronos.Core.Windows.Wic;
using Chronos.Testing;
namespace Chronos.Core.Windows.Tests.Wic;
public sealed class OrientationMapTests
{
[Theory]
[Case(1)]
[Case(2)]
[Case(3)]
[Case(4)]
[Case(5)]
[Case(6)]
[Case(7)]
[Case(8)]
public void MatchesTheExifDefinition(int orientation)
{
const int width = 5, height = 3;
var map = OrientationMap.Create(orientation, width, height);
var swapped = OrientationMap.SwapsAxes(orientation);
Assert.Equal(swapped ? height : width, map.Width);
Assert.Equal(swapped ? width : height, map.Height);
var seen = new HashSet<int>();
for (var y = 0; y < height; y++)
{
for (var x = 0; x < width; x++)
{
var (dx, dy) = Reference(orientation, x, y, width, height);
Assert.Equal((dy * map.Width) + dx, map.IndexOf(x, y), $"orientation {orientation}, pixel ({x},{y})");
seen.Add(map.IndexOf(x, y));
}
}
Assert.Equal(width * height, seen.Count);
}
[Test]
public void UnknownValuesActAsIdentity() => Assert.Equal(OrientationMap.Create(1, 4, 2), OrientationMap.Create(0, 4, 2));
[Theory]
[Case(4000u, 3000u, 1920, 1920u, 1440u)]
[Case(400u, 100u, 100, 100u, 25u)]
[Case(3000u, 4000u, 1000, 750u, 1000u)]
[Case(640u, 480u, 0, 640u, 480u)]
[Case(640u, 480u, 2000, 640u, 480u)]
[Case(2u, 1000u, 10, 1u, 10u)]
public void TargetSizeFitsTheLongEdge(uint width, uint height, int maxLongEdge, uint expectedWidth, uint expectedHeight)
{
var (w, h) = WicDecoderProvider.TargetSize(width, height, maxLongEdge);
Assert.Equal(expectedWidth, w);
Assert.Equal(expectedHeight, h);
}
/// <summary>Displayed position of stored pixel (x, y), straight from the Exif 2.3 orientation table.</summary>
private static (int X, int Y) Reference(int orientation, int x, int y, int w, int h) => orientation switch
{
2 => (w - 1 - x, y),
3 => (w - 1 - x, h - 1 - y),
4 => (x, h - 1 - y),
5 => (y, x),
6 => (h - 1 - y, x),
7 => (h - 1 - y, w - 1 - x),
8 => (y, w - 1 - x),
_ => (x, y),
};
}