Translate suicide response 0x004A as retail's successful self-kill notice. Port /framerate onto the authored SmartBox FPS element with live two-decimal FPS and DEG values, keep diagnostic window chrome independent, and synchronize command-driven settings without discarding panel drafts. Co-Authored-By: Codex <codex@openai.com>
73 lines
2.5 KiB
C#
73 lines
2.5 KiB
C#
using AcDream.UI.Abstractions.Panels.Settings;
|
||
|
||
namespace AcDream.UI.Abstractions.Tests.Panels.Settings;
|
||
|
||
/// <summary>
|
||
/// L.0: <see cref="DisplaySettings"/> is the immutable record of
|
||
/// display-tab preferences. Defaults are pinned here so a regression
|
||
/// (e.g. someone changing the default FOV out from under users)
|
||
/// surfaces immediately.
|
||
/// </summary>
|
||
public sealed class DisplaySettingsTests
|
||
{
|
||
[Fact]
|
||
public void Default_values_match_pre_L0_runtime_state()
|
||
{
|
||
// Defaults pinned to match the actual pre-L.0 startup state:
|
||
// · Resolution matches WindowOptions (1280×720 in GameWindow.Run)
|
||
// · FieldOfView matches camera FovY (60° = π/3)
|
||
// · VSync matches WindowOptions (false during dev)
|
||
// · ShowFps false matches retail's initially-hidden SmartBox meter
|
||
var d = DisplaySettings.Default;
|
||
Assert.Equal("1280x720", d.Resolution);
|
||
Assert.False(d.Fullscreen);
|
||
Assert.False(d.VSync);
|
||
Assert.Equal(60f, d.FieldOfView);
|
||
Assert.Equal(1.0f, d.Gamma);
|
||
Assert.False(d.ShowFps);
|
||
}
|
||
|
||
[Fact]
|
||
public void AvailableResolutions_includes_common_16_9_options()
|
||
{
|
||
var list = DisplaySettings.AvailableResolutions;
|
||
Assert.Contains("1280x720", list);
|
||
Assert.Contains("1920x1080", list);
|
||
Assert.Contains("2560x1440", list);
|
||
Assert.Contains("3840x2160", list);
|
||
// List should be ascending so the dropdown reads naturally.
|
||
for (int i = 1; i < list.Count; i++)
|
||
{
|
||
int prevW = ParseWidth(list[i - 1]);
|
||
int curW = ParseWidth(list[i]);
|
||
Assert.True(curW >= prevW, $"Resolutions not sorted: {list[i - 1]} >= {list[i]}");
|
||
}
|
||
}
|
||
|
||
[Fact]
|
||
public void Equality_is_value_based()
|
||
{
|
||
var a = DisplaySettings.Default;
|
||
var b = DisplaySettings.Default with { Fullscreen = true };
|
||
var c = DisplaySettings.Default with { Fullscreen = true };
|
||
Assert.NotEqual(a, b);
|
||
Assert.Equal(b, c);
|
||
}
|
||
|
||
[Fact]
|
||
public void With_expression_clones_one_field()
|
||
{
|
||
var d = DisplaySettings.Default with { FieldOfView = 90f };
|
||
Assert.Equal(90f, d.FieldOfView);
|
||
// Other fields untouched.
|
||
Assert.Equal("1280x720", d.Resolution);
|
||
Assert.False(d.VSync);
|
||
Assert.False(d.ShowFps);
|
||
}
|
||
|
||
private static int ParseWidth(string res)
|
||
{
|
||
int x = res.IndexOf('x');
|
||
return int.Parse(res.AsSpan(0, x));
|
||
}
|
||
}
|