The owner ran the installed 0.1.0-beta.26 (sessions 64-71) and asked for the results to be checked, the two flaky tests fixed, bugs fixed, and a release if there were bugs. Read from a backup copy of the ledger and the logs (docs/spike-notes/23-owner-runs-2026-10-20.md). - FgWindow.IsNearWholeMultiplier: a window is a state's only within 10 % of a whole multiplier of two or more (FgSlices.Slice.IsActive); FgMixRecord.Parse reads stored rows by the same rule. Silent Hill 2 under Dynamic MFG listed x2.52 for 12.8 s - windows where the multiplier stepped; it now reads x2.0, x3.0, none and 7.36 % not classified. - NgxDriverState / CaptureSession: the driver is not asked after the game has gone, and CREATED | EVALUATE stand once a reading carried them. The last NGX reading, taken after the target exited, replaced every in-game one: none of the 14 answered sessions kept the two bits, so DLSS (driver-reported) and the NVIDIA App's mode (D63) never showed on an NGX-direct title. - CaptureOrchestrator: a launch says it ended on its own (Recorded) with the pids it recorded (Targets), so a process turned away while it ran - the game Steam starts after Lies of P hands itself over - is recorded when it ends; the launch's own process never is. - SessionSummaryOpener: one window per session; opening it again brings it forward. - DisplayTally: the sizes are the mode's last sample that saw the window (a game leaving exclusive fullscreen closes it first; five sessions stored none). - DlssText.Line: no line that says only "DLSS". - Tests: the guard's scan set includes the test host above the harness, which under a full gate releases modules while it starts its other classes - ModuleScanFailed (reproduced 1 run in 12 of the assembly with coverage; 15 of 15 green after), ProcessUnreadable on 2026-10-19. ShmDrainIntegrationTests.InjectAsync asks again on those two reasons only (4 times at most, 250 ms apart); the pause case waits for READY; every injection suite waits for the harness's flushed "presenting" line instead of 800 ms (tests/Shared/HarnessReady.cs). - Docs: 03_METRICS (the mix, the driver-reported rung, display sizes), 04_CAPTURE, 06_DATA_MODEL, 08_UI, 14_TESTING, 18_GPU_VENDOR_APIS, 19_SAFETY (direct starts counted by the crash safety - measured, the policy unchanged), LIMITATIONS, guide (troubleshooting, results), spike-notes section 23, HANDOFF items 20 and 21, CHANGELOG. Then, on the owner's word about Steam games (Play > Start directly says a Steam game may hand itself to Steam - the notice, the tooltip and Settings (en/vi/ja); why a note rather than a fixed Steam rule (beta.27 PR-1)): The owner, 2026-10-20: Steam games hand themselves to Steam; a note in the UI, or a fixed setting that Steam's games always go through the Steam client - the choice left open. The note: - GamePlayer: PlayResult.SteamGame - the game the agent starts (Start directly, or an App running as administrator, or a Steam record with no link) is one Steam's own records name; the notice then reads Play_Started_Steam_Format / Play_Elevated_Steam_Format. Store records are read once a press. - Strings: Play_ToolTip_Direct and Settings_PlayMode_Body say a Steam game may hand itself to Steam and the game Steam then starts is recorded; Settings adds that a few will not start outside Steam at all. en/vi/ja, ja marked review; Strings.Designer regenerated. - Why not the fixed rule: three of the five Steam games started directly on 2026-10-20 ran and were measured from their first frame, and a Vulkan game is measured only when FrameLedger starts it (Everhex Demo) - recorded in 08_UI. - Docs: 08_UI, guide/08-settings, LIMITATIONS, CHANGELOG. - Tests: GamePlayerTests (Steam started directly and elevated say it; a loose or GOG game does not). Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com>
172 lines
8.0 KiB
C#
172 lines
8.0 KiB
C#
// SPDX-License-Identifier: GPL-3.0-only
|
|
// Copyright (C) 2026 poli0981 - additional terms under GPLv3 section 7: see NOTICE
|
|
|
|
using FluentAssertions;
|
|
using FrameLedger.Domain.Display;
|
|
|
|
namespace FrameLedger.Domain.Tests.Display;
|
|
|
|
/// <summary>
|
|
/// The display-mode ladder and its time tally (beta.10, <c>03_METRICS</c> §Display mode): what one sample is, and what a
|
|
/// session's samples add up to.
|
|
/// </summary>
|
|
public sealed class DisplayModeTests
|
|
{
|
|
private static readonly ScreenRect _monitor = new(0, 0, 2560, 1440);
|
|
|
|
private static WindowView Window(ScreenRect client, bool minimized = false) => new(minimized, client, _monitor, 144);
|
|
|
|
private static SwapChainView Chain(bool known = true, bool exclusive = false, bool fresh = true, bool openGl = false) =>
|
|
new(Hwnd: 0x1234, ExclusiveKnown: known, Exclusive: exclusive, OpenGl: openGl, BufferWidth: 2560, BufferHeight: 1440,
|
|
SwapEffect: openGl ? null : "flip_discard", Fresh: fresh);
|
|
|
|
[Fact]
|
|
public void AnExclusiveChainIsExclusiveFullscreen() =>
|
|
DisplayModeClassifier.Classify(Chain(exclusive: true), Window(_monitor)).Mode.Should().Be(DisplayMode.ExclusiveFullscreen);
|
|
|
|
[Fact]
|
|
public void ACoveringWindowOnANonExclusiveChainIsBorderless()
|
|
{
|
|
DisplayObservation o = DisplayModeClassifier.Classify(Chain(), Window(_monitor));
|
|
|
|
o.Mode.Should().Be(DisplayMode.Borderless);
|
|
o.Source.Should().Be(DisplaySource.SwapChain);
|
|
o.Client.Should().Be(_monitor);
|
|
o.BufferWidth.Should().Be(2560u);
|
|
o.MonitorHz.Should().Be(144);
|
|
o.SwapEffect.Should().Be("flip_discard");
|
|
}
|
|
|
|
/// <summary>OpenGL, Vulkan and a game that was not hooked cannot be asked: a covering window is "borderless or fullscreen".</summary>
|
|
[Fact]
|
|
public void ACoveringWindowNobodyCouldAskAboutCoversTheScreen()
|
|
{
|
|
DisplayModeClassifier.Classify(null, Window(_monitor)).Should().Match<DisplayObservation>(o =>
|
|
o.Mode == DisplayMode.CoversScreen && o.Source == DisplaySource.Window);
|
|
DisplayModeClassifier.Classify(Chain(known: false, openGl: true), Window(_monitor)).Should().Match<DisplayObservation>(o =>
|
|
o.Mode == DisplayMode.CoversScreen && o.Source == DisplaySource.OpenGl);
|
|
}
|
|
|
|
/// <summary>A sample older than 2 s says nothing about now: a minimised game presents only probes the hook drops.</summary>
|
|
[Fact]
|
|
public void AStaleExclusiveSampleIsNotExclusive() =>
|
|
DisplayModeClassifier.Classify(Chain(exclusive: true, fresh: false), Window(_monitor)).Mode.Should().Be(DisplayMode.CoversScreen);
|
|
|
|
[Theory]
|
|
[InlineData(100, 100, 1700, 1000)] // a window in the middle of the screen
|
|
[InlineData(0, 31, 2560, 1400)] // a maximised window: title bar above, taskbar below
|
|
public void AClientAreaThatDoesNotCoverTheMonitorIsWindowed(int left, int top, int right, int bottom) =>
|
|
DisplayModeClassifier.Classify(Chain(), Window(new ScreenRect(left, top, right, bottom))).Mode.Should().Be(DisplayMode.Windowed);
|
|
|
|
[Fact]
|
|
public void OnePixelShortOnAnEdgeStillCovers() =>
|
|
DisplayModeClassifier.Classify(Chain(), Window(new ScreenRect(1, 0, 2559, 1440))).Mode.Should().Be(DisplayMode.Borderless);
|
|
|
|
[Fact]
|
|
public void AMinimisedWindowIsMinimisedWhateverTheChainLastSaid() =>
|
|
DisplayModeClassifier.Classify(Chain(exclusive: true), Window(_monitor, minimized: true)).Mode.Should().Be(DisplayMode.Minimized);
|
|
|
|
[Fact]
|
|
public void NoWindowIsNoWindowUnlessTheChainSaidExclusive()
|
|
{
|
|
DisplayModeClassifier.Classify(null, null).Should().Match<DisplayObservation>(o => o.Mode == DisplayMode.NoWindow && o.Source == null);
|
|
DisplayModeClassifier.Classify(Chain(), null).Mode.Should().Be(DisplayMode.NoWindow);
|
|
DisplayModeClassifier.Classify(Chain(exclusive: true), null).Mode.Should().Be(DisplayMode.ExclusiveFullscreen);
|
|
}
|
|
|
|
/// <summary>Two sampling rates, one unit: a 100 ms tick and a 1 s tick each stand for the time until the next.</summary>
|
|
[Fact]
|
|
public void TheTallyAddsTimeAndTheSharesIgnoreTimeWithNoWindow()
|
|
{
|
|
var tally = new DisplayTally();
|
|
DisplayObservation exclusive = DisplayModeClassifier.Classify(Chain(exclusive: true), Window(_monitor));
|
|
DisplayObservation windowed = DisplayModeClassifier.Classify(Chain(), Window(new ScreenRect(100, 100, 1380, 820)));
|
|
DisplayObservation none = DisplayModeClassifier.Classify(null, null);
|
|
|
|
for (int i = 0; i < 30; i++)
|
|
{
|
|
tally.Add(exclusive, 100); // 3 s hooked at 100 ms
|
|
}
|
|
|
|
tally.Add(none, 5_000); // 5 s with no window: outside every share
|
|
tally.Add(windowed, 1_000); // 1 s of a windowed hold tick
|
|
tally.Add(exclusive, -50); // a clock that went backwards adds nothing
|
|
|
|
DisplaySummary s = tally.Summary();
|
|
s.ExclusiveMs.Should().Be(3_000);
|
|
s.WindowedMs.Should().Be(1_000);
|
|
s.NoWindowMs.Should().Be(5_000);
|
|
s.ObservedMs.Should().Be(4_000);
|
|
s.SharePercent(DisplayMode.ExclusiveFullscreen).Should().Be(75.0);
|
|
s.SharePercent(DisplayMode.Windowed).Should().Be(25.0);
|
|
s.Changes.Should().Be(2, "exclusive → windowed → exclusive; the sample with no window is not a mode");
|
|
s.Dominant.Should().Be(DisplayMode.ExclusiveFullscreen);
|
|
s.WindowWidth.Should().Be(2560, "the sizes are the longest-lasting mode's");
|
|
s.MonitorHz.Should().Be(144);
|
|
s.Source.Should().Be(DisplaySource.SwapChain);
|
|
s.ExclusivityKnown.Should().BeTrue();
|
|
}
|
|
|
|
/// <summary>
|
|
/// beta.27: a game leaving exclusive fullscreen destroys its window while its swap chain's last word is still fresh,
|
|
/// so its last samples are exclusive with no window; five Lies of P and Dark Souls III sessions stored no sizes.
|
|
/// </summary>
|
|
[Fact]
|
|
public void TheSizesAreTheLastOnesTheModeSaw()
|
|
{
|
|
var tally = new DisplayTally();
|
|
tally.Add(DisplayModeClassifier.Classify(Chain(exclusive: true), Window(_monitor)), 60_000);
|
|
tally.Add(DisplayModeClassifier.Classify(Chain(exclusive: true), null), 100); // the window is gone
|
|
tally.Add(DisplayModeClassifier.Classify(Chain(exclusive: true, fresh: false), null), 1_500);
|
|
|
|
DisplaySummary s = tally.Summary();
|
|
s.Dominant.Should().Be(DisplayMode.ExclusiveFullscreen);
|
|
s.WindowWidth.Should().Be(2560, "the exclusive samples saw the window before it was destroyed");
|
|
s.WindowHeight.Should().Be(1440);
|
|
s.MonitorWidth.Should().Be(2560);
|
|
s.MonitorHz.Should().Be(144);
|
|
s.BufferWidth.Should().Be(2560u);
|
|
}
|
|
|
|
[Fact]
|
|
public void AModeThatNeverSawItsWindowStoresTheChainsSizesAlone()
|
|
{
|
|
var tally = new DisplayTally();
|
|
tally.Add(DisplayModeClassifier.Classify(Chain(exclusive: true), null), 5_000);
|
|
|
|
DisplaySummary s = tally.Summary();
|
|
s.Dominant.Should().Be(DisplayMode.ExclusiveFullscreen);
|
|
s.WindowWidth.Should().BeNull("no sample of the mode saw a window");
|
|
s.MonitorHz.Should().BeNull();
|
|
s.BufferWidth.Should().Be(2560u, "the swap chain said its own size");
|
|
}
|
|
|
|
[Fact]
|
|
public void ASessionWhoseExclusivityWasUnknownForAMomentSaysSo()
|
|
{
|
|
var tally = new DisplayTally();
|
|
tally.Add(DisplayModeClassifier.Classify(Chain(), Window(_monitor)), 900);
|
|
tally.Add(DisplayModeClassifier.Classify(null, Window(_monitor)), 100);
|
|
|
|
DisplaySummary s = tally.Summary();
|
|
s.BorderlessMs.Should().Be(900);
|
|
s.CoversMs.Should().Be(100);
|
|
s.ExclusivityKnown.Should().BeFalse();
|
|
s.Source.Should().Be(DisplaySource.SwapChain, "the strongest source any sample had");
|
|
}
|
|
|
|
[Fact]
|
|
public void NothingObservedHasNoSharesAndNoSizes()
|
|
{
|
|
var tally = new DisplayTally();
|
|
tally.Any.Should().BeFalse();
|
|
tally.Add(DisplayModeClassifier.Classify(null, null), 1_000);
|
|
|
|
DisplaySummary s = tally.Summary();
|
|
s.SharePercent(DisplayMode.Windowed).Should().BeNull();
|
|
s.Dominant.Should().BeNull();
|
|
s.WindowWidth.Should().BeNull();
|
|
s.Source.Should().BeNull();
|
|
}
|
|
}
|