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
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
7namespace orxonox
8{
9    namespace
10    {
11        // Fixture
12        class ClassFactoryTest : public ::testing::Test
13        {
14            public:
15                virtual void SetUp()
16                {
17                    Context::setRootContext(new Context(NULL));
18                    ModuleInstance::getCurrentModuleInstance()->loadAllStaticallyInitializedInstances();
19                }
20
21                virtual void TearDown()
22                {
23                    ModuleInstance::getCurrentModuleInstance()->unloadAllStaticallyInitializedInstances();
24                    Context::setRootContext(NULL);
25                }
26        };
27    }
28
29    TEST_F(ClassFactoryTest, CanFabricateObject)
30    {
31        Factory* factory = new ClassFactoryWithContext<BaseObject>();
32        Identifiable* object = factory->fabricate(NULL);
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.