From fb8377fe404564871d7be8cf777abe2108c74951 Mon Sep 17 00:00:00 2001 From: Laurent Godard Date: Wed, 6 May 2015 16:36:52 +0200 Subject: unit test for tdf#91095 and ready for any docbook export tests Change-Id: Ia1c7a5066fc72c502c3b0ebb5811910797943742 Reviewed-on: https://gerrit.libreoffice.org/15653 Reviewed-by: Miklos Vajna Tested-by: Miklos Vajna --- sw/CppunitTest_sw_docbookexport.mk | 58 ++++++++++++++++++++++++++ sw/Module_sw.mk | 1 + sw/qa/extras/docbookexport/data/simple.docx | Bin 0 -> 3759 bytes sw/qa/extras/docbookexport/data/tdf91095.docx | Bin 0 -> 19141 bytes sw/qa/extras/docbookexport/docbookexport.cxx | 50 ++++++++++++++++++++++ 5 files changed, 109 insertions(+) create mode 100644 sw/CppunitTest_sw_docbookexport.mk create mode 100644 sw/qa/extras/docbookexport/data/simple.docx create mode 100644 sw/qa/extras/docbookexport/data/tdf91095.docx create mode 100644 sw/qa/extras/docbookexport/docbookexport.cxx (limited to 'sw') diff --git a/sw/CppunitTest_sw_docbookexport.mk b/sw/CppunitTest_sw_docbookexport.mk new file mode 100644 index 000000000000..9bed3e131169 --- /dev/null +++ b/sw/CppunitTest_sw_docbookexport.mk @@ -0,0 +1,58 @@ +# -*- 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_docbookexport)) + +$(eval $(call gb_CppunitTest_add_exception_objects,sw_docbookexport, \ + sw/qa/extras/docbookexport/docbookexport \ +)) + +$(eval $(call gb_CppunitTest_use_libraries,sw_docbookexport, \ + comphelper \ + cppu \ + cppuhelper \ + i18nlangtag \ + sal \ + sw \ + test \ + tl \ + unotest \ + utl \ + vcl \ + $(gb_UWINAPI) \ +)) + +$(eval $(call gb_CppunitTest_use_externals,sw_docbookexport,\ + boost_headers \ + libxml2 \ +)) + +$(eval $(call gb_CppunitTest_set_include,sw_docbookexport,\ + -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_docbookexport,\ + offapi \ + udkapi \ +)) + +$(eval $(call gb_CppunitTest_use_ure,sw_docbookexport)) +$(eval $(call gb_CppunitTest_use_vcl,sw_docbookexport)) + +$(eval $(call gb_CppunitTest_use_rdb,sw_docbookexport,services)) + +$(eval $(call gb_CppunitTest_use_configuration,sw_docbookexport)) + +# vim: set noet sw=4 ts=4: diff --git a/sw/Module_sw.mk b/sw/Module_sw.mk index 13453b5beb10..ce01e9a0904d 100644 --- a/sw/Module_sw.mk +++ b/sw/Module_sw.mk @@ -48,6 +48,7 @@ endif $(eval $(call gb_Module_add_slowcheck_targets,sw,\ $(if $(and $(filter $(COM),MSC),$(MERGELIBS)),, \ CppunitTest_sw_uwriter) \ + CppunitTest_sw_docbookexport \ CppunitTest_sw_htmlexport \ CppunitTest_sw_htmlimport \ CppunitTest_sw_macros_test \ diff --git a/sw/qa/extras/docbookexport/data/simple.docx b/sw/qa/extras/docbookexport/data/simple.docx new file mode 100644 index 000000000000..89081fd3cbb6 Binary files /dev/null and b/sw/qa/extras/docbookexport/data/simple.docx differ diff --git a/sw/qa/extras/docbookexport/data/tdf91095.docx b/sw/qa/extras/docbookexport/data/tdf91095.docx new file mode 100644 index 000000000000..fbe23c80e632 Binary files /dev/null and b/sw/qa/extras/docbookexport/data/tdf91095.docx differ diff --git a/sw/qa/extras/docbookexport/docbookexport.cxx b/sw/qa/extras/docbookexport/docbookexport.cxx new file mode 100644 index 000000000000..2f5254684bf5 --- /dev/null +++ b/sw/qa/extras/docbookexport/docbookexport.cxx @@ -0,0 +1,50 @@ +/* -*- 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 + +class DocbookExportTest : public SwModelTestBase +{ +private: + FieldUnit m_eUnit; + +public: + DocbookExportTest() : + SwModelTestBase("/sw/qa/extras/docbookexport/data/", "DocBook File"), + m_eUnit(FUNIT_NONE) + {} +}; + +#define DECLARE_DOCBOOKEXPORT_TEST(TestName, filename) DECLARE_SW_EXPORT_TEST(TestName, filename, DocbookExportTest) + +DECLARE_DOCBOOKEXPORT_TEST(testsimple, "simple.docx") +{ + xmlDocPtr pDoc = parseXml(maTempFile); + CPPUNIT_ASSERT(pDoc); + + assertXPathContent(pDoc, "/article/para", "aaaa"); +} + +/* the test actually should crash with this file */ +DECLARE_DOCBOOKEXPORT_TEST(testtdf91095, "tdf91095.docx") +{ + xmlDocPtr pDoc = parseXml(maTempFile); + CPPUNIT_ASSERT(pDoc); +} + + +CPPUNIT_PLUGIN_IMPLEMENT(); + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ -- cgit