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

Jens Carl j.carl43 at gmx.de
Wed Aug 23 21:39:35 UTC 2017


 include/test/sheet/xarealink.hxx                              |   38 ++
 qadevOOo/Jar_OOoRunner.mk                                     |    1 
 qadevOOo/objdsc/sc/com.sun.star.comp.office.ScAreaLinkObj.csv |    4 
 qadevOOo/tests/java/ifc/sheet/_XAreaLink.java                 |  150 ----------
 sc/CppunitTest_sc_arealinkobj.mk                              |  107 +++++++
 sc/Module_sc.mk                                               |    1 
 sc/qa/extras/scarealinkobj.cxx                                |  105 +++++++
 test/Library_subsequenttest.mk                                |    1 
 test/source/sheet/xarealink.cxx                               |   79 +++++
 9 files changed, 331 insertions(+), 155 deletions(-)

New commits:
commit aeb525c0f97727bc9add5bf9923adb69c2989aa0
Author: Jens Carl <j.carl43 at gmx.de>
Date:   Mon Aug 7 23:17:51 2017 +0000

    tdf#45904 Move Java _XAreaLink tests to C++
    
    Change-Id: I95112555de3a5dd5a75c478edb5856cf79919db9
    Reviewed-on: https://gerrit.libreoffice.org/40859
    Tested-by: Jenkins <ci at libreoffice.org>
    Reviewed-by: Markus Mohrhard <markus.mohrhard at googlemail.com>

diff --git a/include/test/sheet/xarealink.hxx b/include/test/sheet/xarealink.hxx
new file mode 100644
index 000000000000..4dae48cc1e10
--- /dev/null
+++ b/include/test/sheet/xarealink.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_SHEET_XAREALINK_HXX
+#define INCLUDED_TEST_SHEET_XAREALINK_HXX
+
+#include <com/sun/star/uno/XInterface.hpp>
+#include <com/sun/star/uno/Reference.hxx>
+#include <test/testdllapi.hxx>
+
+using namespace css;
+using namespace css::uno;
+
+namespace apitest {
+
+class OOO_DLLPUBLIC_TEST XAreaLink
+{
+public:
+    virtual uno::Reference< uno::XInterface > init() = 0;
+    virtual ~XAreaLink(){}
+
+    void testGetSourceArea();
+    void testSetSourceArea();
+    void testGetDestArea();
+    void testSetDestArea();
+};
+
+}
+
+#endif // INCLUDED_TEST_SHEET_XAREALINK_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 c777ff48ee76..0808ae1dc59b 100644
--- a/qadevOOo/Jar_OOoRunner.mk
+++ b/qadevOOo/Jar_OOoRunner.mk
@@ -587,7 +587,6 @@ $(eval $(call gb_Jar_add_sourcefiles,OOoRunner,\
     qadevOOo/tests/java/ifc/sheet/_TableAutoFormatField \
     qadevOOo/tests/java/ifc/sheet/_TableValidation \
     qadevOOo/tests/java/ifc/sheet/_XActivationBroadcaster \
-    qadevOOo/tests/java/ifc/sheet/_XAreaLink \
     qadevOOo/tests/java/ifc/sheet/_XAreaLinks \
     qadevOOo/tests/java/ifc/sheet/_XArrayFormulaRange \
     qadevOOo/tests/java/ifc/sheet/_XCalculatable \
diff --git a/qadevOOo/objdsc/sc/com.sun.star.comp.office.ScAreaLinkObj.csv b/qadevOOo/objdsc/sc/com.sun.star.comp.office.ScAreaLinkObj.csv
index 109b4fa38003..a16e668d5547 100644
--- a/qadevOOo/objdsc/sc/com.sun.star.comp.office.ScAreaLinkObj.csv
+++ b/qadevOOo/objdsc/sc/com.sun.star.comp.office.ScAreaLinkObj.csv
@@ -6,10 +6,6 @@
 "ScAreaLinkObj";"com::sun::star::util::XRefreshable";"refresh()"
 "ScAreaLinkObj";"com::sun::star::util::XRefreshable";"addRefreshListener()"
 "ScAreaLinkObj";"com::sun::star::util::XRefreshable";"removeRefreshListener()"
-"ScAreaLinkObj";"com::sun::star::sheet::XAreaLink";"getSourceArea()"
-"ScAreaLinkObj";"com::sun::star::sheet::XAreaLink";"setSourceArea()"
-"ScAreaLinkObj";"com::sun::star::sheet::XAreaLink";"getDestArea()"
-"ScAreaLinkObj";"com::sun::star::sheet::XAreaLink";"setDestArea()"
 "ScAreaLinkObj";"com::sun::star::beans::XPropertySet";"getPropertySetInfo()"
 "ScAreaLinkObj";"com::sun::star::beans::XPropertySet";"setPropertyValue()"
 "ScAreaLinkObj";"com::sun::star::beans::XPropertySet";"getPropertyValue()"
diff --git a/qadevOOo/tests/java/ifc/sheet/_XAreaLink.java b/qadevOOo/tests/java/ifc/sheet/_XAreaLink.java
deleted file mode 100644
index 51adc5ef76cb..000000000000
--- a/qadevOOo/tests/java/ifc/sheet/_XAreaLink.java
+++ /dev/null
@@ -1,150 +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 com.sun.star.sheet.XAreaLink;
-import com.sun.star.table.CellRangeAddress;
-
-/**
-* Testing <code>com.sun.star.sheet.XAreaLink</code>
-* interface methods :
-* <ul>
-*  <li><code> getSourceArea()</code></li>
-*  <li><code> setSourceArea()</code></li>
-*  <li><code> getDestArea()</code></li>
-*  <li><code> setDestArea()</code></li>
-* </ul> <p>
-* Test is <b> NOT </b> multithread compliant. <p>
-* @see com.sun.star.sheet.XAreaLink
-*/
-public class _XAreaLink extends MultiMethodTest {
-
-    public XAreaLink oObj = null;
-    CellRangeAddress oORAdd, oNRAdd, oCRAdd = null;
-
-    /**
-    * Just calls the method and checks the value returned.
-    * (More complicated testing done in <code>setDestArea</code>)<p>
-    * Has <b>OK</b> status if not null value returned.
-    */
-    public void _getDestArea(){
-        log.println("testing getDestArea()");
-        boolean bResult = false;
-        oORAdd = oObj.getDestArea();
-        if (oORAdd != null){ bResult = true; }
-        tRes.tested("getDestArea()", bResult) ;
-    }
-
-    /**
-    * Just calls the method and checks the value returned.
-    * (More complicated testing done in <code>setSourceArea</code>)<p>
-    * Has <b>OK</b> status if not null value returned.
-    */
-    public void _getSourceArea(){
-        log.println("testing getSourceArea()");
-        boolean bResult = false;
-        String src = null;
-        src = oObj.getSourceArea() ;
-        if (src != null){ bResult = true; }
-        tRes.tested("getSourceArea()", bResult) ;
-    }
-
-    /**
-    * Creates a new destination CellRange address and sets it for
-    * the link object. <p>
-    * After setting the DestArea, the link is refreshed and the area is
-    * adjusted to the size of the source data.
-    * Therefore EndCol and EndRow will change after setting. <p>
-    * Has <b>OK</b> status if Sheet, Starting Column and Row
-    * of the destination range is changed correctly.
-    */
-    public void _setDestArea(){
-        log.println("testing setDestArea()");
-        boolean bResult = false;
-        int newStartCol = 3, newStartRow = 4, newEndCol = 5, newEndRow = 8 ;
-        oORAdd = oObj.getDestArea();
-        log.print("Getting: ");
-        log.println(getCRA(oORAdd));
-        oNRAdd = new CellRangeAddress ((short) 2, newStartCol, newStartRow,
-                                                    newEndCol, newEndRow) ;
-        oObj.setDestArea(oNRAdd) ;
-        log.print("Setting: ");
-        log.println(getCRA(oNRAdd));
-        oCRAdd = oObj.getDestArea();
-        log.print("Getting: ");
-        log.println(getCRA(oCRAdd));
-        // After setting the DestArea, the link is refreshed and the area is
-        // adjusted to the size of the source data.
-        // Therefore EndCol and EndRow will change after setting.
-        log.println("After setting the DestArea, the link is refreshed "+
-            "and the area is");
-        log.println("adjusted to the size of the source data.");
-        log.println("Therefore only 'Sheet', 'StartCol' and 'StartRow' "+
-            "are compared.");
-        if ((oCRAdd.StartColumn == oNRAdd.StartColumn) &&
-                (oCRAdd.Sheet == oNRAdd.Sheet) &&
-                (oCRAdd.StartRow == oNRAdd.StartRow)){
-            bResult = true;
-            oObj.setDestArea(oORAdd);
-        }
-        tRes.tested("setDestArea()", bResult) ;
-    }
-
-    /**
-    * Sets a new source area for the link and then check
-    * it using <code>getSourceArea</code>  method. <p>
-    * Has <b>OK</b> status if areas set and get are equal.
-    */
-    public void _setSourceArea(){
-        log.println("testing setSourceArea()");
-        boolean bResult = false;
-        String oSrc = oObj.getSourceArea() ;
-        String nSrc = "a1:b2";
-        oObj.setSourceArea(nSrc);
-        String cSrc = oObj.getSourceArea();
-        if( nSrc.equals(cSrc)){
-            bResult = true;
-            oObj.setSourceArea(oSrc);
-        }
-        tRes.tested("setSourceArea()", bResult) ;
-    }
-
-    /**
-    * Prints cell range structure to LOG
-    */
-    public String getCRA ( CellRangeAddress oCRA ) {
-        String res = "( Sheet: ";
-        res += oCRA.Sheet;
-        res += ";StartColumn: ";
-        res += oCRA.StartColumn;
-        res += ";StartRow: ";
-        res += oCRA.StartRow;
-        res += ";EndColumn: ";
-        res += oCRA.EndColumn;
-        res += ";EndRow: ";
-        res += oCRA.EndRow;
-        res += " )";
-        return res;
-    }
-
-} // EOC _XAreaLink
-
-
diff --git a/sc/CppunitTest_sc_arealinkobj.mk b/sc/CppunitTest_sc_arealinkobj.mk
new file mode 100644
index 000000000000..042672f6e605
--- /dev/null
+++ b/sc/CppunitTest_sc_arealinkobj.mk
@@ -0,0 +1,107 @@
+# -*- 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_arealinkobj))
+
+$(eval $(call gb_CppunitTest_add_exception_objects,sc_arealinkobj, \
+    sc/qa/extras/scarealinkobj \
+))
+
+$(eval $(call gb_CppunitTest_use_external,sc_arealinkobj,boost_headers))
+
+$(eval $(call gb_CppunitTest_use_libraries,sc_arealinkobj, \
+    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_arealinkobj,\
+    -I$(SRCDIR)/sc/source/ui/inc \
+    -I$(SRCDIR)/sc/inc \
+    $$(INCLUDE) \
+))
+
+$(eval $(call gb_CppunitTest_use_sdk_api,sc_arealinkobj))
+
+$(eval $(call gb_CppunitTest_use_ure,sc_arealinkobj))
+$(eval $(call gb_CppunitTest_use_vcl,sc_arealinkobj))
+
+$(eval $(call gb_CppunitTest_use_components,sc_arealinkobj,\
+    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_arealinkobj))
+
+# vim: set noet sw=4 ts=4:
+
+
diff --git a/sc/Module_sc.mk b/sc/Module_sc.mk
index 766069c2676d..3afc8d8cfeb0 100644
--- a/sc/Module_sc.mk
+++ b/sc/Module_sc.mk
@@ -127,6 +127,7 @@ $(eval $(call gb_Module_add_subsequentcheck_targets,sc,\
 	CppunitTest_sc_cellobj \
 	CppunitTest_sc_cellcursorobj \
 	CppunitTest_sc_tabviewobj \
+	CppunitTest_sc_arealinkobj \
 ))
 
 $(eval $(call gb_Module_add_perfcheck_targets,sc,\
diff --git a/sc/qa/extras/scarealinkobj.cxx b/sc/qa/extras/scarealinkobj.cxx
new file mode 100644
index 000000000000..f918f5116356
--- /dev/null
+++ b/sc/qa/extras/scarealinkobj.cxx
@@ -0,0 +1,105 @@
+/* -*- 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/xarealink.hxx>
+
+#include <com/sun/star/beans/XPropertySet.hpp>
+#include <com/sun/star/lang/XComponent.hpp>
+#include <com/sun/star/sheet/XAreaLink.hpp>
+#include <com/sun/star/sheet/XAreaLinks.hpp>
+#include <com/sun/star/sheet/XSpreadsheetDocument.hpp>
+#include <com/sun/star/table/CellAddress.hpp>
+
+#include <com/sun/star/uno/XInterface.hpp>
+#include <com/sun/star/uno/Reference.hxx>
+
+using namespace css;
+using namespace css::uno;
+
+namespace sc_apitest {
+
+#define NUMBER_OF_TESTS 4
+
+class ScAreaLink : public CalcUnoApiTest, public apitest::XAreaLink
+{
+public:
+    ScAreaLink();
+
+    virtual uno::Reference< uno::XInterface > init() override;
+    virtual void setUp() override;
+    virtual void tearDown() override;
+
+    CPPUNIT_TEST_SUITE(ScAreaLink);
+
+    // XAreaLink
+    CPPUNIT_TEST(testGetDestArea);
+    CPPUNIT_TEST(testGetSourceArea);
+    CPPUNIT_TEST(testSetSourceArea);
+    CPPUNIT_TEST(testSetDestArea);
+
+    CPPUNIT_TEST_SUITE_END();
+
+private:
+    static sal_Int32 nTest;
+    static uno::Reference< lang::XComponent > mxComponent;
+
+};
+
+sal_Int32 ScAreaLink::nTest = 0;
+uno::Reference< lang::XComponent > ScAreaLink::mxComponent;
+
+ScAreaLink::ScAreaLink()
+    : CalcUnoApiTest("/sc/qa/extras/testdocuments")
+{
+}
+
+uno::Reference< uno::XInterface > ScAreaLink::init()
+{
+    // create a calc document
+    if (!mxComponent.is())
+        mxComponent = loadFromDesktop("private:factory/scalc");
+
+    uno::Reference< sheet::XSpreadsheetDocument > xDoc(mxComponent, uno::UNO_QUERY_THROW);
+    CPPUNIT_ASSERT_MESSAGE("no calc document", xDoc.is());
+
+    uno::Reference< beans::XPropertySet > xPropSet(xDoc, uno::UNO_QUERY_THROW);
+    uno::Reference< sheet::XAreaLinks > xLinks(xPropSet->getPropertyValue("AreaLinks"), uno::UNO_QUERY_THROW);
+
+    table::CellAddress aCellAddress(1, 2, 3);
+    xLinks->insertAtPosition(aCellAddress, "", "a1:c1", "", "");
+
+    uno::Reference< sheet::XAreaLink > xLink( xLinks->getByIndex(0), uno::UNO_QUERY_THROW);
+    return xLink;
+}
+
+void ScAreaLink::setUp()
+{
+    nTest++;
+    CalcUnoApiTest::setUp();
+}
+
+void ScAreaLink::tearDown()
+{
+    if (nTest == NUMBER_OF_TESTS)
+    {
+        closeDocument(mxComponent);
+        mxComponent.clear();
+    }
+
+    CalcUnoApiTest::tearDown();
+}
+
+CPPUNIT_TEST_SUITE_REGISTRATION(ScAreaLink);
+
+} // 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 bc442ba621b9..8d1402d4f383 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/cellproperties \
 	test/source/sheet/datapilotfield \
+	test/source/sheet/xarealink \
 	test/source/sheet/xcelladdressable \
 	test/source/sheet/xcellrangedata \
 	test/source/sheet/xcellrangereferrer \
diff --git a/test/source/sheet/xarealink.cxx b/test/source/sheet/xarealink.cxx
new file mode 100644
index 000000000000..6a5f99c485fe
--- /dev/null
+++ b/test/source/sheet/xarealink.cxx
@@ -0,0 +1,79 @@
+/* -*- 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/xarealink.hxx>
+
+#include <com/sun/star/sheet/XAreaLink.hpp>
+#include <com/sun/star/table/CellRangeAddress.hpp>
+#include <com/sun/star/uno/Reference.hxx>
+
+#include "cppunit/extensions/HelperMacros.h"
+
+using namespace com::sun::star;
+using namespace com::sun::star::uno;
+
+CPPUNIT_NS_BEGIN
+
+template<> struct assertion_traits<table::CellRangeAddress>
+{
+    static bool equal(const table::CellRangeAddress& x, const table::CellRangeAddress& y)
+    {
+        return x == y;
+    }
+
+    static std::string toString( const table::CellRangeAddress& x )
+    {
+        OStringStream ost;
+        ost << "Sheet: " << x.Sheet << " StartColumn: " << x.StartColumn << " StartRow: " << x.StartRow
+            << " EndColumn: " << x.EndColumn << " EndRow: " << x.EndRow;
+        return ost.str();
+    }
+};
+
+CPPUNIT_NS_END
+
+namespace apitest {
+
+void XAreaLink::testSetDestArea()
+{
+    uno::Reference< sheet::XAreaLink > xAreaLink(init(), UNO_QUERY_THROW);
+
+    xAreaLink->setDestArea(table::CellRangeAddress(1,3,4,5,8));
+    CPPUNIT_ASSERT_EQUAL_MESSAGE("Couldn't set new dest area",
+                                 table::CellRangeAddress(1,3,4,5,8), xAreaLink->getDestArea());
+}
+
+void XAreaLink::testSetSourceArea()
+{
+    uno::Reference< sheet::XAreaLink > xAreaLink(init(), UNO_QUERY_THROW);
+
+    xAreaLink->setSourceArea("Sheet1.A1:B1");
+    CPPUNIT_ASSERT_EQUAL_MESSAGE("Couldn't set new source area",
+                                 OUString("Sheet1.A1:B1"), xAreaLink->getSourceArea());
+}
+
+void XAreaLink::testGetDestArea()
+{
+    uno::Reference< sheet::XAreaLink > xAreaLink(init(), UNO_QUERY_THROW);
+
+    CPPUNIT_ASSERT_EQUAL_MESSAGE("Couldn't get dest area",
+                                 table::CellRangeAddress(1,2,3,2,3), xAreaLink->getDestArea());
+}
+
+void XAreaLink::testGetSourceArea()
+{
+    uno::Reference< sheet::XAreaLink > xAreaLink(init(), UNO_QUERY_THROW);
+
+    CPPUNIT_ASSERT_EQUAL_MESSAGE("Couldn't get source area",
+                                 OUString("a1:c1"), xAreaLink->getSourceArea());
+}
+
+}
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab cinoptions=b1,g0,N-s cinkeys+=0=break: */


More information about the Libreoffice-commits mailing list