acdream/tests/AcDream.UI.Abstractions.Tests/Panels/Settings/DisplaySettingsTests.cs
Erik 749e8ceeb1 fix(rendering): bound portal resource lifetime
Separate logical ownership, render publication, and GPU retirement across live entities, landblocks, particles, textures, mesh arenas, portal/UI teardown, and per-frame scratch storage. Add bounded DAT/texture caches, upload budgets, three-frame fence retirement, exact-incarnation appearance reconciliation, frame pacing, and extensive lifetime conformance coverage.\n\nThe seven-destination connected route now cuts peak working/private memory roughly in half, returns Caul to 125-153 FPS locally, and produces no WER or AMD reset.\n\nCo-authored-by: OpenAI Codex <codex@openai.com>
2026-07-18 21:35:16 +02:00

73 lines
2.5 KiB
C#
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

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_normal_client_policy()
{
// Defaults pin the normal-client startup policy:
// · Resolution matches WindowOptions (1280×720 in GameWindow.Run)
// · FieldOfView matches camera FovY (60° = π/3)
// · VSync is on so normal presentation follows monitor refresh
// · ShowFps false matches retail's initially-hidden SmartBox meter
var d = DisplaySettings.Default;
Assert.Equal("1280x720", d.Resolution);
Assert.False(d.Fullscreen);
Assert.True(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.True(d.VSync);
Assert.False(d.ShowFps);
}
private static int ParseWidth(string res)
{
int x = res.IndexOf('x');
return int.Parse(res.AsSpan(0, x));
}
}