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

Jens Carl (via logerrit) logerrit at kemper.freedesktop.org
Fri Apr 19 03:01:19 UTC 2019


 include/test/chart/xchartdata.hxx                              |   35 ++
 qadevOOo/objdsc/sc/com.sun.star.comp.office.ScCellRangeObj.csv |    4 
 sc/qa/extras/sccellrangeobj.cxx                                |  134 +++++-----
 test/Library_subsequenttest.mk                                 |    1 
 test/source/chart/xchartdata.cxx                               |   93 ++++++
 5 files changed, 201 insertions(+), 66 deletions(-)

New commits:
commit eb7a731bcfbacec15b77889f0ac545d36ef5ad19
Author:     Jens Carl <j.carl43 at gmx.de>
AuthorDate: Thu Apr 18 14:47:40 2019 -0700
Commit:     Jens Carl <j.carl43 at gmx.de>
CommitDate: Fri Apr 19 05:00:46 2019 +0200

    tdf#45904 Move XChartData Java tests to C++
    
    Fix tdf#43309: Move XChartData Java tests to C++ for ScCellRangeObj.
    
    Change-Id: I6b57db53fdddab2ff382354d32809404224a2e1e
    Reviewed-on: https://gerrit.libreoffice.org/70956
    Tested-by: Jenkins
    Reviewed-by: Jens Carl <j.carl43 at gmx.de>

diff --git a/include/test/chart/xchartdata.hxx b/include/test/chart/xchartdata.hxx
new file mode 100644
index 000000000000..315d727ed5a3
--- /dev/null
+++ b/include/test/chart/xchartdata.hxx
@@ -0,0 +1,35 @@
+/* -*- 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/.
+ */
+
+#pragma once
+
+#include <com/sun/star/uno/XInterface.hpp>
+
+#include <com/sun/star/uno/Reference.hxx>
+
+#include <test/testdllapi.hxx>
+
+namespace apitest
+{
+class OOO_DLLPUBLIC_TEST XChartData
+{
+public:
+    virtual css::uno::Reference<css::uno::XInterface> init() = 0;
+
+    void testChartDataChangeEventListener();
+    void testGetNotANumber();
+    void testIsNotANumber();
+
+protected:
+    ~XChartData() {}
+};
+
+} // namespace apitest
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab cinoptions=b1,g0,N-s cinkeys+=0=break: */
diff --git a/qadevOOo/objdsc/sc/com.sun.star.comp.office.ScCellRangeObj.csv b/qadevOOo/objdsc/sc/com.sun.star.comp.office.ScCellRangeObj.csv
index 3e2bbaf97550..0e3a7ab8191e 100644
--- a/qadevOOo/objdsc/sc/com.sun.star.comp.office.ScCellRangeObj.csv
+++ b/qadevOOo/objdsc/sc/com.sun.star.comp.office.ScCellRangeObj.csv
@@ -35,10 +35,6 @@
 "ScCellRangeObj";"com::sun::star::style::CharacterPropertiesAsian";"ParaIsCharacterDistance"
 "ScCellRangeObj";"com::sun::star::style::CharacterPropertiesAsian";"ParaIsForbiddenRules"
 "ScCellRangeObj";"com::sun::star::style::CharacterPropertiesAsian";"ParaIsHangingPunctuation"
-"ScCellRangeObj";"com::sun::star::chart::XChartData";"addChartDataChangeEventListener()"
-"ScCellRangeObj";"com::sun::star::chart::XChartData";"removeChartDataChangeEventListener()"
-"ScCellRangeObj";"com::sun::star::chart::XChartData";"getNotANumber()"
-"ScCellRangeObj";"com::sun::star::chart::XChartData";"isNotANumber()"
 "ScCellRangeObj";"com::sun::star::style::ParagraphProperties";"ParaAdjust"
 "ScCellRangeObj";"com::sun::star::style::ParagraphProperties";"ParaLineSpacing#optional"
 "ScCellRangeObj";"com::sun::star::style::ParagraphProperties";"ParaBackColor#optional"
diff --git a/sc/qa/extras/sccellrangeobj.cxx b/sc/qa/extras/sccellrangeobj.cxx
index a529c9b4eb1f..aba1a458b9eb 100644
--- a/sc/qa/extras/sccellrangeobj.cxx
+++ b/sc/qa/extras/sccellrangeobj.cxx
@@ -8,6 +8,7 @@
  */
 
 #include <test/calc_unoapi_test.hxx>
+#include <test/chart/xchartdata.hxx>
 #include <test/sheet/cellproperties.hxx>
 #include <test/sheet/sheetcellrange.hxx>
 #include <test/sheet/xarrayformularange.hxx>
@@ -30,60 +31,62 @@
 #include <test/util/xmergeable.hxx>
 #include <test/util/xreplaceable.hxx>
 #include <test/util/xsearchable.hxx>
-
-#include <com/sun/star/sheet/XSpreadsheetDocument.hpp>
-#include <com/sun/star/sheet/XSpreadsheet.hpp>
-#include <com/sun/star/table/XCellRange.hpp>
-#include <com/sun/star/util/XSortable.hpp>
-#include <com/sun/star/util/SortField.hpp>
 #include <comphelper/propertysequence.hxx>
 
 #include <com/sun/star/beans/XPropertySet.hpp>
 #include <com/sun/star/sheet/FilterOperator.hpp>
 #include <com/sun/star/sheet/TableFilterField.hpp>
-#include <com/sun/star/sheet/XSheetFilterable.hpp>
 #include <com/sun/star/sheet/XSheetFilterDescriptor.hpp>
+#include <com/sun/star/sheet/XSheetFilterable.hpp>
+#include <com/sun/star/sheet/XSpreadsheet.hpp>
+#include <com/sun/star/sheet/XSpreadsheetDocument.hpp>
+#include <com/sun/star/table/XCellRange.hpp>
 #include <com/sun/star/table/XColumnRowRange.hpp>
 #include <com/sun/star/table/XTableRows.hpp>
+#include <com/sun/star/util/SortField.hpp>
+#include <com/sun/star/util/XSortable.hpp>
+
+#include <com/sun/star/uno/Any.hxx>
 #include <com/sun/star/uno/Reference.hxx>
 #include <com/sun/star/uno/Sequence.hxx>
 
 using namespace css;
-using namespace css::uno;
-
-namespace sc_apitest {
-
-class ScCellRangeObj : public CalcUnoApiTest, public apitest::CellProperties,
-                                              public apitest::SheetCellRange,
-                                              public apitest::XArrayFormulaRange,
-                                              public apitest::XCellFormatRangesSupplier,
-                                              public apitest::XCellRangeAddressable,
-                                              public apitest::XCellRangeData,
-                                              public apitest::XCellRangeFormula,
-                                              public apitest::XCellRangesQuery,
-                                              public apitest::XCellSeries,
-                                              public apitest::XColumnRowRange,
-                                              public apitest::XFormulaQuery,
-                                              public apitest::XIndent,
-                                              public apitest::XMergeable,
-                                              public apitest::XMultipleOperation,
-                                              public apitest::XReplaceable,
-                                              public apitest::XSearchable,
-                                              public apitest::XSheetCellRange,
-                                              public apitest::XSheetFilterable,
-                                              public apitest::XSheetFilterableEx,
-                                              public apitest::XSheetOperation,
-                                              public apitest::XSubTotalCalculatable,
-                                              public apitest::XUniqueCellFormatRangesSupplier
+
+namespace sc_apitest
+{
+class ScCellRangeObj : public CalcUnoApiTest,
+                       public apitest::CellProperties,
+                       public apitest::SheetCellRange,
+                       public apitest::XArrayFormulaRange,
+                       public apitest::XCellFormatRangesSupplier,
+                       public apitest::XCellRangeAddressable,
+                       public apitest::XCellRangeData,
+                       public apitest::XCellRangeFormula,
+                       public apitest::XCellRangesQuery,
+                       public apitest::XCellSeries,
+                       public apitest::XChartData,
+                       public apitest::XColumnRowRange,
+                       public apitest::XFormulaQuery,
+                       public apitest::XIndent,
+                       public apitest::XMergeable,
+                       public apitest::XMultipleOperation,
+                       public apitest::XReplaceable,
+                       public apitest::XSearchable,
+                       public apitest::XSheetCellRange,
+                       public apitest::XSheetFilterable,
+                       public apitest::XSheetFilterableEx,
+                       public apitest::XSheetOperation,
+                       public apitest::XSubTotalCalculatable,
+                       public apitest::XUniqueCellFormatRangesSupplier
 {
 public:
     ScCellRangeObj();
 
     virtual void setUp() override;
     virtual void tearDown() override;
-    virtual uno::Reference< uno::XInterface > init() override;
-    virtual uno::Reference< uno::XInterface > getXCellRangeData() override;
-    virtual uno::Reference< uno::XInterface > getXSpreadsheet() override;
+    virtual uno::Reference<uno::XInterface> init() override;
+    virtual uno::Reference<uno::XInterface> getXCellRangeData() override;
+    virtual uno::Reference<uno::XInterface> getXSpreadsheet() override;
     void testSortOOB();
 
     CPPUNIT_TEST_SUITE(ScCellRangeObj);
@@ -124,6 +127,11 @@ public:
     CPPUNIT_TEST(testFillAuto);
     CPPUNIT_TEST(testFillSeries);
 
+    // XChartData
+    CPPUNIT_TEST(testGetNotANumber);
+    CPPUNIT_TEST(testIsNotANumber);
+    CPPUNIT_TEST(testChartDataChangeEventListener);
+
     // XColumnRowRange
     CPPUNIT_TEST(testGetColumns);
     CPPUNIT_TEST(testGetRows);
@@ -176,57 +184,60 @@ public:
     CPPUNIT_TEST_SUITE_END();
 
 private:
-    uno::Reference< lang::XComponent > mxComponent;
+    uno::Reference<lang::XComponent> mxComponent;
 };
 
-ScCellRangeObj::ScCellRangeObj():
-        CalcUnoApiTest("/sc/qa/extras/testdocuments"),
-        apitest::XCellSeries(2, 1),
-        apitest::XFormulaQuery(table::CellRangeAddress(0, 15, 15, 15, 15), table::CellRangeAddress(0, 0, 15, 0, 15)),
-        apitest::XReplaceable("15", "35"),
-        apitest::XSearchable("15", 1)
+ScCellRangeObj::ScCellRangeObj()
+    : CalcUnoApiTest("/sc/qa/extras/testdocuments")
+    , XCellSeries(2, 1)
+    , XFormulaQuery(table::CellRangeAddress(0, 15, 15, 15, 15),
+                    table::CellRangeAddress(0, 0, 15, 0, 15))
+    , XReplaceable("15", "35")
+    , XSearchable("15", 1)
 {
 }
 
-uno::Reference< uno::XInterface > ScCellRangeObj::init()
+uno::Reference<uno::XInterface> ScCellRangeObj::init()
 {
-    uno::Reference< sheet::XSpreadsheetDocument> xDoc (mxComponent, UNO_QUERY_THROW);
+    uno::Reference<sheet::XSpreadsheetDocument> xDoc(mxComponent, uno::UNO_QUERY_THROW);
 
-    uno::Reference< container::XIndexAccess > xIndex (xDoc->getSheets(), UNO_QUERY_THROW);
-    uno::Reference< sheet::XSpreadsheet > xSheet( xIndex->getByIndex(0), UNO_QUERY_THROW);
+    uno::Reference<container::XIndexAccess> xIndex(xDoc->getSheets(), uno::UNO_QUERY_THROW);
+    uno::Reference<sheet::XSpreadsheet> xSheet(xIndex->getByIndex(0), uno::UNO_QUERY_THROW);
 
-    uno::Reference<table::XCellRange> xReturn(xSheet->getCellRangeByPosition(0,0,4,4), UNO_QUERY_THROW);
+    uno::Reference<table::XCellRange> xReturn(xSheet->getCellRangeByPosition(0, 0, 4, 4),
+                                              uno::UNO_QUERY_THROW);
 
     return xReturn;
 }
 
-uno::Reference< uno::XInterface > ScCellRangeObj::getXSpreadsheet()
+uno::Reference<uno::XInterface> ScCellRangeObj::getXSpreadsheet()
 {
-    uno::Reference< sheet::XSpreadsheetDocument> xDoc (mxComponent, UNO_QUERY_THROW);
+    uno::Reference<sheet::XSpreadsheetDocument> xDoc(mxComponent, uno::UNO_QUERY_THROW);
 
-    uno::Reference< container::XIndexAccess > xIndex (xDoc->getSheets(), UNO_QUERY_THROW);
-    uno::Reference< sheet::XSpreadsheet > xSheet(xIndex->getByIndex(0), UNO_QUERY_THROW);
+    uno::Reference<container::XIndexAccess> xIndex(xDoc->getSheets(), uno::UNO_QUERY_THROW);
+    uno::Reference<sheet::XSpreadsheet> xSheet(xIndex->getByIndex(0), uno::UNO_QUERY_THROW);
 
     setXCell(xSheet->getCellByPosition(15, 15));
 
     return xSheet;
 }
 
-uno::Reference< uno::XInterface > ScCellRangeObj::getXCellRangeData()
+uno::Reference<uno::XInterface> ScCellRangeObj::getXCellRangeData()
 {
-    uno::Reference< sheet::XSpreadsheetDocument> xDoc (mxComponent, UNO_QUERY_THROW);
+    uno::Reference<sheet::XSpreadsheetDocument> xDoc(mxComponent, uno::UNO_QUERY_THROW);
 
-    uno::Reference< container::XIndexAccess > xIndex (xDoc->getSheets(), UNO_QUERY_THROW);
-    uno::Reference< sheet::XSpreadsheet > xSheet( xIndex->getByIndex(1), UNO_QUERY_THROW);
+    uno::Reference<container::XIndexAccess> xIndex(xDoc->getSheets(), uno::UNO_QUERY_THROW);
+    uno::Reference<sheet::XSpreadsheet> xSheet(xIndex->getByIndex(1), uno::UNO_QUERY_THROW);
 
-    uno::Reference<table::XCellRange> xReturn(xSheet->getCellRangeByPosition(0,0,3,3), UNO_QUERY_THROW);
+    uno::Reference<table::XCellRange> xReturn(xSheet->getCellRangeByPosition(0, 0, 3, 3),
+                                              uno::UNO_QUERY_THROW);
 
     return xReturn;
 }
 
 void ScCellRangeObj::testSortOOB()
 {
-    uno::Reference<util::XSortable> xSortable(init(),UNO_QUERY_THROW);
+    uno::Reference<util::XSortable> xSortable(init(), uno::UNO_QUERY_THROW);
     uno::Sequence<beans::PropertyValue> aEmptyDescriptor;
     xSortable->sort(aEmptyDescriptor);
 
@@ -234,9 +245,8 @@ void ScCellRangeObj::testSortOOB()
     aSort[0].Field = 0xffffff;
     aSort[0].SortAscending = true;
 
-    uno::Sequence<beans::PropertyValue> aProps( comphelper::InitPropertySequence({
-            { "SortFields", Any(aSort) }
-        }));
+    uno::Sequence<beans::PropertyValue> aProps(
+        comphelper::InitPropertySequence({ { "SortFields", uno::Any(aSort) } }));
 
     xSortable->sort(aProps);
 }
@@ -259,7 +269,7 @@ void ScCellRangeObj::tearDown()
 
 CPPUNIT_TEST_SUITE_REGISTRATION(ScCellRangeObj);
 
-}
+} // namespace sc_apitest
 
 CPPUNIT_PLUGIN_IMPLEMENT();
 
diff --git a/test/Library_subsequenttest.mk b/test/Library_subsequenttest.mk
index e400f66ecb62..31762106f3c0 100644
--- a/test/Library_subsequenttest.mk
+++ b/test/Library_subsequenttest.mk
@@ -41,6 +41,7 @@ $(eval $(call gb_Library_add_exception_objects,subsequenttest,\
 	test/source/unoapi_test \
 	test/source/calc_unoapi_test \
 	test/source/beans/xpropertyset \
+	test/source/chart/xchartdata \
 	test/source/container/xchild \
 	test/source/container/xelementaccess \
 	test/source/container/xenumeration \
diff --git a/test/source/chart/xchartdata.cxx b/test/source/chart/xchartdata.cxx
new file mode 100644
index 000000000000..5f099fde69d6
--- /dev/null
+++ b/test/source/chart/xchartdata.cxx
@@ -0,0 +1,93 @@
+/* -*- 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/chart/xchartdata.hxx>
+#include <cppuhelper/implbase.hxx>
+#include <rtl/ref.hxx>
+
+#include <com/sun/star/chart/ChartDataChangeEvent.hpp>
+#include <com/sun/star/chart/XChartData.hpp>
+#include <com/sun/star/chart/XChartDataArray.hpp>
+#include <com/sun/star/chart/XChartDataChangeEventListener.hpp>
+#include <com/sun/star/lang/EventObject.hpp>
+
+#include <cppunit/extensions/HelperMacros.h>
+
+using namespace css;
+
+namespace apitest
+{
+class MockedChartDataChangeEventListener
+    : public ::cppu::WeakImplHelper<chart::XChartDataChangeEventListener>
+{
+public:
+    MockedChartDataChangeEventListener()
+        : m_bListenerCalled(false)
+    {
+    }
+
+    bool m_bListenerCalled;
+    virtual void SAL_CALL chartDataChanged(const chart::ChartDataChangeEvent& /* rEvent */) override
+    {
+        m_bListenerCalled = true;
+    }
+
+    virtual void SAL_CALL disposing(const lang::EventObject& /* xEvent */) override {}
+};
+
+void XChartData::testGetNotANumber()
+{
+    uno::Reference<chart::XChartData> xCD(init(), uno::UNO_QUERY_THROW);
+    const double fNaN = xCD->getNotANumber();
+
+    CPPUNIT_ASSERT(fNaN != 1.0);
+}
+
+void XChartData::testIsNotANumber()
+{
+    uno::Reference<chart::XChartData> xCD(init(), uno::UNO_QUERY_THROW);
+    const double fNaN = xCD->getNotANumber();
+    CPPUNIT_ASSERT(xCD->isNotANumber(fNaN));
+    CPPUNIT_ASSERT(!xCD->isNotANumber(fNaN + 1.0));
+}
+
+void XChartData::testChartDataChangeEventListener()
+{
+    uno::Reference<chart::XChartData> xCD(init(), uno::UNO_QUERY_THROW);
+
+    rtl::Reference<MockedChartDataChangeEventListener> pListener0
+        = new MockedChartDataChangeEventListener();
+    xCD->addChartDataChangeEventListener(
+        uno::Reference<chart::XChartDataChangeEventListener>(pListener0.get()));
+    rtl::Reference<MockedChartDataChangeEventListener> pListener1
+        = new MockedChartDataChangeEventListener();
+    xCD->addChartDataChangeEventListener(
+        uno::Reference<chart::XChartDataChangeEventListener>(pListener1.get()));
+
+    uno::Reference<chart::XChartDataArray> xCDD(xCD, uno::UNO_QUERY_THROW);
+    uno::Sequence<uno::Sequence<double>> aData = xCDD->getData();
+    aData[0][0] += 1.0;
+    xCDD->setData(aData);
+    CPPUNIT_ASSERT(pListener0->m_bListenerCalled);
+    CPPUNIT_ASSERT(pListener1->m_bListenerCalled);
+
+    pListener0->m_bListenerCalled = false;
+    pListener1->m_bListenerCalled = false;
+
+    xCD->removeChartDataChangeEventListener(
+        uno::Reference<chart::XChartDataChangeEventListener>(pListener1.get()));
+    aData[0][0] += 1.0;
+    xCDD->setData(aData);
+    CPPUNIT_ASSERT(pListener0->m_bListenerCalled);
+    CPPUNIT_ASSERT(!pListener1->m_bListenerCalled);
+}
+
+} // namespace apitest
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab cinoptions=b1,g0,N-s cinkeys+=0=break: */


More information about the Libreoffice-commits mailing list