tdf#137469 Prepare tests for encoded text filter

Change-Id: Ifba71748cc389544bfb64e225a7020de8261967b
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/105621
Tested-by: Jenkins
Reviewed-by: Michael Stahl <michael.stahl@allotropia.de>
This commit is contained in:
Oleg Shchelykalnov
2021-05-26 18:20:06 +03:00
committed by Michael Stahl
parent 7af40a4455
commit c96b61f86e
5 changed files with 166 additions and 0 deletions

View File

@@ -12332,6 +12332,7 @@ sw/qa/extras/ooxmlexport/ooxmlfieldexport.cxx
sw/qa/extras/ooxmlexport/ooxmlw14export.cxx
sw/qa/extras/ooxmlimport/ooxmlimport.cxx
sw/qa/extras/tiledrendering/tiledrendering.cxx
sw/qa/extras/txtencexport/txtencexport.cxx
sw/qa/extras/uiwriter/uiwriter.cxx
sw/qa/extras/ww8export/ww8export.cxx
sw/qa/extras/ww8export/ww8export2.cxx

View File

@@ -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,sw_txtencexport))
$(eval $(call gb_CppunitTest_use_common_precompiled_header,sw_txtencexport))
$(eval $(call gb_CppunitTest_add_exception_objects,sw_txtencexport, \
sw/qa/extras/txtencexport/txtencexport \
))
$(eval $(call gb_CppunitTest_use_libraries,sw_txtencexport, \
comphelper \
cppu \
cppuhelper \
i18nlangtag \
sal \
sfx \
sw \
swqahelper \
test \
tl \
unotest \
utl \
vcl \
$(gb_UWINAPI) \
))
$(eval $(call gb_CppunitTest_use_externals,sw_txtencexport,\
boost_headers \
libxml2 \
))
$(eval $(call gb_CppunitTest_set_include,sw_txtencexport,\
-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_txtencexport,\
udkapi \
offapi \
oovbaapi \
))
$(eval $(call gb_CppunitTest_use_ure,sw_txtencexport))
$(eval $(call gb_CppunitTest_use_vcl,sw_txtencexport))
$(eval $(call gb_CppunitTest_use_rdb,sw_txtencexport,services))
$(eval $(call gb_CppunitTest_use_configuration,sw_txtencexport))
# vim: set noet sw=4 ts=4:

View File

@@ -104,6 +104,7 @@ $(eval $(call gb_Module_add_slowcheck_targets,sw,\
CppunitTest_sw_odfexport2 \
CppunitTest_sw_odfimport \
CppunitTest_sw_txtexport \
CppunitTest_sw_txtencexport \
CppunitTest_sw_txtimport \
$(if $(filter-out MACOSX,$(OS)), \
CppunitTest_sw_uiwriter \

Binary file not shown.

View File

@@ -0,0 +1,101 @@
/* -*- 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 <osl/thread.hxx>
class TxtEncExportTest : public SwModelTestBase
{
public:
TxtEncExportTest(const OUString & rFilterOptions)
: SwModelTestBase("/sw/qa/extras/txtencexport/data/", "Text (encoded)")
{
setFilterOptions(rFilterOptions);
}
protected:
OString readExportedFile()
{
SvMemoryStream aMemoryStream;
SvFileStream aStream(maTempFile.GetURL(), StreamMode::READ);
aStream.ReadStream(aMemoryStream);
const char* pData = static_cast<const char*>(aMemoryStream.GetData());
int offset = 0;
if (aMemoryStream.GetSize() > 2 && pData[0] == '\xEF' && pData[1] == '\xBB'
&& pData[2] == '\xBF')
offset = 3;
return OString(pData + offset, aMemoryStream.GetSize() - offset);
}
};
#define DECLARE_TXTENCEXPORT_TEST(TestName, filename, filterOptions, ClassName) \
class ClassName : public TxtEncExportTest { \
public: \
ClassName() : TxtEncExportTest(filterOptions) {} \
}; \
DECLARE_SW_EXPORT_TEST(TestName, filename, nullptr, ClassName)
DECLARE_TXTENCEXPORT_TEST(testBulletsNotHidden, "bullets.odt", "UTF8,,,,", TxtEncExportNotHiddenTest)
{
OString aData = readExportedFile();
OUString aString = OStringToOUString(
"1 Heading 1" SAL_NEWLINE_STRING "1.A Heading 2" SAL_NEWLINE_STRING
"Paragraph" SAL_NEWLINE_STRING "" SAL_NEWLINE_STRING
" \xe2\x80\xa2 First bullet" SAL_NEWLINE_STRING
" \xe2\x80\xa2 Second bullet" SAL_NEWLINE_STRING
" \xe2\x97\xa6 Sub-second bullet" SAL_NEWLINE_STRING
" Third bullet, but deleted" SAL_NEWLINE_STRING
" \xe2\x80\xa2 Fourth bullet" SAL_NEWLINE_STRING "" SAL_NEWLINE_STRING
"Numbering" SAL_NEWLINE_STRING "" SAL_NEWLINE_STRING " 1. First" SAL_NEWLINE_STRING
" 2. Second" SAL_NEWLINE_STRING " 1. Second-first" SAL_NEWLINE_STRING
" Third, but deleted" SAL_NEWLINE_STRING " 3. Actual third" SAL_NEWLINE_STRING
"" SAL_NEWLINE_STRING "Paragraph after numbering" SAL_NEWLINE_STRING
"Next paragraph" SAL_NEWLINE_STRING "Hidden paragraph" SAL_NEWLINE_STRING
"Final paragraph" SAL_NEWLINE_STRING,
RTL_TEXTENCODING_UTF8);
// To get the stuff back in the system's encoding
OString aExpected(OUStringToOString(aString, RTL_TEXTENCODING_UTF8));
CPPUNIT_ASSERT_EQUAL(aExpected, aData);
}
DECLARE_TXTENCEXPORT_TEST(testBulletsHidden, "bullets.odt", "UTF8,,,,,false", TxtEncExportHiddenTest)
{
OString aData = readExportedFile();
OUString aString = OStringToOUString(
"1 Heading 1" SAL_NEWLINE_STRING "1.A Heading 2" SAL_NEWLINE_STRING
"Paragraph" SAL_NEWLINE_STRING "" SAL_NEWLINE_STRING
" \xe2\x80\xa2 First bullet" SAL_NEWLINE_STRING
" \xe2\x80\xa2 Second bullet" SAL_NEWLINE_STRING
" \xe2\x97\xa6 Sub-second bullet" SAL_NEWLINE_STRING
" Third bullet, but deleted" SAL_NEWLINE_STRING
" \xe2\x80\xa2 Fourth bullet" SAL_NEWLINE_STRING "" SAL_NEWLINE_STRING
"Numbering" SAL_NEWLINE_STRING "" SAL_NEWLINE_STRING " 1. First" SAL_NEWLINE_STRING
" 2. Second" SAL_NEWLINE_STRING " 1. Second-first" SAL_NEWLINE_STRING
" Third, but deleted" SAL_NEWLINE_STRING " 3. Actual third" SAL_NEWLINE_STRING
"" SAL_NEWLINE_STRING "Paragraph after numbering" SAL_NEWLINE_STRING
"Next paragraph" SAL_NEWLINE_STRING "Hidden paragraph" SAL_NEWLINE_STRING
"Final paragraph" SAL_NEWLINE_STRING,
RTL_TEXTENCODING_UTF8);
// To get the stuff back in the system's encoding
OString aExpected(OUStringToOString(aString, RTL_TEXTENCODING_UTF8));
CPPUNIT_ASSERT_EQUAL(aExpected, aData);
}
CPPUNIT_PLUGIN_IMPLEMENT();
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */