summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorVasily Melenchuk <Vasily.Melenchuk@cib.de>2017-11-29 16:29:52 +0300
committerEike Rathke <erack@redhat.com>2017-12-07 18:01:42 +0100
commit51cdf6248dbdf7a5dcddd2128bbb8f889cec25d6 (patch)
tree58fddaa89b7e3a0259e55493d6ad8c6a5f18f498
parentfebc90fec11279d5ea14635418af207047977651 (diff)
tdf#113861: Unittest for chart datatable labels expansion
Change-Id: Icfa10b1e75c801a9a025c0173bd8a34e362f049e Reviewed-on: https://gerrit.libreoffice.org/45670 Tested-by: Jenkins <ci@libreoffice.org> Reviewed-by: Eike Rathke <erack@redhat.com>
-rw-r--r--sc/CppunitTest_sc_chart2dataprovider.mk122
-rw-r--r--sc/Module_sc.mk1
-rw-r--r--sc/inc/chart2uno.hxx2
-rw-r--r--sc/qa/unit/chart2dataprovider.cxx122
-rw-r--r--sc/qa/unit/data/ods/chart2dataprovider.odsbin0 -> 9276 bytes
5 files changed, 246 insertions, 1 deletions
diff --git a/sc/CppunitTest_sc_chart2dataprovider.mk b/sc/CppunitTest_sc_chart2dataprovider.mk
new file mode 100644
index 000000000000..7ef131b7f147
--- /dev/null
+++ b/sc/CppunitTest_sc_chart2dataprovider.mk
@@ -0,0 +1,122 @@
+# -*- 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_chart2dataprovider))
+
+$(eval $(call gb_CppunitTest_add_exception_objects,sc_chart2dataprovider, \
+ sc/qa/unit/chart2dataprovider \
+))
+
+$(eval $(call gb_CppunitTest_use_externals,sc_chart2dataprovider, \
+ boost_headers \
+ mdds_headers \
+ libxml2 \
+))
+
+$(eval $(call gb_CppunitTest_use_libraries,sc_chart2dataprovider, \
+ basegfx \
+ comphelper \
+ cppu \
+ cppuhelper \
+ drawinglayer \
+ editeng \
+ for \
+ forui \
+ i18nlangtag \
+ msfilter \
+ oox \
+ sal \
+ salhelper \
+ sax \
+ sb \
+ sc \
+ scqahelper \
+ sfx \
+ sot \
+ subsequenttest \
+ svl \
+ svt \
+ svx \
+ svxcore \
+ test \
+ tk \
+ tl \
+ ucbhelper \
+ unotest \
+ utl \
+ vbahelper \
+ vcl \
+ xo \
+ $(gb_UWINAPI) \
+))
+
+$(eval $(call gb_CppunitTest_set_include,sc_chart2dataprovider,\
+ -I$(SRCDIR)/sc/source/ui/inc \
+ -I$(SRCDIR)/sc/inc \
+ $$(INCLUDE) \
+))
+
+$(eval $(call gb_CppunitTest_use_sdk_api,sc_chart2dataprovider))
+
+$(eval $(call gb_CppunitTest_use_ure,sc_chart2dataprovider))
+$(eval $(call gb_CppunitTest_use_vcl,sc_chart2dataprovider))
+
+$(eval $(call gb_CppunitTest_use_components,sc_chart2dataprovider,\
+ basic/util/sb \
+ chart2/source/chartcore \
+ chart2/source/controller/chartcontroller \
+ comphelper/util/comphelp \
+ configmgr/source/configmgr \
+ dbaccess/util/dba \
+ embeddedobj/util/embobj \
+ eventattacher/source/evtatt \
+ filter/source/config/cache/filterconfig1 \
+ forms/util/frm \
+ framework/util/fwk \
+ i18npool/source/search/i18nsearch \
+ i18npool/util/i18npool \
+ linguistic/source/lng \
+ oox/util/oox \
+ package/source/xstor/xstor \
+ package/util/package2 \
+ sax/source/expatwrap/expwrap \
+ scaddins/source/analysis/analysis \
+ scaddins/source/datefunc/date \
+ sc/util/sc \
+ sc/util/scfilt \
+ sfx2/util/sfx \
+ sot/util/sot \
+ svl/util/svl \
+ svl/source/fsstor/fsstorage \
+ svtools/util/svt \
+ 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 \
+ uui/util/uui \
+ xmloff/util/xo \
+ xmlsecurity/util/xmlsecurity \
+))
+
+ifeq ($(OS),WNT)
+$(eval $(call gb_CppunitTest_use_components,sc_chart2dataprovider,\
+ xmlsecurity/util/xsec_xmlsec.windows \
+))
+else
+$(eval $(call gb_CppunitTest_use_components,sc_chart2dataprovider,\
+ xmlsecurity/util/xsec_xmlsec \
+))
+endif
+
+$(eval $(call gb_CppunitTest_use_configuration,sc_chart2dataprovider))
+
+# vim: set noet sw=4 ts=4:
diff --git a/sc/Module_sc.mk b/sc/Module_sc.mk
index ae9a2c4e89af..dc60e9d1d049 100644
--- a/sc/Module_sc.mk
+++ b/sc/Module_sc.mk
@@ -144,6 +144,7 @@ $(eval $(call gb_Module_add_subsequentcheck_targets,sc,\
CppunitTest_sc_headerfootercontentobj \
CppunitTest_sc_recentfunctionsobj \
CppunitTest_sc_functionlistobj \
+ CppunitTest_sc_chart2dataprovider \
))
$(eval $(call gb_Module_add_perfcheck_targets,sc,\
diff --git a/sc/inc/chart2uno.hxx b/sc/inc/chart2uno.hxx
index 795561b642fa..fb19a502a4c9 100644
--- a/sc/inc/chart2uno.hxx
+++ b/sc/inc/chart2uno.hxx
@@ -53,7 +53,7 @@
class ScDocument;
// DataProvider
-class ScChart2DataProvider : public
+class SC_DLLPUBLIC ScChart2DataProvider : public
::cppu::WeakImplHelper<
css::chart2::data::XDataProvider,
css::chart2::data::XSheetDataProvider,
diff --git a/sc/qa/unit/chart2dataprovider.cxx b/sc/qa/unit/chart2dataprovider.cxx
new file mode 100644
index 000000000000..d7fd25122797
--- /dev/null
+++ b/sc/qa/unit/chart2dataprovider.cxx
@@ -0,0 +1,122 @@
+/* -*- 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 <test/bootstrapfixture.hxx>
+
+#include <docsh.hxx>
+#include <chart2uno.hxx>
+
+#include <com/sun/star/frame/Desktop.hpp>
+#include <com/sun/star/chart2/data/XLabeledDataSequence2.hpp>
+#include <com/sun/star/chart2/data/XDataSource.hpp>
+#include <com/sun/star/chart2/data/XDataSink.hpp>
+
+#include "helper/qahelper.hxx"
+
+using namespace ::com::sun::star;
+using namespace ::com::sun::star::uno;
+
+class ScChart2DataProviderTest : public ScBootstrapFixture
+{
+public:
+ ScChart2DataProviderTest();
+
+ virtual void setUp() override;
+ virtual void tearDown() override;
+
+ void testHeaderExpansion();
+
+ CPPUNIT_TEST_SUITE(ScChart2DataProviderTest);
+ CPPUNIT_TEST(testHeaderExpansion);
+ CPPUNIT_TEST_SUITE_END();
+
+private:
+ uno::Reference<uno::XInterface> m_xCalcComponent;
+};
+
+void lcl_createAndCheckDataProvider(ScDocument& rDoc, const OUString& cellRange, bool hasCategories,
+ bool firstCellAsLabel, sal_Int32 expectedRows,
+ sal_Int32 expectedCols)
+{
+ uno::Reference<chart2::data::XDataProvider> xDataProvider = new ScChart2DataProvider(&rDoc);
+ CPPUNIT_ASSERT(xDataProvider.is());
+
+ uno::Sequence<beans::PropertyValue> aArgs(4);
+
+ aArgs[0].Name = "CellRangeRepresentation";
+ aArgs[0].Value <<= cellRange;
+
+ aArgs[1].Name = "HasCategories";
+ aArgs[1].Value <<= hasCategories;
+
+ aArgs[2].Name = "FirstCellAsLabel";
+ aArgs[2].Value <<= firstCellAsLabel;
+
+ aArgs[3].Name = "DataRowSource";
+ aArgs[3].Value <<= chart::ChartDataRowSource_COLUMNS;
+
+ uno::Reference<chart2::data::XDataSource> xDataSource = xDataProvider->createDataSource(aArgs);
+ CPPUNIT_ASSERT(xDataSource.is());
+
+ css::uno::Sequence<uno::Reference<chart2::data::XLabeledDataSequence>> xSequences
+ = xDataSource->getDataSequences();
+
+ CPPUNIT_ASSERT_EQUAL(expectedRows, xSequences.getLength());
+
+ for (sal_Int32 nIdx = 0; nIdx < xSequences.getLength(); ++nIdx)
+ {
+ Reference<chart2::data::XDataSequence> xValues(xSequences[nIdx]->getValues());
+ if (xValues.is())
+ CPPUNIT_ASSERT_EQUAL(expectedCols, xValues->getData().getLength());
+ }
+}
+
+void ScChart2DataProviderTest::testHeaderExpansion()
+{
+ ScDocShellRef xDocSh = loadDoc("chart2dataprovider.", FORMAT_ODS);
+ CPPUNIT_ASSERT_MESSAGE("Failed to load ch.ods.", xDocSh.is());
+
+ ScDocument& rDoc = xDocSh->GetDocument();
+
+ lcl_createAndCheckDataProvider(rDoc, "$Sheet1.$A$1:$D$4", false, false, 4, 4);
+ lcl_createAndCheckDataProvider(rDoc, "$Sheet1.$A$1:$D$4", true, true, 4, 3);
+
+ lcl_createAndCheckDataProvider(rDoc, "$Sheet1.$A$9:$D$12", true, true, 1, 2);
+
+ xDocSh->DoClose();
+}
+
+ScChart2DataProviderTest::ScChart2DataProviderTest()
+ : ScBootstrapFixture("sc/qa/unit/data")
+{
+}
+
+void ScChart2DataProviderTest::setUp()
+{
+ test::BootstrapFixture::setUp();
+
+ // This is a bit of a fudge, we do this to ensure that ScGlobals::ensure,
+ // which is a private symbol to us, gets called
+ m_xCalcComponent
+ = getMultiServiceFactory()->createInstance("com.sun.star.comp.Calc.SpreadsheetDocument");
+ CPPUNIT_ASSERT_MESSAGE("no calc component!", m_xCalcComponent.is());
+}
+
+void ScChart2DataProviderTest::tearDown()
+{
+ uno::Reference<lang::XComponent>(m_xCalcComponent, UNO_QUERY_THROW)->dispose();
+ test::BootstrapFixture::tearDown();
+}
+
+CPPUNIT_TEST_SUITE_REGISTRATION(ScChart2DataProviderTest);
+
+CPPUNIT_PLUGIN_IMPLEMENT();
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/sc/qa/unit/data/ods/chart2dataprovider.ods b/sc/qa/unit/data/ods/chart2dataprovider.ods
new file mode 100644
index 000000000000..d27b78c83e82
--- /dev/null
+++ b/sc/qa/unit/data/ods/chart2dataprovider.ods
Binary files differ