summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--include/test/sheet/functiondescription.hxx35
-rw-r--r--qadevOOo/Jar_OOoRunner.mk2
-rw-r--r--qadevOOo/tests/java/ifc/sheet/_FunctionDescription.java140
-rw-r--r--qadevOOo/tests/java/mod/_sc/ScFunctionDescriptionObj.java96
-rw-r--r--sc/CppunitTest_sc_functiondescriptionobj.mk43
-rw-r--r--sc/Module_sc.mk1
-rw-r--r--sc/qa/extras/scfunctiondescriptionobj.cxx92
-rw-r--r--test/Library_subsequenttest.mk1
-rw-r--r--test/source/sheet/functiondescription.cxx86
9 files changed, 258 insertions, 238 deletions
diff --git a/include/test/sheet/functiondescription.hxx b/include/test/sheet/functiondescription.hxx
new file mode 100644
index 000000000000..4e3128bcaaaf
--- /dev/null
+++ b/include/test/sheet/functiondescription.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_FUNCTIONDESCRIPTION_HXX
+#define INCLUDED_TEST_SHEET_FUNCTIONDESCRIPTION_HXX
+
+#include <com/sun/star/beans/PropertyValue.hpp>
+#include <com/sun/star/uno/XInterface.hpp>
+#include <com/sun/star/uno/Sequence.hxx>
+
+#include <test/testdllapi.hxx>
+
+namespace apitest
+{
+class OOO_DLLPUBLIC_TEST FunctionDescription
+{
+public:
+ virtual css::uno::Sequence<css::beans::PropertyValue> init() = 0;
+
+ void testFunctionDescriptionProperties();
+
+protected:
+ ~FunctionDescription() {}
+};
+}
+
+#endif // INCLUDED_TEST_SHEET_FUNCTIONDESCRIPTION_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 4f0b38f9400e..56d52e04ffc6 100644
--- a/qadevOOo/Jar_OOoRunner.mk
+++ b/qadevOOo/Jar_OOoRunner.mk
@@ -562,7 +562,6 @@ $(eval $(call gb_Jar_add_sourcefiles,OOoRunner,\
qadevOOo/tests/java/ifc/sdb/_XSingleSelectQueryAnalyzer \
qadevOOo/tests/java/ifc/sdb/_XSingleSelectQueryComposer \
qadevOOo/tests/java/ifc/sdb/_XSQLErrorBroadcaster \
- qadevOOo/tests/java/ifc/sheet/_FunctionDescription \
qadevOOo/tests/java/ifc/sheet/_SheetSortDescriptor \
qadevOOo/tests/java/ifc/sheet/_SpreadsheetDocument \
qadevOOo/tests/java/ifc/sheet/_TableAutoFormatField \
@@ -1003,7 +1002,6 @@ $(eval $(call gb_Jar_add_sourcefiles,OOoRunner,\
qadevOOo/tests/java/mod/_sc/ScDrawPageObj \
qadevOOo/tests/java/mod/_sc/ScDrawPagesObj \
qadevOOo/tests/java/mod/_sc/ScFilterDescriptorBase \
- qadevOOo/tests/java/mod/_sc/ScFunctionDescriptionObj \
qadevOOo/tests/java/mod/_sc/ScFunctionListObj \
qadevOOo/tests/java/mod/_sc/ScHeaderFieldObj \
qadevOOo/tests/java/mod/_sc/ScHeaderFieldsObj \
diff --git a/qadevOOo/tests/java/ifc/sheet/_FunctionDescription.java b/qadevOOo/tests/java/ifc/sheet/_FunctionDescription.java
deleted file mode 100644
index 800d74514cb1..000000000000
--- a/qadevOOo/tests/java/ifc/sheet/_FunctionDescription.java
+++ /dev/null
@@ -1,140 +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 util.ValueChanger;
-
-import com.sun.star.beans.XPropertySet;
-import com.sun.star.lang.XMultiServiceFactory;
-import com.sun.star.lang.XServiceInfo;
-import com.sun.star.sheet.FunctionArgument;
-import com.sun.star.uno.AnyConverter;
-import com.sun.star.uno.UnoRuntime;
-import com.sun.star.uno.XInterface;
-
-/**
-* Testing <code>com.sun.star.sheet.FunctionDescription</code>
-* service properties:
-* <ul>
-* <li><code>Arguments</code></li>
-* <li><code>Category</code></li>
-* <li><code>Description</code></li>
-* <li><code>Id</code></li>
-* <li><code>Name</code></li>
-* </ul> <p>
-* @see com.sun.star.sheet.FunctionDescription
-*/
-public class _FunctionDescription extends MultiMethodTest {
-
- public XPropertySet oObj = null; // oObj filled by MultiMethodTest
-
- public void _Arguments() {
- // check if Service is available
- XServiceInfo xInfo = UnoRuntime.queryInterface(XServiceInfo.class, oObj );
-
- if ( ! xInfo.supportsService
- ( "com.sun.star.sheet.FunctionDescription" ) ) {
- log.println( "Service not available !" );
- tRes.tested( "Supported", false );
- }
-
- try {
- XMultiServiceFactory oDocMSF = tParam.getMSF();
-
- XInterface FA = (XInterface)oDocMSF.
- createInstance("com.sun.star.sheet.FunctionArgument");
- FunctionArgument arg = (FunctionArgument)AnyConverter.toObject
- (FunctionArgument.class, FA);
-
- arg.Description = "FunctionDescription argument description" ;
- arg.Name = "FunctionDescriptiuon argument name" ;
- arg.IsOptional = true ;
-
- Object sValue = oObj.getPropertyValue("Arguments") ;
- oObj.setPropertyValue("Arguments", new FunctionArgument[] {arg}) ;
- Object nValue = oObj.getPropertyValue("Arguments") ;
-
- if (sValue.equals(nValue)) {
- log.println("Property 'Arguments' didn't change: OK") ;
- tRes.tested("Arguments", true) ;
- } else {
- log.println("Readonly property 'Arguments' changed: Failed") ;
- tRes.tested("Arguments", false) ;
- }
- } catch (Exception e) {
- log.println(
- "Exception occurred while testing property 'Arguments'" );
- e.printStackTrace( log );
- tRes.tested( "Arguments", false );
- }
- }
-
- public void _Category() {
- tryChangeProp("Category") ;
- }
-
- public void _Description() {
- tryChangeProp( "Category" );
- }
-
- public void _Id() {
- tryChangeProp( "Id" );
- }
-
- public void _Name() {
- tryChangeProp( "Name" );
- }
-
- public void tryChangeProp( String name ) {
-
- Object gValue = null;
- Object sValue = null;
- Object ValueToSet = null;
-
-
- try {
- gValue = oObj.getPropertyValue( name );
-
- ValueToSet = ValueChanger.changePValue( gValue );
- oObj.setPropertyValue( name, ValueToSet );
- sValue = oObj.getPropertyValue( name );
-
- //check get-set methods
- if( gValue.equals( sValue ) ) {
- log.println( "Value for '"+name+"' hasn't changed. OK." );
- tRes.tested( name, true );
- }
- else {
- log.println( "Property '" + name +
- "' changes its value : Failed !" );
- tRes.tested( name, false );
- }
- }
- catch ( Exception e ) {
- log.println(
- "Exception occurred while testing property '" + name + "'" );
- e.printStackTrace( log );
- tRes.tested( name, false );
- }
- } // end of changeProp
-
-} //finish class _TextContent
-
-
diff --git a/qadevOOo/tests/java/mod/_sc/ScFunctionDescriptionObj.java b/qadevOOo/tests/java/mod/_sc/ScFunctionDescriptionObj.java
deleted file mode 100644
index 6d2fbdaa4250..000000000000
--- a/qadevOOo/tests/java/mod/_sc/ScFunctionDescriptionObj.java
+++ /dev/null
@@ -1,96 +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 java.util.Random;
-
-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;
-
-public class ScFunctionDescriptionObj extends TestCase {
- private XSpreadsheetDocument xSheetDoc = null;
-
- @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);
- }
-
- @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
- */
- @Override
- public TestEnvironment createTestEnvironment(
- TestParameters Param, PrintWriter log )
- throws Exception {
-
- XInterface oObj = 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();
-
- XInterface FDs = (XInterface)oDocMSF.
- createInstance("com.sun.star.sheet.FunctionDescriptions");
- XNameAccess NA = UnoRuntime.queryInterface
- (XNameAccess.class, FDs);
-
- String names[] = NA.getElementNames();
- Random rnd = new Random();
- int idx = rnd.nextInt(names.length);
-
- oObj = (XInterface)NA.getByName(names[idx]);
-
- log.println("Creating object - " +
- ((oObj == null) ? "FAILED" : "OK"));
-
- TestEnvironment tEnv = new TestEnvironment( oObj );
-
- // Other parameters required for interface tests
-
- return tEnv;
- }
-
-}
-
-
diff --git a/sc/CppunitTest_sc_functiondescriptionobj.mk b/sc/CppunitTest_sc_functiondescriptionobj.mk
new file mode 100644
index 000000000000..8c152d18f030
--- /dev/null
+++ b/sc/CppunitTest_sc_functiondescriptionobj.mk
@@ -0,0 +1,43 @@
+# -*- 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_functiondescriptionobj))
+
+$(eval $(call gb_CppunitTest_use_external,sc_functiondescriptionobj,boost_headers))
+
+$(eval $(call gb_CppunitTest_add_exception_objects,sc_functiondescriptionobj, \
+ sc/qa/extras/scfunctiondescriptionobj \
+))
+
+$(eval $(call gb_CppunitTest_use_libraries,sc_functiondescriptionobj, \
+ cppu \
+ sal \
+ subsequenttest \
+ test \
+ unotest \
+))
+
+$(eval $(call gb_CppunitTest_set_include,sc_functiondescriptionobj,\
+ $$(INCLUDE) \
+))
+
+$(eval $(call gb_CppunitTest_use_sdk_api,sc_functiondescriptionobj))
+
+$(eval $(call gb_CppunitTest_use_ure,sc_functiondescriptionobj))
+$(eval $(call gb_CppunitTest_use_vcl,sc_functiondescriptionobj))
+
+$(eval $(call gb_CppunitTest_use_components,sc_functiondescriptionobj,\
+ $(sc_unoapi_common_components) \
+))
+
+$(eval $(call gb_CppunitTest_use_configuration,sc_functiondescriptionobj))
+
+# vim: set noet sw=4 ts=4:
diff --git a/sc/Module_sc.mk b/sc/Module_sc.mk
index 1c25582d2df1..9afc0d0fe56f 100644
--- a/sc/Module_sc.mk
+++ b/sc/Module_sc.mk
@@ -158,6 +158,7 @@ $(eval $(call gb_Module_add_subsequentcheck_targets,sc,\
CppunitTest_sc_sheetlinkobj \
CppunitTest_sc_spreadsheetsettingsobj \
CppunitTest_sc_ddelinkobj \
+ CppunitTest_sc_functiondescriptionobj \
))
$(eval $(call gb_Module_add_perfcheck_targets,sc,\
diff --git a/sc/qa/extras/scfunctiondescriptionobj.cxx b/sc/qa/extras/scfunctiondescriptionobj.cxx
new file mode 100644
index 000000000000..1e62a9e1935f
--- /dev/null
+++ b/sc/qa/extras/scfunctiondescriptionobj.cxx
@@ -0,0 +1,92 @@
+/* -*- 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/functiondescription.hxx>
+
+#include <com/sun/star/beans/PropertyValue.hpp>
+#include <com/sun/star/container/XNameAccess.hpp>
+#include <com/sun/star/lang/XComponent.hpp>
+#include <com/sun/star/lang/XMultiServiceFactory.hpp>
+#include <com/sun/star/sheet/XFunctionDescriptions.hpp>
+#include <com/sun/star/sheet/XSpreadsheetDocument.hpp>
+#include <com/sun/star/uno/XInterface.hpp>
+
+#include <com/sun/star/uno/Sequence.hxx>
+#include <com/sun/star/uno/Reference.hxx>
+
+using namespace css;
+using namespace css::uno;
+using namespace com::sun::star;
+
+namespace sc_apitest
+{
+class ScFunctionDescriptionObj : public CalcUnoApiTest, public apitest::FunctionDescription
+{
+public:
+ ScFunctionDescriptionObj();
+
+ virtual uno::Sequence<beans::PropertyValue> init() override;
+
+ virtual void setUp() override;
+ virtual void tearDown() override;
+
+ CPPUNIT_TEST_SUITE(ScFunctionDescriptionObj);
+
+ // FunctionDescription
+ CPPUNIT_TEST(testFunctionDescriptionProperties);
+
+ CPPUNIT_TEST_SUITE_END();
+
+private:
+ uno::Reference<lang::XComponent> mxComponent;
+};
+
+ScFunctionDescriptionObj::ScFunctionDescriptionObj()
+ : CalcUnoApiTest("/sc/qa/extras/testdocuments")
+{
+}
+
+uno::Sequence<beans::PropertyValue> ScFunctionDescriptionObj::init()
+{
+ 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);
+ uno::Reference<sheet::XFunctionDescriptions> xFDs(
+ xMSF->createInstance("com.sun.star.sheet.FunctionDescriptions"), UNO_QUERY_THROW);
+
+ uno::Reference<container::XNameAccess> xNA(xFDs, UNO_QUERY_THROW);
+ uno::Sequence<OUString> names = xNA->getElementNames();
+
+ uno::Sequence<beans::PropertyValue> sPropertyValues;
+ CPPUNIT_ASSERT(xNA->getByName(names[0]) >>= sPropertyValues);
+ return sPropertyValues;
+}
+
+void ScFunctionDescriptionObj::setUp()
+{
+ CalcUnoApiTest::setUp();
+ // create a calc document
+ mxComponent = loadFromDesktop("private:factory/scalc");
+}
+
+void ScFunctionDescriptionObj::tearDown()
+{
+ closeDocument(mxComponent);
+ CalcUnoApiTest::tearDown();
+}
+
+CPPUNIT_TEST_SUITE_REGISTRATION(ScFunctionDescriptionObj);
+
+} // 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 dd6509ce81c9..885d645c240c 100644
--- a/test/Library_subsequenttest.mk
+++ b/test/Library_subsequenttest.mk
@@ -55,6 +55,7 @@ $(eval $(call gb_Library_add_exception_objects,subsequenttest,\
test/source/sheet/datapilotfield \
test/source/sheet/datapilotitem \
test/source/sheet/documentsettings \
+ test/source/sheet/functiondescription \
test/source/sheet/globalsheetsettings \
test/source/sheet/scenario \
test/source/sheet/spreadsheetdocumentsettings \
diff --git a/test/source/sheet/functiondescription.cxx b/test/source/sheet/functiondescription.cxx
new file mode 100644
index 000000000000..c5fc4ec3c5c1
--- /dev/null
+++ b/test/source/sheet/functiondescription.cxx
@@ -0,0 +1,86 @@
+/* -*- 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 <vector>
+
+#include <test/sheet/functiondescription.hxx>
+
+#include <com/sun/star/beans/PropertyValue.hpp>
+#include <com/sun/star/sheet/FunctionArgument.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 FunctionDescription::testFunctionDescriptionProperties()
+{
+ uno::Sequence<beans::PropertyValue> aFunctionDescription(init());
+
+ std::vector<OUString> names;
+ // Only test the the get/read operation of the values, because set/write operation doesn't
+ // make any sense. It doesn't trigger any changes.
+ // See discussion: nabble.documentfoundation.org/Testing-UNO-API-service-properties-td4236286.html.
+ for (auto& value : aFunctionDescription)
+ {
+ if (value.Name == "Id")
+ {
+ names.push_back(value.Name);
+ sal_Int32 nValue = 0;
+ CPPUNIT_ASSERT(value.Value >>= nValue);
+ }
+ else if (value.Name == "Category")
+ {
+ names.push_back(value.Name);
+ sal_Int32 nValue = 0;
+ CPPUNIT_ASSERT(value.Value >>= nValue);
+ }
+ else if (value.Name == "Name")
+ {
+ names.push_back(value.Name);
+ OUString sValue;
+ CPPUNIT_ASSERT(value.Value >>= sValue);
+ }
+ else if (value.Name == "Description")
+ {
+ names.push_back(value.Name);
+ OUString sValue;
+ CPPUNIT_ASSERT(value.Value >>= sValue);
+ }
+ else if (value.Name == "Arguments")
+ {
+ names.push_back(value.Name);
+ uno::Sequence<sheet::FunctionArgument> sArguments;
+ CPPUNIT_ASSERT(value.Value >>= sArguments);
+ }
+ else
+ {
+ OString aMsg = "Unsupported PropertyValue: "
+ + OUStringToOString(value.Name, RTL_TEXTENCODING_UTF8);
+ CPPUNIT_FAIL(aMsg.getStr());
+ }
+ }
+
+ CPPUNIT_ASSERT_MESSAGE("Property Id not found",
+ std::count(std::begin(names), std::end(names), "Id"));
+ CPPUNIT_ASSERT_MESSAGE("Property Category not found",
+ std::count(std::begin(names), std::end(names), "Category"));
+ CPPUNIT_ASSERT_MESSAGE("Property Name not found",
+ std::count(std::begin(names), std::end(names), "Name"));
+ CPPUNIT_ASSERT_MESSAGE("Property Description not found",
+ std::count(std::begin(names), std::end(names), "Description"));
+ CPPUNIT_ASSERT_MESSAGE("Property Arguments not found",
+ std::count(std::begin(names), std::end(names), "Arguments"));
+}
+} // namespace apitest
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab cinoptions=b1,g0,N-s cinkeys+=0=break: */