[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 03:10:43 UTC 2017


 include/test/sheet/xsheetcellranges.hxx                         |   38 ++++
 qadevOOo/Jar_OOoRunner.mk                                       |    1 
 qadevOOo/objdsc/sc/com.sun.star.comp.office.ScCellRangesObj.csv |    3 
 qadevOOo/tests/java/ifc/sheet/_XSheetCellRanges.java            |   80 ----------
 sc/qa/extras/sccellrangesobj.cxx                                |   21 ++
 test/Library_subsequenttest.mk                                  |    1 
 test/source/sheet/xsheetcellranges.cxx                          |   52 ++++++
 7 files changed, 108 insertions(+), 88 deletions(-)

New commits:
commit bda85f9563b03bb36c7d72dc1178661b3bf23df0
Author: Jens Carl <j.carl43 at gmx.de>
Date:   Thu Nov 2 08:14:14 2017 +0000

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

diff --git a/include/test/sheet/xsheetcellranges.hxx b/include/test/sheet/xsheetcellranges.hxx
new file mode 100644
index 000000000000..18275195df01
--- /dev/null
+++ b/include/test/sheet/xsheetcellranges.hxx
@@ -0,0 +1,38 @@
+/* -*- 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_XSHEETCELLRANGES_HXX
+#define INCLUDED_TEST_SHEET_XSHEETCELLRANGES_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 XSheetCellRanges
+{
+public:
+    virtual css::uno::Reference< css::uno::XInterface > init() =0;
+
+    void testGetCells();
+    void testGetRangeAddresses();
+    void testGetRangeAddressesAsString();
+
+protected:
+    ~XSheetCellRanges() {}
+};
+
+}
+
+#endif // INCLUDED_TEST_SHEET_XSHEETCELLRANGES_HXX
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/qadevOOo/Jar_OOoRunner.mk b/qadevOOo/Jar_OOoRunner.mk
index aa1ca80f0733..94b198cf34d2 100644
--- a/qadevOOo/Jar_OOoRunner.mk
+++ b/qadevOOo/Jar_OOoRunner.mk
@@ -620,7 +620,6 @@ $(eval $(call gb_Jar_add_sourcefiles,OOoRunner,\
     qadevOOo/tests/java/ifc/sheet/_XSheetCellCursor \
     qadevOOo/tests/java/ifc/sheet/_XSheetCellRange \
     qadevOOo/tests/java/ifc/sheet/_XSheetCellRangeContainer \
-    qadevOOo/tests/java/ifc/sheet/_XSheetCellRanges \
     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 927dfc3ce333..a17fa72c561f 100644
--- a/qadevOOo/objdsc/sc/com.sun.star.comp.office.ScCellRangesObj.csv
+++ b/qadevOOo/objdsc/sc/com.sun.star.comp.office.ScCellRangesObj.csv
@@ -45,9 +45,6 @@
 "ScCellRangesObj";"com::sun::star::style::CharacterPropertiesAsian";"ParaIsHangingPunctuation"
 "ScCellRangesObj";"com::sun::star::container::XIndexAccess";"getCount()"
 "ScCellRangesObj";"com::sun::star::container::XIndexAccess";"getByIndex()"
-"ScCellRangesObj";"com::sun::star::sheet::XSheetCellRanges";"getCells()"
-"ScCellRangesObj";"com::sun::star::sheet::XSheetCellRanges";"getRangeAddressesAsString()"
-"ScCellRangesObj";"com::sun::star::sheet::XSheetCellRanges";"getRangeAddresses()"
 "ScCellRangesObj";"com::sun::star::util::XReplaceable";"createReplaceDescriptor()"
 "ScCellRangesObj";"com::sun::star::util::XReplaceable";"replaceAll()"
 "ScCellRangesObj";"com::sun::star::chart::XChartData";"addChartDataChangeEventListener()"
diff --git a/qadevOOo/tests/java/ifc/sheet/_XSheetCellRanges.java b/qadevOOo/tests/java/ifc/sheet/_XSheetCellRanges.java
deleted file mode 100644
index c5db09ece2ee..000000000000
--- a/qadevOOo/tests/java/ifc/sheet/_XSheetCellRanges.java
+++ /dev/null
@@ -1,80 +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.container.XEnumeration;
-import com.sun.star.sheet.XSheetCellRanges;
-import com.sun.star.table.CellRangeAddress;
-
-/**
-* Testing <code>com.sun.star.sheet.XSheetCellRanges</code>
-* interface methods :
-* <ul>
-*  <li><code> getCells()</code></li>
-*  <li><code> getRangeAddressesAsString()</code></li>
-*  <li><code> getRangeAddresses()</code></li>
-* </ul> <p>
-* @see com.sun.star.sheet.XSheetCellRanges
-*/
-public class _XSheetCellRanges extends MultiMethodTest{
-
-    public XSheetCellRanges oObj = null;
-
-    /**
-    * Test calls the method, creates enumeration of returned value
-    * and checks that the enumeration has elements. <p>
-    * Has <b> OK </b> status if gained enumeration has elements. <p>
-    */
-    public void _getCells() {
-        log.println("Testing getCells ...");
-
-        XEnumeration oEnum = oObj.getCells().createEnumeration();
-        boolean res = oEnum.hasMoreElements();
-        if (!res) {
-            log.println(
-                    "The Enumeration gained via getCells() has no Elements");
-        }
-        tRes.tested("getCells()", res);
-    }
-
-    /**
-    * Test calls the method and checks length of returned array. <p>
-    * Has <b> OK </b> status if length of returned array is greater than 2.<p>
-    */
-    public void _getRangeAddresses() {
-        log.println("Testing getRangeAddresses ...");
-        CellRangeAddress[] oRanges = oObj.getRangeAddresses();
-        int howmuch = oRanges.length;
-        tRes.tested("getRangeAddresses()", (howmuch > 2) );
-    }
-
-    /**
-    * Test calls the method and checks returned string. <p>
-    * Has <b> OK </b> status if returned string starts from 'Sheet'.<p>
-    */
-    public void _getRangeAddressesAsString() {
-        log.println("Testing getRangeAddressesAsString ...");
-        String oRanges = oObj.getRangeAddressesAsString();
-        tRes.tested("getRangeAddressesAsString()",oRanges.indexOf("C1:D4")>0);
-    }
-
-} // finished class _XSheetCellRanges
-
diff --git a/sc/qa/extras/sccellrangesobj.cxx b/sc/qa/extras/sccellrangesobj.cxx
index 9e8d287e125d..aaa1fa786c7d 100644
--- a/sc/qa/extras/sccellrangesobj.cxx
+++ b/sc/qa/extras/sccellrangesobj.cxx
@@ -9,6 +9,7 @@
 
 #include <test/calc_unoapi_test.hxx>
 #include <test/sheet/xsheetoperation.hxx>
+#include <test/sheet/xsheetcellranges.hxx>
 
 #include <com/sun/star/lang/XMultiServiceFactory.hpp>
 #include <com/sun/star/container/XIndexAccess.hpp>
@@ -25,9 +26,11 @@ using namespace css::uno;
 
 namespace sc_apitest {
 
-#define NUMBER_OF_TESTS 2
+#define NUMBER_OF_TESTS 5
 
-class ScCellRangesObj : public CalcUnoApiTest, public apitest::XSheetOperation
+class ScCellRangesObj : public CalcUnoApiTest,
+                        public apitest::XSheetCellRanges,
+                        public apitest::XSheetOperation
 {
 public:
     ScCellRangesObj();
@@ -39,6 +42,11 @@ public:
 
     CPPUNIT_TEST_SUITE(ScCellRangesObj);
 
+    // XSheetCellRanges
+    CPPUNIT_TEST(testGetCells);
+    CPPUNIT_TEST(testGetRangeAddresses);
+    CPPUNIT_TEST(testGetRangeAddressesAsString);
+
     // XSheetOperation
     CPPUNIT_TEST(testComputeFunction);
     CPPUNIT_TEST(testClearContents);
@@ -72,9 +80,7 @@ uno::Reference< uno::XInterface > ScCellRangesObj::init()
     uno::Reference< lang::XMultiServiceFactory > xMSF(xDoc, uno::UNO_QUERY_THROW);
     uno::Reference< container::XNameContainer > xRanges(xMSF->createInstance("com.sun.star.sheet.SheetCellRanges"), uno::UNO_QUERY_THROW);
 
-    //uno::Reference< container::XNameContainer > xRanges(xSheet, uno::UNO_QUERY_THROW);
     uno::Any xCellRange;
-
     xCellRange <<= xSheet->getCellRangeByName("C1:D4");
     xRanges->insertByName("Range1", xCellRange);
     xCellRange <<= xSheet->getCellRangeByName("E2:F5");
@@ -84,6 +90,13 @@ uno::Reference< uno::XInterface > ScCellRangesObj::init()
     xCellRange <<= xSheet->getCellRangeByName("I7:J8");
     xRanges->insertByName("Range4", xCellRange);
 
+    for ( int i = 0; i < 10; i++ )
+    {
+        for ( int j = 5; j < 10; j++ )
+        {
+            xSheet->getCellByPosition(i, j)->setValue(i + j);
+        }
+    }
 
     return xRanges;
 }
diff --git a/test/Library_subsequenttest.mk b/test/Library_subsequenttest.mk
index e6f0c99e4985..0435b967dd5d 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/xsheetcellranges \
 	test/source/sheet/xsheetconditionalentries \
 	test/source/sheet/xsheetconditionalentry \
 	test/source/sheet/xsheetcondition \
diff --git a/test/source/sheet/xsheetcellranges.cxx b/test/source/sheet/xsheetcellranges.cxx
new file mode 100644
index 000000000000..0b590ad249a8
--- /dev/null
+++ b/test/source/sheet/xsheetcellranges.cxx
@@ -0,0 +1,52 @@
+/* -*- 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/xsheetcellranges.hxx>
+
+#include <com/sun/star/container/XEnumeration.hpp>
+#include <com/sun/star/container/XEnumerationAccess.hpp>
+#include <com/sun/star/sheet/XSheetCellRanges.hpp>
+#include <com/sun/star/table/CellRangeAddress.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;
+
+namespace apitest {
+
+void XSheetCellRanges::testGetCells()
+{
+    uno::Reference< sheet::XSheetCellRanges > xSheetCellRanges(init(), UNO_QUERY_THROW);
+    uno::Reference< container::XEnumerationAccess > xEA = xSheetCellRanges->getCells();
+
+    CPPUNIT_ASSERT_MESSAGE("Unable to get cells", xEA->hasElements());
+}
+
+void XSheetCellRanges::testGetRangeAddresses()
+{
+    uno::Reference< sheet::XSheetCellRanges > xSheetCellRanges(init(), UNO_QUERY_THROW);
+    uno::Sequence< table::CellRangeAddress > aCellRangeAddress = xSheetCellRanges->getRangeAddresses();
+    CPPUNIT_ASSERT_MESSAGE("Unable to get RangeAddresses",
+                           aCellRangeAddress.getLength() > 2);
+}
+
+void XSheetCellRanges::testGetRangeAddressesAsString()
+{
+    uno::Reference< sheet::XSheetCellRanges > xSheetCellRanges(init(), UNO_QUERY_THROW);
+    CPPUNIT_ASSERT_MESSAGE("Unable to get RangeAddresses (string)",
+                           xSheetCellRanges->getRangeAddressesAsString().indexOf("C1:D4") > 0);
+}
+
+}
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab cinoptions=b1,g0,N-s cinkeys+=0=break: */


More information about the Libreoffice-commits mailing list