bump product version to 4.1.6.2
[LibreOffice.git] / sc / qa / extras / scdatapilotfieldobj.cxx
blob637dadad64f8447d70d0213cf543f391fa467d72
1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
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/unoapi_test.hxx>
11 #include <test/sheet/xdatapilotfieldgrouping.hxx>
12 #include <test/sheet/datapilotfield.hxx>
14 #include <com/sun/star/sheet/XSpreadsheetDocument.hpp>
15 #include <com/sun/star/sheet/XSpreadsheet.hpp>
16 #include <com/sun/star/sheet/XDataPilotTablesSupplier.hpp>
17 #include <com/sun/star/sheet/XDataPilotTables.hpp>
18 #include <com/sun/star/sheet/XDataPilotDescriptor.hpp>
20 using namespace css;
21 using namespace css::uno;
23 namespace sc_apitest {
25 #define NUMBER_OF_TESTS 6
27 class ScDataPilotFieldObj : public UnoApiTest, apitest::XDataPilotFieldGrouping,
28 apitest::DataPilotField
30 public:
31 virtual void setUp();
32 virtual void tearDown();
33 virtual uno::Reference< uno::XInterface > init();
35 ScDataPilotFieldObj();
37 CPPUNIT_TEST_SUITE(ScDataPilotFieldObj);
38 CPPUNIT_TEST(testSortInfo);
39 CPPUNIT_TEST(testLayoutInfo);
40 CPPUNIT_TEST(testAutoShowInfo);
41 CPPUNIT_TEST(testReference);
42 CPPUNIT_TEST(testIsGroupField);
43 CPPUNIT_TEST(testCreateNameGroup);
44 // see fdo#
45 //CPPUNIT_TEST(testCreateDateGroup);
46 CPPUNIT_TEST_SUITE_END();
47 private:
48 static sal_Int32 nTest;
49 static uno::Reference< lang::XComponent > mxComponent;
52 sal_Int32 ScDataPilotFieldObj::nTest = 0;
53 uno::Reference< lang::XComponent > ScDataPilotFieldObj::mxComponent;
55 ScDataPilotFieldObj::ScDataPilotFieldObj()
56 : UnoApiTest("/sc/qa/extras/testdocuments")
60 uno::Reference< uno::XInterface > ScDataPilotFieldObj::init()
62 OUString aFileURL;
63 createFileURL(OUString("scdatapilotfieldobj.ods"), aFileURL);
64 if(!mxComponent.is())
65 mxComponent = loadFromDesktop(aFileURL, "com.sun.star.sheet.SpreadsheetDocument");
66 CPPUNIT_ASSERT(mxComponent.is());
68 uno::Reference< sheet::XSpreadsheetDocument > xDoc(mxComponent, UNO_QUERY_THROW);
69 uno::Reference< container::XIndexAccess > xIndex (xDoc->getSheets(), UNO_QUERY_THROW);
70 uno::Reference< sheet::XSpreadsheet > xSheet( xIndex->getByIndex(1), UNO_QUERY_THROW);
72 CPPUNIT_ASSERT_MESSAGE("Could not create interface of type XSpreadsheet", xSheet.is());
73 uno::Reference< sheet::XDataPilotTablesSupplier > xDPTS(xSheet, UNO_QUERY_THROW);
74 CPPUNIT_ASSERT(xDPTS.is());
75 uno::Reference< sheet::XDataPilotTables > xDPT = xDPTS->getDataPilotTables();
76 CPPUNIT_ASSERT(xDPT.is());
77 uno::Sequence<OUString> aElementNames = xDPT->getElementNames();
79 uno::Reference< sheet::XDataPilotDescriptor > xDPDsc(xDPT->getByName(OUString("DataPilot1")),UNO_QUERY_THROW);
80 CPPUNIT_ASSERT(xDPDsc.is());
81 uno::Reference< container::XIndexAccess > xIA( xDPDsc->getDataPilotFields(), UNO_QUERY_THROW);
82 uno::Reference< uno::XInterface > xReturnValue( xIA->getByIndex(0), UNO_QUERY_THROW);
83 CPPUNIT_ASSERT(xReturnValue.is());
84 return xReturnValue;
87 void ScDataPilotFieldObj::setUp()
89 nTest++;
90 UnoApiTest::setUp();
93 void ScDataPilotFieldObj::tearDown()
95 if (nTest == NUMBER_OF_TESTS)
96 closeDocument(mxComponent);
98 UnoApiTest::tearDown();
101 CPPUNIT_TEST_SUITE_REGISTRATION(ScDataPilotFieldObj);
103 CPPUNIT_PLUGIN_IMPLEMENT();
107 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */