Compare commits

...
Author SHA1 Message Date
poli0981andClaude Opus 5.5 092d4b6262 test(app): the chart-wheel test says which keys are held instead of reading the machine's keyboard (beta.14)
A local ./build.ps1 check (PR-6) went red on ChartWheelTests.APlainWheelOverAChartScrollsThePageAndNotTheChart:
offset 0. Nothing in that gate touched the App. ChartWheel read Keyboard.Modifiers, which is the machine's real
keyboard from any thread - measured: a fresh background STA thread's GetKeyState reported the machine's NumLock - so a
Ctrl held anywhere while the test ran sent the plain wheel down the zoom path (page not scrolled). CI, with no person at
the keyboard, never saw it.

ChartWheel.CurrentModifiers (default Keyboard.Modifiers; the App never sets it) is what both handlers read; the test sets
it inside its own work item on the one STA thread and puts it back. The keys are a parameter now, so the Ctrl+wheel half
is driven end to end too (page stays, the surface ScottPlot zooms from is reached). A mutation that stops Ctrl+wheel at
the plot turns that case red.

Docs: 14_TESTING (a test that sends input says which keys are held), CHANGELOG.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-10-06 02:02:58 +07:00
4 changed files with 59 additions and 27 deletions

No files matched your search

+3
View File
@@ -67,6 +67,9 @@ numeric core and does not move; the heading is the full version — corrected 20
own scroller had nothing to scroll and still took every wheel. Every page scrolls itself now. The Logs page had the same
cause: its tail grew to hold every line and never followed the newest one, as it was meant to. A scroller inside a
dialog (the consent, administrator, anti-cheat exception and bug report dialogs) hands the wheel on at its ends.
- **The chart-wheel test read the real keyboard** (developers): a Ctrl held anywhere on the machine while the test ran
turned its plain wheel into a zoom, and a local gate went red once. The keys held are now the test's own input, and the
Ctrl+wheel half is driven end to end as well.
### Changed
+6
View File
@@ -63,6 +63,12 @@ cell against that colour in both themes and counts the accent pixels of each tic
paging checks navigate a real page in WPF UI's presenter and send it the wheel. Each was run red against the unfixed XAML
first — a rendered check that cannot fail is the counted-rows check again.
**A test that sends input must also say which keys are held.** `Keyboard.Modifiers` is the machine's real keyboard, read
from any thread (a fresh background thread's `GetKeyState` reports the machine's NumLock — measured 2026-10-06), so a
wheel test that read it held whatever key a person pressed while the gate ran: `ChartWheelTests`' plain half went red once
on the developer's machine and never on CI. The handlers read `ChartWheel.CurrentModifiers`, which the test sets inside its
own work item on the STA thread and puts back — and with the keys a parameter, the Ctrl half is driven end to end too.
## Integration tests (CI-runnable, no game, no anti-cheat surface)
`hook-harness` is what makes this architecture testable without touching a real title:
+12 -2
View File
@@ -20,6 +20,16 @@ internal static class ChartWheel
/// <summary>Whether a wheel with these modifier keys zooms the chart rather than scrolling the page: Ctrl held.</summary>
public static bool Zooms(ModifierKeys modifiers) => (modifiers & ModifierKeys.Control) == ModifierKeys.Control;
/// <summary>
/// The modifier keys the two handlers read: <see cref="Keyboard.Modifiers"/>, which is the machine's real keyboard — a
/// thread that never had keyboard focus still reads it (measured 2026-10-06: a fresh background thread's
/// <c>GetKeyState</c> reported the machine's NumLock). So a test driving the wheel end to end held whatever key a person
/// pressed while it ran — the one input it did not control, and the plain half went red once in a gate on the developer's
/// machine and never on CI. The tests set this for the length of one dispatcher work item and put it back; the App never
/// sets it.
/// </summary>
internal static Func<ModifierKeys> CurrentModifiers { get; set; } = static () => Keyboard.Modifiers;
public static void Attach(WpfPlot plot)
{
ArgumentNullException.ThrowIfNull(plot);
@@ -33,7 +43,7 @@ internal static class ChartWheel
/// </summary>
private static void OnPreviewMouseWheel(object sender, MouseWheelEventArgs e)
{
if (e.Handled || Zooms(Keyboard.Modifiers) || sender is not DependencyObject plot)
if (e.Handled || Zooms(CurrentModifiers()) || sender is not DependencyObject plot)
{
return;
}
@@ -48,7 +58,7 @@ internal static class ChartWheel
/// <summary>The bubbling half, after ScottPlot has zoomed: Ctrl+wheel stops here, so the page does not scroll as well.</summary>
private static void OnMouseWheel(object sender, MouseWheelEventArgs e)
{
if (Zooms(Keyboard.Modifiers))
if (Zooms(CurrentModifiers()))
{
e.Handled = true;
}
+38 -25
View File
@@ -12,9 +12,9 @@ namespace FrameLedger.App.Tests;
/// <summary>
/// The wheel over a chart (beta.14): ScottPlot zooms on every wheel and never marks it handled, so on a page that scrolls a
/// wheel over a chart zoomed it AND scrolled the page. A plain wheel is the page's now and Ctrl+wheel the chart's. The Ctrl
/// half reads <see cref="Keyboard.Modifiers"/>, which a test cannot press, so it is held by the pure rule; the plain half is
/// driven end to end.
/// wheel over a chart zoomed it AND scrolled the page. A plain wheel is the page's now and Ctrl+wheel the chart's. Both
/// halves are driven end to end with the keys held given to <see cref="ChartWheel.CurrentModifiers"/>: the handlers read the
/// machine's real keyboard otherwise, and this test once read a Ctrl someone held while it ran (2026-10-06).
/// </summary>
public sealed class ChartWheelTests
{
@@ -27,35 +27,48 @@ public sealed class ChartWheelTests
public void OnlyCtrlZooms(ModifierKeys modifiers, bool zooms) => ChartWheel.Zooms(modifiers).Should().Be(zooms);
/// <summary>
/// A plain wheel over the plot reaches the page and never the plot's drawing surface, where ScottPlot listens: the probe
/// subscribes to the surface's wheel exactly as ScottPlot does, so it is called whenever ScottPlot would zoom.
/// A plain wheel over the plot reaches the page and never the plot's drawing surface, where ScottPlot listens; Ctrl+wheel
/// reaches the surface and stops at the plot, so the page stays where it is. The probe subscribes to the surface's wheel
/// exactly as ScottPlot does, so it is called whenever ScottPlot would zoom.
/// </summary>
[Fact]
public async Task APlainWheelOverAChartScrollsThePageAndNotTheChart()
[Theory]
[InlineData(ModifierKeys.None, true, 0)]
[InlineData(ModifierKeys.Shift, true, 0)]
[InlineData(ModifierKeys.Control, false, 1)]
public async Task APlainWheelScrollsThePageAndCtrlWheelReachesOnlyTheChart(ModifierKeys held, bool pageScrolls, int surfaceWheels)
{
(double Offset, int SurfaceWheels) result = await PagesLoadTests.OnStaAsync(() =>
{
var plot = new WpfPlot { Height = 300 };
ChartTheme.Attach(plot);
var page = new ScrollViewer
Func<ModifierKeys> keyboard = ChartWheel.CurrentModifiers;
ChartWheel.CurrentModifiers = () => held;
try
{
Height = 400,
Content = new StackPanel { Children = { new Border { Height = 200 }, plot, new Border { Height = 900 } } },
};
Visuals.Layout(page, 800, 400);
var plot = new WpfPlot { Height = 300 };
ChartTheme.Attach(plot);
var page = new ScrollViewer
{
Height = 400,
Content = new StackPanel { Children = { new Border { Height = 200 }, plot, new Border { Height = 900 } } },
};
Visuals.Layout(page, 800, 400);
UIElement surface = Visuals.FindAll<FrameworkElement>(plot).First(static e => string.Equals(e.GetType().Name, "SKElement", StringComparison.Ordinal));
int surfaceWheels = 0;
surface.MouseWheel += (_, _) => surfaceWheels++;
var wheel = new MouseWheelEventArgs(Mouse.PrimaryDevice, Environment.TickCount, -120) { RoutedEvent = UIElement.PreviewMouseWheelEvent };
surface.RaiseEvent(wheel);
wheel.RoutedEvent = UIElement.MouseWheelEvent;
surface.RaiseEvent(wheel);
page.UpdateLayout();
return (page.VerticalOffset, surfaceWheels);
UIElement surface = Visuals.FindAll<FrameworkElement>(plot).First(static e => string.Equals(e.GetType().Name, "SKElement", StringComparison.Ordinal));
int wheels = 0;
surface.MouseWheel += (_, _) => wheels++;
var wheel = new MouseWheelEventArgs(Mouse.PrimaryDevice, Environment.TickCount, -120) { RoutedEvent = UIElement.PreviewMouseWheelEvent };
surface.RaiseEvent(wheel);
wheel.RoutedEvent = UIElement.MouseWheelEvent;
surface.RaiseEvent(wheel);
page.UpdateLayout();
return (page.VerticalOffset, wheels);
}
finally
{
ChartWheel.CurrentModifiers = keyboard;
}
});
result.Offset.Should().BeGreaterThan(0, "a plain wheel over a chart scrolls the page it is on");
result.SurfaceWheels.Should().Be(0, "and never reaches the surface ScottPlot zooms from: zoom is Ctrl+wheel");
(result.Offset > 0).Should().Be(pageScrolls, "a plain wheel over a chart scrolls the page it is on, and Ctrl+wheel leaves it where it is");
result.SurfaceWheels.Should().Be(surfaceWheels, "only Ctrl+wheel reaches the surface ScottPlot zooms from");
}
}