From: Tayrtahn Date: Sun, 23 Feb 2025 13:46:59 +0000 (-0500) Subject: Add interaction tests for prying airlocks (#35409) X-Git-Url: https://git.smokeofanarchy.ru/gitweb.cgi?a=commitdiff_plain;h=9cb65033199b1d1672f026e40c64ef0440a3c1d9;p=space-station-14.git Add interaction tests for prying airlocks (#35409) --- diff --git a/Content.IntegrationTests/Tests/Doors/AirlockPryingTest.cs b/Content.IntegrationTests/Tests/Doors/AirlockPryingTest.cs new file mode 100644 index 0000000000..135abb28dc --- /dev/null +++ b/Content.IntegrationTests/Tests/Doors/AirlockPryingTest.cs @@ -0,0 +1,84 @@ +using Content.IntegrationTests.Tests.Interaction; +using Content.Server.Doors.Systems; +using Content.Shared.Doors.Components; + +namespace Content.IntegrationTests.Tests.Doors; + +public sealed class AirlockPryingTest : InteractionTest +{ + [Test] + public async Task PoweredClosedAirlock_Pry_DoesNotOpen() + { + await SpawnTarget(Airlock); + await SpawnEntity("APCBasic", SEntMan.GetCoordinates(TargetCoords)); + + await RunTicks(1); + + Assert.That(TryComp(out var airlockComp), "Airlock does not have AirlockComponent?"); + Assert.That(airlockComp.Powered, "Airlock should be powered for this test."); + + Assert.That(TryComp(out var doorComp), "Airlock does not have DoorComponent?"); + Assert.That(doorComp.State, Is.EqualTo(DoorState.Closed), "Airlock did not start closed."); + + await InteractUsing(Pry); + + Assert.That(doorComp.State, Is.EqualTo(DoorState.Closed), "Powered airlock was pried open."); + } + + [Test] + public async Task PoweredOpenAirlock_Pry_DoesNotClose() + { + await SpawnTarget(Airlock); + await SpawnEntity("APCBasic", SEntMan.GetCoordinates(TargetCoords)); + + await RunTicks(1); + + Assert.That(TryComp(out var airlockComp), "Airlock does not have AirlockComponent?"); + Assert.That(airlockComp.Powered, "Airlock should be powered for this test."); + + var doorSys = SEntMan.System(); + await Server.WaitPost(() => doorSys.SetState(SEntMan.GetEntity(Target.Value), DoorState.Open)); + + Assert.That(TryComp(out var doorComp), "Airlock does not have DoorComponent?"); + Assert.That(doorComp.State, Is.EqualTo(DoorState.Open), "Airlock did not start open."); + + await InteractUsing(Pry); + + Assert.That(doorComp.State, Is.EqualTo(DoorState.Open), "Powered airlock was pried closed."); + } + + [Test] + public async Task UnpoweredClosedAirlock_Pry_Opens() + { + await SpawnTarget(Airlock); + + Assert.That(TryComp(out var airlockComp), "Airlock does not have AirlockComponent?"); + Assert.That(airlockComp.Powered, Is.False, "Airlock should not be powered for this test."); + + Assert.That(TryComp(out var doorComp), "Airlock does not have DoorComponent?"); + Assert.That(doorComp.State, Is.EqualTo(DoorState.Closed), "Airlock did not start closed."); + + await InteractUsing(Pry); + + Assert.That(doorComp.State, Is.EqualTo(DoorState.Opening), "Unpowered airlock failed to pry open."); + } + + [Test] + public async Task UnpoweredOpenAirlock_Pry_Closes() + { + await SpawnTarget(Airlock); + + Assert.That(TryComp(out var airlockComp), "Airlock does not have AirlockComponent?"); + Assert.That(airlockComp.Powered, Is.False, "Airlock should not be powered for this test."); + + var doorSys = SEntMan.System(); + await Server.WaitPost(() => doorSys.SetState(SEntMan.GetEntity(Target.Value), DoorState.Open)); + + Assert.That(TryComp(out var doorComp), "Airlock does not have DoorComponent?"); + Assert.That(doorComp.State, Is.EqualTo(DoorState.Open), "Airlock did not start open."); + + await InteractUsing(Pry); + + Assert.That(doorComp.State, Is.EqualTo(DoorState.Closing), "Unpowered airlock failed to pry closed."); + } +} diff --git a/Content.IntegrationTests/Tests/Interaction/InteractionTest.Constants.cs b/Content.IntegrationTests/Tests/Interaction/InteractionTest.Constants.cs index 11381fb8cc..aa58b30bf3 100644 --- a/Content.IntegrationTests/Tests/Interaction/InteractionTest.Constants.cs +++ b/Content.IntegrationTests/Tests/Interaction/InteractionTest.Constants.cs @@ -10,6 +10,9 @@ public abstract partial class InteractionTest protected const string Plating = "Plating"; protected const string Lattice = "Lattice"; + // Structures + protected const string Airlock = "Airlock"; + // Tools/steps protected const string Wrench = "Wrench"; protected const string Screw = "Screwdriver"; diff --git a/Content.Shared/Doors/Systems/SharedDoorSystem.cs b/Content.Shared/Doors/Systems/SharedDoorSystem.cs index a0d48b7d67..4d92cf9681 100644 --- a/Content.Shared/Doors/Systems/SharedDoorSystem.cs +++ b/Content.Shared/Doors/Systems/SharedDoorSystem.cs @@ -149,7 +149,7 @@ public abstract partial class SharedDoorSystem : EntitySystem RaiseLocalEvent(ent, new DoorStateChangedEvent(door.State)); } - protected bool SetState(EntityUid uid, DoorState state, DoorComponent? door = null) + public bool SetState(EntityUid uid, DoorState state, DoorComponent? door = null) { if (!Resolve(uid, ref door)) return false;