From 22d2b332dfd38da82902ace5d6d3763cb3f56f17 Mon Sep 17 00:00:00 2001 From: Thorsten Behrens Date: Thu, 30 Aug 2018 06:03:12 +0200 Subject: 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 --- sw/CppunitTest_sw_xhtmlexport.mk | 59 +++++++++++++++++++++++++++++++++ sw/Module_sw.mk | 1 + sw/qa/extras/htmlexport/xhtmlexport.cxx | 59 +++++++++++++++++++++++++++++++++ 3 files changed, 119 insertions(+) create mode 100644 sw/CppunitTest_sw_xhtmlexport.mk create mode 100644 sw/qa/extras/htmlexport/xhtmlexport.cxx 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 +#include + +#include +#include +#include +#include +#include +#include +#include + +#include +#include +#include + +#include + +class XHtmlExportTest : public SwModelTestBase, public HtmlTestTools +{ +public: + XHtmlExportTest() + : SwModelTestBase("/sw/qa/extras/odfexport/data/", "XHTML Writer File") + { + } + +private: + virtual std::unique_ptr 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: */ -- cgit v1.2.3