SandboxTest changes (#18595)

This commit is contained in:
Leon Friedrich
2023-08-07 09:15:09 +12:00
committed by GitHub
parent 782ef6918c
commit 9af3c8862b

View File

@@ -1,3 +1,11 @@
using Content.Client.IoC;
using Content.Client.Parallax.Managers;
using Robust.Client;
using Robust.Shared.Configuration;
using Robust.Shared.ContentPack;
using Robust.Shared.IoC;
using Robust.Shared.Log;
using Robust.UnitTesting;
namespace Content.IntegrationTests.Tests.Utility; namespace Content.IntegrationTests.Tests.Utility;
@@ -6,9 +14,41 @@ public sealed class SandboxTest
[Test] [Test]
public async Task Test() public async Task Test()
{ {
await using var pairTracker = await PoolManager.GetServerClient(new PoolSettings { Destructive = true }); // Not using PoolManager.GetServerClient() because we want to avoid having to unnecessarily create & destroy a
var client = pairTracker.Pair.Client; // server. This all becomes unnecessary if ever the test becomes non-destructive or the no-server option
// actually creates a pair without a server.
var logHandler = new PoolTestLogHandler("CLIENT");
logHandler.ActivateContext(TestContext.Out);
var options = new RobustIntegrationTest.ClientIntegrationOptions
{
ContentStart = true,
OverrideLogHandler = () => logHandler,
ContentAssemblies = new[]
{
typeof(Shared.Entry.EntryPoint).Assembly,
typeof(Client.Entry.EntryPoint).Assembly
},
Options = new GameControllerOptions { LoadConfigAndUserData = false }
};
options.BeforeStart += () =>
{
IoCManager.Resolve<IModLoader>().SetModuleBaseCallbacks(new ClientModuleTestingCallbacks
{
ClientBeforeIoC = () =>
{
IoCManager.Register<IParallaxManager, DummyParallaxManager>(true);
IoCManager.Resolve<ILogManager>().GetSawmill("loc").Level = LogLevel.Error;
IoCManager.Resolve<IConfigurationManager>()
.OnValueChanged(RTCVars.FailureLogLevel, value => logHandler.FailureLevel = value, true);
}
});
};
using var client = new RobustIntegrationTest.ClientIntegrationInstance(options);
await client.WaitIdleAsync();
await client.CheckSandboxed(typeof(Client.Entry.EntryPoint).Assembly); await client.CheckSandboxed(typeof(Client.Entry.EntryPoint).Assembly);
await pairTracker.CleanReturnAsync(); await client.CheckSandboxed(typeof(Shared.IoC.SharedContentIoC).Assembly);
} }
} }