Files
frameledger/tests/FrameLedger.App.Tests/DisplayTextTests.cs
poli0981andClaude Opus 5.5 ff949afc6f feat(legal): NOTICE with the GPLv3 section 7 additional terms, the licence header in every source file, and the documents for people who build, contribute or redistribute (D45, beta.12 PR-1) (#253)
- NOTICE: copyright, GPL-3.0-only, and three additional terms of the kinds section 7 permits - (b) preserve the
  notices and the attribution in the program's legal notices, (c) mark a modified version as different and do not
  call it "FrameLedger" alone, (e) no trademark rights in the name. Shipped as licenses\NOTICE.txt; release.yml
  refuses a published tree without it.
- Section 7 wants additional terms named in the source files: every first-party .cs .cpp .h .inl .ps1 .xaml file
  (1,053; src/native/third_party excluded) opens with the SPDX line and a pointer to NOTICE. tools/notice-check.ps1
  is the gate (six self-test cases, both directions; -Fix writes a missing header) and tools/resx-gen.ps1 generates
  the string accessors with the header.
- The native VERSIONINFO LegalCopyright said GPL-3.0-or-later; it now names the real licence.
- CONTRIBUTING.md, FORKING.md, CODE_OF_CONDUCT.md (Contributor Covenant 2.1 by reference), legal/TRADEMARKS.md.
- 12_BUILD gate list, CLAUDE.md layout and conventions.

Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com>
2026-10-03 22:16:00 +07:00

105 lines
4.0 KiB
C#
Raw Permalink Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
// SPDX-License-Identifier: GPL-3.0-only
// Copyright (C) 2026 poli0981 - additional terms under GPLv3 section 7: see NOTICE
using System.Globalization;
using FluentAssertions;
using FrameLedger.App.Services;
using FrameLedger.Domain.Display;
namespace FrameLedger.App.Tests;
/// <summary>
/// The display facts as the pages say them (beta.10, <c>03_METRICS</c> §Display mode): never more certain than the source,
/// a share that was there never rounded to nothing, and N/A for a row that has none.
/// </summary>
[Collection(StringsCultureCollection.Name)]
public sealed class DisplayTextTests
{
private static T InEnglish<T>(Func<T> read)
{
CultureInfo? previous = Strings.Culture;
CultureInfo current = CultureInfo.CurrentCulture;
Strings.Culture = CultureInfo.GetCultureInfo("en");
CultureInfo.CurrentCulture = CultureInfo.GetCultureInfo("en-US");
try
{
return read();
}
finally
{
Strings.Culture = previous;
CultureInfo.CurrentCulture = current;
}
}
[Fact]
public void TheHeadlineIsTheModeShownLongestWithItsShare() => InEnglish(() =>
{
DisplayText.Headline(new DisplaySummary { ExclusiveMs = 30_000, BorderlessMs = 70_000 }).Should().Be("Borderless 70%");
DisplayText.Headline(new DisplaySummary { CoversMs = 10_000 }).Should().Be("Fullscreen or borderless 100%");
DisplayText.Headline(new DisplaySummary { MinimizedMs = 5_000 }).Should().Be("Minimized 100%", "a session spent minimised says so rather than 'no window'");
DisplayText.Headline(new DisplaySummary { NoWindowMs = 5_000 }).Should().Be("No window read");
DisplayText.Headline(null).Should().Be("N/A");
return 0;
});
[Fact]
public void SharesAreSaidFullscreenEndFirstAndATraceIsNeverRoundedAway() => InEnglish(() =>
{
var display = new DisplaySummary { WindowedMs = 99_800, ExclusiveMs = 200 };
DisplayText.Shares(display).Should().Be("Exclusive fullscreen <1% · Windowed 100%");
DisplayText.Shares(null).Should().Be("N/A");
return 0;
});
[Fact]
public void TheSizesAreSaidOnlyWhenTheyWereRead() => InEnglish(() =>
{
var display = new DisplaySummary { WindowedMs = 1, WindowWidth = 1280, WindowHeight = 720, MonitorWidth = 2560, MonitorHeight = 1440 };
DisplayText.Window(display).Should().Be("1280×720");
DisplayText.Monitor(display).Should().Be("2560×1440", "no refresh rate was read");
DisplayText.Monitor(display with { MonitorHz = 60 }).Should().Be("2560×1440 @ 60 Hz");
DisplayText.Window(new DisplaySummary()).Should().Be("N/A");
DisplayText.Monitor(null).Should().Be("N/A");
return 0;
});
[Fact]
public void TheLineNamesWhatTheFactsRestedOn() => InEnglish(() =>
{
var display = new DisplaySummary
{
ExclusiveMs = 60_000,
Changes = 3,
Source = DisplaySource.SwapChain,
BufferWidth = 3840,
BufferHeight = 2160,
SwapEffect = "flip_discard",
};
DisplayText.Line(display).Should().Be("Display: Exclusive fullscreen 100% · changed 3 times · back buffer 3840×2160 (flip_discard)"
+ " · the swap chain said whether it was exclusive");
DisplayText.Line(null).Should().BeNull();
return 0;
});
[Fact]
public void TheExportLineIsInvariant()
{
CultureInfo current = CultureInfo.CurrentCulture;
CultureInfo.CurrentCulture = CultureInfo.GetCultureInfo("de-DE");
try
{
DisplayText.ExportLine(new DisplaySummary { WindowedMs = 1_234_567, MonitorWidth = 1920, MonitorHeight = 1080 })
.Should().Be("exclusive_ms=0; borderless_ms=0; covers_ms=0; windowed_ms=1234567; minimized_ms=0; nowindow_ms=0; changes=0; source=n/a;"
+ " window=n/a; buffer=n/a; monitor=1920x1080");
}
finally
{
CultureInfo.CurrentCulture = current;
}
}
}