Split PoolManager into separate classes. (#19370)

This commit is contained in:
Leon Friedrich
2023-08-23 00:14:01 +12:00
committed by GitHub
parent efdb756065
commit 89a287c1fd
19 changed files with 785 additions and 696 deletions

View File

@@ -146,7 +146,7 @@ namespace Content.IntegrationTests.Tests.Commands
Assert.That(sPlayerManager.Sessions.Count(), Is.EqualTo(0));
client.SetConnectTarget(server);
await client.WaitPost(() => netMan.ClientConnect(null!, 0, null!));
await PoolManager.ReallyBeIdle(pairTracker.Pair);
await pairTracker.RunTicksSync(5);
Assert.That(sPlayerManager.Sessions.Count(), Is.EqualTo(1));
await pairTracker.CleanReturnAsync();

View File

@@ -3,6 +3,7 @@ using System.Linq;
using System.Numerics;
using Content.Client.Construction;
using Content.Client.Examine;
using Content.IntegrationTests.Pair;
using Content.Server.Body.Systems;
using Content.Server.Mind;
using Content.Server.Players;
@@ -40,11 +41,11 @@ public abstract partial class InteractionTest
{
protected virtual string PlayerPrototype => "InteractionTestMob";
protected PairTracker PairTracker = default!;
protected TestMapData MapData = default!;
protected TestPair PairTracker = default!;
protected TestMapData MapData => PairTracker.TestMap!;
protected RobustIntegrationTest.ServerIntegrationInstance Server => PairTracker.Pair.Server;
protected RobustIntegrationTest.ClientIntegrationInstance Client => PairTracker.Pair.Client;
protected RobustIntegrationTest.ServerIntegrationInstance Server => PairTracker.Server;
protected RobustIntegrationTest.ClientIntegrationInstance Client => PairTracker.Client;
protected MapId MapId => MapData.MapId;
@@ -172,7 +173,7 @@ public abstract partial class InteractionTest
CLogger = Client.ResolveDependency<ILogManager>().RootSawmill;
// Setup map.
MapData = await PoolManager.CreateTestMap(PairTracker);
await PairTracker.CreateTestMap();
PlayerCoords = MapData.GridCoords.Offset(new Vector2(0.5f, 0.5f)).WithEntityId(MapData.MapUid, Transform, SEntMan);
TargetCoords = MapData.GridCoords.Offset(new Vector2(1.5f, 0.5f)).WithEntityId(MapData.MapUid, Transform, SEntMan);
await SetTile(Plating, grid: MapData.MapGrid);
@@ -225,7 +226,7 @@ public abstract partial class InteractionTest
});
// Final player asserts/checks.
await PoolManager.ReallyBeIdle(PairTracker.Pair, 5);
await PairTracker.ReallyBeIdle(5);
Assert.Multiple(() =>
{
Assert.That(cPlayerMan.LocalPlayer.ControlledEntity, Is.EqualTo(Player));

View File

@@ -1,4 +1,5 @@
using System.Linq;
using Content.IntegrationTests.Pair;
using Content.Server.Ghost.Components;
using Content.Server.Mind;
using Content.Server.Players;
@@ -23,7 +24,7 @@ public sealed partial class MindTests
/// the player's mind's current entity, likely because some previous test directly changed the players attached
/// entity.
/// </remarks>
private static async Task<PairTracker> SetupPair(bool dirty = false)
private static async Task<Pair.TestPair> SetupPair(bool dirty = false)
{
var pairTracker = await PoolManager.GetServerClient(new PoolSettings
{
@@ -61,7 +62,7 @@ public sealed partial class MindTests
return pairTracker;
}
private static async Task<EntityUid> BecomeGhost(Pair pair, bool visit = false)
private static async Task<EntityUid> BecomeGhost(TestPair pair, bool visit = false)
{
var entMan = pair.Server.ResolveDependency<IServerEntityManager>();
var playerMan = pair.Server.ResolveDependency<IPlayerManager>();
@@ -103,7 +104,7 @@ public sealed partial class MindTests
return ghostUid;
}
private static async Task<EntityUid> VisitGhost(Pair pair, bool _ = false)
private static async Task<EntityUid> VisitGhost(Pair.TestPair pair, bool _ = false)
{
return await BecomeGhost(pair, visit: true);
}
@@ -111,7 +112,7 @@ public sealed partial class MindTests
/// <summary>
/// Get the player's current mind and check that the entities exists.
/// </summary>
private static Mind GetMind(Pair pair)
private static Mind GetMind(Pair.TestPair pair)
{
var playerMan = pair.Server.ResolveDependency<IPlayerManager>();
var entMan = pair.Server.ResolveDependency<IEntityManager>();
@@ -130,7 +131,7 @@ public sealed partial class MindTests
return mind;
}
private static async Task Disconnect(Pair pair)
private static async Task Disconnect(Pair.TestPair pair)
{
var netManager = pair.Client.ResolveDependency<IClientNetManager>();
var playerMan = pair.Server.ResolveDependency<IPlayerManager>();
@@ -151,7 +152,7 @@ public sealed partial class MindTests
});
}
private static async Task Connect(Pair pair, string username)
private static async Task Connect(Pair.TestPair pair, string username)
{
var netManager = pair.Client.ResolveDependency<IClientNetManager>();
var playerMan = pair.Server.ResolveDependency<IPlayerManager>();
@@ -166,7 +167,7 @@ public sealed partial class MindTests
Assert.That(player.Status, Is.EqualTo(SessionStatus.InGame));
}
private static async Task<IPlayerSession> DisconnectReconnect(Pair pair)
private static async Task<IPlayerSession> DisconnectReconnect(Pair.TestPair pair)
{
var playerMan = pair.Server.ResolveDependency<IPlayerManager>();
var player = playerMan.ServerSessions.Single();

View File

@@ -60,8 +60,8 @@ namespace Content.IntegrationTests.Tests.Networking
});
// Run some ticks and ensure that the buffer has filled up.
await PoolManager.SyncTicks(pairTracker.Pair);
await PoolManager.RunTicksSync(pairTracker.Pair, 25);
await pairTracker.SyncTicks();
await pairTracker.RunTicksSync(25);
Assert.That(cGameTiming.TickTimingAdjustment, Is.EqualTo(0));
Assert.That(sGameTiming.TickTimingAdjustment, Is.EqualTo(0));

View File

@@ -137,8 +137,6 @@ namespace Content.IntegrationTests.Tests
roundEndSystem.DefaultCountdownDuration = TimeSpan.FromMinutes(4);
ticker.RestartRound();
});
await PoolManager.ReallyBeIdle(pairTracker.Pair, 10);
await pairTracker.CleanReturnAsync();
}
}

View File

@@ -19,7 +19,7 @@ public sealed class StackTest
Assert.Multiple(() =>
{
foreach (var entity in PoolManager.GetEntityPrototypes<StackComponent>(server))
foreach (var entity in PoolManager.GetPrototypesWithComponent<StackComponent>(server))
{
if (!entity.TryGetComponent<StackComponent>(out var stackComponent, compFact) ||
!entity.TryGetComponent<ItemComponent>(out var itemComponent, compFact))

View File

@@ -79,7 +79,7 @@ namespace Content.IntegrationTests.Tests
Assert.Multiple(() =>
{
foreach (var proto in PoolManager.GetEntityPrototypes<StorageFillComponent>(server))
foreach (var proto in PoolManager.GetPrototypesWithComponent<StorageFillComponent>(server))
{
int capacity;
var isEntStorage = false;

View File

@@ -1,5 +1,6 @@
#nullable enable
using System.Collections.Generic;
using Content.IntegrationTests.Pair;
using Content.Server.Administration.Managers;
using Robust.Server.Player;
using Robust.Shared.Players;
@@ -14,7 +15,7 @@ namespace Content.IntegrationTests.Tests.Toolshed;
[FixtureLifeCycle(LifeCycle.InstancePerTestCase)]
public abstract class ToolshedTest : IInvocationContext
{
protected PairTracker PairTracker = default!;
protected TestPair PairTracker = default!;
protected virtual bool Connected => false;
protected virtual bool AssertOnUnexpectedError => true;