Skip to content

Commit

Permalink
Test that entity updates when its entity class is modified
Browse files Browse the repository at this point in the history
Confirm that a light entity captures a new wireframe shader in response to a
colour change on its entity class. Currently we can't confirm that it's the
*right* shader because the Shader interface doesn't expose that much (the
result of getMaterial() will be null because this is a built-in single-colour
shader rather than one derived from a material).
  • Loading branch information
Matthew Mott committed Feb 2, 2021
1 parent 859ed64 commit b4b79b0
Showing 1 changed file with 25 additions and 0 deletions.
25 changes: 25 additions & 0 deletions test/Entity.cpp
Expand Up @@ -319,6 +319,31 @@ namespace
};
}

TEST_F(EntityTest, ModifyEntityClass)
{
auto cls = GlobalEntityClassManager().findClass("light");
auto light = GlobalEntityModule().createEntity(cls);
auto& spawnArgs = light->getEntity();

// Light doesn't initially have a colour set
RenderFixture rf;
light->setRenderSystem(rf.backend);
const ShaderPtr origWireShader = light->getWireShader();
ASSERT_TRUE(origWireShader);

// The shader shouldn't just change by itself (this would invalidate the
// test)
EXPECT_EQ(light->getWireShader(), origWireShader);

// Set a new colour value on the entity *class* (not the entity)
cls->setColour(Vector3(0.5, 0.24, 0.87));

// Shader should have changed due to the entity class update (although there
// aren't currently any public Shader properties that we can examine to
// confirm its contents)
EXPECT_NE(light->getWireShader(), origWireShader);
}

TEST_F(EntityTest, RenderUnselectedLightEntity)
{
auto light = createByClassName("light");
Expand Down

0 comments on commit b4b79b0

Please sign in to comment.