framework/qa/complex/api_internal/api.lst                    |    1 
 include/test/util/xrefreshable.hxx                           |   38 ++
 qadevOOo/Jar_OOoRunner.mk                                    |    1 
 qadevOOo/objdsc/sc/com.sun.star.comp.office.ScDDELinkObj.csv |    3 
 qadevOOo/tests/java/mod/_sc/ScDDELinkObj.java                |  181 -----------
 sc/qa/extras/scddelinkobj.cxx                                |   11 
 sc/qa/unoapi/sc_3.sce                                        |    1 
 test/Library_subsequenttest.mk                               |    1 
 test/source/util/xrefreshable.cxx                            |   81 ++++
 9 files changed, 130 insertions(+), 188 deletions(-)

New commits:
commit 63ff8602c16b0c26927dc3413b12a5368fe367b0
Author:     Jens Carl <j.car...@gmx.de>
AuthorDate: Tue Dec 4 09:29:11 2018 +0000
Commit:     Jens Carl <j.car...@gmx.de>
CommitDate: Wed Dec 5 04:45:59 2018 +0100

    tdf#45904 Move XRefreshable Java tests to C++
    
    Move XRefreshable Java tests to C++ for ScDDELinkObj.
    
    Change-Id: I121d9fe6a66c549e402b0cf6fd54fea1201e443f
    Reviewed-on: https://gerrit.libreoffice.org/64511
    Tested-by: Jenkins
    Reviewed-by: Jens Carl <j.car...@gmx.de>

diff --git a/framework/qa/complex/api_internal/api.lst 
b/framework/qa/complex/api_internal/api.lst
index a4b45dfd2053..4f1cc7cb2540 100644
--- a/framework/qa/complex/api_internal/api.lst
+++ b/framework/qa/complex/api_internal/api.lst
@@ -84,7 +84,6 @@ job89=sc.ScDatabaseRangesObj
 job90=sc.ScDataPilotFieldObj
 job91=sc.ScDataPilotFieldsObj
 job92=sc.ScDataPilotTablesObj
-job93=sc.ScDDELinkObj
 job94=sc.ScDDELinksObj
 job95=sc.ScDrawPagesObj
 job96=sc.ScFilterDescriptorBase
diff --git a/include/test/util/xrefreshable.hxx 
b/include/test/util/xrefreshable.hxx
new file mode 100644
index 000000000000..2ffab9946e4a
--- /dev/null
+++ b/include/test/util/xrefreshable.hxx
@@ -0,0 +1,38 @@
+/* -*- 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_UTIL_XREFRESHABLE_HXX
+#define INCLUDED_TEST_UTIL_XREFRESHABLE_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 XRefreshable
+{
+public:
+    virtual css::uno::Reference<css::uno::XInterface> init() = 0;
+
+    void testAddRefreshListener();
+    void testRefresh();
+    void testRemoveRefreshListener();
+
+protected:
+    ~XRefreshable() {}
+};
+
+} // namespace apitest
+
+#endif // INCLUDED_TEST_UTIL_XREFRESHABLE_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 9de56bbe02dd..80b62f084af6 100644
--- a/qadevOOo/Jar_OOoRunner.mk
+++ b/qadevOOo/Jar_OOoRunner.mk
@@ -978,7 +978,6 @@ $(eval $(call gb_Jar_add_sourcefiles,OOoRunner,\
     qadevOOo/tests/java/mod/_sc/ScDataPilotItemObj \
     qadevOOo/tests/java/mod/_sc/ScDataPilotItemsObj \
     qadevOOo/tests/java/mod/_sc/ScDataPilotTablesObj \
-    qadevOOo/tests/java/mod/_sc/ScDDELinkObj \
     qadevOOo/tests/java/mod/_sc/ScDDELinksObj \
     qadevOOo/tests/java/mod/_sc/ScDocumentConfiguration \
     qadevOOo/tests/java/mod/_sc/ScDrawPageObj \
diff --git a/qadevOOo/objdsc/sc/com.sun.star.comp.office.ScDDELinkObj.csv 
b/qadevOOo/objdsc/sc/com.sun.star.comp.office.ScDDELinkObj.csv
deleted file mode 100644
index 651b7c6ffebd..000000000000
--- a/qadevOOo/objdsc/sc/com.sun.star.comp.office.ScDDELinkObj.csv
+++ /dev/null
@@ -1,3 +0,0 @@
-"ScDDELinkObj";"com::sun::star::util::XRefreshable";"refresh()"
-"ScDDELinkObj";"com::sun::star::util::XRefreshable";"addRefreshListener()"
-"ScDDELinkObj";"com::sun::star::util::XRefreshable";"removeRefreshListener()"
diff --git a/qadevOOo/tests/java/mod/_sc/ScDDELinkObj.java 
b/qadevOOo/tests/java/mod/_sc/ScDDELinkObj.java
deleted file mode 100644
index 04e9beebb8c5..000000000000
--- a/qadevOOo/tests/java/mod/_sc/ScDDELinkObj.java
+++ /dev/null
@@ -1,181 +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.beans.XPropertySet;
-import com.sun.star.container.XIndexAccess;
-import com.sun.star.container.XNameAccess;
-import com.sun.star.lang.XComponent;
-import com.sun.star.lang.XMultiServiceFactory;
-import com.sun.star.sheet.XSpreadsheet;
-import com.sun.star.sheet.XSpreadsheetDocument;
-import com.sun.star.sheet.XSpreadsheets;
-import com.sun.star.uno.AnyConverter;
-import com.sun.star.uno.Type;
-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.DDELink</code>. <p>
-* Object implements the following interfaces :
-* <ul>
-*  <li> <code>com::sun::star::container::XNamed</code></li>
-*  <li> <code>com::sun::star::util::XRefreshable</code></li>
-*  <li> <code>com::sun::star::sheet::XDDELink</code></li>
-* </ul>
-* The following files used by this test :
-* <ul>
-*  <li><b> ScDDELinksObj.ods </b> : the predefined testdocument </li>
-* </ul> <p>
-* @see com.sun.star.sheet.DDELink
-* @see com.sun.star.container.XNamed
-* @see com.sun.star.util.XRefreshable
-* @see com.sun.star.sheet.XDDELink
-* @see ifc.container._XNamed
-* @see ifc.util._XRefreshable
-* @see ifc.sheet._XDDELink
-*/
-public class ScDDELinkObj extends TestCase {
-    private XSpreadsheetDocument xSheetDoc = null;
-    static XComponent oDoc = 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 and testdocument if it was loaded already.
-    */
-    @Override
-    protected void cleanup( TestParameters tParam, PrintWriter log ) {
-        log.println( "    disposing xSheetDoc " );
-        XComponent oComp = UnoRuntime.queryInterface(XComponent.class, 
xSheetDoc) ;
-        util.DesktopTools.closeDoc(oComp);
-        if (oDoc != null) {
-            util.DesktopTools.closeDoc(oDoc);
-        }
-    }
-
-    /**
-    * Creating a TestEnvironment for the interfaces to be tested.
-    * Disposes the testdocument if it was loaded already.
-    * Creates an instance of the <code>com.sun.star.frame.Desktop</code>
-    * and loads the predefined testdocument. Retrieves a collection of
-    * spreadsheets from a document and takes one of them. Sets specific formula
-    * to some cells in the spreadsheet(the formula specify DDE links to the
-    * testdocument). Retrieves the collection of DDE links in the document and
-    * retrieves first DDE link from the collection.
-    * The retrieved DDE link is the instance of the service
-    * <code>com.sun.star.sheet.DDELink</code>.
-    * Object relations created :
-    * <ul>
-    *  <li> <code>'setName'</code> for
-    *      {@link ifc.container._XNamed}(specify that the method
-    *      <code>setName</code> must not be tested)</li>
-    *  <li> <code>'APPLICATION'</code> for
-    *      {@link ifc.sheet._XDDELink}(the name of the current 
application)</li>
-    *  <li> <code>'ITEM'</code> for
-    *      {@link ifc.sheet._XDDELink}(the DDE item that was set in the 
formula)</li>
-    *  <li> <code>'TOPIC'</code> for
-    *      {@link ifc.sheet._XDDELink}(the full testdocument name)</li>
-    * </ul>
-    * @see com.sun.star.frame.Desktop
-    * @see com.sun.star.sheet.DDELink
-    */
-    @Override
-    protected TestEnvironment createTestEnvironment(TestParameters Param, 
PrintWriter log) throws Exception {
-
-        XInterface oObj = null;
-
-        if (oDoc != null) {
-            util.DesktopTools.closeDoc(oDoc);
-        }
-
-        // 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
-
-        XMultiServiceFactory oMSF = Param.getMSF();
-
-        // load the predefined testdocument
-        String testdoc = util.utils.getFullTestURL("ScDDELinksObj.ods");
-        oDoc = SOfficeFactory.getFactory(oMSF).loadDocument(testdoc);
-
-        log.println("getting sheets");
-        XSpreadsheets xSpreadsheets = xSheetDoc.getSheets();
-
-        log.println("getting a sheet");
-        XSpreadsheet oSheet = null;
-        XIndexAccess oIndexAccess = 
UnoRuntime.queryInterface(XIndexAccess.class, xSpreadsheets);
-        oSheet = (XSpreadsheet) AnyConverter.toObject(
-                new Type(XSpreadsheet.class),oIndexAccess.getByIndex(0));
-
-        log.println("filling some cells");
-        String sAppl = "soffice";
-        String sItem = "Sheet1.A1";
-        testdoc = util.utils.getFullTestDocName("ScDDELinksObj.ods");
-        oSheet.getCellByPosition(5, 5).setFormula(
-            "=DDE(\""+ sAppl +"\";\""+testdoc+"\";\""+ sItem +"\"");
-        oSheet.getCellByPosition(1, 4).setFormula(
-            "=DDE(\""+ sAppl +"\";\""+testdoc+"\";\""+ sItem +"\"");
-
-        log.println("Getting test object ") ;
-
-        // Getting named ranges.
-        XPropertySet docProps = UnoRuntime.queryInterface(XPropertySet.class, 
xSheetDoc);
-        XNameAccess links = (XNameAccess) AnyConverter.toObject(
-            new Type(XNameAccess.class), UnoRuntime.queryInterface(
-                XNameAccess.class, docProps.getPropertyValue("DDELinks")));
-
-        String[] linkNames = links.getElementNames();
-
-        oObj = (XInterface) AnyConverter.toObject(
-            new Type(XInterface.class),links.getByName(linkNames[0]));
-        log.println("Creating object - " +
-                                        ((oObj == null) ? "FAILED" : "OK"));
-
-        TestEnvironment tEnv = new TestEnvironment( oObj );
-
-        // Other parameters required for interface tests
-        tEnv.addObjRelation("APPLICATION", sAppl);
-        tEnv.addObjRelation("ITEM", sItem);
-        tEnv.addObjRelation("TOPIC", testdoc);
-        tEnv.addObjRelation("setName", Boolean.TRUE);
-
-        return tEnv;
-    }
-
-}
-
-
diff --git a/sc/qa/extras/scddelinkobj.cxx b/sc/qa/extras/scddelinkobj.cxx
index 2b2263af5df6..204c5b6f8ace 100644
--- a/sc/qa/extras/scddelinkobj.cxx
+++ b/sc/qa/extras/scddelinkobj.cxx
@@ -10,6 +10,7 @@
 #include <test/calc_unoapi_test.hxx>
 #include <test/container/xnamed.hxx>
 #include <test/sheet/xddelink.hxx>
+#include <test/util/xrefreshable.hxx>
 
 #include <com/sun/star/beans/XPropertySet.hpp>
 #include <com/sun/star/container/XIndexAccess.hpp>
@@ -30,7 +31,10 @@ using namespace com::sun::star;
 
 namespace sc_apitest
 {
-class ScDDELinkObj : public CalcUnoApiTest, public apitest::XDDELink, public 
apitest::XNamed
+class ScDDELinkObj : public CalcUnoApiTest,
+                     public apitest::XDDELink,
+                     public apitest::XNamed,
+                     public apitest::XRefreshable
 {
 public:
     ScDDELinkObj();
@@ -50,6 +54,11 @@ public:
     CPPUNIT_TEST(testGetName);
     CPPUNIT_TEST(testSetNameThrowsException);
 
+    // XRefreshable
+    CPPUNIT_TEST(testAddRefreshListener);
+    CPPUNIT_TEST(testRefresh);
+    CPPUNIT_TEST(testRemoveRefreshListener);
+
     CPPUNIT_TEST_SUITE_END();
 
 private:
diff --git a/sc/qa/unoapi/sc_3.sce b/sc/qa/unoapi/sc_3.sce
index 1848392779a8..953875a3f94d 100644
--- a/sc/qa/unoapi/sc_3.sce
+++ b/sc/qa/unoapi/sc_3.sce
@@ -21,5 +21,4 @@
 -o sc.ScCellTextCursor
 -o sc.ScChartObj
 -o sc.ScChartsObj
--o sc.ScDDELinkObj
 -o sc.ScDDELinksObj
diff --git a/test/Library_subsequenttest.mk b/test/Library_subsequenttest.mk
index b6ca7bfa4085..78c2e7f6a727 100644
--- a/test/Library_subsequenttest.mk
+++ b/test/Library_subsequenttest.mk
@@ -159,6 +159,7 @@ $(eval $(call 
gb_Library_add_exception_objects,subsequenttest,\
        test/source/text/xtextfield \
        test/source/util/xindent \
        test/source/util/xmergeable \
+       test/source/util/xrefreshable \
        test/source/util/xreplaceable \
        test/source/util/xsearchable \
 ))
diff --git a/test/source/util/xrefreshable.cxx 
b/test/source/util/xrefreshable.cxx
new file mode 100644
index 000000000000..174115e64289
--- /dev/null
+++ b/test/source/util/xrefreshable.cxx
@@ -0,0 +1,81 @@
+/* -*- 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/util/xrefreshable.hxx>
+
+#include <com/sun/star/lang/EventObject.hpp>
+#include <com/sun/star/util/XRefreshListener.hpp>
+#include <com/sun/star/util/XRefreshable.hpp>
+
+#include <com/sun/star/uno/Reference.hxx>
+
+#include <cppuhelper/implbase.hxx>
+#include <rtl/ref.hxx>
+
+#include <cppunit/extensions/HelperMacros.h>
+
+using namespace com::sun::star;
+using namespace com::sun::star::uno;
+
+namespace apitest
+{
+class MockedRefreshListener : public 
::cppu::WeakImplHelper<util::XRefreshListener>
+{
+public:
+    MockedRefreshListener()
+        : m_bListenerCalled(false)
+    {
+    }
+
+    bool m_bListenerCalled;
+    virtual void SAL_CALL refreshed(const lang::EventObject& /* xEvent */) 
override
+    {
+        m_bListenerCalled = true;
+    }
+    virtual void SAL_CALL disposing(const lang::EventObject& /* xEventObj */) 
override {}
+};
+
+void XRefreshable::testAddRefreshListener()
+{
+    uno::Reference<util::XRefreshable> xRefreshable(init(), 
uno::UNO_QUERY_THROW);
+
+    rtl::Reference<MockedRefreshListener> xListener = new 
MockedRefreshListener();
+    
xRefreshable->addRefreshListener(uno::Reference<util::XRefreshListener>(xListener.get()));
+}
+
+void XRefreshable::testRefresh()
+{
+    uno::Reference<util::XRefreshable> xRefreshable(init(), 
uno::UNO_QUERY_THROW);
+
+    rtl::Reference<MockedRefreshListener> xListener = new 
MockedRefreshListener();
+    
xRefreshable->addRefreshListener(uno::Reference<util::XRefreshListener>(xListener.get()));
+
+    xRefreshable->refresh();
+
+    CPPUNIT_ASSERT(xListener->m_bListenerCalled);
+}
+
+void XRefreshable::testRemoveRefreshListener()
+{
+    uno::Reference<util::XRefreshable> xRefreshable(init(), 
uno::UNO_QUERY_THROW);
+
+    rtl::Reference<MockedRefreshListener> xListener = new 
MockedRefreshListener();
+    
xRefreshable->addRefreshListener(uno::Reference<util::XRefreshListener>(xListener.get()));
+
+    xRefreshable->refresh();
+    CPPUNIT_ASSERT(xListener->m_bListenerCalled);
+
+    xListener->m_bListenerCalled = false;
+    
xRefreshable->removeRefreshListener(uno::Reference<util::XRefreshListener>(xListener.get()));
+    xRefreshable->refresh();
+    CPPUNIT_ASSERT(!xListener->m_bListenerCalled);
+}
+
+} // namespace apitest
+/* vim:set shiftwidth=4 softtabstop=4 expandtab cinoptions=b1,g0,N-s 
cinkeys+=0=break: */
_______________________________________________
Libreoffice-commits mailing list
libreoffice-comm...@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/libreoffice-commits

Reply via email to