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

Add testcase for SwXTextDocument::resetSelection().

Change-Id: Idc97ebfe3db27ac52c1c6b16177f08118a750e69
üst 73ed546f
# -*- 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:
......@@ -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 \
))
......
<?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:oasis: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>
/* -*- 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: */
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