defer finding dialog parent until we need it
[LibreOffice.git] / sc / qa / extras / scdatabaserangesobj.cxx
blobae0df82889ed0e1ea07753e1f85056f4fba6c226
1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4; fill-column: 100 -*- */
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/container/xelementaccess.hxx>
12 #include <test/container/xenumerationaccess.hxx>
13 #include <test/container/xindexaccess.hxx>
14 #include <test/container/xnameaccess.hxx>
15 #include <test/lang/xserviceinfo.hxx>
16 #include <test/sheet/xdatabaseranges.hxx>
18 #include <com/sun/star/beans/XPropertySet.hpp>
19 #include <com/sun/star/sheet/XDatabaseRange.hpp>
20 #include <com/sun/star/sheet/XDatabaseRanges.hpp>
21 #include <com/sun/star/sheet/XSpreadsheetDocument.hpp>
22 #include <com/sun/star/table/CellRangeAddress.hpp>
23 #include <com/sun/star/uno/XInterface.hpp>
25 #include <com/sun/star/uno/Reference.hxx>
27 #include <cppu/unotype.hxx>
29 using namespace css;
30 using namespace css::uno;
31 using namespace com::sun::star;
33 namespace sc_apitest
35 class ScDatabaseRangesObj : public UnoApiTest,
36 public apitest::XDatabaseRanges,
37 public apitest::XElementAccess,
38 public apitest::XEnumerationAccess,
39 public apitest::XIndexAccess,
40 public apitest::XNameAccess,
41 public apitest::XServiceInfo
43 public:
44 ScDatabaseRangesObj();
46 virtual uno::Reference<uno::XInterface> init() override;
47 virtual void setUp() override;
49 CPPUNIT_TEST_SUITE(ScDatabaseRangesObj);
51 // XDatabaseRanges
52 CPPUNIT_TEST(testAddRemoveDbRanges);
54 // XElementAccess
55 CPPUNIT_TEST(testGetElementType);
56 CPPUNIT_TEST(testHasElements);
58 // XEnumerationAccess
59 CPPUNIT_TEST(testCreateEnumeration);
61 // XIndexAccess
62 CPPUNIT_TEST(testGetByIndex);
63 CPPUNIT_TEST(testGetCount);
65 // XNameAccess
66 CPPUNIT_TEST(testGetByName);
67 CPPUNIT_TEST(testGetElementNames);
68 CPPUNIT_TEST(testHasByName);
70 // XServiceInfo
71 CPPUNIT_TEST(testGetImplementationName);
72 CPPUNIT_TEST(testGetSupportedServiceNames);
73 CPPUNIT_TEST(testSupportsService);
75 CPPUNIT_TEST_SUITE_END();
78 ScDatabaseRangesObj::ScDatabaseRangesObj()
79 : UnoApiTest(u"/sc/qa/extras/testdocuments"_ustr)
80 , XElementAccess(cppu::UnoType<sheet::XDatabaseRange>::get())
81 , XIndexAccess(1)
82 , XNameAccess(u"DbRange"_ustr)
83 , XServiceInfo(u"ScDatabaseRangesObj"_ustr, u"com.sun.star.sheet.DatabaseRanges"_ustr)
87 uno::Reference<uno::XInterface> ScDatabaseRangesObj::init()
89 uno::Reference<sheet::XSpreadsheetDocument> xDoc(mxComponent, UNO_QUERY_THROW);
91 uno::Reference<beans::XPropertySet> xPropSet(xDoc, UNO_QUERY_THROW);
92 uno::Reference<sheet::XDatabaseRanges> xDbRanges(
93 xPropSet->getPropertyValue(u"DatabaseRanges"_ustr), UNO_QUERY_THROW);
95 if (!xDbRanges->hasByName(u"DbRange"_ustr))
96 xDbRanges->addNewByName(u"DbRange"_ustr, table::CellRangeAddress(0, 2, 4, 5, 6));
98 return xDbRanges;
101 void ScDatabaseRangesObj::setUp()
103 UnoApiTest::setUp();
104 // create a calc document
105 loadFromURL(u"private:factory/scalc"_ustr);
108 CPPUNIT_TEST_SUITE_REGISTRATION(ScDatabaseRangesObj);
110 } // namespace sc_apitest
112 CPPUNIT_PLUGIN_IMPLEMENT();
114 /* vim:set shiftwidth=4 softtabstop=4 expandtab cinoptions=b1,g0,N-s cinkeys+=0=break: */