StrippableTest.cs 1.4 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546
  1. using Content.Client.Interaction;
  2. using Content.IntegrationTests.Tests.Interaction;
  3. using Robust.Shared.GameObjects;
  4. using Robust.Shared.Input;
  5. using Robust.Shared.Map;
  6. namespace Content.IntegrationTests.Tests.Strip;
  7. public sealed class StrippableTest : InteractionTest
  8. {
  9. protected override string PlayerPrototype => "MobHuman";
  10. [Test]
  11. public async Task DragDropOpensStrip()
  12. {
  13. // Spawn one tile away
  14. TargetCoords = SEntMan.GetNetCoordinates(new EntityCoordinates(MapData.MapUid, 1, 0));
  15. await SpawnTarget("MobHuman");
  16. var userInterface = Comp<UserInterfaceComponent>(Target);
  17. Assert.That(userInterface.Actors.Count == 0);
  18. // screenCoordinates diff needs to be larger than DragDropSystem._deadzone
  19. var screenX = CEntMan.System<DragDropSystem>().Deadzone + 1f;
  20. // Start drag
  21. await SetKey(EngineKeyFunctions.Use,
  22. BoundKeyState.Down,
  23. TargetCoords,
  24. Target,
  25. screenCoordinates: new ScreenCoordinates(screenX, 0f, WindowId.Main));
  26. await RunTicks(5);
  27. // End drag
  28. await SetKey(EngineKeyFunctions.Use,
  29. BoundKeyState.Up,
  30. PlayerCoords,
  31. Player,
  32. screenCoordinates: new ScreenCoordinates(0f, 0f, WindowId.Main));
  33. await RunTicks(5);
  34. Assert.That(userInterface.Actors.Count > 0);
  35. }
  36. }