Last change
on this file since 10959 was
10624,
checked in by landauf, 9 years ago
|
merged branch core7 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: |
---|
| 16 | virtual void SetUp() |
---|
| 17 | { |
---|
[10624] | 18 | new IdentifierManager(); |
---|
| 19 | ModuleInstance::getCurrentModuleInstance()->loadAllStaticallyInitializedInstances(StaticInitialization::IDENTIFIER); |
---|
[9649] | 20 | Context::setRootContext(new Context(NULL)); |
---|
| 21 | } |
---|
| 22 | |
---|
| 23 | virtual void TearDown() |
---|
| 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>(); |
---|
[9632] | 35 | Identifiable* object = factory->fabricate(NULL); |
---|
[9603] | 36 | ASSERT_TRUE(object != NULL); |
---|
| 37 | BaseObject* baseObject = dynamic_cast<BaseObject*>(object); |
---|
| 38 | EXPECT_TRUE(baseObject != NULL); |
---|
| 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.