Four new InputAction entries for held-key offset integration (CameraZoomIn/Out, CameraRaise/Lower; default unbound). Six new DebugVM mirror properties forwarding to CameraDiagnostics so the upcoming "Chase camera" DebugPanel section can drive them live. Also folds in four small cleanups from the Task 4 code review: - Both CameraDiagnostics-mutating tests in CameraControllerTests now use try/finally save/restore (consistency with Task-3 follow-up B) - Drop unused `using System.Numerics` from CameraControllerTests - Reword the XML doc on CameraController.Active to explain WHY both cameras are held simultaneously (flag flip takes effect on the next Active access without re-entry) rather than restating the getter logic Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
95 lines
2.6 KiB
C#
95 lines
2.6 KiB
C#
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()
|
|
{
|
|
bool saved = CameraDiagnostics.UseRetailChaseCamera;
|
|
try
|
|
{
|
|
CameraDiagnostics.UseRetailChaseCamera = false;
|
|
var (ctl, legacy, _) = MakeChaseFixture();
|
|
Assert.Same(legacy, ctl.Active);
|
|
Assert.True(ctl.IsChaseMode);
|
|
}
|
|
finally
|
|
{
|
|
CameraDiagnostics.UseRetailChaseCamera = saved;
|
|
}
|
|
}
|
|
|
|
[Fact]
|
|
public void ChaseMode_WhenFlagOn_ActiveIsRetail()
|
|
{
|
|
bool saved = CameraDiagnostics.UseRetailChaseCamera;
|
|
try
|
|
{
|
|
CameraDiagnostics.UseRetailChaseCamera = true;
|
|
var (ctl, _, retail) = MakeChaseFixture();
|
|
Assert.Same(retail, ctl.Active);
|
|
Assert.True(ctl.IsChaseMode);
|
|
}
|
|
finally
|
|
{
|
|
CameraDiagnostics.UseRetailChaseCamera = saved;
|
|
}
|
|
}
|
|
|
|
[Fact]
|
|
public void ChaseMode_FlagFlipped_ActiveSwaps()
|
|
{
|
|
bool saved = CameraDiagnostics.UseRetailChaseCamera;
|
|
try
|
|
{
|
|
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);
|
|
}
|
|
finally
|
|
{
|
|
CameraDiagnostics.UseRetailChaseCamera = saved;
|
|
}
|
|
}
|
|
|
|
[Fact]
|
|
public void ExitChaseMode_ClearsBothCameras()
|
|
{
|
|
bool saved = CameraDiagnostics.UseRetailChaseCamera;
|
|
try
|
|
{
|
|
CameraDiagnostics.UseRetailChaseCamera = false;
|
|
var (ctl, _, _) = MakeChaseFixture();
|
|
ctl.ExitChaseMode();
|
|
|
|
Assert.Null(ctl.Chase);
|
|
Assert.Null(ctl.RetailChase);
|
|
Assert.False(ctl.IsChaseMode);
|
|
}
|
|
finally
|
|
{
|
|
CameraDiagnostics.UseRetailChaseCamera = saved;
|
|
}
|
|
}
|
|
}
|