71 lines
2.2 KiB
C#
71 lines
2.2 KiB
C#
using System;
|
|
using System.Collections.Generic;
|
|
using System.Windows;
|
|
using Paca.App.Core;
|
|
using Xunit;
|
|
|
|
namespace Paca.Tests.App;
|
|
|
|
public class MultiDisplayLayoutEngineGateTests
|
|
{
|
|
[Fact]
|
|
public void Gate269_MultiDisplayLayoutEngine_ClampsWindow_WithinSingleMonitorBounds()
|
|
{
|
|
var workArea = new Rect(0, 0, 1920, 1080);
|
|
// Window 400x300 requested at (1800, 950) -> exceeds 1920 and 1080
|
|
var clamped = MultiDisplayLayoutEngine.ClampToWorkArea(
|
|
requestedLeft: 1800,
|
|
requestedTop: 950,
|
|
windowWidth: 400,
|
|
windowHeight: 300,
|
|
workArea: workArea,
|
|
margin: 16
|
|
);
|
|
|
|
Assert.Equal(1920 - 400 - 16, clamped.X);
|
|
Assert.Equal(1080 - 300 - 16, clamped.Y);
|
|
}
|
|
|
|
[Fact]
|
|
public void Gate270_MultiDisplayLayoutEngine_HandlesNegativeCoordinates_OnSecondaryLeftMonitor()
|
|
{
|
|
var leftMonitorWorkArea = new Rect(-1920, 0, 1920, 1080);
|
|
|
|
// Window 400x300 requested at -2000 (beyond left edge)
|
|
var clamped = MultiDisplayLayoutEngine.ClampToWorkArea(
|
|
requestedLeft: -2000,
|
|
requestedTop: 100,
|
|
windowWidth: 400,
|
|
windowHeight: 300,
|
|
workArea: leftMonitorWorkArea,
|
|
margin: 16
|
|
);
|
|
|
|
Assert.Equal(-1920 + 16, clamped.X);
|
|
Assert.Equal(100, clamped.Y);
|
|
}
|
|
|
|
[Fact]
|
|
public void Gate271_MultiDisplayLayoutEngine_ConvertsDpiToDips()
|
|
{
|
|
// Standard 96 DPI = 1.0 scale
|
|
Assert.Equal(100.0, MultiDisplayLayoutEngine.PixelsToDips(100, 96));
|
|
|
|
// 144 DPI (150% scaling) -> 150 pixels = 100 DIPs
|
|
Assert.Equal(100.0, MultiDisplayLayoutEngine.PixelsToDips(150, 144));
|
|
}
|
|
|
|
[Fact]
|
|
public void Gate272_MultiDisplayLayoutEngine_FindsBestScreen_ForWindow()
|
|
{
|
|
var screens = new List<Rect>
|
|
{
|
|
new(0, 0, 1920, 1080), // Primary screen
|
|
new(1920, 0, 1920, 1080) // Secondary screen to the right
|
|
};
|
|
|
|
// Window placed mostly on secondary screen (e.g. x=2000)
|
|
var bestScreen = MultiDisplayLayoutEngine.FindBestScreen(new Rect(2000, 200, 400, 300), screens);
|
|
Assert.Equal(1920, bestScreen.X);
|
|
}
|
|
}
|