summaryrefslogtreecommitdiff
path: root/writerperfect
diff options
context:
space:
mode:
authorMiklos Vajna <vmiklos@collabora.co.uk>2017-08-24 14:32:59 +0200
committerMiklos Vajna <vmiklos@collabora.co.uk>2017-08-24 18:04:50 +0200
commitab8b8fb183067fd0bded089f513b614d35138e18 (patch)
tree003897b179c58535c1f14e0d2d801751ac7aad72 /writerperfect
parent8d1dc9a662d2e1bc833d5488f3f0013f98e7f3fd (diff)
Add initial CppunitTest_writerperfect_epubexport
Fails with the writerperfect/source/writer/exp/txtparai.cxx part of commit b6f39c47fb477f16c65631523b0c18b4f262fadf (EPUB export: initial index support, 2017-08-15) reverted. Change-Id: I56457b3e3b312682e4c83ea08dbd459ca42152ef Reviewed-on: https://gerrit.libreoffice.org/41518 Tested-by: Jenkins <ci@libreoffice.org> Reviewed-by: Miklos Vajna <vmiklos@collabora.co.uk>
Diffstat (limited to 'writerperfect')
-rw-r--r--writerperfect/CppunitTest_writerperfect_epubexport.mk41
-rw-r--r--writerperfect/Module_writerperfect.mk1
-rw-r--r--writerperfect/qa/unit/EPUBExportTest.cxx88
-rw-r--r--writerperfect/qa/unit/data/writer/epubexport/outline-level.fodt15
4 files changed, 145 insertions, 0 deletions
diff --git a/writerperfect/CppunitTest_writerperfect_epubexport.mk b/writerperfect/CppunitTest_writerperfect_epubexport.mk
new file mode 100644
index 000000000000..ea5285730b31
--- /dev/null
+++ b/writerperfect/CppunitTest_writerperfect_epubexport.mk
@@ -0,0 +1,41 @@
+# -*- 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,writerperfect_epubexport))
+
+$(eval $(call gb_CppunitTest_add_exception_objects,writerperfect_epubexport, \
+ writerperfect/qa/unit/EPUBExportTest \
+))
+
+$(eval $(call gb_CppunitTest_use_sdk_api,writerperfect_epubexport))
+
+$(eval $(call gb_CppunitTest_use_libraries,writerperfect_epubexport, \
+ comphelper \
+ cppu \
+ cppuhelper \
+ sal \
+ test \
+ unotest \
+ utl \
+ tl \
+ $(gb_UWINAPI) \
+))
+
+$(eval $(call gb_CppunitTest_use_external,writerperfect_epubexport,boost_headers))
+
+$(eval $(call gb_CppunitTest_use_sdk_api,writerperfect_epubexport))
+
+$(eval $(call gb_CppunitTest_use_ure,writerperfect_epubexport))
+$(eval $(call gb_CppunitTest_use_vcl,writerperfect_epubexport))
+
+$(eval $(call gb_CppunitTest_use_rdb,writerperfect_epubexport,services))
+
+$(eval $(call gb_CppunitTest_use_configuration,writerperfect_epubexport))
+
+# vim: set noet sw=4 ts=4:
diff --git a/writerperfect/Module_writerperfect.mk b/writerperfect/Module_writerperfect.mk
index b2102c54b987..859f0cbe2507 100644
--- a/writerperfect/Module_writerperfect.mk
+++ b/writerperfect/Module_writerperfect.mk
@@ -40,6 +40,7 @@ $(eval $(call gb_Module_add_check_targets,writerperfect,\
$(eval $(call gb_Module_add_slowcheck_targets,writerperfect,\
CppunitTest_writerperfect_calc \
CppunitTest_writerperfect_draw \
+ CppunitTest_writerperfect_epubexport \
CppunitTest_writerperfect_import \
CppunitTest_writerperfect_impress \
CppunitTest_writerperfect_writer \
diff --git a/writerperfect/qa/unit/EPUBExportTest.cxx b/writerperfect/qa/unit/EPUBExportTest.cxx
new file mode 100644
index 000000000000..ef65012daca9
--- /dev/null
+++ b/writerperfect/qa/unit/EPUBExportTest.cxx
@@ -0,0 +1,88 @@
+/* -*- 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 <com/sun/star/frame/Desktop.hpp>
+#include <com/sun/star/frame/XStorable.hpp>
+#include <com/sun/star/packages/zip/ZipFileAccess.hpp>
+
+#include <comphelper/processfactory.hxx>
+#include <cppuhelper/implbase.hxx>
+#include <test/bootstrapfixture.hxx>
+#include <unotest/macros_test.hxx>
+#include <unotools/mediadescriptor.hxx>
+#include <unotools/tempfile.hxx>
+
+using namespace ::com::sun::star;
+
+namespace
+{
+
+char const DATA_DIRECTORY[] = "/writerperfect/qa/unit/data/writer/epubexport/";
+
+/// Tests the EPUB export filter.
+class EPUBExportTest : public test::BootstrapFixture, public unotest::MacrosTest
+{
+ uno::Reference<uno::XComponentContext> mxComponentContext;
+ uno::Reference<lang::XComponent> mxComponent;
+
+public:
+ virtual void setUp() override;
+ virtual void tearDown() override;
+ void testOutlineLevel();
+
+ CPPUNIT_TEST_SUITE(EPUBExportTest);
+ CPPUNIT_TEST(testOutlineLevel);
+ CPPUNIT_TEST_SUITE_END();
+};
+
+void EPUBExportTest::setUp()
+{
+ test::BootstrapFixture::setUp();
+
+ mxComponentContext.set(comphelper::getComponentContext(getMultiServiceFactory()));
+ mxDesktop.set(frame::Desktop::create(mxComponentContext));
+}
+
+void EPUBExportTest::tearDown()
+{
+ if (mxComponent.is())
+ mxComponent->dispose();
+
+ test::BootstrapFixture::tearDown();
+}
+
+void EPUBExportTest::testOutlineLevel()
+{
+ // Import the bugdoc and export as EPUB.
+ OUString aURL = m_directories.getURLFromSrc(DATA_DIRECTORY) + "outline-level.fodt";
+ mxComponent = loadFromDesktop(aURL);
+ CPPUNIT_ASSERT(mxComponent.is());
+
+ uno::Reference<frame::XStorable> xStorable(mxComponent, uno::UNO_QUERY);
+ utl::TempFile aTempFile;
+ aTempFile.EnableKillingFile();
+ utl::MediaDescriptor aMediaDescriptor;
+ aMediaDescriptor["FilterName"] <<= OUString("EPUB");
+ xStorable->storeToURL(aTempFile.GetURL(), aMediaDescriptor.getAsConstPropertyValueList());
+
+ // Make sure that the output is split into two.
+ uno::Reference<packages::zip::XZipFileAccess2> xNameAccess = packages::zip::ZipFileAccess::createWithURL(mxComponentContext, aTempFile.GetURL());
+ CPPUNIT_ASSERT(xNameAccess->hasByName("OEBPS/sections/section0001.xhtml"));
+ // This failed, output was a single section.
+ CPPUNIT_ASSERT(xNameAccess->hasByName("OEBPS/sections/section0002.xhtml"));
+ CPPUNIT_ASSERT(!xNameAccess->hasByName("OEBPS/sections/section0003.xhtml"));
+}
+
+CPPUNIT_TEST_SUITE_REGISTRATION(EPUBExportTest);
+
+}
+
+CPPUNIT_PLUGIN_IMPLEMENT();
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/writerperfect/qa/unit/data/writer/epubexport/outline-level.fodt b/writerperfect/qa/unit/data/writer/epubexport/outline-level.fodt
new file mode 100644
index 000000000000..11cbf3dc22a1
--- /dev/null
+++ b/writerperfect/qa/unit/data/writer/epubexport/outline-level.fodt
@@ -0,0 +1,15 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<office:document office:mimetype="application/vnd.oasis.opendocument.text" office:version="1.2" xmlns:office="urn:oasis:names:tc:opendocument:xmlns:office:1.0" xmlns:text="urn:oasis:names:tc:opendocument:xmlns:text:1.0">
+ <office:body>
+ <office:text>
+ <text:h text:outline-level="1">Chapter 1</text:h>
+ <text:p>foo</text:p>
+ <text:h text:outline-level="2">Chapter 1.1</text:h>
+ <text:p>foo</text:p>
+ <text:h text:outline-level="1">Chapter 2</text:h>
+ <text:p>bar</text:p>
+ <text:h text:outline-level="2">Chapter 2.1</text:h>
+ <text:p>bar</text:p>
+ </office:text>
+ </office:body>
+</office:document>