Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

source: code/branches/libs/test/core/object/ClassFactoryTest.cc @ 10077

Last change on this file since 10077 was 9649, checked in by landauf, 11 years ago

added ability to set the root-context explicitly (and also to destroy it before the class-hierarchy is destroyed).
currently it's not possible to set the root context explicitly during startup of the game because it is already used by static initialization

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