Show
Ignore:
Timestamp:
12/19/07 17:56:03 (9 months ago)
Author:
cneumann
Message:

changed: generic interface activated
fixed: single parent unlinking

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • branches/Carsten_PtrWork2/Source/System/FieldContainer/Base/OSGReferenceCountTest.cpp

    r1031 r1033  
    134134    CHECK_EQUAL(OSG::FieldContainerFactory::the()->getContainer(ni0), OSG::FieldContainerPtr(NullFC)); 
    135135    CHECK_EQUAL(OSG::FieldContainerFactory::the()->getContainer(ni1), OSG::FieldContainerPtr(NullFC)); 
    136 
     136     
     137} // BasicStructure 
    137138 
    138139TEST(RefPtrReuse) 
     
    203204    CHECK_EQUAL(OSG::FieldContainerFactory::the()->getContainer(ni1), OSG::FieldContainerPtr(NullFC)); 
    204205    CHECK_EQUAL(OSG::FieldContainerFactory::the()->getContainer(ni2), OSG::FieldContainerPtr(NullFC)); 
    205 
     206     
     207} // RefPtrReuse 
    206208 
    207209TEST(SharedCore) 
     
    323325    CHECK_EQUAL(OSG::FieldContainerFactory::the()->getContainer(ni0), OSG::FieldContainerPtr(NullFC)); 
    324326    CHECK_EQUAL(OSG::FieldContainerFactory::the()->getContainer(ni1), OSG::FieldContainerPtr(NullFC)); 
    325 
     327     
     328} // SharedCore 
    326329 
    327330TEST(MultipleChildrenSharedCores) 
     
    410413    CHECK_EQUAL(OSG::FieldContainerFactory::the()->getContainer(ni2), OSG::FieldContainerPtr(NullFC)); 
    411414    CHECK_EQUAL(OSG::FieldContainerFactory::the()->getContainer(ni3), OSG::FieldContainerPtr(NullFC)); 
    412 
     415     
     416} // MultipleChildrenSharedCores 
     417 
     418TEST(Remove) 
     419
     420    // Test removal of objects 
     421     
     422    OSG::NodeRefPtr  nrp0 = OSG::Node::create(); 
     423    OSG::NodeRefPtr  nrp1 = OSG::Node::create(); 
     424     
     425    OSG::GroupRefPtr grp0 = OSG::Group::create(); 
     426     
     427    // add child and core 
     428    nrp0->addChild(nrp1); 
     429    nrp0->setCore (grp0); 
     430     
     431    CHECK_EQUAL(nrp0->getNChildren(),  1   ); 
     432    CHECK_EQUAL(nrp0->getCore(),       grp0); 
     433    CHECK_EQUAL(grp0->getParents()[0], nrp0); 
     434     
     435    // remove child 
     436    nrp0->subChild(OSG::UInt32(0)); 
     437     
     438    CHECK_EQUAL(nrp0->getNChildren(), 0); 
     439    CHECK(nrp1->getParent() == NullFC); 
     440     
     441    // remove core 
     442    nrp0->setCore(NullFC); 
     443     
     444    CHECK(nrp0->getCore() == NullFC); 
     445    CHECK(grp0->getParents().size() == 0); 
     446     
     447     
     448    // share the core 
     449    nrp0->setCore(grp0); 
     450    nrp1->setCore(grp0); 
     451     
     452    CHECK(grp0->getParents().size() == 2); 
     453    CHECK(grp0->getParents()[0]     == nrp0); 
     454    CHECK(grp0->getParents()[1]     == nrp1); 
     455 
     456    // remove core from one node 
     457    nrp0->setCore(NullFC); 
     458     
     459    CHECK(grp0->getParents().size() == 1); 
     460    CHECK(grp0->getParents()[0]     == nrp1); 
     461     
     462    CHECK(nrp0->getCore() == NullFC); 
     463    CHECK(nrp1->getCore() == grp0); 
     464     
     465} // Remove 
     466 
     467 
     468TEST(MoveChild) 
     469
     470    // Test moving a child from one parent to another 
     471 
     472    OSG::NodeRefPtr nrp0 = OSG::Node::create(); 
     473    OSG::NodeRefPtr nrp1 = OSG::Node::create(); 
     474    OSG::NodeRefPtr nrp2 = OSG::Node::create(); 
     475     
     476    // add child to one node 
     477    nrp0->addChild(nrp1); 
     478     
     479    CHECK_EQUAL(nrp0->getNChildren(),   1   ); 
     480    CHECK_EQUAL(nrp0->getChildren()[0], nrp1); 
     481    CHECK_EQUAL(nrp1->getParent(),      nrp0); 
     482     
     483    // add same child to different node 
     484    nrp2->addChild(nrp1); 
     485     
     486    CHECK_EQUAL(nrp2->getNChildren(),   1   ); 
     487    CHECK_EQUAL(nrp2->getChildren()[0], nrp1); 
     488    CHECK_EQUAL(nrp1->getParent(),      nrp2); 
     489     
     490    // make sure it is removed from former parent 
     491    CHECK_EQUAL(nrp0->getNChildren(), 0); 
     492     
     493} // MoveChild 
    413494 
    414495} // SUITE(ReferenceCountTests)