Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add some failing unit tests to check the material file name validatio…
…n requirements
- Loading branch information
1 parent
e129733
commit e14b83d
Showing
4 changed files
with
147 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,86 @@ | ||
#pragma once | ||
|
||
#include "RadiantTest.h" | ||
|
||
namespace test | ||
{ | ||
|
||
// Test context setting up a temporary FM folder | ||
class TdmMissionContext : | ||
public radiant::TestContext | ||
{ | ||
private: | ||
std::string _projectFolder; | ||
|
||
public: | ||
TdmMissionContext() | ||
{ | ||
// Set up the temporary settings folder | ||
_projectFolder = (os::getTemporaryPath() / "tdm_fm/").string(); | ||
|
||
os::removeDirectory(_projectFolder); | ||
os::makeDirectory(_projectFolder); | ||
} | ||
|
||
~TdmMissionContext() | ||
{ | ||
if (!_projectFolder.empty()) | ||
{ | ||
os::removeDirectory(_projectFolder); | ||
} | ||
} | ||
|
||
virtual std::string getTestProjectPath() const override | ||
{ | ||
return os::standardPathWithSlash(_projectFolder); | ||
} | ||
}; | ||
|
||
// Test setup using an empty FM to be used as TDM project config | ||
class TdmMissionSetup : | ||
public RadiantTest | ||
{ | ||
protected: | ||
TdmMissionContext _context; | ||
|
||
constexpr static const char* TestMissionName = "testfm"; | ||
constexpr static const char* MissionBasePath = "fms"; | ||
|
||
private: | ||
std::string _testFmPath; | ||
std::string _fmBasePath; | ||
|
||
protected: | ||
const std::string& getTestMissionPath() | ||
{ | ||
return _testFmPath; | ||
} | ||
|
||
virtual void setupGameFolder() override | ||
{ | ||
_fmBasePath = _context.getTestProjectPath() + MissionBasePath + "/"; | ||
_testFmPath = os::standardPathWithSlash(_fmBasePath + TestMissionName); | ||
|
||
os::makeDirectory(_fmBasePath); | ||
os::makeDirectory(_testFmPath); | ||
} | ||
|
||
virtual void TearDown() override | ||
{ | ||
os::removeDirectory(_fmBasePath); | ||
} | ||
|
||
virtual void handleGameConfigMessage(game::ConfigurationNeeded& message) override | ||
{ | ||
game::GameConfiguration config; | ||
|
||
config.gameType = "The Dark Mod 2.0 (Standalone)"; | ||
config.enginePath = _context.getTestProjectPath(); | ||
config.modPath = std::string(MissionBasePath) + "/" + TestMissionName; | ||
|
||
message.setConfig(config); | ||
message.setHandled(true); | ||
} | ||
}; | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters