Last change
on this file since 12202 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
|
Line | |
---|
1 | #include <gtest/gtest.h> |
---|
2 | #include "core/object/ClassFactory.h" |
---|
3 | #include "core/BaseObject.h" |
---|
4 | #include "core/object/Context.h" |
---|
5 | #include "core/module/ModuleInstance.h" |
---|
6 | #include "core/CoreIncludes.h" |
---|
7 | |
---|
8 | namespace orxonox |
---|
9 | { |
---|
10 | namespace |
---|
11 | { |
---|
12 | // Fixture |
---|
13 | class ClassFactoryTest : public ::testing::Test |
---|
14 | { |
---|
15 | public: |
---|
16 | virtual void SetUp() override |
---|
17 | { |
---|
18 | new IdentifierManager(); |
---|
19 | ModuleInstance::getCurrentModuleInstance()->loadAllStaticallyInitializedInstances(StaticInitialization::IDENTIFIER); |
---|
20 | Context::setRootContext(new Context(nullptr)); |
---|
21 | } |
---|
22 | |
---|
23 | virtual void TearDown() override |
---|
24 | { |
---|
25 | Context::destroyRootContext(); |
---|
26 | ModuleInstance::getCurrentModuleInstance()->unloadAllStaticallyInitializedInstances(StaticInitialization::IDENTIFIER); |
---|
27 | delete &IdentifierManager::getInstance(); |
---|
28 | } |
---|
29 | }; |
---|
30 | } |
---|
31 | |
---|
32 | TEST_F(ClassFactoryTest, CanFabricateObject) |
---|
33 | { |
---|
34 | Factory* factory = new ClassFactoryWithContext<BaseObject>(); |
---|
35 | Identifiable* object = factory->fabricate(nullptr); |
---|
36 | ASSERT_TRUE(object != nullptr); |
---|
37 | BaseObject* baseObject = dynamic_cast<BaseObject*>(object); |
---|
38 | EXPECT_TRUE(baseObject != nullptr); |
---|
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.