Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

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

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

statically initialized instances are now registered with a type. CoreStaticInitializationHandler initializes all instances in core, NetworkStaticInitializationHandler initializes all instances in network.

  • Property svn:eol-style set to native
File size: 1.3 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
8namespace orxonox
9{
10    namespace
11    {
12        // Fixture
13        class ClassFactoryTest : public ::testing::Test
14        {
15            public:
16                virtual void SetUp()
17                {
18                    Context::setRootContext(new Context(NULL));
19                    ModuleInstance::getCurrentModuleInstance()->loadAllStaticallyInitializedInstances(StaticInitialization::IDENTIFIER);
20                }
21
22                virtual void TearDown()
23                {
24                    ModuleInstance::getCurrentModuleInstance()->unloadAllStaticallyInitializedInstances(StaticInitialization::IDENTIFIER);
25                    Context::setRootContext(NULL);
26                }
27        };
28    }
29
30    TEST_F(ClassFactoryTest, CanFabricateObject)
31    {
32        Factory* factory = new ClassFactoryWithContext<BaseObject>();
33        Identifiable* object = factory->fabricate(NULL);
34        ASSERT_TRUE(object != NULL);
35        BaseObject* baseObject = dynamic_cast<BaseObject*>(object);
36        EXPECT_TRUE(baseObject != NULL);
37        delete object;
38        // don't delete factory - it remains in the identifier
39    }
40}
Note: See TracBrowser for help on using the repository browser.