summaryrefslogtreecommitdiffstats
path: root/slideshow/test
diff options
context:
space:
mode:
Diffstat (limited to '')
-rw-r--r--slideshow/test/slidetest.cxx368
-rw-r--r--slideshow/test/tests.hxx56
-rw-r--r--slideshow/test/testshape.cxx205
-rw-r--r--slideshow/test/testview.cxx279
-rw-r--r--slideshow/test/views.cxx71
5 files changed, 979 insertions, 0 deletions
diff --git a/slideshow/test/slidetest.cxx b/slideshow/test/slidetest.cxx
new file mode 100644
index 000000000..ca5278a7a
--- /dev/null
+++ b/slideshow/test/slidetest.cxx
@@ -0,0 +1,368 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*
+ * This file is part of the LibreOffice project.
+ *
+ * This Source Code Form is subject to the terms of the Mozilla Public
+ * License, v. 2.0. If a copy of the MPL was not distributed with this
+ * file, You can obtain one at http://mozilla.org/MPL/2.0/.
+ *
+ * This file incorporates work covered by the following license notice:
+ *
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed
+ * with this work for additional information regarding copyright
+ * ownership. The ASF licenses this file to you under the Apache
+ * License, Version 2.0 (the "License"); you may not use this file
+ * except in compliance with the License. You may obtain a copy of
+ * the License at http://www.apache.org/licenses/LICENSE-2.0 .
+ */
+
+#include <sal/types.h>
+#include <cppunit/TestAssert.h>
+#include <cppunit/TestFixture.h>
+#include <cppunit/extensions/HelperMacros.h>
+#include <cppunit/plugin/TestPlugIn.h>
+
+#include <unoview.hxx>
+#include <unoviewcontainer.hxx>
+#include "tests.hxx"
+#include <../engine/slide/layermanager.hxx>
+#include <../engine/slide/layer.hxx>
+
+namespace target = slideshow::internal;
+using namespace ::com::sun::star;
+
+namespace
+{
+
+class LayerManagerTest : public CppUnit::TestFixture
+{
+ target::UnoViewContainer maViews;
+ target::LayerManagerSharedPtr mpLayerManager;
+ TestViewSharedPtr mpTestView;
+ TestShapeSharedPtr mpTestShape;
+
+public:
+ void setUp() override
+ {
+ mpTestShape = createTestShape(
+ basegfx::B2DRange(0.0,0.0,10.0,10.0),
+ 1.0);
+ mpTestView = createTestView();
+ maViews.addView( mpTestView );
+
+ mpLayerManager =
+ std::make_shared<target::LayerManager>(
+ maViews,
+ false );
+ }
+
+ void tearDown() override
+ {
+ mpLayerManager.reset();
+ maViews.dispose();
+ }
+
+ void testLayer()
+ {
+ target::LayerSharedPtr pBgLayer(
+ target::Layer::createBackgroundLayer() );
+ pBgLayer->addView( mpTestView );
+
+ target::LayerSharedPtr pFgLayer(
+ target::Layer::createLayer() );
+ pFgLayer->addView( mpTestView );
+
+ CPPUNIT_ASSERT_MESSAGE( "BG layer must confess that!",
+ pBgLayer->isBackgroundLayer() );
+ CPPUNIT_ASSERT_MESSAGE( "FG layer lies!",
+ !pFgLayer->isBackgroundLayer() );
+
+ 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() );
+
+ TestShapeSharedPtr pTestShape2 = createTestShape(
+ basegfx::B2DRange(0.0,0.0,1.0,1.0),
+ 1.0);
+ pFgLayer->updateBounds( pTestShape2 );
+ CPPUNIT_ASSERT_MESSAGE( "FG layer must resize!",
+ pFgLayer->commitBounds() );
+ }
+
+ void testBasics()
+ {
+ mpLayerManager->activate();
+
+ 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() );
+
+ mpLayerManager->deactivate();
+ }
+
+ void testShapeOrdering()
+ {
+ TestShapeSharedPtr pShape2( createTestShape(
+ basegfx::B2DRange(0.0,0.0,10.0,10.0),
+ 2.0));
+ TestShapeSharedPtr pShape3( createTestShape(
+ basegfx::B2DRange(0.0,0.0,10.0,10.0),
+ 3.0));
+ TestShapeSharedPtr pShape4( createTestShape(
+ basegfx::B2DRange(0.0,0.0,10.0,10.0),
+ 4.0));
+
+ mpLayerManager->addShape(mpTestShape);
+ mpLayerManager->addShape(pShape2);
+ mpLayerManager->addShape(pShape3);
+ mpLayerManager->addShape(pShape4);
+
+ mpLayerManager->activate();
+
+ // 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() );
+ }
+
+ void testShapeRepaint()
+ {
+ TestShapeSharedPtr pShape2( createTestShape(
+ basegfx::B2DRange(0.0,0.0,10.0,10.0),
+ 2.0));
+ TestShapeSharedPtr pShape3( createTestShape(
+ basegfx::B2DRange(0.0,0.0,10.0,10.0),
+ 3.0));
+ TestShapeSharedPtr pShape4( createTestShape(
+ basegfx::B2DRange(0.0,0.0,10.0,10.0),
+ 4.0));
+ TestShapeSharedPtr pShape5( createTestShape(
+ basegfx::B2DRange(20.0,20.0,30.0,30.0),
+ 4.0));
+
+ mpLayerManager->addShape(mpTestShape);
+ mpLayerManager->addShape(pShape2);
+ mpLayerManager->addShape(pShape3);
+ mpLayerManager->addShape(pShape4);
+ mpLayerManager->addShape(pShape5);
+
+ mpLayerManager->activate();
+
+ mpLayerManager->enterAnimationMode(pShape2);
+ mpLayerManager->update();
+
+ CPPUNIT_ASSERT_EQUAL_MESSAGE( "First shape not rendered",
+ sal_Int32(1), mpTestShape->getNumRenders() );
+ // CPPUNIT_ASSERT_MESSAGE( "Second shape not rendered",
+ // pShape2->getNumRenders() == 1 );
+ CPPUNIT_ASSERT_EQUAL_MESSAGE( "Second shape not rendered",
+ sal_Int32(0), pShape2->getNumRenders() );
+ CPPUNIT_ASSERT_EQUAL_MESSAGE( "Third shape not rendered",
+ sal_Int32(1), pShape3->getNumRenders() );
+ CPPUNIT_ASSERT_EQUAL_MESSAGE( "Fourth shape not rendered",
+ sal_Int32(1), pShape4->getNumRenders() );
+ CPPUNIT_ASSERT_EQUAL_MESSAGE( "Fifth shape not rendered",
+ sal_Int32(1), pShape5->getNumRenders() );
+
+ mpLayerManager->enterAnimationMode(pShape4);
+ mpLayerManager->update();
+
+ CPPUNIT_ASSERT_EQUAL_MESSAGE( "First shape not rendered",
+ sal_Int32(1), mpTestShape->getNumRenders() );
+ // CPPUNIT_ASSERT_MESSAGE( "Second shape not rendered",
+ // pShape2->getNumRenders() == 1 );
+ CPPUNIT_ASSERT_EQUAL_MESSAGE( "Second shape not rendered",
+ sal_Int32(0), pShape2->getNumRenders() );
+ CPPUNIT_ASSERT_EQUAL_MESSAGE( "Third shape not rendered",
+ sal_Int32(2), pShape3->getNumRenders() );
+ // interesting - windows does not render this? # == 1...
+ // CPPUNIT_ASSERT_EQUAL_MESSAGE( "Fourth shape not rendered",
+ // sal_Int32(2), pShape4->getNumRenders() );
+ // interesting - windows does not render this? # == 1...
+ // CPPUNIT_ASSERT_EQUAL_MESSAGE( "Fifth shape not rendered",
+ // sal_Int32(2), pShape5->getNumRenders() );
+
+ mpLayerManager->leaveAnimationMode(pShape2);
+ mpLayerManager->leaveAnimationMode(pShape4);
+ mpLayerManager->update();
+
+ // first shape is on slide background, *now* gets rendered
+ // CPPUNIT_ASSERT_MESSAGE( "First shape not rendered #2",
+ // mpTestShape->getNumRenders() == 1 );
+ CPPUNIT_ASSERT_EQUAL_MESSAGE( "First shape not rendered #2",
+ sal_Int32(2), mpTestShape->getNumRenders() );
+ // CPPUNIT_ASSERT_MESSAGE( "Second shape not rendered #2",
+ // pShape2->getNumRenders() == 2 );
+ CPPUNIT_ASSERT_EQUAL_MESSAGE( "Second shape not rendered #2",
+ sal_Int32(1), pShape2->getNumRenders() );
+ CPPUNIT_ASSERT_EQUAL_MESSAGE( "Third shape not rendered #2",
+ sal_Int32(3), pShape3->getNumRenders() );
+ // interesting - windows does not render this? # == 2...
+ // CPPUNIT_ASSERT_EQUAL_MESSAGE( "Fourth shape not rendered #2",
+ // sal_Int32(3), pShape4->getNumRenders() );
+ // interesting - windows does not render this? # == 2...
+ // CPPUNIT_ASSERT_EQUAL_MESSAGE( "Fifth shape not rendered #2",
+ // sal_Int32(3), pShape5->getNumRenders() );
+ }
+
+ void testRefCounting()
+ {
+ TestShapeSharedPtr pShape2( createTestShape(
+ basegfx::B2DRange(0.0,0.0,10.0,10.0),
+ 2.0));
+ TestShapeSharedPtr pShape3( createTestShape(
+ basegfx::B2DRange(0.0,0.0,10.0,10.0),
+ 3.0));
+ TestShapeSharedPtr pShape4( createTestShape(
+ basegfx::B2DRange(0.0,0.0,10.0,10.0),
+ 4.0));
+
+ mpLayerManager->addShape(mpTestShape);
+ mpLayerManager->addShape(pShape2);
+ mpLayerManager->addShape(pShape3);
+ mpLayerManager->addShape(pShape4);
+
+ mpLayerManager->removeShape(mpTestShape);
+ mpLayerManager->removeShape(pShape2);
+ mpLayerManager->removeShape(pShape3);
+ mpLayerManager->removeShape(pShape4);
+
+ 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() );
+
+
+ mpLayerManager->addShape(mpTestShape);
+ mpLayerManager->addShape(pShape2);
+ mpLayerManager->addShape(pShape3);
+ mpLayerManager->addShape(pShape4);
+
+ mpLayerManager->activate();
+ mpLayerManager->update();
+
+ mpLayerManager->removeShape(mpTestShape);
+ mpLayerManager->removeShape(pShape2);
+ mpLayerManager->removeShape(pShape3);
+ mpLayerManager->removeShape(pShape4);
+
+ 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();
+
+}; // class LayerManagerTest
+
+
+CPPUNIT_TEST_SUITE_REGISTRATION(LayerManagerTest);
+} // namespace
+
+CPPUNIT_PLUGIN_IMPLEMENT();
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/slideshow/test/tests.hxx b/slideshow/test/tests.hxx
new file mode 100644
index 000000000..36d80607c
--- /dev/null
+++ b/slideshow/test/tests.hxx
@@ -0,0 +1,56 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*
+ * This file is part of the LibreOffice project.
+ *
+ * This Source Code Form is subject to the terms of the Mozilla Public
+ * License, v. 2.0. If a copy of the MPL was not distributed with this
+ * file, You can obtain one at http://mozilla.org/MPL/2.0/.
+ *
+ * This file incorporates work covered by the following license notice:
+ *
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed
+ * with this work for additional information regarding copyright
+ * ownership. The ASF licenses this file to you under the Apache
+ * License, Version 2.0 (the "License"); you may not use this file
+ * except in compliance with the License. You may obtain a copy of
+ * the License at http://www.apache.org/licenses/LICENSE-2.0 .
+ */
+
+#ifndef INCLUDED_SLIDESHOW_TEST_TESTS_HXX
+#define INCLUDED_SLIDESHOW_TEST_TESTS_HXX
+
+#include <animatableshape.hxx>
+#include <unoview.hxx>
+#include <memory>
+
+namespace basegfx{ class B1DRange; class B2DRange; class B2DVector; }
+
+class TestView : public slideshow::internal::UnoView
+{
+public:
+ virtual basegfx::B2DRange getBounds() const = 0;
+
+ virtual std::vector<std::shared_ptr<TestView> > getViewLayers() const = 0;
+};
+
+typedef std::shared_ptr<TestView> TestViewSharedPtr;
+TestViewSharedPtr createTestView();
+
+
+class TestShape : public slideshow::internal::AnimatableShape
+{
+public:
+ virtual std::vector<
+ std::pair<slideshow::internal::ViewLayerSharedPtr,bool> > getViewLayers() const = 0;
+ virtual sal_Int32 getNumUpdates() const = 0;
+ virtual sal_Int32 getNumRenders() const = 0;
+};
+
+typedef std::shared_ptr<TestShape> TestShapeSharedPtr;
+TestShapeSharedPtr createTestShape(const basegfx::B2DRange& rRect,
+ double nPrio);
+
+#endif // INCLUDED_SLIDESHOW_TEST_TESTS_HXX
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/slideshow/test/testshape.cxx b/slideshow/test/testshape.cxx
new file mode 100644
index 000000000..db7031070
--- /dev/null
+++ b/slideshow/test/testshape.cxx
@@ -0,0 +1,205 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*
+ * This file is part of the LibreOffice project.
+ *
+ * This Source Code Form is subject to the terms of the Mozilla Public
+ * License, v. 2.0. If a copy of the MPL was not distributed with this
+ * file, You can obtain one at http://mozilla.org/MPL/2.0/.
+ *
+ * This file incorporates work covered by the following license notice:
+ *
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed
+ * with this work for additional information regarding copyright
+ * ownership. The ASF licenses this file to you under the Apache
+ * License, Version 2.0 (the "License"); you may not use this file
+ * except in compliance with the License. You may obtain a copy of
+ * the License at http://www.apache.org/licenses/LICENSE-2.0 .
+ */
+
+#include <sal/types.h>
+#include <cppunit/TestAssert.h>
+
+#include <cppuhelper/compbase.hxx>
+#include <cppuhelper/basemutex.hxx>
+#include <comphelper/make_shared_from_uno.hxx>
+
+#include <basegfx/range/b2drange.hxx>
+
+#include "tests.hxx"
+
+namespace target = slideshow::internal;
+using namespace ::com::sun::star;
+
+// our test shape subject
+typedef ::cppu::WeakComponentImplHelper< drawing::XShape > ShapeBase;
+
+namespace {
+
+class ImplTestShape : public TestShape,
+ private cppu::BaseMutex,
+ public ShapeBase
+{
+ typedef std::vector<std::pair<target::ViewLayerSharedPtr,bool> > ViewVector;
+ ViewVector maViewLayers;
+ const basegfx::B2DRange maRect;
+ const double mnPrio;
+ sal_Int32 mnAnimated;
+ mutable sal_Int32 mnNumUpdates;
+ mutable sal_Int32 mnNumRenders;
+
+public:
+ ImplTestShape( const basegfx::B2DRange& rRect,
+ double nPrio ) :
+ ShapeBase( m_aMutex ),
+ maViewLayers(),
+ maRect( rRect ),
+ mnPrio( nPrio ),
+ mnAnimated(0),
+ mnNumUpdates(0),
+ mnNumRenders(0)
+ {}
+
+
+private:
+ // TestShape
+ virtual std::vector<std::pair<target::ViewLayerSharedPtr,bool> > getViewLayers() const override
+ {
+ return maViewLayers;
+ }
+ virtual sal_Int32 getNumUpdates() const override
+ {
+ return mnNumUpdates;
+ }
+ virtual sal_Int32 getNumRenders() const override
+ {
+ return mnNumRenders;
+ }
+
+ // XShape
+ virtual OUString SAL_CALL getShapeType( ) override
+ {
+ CPPUNIT_ASSERT_MESSAGE( "TestShape::getShapeType: unexpected method call", false );
+ return OUString();
+ }
+
+ virtual awt::Point SAL_CALL getPosition( ) override
+ {
+ CPPUNIT_ASSERT_MESSAGE( "TestShape::getPosition: unexpected method call", false );
+ return awt::Point();
+ }
+
+ virtual void SAL_CALL setPosition( const awt::Point& ) override
+ {
+ CPPUNIT_ASSERT_MESSAGE( "TestShape::setPosition: unexpected method call", false );
+ }
+
+ virtual awt::Size SAL_CALL getSize( ) override
+ {
+ CPPUNIT_ASSERT_MESSAGE( "TestShape::getSize: unexpected method call", false );
+ return awt::Size();
+ }
+
+ virtual void SAL_CALL setSize( const awt::Size& /*aSize*/ ) override
+ {
+ CPPUNIT_ASSERT_MESSAGE( "TestShape::setSize: unexpected method call", false );
+ }
+
+
+ // Shape
+ virtual uno::Reference< drawing::XShape > getXShape() const override
+ {
+ return uno::Reference< drawing::XShape >( const_cast<ImplTestShape*>(this) );
+ }
+ virtual void addViewLayer( const target::ViewLayerSharedPtr& rNewLayer,
+ bool bRedrawLayer ) override
+ {
+ maViewLayers.push_back( std::make_pair(rNewLayer,bRedrawLayer) );
+ }
+ virtual bool removeViewLayer( const target::ViewLayerSharedPtr& rNewLayer ) override
+ {
+ if( std::none_of(
+ maViewLayers.begin(),
+ maViewLayers.end(),
+ [&rNewLayer]
+ ( const ViewVector::value_type& cp )
+ { return cp.first == rNewLayer; } ) )
+ throw std::exception();
+
+ maViewLayers.erase(
+ std::remove_if(
+ maViewLayers.begin(),
+ maViewLayers.end(),
+ [&rNewLayer]
+ ( const ViewVector::value_type& cp )
+ { return cp.first == rNewLayer; } ) );
+ return true;
+ }
+ virtual void clearAllViewLayers() override
+ {
+ maViewLayers.clear();
+ }
+
+ virtual bool update() const override
+ {
+ ++mnNumUpdates;
+ return true;
+ }
+ virtual bool render() const override
+ {
+ ++mnNumRenders;
+ return true;
+ }
+ virtual bool isContentChanged() const override
+ {
+ return true;
+ }
+ virtual ::basegfx::B2DRectangle getBounds() const override
+ {
+ return maRect;
+ }
+ virtual ::basegfx::B2DRectangle getDomBounds() const override
+ {
+ return maRect;
+ }
+ virtual ::basegfx::B2DRectangle getUpdateArea() const override
+ {
+ return maRect;
+ }
+
+ virtual bool isVisible() const override
+ {
+ return true;
+ }
+ virtual double getPriority() const override
+ {
+ return mnPrio;
+ }
+ virtual bool isBackgroundDetached() const override
+ {
+ return mnAnimated != 0;
+ }
+
+ // AnimatableShape
+ virtual void enterAnimationMode() override
+ {
+ ++mnAnimated;
+ }
+
+ virtual void leaveAnimationMode() override
+ {
+ --mnAnimated;
+ }
+};
+
+}
+
+TestShapeSharedPtr createTestShape(const basegfx::B2DRange& rRect,
+ double nPrio)
+{
+ return TestShapeSharedPtr(
+ comphelper::make_shared_from_UNO(
+ new ImplTestShape(rRect,nPrio)) );
+}
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/slideshow/test/testview.cxx b/slideshow/test/testview.cxx
new file mode 100644
index 000000000..237fb3d38
--- /dev/null
+++ b/slideshow/test/testview.cxx
@@ -0,0 +1,279 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*
+ * This file is part of the LibreOffice project.
+ *
+ * This Source Code Form is subject to the terms of the Mozilla Public
+ * License, v. 2.0. If a copy of the MPL was not distributed with this
+ * file, You can obtain one at http://mozilla.org/MPL/2.0/.
+ *
+ * This file incorporates work covered by the following license notice:
+ *
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed
+ * with this work for additional information regarding copyright
+ * ownership. The ASF licenses this file to you under the Apache
+ * License, Version 2.0 (the "License"); you may not use this file
+ * except in compliance with the License. You may obtain a copy of
+ * the License at http://www.apache.org/licenses/LICENSE-2.0 .
+ */
+
+#include <sal/types.h>
+
+#include <cppuhelper/compbase.hxx>
+#include <cppuhelper/basemutex.hxx>
+#include <comphelper/make_shared_from_uno.hxx>
+
+#include <basegfx/matrix/b2dhommatrix.hxx>
+#include <basegfx/range/b1drange.hxx>
+#include <basegfx/polygon/b2dpolypolygon.hxx>
+
+#include "tests.hxx"
+#include <view.hxx>
+#include <com/sun/star/presentation/XSlideShowView.hpp>
+
+#include <vector>
+#include <exception>
+
+
+namespace target = slideshow::internal;
+using namespace ::com::sun::star;
+
+// our test view subject
+typedef ::cppu::WeakComponentImplHelper< presentation::XSlideShowView > ViewBase;
+
+namespace {
+
+class ImplTestView : public TestView,
+ private cppu::BaseMutex,
+ public ViewBase
+{
+ mutable std::vector<std::pair<basegfx::B2DVector,double> > maCreatedSprites;
+ mutable std::vector<TestViewSharedPtr> maViewLayers;
+ basegfx::B2DRange maBounds;
+ basegfx::B1DRange maPriority;
+ bool mbIsClipSet;
+ bool mbIsClipEmptied;
+ bool mbDisposed;
+
+
+public:
+ ImplTestView() :
+ ViewBase(m_aMutex),
+ maCreatedSprites(),
+ maViewLayers(),
+ maBounds(),
+ maPriority(),
+ mbIsClipSet(false),
+ mbIsClipEmptied(false),
+ mbDisposed( false )
+ {
+ }
+
+ // XSlideShowView
+ virtual uno::Reference< rendering::XSpriteCanvas > SAL_CALL getCanvas( ) override
+ {
+ return uno::Reference< rendering::XSpriteCanvas >();
+ }
+
+ virtual void SAL_CALL clear( ) override
+ {
+ }
+
+ virtual geometry::AffineMatrix2D SAL_CALL getTransformation( ) override
+ {
+ return geometry::AffineMatrix2D();
+ }
+
+ virtual ::css::geometry::IntegerSize2D SAL_CALL getTranslationOffset() override
+ {
+ return geometry::IntegerSize2D();
+ }
+
+ virtual geometry::IntegerSize2D getTranslationOffset() const override
+ {
+ return geometry::IntegerSize2D();
+ }
+
+ virtual void SAL_CALL addTransformationChangedListener( const uno::Reference< util::XModifyListener >& ) override
+ {
+ }
+
+ virtual void SAL_CALL removeTransformationChangedListener( const uno::Reference< util::XModifyListener >& ) override
+ {
+ }
+
+ virtual void SAL_CALL addPaintListener( const uno::Reference< awt::XPaintListener >& ) override
+ {
+ }
+
+ virtual void SAL_CALL removePaintListener( const uno::Reference< awt::XPaintListener >& ) override
+ {
+ }
+
+ virtual void SAL_CALL addMouseListener( const uno::Reference< awt::XMouseListener >& ) override
+ {
+ }
+
+ virtual void SAL_CALL removeMouseListener( const uno::Reference< awt::XMouseListener >& ) override
+ {
+ }
+
+ virtual void SAL_CALL addMouseMotionListener( const uno::Reference< awt::XMouseMotionListener >& ) override
+ {
+ }
+
+ virtual void SAL_CALL removeMouseMotionListener( const uno::Reference< awt::XMouseMotionListener >& ) override
+ {
+ }
+
+ virtual void SAL_CALL setMouseCursor( ::sal_Int16 ) override
+ {
+ }
+
+ virtual awt::Rectangle SAL_CALL getCanvasArea( ) override
+ {
+ return awt::Rectangle(0,0,100,100);
+ }
+
+ virtual basegfx::B2DRange getBounds() const override
+ {
+ return maBounds;
+ }
+
+ virtual std::vector<std::shared_ptr<TestView> > getViewLayers() const override
+ {
+ return maViewLayers;
+ }
+
+ // ViewLayer
+ virtual bool isOnView(target::ViewSharedPtr const& /*rView*/) const override
+ {
+ return true;
+ }
+
+ virtual ::cppcanvas::CanvasSharedPtr getCanvas() const override
+ {
+ return ::cppcanvas::CanvasSharedPtr();
+ }
+
+ virtual ::cppcanvas::CustomSpriteSharedPtr createSprite( const ::basegfx::B2DSize& rSpriteSizePixel,
+ double nPriority ) const override
+ {
+ maCreatedSprites.push_back( std::make_pair(rSpriteSizePixel,nPriority) );
+
+ return ::cppcanvas::CustomSpriteSharedPtr();
+ }
+
+ virtual void setPriority( const basegfx::B1DRange& rRange ) override
+ {
+ maPriority = rRange;
+ }
+
+ virtual ::basegfx::B2DHomMatrix getTransformation() const override
+ {
+ return ::basegfx::B2DHomMatrix();
+ }
+
+ virtual ::basegfx::B2DHomMatrix getSpriteTransformation() const override
+ {
+ return ::basegfx::B2DHomMatrix();
+ }
+
+ virtual void setClip( const ::basegfx::B2DPolyPolygon& rClip ) override
+ {
+ if( !mbIsClipSet )
+ {
+ if( rClip.count() > 0 )
+ mbIsClipSet = true;
+ }
+ else if( !mbIsClipEmptied )
+ {
+ if( rClip.count() == 0 )
+ mbIsClipEmptied = true;
+ }
+ else if( rClip.count() > 0 )
+ {
+ mbIsClipSet = true;
+ mbIsClipEmptied = false;
+ }
+ else
+ {
+ // unexpected call
+ throw std::exception();
+ }
+ }
+
+ virtual bool resize( const basegfx::B2DRange& rArea ) override
+ {
+ const bool bRet( maBounds != rArea );
+ maBounds = rArea;
+ return bRet;
+ }
+
+ virtual target::ViewLayerSharedPtr createViewLayer(
+ const basegfx::B2DRange& rLayerBounds ) const override
+ {
+ maViewLayers.push_back( std::make_shared<ImplTestView>());
+ maViewLayers.back()->resize( rLayerBounds );
+
+ return maViewLayers.back();
+ }
+
+ virtual bool updateScreen() const override
+ {
+ // misusing updateScreen for state reporting
+ return !mbDisposed;
+ }
+
+ virtual bool paintScreen() const override
+ {
+ // misusing updateScreen for state reporting
+ return !mbDisposed;
+ }
+
+ virtual void clear() const override
+ {
+ }
+
+ virtual void clearAll() const override
+ {
+ }
+
+ virtual void setViewSize( const ::basegfx::B2DSize& ) override
+ {
+ }
+
+ virtual void setCursorShape( sal_Int16 /*nPointerShape*/ ) override
+ {
+ }
+
+ virtual uno::Reference< presentation::XSlideShowView > getUnoView() const override
+ {
+ return uno::Reference< presentation::XSlideShowView >( const_cast<ImplTestView*>(this) );
+ }
+
+ virtual void _dispose() override
+ {
+ mbDisposed = true;
+ }
+
+ virtual bool isSoundEnabled() const override
+ {
+ return true;
+ }
+
+ virtual void setIsSoundEnabled (const bool /*bValue*/) override
+ {
+ }
+};
+
+}
+
+TestViewSharedPtr createTestView()
+{
+ return TestViewSharedPtr(
+ comphelper::make_shared_from_UNO(
+ new ImplTestView()) );
+}
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/slideshow/test/views.cxx b/slideshow/test/views.cxx
new file mode 100644
index 000000000..275de3ae3
--- /dev/null
+++ b/slideshow/test/views.cxx
@@ -0,0 +1,71 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*
+ * This file is part of the LibreOffice project.
+ *
+ * This Source Code Form is subject to the terms of the Mozilla Public
+ * License, v. 2.0. If a copy of the MPL was not distributed with this
+ * file, You can obtain one at http://mozilla.org/MPL/2.0/.
+ *
+ * This file incorporates work covered by the following license notice:
+ *
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed
+ * with this work for additional information regarding copyright
+ * ownership. The ASF licenses this file to you under the Apache
+ * License, Version 2.0 (the "License"); you may not use this file
+ * except in compliance with the License. You may obtain a copy of
+ * the License at http://www.apache.org/licenses/LICENSE-2.0 .
+ */
+
+#include <sal/types.h>
+#include <cppunit/TestAssert.h>
+#include <cppunit/TestFixture.h>
+#include <cppunit/extensions/HelperMacros.h>
+
+#include <unoviewcontainer.hxx>
+#include "tests.hxx"
+
+namespace target = slideshow::internal;
+using namespace ::com::sun::star;
+
+namespace
+{
+
+class UnoViewContainerTest : public CppUnit::TestFixture
+{
+public:
+ void testContainer()
+ {
+ target::UnoViewContainer aContainer;
+
+ TestViewSharedPtr pView = createTestView();
+ aContainer.addView( pView );
+
+ CPPUNIT_ASSERT_EQUAL_MESSAGE( "Testing container size",
+ std::ptrdiff_t(1),
+ std::distance( aContainer.begin(),
+ aContainer.end() ));
+ CPPUNIT_ASSERT_MESSAGE( "Testing disposedness",
+ pView->paintScreen() );
+ aContainer.dispose();
+ CPPUNIT_ASSERT_EQUAL_MESSAGE( "Testing dispose: container must be empty",
+ std::ptrdiff_t(0),
+ std::distance( aContainer.begin(),
+ aContainer.end() ));
+ CPPUNIT_ASSERT_MESSAGE( "Testing dispose: all elements must receive dispose",
+ !pView->paintScreen() );
+ }
+
+ // hook up the test
+ CPPUNIT_TEST_SUITE(UnoViewContainerTest);
+ CPPUNIT_TEST(testContainer);
+ //CPPUNIT_TEST(testLayerManager);
+ CPPUNIT_TEST_SUITE_END();
+
+}; // class UnoViewContainerTest
+
+
+CPPUNIT_TEST_SUITE_NAMED_REGISTRATION(UnoViewContainerTest, "UnoViewContainerTest");
+} // namespace
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */