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/beans/xpropertyset.hxx>
12 #include <test/lang/xserviceinfo.hxx>
13 #include <test/sheet/tablevalidation.hxx>
14 #include <test/sheet/xsheetcondition.hxx>
15 #include <test/sheet/xmultiformulatokens.hxx>
17 #include <com/sun/star/beans/XPropertySet.hpp>
18 #include <com/sun/star/container/XIndexAccess.hpp>
19 #include <com/sun/star/sheet/XSheetCondition.hpp>
20 #include <com/sun/star/sheet/XSpreadsheetDocument.hpp>
21 #include <com/sun/star/sheet/XSpreadsheet.hpp>
22 #include <com/sun/star/uno/XInterface.hpp>
24 #include <com/sun/star/uno/Reference.hxx>
27 using namespace css::uno
;
28 using namespace com::sun::star
;
32 class ScTableValidationObj
: public UnoApiTest
,
33 public apitest::TableValidation
,
34 public apitest::XMultiFormulaTokens
,
35 public apitest::XPropertySet
,
36 public apitest::XServiceInfo
,
37 public apitest::XSheetCondition
40 ScTableValidationObj();
42 virtual uno::Reference
<uno::XInterface
> init() override
;
43 virtual void setUp() override
;
45 CPPUNIT_TEST_SUITE(ScTableValidationObj
);
48 CPPUNIT_TEST(testTableValidationProperties
);
50 // XMultiFormulaTokens
51 CPPUNIT_TEST(testGetCount
);
52 CPPUNIT_TEST(testGetSetTokens
);
55 CPPUNIT_TEST(testGetPropertySetInfo
);
56 CPPUNIT_TEST(testSetPropertyValue
);
57 CPPUNIT_TEST(testGetPropertyValue
);
58 CPPUNIT_TEST(testPropertyChangeListener
);
59 CPPUNIT_TEST(testVetoableChangeListener
);
62 CPPUNIT_TEST(testGetImplementationName
);
63 CPPUNIT_TEST(testGetSupportedServiceNames
);
64 CPPUNIT_TEST(testSupportsService
);
67 CPPUNIT_TEST(testGetSetFormula1
);
68 CPPUNIT_TEST(testGetSetFormula2
);
69 CPPUNIT_TEST(testGetSetOperator
);
70 CPPUNIT_TEST(testGetSetSourcePosition
);
72 CPPUNIT_TEST_SUITE_END();
75 ScTableValidationObj::ScTableValidationObj()
76 : UnoApiTest(u
"/sc/qa/extras/testdocuments"_ustr
)
77 , XPropertySet({ u
"Type"_ustr
, u
"ErrorAlertStyle"_ustr
})
78 , XServiceInfo(u
"ScTableValidationObj"_ustr
, u
"com.sun.star.sheet.TableValidation"_ustr
)
82 uno::Reference
<uno::XInterface
> ScTableValidationObj::init()
84 uno::Reference
<sheet::XSpreadsheetDocument
> xDoc(mxComponent
, uno::UNO_QUERY_THROW
);
86 uno::Reference
<container::XIndexAccess
> xIndex(xDoc
->getSheets(), uno::UNO_QUERY_THROW
);
87 uno::Reference
<sheet::XSpreadsheet
> xSheet(xIndex
->getByIndex(0), uno::UNO_QUERY_THROW
);
89 xSheet
->getCellByPosition(5, 5)->setValue(15);
90 xSheet
->getCellByPosition(1, 4)->setValue(10);
91 xSheet
->getCellByPosition(2, 0)->setValue(-5.15);
93 uno::Reference
<beans::XPropertySet
> xPropSet(xSheet
, uno::UNO_QUERY_THROW
);
94 uno::Reference
<sheet::XSheetCondition
> xSheetCondition
;
95 CPPUNIT_ASSERT(xPropSet
->getPropertyValue(u
"Validation"_ustr
) >>= xSheetCondition
);
97 return xSheetCondition
;
100 void ScTableValidationObj::setUp()
103 // create a calc document
104 loadFromURL(u
"private:factory/scalc"_ustr
);
107 CPPUNIT_TEST_SUITE_REGISTRATION(ScTableValidationObj
);
109 } // namespace sc_apitest
111 CPPUNIT_PLUGIN_IMPLEMENT();
113 /* vim:set shiftwidth=4 softtabstop=4 expandtab cinoptions=b1,g0,N-s cinkeys+=0=break: */