From e076d93e1f279db254756b86b2cea41671c1f275 Mon Sep 17 00:00:00 2001 From: Vince <39844191+Visne@users.noreply.github.com> Date: Tue, 18 Aug 2020 13:46:12 +0200 Subject: [PATCH] Add test for non abstract entities without icons (#1666) * Add test for non abstract entities without icons Fixes #575. Test will now fail if an entity is added that is not abstract but has no icon. Also added icons or made entities abstract that failed the test. No non abstract entities actually missed textures. Some notes: Changed name of "constructionghost" from "spooky ghost" to "construction ghost", and changed name of "AdminObserver" from "observer" to "admin observer" to avoid overlap in names. * Split up client side and server side tests --- Content.IntegrationTests/Tests/EntityTest.cs | 80 ++++++++++++------- .../Entities/Constructible/Power/turret.yml | 6 ++ .../Entities/Constructible/disposal.yml | 1 + .../Effects/Markers/construction_ghost.yml | 4 +- .../Entities/Effects/Markers/drag_shadow.yml | 1 + .../Entities/Effects/Markers/hover_entity.yml | 1 + .../Entities/Effects/Markers/pointing.yml | 3 + .../Entities/Mobs/Player/admin_ghost.yml | 2 + .../Entities/Mobs/Player/observer.yml | 1 + 9 files changed, 69 insertions(+), 30 deletions(-) diff --git a/Content.IntegrationTests/Tests/EntityTest.cs b/Content.IntegrationTests/Tests/EntityTest.cs index 4df604e4ad..639a2f78b6 100644 --- a/Content.IntegrationTests/Tests/EntityTest.cs +++ b/Content.IntegrationTests/Tests/EntityTest.cs @@ -19,7 +19,7 @@ namespace Content.IntegrationTests.Tests public class EntityTest : ContentIntegrationTest { [Test] - public async Task Test() + public async Task SpawnTest() { var server = StartServerDummyTicker(); await server.WaitIdleAsync(); @@ -41,43 +41,65 @@ namespace Content.IntegrationTests.Tests }); server.Assert(() => + { + var testLocation = new GridCoordinates(new Vector2(0, 0), grid); + + //Generate list of non-abstract prototypes to test + foreach (var prototype in prototypeMan.EnumeratePrototypes()) { - var testLocation = new GridCoordinates(new Vector2(0, 0), grid); - - //Generate list of non-abstract prototypes to test - foreach (var prototype in prototypeMan.EnumeratePrototypes()) + if (prototype.Abstract) { - if (prototype.Abstract) - { - continue; - } - prototypes.Add(prototype); + continue; + } + prototypes.Add(prototype); + } + + //Iterate list of prototypes to spawn + foreach (var prototype in prototypes) + { + try + { + Logger.LogS(LogLevel.Debug, "EntityTest", "Testing: " + prototype.ID); + testEntity = entityMan.SpawnEntity(prototype.ID, testLocation); + server.RunTicks(2); + Assert.That(testEntity.Initialized); + entityMan.DeleteEntity(testEntity.Uid); } - //Iterate list of prototypes to spawn - foreach (var prototype in prototypes) + //Fail any exceptions thrown on spawn + catch (Exception e) { - try - { - Logger.LogS(LogLevel.Debug, "EntityTest", "Testing: " + prototype.ID); - testEntity = entityMan.SpawnEntity(prototype.ID, testLocation); - server.RunTicks(2); - Assert.That(testEntity.Initialized); - entityMan.DeleteEntity(testEntity.Uid); - } - - //Fail any exceptions thrown on spawn - catch (Exception e) - { - Logger.LogS(LogLevel.Error, "EntityTest", "Entity '" + prototype.ID + "' threw: " + e.Message); - //Assert.Fail(); - throw; - } + Logger.LogS(LogLevel.Error, "EntityTest", "Entity '" + prototype.ID + "' threw: " + e.Message); + //Assert.Fail(); + throw; } - }); + } + }); await server.WaitIdleAsync(); } + [Test] + public async Task NotAbstractIconTest() + { + var client = StartClient(); + await client.WaitIdleAsync(); + var prototypeMan = client.ResolveDependency(); + + client.Assert(() => + { + foreach (var prototype in prototypeMan.EnumeratePrototypes()) + { + if (prototype.Abstract) + { + continue; + } + + Assert.That(prototype.Components.ContainsKey("Icon"), $"Entity {prototype.ID} does not have an Icon component, but is not abstract"); + } + }); + + await client.WaitIdleAsync(); + } } } diff --git a/Resources/Prototypes/Entities/Constructible/Power/turret.yml b/Resources/Prototypes/Entities/Constructible/Power/turret.yml index b7f7b86492..33be165066 100644 --- a/Resources/Prototypes/Entities/Constructible/Power/turret.yml +++ b/Resources/Prototypes/Entities/Constructible/Power/turret.yml @@ -9,6 +9,8 @@ - type: Collidable - type: Sprite texture: Constructible/Misc/TurrBase.png + - type: Icon + texture: Constructible/Misc/TurrBase.png - type: entity id: TurretTopGun @@ -23,6 +25,8 @@ drawdepth: WallMountedItems texture: Constructible/Misc/TurrTop.png directional: false + - type: Icon + texture: Constructible/Misc/TurrTop.png - type: entity id: TurretTopLight @@ -35,6 +39,8 @@ drawdepth: WallMountedItems texture: Constructible/Misc/TurrLamp.png directional: false + - type: Icon + texture: Constructible/Misc/TurrLamp.png - type: PointLight radius: 512 mask: flashlight_mask diff --git a/Resources/Prototypes/Entities/Constructible/disposal.yml b/Resources/Prototypes/Entities/Constructible/disposal.yml index 738ec4d1b7..f5fe46c91e 100644 --- a/Resources/Prototypes/Entities/Constructible/disposal.yml +++ b/Resources/Prototypes/Entities/Constructible/disposal.yml @@ -19,6 +19,7 @@ - type: entity id: DisposalHolder + abstract: true name: disposal holder components: - type: DisposalHolder diff --git a/Resources/Prototypes/Entities/Effects/Markers/construction_ghost.yml b/Resources/Prototypes/Entities/Effects/Markers/construction_ghost.yml index d6240e27fb..8a93730b3b 100644 --- a/Resources/Prototypes/Entities/Effects/Markers/construction_ghost.yml +++ b/Resources/Prototypes/Entities/Effects/Markers/construction_ghost.yml @@ -1,6 +1,7 @@ - type: entity - name: spooky ghost + name: construction ghost id: constructionghost + abstract: true components: - type: Sprite color: '#3F38' @@ -12,6 +13,7 @@ - type: entity name: somebody-messed-up frame id: structureconstructionframe + abstract: true components: - type: Sprite - type: Construction diff --git a/Resources/Prototypes/Entities/Effects/Markers/drag_shadow.yml b/Resources/Prototypes/Entities/Effects/Markers/drag_shadow.yml index 29643c4204..e8b4b568bb 100644 --- a/Resources/Prototypes/Entities/Effects/Markers/drag_shadow.yml +++ b/Resources/Prototypes/Entities/Effects/Markers/drag_shadow.yml @@ -1,6 +1,7 @@ - type: entity name: drag shadow id: dragshadow + abstract: true components: - type: Sprite layers: diff --git a/Resources/Prototypes/Entities/Effects/Markers/hover_entity.yml b/Resources/Prototypes/Entities/Effects/Markers/hover_entity.yml index f3eb6bc998..5ba4269602 100644 --- a/Resources/Prototypes/Entities/Effects/Markers/hover_entity.yml +++ b/Resources/Prototypes/Entities/Effects/Markers/hover_entity.yml @@ -1,6 +1,7 @@ - type: entity name: hover entity id: hoverentity + abstract: true components: - type: Sprite layers: diff --git a/Resources/Prototypes/Entities/Effects/Markers/pointing.yml b/Resources/Prototypes/Entities/Effects/Markers/pointing.yml index afceefcbc4..2d21b2804c 100644 --- a/Resources/Prototypes/Entities/Effects/Markers/pointing.yml +++ b/Resources/Prototypes/Entities/Effects/Markers/pointing.yml @@ -6,6 +6,9 @@ netsync: false sprite: Interface/Misc/pointing.rsi state: pointing + - type: Icon + sprite: Interface/Misc/pointing.rsi + state: pointing - type: PointingArrow duration: 4 step: 0.5 diff --git a/Resources/Prototypes/Entities/Mobs/Player/admin_ghost.yml b/Resources/Prototypes/Entities/Mobs/Player/admin_ghost.yml index 736f388b67..f559eaab3d 100644 --- a/Resources/Prototypes/Entities/Mobs/Player/admin_ghost.yml +++ b/Resources/Prototypes/Entities/Mobs/Player/admin_ghost.yml @@ -2,3 +2,5 @@ parent: MobObserver save: false id: AdminObserver + name: admin observer + abstract: true diff --git a/Resources/Prototypes/Entities/Mobs/Player/observer.yml b/Resources/Prototypes/Entities/Mobs/Player/observer.yml index ef8f085f0c..6fb36573fb 100644 --- a/Resources/Prototypes/Entities/Mobs/Player/observer.yml +++ b/Resources/Prototypes/Entities/Mobs/Player/observer.yml @@ -1,6 +1,7 @@ - type: entity id: MobObserver name: observer + abstract: true save: false description: Boo! components: