Skip to content

Commit

Permalink
#6003: One more test checking the IEntityClass:getVisibility() method…
Browse files Browse the repository at this point in the history
… result
  • Loading branch information
codereader committed Jul 22, 2022
1 parent a27f342 commit f05a410
Showing 1 changed file with 37 additions and 0 deletions.
37 changes: 37 additions & 0 deletions test/EntityClass.cpp
Expand Up @@ -10,6 +10,7 @@
#include "algorithm/Entity.h"
#include "algorithm/FileUtils.h"
#include "algorithm/Scene.h"
#include "testutil/TemporaryFile.h"

namespace test
{
Expand Down Expand Up @@ -413,6 +414,42 @@ TEST_F(EntityClassTest, EClassVisibilityIsNotInherited)
EXPECT_EQ(funcStatic->getVisibility(), vfs::Visibility::NORMAL);
}

TEST_F(EntityClassTest, RemovedEntityClassIsHidden)
{
// Create a temporary DEF file
TemporaryFile tempFile(_context.getTestProjectPath() + "def/temporary_file.def");

tempFile.setContents(R"(
entityDef someDefThatIsGoingToBeRemoved
{
"groundlevel" "11"
}
)");

// Reload the decls to find the new entityDef
GlobalDeclarationManager().reloadDeclarations();

auto eclass = GlobalEntityClassManager().findClass("someDefThatIsGoingToBeRemoved");
EXPECT_TRUE(eclass) << "Cannot find someDefThatIsGoingToBeRemoved";

// Remove the def from the file
tempFile.setContents(R"(
entityDef aReplacementDef
{
"groundlevel" "11"
}
)");

GlobalDeclarationManager().reloadDeclarations();

// the decl "someDefThatIsGoingToBeRemoved" should be there, but hidden
eclass = GlobalEntityClassManager().findClass("someDefThatIsGoingToBeRemoved");

EXPECT_TRUE(eclass) << "entityDef should still be registered after reloadDecls";
EXPECT_TRUE(eclass->getBlockSyntax().contents.empty()) << "entityDef should be empty after reloadDecls";
EXPECT_EQ(eclass->getVisibility(), vfs::Visibility::HIDDEN) << "entityDef should be hidden after reloadDecls";
}

TEST_F(EntityClassTest, GetAttributeValue)
{
auto eclass = GlobalEntityClassManager().findClass("attribute_type_test");
Expand Down

0 comments on commit f05a410

Please sign in to comment.