Kaydet (Commit) eb7a731b authored tarafından Jens Carl's avatar Jens Carl

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: 's avatarJens Carl <j.carl43@gmx.de>
üst 68bc7b47
/* -*- 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: */
......@@ -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"
......
......@@ -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();
......
......@@ -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 \
......
/* -*- 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: */
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment