Changeset 9608 for code/branches/core6/test/core
- Timestamp:
- Mar 30, 2013, 10:40:48 PM (12 years ago)
- Location:
- code/branches/core6/test/core/object
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
code/branches/core6/test/core/object/ListableTest.cc
r9606 r9608 20 20 21 21 template <class T> 22 bool objectListContains(T* element )22 bool objectListContains(T* element, Context* context = Context::getRootContext()) 23 23 { 24 for (typename ObjectList<T>::iterator it = ObjectList<T>::begin(); it != ObjectList<T>::end(); ++it) 24 for (typename ObjectList<T>::iterator it = static_cast<ObjectListElement<T>*>(context->getObjectList<T>()->begin()); 25 it != static_cast<ObjectListElement<T>*>(context->getObjectList<T>()->end()); ++it) 25 26 if (*it == element) 26 27 return true; … … 77 78 EXPECT_EQ(0u, ObjectList<ListableSubclassTest>::size()); 78 79 } 80 81 TEST(ListableTest, CanChangeContext) 82 { 83 Context* rootContext = Context::getRootContext(); 84 Context newContext; 85 ListableSubclassTest test; 86 87 EXPECT_EQ(1u, rootContext->getObjectList<ListableTest>()->size()); 88 EXPECT_TRUE(objectListContains<ListableTest>(&test, rootContext)); 89 EXPECT_EQ(1u, rootContext->getObjectList<ListableSubclassTest>()->size()); 90 EXPECT_TRUE(objectListContains<ListableSubclassTest>(&test, rootContext)); 91 92 EXPECT_EQ(0u, newContext.getObjectList<ListableTest>()->size()); 93 EXPECT_FALSE(objectListContains<ListableTest>(&test, &newContext)); 94 EXPECT_EQ(0u, newContext.getObjectList<ListableSubclassTest>()->size()); 95 EXPECT_FALSE(objectListContains<ListableSubclassTest>(&test, &newContext)); 96 97 test.setContext(&newContext); 98 99 EXPECT_EQ(0u, rootContext->getObjectList<ListableTest>()->size()); 100 EXPECT_FALSE(objectListContains<ListableTest>(&test, rootContext)); 101 EXPECT_EQ(0u, rootContext->getObjectList<ListableSubclassTest>()->size()); 102 EXPECT_FALSE(objectListContains<ListableSubclassTest>(&test, rootContext)); 103 104 EXPECT_EQ(1u, newContext.getObjectList<ListableTest>()->size()); 105 EXPECT_TRUE(objectListContains<ListableTest>(&test, &newContext)); 106 EXPECT_EQ(1u, newContext.getObjectList<ListableSubclassTest>()->size()); 107 EXPECT_TRUE(objectListContains<ListableSubclassTest>(&test, &newContext)); 108 } 79 109 } -
code/branches/core6/test/core/object/ObjectListBaseTest.cc
r9605 r9608 2 2 #include <gmock/gmock.h> 3 3 #include "core/object/ObjectListBase.h" 4 #include "core/class/Identifier.h" 4 5 5 6 namespace orxonox … … 23 24 { 24 25 ObjectListBase list; 25 ObjectListBaseElement* element = new ObjectList BaseElement(NULL);26 ObjectListBaseElement* element = new ObjectListElement<Listable>(NULL); 26 27 list.addElement(element); 27 28 EXPECT_EQ(1u, list.size()); … … 31 32 { 32 33 ObjectListBase list; 33 ObjectListBaseElement* element = new ObjectList BaseElement(NULL);34 ObjectListBaseElement* element = new ObjectListElement<Listable>(NULL); 34 35 list.addElement(element); 35 36 EXPECT_EQ(1u, list.size()); … … 51 52 EXPECT_EQ(0u, list.size()); 52 53 { 53 ObjectList BaseElementelement1(NULL);54 ObjectListElement<Listable> element1(NULL); 54 55 list.addElement(&element1); 55 56 EXPECT_EQ(1u, list.size()); 56 57 { 57 ObjectList BaseElementelement1(NULL);58 ObjectListElement<Listable> element1(NULL); 58 59 list.addElement(&element1); 59 60 EXPECT_EQ(2u, list.size()); 60 61 { 61 ObjectList BaseElementelement1(NULL);62 ObjectListElement<Listable> element1(NULL); 62 63 list.addElement(&element1); 63 64 EXPECT_EQ(3u, list.size()); … … 75 76 ObjectListElementRemovalListenerMock listener; 76 77 list.registerRemovalListener(&listener); 77 ObjectListBaseElement* element = new ObjectList BaseElement(NULL);78 ObjectListBaseElement* element = new ObjectListElement<Listable>(NULL); 78 79 list.addElement(element); 79 80 EXPECT_CALL(listener, removedElement(element));
Note: See TracChangeset
for help on using the changeset viewer.