sc_ucalc: move pivot table tests to their own module

in order to split sc_ucalc monster into smaller
modules

Change-Id: I5fa1b9b7366c45414d26804a09d1b78aebc83e2d
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/115568
Tested-by: Jenkins
Reviewed-by: Xisco Fauli <xiscofauli@libreoffice.org>
This commit is contained in:
Xisco Fauli 2021-05-13 18:50:27 +02:00
parent 9da5f12be2
commit 08905cea24
5 changed files with 302 additions and 132 deletions

View file

@ -18,7 +18,6 @@ $(eval $(call gb_CppunitTest_add_exception_objects,sc_ucalc, \
sc/qa/unit/ucalc_column \
sc/qa/unit/ucalc_condformat \
sc/qa/unit/ucalc_formula \
sc/qa/unit/ucalc_pivottable \
))
$(eval $(call gb_CppunitTest_use_library_objects,sc_ucalc, \

View file

@ -0,0 +1,119 @@
# -*- 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_ucalc_pivottable))
$(eval $(call gb_Library_use_common_precompiled_header,sc_ucalc_pivottable))
$(eval $(call gb_CppunitTest_add_exception_objects,sc_ucalc_pivottable, \
sc/qa/unit/ucalc_pivottable \
))
$(eval $(call gb_CppunitTest_use_library_objects,sc_ucalc_pivottable, \
sc \
scqahelper \
))
$(eval $(call gb_CppunitTest_use_externals,sc_ucalc_pivottable,\
boost_headers \
$(call gb_Helper_optional,OPENCL, \
clew) \
icu_headers \
icui18n \
icuuc \
libxml2 \
mdds_headers \
orcus \
orcus-parser \
))
$(eval $(call gb_CppunitTest_use_libraries,sc_ucalc_pivottable, \
$(call gb_Helper_optional,AVMEDIA,avmedia) \
basegfx \
comphelper \
cppu \
cppuhelper \
dbtools \
drawinglayer \
editeng \
for \
forui \
i18nlangtag \
i18nutil \
$(call gb_Helper_optional,OPENCL, \
opencl) \
sal \
salhelper \
sax \
sb \
sfx \
sot \
svl \
svt \
svx \
svxcore \
test \
tk \
tl \
ucbhelper \
unotest \
utl \
vbahelper \
vcl \
xo \
))
$(eval $(call gb_CppunitTest_set_include,sc_ucalc_pivottable,\
-I$(SRCDIR)/sc/source/ui/inc \
-I$(SRCDIR)/sc/source/core/inc \
-I$(SRCDIR)/sc/inc \
$$(INCLUDE) \
))
$(eval $(call gb_CppunitTest_use_api,sc_ucalc_pivottable,\
udkapi \
offapi \
oovbaapi \
))
$(eval $(call gb_CppunitTest_use_custom_headers,sc_ucalc_pivottable,\
officecfg/registry \
))
$(eval $(call gb_CppunitTest_use_ure,sc_ucalc_pivottable))
$(eval $(call gb_CppunitTest_use_vcl,sc_ucalc_pivottable))
$(eval $(call gb_CppunitTest_use_components,sc_ucalc_pivottable,\
configmgr/source/configmgr \
framework/util/fwk \
i18npool/source/search/i18nsearch \
i18npool/util/i18npool \
sax/source/expatwrap/expwrap \
scaddins/source/analysis/analysis \
scaddins/source/datefunc/date \
scaddins/source/pricing/pricing \
sfx2/util/sfx \
ucb/source/core/ucb1 \
ucb/source/ucp/file/ucpfile1 \
unoxml/source/service/unoxml \
uui/util/uui \
vcl/vcl.common \
))
ifeq ($(OS),LINUX)
$(eval $(call gb_CppunitTest_add_libs,sc_ucalc_pivottable,\
-lrt \
))
endif
$(eval $(call gb_CppunitTest_use_configuration,sc_ucalc_pivottable))
# vim: set noet sw=4 ts=4:

View file

@ -39,6 +39,7 @@ $(eval $(call gb_Module_add_check_targets,sc,\
Library_scqahelper \
$(if $(and $(filter $(COM),MSC),$(MERGELIBS)),, \
CppunitTest_sc_ucalc) \
CppunitTest_sc_ucalc_pivottable \
CppunitTest_sc_ucalc_sharedformula \
CppunitTest_sc_ucalc_sort \
CppunitTest_sc_bugfix_test \

View file

@ -153,8 +153,6 @@ public:
void testFuncIFERROR();
void testFuncSHEET();
void testFuncNOW();
void testFuncGETPIVOTDATA();
void testFuncGETPIVOTDATALeafAccess();
void testMatrixOp();
void testFuncRangeOp();
void testFuncFORMULA();
@ -224,90 +222,6 @@ public:
void testEnterMixedMatrix();
void testMatrixEditable();
/**
* Basic test for pivot tables.
*/
void testPivotTable();
/**
* Test against unwanted automatic format detection on field names and
* field members in pivot tables.
*/
void testPivotTableLabels();
/**
* Make sure that we set cells displaying date values numeric cells,
* rather than text cells. Grouping by date or number functionality
* depends on this.
*/
void testPivotTableDateLabels();
/**
* Test for pivot table's filtering functionality by page fields.
*/
void testPivotTableFilters();
/**
* Test for pivot table's named source range.
*/
void testPivotTableNamedSource();
/**
* Test for pivot table cache. Each dimension in the pivot cache stores
* only unique values that are sorted in ascending order.
*/
void testPivotTableCache();
/**
* Test for pivot table containing data fields that reference the same
* source field but different functions.
*/
void testPivotTableDuplicateDataFields();
void testPivotTableNormalGrouping();
void testPivotTableNumberGrouping();
void testPivotTableDateGrouping();
void testPivotTableEmptyRows();
void testPivotTableTextNumber();
/**
* Test for checking that pivot table treats strings in a case insensitive
* manner.
*/
void testPivotTableCaseInsensitiveStrings();
/**
* Test for pivot table's handling of double-precision numbers that are
* very close together.
*/
void testPivotTableNumStability();
/**
* Test for pivot table that include field with various non-default field
* references.
*/
void testPivotTableFieldReference();
/**
* Test pivot table functionality performed via ScDBDocFunc.
*/
void testPivotTableDocFunc();
/**
* Test pivot table per-field repeat item labels functionality
*/
void testPivotTableRepeatItemLabels();
/**
* Test DPCollection public methods
*/
void testPivotTableDPCollection();
/**
* Test pivot table median function
*/
void testPivotTableMedianFunc();
void testCellCopy();
void testSheetCopy();
void testSheetMove();
@ -605,8 +519,6 @@ public:
CPPUNIT_TEST(testFuncIF);
CPPUNIT_TEST(testFuncCHOOSE);
CPPUNIT_TEST(testFuncIFERROR);
CPPUNIT_TEST(testFuncGETPIVOTDATA);
CPPUNIT_TEST(testFuncGETPIVOTDATALeafAccess);
CPPUNIT_TEST(testRefR1C1WholeCol);
CPPUNIT_TEST(testRefR1C1WholeRow);
CPPUNIT_TEST(testIterations);
@ -657,25 +569,6 @@ public:
CPPUNIT_TEST(testMatrixConditionalBooleanResult);
CPPUNIT_TEST(testEnterMixedMatrix);
CPPUNIT_TEST(testMatrixEditable);
CPPUNIT_TEST(testPivotTable);
CPPUNIT_TEST(testPivotTableLabels);
CPPUNIT_TEST(testPivotTableDateLabels);
CPPUNIT_TEST(testPivotTableFilters);
CPPUNIT_TEST(testPivotTableNamedSource);
CPPUNIT_TEST(testPivotTableCache);
CPPUNIT_TEST(testPivotTableDuplicateDataFields);
CPPUNIT_TEST(testPivotTableNormalGrouping);
CPPUNIT_TEST(testPivotTableNumberGrouping);
CPPUNIT_TEST(testPivotTableDateGrouping);
CPPUNIT_TEST(testPivotTableEmptyRows);
CPPUNIT_TEST(testPivotTableTextNumber);
CPPUNIT_TEST(testPivotTableCaseInsensitiveStrings);
CPPUNIT_TEST(testPivotTableNumStability);
CPPUNIT_TEST(testPivotTableFieldReference);
CPPUNIT_TEST(testPivotTableDocFunc);
CPPUNIT_TEST(testPivotTableRepeatItemLabels);
CPPUNIT_TEST(testPivotTableDPCollection);
CPPUNIT_TEST(testPivotTableMedianFunc);
CPPUNIT_TEST(testCellCopy);
CPPUNIT_TEST(testSheetCopy);
CPPUNIT_TEST(testSheetMove);

View file

@ -7,13 +7,14 @@
* file, You can obtain one at http://mozilla.org/MPL/2.0/.
*/
#include <test/bootstrapfixture.hxx>
#include <memory>
#include <string>
#include <cppunit/TestAssert.h>
#include <sal/types.h>
#include "ucalc.hxx"
#include <scdll.hxx>
#include "helper/qahelper.hxx"
#include <dpshttab.hxx>
#include <dpobject.hxx>
@ -201,7 +202,160 @@ ScRange refreshGroups(ScDPCollection* pDPs, ScDPObject* pDPObj)
}
void Test::testPivotTable()
class TestPivottable : public test::BootstrapFixture
{
public:
TestPivottable();
virtual void setUp() override;
virtual void tearDown() override;
/**
* Basic test for pivot tables.
*/
void testPivotTable();
/**
* Test against unwanted automatic format detection on field names and
* field members in pivot tables.
*/
void testPivotTableLabels();
/**
* Make sure that we set cells displaying date values numeric cells,
* rather than text cells. Grouping by date or number functionality
* depends on this.
*/
void testPivotTableDateLabels();
/**
* Test for pivot table's filtering functionality by page fields.
*/
void testPivotTableFilters();
/**
* Test for pivot table's named source range.
*/
void testPivotTableNamedSource();
/**
* Test for pivot table cache. Each dimension in the pivot cache stores
* only unique values that are sorted in ascending order.
*/
void testPivotTableCache();
/**
* Test for pivot table containing data fields that reference the same
* source field but different functions.
*/
void testPivotTableDuplicateDataFields();
void testPivotTableNormalGrouping();
void testPivotTableNumberGrouping();
void testPivotTableDateGrouping();
void testPivotTableEmptyRows();
void testPivotTableTextNumber();
/**
* Test for checking that pivot table treats strings in a case insensitive
* manner.
*/
void testPivotTableCaseInsensitiveStrings();
/**
* Test for pivot table's handling of double-precision numbers that are
* very close together.
*/
void testPivotTableNumStability();
/**
* Test for pivot table that include field with various non-default field
* references.
*/
void testPivotTableFieldReference();
/**
* Test pivot table functionality performed via ScDBDocFunc.
*/
void testPivotTableDocFunc();
void testFuncGETPIVOTDATA();
void testFuncGETPIVOTDATALeafAccess();
/**
* Test pivot table per-field repeat item labels functionality
*/
void testPivotTableRepeatItemLabels();
/**
* Test DPCollection public methods
*/
void testPivotTableDPCollection();
/**
* Test pivot table median function
*/
void testPivotTableMedianFunc();
CPPUNIT_TEST_SUITE(TestPivottable);
CPPUNIT_TEST(testPivotTable);
CPPUNIT_TEST(testPivotTableLabels);
CPPUNIT_TEST(testPivotTableDateLabels);
CPPUNIT_TEST(testPivotTableFilters);
CPPUNIT_TEST(testPivotTableNamedSource);
CPPUNIT_TEST(testPivotTableCache);
CPPUNIT_TEST(testPivotTableDuplicateDataFields);
CPPUNIT_TEST(testPivotTableNormalGrouping);
CPPUNIT_TEST(testPivotTableNumberGrouping);
CPPUNIT_TEST(testPivotTableDateGrouping);
CPPUNIT_TEST(testPivotTableEmptyRows);
CPPUNIT_TEST(testPivotTableTextNumber);
CPPUNIT_TEST(testPivotTableCaseInsensitiveStrings);
CPPUNIT_TEST(testPivotTableNumStability);
CPPUNIT_TEST(testPivotTableFieldReference);
CPPUNIT_TEST(testPivotTableDocFunc);
CPPUNIT_TEST(testFuncGETPIVOTDATA);
CPPUNIT_TEST(testFuncGETPIVOTDATALeafAccess);
CPPUNIT_TEST(testPivotTableRepeatItemLabels);
CPPUNIT_TEST(testPivotTableDPCollection);
CPPUNIT_TEST(testPivotTableMedianFunc);
CPPUNIT_TEST_SUITE_END();
private:
ScDocShellRef m_xDocShell;
ScDocument* m_pDoc;
};
TestPivottable::TestPivottable()
{
}
void TestPivottable::setUp()
{
BootstrapFixture::setUp();
ScDLL::Init();
m_xDocShell = new ScDocShell(
SfxModelFlags::EMBEDDED_OBJECT |
SfxModelFlags::DISABLE_EMBEDDED_SCRIPTS |
SfxModelFlags::DISABLE_DOCUMENT_RECOVERY);
m_xDocShell->SetIsInUcalc();
m_xDocShell->DoInitUnitTest();
m_pDoc = &m_xDocShell->GetDocument();
}
void TestPivottable::tearDown()
{
m_xDocShell->DoClose();
m_xDocShell.clear();
test::BootstrapFixture::tearDown();
}
void TestPivottable::testPivotTable()
{
m_pDoc->InsertTab(0, "Data");
m_pDoc->InsertTab(1, "Table");
@ -385,7 +539,7 @@ void Test::testPivotTable()
m_pDoc->DeleteTab(0);
}
void Test::testPivotTableLabels()
void TestPivottable::testPivotTableLabels()
{
m_pDoc->InsertTab(0, "Data");
m_pDoc->InsertTab(1, "Table");
@ -440,7 +594,7 @@ void Test::testPivotTableLabels()
m_pDoc->DeleteTab(0);
}
void Test::testPivotTableDateLabels()
void TestPivottable::testPivotTableDateLabels()
{
m_pDoc->InsertTab(0, "Data");
m_pDoc->InsertTab(1, "Table");
@ -515,7 +669,7 @@ void Test::testPivotTableDateLabels()
m_pDoc->DeleteTab(0);
}
void Test::testPivotTableFilters()
void TestPivottable::testPivotTableFilters()
{
m_pDoc->InsertTab(0, "Data");
m_pDoc->InsertTab(1, "Table");
@ -667,7 +821,7 @@ void Test::testPivotTableFilters()
m_pDoc->DeleteTab(0);
}
void Test::testPivotTableNamedSource()
void TestPivottable::testPivotTableNamedSource()
{
m_pDoc->InsertTab(0, "Data");
m_pDoc->InsertTab(1, "Table");
@ -770,7 +924,7 @@ void Test::testPivotTableNamedSource()
m_pDoc->DeleteTab(0);
}
void Test::testPivotTableCache()
void TestPivottable::testPivotTableCache()
{
m_pDoc->InsertTab(0, "Data");
@ -975,7 +1129,7 @@ void Test::testPivotTableCache()
m_pDoc->DeleteTab(0);
}
void Test::testPivotTableDuplicateDataFields()
void TestPivottable::testPivotTableDuplicateDataFields()
{
m_pDoc->InsertTab(0, "Data");
m_pDoc->InsertTab(1, "Table");
@ -1070,7 +1224,7 @@ void Test::testPivotTableDuplicateDataFields()
m_pDoc->DeleteTab(0);
}
void Test::testPivotTableNormalGrouping()
void TestPivottable::testPivotTableNormalGrouping()
{
m_pDoc->InsertTab(0, "Data");
m_pDoc->InsertTab(1, "Table");
@ -1219,7 +1373,7 @@ void Test::testPivotTableNormalGrouping()
m_pDoc->DeleteTab(0);
}
void Test::testPivotTableNumberGrouping()
void TestPivottable::testPivotTableNumberGrouping()
{
m_pDoc->InsertTab(0, "Data");
m_pDoc->InsertTab(1, "Table");
@ -1312,7 +1466,7 @@ void Test::testPivotTableNumberGrouping()
m_pDoc->DeleteTab(0);
}
void Test::testPivotTableDateGrouping()
void TestPivottable::testPivotTableDateGrouping()
{
m_pDoc->InsertTab(0, "Data");
m_pDoc->InsertTab(1, "Table");
@ -1484,7 +1638,7 @@ void Test::testPivotTableDateGrouping()
m_pDoc->DeleteTab(0);
}
void Test::testPivotTableEmptyRows()
void TestPivottable::testPivotTableEmptyRows()
{
m_pDoc->InsertTab(0, "Data");
m_pDoc->InsertTab(1, "Table");
@ -1597,7 +1751,7 @@ void Test::testPivotTableEmptyRows()
m_pDoc->DeleteTab(0);
}
void Test::testPivotTableTextNumber()
void TestPivottable::testPivotTableTextNumber()
{
m_pDoc->InsertTab(0, "Data");
m_pDoc->InsertTab(1, "Table");
@ -1698,7 +1852,7 @@ void Test::testPivotTableTextNumber()
m_pDoc->DeleteTab(0);
}
void Test::testPivotTableCaseInsensitiveStrings()
void TestPivottable::testPivotTableCaseInsensitiveStrings()
{
m_pDoc->InsertTab(0, "Data");
m_pDoc->InsertTab(1, "Table");
@ -1752,7 +1906,7 @@ void Test::testPivotTableCaseInsensitiveStrings()
m_pDoc->DeleteTab(0);
}
void Test::testPivotTableNumStability()
void TestPivottable::testPivotTableNumStability()
{
FormulaGrammarSwitch aFGSwitch(m_pDoc, formula::FormulaGrammar::GRAM_ENGLISH_XL_R1C1);
@ -1854,7 +2008,7 @@ void Test::testPivotTableNumStability()
m_pDoc->DeleteTab(0);
}
void Test::testPivotTableFieldReference()
void TestPivottable::testPivotTableFieldReference()
{
m_pDoc->InsertTab(0, "Data");
m_pDoc->InsertTab(1, "Table");
@ -2020,7 +2174,7 @@ void Test::testPivotTableFieldReference()
m_pDoc->DeleteTab(0);
}
void Test::testPivotTableDocFunc()
void TestPivottable::testPivotTableDocFunc()
{
m_pDoc->InsertTab(0, "Data");
m_pDoc->InsertTab(1, "Table");
@ -2052,7 +2206,7 @@ void Test::testPivotTableDocFunc()
CPPUNIT_ASSERT_MESSAGE("Failed to create pivot table object.", pDPObj);
// Create a new pivot table output.
ScDBDocFunc aFunc(getDocShell());
ScDBDocFunc aFunc(*m_xDocShell);
bool bSuccess = aFunc.CreatePivotTable(*pDPObj, false, true);
CPPUNIT_ASSERT_MESSAGE("Failed to create pivot table output via ScDBDocFunc.", bSuccess);
ScDPCollection* pDPs = m_pDoc->GetDPCollection();
@ -2088,7 +2242,7 @@ void Test::testPivotTableDocFunc()
m_pDoc->DeleteTab(0);
}
void Test::testFuncGETPIVOTDATA()
void TestPivottable::testFuncGETPIVOTDATA()
{
m_pDoc->InsertTab(0, "Data");
m_pDoc->InsertTab(1, "Table");
@ -2244,7 +2398,7 @@ void Test::testFuncGETPIVOTDATA()
m_pDoc->DeleteTab(0);
}
void Test::testFuncGETPIVOTDATALeafAccess()
void TestPivottable::testFuncGETPIVOTDATALeafAccess()
{
m_pDoc->InsertTab(0, "Data");
m_pDoc->InsertTab(1, "Table");
@ -2334,7 +2488,7 @@ void Test::testFuncGETPIVOTDATALeafAccess()
m_pDoc->DeleteTab(0);
}
void Test::testPivotTableRepeatItemLabels()
void TestPivottable::testPivotTableRepeatItemLabels()
{
m_pDoc->InsertTab(0, "Data");
m_pDoc->InsertTab(1, "Table");
@ -2411,7 +2565,7 @@ void Test::testPivotTableRepeatItemLabels()
m_pDoc->DeleteTab(0);
}
void Test::testPivotTableDPCollection()
void TestPivottable::testPivotTableDPCollection()
{
m_pDoc->InsertTab(0, "Data");
m_pDoc->InsertTab(1, "Table");
@ -2497,7 +2651,7 @@ void Test::testPivotTableDPCollection()
m_pDoc->DeleteTab(0);
}
void Test::testPivotTableMedianFunc()
void TestPivottable::testPivotTableMedianFunc()
{
m_pDoc->InsertTab(0, "Data");
m_pDoc->InsertTab(1, "Table");
@ -2542,7 +2696,7 @@ void Test::testPivotTableMedianFunc()
CPPUNIT_ASSERT_MESSAGE("Failed to create pivot table object.", pDPObj);
// Create a new pivot table output.
ScDBDocFunc aFunc(getDocShell());
ScDBDocFunc aFunc(*m_xDocShell);
bool bSuccess = aFunc.CreatePivotTable(*pDPObj, false, true);
CPPUNIT_ASSERT_MESSAGE("Failed to create pivot table output via ScDBDocFunc.", bSuccess);
ScDPCollection* pDPs = m_pDoc->GetDPCollection();
@ -2575,4 +2729,8 @@ void Test::testPivotTableMedianFunc()
m_pDoc->DeleteTab(0);
}
CPPUNIT_TEST_SUITE_REGISTRATION(TestPivottable);
CPPUNIT_PLUGIN_IMPLEMENT();
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */