1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4; fill-column: 100 -*- */
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/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/container/xnamecontainer.hxx>
16 #include <test/container/xnamereplace.hxx>
17 #include <test/lang/xserviceinfo.hxx>
18 #include <cppu/unotype.hxx>
20 #include <com/sun/star/container/XNameContainer.hpp>
21 #include <com/sun/star/container/XNamed.hpp>
22 #include <com/sun/star/lang/XMultiServiceFactory.hpp>
23 #include <com/sun/star/uno/XInterface.hpp>
25 #include <com/sun/star/uno/Any.hxx>
26 #include <com/sun/star/uno/Reference.hxx>
32 class ScAutoFormatsObj
: public UnoApiTest
,
33 public apitest::XElementAccess
,
34 public apitest::XEnumerationAccess
,
35 public apitest::XIndexAccess
,
36 public apitest::XNameAccess
,
37 public apitest::XNameContainer
,
38 public apitest::XNameReplace
,
39 public apitest::XServiceInfo
44 virtual uno::Reference
<uno::XInterface
> init() override
;
45 virtual void setUp() override
;
47 CPPUNIT_TEST_SUITE(ScAutoFormatsObj
);
50 CPPUNIT_TEST(testGetElementType
);
51 CPPUNIT_TEST(testHasElements
);
54 CPPUNIT_TEST(testCreateEnumeration
);
57 CPPUNIT_TEST(testGetByIndex
);
58 CPPUNIT_TEST(testGetCount
);
61 CPPUNIT_TEST(testGetByName
);
62 CPPUNIT_TEST(testGetElementNames
);
63 CPPUNIT_TEST(testHasByName
);
66 CPPUNIT_TEST(testInsertByName
);
67 CPPUNIT_TEST(testInsertByNameEmptyName
);
68 CPPUNIT_TEST(testInsertByNameDuplicate
);
69 CPPUNIT_TEST(testRemoveByName
);
70 CPPUNIT_TEST(testRemoveByNameNoneExistingElement
);
73 CPPUNIT_TEST(testReplaceByName
);
76 CPPUNIT_TEST(testGetImplementationName
);
77 CPPUNIT_TEST(testGetSupportedServiceNames
);
78 CPPUNIT_TEST(testSupportsService
);
80 CPPUNIT_TEST_SUITE_END();
83 ScAutoFormatsObj::ScAutoFormatsObj()
84 : UnoApiTest(u
"/sc/qa/extras/testdocuments"_ustr
)
85 , XElementAccess(cppu::UnoType
<container::XNamed
>::get())
87 , XNameAccess(u
"Default"_ustr
)
88 , XNameContainer(u
"ScAutoFormatsObj"_ustr
)
89 , XNameReplace(u
"ScAutoFormatsObj"_ustr
)
90 , XServiceInfo(u
"stardiv.StarCalc.ScAutoFormatsObj"_ustr
,
91 u
"com.sun.star.sheet.TableAutoFormats"_ustr
)
95 uno::Reference
<uno::XInterface
> ScAutoFormatsObj::init()
97 uno::Reference
<lang::XMultiServiceFactory
> xMSF(mxComponent
, uno::UNO_QUERY_THROW
);
98 uno::Reference
<uno::XInterface
> xTAF(
99 xMSF
->createInstance(u
"com.sun.star.sheet.TableAutoFormats"_ustr
), uno::UNO_SET_THROW
);
101 uno::Reference
<container::XNameContainer
> xNC(xTAF
, uno::UNO_QUERY_THROW
);
102 if (!xNC
->hasByName(u
"ScAutoFormatsObj"_ustr
))
105 u
"ScAutoFormatsObj"_ustr
,
106 uno::Any(xMSF
->createInstance(u
"com.sun.star.sheet.TableAutoFormat"_ustr
)));
109 XNameContainer::setElement(
110 uno::Any(xMSF
->createInstance(u
"com.sun.star.sheet.TableAutoFormat"_ustr
)));
112 XNameReplace::setElement(
113 uno::Any(xMSF
->createInstance(u
"com.sun.star.sheet.TableAutoFormat"_ustr
)));
118 void ScAutoFormatsObj::setUp()
121 // create calc document
122 loadFromURL(u
"private:factory/scalc"_ustr
);
125 CPPUNIT_TEST_SUITE_REGISTRATION(ScAutoFormatsObj
);
127 } // namespace sc_apitest
129 CPPUNIT_PLUGIN_IMPLEMENT();
131 /* vim:set shiftwidth=4 softtabstop=4 expandtab cinoptions=b1,g0,N-s cinkeys+=0=break: */