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/sheet/xdatabaserange.hxx>
13 #include <com/sun/star/beans/XPropertySet.hpp>
14 #include <com/sun/star/sheet/XSpreadsheetDocument.hpp>
15 #include <com/sun/star/container/XNameAccess.hpp>
16 #include <com/sun/star/sheet/XDatabaseRange.hpp>
19 using namespace css::uno
;
21 namespace sc_apitest
{
23 #define NUMBER_OF_TESTS 6
25 class ScDatabaseRangeObj
: public CalcUnoApiTest
, apitest::XDatabaseRange
28 virtual void setUp() SAL_OVERRIDE
;
29 virtual void tearDown() SAL_OVERRIDE
;
31 virtual uno::Reference
< uno::XInterface
> init( const OUString
& rDBName
) SAL_OVERRIDE
;
35 CPPUNIT_TEST_SUITE(ScDatabaseRangeObj
);
36 CPPUNIT_TEST(testDataArea
);
37 CPPUNIT_TEST(testGetSortDescriptor
);
38 CPPUNIT_TEST(testGetSubtotalDescriptor
);
39 CPPUNIT_TEST(testGetImportDescriptor
);
40 CPPUNIT_TEST(testGetFilterDescriptor
);
41 CPPUNIT_TEST(testRefresh
);
42 CPPUNIT_TEST_SUITE_END();
44 static sal_Int32 nTest
;
45 static uno::Reference
< lang::XComponent
> mxComponent
;
48 sal_Int32
ScDatabaseRangeObj::nTest
= 0;
49 uno::Reference
< lang::XComponent
> ScDatabaseRangeObj::mxComponent
;
51 ScDatabaseRangeObj::ScDatabaseRangeObj()
52 : CalcUnoApiTest("/sc/qa/extras/testdocuments")
56 uno::Reference
< uno::XInterface
> ScDatabaseRangeObj::init( const OUString
& rDBName
)
59 createFileURL("ScDatabaseRangeObj.ods", aFileURL
);
61 mxComponent
= loadFromDesktop(aFileURL
, "com.sun.star.sheet.SpreadsheetDocument");
62 CPPUNIT_ASSERT(mxComponent
.is());
64 uno::Reference
< sheet::XSpreadsheetDocument
> xDoc(mxComponent
, UNO_QUERY_THROW
);
65 uno::Reference
< beans::XPropertySet
> xPropSet(xDoc
, UNO_QUERY_THROW
);
66 uno::Reference
< container::XNameAccess
> xNameAccess( xPropSet
->getPropertyValue("DatabaseRanges"), UNO_QUERY_THROW
);
67 uno::Reference
< sheet::XDatabaseRange
> xDBRange( xNameAccess
->getByName(rDBName
), UNO_QUERY_THROW
);
68 CPPUNIT_ASSERT(xDBRange
.is());
72 void ScDatabaseRangeObj::setUp()
75 CalcUnoApiTest::setUp();
78 void ScDatabaseRangeObj::tearDown()
80 if (nTest
== NUMBER_OF_TESTS
)
82 closeDocument(mxComponent
);
86 CalcUnoApiTest::tearDown();
89 CPPUNIT_TEST_SUITE_REGISTRATION(ScDatabaseRangeObj
);
93 CPPUNIT_PLUGIN_IMPLEMENT();
95 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */