diff options
Diffstat (limited to 'slideshow/test')
-rw-r--r-- | slideshow/test/demoshow.cxx | 580 | ||||
-rw-r--r-- | slideshow/test/export.map | 34 | ||||
-rw-r--r-- | slideshow/test/slidetest.cxx | 374 | ||||
-rw-r--r-- | slideshow/test/tests.hxx | 75 | ||||
-rw-r--r-- | slideshow/test/testshape.cxx | 229 | ||||
-rw-r--r-- | slideshow/test/testview.cxx | 306 | ||||
-rw-r--r-- | slideshow/test/views.cxx | 88 |
7 files changed, 0 insertions, 1686 deletions
diff --git a/slideshow/test/demoshow.cxx b/slideshow/test/demoshow.cxx deleted file mode 100644 index 0bf6f34a6..000000000 --- a/slideshow/test/demoshow.cxx +++ /dev/null @@ -1,580 +0,0 @@ -/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ -/************************************************************************* - * - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - * - * Copyright 2000, 2010 Oracle and/or its affiliates. - * - * OpenOffice.org - a multi-platform office productivity suite - * - * This file is part of OpenOffice.org. - * - * OpenOffice.org is free software: you can redistribute it and/or modify - * it under the terms of the GNU Lesser General Public License version 3 - * only, as published by the Free Software Foundation. - * - * OpenOffice.org is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Lesser General Public License version 3 for more details - * (a copy is included in the LICENSE file that accompanied this code). - * - * You should have received a copy of the GNU Lesser General Public License - * version 3 along with OpenOffice.org. If not, see - * <http://www.openoffice.org/license.html> - * for a copy of the LGPLv3 License. - * - ************************************************************************/ - -#include <sal/main.h> -#include <rtl/ref.hxx> -#include <rtl/bootstrap.hxx> - -#include <cppuhelper/bootstrap.hxx> -#include <cppuhelper/servicefactory.hxx> -#include <cppuhelper/interfacecontainer.hxx> -#include <cppuhelper/compbase1.hxx> -#include <cppuhelper/compbase2.hxx> - -#include <comphelper/processfactory.hxx> -#include <comphelper/broadcasthelper.hxx> -#include <comphelper/anytostring.hxx> -#include <cppuhelper/exc_hlp.hxx> - -#include <com/sun/star/lang/XMultiServiceFactory.hpp> -#include <com/sun/star/beans/XPropertySet.hpp> -#include <com/sun/star/rendering/XCanvas.hpp> -#include <com/sun/star/rendering/XSpriteCanvas.hpp> -#include <com/sun/star/presentation/XSlideShow.hpp> -#include <com/sun/star/presentation/XSlideShowView.hpp> -#include "com/sun/star/animations/TransitionType.hpp" -#include "com/sun/star/animations/TransitionSubType.hpp" - -#include <ucbhelper/contentbroker.hxx> -#include <ucbhelper/configurationkeys.hxx> - -#include <basegfx/matrix/b2dhommatrix.hxx> -#include <basegfx/matrix/b2dhommatrixtools.hxx> -#include <basegfx/tools/canvastools.hxx> -#include <basegfx/range/b2drectangle.hxx> -#include <basegfx/polygon/b2dpolygon.hxx> -#include <basegfx/polygon/b2dpolygontools.hxx> - -#include <cppcanvas/vclfactory.hxx> -#include <cppcanvas/basegfxfactory.hxx> -#include <cppcanvas/polypolygon.hxx> - -#include <canvas/canvastools.hxx> - -#include <vcl/dialog.hxx> -#include <vcl/timer.hxx> -#include <vcl/window.hxx> -#include <vcl/svapp.hxx> - -#include <stdio.h> -#include <unistd.h> - - -using namespace ::com::sun::star; - -namespace { - -typedef ::cppu::WeakComponentImplHelper1< presentation::XSlideShowView > ViewBase; -class View : public ::comphelper::OBaseMutex, - public ViewBase -{ -public: - explicit View( const uno::Reference< rendering::XSpriteCanvas >& rCanvas ) : - ViewBase( m_aMutex ), - mxCanvas( rCanvas ), - maPaintListeners( m_aMutex ), - maTransformationListeners( m_aMutex ), - maMouseListeners( m_aMutex ), - maMouseMotionListeners( m_aMutex ), - maTransform(), - maSize() - { - } - - void resize( const ::Size& rNewSize ) - { - maSize = rNewSize; - const sal_Int32 nSize( std::min( rNewSize.Width(), rNewSize.Height() ) - 10); - maTransform = basegfx::tools::createScaleTranslateB2DHomMatrix( - nSize, nSize, (rNewSize.Width() - nSize) / 2, (rNewSize.Height() - nSize) / 2); - - lang::EventObject aEvent( *this ); - maTransformationListeners.notifyEach( &util::XModifyListener::modified, - aEvent ); - } - - void repaint() - { - awt::PaintEvent aEvent( *this, - awt::Rectangle(), - 0 ); - maPaintListeners.notifyEach( &awt::XPaintListener::windowPaint, - aEvent ); - } - -private: - virtual ~View() {} - - virtual uno::Reference< rendering::XSpriteCanvas > SAL_CALL getCanvas( ) throw (uno::RuntimeException) - { - return mxCanvas; - } - - virtual void SAL_CALL clear( ) throw (uno::RuntimeException) - { - ::basegfx::B2DPolygon aPoly( ::basegfx::tools::createPolygonFromRect( - ::basegfx::B2DRectangle(0.0,0.0, - maSize.Width(), - maSize.Height() ))); - ::cppcanvas::SpriteCanvasSharedPtr pCanvas( - ::cppcanvas::VCLFactory::getInstance().createSpriteCanvas( mxCanvas )); - if( !pCanvas ) - return; - - ::cppcanvas::PolyPolygonSharedPtr pPolyPoly( - ::cppcanvas::BaseGfxFactory::getInstance().createPolyPolygon( pCanvas, - aPoly ) ); - if( !pPolyPoly ) - return; - - if( pPolyPoly ) - { - pPolyPoly->setRGBAFillColor( 0x808080FFU ); - pPolyPoly->draw(); - } - } - - virtual geometry::AffineMatrix2D SAL_CALL getTransformation( ) throw (uno::RuntimeException) - { - geometry::AffineMatrix2D aRes; - return basegfx::unotools::affineMatrixFromHomMatrix( aRes, - maTransform ); - } - - virtual void SAL_CALL addTransformationChangedListener( const uno::Reference< util::XModifyListener >& xListener ) throw (uno::RuntimeException) - { - maTransformationListeners.addInterface( xListener ); - } - - virtual void SAL_CALL removeTransformationChangedListener( const uno::Reference< util::XModifyListener >& xListener ) throw (uno::RuntimeException) - { - maTransformationListeners.removeInterface( xListener ); - } - - virtual void SAL_CALL addPaintListener( const uno::Reference< awt::XPaintListener >& xListener ) throw (uno::RuntimeException) - { - maPaintListeners.addInterface( xListener ); - } - - virtual void SAL_CALL removePaintListener( const uno::Reference< awt::XPaintListener >& xListener ) throw (uno::RuntimeException) - { - maPaintListeners.removeInterface( xListener ); - } - - virtual void SAL_CALL addMouseListener( const uno::Reference< awt::XMouseListener >& xListener ) throw (uno::RuntimeException) - { - maMouseListeners.addInterface( xListener ); - } - - virtual void SAL_CALL removeMouseListener( const uno::Reference< awt::XMouseListener >& xListener ) throw (uno::RuntimeException) - { - maMouseListeners.removeInterface( xListener ); - } - - virtual void SAL_CALL addMouseMotionListener( const uno::Reference< awt::XMouseMotionListener >& xListener ) throw (uno::RuntimeException) - { - maMouseMotionListeners.addInterface( xListener ); - } - - virtual void SAL_CALL removeMouseMotionListener( const uno::Reference< awt::XMouseMotionListener >& xListener ) throw (uno::RuntimeException) - { - maMouseMotionListeners.removeInterface( xListener ); - } - - virtual void SAL_CALL setMouseCursor( ::sal_Int16 /*nPointerShape*/ ) throw (uno::RuntimeException) - { - } - - virtual awt::Rectangle SAL_CALL getCanvasArea( ) throw (uno::RuntimeException) - { - return awt::Rectangle(0,0,maSize.Width(),maSize.Height()); - } - - uno::Reference< rendering::XSpriteCanvas > mxCanvas; - ::cppu::OInterfaceContainerHelper maPaintListeners; - ::cppu::OInterfaceContainerHelper maTransformationListeners; - ::cppu::OInterfaceContainerHelper maMouseListeners; - ::cppu::OInterfaceContainerHelper maMouseMotionListeners; - basegfx::B2DHomMatrix maTransform; - Size maSize; -}; - -typedef ::cppu::WeakComponentImplHelper2< drawing::XDrawPage, - beans::XPropertySet > SlideBase; -class DummySlide : public ::comphelper::OBaseMutex, - public SlideBase -{ -public: - DummySlide() : SlideBase( m_aMutex ) {} - -private: - // XDrawPage - virtual void SAL_CALL add( const uno::Reference< drawing::XShape >& /*xShape*/ ) throw (uno::RuntimeException) - { - } - - virtual void SAL_CALL remove( const uno::Reference< drawing::XShape >& /*xShape*/ ) throw (uno::RuntimeException) - { - } - - virtual ::sal_Int32 SAL_CALL getCount( ) throw (uno::RuntimeException) - { - return 0; - } - - virtual uno::Any SAL_CALL getByIndex( ::sal_Int32 /*Index*/ ) throw (lang::IndexOutOfBoundsException, lang::WrappedTargetException, uno::RuntimeException) - { - return uno::Any(); - } - - virtual uno::Type SAL_CALL getElementType( ) throw (uno::RuntimeException) - { - return uno::Type(); - } - - virtual ::sal_Bool SAL_CALL hasElements( ) throw (uno::RuntimeException) - { - return false; - } - - // XPropertySet - virtual uno::Reference< beans::XPropertySetInfo > SAL_CALL getPropertySetInfo( ) throw (uno::RuntimeException) - { - return uno::Reference< beans::XPropertySetInfo >(); - } - - virtual void SAL_CALL setPropertyValue( const ::rtl::OUString& /*aPropertyName*/, - const uno::Any& /*aValue*/ ) throw (beans::UnknownPropertyException, beans::PropertyVetoException, lang::IllegalArgumentException, lang::WrappedTargetException, uno::RuntimeException) - { - } - - virtual uno::Any SAL_CALL getPropertyValue( const ::rtl::OUString& PropertyName ) throw (beans::UnknownPropertyException, lang::WrappedTargetException, uno::RuntimeException) - { - typedef ::canvas::tools::ValueMap< sal_Int16 > PropMapT; - - // fixed PropertyValue map - static PropMapT::MapEntry lcl_propertyMap[] = - { - {"Height", 100}, - {"MinimalFrameNumber", 50}, - {"TransitionDuration", 10}, - {"TransitionSubtype", animations::TransitionSubType::FROMTOPLEFT}, - {"TransitionType", animations::TransitionType::PUSHWIPE}, - {"Width", 100} - }; - - static PropMapT aMap( lcl_propertyMap, - sizeof(lcl_propertyMap)/sizeof(*lcl_propertyMap), - true ); - - sal_Int16 aRes; - if( !aMap.lookup( PropertyName, aRes )) - return uno::Any(); - - return uno::makeAny(aRes); - } - - virtual void SAL_CALL addPropertyChangeListener( const ::rtl::OUString& /*aPropertyName*/, - const uno::Reference< beans::XPropertyChangeListener >& /*xListener*/ ) throw (beans::UnknownPropertyException, lang::WrappedTargetException, uno::RuntimeException) - { - } - - virtual void SAL_CALL removePropertyChangeListener( const ::rtl::OUString& /*aPropertyName*/, - const uno::Reference< beans::XPropertyChangeListener >& /*aListener*/ ) throw (beans::UnknownPropertyException, lang::WrappedTargetException, uno::RuntimeException) - { - } - - virtual void SAL_CALL addVetoableChangeListener( const ::rtl::OUString& /*PropertyName*/, - const uno::Reference< beans::XVetoableChangeListener >& /*aListener*/ ) throw (beans::UnknownPropertyException, lang::WrappedTargetException, uno::RuntimeException) - { - } - - virtual void SAL_CALL removeVetoableChangeListener( const ::rtl::OUString& /*PropertyName*/, - const uno::Reference< beans::XVetoableChangeListener >& /*aListener*/ ) throw (beans::UnknownPropertyException, lang::WrappedTargetException, uno::RuntimeException) - { - } -}; - - -class DemoApp : public Application -{ -public: - virtual void Main(); - virtual sal_uInt16 Exception( sal_uInt16 nError ); -}; - -class ChildWindow : public Window -{ -public: - ChildWindow( Window* pParent ); - virtual ~ChildWindow(); - virtual void Paint( const Rectangle& rRect ); - virtual void Resize(); - - void setShow( const uno::Reference< presentation::XSlideShow >& rShow ) { mxShow = rShow; init(); } - -private: - void init(); - - rtl::Reference< View > mpView; - uno::Reference< presentation::XSlideShow > mxShow; -}; - -ChildWindow::ChildWindow( Window* pParent ) : - Window(pParent, WB_CLIPCHILDREN | WB_BORDER| WB_3DLOOK ), - mpView(), - mxShow() -{ - EnablePaint( true ); - Show(); -} - -ChildWindow::~ChildWindow() -{ - if( mxShow.is() && mpView.is() ) - mxShow->removeView( mpView.get() ); -} - -void ChildWindow::init() -{ - try - { - if( !mpView.is() ) - { - uno::Reference< rendering::XCanvas > xCanvas( GetCanvas(), - uno::UNO_QUERY_THROW ); - uno::Reference< rendering::XSpriteCanvas > xSpriteCanvas( xCanvas, - uno::UNO_QUERY_THROW ); - mpView = new View( xSpriteCanvas ); - mpView->resize( GetSizePixel() ); - - if( mxShow.is() ) - mxShow->addView( mpView.get() ); - } - } - catch (const uno::Exception &e) - { - OSL_TRACE( "Exception '%s' thrown\n" , - (const sal_Char*)::rtl::OUStringToOString( e.Message, - RTL_TEXTENCODING_UTF8 )); - } -} - -void ChildWindow::Paint( const Rectangle& /*rRect*/ ) -{ - try - { - if( mpView.is() ) - mpView->repaint(); - } - catch (const uno::Exception &e) - { - OSL_TRACE( "Exception '%s' thrown\n" , - (const sal_Char*)::rtl::OUStringToOString( e.Message, - RTL_TEXTENCODING_UTF8 )); - } -} - -void ChildWindow::Resize() -{ - if( mpView.is() ) - mpView->resize( GetSizePixel() ); -} - -class DemoWindow : public Dialog -{ -public: - DemoWindow(); - virtual void Paint( const Rectangle& rRect ); - virtual void Resize(); - -private: - void init(); - DECL_LINK( updateHdl, Timer* ); - - ChildWindow maLeftChild; - ChildWindow maRightTopChild; - ChildWindow maRightBottomChild; - uno::Reference< presentation::XSlideShow > mxShow; - AutoTimer maUpdateTimer; - bool mbSlideDisplayed; -}; - -DemoWindow::DemoWindow() : - Dialog((Window*)NULL), - maLeftChild( this ), - maRightTopChild( this ), - maRightBottomChild( this ), - mxShow(), - maUpdateTimer(), - mbSlideDisplayed( false ) -{ - SetText( rtl::OUString(RTL_CONSTASCII_USTRINGPARAM( "Slideshow Demo" )) ); - SetSizePixel( Size( 640, 480 ) ); - EnablePaint( true ); - - maLeftChild.SetPosSizePixel( Point(), Size(320,480) ); - maRightTopChild.SetPosSizePixel( Point(320,0), Size(320,240) ); - maRightBottomChild.SetPosSizePixel( Point(320,240), Size(320,240) ); - Show(); - - maUpdateTimer.SetTimeoutHdl(LINK(this, DemoWindow, updateHdl)); - maUpdateTimer.SetTimeout( (sal_uLong)30 ); - maUpdateTimer.Start(); -} - -void DemoWindow::init() -{ - try - { - if( !mxShow.is() ) - { - uno::Reference< lang::XMultiServiceFactory > xFactory( - ::comphelper::getProcessServiceFactory(), - uno::UNO_QUERY_THROW ); - - uno::Reference< uno::XInterface > xInt( xFactory->createInstance( - ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("com.sun.star.presentation.SlideShow")) )); - - mxShow.set( xInt, - uno::UNO_QUERY_THROW ); - - maLeftChild.setShow( mxShow ); - maRightTopChild.setShow( mxShow ); - maRightBottomChild.setShow( mxShow ); - } - - if( mxShow.is() && !mbSlideDisplayed ) - { - uno::Reference< drawing::XDrawPage > xSlide( new DummySlide ); - uno::Reference< drawing::XDrawPages > xDrawPages; - mxShow->displaySlide( xSlide, - uno::Reference< drawing::XDrawPagesSupplier >(), - uno::Reference< animations::XAnimationNode >(), - uno::Sequence< beans::PropertyValue >() ); - mxShow->setProperty( beans::PropertyValue( - rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("RehearseTimings")), - 0, - uno::makeAny( sal_True ), - beans::PropertyState_DIRECT_VALUE )); - mbSlideDisplayed = true; - } - } - catch (const uno::Exception &e) - { - OSL_TRACE( "Exception '%s' thrown\n" , - (const sal_Char*)::rtl::OUStringToOString( e.Message, - RTL_TEXTENCODING_UTF8 )); - } -} - -IMPL_LINK( DemoWindow, updateHdl, Timer*, EMPTYARG ) -{ - init(); - - if( mxShow.is() ) - double nTimeout; - mxShow->update(nTimeout); - - return 0; -} - -void DemoWindow::Paint( const Rectangle& /*rRect*/ ) -{ - init(); -} - -void DemoWindow::Resize() -{ - // TODO -} - -sal_uInt16 DemoApp::Exception( sal_uInt16 nError ) -{ - switch( nError & EXC_MAJORTYPE ) - { - case EXC_RSCNOTLOADED: - Abort( String::CreateFromAscii( "Error: could not load language resources.\nPlease check your installation.\n" ) ); - break; - } - return 0; -} - -void DemoApp::Main() -{ - bool bHelp = false; - - for( sal_uInt16 i = 0; i < GetCommandLineParamCount(); i++ ) - { - ::rtl::OUString aParam = GetCommandLineParam( i ); - - if( aParam.equalsAsciiL( RTL_CONSTASCII_STRINGPARAM( "--help" ) ) || - aParam.equalsAsciiL( RTL_CONSTASCII_STRINGPARAM( "-h" ) ) ) - bHelp = true; - } - - if( bHelp ) - { - printf( "demoshow - life Slideshow testbed\n" ); - return; - } - - // bootstrap UNO - uno::Reference< lang::XMultiServiceFactory > xFactory; - try - { - uno::Reference< uno::XComponentContext > xCtx = ::cppu::defaultBootstrap_InitialComponentContext(); - xFactory = uno::Reference< lang::XMultiServiceFactory >( xCtx->getServiceManager(), - uno::UNO_QUERY ); - if( xFactory.is() ) - ::comphelper::setProcessServiceFactory( xFactory ); - } - catch( uno::RuntimeException& ) - { - throw; - } - catch( uno::Exception& ) - { - OSL_FAIL( rtl::OUStringToOString( - comphelper::anyToString( cppu::getCaughtException() ), - RTL_TEXTENCODING_UTF8 ).getStr() ); - } - - if( !xFactory.is() ) - { - OSL_TRACE( "Could not bootstrap UNO, installation must be in disorder. Exiting.\n" ); - exit( 1 ); - } - - // Create UCB. - uno::Sequence< uno::Any > aArgs( 2 ); - aArgs[ 0 ] <<= rtl::OUString(RTL_CONSTASCII_USTRINGPARAM( UCB_CONFIGURATION_KEY1_LOCAL )); - aArgs[ 1 ] <<= rtl::OUString(RTL_CONSTASCII_USTRINGPARAM( UCB_CONFIGURATION_KEY2_OFFICE )); - ::ucbhelper::ContentBroker::initialize( xFactory, aArgs ); - - DemoWindow pWindow; - pWindow.Execute(); - - // clean up UCB - ::ucbhelper::ContentBroker::deinitialize(); -} -} - -DemoApp aApp; - -/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/slideshow/test/export.map b/slideshow/test/export.map deleted file mode 100644 index 0dbbcc5a7..000000000 --- a/slideshow/test/export.map +++ /dev/null @@ -1,34 +0,0 @@ -#************************************************************************* -# -# DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. -# -# Copyright 2000, 2010 Oracle and/or its affiliates. -# -# OpenOffice.org - a multi-platform office productivity suite -# -# This file is part of OpenOffice.org. -# -# OpenOffice.org is free software: you can redistribute it and/or modify -# it under the terms of the GNU Lesser General Public License version 3 -# only, as published by the Free Software Foundation. -# -# OpenOffice.org is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -# GNU Lesser General Public License version 3 for more details -# (a copy is included in the LICENSE file that accompanied this code). -# -# You should have received a copy of the GNU Lesser General Public License -# version 3 along with OpenOffice.org. If not, see -# <http://www.openoffice.org/license.html> -# for a copy of the LGPLv3 License. -# -#************************************************************************* - -UDK_3_0_0 { - global: - cppunitTestPlugIn; - - local: - *; -}; diff --git a/slideshow/test/slidetest.cxx b/slideshow/test/slidetest.cxx deleted file mode 100644 index f43c284dc..000000000 --- a/slideshow/test/slidetest.cxx +++ /dev/null @@ -1,374 +0,0 @@ -/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ -/************************************************************************* - * - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - * - * Copyright 2000, 2010 Oracle and/or its affiliates. - * - * OpenOffice.org - a multi-platform office productivity suite - * - * This file is part of OpenOffice.org. - * - * OpenOffice.org is free software: you can redistribute it and/or modify - * it under the terms of the GNU Lesser General Public License version 3 - * only, as published by the Free Software Foundation. - * - * OpenOffice.org is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Lesser General Public License version 3 for more details - * (a copy is included in the LICENSE file that accompanied this code). - * - * You should have received a copy of the GNU Lesser General Public License - * version 3 along with OpenOffice.org. If not, see - * <http://www.openoffice.org/license.html> - * for a copy of the LGPLv3 License. - * - ************************************************************************/ - -#include <sal/cppunit.h> - -#include <cppuhelper/compbase1.hxx> -#include <comphelper/broadcasthelper.hxx> - -#include <basegfx/matrix/b2dhommatrix.hxx> -#include <basegfx/range/b2drectangle.hxx> -#include <cppcanvas/spritecanvas.hxx> - -#include "view.hxx" -#include "unoview.hxx" -#include "unoviewcontainer.hxx" -#include "shape.hxx" -#include "tests.hxx" -#include "../engine/slide/layermanager.hxx" -#include "../engine/slide/layer.hxx" -#include "com/sun/star/presentation/XSlideShowView.hpp" - -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() - { - mpTestShape = createTestShape( - basegfx::B2DRange(0.0,0.0,10.0,10.0), - 1.0); - mpTestView = createTestView(); - maViews.addView( mpTestView ); - - mpLayerManager.reset( - new target::LayerManager( - maViews, - basegfx::B2DRange(0.0,0.0,100.0,100.0), - false )); - } - - void tearDown() - { - mpLayerManager.reset(); - maViews.dispose(); - } - - void testLayer() - { - target::LayerSharedPtr pBgLayer( - target::Layer::createBackgroundLayer( basegfx::B2DRange(0,0,100,100) ) ); - pBgLayer->addView( mpTestView ); - - target::LayerSharedPtr pFgLayer( - target::Layer::createLayer( basegfx::B2DRange(0,0,100,100) ) ); - 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( false ); - - 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_MESSAGE( "Added shape must have one view layer", - mpTestShape->getViewLayers().size() == 1 ); - 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_MESSAGE( "View container must have two views", - maViews.end() - maViews.begin() == 2 ); - mpLayerManager->viewAdded(pTestView); - CPPUNIT_ASSERT_MESSAGE( "Added shape must have two view layers", - mpTestShape->getViewLayers().size() == 2 ); - - CPPUNIT_ASSERT_MESSAGE( "Removing second View failed", - maViews.removeView( pTestView ) ); - mpLayerManager->viewRemoved(pTestView); - CPPUNIT_ASSERT_MESSAGE( "Added shape must have one view layer", - mpTestShape->getViewLayers().size() == 1 ); - - 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( false ); - - // 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_MESSAGE( "View must have one extra layer only", - mpTestView->getViewLayers().size() == 1 ); - CPPUNIT_ASSERT_MESSAGE( "View layer must have 10x10 size", - mpTestView->getViewLayers().at(0)->getBounds() == - basegfx::B2DRange(0.0,0.0,10.0,10.0) ); - - // 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_MESSAGE( "Shape 1 must be on background layer", - mpTestShape->getViewLayers().at(0).first == mpTestView ); - CPPUNIT_ASSERT_MESSAGE( "Shape 2 must be on background layer", - pShape2->getViewLayers().at(0).first == mpTestView ); - CPPUNIT_ASSERT_MESSAGE( "Shape 3 must have one layer", - pShape3->getViewLayers().size() == 1 ); - CPPUNIT_ASSERT_MESSAGE( "Shape 3 must be on background layer", - pShape3->getViewLayers().at(0).first == mpTestView ); - CPPUNIT_ASSERT_MESSAGE( "Shape 4 must be on background layer", - pShape4->getViewLayers().at(0).first == mpTestView ); - - // 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_MESSAGE( "Shape 4 must be on background layer", - pShape4->getViewLayers().at(0).first == mpTestView ); - - 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->enterAnimationMode(pShape2); - mpLayerManager->addShape(pShape3); - mpLayerManager->addShape(pShape4); - mpLayerManager->addShape(pShape5); - - mpLayerManager->activate( false ); - mpLayerManager->update(); - - CPPUNIT_ASSERT_MESSAGE( "First shape not rendered", - mpTestShape->getNumRenders() == 1 ); - CPPUNIT_ASSERT_MESSAGE( "Second shape not rendered", - pShape2->getNumRenders() == 1 ); - CPPUNIT_ASSERT_MESSAGE( "Third shape not rendered", - pShape3->getNumRenders() == 1 ); - CPPUNIT_ASSERT_MESSAGE( "Fourth shape not rendered", - pShape4->getNumRenders() == 1 ); - CPPUNIT_ASSERT_MESSAGE( "Fifth shape not rendered", - pShape5->getNumRenders() == 1 ); - - mpLayerManager->enterAnimationMode(pShape4); - mpLayerManager->update(); - - CPPUNIT_ASSERT_MESSAGE( "First shape not rendered", - mpTestShape->getNumRenders() == 1 ); - CPPUNIT_ASSERT_MESSAGE( "Second shape not rendered", - pShape2->getNumRenders() == 1 ); - CPPUNIT_ASSERT_MESSAGE( "Third shape not rendered", - pShape3->getNumRenders() == 2 ); - CPPUNIT_ASSERT_MESSAGE( "Fourth shape not rendered", - pShape4->getNumRenders() == 2 ); - CPPUNIT_ASSERT_MESSAGE( "Fifth shape not rendered", - pShape5->getNumRenders() == 2 ); - - mpLayerManager->leaveAnimationMode(pShape2); - mpLayerManager->leaveAnimationMode(pShape4); - mpLayerManager->update(); - - CPPUNIT_ASSERT_MESSAGE( "First shape not rendered #2", - mpTestShape->getNumRenders() == 2 ); - CPPUNIT_ASSERT_MESSAGE( "Second shape not rendered #2", - pShape2->getNumRenders() == 2 ); - CPPUNIT_ASSERT_MESSAGE( "Third shape not rendered #2", - pShape3->getNumRenders() == 3 ); - CPPUNIT_ASSERT_MESSAGE( "Fourth shape not rendered #2", - pShape4->getNumRenders() == 3 ); - CPPUNIT_ASSERT_MESSAGE( "Fifth shape not rendered #2", - pShape5->getNumRenders() == 3 ); - } - - 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_MESSAGE( "Shape 1 must have refcount of 1", - mpTestShape.use_count() == 1 ); - CPPUNIT_ASSERT_MESSAGE( "Shape 2 must have refcount of ", - pShape2.use_count() == 1 ); - CPPUNIT_ASSERT_MESSAGE( "Shape 3 must have refcount of 1", - pShape3.use_count() == 1 ); - CPPUNIT_ASSERT_MESSAGE( "Shape 4 must have refcount of", - pShape4.use_count() == 1 ); - - - mpLayerManager->addShape(mpTestShape); - mpLayerManager->addShape(pShape2); - mpLayerManager->addShape(pShape3); - mpLayerManager->addShape(pShape4); - - mpLayerManager->activate( false ); - mpLayerManager->update(); - - mpLayerManager->removeShape(mpTestShape); - mpLayerManager->removeShape(pShape2); - mpLayerManager->removeShape(pShape3); - mpLayerManager->removeShape(pShape4); - - CPPUNIT_ASSERT_MESSAGE( "Shape 1 must have refcount of 1", - mpTestShape.use_count() == 1 ); - CPPUNIT_ASSERT_MESSAGE( "Shape 2 must have refcount of ", - pShape2.use_count() == 1 ); - CPPUNIT_ASSERT_MESSAGE( "Shape 3 must have refcount of 1", - pShape3.use_count() == 1 ); - CPPUNIT_ASSERT_MESSAGE( "Shape 4 must have refcount of 1", - pShape4.use_count() == 1 ); - - maViews.removeView(mpTestView); - mpLayerManager->viewRemoved(mpTestView); - CPPUNIT_ASSERT_MESSAGE( "View must have refcount of 1", - mpTestView.use_count() == 1 ); - } - - // 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 deleted file mode 100644 index bce515445..000000000 --- a/slideshow/test/tests.hxx +++ /dev/null @@ -1,75 +0,0 @@ -/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ -/************************************************************************* - * - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - * - * Copyright 2000, 2010 Oracle and/or its affiliates. - * - * OpenOffice.org - a multi-platform office productivity suite - * - * This file is part of OpenOffice.org. - * - * OpenOffice.org is free software: you can redistribute it and/or modify - * it under the terms of the GNU Lesser General Public License version 3 - * only, as published by the Free Software Foundation. - * - * OpenOffice.org is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Lesser General Public License version 3 for more details - * (a copy is included in the LICENSE file that accompanied this code). - * - * You should have received a copy of the GNU Lesser General Public License - * version 3 along with OpenOffice.org. If not, see - * <http://www.openoffice.org/license.html> - * for a copy of the LGPLv3 License. - * - ************************************************************************/ - -#ifndef INCLUDED_TESTS_HXX -#define INCLUDED_TESTS_HXX - -#include "animatableshape.hxx" -#include "unoview.hxx" -#include <boost/shared_ptr.hpp> - -namespace basegfx{ class B1DRange; class B2DRange; class B2DVector; } - -class TestView : public slideshow::internal::UnoView -{ -public: - /// true iff clear() has been called - virtual bool isClearCalled() const = 0; - virtual std::vector<std::pair<basegfx::B2DVector,double> > getCreatedSprites() const = 0; - virtual basegfx::B1DRange getPriority() const = 0; - /// true iff setClip was called (on and off) - virtual bool wasClipSet() const = 0; - virtual basegfx::B2DRange getBounds() const = 0; - - virtual std::vector<boost::shared_ptr<TestView> > getViewLayers() const = 0; -}; - -typedef boost::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; - virtual sal_Int32 getAnimationCount() const = 0; -}; - -typedef boost::shared_ptr<TestShape> TestShapeSharedPtr; -TestShapeSharedPtr createTestShape(const basegfx::B2DRange& rRect, - double nPrio); - -#endif /* INCLUDED_TESTS_HXX */ - -/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/slideshow/test/testshape.cxx b/slideshow/test/testshape.cxx deleted file mode 100644 index 12db1ddf3..000000000 --- a/slideshow/test/testshape.cxx +++ /dev/null @@ -1,229 +0,0 @@ -/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ -/************************************************************************* - * - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - * - * Copyright 2000, 2010 Oracle and/or its affiliates. - * - * OpenOffice.org - a multi-platform office productivity suite - * - * This file is part of OpenOffice.org. - * - * OpenOffice.org is free software: you can redistribute it and/or modify - * it under the terms of the GNU Lesser General Public License version 3 - * only, as published by the Free Software Foundation. - * - * OpenOffice.org is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Lesser General Public License version 3 for more details - * (a copy is included in the LICENSE file that accompanied this code). - * - * You should have received a copy of the GNU Lesser General Public License - * version 3 along with OpenOffice.org. If not, see - * <http://www.openoffice.org/license.html> - * for a copy of the LGPLv3 License. - * - ************************************************************************/ - -#include <cppunit/TestAssert.h> -#include <cppunit/TestFixture.h> -#include <cppunit/extensions/HelperMacros.h> - -#include <cppuhelper/compbase1.hxx> -#include <cppuhelper/basemutex.hxx> -#include <comphelper/make_shared_from_uno.hxx> - -#include <basegfx/matrix/b2dhommatrix.hxx> -#include <basegfx/range/b2drange.hxx> - -#include "shape.hxx" -#include "tests.hxx" -#include "com/sun/star/presentation/XSlideShowView.hpp" - -#include <o3tl/compat_functional.hxx> - -#include <boost/bind.hpp> - -namespace target = slideshow::internal; -using namespace ::com::sun::star; - -// our test shape subject -typedef ::cppu::WeakComponentImplHelper1< drawing::XShape > ShapeBase; -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 - { - return maViewLayers; - } - virtual sal_Int32 getNumUpdates() const - { - return mnNumUpdates; - } - virtual sal_Int32 getNumRenders() const - { - return mnNumRenders; - } - virtual sal_Int32 getAnimationCount() const - { - return mnAnimated; - } - - - // XShape - virtual ::rtl::OUString SAL_CALL getShapeType( ) throw (uno::RuntimeException) - { - CPPUNIT_ASSERT_MESSAGE( "TestShape::getShapeType: unexpected method call", false ); - return ::rtl::OUString(); - } - - virtual awt::Point SAL_CALL getPosition( ) throw (uno::RuntimeException) - { - CPPUNIT_ASSERT_MESSAGE( "TestShape::getPosition: unexpected method call", false ); - return awt::Point(); - } - - virtual void SAL_CALL setPosition( const awt::Point& ) throw (uno::RuntimeException) - { - CPPUNIT_ASSERT_MESSAGE( "TestShape::setPosition: unexpected method call", false ); - } - - virtual awt::Size SAL_CALL getSize( ) throw (uno::RuntimeException) - { - CPPUNIT_ASSERT_MESSAGE( "TestShape::getSize: unexpected method call", false ); - return awt::Size(); - } - - virtual void SAL_CALL setSize( const awt::Size& /*aSize*/ ) throw (beans::PropertyVetoException, uno::RuntimeException) - { - CPPUNIT_ASSERT_MESSAGE( "TestShape::setSize: unexpected method call", false ); - } - - - ////////////////////////////////////////////////////////////////////////// - - - // Shape - virtual uno::Reference< drawing::XShape > getXShape() const - { - return uno::Reference< drawing::XShape >( const_cast<ImplTestShape*>(this) ); - } - virtual void addViewLayer( const target::ViewLayerSharedPtr& rNewLayer, - bool bRedrawLayer ) - { - maViewLayers.push_back( std::make_pair(rNewLayer,bRedrawLayer) ); - } - virtual bool removeViewLayer( const target::ViewLayerSharedPtr& rNewLayer ) - { - if( std::find_if( - maViewLayers.begin(), - maViewLayers.end(), - boost::bind( std::equal_to< target::ViewLayerSharedPtr >(), - boost::cref( rNewLayer ), - boost::bind( o3tl::select1st<ViewVector::value_type>(), - _1 ))) == maViewLayers.end() ) - throw std::exception(); - - maViewLayers.erase( - std::remove_if( - maViewLayers.begin(), - maViewLayers.end(), - boost::bind( std::equal_to< target::ViewLayerSharedPtr >(), - boost::cref( rNewLayer ), - boost::bind( o3tl::select1st<ViewVector::value_type>(), - _1 )))); - return true; - } - virtual bool clearAllViewLayers() - { - maViewLayers.clear(); - return true; - } - - virtual bool update() const - { - ++mnNumUpdates; - return true; - } - virtual bool render() const - { - ++mnNumRenders; - return true; - } - virtual bool isContentChanged() const - { - return true; - } - virtual ::basegfx::B2DRectangle getBounds() const - { - return maRect; - } - virtual ::basegfx::B2DRectangle getDomBounds() const - { - return maRect; - } - virtual ::basegfx::B2DRectangle getUpdateArea() const - { - return maRect; - } - - virtual bool isVisible() const - { - return true; - } - virtual double getPriority() const - { - return mnPrio; - } - virtual bool isBackgroundDetached() const - { - return mnAnimated != 0; - } - - // AnimatableShape - virtual void enterAnimationMode() - { - ++mnAnimated; - } - - virtual void leaveAnimationMode() - { - --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 deleted file mode 100644 index 1b06b717d..000000000 --- a/slideshow/test/testview.cxx +++ /dev/null @@ -1,306 +0,0 @@ -/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ -/************************************************************************* - * - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - * - * Copyright 2000, 2010 Oracle and/or its affiliates. - * - * OpenOffice.org - a multi-platform office productivity suite - * - * This file is part of OpenOffice.org. - * - * OpenOffice.org is free software: you can redistribute it and/or modify - * it under the terms of the GNU Lesser General Public License version 3 - * only, as published by the Free Software Foundation. - * - * OpenOffice.org is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Lesser General Public License version 3 for more details - * (a copy is included in the LICENSE file that accompanied this code). - * - * You should have received a copy of the GNU Lesser General Public License - * version 3 along with OpenOffice.org. If not, see - * <http://www.openoffice.org/license.html> - * for a copy of the LGPLv3 License. - * - ************************************************************************/ - -#include <cppunit/TestAssert.h> -#include <cppunit/TestFixture.h> -#include <cppunit/extensions/HelperMacros.h> - -#include <cppuhelper/compbase1.hxx> -#include <cppuhelper/basemutex.hxx> -#include <comphelper/make_shared_from_uno.hxx> - -#include <basegfx/matrix/b2dhommatrix.hxx> -#include <basegfx/range/b1drange.hxx> -#include <basegfx/range/b2drectangle.hxx> -#include <basegfx/polygon/b2dpolypolygon.hxx> -#include <cppcanvas/spritecanvas.hxx> - -#include "tests.hxx" -#include "view.hxx" -#include "unoview.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::WeakComponentImplHelper1< presentation::XSlideShowView > ViewBase; -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 mbIsClearCalled; - bool mbDisposed; - - -public: - ImplTestView() : - ViewBase(m_aMutex), - maCreatedSprites(), - maViewLayers(), - maBounds(), - maPriority(), - mbIsClipSet(false), - mbIsClipEmptied(false), - mbIsClearCalled(false), - mbDisposed( false ) - { - } - - virtual ~ImplTestView() - { - } - - // XSlideShowView - virtual uno::Reference< rendering::XSpriteCanvas > SAL_CALL getCanvas( ) throw (uno::RuntimeException) - { - return uno::Reference< rendering::XSpriteCanvas >(); - } - - virtual void SAL_CALL clear( ) throw (uno::RuntimeException) - { - } - - virtual geometry::AffineMatrix2D SAL_CALL getTransformation( ) throw (uno::RuntimeException) - { - return geometry::AffineMatrix2D(); - } - - virtual void SAL_CALL addTransformationChangedListener( const uno::Reference< util::XModifyListener >& ) throw (uno::RuntimeException) - { - } - - virtual void SAL_CALL removeTransformationChangedListener( const uno::Reference< util::XModifyListener >& ) throw (uno::RuntimeException) - { - } - - virtual void SAL_CALL addPaintListener( const uno::Reference< awt::XPaintListener >& ) throw (uno::RuntimeException) - { - } - - virtual void SAL_CALL removePaintListener( const uno::Reference< awt::XPaintListener >& ) throw (uno::RuntimeException) - { - } - - virtual void SAL_CALL addMouseListener( const uno::Reference< awt::XMouseListener >& ) throw (uno::RuntimeException) - { - } - - virtual void SAL_CALL removeMouseListener( const uno::Reference< awt::XMouseListener >& ) throw (uno::RuntimeException) - { - } - - virtual void SAL_CALL addMouseMotionListener( const uno::Reference< awt::XMouseMotionListener >& ) throw (uno::RuntimeException) - { - } - - virtual void SAL_CALL removeMouseMotionListener( const uno::Reference< awt::XMouseMotionListener >& ) throw (uno::RuntimeException) - { - } - - virtual void SAL_CALL setMouseCursor( ::sal_Int16 ) throw (uno::RuntimeException) - { - } - - virtual awt::Rectangle SAL_CALL getCanvasArea( ) throw (uno::RuntimeException) - { - return awt::Rectangle(0,0,100,100); - } - - // TestView - virtual bool isClearCalled() const - { - return mbIsClearCalled; - } - - virtual std::vector<std::pair<basegfx::B2DVector,double> > getCreatedSprites() const - { - return maCreatedSprites; - } - - virtual basegfx::B1DRange getPriority() const - { - return maPriority; - } - - virtual bool wasClipSet() const - { - return mbIsClipEmptied; - } - - virtual basegfx::B2DRange getBounds() const - { - return maBounds; - } - - virtual std::vector<boost::shared_ptr<TestView> > getViewLayers() const - { - return maViewLayers; - } - - // ViewLayer - virtual bool isOnView(target::ViewSharedPtr const& /*rView*/) const - { - return true; - } - - virtual ::cppcanvas::CanvasSharedPtr getCanvas() const - { - return ::cppcanvas::CanvasSharedPtr(); - } - - virtual ::cppcanvas::CustomSpriteSharedPtr createSprite( const ::basegfx::B2DSize& rSpriteSizePixel, - double nPriority ) const - { - maCreatedSprites.push_back( std::make_pair(rSpriteSizePixel,nPriority) ); - - return ::cppcanvas::CustomSpriteSharedPtr(); - } - - virtual void setPriority( const basegfx::B1DRange& rRange ) - { - maPriority = rRange; - } - - virtual ::basegfx::B2DHomMatrix getTransformation() const - { - return ::basegfx::B2DHomMatrix(); - } - - virtual ::basegfx::B2DHomMatrix getSpriteTransformation() const - { - return ::basegfx::B2DHomMatrix(); - } - - virtual void setClip( const ::basegfx::B2DPolyPolygon& rClip ) - { - 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 ) - { - const bool bRet( maBounds != rArea ); - maBounds = rArea; - return bRet; - } - - virtual target::ViewLayerSharedPtr createViewLayer( - const basegfx::B2DRange& rLayerBounds ) const - { - maViewLayers.push_back( TestViewSharedPtr(new ImplTestView())); - maViewLayers.back()->resize( rLayerBounds ); - - return maViewLayers.back(); - } - - virtual bool updateScreen() const - { - // misusing updateScreen for state reporting - return !mbDisposed; - } - - virtual bool paintScreen() const - { - // misusing updateScreen for state reporting - return !mbDisposed; - } - - virtual void clear() const - { - } - - virtual void clearAll() const - { - } - - virtual void setViewSize( const ::basegfx::B2DSize& ) - { - } - - virtual void setCursorShape( sal_Int16 /*nPointerShape*/ ) - { - } - - virtual uno::Reference< presentation::XSlideShowView > getUnoView() const - { - return uno::Reference< presentation::XSlideShowView >( const_cast<ImplTestView*>(this) ); - } - - virtual void _dispose() - { - mbDisposed = true; - } - - virtual bool isSoundEnabled (void) const - { - return true; - } - - virtual void setIsSoundEnabled (const bool /*bValue*/) - { - } -}; - - -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 deleted file mode 100644 index 964e7ecd1..000000000 --- a/slideshow/test/views.cxx +++ /dev/null @@ -1,88 +0,0 @@ -/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ -/************************************************************************* - * - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - * - * Copyright 2000, 2010 Oracle and/or its affiliates. - * - * OpenOffice.org - a multi-platform office productivity suite - * - * This file is part of OpenOffice.org. - * - * OpenOffice.org is free software: you can redistribute it and/or modify - * it under the terms of the GNU Lesser General Public License version 3 - * only, as published by the Free Software Foundation. - * - * OpenOffice.org is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Lesser General Public License version 3 for more details - * (a copy is included in the LICENSE file that accompanied this code). - * - * You should have received a copy of the GNU Lesser General Public License - * version 3 along with OpenOffice.org. If not, see - * <http://www.openoffice.org/license.html> - * for a copy of the LGPLv3 License. - * - ************************************************************************/ - -#include <cppunit/TestAssert.h> -#include <cppunit/TestFixture.h> -#include <cppunit/extensions/HelperMacros.h> - -#include <cppuhelper/compbase1.hxx> -#include <comphelper/broadcasthelper.hxx> - -#include <basegfx/matrix/b2dhommatrix.hxx> -#include <basegfx/range/b2drectangle.hxx> -#include <cppcanvas/spritecanvas.hxx> - -#include "view.hxx" -#include "unoview.hxx" -#include "unoviewcontainer.hxx" -#include "shape.hxx" -#include "tests.hxx" -#include "com/sun/star/presentation/XSlideShowView.hpp" - -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_MESSAGE( "Testing container size", - 1 == std::distance( aContainer.begin(), - aContainer.end() )); - CPPUNIT_ASSERT_MESSAGE( "Testing disposedness", - pView->paintScreen() ); - aContainer.dispose(); - CPPUNIT_ASSERT_MESSAGE( "Testing dispose: container must be empty", - 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: */ |