EnterChaseMode now takes (ChaseCamera, RetailChaseCamera); Active consults CameraDiagnostics.UseRetailChaseCamera to pick which to expose. Flag flip at runtime swaps cameras instantly (both are kept warm). GameWindow's two EnterChaseMode call sites get a temporary stub RetailChaseCamera; Task 7 wires proper construction + per-frame updates. Also folds in two minor cleanups from the Task 3 code review: - Update() discards the unused `right` axis from BuildBasis (no caller in the chase-cam math; viewer_offset.X is always 0) - The three CameraDiagnostics-mutating integration tests now save and restore the static state in try/finally to avoid ordering-dependent contamination Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
67 lines
1.9 KiB
C#
67 lines
1.9 KiB
C#
using System.Numerics;
|
|
using AcDream.App.Rendering;
|
|
using AcDream.Core.Rendering;
|
|
using Xunit;
|
|
|
|
namespace AcDream.App.Tests.Rendering;
|
|
|
|
public class CameraControllerTests
|
|
{
|
|
private static (CameraController ctl, ChaseCamera legacy, RetailChaseCamera retail) MakeChaseFixture()
|
|
{
|
|
var orbit = new OrbitCamera();
|
|
var fly = new FlyCamera();
|
|
var ctl = new CameraController(orbit, fly);
|
|
var legacy = new ChaseCamera();
|
|
var retail = new RetailChaseCamera();
|
|
ctl.EnterChaseMode(legacy, retail);
|
|
return (ctl, legacy, retail);
|
|
}
|
|
|
|
[Fact]
|
|
public void ChaseMode_WhenFlagOff_ActiveIsLegacy()
|
|
{
|
|
CameraDiagnostics.UseRetailChaseCamera = false;
|
|
var (ctl, legacy, _) = MakeChaseFixture();
|
|
Assert.Same(legacy, ctl.Active);
|
|
Assert.True(ctl.IsChaseMode);
|
|
}
|
|
|
|
[Fact]
|
|
public void ChaseMode_WhenFlagOn_ActiveIsRetail()
|
|
{
|
|
CameraDiagnostics.UseRetailChaseCamera = true;
|
|
var (ctl, _, retail) = MakeChaseFixture();
|
|
Assert.Same(retail, ctl.Active);
|
|
Assert.True(ctl.IsChaseMode);
|
|
|
|
// Reset.
|
|
CameraDiagnostics.UseRetailChaseCamera = false;
|
|
}
|
|
|
|
[Fact]
|
|
public void ChaseMode_FlagFlipped_ActiveSwaps()
|
|
{
|
|
CameraDiagnostics.UseRetailChaseCamera = false;
|
|
var (ctl, legacy, retail) = MakeChaseFixture();
|
|
Assert.Same(legacy, ctl.Active);
|
|
|
|
CameraDiagnostics.UseRetailChaseCamera = true;
|
|
Assert.Same(retail, ctl.Active);
|
|
|
|
CameraDiagnostics.UseRetailChaseCamera = false;
|
|
Assert.Same(legacy, ctl.Active);
|
|
}
|
|
|
|
[Fact]
|
|
public void ExitChaseMode_ClearsBothCameras()
|
|
{
|
|
CameraDiagnostics.UseRetailChaseCamera = false;
|
|
var (ctl, _, _) = MakeChaseFixture();
|
|
ctl.ExitChaseMode();
|
|
|
|
Assert.Null(ctl.Chase);
|
|
Assert.Null(ctl.RetailChase);
|
|
Assert.False(ctl.IsChaseMode);
|
|
}
|
|
}
|