using System.Reflection;
using AcDream.App.Rendering;
using AcDream.App.Tests.Architecture;
namespace AcDream.App.Tests.Rendering;
public sealed class RetailPViewRendererTests
{
///
/// S4-c2 fix round 1 addendum (A1): retail's LandscapeFlush
/// (PView::DrawCells @0x005a4840's own FlushAlphaList(0f)
/// @0x005a4872) only ever fires on an INTERIOR PView, strictly inside
/// if (outside_view.view_count > 0) — an outdoor root never
/// reaches it (terrace-edge's capture: zero 005a4877 FL lines).
/// In production the interior case reaches
/// through the
/// walk driver's LandscapeFlush leaf (FlushWalkLandscape, a
/// SEPARATE method the driver calls during Replay) — never as a
/// direct call compiled into 's
/// own body. The outdoor-root direct call that used to sit inline here
/// (mislabelled LandscapeFlush) is deleted; retail's real outdoor-root
/// drains are the DrawBlock 0.75 valve (already wired via
/// WalkFrameEventKind.SortCellExit) and
/// SmartBox::RenderNormalMode's pass-end flush
/// (, called from
/// WorldSceneRenderer.CompleteWorldFrame).
///
/// Mutation check: reverting the deletion (restoring
/// if (ctx.RootCell.IsOutdoorNode) passes.FlushLandscapeAlpha();)
/// reintroduces a direct call to
/// inside
/// 's compiled body — the
/// Assert.DoesNotContain below fails against that mutation.
///
[Fact]
public void DrawInside_NeverCallsFlushLandscapeAlphaDirectly()
{
MethodInfo drawInside = typeof(RetailPViewRenderer).GetMethod(
"DrawInside",
BindingFlags.Instance | BindingFlags.NonPublic | BindingFlags.Public)!;
IReadOnlyList calls = CompiledCallGraph.Read(drawInside);
Assert.DoesNotContain(
calls,
call => call.Target.DeclaringType == typeof(RetailPViewPassExecutor)
&& call.Target.Name == nameof(RetailPViewPassExecutor.FlushLandscapeAlpha));
// The interior-cell unattached-emitter draw beside the deleted call
// must remain — this pin only removes the mislabelled flush, not
// the particle submission next to it.
Assert.Contains(
calls,
call => call.Target.DeclaringType == typeof(RetailPViewPassExecutor)
&& call.Target.Name == nameof(RetailPViewPassExecutor.DrawUnattachedSceneParticles));
}
}