Files
Chronos/tests/Chronos.App.Tests/Editor/EditorTextTests.cs
T
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

89 lines
4.7 KiB
C#

using Chronos.App.Editor;
using Chronos.Core.Advice;
using Chronos.Core.Imaging;
using Chronos.Core.Localization;
using Chronos.Core.Project;
using Chronos.Testing;
namespace Chronos.App.Tests.Editor;
/// <summary>Composed texts of the editor (the conflict prompt among them), crop margins and the waveform monitor.</summary>
public sealed class EditorTextTests
{
static EditorTextTests() => _ = EditorFixture.Sunset;
[Test]
public void ColourTemperatureShowsToTheNearestTen()
{
Assert.Equal(5560.0, ExposureTab.RoundToTens(5557.2));
Assert.Equal(3200.0, ExposureTab.RoundToTens(3203.9));
Assert.Equal(12_000.0, ExposureTab.RoundToTens(11_998));
}
[Test]
public void OptimiseReportsValuesAsTheControlsShowThem()
{
Assert.Equal("Frame 0413", EditorText.Value(AdvisorParameters.Hero, 412), "1-based, four digits, like the Frames tab");
Assert.Equal("Source", EditorText.Value(AdvisorParameters.Aspect, "source"));
Assert.Equal("16:9", EditorText.Value(AdvisorParameters.Aspect, "16:9"));
Assert.Equal("24 fps", EditorText.Value(AdvisorParameters.FrameRate, "24"));
Assert.Equal("41 frames", EditorText.Value(AdvisorParameters.DeflickerWindow, 41));
Assert.Equal("0.80", EditorText.Value(AdvisorParameters.DeflickerStrength, 0.8));
Assert.Equal("Centred", EditorText.Value(AdvisorParameters.OffsetY, 0.0));
Assert.Equal("On", EditorText.Value(AdvisorParameters.Deflicker, true));
Assert.Equal("Horizon", EditorText.Value(AdvisorParameters.Regions, RegionMode.Horizon));
Assert.Equal("None", EditorText.Value(AdvisorParameters.Hero, null));
Assert.Equal("3 frames", EditorText.Value(AdvisorParameters.Excluded, new[] { 1, 2, 3 }));
}
[Test]
public void CropMarginsKeepAtLeastATenthOfTheFrame()
{
Assert.SequenceEqual([0.0, 0, 0, 0], CropMargins.Of(null));
var crop = CropMargins.With(null, CropSide.Left, 0.2);
Assert.SequenceEqual([0.2, 0, 0.8, 1], crop!);
crop = CropMargins.With(crop, CropSide.Top, 0.6);
Assert.Approximately(CropMargins.MaxMargin, crop![1], 1e-12, "no margin beyond the maximum");
crop = CropMargins.With(crop, CropSide.Left, 0.45);
crop = CropMargins.With(crop, CropSide.Right, 0.45);
Assert.Approximately(CropMargins.MinSize, crop![2], 1e-12, "opposite margins leave a tenth of the width");
var margins = CropMargins.Of(crop);
Assert.Approximately(0.45, margins[0], 1e-12);
Assert.Approximately(0.45, margins[1], 1e-12);
Assert.Null(CropMargins.With(CropMargins.With(CropMargins.With(crop, CropSide.Left, 0), CropSide.Right, 0), CropSide.Top, 0),
"no margin left is the whole frame");
Assert.SequenceEqual([0.0, 0, 0, 0], CropMargins.Of([double.NaN, 0, 1, 1]), "an invalid crop is ignored, as the render does");
}
[Test]
public void AFlatGreyPictureIsOneLineOfTheWaveform()
{
using var grey = new ImageBuffer(40, 10);
grey.Data.Fill((float)ColorSpace.SrgbToLinear(0.5));
var waveform = LumaWaveform.Measure(grey);
Assert.Equal(40, waveform.Columns);
Assert.Equal(LumaWaveform.Levels, waveform.Rows);
var lit = Enumerable.Range(0, waveform.Rows).Where(r => waveform.Density[r * waveform.Columns] > 0).ToList();
Assert.Equal(1, lit.Count, "one level");
Assert.LessOrEqual(Math.Abs(lit[0] - (LumaWaveform.Levels - 1) / 2.0), 1.0, "half grey sits halfway up");
Assert.Equal(255, waveform.Density[lit[0] * waveform.Columns], "every pixel of the column there");
}
[Test]
public void TheConflictPromptSaysWhatDiffersAndTakesTheServersValuesUnlessAsked()
{
var basis = new ProjectSettings();
var mine = basis with { Exposure = basis.Exposure with { ExposureOffsetEv = 0.5 }, HeroFrame = 3 };
var theirs = basis with { Exposure = basis.Exposure with { ExposureOffsetEv = 0.3 } };
var conflict = new ProjectConflictException("changed", theirs, ProjectMerge.Conflicts(basis, mine, theirs));
var request = EditorViewModel.ConflictRequest(conflict, "Harbour sunset", "Studio NAS");
Assert.Equal(Loc.L("Server.Conflict.Difference", Loc.L("Server.Setting.ExposureOffset"), 0.5.ToString("0.###", Loc.Culture),
0.3.ToString("0.###", Loc.Culture)), request.Detail, "only the setting both changed; the editor's value first");
Assert.Equal(Loc.L("Server.Sync.Action.TakeServer"), request.SafeText, "the safe default loses nothing: Ctrl+Z brings the editor's values back");
Assert.Equal(Loc.L("Server.Sync.Action.KeepMine"), request.ActionText);
Assert.True(request.IsDestructive, "Keep mine overwrites the server's values");
Assert.Contains("Studio NAS", request.Heading);
}
}