From 39d5000a2c545607f5c94cd391b594e7b096223c Mon Sep 17 00:00:00 2001 From: Matthew Mott Date: Wed, 24 Feb 2021 20:27:16 +0000 Subject: [PATCH] #5546: add failing test to capture issue OverrideEClassColour test confirms that adding an override for 'light' correctly changes the colour of 'light' itself but not its subclasses. --- test/Entity.cpp | 26 ++++++++++++++++++++++++++ 1 file changed, 26 insertions(+) diff --git a/test/Entity.cpp b/test/Entity.cpp index a49a44fe4b..acdb6d3173 100644 --- a/test/Entity.cpp +++ b/test/Entity.cpp @@ -7,6 +7,7 @@ #include "iselection.h" #include "ishaders.h" #include "icolourscheme.h" +#include "ieclasscolours.h" #include "render/NopVolumeTest.h" #include "string/convert.h" @@ -507,6 +508,31 @@ TEST_F(EntityTest, OverrideLightVolumeColour) registry::setValue(colours::RKEY_OVERRIDE_LIGHTCOL, false); } +TEST_F(EntityTest, OverrideEClassColour) +{ + auto light = createByClassName("light"); + auto torch = createByClassName("light_torchflame_small"); + auto lightCls = light->getEntity().getEntityClass(); + auto torchCls = torch->getEntity().getEntityClass(); + + static const Vector3 GREEN(0, 1, 0); + static const Vector3 YELLOW(1, 0, 1); + + // Light has an explicit green editor_color + EXPECT_EQ(lightCls->getColour(), GREEN); + + // This class does not have an explicit editor_color value, but should + // inherit the one from 'light'. + EXPECT_EQ(torchCls->getColour(), GREEN); + + // Set an override for the 'light' class + GlobalEclassColourManager().addOverrideColour("light", YELLOW); + + // Both 'light' and its subclasses should have the new colour + EXPECT_EQ(lightCls->getColour(), YELLOW); + EXPECT_EQ(torchCls->getColour(), YELLOW); +} + TEST_F(EntityTest, FuncStaticLocalToWorld) { auto funcStatic = createByClassName("func_static");