summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--include/test/sheet/xfunctiondescriptions.hxx34
-rw-r--r--qadevOOo/Jar_OOoRunner.mk1
-rw-r--r--qadevOOo/objdsc/sc/com.sun.star.comp.office.ScFunctionListObj.csv1
-rw-r--r--qadevOOo/tests/java/ifc/sheet/_XFunctionDescriptions.java124
-rw-r--r--sc/CppunitTest_sc_functionlistobj.mk105
-rw-r--r--sc/Module_sc.mk1
-rw-r--r--sc/qa/extras/scfunctionlistobj.cxx93
-rw-r--r--test/Library_subsequenttest.mk1
-rw-r--r--test/source/sheet/xfunctiondescriptions.cxx75
9 files changed, 309 insertions, 126 deletions
diff --git a/include/test/sheet/xfunctiondescriptions.hxx b/include/test/sheet/xfunctiondescriptions.hxx
new file mode 100644
index 000000000000..ffffe3b59f30
--- /dev/null
+++ b/include/test/sheet/xfunctiondescriptions.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_XFUNCTIONDESCRIPTIONS_HXX
+#define INCLUDED_TEST_SHEET_XFUNCTIONDESCRIPTIONS_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 XFunctionDescriptions
+{
+public:
+ virtual css::uno::Reference<css::uno::XInterface> init() = 0;
+
+ void testGetById();
+
+protected:
+ ~XFunctionDescriptions() {}
+};
+}
+
+#endif // INCLUDED_TEST_SHEET_XFUNCTIONDESCRIPTIONS_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 775cdb348625..24dd5cd7f8a9 100644
--- a/qadevOOo/Jar_OOoRunner.mk
+++ b/qadevOOo/Jar_OOoRunner.mk
@@ -603,7 +603,6 @@ $(eval $(call gb_Jar_add_sourcefiles,OOoRunner,\
qadevOOo/tests/java/ifc/sheet/_XDocumentAuditing \
qadevOOo/tests/java/ifc/sheet/_XEnhancedMouseClickBroadcaster \
qadevOOo/tests/java/ifc/sheet/_XFormulaQuery \
- qadevOOo/tests/java/ifc/sheet/_XFunctionDescriptions \
qadevOOo/tests/java/ifc/sheet/_XRangeSelection \
qadevOOo/tests/java/ifc/sheet/_XScenario \
qadevOOo/tests/java/ifc/sheet/_XSheetCellCursor \
diff --git a/qadevOOo/objdsc/sc/com.sun.star.comp.office.ScFunctionListObj.csv b/qadevOOo/objdsc/sc/com.sun.star.comp.office.ScFunctionListObj.csv
index a784e0e0f29f..5253ef4dbe6f 100644
--- a/qadevOOo/objdsc/sc/com.sun.star.comp.office.ScFunctionListObj.csv
+++ b/qadevOOo/objdsc/sc/com.sun.star.comp.office.ScFunctionListObj.csv
@@ -5,5 +5,4 @@
"ScFunctionListObj";"com::sun::star::container::XIndexAccess";"getByIndex()"
"ScFunctionListObj";"com::sun::star::container::XElementAccess";"getElementType()"
"ScFunctionListObj";"com::sun::star::container::XElementAccess";"hasElements()"
-"ScFunctionListObj";"com::sun::star::sheet::XFunctionDescriptions";"getById()"
"ScFunctionListObj";"com::sun::star::container::XEnumerationAccess";"createEnumeration()"
diff --git a/qadevOOo/tests/java/ifc/sheet/_XFunctionDescriptions.java b/qadevOOo/tests/java/ifc/sheet/_XFunctionDescriptions.java
deleted file mode 100644
index 20c4240c35bd..000000000000
--- a/qadevOOo/tests/java/ifc/sheet/_XFunctionDescriptions.java
+++ /dev/null
@@ -1,124 +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 java.util.Random;
-
-import lib.MultiMethodTest;
-
-import com.sun.star.beans.PropertyValue;
-import com.sun.star.sheet.XFunctionDescriptions;
-
-/**
-* Testing <code>com.sun.star.sheet.XFunctionDescriptions</code>
-* interface methods :
-* <ul>
-* <li><code> getById()</code></li>
-* </ul> <p>
-* @see com.sun.star.sheet.XFunctionDescriptions
-*/
-public class _XFunctionDescriptions extends MultiMethodTest {
-
- public XFunctionDescriptions oObj = null;
-
- /**
- * Test finds available id, calls method using this id, checks returned
- * value and then tries to get description with wrong id. <p>
- * Has <b>OK</b> status if returned value is equal to value obtained by the
- * method <code>getByIndex()</code> in first call and exception
- * <code>IllegalArgumentException</code> was thrown in second call.<p>
- * @see com.sun.star.lang.IllegalArgumentException
- */
- public void _getById() {
- boolean bResult = true;
- // Finding available id...
-
- int count = oObj.getCount();
- if (count > 0) {
- Random rnd = new Random();
- int nr = rnd.nextInt(count);
-
- PropertyValue[] PVals = null;
- try {
- PVals = (PropertyValue[])oObj.getByIndex(nr);
- } catch(com.sun.star.lang.WrappedTargetException e) {
- e.printStackTrace(log);
- tRes.tested("getById()", false);
- return;
- } catch(com.sun.star.lang.IndexOutOfBoundsException e) {
- e.printStackTrace(log);
- tRes.tested("getById()", false);
- return;
- }
-
- String FName = null;
- Integer FId = null;
-
- for (int i = 0; i < PVals.length; i++) {
- if (PVals[i].Name.equals("Name"))
- FName = (String)PVals[i].Value;
- if (PVals[i].Name.equals("Id"))
- FId = (Integer)PVals[i].Value;
- }
-
- log.println("The id of function '" + FName + "' is " + FId);
-
- PropertyValue[] PVals2 = null;
- try {
- PVals2 = oObj.getById(FId.intValue());
- } catch(com.sun.star.lang.IllegalArgumentException e) {
- e.printStackTrace(log);
- tRes.tested("getById()", false);
- return;
- }
-
- String objFName = null;
- Integer objFId = null;
- for (int i = 0; i < PVals2.length; i++) {
- if (PVals2[i].Name.equals("Name"))
- objFName = (String)PVals[i].Value;
- if (PVals2[i].Name.equals("Id"))
- objFId = (Integer)PVals[i].Value;
- }
-
- log.println("The id of returned function '" +
- objFName + "' is " + objFId);
-
- bResult &= FName.equals(objFName);
- bResult &= FId.equals(objFId);
- }
-
- log.println("OK.");
-
- if (bResult) {
- try {
- log.println("Now trying to get description with wrong id ... ");
- oObj.getById(-1);
- bResult = false;
- log.println("Exception expected! - FAILED");
- } catch (com.sun.star.lang.IllegalArgumentException e) {
- log.println("Expected exception " + e + " - OK!");
- }
- }
-
- tRes.tested("getById()", bResult);
- }
-} // finish class _XFunctionDescriptions
-
-
diff --git a/sc/CppunitTest_sc_functionlistobj.mk b/sc/CppunitTest_sc_functionlistobj.mk
new file mode 100644
index 000000000000..959d53223823
--- /dev/null
+++ b/sc/CppunitTest_sc_functionlistobj.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_functionlistobj))
+
+$(eval $(call gb_CppunitTest_use_external,sc_functionlistobj,boost_headers))
+
+$(eval $(call gb_CppunitTest_add_exception_objects,sc_functionlistobj, \
+ sc/qa/extras/scfunctionlistobj \
+))
+
+$(eval $(call gb_CppunitTest_use_libraries,sc_functionlistobj, \
+ 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_functionlistobj,\
+ -I$(SRCDIR)/sc/source/ui/inc \
+ -I$(SRCDIR)/sc/inc \
+ $$(INCLUDE) \
+))
+
+$(eval $(call gb_CppunitTest_use_sdk_api,sc_functionlistobj))
+
+$(eval $(call gb_CppunitTest_use_ure,sc_functionlistobj))
+$(eval $(call gb_CppunitTest_use_vcl,sc_functionlistobj))
+
+$(eval $(call gb_CppunitTest_use_components,sc_functionlistobj,\
+ 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_functionlistobj))
+
+# vim: set noet sw=4 ts=4:
diff --git a/sc/Module_sc.mk b/sc/Module_sc.mk
index ee83c1b4026d..ae9a2c4e89af 100644
--- a/sc/Module_sc.mk
+++ b/sc/Module_sc.mk
@@ -143,6 +143,7 @@ $(eval $(call gb_Module_add_subsequentcheck_targets,sc,\
CppunitTest_sc_labelrangeobj \
CppunitTest_sc_headerfootercontentobj \
CppunitTest_sc_recentfunctionsobj \
+ CppunitTest_sc_functionlistobj \
))
$(eval $(call gb_Module_add_perfcheck_targets,sc,\
diff --git a/sc/qa/extras/scfunctionlistobj.cxx b/sc/qa/extras/scfunctionlistobj.cxx
new file mode 100644
index 000000000000..bf95e9d7e81f
--- /dev/null
+++ b/sc/qa/extras/scfunctionlistobj.cxx
@@ -0,0 +1,93 @@
+/* -*- 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/xfunctiondescriptions.hxx>
+
+#include <com/sun/star/lang/XComponent.hpp>
+#include <com/sun/star/lang/XMultiServiceFactory.hpp>
+#include <com/sun/star/sheet/XSpreadsheetDocument.hpp>
+#include <com/sun/star/uno/Reference.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 1
+
+class ScFunctionListObj : public CalcUnoApiTest, public apitest::XFunctionDescriptions
+{
+public:
+ ScFunctionListObj();
+
+ virtual uno::Reference<uno::XInterface> init() override;
+ virtual void setUp() override;
+ virtual void tearDown() override;
+
+ CPPUNIT_TEST_SUITE(ScFunctionListObj);
+
+ // XFunctionDescriptions
+ CPPUNIT_TEST(testGetById);
+
+ CPPUNIT_TEST_SUITE_END();
+
+private:
+ static sal_Int32 nTest;
+ static uno::Reference<lang::XComponent> mxComponent;
+};
+
+sal_Int32 ScFunctionListObj::nTest = 0;
+uno::Reference<lang::XComponent> ScFunctionListObj::mxComponent;
+
+ScFunctionListObj::ScFunctionListObj()
+ : CalcUnoApiTest("/sc/qa/extras/testdocuments")
+{
+}
+
+uno::Reference<uno::XInterface> ScFunctionListObj::init()
+{
+ // create a calc document
+ if (!mxComponent.is())
+ mxComponent = loadFromDesktop("private:factory/scalc");
+
+ uno::Reference<sheet::XSpreadsheetDocument> xDoc(mxComponent, UNO_QUERY_THROW);
+ CPPUNIT_ASSERT_MESSAGE("no calc document", xDoc.is());
+
+ uno::Reference<lang::XMultiServiceFactory> xMSF(xDoc, UNO_QUERY_THROW);
+ return xMSF->createInstance("com.sun.star.sheet.FunctionDescriptions");
+}
+
+void ScFunctionListObj::setUp()
+{
+ nTest++;
+ CPPUNIT_ASSERT(nTest <= NUMBER_OF_TESTS);
+ CalcUnoApiTest::setUp();
+}
+
+void ScFunctionListObj::tearDown()
+{
+ if (nTest == NUMBER_OF_TESTS)
+ {
+ closeDocument(mxComponent);
+ mxComponent.clear();
+ }
+
+ CalcUnoApiTest::tearDown();
+}
+
+CPPUNIT_TEST_SUITE_REGISTRATION(ScFunctionListObj);
+
+} // 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 ff3e4944b000..ff19a72912b6 100644
--- a/test/Library_subsequenttest.mk
+++ b/test/Library_subsequenttest.mk
@@ -60,6 +60,7 @@ $(eval $(call gb_Library_add_exception_objects,subsequenttest,\
test/source/sheet/xdatapilotfieldgrouping \
test/source/sheet/xdatapilottable \
test/source/sheet/xdatapilottable2 \
+ test/source/sheet/xfunctiondescriptions \
test/source/sheet/xheaderfootercontent \
test/source/sheet/xlabelrange \
test/source/sheet/xlabelranges \
diff --git a/test/source/sheet/xfunctiondescriptions.cxx b/test/source/sheet/xfunctiondescriptions.cxx
new file mode 100644
index 000000000000..12da126cb8d3
--- /dev/null
+++ b/test/source/sheet/xfunctiondescriptions.cxx
@@ -0,0 +1,75 @@
+/* -*- 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/xfunctiondescriptions.hxx>
+
+#include <com/sun/star/beans/XPropertySet.hpp>
+#include <com/sun/star/beans/PropertyValue.hpp>
+#include <com/sun/star/sheet/XFunctionDescriptions.hpp>
+#include <com/sun/star/lang/IllegalArgumentException.hpp>
+#include <com/sun/star/uno/Reference.hxx>
+
+#include <cppunit/extensions/HelperMacros.h>
+
+using namespace css;
+using namespace com::sun::star;
+using namespace com::sun::star::uno;
+
+namespace apitest
+{
+void XFunctionDescriptions::testGetById()
+{
+ uno::Reference<sheet::XFunctionDescriptions> xFD(init(), UNO_QUERY_THROW);
+
+ const sal_Int32 nCount = xFD->getCount();
+ CPPUNIT_ASSERT_MESSAGE("No FunctionDescriptions available", 0 != nCount);
+
+ // first grab a random function descriptions
+ std::random_device rd;
+ std::mt19937 gen(rd());
+ std::uniform_int_distribution<> distr(1, nCount);
+ int nNumber = distr(gen);
+
+ sal_Int32 aId1 = 0;
+ OUString aName1;
+ uno::Sequence<beans::PropertyValue> aProps1;
+ CPPUNIT_ASSERT(xFD->getByIndex(nNumber) >>= aProps1);
+ for (const auto& aProp : aProps1)
+ {
+ if (aProp.Name == "Id")
+ aId1 = aProp.Value.get<sal_Int32>();
+ if (aProp.Name == "Name")
+ aName1 = aProp.Value.get<OUString>();
+ }
+
+ // fetch the same descriptions by its id
+ sal_Int32 aId2 = 0;
+ OUString aName2;
+ uno::Sequence<beans::PropertyValue> aProps2;
+ aProps2 = xFD->getById(aId1);
+ CPPUNIT_ASSERT_MESSAGE("Received empty FunctionDescriptions from getById()",
+ aProps2.getLength());
+ for (const auto& aProp : aProps2)
+ {
+ if (aProp.Name == "Id")
+ aId2 = aProp.Value.get<sal_Int32>();
+ if (aProp.Name == "Name")
+ aName2 = aProp.Value.get<OUString>();
+ }
+ CPPUNIT_ASSERT_EQUAL_MESSAGE("Received wrong FunctionDescriptions (Id)", aId1, aId2);
+ CPPUNIT_ASSERT_EQUAL_MESSAGE("Received wrong FunctionDescriptions (Name)", aName1, aName2);
+
+ CPPUNIT_ASSERT_THROW_MESSAGE("No IllegalArgumentException thrown", xFD->getById(-1),
+ css::lang::IllegalArgumentException);
+}
+}
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab cinoptions=b1,g0,N-s cinkeys+=0=break: */