Skip to content

Commit

Permalink
#5546: add failing test to capture issue
Browse files Browse the repository at this point in the history
OverrideEClassColour test confirms that adding an override for 'light'
correctly changes the colour of 'light' itself but not its subclasses.
  • Loading branch information
Matthew Mott committed Feb 24, 2021
1 parent d4e8fd7 commit 39d5000
Showing 1 changed file with 26 additions and 0 deletions.
26 changes: 26 additions & 0 deletions test/Entity.cpp
Expand Up @@ -7,6 +7,7 @@
#include "iselection.h"
#include "ishaders.h"
#include "icolourscheme.h"
#include "ieclasscolours.h"

#include "render/NopVolumeTest.h"
#include "string/convert.h"
Expand Down Expand Up @@ -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");
Expand Down

0 comments on commit 39d5000

Please sign in to comment.