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
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>
145 lines
5.4 KiB
C#
145 lines
5.4 KiB
C#
using Chronos.Testing;
|
||
using Chronos.Ui.Visuals;
|
||
|
||
namespace Chronos.App.Tests.Visuals;
|
||
|
||
public sealed class WrapLayoutTests
|
||
{
|
||
[Theory]
|
||
[Case(0.0, 1)]
|
||
[Case(235.0, 1)]
|
||
[Case(236.0, 1)]
|
||
[Case(487.0, 1)]
|
||
[Case(488.0, 2)]
|
||
[Case(1252.0, 5)]
|
||
[Case(1255.0, 5)]
|
||
public void ColumnsCountWholeItemsWithGapsBetween(double width, int expected)
|
||
{
|
||
// 236-px cards with 16-px gaps: n columns need n·236 + (n−1)·16 px.
|
||
Assert.Equal(expected, WrapLayout.ColumnsFor(width, 236, 16));
|
||
}
|
||
|
||
[Test]
|
||
public void RowsAndExtentLeaveNoTrailingGap()
|
||
{
|
||
var layout = new WrapLayout(11, 1252, 236, 208, 16);
|
||
Assert.Equal(5, layout.Columns);
|
||
Assert.Equal(3, layout.Rows);
|
||
Assert.Approximately(3 * 224 - 16, layout.ExtentHeight, 1e-9);
|
||
Assert.Approximately(5 * 236 + 4 * 16, layout.ExtentWidth, 1e-9);
|
||
Assert.Approximately(0, new WrapLayout(0, 1252, 236, 208, 16).ExtentHeight, 1e-9);
|
||
}
|
||
|
||
[Test]
|
||
public void IndexMapsToRowColumnAndPixelOrigin()
|
||
{
|
||
var layout = new WrapLayout(500_000, 1252, 236, 208, 16);
|
||
Assert.Equal(1234, layout.RowOf(6172));
|
||
Assert.Equal(2, layout.ColumnOf(6172));
|
||
Assert.Approximately(2 * 252, layout.LeftOf(6172), 1e-9);
|
||
Assert.Approximately(1234 * 224, layout.TopOf(6172), 1e-6);
|
||
Assert.Equal(100_000, layout.Rows);
|
||
}
|
||
|
||
[Test]
|
||
public void VisibleRangeIsConstantTimeAndCoversPartialRows()
|
||
{
|
||
var layout = new WrapLayout(500_000, 1252, 236, 208, 16);
|
||
// Offset in the middle of row 50 000's gap: row 50 000 has ended, row 50 001 starts at 50 001·224.
|
||
var offset = 50_000 * 224.0 + 210;
|
||
var (first, last) = layout.VisibleRange(offset, 600);
|
||
Assert.Equal(50_001 * 5, first);
|
||
// Bottom edge at offset + 600 = 50 000·224 + 810 → rows up to 50 003 (starts at +672) are visible.
|
||
Assert.Equal(50_004 * 5 - 1, last);
|
||
|
||
var (cachedFirst, cachedLast) = layout.VisibleRange(offset, 600, cacheRows: 1);
|
||
Assert.Equal(first - 5, cachedFirst);
|
||
Assert.Equal(last + 5, cachedLast);
|
||
}
|
||
|
||
[Test]
|
||
public void VisibleRangeExcludesRowStartingAtBottomEdge()
|
||
{
|
||
var layout = new WrapLayout(100, 1252, 236, 208, 16);
|
||
var (first, last) = layout.VisibleRange(0, 224);
|
||
Assert.Equal(0, first);
|
||
Assert.Equal(4, last);
|
||
}
|
||
|
||
[Test]
|
||
public void VisibleRangeClampsToLastPartialRow()
|
||
{
|
||
var layout = new WrapLayout(12, 1252, 236, 208, 16);
|
||
var (first, last) = layout.VisibleRange(0, 10_000, cacheRows: 2);
|
||
Assert.Equal(0, first);
|
||
Assert.Equal(11, last);
|
||
Assert.Equal((0, -1), new WrapLayout(0, 1252, 236, 208, 16).VisibleRange(0, 500));
|
||
}
|
||
|
||
[Test]
|
||
public void OffsetToRevealScrollsTheLeastAmount()
|
||
{
|
||
var layout = new WrapLayout(100, 1252, 236, 208, 16);
|
||
// Row 3 spans [672, 880): below a viewport [0, 600) → bottom-aligned.
|
||
Assert.Approximately(880 - 600, layout.OffsetToReveal(15, 0, 600), 1e-9);
|
||
// Already visible → unchanged.
|
||
Assert.Approximately(300, layout.OffsetToReveal(15, 300, 600), 1e-9);
|
||
// Above the viewport → top-aligned.
|
||
Assert.Approximately(224, layout.OffsetToReveal(5, 1000, 600), 1e-9);
|
||
// Taller than the viewport → top-aligned.
|
||
Assert.Approximately(672, WrapLayout.OffsetToReveal(672, 208, 0, 100), 1e-9);
|
||
}
|
||
|
||
[Test]
|
||
public void ClampOffsetKeepsViewportInsideExtent()
|
||
{
|
||
var layout = new WrapLayout(10, 1252, 236, 208, 16);
|
||
Assert.Approximately(432 - 300, layout.ClampOffset(5000, 300), 1e-9);
|
||
Assert.Approximately(0, layout.ClampOffset(-20, 300), 1e-9);
|
||
Assert.Approximately(0, layout.ClampOffset(50, 1000), 1e-9);
|
||
}
|
||
|
||
[Test]
|
||
public void JustifySpreadsLeftoverWidthOverGaps()
|
||
{
|
||
var layout = new WrapLayout(10, 1300, 236, 208, 16, justify: true);
|
||
Assert.Equal(5, layout.Columns);
|
||
Assert.Approximately(1300, layout.LeftOf(4) + 236, 1e-9);
|
||
Assert.Approximately(1300, layout.ExtentWidth, 1e-9);
|
||
}
|
||
|
||
[Theory]
|
||
[Case(7, WrapStep.Left, 6)]
|
||
[Case(5, WrapStep.Left, 4)]
|
||
[Case(0, WrapStep.Left, 0)]
|
||
[Case(4, WrapStep.Right, 5)]
|
||
[Case(11, WrapStep.Right, 11)]
|
||
[Case(7, WrapStep.Up, 2)]
|
||
[Case(2, WrapStep.Up, 2)]
|
||
[Case(2, WrapStep.Down, 7)]
|
||
[Case(9, WrapStep.Down, 11)]
|
||
[Case(11, WrapStep.Down, 11)]
|
||
[Case(7, WrapStep.First, 0)]
|
||
[Case(7, WrapStep.Last, 11)]
|
||
public void KeyboardStepsFollowReadingOrderAndColumns(int from, WrapStep step, int expected)
|
||
{
|
||
// 12 items in rows of 5: 0–4, 5–9, 10–11.
|
||
var layout = new WrapLayout(12, 1252, 236, 208, 16);
|
||
Assert.Equal(expected, layout.Navigate(from, step, pageRows: 2));
|
||
}
|
||
|
||
[Test]
|
||
public void PageStepsMoveWholeViewportRowsInTheSameColumn()
|
||
{
|
||
var layout = new WrapLayout(1000, 1252, 236, 208, 16);
|
||
var pageRows = layout.PageRows(700);
|
||
Assert.Equal(3, pageRows);
|
||
Assert.Equal(2 + 3 * 5, layout.Navigate(2, WrapStep.PageDown, pageRows));
|
||
Assert.Equal(2, layout.Navigate(2 + 3 * 5, WrapStep.PageUp, pageRows));
|
||
Assert.Equal(3, layout.Navigate(8, WrapStep.PageUp, pageRows));
|
||
// From row 198 a page down is clamped to the last row, same column.
|
||
Assert.Equal(999, layout.Navigate(994, WrapStep.PageDown, pageRows));
|
||
Assert.Equal(-1, new WrapLayout(0, 1252, 236, 208, 16).Navigate(0, WrapStep.Down, 1));
|
||
}
|
||
}
|