Last change
on this file since 9649 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:
1.4 KB
|
Line | |
---|
1 | #include <gtest/gtest.h> |
---|
2 | #include "core/object/Context.h" |
---|
3 | #include "core/class/OrxonoxClass.h" |
---|
4 | #include "core/CoreIncludes.h" |
---|
5 | |
---|
6 | namespace orxonox |
---|
7 | { |
---|
8 | namespace |
---|
9 | { |
---|
10 | class SubclassContext : public OrxonoxClass, public Context |
---|
11 | { |
---|
12 | public: |
---|
13 | SubclassContext() : Context(NULL) { RegisterRootObject(SubclassContext); } |
---|
14 | }; |
---|
15 | |
---|
16 | // Fixture |
---|
17 | class ContextTest : public ::testing::Test |
---|
18 | { |
---|
19 | public: |
---|
20 | virtual void SetUp() |
---|
21 | { |
---|
22 | Context::setRootContext(new Context(NULL)); |
---|
23 | } |
---|
24 | |
---|
25 | virtual void TearDown() |
---|
26 | { |
---|
27 | Context::setRootContext(NULL); |
---|
28 | } |
---|
29 | }; |
---|
30 | } |
---|
31 | |
---|
32 | TEST_F(ContextTest, CanCreateContext) |
---|
33 | { |
---|
34 | Context context(NULL); |
---|
35 | } |
---|
36 | |
---|
37 | TEST_F(ContextTest, CanCreateSubclassContext) |
---|
38 | { |
---|
39 | SubclassContext context; |
---|
40 | } |
---|
41 | |
---|
42 | TEST_F(ContextTest, ContextIsItsOwnContext) |
---|
43 | { |
---|
44 | Context context(NULL); |
---|
45 | EXPECT_EQ(&context, context.getContext()); |
---|
46 | } |
---|
47 | |
---|
48 | TEST_F(ContextTest, SubclassContextIsItsOwnContext) |
---|
49 | { |
---|
50 | SubclassContext context; |
---|
51 | EXPECT_EQ(&context, context.getContext()); |
---|
52 | } |
---|
53 | |
---|
54 | TEST_F(ContextTest, SubclassAddsToItsOwnObjectList) |
---|
55 | { |
---|
56 | SubclassContext context; |
---|
57 | EXPECT_EQ(&context, context.getContext()); |
---|
58 | EXPECT_EQ(1u, context.getObjectList<SubclassContext>()->size()); |
---|
59 | } |
---|
60 | } |
---|
Note: See
TracBrowser
for help on using the repository browser.