Line data Source code
1 : /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 : /*
3 : * This file is part of the LibreOffice project.
4 : *
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 : */
9 :
10 : #include <test/calc_unoapi_test.hxx>
11 : #include <test/sheet/xdatapilotfieldgrouping.hxx>
12 : #include <test/sheet/datapilotfield.hxx>
13 :
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>
19 :
20 : using namespace css;
21 : using namespace css::uno;
22 :
23 : namespace sc_apitest {
24 :
25 : #define NUMBER_OF_TESTS 6
26 :
27 24 : class ScDataPilotFieldObj : public CalcUnoApiTest, apitest::XDataPilotFieldGrouping,
28 : apitest::DataPilotField
29 : {
30 : public:
31 : virtual void setUp() SAL_OVERRIDE;
32 : virtual void tearDown() SAL_OVERRIDE;
33 : virtual uno::Reference< uno::XInterface > init() SAL_OVERRIDE;
34 :
35 : ScDataPilotFieldObj();
36 :
37 4 : CPPUNIT_TEST_SUITE(ScDataPilotFieldObj);
38 2 : CPPUNIT_TEST(testSortInfo);
39 2 : CPPUNIT_TEST(testLayoutInfo);
40 2 : CPPUNIT_TEST(testAutoShowInfo);
41 2 : CPPUNIT_TEST(testReference);
42 2 : CPPUNIT_TEST(testIsGroupField);
43 2 : CPPUNIT_TEST(testCreateNameGroup);
44 : // see fdo#
45 : //CPPUNIT_TEST(testCreateDateGroup);
46 4 : CPPUNIT_TEST_SUITE_END();
47 : private:
48 : static sal_Int32 nTest;
49 : static uno::Reference< lang::XComponent > mxComponent;
50 : };
51 :
52 : sal_Int32 ScDataPilotFieldObj::nTest = 0;
53 2 : uno::Reference< lang::XComponent > ScDataPilotFieldObj::mxComponent;
54 :
55 12 : ScDataPilotFieldObj::ScDataPilotFieldObj()
56 12 : : CalcUnoApiTest("/sc/qa/extras/testdocuments")
57 : {
58 12 : }
59 :
60 12 : uno::Reference< uno::XInterface > ScDataPilotFieldObj::init()
61 : {
62 12 : OUString aFileURL;
63 12 : createFileURL(OUString("scdatapilotfieldobj.ods"), aFileURL);
64 12 : if(!mxComponent.is())
65 2 : mxComponent = loadFromDesktop(aFileURL, "com.sun.star.sheet.SpreadsheetDocument");
66 12 : CPPUNIT_ASSERT(mxComponent.is());
67 :
68 24 : uno::Reference< sheet::XSpreadsheetDocument > xDoc(mxComponent, UNO_QUERY_THROW);
69 24 : uno::Reference< container::XIndexAccess > xIndex (xDoc->getSheets(), UNO_QUERY_THROW);
70 24 : uno::Reference< sheet::XSpreadsheet > xSheet( xIndex->getByIndex(1), UNO_QUERY_THROW);
71 :
72 12 : CPPUNIT_ASSERT_MESSAGE("Could not create interface of type XSpreadsheet", xSheet.is());
73 24 : uno::Reference< sheet::XDataPilotTablesSupplier > xDPTS(xSheet, UNO_QUERY_THROW);
74 12 : CPPUNIT_ASSERT(xDPTS.is());
75 24 : uno::Reference< sheet::XDataPilotTables > xDPT = xDPTS->getDataPilotTables();
76 12 : CPPUNIT_ASSERT(xDPT.is());
77 24 : uno::Sequence<OUString> aElementNames = xDPT->getElementNames();
78 : (void) aElementNames;
79 :
80 24 : uno::Reference< sheet::XDataPilotDescriptor > xDPDsc(xDPT->getByName("DataPilot1"),UNO_QUERY_THROW);
81 12 : CPPUNIT_ASSERT(xDPDsc.is());
82 24 : uno::Reference< container::XIndexAccess > xIA( xDPDsc->getDataPilotFields(), UNO_QUERY_THROW);
83 12 : uno::Reference< uno::XInterface > xReturnValue( xIA->getByIndex(0), UNO_QUERY_THROW);
84 12 : CPPUNIT_ASSERT(xReturnValue.is());
85 24 : return xReturnValue;
86 : }
87 :
88 12 : void ScDataPilotFieldObj::setUp()
89 : {
90 12 : nTest++;
91 12 : CalcUnoApiTest::setUp();
92 12 : }
93 :
94 12 : void ScDataPilotFieldObj::tearDown()
95 : {
96 12 : if (nTest == NUMBER_OF_TESTS)
97 : {
98 2 : closeDocument(mxComponent);
99 2 : mxComponent.clear();
100 : }
101 :
102 12 : CalcUnoApiTest::tearDown();
103 12 : }
104 :
105 2 : CPPUNIT_TEST_SUITE_REGISTRATION(ScDataPilotFieldObj);
106 :
107 : }
108 :
109 8 : CPPUNIT_PLUGIN_IMPLEMENT();
110 :
111 : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
|