Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

source: code/branches/core7/test/core/object/ClassFactoryTest.cc @ 10481

Last change on this file since 10481 was 10481, checked in by landauf, 9 years ago

StaticallyInitializedIdentifier is now responsible to register and unregister the assigned identifier.

  • Property svn:eol-style set to native
File size: 1.2 KB
RevLine 
[9603]1#include <gtest/gtest.h>
2#include "core/object/ClassFactory.h"
3#include "core/BaseObject.h"
[9649]4#include "core/object/Context.h"
[10481]5#include "core/module/ModuleInstance.h"
[9603]6
7namespace orxonox
8{
[9649]9    namespace
[9603]10    {
[9649]11        // Fixture
12        class ClassFactoryTest : public ::testing::Test
13        {
14            public:
15                virtual void SetUp()
16                {
17                    Context::setRootContext(new Context(NULL));
[10481]18                    ModuleInstance::getCurrentModuleInstance()->loadAllStaticallyInitializedInstances();
[9649]19                }
20
21                virtual void TearDown()
22                {
[10481]23                    ModuleInstance::getCurrentModuleInstance()->unloadAllStaticallyInitializedInstances();
[9649]24                    Context::setRootContext(NULL);
25                }
26        };
27    }
28
29    TEST_F(ClassFactoryTest, CanFabricateObject)
30    {
[9637]31        Factory* factory = new ClassFactoryWithContext<BaseObject>();
[9632]32        Identifiable* object = factory->fabricate(NULL);
[9603]33        ASSERT_TRUE(object != NULL);
34        BaseObject* baseObject = dynamic_cast<BaseObject*>(object);
35        EXPECT_TRUE(baseObject != NULL);
36        delete object;
37        // don't delete factory - it remains in the identifier
38    }
39}
Note: See TracBrowser for help on using the repository browser.