include/test/table/xtablechart.hxx                         |   37 ++
 qadevOOo/Jar_OOoRunner.mk                                  |    1 
 qadevOOo/objdsc/sc/com.sun.star.comp.office.ScChartObj.csv |    6 
 qadevOOo/tests/java/mod/_sc/ScChartObj.java                |  234 -------------
 sc/qa/extras/scchartobj.cxx                                |    9 
 sc/qa/unoapi/sc_3.sce                                      |    1 
 test/Library_subsequenttest.mk                             |    1 
 test/source/table/xtablechart.cxx                          |   60 +++
 8 files changed, 106 insertions(+), 243 deletions(-)

New commits:
commit b5d2ebb76e763457a8c8f07b26d542295e82e192
Author:     Jens Carl <j.car...@gmx.de>
AuthorDate: Thu Jan 24 08:49:21 2019 +0000
Commit:     Jens Carl <j.car...@gmx.de>
CommitDate: Thu Jan 24 22:02:07 2019 +0100

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

diff --git a/include/test/table/xtablechart.hxx 
b/include/test/table/xtablechart.hxx
new file mode 100644
index 000000000000..6c57bf3ac332
--- /dev/null
+++ b/include/test/table/xtablechart.hxx
@@ -0,0 +1,37 @@
+/* -*- 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_TABLE_XTABLECHART_HXX
+#define INCLUDED_TEST_TABLE_XTABLECHART_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 XTableChart
+{
+public:
+    virtual css::uno::Reference<css::uno::XInterface> init() = 0;
+
+    void testGetSetHasColumnHeaders();
+    void testGetSetHasRowHeaders();
+    void testGetSetRanges();
+
+protected:
+    ~XTableChart() {}
+};
+} // namespace apitest
+
+#endif // INCLUDED_TEST_TABLE_XTABLECHART_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 2828744ee90e..8a8374069326 100644
--- a/qadevOOo/Jar_OOoRunner.mk
+++ b/qadevOOo/Jar_OOoRunner.mk
@@ -962,7 +962,6 @@ $(eval $(call gb_Jar_add_sourcefiles,OOoRunner,\
     qadevOOo/tests/java/mod/_sc/ScCellRangesObj \
     qadevOOo/tests/java/mod/_sc/ScCellSearchObj \
     qadevOOo/tests/java/mod/_sc/ScCellTextCursor \
-    qadevOOo/tests/java/mod/_sc/ScChartObj \
     qadevOOo/tests/java/mod/_sc/ScChartsObj \
     qadevOOo/tests/java/mod/_sc/ScDatabaseRangeObj \
     qadevOOo/tests/java/mod/_sc/ScDataPilotFieldGroupItemObj \
diff --git a/qadevOOo/objdsc/sc/com.sun.star.comp.office.ScChartObj.csv 
b/qadevOOo/objdsc/sc/com.sun.star.comp.office.ScChartObj.csv
deleted file mode 100644
index 921ae1ef8e1b..000000000000
--- a/qadevOOo/objdsc/sc/com.sun.star.comp.office.ScChartObj.csv
+++ /dev/null
@@ -1,6 +0,0 @@
-"ScChartObj";"com::sun::star::table::XTableChart";"getHasColumnHeaders()"
-"ScChartObj";"com::sun::star::table::XTableChart";"setHasColumnHeaders()"
-"ScChartObj";"com::sun::star::table::XTableChart";"getHasRowHeaders()"
-"ScChartObj";"com::sun::star::table::XTableChart";"setHasRowHeaders()"
-"ScChartObj";"com::sun::star::table::XTableChart";"getRanges()"
-"ScChartObj";"com::sun::star::table::XTableChart";"setRanges()"
diff --git a/qadevOOo/tests/java/mod/_sc/ScChartObj.java 
b/qadevOOo/tests/java/mod/_sc/ScChartObj.java
deleted file mode 100644
index d768ceb61128..000000000000
--- a/qadevOOo/tests/java/mod/_sc/ScChartObj.java
+++ /dev/null
@@ -1,234 +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.awt.Rectangle;
-import com.sun.star.container.XIndexAccess;
-import com.sun.star.container.XNameAccess;
-import com.sun.star.lang.XComponent;
-import com.sun.star.sheet.XCellRangeAddressable;
-import com.sun.star.sheet.XSpreadsheet;
-import com.sun.star.sheet.XSpreadsheetDocument;
-import com.sun.star.sheet.XSpreadsheets;
-import com.sun.star.table.CellRangeAddress;
-import com.sun.star.table.XCell;
-import com.sun.star.table.XCellRange;
-import com.sun.star.table.XTableChart;
-import com.sun.star.table.XTableCharts;
-import com.sun.star.table.XTableChartsSupplier;
-import com.sun.star.uno.AnyConverter;
-import com.sun.star.uno.Type;
-import com.sun.star.uno.UnoRuntime;
-
-/**
-* Test for object which is represented by service
-* <code>com.sun.star.table.TableChart</code>. <p>
-* Object implements the following interfaces :
-* <ul>
-*  <li> <code>com::sun::star::container::XNamed</code></li>
-*  <li> <code>com::sun::star::table::XTableChart</code></li>
-*  <li> <code>com::sun::star::document::XEmbeddedObjectSupplier</code></li>
-* </ul>
-* @see com.sun.star.table.TableChart
-* @see com.sun.star.container.XNamed
-* @see com.sun.star.table.XTableChart
-* @see com.sun.star.document.XEmbeddedObjectSupplier
-* @see ifc.container._XNamed
-* @see ifc.table._XTableChart
-* @see ifc.document._XEmbeddedObjectSupplier
-*/
-public class ScChartObj extends TestCase {
-    private XSpreadsheetDocument xSheetDoc = null;
-
-    /**
-    * Creates Spreadsheet document.
-    */
-    @Override
-    protected void initialize( TestParameters tParam, PrintWriter log ) throws 
Exception {
-        // get a soffice factory object
-        SOfficeFactory SOF = SOfficeFactory.getFactory( tParam.getMSF());
-        log.println( "creating a sheetdocument" );
-        xSheetDoc = SOF.createCalcDoc(null);
-    }
-
-    /**
-    * Disposes Spreadsheet document.
-    */
-    @Override
-    protected void cleanup( TestParameters tParam, PrintWriter log ) {
-        log.println( "    disposing xSheetDoc " );
-        XComponent oComp = UnoRuntime.queryInterface(XComponent.class, 
xSheetDoc);
-        util.DesktopTools.closeDoc(oComp);
-    }
-
-    /**
-    * Creating a TestEnvironment for the interfaces to be tested.
-    * Retrieves a collection of spreadsheets from a document
-    * and takes one of them. Inserts some values into the cells of the same 
cell
-    * range address. Adds the chart that using the data from the cells of this
-    * cell range address. New chart is the instance of
-    * the service <code>com.sun.star.table.TableChart</code>.
-    * Object relations created :
-    * <ul>
-    *  <li> <code>'setName'</code> for
-    *      {@link ifc.container._XNamed}(the method <code>setName</code> must
-    *      not be tested)</li>
-    * </ul>
-    * @see com.sun.star.container.XNamed
-    */
-    @Override
-    protected TestEnvironment createTestEnvironment(TestParameters Param, 
PrintWriter log) throws Exception {
-
-        XSpreadsheet oSheet=null;
-
-        log.println("Getting spreadsheet") ;
-        XSpreadsheets oSheets = xSheetDoc.getSheets() ;
-        XIndexAccess oIndexSheets = 
UnoRuntime.queryInterface(XIndexAccess.class, oSheets);
-        oSheet = (XSpreadsheet) AnyConverter.toObject(
-                new Type(XSpreadsheet.class),oIndexSheets.getByIndex(0));
-
-        log.println("Creating the Header") ;
-
-        insertIntoCell(1,0,"JAN",oSheet,"");
-        insertIntoCell(2,0,"FEB",oSheet,"");
-        insertIntoCell(3,0,"MAR",oSheet,"");
-        insertIntoCell(4,0,"APR",oSheet,"");
-        insertIntoCell(5,0,"MAI",oSheet,"");
-        insertIntoCell(6,0,"JUN",oSheet,"");
-        insertIntoCell(7,0,"JUL",oSheet,"");
-        insertIntoCell(8,0,"AUG",oSheet,"");
-        insertIntoCell(9,0,"SEP",oSheet,"");
-        insertIntoCell(10,0,"OCT",oSheet,"");
-        insertIntoCell(11,0,"NOV",oSheet,"");
-        insertIntoCell(12,0,"DEC",oSheet,"");
-        insertIntoCell(13,0,"SUM",oSheet,"");
-
-        log.println("Fill the lines");
-
-        insertIntoCell(0,1,"Smith",oSheet,"");
-        insertIntoCell(1,1,"42",oSheet,"V");
-        insertIntoCell(2,1,"58.9",oSheet,"V");
-        insertIntoCell(3,1,"-66.5",oSheet,"V");
-        insertIntoCell(4,1,"43.4",oSheet,"V");
-        insertIntoCell(5,1,"44.5",oSheet,"V");
-        insertIntoCell(6,1,"45.3",oSheet,"V");
-        insertIntoCell(7,1,"-67.3",oSheet,"V");
-        insertIntoCell(8,1,"30.5",oSheet,"V");
-        insertIntoCell(9,1,"23.2",oSheet,"V");
-        insertIntoCell(10,1,"-97.3",oSheet,"V");
-        insertIntoCell(11,1,"22.4",oSheet,"V");
-        insertIntoCell(12,1,"23.5",oSheet,"V");
-        insertIntoCell(13,1,"=SUM(B2:M2)",oSheet,"");
-
-        insertIntoCell(0,2,"Jones",oSheet,"");
-        insertIntoCell(1,2,"21",oSheet,"V");
-        insertIntoCell(2,2,"40.9",oSheet,"V");
-        insertIntoCell(3,2,"-57.5",oSheet,"V");
-        insertIntoCell(4,2,"-23.4",oSheet,"V");
-        insertIntoCell(5,2,"34.5",oSheet,"V");
-        insertIntoCell(6,2,"59.3",oSheet,"V");
-        insertIntoCell(7,2,"27.3",oSheet,"V");
-        insertIntoCell(8,2,"-38.5",oSheet,"V");
-        insertIntoCell(9,2,"43.2",oSheet,"V");
-        insertIntoCell(10,2,"57.3",oSheet,"V");
-        insertIntoCell(11,2,"25.4",oSheet,"V");
-        insertIntoCell(12,2,"28.5",oSheet,"V");
-        insertIntoCell(13,2,"=SUM(B3:M3)",oSheet,"");
-
-        insertIntoCell(0,3,"Brown",oSheet,"");
-        insertIntoCell(1,3,"31.45",oSheet,"V");
-        insertIntoCell(2,3,"-20.9",oSheet,"V");
-        insertIntoCell(3,3,"-117.5",oSheet,"V");
-        insertIntoCell(4,3,"23.4",oSheet,"V");
-        insertIntoCell(5,3,"-114.5",oSheet,"V");
-        insertIntoCell(6,3,"115.3",oSheet,"V");
-        insertIntoCell(7,3,"-171.3",oSheet,"V");
-        insertIntoCell(8,3,"89.5",oSheet,"V");
-        insertIntoCell(9,3,"41.2",oSheet,"V");
-        insertIntoCell(10,3,"71.3",oSheet,"V");
-        insertIntoCell(11,3,"25.4",oSheet,"V");
-        insertIntoCell(12,3,"38.5",oSheet,"V");
-        insertIntoCell(13,3,"=SUM(A4:L4)",oSheet,"");
-
-        // insert a chart
-
-        Rectangle oRect = new Rectangle(500, 3000, 25000, 11000);
-
-        XCellRange oRange = UnoRuntime.queryInterface(XCellRange.class, 
oSheet);
-        XCellRange myRange = oRange.getCellRangeByName("A1:N4");
-        XCellRangeAddressable oRangeAddr = 
UnoRuntime.queryInterface(XCellRangeAddressable.class, myRange);
-        CellRangeAddress myAddr = oRangeAddr.getRangeAddress();
-
-        CellRangeAddress[] oAddr = new CellRangeAddress[1];
-        oAddr[0] = myAddr;
-        XTableChartsSupplier oSupp = 
UnoRuntime.queryInterface(XTableChartsSupplier.class, oSheet);
-
-        log.println("Insert Chart");
-
-        XTableCharts oCharts = oSupp.getCharts();
-        oCharts.addNewByName("ScChartObj", oRect, oAddr, true, true);
-
-        // get the TableChart
-        XTableChart oChart = null;
-        XNameAccess names = (XNameAccess) AnyConverter.toObject(
-            new Type(XNameAccess.class),UnoRuntime.queryInterface(
-                XNameAccess.class, oCharts));
-
-        oChart = (XTableChart) AnyConverter.toObject(
-            new Type(XTableChart.class),names.getByName("ScChartObj"));
-
-        log.println("creating a new environment for object");
-        TestEnvironment tEnv = new TestEnvironment(oChart);
-
-        //adding ObjRelation 'setName' for 'XNamed'
-        tEnv.addObjRelation("setName", Boolean.TRUE);
-
-        return tEnv;
-    }
-
-    /**
-    * Inserts a value or a formula in the cell of the spreasheet.
-    * @param CellX is the column index of the cell
-    * @param CellY is the row index of the cell
-    * @param theValue string representation of the value
-    * @param TT1 specify the spreadsheet, the interface
-    * <code>com.sun.star.sheet.XSpreadsheet</code>
-    * @param flag if it's equal to <code>'V'</code> then the method inserts
-    * a double-value in the cell else it inserts a formula in the cell
-    */
-    public static void insertIntoCell(
-        int CellX, int CellY, String theValue, XSpreadsheet TT1, String flag)
-            throws com.sun.star.lang.IndexOutOfBoundsException {
-        XCell oCell = TT1.getCellByPosition(CellX, CellY);
-
-        if (flag.equals("V")) {
-            oCell.setValue(Float.parseFloat(theValue));
-        } else {
-            oCell.setFormula(theValue);
-        }
-    } // end of insertIntoCell
-}
-
diff --git a/sc/qa/extras/scchartobj.cxx b/sc/qa/extras/scchartobj.cxx
index b4925ac43219..20c6688aa4d7 100644
--- a/sc/qa/extras/scchartobj.cxx
+++ b/sc/qa/extras/scchartobj.cxx
@@ -10,6 +10,7 @@
 #include <test/calc_unoapi_test.hxx>
 #include <test/container/xnamed.hxx>
 #include <test/document/xembeddedobjectsupplier.hxx>
+#include <test/table/xtablechart.hxx>
 
 #include <com/sun/star/awt/Rectangle.hpp>
 #include <com/sun/star/container/XIndexAccess.hpp>
@@ -36,7 +37,8 @@ namespace sc_apitest
 {
 class ScChartObj : public CalcUnoApiTest,
                    public apitest::XEmbeddedObjectSupplier,
-                   public apitest::XNamed
+                   public apitest::XNamed,
+                   public apitest::XTableChart
 {
 public:
     ScChartObj();
@@ -54,6 +56,11 @@ public:
     CPPUNIT_TEST(testGetName);
     CPPUNIT_TEST(testSetNameThrowsException);
 
+    // XTableChart
+    CPPUNIT_TEST(testGetSetHasColumnHeaders);
+    CPPUNIT_TEST(testGetSetHasRowHeaders);
+    CPPUNIT_TEST(testGetSetRanges);
+
     CPPUNIT_TEST_SUITE_END();
 
 private:
diff --git a/sc/qa/unoapi/sc_3.sce b/sc/qa/unoapi/sc_3.sce
index f663451e8d5a..c1cf5040a4b9 100644
--- a/sc/qa/unoapi/sc_3.sce
+++ b/sc/qa/unoapi/sc_3.sce
@@ -19,5 +19,4 @@
 -o sc.ScCellRangesObj
 -o sc.ScCellSearchObj
 -o sc.ScCellTextCursor
--o sc.ScChartObj
 -o sc.ScChartsObj
diff --git a/test/Library_subsequenttest.mk b/test/Library_subsequenttest.mk
index 14faf49f6e57..5ea8ade69775 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/table/xcell \
        test/source/table/xcellcursor \
        test/source/table/xcolumnrowrange \
+       test/source/table/xtablechart \
        test/source/table/xtablechartssupplier \
        test/source/table/xtablerows \
        test/source/text/xtext \
diff --git a/test/source/table/xtablechart.cxx 
b/test/source/table/xtablechart.cxx
new file mode 100644
index 000000000000..6dfb131bd3fd
--- /dev/null
+++ b/test/source/table/xtablechart.cxx
@@ -0,0 +1,60 @@
+/* -*- 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/table/xtablechart.hxx>
+#include <test/cppunitasserthelper.hxx>
+
+#include <com/sun/star/table/CellRangeAddress.hpp>
+#include <com/sun/star/table/XTableChart.hpp>
+
+#include <com/sun/star/uno/Reference.hxx>
+#include <com/sun/star/uno/Sequence.hxx>
+
+#include <cppunit/extensions/HelperMacros.h>
+
+using namespace css;
+
+namespace apitest
+{
+void XTableChart::testGetSetHasColumnHeaders()
+{
+    uno::Reference<table::XTableChart> xTC(init(), uno::UNO_QUERY_THROW);
+
+    xTC->setHasColumnHeaders(false);
+    CPPUNIT_ASSERT(!xTC->getHasColumnHeaders());
+
+    xTC->setHasColumnHeaders(true);
+    CPPUNIT_ASSERT(xTC->getHasColumnHeaders());
+}
+
+void XTableChart::testGetSetHasRowHeaders()
+{
+    uno::Reference<table::XTableChart> xTC(init(), uno::UNO_QUERY_THROW);
+
+    xTC->setHasRowHeaders(false);
+    CPPUNIT_ASSERT(!xTC->getHasRowHeaders());
+
+    xTC->setHasRowHeaders(true);
+    CPPUNIT_ASSERT(xTC->getHasRowHeaders());
+}
+
+void XTableChart::testGetSetRanges()
+{
+    uno::Reference<table::XTableChart> xTC(init(), uno::UNO_QUERY_THROW);
+
+    uno::Sequence<table::CellRangeAddress> aCRA = xTC->getRanges();
+    aCRA[0].EndRow = 1;
+
+    xTC->setRanges(aCRA);
+
+    CPPUNIT_ASSERT_EQUAL(aCRA[0], xTC->getRanges()[0]);
+}
+
+} // 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