[Libreoffice-commits] core.git: framework/qa include/test qadevOOo/Jar_OOoRunner.mk qadevOOo/objdsc qadevOOo/tests sc/CppunitTest_sc_recentfunctionsobj.mk sc/Module_sc.mk sc/qa test/Library_subsequenttest.mk test/source

Jens Carl j.carl43 at gmx.de
Tue Dec 5 06:55:34 UTC 2017


 framework/qa/complex/api_internal/api.lst                            |    1 
 include/test/sheet/xrecentfunctions.hxx                              |   36 ++
 qadevOOo/Jar_OOoRunner.mk                                            |    2 
 qadevOOo/objdsc/sc/com.sun.star.comp.office.ScRecentFunctionsObj.csv |    3 
 qadevOOo/tests/java/ifc/sheet/_XRecentFunctions.java                 |  158 ----------
 qadevOOo/tests/java/mod/_sc/ScRecentFunctionsObj.java                |  112 -------
 sc/CppunitTest_sc_recentfunctionsobj.mk                              |  105 ++++++
 sc/Module_sc.mk                                                      |    1 
 sc/qa/extras/screcentfunctionsobj.cxx                                |   97 ++++++
 sc/qa/unoapi/sc_6.sce                                                |    1 
 test/Library_subsequenttest.mk                                       |    1 
 test/source/sheet/xrecentfunctions.cxx                               |   76 ++++
 12 files changed, 316 insertions(+), 277 deletions(-)

New commits:
commit 958d8d316dbda970dc31d5b060f8d317db0516ff
Author: Jens Carl <j.carl43 at gmx.de>
Date:   Fri Dec 1 06:22:30 2017 +0000

    tdf#45904 Move _XRecentFunctions Java tests to C++
    
    Fix for #i84761.
    
    Change-Id: I3ea608ce60ecc274bc2af9eb1d8117372b663a6f
    Reviewed-on: https://gerrit.libreoffice.org/45637
    Tested-by: Jenkins <ci at libreoffice.org>
    Reviewed-by: Jens Carl <j.carl43 at gmx.de>

diff --git a/framework/qa/complex/api_internal/api.lst b/framework/qa/complex/api_internal/api.lst
index dae7278c29b0..3f89f85de88d 100644
--- a/framework/qa/complex/api_internal/api.lst
+++ b/framework/qa/complex/api_internal/api.lst
@@ -118,7 +118,6 @@ job119=sc.ScIndexEnumeration_TableConditionalEntryEnumeration
 job120=sc.ScIndexEnumeration_TextFieldEnumeration
 job122=sc.ScLabelRangesObj
 job123=sc.ScNamedRangeObj
-job124=sc.ScRecentFunctionsObj
 job125=sc.ScScenariosObj
 job126=sc.ScSheetLinkObj
 job127=sc.ScSheetLinksObj
diff --git a/include/test/sheet/xrecentfunctions.hxx b/include/test/sheet/xrecentfunctions.hxx
new file mode 100644
index 000000000000..8f7ac55a2521
--- /dev/null
+++ b/include/test/sheet/xrecentfunctions.hxx
@@ -0,0 +1,36 @@
+/* -*- 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_XRECENTFUNCTIONS_HXX
+#define INCLUDED_TEST_SHEET_XRECENTFUNCTIONS_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 XRecentFunctions
+{
+public:
+    virtual css::uno::Reference<css::uno::XInterface> init() = 0;
+
+    void testGetRecentFunctionIds();
+    void testSetRecentFunctionIds();
+    void testGetMaxRecentFunctions();
+
+protected:
+    ~XRecentFunctions() {}
+};
+}
+
+#endif // INCLUDED_TEST_SHEET_XRECENTFUNCTIONS_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 d7476b028d5a..775cdb348625 100644
--- a/qadevOOo/Jar_OOoRunner.mk
+++ b/qadevOOo/Jar_OOoRunner.mk
@@ -605,7 +605,6 @@ $(eval $(call gb_Jar_add_sourcefiles,OOoRunner,\
     qadevOOo/tests/java/ifc/sheet/_XFormulaQuery \
     qadevOOo/tests/java/ifc/sheet/_XFunctionDescriptions \
     qadevOOo/tests/java/ifc/sheet/_XRangeSelection \
-    qadevOOo/tests/java/ifc/sheet/_XRecentFunctions \
     qadevOOo/tests/java/ifc/sheet/_XScenario \
     qadevOOo/tests/java/ifc/sheet/_XSheetCellCursor \
     qadevOOo/tests/java/ifc/style/_CharacterProperties \
@@ -1070,7 +1069,6 @@ $(eval $(call gb_Jar_add_sourcefiles,OOoRunner,\
     qadevOOo/tests/java/mod/_sc/ScModelObj \
     qadevOOo/tests/java/mod/_sc/ScNamedRangeObj \
     qadevOOo/tests/java/mod/_sc/ScNamedRangesObj \
-    qadevOOo/tests/java/mod/_sc/ScRecentFunctionsObj \
     qadevOOo/tests/java/mod/_sc/ScScenariosObj \
     qadevOOo/tests/java/mod/_sc/ScShapeObj \
     qadevOOo/tests/java/mod/_sc/ScSheetLinkObj \
diff --git a/qadevOOo/objdsc/sc/com.sun.star.comp.office.ScRecentFunctionsObj.csv b/qadevOOo/objdsc/sc/com.sun.star.comp.office.ScRecentFunctionsObj.csv
deleted file mode 100644
index 67bf2d9a2a5c..000000000000
--- a/qadevOOo/objdsc/sc/com.sun.star.comp.office.ScRecentFunctionsObj.csv
+++ /dev/null
@@ -1,3 +0,0 @@
-"ScRecentFunctionsObj";"com::sun::star::sheet::XRecentFunctions";"getRecentFunctionIds()"
-"ScRecentFunctionsObj";"com::sun::star::sheet::XRecentFunctions";"setRecentFunctionIds()"
-"ScRecentFunctionsObj";"com::sun::star::sheet::XRecentFunctions";"getMaxRecentFunctions()"
diff --git a/qadevOOo/tests/java/ifc/sheet/_XRecentFunctions.java b/qadevOOo/tests/java/ifc/sheet/_XRecentFunctions.java
deleted file mode 100644
index 3ca88e281f68..000000000000
--- a/qadevOOo/tests/java/ifc/sheet/_XRecentFunctions.java
+++ /dev/null
@@ -1,158 +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 lib.Status;
-import lib.StatusException;
-
-import com.sun.star.beans.PropertyValue;
-import com.sun.star.container.XNameAccess;
-import com.sun.star.sheet.XRecentFunctions;
-
-/**
-* Testing <code>com.sun.star.sheet.XRecentFunctions</code>
-* interface methods :
-* <ul>
-*  <li><code> getRecentFunctionIds()</code></li>
-*  <li><code> setRecentFunctionIds()</code></li>
-*  <li><code> getMaxRecentFunctions()</code></li>
-* </ul> <p>
-* This test needs the following object relations :
-* <ul>
-*  <li> <code>'FUNCTIONLIST'</code> (of type <code>XNameAccess</code>):
-*   to have the set of available functions </li>
-* <ul> <p>
-* @see com.sun.star.sheet.XRecentFunctions
-*/
-public class _XRecentFunctions extends MultiMethodTest {
-
-    public XRecentFunctions oObj = null;
-    int iMaxNumber = 0;
-
-    /**
-    * Test calls the method, checks returned value and stores it. <p>
-    * Has <b> OK </b> status if returned value isn't equal to zero. <p>
-    */
-    public void _getMaxRecentFunctions() {
-
-        iMaxNumber = oObj.getMaxRecentFunctions();
-        log.println("Maximum recent functions : " + iMaxNumber);
-
-        tRes.tested("getMaxRecentFunctions()", iMaxNumber != 0);
-    }
-
-    /**
-    * Test calls the method and checks returned value. <p>
-    * Has <b> OK </b> status if returned value isn't null, if length of returned
-    * array is equal or less to the maximum number of functions and obtained
-    * array doesn't contain equal functions. <p>
-    * The following method tests are to be completed successfully before :
-    * <ul>
-    *  <li> <code> getMaxRecentFunctions() </code> : to have the maximum number
-    *  of recent functions </li>
-    * </ul>
-    */
-    public void _getRecentFunctionIds() {
-        requiredMethod("getMaxRecentFunctions()");
-
-        boolean bResult = true;
-        int[] IDs = null;
-        int iNumber = 0;
-
-        IDs = oObj.getRecentFunctionIds();
-        iNumber = IDs.length;
-        bResult &= (iNumber <= iMaxNumber);
-        log.println("Now there are " + iNumber + " recent functions");
-        if (bResult) {
-            for (int i = 0; i < iNumber - 1; i++)
-                for (int j = i + 1; j < iNumber; j++) {
-                    bResult &= (IDs[i] != IDs[j]);
-                }
-        }
-
-        tRes.tested("getRecentFunctionIds()", bResult);
-    }
-
-    /**
-    * Test gets the set of available functions, sets empty list of recent
-    * functions, sets list of maximum size. <p>
-    * Has <b> OK </b> status if length of recent function list is equal to zero
-    * after list was set to empty, if length of list is equal to maximum size
-    * after list was set to its maximum size and no exception were thrown. <p>
-    * The following method tests are to be completed successfully before :
-    * <ul>
-    *  <li> <code> getMaxRecentFunctions() </code> : to have the maximum number
-    *  of recent functions </li>
-    * </ul>
-    */
-    public void _setRecentFunctionIds() {
-        requiredMethod("getMaxRecentFunctions()");
-
-        boolean bResult = true;
-        int[] IDs = new int[0];
-        XNameAccess functionList = null;
-
-        log.println("First, get the set of available functions.");
-        functionList = (XNameAccess)tEnv.getObjRelation("FUNCTIONLIST");
-        if (functionList == null) throw new StatusException(Status.failed
-            ("Relation 'FUNCTIONLIST' not found"));
-
-        log.println("Now trying to set empty list.");
-        oObj.setRecentFunctionIds(IDs);
-        bResult &= (oObj.getRecentFunctionIds().length == 0);
-
-        log.println("Now trying to set list of maximum size.");
-        String[] names = functionList.getElementNames();
-        Random rnd = new Random();
-
-        IDs = new int[iMaxNumber];
-        int startIdx = rnd.nextInt(names.length - iMaxNumber - 1) + 1;
-
-        try {
-            for (int i = startIdx; i < startIdx + iMaxNumber; i++) {
-                PropertyValue[] propVals = (PropertyValue[])
-                    functionList.getByName(names[i]);
-                for (int j = 0; j < propVals.length; j++) {
-                    String propName = propVals[j].Name;
-                    if (propName.equals("Id")) {
-                        IDs[i - startIdx] =
-                            ((Integer)propVals[j].Value).intValue();
-                        break;
-                    }
-                }
-            }
-        } catch(com.sun.star.lang.WrappedTargetException e) {
-            e.printStackTrace(log);
-            bResult = false;
-        } catch(com.sun.star.container.NoSuchElementException e) {
-            e.printStackTrace(log);
-            bResult = false;
-        }
-
-        oObj.setRecentFunctionIds(IDs);
-        bResult &= (oObj.getRecentFunctionIds().length == iMaxNumber);
-
-        tRes.tested("setRecentFunctionIds()", bResult);
-    }
-
-}
-
diff --git a/qadevOOo/tests/java/mod/_sc/ScRecentFunctionsObj.java b/qadevOOo/tests/java/mod/_sc/ScRecentFunctionsObj.java
deleted file mode 100644
index bcce14359251..000000000000
--- a/qadevOOo/tests/java/mod/_sc/ScRecentFunctionsObj.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 mod._sc;
-
-import java.io.PrintWriter;
-
-import lib.TestCase;
-import lib.TestEnvironment;
-import lib.TestParameters;
-import util.SOfficeFactory;
-
-import com.sun.star.container.XNameAccess;
-import com.sun.star.lang.XComponent;
-import com.sun.star.lang.XMultiServiceFactory;
-import com.sun.star.sheet.XSpreadsheetDocument;
-import com.sun.star.uno.UnoRuntime;
-import com.sun.star.uno.XInterface;
-
-/**
-* Test for object which is represented by service
-* <code>com.sun.star.sheet.RecentFunctions</code>. <p>
-* Object implements the following interfaces :
-* <ul>
-*  <li> <code>com::sun::star::sheet::XRecentFunctions</code></li>
-* </ul>
-* @see com.sun.star.sheet.RecentFunctions
-* @see com.sun.star.sheet.XRecentFunctions
-* @see ifc.sheet._XRecentFunctions
-*/
-public class ScRecentFunctionsObj extends TestCase {
-    private XSpreadsheetDocument xSheetDoc = null;
-
-    /**
-    * Creates Spreadsheet document.
-    */
-    @Override
-    protected void initialize( TestParameters tParam, PrintWriter log ) throws Exception {
-        SOfficeFactory SOF = SOfficeFactory.getFactory( tParam.getMSF() );
-        log.println( "creating a Spreadsheet document" );
-        xSheetDoc = SOF.createCalcDoc(null);
-    }
-
-    /**
-    * Disposes Spreadsheet document.
-    */
-    @Override
-    protected void cleanup( TestParameters tParam, PrintWriter log ) {
-        log.println( "    disposing xSheetDoc " );
-        XComponent oComp = UnoRuntime.queryInterface(XComponent.class, xSheetDoc) ;
-        util.DesktopTools.closeDoc(oComp);
-    }
-
-    /**
-    * Creating a TestEnvironment for the interfaces to be tested.
-    * Creates an instance of the service
-    * <code>com.sun.star.sheet.RecentFunctions</code> and an instance of the
-    * service <code>com.sun.star.sheet.FunctionDescriptions</code>.
-    * Object relations created :
-    * <ul>
-    *  <li> <code>'FUNCTIONLIST'</code> for
-    *      {@link ifc.sheet._XRecentFunctions}(the second created instance)</li>
-    * </ul>
-    */
-    @Override
-    public TestEnvironment createTestEnvironment(
-        TestParameters Param, PrintWriter log ) throws Exception {
-
-        XInterface oObj = null;
-        XInterface allFunctions = null;
-
-        // creation of testobject here
-        // first we write what we are intend to do to log file
-        log.println( "Creating a test environment" );
-
-        log.println("Getting test object ") ;
-        XMultiServiceFactory oDocMSF = Param.getMSF();
-        oObj =  (XInterface)oDocMSF.createInstance(
-            "com.sun.star.sheet.RecentFunctions");
-        allFunctions =  (XInterface)oDocMSF.createInstance(
-            "com.sun.star.sheet.FunctionDescriptions");
-
-        log.println("Creating object - " +
-                                    ((oObj == null) ? "FAILED" : "OK"));
-
-        TestEnvironment tEnv = new TestEnvironment( oObj );
-
-        // Other parameters required for interface tests
-        XNameAccess NA = UnoRuntime.queryInterface(XNameAccess.class, allFunctions);
-        tEnv.addObjRelation("FUNCTIONLIST", NA);
-
-        return tEnv;
-    }
-
-}
-
-
diff --git a/sc/CppunitTest_sc_recentfunctionsobj.mk b/sc/CppunitTest_sc_recentfunctionsobj.mk
new file mode 100644
index 000000000000..54f54501f025
--- /dev/null
+++ b/sc/CppunitTest_sc_recentfunctionsobj.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_recentfunctionsobj))
+
+$(eval $(call gb_CppunitTest_use_external,sc_recentfunctionsobj,boost_headers))
+
+$(eval $(call gb_CppunitTest_add_exception_objects,sc_recentfunctionsobj, \
+	sc/qa/extras/screcentfunctionsobj \
+))
+
+$(eval $(call gb_CppunitTest_use_libraries,sc_recentfunctionsobj, \
+	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_recentfunctionsobj,\
+	-I$(SRCDIR)/sc/source/ui/inc \
+	-I$(SRCDIR)/sc/inc \
+	$$(INCLUDE) \
+))
+
+$(eval $(call gb_CppunitTest_use_sdk_api,sc_recentfunctionsobj))
+
+$(eval $(call gb_CppunitTest_use_ure,sc_recentfunctionsobj))
+$(eval $(call gb_CppunitTest_use_vcl,sc_recentfunctionsobj))
+
+$(eval $(call gb_CppunitTest_use_components,sc_recentfunctionsobj,\
+	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_recentfunctionsobj))
+
+# vim: set noet sw=4 ts=4:
diff --git a/sc/Module_sc.mk b/sc/Module_sc.mk
index 6e30bd22c1f0..ee83c1b4026d 100644
--- a/sc/Module_sc.mk
+++ b/sc/Module_sc.mk
@@ -142,6 +142,7 @@ $(eval $(call gb_Module_add_subsequentcheck_targets,sc,\
 	CppunitTest_sc_labelrangesobj \
 	CppunitTest_sc_labelrangeobj \
 	CppunitTest_sc_headerfootercontentobj \
+	CppunitTest_sc_recentfunctionsobj \
 ))
 
 $(eval $(call gb_Module_add_perfcheck_targets,sc,\
diff --git a/sc/qa/extras/screcentfunctionsobj.cxx b/sc/qa/extras/screcentfunctionsobj.cxx
new file mode 100644
index 000000000000..289c87479cb0
--- /dev/null
+++ b/sc/qa/extras/screcentfunctionsobj.cxx
@@ -0,0 +1,97 @@
+/* -*- 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/xrecentfunctions.hxx>
+
+#include <com/sun/star/lang/XComponent.hpp>
+#include <com/sun/star/lang/XMultiServiceFactory.hpp>
+#include <com/sun/star/sheet/XRecentFunctions.hpp>
+#include <com/sun/star/sheet/XSpreadsheetDocument.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 3
+
+class ScRecentFunctionsObj : public CalcUnoApiTest, public apitest::XRecentFunctions
+{
+public:
+    ScRecentFunctionsObj();
+
+    virtual uno::Reference<uno::XInterface> init() override;
+    virtual void setUp() override;
+    virtual void tearDown() override;
+
+    CPPUNIT_TEST_SUITE(ScRecentFunctionsObj);
+
+    // XRecentFunctions
+    CPPUNIT_TEST(testGetRecentFunctionIds);
+    CPPUNIT_TEST(testSetRecentFunctionIds);
+    CPPUNIT_TEST(testGetMaxRecentFunctions);
+
+    CPPUNIT_TEST_SUITE_END();
+
+private:
+    static sal_Int32 nTest;
+    static uno::Reference<lang::XComponent> mxComponent;
+};
+
+sal_Int32 ScRecentFunctionsObj::nTest = 0;
+uno::Reference<lang::XComponent> ScRecentFunctionsObj::mxComponent;
+
+ScRecentFunctionsObj::ScRecentFunctionsObj()
+    : CalcUnoApiTest("/sc/qa/extras/testdocuments")
+{
+}
+
+uno::Reference<uno::XInterface> ScRecentFunctionsObj::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.RecentFunctions");
+}
+
+void ScRecentFunctionsObj::setUp()
+{
+    nTest++;
+    CPPUNIT_ASSERT(nTest <= NUMBER_OF_TESTS);
+    CalcUnoApiTest::setUp();
+}
+
+void ScRecentFunctionsObj::tearDown()
+{
+    if (nTest == NUMBER_OF_TESTS)
+    {
+        closeDocument(mxComponent);
+        mxComponent.clear();
+    }
+
+    CalcUnoApiTest::tearDown();
+}
+
+CPPUNIT_TEST_SUITE_REGISTRATION(ScRecentFunctionsObj);
+
+} // end namespace
+
+CPPUNIT_PLUGIN_IMPLEMENT();
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab cinoptions=b1,g0,N-s cinkeys+=0=break: */
diff --git a/sc/qa/unoapi/sc_6.sce b/sc/qa/unoapi/sc_6.sce
index 6467d0885485..dc4a58459443 100644
--- a/sc/qa/unoapi/sc_6.sce
+++ b/sc/qa/unoapi/sc_6.sce
@@ -23,7 +23,6 @@
 -o sc.ScModelObj
 -o sc.ScNamedRangeObj
 -o sc.ScNamedRangesObj
--o sc.ScRecentFunctionsObj
 # -o sc.ScScenariosObj
 # -o sc.ScShapeObj
 # -o sc.ScSheetLinkObj
diff --git a/test/Library_subsequenttest.mk b/test/Library_subsequenttest.mk
index c398bb0cf10b..ff3e4944b000 100644
--- a/test/Library_subsequenttest.mk
+++ b/test/Library_subsequenttest.mk
@@ -67,6 +67,7 @@ $(eval $(call gb_Library_add_exception_objects,subsequenttest,\
 	test/source/sheet/xnamedranges \
 	test/source/sheet/xmultipleoperation \
 	test/source/sheet/xprintareas \
+	test/source/sheet/xrecentfunctions \
 	test/source/sheet/xscenarioenhanced \
 	test/source/sheet/xscenarios \
 	test/source/sheet/xscenariossupplier \
diff --git a/test/source/sheet/xrecentfunctions.cxx b/test/source/sheet/xrecentfunctions.cxx
new file mode 100644
index 000000000000..1d88943d4e39
--- /dev/null
+++ b/test/source/sheet/xrecentfunctions.cxx
@@ -0,0 +1,76 @@
+/* -*- 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/xrecentfunctions.hxx>
+
+#include <com/sun/star/sheet/XRecentFunctions.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 XRecentFunctions::testGetRecentFunctionIds()
+{
+    uno::Reference<sheet::XRecentFunctions> xRecentFunctions(init(), UNO_QUERY_THROW);
+
+    uno::Sequence<sal_Int32> aIds = xRecentFunctions->getRecentFunctionIds();
+    const sal_Int32 nNumber = aIds.getLength();
+    CPPUNIT_ASSERT_MESSAGE("Recent IDs greater the max number",
+                           nNumber <= xRecentFunctions->getMaxRecentFunctions());
+    for (int i = 0; i < nNumber - 1; i++)
+        for (int j = i + 1; j < nNumber; j++)
+            CPPUNIT_ASSERT_MESSAGE("Same IDs found", aIds[i] != aIds[j]);
+}
+
+void XRecentFunctions::testSetRecentFunctionIds()
+{
+    uno::Reference<sheet::XRecentFunctions> xRecentFunctions(init(), UNO_QUERY_THROW);
+
+    const sal_Int32 nMaxNumber = xRecentFunctions->getMaxRecentFunctions();
+
+    // empty list
+    uno::Sequence<sal_Int32> aIds;
+    xRecentFunctions->setRecentFunctionIds(aIds);
+
+    aIds = xRecentFunctions->getRecentFunctionIds();
+    CPPUNIT_ASSERT_EQUAL_MESSAGE("Unable to set Ids (empty list)", sal_Int32(0), aIds.getLength());
+
+    // max. size list
+    aIds.realloc(nMaxNumber);
+    std::random_device rd;
+    std::mt19937 gen(rd());
+    std::uniform_int_distribution<> distr(1, nMaxNumber + 1);
+
+    int nStartIdx = distr(gen);
+    for (int i = nStartIdx; i < nStartIdx + nMaxNumber; i++)
+        aIds[i - nStartIdx] = 1;
+
+    xRecentFunctions->setRecentFunctionIds(aIds);
+
+    aIds = xRecentFunctions->getRecentFunctionIds();
+    CPPUNIT_ASSERT_EQUAL_MESSAGE("Unable to set Ids (max. size list)", nMaxNumber,
+                                 aIds.getLength());
+}
+
+void XRecentFunctions::testGetMaxRecentFunctions()
+{
+    uno::Reference<sheet::XRecentFunctions> xRecentFunctions(init(), UNO_QUERY_THROW);
+    CPPUNIT_ASSERT_MESSAGE("Unable to execute getMaxRecentFunctions()",
+                           sal_Int32(0) != xRecentFunctions->getMaxRecentFunctions());
+}
+}
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab cinoptions=b1,g0,N-s cinkeys+=0=break: */


More information about the Libreoffice-commits mailing list