Completes Phase 5 (Polish): - Home dashboard (default screen): recent commands, pinned favorites, and a read-only system-status widget (Windows + build, RAM, system drive, uptime) via ISystemInfoService. Status is read locally with no process spawn, no elevation and no network (golden rules). - Favorites: pin/unpin from the list + detail star, persisted by id in config.json; a Favorites sidebar item filters the catalog to pins. - Recent commands: last 10 run command ids tracked for Home. - Window placement: persist + restore size/position/maximized, clamped to the virtual screen so a stale multi-monitor position never lands off-screen. - Accessibility: AutomationProperties.Name on new controls + palette and confirmation inputs; heading semantics on Home; Ctrl+H opens Home. Implementation notes: - ISystemInfoService uses Environment.OSVersion + CsWin32 GlobalMemoryStatusEx + DriveInfo + TickCount64 (AllowUnsafeBlocks for the generated interop). - Pure, unit-tested helpers RecentCommands.Add / Favorites.Toggle and WindowPlacement.IsOnScreen. - 102 tests pass; 0-warning Release build. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
42 lines
1.6 KiB
C#
42 lines
1.6 KiB
C#
using CommandForge.Wpf.Views;
|
|
|
|
namespace CommandForge.Tests;
|
|
|
|
/// <summary>Tests the off-screen guard used when restoring a saved window position.</summary>
|
|
public sealed class WindowPlacementTests
|
|
{
|
|
// A single 1920x1080 monitor at the origin.
|
|
private const double VsLeft = 0;
|
|
private const double VsTop = 0;
|
|
private const double VsWidth = 1920;
|
|
private const double VsHeight = 1080;
|
|
|
|
[Fact]
|
|
public void IsOnScreen_True_ForFullyVisibleWindow()
|
|
=> Assert.True(WindowPlacement.IsOnScreen(100, 100, 800, 600, VsLeft, VsTop, VsWidth, VsHeight));
|
|
|
|
[Fact]
|
|
public void IsOnScreen_False_WhenTitleBarAboveTop()
|
|
=> Assert.False(WindowPlacement.IsOnScreen(100, -200, 800, 600, VsLeft, VsTop, VsWidth, VsHeight));
|
|
|
|
[Fact]
|
|
public void IsOnScreen_False_WhenOnlyASliverIsVisibleOnTheRight()
|
|
=> Assert.False(WindowPlacement.IsOnScreen(1900, 100, 800, 600, VsLeft, VsTop, VsWidth, VsHeight));
|
|
|
|
[Fact]
|
|
public void IsOnScreen_True_OnSecondaryMonitorWithNegativeLeft()
|
|
{
|
|
// Two monitors: a left one at negative coordinates plus the primary.
|
|
const double virtualLeft = -1920;
|
|
const double virtualWidth = 3840;
|
|
Assert.True(WindowPlacement.IsOnScreen(-1800, 100, 800, 600, virtualLeft, VsTop, virtualWidth, VsHeight));
|
|
}
|
|
|
|
[Fact]
|
|
public void IsOnScreen_False_WhenSavedMonitorIsNowDisconnected()
|
|
{
|
|
// Position was saved on a left monitor that is no longer present (virtual screen is now the primary only).
|
|
Assert.False(WindowPlacement.IsOnScreen(-1800, 100, 800, 600, VsLeft, VsTop, VsWidth, VsHeight));
|
|
}
|
|
}
|