CPPUNIT_ASSERT_MESSAGE( "BG layer must not have pending updates!",
!pBgLayer->isUpdatePending() );
pBgLayer->addUpdateRange( basegfx::B2DRange(0,0,10,10) );
CPPUNIT_ASSERT_MESSAGE( "BG layer must have pending updates!",
pBgLayer->isUpdatePending() );
TestShapeSharedPtr pTestShape = createTestShape(
basegfx::B2DRange(0.0,0.0,1000.0,1000.0), 1.0);
pBgLayer->updateBounds( pTestShape );
CPPUNIT_ASSERT_MESSAGE( "BG layer must not resize!",
!pBgLayer->commitBounds() );
CPPUNIT_ASSERT_MESSAGE( "Un-added shape must have zero view layers",
mpTestShape->getViewLayers().empty() );
mpLayerManager->addShape(mpTestShape);
CPPUNIT_ASSERT_MESSAGE( "Adding a shape requires a LayerManager update",
mpLayerManager->isUpdatePending() );
// update does the delayed viewAdded call to the shape
CPPUNIT_ASSERT_MESSAGE( "Update failed on LayerManager",
mpLayerManager->update() );
CPPUNIT_ASSERT_EQUAL_MESSAGE( "Added shape must have one view layer",
size_t(1), mpTestShape->getViewLayers().size() );
CPPUNIT_ASSERT_MESSAGE( "Shape must been rendered",
mpTestShape->getNumRenders() );
CPPUNIT_ASSERT_MESSAGE( "Shape must not been updated",
!mpTestShape->getNumUpdates() );
// test second view, check whether shape gets additional view
TestViewSharedPtr pTestView( createTestView() );
CPPUNIT_ASSERT_MESSAGE( "Adding second View failed",
maViews.addView( pTestView ) );
CPPUNIT_ASSERT_EQUAL_MESSAGE( "View container must have two views",
std::ptrdiff_t(2),
maViews.end() - maViews.begin() );
mpLayerManager->viewAdded(pTestView);
CPPUNIT_ASSERT_EQUAL_MESSAGE( "Added shape must have two view layers",
size_t(2),
mpTestShape->getViewLayers().size() );
// update does the delayed viewAdded call to the shape
CPPUNIT_ASSERT_MESSAGE( "Update failed on LayerManager",
mpLayerManager->update() );
CPPUNIT_ASSERT_MESSAGE( "View must have background layer only",
mpTestView->getViewLayers().empty() );
// LayerManager must now generate one extra view layer
mpLayerManager->enterAnimationMode(pShape2);
CPPUNIT_ASSERT_MESSAGE( "No update pending on LayerManager",
mpLayerManager->isUpdatePending() );
CPPUNIT_ASSERT_MESSAGE( "Update failed on LayerManager",
mpLayerManager->update() );
CPPUNIT_ASSERT_EQUAL_MESSAGE( "View must have one extra layer only",
size_t(1), mpTestView->getViewLayers().size() );
CPPUNIT_ASSERT_EQUAL_MESSAGE( "View layer must have 10x10 size",
basegfx::B2DRange(0.0,0.0,10.0,10.0),
mpTestView->getViewLayers().at(0)->getBounds() );
// LayerManager must now remove the extra view layer
mpLayerManager->leaveAnimationMode(pShape2);
CPPUNIT_ASSERT_MESSAGE( "No update pending on LayerManager",
mpLayerManager->isUpdatePending() );
CPPUNIT_ASSERT_MESSAGE( "Update failed on LayerManager #2",
mpLayerManager->update() );
CPPUNIT_ASSERT_EQUAL_MESSAGE( "Shape 1 must be on background layer", static_cast<slideshow::internal::ViewLayer*>(mpTestView.get()),
mpTestShape->getViewLayers().at(0).first.get() );
CPPUNIT_ASSERT_EQUAL_MESSAGE( "Shape 2 must be on background layer", static_cast<slideshow::internal::ViewLayer*>(mpTestView.get()),
pShape2->getViewLayers().at(0).first.get() );
CPPUNIT_ASSERT_EQUAL_MESSAGE( "Shape 3 must have one layer",
size_t(1), pShape3->getViewLayers().size() );
CPPUNIT_ASSERT_EQUAL_MESSAGE( "Shape 3 must be on background layer", static_cast<slideshow::internal::ViewLayer*>(mpTestView.get()),
pShape3->getViewLayers().at(0).first.get() );
CPPUNIT_ASSERT_EQUAL_MESSAGE( "Shape 4 must be on background layer", static_cast<slideshow::internal::ViewLayer*>(mpTestView.get()),
pShape4->getViewLayers().at(0).first.get() );
// checking deactivation (all layers except background layer // must vanish)
mpLayerManager->enterAnimationMode(pShape3);
CPPUNIT_ASSERT_MESSAGE( "No update pending on LayerManager",
mpLayerManager->isUpdatePending() );
CPPUNIT_ASSERT_MESSAGE( "Update failed on LayerManager",
mpLayerManager->update() );
CPPUNIT_ASSERT_MESSAGE( "Shape 4 must not be on background layer",
pShape4->getViewLayers().at(0).first != mpTestView );
mpLayerManager->leaveAnimationMode(pShape3);
CPPUNIT_ASSERT_MESSAGE( "Update failed on LayerManager",
mpLayerManager->update() );
CPPUNIT_ASSERT_EQUAL_MESSAGE( "Shape 4 must be on background layer", static_cast<slideshow::internal::ViewLayer*>(mpTestView.get()),
pShape4->getViewLayers().at(0).first.get() );
mpLayerManager->deactivate();
CPPUNIT_ASSERT_MESSAGE( "Update pending on deactivated LayerManager",
!mpLayerManager->isUpdatePending() );
}
CPPUNIT_ASSERT_EQUAL_MESSAGE( "Shape 1 must have refcount of 1", 1L, mpTestShape.use_count() );
CPPUNIT_ASSERT_EQUAL_MESSAGE( "Shape 2 must have refcount of ", 1L, pShape2.use_count() );
CPPUNIT_ASSERT_EQUAL_MESSAGE( "Shape 3 must have refcount of 1", 1L, pShape3.use_count() );
CPPUNIT_ASSERT_EQUAL_MESSAGE( "Shape 4 must have refcount of", 1L, pShape4.use_count() );
CPPUNIT_ASSERT_EQUAL_MESSAGE( "Shape 1 must have refcount of 1", 1L, mpTestShape.use_count() );
CPPUNIT_ASSERT_EQUAL_MESSAGE( "Shape 2 must have refcount of ", 1L, pShape2.use_count() );
CPPUNIT_ASSERT_EQUAL_MESSAGE( "Shape 3 must have refcount of 1", 1L, pShape3.use_count() );
CPPUNIT_ASSERT_EQUAL_MESSAGE( "Shape 4 must have refcount of 1", 1L, pShape4.use_count() );
}
// hook up the test
CPPUNIT_TEST_SUITE(LayerManagerTest);
CPPUNIT_TEST(testBasics);
CPPUNIT_TEST(testLayer);
CPPUNIT_TEST(testShapeOrdering);
CPPUNIT_TEST(testShapeRepaint);
CPPUNIT_TEST(testRefCounting);
CPPUNIT_TEST_SUITE_END();
Die Informationen auf dieser Webseite wurden
nach bestem Wissen sorgfältig zusammengestellt. Es wird jedoch weder Vollständigkeit, noch Richtigkeit,
noch Qualität der bereit gestellten Informationen zugesichert.
Bemerkung:
Die farbliche Syntaxdarstellung und die Messung sind noch experimentell.