Update git submodules
[LibreOffice.git] / sc / qa / extras / scautoformatsobj.cxx
blobd000ee4a51aba7ac13563776a6e331c5978b399b
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/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>
28 using namespace css;
30 namespace sc_apitest
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
41 public:
42 ScAutoFormatsObj();
44 virtual uno::Reference<uno::XInterface> init() override;
45 virtual void setUp() override;
47 CPPUNIT_TEST_SUITE(ScAutoFormatsObj);
49 // XElementAccess
50 CPPUNIT_TEST(testGetElementType);
51 CPPUNIT_TEST(testHasElements);
53 // XEnumerationAccess
54 CPPUNIT_TEST(testCreateEnumeration);
56 // XIndexAccess
57 CPPUNIT_TEST(testGetByIndex);
58 CPPUNIT_TEST(testGetCount);
60 // XNameAccess
61 CPPUNIT_TEST(testGetByName);
62 CPPUNIT_TEST(testGetElementNames);
63 CPPUNIT_TEST(testHasByName);
65 // XNameContainer
66 CPPUNIT_TEST(testInsertByName);
67 CPPUNIT_TEST(testInsertByNameEmptyName);
68 CPPUNIT_TEST(testInsertByNameDuplicate);
69 CPPUNIT_TEST(testRemoveByName);
70 CPPUNIT_TEST(testRemoveByNameNoneExistingElement);
72 // XNameReplace
73 CPPUNIT_TEST(testReplaceByName);
75 // XServiceInfo
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())
86 , XIndexAccess(2)
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))
104 xNC->insertByName(
105 u"ScAutoFormatsObj"_ustr,
106 uno::Any(xMSF->createInstance(u"com.sun.star.sheet.TableAutoFormat"_ustr)));
108 // XNameContainer
109 XNameContainer::setElement(
110 uno::Any(xMSF->createInstance(u"com.sun.star.sheet.TableAutoFormat"_ustr)));
111 // XNameReplace
112 XNameReplace::setElement(
113 uno::Any(xMSF->createInstance(u"com.sun.star.sheet.TableAutoFormat"_ustr)));
115 return xTAF;
118 void ScAutoFormatsObj::setUp()
120 UnoApiTest::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: */