Files
RobustToolbox/Robust.UnitTesting/Client/Graphics/EyeManagerTest.cs
T
metalgearslothandGitHub 209eb5fea0 Fix 90% of grid rotation bugs (#2003)
* View box2rotated

* Changes

* Stash someday

* Sync

* Grid rotation in a commit

* SIMD comment

* Minor TryFindGridAt optimisation

* More fixes

* Optimise rays a tad

* Reduce code duplication

* Fix anchoring

* More fixes woopsie

* Eye matching parent

* Centre of mass stuffsies

* Remove TODO

* Add TODO

* Revert anchor crash

* Fix master merge-in whoopsie

* Fixes

* Woops

* Fixed viewport transform

* Re-fix rendering
2021-09-16 12:59:16 +10:00

45 lines
1.5 KiB
C#

using System;
using System.Threading.Tasks;
using NUnit.Framework;
using Robust.Client.Graphics;
using Robust.Shared.Maths;
namespace Robust.UnitTesting.Client.Graphics
{
[TestFixture]
[TestOf(typeof(IEyeManager))]
public sealed class EyeManagerTest : RobustIntegrationTest
{
[Test]
public async Task TestViewportRotation()
{
// At cardinal rotations with a square viewport these should all be the same.
var client = StartClient();
await client.WaitIdleAsync();
var eyeManager = client.ResolveDependency<IEyeManager>();
await client.WaitAssertion(() =>
{
// At this stage integration tests aren't pooled so no way I'm making each of these a new test for now.
foreach (var angle in new[]
{
Angle.Zero,
new Angle(Math.PI / 4),
new Angle(Math.PI / 2),
new Angle(Math.PI),
new Angle(-Math.PI / 4),
new Angle(-Math.PI / 2),
new Angle(-Math.PI)
})
{
var worldAABB = eyeManager.GetWorldViewport();
var worldPort = eyeManager.GetWorldViewbounds();
Assert.That(worldAABB.EqualsApprox(worldPort.CalcBoundingBox()), $"Invalid EyeRotation bounds found for {angle}: Expected {worldAABB} and received {worldPort.CalcBoundingBox()}");
}
});
}
}
}