1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
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/.
10 #include <test/calc_unoapi_test.hxx>
11 #include <test/container/xnamed.hxx>
12 #include <test/sheet/xdatapilotdescriptor.hxx>
13 #include <test/sheet/xdatapilottable.hxx>
14 #include <test/sheet/xdatapilottable2.hxx>
16 #include <com/sun/star/lang/XComponent.hpp>
17 #include <com/sun/star/sheet/XSpreadsheetDocument.hpp>
18 #include <com/sun/star/sheet/XSpreadsheet.hpp>
19 #include <com/sun/star/sheet/XDataPilotTablesSupplier.hpp>
20 #include <com/sun/star/sheet/XDataPilotTables.hpp>
21 #include <com/sun/star/sheet/XDataPilotTable.hpp>
24 using namespace css::uno
;
26 namespace sc_apitest
{
28 class ScDataPilotTableObj
: public CalcUnoApiTest
,
29 public apitest::XDataPilotDescriptor
,
30 public apitest::XDataPilotTable
,
31 public apitest::XDataPilotTable2
,
32 public apitest::XNamed
35 ScDataPilotTableObj();
37 virtual void setUp() override
;
38 virtual void tearDown() override
;
39 virtual uno::Reference
< uno::XInterface
> init() override
;
40 virtual uno::Reference
< uno::XInterface
> initDP2() override
;
41 virtual uno::Reference
< uno::XInterface
> getSheets() override
;
43 CPPUNIT_TEST_SUITE(ScDataPilotTableObj
);
45 // XDataPilotDescriptor
46 CPPUNIT_TEST(testSourceRange
);
47 CPPUNIT_TEST(testTag
);
48 CPPUNIT_TEST(testGetFilterDescriptor
);
49 CPPUNIT_TEST(testGetDataPilotFields
);
50 CPPUNIT_TEST(testGetColumnFields
);
51 CPPUNIT_TEST(testGetRowFields
);
52 CPPUNIT_TEST(testGetPageFields
);
53 CPPUNIT_TEST(testGetDataFields
);
54 //CPPUNIT_TEST(testGetHiddenFields);
57 CPPUNIT_TEST(testGetOutputRange
);
58 CPPUNIT_TEST(testRefresh
);
61 CPPUNIT_TEST(testGetDrillDownData
);
62 CPPUNIT_TEST(testInsertDrillDownSheet
);
63 CPPUNIT_TEST(testGetPositionData
);
64 CPPUNIT_TEST(testGetOutputRangeByType
);
67 CPPUNIT_TEST(testGetName
);
68 CPPUNIT_TEST(testSetName
);
70 CPPUNIT_TEST_SUITE_END();
73 uno::Reference
< lang::XComponent
> mxComponent
;
76 ScDataPilotTableObj::ScDataPilotTableObj()
77 : CalcUnoApiTest("/sc/qa/extras/testdocuments"),
78 apitest::XNamed("DataPilotTable")
82 uno::Reference
< uno::XInterface
> ScDataPilotTableObj::init()
84 uno::Reference
< sheet::XSpreadsheetDocument
> xDoc(mxComponent
, UNO_QUERY_THROW
);
86 uno::Reference
< container::XIndexAccess
> xIndex (xDoc
->getSheets(), UNO_QUERY_THROW
);
87 uno::Reference
< sheet::XSpreadsheet
> xSheet( xIndex
->getByIndex(0), UNO_QUERY_THROW
);
89 // set variables from xdatapilottable.[ch]xx
90 xCellForChange
= xSheet
->getCellByPosition( 1, 5 );
91 xCellForCheck
= xSheet
->getCellByPosition( 7, 11 );
92 CPPUNIT_ASSERT(xCellForCheck
.is());
93 CPPUNIT_ASSERT(xCellForChange
.is());
95 CPPUNIT_ASSERT_MESSAGE("Could not create interface of type XSpreadsheet", xSheet
.is());
96 uno::Reference
< sheet::XDataPilotTablesSupplier
> xDPTS(xSheet
, UNO_QUERY_THROW
);
97 uno::Reference
< sheet::XDataPilotTables
> xDPT
= xDPTS
->getDataPilotTables();
98 CPPUNIT_ASSERT(xDPT
.is());
100 uno::Reference
< sheet::XDataPilotTable
> xDPTable(xDPT
->getByName("DataPilotTable"),UNO_QUERY_THROW
);
105 uno::Reference
< uno::XInterface
> ScDataPilotTableObj::getSheets()
107 uno::Reference
< sheet::XSpreadsheetDocument
> xDoc(mxComponent
, UNO_QUERY_THROW
);
108 uno::Reference
< uno::XInterface
> xSheets(xDoc
->getSheets());
112 uno::Reference
< uno::XInterface
> ScDataPilotTableObj::initDP2()
114 uno::Reference
< sheet::XSpreadsheetDocument
> xDoc(mxComponent
, UNO_QUERY_THROW
);
115 uno::Reference
< container::XIndexAccess
> xIndex (xDoc
->getSheets(), UNO_QUERY_THROW
);
116 uno::Reference
< sheet::XSpreadsheet
> xSheet( xIndex
->getByIndex(0), UNO_QUERY_THROW
);
118 // set variables from xdatapilottable.[ch]xx
119 xCellForChange
= xSheet
->getCellByPosition( 1, 5 );
120 xCellForCheck
= xSheet
->getCellByPosition( 7, 11 );
121 CPPUNIT_ASSERT(xCellForCheck
.is());
122 CPPUNIT_ASSERT(xCellForChange
.is());
124 CPPUNIT_ASSERT_MESSAGE("Could not create interface of type XSpreadsheet", xSheet
.is());
125 uno::Reference
< sheet::XDataPilotTablesSupplier
> xDPTS(xSheet
, UNO_QUERY_THROW
);
126 uno::Reference
< sheet::XDataPilotTables
> xDPT
= xDPTS
->getDataPilotTables();
127 CPPUNIT_ASSERT(xDPT
.is());
129 uno::Reference
< sheet::XDataPilotTable
> xDPTable(xDPT
->getByName("DataPilotTable2"),UNO_QUERY_THROW
);
134 void ScDataPilotTableObj::setUp()
136 CalcUnoApiTest::setUp();
137 // create a calc document
139 createFileURL("ScDataPilotTableObj.ods", aFileURL
);
140 mxComponent
= loadFromDesktop(aFileURL
, "com.sun.star.sheet.SpreadsheetDocument");
143 void ScDataPilotTableObj::tearDown()
145 closeDocument(mxComponent
);
146 CalcUnoApiTest::tearDown();
149 CPPUNIT_TEST_SUITE_REGISTRATION(ScDataPilotTableObj
);
153 CPPUNIT_PLUGIN_IMPLEMENT();
155 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */