Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

Changeset 9650 for code/branches


Ignore:
Timestamp:
Aug 14, 2013, 7:04:40 PM (11 years ago)
Author:
landauf
Message:

add context to objectlist

Location:
code/branches/core6
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • code/branches/core6/src/libraries/core/object/Context.cc

    r9649 r9650  
    3434#include "Context.h"
    3535#include "core/class/Identifier.h"
     36#include "core/CoreIncludes.h"
    3637
    3738namespace orxonox
    3839{
     40    RegisterClass(Context);
     41
    3942    Context* Context::rootContext_s = 0;
    4043
     
    4649        // setContext(this) here).
    4750        this->setContext(this);
     51
     52        RegisterObject(Context);
    4853    }
    4954
  • code/branches/core6/test/core/object/ContextTest.cc

    r9649 r9650  
    5858        EXPECT_EQ(1u, context.getObjectList<SubclassContext>()->size());
    5959    }
     60
     61    TEST_F(ContextTest, ContextIsAddedToItsOwnObjectList)
     62    {
     63        Context context(NULL);
     64        ASSERT_EQ(1u, context.getObjectList<Context>()->size());
     65        EXPECT_TRUE(context.getObjectList<Context>()->begin()->objectBase_ == static_cast<Listable*>(&context));
     66    }
     67
     68    TEST_F(ContextTest, ContextIsAddedToObjectListOfBaseContext)
     69    {
     70        Context baseContext(NULL);
     71        Context subContext(&baseContext);
     72
     73        ASSERT_EQ(1u, subContext.getObjectList<Context>()->size());
     74        EXPECT_TRUE(subContext.getObjectList<Context>()->begin()->objectBase_ == static_cast<Listable*>(&subContext));
     75
     76        ASSERT_EQ(2u, baseContext.getObjectList<Context>()->size());
     77        EXPECT_TRUE(baseContext.getObjectList<Context>()->begin()->objectBase_ == static_cast<Listable*>(&baseContext));
     78        EXPECT_TRUE(baseContext.getObjectList<Context>()->begin()->next_->objectBase_ == static_cast<Listable*>(&subContext));
     79    }
    6080}
Note: See TracChangeset for help on using the changeset viewer.