test: replace composition source freezes

This commit is contained in:
Erik 2026-08-18 15:50:53 +02:00
parent caa5eb8b2b
commit 80c7b44457
8 changed files with 471 additions and 406 deletions

View file

@ -4,6 +4,7 @@ using AcDream.App.Composition;
using AcDream.App.Input;
using AcDream.App.Rendering;
using AcDream.App.Rendering.Gpu;
using AcDream.App.Tests.Architecture;
using AcDream.App.Tests.Rendering.Gpu;
using AcDream.UI.Abstractions.Input;
using Silk.NET.Input;
@ -67,21 +68,35 @@ public sealed class HostInputCameraCompositionTests
[Fact]
public void GameWindowUsesTheExactPlatformPreludeAndPhaseOneType()
{
string source = File.ReadAllText(Path.Combine(
FindRepoRoot(),
"src",
"AcDream.App",
"Rendering",
"GameWindow.cs"));
IReadOnlyList<CompiledCall> declaredCalls =
CompiledCallGraph.ReadDeclared(typeof(GameWindow));
Assert.Contains("GameWindowPlatformAcquisition.Acquire(", source,
StringComparison.Ordinal);
Assert.Contains("new HostInputCameraCompositionPhase(", source,
StringComparison.Ordinal);
Assert.DoesNotContain("_gl = GL.GetApi(_window!)", source,
StringComparison.Ordinal);
Assert.DoesNotContain("_input = _window!.CreateInput()", source,
StringComparison.Ordinal);
Assert.Single(
declaredCalls,
call => call.Target.DeclaringType
== typeof(GameWindowPlatformAcquisition)
&& call.Target.Name == nameof(GameWindowPlatformAcquisition.Acquire));
Assert.Single(
declaredCalls,
call => call.Target.DeclaringType
== typeof(HostInputCameraCompositionPhase)
&& call.Target.IsConstructor);
MethodInfo onLoad = typeof(GameWindow).GetMethod(
"OnLoad",
BindingFlags.Instance | BindingFlags.NonPublic)
?? throw new MissingMethodException(typeof(GameWindow).FullName, "OnLoad");
IReadOnlyList<CompiledCall> loadCalls = CompiledCallGraph.Read(onLoad);
Assert.Contains(
loadCalls,
call => call.Target.DeclaringType == typeof(GameWindow)
&& call.Target.Name == "AcquirePlatform");
Assert.Contains(
loadCalls,
call => call.Target.DeclaringType == typeof(GameWindowCompositionPipeline)
&& call.Target.Name == nameof(GameWindowCompositionPipeline.Run));
Assert.DoesNotContain(loadCalls, call => call.Target.Name == "GetApi");
Assert.DoesNotContain(loadCalls, call => call.Target.Name == "CreateInput");
}
private sealed class Fixture : IDisposable
@ -450,16 +465,4 @@ public sealed class HostInputCameraCompositionTests
public void WriteLine(string message) { }
}
private static string FindRepoRoot()
{
DirectoryInfo? directory = new(AppContext.BaseDirectory);
while (directory is not null)
{
if (File.Exists(Path.Combine(directory.FullName, "AcDream.slnx")))
return directory.FullName;
directory = directory.Parent;
}
throw new DirectoryNotFoundException("Could not find AcDream.slnx.");
}
}