]> git.smokeofanarchy.ru Git - space-station-14.git/commitdiff
Add an integration test for solution fill level sprites. (#28564)
authorTayrtahn <tayrtahn@gmail.com>
Tue, 4 Jun 2024 00:23:43 +0000 (20:23 -0400)
committerGitHub <noreply@github.com>
Tue, 4 Jun 2024 00:23:43 +0000 (10:23 +1000)
Content.IntegrationTests/Tests/FillLevelSpriteTest.cs [new file with mode: 0644]
Resources/Prototypes/Entities/Objects/Fun/darts.yml
Resources/Prototypes/Entities/Objects/Specific/chemistry.yml

diff --git a/Content.IntegrationTests/Tests/FillLevelSpriteTest.cs b/Content.IntegrationTests/Tests/FillLevelSpriteTest.cs
new file mode 100644 (file)
index 0000000..37e777f
--- /dev/null
@@ -0,0 +1,71 @@
+using System.Linq;
+using Content.Shared.Chemistry.Components;
+using Robust.Client.GameObjects;
+using Robust.Shared.GameObjects;
+using Robust.Shared.Prototypes;
+
+namespace Content.IntegrationTests.Tests;
+
+/// <summary>
+/// Tests to see if any entity prototypes specify solution fill level sprites that don't exist.
+/// </summary>
+[TestFixture]
+public sealed class FillLevelSpriteTest
+{
+    private static readonly string[] HandStateNames = ["left", "right"];
+
+    [Test]
+    public async Task FillLevelSpritesExist()
+    {
+        await using var pair = await PoolManager.GetServerClient();
+        var client = pair.Client;
+        var protoMan = client.ResolveDependency<IPrototypeManager>();
+        var componentFactory = client.ResolveDependency<IComponentFactory>();
+
+        await client.WaitAssertion(() =>
+        {
+            var protos = protoMan.EnumeratePrototypes<EntityPrototype>()
+                .Where(p => !p.Abstract)
+                .Where(p => !pair.IsTestPrototype(p))
+                .Where(p => p.TryGetComponent<SolutionContainerVisualsComponent>(out _, componentFactory))
+                .OrderBy(p => p.ID)
+                .ToList();
+
+            foreach (var proto in protos)
+            {
+                Assert.That(proto.TryGetComponent<SolutionContainerVisualsComponent>(out var visuals, componentFactory));
+                Assert.That(proto.TryGetComponent<SpriteComponent>(out var sprite, componentFactory));
+
+                var rsi = sprite.BaseRSI;
+
+                // Test base sprite fills
+                if (!string.IsNullOrEmpty(visuals.FillBaseName))
+                {
+                    for (var i = 1; i <= visuals.MaxFillLevels; i++)
+                    {
+                        var state = $"{visuals.FillBaseName}{i}";
+                        Assert.That(rsi.TryGetState(state, out _), @$"{proto.ID} has SolutionContainerVisualsComponent with
+                            MaxFillLevels = {visuals.MaxFillLevels}, but {rsi.Path} doesn't have state {state}!");
+                    }
+                }
+
+                // Test inhand sprite fills
+                if (!string.IsNullOrEmpty(visuals.InHandsFillBaseName))
+                {
+                    for (var i = 1; i <= visuals.InHandsMaxFillLevels; i++)
+                    {
+                        foreach (var handname in HandStateNames)
+                        {
+                            var state = $"inhand-{handname}{visuals.InHandsFillBaseName}{i}";
+                            Assert.That(rsi.TryGetState(state, out _), @$"{proto.ID} has SolutionContainerVisualsComponent with
+                                InHandsMaxFillLevels = {visuals.InHandsMaxFillLevels}, but {rsi.Path} doesn't have state {state}!");
+                        }
+
+                    }
+                }
+            }
+        });
+
+        await pair.CleanReturnAsync();
+    }
+}
index 36c841995e5c7bbdf070546bc7769edbd03fd734..c0b5eb33999d9b9b4b40ed151af578242d2ef056 100644 (file)
             max: 1
       - !type:DoActsBehavior
         acts: [ "Destruction" ]
-  - type: Appearance
-  - type: SolutionContainerVisuals
-    maxFillLevels: 1
-    fillBaseName: dart
 
 - type: entity
   parent: Dart
index ce0e0b629a3e605bdada7e90515c171941510500..dd15a90baa2384b774d7717ad817ed7a17e8e2f4 100644 (file)
     sprite: Objects/Specific/Chemistry/beaker_cryostasis.rsi
     layers:
       - state: beakernoreact
+  - type: SolutionContainerVisuals
+    maxFillLevels: 0
   - type: SolutionContainerManager
     solutions:
       beaker:
     sprite: Objects/Specific/Chemistry/beaker_bluespace.rsi
     layers:
       - state: beakerbluespace
+  - type: SolutionContainerVisuals
+    maxFillLevels: 0
   - type: SolutionContainerManager
     solutions:
       beaker: