Kaydet (Commit) 51cdf624 authored tarafından Vasily Melenchuk's avatar Vasily Melenchuk Kaydeden (comit) Eike Rathke

tdf#113861: Unittest for chart datatable labels expansion

Change-Id: Icfa10b1e75c801a9a025c0173bd8a34e362f049e
Reviewed-on: https://gerrit.libreoffice.org/45670Tested-by: 's avatarJenkins <ci@libreoffice.org>
Reviewed-by: 's avatarEike Rathke <erack@redhat.com>
üst febc90fe
# -*- 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:
......@@ -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,\
......
......@@ -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,
......
/* -*- 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: */
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment