summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorTomaž Vajngerl <tomaz.vajngerl@collabora.com>2014-04-29 23:54:32 +0200
committerTomaž Vajngerl <tomaz.vajngerl@collabora.com>2014-04-29 23:57:34 +0200
commitfa8d10adbf12bef19cfe6dd39d2667944a2fb7d6 (patch)
tree790a8aa5bd62c5d090436e370b930c3040d60945
parentdde833575e29afecb6b053d3be28d9d028a72bef (diff)
sc html export: HTML export test fixture & "SkipImages" test
Change-Id: I8a419f535570924d508e1ce5f0c6bb1fbdd829a7
-rw-r--r--sc/CppunitTest_sc_html_export_test.mk114
-rw-r--r--sc/Module_sc.mk1
-rw-r--r--sc/qa/extras/htmlexporttest.cxx100
-rw-r--r--sc/qa/extras/testdocuments/BaseForHTMLExport.odsbin0 -> 10933 bytes
4 files changed, 215 insertions, 0 deletions
diff --git a/sc/CppunitTest_sc_html_export_test.mk b/sc/CppunitTest_sc_html_export_test.mk
new file mode 100644
index 000000000000..15b42d15fcd5
--- /dev/null
+++ b/sc/CppunitTest_sc_html_export_test.mk
@@ -0,0 +1,114 @@
+# -*- 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,sc_html_export_test))
+
+$(eval $(call gb_CppunitTest_add_exception_objects,sc_html_export_test, \
+ sc/qa/extras/htmlexporttest \
+))
+
+$(eval $(call gb_CppunitTest_use_externals,sc_html_export_test, \
+ boost_headers \
+ libxml2 \
+))
+
+$(eval $(call gb_CppunitTest_use_libraries,sc_html_export_test, \
+ basegfx \
+ comphelper \
+ cppu \
+ cppuhelper \
+ drawinglayer \
+ editeng \
+ for \
+ forui \
+ i18nlangtag \
+ msfilter \
+ oox \
+ sal \
+ salhelper \
+ sax \
+ sc \
+ scqahelper \
+ sfx \
+ sot \
+ svl \
+ svt \
+ svx \
+ svxcore \
+ test \
+ tl \
+ tk \
+ ucbhelper \
+ unotest \
+ utl \
+ vcl \
+ xo \
+ $(gb_UWINAPI) \
+))
+
+$(eval $(call gb_CppunitTest_set_include,sc_html_export_test,\
+ -I$(SRCDIR)/sc/source/ui/inc \
+ -I$(SRCDIR)/sc/inc \
+ $$(INCLUDE) \
+))
+
+$(eval $(call gb_CppunitTest_use_api,sc_html_export_test,\
+ offapi \
+ udkapi \
+))
+
+$(eval $(call gb_CppunitTest_use_ure,sc_html_export_test))
+
+$(eval $(call gb_CppunitTest_use_components,sc_html_export_test,\
+ basic/util/sb \
+ comphelper/util/comphelp \
+ configmgr/source/configmgr \
+ dbaccess/util/dba \
+ filter/source/config/cache/filterconfig1 \
+ forms/util/frm \
+ framework/util/fwk \
+ i18npool/util/i18npool \
+ linguistic/source/lng \
+ oox/util/oox \
+ package/source/xstor/xstor \
+ package/util/package2 \
+ sax/source/expatwrap/expwrap \
+ sc/util/sc \
+ sc/util/scd \
+ sc/util/scfilt \
+ $(if $(filter TRUE,$(DISABLE_SCRIPTING)),, \
+ sc/util/vbaobj) \
+ scripting/source/basprov/basprov \
+ scripting/util/scriptframe \
+ scripting/source/vbaevents/vbaevents \
+ scripting/source/dlgprov/dlgprov \
+ sfx2/util/sfx \
+ sot/util/sot \
+ svl/source/fsstor/fsstorage \
+ svtools/util/svt \
+ svx/util/svx \
+ svx/util/svxcore \
+ toolkit/util/tk \
+ ucb/source/core/ucb1 \
+ ucb/source/ucp/file/ucpfile1 \
+ ucb/source/ucp/tdoc/ucptdoc1 \
+ unotools/util/utl \
+ unoxml/source/rdf/unordf \
+ unoxml/source/service/unoxml \
+ xmloff/util/xo \
+ eventattacher/source/evtatt \
+ i18npool/source/search/i18nsearch \
+ vbahelper/util/msforms \
+))
+
+$(eval $(call gb_CppunitTest_use_configuration,sc_html_export_test))
+
+$(eval $(call gb_CppunitTest_use_unittest_configuration,sc_html_export_test))
+
+# vim: set noet sw=4 ts=4:
diff --git a/sc/Module_sc.mk b/sc/Module_sc.mk
index fae40f5bf622..41804b2fddbb 100644
--- a/sc/Module_sc.mk
+++ b/sc/Module_sc.mk
@@ -54,6 +54,7 @@ $(eval $(call gb_Module_add_check_targets,sc,\
CppunitTest_sc_ucalc \
CppunitTest_sc_filters_test \
CppunitTest_sc_rangelst_test \
+ CppunitTest_sc_html_export_test \
))
$(eval $(call gb_Module_add_slowcheck_targets,sc, \
diff --git a/sc/qa/extras/htmlexporttest.cxx b/sc/qa/extras/htmlexporttest.cxx
new file mode 100644
index 000000000000..e06525109cc9
--- /dev/null
+++ b/sc/qa/extras/htmlexporttest.cxx
@@ -0,0 +1,100 @@
+/* -*- 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 <sal/config.h>
+
+#include <com/sun/star/frame/Desktop.hpp>
+#include <com/sun/star/frame/XStorable.hpp>
+#include <com/sun/star/lang/XComponent.hpp>
+
+#include <test/bootstrapfixture.hxx>
+#include <test/htmltesttools.hxx>
+#include <test/xmltesttools.hxx>
+#include <comphelper/processfactory.hxx>
+#include <unotools/mediadescriptor.hxx>
+#include <unotools/ucbstreamhelper.hxx>
+#include <unotest/macros_test.hxx>
+#include <sfx2/docfilt.hxx>
+#include <sfx2/docfile.hxx>
+
+#include "docsh.hxx"
+
+using namespace css::uno;
+using namespace css::lang;
+using namespace css::frame;
+using namespace utl;
+
+class ScHTMLExportTest : public test::BootstrapFixture, public unotest::MacrosTest, public XmlTestTools, public HtmlTestTools
+{
+ Reference<XComponent> mxComponent;
+ TempFile maTempFile;
+ OUString maFilterOptions;
+
+ void load(const char* pDir, const char* pName)
+ {
+ if (mxComponent.is())
+ mxComponent->dispose();
+ mxComponent = loadFromDesktop(getURLFromSrc(pDir) + OUString::createFromAscii(pName), "com.sun.star.comp.Calc.SpreadsheetDocument");
+ }
+
+ void save(const OUString& aFilterName, TempFile& rTempFile)
+ {
+ rTempFile.EnableKillingFile();
+
+ Reference<XStorable> xStorable(mxComponent, UNO_QUERY);
+ MediaDescriptor aMediaDescriptor;
+ aMediaDescriptor["FilterName"] <<= aFilterName;
+ if (!maFilterOptions.isEmpty())
+ aMediaDescriptor["FilterOptions"] <<= maFilterOptions;
+ xStorable->storeToURL(rTempFile.GetURL(), aMediaDescriptor.getAsConstPropertyValueList());
+ }
+
+public:
+ ScHTMLExportTest()
+ {}
+
+ virtual void setUp() SAL_OVERRIDE
+ {
+ test::BootstrapFixture::setUp();
+ mxDesktop.set(css::frame::Desktop::create(comphelper::getComponentContext(getMultiServiceFactory())));
+ }
+
+ void testHtmlSkipImage()
+ {
+ htmlDocPtr pDoc;
+
+ load("/sc/qa/extras/testdocuments/", "BaseForHTMLExport.ods");
+ save("HTML (StarCalc)", maTempFile);
+ pDoc = parseHtml(maTempFile);
+ CPPUNIT_ASSERT (pDoc);
+
+ assertXPath(pDoc, "/html/body", 1);
+ assertXPath(pDoc, "/html/body/table/tr/td/img", 1);
+
+ load("/sc/qa/extras/testdocuments/", "BaseForHTMLExport.ods");
+ maFilterOptions = OUString("SkipImages");
+ save("HTML (StarCalc)", maTempFile);
+
+ pDoc = parseHtml(maTempFile);
+ CPPUNIT_ASSERT (pDoc);
+ assertXPath(pDoc, "/html/body", 1);
+ assertXPath(pDoc, "/html/body/table/tr/td/img", 0);
+ }
+
+ CPPUNIT_TEST_SUITE(ScHTMLExportTest);
+ CPPUNIT_TEST(testHtmlSkipImage);
+ CPPUNIT_TEST_SUITE_END();
+
+};
+
+CPPUNIT_TEST_SUITE_REGISTRATION(ScHTMLExportTest);
+
+CPPUNIT_PLUGIN_IMPLEMENT();
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/sc/qa/extras/testdocuments/BaseForHTMLExport.ods b/sc/qa/extras/testdocuments/BaseForHTMLExport.ods
new file mode 100644
index 000000000000..025b1e48069d
--- /dev/null
+++ b/sc/qa/extras/testdocuments/BaseForHTMLExport.ods
Binary files differ