* ci: Qodana - a workflow of its own from JetBrains' template, Qodana Community for .NET over FrameLedger.slnx (D93) The first run: the linter in its Linux container, EnableWindowsTargeting passed to it, no quality gate yet - what it builds and what it reports decides the rest. Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com> * ci: Qodana's gate is zero problems, and the inspections this project argues with are off in .editorconfig, each with its reason (D93) Pushed before the fixes on purpose: the run this starts has the settings and none of the fixes, so it shows the gate failing on what is left. Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com> * fix: what Qodana's first run reported, settled - about 400 fixes in 181 files, none changing behaviour; the documents (D93) Redundant qualifiers, casts, using directives, nullable suppressions and unsafe modifiers removed from the report's own positions; var for built-in types and one-line block bodies brought to .editorconfig's style by dotnet format; every XAML item template names its DataType and a binding that reached its page through DataContext.ViewModel names the page's type; two unread fields, two overwritten initialisers and an unused parameter removed; SpokenTextAutomationPeer no longer assumes the base peer's name is a string. docs/13_CI_CD.md §Qodana, CLAUDE.md, the wiki's workflow table, HANDOFF's decisions index (D93) and the changelog entry. Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com> --------- Co-authored-by: Claude Fable 5.2 <noreply@anthropic.com>
133 lines
6.5 KiB
C#
133 lines
6.5 KiB
C#
// SPDX-License-Identifier: GPL-3.0-only
|
|
// Copyright (C) 2026 poli0981 - additional terms under GPLv3 section 7: see NOTICE
|
|
|
|
using System.Windows;
|
|
using System.Windows.Controls;
|
|
using System.Windows.Input;
|
|
using FluentAssertions;
|
|
using FrameLedger.App.Charts;
|
|
using FrameLedger.App.Pages;
|
|
using FrameLedger.App.Services;
|
|
using FrameLedger.App.ViewModels;
|
|
using FrameLedger.Application.Persistence;
|
|
using FrameLedger.Infrastructure.Persistence;
|
|
using Wpf.Ui.Controls;
|
|
|
|
namespace FrameLedger.App.Tests;
|
|
|
|
/// <summary>
|
|
/// The mouse wheel on the pages (beta.14, owner: "the wheel does not scroll, I have to drag the scroll bar"). WPF UI 4.3.0's
|
|
/// <see cref="NavigationViewContentPresenter"/> wraps a page in a <c>DynamicScrollViewer</c> unless the page sets
|
|
/// <c>ScrollViewer.CanContentScroll="False"</c>; inside it the page's own root scroller had infinite height, nothing to
|
|
/// scroll, and took every wheel all the same. Each check hosts a page the way the App does — navigated in the presenter.
|
|
/// </summary>
|
|
public sealed partial class PagesLoadTests
|
|
{
|
|
/// <summary>A page navigated in WPF UI's presenter and laid out in an area the size of the window's.</summary>
|
|
private static NavigationViewContentPresenter Navigated(Page page, double height)
|
|
{
|
|
var presenter = new NavigationViewContentPresenter();
|
|
var area = new Grid { Width = 1000, Height = height, Children = { presenter } };
|
|
Visuals.Layout(area, 1000, height);
|
|
_ = presenter.Navigate(page);
|
|
Visuals.Pump();
|
|
Visuals.Layout(area, 1000, height);
|
|
Visuals.Pump();
|
|
area.UpdateLayout();
|
|
return presenter;
|
|
}
|
|
|
|
private static void Wheel(UIElement over, int delta)
|
|
{
|
|
var wheel = new MouseWheelEventArgs(Mouse.PrimaryDevice, Environment.TickCount, delta) { RoutedEvent = UIElement.PreviewMouseWheelEvent };
|
|
over.RaiseEvent(wheel);
|
|
wheel.RoutedEvent = UIElement.MouseWheelEvent;
|
|
over.RaiseEvent(wheel);
|
|
}
|
|
|
|
[Fact]
|
|
public async Task ANavigatedPageIsNotWrappedInTheDynamicScrollViewerAndTheWheelScrollsIt()
|
|
{
|
|
await using ScratchLedger s = await ScratchLedger.OpenAsync();
|
|
var consent = new HookingConsent(new NoAgent(), new NoPrompt());
|
|
(SettingsViewModel settings, _) = await SettingsAndLogsAsync(s, consent, new NoStrip());
|
|
|
|
(bool Wrapped, double Offset) result = await OnStaAsync(() =>
|
|
{
|
|
var page = new SettingsPage(settings, new SystemInfoViewModel(new FixedHardware(), new NoClipboard(), new NoStrip()));
|
|
NavigationViewContentPresenter presenter = Navigated(page, 500);
|
|
ScrollViewer root = Visuals.Find<ScrollViewer>(page)!;
|
|
Wheel(Visuals.Leaf((UIElement)root.Content), -120);
|
|
presenter.UpdateLayout();
|
|
return (presenter.IsDynamicScrollViewerEnabled, root.VerticalOffset);
|
|
});
|
|
|
|
result.Wrapped.Should().BeFalse("the page opts out of WPF UI's wrapper (ScrollViewer.CanContentScroll=\"False\")");
|
|
result.Offset.Should().BeGreaterThan(0, "the wheel over the page's text scrolls the page");
|
|
}
|
|
|
|
[Fact]
|
|
public async Task TheLogsTailIsBoundedAndFollowsTheEnd()
|
|
{
|
|
await using ScratchLedger s = await ScratchLedger.OpenAsync();
|
|
var consent = new HookingConsent(new NoAgent(), new NoPrompt());
|
|
(_, LogsViewModel logs) = await SettingsAndLogsAsync(s, consent, new NoStrip());
|
|
|
|
(double Height, double Offset) tail = await OnStaAsync(() =>
|
|
{
|
|
var page = new LogsPage(logs);
|
|
_ = Navigated(page, 500);
|
|
page.Tail.Text = string.Join(Environment.NewLine, Enumerable.Range(1, 400).Select(static i => "line " + i.ToString(System.Globalization.CultureInfo.InvariantCulture)));
|
|
page.UpdateLayout();
|
|
page.Tail.ScrollToEnd();
|
|
page.UpdateLayout();
|
|
return (page.Tail.ActualHeight, page.Tail.VerticalOffset);
|
|
});
|
|
|
|
tail.Height.Should().BeLessThan(500, "the tail has the height the page leaves it, not one tall enough for every line");
|
|
tail.Offset.Should().BeGreaterThan(0, "so it scrolls, and ScrollToEnd (autoscroll) shows the newest line");
|
|
}
|
|
/// <summary>
|
|
/// beta.23: the game page's Sessions grid is bounded, so it builds the rows on screen and scrolls itself. Inside the page's
|
|
/// own scroller it was measured with no height limit and built every row - 100 sessions were 100 rows of 17 columns at
|
|
/// every open, 1.2 s (spike-notes 21). The wheel over it still reaches the page once the grid can scroll no further.
|
|
/// </summary>
|
|
[Fact]
|
|
public async Task TheSessionsGridBuildsTheRowsOnScreenAndHandsTheWheelOnAtItsEnd()
|
|
{
|
|
await using ScratchLedger s = await ScratchLedger.OpenAsync();
|
|
GameRow game = await s.GameAsync("Alpha");
|
|
for (int i = 0; i < 100; i++)
|
|
{
|
|
await s.SessionAsync(game.Id, DateTimeOffset.UtcNow.AddHours(-i - 1));
|
|
}
|
|
|
|
var detail = new GameDetailViewModel(s.Library, new GameSelection { GameId = game.Id }, new HookingConsent(new NoAgent(), new NoPrompt()), new NoNavigation(),
|
|
new NoConfirm(), new NoEdit(), new NoStrip(), new NoSummaries(), new SessionSeriesLoader(s.Sessions),
|
|
new SqliteHardwareSnapshotRepository(s.Db), new SessionSelection(), new NoPicker());
|
|
Task pending = detail.Pending;
|
|
await pending;
|
|
|
|
(int Rows, double PageBefore, double PageAfter, double GridOffset) result = await OnStaAsync(() =>
|
|
{
|
|
var page = new GameDetailPage(detail);
|
|
NavigationViewContentPresenter presenter = Navigated(page, 900);
|
|
int rows = Visuals.FindAll<DataGridRow>(page).Count();
|
|
System.Windows.Controls.DataGrid grid = Visuals.Find<System.Windows.Controls.DataGrid>(page)!;
|
|
ScrollViewer gridScroller = Visuals.Find<ScrollViewer>(grid)!;
|
|
ScrollViewer root = Visuals.Find<ScrollViewer>(page)!;
|
|
gridScroller.ScrollToEnd();
|
|
presenter.UpdateLayout();
|
|
double before = root.VerticalOffset;
|
|
Wheel(Visuals.Leaf(Visuals.FindAll<DataGridRow>(grid).Last()), -120);
|
|
presenter.UpdateLayout();
|
|
return (rows, before, root.VerticalOffset, gridScroller.VerticalOffset);
|
|
});
|
|
|
|
detail.Sessions.Should().HaveCount(100);
|
|
result.Rows.Should().BeInRange(1, 40, "only the rows the bounded grid shows are built");
|
|
result.GridOffset.Should().BeGreaterThan(0, "the grid scrolls its own rows");
|
|
result.PageAfter.Should().BeGreaterThan(result.PageBefore, "at the grid's end the wheel scrolls the page");
|
|
}
|
|
}
|