Version 6.4.0.3, tag libreoffice-6.4.0.3
[LibreOffice.git] / sc / qa / extras / scdatapilotfieldobj.cxx
blob89ad71daeb183b63fff18c4cbbba697ca099dd2d
1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4; fill-column: 100 -*- */
2 /*
3 * This file is part of the LibreOffice project.
5 * This Source Code Form is subject to the terms of the Mozilla Public
6 * License, v. 2.0. If a copy of the MPL was not distributed with this
7 * file, You can obtain one at http://mozilla.org/MPL/2.0/.
8 */
10 #include <test/calc_unoapi_test.hxx>
11 #include <test/beans/xpropertyset.hxx>
12 #include <test/container/xnamed.hxx>
13 #include <test/lang/xserviceinfo.hxx>
14 #include <test/sheet/datapilotfield.hxx>
15 #include <test/sheet/xdatapilotfield.hxx>
16 #include <test/sheet/xdatapilotfieldgrouping.hxx>
18 #include <com/sun/star/lang/XComponent.hpp>
19 #include <com/sun/star/sheet/XSpreadsheetDocument.hpp>
20 #include <com/sun/star/sheet/XSpreadsheet.hpp>
21 #include <com/sun/star/sheet/XDataPilotTablesSupplier.hpp>
22 #include <com/sun/star/sheet/XDataPilotTables.hpp>
23 #include <com/sun/star/sheet/XDataPilotDescriptor.hpp>
24 #include <com/sun/star/uno/XInterface.hpp>
26 #include <com/sun/star/uno/Reference.hxx>
28 using namespace css;
30 namespace sc_apitest
32 class ScDataPilotFieldObj : public CalcUnoApiTest,
33 public apitest::DataPilotField,
34 public apitest::XDataPilotField,
35 public apitest::XDataPilotFieldGrouping,
36 public apitest::XNamed,
37 public apitest::XPropertySet,
38 public apitest::XServiceInfo
40 public:
41 virtual void setUp() override;
42 virtual void tearDown() override;
43 virtual uno::Reference<uno::XInterface> init() override;
45 ScDataPilotFieldObj();
47 CPPUNIT_TEST_SUITE(ScDataPilotFieldObj);
49 // DataPilotField
50 CPPUNIT_TEST(testSortInfo);
51 CPPUNIT_TEST(testLayoutInfo);
52 CPPUNIT_TEST(testAutoShowInfo);
53 CPPUNIT_TEST(testReference);
54 CPPUNIT_TEST(testIsGroupField);
56 // XDataPilotField
57 CPPUNIT_TEST(testGetItems);
59 // XDataPilotFieldGrouping
60 CPPUNIT_TEST(testCreateNameGroup);
61 // see fdo#
62 //CPPUNIT_TEST(testCreateDateGroup);
64 // XNamed
65 CPPUNIT_TEST(testGetName);
66 CPPUNIT_TEST(testSetName);
68 // XPropertySet
69 CPPUNIT_TEST(testGetPropertySetInfo);
70 CPPUNIT_TEST(testGetPropertyValue);
71 CPPUNIT_TEST(testSetPropertyValue);
72 CPPUNIT_TEST(testPropertyChangeListener);
73 CPPUNIT_TEST(testVetoableChangeListener);
75 // XServiceInfo
76 CPPUNIT_TEST(testGetImplementationName);
77 CPPUNIT_TEST(testGetSupportedServiceNames);
78 CPPUNIT_TEST(testSupportsService);
80 CPPUNIT_TEST_SUITE_END();
82 private:
83 uno::Reference<lang::XComponent> mxComponent;
86 ScDataPilotFieldObj::ScDataPilotFieldObj()
87 : CalcUnoApiTest("/sc/qa/extras/testdocuments")
88 , XNamed("Col1")
89 , XPropertySet({ "Function", "HasAutoShowInfo", "HasLayoutInfo", "HasSortInfo", "Subtotals",
90 "Subtotals2" })
91 , XServiceInfo("ScDataPilotFieldObj", "com.sun.star.sheet.DataPilotField")
95 uno::Reference<uno::XInterface> ScDataPilotFieldObj::init()
97 uno::Reference<sheet::XSpreadsheetDocument> xDoc(mxComponent, uno::UNO_QUERY_THROW);
98 uno::Reference<container::XIndexAccess> xIndex(xDoc->getSheets(), uno::UNO_QUERY_THROW);
99 uno::Reference<sheet::XSpreadsheet> xSheet(xIndex->getByIndex(1), uno::UNO_QUERY_THROW);
101 uno::Reference<sheet::XDataPilotTablesSupplier> xDPTS(xSheet, uno::UNO_QUERY_THROW);
102 uno::Reference<sheet::XDataPilotTables> xDPT(xDPTS->getDataPilotTables(), uno::UNO_SET_THROW);
103 uno::Sequence<OUString> aElementNames = xDPT->getElementNames();
104 (void)aElementNames;
106 uno::Reference<sheet::XDataPilotDescriptor> xDPDsc(xDPT->getByName("DataPilot1"),
107 uno::UNO_QUERY_THROW);
108 uno::Reference<container::XIndexAccess> xIA(xDPDsc->getDataPilotFields(), uno::UNO_SET_THROW);
109 uno::Reference<uno::XInterface> xReturnValue(xIA->getByIndex(0), uno::UNO_QUERY_THROW);
110 return xReturnValue;
113 void ScDataPilotFieldObj::setUp()
115 CalcUnoApiTest::setUp();
117 OUString aFileURL;
118 createFileURL("scdatapilotfieldobj.ods", aFileURL);
119 mxComponent = loadFromDesktop(aFileURL, "com.sun.star.sheet.SpreadsheetDocument");
122 void ScDataPilotFieldObj::tearDown()
124 closeDocument(mxComponent);
125 CalcUnoApiTest::tearDown();
128 CPPUNIT_TEST_SUITE_REGISTRATION(ScDataPilotFieldObj);
130 } // namespace sc_apitest
132 CPPUNIT_PLUGIN_IMPLEMENT();
134 /* vim:set shiftwidth=4 softtabstop=4 expandtab cinoptions=b1,g0,N-s cinkeys+=0=break: */