Add climb & slip tests (#15459)
This commit is contained in:
@@ -14,9 +14,12 @@ using Content.Shared.Hands.EntitySystems;
|
||||
using Content.Shared.Interaction;
|
||||
using NUnit.Framework;
|
||||
using Robust.Client.GameObjects;
|
||||
using Robust.Client.Input;
|
||||
using Robust.Client.UserInterface;
|
||||
using Robust.Server.Player;
|
||||
using Robust.Shared.GameObjects;
|
||||
using Robust.Shared.Map;
|
||||
using Robust.Shared.Players;
|
||||
using Robust.Shared.Prototypes;
|
||||
using Robust.Shared.Timing;
|
||||
using Robust.UnitTesting;
|
||||
@@ -34,6 +37,8 @@ namespace Content.IntegrationTests.Tests.Interaction;
|
||||
[FixtureLifeCycle(LifeCycle.InstancePerTestCase)]
|
||||
public abstract partial class InteractionTest
|
||||
{
|
||||
protected virtual string PlayerPrototype => "AdminObserver";
|
||||
|
||||
protected PairTracker PairTracker = default!;
|
||||
protected TestMapData MapData = default!;
|
||||
|
||||
@@ -59,6 +64,9 @@ public abstract partial class InteractionTest
|
||||
/// </summary>
|
||||
protected EntityUid Player;
|
||||
|
||||
protected ICommonSession ClientSession = default!;
|
||||
protected IPlayerSession ServerSession = default!;
|
||||
|
||||
/// <summary>
|
||||
/// The current target entity. This is the default entity for various helper functions.
|
||||
/// </summary>
|
||||
@@ -79,7 +87,7 @@ public abstract partial class InteractionTest
|
||||
protected ITileDefinitionManager TileMan = default!;
|
||||
protected IMapManager MapMan = default!;
|
||||
protected IPrototypeManager ProtoMan = default!;
|
||||
protected IGameTiming Timing = default!;
|
||||
protected IGameTiming STiming = default!;
|
||||
protected IComponentFactory Factory = default!;
|
||||
protected SharedHandsSystem HandSys = default!;
|
||||
protected StackSystem Stack = default!;
|
||||
@@ -92,16 +100,20 @@ public abstract partial class InteractionTest
|
||||
|
||||
// CLIENT dependencies
|
||||
protected IEntityManager CEntMan = default!;
|
||||
protected IGameTiming CTiming = default!;
|
||||
protected IUserInterfaceManager UiMan = default!;
|
||||
protected IInputManager InputManager = default!;
|
||||
protected InputSystem InputSystem = default!;
|
||||
protected ConstructionSystem CConSys = default!;
|
||||
protected ExamineSystem ExamineSys = default!;
|
||||
protected InteractionTestSystem CTestSystem = default!;
|
||||
protected UserInterfaceSystem CUISystem = default!;
|
||||
|
||||
// player components
|
||||
protected HandsComponent Hands = default!;
|
||||
protected DoAfterComponent DoAfters = default!;
|
||||
|
||||
public float TickPeriod => (float)Timing.TickPeriod.TotalSeconds;
|
||||
public float TickPeriod => (float)STiming.TickPeriod.TotalSeconds;
|
||||
|
||||
[SetUp]
|
||||
public virtual async Task Setup()
|
||||
@@ -114,7 +126,7 @@ public abstract partial class InteractionTest
|
||||
MapMan = Server.ResolveDependency<IMapManager>();
|
||||
ProtoMan = Server.ResolveDependency<IPrototypeManager>();
|
||||
Factory = Server.ResolveDependency<IComponentFactory>();
|
||||
Timing = Server.ResolveDependency<IGameTiming>();
|
||||
STiming = Server.ResolveDependency<IGameTiming>();
|
||||
HandSys = SEntMan.System<SharedHandsSystem>();
|
||||
InteractSys = SEntMan.System<SharedInteractionSystem>();
|
||||
ToolSys = SEntMan.System<ToolSystem>();
|
||||
@@ -127,6 +139,9 @@ public abstract partial class InteractionTest
|
||||
// client dependencies
|
||||
CEntMan = Client.ResolveDependency<IEntityManager>();
|
||||
UiMan = Client.ResolveDependency<IUserInterfaceManager>();
|
||||
CTiming = Client.ResolveDependency<IGameTiming>();
|
||||
InputManager = Client.ResolveDependency<IInputManager>();
|
||||
InputSystem = CEntMan.System<InputSystem>();
|
||||
CTestSystem = CEntMan.System<InteractionTestSystem>();
|
||||
CConSys = CEntMan.System<ConstructionSystem>();
|
||||
ExamineSys = CEntMan.System<ExamineSystem>();
|
||||
@@ -142,16 +157,16 @@ public abstract partial class InteractionTest
|
||||
var cPlayerMan = Client.ResolveDependency<Robust.Client.Player.IPlayerManager>();
|
||||
if (cPlayerMan.LocalPlayer?.Session == null)
|
||||
Assert.Fail("No player");
|
||||
var cSession = cPlayerMan.LocalPlayer!.Session!;
|
||||
var sSession = sPlayerMan.GetSessionByUserId(cSession.UserId);
|
||||
ClientSession = cPlayerMan.LocalPlayer!.Session!;
|
||||
ServerSession = sPlayerMan.GetSessionByUserId(ClientSession.UserId);
|
||||
|
||||
// Spawn player entity & attach
|
||||
EntityUid? old = default;
|
||||
await Server.WaitPost(() =>
|
||||
{
|
||||
old = cPlayerMan.LocalPlayer.ControlledEntity;
|
||||
Player = SEntMan.SpawnEntity(PlayerEntity, PlayerCoords);
|
||||
sSession.AttachToEntity(Player);
|
||||
Player = SEntMan.SpawnEntity(PlayerPrototype, PlayerCoords);
|
||||
ServerSession.AttachToEntity(Player);
|
||||
Hands = SEntMan.GetComponent<HandsComponent>(Player);
|
||||
DoAfters = SEntMan.GetComponent<DoAfterComponent>(Player);
|
||||
});
|
||||
@@ -189,7 +204,7 @@ public abstract partial class InteractionTest
|
||||
// Final player asserts/checks.
|
||||
await PoolManager.ReallyBeIdle(PairTracker.Pair, 5);
|
||||
Assert.That(cPlayerMan.LocalPlayer.ControlledEntity, Is.EqualTo(Player));
|
||||
Assert.That(sPlayerMan.GetSessionByUserId(cSession.UserId).AttachedEntity, Is.EqualTo(Player));
|
||||
Assert.That(sPlayerMan.GetSessionByUserId(ClientSession.UserId).AttachedEntity, Is.EqualTo(Player));
|
||||
}
|
||||
|
||||
[TearDown]
|
||||
|
||||
Reference in New Issue
Block a user