diff options
author | Thorsten Behrens <Thorsten.Behrens@CIB.de> | 2018-08-30 06:03:12 +0200 |
---|---|---|
committer | Thorsten Behrens <Thorsten.Behrens@CIB.de> | 2018-08-31 02:58:49 +0200 |
commit | 22d2b332dfd38da82902ace5d6d3763cb3f56f17 (patch) | |
tree | 9e43937a0c8dcca17b1bc8f489ac74f056f3d853 /sw | |
parent | 8fbf75895e92f179ecc8a90b90d076552a279285 (diff) |
sw: add unit test for the XHTML part of tdf#109202
Change-Id: Ifb1b5b30e1c3586be75ff01f7bc0612a6b8b1f8d
Reviewed-on: https://gerrit.libreoffice.org/59785
Tested-by: Jenkins
Reviewed-by: Thorsten Behrens <Thorsten.Behrens@CIB.de>
Diffstat (limited to 'sw')
-rw-r--r-- | sw/CppunitTest_sw_xhtmlexport.mk | 59 | ||||
-rw-r--r-- | sw/Module_sw.mk | 1 | ||||
-rw-r--r-- | sw/qa/extras/htmlexport/xhtmlexport.cxx | 59 |
3 files changed, 119 insertions, 0 deletions
diff --git a/sw/CppunitTest_sw_xhtmlexport.mk b/sw/CppunitTest_sw_xhtmlexport.mk new file mode 100644 index 000000000000..ce454f367b99 --- /dev/null +++ b/sw/CppunitTest_sw_xhtmlexport.mk @@ -0,0 +1,59 @@ +# -*- 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_xhtmlexport)) + +$(eval $(call gb_CppunitTest_add_exception_objects,sw_xhtmlexport, \ + sw/qa/extras/htmlexport/xhtmlexport \ +)) + +$(eval $(call gb_CppunitTest_use_libraries,sw_xhtmlexport, \ + comphelper \ + cppu \ + cppuhelper \ + i18nlangtag \ + sal \ + sfx \ + sw \ + test \ + tl \ + unotest \ + utl \ + vcl \ +)) + +$(eval $(call gb_CppunitTest_use_externals,sw_xhtmlexport,\ + boost_headers \ + libxml2 \ +)) + +$(eval $(call gb_CppunitTest_set_include,sw_xhtmlexport,\ + -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_xhtmlexport,\ + udkapi \ + offapi \ + oovbaapi \ +)) + +$(eval $(call gb_CppunitTest_use_ure,sw_xhtmlexport)) +$(eval $(call gb_CppunitTest_use_vcl,sw_xhtmlexport)) + +$(eval $(call gb_CppunitTest_use_rdb,sw_xhtmlexport,services)) + +$(eval $(call gb_CppunitTest_use_configuration,sw_xhtmlexport)) + +# vim: set noet sw=4 ts=4: diff --git a/sw/Module_sw.mk b/sw/Module_sw.mk index b9127c379424..c3feaa8feb5b 100644 --- a/sw/Module_sw.mk +++ b/sw/Module_sw.mk @@ -58,6 +58,7 @@ $(eval $(call gb_Module_add_slowcheck_targets,sw,\ CppunitTest_sw_docbookexport \ CppunitTest_sw_fodfexport \ CppunitTest_sw_htmlexport \ + CppunitTest_sw_xhtmlexport \ CppunitTest_sw_htmlimport \ CppunitTest_sw_macros_test \ CppunitTest_sw_ooxmlexport \ diff --git a/sw/qa/extras/htmlexport/xhtmlexport.cxx b/sw/qa/extras/htmlexport/xhtmlexport.cxx new file mode 100644 index 000000000000..af97e6a821fc --- /dev/null +++ b/sw/qa/extras/htmlexport/xhtmlexport.cxx @@ -0,0 +1,59 @@ +/* -*- 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 <memory> +#include <swmodeltestbase.hxx> + +#include <com/sun/star/awt/Gradient.hpp> +#include <com/sun/star/drawing/FillStyle.hpp> +#include <com/sun/star/document/XEmbeddedObjectSupplier2.hpp> +#include <com/sun/star/embed/ElementModes.hpp> +#include <com/sun/star/io/XActiveDataStreamer.hpp> +#include <com/sun/star/io/XSeekable.hpp> +#include <rtl/byteseq.hxx> + +#include <swmodule.hxx> +#include <swdll.hxx> +#include <usrpref.hxx> + +#include <test/htmltesttools.hxx> + +class XHtmlExportTest : public SwModelTestBase, public HtmlTestTools +{ +public: + XHtmlExportTest() + : SwModelTestBase("/sw/qa/extras/odfexport/data/", "XHTML Writer File") + { + } + +private: + virtual std::unique_ptr<Resetter> preTest(const char*) override + { + setFilterOptions("UTF8"); + return nullptr; + } +}; + +#define DECLARE_HTMLEXPORT_TEST(TestName, filename) \ + DECLARE_SW_EXPORT_TEST(TestName, filename, nullptr, XHtmlExportTest) + +DECLARE_HTMLEXPORT_TEST(testImageEmbedding, "image-mimetype.odt") +{ + htmlDocPtr pDoc = parseHtml(maTempFile); + CPPUNIT_ASSERT(pDoc); + + assertXPath(pDoc, "/html/body", 1); + assertXPath(pDoc, "/html/body/div[1]/div[1]/img", 1); + OUString aValue = getXPath(pDoc, "/html/body/div[1]/div[1]/img", "src"); + CPPUNIT_ASSERT(aValue.startsWith("data:image/svg+xml;base64")); +} + +CPPUNIT_PLUGIN_IMPLEMENT(); + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ |