using System.IO;
using System.Text.Json;
using AcDream.App.UI.Layout;
namespace AcDream.App.Tests.UI.Layout;
///
/// Loads the committed vitals ElementInfo fixture and builds the widget tree —
/// no dats required. The fixture was generated from layout 0x2100006C
/// via the real portal.dat and serialized with .
///
public static class FixtureLoader
{
private static readonly JsonSerializerOptions _opts = new()
{
IncludeFields = true,
};
///
/// Deserializes the committed vitals_2100006C.json fixture (copied to
/// the test output directory via the csproj CopyToOutputDirectory item)
/// into an tree, then builds and returns the
/// using a null-returning sprite resolver and no
/// dat font — sufficient for conformance checks on tree structure and slice ids.
///
public static ImportedLayout LoadVitals()
{
var fixturePath = Path.Combine(AppContext.BaseDirectory, "UI", "Layout", "fixtures", "vitals_2100006C.json");
if (!File.Exists(fixturePath))
throw new FileNotFoundException($"Vitals fixture not found at: {fixturePath}");
var json = File.ReadAllText(fixturePath, System.Text.Encoding.UTF8);
var root = JsonSerializer.Deserialize(json, _opts)
?? throw new InvalidOperationException("Failed to deserialize vitals fixture.");
return LayoutImporter.Build(root, _ => (0u, 0, 0), null);
}
}