diff options
author | Jens Carl <j.carl43@gmx.de> | 2017-11-01 23:55:50 +0000 |
---|---|---|
committer | Jens Carl <j.carl43@gmx.de> | 2017-11-03 04:09:44 +0100 |
commit | 44e9640748791f602edb22cbc499200283466e1e (patch) | |
tree | cf10452b780bba32740d9072604bfb5ddc99e0d4 | |
parent | 6bddeb4de19685c1ce1a3c1f9bd32cffb6b14bc6 (diff) |
tdf#45904 Move Java _XSheetConditionalEntries test to C++
Change-Id: I96c1b0dc8d6c6b9cc4f8e02ef8c9ca184fb4d6a4
Reviewed-on: https://gerrit.libreoffice.org/44184
Tested-by: Jenkins <ci@libreoffice.org>
Reviewed-by: Jens Carl <j.carl43@gmx.de>
-rw-r--r-- | include/test/sheet/xsheetconditionalentries.hxx | 42 | ||||
-rw-r--r-- | qadevOOo/Jar_OOoRunner.mk | 1 | ||||
-rw-r--r-- | qadevOOo/objdsc/sc/com.sun.star.comp.office.ScTableConditionalFormat.csv | 3 | ||||
-rw-r--r-- | qadevOOo/tests/java/ifc/sheet/_XSheetConditionalEntries.java | 129 | ||||
-rw-r--r-- | sc/CppunitTest_sc_tableconditionalformatobj.mk | 105 | ||||
-rw-r--r-- | sc/Module_sc.mk | 1 | ||||
-rw-r--r-- | sc/qa/extras/sctableconditionalformatobj.cxx | 140 | ||||
-rw-r--r-- | test/Library_subsequenttest.mk | 1 | ||||
-rw-r--r-- | test/source/sheet/xsheetconditionalentries.cxx | 59 |
9 files changed, 348 insertions, 133 deletions
diff --git a/include/test/sheet/xsheetconditionalentries.hxx b/include/test/sheet/xsheetconditionalentries.hxx new file mode 100644 index 000000000000..35389cc4ca42 --- /dev/null +++ b/include/test/sheet/xsheetconditionalentries.hxx @@ -0,0 +1,42 @@ +/* -*- 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_XSHEETCONDITIONALENTRIES_HXX +#define INCLUDED_TEST_SHEET_XSHEETCONDITIONALENTRIES_HXX + + +#include <com/sun/star/beans/PropertyValue.hpp> +#include <com/sun/star/uno/XInterface.hpp> + +#include <com/sun/star/uno/Sequence.hxx> +#include <com/sun/star/uno/Reference.hxx> + +#include <test/testdllapi.hxx> + +namespace apitest { + +class OOO_DLLPUBLIC_TEST XSheetConditionalEntries +{ +public: + virtual css::uno::Reference< css::uno::XInterface > init() =0; + virtual css::uno::Sequence< com::sun::star::beans::PropertyValue > createCondition(const sal_Int32 nr) =0; + + void testAddNew(); + void testClear(); + void testRemoveByIndex(); + +protected: + ~XSheetConditionalEntries() {} +}; + +} + +#endif // INCLUDED_TEST_SHEET_XSHEETCONDITIONALENTRIES_HXX + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/qadevOOo/Jar_OOoRunner.mk b/qadevOOo/Jar_OOoRunner.mk index 4af94611e1b9..aa1ca80f0733 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/_XSheetConditionalEntries \ qadevOOo/tests/java/ifc/sheet/_XSheetFilterableEx \ qadevOOo/tests/java/ifc/sheet/_XSpreadsheetView \ qadevOOo/tests/java/ifc/style/_CharacterProperties \ diff --git a/qadevOOo/objdsc/sc/com.sun.star.comp.office.ScTableConditionalFormat.csv b/qadevOOo/objdsc/sc/com.sun.star.comp.office.ScTableConditionalFormat.csv index a20c6c01da35..e8087460e929 100644 --- a/qadevOOo/objdsc/sc/com.sun.star.comp.office.ScTableConditionalFormat.csv +++ b/qadevOOo/objdsc/sc/com.sun.star.comp.office.ScTableConditionalFormat.csv @@ -5,7 +5,4 @@ "ScTableConditionalFormat";"com::sun::star::container::XIndexAccess";"getByIndex()" "ScTableConditionalFormat";"com::sun::star::container::XElementAccess";"getElementType()" "ScTableConditionalFormat";"com::sun::star::container::XElementAccess";"hasElements()" -"ScTableConditionalFormat";"com::sun::star::sheet::XSheetConditionalEntries";"addNew()" -"ScTableConditionalFormat";"com::sun::star::sheet::XSheetConditionalEntries";"removeByIndex()" -"ScTableConditionalFormat";"com::sun::star::sheet::XSheetConditionalEntries";"clear()" "ScTableConditionalFormat";"com::sun::star::container::XEnumerationAccess";"createEnumeration()" diff --git a/qadevOOo/tests/java/ifc/sheet/_XSheetConditionalEntries.java b/qadevOOo/tests/java/ifc/sheet/_XSheetConditionalEntries.java deleted file mode 100644 index fc631d909579..000000000000 --- a/qadevOOo/tests/java/ifc/sheet/_XSheetConditionalEntries.java +++ /dev/null @@ -1,129 +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 com.sun.star.beans.PropertyValue; -import com.sun.star.sheet.ConditionOperator; -import com.sun.star.sheet.XSheetConditionalEntries; -import com.sun.star.table.CellAddress; - -/** -* Testing <code>com.sun.star.sheet.XSheetConditionalEntries</code> -* interface methods : -* <ul> -* <li><code> addNew()</code></li> -* <li><code> removeByIndex()</code></li> -* <li><code> clear()</code></li> -* </ul> <p> -* @see com.sun.star.sheet.XSheetConditionalEntries -*/ -public class _XSheetConditionalEntries extends MultiMethodTest { - public XSheetConditionalEntries oObj = null; - int nNum = 0; - - /** - * Test adds a conditional entry to the format. <p> - * Has <b> OK </b> status if the method successfully returns. <p> - */ - public void _addNew() { - nNum = oObj.getCount(); - oObj.addNew( Conditions(4) ); - boolean res = (nNum + 1) == oObj.getCount(); - - tRes.tested("addNew()", res); - } - - /** - * Test calls the method and checks number of conditional entries in - * collection. <p> - * Has <b> OK </b> status if number of conditional entries in co0llection - * after method call is equal zero. <p> - * The following method tests are to be completed successfully before : - * <ul> - * <li> <code> addNew() </code> : to have one conditional entry in - * collection at least </li> - * </ul> - */ - public void _clear() { - requiredMethod("removeByIndex()"); - oObj.clear(); - int anz = oObj.getCount(); - tRes.tested("clear()", anz == 0); - } - - /** - * Test adds a conditional entry, removes entry with index 0 - * and compares number of entries after adding to number of entries after - * removing. <p> - * Has <b> OK </b> status if number of entries after adding is greater - * than number of entries after removing. <p> - * The following method tests are to be completed successfully before : - * <ul> - * <li> <code> clear() </code> : to be sure that collection hasn't - * elements </li> - * </ul> - */ - public void _removeByIndex() { - requiredMethod("addNew()"); - oObj.removeByIndex(0); - int pastNum = oObj.getCount(); - tRes.tested("removeByIndex()", pastNum == nNum); - } - - /** - * Method creates array of property value for conditional entry using - * passed parameter <code>nr</code>. - * @param nr number of row for conditional entry - */ - protected PropertyValue[] Conditions(int nr) { - PropertyValue[] con = new PropertyValue[5]; - CellAddress ca = new CellAddress(); - ca.Column = 1; - ca.Row = 5; - ca.Sheet = 0; - con[0] = new PropertyValue(); - con[0].Name = "StyleName"; - con[0].Value = "Result2"; - con[1] = new PropertyValue(); - con[1].Name = "Formula1"; - con[1].Value = "$Sheet1.$B$"+nr; - con[2] = new PropertyValue(); - con[2].Name = "Formula2"; - con[2].Value = ""; - con[3] = new PropertyValue(); - con[3].Name = "Operator"; - con[3].Value = ConditionOperator.EQUAL; - con[4] = new PropertyValue(); - con[4].Name = "SourcePosition"; - con[4].Value = ca; - return con; - } - - /** - * Forces object environment recreation. - */ - @Override - protected void after() { - this.disposeEnvironment(); - } -} // finish class _XSheetConditionalEntries - - diff --git a/sc/CppunitTest_sc_tableconditionalformatobj.mk b/sc/CppunitTest_sc_tableconditionalformatobj.mk new file mode 100644 index 000000000000..e55cdc365b0d --- /dev/null +++ b/sc/CppunitTest_sc_tableconditionalformatobj.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_tableconditionalformatobj)) + +$(eval $(call gb_CppunitTest_use_external,sc_tableconditionalformatobj,boost_headers)) + +$(eval $(call gb_CppunitTest_add_exception_objects,sc_tableconditionalformatobj, \ + sc/qa/extras/sctableconditionalformatobj \ +)) + +$(eval $(call gb_CppunitTest_use_libraries,sc_tableconditionalformatobj, \ + 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_tableconditionalformatobj,\ + -I$(SRCDIR)/sc/source/ui/inc \ + -I$(SRCDIR)/sc/inc \ + $$(INCLUDE) \ +)) + +$(eval $(call gb_CppunitTest_use_sdk_api,sc_tableconditionalformatobj)) + +$(eval $(call gb_CppunitTest_use_ure,sc_tableconditionalformatobj)) +$(eval $(call gb_CppunitTest_use_vcl,sc_tableconditionalformatobj)) + +$(eval $(call gb_CppunitTest_use_components,sc_tableconditionalformatobj,\ + 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_tableconditionalformatobj)) + +# vim: set noet sw=4 ts=4: diff --git a/sc/Module_sc.mk b/sc/Module_sc.mk index a4886ca0d929..fab66a9a48c7 100644 --- a/sc/Module_sc.mk +++ b/sc/Module_sc.mk @@ -136,6 +136,7 @@ $(eval $(call gb_Module_add_subsequentcheck_targets,sc,\ CppunitTest_sc_filterdescriptorbaseobj \ CppunitTest_sc_tablevalidationobj \ CppunitTest_sc_tableconditionalentryobj \ + CppunitTest_sc_tableconditionalformatobj \ )) $(eval $(call gb_Module_add_perfcheck_targets,sc,\ diff --git a/sc/qa/extras/sctableconditionalformatobj.cxx b/sc/qa/extras/sctableconditionalformatobj.cxx new file mode 100644 index 000000000000..e8a66552516b --- /dev/null +++ b/sc/qa/extras/sctableconditionalformatobj.cxx @@ -0,0 +1,140 @@ +/* -*- 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/xsheetconditionalentries.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 3 + +class ScTableConditionalFormatObj : public CalcUnoApiTest, + public apitest::XSheetConditionalEntries +{ +public: + ScTableConditionalFormatObj(); + + virtual uno::Reference< uno::XInterface > init() override; + virtual uno::Sequence< beans::PropertyValue > createCondition(const sal_Int32 nr) override; + virtual void setUp() override; + virtual void tearDown() override; + + CPPUNIT_TEST_SUITE(ScTableConditionalFormatObj); + + // XSheetConditionalEntries + CPPUNIT_TEST(testAddNew); + CPPUNIT_TEST(testClear); + CPPUNIT_TEST(testRemoveByIndex); + + CPPUNIT_TEST_SUITE_END(); + +private: + static sal_Int32 nTest; + static uno::Reference< lang::XComponent > mxComponent; + +}; + +sal_Int32 ScTableConditionalFormatObj::nTest = 0; +uno::Reference< lang::XComponent > ScTableConditionalFormatObj::mxComponent; + +ScTableConditionalFormatObj::ScTableConditionalFormatObj() + : CalcUnoApiTest("/sc/qa/extras/testdocuments") +{ +} + +uno::Reference< uno::XInterface > ScTableConditionalFormatObj::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); + + xSheetConditionalEntries->addNew(createCondition(5)); + xSheetConditionalEntries->addNew(createCondition(2)); + + return xSheetConditionalEntries; +} + +uno::Sequence< beans::PropertyValue > ScTableConditionalFormatObj::createCondition(const sal_Int32 nr) +{ + 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 <<= "$Sheet1.$B$" + OUString::number(nr); + 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); + + return aPropValue; +} + +void ScTableConditionalFormatObj::setUp() +{ + nTest++; + CPPUNIT_ASSERT(nTest <= NUMBER_OF_TESTS); + CalcUnoApiTest::setUp(); +} + +void ScTableConditionalFormatObj::tearDown() +{ + if (nTest == NUMBER_OF_TESTS) + { + closeDocument(mxComponent); + mxComponent.clear(); + } + + CalcUnoApiTest::tearDown(); +} + +CPPUNIT_TEST_SUITE_REGISTRATION(ScTableConditionalFormatObj); + +} // 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 21c5881ceca0..e6f0c99e4985 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/xsheetconditionalentries \ test/source/sheet/xsheetconditionalentry \ test/source/sheet/xsheetcondition \ test/source/sheet/xsheetfilterable \ diff --git a/test/source/sheet/xsheetconditionalentries.cxx b/test/source/sheet/xsheetconditionalentries.cxx new file mode 100644 index 000000000000..e22f3b8195e9 --- /dev/null +++ b/test/source/sheet/xsheetconditionalentries.cxx @@ -0,0 +1,59 @@ +/* -*- 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/xsheetconditionalentries.hxx> + +#include <com/sun/star/beans/PropertyValue.hpp> +#include <com/sun/star/table/CellAddress.hpp> +#include <com/sun/star/sheet/ConditionOperator.hpp> +#include <com/sun/star/sheet/XSheetConditionalEntries.hpp> + +#include <com/sun/star/uno/Reference.hxx> + +#include <cppunit/extensions/HelperMacros.h> + +using namespace com::sun::star; +using namespace com::sun::star::uno; + +namespace apitest { + +void XSheetConditionalEntries::testAddNew() +{ + uno::Reference< sheet::XSheetConditionalEntries > xSheetConditionalEntries(init(), UNO_QUERY_THROW); + const sal_Int32 aCount = xSheetConditionalEntries->getCount(); + + xSheetConditionalEntries->addNew(createCondition(4)); + + CPPUNIT_ASSERT_EQUAL_MESSAGE("Unable to add new condition", + aCount + 1, xSheetConditionalEntries->getCount()); + +} + +void XSheetConditionalEntries::testClear() +{ + uno::Reference< sheet::XSheetConditionalEntries > xSheetConditionalEntries(init(), UNO_QUERY_THROW); + xSheetConditionalEntries->clear(); + CPPUNIT_ASSERT_EQUAL_MESSAGE("Unable to clear conditions", + sal_Int32(0), xSheetConditionalEntries->getCount()); +} + +void XSheetConditionalEntries::testRemoveByIndex() +{ + uno::Reference< sheet::XSheetConditionalEntries > xSheetConditionalEntries(init(), UNO_QUERY_THROW); + const sal_Int32 aCount = xSheetConditionalEntries->getCount(); + + xSheetConditionalEntries->removeByIndex(0); + + CPPUNIT_ASSERT_EQUAL_MESSAGE("Unable to remove condition", + aCount - 1, xSheetConditionalEntries->getCount()); +} + +} + +/* vim:set shiftwidth=4 softtabstop=4 expandtab cinoptions=b1,g0,N-s cinkeys+=0=break: */ |