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/calc_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/lang/XComponent.hpp>
20 #include <com/sun/star/sheet/XSheetCondition.hpp>
21 #include <com/sun/star/sheet/XSpreadsheetDocument.hpp>
22 #include <com/sun/star/sheet/XSpreadsheet.hpp>
23 #include <com/sun/star/uno/XInterface.hpp>
25 #include <com/sun/star/uno/Reference.hxx>
28 using namespace css::uno
;
29 using namespace com::sun::star
;
33 class ScTableValidationObj
: public CalcUnoApiTest
,
34 public apitest::TableValidation
,
35 public apitest::XMultiFormulaTokens
,
36 public apitest::XPropertySet
,
37 public apitest::XServiceInfo
,
38 public apitest::XSheetCondition
41 ScTableValidationObj();
43 virtual uno::Reference
<uno::XInterface
> init() override
;
44 virtual void setUp() override
;
45 virtual void tearDown() override
;
47 CPPUNIT_TEST_SUITE(ScTableValidationObj
);
50 CPPUNIT_TEST(testTableValidationProperties
);
52 // XMultiFormulaTokens
53 CPPUNIT_TEST(testGetCount
);
54 CPPUNIT_TEST(testGetSetTokens
);
57 CPPUNIT_TEST(testGetPropertySetInfo
);
58 CPPUNIT_TEST(testSetPropertyValue
);
59 CPPUNIT_TEST(testGetPropertyValue
);
60 CPPUNIT_TEST(testPropertyChangeListener
);
61 CPPUNIT_TEST(testVetoableChangeListener
);
64 CPPUNIT_TEST(testGetImplementationName
);
65 CPPUNIT_TEST(testGetSupportedServiceNames
);
66 CPPUNIT_TEST(testSupportsService
);
69 CPPUNIT_TEST(testGetSetFormula1
);
70 CPPUNIT_TEST(testGetSetFormula2
);
71 CPPUNIT_TEST(testGetSetOperator
);
72 CPPUNIT_TEST(testGetSetSourcePosition
);
74 CPPUNIT_TEST_SUITE_END();
77 uno::Reference
<lang::XComponent
> mxComponent
;
80 ScTableValidationObj::ScTableValidationObj()
81 : CalcUnoApiTest("/sc/qa/extras/testdocuments")
82 , XPropertySet({ "Type", "ErrorAlertStyle" })
83 , XServiceInfo("ScTableValidationObj", "com.sun.star.sheet.TableValidation")
87 uno::Reference
<uno::XInterface
> ScTableValidationObj::init()
89 uno::Reference
<sheet::XSpreadsheetDocument
> xDoc(mxComponent
, uno::UNO_QUERY_THROW
);
91 uno::Reference
<container::XIndexAccess
> xIndex(xDoc
->getSheets(), uno::UNO_QUERY_THROW
);
92 uno::Reference
<sheet::XSpreadsheet
> xSheet(xIndex
->getByIndex(0), uno::UNO_QUERY_THROW
);
94 xSheet
->getCellByPosition(5, 5)->setValue(15);
95 xSheet
->getCellByPosition(1, 4)->setValue(10);
96 xSheet
->getCellByPosition(2, 0)->setValue(-5.15);
98 uno::Reference
<beans::XPropertySet
> xPropSet(xSheet
, uno::UNO_QUERY_THROW
);
99 uno::Reference
<sheet::XSheetCondition
> xSheetCondition
;
100 CPPUNIT_ASSERT(xPropSet
->getPropertyValue("Validation") >>= xSheetCondition
);
102 return xSheetCondition
;
105 void ScTableValidationObj::setUp()
107 CalcUnoApiTest::setUp();
108 // create a calc document
109 mxComponent
= loadFromDesktop("private:factory/scalc");
112 void ScTableValidationObj::tearDown()
114 closeDocument(mxComponent
);
115 CalcUnoApiTest::tearDown();
118 CPPUNIT_TEST_SUITE_REGISTRATION(ScTableValidationObj
);
120 } // namespace sc_apitest
122 CPPUNIT_PLUGIN_IMPLEMENT();
124 /* vim:set shiftwidth=4 softtabstop=4 expandtab cinoptions=b1,g0,N-s cinkeys+=0=break: */