Last change
on this file since 11893 was
11071,
checked in by landauf, 9 years ago
|
merged branch cpp11_v3 back to trunk
|
-
Property svn:eol-style set to
native
|
File size:
1.4 KB
|
Rev | Line | |
---|
[9603] | 1 | #include <gtest/gtest.h> |
---|
| 2 | #include "core/object/ClassFactory.h" |
---|
| 3 | #include "core/BaseObject.h" |
---|
[9649] | 4 | #include "core/object/Context.h" |
---|
[10624] | 5 | #include "core/module/ModuleInstance.h" |
---|
| 6 | #include "core/CoreIncludes.h" |
---|
[9603] | 7 | |
---|
| 8 | namespace orxonox |
---|
| 9 | { |
---|
[9649] | 10 | namespace |
---|
[9603] | 11 | { |
---|
[9649] | 12 | // Fixture |
---|
| 13 | class ClassFactoryTest : public ::testing::Test |
---|
| 14 | { |
---|
| 15 | public: |
---|
[11071] | 16 | virtual void SetUp() override |
---|
[9649] | 17 | { |
---|
[10624] | 18 | new IdentifierManager(); |
---|
| 19 | ModuleInstance::getCurrentModuleInstance()->loadAllStaticallyInitializedInstances(StaticInitialization::IDENTIFIER); |
---|
[11071] | 20 | Context::setRootContext(new Context(nullptr)); |
---|
[9649] | 21 | } |
---|
| 22 | |
---|
[11071] | 23 | virtual void TearDown() override |
---|
[9649] | 24 | { |
---|
[10624] | 25 | Context::destroyRootContext(); |
---|
| 26 | ModuleInstance::getCurrentModuleInstance()->unloadAllStaticallyInitializedInstances(StaticInitialization::IDENTIFIER); |
---|
| 27 | delete &IdentifierManager::getInstance(); |
---|
[9649] | 28 | } |
---|
| 29 | }; |
---|
| 30 | } |
---|
| 31 | |
---|
| 32 | TEST_F(ClassFactoryTest, CanFabricateObject) |
---|
| 33 | { |
---|
[9637] | 34 | Factory* factory = new ClassFactoryWithContext<BaseObject>(); |
---|
[11071] | 35 | Identifiable* object = factory->fabricate(nullptr); |
---|
| 36 | ASSERT_TRUE(object != nullptr); |
---|
[9603] | 37 | BaseObject* baseObject = dynamic_cast<BaseObject*>(object); |
---|
[11071] | 38 | EXPECT_TRUE(baseObject != nullptr); |
---|
[9603] | 39 | delete object; |
---|
| 40 | // don't delete factory - it remains in the identifier |
---|
| 41 | } |
---|
| 42 | } |
---|
Note: See
TracBrowser
for help on using the repository browser.