Impress Remote 1.0.5, tag sdremote-1.0.5
[LibreOffice.git] / sc / qa / extras / scdatapilottableobj.cxx
blob6ab1c33846a06ad54828e112430e4e826ada5926
1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 /*
3 * Version: MPL 1.1 / GPLv3+ / LGPLv3+
5 * The contents of this file are subject to the Mozilla Public License Version
6 * 1.1 (the "License"); you may not use this file except in compliance with
7 * the License or as specified alternatively below. You may obtain a copy of
8 * the License at http://www.mozilla.org/MPL/
10 * Software distributed under the License is distributed on an "AS IS" basis,
11 * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
12 * for the specific language governing rights and limitations under the
13 * License.
15 * Major Contributor(s):
16 * Copyright (C) 2012 Markus Mohrhard <markus.mohrhard@googlemail.com> (initial developer)
18 * All Rights Reserved.
20 * For minor contributions see the git repository.
22 * Alternatively, the contents of this file may be used under the terms of
23 * either the GNU General Public License Version 3 or later (the "GPLv3+"), or
24 * the GNU Lesser General Public License Version 3 or later (the "LGPLv3+"),
25 * in which case the provisions of the GPLv3+ or the LGPLv3+ are applicable
26 * instead of those above.
29 #include <test/unoapi_test.hxx>
30 #include <test/sheet/xdatapilottable.hxx>
31 #include <test/sheet/xdatapilottable2.hxx>
32 #include <test/sheet/xdatapilotdescriptor.hxx>
33 #include <test/container/xnamed.hxx>
35 #include <com/sun/star/sheet/XSpreadsheetDocument.hpp>
36 #include <com/sun/star/sheet/XSpreadsheet.hpp>
37 #include <com/sun/star/sheet/XDataPilotTablesSupplier.hpp>
38 #include <com/sun/star/sheet/XDataPilotTables.hpp>
39 #include <com/sun/star/sheet/XDataPilotTable.hpp>
41 namespace sc_apitest {
43 #define NUMBER_OF_TESTS 16
45 class ScDataPilotTableObj : public UnoApiTest, apitest::XDataPilotDescriptor, apitest::XDataPilotTable,
46 apitest::XNamed, apitest::XDataPilotTable2
48 public:
49 ScDataPilotTableObj();
51 virtual void setUp();
52 virtual void tearDown();
53 virtual uno::Reference< uno::XInterface > init();
54 virtual uno::Reference< uno::XInterface > initDP2();
55 virtual uno::Reference< uno::XInterface > getSheets();
57 CPPUNIT_TEST_SUITE(ScDataPilotTableObj);
58 CPPUNIT_TEST(testRefresh);
59 //CPPUNIT_TEST(testGetHiddenFields);
60 CPPUNIT_TEST(testGetOutputRange);
61 CPPUNIT_TEST(testSourceRange);
62 CPPUNIT_TEST(testTag);
63 CPPUNIT_TEST(testGetFilterDescriptor);
64 CPPUNIT_TEST(testGetDataPilotFields);
65 CPPUNIT_TEST(testGetColumnFields);
66 CPPUNIT_TEST(testGetRowFields);
67 CPPUNIT_TEST(testGetPageFields);
68 CPPUNIT_TEST(testGetDataFields);
69 CPPUNIT_TEST(testGetName);
70 CPPUNIT_TEST(testSetName);
71 CPPUNIT_TEST(testGetDrillDownData);
72 CPPUNIT_TEST(testInsertDrillDownSheet);
73 CPPUNIT_TEST(testGetPositionData);
74 CPPUNIT_TEST(testGetOutputRangeByType);
75 CPPUNIT_TEST_SUITE_END();
77 private:
78 static sal_Int32 nTest;
79 static uno::Reference< lang::XComponent > mxComponent;
82 sal_Int32 ScDataPilotTableObj::nTest = 0;
83 uno::Reference< lang::XComponent > ScDataPilotTableObj::mxComponent;
85 ScDataPilotTableObj::ScDataPilotTableObj()
86 : apitest::XNamed(rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("DataPilotTable")))
91 uno::Reference< uno::XInterface > ScDataPilotTableObj::init()
93 rtl::OUString aFileURL;
94 createFileURL(rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("ScDataPilotTableObj.ods")), aFileURL);
95 if(!mxComponent.is())
96 mxComponent = loadFromDesktop(aFileURL);
97 CPPUNIT_ASSERT(mxComponent.is());
99 uno::Reference< sheet::XSpreadsheetDocument > xDoc(mxComponent, UNO_QUERY_THROW);
100 uno::Reference< container::XIndexAccess > xIndex (xDoc->getSheets(), UNO_QUERY_THROW);
101 uno::Reference< sheet::XSpreadsheet > xSheet( xIndex->getByIndex(0), UNO_QUERY_THROW);
103 // set variables from xdatapilottable.[ch]xx
104 xCellForChange = xSheet->getCellByPosition( 1, 5 );
105 xCellForCheck = xSheet->getCellByPosition( 7, 11 );
106 CPPUNIT_ASSERT(xCellForCheck.is());
107 CPPUNIT_ASSERT(xCellForChange.is());
109 CPPUNIT_ASSERT_MESSAGE("Could not create interface of type XSpreadsheet", xSheet.is());
110 uno::Reference< sheet::XDataPilotTablesSupplier > xDPTS(xSheet, UNO_QUERY_THROW);
111 CPPUNIT_ASSERT(xDPTS.is());
112 uno::Reference< sheet::XDataPilotTables > xDPT = xDPTS->getDataPilotTables();
113 CPPUNIT_ASSERT(xDPT.is());
115 uno::Reference< sheet::XDataPilotTable > xDPTable(xDPT->getByName(rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("DataPilotTable"))),UNO_QUERY_THROW);
117 CPPUNIT_ASSERT(xDPTable.is());
118 return xDPTable;
121 uno::Reference< uno::XInterface > ScDataPilotTableObj::getSheets()
123 uno::Reference< sheet::XSpreadsheetDocument > xDoc(mxComponent, UNO_QUERY_THROW);
124 uno::Reference< uno::XInterface > xSheets(xDoc->getSheets());
125 return xSheets;
128 uno::Reference< uno::XInterface > ScDataPilotTableObj::initDP2()
130 rtl::OUString aFileURL;
131 createFileURL(rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("ScDataPilotTableObj.ods")), aFileURL);
132 if(!mxComponent.is())
133 mxComponent = loadFromDesktop(aFileURL);
134 CPPUNIT_ASSERT(mxComponent.is());
136 uno::Reference< sheet::XSpreadsheetDocument > xDoc(mxComponent, UNO_QUERY_THROW);
137 uno::Reference< container::XIndexAccess > xIndex (xDoc->getSheets(), UNO_QUERY_THROW);
138 uno::Reference< sheet::XSpreadsheet > xSheet( xIndex->getByIndex(0), UNO_QUERY_THROW);
140 // set variables from xdatapilottable.[ch]xx
141 xCellForChange = xSheet->getCellByPosition( 1, 5 );
142 xCellForCheck = xSheet->getCellByPosition( 7, 11 );
143 CPPUNIT_ASSERT(xCellForCheck.is());
144 CPPUNIT_ASSERT(xCellForChange.is());
146 CPPUNIT_ASSERT_MESSAGE("Could not create interface of type XSpreadsheet", xSheet.is());
147 uno::Reference< sheet::XDataPilotTablesSupplier > xDPTS(xSheet, UNO_QUERY_THROW);
148 CPPUNIT_ASSERT(xDPTS.is());
149 uno::Reference< sheet::XDataPilotTables > xDPT = xDPTS->getDataPilotTables();
150 CPPUNIT_ASSERT(xDPT.is());
152 uno::Reference< sheet::XDataPilotTable > xDPTable(xDPT->getByName(rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("DataPilotTable2"))),UNO_QUERY_THROW);
154 CPPUNIT_ASSERT(xDPTable.is());
155 return xDPTable;
158 void ScDataPilotTableObj::setUp()
160 nTest++;
161 UnoApiTest::setUp();
164 void ScDataPilotTableObj::tearDown()
166 if (nTest == NUMBER_OF_TESTS)
167 closeDocument(mxComponent);
169 UnoApiTest::tearDown();
172 CPPUNIT_TEST_SUITE_REGISTRATION(ScDataPilotTableObj);
174 CPPUNIT_PLUGIN_IMPLEMENT();
178 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */