diff options
author | Jens Carl <j.carl43@gmx.de> | 2017-11-01 20:30:32 +0000 |
---|---|---|
committer | Jens Carl <j.carl43@gmx.de> | 2017-11-03 03:20:07 +0100 |
commit | 2416d69ad4fa26b65d5b05a8575ac96af6b2c9a9 (patch) | |
tree | 330ec8c0b083307d89390193282d5b7eabf994b2 | |
parent | 8c374022790b54834fa54615e1953c8ee30641a8 (diff) |
tdf#45904 Move Java _XSheetCondition tests to C++
Change-Id: I013ccd0258a567ba69d624a02a4d4daab5c7f4fa
Reviewed-on: https://gerrit.libreoffice.org/44181
Reviewed-by: Jens Carl <j.carl43@gmx.de>
Tested-by: Jens Carl <j.carl43@gmx.de>
-rw-r--r-- | include/test/sheet/xsheetcondition.hxx | 39 | ||||
-rw-r--r-- | qadevOOo/Jar_OOoRunner.mk | 1 | ||||
-rw-r--r-- | qadevOOo/objdsc/sc/com.sun.star.comp.office.ScTableConditionalEntry.csv | 8 | ||||
-rw-r--r-- | qadevOOo/objdsc/sc/com.sun.star.comp.office.ScTableValidationObj.csv | 8 | ||||
-rw-r--r-- | qadevOOo/tests/java/ifc/sheet/_XSheetCondition.java | 149 | ||||
-rw-r--r-- | sc/CppunitTest_sc_tableconditionalentryobj.mk | 105 | ||||
-rw-r--r-- | sc/CppunitTest_sc_tablevalidationobj.mk | 105 | ||||
-rw-r--r-- | sc/Module_sc.mk | 2 | ||||
-rw-r--r-- | sc/qa/extras/sctableconditionalentryobj.cxx | 133 | ||||
-rw-r--r-- | sc/qa/extras/sctablevalidationobj.cxx | 113 | ||||
-rw-r--r-- | test/Library_subsequenttest.mk | 1 | ||||
-rw-r--r-- | test/source/sheet/xsheetcondition.cxx | 74 |
12 files changed, 572 insertions, 166 deletions
diff --git a/include/test/sheet/xsheetcondition.hxx b/include/test/sheet/xsheetcondition.hxx new file mode 100644 index 000000000000..39fef9870c63 --- /dev/null +++ b/include/test/sheet/xsheetcondition.hxx @@ -0,0 +1,39 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ +/* + * This file is part of the LibreOffice project. + * + * This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. + */ + +#ifndef INCLUDED_TEST_SHEET_XSHEETCONDITION_HXX +#define INCLUDED_TEST_SHEET_XSHEETCONDITION_HXX + + +#include <com/sun/star/uno/XInterface.hpp> +#include <com/sun/star/uno/Reference.hxx> + +#include <test/testdllapi.hxx> + +namespace apitest { + +class OOO_DLLPUBLIC_TEST XSheetCondition +{ +public: + virtual css::uno::Reference< css::uno::XInterface > init() =0; + + void testGetSetFormula1(); + void testGetSetFormula2(); + void testGetSetOperator(); + void testGetSetSourcePosition(); + +protected: + ~XSheetCondition() {} +}; + +} + +#endif // INCLUDED_TEST_SHEET_XSHEETCONDITION_HXX + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/qadevOOo/Jar_OOoRunner.mk b/qadevOOo/Jar_OOoRunner.mk index 570a69d29e79..e85731f3f3a9 100644 --- a/qadevOOo/Jar_OOoRunner.mk +++ b/qadevOOo/Jar_OOoRunner.mk @@ -621,7 +621,6 @@ $(eval $(call gb_Jar_add_sourcefiles,OOoRunner,\ qadevOOo/tests/java/ifc/sheet/_XSheetCellRange \ qadevOOo/tests/java/ifc/sheet/_XSheetCellRangeContainer \ qadevOOo/tests/java/ifc/sheet/_XSheetCellRanges \ - qadevOOo/tests/java/ifc/sheet/_XSheetCondition \ qadevOOo/tests/java/ifc/sheet/_XSheetConditionalEntries \ qadevOOo/tests/java/ifc/sheet/_XSheetConditionalEntry \ qadevOOo/tests/java/ifc/sheet/_XSheetFilterableEx \ diff --git a/qadevOOo/objdsc/sc/com.sun.star.comp.office.ScTableConditionalEntry.csv b/qadevOOo/objdsc/sc/com.sun.star.comp.office.ScTableConditionalEntry.csv index 7666b1eecf78..5de029653f0c 100644 --- a/qadevOOo/objdsc/sc/com.sun.star.comp.office.ScTableConditionalEntry.csv +++ b/qadevOOo/objdsc/sc/com.sun.star.comp.office.ScTableConditionalEntry.csv @@ -1,10 +1,2 @@ "ScTableConditionalEntry";"com::sun::star::sheet::XSheetConditionalEntry";"getStyleName()" "ScTableConditionalEntry";"com::sun::star::sheet::XSheetConditionalEntry";"setStyleName()" -"ScTableConditionalEntry";"com::sun::star::sheet::XSheetCondition";"getOperator()" -"ScTableConditionalEntry";"com::sun::star::sheet::XSheetCondition";"setOperator()" -"ScTableConditionalEntry";"com::sun::star::sheet::XSheetCondition";"getFormula1()" -"ScTableConditionalEntry";"com::sun::star::sheet::XSheetCondition";"setFormula1()" -"ScTableConditionalEntry";"com::sun::star::sheet::XSheetCondition";"getFormula2()" -"ScTableConditionalEntry";"com::sun::star::sheet::XSheetCondition";"setFormula2()" -"ScTableConditionalEntry";"com::sun::star::sheet::XSheetCondition";"getSourcePosition()" -"ScTableConditionalEntry";"com::sun::star::sheet::XSheetCondition";"setSourcePosition()" diff --git a/qadevOOo/objdsc/sc/com.sun.star.comp.office.ScTableValidationObj.csv b/qadevOOo/objdsc/sc/com.sun.star.comp.office.ScTableValidationObj.csv index 5ee5e9d6f919..6ece7b010e7c 100644 --- a/qadevOOo/objdsc/sc/com.sun.star.comp.office.ScTableValidationObj.csv +++ b/qadevOOo/objdsc/sc/com.sun.star.comp.office.ScTableValidationObj.csv @@ -1,11 +1,3 @@ -"ScTableValidationObj";"com::sun::star::sheet::XSheetCondition";"getOperator()" -"ScTableValidationObj";"com::sun::star::sheet::XSheetCondition";"setOperator()" -"ScTableValidationObj";"com::sun::star::sheet::XSheetCondition";"getFormula1()" -"ScTableValidationObj";"com::sun::star::sheet::XSheetCondition";"setFormula1()" -"ScTableValidationObj";"com::sun::star::sheet::XSheetCondition";"getFormula2()" -"ScTableValidationObj";"com::sun::star::sheet::XSheetCondition";"setFormula2()" -"ScTableValidationObj";"com::sun::star::sheet::XSheetCondition";"getSourcePosition()" -"ScTableValidationObj";"com::sun::star::sheet::XSheetCondition";"setSourcePosition()" "ScTableValidationObj";"com::sun::star::sheet::TableValidation";"Type" "ScTableValidationObj";"com::sun::star::sheet::TableValidation";"ShowInputMessage" "ScTableValidationObj";"com::sun::star::sheet::TableValidation";"InputTitle" diff --git a/qadevOOo/tests/java/ifc/sheet/_XSheetCondition.java b/qadevOOo/tests/java/ifc/sheet/_XSheetCondition.java deleted file mode 100644 index 79a287b20917..000000000000 --- a/qadevOOo/tests/java/ifc/sheet/_XSheetCondition.java +++ /dev/null @@ -1,149 +0,0 @@ -/* - * This file is part of the LibreOffice project. - * - * This Source Code Form is subject to the terms of the Mozilla Public - * License, v. 2.0. If a copy of the MPL was not distributed with this - * file, You can obtain one at http://mozilla.org/MPL/2.0/. - * - * This file incorporates work covered by the following license notice: - * - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed - * with this work for additional information regarding copyright - * ownership. The ASF licenses this file to you under the Apache - * License, Version 2.0 (the "License"); you may not use this file - * except in compliance with the License. You may obtain a copy of - * the License at http://www.apache.org/licenses/LICENSE-2.0 . - */ - -package ifc.sheet; - -import lib.MultiMethodTest; -import util.ValueChanger; - -import com.sun.star.sheet.ConditionOperator; -import com.sun.star.sheet.XSheetCondition; -import com.sun.star.table.CellAddress; - -/** -* Testing <code>com.sun.star.sheet.XSheetCondition</code> -* interface methods : -* <ul> -* <li><code> getOperator()</code></li> -* <li><code> setOperator()</code></li> -* <li><code> getFormula1()</code></li> -* <li><code> setFormula1()</code></li> -* <li><code> getFormula2()</code></li> -* <li><code> setFormula2()</code></li> -* <li><code> getSourcePosition()</code></li> -* <li><code> setSourcePosition()</code></li> -* </ul> <p> -* @see com.sun.star.sheet.XSheetCondition -*/ -public class _XSheetCondition extends MultiMethodTest { - public XSheetCondition oObj = null; - public String Formula1 = null; - public String Formula2 = null; - public ConditionOperator Operator = null; - public CellAddress SourcePosition = null; - - /** - * Test calls the method, checks and stores returned value. <p> - * Has <b> OK </b> status if returned vakue isn't null. <p> - */ - public void _getFormula1() { - Formula1 = oObj.getFormula1(); - tRes.tested("getFormula1()", Formula1 != null); - } - - /** - * Test calls the method, checks and stores returned value. <p> - * Has <b> OK </b> status if returned vakue isn't null. <p> - */ - public void _getFormula2() { - Formula2 = oObj.getFormula2(); - tRes.tested("getFormula2()", Formula2 != null); - } - - /** - * Test calls the method, checks and stores returned value. <p> - * Has <b> OK </b> status if returned vakue isn't null. <p> - */ - public void _getOperator() { - Operator = oObj.getOperator(); - tRes.tested("getOperator()", Operator != null); - } - - /** - * Test calls the method, checks and stores returned value. <p> - * Has <b> OK </b> status if returned vakue isn't null. <p> - */ - public void _getSourcePosition() { - SourcePosition = oObj.getSourcePosition(); - tRes.tested("getSourcePosition()", SourcePosition != null); - } - - /** - * Test sets new value of formula1, gets formula1 again and compares - * returned value with value that was stored by method - * <code>getFormula1()</code>. <p> - * Has <b> OK </b> status if values aren't equal. <p> - * The following method tests are to be completed successfully before : - * <ul> - * <li> <code> getFormula1() </code> : to have value of 'Formula1' </li> - * </ul> - */ - public void _setFormula1() { - requiredMethod("getFormula1()"); - oObj.setFormula1("$Sheet1.$C$" + Thread.activeCount()); - tRes.tested("setFormula1()", !Formula1.equals( oObj.getFormula1() ) ); - } - - /** - * Test sets new value of formula2, gets formula2 again and compares - * returned value with value that was stored by method - * <code>getFormula2()</code>. <p> - * Has <b> OK </b> status if values aren't equal. <p> - * The following method tests are to be completed successfully before : - * <ul> - * <li> <code> getFormula2() </code> : to have value of 'Formula2' </li> - * </ul> - */ - public void _setFormula2() { - requiredMethod("getFormula2()"); - oObj.setFormula2("$Sheet1.$A$" + Thread.activeCount()); - tRes.tested("setFormula2()", !Formula2.equals( oObj.getFormula2() ) ); - } - - /** - * Test sets new value of operator, gets operator and compares - * returned value with value that was set. <p> - * Has <b> OK </b> status if values aren't equal. <p> - */ - public void _setOperator() { - oObj.setOperator(ConditionOperator.BETWEEN); - tRes.tested("setOperator()", !Operator.equals( oObj.getOperator() ) ); - } - - /** - * Test change value that was stored by method - * <code>getSourcePosition()</code>, sets this new value, gets source - * position again and compares returned value with value that was set. <p> - * Has <b> OK </b> status if values aren't equal. <p> - * The following method tests are to be completed successfully before : - * <ul> - * <li> <code> getSourcePosition() </code> : to have value of source - * position </li> - * </ul> - */ - public void _setSourcePosition() { - requiredMethod("getSourcePosition()"); - oObj.setSourcePosition( - (CellAddress)ValueChanger.changePValue(SourcePosition)); - tRes.tested( - "setSourcePosition()", - !SourcePosition.equals( oObj.getSourcePosition() ) ); - } - -} // finish class _XSheetCondition - diff --git a/sc/CppunitTest_sc_tableconditionalentryobj.mk b/sc/CppunitTest_sc_tableconditionalentryobj.mk new file mode 100644 index 000000000000..b5e981ea9250 --- /dev/null +++ b/sc/CppunitTest_sc_tableconditionalentryobj.mk @@ -0,0 +1,105 @@ +# -*- Mode: makefile-gmake; tab-width: 4; indent-tabs-mode: t -*- +#************************************************************************* +# +# This file is part of the LibreOffice project. +# +# This Source Code Form is subject to the terms of the Mozilla Public +# License, v. 2.0. If a copy of the MPL was not distributed with this +# file, You can obtain one at http://mozilla.org/MPL/2.0/. +# +#************************************************************************* + +$(eval $(call gb_CppunitTest_CppunitTest,sc_tableconditionalentryobj)) + +$(eval $(call gb_CppunitTest_use_external,sc_tableconditionalentryobj,boost_headers)) + +$(eval $(call gb_CppunitTest_add_exception_objects,sc_tableconditionalentryobj, \ + sc/qa/extras/sctableconditionalentryobj \ +)) + +$(eval $(call gb_CppunitTest_use_libraries,sc_tableconditionalentryobj, \ + basegfx \ + comphelper \ + cppu \ + cppuhelper \ + drawinglayer \ + editeng \ + for \ + forui \ + i18nlangtag \ + msfilter \ + oox \ + sal \ + salhelper \ + sax \ + sb \ + sc \ + sfx \ + sot \ + subsequenttest \ + svl \ + svt \ + svx \ + svxcore \ + test \ + tk \ + tl \ + ucbhelper \ + unotest \ + utl \ + vbahelper \ + vcl \ + xo \ +)) + +$(eval $(call gb_CppunitTest_set_include,sc_tableconditionalentryobj,\ + -I$(SRCDIR)/sc/source/ui/inc \ + -I$(SRCDIR)/sc/inc \ + $$(INCLUDE) \ +)) + +$(eval $(call gb_CppunitTest_use_sdk_api,sc_tableconditionalentryobj)) + +$(eval $(call gb_CppunitTest_use_ure,sc_tableconditionalentryobj)) +$(eval $(call gb_CppunitTest_use_vcl,sc_tableconditionalentryobj)) + +$(eval $(call gb_CppunitTest_use_components,sc_tableconditionalentryobj,\ + basic/util/sb \ + comphelper/util/comphelp \ + configmgr/source/configmgr \ + dbaccess/util/dba \ + filter/source/config/cache/filterconfig1 \ + filter/source/storagefilterdetect/storagefd \ + forms/util/frm \ + framework/util/fwk \ + i18npool/util/i18npool \ + linguistic/source/lng \ + oox/util/oox \ + package/source/xstor/xstor \ + package/util/package2 \ + sax/source/expatwrap/expwrap \ + scripting/source/basprov/basprov \ + scripting/util/scriptframe \ + sc/util/sc \ + sc/util/scd \ + sc/util/scfilt \ + $(call gb_Helper_optional,SCRIPTING, \ + sc/util/vbaobj) \ + sfx2/util/sfx \ + sot/util/sot \ + svl/source/fsstor/fsstorage \ + toolkit/util/tk \ + ucb/source/core/ucb1 \ + ucb/source/ucp/file/ucpfile1 \ + ucb/source/ucp/tdoc/ucptdoc1 \ + unotools/util/utl \ + unoxml/source/rdf/unordf \ + unoxml/source/service/unoxml \ + uui/util/uui \ + xmloff/util/xo \ + svtools/util/svt \ +)) + +$(eval $(call gb_CppunitTest_use_configuration,sc_tableconditionalentryobj)) + +# vim: set noet sw=4 ts=4: diff --git a/sc/CppunitTest_sc_tablevalidationobj.mk b/sc/CppunitTest_sc_tablevalidationobj.mk new file mode 100644 index 000000000000..c6807558064b --- /dev/null +++ b/sc/CppunitTest_sc_tablevalidationobj.mk @@ -0,0 +1,105 @@ +# -*- Mode: makefile-gmake; tab-width: 4; indent-tabs-mode: t -*- +#************************************************************************* +# +# This file is part of the LibreOffice project. +# +# This Source Code Form is subject to the terms of the Mozilla Public +# License, v. 2.0. If a copy of the MPL was not distributed with this +# file, You can obtain one at http://mozilla.org/MPL/2.0/. +# +#************************************************************************* + +$(eval $(call gb_CppunitTest_CppunitTest,sc_tablevalidationobj)) + +$(eval $(call gb_CppunitTest_use_external,sc_tablevalidationobj,boost_headers)) + +$(eval $(call gb_CppunitTest_add_exception_objects,sc_tablevalidationobj, \ + sc/qa/extras/sctablevalidationobj \ +)) + +$(eval $(call gb_CppunitTest_use_libraries,sc_tablevalidationobj, \ + basegfx \ + comphelper \ + cppu \ + cppuhelper \ + drawinglayer \ + editeng \ + for \ + forui \ + i18nlangtag \ + msfilter \ + oox \ + sal \ + salhelper \ + sax \ + sb \ + sc \ + sfx \ + sot \ + subsequenttest \ + svl \ + svt \ + svx \ + svxcore \ + test \ + tk \ + tl \ + ucbhelper \ + unotest \ + utl \ + vbahelper \ + vcl \ + xo \ +)) + +$(eval $(call gb_CppunitTest_set_include,sc_tablevalidationobj,\ + -I$(SRCDIR)/sc/source/ui/inc \ + -I$(SRCDIR)/sc/inc \ + $$(INCLUDE) \ +)) + +$(eval $(call gb_CppunitTest_use_sdk_api,sc_tablevalidationobj)) + +$(eval $(call gb_CppunitTest_use_ure,sc_tablevalidationobj)) +$(eval $(call gb_CppunitTest_use_vcl,sc_tablevalidationobj)) + +$(eval $(call gb_CppunitTest_use_components,sc_tablevalidationobj,\ + basic/util/sb \ + comphelper/util/comphelp \ + configmgr/source/configmgr \ + dbaccess/util/dba \ + filter/source/config/cache/filterconfig1 \ + filter/source/storagefilterdetect/storagefd \ + forms/util/frm \ + framework/util/fwk \ + i18npool/util/i18npool \ + linguistic/source/lng \ + oox/util/oox \ + package/source/xstor/xstor \ + package/util/package2 \ + sax/source/expatwrap/expwrap \ + scripting/source/basprov/basprov \ + scripting/util/scriptframe \ + sc/util/sc \ + sc/util/scd \ + sc/util/scfilt \ + $(call gb_Helper_optional,SCRIPTING, \ + sc/util/vbaobj) \ + sfx2/util/sfx \ + sot/util/sot \ + svl/source/fsstor/fsstorage \ + toolkit/util/tk \ + ucb/source/core/ucb1 \ + ucb/source/ucp/file/ucpfile1 \ + ucb/source/ucp/tdoc/ucptdoc1 \ + unotools/util/utl \ + unoxml/source/rdf/unordf \ + unoxml/source/service/unoxml \ + uui/util/uui \ + xmloff/util/xo \ + svtools/util/svt \ +)) + +$(eval $(call gb_CppunitTest_use_configuration,sc_tablevalidationobj)) + +# vim: set noet sw=4 ts=4: diff --git a/sc/Module_sc.mk b/sc/Module_sc.mk index 1fba8a97959a..a4886ca0d929 100644 --- a/sc/Module_sc.mk +++ b/sc/Module_sc.mk @@ -134,6 +134,8 @@ $(eval $(call gb_Module_add_subsequentcheck_targets,sc,\ CppunitTest_sc_arealinksobj \ CppunitTest_sc_cellrangesobj \ CppunitTest_sc_filterdescriptorbaseobj \ + CppunitTest_sc_tablevalidationobj \ + CppunitTest_sc_tableconditionalentryobj \ )) $(eval $(call gb_Module_add_perfcheck_targets,sc,\ diff --git a/sc/qa/extras/sctableconditionalentryobj.cxx b/sc/qa/extras/sctableconditionalentryobj.cxx new file mode 100644 index 000000000000..be7432416cf4 --- /dev/null +++ b/sc/qa/extras/sctableconditionalentryobj.cxx @@ -0,0 +1,133 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4; fill-column: 100 -*- */ +/* + * This file is part of the LibreOffice project. + * + * This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. + */ + +#include <test/calc_unoapi_test.hxx> +#include <test/sheet/xsheetcondition.hxx> + +#include <com/sun/star/beans/PropertyValue.hpp> +#include <com/sun/star/beans/XPropertySet.hpp> +#include <com/sun/star/container/XIndexAccess.hpp> +#include <com/sun/star/lang/XComponent.hpp> +#include <com/sun/star/sheet/ConditionOperator.hpp> +#include <com/sun/star/sheet/XSheetConditionalEntry.hpp> +#include <com/sun/star/sheet/XSheetConditionalEntries.hpp> +#include <com/sun/star/sheet/XSpreadsheetDocument.hpp> +#include <com/sun/star/sheet/XSpreadsheets.hpp> +#include <com/sun/star/sheet/XSpreadsheet.hpp> +#include <com/sun/star/table/CellAddress.hpp> + +#include <unonames.hxx> + +#include <com/sun/star/uno/Reference.hxx> +#include <com/sun/star/uno/Sequence.hxx> +#include <com/sun/star/uno/XInterface.hpp> + +using namespace css; +using namespace css::uno; +using namespace com::sun::star; + +namespace sc_apitest { + +#define NUMBER_OF_TESTS 4 + +class ScTableConditionalEntryObj : public CalcUnoApiTest, public apitest::XSheetCondition +{ +public: + ScTableConditionalEntryObj(); + + virtual uno::Reference< uno::XInterface > init() override; + virtual void setUp() override; + virtual void tearDown() override; + + CPPUNIT_TEST_SUITE(ScTableConditionalEntryObj); + + // XSheetCondition + CPPUNIT_TEST(testGetSetFormula1); + CPPUNIT_TEST(testGetSetFormula2); + CPPUNIT_TEST(testGetSetOperator); + CPPUNIT_TEST(testGetSetSourcePosition); + + CPPUNIT_TEST_SUITE_END(); + +private: + static sal_Int32 nTest; + static uno::Reference< lang::XComponent > mxComponent; + +}; + +sal_Int32 ScTableConditionalEntryObj::nTest = 0; +uno::Reference< lang::XComponent > ScTableConditionalEntryObj::mxComponent; + +ScTableConditionalEntryObj::ScTableConditionalEntryObj() + : CalcUnoApiTest("/sc/qa/extras/testdocuments") +{ +} + +uno::Reference< uno::XInterface > ScTableConditionalEntryObj::init() +{ + // create a calc document + if (!mxComponent.is()) + mxComponent = loadFromDesktop("private:factory/scalc"); + + uno::Reference< sheet::XSpreadsheetDocument > xDoc(mxComponent, uno::UNO_QUERY_THROW); + CPPUNIT_ASSERT_MESSAGE("no calc document", xDoc.is()); + + uno::Reference< container::XIndexAccess > xIndex(xDoc->getSheets(), uno::UNO_QUERY_THROW); + uno::Reference< sheet::XSpreadsheet > xSheet(xIndex->getByIndex(0), uno::UNO_QUERY_THROW); + + xSheet->getCellByPosition(5, 5)->setValue(15); + xSheet->getCellByPosition(1, 4)->setValue(10); + xSheet->getCellByPosition(2, 0)->setValue(-5.15); + + uno::Reference< beans::XPropertySet > xPropSet(xSheet, uno::UNO_QUERY_THROW); + uno::Reference< sheet::XSheetConditionalEntries > xSheetConditionalEntries; + xSheetConditionalEntries.set(xPropSet->getPropertyValue(SC_UNONAME_CONDFMT), uno::UNO_QUERY_THROW); + + uno::Sequence< beans::PropertyValue > aPropValue(5); + aPropValue[0].Name = SC_UNONAME_STYLENAME; + aPropValue[0].Value <<= OUString("Result2"); + aPropValue[1].Name = SC_UNONAME_FORMULA1; + aPropValue[1].Value <<= OUString("$Sheet1.$B$5"); + aPropValue[2].Name = SC_UNONAME_FORMULA2; + aPropValue[2].Value <<= OUString(""); + aPropValue[3].Name = SC_UNONAME_OPERATOR; + aPropValue[3].Value <<= sheet::ConditionOperator_EQUAL; + aPropValue[4].Name = SC_UNONAME_SOURCEPOS; + aPropValue[4].Value <<= table::CellAddress(0, 1, 5); + xSheetConditionalEntries->addNew(aPropValue); + + uno::Reference< sheet::XSheetConditionalEntry > xSheetConditionalEntry(xSheetConditionalEntries->getByIndex(0), uno::UNO_QUERY_THROW); + return xSheetConditionalEntry; +} + +void ScTableConditionalEntryObj::setUp() +{ + nTest++; + CPPUNIT_ASSERT(nTest <= NUMBER_OF_TESTS); + CalcUnoApiTest::setUp(); +} + +void ScTableConditionalEntryObj::tearDown() +{ + if (nTest == NUMBER_OF_TESTS) + { + closeDocument(mxComponent); + mxComponent.clear(); + } + + CalcUnoApiTest::tearDown(); +} + +CPPUNIT_TEST_SUITE_REGISTRATION(ScTableConditionalEntryObj); + +} // end namespace + +CPPUNIT_PLUGIN_IMPLEMENT(); + +/* vim:set shiftwidth=4 softtabstop=4 expandtab cinoptions=b1,g0,N-s cinkeys+=0=break: */ diff --git a/sc/qa/extras/sctablevalidationobj.cxx b/sc/qa/extras/sctablevalidationobj.cxx new file mode 100644 index 000000000000..4b6b27622615 --- /dev/null +++ b/sc/qa/extras/sctablevalidationobj.cxx @@ -0,0 +1,113 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4; fill-column: 100 -*- */ +/* + * This file is part of the LibreOffice project. + * + * This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. + */ + +#include <test/calc_unoapi_test.hxx> +#include <test/sheet/xsheetcondition.hxx> + +#include <com/sun/star/beans/XPropertySet.hpp> +#include <com/sun/star/container/XIndexAccess.hpp> +#include <com/sun/star/lang/XComponent.hpp> +#include <com/sun/star/sheet/XSheetCondition.hpp> +#include <com/sun/star/sheet/XSpreadsheetDocument.hpp> +#include <com/sun/star/sheet/XSpreadsheets.hpp> +#include <com/sun/star/sheet/XSpreadsheet.hpp> + +#include <com/sun/star/uno/Reference.hxx> +#include <com/sun/star/uno/Sequence.hxx> +#include <com/sun/star/uno/XInterface.hpp> + +using namespace css; +using namespace css::uno; +using namespace com::sun::star; + +namespace sc_apitest { + +#define NUMBER_OF_TESTS 4 + +class ScTableValidationObj : public CalcUnoApiTest, public apitest::XSheetCondition +{ +public: + ScTableValidationObj(); + + virtual uno::Reference< uno::XInterface > init() override; + virtual void setUp() override; + virtual void tearDown() override; + + CPPUNIT_TEST_SUITE(ScTableValidationObj); + + // XSheetCondition + CPPUNIT_TEST(testGetSetFormula1); + CPPUNIT_TEST(testGetSetFormula2); + CPPUNIT_TEST(testGetSetOperator); + CPPUNIT_TEST(testGetSetSourcePosition); + + CPPUNIT_TEST_SUITE_END(); + +private: + static sal_Int32 nTest; + static uno::Reference< lang::XComponent > mxComponent; + +}; + +sal_Int32 ScTableValidationObj::nTest = 0; +uno::Reference< lang::XComponent > ScTableValidationObj::mxComponent; + +ScTableValidationObj::ScTableValidationObj() + : CalcUnoApiTest("/sc/qa/extras/testdocuments") +{ +} + +uno::Reference< uno::XInterface > ScTableValidationObj::init() +{ + // create a calc document + if (!mxComponent.is()) + mxComponent = loadFromDesktop("private:factory/scalc"); + + uno::Reference< sheet::XSpreadsheetDocument > xDoc(mxComponent, uno::UNO_QUERY_THROW); + CPPUNIT_ASSERT_MESSAGE("no calc document", xDoc.is()); + + uno::Reference< container::XIndexAccess > xIndex(xDoc->getSheets(), uno::UNO_QUERY_THROW); + uno::Reference< sheet::XSpreadsheet > xSheet(xIndex->getByIndex(0), uno::UNO_QUERY_THROW); + + xSheet->getCellByPosition(5, 5)->setValue(15); + xSheet->getCellByPosition(1, 4)->setValue(10); + xSheet->getCellByPosition(2, 0)->setValue(-5.15); + + uno::Reference< beans::XPropertySet > xPropSet(xSheet, uno::UNO_QUERY_THROW); + uno::Reference< sheet::XSheetCondition > xSheetCondition; + CPPUNIT_ASSERT(xPropSet->getPropertyValue("Validation") >>= xSheetCondition); + + return xSheetCondition; +} + +void ScTableValidationObj::setUp() +{ + nTest++; + CPPUNIT_ASSERT(nTest <= NUMBER_OF_TESTS); + CalcUnoApiTest::setUp(); +} + +void ScTableValidationObj::tearDown() +{ + if (nTest == NUMBER_OF_TESTS) + { + closeDocument(mxComponent); + mxComponent.clear(); + } + + CalcUnoApiTest::tearDown(); +} + +CPPUNIT_TEST_SUITE_REGISTRATION(ScTableValidationObj); + +} // end namespace + +CPPUNIT_PLUGIN_IMPLEMENT(); + +/* vim:set shiftwidth=4 softtabstop=4 expandtab cinoptions=b1,g0,N-s cinkeys+=0=break: */ diff --git a/test/Library_subsequenttest.mk b/test/Library_subsequenttest.mk index 90090d55f461..87b7e0ecc7e7 100644 --- a/test/Library_subsequenttest.mk +++ b/test/Library_subsequenttest.mk @@ -70,6 +70,7 @@ $(eval $(call gb_Library_add_exception_objects,subsequenttest,\ test/source/sheet/xsheetannotation \ test/source/sheet/xsheetannotations \ test/source/sheet/xsheetannotationshapesupplier \ + test/source/sheet/xsheetcondition \ test/source/sheet/xsheetfilterable \ test/source/sheet/xsheetfilterdescriptor \ test/source/sheet/xsheetoutline \ diff --git a/test/source/sheet/xsheetcondition.cxx b/test/source/sheet/xsheetcondition.cxx new file mode 100644 index 000000000000..ba7c22ecc436 --- /dev/null +++ b/test/source/sheet/xsheetcondition.cxx @@ -0,0 +1,74 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4; fill-column: 100 -*- */ +/* + * This file is part of the LibreOffice project. + * + * This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. + */ + +#include <test/sheet/xsheetcondition.hxx> + +#include <com/sun/star/sheet/ConditionOperator.hpp> +#include <com/sun/star/sheet/XSheetCondition.hpp> + +#include <com/sun/star/uno/Reference.hxx> +#include <com/sun/star/uno/Sequence.hxx> + +#include <cppunit/extensions/HelperMacros.h> + +using namespace com::sun::star; +using namespace com::sun::star::uno; + +namespace apitest { + +void XSheetCondition::testGetSetFormula1() +{ + uno::Reference< sheet::XSheetCondition > xSheetCondition(init(), UNO_QUERY_THROW); + OUString aFormula1; + CPPUNIT_ASSERT_NO_THROW_MESSAGE("Unable to get Formula1", + aFormula1 = xSheetCondition->getFormula1()); + + xSheetCondition->setFormula1("$Sheet1.$C$"); + CPPUNIT_ASSERT_MESSAGE("Unable to set Formula1", aFormula1 != xSheetCondition->getFormula1()); +} + +void XSheetCondition::testGetSetFormula2() +{ + uno::Reference< sheet::XSheetCondition > xSheetCondition(init(), UNO_QUERY_THROW); + OUString aFormula2; + CPPUNIT_ASSERT_NO_THROW_MESSAGE("Unable to get Formula2", + aFormula2 = xSheetCondition->getFormula2()); + + xSheetCondition->setFormula2("$Sheet1.$A$"); + CPPUNIT_ASSERT_MESSAGE("Unable to set Formula2", aFormula2 != xSheetCondition->getFormula2()); +} + +void XSheetCondition::testGetSetOperator() +{ + uno::Reference< sheet::XSheetCondition > xSheetCondition(init(), UNO_QUERY_THROW); + sheet::ConditionOperator aOperator = sheet::ConditionOperator_NONE; + CPPUNIT_ASSERT_NO_THROW_MESSAGE("Unable to get Operator", + aOperator = xSheetCondition->getOperator()); + + xSheetCondition->setOperator( sheet::ConditionOperator_BETWEEN ); + sheet::ConditionOperator aOperatorNew = xSheetCondition->getOperator(); + CPPUNIT_ASSERT_MESSAGE("Unable to set Operator", aOperator != aOperatorNew); +} + +void XSheetCondition::testGetSetSourcePosition() +{ + uno::Reference< sheet::XSheetCondition > xSheetCondition(init(), UNO_QUERY_THROW); + table::CellAddress aSourcePosition(0, 0, 0); + CPPUNIT_ASSERT_NO_THROW_MESSAGE("Unable to get SourcePosition", + aSourcePosition = xSheetCondition->getSourcePosition()); + + xSheetCondition->setSourcePosition(table::CellAddress(0, 1, 1)); + table::CellAddress aSourcePositionNew = xSheetCondition->getSourcePosition(); + CPPUNIT_ASSERT_MESSAGE("Unable to set SourcePosition", + aSourcePosition.Row != aSourcePositionNew.Row); +} + +} + +/* vim:set shiftwidth=4 softtabstop=4 expandtab cinoptions=b1,g0,N-s cinkeys+=0=break: */ |