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

Jens Carl j.carl43 at gmx.de
Tue Mar 27 01:14:56 UTC 2018


 include/test/sheet/xddelink.hxx                              |   36 +++
 qadevOOo/Jar_OOoRunner.mk                                    |    1 
 qadevOOo/objdsc/sc/com.sun.star.comp.office.ScDDELinkObj.csv |    3 
 qadevOOo/tests/java/ifc/sheet/_XDDELink.java                 |  102 -----------
 sc/CppunitTest_sc_ddelinkobj.mk                              |   72 +++++++
 sc/Module_sc.mk                                              |    1 
 sc/qa/extras/scddelinkobj.cxx                                |  100 ++++++++++
 test/Library_subsequenttest.mk                               |    1 
 test/source/sheet/xddelink.cxx                               |   45 ++++
 9 files changed, 255 insertions(+), 106 deletions(-)

New commits:
commit 655b9054bc265de377c3dc411e2ef40cdfd16dce
Author: Jens Carl <j.carl43 at gmx.de>
Date:   Mon Mar 26 07:13:25 2018 +0000

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

diff --git a/include/test/sheet/xddelink.hxx b/include/test/sheet/xddelink.hxx
new file mode 100644
index 000000000000..fa974ea321d8
--- /dev/null
+++ b/include/test/sheet/xddelink.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_XDDELINK_HXX
+#define INCLUDED_TEST_SHEET_XDDELINK_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 XDDELink
+{
+public:
+    virtual css::uno::Reference<css::uno::XInterface> init() = 0;
+
+    void testGetApplication();
+    void testGetItem();
+    void testGetTopic();
+
+protected:
+    ~XDDELink() {}
+};
+} // namespace apitest
+
+#endif // INCLUDED_TEST_SHEET_XDDELINK_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 a4c1b2d0105f..6e8f20b69683 100644
--- a/qadevOOo/Jar_OOoRunner.mk
+++ b/qadevOOo/Jar_OOoRunner.mk
@@ -575,7 +575,6 @@ $(eval $(call gb_Jar_add_sourcefiles,OOoRunner,\
     qadevOOo/tests/java/ifc/sheet/_XCellRangeMovement \
     qadevOOo/tests/java/ifc/sheet/_XCellRangeReferrer \
     qadevOOo/tests/java/ifc/sheet/_XCellRangesQuery \
-    qadevOOo/tests/java/ifc/sheet/_XDDELink \
     qadevOOo/tests/java/ifc/sheet/_XDocumentAuditing \
     qadevOOo/tests/java/ifc/sheet/_XEnhancedMouseClickBroadcaster \
     qadevOOo/tests/java/ifc/sheet/_XFormulaQuery \
diff --git a/qadevOOo/objdsc/sc/com.sun.star.comp.office.ScDDELinkObj.csv b/qadevOOo/objdsc/sc/com.sun.star.comp.office.ScDDELinkObj.csv
index 57dce6828d02..d66cec243583 100644
--- a/qadevOOo/objdsc/sc/com.sun.star.comp.office.ScDDELinkObj.csv
+++ b/qadevOOo/objdsc/sc/com.sun.star.comp.office.ScDDELinkObj.csv
@@ -1,8 +1,5 @@
 "ScDDELinkObj";"com::sun::star::util::XRefreshable";"refresh()"
 "ScDDELinkObj";"com::sun::star::util::XRefreshable";"addRefreshListener()"
 "ScDDELinkObj";"com::sun::star::util::XRefreshable";"removeRefreshListener()"
-"ScDDELinkObj";"com::sun::star::sheet::XDDELink";"getApplication()"
-"ScDDELinkObj";"com::sun::star::sheet::XDDELink";"getTopic()"
-"ScDDELinkObj";"com::sun::star::sheet::XDDELink";"getItem()"
 "ScDDELinkObj";"com::sun::star::container::XNamed";"getName()"
 "ScDDELinkObj";"com::sun::star::container::XNamed";"setName()"
diff --git a/qadevOOo/tests/java/ifc/sheet/_XDDELink.java b/qadevOOo/tests/java/ifc/sheet/_XDDELink.java
deleted file mode 100644
index 5e87e3999e4a..000000000000
--- a/qadevOOo/tests/java/ifc/sheet/_XDDELink.java
+++ /dev/null
@@ -1,102 +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 lib.Status;
-import lib.StatusException;
-
-import com.sun.star.sheet.XDDELink;
-
-/**
-* Testing <code>com.sun.star.sheet.XDDELink</code>
-* interface methods :
-* <ul>
-*  <li><code> getApplication()</code></li>
-*  <li><code> getTopic()</code></li>
-*  <li><code> getItem()</code></li>
-* </ul> <p>
-* This test needs the following object relations :
-* <ul>
-*  <li> <code>'APPLICATION'</code> (of type <code>String</code>):
-*   to have application name </li>
-*  <li> <code>'ITEM'</code> (of type <code>String</code>):
-*   to have DDE item </li>
-*  <li> <code>'TOPIC'</code> (of type <code>String</code>):
-*   to have DDE topic </li>
-* <ul> <p>
-* @see com.sun.star.sheet.XDDELink
-*/
-public class _XDDELink extends MultiMethodTest {
-    public XDDELink oObj = null;
-
-    /**
-    * Test calls the method and compares returned value to value obtained by
-    * relation <code>'APPLICATION'</code>. <p>
-    * Has <b> OK </b> status if values are equal. <p>
-    */
-    public void _getApplication(){
-        log.println("testing getApplication()");
-        boolean bResult = false;
-
-        String oAppl = (String)tEnv.getObjRelation("APPLICATION");
-        if (oAppl == null) throw new StatusException(Status.failed
-            ("Relation 'APPLICATION' not found"));
-
-        bResult = oAppl.equals(oObj.getApplication());
-        tRes.tested("getApplication()", bResult) ;
-    }
-
-    /**
-    * Test calls the method and compares returned value to value obtained by
-    * relation <code>'ITEM'</code>. <p>
-    * Has <b> OK </b> status if values are equal. <p>
-    */
-    public void _getItem(){
-        log.println("testing getItem()");
-        boolean bResult = false;
-        String sItem = oObj.getItem();
-
-        String oItem = (String)tEnv.getObjRelation("ITEM");
-        if (oItem == null) throw new StatusException(Status.failed
-            ("Relation 'ITEM' not found"));
-
-        bResult = oItem.equals(sItem);
-        tRes.tested("getItem()", bResult) ;
-    }
-
-    /**
-    * Test calls the method and compares returned value to value obtained by
-    * relation <code>'TOPIC'</code>. <p>
-    * Has <b> OK </b> status if values are equal. <p>
-    */
-    public void _getTopic(){
-        log.println("testing getTopic()");
-        boolean bResult = false;
-        String sTopic = oObj.getTopic();
-
-        String oTopic = (String)tEnv.getObjRelation("TOPIC");
-        if (oTopic == null) throw new StatusException(Status.failed
-            ("Relation 'TOPIC' not found"));
-
-        bResult = oTopic.equals(sTopic);
-        tRes.tested("getTopic()", bResult) ;
-    }
-}
-
diff --git a/sc/CppunitTest_sc_ddelinkobj.mk b/sc/CppunitTest_sc_ddelinkobj.mk
new file mode 100644
index 000000000000..79af2daf687a
--- /dev/null
+++ b/sc/CppunitTest_sc_ddelinkobj.mk
@@ -0,0 +1,72 @@
+# -*- 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_ddelinkobj))
+
+$(eval $(call gb_CppunitTest_use_external,sc_ddelinkobj,boost_headers))
+
+$(eval $(call gb_CppunitTest_add_exception_objects,sc_ddelinkobj, \
+	sc/qa/extras/scddelinkobj \
+))
+
+$(eval $(call gb_CppunitTest_use_libraries,sc_ddelinkobj, \
+	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_ddelinkobj,\
+	-I$(SRCDIR)/sc/source/ui/inc \
+	-I$(SRCDIR)/sc/inc \
+	$$(INCLUDE) \
+))
+
+$(eval $(call gb_CppunitTest_use_sdk_api,sc_ddelinkobj))
+
+$(eval $(call gb_CppunitTest_use_ure,sc_ddelinkobj))
+$(eval $(call gb_CppunitTest_use_vcl,sc_ddelinkobj))
+
+$(eval $(call gb_CppunitTest_use_components,sc_ddelinkobj,\
+    $(sc_unoapi_common_components) \
+))
+
+$(eval $(call gb_CppunitTest_use_configuration,sc_ddelinkobj))
+
+# vim: set noet sw=4 ts=4:
diff --git a/sc/Module_sc.mk b/sc/Module_sc.mk
index 68537c5d7d2e..1c25582d2df1 100644
--- a/sc/Module_sc.mk
+++ b/sc/Module_sc.mk
@@ -157,6 +157,7 @@ $(eval $(call gb_Module_add_subsequentcheck_targets,sc,\
 	CppunitTest_sc_shapeobj \
 	CppunitTest_sc_sheetlinkobj \
 	CppunitTest_sc_spreadsheetsettingsobj \
+	CppunitTest_sc_ddelinkobj \
 ))
 
 $(eval $(call gb_Module_add_perfcheck_targets,sc,\
diff --git a/sc/qa/extras/scddelinkobj.cxx b/sc/qa/extras/scddelinkobj.cxx
new file mode 100644
index 000000000000..91899ceef78a
--- /dev/null
+++ b/sc/qa/extras/scddelinkobj.cxx
@@ -0,0 +1,100 @@
+/* -*- 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/xddelink.hxx>
+
+#include <com/sun/star/beans/XPropertySet.hpp>
+#include <com/sun/star/container/XIndexAccess.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/XDDELink.hpp>
+#include <com/sun/star/sheet/XSpreadsheet.hpp>
+#include <com/sun/star/sheet/XSpreadsheetDocument.hpp>
+#include <com/sun/star/sheet/XSpreadsheets.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
+{
+class ScDDELinkObj : public CalcUnoApiTest, public apitest::XDDELink
+{
+public:
+    ScDDELinkObj();
+
+    virtual uno::Reference<uno::XInterface> init() override;
+    virtual void setUp() override;
+    virtual void tearDown() override;
+
+    CPPUNIT_TEST_SUITE(ScDDELinkObj);
+
+    // XDDELink
+    CPPUNIT_TEST(testGetApplication);
+    CPPUNIT_TEST(testGetItem);
+    CPPUNIT_TEST(testGetTopic);
+
+    CPPUNIT_TEST_SUITE_END();
+
+private:
+    uno::Reference<lang::XComponent> mxComponent;
+};
+
+ScDDELinkObj::ScDDELinkObj()
+    : CalcUnoApiTest("/sc/qa/extras/testdocuments")
+{
+}
+
+uno::Reference<uno::XInterface> ScDDELinkObj::init()
+{
+    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);
+
+    xSheet->getCellByPosition(5, 5)->setFormula(
+        "=DDE(\"soffice\";\"ScDDELinksObj.ods\";\"Sheet.A1\"");
+    xSheet->getCellByPosition(1, 4)->setFormula(
+        "=DDE(\"soffice\";\"ScDDELinksObj.ods\";\"Sheet.A1\"");
+
+    uno::Reference<beans::XPropertySet> xPropSet(xDoc, UNO_QUERY_THROW);
+    uno::Any aDDELinks = xPropSet->getPropertyValue("DDELinks");
+    uno::Reference<container::XNameAccess> xNA(aDDELinks, UNO_QUERY_THROW);
+    uno::Sequence<OUString> sLinkNames = xNA->getElementNames();
+    uno::Reference<sheet::XDDELink> xDDELink(xNA->getByName(sLinkNames[0]), UNO_QUERY_THROW);
+    return xDDELink;
+}
+
+void ScDDELinkObj::setUp()
+{
+    CalcUnoApiTest::setUp();
+    // create a calc document
+    mxComponent = loadFromDesktop("private:factory/scalc");
+}
+
+void ScDDELinkObj::tearDown()
+{
+    closeDocument(mxComponent);
+    CalcUnoApiTest::tearDown();
+}
+
+CPPUNIT_TEST_SUITE_REGISTRATION(ScDDELinkObj);
+
+} // namespace sc_apitest
+
+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 ff608b0d389b..c781af1fa31d 100644
--- a/test/Library_subsequenttest.mk
+++ b/test/Library_subsequenttest.mk
@@ -89,6 +89,7 @@ $(eval $(call gb_Library_add_exception_objects,subsequenttest,\
 	test/source/sheet/xdatapilottable2 \
 	test/source/sheet/xdatapilottables \
 	test/source/sheet/xdatapilottablessupplier \
+	test/source/sheet/xddelink \
 	test/source/sheet/xfunctiondescriptions \
 	test/source/sheet/xheaderfootercontent \
 	test/source/sheet/xlabelrange \
diff --git a/test/source/sheet/xddelink.cxx b/test/source/sheet/xddelink.cxx
new file mode 100644
index 000000000000..403449452ba5
--- /dev/null
+++ b/test/source/sheet/xddelink.cxx
@@ -0,0 +1,45 @@
+/* -*- 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/xddelink.hxx>
+
+#include <com/sun/star/sheet/XDDELink.hpp>
+#include <com/sun/star/uno/Reference.hxx>
+
+#include <cppunit/extensions/HelperMacros.h>
+
+using namespace css;
+using namespace css::uno;
+
+namespace apitest
+{
+void XDDELink::testGetApplication()
+{
+    uno::Reference<sheet::XDDELink> xLink(init(), UNO_QUERY_THROW);
+
+    CPPUNIT_ASSERT_EQUAL_MESSAGE("Unable to execute getApplication()", OUString("soffice"),
+                                 xLink->getApplication());
+}
+void XDDELink::testGetItem()
+{
+    uno::Reference<sheet::XDDELink> xLink(init(), UNO_QUERY_THROW);
+
+    CPPUNIT_ASSERT_EQUAL_MESSAGE("Unable to execute getItem()", OUString("Sheet.A1"),
+                                 xLink->getItem());
+}
+void XDDELink::testGetTopic()
+{
+    uno::Reference<sheet::XDDELink> xLink(init(), UNO_QUERY_THROW);
+
+    CPPUNIT_ASSERT_EQUAL_MESSAGE("Unable to execute getTopic()", OUString("ScDDELinksObj.ods"),
+                                 xLink->getTopic());
+}
+} // namespace apitest
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab cinoptions=b1,g0,N-s cinkeys+=0=break: */


More information about the Libreoffice-commits mailing list