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

Jens Carl j.carl43 at gmx.de
Fri Jan 5 01:41:07 UTC 2018


 include/test/sheet/databaseimportdescriptor.hxx              |   35 +++
 qadevOOo/Jar_OOoRunner.mk                                    |    2 
 qadevOOo/tests/java/ifc/sheet/_DatabaseImportDescriptor.java |   96 --------
 qadevOOo/tests/java/mod/_sc/ScImportDescriptorBase.java      |  128 -----------
 sc/CppunitTest_sc_importdescriptorbaseobj.mk                 |  105 +++++++++
 sc/Module_sc.mk                                              |    1 
 sc/qa/extras/scimportdescriptorbaseobj.cxx                   |  119 ++++++++++
 test/Library_subsequenttest.mk                               |    1 
 test/source/sheet/databaseimportdescriptor.cxx               |  102 ++++++++
 9 files changed, 363 insertions(+), 226 deletions(-)

New commits:
commit b673cbeeeb0cedb6836e1946e6e6c12bfd68add4
Author: Jens Carl <j.carl43 at gmx.de>
Date:   Thu Jan 4 23:55:51 2018 +0000

    tdf#45904 Move _DatabaseImportDescriptor Java tests to C++
    
    Change-Id: I53e9a449cb18c26187f3b1676f8ab67918128499
    Reviewed-on: https://gerrit.libreoffice.org/47447
    Tested-by: Jenkins <ci at libreoffice.org>
    Reviewed-by: Jens Carl <j.carl43 at gmx.de>

diff --git a/include/test/sheet/databaseimportdescriptor.hxx b/include/test/sheet/databaseimportdescriptor.hxx
new file mode 100644
index 000000000000..14c9c6f294df
--- /dev/null
+++ b/include/test/sheet/databaseimportdescriptor.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_DATABASEIMPORTDESCRIPTOR_HXX
+#define INCLUDED_TEST_SHEET_DATABASEIMPORTDESCRIPTOR_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 DatabaseImportDescriptor
+{
+public:
+    virtual css::uno::Reference<css::uno::XInterface> init() = 0;
+    virtual css::uno::Reference<css::uno::XInterface> getXImportable() = 0;
+
+    void testDatabaseImportDescriptorProperties();
+
+protected:
+    ~DatabaseImportDescriptor() {}
+};
+}
+
+#endif // INCLUDED_TEST_SHEET_DATABASEIMPORTDESCRIPTOR_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 bc33f52aa853..d99390962f85 100644
--- a/qadevOOo/Jar_OOoRunner.mk
+++ b/qadevOOo/Jar_OOoRunner.mk
@@ -563,7 +563,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/_DatabaseImportDescriptor \
     qadevOOo/tests/java/ifc/sheet/_DocumentSettings \
     qadevOOo/tests/java/ifc/sheet/_FunctionDescription \
     qadevOOo/tests/java/ifc/sheet/_GlobalSheetSettings \
@@ -1029,7 +1028,6 @@ $(eval $(call gb_Jar_add_sourcefiles,OOoRunner,\
     qadevOOo/tests/java/mod/_sc/ScHeaderFieldsObj \
     qadevOOo/tests/java/mod/_sc/ScHeaderFooterTextCursor \
     qadevOOo/tests/java/mod/_sc/ScHeaderFooterTextObj \
-    qadevOOo/tests/java/mod/_sc/ScImportDescriptorBase \
     qadevOOo/tests/java/mod/_sc/ScIndexEnumeration_CellAnnotationsEnumeration \
     qadevOOo/tests/java/mod/_sc/ScIndexEnumeration_CellAreaLinksEnumeration \
     qadevOOo/tests/java/mod/_sc/ScIndexEnumeration_DatabaseRangesEnumeration \
diff --git a/qadevOOo/tests/java/ifc/sheet/_DatabaseImportDescriptor.java b/qadevOOo/tests/java/ifc/sheet/_DatabaseImportDescriptor.java
deleted file mode 100644
index 6a8f402e741f..000000000000
--- a/qadevOOo/tests/java/ifc/sheet/_DatabaseImportDescriptor.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 ifc.sheet;
-
-import lib.MultiMethodTest;
-import util.ValueChanger;
-
-import com.sun.star.beans.PropertyValue;
-import com.sun.star.beans.XPropertySet;
-import com.sun.star.util.XImportable;
-
-/**
-* Testing <code>com.sun.star.sheet.DatabaseImportDescriptor</code>
-* service properties:
-* <ul>
-*   <li><code>DatabaseName</code></li>
-*   <li><code>SourceObject</code></li>
-*   <li><code>SourceType</code></li>
-* </ul> <p>
-* @see com.sun.star.sheet.DatabaseImportDescriptor
-*/
-public class _DatabaseImportDescriptor extends MultiMethodTest {
-
-    public XPropertySet oObj = null;
-    public XImportable xIMP = null;
-    public PropertyValue[] props = null;
-
-    public void _DatabaseName() {
-        xIMP = (XImportable) tEnv.getObjRelation("xIMP");
-        props = xIMP.createImportDescriptor(true);
-        changeProp("DatabaseName",0);
-    }
-
-    public void _SourceObject() {
-        changeProp("SourceObject",2);
-    }
-
-    public void _SourceType() {
-        changeProp("SourceType",1);
-    }
-
-    public void changeProp(String name, int nr) {
-
-        Object gValue = null;
-        Object sValue = null;
-        Object ValueToSet = null;
-
-        if ( ! name.equals(props[nr].Name) ) {
-            log.println("Property '"+props[nr].Name+"' is tested");
-            log.println("But the status is for '"+name+"'");
-        }
-
-
-        try {
-            gValue = props[nr].Value;
-            ValueToSet = ValueChanger.changePValue(gValue);
-            props[nr].Value=ValueToSet;
-            sValue = props[nr].Value;
-
-            //check get-set methods
-            if ( (gValue.equals(sValue)) || (sValue == null) ) {
-                log.println("Value for '"+name+"' hasn't changed");
-                tRes.tested(name, false);
-            }
-            else {
-                log.println("Property '"+name+"' OK");
-                tRes.tested(name, true);
-            }
-        } catch (Exception e) {
-             log.println("Exception occurred while testing property '" +
-                 name + "'");
-             e.printStackTrace(log);
-             tRes.tested(name, false);
-        }
-    }// end of changeProp
-
-
-}  // finish class _DatabaseImportDescriptor
-
-
diff --git a/qadevOOo/tests/java/mod/_sc/ScImportDescriptorBase.java b/qadevOOo/tests/java/mod/_sc/ScImportDescriptorBase.java
deleted file mode 100644
index 5782b1327016..000000000000
--- a/qadevOOo/tests/java/mod/_sc/ScImportDescriptorBase.java
+++ /dev/null
@@ -1,128 +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.XIndexAccess;
-import com.sun.star.lang.XComponent;
-import com.sun.star.sheet.XSpreadsheetDocument;
-import com.sun.star.sheet.XSpreadsheets;
-import com.sun.star.uno.UnoRuntime;
-import com.sun.star.uno.XInterface;
-import com.sun.star.util.XImportable;
-
-/**
- *
- * initial description
- * @see com.sun.star.sheet.DatabaseImportDescriptor
- *
- */
-public class ScImportDescriptorBase extends TestCase {
-
-    XSpreadsheetDocument xSpreadsheetDoc;
-
-    /**
-     * in general this method creates a testdocument
-     *
-     *  @param tParam    class which contains additional test parameters
-     *  @param log        class to log the test state and result
-     *
-     *
-     *  @see TestParameters
-     *    @see PrintWriter
-     *
-     */
-    @Override
-    protected void initialize( TestParameters tParam, PrintWriter log ) throws Exception {
-        SOfficeFactory SOF = SOfficeFactory.getFactory(  tParam.getMSF() );
-        log.println( "creating a Spreadsheet document" );
-        xSpreadsheetDoc = SOF.createCalcDoc(null);
-    }
-
-    /**
-     * in general this method disposes the testenvironment and document
-     *
-     *  @param tParam    class which contains additional test parameters
-     *  @param log        class to log the test state and result
-     *
-     *
-     *  @see TestParameters
-     *    @see PrintWriter
-     *
-     */
-    @Override
-    protected void cleanup( TestParameters tParam, PrintWriter log ) {
-        log.println( "    disposing xSheetDoc " );
-        XComponent oComp = UnoRuntime.queryInterface
-            (XComponent.class, xSpreadsheetDoc) ;
-        util.DesktopTools.closeDoc(oComp);
-    }
-
-
-
-    /**
-     *    creating a TestEnvironment for the interfaces to be tested
-     *
-     *  @param tParam    class which contains additional test parameters
-     *  @param log        class to log the test state and result
-     *
-     *  @return    Status class
-     *
-     *  @see TestParameters
-     *    @see PrintWriter
-     */
-    @Override
-    public TestEnvironment createTestEnvironment( TestParameters tParam,
-                                                  PrintWriter log )
-                                                    throws Exception {
-
-        XInterface oObj = null;
-        XImportable xIMP = null;
-
-        // creation of testobject here
-        // first we write what we are intend to do to log file
-        log.println( "creating a test environment" );
-
-        // create testobject here
-
-        log.println("getting sheets");
-        XSpreadsheets xSpreadsheets = xSpreadsheetDoc.getSheets();
-        if (xSpreadsheets == null) log.println("FAILED"); else log.println("OK");
-
-        log.println("getting a sheet");
-        XIndexAccess oIndexAccess = UnoRuntime.queryInterface(XIndexAccess.class, xSpreadsheets);
-
-        oObj = UnoRuntime.queryInterface(XInterface.class,oIndexAccess.getByIndex(0));
-
-        xIMP = UnoRuntime.queryInterface(XImportable.class,oObj);
-
-        TestEnvironment tEnv = new TestEnvironment(oObj);
-        tEnv.addObjRelation("xIMP",xIMP);
-        return tEnv;
-
-    } // finish method getTestEnvironment
-
-}    // finish class ScImportDescriptorBase
-
diff --git a/sc/CppunitTest_sc_importdescriptorbaseobj.mk b/sc/CppunitTest_sc_importdescriptorbaseobj.mk
new file mode 100644
index 000000000000..122b70ea2f3a
--- /dev/null
+++ b/sc/CppunitTest_sc_importdescriptorbaseobj.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_importdescriptorbaseobj))
+
+$(eval $(call gb_CppunitTest_use_external,sc_importdescriptorbaseobj,boost_headers))
+
+$(eval $(call gb_CppunitTest_add_exception_objects,sc_importdescriptorbaseobj, \
+	sc/qa/extras/scimportdescriptorbaseobj \
+))
+
+$(eval $(call gb_CppunitTest_use_libraries,sc_importdescriptorbaseobj, \
+	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_importdescriptorbaseobj,\
+	-I$(SRCDIR)/sc/source/ui/inc \
+	-I$(SRCDIR)/sc/inc \
+	$$(INCLUDE) \
+))
+
+$(eval $(call gb_CppunitTest_use_sdk_api,sc_importdescriptorbaseobj))
+
+$(eval $(call gb_CppunitTest_use_ure,sc_importdescriptorbaseobj))
+$(eval $(call gb_CppunitTest_use_vcl,sc_importdescriptorbaseobj))
+
+$(eval $(call gb_CppunitTest_use_components,sc_importdescriptorbaseobj,\
+	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_importdescriptorbaseobj))
+
+# vim: set noet sw=4 ts=4:
diff --git a/sc/Module_sc.mk b/sc/Module_sc.mk
index a9e986b7053d..69ac588987db 100644
--- a/sc/Module_sc.mk
+++ b/sc/Module_sc.mk
@@ -149,6 +149,7 @@ $(eval $(call gb_Module_add_subsequentcheck_targets,sc,\
 	CppunitTest_sc_consolidationdescriptorobj \
 	CppunitTest_sc_chart2dataprovider \
 	CppunitTest_sc_autoformatobj \
+	CppunitTest_sc_importdescriptorbaseobj \
 ))
 
 $(eval $(call gb_Module_add_perfcheck_targets,sc,\
diff --git a/sc/qa/extras/scimportdescriptorbaseobj.cxx b/sc/qa/extras/scimportdescriptorbaseobj.cxx
new file mode 100644
index 000000000000..e4957e95f131
--- /dev/null
+++ b/sc/qa/extras/scimportdescriptorbaseobj.cxx
@@ -0,0 +1,119 @@
+/* -*- 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/databaseimportdescriptor.hxx>
+
+#include <com/sun/star/container/XIndexAccess.hpp>
+#include <com/sun/star/lang/XComponent.hpp>
+#include <com/sun/star/sheet/XSpreadsheetDocument.hpp>
+#include <com/sun/star/sheet/XSpreadsheet.hpp>
+#include <com/sun/star/sheet/XSpreadsheets.hpp>
+#include <com/sun/star/util/XImportable.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 ScImportDescriptorBaseObj : public CalcUnoApiTest, public apitest::DatabaseImportDescriptor
+{
+public:
+    ScImportDescriptorBaseObj();
+
+    virtual uno::Reference<uno::XInterface> init() override;
+    virtual uno::Reference<uno::XInterface> getXImportable() override;
+
+    virtual void setUp() override;
+    virtual void tearDown() override;
+
+    CPPUNIT_TEST_SUITE(ScImportDescriptorBaseObj);
+
+    // DatabaseImportDescriptor
+    CPPUNIT_TEST(testDatabaseImportDescriptorProperties);
+
+    CPPUNIT_TEST_SUITE_END();
+
+private:
+    static sal_Int32 nTest;
+    static uno::Reference<lang::XComponent> mxComponent;
+};
+
+sal_Int32 ScImportDescriptorBaseObj::nTest = 0;
+uno::Reference<lang::XComponent> ScImportDescriptorBaseObj::mxComponent;
+
+ScImportDescriptorBaseObj::ScImportDescriptorBaseObj()
+    : CalcUnoApiTest("/sc/qa/extras/testdocuments")
+{
+}
+
+uno::Reference<uno::XInterface> ScImportDescriptorBaseObj::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<sheet::XSpreadsheets> xSheets(xDoc->getSheets(), UNO_QUERY_THROW);
+    uno::Reference<container::XIndexAccess> xIA(xSheets, UNO_QUERY_THROW);
+
+    uno::Reference<sheet::XSpreadsheet> xSheet(xIA->getByIndex(0), UNO_QUERY_THROW);
+    return xSheet;
+}
+
+uno::Reference<uno::XInterface> ScImportDescriptorBaseObj::getXImportable()
+{
+    // 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<sheet::XSpreadsheets> xSheets(xDoc->getSheets(), UNO_QUERY_THROW);
+    uno::Reference<container::XIndexAccess> xIA(xSheets, UNO_QUERY_THROW);
+
+    uno::Reference<sheet::XSpreadsheet> xSheet(xIA->getByIndex(0), UNO_QUERY_THROW);
+    uno::Reference<util::XImportable> XImportable(xSheet, UNO_QUERY_THROW);
+    return XImportable;
+}
+
+void ScImportDescriptorBaseObj::setUp()
+{
+    nTest++;
+    CPPUNIT_ASSERT(nTest <= NUMBER_OF_TESTS);
+    CalcUnoApiTest::setUp();
+}
+
+void ScImportDescriptorBaseObj::tearDown()
+{
+    if (nTest == NUMBER_OF_TESTS)
+    {
+        closeDocument(mxComponent);
+        mxComponent.clear();
+    }
+
+    CalcUnoApiTest::tearDown();
+}
+
+CPPUNIT_TEST_SUITE_REGISTRATION(ScImportDescriptorBaseObj);
+
+} // 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 d4152b3290e6..f90b8f3ef3ea 100644
--- a/test/Library_subsequenttest.mk
+++ b/test/Library_subsequenttest.mk
@@ -44,6 +44,7 @@ $(eval $(call gb_Library_add_exception_objects,subsequenttest,\
 	test/source/container/xnamed \
 	test/source/sheet/cellarealink \
 	test/source/sheet/cellproperties \
+	test/source/sheet/databaseimportdescriptor \
 	test/source/sheet/databaserange \
 	test/source/sheet/datapilotfield \
 	test/source/sheet/datapilotitem \
diff --git a/test/source/sheet/databaseimportdescriptor.cxx b/test/source/sheet/databaseimportdescriptor.cxx
new file mode 100644
index 000000000000..acbe44b1ff71
--- /dev/null
+++ b/test/source/sheet/databaseimportdescriptor.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/sheet/databaseimportdescriptor.hxx>
+
+#include <com/sun/star/beans/PropertyValue.hpp>
+#include <com/sun/star/beans/XPropertySet.hpp>
+#include <com/sun/star/sheet/DataImportMode.hpp>
+#include <com/sun/star/util/XImportable.hpp>
+#include <com/sun/star/uno/Any.hxx>
+#include <com/sun/star/uno/Reference.hxx>
+#include <com/sun/star/uno/Sequence.hxx>
+
+#include <cppunit/extensions/HelperMacros.h>
+
+using namespace com::sun::star;
+using namespace com::sun::star::uno;
+
+namespace apitest
+{
+void DatabaseImportDescriptor::testDatabaseImportDescriptorProperties()
+{
+    uno::Reference<beans::XPropertySet> xDatabaseImportDescriptor(init(), UNO_QUERY_THROW);
+    uno::Reference<util::XImportable> xImportable(getXImportable(), UNO_QUERY_THROW);
+    uno::Sequence<beans::PropertyValue> aPropValues = xImportable->createImportDescriptor(true);
+
+    for (auto i = 0; i < aPropValues.getLength(); i++)
+    {
+        uno::Any aOldValue;
+        uno::Any aNewValue;
+        if (aPropValues[i].Name == "DatabaseName" || aPropValues[i].Name == "SourceObject"
+            || aPropValues[i].Name == "ConnectionResource")
+        {
+            OUString aValue;
+            aOldValue = aPropValues[i].Value;
+            aOldValue >>= aValue;
+            OString aMsgGet = "Unable to get PropertyValue "
+                              + OUStringToOString(aPropValues[i].Name, RTL_TEXTENCODING_UTF8);
+            CPPUNIT_ASSERT_EQUAL_MESSAGE(aMsgGet.getStr(), OUString(""), aValue);
+
+            aNewValue <<= OUString("New");
+            aPropValues[i].Value = aNewValue;
+
+            aOldValue = aPropValues[i].Value;
+            aOldValue >>= aValue;
+            OString aMsgSet = "Unable to set PropertyValue "
+                              + OUStringToOString(aPropValues[i].Name, RTL_TEXTENCODING_UTF8);
+            CPPUNIT_ASSERT_EQUAL_MESSAGE(aMsgSet.getStr(), OUString("New"), aValue);
+        }
+        else if (aPropValues[i].Name == "IsNative")
+        {
+            bool aValue = true;
+            aOldValue = aPropValues[i].Value;
+            aOldValue >>= aValue;
+            OString aMsgGet = "Unable to get PropertyValue "
+                              + OUStringToOString(aPropValues[i].Name, RTL_TEXTENCODING_UTF8);
+            CPPUNIT_ASSERT_MESSAGE(aMsgGet.getStr(), !aValue);
+
+            aNewValue <<= true;
+            aPropValues[i].Value = aNewValue;
+
+            aOldValue = aPropValues[i].Value;
+            aOldValue >>= aValue;
+            OString aMsgSet = "Unable to set PropertyValue "
+                              + OUStringToOString(aPropValues[i].Name, RTL_TEXTENCODING_UTF8);
+            CPPUNIT_ASSERT_MESSAGE(aMsgSet.getStr(), aValue);
+        }
+        else if (aPropValues[i].Name == "SourceType")
+        {
+            sheet::DataImportMode aValue;
+            aOldValue = aPropValues[i].Value;
+            aOldValue >>= aValue;
+            OString aMsgGet = "Unable to get PropertyValue "
+                              + OUStringToOString(aPropValues[i].Name, RTL_TEXTENCODING_UTF8);
+            CPPUNIT_ASSERT_EQUAL_MESSAGE(aMsgGet.getStr(), sheet::DataImportMode_NONE, aValue);
+
+            aNewValue <<= sheet::DataImportMode_SQL;
+            aPropValues[i].Value = aNewValue;
+
+            aOldValue = aPropValues[i].Value;
+            aOldValue >>= aValue;
+            OString aMsgSet = "Unable to set PropertyValue "
+                              + OUStringToOString(aPropValues[i].Name, RTL_TEXTENCODING_UTF8);
+            CPPUNIT_ASSERT_EQUAL_MESSAGE(aMsgSet.getStr(), sheet::DataImportMode_SQL, aValue);
+        }
+        else
+        {
+            OString aMsg = "Unsupported PropertyValue "
+                           + OUStringToOString(aPropValues[i].Name, RTL_TEXTENCODING_UTF8);
+            CPPUNIT_FAIL(aMsg.getStr());
+        }
+    }
+}
+}
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab cinoptions=b1,g0,N-s cinkeys+=0=break: */


More information about the Libreoffice-commits mailing list