[Libreoffice-commits] core.git: Branch 'private/swe/libreoffice-5-2+backports' - sc/CppunitTest_sc_chart2dataprovider.mk sc/inc sc/Module_sc.mk sc/qa

Vasily Melenchuk Vasily.Melenchuk at cib.de
Thu Dec 7 18:30:38 UTC 2017


 sc/CppunitTest_sc_chart2dataprovider.mk    |  122 +++++++++++++++++++++++++++++
 sc/Module_sc.mk                            |    1 
 sc/inc/chart2uno.hxx                       |    2 
 sc/qa/unit/chart2dataprovider.cxx          |  122 +++++++++++++++++++++++++++++
 sc/qa/unit/data/ods/chart2dataprovider.ods |binary
 5 files changed, 246 insertions(+), 1 deletion(-)

New commits:
commit e996e61bc98751d4a4ad86920486777fdbccb6a9
Author: Vasily Melenchuk <Vasily.Melenchuk at cib.de>
Date:   Wed Nov 29 16:29:52 2017 +0300

    tdf#113861: Unittest for chart datatable labels expansion
    
    Reviewed-on: https://gerrit.libreoffice.org/45670
    Tested-by: Jenkins <ci at libreoffice.org>
    Reviewed-by: Eike Rathke <erack at redhat.com>
    (cherry picked from commit 51cdf6248dbdf7a5dcddd2128bbb8f889cec25d6)
    
    Conflicts:
            sc/Module_sc.mk
    
    Change-Id: Icfa10b1e75c801a9a025c0173bd8a34e362f049e
    Reviewed-on: https://gerrit.libreoffice.org/46038
    Reviewed-by: Thorsten Behrens <Thorsten.Behrens at CIB.de>
    Tested-by: Thorsten Behrens <Thorsten.Behrens at CIB.de>

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 26f967d7b267..d8561753f376 100644
--- a/sc/Module_sc.mk
+++ b/sc/Module_sc.mk
@@ -98,6 +98,7 @@ $(eval $(call gb_Module_add_subsequentcheck_targets,sc,\
 	CppunitTest_sc_check_data_pilot_field \
 	CppunitTest_sc_check_data_pilot_table \
 	CppunitTest_sc_viewpaneobj \
+	CppunitTest_sc_chart2dataprovider \
 ))
 
 $(eval $(call gb_Module_add_perfcheck_targets,sc,\
diff --git a/sc/inc/chart2uno.hxx b/sc/inc/chart2uno.hxx
index 3d2a61fe33af..3765db35596e 100644
--- a/sc/inc/chart2uno.hxx
+++ b/sc/inc/chart2uno.hxx
@@ -54,7 +54,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
Binary files /dev/null and b/sc/qa/unit/data/ods/chart2dataprovider.ods differ


More information about the Libreoffice-commits mailing list