nss: upgrade to release 3.73
[LibreOffice.git] / sc / qa / extras / scautoformatsobj.cxx
blobed799c018ef49eb9efeb1649d5194ad6a2e147dd
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/calc_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/XComponent.hpp>
23 #include <com/sun/star/lang/XMultiServiceFactory.hpp>
24 #include <com/sun/star/uno/XInterface.hpp>
26 #include <com/sun/star/uno/Any.hxx>
27 #include <com/sun/star/uno/Reference.hxx>
29 using namespace css;
31 namespace sc_apitest
33 class ScAutoFormatsObj : public CalcUnoApiTest,
34 public apitest::XElementAccess,
35 public apitest::XEnumerationAccess,
36 public apitest::XIndexAccess,
37 public apitest::XNameAccess,
38 public apitest::XNameContainer,
39 public apitest::XNameReplace,
40 public apitest::XServiceInfo
42 public:
43 ScAutoFormatsObj();
45 virtual uno::Reference<uno::XInterface> init() override;
46 virtual void setUp() override;
47 virtual void tearDown() override;
49 CPPUNIT_TEST_SUITE(ScAutoFormatsObj);
51 // XElementAccess
52 CPPUNIT_TEST(testGetElementType);
53 CPPUNIT_TEST(testHasElements);
55 // XEnumerationAccess
56 CPPUNIT_TEST(testCreateEnumeration);
58 // XIndexAccess
59 CPPUNIT_TEST(testGetByIndex);
60 CPPUNIT_TEST(testGetCount);
62 // XNameAccess
63 CPPUNIT_TEST(testGetByName);
64 CPPUNIT_TEST(testGetElementNames);
65 CPPUNIT_TEST(testHasByName);
67 // XNameContainer
68 CPPUNIT_TEST(testInsertByName);
69 CPPUNIT_TEST(testInsertByNameEmptyName);
70 CPPUNIT_TEST(testInsertByNameDuplicate);
71 CPPUNIT_TEST(testRemoveByName);
72 CPPUNIT_TEST(testRemoveByNameNoneExistingElement);
74 // XNameReplace
75 CPPUNIT_TEST(testReplaceByName);
77 // XServiceInfo
78 CPPUNIT_TEST(testGetImplementationName);
79 CPPUNIT_TEST(testGetSupportedServiceNames);
80 CPPUNIT_TEST(testSupportsService);
82 CPPUNIT_TEST_SUITE_END();
84 private:
85 uno::Reference<lang::XComponent> m_xComponent;
88 ScAutoFormatsObj::ScAutoFormatsObj()
89 : CalcUnoApiTest("/sc/qa/extras/testdocuments")
90 , XElementAccess(cppu::UnoType<container::XNamed>::get())
91 , XIndexAccess(2)
92 , XNameAccess("Default")
93 , XNameContainer("ScAutoFormatsObj")
94 , XNameReplace("ScAutoFormatsObj")
95 , XServiceInfo("stardiv.StarCalc.ScAutoFormatsObj", "com.sun.star.sheet.TableAutoFormats")
99 uno::Reference<uno::XInterface> ScAutoFormatsObj::init()
101 uno::Reference<lang::XMultiServiceFactory> xMSF(m_xComponent, uno::UNO_QUERY_THROW);
102 uno::Reference<uno::XInterface> xTAF(
103 xMSF->createInstance("com.sun.star.sheet.TableAutoFormats"), uno::UNO_SET_THROW);
105 uno::Reference<container::XNameContainer> xNC(xTAF, uno::UNO_QUERY_THROW);
106 if (!xNC->hasByName("ScAutoFormatsObj"))
108 xNC->insertByName("ScAutoFormatsObj",
109 uno::makeAny(xMSF->createInstance("com.sun.star.sheet.TableAutoFormat")));
111 // XNameContainer
112 XNameContainer::setElement(
113 uno::makeAny(xMSF->createInstance("com.sun.star.sheet.TableAutoFormat")));
114 // XNameReplace
115 XNameReplace::setElement(
116 uno::makeAny(xMSF->createInstance("com.sun.star.sheet.TableAutoFormat")));
118 return xTAF;
121 void ScAutoFormatsObj::setUp()
123 CalcUnoApiTest::setUp();
124 // create calc document
125 m_xComponent = loadFromDesktop("private:factory/scalc");
128 void ScAutoFormatsObj::tearDown()
130 closeDocument(m_xComponent);
131 CalcUnoApiTest::tearDown();
134 CPPUNIT_TEST_SUITE_REGISTRATION(ScAutoFormatsObj);
136 } // namespace sc_apitest
138 CPPUNIT_PLUGIN_IMPLEMENT();
140 /* vim:set shiftwidth=4 softtabstop=4 expandtab cinoptions=b1,g0,N-s cinkeys+=0=break: */