sd/CppunitTest_sd_tiledrendering.mk | 63 +++++++++++++ sd/Module_sd.mk | 1 sd/qa/unit/tiledrendering/data/dummy.odp |binary sd/qa/unit/tiledrendering/tiledrendering.cxx | 125 +++++++++++++++++++++++++++ sd/source/ui/inc/unomodel.hxx | 3 sd/source/ui/view/viewshel.cxx | 2 6 files changed, 192 insertions(+), 2 deletions(-)
New commits: commit 4df3f8139ad1a46aa31d9b40c1d0c11229296366 Author: Miklos Vajna <vmik...@collabora.co.uk> Date: Tue Mar 31 11:40:27 2015 +0200 sd::ViewShell::LogicMouseButtonUp: typo See commit 845708fcc8e9a5a18aa7e70741008c6602f08eae (Add vcl::Window::SetLastMousePos(), 2015-02-24), what we really want is to set the remembered mouse click position, i.e. SetLastMousePos(), not SetPointerPosPixel(), which would move the mouse (and is a NOP for the headless backend). Change-Id: I126836a72ba09a92b4f70169257d7293bb5e980c diff --git a/sd/source/ui/view/viewshel.cxx b/sd/source/ui/view/viewshel.cxx index 541963e..39aff2f 100644 --- a/sd/source/ui/view/viewshel.cxx +++ b/sd/source/ui/view/viewshel.cxx @@ -525,7 +525,7 @@ void ViewShell::LogicMouseButtonUp(const MouseEvent& rMouseEvent) assert(GetDoc()->isTiledRendering()); Point aPoint = mpActiveWindow->GetPointerPosPixel(); - mpActiveWindow->SetPointerPosPixel(rMouseEvent.GetPosPixel()); + mpActiveWindow->SetLastMousePos(rMouseEvent.GetPosPixel()); MouseButtonUp(rMouseEvent, 0); commit 31e77c436b0085efa7a8c45270577f0ee26496dd Author: Miklos Vajna <vmik...@collabora.co.uk> Date: Tue Mar 31 11:36:54 2015 +0200 Add testcase for sd::Window::LogicInvalidate(). Change-Id: I1d2e6ed9691ca43abb18bdf04fcf5a6c73a66f18 diff --git a/sd/CppunitTest_sd_tiledrendering.mk b/sd/CppunitTest_sd_tiledrendering.mk new file mode 100644 index 0000000..2a3f29c --- /dev/null +++ b/sd/CppunitTest_sd_tiledrendering.mk @@ -0,0 +1,63 @@ +# -*- Mode: makefile-gmake; tab-width: 4; indent-tabs-mode: t -*- +#************************************************************************* +# +# 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/. +# +#************************************************************************* + +$(eval $(call gb_CppunitTest_CppunitTest,sd_tiledrendering)) + +$(eval $(call gb_CppunitTest_add_exception_objects,sd_tiledrendering, \ + sd/qa/unit/tiledrendering/tiledrendering \ +)) + +$(eval $(call gb_CppunitTest_use_libraries,sd_tiledrendering, \ + comphelper \ + cppu \ + cppuhelper \ + editeng \ + sal \ + sfx \ + svl \ + svt \ + svxcore \ + sd \ + test \ + unotest \ + vcl \ + tl \ + utl \ + $(gb_UWINAPI) \ +)) + +$(eval $(call gb_CppunitTest_use_externals,sd_tiledrendering,\ + boost_headers \ + libxml2 \ +)) + +$(eval $(call gb_CppunitTest_set_include,sd_tiledrendering,\ + -I$(SRCDIR)/sd/inc \ + -I$(SRCDIR)/sd/source/ui/inc \ + -I$(SRCDIR)/sd/qa/unit \ + $$(INCLUDE) \ +)) + +$(eval $(call gb_CppunitTest_use_api,sd_tiledrendering,\ + offapi \ + udkapi \ +)) + +$(eval $(call gb_CppunitTest_use_ure,sd_tiledrendering)) +$(eval $(call gb_CppunitTest_use_vcl,sd_tiledrendering)) + +$(eval $(call gb_CppunitTest_use_rdb,sd_tiledrendering,services)) + +$(eval $(call gb_CppunitTest_use_configuration,sd_tiledrendering)) + +$(call gb_CppunitTest_get_target,sd_tiledrendering) : $(call gb_AllLangResTarget_get_target,sd) + +# vim: set noet sw=4 ts=4: diff --git a/sd/Module_sd.mk b/sd/Module_sd.mk index 0c2d577..4bd26ac 100644 --- a/sd/Module_sd.mk +++ b/sd/Module_sd.mk @@ -33,6 +33,7 @@ $(eval $(call gb_Module_add_check_targets,sd,\ CppunitTest_sd_export_tests \ CppunitTest_sd_filters_test \ CppunitTest_sd_html_export_tests \ + CppunitTest_sd_tiledrendering \ )) endif diff --git a/sd/qa/unit/tiledrendering/data/dummy.odp b/sd/qa/unit/tiledrendering/data/dummy.odp new file mode 100644 index 0000000..e559de6 Binary files /dev/null and b/sd/qa/unit/tiledrendering/data/dummy.odp differ diff --git a/sd/qa/unit/tiledrendering/tiledrendering.cxx b/sd/qa/unit/tiledrendering/tiledrendering.cxx new file mode 100644 index 0000000..d1e924d --- /dev/null +++ b/sd/qa/unit/tiledrendering/tiledrendering.cxx @@ -0,0 +1,125 @@ +/* -*- 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/. + */ + +#define LOK_USE_UNSTABLE_API +#include <LibreOfficeKit/LibreOfficeKitEnums.h> +#include <com/sun/star/frame/Desktop.hpp> +#include <comphelper/processfactory.hxx> +#include <comphelper/string.hxx> +#include <test/bootstrapfixture.hxx> +#include <test/xmltesttools.hxx> +#include <unotest/macros_test.hxx> + +#include <DrawDocShell.hxx> +#include <ViewShell.hxx> +#include <unomodel.hxx> + +using namespace css; + +static const char* DATA_DIRECTORY = "/sd/qa/unit/tiledrendering/data/"; + +class SdTiledRenderingTest : public test::BootstrapFixture, public unotest::MacrosTest, public XmlTestTools +{ +public: + virtual void setUp() SAL_OVERRIDE; + virtual void tearDown() SAL_OVERRIDE; + + void testRegisterCallback(); + + CPPUNIT_TEST_SUITE(SdTiledRenderingTest); +#if !defined(WNT) && !defined(MACOSX) + CPPUNIT_TEST(testRegisterCallback); +#endif + CPPUNIT_TEST_SUITE_END(); + +private: + SdXImpressDocument* createDoc(const char* pName); + static void callback(int nType, const char* pPayload, void* pData); + void callbackImpl(int nType, const char* pPayload); + + uno::Reference<lang::XComponent> mxComponent; + Rectangle m_aInvalidation; +}; + +void SdTiledRenderingTest::setUp() +{ + test::BootstrapFixture::setUp(); + + mxDesktop.set(css::frame::Desktop::create(comphelper::getComponentContext(getMultiServiceFactory()))); +} + +void SdTiledRenderingTest::tearDown() +{ + if (mxComponent.is()) + mxComponent->dispose(); + + test::BootstrapFixture::tearDown(); +} + +SdXImpressDocument* SdTiledRenderingTest::createDoc(const char* pName) +{ + if (mxComponent.is()) + mxComponent->dispose(); + mxComponent = loadFromDesktop(getURLFromSrc(DATA_DIRECTORY) + OUString::createFromAscii(pName), "com.sun.star.presentation.PresentationDocument"); + SdXImpressDocument* pImpressDocument = dynamic_cast<SdXImpressDocument*>(mxComponent.get()); + CPPUNIT_ASSERT(pImpressDocument); + pImpressDocument->initializeForTiledRendering(); + return pImpressDocument; +} + +void SdTiledRenderingTest::callback(int nType, const char* pPayload, void* pData) +{ + static_cast<SdTiledRenderingTest*>(pData)->callbackImpl(nType, pPayload); +} + +void SdTiledRenderingTest::callbackImpl(int nType, const char* pPayload) +{ + switch (nType) + { + case LOK_CALLBACK_INVALIDATE_TILES: + { + OUString aPayload = OUString::createFromAscii(pPayload); + if (aPayload != "EMPTY" && m_aInvalidation.IsEmpty()) + { + uno::Sequence<OUString> aSeq = comphelper::string::convertCommaSeparated(aPayload); + CPPUNIT_ASSERT_EQUAL(static_cast<sal_Int32>(4), aSeq.getLength()); + m_aInvalidation.setX(aSeq[0].toInt32()); + m_aInvalidation.setY(aSeq[1].toInt32()); + m_aInvalidation.setWidth(aSeq[2].toInt32()); + m_aInvalidation.setHeight(aSeq[3].toInt32()); + } + } + break; + } +} + +void SdTiledRenderingTest::testRegisterCallback() +{ + // Tests sd::Window::LogicInvalidate(). + SdXImpressDocument* pXImpressDocument = createDoc("dummy.odp"); + pXImpressDocument->registerCallback(&SdTiledRenderingTest::callback, this); + sd::ViewShell* pViewShell = pXImpressDocument->GetDocShell()->GetViewShell(); + + // Append a character to the empty title shape. + vcl::KeyCode aKeyCode(0, 0); + KeyEvent aKeyEvent(static_cast<sal_Unicode>('x'), aKeyCode, 0); + pViewShell->KeyInput(aKeyEvent, 0); + mxComponent->dispose(); + + // Check that the top left 256x256px tile would be invalidated. + CPPUNIT_ASSERT(!m_aInvalidation.IsEmpty()); + Rectangle aTopLeft(0, 0, 256*15, 256*15); // 1 px = 15 twips, assuming 96 DPI. + CPPUNIT_ASSERT(m_aInvalidation.IsOver(aTopLeft)); +} + +CPPUNIT_TEST_SUITE_REGISTRATION(SdTiledRenderingTest); + +CPPUNIT_PLUGIN_IMPLEMENT(); + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/sd/source/ui/inc/unomodel.hxx b/sd/source/ui/inc/unomodel.hxx index 409b620..bb840f2 100644 --- a/sd/source/ui/inc/unomodel.hxx +++ b/sd/source/ui/inc/unomodel.hxx @@ -50,6 +50,7 @@ #include <editeng/unoipset.hxx> #include <comphelper/servicehelper.hxx> +#include <sddllapi.h> class SdDrawDocument; class SdPage; @@ -65,7 +66,7 @@ extern OUString getPageApiNameFromUiName( const OUString& rUIName ); /*********************************************************************** * * ***********************************************************************/ -class SdXImpressDocument : public SfxBaseModel, // implements SfxListener, OWEAKOBJECT & other +class SD_DLLPUBLIC SdXImpressDocument : public SfxBaseModel, // implements SfxListener, OWEAKOBJECT & other public SvxFmMSFactory, public ::com::sun::star::drawing::XDrawPageDuplicator, public ::com::sun::star::drawing::XLayerSupplier, _______________________________________________ Libreoffice-commits mailing list libreoffice-comm...@lists.freedesktop.org http://lists.freedesktop.org/mailman/listinfo/libreoffice-commits