diff options
author | Jens Carl <j.carl43@gmx.de> | 2017-11-11 09:09:30 +0000 |
---|---|---|
committer | Jens Carl <j.carl43@gmx.de> | 2017-11-12 00:33:20 +0100 |
commit | e2b748e0a4ab7a33dd9ebde1d7f37776dff60c3b (patch) | |
tree | 3f5ce6727c8920e47e22ca36c00c64d19bcd1b3b | |
parent | b73c66597884f03443ee8888cb6c204b78bb6cda (diff) |
tdf#45904 Move _XScenarios Java test to C++
Change-Id: Ie15243714464cf8343fff27507e4b257846cdebd
Reviewed-on: https://gerrit.libreoffice.org/44638
Tested-by: Jenkins <ci@libreoffice.org>
Reviewed-by: Jens Carl <j.carl43@gmx.de>
-rw-r--r-- | include/test/sheet/xscenarios.hxx | 35 | ||||
-rw-r--r-- | qadevOOo/Jar_OOoRunner.mk | 1 | ||||
-rw-r--r-- | qadevOOo/objdsc/sc/com.sun.star.comp.office.ScScenariosObj.csv | 2 | ||||
-rw-r--r-- | qadevOOo/tests/java/ifc/sheet/_XScenarios.java | 79 | ||||
-rw-r--r-- | sc/CppunitTest_sc_scenariosobj.mk | 105 | ||||
-rw-r--r-- | sc/Module_sc.mk | 1 | ||||
-rw-r--r-- | sc/qa/extras/scscenariosobj.cxx | 120 | ||||
-rw-r--r-- | test/Library_subsequenttest.mk | 1 | ||||
-rw-r--r-- | test/source/sheet/xscenarios.cxx | 44 |
9 files changed, 306 insertions, 82 deletions
diff --git a/include/test/sheet/xscenarios.hxx b/include/test/sheet/xscenarios.hxx new file mode 100644 index 000000000000..f890a5030f49 --- /dev/null +++ b/include/test/sheet/xscenarios.hxx @@ -0,0 +1,35 @@ +/* -*- 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/. + */ + +#ifndef INCLUDED_TEST_SHEET_XSCENARIOS_HXX +#define INCLUDED_TEST_SHEET_XSCENARIOS_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 XScenarios +{ +public: + virtual css::uno::Reference<css::uno::XInterface> init() = 0; + + void testAddNewByName(); + void testRemoveByName(); + +protected: + ~XScenarios() {} +}; +} + +#endif // INCLUDED_TEST_SHEET_XSCENARIOS_HXX + +/* vim:set shiftwidth=4 softtabstop=4 expandtab cinoptions=b1,g0,N-s cinkeys+=0=break: */ diff --git a/qadevOOo/Jar_OOoRunner.mk b/qadevOOo/Jar_OOoRunner.mk index 8418c1e65c41..36c651d375f3 100644 --- a/qadevOOo/Jar_OOoRunner.mk +++ b/qadevOOo/Jar_OOoRunner.mk @@ -612,7 +612,6 @@ $(eval $(call gb_Jar_add_sourcefiles,OOoRunner,\ qadevOOo/tests/java/ifc/sheet/_XRecentFunctions \ qadevOOo/tests/java/ifc/sheet/_XScenario \ qadevOOo/tests/java/ifc/sheet/_XScenarioEnhanced \ - qadevOOo/tests/java/ifc/sheet/_XScenarios \ qadevOOo/tests/java/ifc/sheet/_XScenariosSupplier \ qadevOOo/tests/java/ifc/sheet/_XSheetAnnotationAnchor \ qadevOOo/tests/java/ifc/sheet/_XSheetAnnotationsSupplier \ diff --git a/qadevOOo/objdsc/sc/com.sun.star.comp.office.ScScenariosObj.csv b/qadevOOo/objdsc/sc/com.sun.star.comp.office.ScScenariosObj.csv index 4e88b9a6ae7a..6e1065e5bba4 100644 --- a/qadevOOo/objdsc/sc/com.sun.star.comp.office.ScScenariosObj.csv +++ b/qadevOOo/objdsc/sc/com.sun.star.comp.office.ScScenariosObj.csv @@ -3,8 +3,6 @@ "ScScenariosObj";"com::sun::star::container::XNameAccess";"hasByName()" "ScScenariosObj";"com::sun::star::container::XIndexAccess";"getCount()" "ScScenariosObj";"com::sun::star::container::XIndexAccess";"getByIndex()" -"ScScenariosObj";"com::sun::star::sheet::XScenarios";"addNewByName()" -"ScScenariosObj";"com::sun::star::sheet::XScenarios";"removeByName()" "ScScenariosObj";"com::sun::star::container::XElementAccess";"getElementType()" "ScScenariosObj";"com::sun::star::container::XElementAccess";"hasElements()" "ScScenariosObj";"com::sun::star::container::XEnumerationAccess";"createEnumeration()" diff --git a/qadevOOo/tests/java/ifc/sheet/_XScenarios.java b/qadevOOo/tests/java/ifc/sheet/_XScenarios.java deleted file mode 100644 index 447c627b52e8..000000000000 --- a/qadevOOo/tests/java/ifc/sheet/_XScenarios.java +++ /dev/null @@ -1,79 +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 lib.Status; -import lib.StatusException; - -import com.sun.star.sheet.XScenarios; -import com.sun.star.table.CellRangeAddress; - -/** -* Testing <code>com.sun.star.sheet.XScenarios</code> -* interface methods : -* <ul> -* <li><code> addNewByName()</code></li> -* <li><code> removeByName()</code></li> -* </ul> <p> -* This test needs the following object relations : -* <ul> -* <li> <code>'ADDR'</code> (of type <code>CellRangeAddress[]</code>): -* the array of cell range addresses for adding new scenario </li> -* <ul> <p> -* @see com.sun.star.sheet.XScenarios -*/ -public class _XScenarios extends MultiMethodTest { - - public XScenarios oObj = null; - - /** - * Test adds new scenario, stores name of this scenario and checks that - * scenario with this name is present in collection. <p> - * Has <b> OK </b> status if the new scenario is present in collection. <p> - */ - public void _addNewByName() { - CellRangeAddress[] oAddr = (CellRangeAddress[]) - tEnv.getObjRelation("ADDR"); - if (oAddr == null) throw new StatusException(Status.failed - ("Relation 'ADDR' not found")); - - oObj.addNewByName("XScenarios", oAddr, "new"); - tRes.tested("addNewByName()",oObj.hasByName("XScenarios")); - } - - /** - * Test removes the scenario with stored name and checks that scenario - * with this name isn't present in collection. <p> - * Has <b> OK </b> status if the scenario with stored name isn't present in - * collection after it was removed. <p> - * The following method tests are to be completed successfully before : - * <ul> - * <li> <code> addNewByName() </code> : to have name of the scenario </li> - * </ul> - */ - public void _removeByName() { - requiredMethod("addNewByName()"); - oObj.removeByName("XScenarios"); - tRes.tested("removeByName()",!oObj.hasByName("XScenarios")); - } - - -} // EOC _XScenarios - diff --git a/sc/CppunitTest_sc_scenariosobj.mk b/sc/CppunitTest_sc_scenariosobj.mk new file mode 100644 index 000000000000..65c6f5e984e0 --- /dev/null +++ b/sc/CppunitTest_sc_scenariosobj.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_scenariosobj)) + +$(eval $(call gb_CppunitTest_use_external,sc_scenariosobj,boost_headers)) + +$(eval $(call gb_CppunitTest_add_exception_objects,sc_scenariosobj, \ + sc/qa/extras/scscenariosobj \ +)) + +$(eval $(call gb_CppunitTest_use_libraries,sc_scenariosobj, \ + 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_scenariosobj,\ + -I$(SRCDIR)/sc/source/ui/inc \ + -I$(SRCDIR)/sc/inc \ + $$(INCLUDE) \ +)) + +$(eval $(call gb_CppunitTest_use_sdk_api,sc_scenariosobj)) + +$(eval $(call gb_CppunitTest_use_ure,sc_scenariosobj)) +$(eval $(call gb_CppunitTest_use_vcl,sc_scenariosobj)) + +$(eval $(call gb_CppunitTest_use_components,sc_scenariosobj,\ + 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_scenariosobj)) + +# vim: set noet sw=4 ts=4: diff --git a/sc/Module_sc.mk b/sc/Module_sc.mk index 1879ca435abf..c2c58bda92f1 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_tablevalidationobj \ CppunitTest_sc_tableconditionalentryobj \ CppunitTest_sc_tableconditionalformatobj \ + CppunitTest_sc_scenariosobj \ )) $(eval $(call gb_Module_add_perfcheck_targets,sc,\ diff --git a/sc/qa/extras/scscenariosobj.cxx b/sc/qa/extras/scscenariosobj.cxx new file mode 100644 index 000000000000..5f3533785103 --- /dev/null +++ b/sc/qa/extras/scscenariosobj.cxx @@ -0,0 +1,120 @@ +/* -*- 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/xscenarios.hxx> + +#include <com/sun/star/container/XIndexAccess.hpp> +#include <com/sun/star/lang/XComponent.hpp> +#include <com/sun/star/sheet/XCellRangeAddressable.hpp> +#include <com/sun/star/sheet/XScenariosSupplier.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/XCellRange.hpp> +#include <com/sun/star/table/CellRangeAddress.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 2 + +class ScScenariosObj : public CalcUnoApiTest, public apitest::XScenarios +{ +public: + ScScenariosObj(); + + virtual uno::Reference<uno::XInterface> init() override; + virtual void setUp() override; + virtual void tearDown() override; + + CPPUNIT_TEST_SUITE(ScScenariosObj); + + // XScenarios + CPPUNIT_TEST(testAddNewByName); + CPPUNIT_TEST(testRemoveByName); + + CPPUNIT_TEST_SUITE_END(); + +private: + static sal_Int32 nTest; + static uno::Reference<lang::XComponent> mxComponent; +}; + +sal_Int32 ScScenariosObj::nTest = 0; +uno::Reference<lang::XComponent> ScScenariosObj::mxComponent; + +ScScenariosObj::ScScenariosObj() + : CalcUnoApiTest("/sc/qa/extras/testdocuments") +{ +} + +uno::Reference<uno::XInterface> ScScenariosObj::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<table::XCellRange> xCellRange(xSheet, uno::UNO_QUERY_THROW); + uno::Reference<table::XCellRange> xCellRange2 = xCellRange->getCellRangeByName("A1:N4"); + uno::Reference<sheet::XCellRangeAddressable> xCRAddressable(xCellRange2, uno::UNO_QUERY_THROW); + table::CellRangeAddress aCellRangeAddr = xCRAddressable->getRangeAddress(); + + uno::Sequence<table::CellRangeAddress> aCellRangeAddresses(1); + aCellRangeAddresses[0] = aCellRangeAddr; + uno::Reference<sheet::XScenariosSupplier> xSupplier(xSheet, uno::UNO_QUERY_THROW); + xSupplier->getScenarios()->addNewByName("ScScenarios", aCellRangeAddresses, "Range"); + + return xSupplier->getScenarios(); +} + +void ScScenariosObj::setUp() +{ + nTest++; + CPPUNIT_ASSERT(nTest <= NUMBER_OF_TESTS); + CalcUnoApiTest::setUp(); +} + +void ScScenariosObj::tearDown() +{ + if (nTest == NUMBER_OF_TESTS) + { + closeDocument(mxComponent); + mxComponent.clear(); + } + + CalcUnoApiTest::tearDown(); +} + +CPPUNIT_TEST_SUITE_REGISTRATION(ScScenariosObj); + +} // 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 49eab32c01cd..a76bbcf75474 100644 --- a/test/Library_subsequenttest.mk +++ b/test/Library_subsequenttest.mk @@ -63,6 +63,7 @@ $(eval $(call gb_Library_add_exception_objects,subsequenttest,\ test/source/sheet/xnamedrange \ test/source/sheet/xnamedranges \ test/source/sheet/xprintareas \ + test/source/sheet/xscenarios \ test/source/sheet/xspreadsheetdocument \ test/source/sheet/xspreadsheet \ test/source/sheet/xspreadsheets \ diff --git a/test/source/sheet/xscenarios.cxx b/test/source/sheet/xscenarios.cxx new file mode 100644 index 000000000000..e8d007a8a1ff --- /dev/null +++ b/test/source/sheet/xscenarios.cxx @@ -0,0 +1,44 @@ +/* -*- 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/xscenarios.hxx> + +#include <com/sun/star/sheet/XScenarios.hpp> +#include <com/sun/star/table/CellRangeAddress.hpp> +#include <com/sun/star/uno/Reference.hxx> +#include <com/sun/star/uno/Sequence.hxx> + +#include <cppunit/extensions/HelperMacros.h> + +using namespace css; +using namespace css::uno; + +namespace apitest +{ +void XScenarios::testAddNewByName() +{ + uno::Reference<sheet::XScenarios> xScenarios(init(), UNO_QUERY_THROW); + + uno::Sequence<table::CellRangeAddress> aCellRangeAddresses(1); + aCellRangeAddresses[0] = table::CellRangeAddress(0, 0, 0, 0, 0); + + xScenarios->addNewByName("XScenarios2", aCellRangeAddresses, "new"); + CPPUNIT_ASSERT_MESSAGE("Unable to add new XScenario", xScenarios->hasByName("XScenarios2")); +} + +void XScenarios::testRemoveByName() +{ + uno::Reference<sheet::XScenarios> xScenarios(init(), UNO_QUERY_THROW); + + xScenarios->removeByName("XScenarios"); + CPPUNIT_ASSERT_MESSAGE("Unable to remove XScenario", !xScenarios->hasByName("XScenario")); +} +} + +/* vim:set shiftwidth=4 softtabstop=4 expandtab cinoptions=b1,g0,N-s cinkeys+=0=break: */ |