| Last change
                  on this file since 10722 was
                  10624,
                  checked in by landauf, 10 years ago | 
        
          | 
merged branch core7 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() | 
|---|
| 17 | { | 
|---|
| 18 | new IdentifierManager(); | 
|---|
| 19 | ModuleInstance::getCurrentModuleInstance()->loadAllStaticallyInitializedInstances(StaticInitialization::IDENTIFIER); | 
|---|
| 20 | Context::setRootContext(new Context(NULL)); | 
|---|
| 21 | } | 
|---|
| 22 |  | 
|---|
| 23 | virtual void TearDown() | 
|---|
| 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(NULL); | 
|---|
| 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.