sw/CppunitTest_sw_tiledrendering.mk | 62 +++++++++++++++ sw/Module_sw.mk | 1 sw/qa/extras/tiledrendering/data/reset-selection.fodt | 17 ++++ sw/qa/extras/tiledrendering/tiledrendering.cxx | 74 ++++++++++++++++++ 4 files changed, 154 insertions(+)
New commits: commit cc5a7c157aee99d457872dba2ac6a71d25bd624b Author: Miklos Vajna <[email protected]> Date: Wed Mar 11 18:00:26 2015 +0100 Add testcase for SwXTextDocument::resetSelection(). Change-Id: Idc97ebfe3db27ac52c1c6b16177f08118a750e69 diff --git a/sw/CppunitTest_sw_tiledrendering.mk b/sw/CppunitTest_sw_tiledrendering.mk new file mode 100644 index 0000000..be7986b --- /dev/null +++ b/sw/CppunitTest_sw_tiledrendering.mk @@ -0,0 +1,62 @@ +# -*- 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,sw_tiledrendering)) + +$(eval $(call gb_CppunitTest_add_exception_objects,sw_tiledrendering, \ + sw/qa/extras/tiledrendering/tiledrendering \ +)) + +$(eval $(call gb_CppunitTest_use_libraries,sw_tiledrendering, \ + comphelper \ + cppu \ + cppuhelper \ + editeng \ + sal \ + sfx \ + svl \ + svt \ + svxcore \ + sw \ + test \ + unotest \ + vcl \ + tl \ + utl \ + $(gb_UWINAPI) \ +)) + +$(eval $(call gb_CppunitTest_use_externals,sw_tiledrendering,\ + boost_headers \ + libxml2 \ +)) + +$(eval $(call gb_CppunitTest_set_include,sw_tiledrendering,\ + -I$(SRCDIR)/sw/inc \ + -I$(SRCDIR)/sw/source/core/inc \ + -I$(SRCDIR)/sw/source/uibase/inc \ + -I$(SRCDIR)/sw/qa/extras/inc \ + $$(INCLUDE) \ +)) + +$(eval $(call gb_CppunitTest_use_api,sw_tiledrendering,\ + offapi \ + udkapi \ +)) + +$(eval $(call gb_CppunitTest_use_ure,sw_tiledrendering)) +$(eval $(call gb_CppunitTest_use_vcl,sw_tiledrendering)) + +$(eval $(call gb_CppunitTest_use_rdb,sw_tiledrendering,services)) + +$(eval $(call gb_CppunitTest_use_configuration,sw_tiledrendering)) + +# vim: set noet sw=4 ts=4: diff --git a/sw/Module_sw.mk b/sw/Module_sw.mk index d15c5b5..78a45e1 100644 --- a/sw/Module_sw.mk +++ b/sw/Module_sw.mk @@ -70,6 +70,7 @@ $(eval $(call gb_Module_add_slowcheck_targets,sw,\ CppunitTest_sw_odfexport \ CppunitTest_sw_odfimport \ CppunitTest_sw_uiwriter \ + CppunitTest_sw_tiledrendering \ CppunitTest_sw_mailmerge \ CppunitTest_sw_globalfilter \ )) diff --git a/sw/qa/extras/tiledrendering/data/reset-selection.fodt b/sw/qa/extras/tiledrendering/data/reset-selection.fodt new file mode 100644 index 0000000..feefe48 --- /dev/null +++ b/sw/qa/extras/tiledrendering/data/reset-selection.fodt @@ -0,0 +1,17 @@ +<?xml version="1.0" encoding="UTF-8"?> +<office:document xmlns:office="urn:oasis:names:tc:opendocument:xmlns:office:1.0" xmlns:style="urn:oasis:names:tc:opendocument:xmlns:style:1.0" xmlns:text="urn:oasis:names:tc:opendocument:xmlns:text:1.0" xmlns:table="urn:oasis:names:tc:opendocument:xmlns:table:1.0" xmlns:draw="urn:oasis:names:tc:opendocument:xmlns:drawing:1.0" xmlns:fo="urn:oasis:names:tc:opendocument:xmlns:xsl-fo-compatible:1.0" xmlns:xlink="http://www.w3.org/1999/xlink" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:meta="urn:oasis:names:tc:opendocument:xmlns:meta:1.0" xmlns:number="urn:oasis:names:tc:opendocument:xmlns:datastyle:1.0" xmlns:svg="urn:oasis:names:tc:opendocument:xmlns:svg-compatible:1.0" xmlns:chart="urn:oasis:names:tc:opendocument:xmlns:chart:1.0" xmlns:dr3d="urn:oasis:names:tc:opendocument:xmlns:dr3d:1.0" xmlns:math="http://www.w3.org/1998/Math/MathML" xmlns:form="urn:oasis:names:tc:opendocument:xmlns:form:1.0" xmlns:script="urn:oasis:names:tc:opendocument:xmlns:script:1.0" xmlns:config="urn:oas is:names:tc:opendocument:xmlns:config:1.0" xmlns:ooo="http://openoffice.org/2004/office" xmlns:ooow="http://openoffice.org/2004/writer" xmlns:oooc="http://openoffice.org/2004/calc" xmlns:dom="http://www.w3.org/2001/xml-events" xmlns:xforms="http://www.w3.org/2002/xforms" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:rpt="http://openoffice.org/2005/report" xmlns:of="urn:oasis:names:tc:opendocument:xmlns:of:1.2" xmlns:xhtml="http://www.w3.org/1999/xhtml" xmlns:grddl="http://www.w3.org/2003/g/data-view#" xmlns:officeooo="http://openoffice.org/2009/office" xmlns:tableooo="http://openoffice.org/2009/table" xmlns:drawooo="http://openoffice.org/2010/draw" xmlns:calcext="urn:org:documentfoundation:names:experimental:calc:xmlns:calcext:1.0" xmlns:loext="urn:org:documentfoundation:names:experimental:office:xmlns:loext:1.0" xmlns:field="urn:openoffice:names:experimental:ooo-ms-interop:xmlns:field:1.0" xmlns:formx="urn:openoffice:names: experimental:ooxml-odf-interop:xmlns:form:1.0" xmlns:css3t="http://www.w3.org/TR/css3-text/" office:version="1.2" office:mimetype="application/vnd.oasis.opendocument.text"> + <office:body> + <office:text> + <text:sequence-decls> + <text:sequence-decl text:display-outline-level="0" text:name="Illustration"/> + <text:sequence-decl text:display-outline-level="0" text:name="Table"/> + <text:sequence-decl text:display-outline-level="0" text:name="Text"/> + <text:sequence-decl text:display-outline-level="0" text:name="Drawing"/> + </text:sequence-decls> + <text:p><draw:custom-shape text:anchor-type="paragraph" draw:z-index="0" svg:width="4.883cm" svg:height="3.225cm" svg:x="2.602cm" svg:y="1.178cm"> + <text:p/> + <draw:enhanced-geometry svg:viewBox="0 0 21600 21600" draw:glue-points="10800 0 3163 3163 0 10800 3163 18437 10800 21600 18437 18437 21600 10800 18437 3163" draw:text-areas="3163 3163 18437 18437" draw:type="ellipse" draw:enhanced-path="U 10800 10800 10800 10800 0 360 Z N"/> + </draw:custom-shape>Hello.</text:p> + </office:text> + </office:body> +</office:document> diff --git a/sw/qa/extras/tiledrendering/tiledrendering.cxx b/sw/qa/extras/tiledrendering/tiledrendering.cxx new file mode 100644 index 0000000..de23c69 --- /dev/null +++ b/sw/qa/extras/tiledrendering/tiledrendering.cxx @@ -0,0 +1,74 @@ +/* -*- 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/. + */ + +#include <swmodeltestbase.hxx> +#include <svx/svdpage.hxx> +#include <svx/svdview.hxx> +#include <crsskip.hxx> +#include <drawdoc.hxx> +#include <wrtsh.hxx> + +static const char* DATA_DIRECTORY = "/sw/qa/extras/tiledrendering/data/"; + +/// Testsuite for the SwXTextDocument methods implementing the vcl::ITiledRenderable interface. +class SwTiledRenderingTest : public SwModelTestBase +{ + +public: + void testResetSelection(); + + CPPUNIT_TEST_SUITE(SwTiledRenderingTest); + CPPUNIT_TEST(testResetSelection); + CPPUNIT_TEST_SUITE_END(); + +private: + SwXTextDocument* createDoc(const char* pName); +}; + +SwXTextDocument* SwTiledRenderingTest::createDoc(const char* pName) +{ + load(DATA_DIRECTORY, pName); + + SwXTextDocument* pTextDocument = dynamic_cast<SwXTextDocument*>(mxComponent.get()); + CPPUNIT_ASSERT(pTextDocument); + return pTextDocument; +} + +void SwTiledRenderingTest::testResetSelection() +{ + SwXTextDocument* pXTextDocument = createDoc("reset-selection.fodt"); + SwWrtShell* pWrtShell = pXTextDocument->GetDocShell()->GetWrtShell(); + // Select one character. + pWrtShell->Right(CRSR_SKIP_CHARS, /*bSelect=*/true, 1, /*bBasicCall=*/false); + SwShellCrsr* pShellCrsr = pWrtShell->getShellCrsr(false); + // We have a text selection. + CPPUNIT_ASSERT(pShellCrsr->HasMark()); + + pXTextDocument->resetSelection(); + // We no longer have a text selection. + CPPUNIT_ASSERT(!pShellCrsr->HasMark()); + + SdrPage* pPage = pWrtShell->GetDoc()->getIDocumentDrawModelAccess().GetDrawModel()->GetPage(0); + SdrObject* pObject = pPage->GetObj(0); + Point aPoint = pObject->GetSnapRect().Center(); + // Select the shape. + pWrtShell->EnterSelFrmMode(&aPoint); + // We have a graphic selection. + CPPUNIT_ASSERT(pWrtShell->IsSelFrmMode()); + + pXTextDocument->resetSelection(); + // We no longer have a graphic selection. + CPPUNIT_ASSERT(!pWrtShell->IsSelFrmMode()); +} + +CPPUNIT_TEST_SUITE_REGISTRATION(SwTiledRenderingTest); + +CPPUNIT_PLUGIN_IMPLEMENT(); + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ _______________________________________________ Libreoffice-commits mailing list [email protected] http://lists.freedesktop.org/mailman/listinfo/libreoffice-commits
