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.
4 *
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 */
9
10 #include <test/calc_unoapi_test.hxx>
11 #include <test/beans/xpropertyset.hxx>
12 #include <test/container/xelementaccess.hxx>
13 #include <test/container/xenumerationaccess.hxx>
14 #include <test/container/xindexaccess.hxx>
15 #include <test/container/xnamed.hxx>
16 #include <test/lang/xserviceinfo.hxx>
17 #include <test/sheet/tableautoformat.hxx>
18 #include <cppu/unotype.hxx>
19
20 #include <com/sun/star/beans/XPropertySet.hpp>
21 #include <com/sun/star/container/XIndexAccess.hpp>
22 #include <com/sun/star/lang/XComponent.hpp>
23 #include <com/sun/star/lang/XMultiServiceFactory.hpp>
24 #include <com/sun/star/sheet/XSpreadsheetDocument.hpp>
25 #include <com/sun/star/uno/XInterface.hpp>
26
27 #include <com/sun/star/uno/Reference.hxx>
28
29 using namespace css;
30
31 namespace sc_apitest
32 {
33 class ScAutoFormatObj : public CalcUnoApiTest,
34 public apitest::TableAutoFormat,
35 public apitest::XElementAccess,
36 public apitest::XEnumerationAccess,
37 public apitest::XIndexAccess,
38 public apitest::XNamed,
39 public apitest::XPropertySet,
40 public apitest::XServiceInfo
41 {
42 public:
43 ScAutoFormatObj();
44
45 virtual uno::Reference<uno::XInterface> init() override;
46 virtual void setUp() override;
47 virtual void tearDown() override;
48
49 CPPUNIT_TEST_SUITE(ScAutoFormatObj);
50
51 // TableAutoFormat
52 CPPUNIT_TEST(testTableAutoFormatProperties);
53
54 // XElementAccess
55 CPPUNIT_TEST(testGetElementType);
56 CPPUNIT_TEST(testHasElements);
57
58 // XEnumerationAccess
59 CPPUNIT_TEST(testCreateEnumeration);
60
61 // XIndexAccess
62 CPPUNIT_TEST(testGetByIndex);
63 CPPUNIT_TEST(testGetCount);
64
65 // XNamed
66 CPPUNIT_TEST(testGetName);
67 CPPUNIT_TEST(testSetName);
68
69 // XPropertySet
70 CPPUNIT_TEST(testGetPropertySetInfo);
71 CPPUNIT_TEST(testGetPropertyValue);
72 CPPUNIT_TEST(testSetPropertyValue);
73 CPPUNIT_TEST(testPropertyChangeListener);
74 CPPUNIT_TEST(testVetoableChangeListener);
75
76 // XServiceInfo
77 CPPUNIT_TEST(testGetImplementationName);
78 CPPUNIT_TEST(testGetSupportedServiceNames);
79 CPPUNIT_TEST(testSupportsService);
80
81 CPPUNIT_TEST_SUITE_END();
82
83 private:
84 uno::Reference<lang::XComponent> mxComponent;
85 };
86
ScAutoFormatObj()87 ScAutoFormatObj::ScAutoFormatObj()
88 : CalcUnoApiTest("/sc/qa/extras/testdocuments")
89 , XElementAccess(cppu::UnoType<beans::XPropertySet>::get())
90 , XIndexAccess(16)
91 , XNamed("Default")
92 , XServiceInfo("ScAutoFormatObj", "com.sun.star.sheet.TableAutoFormat")
93 {
94 }
95
init()96 uno::Reference<uno::XInterface> ScAutoFormatObj::init()
97 {
98 uno::Reference<sheet::XSpreadsheetDocument> xDoc(mxComponent, uno::UNO_QUERY_THROW);
99
100 uno::Reference<lang::XMultiServiceFactory> xMSF(xDoc, uno::UNO_QUERY_THROW);
101 uno::Reference<container::XIndexAccess> xIA(
102 xMSF->createInstance("com.sun.star.sheet.TableAutoFormats"), uno::UNO_QUERY_THROW);
103
104 uno::Reference<beans::XPropertySet> xTableAutoFormat(xIA->getByIndex(xIA->getCount() - 1),
105 uno::UNO_QUERY_THROW);
106 return xTableAutoFormat;
107 }
108
setUp()109 void ScAutoFormatObj::setUp()
110 {
111 CalcUnoApiTest::setUp();
112 mxComponent = loadFromDesktop("private:factory/scalc");
113 }
114
tearDown()115 void ScAutoFormatObj::tearDown()
116 {
117 closeDocument(mxComponent);
118 CalcUnoApiTest::tearDown();
119 }
120
121 CPPUNIT_TEST_SUITE_REGISTRATION(ScAutoFormatObj);
122
123 } // namespace sc_apitest
124
125 CPPUNIT_PLUGIN_IMPLEMENT();
126
127 /* vim:set shiftwidth=4 softtabstop=4 expandtab cinoptions=b1,g0,N-s cinkeys+=0=break: */
128