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

Jens Carl j.carl43 at gmx.de
Fri Nov 3 18:09:10 UTC 2017


 include/test/sheet/xsheetcellrangecontainer.hxx                 |   40 ++
 qadevOOo/Jar_OOoRunner.mk                                       |    1 
 qadevOOo/objdsc/sc/com.sun.star.comp.office.ScCellRangesObj.csv |    4 
 qadevOOo/tests/java/ifc/sheet/_XSheetCellRangeContainer.java    |  198 ----------
 sc/qa/extras/sccellrangesobj.cxx                                |   10 
 test/Library_subsequenttest.mk                                  |    1 
 test/source/sheet/xsheetcellrangecontainer.cxx                  |  121 ++++++
 7 files changed, 170 insertions(+), 205 deletions(-)

New commits:
commit 6f29841acb201b118bbf5815163fb50d83929e9f
Author: Jens Carl <j.carl43 at gmx.de>
Date:   Fri Nov 3 07:15:10 2017 +0000

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

diff --git a/include/test/sheet/xsheetcellrangecontainer.hxx b/include/test/sheet/xsheetcellrangecontainer.hxx
new file mode 100644
index 000000000000..f0b0c7355420
--- /dev/null
+++ b/include/test/sheet/xsheetcellrangecontainer.hxx
@@ -0,0 +1,40 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*
+ * 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_XSHEETCELLRANGECONTAINER_HXX
+#define INCLUDED_TEST_SHEET_XSHEETCELLRANGECONTAINER_HXX
+
+#include <com/sun/star/table/CellRangeAddress.hpp>
+
+#include <com/sun/star/uno/XInterface.hpp>
+#include <com/sun/star/uno/Reference.hxx>
+#include <com/sun/star/uno/Sequence.hxx>
+
+#include <test/testdllapi.hxx>
+
+namespace apitest {
+
+class OOO_DLLPUBLIC_TEST XSheetCellRangeContainer
+{
+public:
+    virtual css::uno::Reference< css::uno::XInterface > init() =0;
+
+    void testAddRemoveRangeAddress();
+    void testAddRemoveRangeAddresses();
+
+protected:
+    ~XSheetCellRangeContainer() {}
+    css::uno::Sequence< com::sun::star::table::CellRangeAddress > createCellRangeAddresses();
+};
+
+}
+
+#endif // INCLUDED_TEST_SHEET_XSHEETCELLRANGECONTAINER_HXX
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/qadevOOo/Jar_OOoRunner.mk b/qadevOOo/Jar_OOoRunner.mk
index 16ebecb84344..7faba4235a32 100644
--- a/qadevOOo/Jar_OOoRunner.mk
+++ b/qadevOOo/Jar_OOoRunner.mk
@@ -618,7 +618,6 @@ $(eval $(call gb_Jar_add_sourcefiles,OOoRunner,\
     qadevOOo/tests/java/ifc/sheet/_XSheetAnnotationsSupplier \
     qadevOOo/tests/java/ifc/sheet/_XSheetAuditing \
     qadevOOo/tests/java/ifc/sheet/_XSheetCellCursor \
-    qadevOOo/tests/java/ifc/sheet/_XSheetCellRangeContainer \
     qadevOOo/tests/java/ifc/sheet/_XSheetFilterableEx \
     qadevOOo/tests/java/ifc/sheet/_XSpreadsheetView \
     qadevOOo/tests/java/ifc/style/_CharacterProperties \
diff --git a/qadevOOo/objdsc/sc/com.sun.star.comp.office.ScCellRangesObj.csv b/qadevOOo/objdsc/sc/com.sun.star.comp.office.ScCellRangesObj.csv
index a17fa72c561f..bedb81212c36 100644
--- a/qadevOOo/objdsc/sc/com.sun.star.comp.office.ScCellRangesObj.csv
+++ b/qadevOOo/objdsc/sc/com.sun.star.comp.office.ScCellRangesObj.csv
@@ -113,10 +113,6 @@
 "ScCellRangesObj";"com::sun::star::style::CharacterPropertiesComplex";"CharFontPitchComplex"
 "ScCellRangesObj";"com::sun::star::style::CharacterPropertiesComplex";"CharPostureComplex"
 "ScCellRangesObj";"com::sun::star::style::CharacterPropertiesComplex";"CharLocaleComplex"
-"ScCellRangesObj";"com::sun::star::sheet::XSheetCellRangeContainer";"addRangeAddress()"
-"ScCellRangesObj";"com::sun::star::sheet::XSheetCellRangeContainer";"removeRangeAddress()"
-"ScCellRangesObj";"com::sun::star::sheet::XSheetCellRangeContainer";"addRangeAddresses()"
-"ScCellRangesObj";"com::sun::star::sheet::XSheetCellRangeContainer";"removeRangeAddresses()"
 "ScCellRangesObj";"com::sun::star::sheet::XFormulaQuery";"queryDependents()"
 "ScCellRangesObj";"com::sun::star::sheet::XFormulaQuery";"queryPrecedents()"
 "ScCellRangesObj";"com::sun::star::sheet::SheetCellRanges";"ConditionalFormat"
diff --git a/qadevOOo/tests/java/ifc/sheet/_XSheetCellRangeContainer.java b/qadevOOo/tests/java/ifc/sheet/_XSheetCellRangeContainer.java
deleted file mode 100644
index ee5fbcc68467..000000000000
--- a/qadevOOo/tests/java/ifc/sheet/_XSheetCellRangeContainer.java
+++ /dev/null
@@ -1,198 +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.StatusException;
-
-import com.sun.star.sheet.XSheetCellRangeContainer;
-import com.sun.star.table.CellRangeAddress;
-
-/**
-* Testing <code>com.sun.star.sheet.XSheetCellRangeContainer</code>
-* interface methods :
-* <ul>
-*  <li><code> addRangeAddress() </code></li>
-*  <li><code> removeRangeAddress() </code></li>
-*  <li><code> addRangeAddresses() </code></li>
-*  <li><code> removeRangeAddresses() </code></li>
-* </ul> <p>
-* Test is <b> NOT </b> multithread compliant. <p>
-* @see com.sun.star.sheet.XSheetCellRangeContainer
-*/
-public class _XSheetCellRangeContainer extends MultiMethodTest {
-    public XSheetCellRangeContainer oObj = null;
-    public CellRangeAddress[] rAddr = new CellRangeAddress[3];
-
-    /**
-    * After method called, the new array of structures 'CellRangeAddress'
-    *  is created. Then container is cleared.
-    */
-    @Override
-    public void before() {
-        for ( short i=0; i<=2; i++ ) {
-            rAddr[i] = new CellRangeAddress();
-            rAddr[i].Sheet = i;
-            rAddr[i].StartColumn = i;
-            rAddr[i].StartRow = i;
-            rAddr[i].EndColumn = i + 3;
-            rAddr[i].EndRow = i + 3;
-            try {
-                oObj.removeRangeAddresses(oObj.getRangeAddresses());
-            } catch (com.sun.star.uno.Exception e) {
-                e.printStackTrace(log);
-                throw new StatusException("Error: Cannot remove "+
-                    "range addresses." ,e);
-            }
-        }
-    }
-
-    /**
-    * The method called. Then new value is added to Container.
-    * Next we try to obtain back added value and check it. <p>
-    *
-    * Has <b> OK </b> status if the range just added presents among
-    * all ranges in the container.
-    */
-    public void _addRangeAddress() {
-        boolean result = true;
-
-        log.println("Elements before adding: " + oObj.getCount());
-        oObj.addRangeAddress(rAddr[0], false);
-        log.println("Elements after adding: " + oObj.getCount());
-        CellRangeAddress[] addr = oObj.getRangeAddresses();
-        boolean exist = false ;
-        for (int i=0; i<=oObj.getCount()-1; i++) {
-            if ( addr[i].Sheet == rAddr[0].Sheet &&
-                 addr[i].StartColumn == rAddr[0].StartColumn &&
-                 addr[i].StartRow == rAddr[0].StartRow &&
-                 addr[i].EndColumn == rAddr[0].EndColumn &&
-                 addr[i].EndRow == rAddr[0].EndRow) {
-
-                exist = true;
-            }
-        }
-
-        result &= exist ;
-
-        tRes.tested("addRangeAddress()" ,result);
-    }
-
-    /**
-    * The method called. Then a value added before is removed.
-    * Next we check Container for existence of removed value. <p>
-    * Has <b> OK </b> status if the range just removed doesn't presents among
-    * all ranges in the container.
-    */
-    public void _removeRangeAddress() {
-        boolean result = true;
-
-        log.println("Elements before removing: " + oObj.getCount());
-        try {
-            oObj.removeRangeAddress(rAddr[0]);
-        } catch (com.sun.star.container.NoSuchElementException e) {
-            e.printStackTrace(log);
-            result = false;
-        }
-        log.println("Elements after removing: " + oObj.getCount());
-        CellRangeAddress[] addr = oObj.getRangeAddresses();
-        for (int i=0; i<=oObj.getCount()-1; i++) {
-            if ( (addr[i].Sheet == rAddr[0].Sheet) &&
-                    (addr[i].StartColumn == rAddr[0].StartColumn) &&
-                    (addr[i].StartRow == rAddr[0].StartRow) &&
-                    (addr[i].EndColumn == rAddr[0].EndColumn) &&
-                    (addr[i].EndRow == rAddr[0].EndRow) ) {
-                result = false;
-            }
-        }
-        tRes.tested("removeRangeAddress()" ,result);
-    }
-
-    /**
-     * The method called. Then new values are added to Container.
-     * Next we try to obtain back all added values and check it. <p>
-     *
-     * Has <b> OK </b> status if the count of ranges increases by
-     * number of added ranges - 1 (one of ranges already exists in the
-     * container). And if all of ranges added exist in the container.
-     */
-    public void _addRangeAddresses() {
-        executeMethod("addRangeAddress()");
-
-        boolean result = true;
-
-        int cntBefore = oObj.getCount();
-        log.println("Elements before adding: " + cntBefore);
-        oObj.addRangeAddresses(rAddr, false);
-        log.println("Elements after adding: " + oObj.getCount());
-        CellRangeAddress[] addr = oObj.getRangeAddresses();
-
-        result &= cntBefore + rAddr.length == oObj.getCount();
-
-        for (int j = 0; j < rAddr.length; j++) {
-            boolean exist = false ;
-            for (int i=0; i < oObj.getCount(); i++) {
-                if ( addr[i].Sheet == rAddr[j].Sheet &&
-                     addr[i].StartColumn == rAddr[j].StartColumn &&
-                     addr[i].StartRow == rAddr[j].StartRow &&
-                     addr[i].EndColumn == rAddr[j].EndColumn &&
-                     addr[i].EndRow == rAddr[j].EndRow ) {
-
-                    exist = true;
-                    break;
-                }
-            }
-            result &= exist;
-        }
-
-        tRes.tested("addRangeAddresses()" ,result);
-    }
-
-    /**
-     * All ranges are remover from container.
-     *
-     * Has <b> OK </b> status if there are no more ranges in the container.
-     */
-    public void _removeRangeAddresses() {
-        boolean result = false;
-        int cnt;
-
-        log.println("Elements before removing: " + oObj.getCount());
-        try {
-            oObj.removeRangeAddresses(oObj.getRangeAddresses());
-        } catch (com.sun.star.container.NoSuchElementException e) {
-            e.printStackTrace(log);
-            result = false;
-        }
-        if ( (cnt = oObj.getCount()) == 0) {
-            result = true;
-        }
-        log.println("Elements after removing: " + cnt);
-        tRes.tested("removeRangeAddresses()" ,result);
-    }
-
-    /**
-    * Forces environment recreation.
-    */
-    @Override
-    protected void after() {
-        disposeEnvironment();
-    }
-
-}
diff --git a/sc/qa/extras/sccellrangesobj.cxx b/sc/qa/extras/sccellrangesobj.cxx
index aaa1fa786c7d..7ebe5d876842 100644
--- a/sc/qa/extras/sccellrangesobj.cxx
+++ b/sc/qa/extras/sccellrangesobj.cxx
@@ -8,8 +8,9 @@
  */
 
 #include <test/calc_unoapi_test.hxx>
-#include <test/sheet/xsheetoperation.hxx>
+#include <test/sheet/xsheetcellrangecontainer.hxx>
 #include <test/sheet/xsheetcellranges.hxx>
+#include <test/sheet/xsheetoperation.hxx>
 
 #include <com/sun/star/lang/XMultiServiceFactory.hpp>
 #include <com/sun/star/container/XIndexAccess.hpp>
@@ -26,9 +27,10 @@ using namespace css::uno;
 
 namespace sc_apitest {
 
-#define NUMBER_OF_TESTS 5
+#define NUMBER_OF_TESTS 7
 
 class ScCellRangesObj : public CalcUnoApiTest,
+                        public apitest::XSheetCellRangeContainer,
                         public apitest::XSheetCellRanges,
                         public apitest::XSheetOperation
 {
@@ -42,6 +44,10 @@ public:
 
     CPPUNIT_TEST_SUITE(ScCellRangesObj);
 
+    // XSheetCellRangeContainer
+    CPPUNIT_TEST(testAddRemoveRangeAddress);
+    CPPUNIT_TEST(testAddRemoveRangeAddresses);
+
     // XSheetCellRanges
     CPPUNIT_TEST(testGetCells);
     CPPUNIT_TEST(testGetRangeAddresses);
diff --git a/test/Library_subsequenttest.mk b/test/Library_subsequenttest.mk
index 2139e05a0311..eb8fc2d1d97e 100644
--- a/test/Library_subsequenttest.mk
+++ b/test/Library_subsequenttest.mk
@@ -70,6 +70,7 @@ $(eval $(call gb_Library_add_exception_objects,subsequenttest,\
 	test/source/sheet/xsheetannotation \
 	test/source/sheet/xsheetannotations \
 	test/source/sheet/xsheetannotationshapesupplier \
+	test/source/sheet/xsheetcellrangecontainer \
 	test/source/sheet/xsheetcellrange \
 	test/source/sheet/xsheetcellranges \
 	test/source/sheet/xsheetconditionalentries \
diff --git a/test/source/sheet/xsheetcellrangecontainer.cxx b/test/source/sheet/xsheetcellrangecontainer.cxx
new file mode 100644
index 000000000000..e18bff3ba226
--- /dev/null
+++ b/test/source/sheet/xsheetcellrangecontainer.cxx
@@ -0,0 +1,121 @@
+/* -*- 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/xsheetcellrangecontainer.hxx>
+
+#include <com/sun/star/sheet/XSheetCellRangeContainer.hpp>
+
+#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;
+
+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 XSheetCellRangeContainer::testAddRemoveRangeAddress()
+{
+    uno::Reference< sheet::XSheetCellRangeContainer > xSCRC(init(), UNO_QUERY_THROW);
+    xSCRC->removeRangeAddresses(xSCRC->getRangeAddresses()); // prepare a clean slate
+    uno::Sequence< table::CellRangeAddress > aAddr = createCellRangeAddresses();
+
+    sal_Int32 cnt = xSCRC->getCount();
+    xSCRC->addRangeAddress(aAddr[0], false);
+    CPPUNIT_ASSERT_EQUAL_MESSAGE("Unable to add CellRangeAddress (count)",
+                                 cnt + 1, xSCRC->getCount());
+
+    uno::Sequence< table::CellRangeAddress > aAfterAddAddr = xSCRC->getRangeAddresses();
+    cnt = xSCRC->getCount();
+    CPPUNIT_ASSERT_EQUAL_MESSAGE("Unable to add CellRangeAddress (entry)",
+                                 aAddr[0], aAfterAddAddr[cnt - 1]);
+
+    xSCRC->removeRangeAddress(aAddr[0]);
+    CPPUNIT_ASSERT_EQUAL_MESSAGE("Unable to remove CellRangeAddress (count)",
+                                 cnt - 1, xSCRC->getCount());
+
+    uno::Sequence< table::CellRangeAddress > aAfterRemoveAddr = xSCRC->getRangeAddresses();
+    for ( auto const & addr : aAfterRemoveAddr )
+    {
+        CPPUNIT_ASSERT_MESSAGE("Unable to remove CellRangeAddress (entry)",
+                               aAddr[0] != addr);
+    }
+}
+
+void XSheetCellRangeContainer::testAddRemoveRangeAddresses()
+{
+    uno::Reference< sheet::XSheetCellRangeContainer > xSCRC(init(), UNO_QUERY_THROW);
+    xSCRC->removeRangeAddresses(xSCRC->getRangeAddresses()); // prepare a clean slate
+    uno::Sequence< table::CellRangeAddress > aAddr = createCellRangeAddresses();
+
+    sal_Int32 cnt = xSCRC->getCount();
+    xSCRC->addRangeAddresses(aAddr, false);
+    CPPUNIT_ASSERT_EQUAL_MESSAGE("Unable to add CellRangeAddress (count)",
+                                 cnt + 2, xSCRC->getCount());
+
+    uno::Sequence< table::CellRangeAddress > aAfterAddAddr = xSCRC->getRangeAddresses();
+    cnt = xSCRC->getCount();
+    CPPUNIT_ASSERT_EQUAL_MESSAGE("Unable to add CellRangeAddresses (entry: first)",
+                                 aAddr[0], aAfterAddAddr[cnt - 2]);
+    CPPUNIT_ASSERT_EQUAL_MESSAGE("Unable to add CellRangeAddresses (entry: second)",
+                                 aAddr[1], aAfterAddAddr[cnt - 1]);
+
+    xSCRC->removeRangeAddresses(aAddr);
+    CPPUNIT_ASSERT_EQUAL_MESSAGE("Unable to remove CellRangeAddresses (count)",
+                                 cnt - 2, xSCRC->getCount());
+
+    uno::Sequence< table::CellRangeAddress > aAfterRemoveAddr = xSCRC->getRangeAddresses();
+    for ( auto const & addr : aAfterRemoveAddr )
+    {
+        CPPUNIT_ASSERT_MESSAGE("Unable to remove CellRangeAddresses (entry: first)",
+                               aAddr[0] != addr);
+        CPPUNIT_ASSERT_MESSAGE("Unable to remove CellRangeAddresses (entry: second)",
+                               aAddr[1] != addr);
+    }
+}
+
+uno::Sequence< table::CellRangeAddress > XSheetCellRangeContainer::createCellRangeAddresses()
+{
+    uno::Sequence< table::CellRangeAddress > aAddr(2);
+    for ( unsigned int i = 0; i < 2; i++ )
+    {
+        aAddr[i].Sheet = i;
+        aAddr[i].StartColumn = i;
+        aAddr[i].StartRow = i;
+        aAddr[i].EndColumn = i + 3;
+        aAddr[i].EndRow = i + 3;
+    }
+
+    return aAddr;
+}
+
+}
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab cinoptions=b1,g0,N-s cinkeys+=0=break: */


More information about the Libreoffice-commits mailing list