summaryrefslogtreecommitdiff
path: root/sc
diff options
context:
space:
mode:
authorJens Carl <j.carl43@gmx.de>2019-03-02 01:14:07 +0000
committerJens Carl <j.carl43@gmx.de>2019-03-02 04:33:04 +0100
commit71dc14936cbc37bae5f3d997d92b0e0d1e4b122b (patch)
tree4e95884ce8d306b22475c9647ac27adaa443efc8 /sc
parent222b5b5b9b0d0419e30961261c63ff8585550b81 (diff)
Add XServiceInfo tests to ScDataPilotItemsObj
Change-Id: Ie6e6e0edf9815744fd8ba97e0259b409db4d8c75 Reviewed-on: https://gerrit.libreoffice.org/68607 Tested-by: Jenkins Reviewed-by: Jens Carl <j.carl43@gmx.de>
Diffstat (limited to 'sc')
-rw-r--r--sc/CppunitTest_sc_datapilotitemsobj.mk47
-rw-r--r--sc/Module_sc.mk1
-rw-r--r--sc/qa/extras/scdatapilotitemsobj.cxx143
3 files changed, 191 insertions, 0 deletions
diff --git a/sc/CppunitTest_sc_datapilotitemsobj.mk b/sc/CppunitTest_sc_datapilotitemsobj.mk
new file mode 100644
index 000000000000..dab71b60ee23
--- /dev/null
+++ b/sc/CppunitTest_sc_datapilotitemsobj.mk
@@ -0,0 +1,47 @@
+# -*- 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_datapilotitemsobj))
+
+$(eval $(call gb_CppunitTest_use_external,sc_datapilotitemsobj,boost_headers))
+
+$(eval $(call gb_CppunitTest_add_exception_objects,sc_datapilotitemsobj, \
+ sc/qa/extras/scdatapilotitemsobj \
+))
+
+$(eval $(call gb_CppunitTest_use_libraries,sc_datapilotitemsobj, \
+ comphelper \
+ cppu \
+ sal \
+ subsequenttest \
+ test \
+ unotest \
+))
+
+$(eval $(call gb_CppunitTest_set_include,sc_datapilotitemsobj,\
+ $$(INCLUDE) \
+))
+
+$(eval $(call gb_CppunitTest_use_api,sc_datapilotitemsobj,\
+ offapi \
+ udkapi \
+))
+
+$(eval $(call gb_CppunitTest_use_ure,sc_datapilotitemsobj))
+$(eval $(call gb_CppunitTest_use_vcl,sc_datapilotitemsobj))
+
+$(eval $(call gb_CppunitTest_use_rdb,sc_datapilotitemsobj,services))
+
+$(eval $(call gb_CppunitTest_use_components,sc_datapilotitemsobj))
+
+$(eval $(call gb_CppunitTest_use_configuration,sc_datapilotitemsobj))
+
+# vim: set noet sw=4 ts=4:
diff --git a/sc/Module_sc.mk b/sc/Module_sc.mk
index 789c7880207e..eebd6340e8b8 100644
--- a/sc/Module_sc.mk
+++ b/sc/Module_sc.mk
@@ -130,6 +130,7 @@ $(eval $(call gb_Module_add_subsequentcheck_targets,sc,\
CppunitTest_sc_datapilotfieldobj \
CppunitTest_sc_datapilotfieldsobj \
CppunitTest_sc_datapilotitemobj \
+ CppunitTest_sc_datapilotitemsobj \
CppunitTest_sc_datapilottableobj \
CppunitTest_sc_datapilottablesobj \
CppunitTest_sc_ddelinkobj \
diff --git a/sc/qa/extras/scdatapilotitemsobj.cxx b/sc/qa/extras/scdatapilotitemsobj.cxx
new file mode 100644
index 000000000000..578668424302
--- /dev/null
+++ b/sc/qa/extras/scdatapilotitemsobj.cxx
@@ -0,0 +1,143 @@
+/* -*- 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 <test/calc_unoapi_test.hxx>
+#include <test/lang/xserviceinfo.hxx>
+
+#include <com/sun/star/beans/XPropertySet.hpp>
+#include <com/sun/star/container/XIndexAccess.hpp>
+#include <com/sun/star/container/XNamed.hpp>
+#include <com/sun/star/lang/XComponent.hpp>
+#include <com/sun/star/sheet/DataPilotFieldOrientation.hpp>
+#include <com/sun/star/sheet/GeneralFunction.hpp>
+#include <com/sun/star/sheet/XDataPilotDescriptor.hpp>
+#include <com/sun/star/sheet/XDataPilotField.hpp>
+#include <com/sun/star/sheet/XDataPilotTables.hpp>
+#include <com/sun/star/sheet/XDataPilotTablesSupplier.hpp>
+#include <com/sun/star/sheet/XSpreadsheet.hpp>
+#include <com/sun/star/sheet/XSpreadsheetDocument.hpp>
+#include <com/sun/star/sheet/XSpreadsheets.hpp>
+#include <com/sun/star/table/CellAddress.hpp>
+#include <com/sun/star/table/CellRangeAddress.hpp>
+#include <com/sun/star/uno/XInterface.hpp>
+
+#include <com/sun/star/uno/Reference.hxx>
+
+#include <comphelper/types.hxx>
+#include <rtl/string.hxx>
+
+using namespace css;
+
+namespace sc_apitest
+{
+const auto nMaxFieldIndex = 6;
+
+class ScDataPilotItemsObj : public CalcUnoApiTest, public apitest::XServiceInfo
+{
+public:
+ ScDataPilotItemsObj();
+
+ virtual uno::Reference<uno::XInterface> init() override;
+ virtual void setUp() override;
+ virtual void tearDown() override;
+
+ CPPUNIT_TEST_SUITE(ScDataPilotItemsObj);
+
+ // XServiceInfo
+ CPPUNIT_TEST(testGetImplementationName);
+ CPPUNIT_TEST(testGetSupportedServiceNames);
+ CPPUNIT_TEST(testSupportsService);
+
+ CPPUNIT_TEST_SUITE_END();
+
+private:
+ uno::Reference<lang::XComponent> m_xComponent;
+};
+
+ScDataPilotItemsObj::ScDataPilotItemsObj()
+ : CalcUnoApiTest("/sc/qa/extras/testdocuments")
+ , XServiceInfo("ScDataPilotItemsObj", "com.sun.star.sheet.DataPilotItems")
+{
+}
+
+uno::Reference<uno::XInterface> ScDataPilotItemsObj::init()
+{
+ table::CellRangeAddress aCellRangeAddress(0, 1, 0, nMaxFieldIndex - 1, nMaxFieldIndex - 1);
+ table::CellAddress aCellAddress(0, 7, 8);
+
+ uno::Reference<sheet::XSpreadsheetDocument> xDoc(m_xComponent, uno::UNO_QUERY_THROW);
+ uno::Reference<sheet::XSpreadsheets> xSheets(xDoc->getSheets(), uno::UNO_QUERY_THROW);
+ uno::Reference<container::XIndexAccess> xIA(xSheets, uno::UNO_QUERY_THROW);
+ xSheets->insertNewByName("Some Sheet", 0);
+
+ uno::Reference<sheet::XSpreadsheet> xSheet0(xIA->getByIndex(0), uno::UNO_QUERY_THROW);
+ uno::Reference<sheet::XSpreadsheet> xSheet1(xIA->getByIndex(1), uno::UNO_QUERY_THROW);
+
+ for (auto i = 1; i < nMaxFieldIndex; ++i)
+ {
+ xSheet0->getCellByPosition(i, 0)->setFormula("Col" + OUString::number(i));
+ xSheet0->getCellByPosition(0, i)->setFormula("Row" + OUString::number(i));
+ xSheet1->getCellByPosition(i, 0)->setFormula("Col" + OUString::number(i));
+ xSheet1->getCellByPosition(0, i)->setFormula("Row" + OUString::number(i));
+ }
+
+ for (auto i = 1; i < nMaxFieldIndex; ++i)
+ {
+ for (auto j = 1; j < nMaxFieldIndex; ++j)
+ {
+ xSheet0->getCellByPosition(i, j)->setValue(i * (j + 1));
+ xSheet1->getCellByPosition(i, j)->setValue(i * (j + 2));
+ }
+ }
+
+ xSheet0->getCellByPosition(1, 5);
+ xSheet0->getCellByPosition(aCellAddress.Column, aCellAddress.Row + 3);
+
+ uno::Reference<sheet::XDataPilotTablesSupplier> xDPTS(xSheet0, uno::UNO_QUERY_THROW);
+ uno::Reference<sheet::XDataPilotTables> xDPT(xDPTS->getDataPilotTables(), uno::UNO_QUERY_THROW);
+ uno::Reference<sheet::XDataPilotDescriptor> xDPD(xDPT->createDataPilotDescriptor(),
+ uno::UNO_QUERY_THROW);
+
+ xDPD->setSourceRange(aCellRangeAddress);
+
+ uno::Reference<beans::XPropertySet> xPropertySet(xDPD->getDataPilotFields()->getByIndex(1),
+ uno::UNO_QUERY_THROW);
+ xPropertySet->setPropertyValue("Function", uno::makeAny(sheet::GeneralFunction_SUM));
+ xPropertySet->setPropertyValue("Orientation",
+ uno::makeAny(sheet::DataPilotFieldOrientation_DATA));
+
+ xDPT->insertNewByName("DataPilotTable", aCellAddress, xDPD);
+
+ uno::Reference<container::XIndexAccess> xIA_DPF(xDPD->getDataPilotFields(),
+ uno::UNO_QUERY_THROW);
+ uno::Reference<sheet::XDataPilotField> xDPF(xIA_DPF->getByIndex(0), uno::UNO_QUERY_THROW);
+
+ return xDPF->getItems();
+}
+
+void ScDataPilotItemsObj::setUp()
+{
+ CalcUnoApiTest::setUp();
+ // create a calc document
+ m_xComponent = loadFromDesktop("private:factory/scalc");
+}
+
+void ScDataPilotItemsObj::tearDown()
+{
+ closeDocument(m_xComponent);
+ CalcUnoApiTest::tearDown();
+}
+
+CPPUNIT_TEST_SUITE_REGISTRATION(ScDataPilotItemsObj);
+
+} // namespace sc_apitest
+
+CPPUNIT_PLUGIN_IMPLEMENT();
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */