diff options
-rw-r--r-- | include/test/sheet/xdatabaseranges.hxx | 34 | ||||
-rw-r--r-- | qadevOOo/Jar_OOoRunner.mk | 1 | ||||
-rw-r--r-- | qadevOOo/objdsc/sc/com.sun.star.comp.office.ScDatabaseRangesObj.csv | 2 | ||||
-rw-r--r-- | qadevOOo/tests/java/ifc/sheet/_XDatabaseRanges.java | 112 | ||||
-rw-r--r-- | sc/CppunitTest_sc_databaserangesobj.mk | 105 | ||||
-rw-r--r-- | sc/Module_sc.mk | 1 | ||||
-rw-r--r-- | sc/qa/extras/scdatabaserangesobj.cxx | 102 | ||||
-rw-r--r-- | test/Library_subsequenttest.mk | 1 | ||||
-rw-r--r-- | test/source/sheet/xdatabaseranges.cxx | 47 |
9 files changed, 290 insertions, 115 deletions
diff --git a/include/test/sheet/xdatabaseranges.hxx b/include/test/sheet/xdatabaseranges.hxx new file mode 100644 index 000000000000..b42e6fcc93cf --- /dev/null +++ b/include/test/sheet/xdatabaseranges.hxx @@ -0,0 +1,34 @@ +/* -*- 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_XDATABASERANGES_HXX +#define INCLUDED_TEST_SHEET_XDATABASERANGES_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 XDatabaseRanges +{ +public: + virtual css::uno::Reference<css::uno::XInterface> init() = 0; + + void testAddRemoveDbRanges(); + +protected: + ~XDatabaseRanges() {} +}; +} + +#endif // INCLUDED_TEST_SHEET_XDATABASERANGES_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 bf717ebb1f37..abd1b2efdf3e 100644 --- a/qadevOOo/Jar_OOoRunner.mk +++ b/qadevOOo/Jar_OOoRunner.mk @@ -595,7 +595,6 @@ $(eval $(call gb_Jar_add_sourcefiles,OOoRunner,\ qadevOOo/tests/java/ifc/sheet/_XCellRangesQuery \ qadevOOo/tests/java/ifc/sheet/_XConsolidatable \ qadevOOo/tests/java/ifc/sheet/_XConsolidationDescriptor \ - qadevOOo/tests/java/ifc/sheet/_XDatabaseRanges \ qadevOOo/tests/java/ifc/sheet/_XDDELink \ qadevOOo/tests/java/ifc/sheet/_XDocumentAuditing \ qadevOOo/tests/java/ifc/sheet/_XEnhancedMouseClickBroadcaster \ diff --git a/qadevOOo/objdsc/sc/com.sun.star.comp.office.ScDatabaseRangesObj.csv b/qadevOOo/objdsc/sc/com.sun.star.comp.office.ScDatabaseRangesObj.csv index 6b8b71e47fb2..b96b85557d70 100644 --- a/qadevOOo/objdsc/sc/com.sun.star.comp.office.ScDatabaseRangesObj.csv +++ b/qadevOOo/objdsc/sc/com.sun.star.comp.office.ScDatabaseRangesObj.csv @@ -3,8 +3,6 @@ "ScDatabaseRangesObj";"com::sun::star::container::XNameAccess";"hasByName()" "ScDatabaseRangesObj";"com::sun::star::container::XIndexAccess";"getCount()" "ScDatabaseRangesObj";"com::sun::star::container::XIndexAccess";"getByIndex()" -"ScDatabaseRangesObj";"com::sun::star::sheet::XDatabaseRanges";"addNewByName()" -"ScDatabaseRangesObj";"com::sun::star::sheet::XDatabaseRanges";"removeByName()" "ScDatabaseRangesObj";"com::sun::star::container::XElementAccess";"getElementType()" "ScDatabaseRangesObj";"com::sun::star::container::XElementAccess";"hasElements()" "ScDatabaseRangesObj";"com::sun::star::container::XEnumerationAccess";"createEnumeration()" diff --git a/qadevOOo/tests/java/ifc/sheet/_XDatabaseRanges.java b/qadevOOo/tests/java/ifc/sheet/_XDatabaseRanges.java deleted file mode 100644 index a58fb1f968aa..000000000000 --- a/qadevOOo/tests/java/ifc/sheet/_XDatabaseRanges.java +++ /dev/null @@ -1,112 +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.sheet.XDatabaseRanges; -import com.sun.star.table.CellRangeAddress; - -/** -* Testing <code>com.sun.star.sheet.XDatabaseRanges</code> -* interface methods : -* <ul> -* <li><code> addNewByName()</code></li> -* <li><code> removeByName()</code></li> -* </ul> <p> -* @see com.sun.star.sheet.XDatabaseRanges -*/ -public class _XDatabaseRanges extends MultiMethodTest { - - public XDatabaseRanges oObj = null; - CellRangeAddress CRA = null; - String name = null; - - /** - * Test adds a new database range to the collection, checks that range with - * this name exist in collection and then tries to add range with the same - * name. <p> - * Has <b> OK </b> status if the added range exists in collection and - * exception was thrown when trying to add range with name that is same as name - * of existent range. <p> - */ - public void _addNewByName() { - boolean bResult = true; - log.println("Trying to add range with proper name."); - - CRA = new CellRangeAddress((short)0, 1, 2, 3, 4); - name = "_XDatabaseRanges_addNewByRange"; - - oObj.addNewByName(name, CRA); - - bResult &= oObj.hasByName(name); - - if (bResult) log.println("Ok"); - log.println("Trying to add existing element."); - - try { - oObj.addNewByName(name, CRA); - log.println("Exception expected... Test failed."); - bResult = false; - } catch(com.sun.star.uno.RuntimeException e) { - log.println("Exception occurred while testing addNewByName() : " + e); - bResult = true; - } - - tRes.tested("addNewByName()", bResult); - } - - /** - * Test removes the database range with name that exist exactly and then - * tries to remove the range with name that doesn't exist exactly. <p> - * Has <b> OK </b> status if first range was successfully removed and - * exception was thrown when trying to remove non-existent database range.<p> - * The following method tests are to be completed successfully before : - * <ul> - * <li> <code> addNewByName() </code> : to have definitely existed database - * range </li> - * </ul> - */ - public void _removeByName(){ - boolean bResult = true; - requiredMethod("addNewByName()"); - - log.println("Remove inserted element."); - - try { - oObj.removeByName(name); - bResult &= !oObj.hasByName(name); - } catch (com.sun.star.uno.RuntimeException e) { - log.println("Exception occurred while testing removeByName() : " + e); - bResult = false; - } - - log.println("OK.\nTrying to remove unexistant element."); - - try { - oObj.removeByName(name); - log.println("Exception expected... - FAILED"); - bResult = false; - } catch (com.sun.star.uno.RuntimeException e) { - log.println("Expected exception. - OK : " + e); - } - tRes.tested("removeByName()", bResult); - } -} - diff --git a/sc/CppunitTest_sc_databaserangesobj.mk b/sc/CppunitTest_sc_databaserangesobj.mk new file mode 100644 index 000000000000..7b363575a896 --- /dev/null +++ b/sc/CppunitTest_sc_databaserangesobj.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_databaserangesobj)) + +$(eval $(call gb_CppunitTest_use_external,sc_databaserangesobj,boost_headers)) + +$(eval $(call gb_CppunitTest_add_exception_objects,sc_databaserangesobj, \ + sc/qa/extras/scdatabaserangesobj \ +)) + +$(eval $(call gb_CppunitTest_use_libraries,sc_databaserangesobj, \ + 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_databaserangesobj,\ + -I$(SRCDIR)/sc/source/ui/inc \ + -I$(SRCDIR)/sc/inc \ + $$(INCLUDE) \ +)) + +$(eval $(call gb_CppunitTest_use_sdk_api,sc_databaserangesobj)) + +$(eval $(call gb_CppunitTest_use_ure,sc_databaserangesobj)) +$(eval $(call gb_CppunitTest_use_vcl,sc_databaserangesobj)) + +$(eval $(call gb_CppunitTest_use_components,sc_databaserangesobj,\ + 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_databaserangesobj)) + +# vim: set noet sw=4 ts=4: diff --git a/sc/Module_sc.mk b/sc/Module_sc.mk index 53d744397818..9c8eceba8bd1 100644 --- a/sc/Module_sc.mk +++ b/sc/Module_sc.mk @@ -145,6 +145,7 @@ $(eval $(call gb_Module_add_subsequentcheck_targets,sc,\ CppunitTest_sc_recentfunctionsobj \ CppunitTest_sc_functionlistobj \ CppunitTest_sc_datapilottablesobj \ + CppunitTest_sc_databaserangesobj \ )) $(eval $(call gb_Module_add_perfcheck_targets,sc,\ diff --git a/sc/qa/extras/scdatabaserangesobj.cxx b/sc/qa/extras/scdatabaserangesobj.cxx new file mode 100644 index 000000000000..8c7f14890927 --- /dev/null +++ b/sc/qa/extras/scdatabaserangesobj.cxx @@ -0,0 +1,102 @@ +/* -*- 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/xdatabaseranges.hxx> + +#include <com/sun/star/beans/XPropertySet.hpp> +#include <com/sun/star/lang/XComponent.hpp> +#include <com/sun/star/sheet/XDatabaseRanges.hpp> +#include <com/sun/star/sheet/XSpreadsheetDocument.hpp> +#include <com/sun/star/table/CellRangeAddress.hpp> +#include <com/sun/star/uno/XInterface.hpp> + +#include <com/sun/star/uno/Reference.hxx> + +using namespace css; +using namespace css::uno; +using namespace com::sun::star; + +namespace sc_apitest +{ +#define NUMBER_OF_TESTS 1 + +class ScDatabaseRangesObj : public CalcUnoApiTest, public apitest::XDatabaseRanges +{ +public: + ScDatabaseRangesObj(); + + virtual uno::Reference<uno::XInterface> init() override; + virtual void setUp() override; + virtual void tearDown() override; + + CPPUNIT_TEST_SUITE(ScDatabaseRangesObj); + + // XDatabaseRanges + CPPUNIT_TEST(testAddRemoveDbRanges); + + CPPUNIT_TEST_SUITE_END(); + +private: + static sal_Int32 nTest; + static uno::Reference<lang::XComponent> mxComponent; +}; + +sal_Int32 ScDatabaseRangesObj::nTest = 0; +uno::Reference<lang::XComponent> ScDatabaseRangesObj::mxComponent; + +ScDatabaseRangesObj::ScDatabaseRangesObj() + : CalcUnoApiTest("/sc/qa/extras/testdocuments") +{ +} + +uno::Reference<uno::XInterface> ScDatabaseRangesObj::init() +{ + // create a calc document + if (!mxComponent.is()) + mxComponent = loadFromDesktop("private:factory/scalc"); + CPPUNIT_ASSERT_MESSAGE("no calc document", mxComponent.is()); + + uno::Reference<sheet::XSpreadsheetDocument> xDoc(mxComponent, UNO_QUERY_THROW); + uno::Reference<beans::XPropertySet> xPropSet(xDoc, UNO_QUERY_THROW); + + uno::Reference<sheet::XDatabaseRanges> xDbRanges(xPropSet->getPropertyValue("DatabaseRanges"), + UNO_QUERY_THROW); + + if (!xDbRanges->hasByName("DbRange")) + xDbRanges->addNewByName("DbRange", table::CellRangeAddress(0, 2, 4, 5, 6)); + + return xDbRanges; +} + +void ScDatabaseRangesObj::setUp() +{ + nTest++; + CPPUNIT_ASSERT(nTest <= NUMBER_OF_TESTS); + CalcUnoApiTest::setUp(); +} + +void ScDatabaseRangesObj::tearDown() +{ + if (nTest == NUMBER_OF_TESTS) + { + closeDocument(mxComponent); + mxComponent.clear(); + } + + CalcUnoApiTest::tearDown(); +} + +CPPUNIT_TEST_SUITE_REGISTRATION(ScDatabaseRangesObj); + +} // 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 a03fb5b822f4..e2a8f3f64a09 100644 --- a/test/Library_subsequenttest.mk +++ b/test/Library_subsequenttest.mk @@ -56,6 +56,7 @@ $(eval $(call gb_Library_add_exception_objects,subsequenttest,\ test/source/sheet/xcellseries \ test/source/sheet/xgoalseek \ test/source/sheet/xdatabaserange \ + test/source/sheet/xdatabaseranges \ test/source/sheet/xdatapilotdescriptor \ test/source/sheet/xdatapilotfield \ test/source/sheet/xdatapilotfieldgrouping \ diff --git a/test/source/sheet/xdatabaseranges.cxx b/test/source/sheet/xdatabaseranges.cxx new file mode 100644 index 000000000000..972631014e64 --- /dev/null +++ b/test/source/sheet/xdatabaseranges.cxx @@ -0,0 +1,47 @@ +/* -*- 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 <random> + +#include <test/sheet/xdatabaseranges.hxx> + +#include <com/sun/star/sheet/XDatabaseRanges.hpp> +#include <com/sun/star/table/CellRangeAddress.hpp> +#include <com/sun/star/uno/RuntimeException.hpp> +#include <com/sun/star/uno/Reference.hxx> + +#include <cppunit/extensions/HelperMacros.h> + +using namespace css; +using namespace css::uno; + +namespace apitest +{ +void XDatabaseRanges::testAddRemoveDbRanges() +{ + uno::Reference<sheet::XDatabaseRanges> xDbRanges(init(), UNO_QUERY_THROW); + + xDbRanges->addNewByName("addNewRange", table::CellRangeAddress(0, 1, 2, 3, 4)); + CPPUNIT_ASSERT_MESSAGE("Unable to add new db range", xDbRanges->hasByName("addNewRange")); + + CPPUNIT_ASSERT_THROW_MESSAGE( + "No execption thrown, when adding range with existing name", + xDbRanges->addNewByName("addNewRange", table::CellRangeAddress(0, 1, 2, 3, 4)), + css::uno::RuntimeException); + + xDbRanges->removeByName("addNewRange"); + CPPUNIT_ASSERT_MESSAGE("Unable to remove db range", !xDbRanges->hasByName("addNewRange")); + + CPPUNIT_ASSERT_THROW_MESSAGE("No execption, when removing none-existing range", + xDbRanges->removeByName("addNewRange"), + css::uno::RuntimeException); +} +} + +/* vim:set shiftwidth=4 softtabstop=4 expandtab cinoptions=b1,g0,N-s cinkeys+=0=break: */ |