tdf#92029: sw_autocorrect: Add unittest

Change-Id: I7ac855ac826353869c3a905ea70448d0c8dc1b76
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/169711
Tested-by: Jenkins
Reviewed-by: Xisco Fauli <xiscofauli@libreoffice.org>
This commit is contained in:
Xisco Fauli 2024-06-28 15:17:56 +02:00
parent 6c94932865
commit 93987194f5
4 changed files with 136 additions and 0 deletions

View file

@ -0,0 +1,78 @@
# -*- 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_autocorrect))
$(eval $(call gb_CppunitTest_use_common_precompiled_header,sw_autocorrect))
$(eval $(call gb_CppunitTest_add_exception_objects,sw_autocorrect, \
sw/qa/extras/autocorrect/autocorrect \
))
$(eval $(call gb_CppunitTest_use_libraries,sw_autocorrect, \
comphelper \
cppu \
cppuhelper \
editeng \
sal \
sfx \
subsequenttest \
svl \
svx \
svxcore \
sw \
swqahelper \
test \
unotest \
utl \
vcl \
tl \
))
$(eval $(call gb_CppunitTest_use_externals,sw_autocorrect,\
boost_headers \
libxml2 \
))
$(eval $(call gb_CppunitTest_set_include,sw_autocorrect,\
-I$(SRCDIR)/sw/inc \
-I$(SRCDIR)/sw/source/core/inc \
-I$(SRCDIR)/sw/source/uibase/inc \
-I$(SRCDIR)/sw/qa/inc \
$$(INCLUDE) \
))
$(eval $(call gb_CppunitTest_use_api,sw_autocorrect,\
udkapi \
offapi \
oovbaapi \
))
$(eval $(call gb_CppunitTest_use_ure,sw_autocorrect))
$(eval $(call gb_CppunitTest_use_vcl,sw_autocorrect))
$(eval $(call gb_CppunitTest_use_rdb,sw_autocorrect,services))
$(eval $(call gb_CppunitTest_use_custom_headers,sw_autocorrect,\
officecfg/registry \
))
$(eval $(call gb_CppunitTest_use_configuration,sw_autocorrect))
$(eval $(call gb_CppunitTest_use_uiconfigs,sw_autocorrect, \
modules/swriter \
))
$(eval $(call gb_CppunitTest_use_more_fonts,sw_autocorrect))
ifneq ($(filter MORE_FONTS,$(BUILD_TYPE)),)
$(eval $(call gb_CppunitTest_set_non_application_font_use,sw_autocorrect,abort))
endif
# vim: set noet sw=4 ts=4:

View file

@ -136,6 +136,7 @@ $(eval $(call gb_Module_add_slowcheck_targets,sw,\
CppunitTest_sw_accessible_relation_set \
CppunitTest_sw_apiterminate \
CppunitTest_sw_apitests \
CppunitTest_sw_autocorrect \
CppunitTest_sw_unowriter \
CppunitTest_sw_core_text \
CppunitTest_sw_core_doc \

View file

@ -0,0 +1,43 @@
/* -*- 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 <docsh.hxx>
#include <unotxdoc.hxx>
// If you want to add a test for a language that doesn't exists yet
// copy an existing document and adapt "fo:language" and "fo:country"
class SwAutoCorrect : public SwModelTestBase
{
public:
SwAutoCorrect()
: SwModelTestBase(u"/sw/qa/extras/autocorrect/data/"_ustr)
{
}
};
CPPUNIT_TEST_FIXTURE(SwAutoCorrect, nl_BE)
{
createSwDoc("nl-BE.fodt");
SwXTextDocument* pTextDoc = dynamic_cast<SwXTextDocument*>(mxComponent.get());
// tdf#92029: Without the fix in place, this test would have failed with
// - Expected: Ik ben s morgens opgestaan
// - Actual : Ik ben s morgens opgestaan
emulateTyping(*pTextDoc, u"Ik ben 's morgens opgestaan");
OUString sReplaced(u"Ik ben s morgens opgestaan"_ustr);
CPPUNIT_ASSERT_EQUAL(sReplaced, getParagraph(1)->getString());
}
CPPUNIT_PLUGIN_IMPLEMENT();
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */

View file

@ -0,0 +1,14 @@
<?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:table="urn:oasis:names:tc:opendocument:xmlns:table:1.0" xmlns:text="urn:oasis:names:tc:opendocument:xmlns:text:1.0" xmlns:fo="urn:oasis:names:tc:opendocument:xmlns:xsl-fo-compatible:1.0" xmlns:officeooo="http://openoffice.org/2009/office" xmlns:loext="urn:org:documentfoundation:names:experimental:office:xmlns:loext:1.0" office:version="1.2" office:mimetype="application/vnd.oasis.opendocument.text">
<office:styles>
<style:style style:name="Standard" style:family="paragraph" style:class="text"/>
<style:default-style style:family="paragraph">
<style:text-properties fo:language="nl" fo:country="BE"/>
</style:default-style>
</office:styles>
<office:body>
<office:text>
<text:p text:style-name="Standard"></text:p>
</office:text>
</office:body>
</office:document>