Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
#5977: Add empty implementation, define a few unit tests
- Loading branch information
1 parent
0f91058
commit 0aa291a
Showing
8 changed files
with
124 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,48 @@ | ||
#include "ideclmanager.h" | ||
|
||
#include "module/StaticModule.h" | ||
|
||
namespace decl | ||
{ | ||
|
||
class DeclarationManager : | ||
public IDeclarationManager | ||
{ | ||
public: | ||
void registerDeclType(const std::string& typeName, const IDeclarationParser::Ptr& parser) override | ||
{ | ||
|
||
} | ||
|
||
void unregisterDeclType(const std::string& typeName) override | ||
{ | ||
|
||
} | ||
|
||
void registerDeclFolder(Type defaultType, const std::string& vfsFolder, const std::string& extension) override | ||
{ | ||
|
||
} | ||
|
||
const std::string& getName() const override | ||
{ | ||
static std::string _name(MODULE_DECLMANAGER); | ||
return _name; | ||
} | ||
|
||
const StringSet& getDependencies() const override | ||
{ | ||
static StringSet _dependencies{}; | ||
|
||
return _dependencies; | ||
} | ||
|
||
void initialiseModule(const IApplicationContext& ctx) override | ||
{ | ||
rMessage() << getName() << "::initialiseModule called." << std::endl; | ||
} | ||
}; | ||
|
||
module::StaticModuleRegistration<DeclarationManager> _declManagerModule; | ||
|
||
} |
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,68 @@ | ||
#include "RadiantTest.h" | ||
|
||
#include "ideclmanager.h" | ||
|
||
namespace test | ||
{ | ||
|
||
using DeclManagerTest = RadiantTest; | ||
|
||
class TestDeclaration : | ||
public decl::IDeclaration | ||
{ | ||
public: | ||
const std::string& getName() const override | ||
{ | ||
static std::string _testName("TestName"); | ||
return _testName; | ||
} | ||
|
||
decl::Type getType() const override | ||
{ | ||
return decl::Type::Material; | ||
} | ||
}; | ||
|
||
class TestDeclarationParser : | ||
public decl::IDeclarationParser | ||
{ | ||
public: | ||
// Returns the declaration type this parser can handle | ||
decl::Type getDeclType() const override | ||
{ | ||
return decl::Type::Material; | ||
} | ||
|
||
// Create a new declaration instance from the given block | ||
decl::IDeclaration::Ptr parseFromBlock(const decl::DeclarationBlockSyntax& block) override | ||
{ | ||
return std::make_shared<TestDeclaration>(); | ||
} | ||
}; | ||
|
||
TEST_F(DeclManagerTest, DeclTypeRegistration) | ||
{ | ||
auto parser = std::make_shared<TestDeclarationParser>(); | ||
EXPECT_NO_THROW(GlobalDeclarationManager().registerDeclType("sometype", parser)); | ||
|
||
// Registering the same type name twice should result in an exception | ||
EXPECT_THROW(GlobalDeclarationManager().registerDeclType("sometype", parser), std::logic_error); | ||
|
||
// Passing a new parser instance doesn't help either | ||
auto parser2 = std::make_shared<TestDeclarationParser>(); | ||
EXPECT_THROW(GlobalDeclarationManager().registerDeclType("sometype", parser2), std::logic_error); | ||
} | ||
|
||
TEST_F(DeclManagerTest, DeclTypeUnregistration) | ||
{ | ||
auto parser = std::make_shared<TestDeclarationParser>(); | ||
GlobalDeclarationManager().registerDeclType("sometype", parser); | ||
|
||
// Unregistering the parser should succeed | ||
EXPECT_NO_THROW(GlobalDeclarationManager().unregisterDeclType("sometype")); | ||
|
||
// Trying to unregister it twice should result in an exception | ||
EXPECT_THROW(GlobalDeclarationManager().unregisterDeclType("sometype"), std::logic_error); | ||
} | ||
|
||
} |
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
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