Kaydet (Commit) f8bd9687 authored tarafından Miklos Vajna's avatar Miklos Vajna

Add testcase for sd::Window::LogicInvalidate().

Change-Id: I1d2e6ed9691ca43abb18bdf04fcf5a6c73a66f18
üst f15a6a06
# -*- 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:
......@@ -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
......
/* -*- 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: */
......@@ -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,
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment