Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
Fix other unit tests due to changed behaviour of setShaderFileName()
  • Loading branch information
codereader committed Apr 18, 2021
1 parent 39bdf9a commit 32951bd
Show file tree
Hide file tree
Showing 7 changed files with 16 additions and 7 deletions.
1 change: 0 additions & 1 deletion radiantcore/shaders/Doom3ShaderSystem.cpp
Expand Up @@ -415,7 +415,6 @@ MaterialPtr Doom3ShaderSystem::copyMaterial(const std::string& nameOfOriginal, c

auto material = _library->findShader(candidate);
material->setIsModified();
material->setShaderFileName("");

return material;
}
Expand Down
6 changes: 5 additions & 1 deletion test/MaterialExport.cpp
Expand Up @@ -1215,6 +1215,10 @@ TEST_F(MaterialExportTest, WritingMaterialFiles)

// Create a new material, which is definitely not present in the file
auto newMaterial = GlobalMaterialManager().copyMaterial("textures/exporttest/renderBumpFlat1", "textures/exporttest/renderBumpX");
EXPECT_EQ(newMaterial->getShaderFileInfo().name, "");
EXPECT_EQ(newMaterial->getShaderFileInfo().topDir, "");
EXPECT_EQ(newMaterial->getShaderFileInfo().visibility, vfs::Visibility::HIDDEN);

newMaterial->setDescription(description);
newMaterial->setShaderFileName(exportTestFile.string());
EXPECT_TRUE(newMaterial->isModified());
Expand Down Expand Up @@ -1291,7 +1295,7 @@ TEST_F(MaterialExportTest_TdmMissionSetup, ShaderFilePathValidation)
EXPECT_THROW(newMaterial->setShaderFileName(tdmPath + "materials/exporttest.mtr2"), std::invalid_argument);

// FM setup says this is OK
auto missionPath = tdmPath + MaterialExportTest_TdmMissionSetup::MissionBasePath + "/" + MaterialExportTest_TdmMissionSetup::TestMissionName + "/";
auto missionPath = getTestMissionPath();
auto wrongMissionPath = tdmPath + MaterialExportTest_TdmMissionSetup::MissionBasePath + "/tork/";

EXPECT_NO_THROW(newMaterial->setShaderFileName(missionPath + "materials/exporttest.mtr"));
Expand Down
2 changes: 2 additions & 0 deletions test/Materials.cpp
Expand Up @@ -173,6 +173,8 @@ TEST_F(MaterialsTest, MaterialCopy)
EXPECT_EQ(material->getName(), "texures/copytest");
EXPECT_TRUE(materialManager.materialCanBeModified("texures/copytest"));
EXPECT_STREQ(material->getShaderFileName(), "");
EXPECT_EQ(material->getShaderFileInfo().name, "");
EXPECT_EQ(material->getShaderFileInfo().topDir, "");

// Check signal emission
EXPECT_EQ(firedNewName, "texures/copytest");
Expand Down
2 changes: 1 addition & 1 deletion test/RadiantTest.h
Expand Up @@ -128,7 +128,7 @@ class RadiantTest :
/// Override this to perform custom actions after the main module shuts down
virtual void postShutdown() {}

~RadiantTest()
virtual ~RadiantTest()
{
_coreModule->get()->getLogWriter().detach(_testLogFile.get());
_testLogFile->close();
Expand Down
6 changes: 4 additions & 2 deletions test/TdmMissionSetup.h
Expand Up @@ -22,7 +22,7 @@ class TdmMissionContext :
os::makeDirectory(_projectFolder);
}

~TdmMissionContext()
virtual ~TdmMissionContext()
{
if (!_projectFolder.empty())
{
Expand Down Expand Up @@ -68,6 +68,8 @@ class TdmMissionSetup :
virtual void TearDown() override
{
os::removeDirectory(_fmBasePath);

RadiantTest::TearDown();
}

virtual void handleGameConfigMessage(game::ConfigurationNeeded& message) override
Expand All @@ -76,7 +78,7 @@ class TdmMissionSetup :

config.gameType = "The Dark Mod 2.0 (Standalone)";
config.enginePath = _context.getTestProjectPath();
config.modPath = std::string(MissionBasePath) + "/" + TestMissionName;
config.modPath = getTestMissionPath();

message.setConfig(config);
message.setHandled(true);
Expand Down
2 changes: 1 addition & 1 deletion test/TestContext.h
Expand Up @@ -43,7 +43,7 @@ class TestContext :
});
}

~TestContext()
virtual ~TestContext()
{
if (!_settingsFolder.empty())
{
Expand Down
4 changes: 3 additions & 1 deletion test/WorldspawnColour.cpp
Expand Up @@ -30,7 +30,7 @@ class Quake4TestContext :
os::makeDirectory(_projectFolder);
}

~Quake4TestContext()
virtual ~Quake4TestContext()
{
if (!_projectFolder.empty())
{
Expand All @@ -57,6 +57,8 @@ class EmptyQuake4Setup :
protected:
virtual void setupGameFolder() override
{
RadiantTest::setupGameFolder();

// Create the q4base folder
os::makeDirectory(_context.getTestProjectPath() + "q4base");

Expand Down

0 comments on commit 32951bd

Please sign in to comment.