Add StorageInteractionTest (#28541)
This commit is contained in:
@@ -1,8 +1,10 @@
|
||||
#nullable enable
|
||||
using System.Diagnostics.CodeAnalysis;
|
||||
using System.Linq;
|
||||
using System.Numerics;
|
||||
using Content.Client.Construction;
|
||||
using Content.Client.Examine;
|
||||
using Content.Client.Gameplay;
|
||||
using Content.IntegrationTests.Pair;
|
||||
using Content.Server.Body.Systems;
|
||||
using Content.Server.Hands.Systems;
|
||||
@@ -24,6 +26,7 @@ using Robust.Shared.Prototypes;
|
||||
using Robust.Shared.Timing;
|
||||
using Robust.UnitTesting;
|
||||
using Content.Shared.Item.ItemToggle;
|
||||
using Robust.Client.State;
|
||||
|
||||
namespace Content.IntegrationTests.Tests.Interaction;
|
||||
|
||||
@@ -64,15 +67,12 @@ public abstract partial class InteractionTest
|
||||
/// The player entity that performs all these interactions. Defaults to an admin-observer with 1 hand.
|
||||
/// </summary>
|
||||
protected NetEntity Player;
|
||||
|
||||
protected EntityUid SPlayer => ToServer(Player);
|
||||
protected EntityUid CPlayer => ToClient(Player);
|
||||
protected EntityUid SPlayer;
|
||||
protected EntityUid CPlayer;
|
||||
|
||||
protected ICommonSession ClientSession = default!;
|
||||
protected ICommonSession ServerSession = default!;
|
||||
|
||||
public EntityUid? ClientTarget;
|
||||
|
||||
/// <summary>
|
||||
/// The current target entity. This is the default entity for various helper functions.
|
||||
/// </summary>
|
||||
@@ -108,6 +108,7 @@ public abstract partial class InteractionTest
|
||||
protected InteractionTestSystem STestSystem = default!;
|
||||
protected SharedTransformSystem Transform = default!;
|
||||
protected ISawmill SLogger = default!;
|
||||
protected SharedUserInterfaceSystem SUiSys = default!;
|
||||
|
||||
// CLIENT dependencies
|
||||
protected IEntityManager CEntMan = default!;
|
||||
@@ -119,6 +120,7 @@ public abstract partial class InteractionTest
|
||||
protected ExamineSystem ExamineSys = default!;
|
||||
protected InteractionTestSystem CTestSystem = default!;
|
||||
protected ISawmill CLogger = default!;
|
||||
protected SharedUserInterfaceSystem CUiSys = default!;
|
||||
|
||||
// player components
|
||||
protected HandsComponent Hands = default!;
|
||||
@@ -168,6 +170,7 @@ public abstract partial class InteractionTest
|
||||
STestSystem = SEntMan.System<InteractionTestSystem>();
|
||||
Stack = SEntMan.System<StackSystem>();
|
||||
SLogger = Server.ResolveDependency<ILogManager>().RootSawmill;
|
||||
SUiSys = Client.System<SharedUserInterfaceSystem>();
|
||||
|
||||
// client dependencies
|
||||
CEntMan = Client.ResolveDependency<IEntityManager>();
|
||||
@@ -179,6 +182,7 @@ public abstract partial class InteractionTest
|
||||
CConSys = CEntMan.System<ConstructionSystem>();
|
||||
ExamineSys = CEntMan.System<ExamineSystem>();
|
||||
CLogger = Client.ResolveDependency<ILogManager>().RootSawmill;
|
||||
CUiSys = Client.System<SharedUserInterfaceSystem>();
|
||||
|
||||
// Setup map.
|
||||
await Pair.CreateTestMap();
|
||||
@@ -204,15 +208,16 @@ public abstract partial class InteractionTest
|
||||
|
||||
old = cPlayerMan.LocalEntity;
|
||||
Player = SEntMan.GetNetEntity(SEntMan.SpawnEntity(PlayerPrototype, SEntMan.GetCoordinates(PlayerCoords)));
|
||||
var serverPlayerEnt = SEntMan.GetEntity(Player);
|
||||
Server.PlayerMan.SetAttachedEntity(ServerSession, serverPlayerEnt);
|
||||
Hands = SEntMan.GetComponent<HandsComponent>(serverPlayerEnt);
|
||||
DoAfters = SEntMan.GetComponent<DoAfterComponent>(serverPlayerEnt);
|
||||
SPlayer = SEntMan.GetEntity(Player);
|
||||
Server.PlayerMan.SetAttachedEntity(ServerSession, SPlayer);
|
||||
Hands = SEntMan.GetComponent<HandsComponent>(SPlayer);
|
||||
DoAfters = SEntMan.GetComponent<DoAfterComponent>(SPlayer);
|
||||
});
|
||||
|
||||
// Check player got attached.
|
||||
await RunTicks(5);
|
||||
Assert.That(CEntMan.GetNetEntity(cPlayerMan.LocalEntity), Is.EqualTo(Player));
|
||||
CPlayer = ToClient(Player);
|
||||
Assert.That(cPlayerMan.LocalEntity, Is.EqualTo(CPlayer));
|
||||
|
||||
// Delete old player entity.
|
||||
await Server.WaitPost(() =>
|
||||
@@ -235,6 +240,10 @@ public abstract partial class InteractionTest
|
||||
}
|
||||
});
|
||||
|
||||
// Change UI state to in-game.
|
||||
var state = Client.ResolveDependency<IStateManager>();
|
||||
await Client.WaitPost(() => state.RequestStateChange<GameplayState>());
|
||||
|
||||
// Final player asserts/checks.
|
||||
await Pair.ReallyBeIdle(5);
|
||||
Assert.Multiple(() =>
|
||||
|
||||
Reference in New Issue
Block a user