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>
This commit is contained in:
Jens Carl 2017-11-01 20:30:32 +00:00
parent 8c37402279
commit 2416d69ad4
12 changed files with 572 additions and 166 deletions

View File

@ -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: */

View File

@ -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 \

View File

@ -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()"

1 ScTableConditionalEntry com::sun::star::sheet::XSheetConditionalEntry getStyleName()
2 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()

View File

@ -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"

1 ScTableValidationObj com::sun::star::sheet::XSheetCondition com::sun::star::sheet::TableValidation getOperator() Type
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()
1 ScTableValidationObj com::sun::star::sheet::TableValidation com::sun::star::sheet::TableValidation Type Type
2 ScTableValidationObj com::sun::star::sheet::TableValidation com::sun::star::sheet::TableValidation ShowInputMessage ShowInputMessage
3 ScTableValidationObj com::sun::star::sheet::TableValidation com::sun::star::sheet::TableValidation InputTitle InputTitle

View File

@ -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

View File

@ -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:

View File

@ -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:

View File

@ -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,\

View File

@ -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: */

View File

@ -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: */

View File

@ -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 \

View File

@ -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: */