xref: /aoo41x/main/slideshow/test/slidetest.cxx (revision 70f497fb)
1*70f497fbSAndrew Rist /**************************************************************
2cdf0e10cSrcweir  *
3*70f497fbSAndrew Rist  * Licensed to the Apache Software Foundation (ASF) under one
4*70f497fbSAndrew Rist  * or more contributor license agreements.  See the NOTICE file
5*70f497fbSAndrew Rist  * distributed with this work for additional information
6*70f497fbSAndrew Rist  * regarding copyright ownership.  The ASF licenses this file
7*70f497fbSAndrew Rist  * to you under the Apache License, Version 2.0 (the
8*70f497fbSAndrew Rist  * "License"); you may not use this file except in compliance
9*70f497fbSAndrew Rist  * with the License.  You may obtain a copy of the License at
10*70f497fbSAndrew Rist  *
11*70f497fbSAndrew Rist  *   http://www.apache.org/licenses/LICENSE-2.0
12*70f497fbSAndrew Rist  *
13*70f497fbSAndrew Rist  * Unless required by applicable law or agreed to in writing,
14*70f497fbSAndrew Rist  * software distributed under the License is distributed on an
15*70f497fbSAndrew Rist  * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
16*70f497fbSAndrew Rist  * KIND, either express or implied.  See the License for the
17*70f497fbSAndrew Rist  * specific language governing permissions and limitations
18*70f497fbSAndrew Rist  * under the License.
19*70f497fbSAndrew Rist  *
20*70f497fbSAndrew Rist  *************************************************************/
21*70f497fbSAndrew Rist 
22*70f497fbSAndrew Rist 
23cdf0e10cSrcweir 
24cdf0e10cSrcweir #include <testshl/simpleheader.hxx>
25cdf0e10cSrcweir #include <cppuhelper/compbase1.hxx>
26cdf0e10cSrcweir #include <comphelper/broadcasthelper.hxx>
27cdf0e10cSrcweir 
28cdf0e10cSrcweir #include <basegfx/matrix/b2dhommatrix.hxx>
29cdf0e10cSrcweir #include <basegfx/range/b2drectangle.hxx>
30cdf0e10cSrcweir #include <cppcanvas/spritecanvas.hxx>
31cdf0e10cSrcweir 
32cdf0e10cSrcweir #include "view.hxx"
33cdf0e10cSrcweir #include "unoview.hxx"
34cdf0e10cSrcweir #include "unoviewcontainer.hxx"
35cdf0e10cSrcweir #include "shape.hxx"
36cdf0e10cSrcweir #include "tests.hxx"
37cdf0e10cSrcweir #include "../engine/slide/layermanager.hxx"
38cdf0e10cSrcweir #include "../engine/slide/layer.hxx"
39cdf0e10cSrcweir #include "com/sun/star/presentation/XSlideShowView.hpp"
40cdf0e10cSrcweir 
41cdf0e10cSrcweir namespace target = slideshow::internal;
42cdf0e10cSrcweir using namespace ::com::sun::star;
43cdf0e10cSrcweir 
44cdf0e10cSrcweir namespace
45cdf0e10cSrcweir {
46cdf0e10cSrcweir 
47cdf0e10cSrcweir class LayerManagerTest : public CppUnit::TestFixture
48cdf0e10cSrcweir {
49cdf0e10cSrcweir     target::UnoViewContainer      maViews;
50cdf0e10cSrcweir     target::LayerManagerSharedPtr mpLayerManager;
51cdf0e10cSrcweir     TestViewSharedPtr             mpTestView;
52cdf0e10cSrcweir     TestShapeSharedPtr            mpTestShape;
53cdf0e10cSrcweir 
54cdf0e10cSrcweir public:
setUp()55cdf0e10cSrcweir     void setUp()
56cdf0e10cSrcweir     {
57cdf0e10cSrcweir         mpTestShape = createTestShape(
58cdf0e10cSrcweir             basegfx::B2DRange(0.0,0.0,10.0,10.0),
59cdf0e10cSrcweir             1.0);
60cdf0e10cSrcweir         mpTestView = createTestView();
61cdf0e10cSrcweir         maViews.addView( mpTestView );
62cdf0e10cSrcweir 
63cdf0e10cSrcweir         mpLayerManager.reset(
64cdf0e10cSrcweir             new target::LayerManager(
65cdf0e10cSrcweir                 maViews,
66cdf0e10cSrcweir                 basegfx::B2DRange(0.0,0.0,100.0,100.0),
67cdf0e10cSrcweir                 false ));
68cdf0e10cSrcweir     }
69cdf0e10cSrcweir 
tearDown()70cdf0e10cSrcweir     void tearDown()
71cdf0e10cSrcweir     {
72cdf0e10cSrcweir         mpLayerManager.reset();
73cdf0e10cSrcweir         maViews.dispose();
74cdf0e10cSrcweir     }
75cdf0e10cSrcweir 
testLayer()76cdf0e10cSrcweir     void testLayer()
77cdf0e10cSrcweir     {
78cdf0e10cSrcweir         target::LayerSharedPtr pBgLayer(
79cdf0e10cSrcweir             target::Layer::createBackgroundLayer( basegfx::B2DRange(0,0,100,100) ) );
80cdf0e10cSrcweir         pBgLayer->addView( mpTestView );
81cdf0e10cSrcweir 
82cdf0e10cSrcweir         target::LayerSharedPtr pFgLayer(
83cdf0e10cSrcweir             target::Layer::createLayer( basegfx::B2DRange(0,0,100,100) ) );
84cdf0e10cSrcweir         pFgLayer->addView( mpTestView );
85cdf0e10cSrcweir 
86cdf0e10cSrcweir         CPPUNIT_ASSERT_MESSAGE( "BG layer must confess that!",
87cdf0e10cSrcweir                                 pBgLayer->isBackgroundLayer() );
88cdf0e10cSrcweir         CPPUNIT_ASSERT_MESSAGE( "FG layer lies!",
89cdf0e10cSrcweir                                 !pFgLayer->isBackgroundLayer() );
90cdf0e10cSrcweir 
91cdf0e10cSrcweir         CPPUNIT_ASSERT_MESSAGE( "BG layer must not have pending updates!",
92cdf0e10cSrcweir                                 !pBgLayer->isUpdatePending() );
93cdf0e10cSrcweir         pBgLayer->addUpdateRange( basegfx::B2DRange(0,0,10,10) );
94cdf0e10cSrcweir         CPPUNIT_ASSERT_MESSAGE( "BG layer must have pending updates!",
95cdf0e10cSrcweir                                 pBgLayer->isUpdatePending() );
96cdf0e10cSrcweir 
97cdf0e10cSrcweir         TestShapeSharedPtr pTestShape = createTestShape(
98cdf0e10cSrcweir             basegfx::B2DRange(0.0,0.0,1000.0,1000.0),
99cdf0e10cSrcweir             1.0);
100cdf0e10cSrcweir         pBgLayer->updateBounds( pTestShape );
101cdf0e10cSrcweir         CPPUNIT_ASSERT_MESSAGE( "BG layer must not resize!",
102cdf0e10cSrcweir                                 !pBgLayer->commitBounds() );
103cdf0e10cSrcweir 
104cdf0e10cSrcweir         TestShapeSharedPtr pTestShape2 = createTestShape(
105cdf0e10cSrcweir             basegfx::B2DRange(0.0,0.0,1.0,1.0),
106cdf0e10cSrcweir             1.0);
107cdf0e10cSrcweir         pFgLayer->updateBounds( pTestShape2 );
108cdf0e10cSrcweir         CPPUNIT_ASSERT_MESSAGE( "FG layer must resize!",
109cdf0e10cSrcweir                                 pFgLayer->commitBounds() );
110cdf0e10cSrcweir     }
111cdf0e10cSrcweir 
testBasics()112cdf0e10cSrcweir     void testBasics()
113cdf0e10cSrcweir     {
114cdf0e10cSrcweir         mpLayerManager->activate( false );
115cdf0e10cSrcweir 
116cdf0e10cSrcweir         CPPUNIT_ASSERT_MESSAGE( "Un-added shape must have zero view layers",
117cdf0e10cSrcweir                                 mpTestShape->getViewLayers().empty() );
118cdf0e10cSrcweir         mpLayerManager->addShape(mpTestShape);
119cdf0e10cSrcweir         CPPUNIT_ASSERT_MESSAGE( "Adding a shape requires a LayerManager update",
120cdf0e10cSrcweir                                 mpLayerManager->isUpdatePending() );
121cdf0e10cSrcweir 
122cdf0e10cSrcweir         // update does the delayed viewAdded call to the shape
123cdf0e10cSrcweir         CPPUNIT_ASSERT_MESSAGE( "Update failed on LayerManager",
124cdf0e10cSrcweir                                 mpLayerManager->update() );
125cdf0e10cSrcweir         CPPUNIT_ASSERT_MESSAGE( "Added shape must have one view layer",
126cdf0e10cSrcweir                                 mpTestShape->getViewLayers().size() == 1 );
127cdf0e10cSrcweir         CPPUNIT_ASSERT_MESSAGE( "Shape must been rendered",
128cdf0e10cSrcweir                                 mpTestShape->getNumRenders() );
129cdf0e10cSrcweir         CPPUNIT_ASSERT_MESSAGE( "Shape must not been updated",
130cdf0e10cSrcweir                                 !mpTestShape->getNumUpdates() );
131cdf0e10cSrcweir 
132cdf0e10cSrcweir         // test second view, check whether shape gets additional view
133cdf0e10cSrcweir         TestViewSharedPtr pTestView( createTestView() );
134cdf0e10cSrcweir         CPPUNIT_ASSERT_MESSAGE( "Adding second View failed",
135cdf0e10cSrcweir                                 maViews.addView( pTestView ) );
136cdf0e10cSrcweir         CPPUNIT_ASSERT_MESSAGE( "View container must have two views",
137cdf0e10cSrcweir                                 maViews.end() - maViews.begin() == 2 );
138cdf0e10cSrcweir         mpLayerManager->viewAdded(pTestView);
139cdf0e10cSrcweir         CPPUNIT_ASSERT_MESSAGE( "Added shape must have two view layers",
140cdf0e10cSrcweir                                 mpTestShape->getViewLayers().size() == 2 );
141cdf0e10cSrcweir 
142cdf0e10cSrcweir         CPPUNIT_ASSERT_MESSAGE( "Removing second View failed",
143cdf0e10cSrcweir                                 maViews.removeView( pTestView ) );
144cdf0e10cSrcweir         mpLayerManager->viewRemoved(pTestView);
145cdf0e10cSrcweir         CPPUNIT_ASSERT_MESSAGE( "Added shape must have one view layer",
146cdf0e10cSrcweir                                 mpTestShape->getViewLayers().size() == 1 );
147cdf0e10cSrcweir 
148cdf0e10cSrcweir         mpLayerManager->deactivate();
149cdf0e10cSrcweir     }
150cdf0e10cSrcweir 
testShapeOrdering()151cdf0e10cSrcweir     void testShapeOrdering()
152cdf0e10cSrcweir     {
153cdf0e10cSrcweir         TestShapeSharedPtr pShape2( createTestShape(
154cdf0e10cSrcweir             basegfx::B2DRange(0.0,0.0,10.0,10.0),
155cdf0e10cSrcweir             2.0));
156cdf0e10cSrcweir         TestShapeSharedPtr pShape3( createTestShape(
157cdf0e10cSrcweir             basegfx::B2DRange(0.0,0.0,10.0,10.0),
158cdf0e10cSrcweir             3.0));
159cdf0e10cSrcweir         TestShapeSharedPtr pShape4( createTestShape(
160cdf0e10cSrcweir             basegfx::B2DRange(0.0,0.0,10.0,10.0),
161cdf0e10cSrcweir             4.0));
162cdf0e10cSrcweir 
163cdf0e10cSrcweir         mpLayerManager->addShape(mpTestShape);
164cdf0e10cSrcweir         mpLayerManager->addShape(pShape2);
165cdf0e10cSrcweir         mpLayerManager->addShape(pShape3);
166cdf0e10cSrcweir         mpLayerManager->addShape(pShape4);
167cdf0e10cSrcweir 
168cdf0e10cSrcweir         mpLayerManager->activate( false );
169cdf0e10cSrcweir 
170cdf0e10cSrcweir         // update does the delayed viewAdded call to the shape
171cdf0e10cSrcweir         CPPUNIT_ASSERT_MESSAGE( "Update failed on LayerManager",
172cdf0e10cSrcweir                                 mpLayerManager->update() );
173cdf0e10cSrcweir         CPPUNIT_ASSERT_MESSAGE( "View must have background layer only",
174cdf0e10cSrcweir                                 mpTestView->getViewLayers().empty() );
175cdf0e10cSrcweir 
176cdf0e10cSrcweir         // LayerManager must now generate one extra view layer
177cdf0e10cSrcweir         mpLayerManager->enterAnimationMode(pShape2);
178cdf0e10cSrcweir         CPPUNIT_ASSERT_MESSAGE( "No update pending on LayerManager",
179cdf0e10cSrcweir                                 mpLayerManager->isUpdatePending() );
180cdf0e10cSrcweir         CPPUNIT_ASSERT_MESSAGE( "Update failed on LayerManager",
181cdf0e10cSrcweir                                 mpLayerManager->update() );
182cdf0e10cSrcweir         CPPUNIT_ASSERT_MESSAGE( "View must have one extra layer only",
183cdf0e10cSrcweir                                 mpTestView->getViewLayers().size() == 1 );
184cdf0e10cSrcweir         CPPUNIT_ASSERT_MESSAGE( "View layer must have 10x10 size",
185cdf0e10cSrcweir                                 mpTestView->getViewLayers().at(0)->getBounds() ==
186cdf0e10cSrcweir                                 basegfx::B2DRange(0.0,0.0,10.0,10.0) );
187cdf0e10cSrcweir 
188cdf0e10cSrcweir         // LayerManager must now remove the extra view layer
189cdf0e10cSrcweir         mpLayerManager->leaveAnimationMode(pShape2);
190cdf0e10cSrcweir         CPPUNIT_ASSERT_MESSAGE( "No update pending on LayerManager",
191cdf0e10cSrcweir                                 mpLayerManager->isUpdatePending() );
192cdf0e10cSrcweir         CPPUNIT_ASSERT_MESSAGE( "Update failed on LayerManager #2",
193cdf0e10cSrcweir                                 mpLayerManager->update() );
194cdf0e10cSrcweir         CPPUNIT_ASSERT_MESSAGE( "Shape 1 must be on background layer",
195cdf0e10cSrcweir                                 mpTestShape->getViewLayers().at(0).first == mpTestView );
196cdf0e10cSrcweir         CPPUNIT_ASSERT_MESSAGE( "Shape 2 must be on background layer",
197cdf0e10cSrcweir                                 pShape2->getViewLayers().at(0).first == mpTestView );
198cdf0e10cSrcweir         CPPUNIT_ASSERT_MESSAGE( "Shape 3 must have one layer",
199cdf0e10cSrcweir                                 pShape3->getViewLayers().size() == 1 );
200cdf0e10cSrcweir         CPPUNIT_ASSERT_MESSAGE( "Shape 3 must be on background layer",
201cdf0e10cSrcweir                                 pShape3->getViewLayers().at(0).first == mpTestView );
202cdf0e10cSrcweir         CPPUNIT_ASSERT_MESSAGE( "Shape 4 must be on background layer",
203cdf0e10cSrcweir                                 pShape4->getViewLayers().at(0).first == mpTestView );
204cdf0e10cSrcweir 
205cdf0e10cSrcweir         // checking deactivation (all layers except background layer
206cdf0e10cSrcweir         // must vanish)
207cdf0e10cSrcweir         mpLayerManager->enterAnimationMode(pShape3);
208cdf0e10cSrcweir         CPPUNIT_ASSERT_MESSAGE( "No update pending on LayerManager",
209cdf0e10cSrcweir                                 mpLayerManager->isUpdatePending() );
210cdf0e10cSrcweir         CPPUNIT_ASSERT_MESSAGE( "Update failed on LayerManager",
211cdf0e10cSrcweir                                 mpLayerManager->update() );
212cdf0e10cSrcweir         CPPUNIT_ASSERT_MESSAGE( "Shape 4 must not be on background layer",
213cdf0e10cSrcweir                                 pShape4->getViewLayers().at(0).first != mpTestView );
214cdf0e10cSrcweir         mpLayerManager->leaveAnimationMode(pShape3);
215cdf0e10cSrcweir         CPPUNIT_ASSERT_MESSAGE( "Update failed on LayerManager",
216cdf0e10cSrcweir                                 mpLayerManager->update() );
217cdf0e10cSrcweir         CPPUNIT_ASSERT_MESSAGE( "Shape 4 must be on background layer",
218cdf0e10cSrcweir                                 pShape4->getViewLayers().at(0).first == mpTestView );
219cdf0e10cSrcweir 
220cdf0e10cSrcweir         mpLayerManager->deactivate();
221cdf0e10cSrcweir         CPPUNIT_ASSERT_MESSAGE( "Update pending on deactivated LayerManager",
222cdf0e10cSrcweir                                 !mpLayerManager->isUpdatePending() );
223cdf0e10cSrcweir     }
224cdf0e10cSrcweir 
testShapeRepaint()225cdf0e10cSrcweir     void testShapeRepaint()
226cdf0e10cSrcweir     {
227cdf0e10cSrcweir         TestShapeSharedPtr pShape2( createTestShape(
228cdf0e10cSrcweir             basegfx::B2DRange(0.0,0.0,10.0,10.0),
229cdf0e10cSrcweir             2.0));
230cdf0e10cSrcweir         TestShapeSharedPtr pShape3( createTestShape(
231cdf0e10cSrcweir             basegfx::B2DRange(0.0,0.0,10.0,10.0),
232cdf0e10cSrcweir             3.0));
233cdf0e10cSrcweir         TestShapeSharedPtr pShape4( createTestShape(
234cdf0e10cSrcweir             basegfx::B2DRange(0.0,0.0,10.0,10.0),
235cdf0e10cSrcweir             4.0));
236cdf0e10cSrcweir         TestShapeSharedPtr pShape5( createTestShape(
237cdf0e10cSrcweir             basegfx::B2DRange(20.0,20.0,30.0,30.0),
238cdf0e10cSrcweir             4.0));
239cdf0e10cSrcweir 
240cdf0e10cSrcweir         mpLayerManager->addShape(mpTestShape);
241cdf0e10cSrcweir         mpLayerManager->addShape(pShape2);
242cdf0e10cSrcweir         mpLayerManager->enterAnimationMode(pShape2);
243cdf0e10cSrcweir         mpLayerManager->addShape(pShape3);
244cdf0e10cSrcweir         mpLayerManager->addShape(pShape4);
245cdf0e10cSrcweir         mpLayerManager->addShape(pShape5);
246cdf0e10cSrcweir 
247cdf0e10cSrcweir         mpLayerManager->activate( false );
248cdf0e10cSrcweir         mpLayerManager->update();
249cdf0e10cSrcweir 
250cdf0e10cSrcweir         CPPUNIT_ASSERT_MESSAGE( "First shape not rendered",
251cdf0e10cSrcweir                                 mpTestShape->getNumRenders() == 1 );
252cdf0e10cSrcweir         CPPUNIT_ASSERT_MESSAGE( "Second shape not rendered",
253cdf0e10cSrcweir                                 pShape2->getNumRenders() == 1 );
254cdf0e10cSrcweir         CPPUNIT_ASSERT_MESSAGE( "Third shape not rendered",
255cdf0e10cSrcweir                                 pShape3->getNumRenders() == 1 );
256cdf0e10cSrcweir         CPPUNIT_ASSERT_MESSAGE( "Fourth shape not rendered",
257cdf0e10cSrcweir                                 pShape4->getNumRenders() == 1 );
258cdf0e10cSrcweir         CPPUNIT_ASSERT_MESSAGE( "Fifth shape not rendered",
259cdf0e10cSrcweir                                 pShape5->getNumRenders() == 1 );
260cdf0e10cSrcweir 
261cdf0e10cSrcweir         mpLayerManager->enterAnimationMode(pShape4);
262cdf0e10cSrcweir         mpLayerManager->update();
263cdf0e10cSrcweir 
264cdf0e10cSrcweir         CPPUNIT_ASSERT_MESSAGE( "First shape not rendered",
265cdf0e10cSrcweir                                 mpTestShape->getNumRenders() == 1 );
266cdf0e10cSrcweir         CPPUNIT_ASSERT_MESSAGE( "Second shape not rendered",
267cdf0e10cSrcweir                                 pShape2->getNumRenders() == 1 );
268cdf0e10cSrcweir         CPPUNIT_ASSERT_MESSAGE( "Third shape not rendered",
269cdf0e10cSrcweir                                 pShape3->getNumRenders() == 2 );
270cdf0e10cSrcweir         CPPUNIT_ASSERT_MESSAGE( "Fourth shape not rendered",
271cdf0e10cSrcweir                                 pShape4->getNumRenders() == 2 );
272cdf0e10cSrcweir         CPPUNIT_ASSERT_MESSAGE( "Fifth shape not rendered",
273cdf0e10cSrcweir                                 pShape5->getNumRenders() == 2 );
274cdf0e10cSrcweir 
275cdf0e10cSrcweir         mpLayerManager->leaveAnimationMode(pShape2);
276cdf0e10cSrcweir         mpLayerManager->leaveAnimationMode(pShape4);
277cdf0e10cSrcweir         mpLayerManager->update();
278cdf0e10cSrcweir 
279cdf0e10cSrcweir         CPPUNIT_ASSERT_MESSAGE( "First shape not rendered #2",
280cdf0e10cSrcweir                                 mpTestShape->getNumRenders() == 2 );
281cdf0e10cSrcweir         CPPUNIT_ASSERT_MESSAGE( "Second shape not rendered #2",
282cdf0e10cSrcweir                                 pShape2->getNumRenders() == 2 );
283cdf0e10cSrcweir         CPPUNIT_ASSERT_MESSAGE( "Third shape not rendered #2",
284cdf0e10cSrcweir                                 pShape3->getNumRenders() == 3 );
285cdf0e10cSrcweir         CPPUNIT_ASSERT_MESSAGE( "Fourth shape not rendered #2",
286cdf0e10cSrcweir                                 pShape4->getNumRenders() == 3 );
287cdf0e10cSrcweir         CPPUNIT_ASSERT_MESSAGE( "Fifth shape not rendered #2",
288cdf0e10cSrcweir                                 pShape5->getNumRenders() == 3 );
289cdf0e10cSrcweir     }
290cdf0e10cSrcweir 
testRefCounting()291cdf0e10cSrcweir     void testRefCounting()
292cdf0e10cSrcweir     {
293cdf0e10cSrcweir         TestShapeSharedPtr pShape2( createTestShape(
294cdf0e10cSrcweir             basegfx::B2DRange(0.0,0.0,10.0,10.0),
295cdf0e10cSrcweir             2.0));
296cdf0e10cSrcweir         TestShapeSharedPtr pShape3( createTestShape(
297cdf0e10cSrcweir             basegfx::B2DRange(0.0,0.0,10.0,10.0),
298cdf0e10cSrcweir             3.0));
299cdf0e10cSrcweir         TestShapeSharedPtr pShape4( createTestShape(
300cdf0e10cSrcweir             basegfx::B2DRange(0.0,0.0,10.0,10.0),
301cdf0e10cSrcweir             4.0));
302cdf0e10cSrcweir 
303cdf0e10cSrcweir         mpLayerManager->addShape(mpTestShape);
304cdf0e10cSrcweir         mpLayerManager->addShape(pShape2);
305cdf0e10cSrcweir         mpLayerManager->addShape(pShape3);
306cdf0e10cSrcweir         mpLayerManager->addShape(pShape4);
307cdf0e10cSrcweir 
308cdf0e10cSrcweir         mpLayerManager->removeShape(mpTestShape);
309cdf0e10cSrcweir         mpLayerManager->removeShape(pShape2);
310cdf0e10cSrcweir         mpLayerManager->removeShape(pShape3);
311cdf0e10cSrcweir         mpLayerManager->removeShape(pShape4);
312cdf0e10cSrcweir 
313cdf0e10cSrcweir         CPPUNIT_ASSERT_MESSAGE( "Shape 1 must have refcount of 1",
314cdf0e10cSrcweir                                 mpTestShape.use_count() == 1 );
315cdf0e10cSrcweir         CPPUNIT_ASSERT_MESSAGE( "Shape 2 must have refcount of ",
316cdf0e10cSrcweir                                 pShape2.use_count() == 1 );
317cdf0e10cSrcweir         CPPUNIT_ASSERT_MESSAGE( "Shape 3 must have refcount of 1",
318cdf0e10cSrcweir                                 pShape3.use_count() == 1 );
319cdf0e10cSrcweir         CPPUNIT_ASSERT_MESSAGE( "Shape 4 must have refcount of",
320cdf0e10cSrcweir                                 pShape4.use_count() == 1 );
321cdf0e10cSrcweir 
322cdf0e10cSrcweir 
323cdf0e10cSrcweir         mpLayerManager->addShape(mpTestShape);
324cdf0e10cSrcweir         mpLayerManager->addShape(pShape2);
325cdf0e10cSrcweir         mpLayerManager->addShape(pShape3);
326cdf0e10cSrcweir         mpLayerManager->addShape(pShape4);
327cdf0e10cSrcweir 
328cdf0e10cSrcweir         mpLayerManager->activate( false );
329cdf0e10cSrcweir         mpLayerManager->update();
330cdf0e10cSrcweir 
331cdf0e10cSrcweir         mpLayerManager->removeShape(mpTestShape);
332cdf0e10cSrcweir         mpLayerManager->removeShape(pShape2);
333cdf0e10cSrcweir         mpLayerManager->removeShape(pShape3);
334cdf0e10cSrcweir         mpLayerManager->removeShape(pShape4);
335cdf0e10cSrcweir 
336cdf0e10cSrcweir         CPPUNIT_ASSERT_MESSAGE( "Shape 1 must have refcount of 1",
337cdf0e10cSrcweir                                 mpTestShape.use_count() == 1 );
338cdf0e10cSrcweir         CPPUNIT_ASSERT_MESSAGE( "Shape 2 must have refcount of ",
339cdf0e10cSrcweir                                 pShape2.use_count() == 1 );
340cdf0e10cSrcweir         CPPUNIT_ASSERT_MESSAGE( "Shape 3 must have refcount of 1",
341cdf0e10cSrcweir                                 pShape3.use_count() == 1 );
342cdf0e10cSrcweir         CPPUNIT_ASSERT_MESSAGE( "Shape 4 must have refcount of 1",
343cdf0e10cSrcweir                                 pShape4.use_count() == 1 );
344cdf0e10cSrcweir 
345cdf0e10cSrcweir         maViews.removeView(mpTestView);
346cdf0e10cSrcweir         mpLayerManager->viewRemoved(mpTestView);
347cdf0e10cSrcweir         CPPUNIT_ASSERT_MESSAGE( "View must have refcount of 1",
348cdf0e10cSrcweir                                 mpTestView.use_count() == 1 );
349cdf0e10cSrcweir     }
350cdf0e10cSrcweir 
351cdf0e10cSrcweir     // hook up the test
352cdf0e10cSrcweir     CPPUNIT_TEST_SUITE(LayerManagerTest);
353cdf0e10cSrcweir     CPPUNIT_TEST(testBasics);
354cdf0e10cSrcweir     CPPUNIT_TEST(testLayer);
355cdf0e10cSrcweir     CPPUNIT_TEST(testShapeOrdering);
356cdf0e10cSrcweir     CPPUNIT_TEST(testShapeRepaint);
357cdf0e10cSrcweir     CPPUNIT_TEST(testRefCounting);
358cdf0e10cSrcweir     CPPUNIT_TEST_SUITE_END();
359cdf0e10cSrcweir 
360cdf0e10cSrcweir }; // class LayerManagerTest
361cdf0e10cSrcweir 
362cdf0e10cSrcweir // -----------------------------------------------------------------------------
363cdf0e10cSrcweir CPPUNIT_TEST_SUITE_NAMED_REGISTRATION(LayerManagerTest, "LayerManagerTest");
364cdf0e10cSrcweir } // namespace
365cdf0e10cSrcweir 
366cdf0e10cSrcweir 
367