tdf#45904 Move remaining XCellSeries test code to C++

Change-Id: Ie4ee1e52157dd38ac0defee2e9d5cfa822763183
Reviewed-on: https://gerrit.libreoffice.org/38807
Tested-by: Jenkins <ci@libreoffice.org>
Reviewed-by: Markus Mohrhard <markus.mohrhard@googlemail.com>
This commit is contained in:
Paul Trojahn 2017-06-08 16:30:08 +02:00 committed by Markus Mohrhard
parent e89e3ca2a6
commit 2516285d2a
14 changed files with 312 additions and 285 deletions

View file

@ -18,13 +18,21 @@ namespace apitest {
class OOO_DLLPUBLIC_TEST XCellSeries
{
public:
XCellSeries(sal_Int32 aStartX, sal_Int32 aStartY) : maStartX(aStartX), maStartY(aStartY){}
virtual css::uno::Reference< css::uno::XInterface > init() = 0;
virtual ~XCellSeries(){}
void testFillAuto();
void testFillSeries();
private:
sal_Int32 maStartX;
sal_Int32 maStartY;
};
}
#endif // INCLUDED_TEST_SHEET_XCELLSERIES_HXX
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */

View file

@ -600,7 +600,6 @@ $(eval $(call gb_Jar_add_sourcefiles,OOoRunner,\
qadevOOo/tests/java/ifc/sheet/_XCellRangeMovement \
qadevOOo/tests/java/ifc/sheet/_XCellRangeReferrer \
qadevOOo/tests/java/ifc/sheet/_XCellRangesQuery \
qadevOOo/tests/java/ifc/sheet/_XCellSeries \
qadevOOo/tests/java/ifc/sheet/_XConsolidatable \
qadevOOo/tests/java/ifc/sheet/_XConsolidationDescriptor \
qadevOOo/tests/java/ifc/sheet/_XDatabaseRange \

View file

@ -222,8 +222,6 @@
"ScCellCursorObj";"com::sun::star::chart::XChartDataArray";"setRowDescriptions()"
"ScCellCursorObj";"com::sun::star::chart::XChartDataArray";"getColumnDescriptions()"
"ScCellCursorObj";"com::sun::star::chart::XChartDataArray";"setColumnDescriptions()"
"ScCellCursorObj";"com::sun::star::sheet::XCellSeries";"fillSeries()"
"ScCellCursorObj";"com::sun::star::sheet::XCellSeries";"fillAuto()"
"ScCellCursorObj";"com::sun::star::sheet::XCellFormatRangesSupplier";"getCellFormatRanges()"
"ScCellCursorObj";"com::sun::star::sheet::XSheetCellCursor";"collapseToCurrentRegion()"
"ScCellCursorObj";"com::sun::star::sheet::XSheetCellCursor";"collapseToCurrentArray()"

1 ScCellCursorObj com::sun::star::table::CellProperties CellStyle#optional
222 ScCellCursorObj com::sun::star::chart::XChartDataArray setRowDescriptions()
223 ScCellCursorObj com::sun::star::chart::XChartDataArray getColumnDescriptions()
224 ScCellCursorObj com::sun::star::chart::XChartDataArray setColumnDescriptions()
ScCellCursorObj com::sun::star::sheet::XCellSeries fillSeries()
ScCellCursorObj com::sun::star::sheet::XCellSeries fillAuto()
225 ScCellCursorObj com::sun::star::sheet::XCellFormatRangesSupplier getCellFormatRanges()
226 ScCellCursorObj com::sun::star::sheet::XSheetCellCursor collapseToCurrentRegion()
227 ScCellCursorObj com::sun::star::sheet::XSheetCellCursor collapseToCurrentArray()

View file

@ -215,8 +215,6 @@
"ScCellRangeObj";"com::sun::star::chart::XChartDataArray";"setRowDescriptions()"
"ScCellRangeObj";"com::sun::star::chart::XChartDataArray";"getColumnDescriptions()"
"ScCellRangeObj";"com::sun::star::chart::XChartDataArray";"setColumnDescriptions()"
"ScCellRangeObj";"com::sun::star::sheet::XCellSeries";"fillSeries()"
"ScCellRangeObj";"com::sun::star::sheet::XCellSeries";"fillAuto()"
"ScCellRangeObj";"com::sun::star::sheet::XCellFormatRangesSupplier";"getCellFormatRanges()"
"ScCellRangeObj";"com::sun::star::util::XModifyBroadcaster#optional";"addModifyListener()"
"ScCellRangeObj";"com::sun::star::util::XModifyBroadcaster#optional";"removeModifyListener()"

1 ScCellRangeObj com::sun::star::table::CellProperties CellStyle#optional
215 ScCellRangeObj com::sun::star::chart::XChartDataArray setRowDescriptions()
216 ScCellRangeObj com::sun::star::chart::XChartDataArray getColumnDescriptions()
217 ScCellRangeObj com::sun::star::chart::XChartDataArray setColumnDescriptions()
ScCellRangeObj com::sun::star::sheet::XCellSeries fillSeries()
ScCellRangeObj com::sun::star::sheet::XCellSeries fillAuto()
218 ScCellRangeObj com::sun::star::sheet::XCellFormatRangesSupplier getCellFormatRanges()
219 ScCellRangeObj com::sun::star::util::XModifyBroadcaster#optional addModifyListener()
220 ScCellRangeObj com::sun::star::util::XModifyBroadcaster#optional removeModifyListener()

View file

@ -1,237 +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 helper.LoggingThread;
import lib.MultiMethodTest;
import lib.Status;
import lib.StatusException;
import com.sun.star.sheet.XCellSeries;
import com.sun.star.sheet.XSpreadsheet;
import com.sun.star.uno.UnoRuntime;
import share.LogWriter;
public class _XCellSeries extends MultiMethodTest {
public XCellSeries oObj = null;
protected XSpreadsheet oSheet = null;
protected boolean isSpreadSheet = false;
protected boolean fillAuto = true;
protected boolean forceFillAuto = false;
@Override
protected void before() {
oSheet = (XSpreadsheet) tEnv.getObjRelation("SHEET");
if (oSheet == null) {
log.println("Object relation oSheet is missing");
log.println("Trying to query the needed Interface");
oSheet = UnoRuntime.queryInterface(
XSpreadsheet.class, tEnv.getTestObject());
if (oSheet == null) {
throw new StatusException(Status.failed(
"Object relation oSheet is missing"));
} else {
isSpreadSheet = true;
}
}
Boolean myFillAuto = (Boolean) tEnv.getObjRelation("XCELLSERIES_FILLAUTO");
if (myFillAuto != null) fillAuto = myFillAuto.booleanValue();
if (tParam.containsKey("force_fillauto")){
fillAuto = tParam.getBool("force_fillauto");
forceFillAuto = tParam.getBool("force_fillauto");
}
}
public void _fillAuto() {
if ((isSpreadSheet && !forceFillAuto) || !fillAuto) {
log.println("This method consumes to much time for a complete SpreadSheet");
log.println("Please use parameter '-force_fillauto true' to force this test");
tRes.tested("fillAuto()",Status.skipped(true));
return;
}
boolean res = true;
try {
oSheet.getCellByPosition(0, 0).setValue(2);
log.println(
"calling oObj.fillAuto(com.sun.star.sheet.FillDirection.TO_RIGHT, 1)");
oObj.fillAuto(com.sun.star.sheet.FillDirection.TO_RIGHT, 1);
oSheet.getCellByPosition(0, 4).setFormula("=sum(A1:D1)");
double getting = oSheet.getCellByPosition(0, 4).getValue();
boolean locres = (getting == 14);
if (!locres) {
log.println("Operation failed");
} else {
log.println("Successful");
}
res &= locres;
log.println(
"calling oObj.fillAuto(com.sun.star.sheet.FillDirection.TO_BOTTOM, 1)");
oObj.fillAuto(com.sun.star.sheet.FillDirection.TO_BOTTOM, 1);
oSheet.getCellByPosition(4, 0).setFormula("=sum(A1:A4)");
getting = oSheet.getCellByPosition(4, 0).getValue();
locres = (getting == 14);
if (!locres) {
log.println("Operation failed");
} else {
log.println("Successful");
}
res &= locres;
} catch (com.sun.star.lang.IndexOutOfBoundsException e) {
log.println("Couldn't set initial version to cell");
res = false;
}
tRes.tested("fillAuto()", res);
}
public void _fillSeries() {
if (isSpreadSheet) {
log.println("This method consumes to much time for a complete SpreadSheet");
tRes.tested("fillSeries()",Status.skipped(true));
return;
}
boolean res = true;
try {
oSheet.getCellByPosition(0, 0).setValue(2);
LoggingThread logger = new LoggingThread((LogWriter)log, tParam);
logger.start();
log.println(
"calling oObj.fillSeries(com.sun.star.sheet.FillDirection.TO_RIGHT, com.sun.star.sheet.FillMode.LINEAR, com.sun.star.sheet.FillDateMode.FILL_DATE_DAY, 2, 8)");
oObj.fillSeries(com.sun.star.sheet.FillDirection.TO_RIGHT,
com.sun.star.sheet.FillMode.LINEAR,
com.sun.star.sheet.FillDateMode.FILL_DATE_DAY, 2, 8);
oSheet.getCellByPosition(0, 4).setFormula("=sum(A1:D1)");
double getting = oSheet.getCellByPosition(0, 4).getValue();
boolean locres = (getting == 20);
logger.finish();
if (!locres) {
log.println("Operation failed");
} else {
log.println("Successful");
}
res &= locres;
logger = new LoggingThread((LogWriter)log, tParam);
logger.start();
log.println(
"calling oObj.fillSeries(com.sun.star.sheet.FillDirection.TO_RIGHT, com.sun.star.sheet.FillMode.GROWTH, com.sun.star.sheet.FillDateMode.FILL_DATE_DAY, 2, 16)");
oObj.fillSeries(com.sun.star.sheet.FillDirection.TO_RIGHT,
com.sun.star.sheet.FillMode.GROWTH,
com.sun.star.sheet.FillDateMode.FILL_DATE_DAY, 2,
16);
oSheet.getCellByPosition(0, 4).setFormula("=sum(A1:D1)");
getting = oSheet.getCellByPosition(0, 4).getValue();
locres = (getting == 30);
logger.finish();
if (!locres) {
log.println("Operation failed");
} else {
log.println("Successful");
}
res &= locres;
logger = new LoggingThread((LogWriter)log, tParam);
logger.start();
log.println(
"calling oObj.fillSeries(com.sun.star.sheet.FillDirection.TO_BOTTOM, com.sun.star.sheet.FillMode.LINEAR, com.sun.star.sheet.FillDateMode.FILL_DATE_DAY, 2, 8)");
oObj.fillSeries(com.sun.star.sheet.FillDirection.TO_BOTTOM,
com.sun.star.sheet.FillMode.LINEAR,
com.sun.star.sheet.FillDateMode.FILL_DATE_DAY, 2, 8);
oSheet.getCellByPosition(4, 0).setFormula("=sum(A1:A4)");
getting = oSheet.getCellByPosition(4, 0).getValue();
locres = (getting == 20);
logger.finish();
if (!locres) {
log.println("Operation failed");
} else {
log.println("Successful");
}
res &= locres;
logger = new LoggingThread((LogWriter)log, tParam);
logger.start();
log.println(
"calling oObj.fillSeries(com.sun.star.sheet.FillDirection.TO_BOTTOM, com.sun.star.sheet.FillMode.GROWTH, com.sun.star.sheet.FillDateMode.FILL_DATE_DAY, 2, 16)");
oObj.fillSeries(com.sun.star.sheet.FillDirection.TO_BOTTOM,
com.sun.star.sheet.FillMode.GROWTH,
com.sun.star.sheet.FillDateMode.FILL_DATE_DAY, 2,
16);
oSheet.getCellByPosition(4, 0).setFormula("=sum(A1:A4)");
getting = oSheet.getCellByPosition(4, 0).getValue();
locres = (getting == 30);
logger.finish();
if (!locres) {
log.println("Operation failed");
} else {
log.println("Successful");
}
res &= locres;
} catch (com.sun.star.lang.IndexOutOfBoundsException e) {
log.println("Couldn't set initial version to cell");
res = false;
}
tRes.tested("fillSeries()", res);
}
/**
* Forces environment recreation.
*/
@Override
public void after() {
disposeEnvironment();
}
}

View file

@ -0,0 +1,105 @@
# -*- Mode: makefile-gmake; tab-width: 4; indent-tabs-mode: t -*-
#*************************************************************************
#
# 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/.
#
#*************************************************************************
$(eval $(call gb_CppunitTest_CppunitTest,sc_cellcursorobj))
$(eval $(call gb_CppunitTest_add_exception_objects,sc_cellcursorobj, \
sc/qa/extras/sccellcursorobj \
))
$(eval $(call gb_CppunitTest_use_external,sc_cellcursorobj,boost_headers))
$(eval $(call gb_CppunitTest_use_libraries,sc_cellcursorobj, \
basegfx \
comphelper \
cppu \
cppuhelper \
drawinglayer \
editeng \
for \
forui \
i18nlangtag \
msfilter \
oox \
sal \
salhelper \
sax \
sb \
sc \
sfx \
sot \
subsequenttest \
svl \
svt \
svx \
svxcore \
test \
tk \
tl \
ucbhelper \
unotest \
utl \
vbahelper \
vcl \
xo \
))
$(eval $(call gb_CppunitTest_set_include,sc_cellcursorobj,\
-I$(SRCDIR)/sc/source/ui/inc \
-I$(SRCDIR)/sc/inc \
$$(INCLUDE) \
))
$(eval $(call gb_CppunitTest_use_sdk_api,sc_cellcursorobj))
$(eval $(call gb_CppunitTest_use_ure,sc_cellcursorobj))
$(eval $(call gb_CppunitTest_use_vcl,sc_cellcursorobj))
$(eval $(call gb_CppunitTest_use_components,sc_cellcursorobj,\
basic/util/sb \
comphelper/util/comphelp \
configmgr/source/configmgr \
dbaccess/util/dba \
filter/source/config/cache/filterconfig1 \
filter/source/storagefilterdetect/storagefd \
forms/util/frm \
framework/util/fwk \
i18npool/util/i18npool \
linguistic/source/lng \
oox/util/oox \
package/source/xstor/xstor \
package/util/package2 \
sax/source/expatwrap/expwrap \
scripting/source/basprov/basprov \
scripting/util/scriptframe \
sc/util/sc \
sc/util/scd \
sc/util/scfilt \
$(call gb_Helper_optional,SCRIPTING, \
sc/util/vbaobj) \
sfx2/util/sfx \
sot/util/sot \
svl/source/fsstor/fsstorage \
toolkit/util/tk \
ucb/source/core/ucb1 \
ucb/source/ucp/file/ucpfile1 \
ucb/source/ucp/tdoc/ucptdoc1 \
unotools/util/utl \
unoxml/source/rdf/unordf \
unoxml/source/service/unoxml \
uui/util/uui \
xmloff/util/xo \
svtools/util/svt \
))
$(eval $(call gb_CppunitTest_use_configuration,sc_cellcursorobj))
# vim: set noet sw=4 ts=4:

View file

@ -120,6 +120,7 @@ $(eval $(call gb_Module_add_subsequentcheck_targets,sc,\
CppunitTest_sc_check_data_pilot_field \
CppunitTest_sc_check_data_pilot_table \
CppunitTest_sc_viewpaneobj \
CppunitTest_sc_cellcursorobj \
))
$(eval $(call gb_Module_add_perfcheck_targets,sc,\

View file

@ -0,0 +1,92 @@
/* -*- 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/.
*/
#include <test/calc_unoapi_test.hxx>
#include <test/sheet/xcellseries.hxx>
#include <com/sun/star/table/XCellCursor.hpp>
#include <com/sun/star/sheet/XSpreadsheetDocument.hpp>
#include <com/sun/star/sheet/XSpreadsheet.hpp>
using namespace css;
using namespace css::uno;
namespace sc_apitest {
#define NUMBER_OF_TESTS 2
class ScCellCursorObj : public CalcUnoApiTest, apitest::XCellSeries
{
public:
ScCellCursorObj();
virtual void setUp() override;
virtual void tearDown() override;
virtual uno::Reference< uno::XInterface > init() override;
CPPUNIT_TEST_SUITE(ScCellCursorObj);
CPPUNIT_TEST(testFillAuto);
CPPUNIT_TEST(testFillSeries);
CPPUNIT_TEST_SUITE_END();
private:
static sal_Int32 nTest;
static uno::Reference< lang::XComponent > mxComponent;
};
sal_Int32 ScCellCursorObj::nTest = 0;
uno::Reference< lang::XComponent > ScCellCursorObj::mxComponent;
ScCellCursorObj::ScCellCursorObj():
CalcUnoApiTest("/sc/qa/extras/testdocuments"),
apitest::XCellSeries(0, 0)
{
}
uno::Reference< uno::XInterface > ScCellCursorObj::init()
{
OUString aFileURL;
createFileURL("ScCellCursorObj.ods", aFileURL);
if(!mxComponent.is())
mxComponent = loadFromDesktop(aFileURL, "com.sun.star.sheet.SpreadsheetDocument");
CPPUNIT_ASSERT(mxComponent.is());
uno::Reference< sheet::XSpreadsheetDocument > xDoc(mxComponent, 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< table::XCellCursor > xCellCursor( xSheet->createCursor(), UNO_QUERY_THROW);
return xCellCursor;
}
void ScCellCursorObj::setUp()
{
nTest++;
CPPUNIT_ASSERT(nTest <= NUMBER_OF_TESTS);
CalcUnoApiTest::setUp();
}
void ScCellCursorObj::tearDown()
{
if (nTest == NUMBER_OF_TESTS)
{
closeDocument(mxComponent);
mxComponent.clear();
}
CalcUnoApiTest::tearDown();
}
CPPUNIT_TEST_SUITE_REGISTRATION(ScCellCursorObj);
}
CPPUNIT_PLUGIN_IMPLEMENT();
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */

View file

@ -13,6 +13,7 @@
#include <test/util/xreplaceable.hxx>
#include <test/util/xsearchable.hxx>
#include <test/sheet/xcellrangedata.hxx>
#include <test/sheet/xcellseries.hxx>
#include <com/sun/star/sheet/XSpreadsheetDocument.hpp>
#include <com/sun/star/sheet/XSpreadsheet.hpp>
@ -26,10 +27,11 @@ using namespace css::uno;
namespace sc_apitest {
#define NUMBER_OF_TESTS 15
#define NUMBER_OF_TESTS 17
class ScCellRangeObj : public CalcUnoApiTest, public apitest::XCellRangesQuery, public apitest::CellProperties,
public apitest::XSearchable, public apitest::XReplaceable, public apitest::XCellRangeData
public apitest::XSearchable, public apitest::XReplaceable, public apitest::XCellRangeData,
public apitest::XCellSeries
{
public:
ScCellRangeObj();
@ -58,6 +60,8 @@ public:
CPPUNIT_TEST(testGetDataArray);
CPPUNIT_TEST(testSetDataArray);
CPPUNIT_TEST(testSortOOB);
CPPUNIT_TEST(testFillAuto);
CPPUNIT_TEST(testFillSeries);
CPPUNIT_TEST_SUITE_END();
private:
@ -71,7 +75,8 @@ uno::Reference< lang::XComponent > ScCellRangeObj::mxComponent;
ScCellRangeObj::ScCellRangeObj():
CalcUnoApiTest("/sc/qa/extras/testdocuments"),
apitest::XSearchable("15", 1),
apitest::XReplaceable("15", "35")
apitest::XReplaceable("15", "35"),
apitest::XCellSeries(2, 1)
{
}
@ -89,7 +94,7 @@ uno::Reference< uno::XInterface > ScCellRangeObj::init()
CPPUNIT_ASSERT_MESSAGE("Could not create interface of type XSpreadsheet", xSheet.is());
uno::Reference<table::XCellRange> xReturn(xSheet->getCellRangeByPosition(0,0,3,4), UNO_QUERY_THROW);
uno::Reference<table::XCellRange> xReturn(xSheet->getCellRangeByPosition(0,0,4,4), UNO_QUERY_THROW);
CPPUNIT_ASSERT_MESSAGE("Could not create object of type XCellRangesQuery", xReturn.is());
return xReturn;

View file

@ -22,11 +22,14 @@ using namespace css::uno;
namespace sc_apitest
{
#define NUMBER_OF_TESTS 9
class ScTableSheetObj : public CalcUnoApiTest, public apitest::XSearchable, public apitest::XReplaceable, public apitest::XPrintAreas, public apitest::XCellSeries
{
public:
ScTableSheetObj();
virtual void setUp() override;
virtual void tearDown() override;
virtual uno::Reference< uno::XInterface > init() override;
@ -46,13 +49,18 @@ public:
CPPUNIT_TEST_SUITE_END();
private:
uno::Reference< lang::XComponent > mxComponent;
static sal_Int32 nTest;
static uno::Reference< lang::XComponent > mxComponent;
};
sal_Int32 ScTableSheetObj::nTest = 0;
uno::Reference< lang::XComponent > ScTableSheetObj::mxComponent;
ScTableSheetObj::ScTableSheetObj():
CalcUnoApiTest("/sc/qa/extras/testdocuments"),
apitest::XSearchable("test", 4),
apitest::XReplaceable("searchReplaceString", "replaceReplaceString")
apitest::XReplaceable("searchReplaceString", "replaceReplaceString"),
apitest::XCellSeries(1, 0)
{
}
@ -71,10 +79,20 @@ uno::Reference< uno::XInterface > ScTableSheetObj::init()
return xSheet;
}
void ScTableSheetObj::setUp()
{
nTest++;
CPPUNIT_ASSERT(nTest <= NUMBER_OF_TESTS);
CalcUnoApiTest::setUp();
}
void ScTableSheetObj::tearDown()
{
closeDocument(mxComponent);
mxComponent.clear();
if (nTest == NUMBER_OF_TESTS)
{
closeDocument(mxComponent);
mxComponent.clear();
}
CalcUnoApiTest::tearDown();
}

Binary file not shown.

View file

@ -29,67 +29,67 @@ void XCellRangesQuery::testQueryColumnDifference()
uno::Reference<sheet::XSheetCellRanges> xRanges = xCellRangesQuery->queryColumnDifferences(table::CellAddress(0, 1, 1));
OUString aResult = xRanges->getRangeAddressesAsString();
std::cout << "testQueryColumnDifference: Result: " << aResult << std::endl;
CPPUNIT_ASSERT_EQUAL_MESSAGE("testQueryColumnDifference", aResult, aExpected);
CPPUNIT_ASSERT_EQUAL_MESSAGE("testQueryColumnDifference", aExpected, aResult);
}
void XCellRangesQuery::testQueryContentDifference()
{
OUString aExpected( "Sheet1.B2:B3" );
OUString aExpected( "Sheet1.B3,Sheet1.C2" );
uno::Reference<sheet::XCellRangesQuery> xCellRangesQuery(init(),UNO_QUERY_THROW);
uno::Reference<sheet::XSheetCellRanges> xRanges = xCellRangesQuery->queryContentCells(sheet::CellFlags::VALUE);
OUString aResult = xRanges->getRangeAddressesAsString();
std::cout << "testQueryContentDifference: Result: " << aResult << std::endl;
CPPUNIT_ASSERT_EQUAL_MESSAGE("testQueryContentDifference", aResult, aExpected);
CPPUNIT_ASSERT_EQUAL_MESSAGE("testQueryContentDifference", aExpected, aResult);
}
void XCellRangesQuery::testQueryEmptyCells()
{
OUString aExpected( "Sheet1.A1:A5,Sheet1.B1:C1,Sheet1.B5,Sheet1.C3:C5,Sheet1.D1:D5" );
OUString aExpected( "Sheet1.A1:A5,Sheet1.B1:C1,Sheet1.B5,Sheet1.C3:C5,Sheet1.D1:E5" );
uno::Reference<sheet::XCellRangesQuery> xCellRangesQuery(init(),UNO_QUERY_THROW);
uno::Reference<sheet::XSheetCellRanges> xRanges = xCellRangesQuery->queryEmptyCells();
OUString aResult = xRanges->getRangeAddressesAsString();
std::cout << "testQueryEmptyCells: Result: " << aResult << std::endl;
CPPUNIT_ASSERT_EQUAL_MESSAGE("testQueryEmptyCells", aResult, aExpected);
CPPUNIT_ASSERT_EQUAL_MESSAGE("testQueryEmptyCells", aExpected, aResult);
}
void XCellRangesQuery::testQueryFormulaCells()
{
OUString aExpected( "Sheet1.C2" );
OUString aExpected( "Sheet1.B2" );
uno::Reference<sheet::XCellRangesQuery> xCellRangesQuery(init(),UNO_QUERY_THROW);
uno::Reference<sheet::XSheetCellRanges> xRanges = xCellRangesQuery->queryFormulaCells(sheet::CellFlags::FORMULA);
OUString aResult = xRanges->getRangeAddressesAsString();
std::cout << "testQueryFormulaCells: Result: " << aResult << std::endl;
CPPUNIT_ASSERT_EQUAL_MESSAGE("testQueryFormulaCells", aResult, aExpected);
CPPUNIT_ASSERT_EQUAL_MESSAGE("testQueryFormulaCells", aExpected, aResult);
}
void XCellRangesQuery::testQueryIntersection()
{
OUString aExpected( "Sheet1.D4:D5" );
OUString aExpected( "Sheet1.D4:E5" );
uno::Reference<sheet::XCellRangesQuery> xCellRangesQuery(init(),UNO_QUERY_THROW);
uno::Reference<sheet::XSheetCellRanges> xRanges = xCellRangesQuery->queryIntersection(table::CellRangeAddress(0,3,3,7,7));
OUString aResult = xRanges->getRangeAddressesAsString();
std::cout << "testQueryIntersection: Result: " << aResult << std::endl;
CPPUNIT_ASSERT_EQUAL_MESSAGE("testQueryIntersection", aResult, aExpected);
CPPUNIT_ASSERT_EQUAL_MESSAGE("testQueryIntersection", aExpected, aResult);
}
void XCellRangesQuery::testQueryRowDifference()
{
OUString aExpected( "Sheet1.A2:A4,Sheet1.C2:D4" );
OUString aExpected( "Sheet1.A2:A4,Sheet1.C2:E4" );
uno::Reference<sheet::XCellRangesQuery> xCellRangesQuery(init(),UNO_QUERY_THROW);
uno::Reference<sheet::XSheetCellRanges> xRanges = xCellRangesQuery->queryRowDifferences(table::CellAddress(0,1,1));
OUString aResult = xRanges->getRangeAddressesAsString();
std::cout << "testQueryRowDifference: Result: " << aResult << std::endl;
CPPUNIT_ASSERT_EQUAL_MESSAGE("testQueryRowDifference", aResult, aExpected);
CPPUNIT_ASSERT_EQUAL_MESSAGE("testQueryRowDifference", aExpected, aResult);
}
void XCellRangesQuery::testQueryVisibleCells()
{
OUString aExpected( "Sheet1.A1:D5" );
OUString aExpected( "Sheet1.A1:E5" );
uno::Reference<sheet::XCellRangesQuery> xCellRangesQuery(init(),UNO_QUERY_THROW);
uno::Reference<sheet::XSheetCellRanges> xRanges = xCellRangesQuery->queryVisibleCells();
OUString aResult = xRanges->getRangeAddressesAsString();
std::cout << "testQueryVisibleCells: Result: " << aResult << std::endl;
CPPUNIT_ASSERT_EQUAL_MESSAGE("testQueryVisibleCells", aResult, aExpected);
CPPUNIT_ASSERT_EQUAL_MESSAGE("testQueryVisibleCells", aExpected, aResult);
}
}

View file

@ -22,53 +22,93 @@ namespace apitest {
void XCellSeries::testFillAuto()
{
uno::Reference<table::XCellRange> xCellRange(init(), UNO_QUERY_THROW);
sal_Int32 maValue = xCellRange->getCellByPosition(maStartX, maStartY)->getValue();
uno::Reference<table::XCellRange> xCellRangeH(xCellRange->getCellRangeByPosition(1, 0, 4, 0), UNO_QUERY_THROW);
uno::Reference<table::XCellRange> xCellRangeH(xCellRange->getCellRangeByPosition(maStartX, maStartY, maStartX + 2, maStartY), UNO_QUERY_THROW);
uno::Reference<sheet::XCellSeries> xCellSeriesH(xCellRangeH, UNO_QUERY_THROW);
xCellSeriesH->fillAuto(sheet::FillDirection_TO_RIGHT, 1);
uno::Reference<table::XCell> xCellResultH(xCellRange->getCellByPosition(5, 0), UNO_QUERY_THROW);
xCellResultH->setFormula("=SUM(B1:E1)");
CPPUNIT_ASSERT_EQUAL_MESSAGE("Wrong result for fillAuto with TO_RIGHT", 14., xCellResultH->getValue());
sal_Int32 sumH = 0;
for(sal_Int32 i = 0; i < 3; i++) {
uno::Reference<table::XCell> xCellResultH(xCellRange->getCellByPosition(maStartX + i, maStartY), UNO_QUERY_THROW);
sumH += xCellResultH->getValue();
}
CPPUNIT_ASSERT_EQUAL_MESSAGE("Wrong result for fillAuto with TO_RIGHT", maValue * 3 + 3, sumH);
uno::Reference<table::XCellRange> xCellRangeV(xCellRange->getCellRangeByPosition(1, 0, 1, 3), UNO_QUERY_THROW);
uno::Reference<table::XCellRange> xCellRangeV(xCellRange->getCellRangeByPosition(maStartX, maStartY, maStartX, maStartY + 2), UNO_QUERY_THROW);
uno::Reference<sheet::XCellSeries> xCellSeriesV(xCellRangeV, UNO_QUERY_THROW);
xCellSeriesV->fillAuto(sheet::FillDirection_TO_BOTTOM, 1);
uno::Reference<table::XCell> xCellResultV(xCellRange->getCellByPosition(1, 4), UNO_QUERY_THROW);
xCellResultV->setFormula("=SUM(B1:B4)");
CPPUNIT_ASSERT_EQUAL_MESSAGE("Wrong result for fillAuto with TO_BOTTOM", 14., xCellResultV->getValue());
sal_Int32 sumV = 0;
for(sal_Int32 i = 0; i < 3; i++) {
uno::Reference<table::XCell> xCellResultV(xCellRange->getCellByPosition(maStartX, maStartY + i), UNO_QUERY_THROW);
sumV += xCellResultV->getValue();
}
CPPUNIT_ASSERT_EQUAL_MESSAGE("Wrong result for fillAuto with TO_BOTTOM", maValue * 3 + 3, sumV);
for(sal_Int32 i = 1; i < 3; i++) {
uno::Reference<table::XCell> xCellResultH(xCellRange->getCellByPosition(maStartX + i, maStartY), UNO_QUERY_THROW);
xCellResultH->setFormula("");
uno::Reference<table::XCell> xCellResultV(xCellRange->getCellByPosition(maStartX, maStartY + i), UNO_QUERY_THROW);
xCellResultV->setFormula("");
}
}
void XCellSeries::testFillSeries()
{
uno::Reference<table::XCellRange> xCellRange(init(), UNO_QUERY_THROW);
sal_Int32 maValue = xCellRange->getCellByPosition(maStartX, maStartY)->getValue();
uno::Reference<table::XCellRange> xCellRangeH(xCellRange->getCellRangeByPosition(1, 0, 4, 0), UNO_QUERY_THROW);
uno::Reference<table::XCellRange> xCellRangeH(xCellRange->getCellRangeByPosition(maStartX, maStartY, maStartX + 2, maStartY), UNO_QUERY_THROW);
uno::Reference<sheet::XCellSeries> xCellSeriesH(xCellRangeH, UNO_QUERY_THROW);
xCellSeriesH->fillSeries(sheet::FillDirection_TO_RIGHT,
sheet::FillMode_LINEAR,
sheet::FillDateMode_FILL_DATE_DAY, 2, 8);
uno::Reference<table::XCell> xCellResultH(xCellRange->getCellByPosition(5, 0), UNO_QUERY_THROW);
xCellResultH->setFormula("=SUM(B1:E1)");
CPPUNIT_ASSERT_EQUAL_MESSAGE("Wrong result for fillSeries with TO_RIGHT and LINEAR", 20., xCellResultH->getValue());
sheet::FillDateMode_FILL_DATE_DAY, 2, 1000);
sal_Int32 sumH = 0;
for(sal_Int32 i = 0; i < 3; i++) {
uno::Reference<table::XCell> xCellResultH(xCellRange->getCellByPosition(maStartX + i, maStartY), UNO_QUERY_THROW);
sumH += xCellResultH->getValue();
}
CPPUNIT_ASSERT_EQUAL_MESSAGE("Wrong result for fillSeries with TO_RIGHT and LINEAR", maValue * 3 + 6, sumH);
xCellSeriesH->fillSeries(sheet::FillDirection_TO_RIGHT,
sheet::FillMode_GROWTH,
sheet::FillDateMode_FILL_DATE_DAY, 2, 16);
CPPUNIT_ASSERT_EQUAL_MESSAGE("Wrong result for fillSeries with TO_RIGHT and GROWTH", 30., xCellResultH->getValue());
sheet::FillDateMode_FILL_DATE_DAY, 2, 1000);
sumH = 0;
for(sal_Int32 i = 0; i < 3; i++) {
uno::Reference<table::XCell> xCellResultH(xCellRange->getCellByPosition(maStartX + i, maStartY), UNO_QUERY_THROW);
sumH += xCellResultH->getValue();
}
CPPUNIT_ASSERT_EQUAL_MESSAGE("Wrong result for fillSeries with TO_RIGHT and GROWTH", maValue + maValue * 2 + maValue * 4, sumH);
uno::Reference<table::XCellRange> xCellRangeV(xCellRange->getCellRangeByPosition(1, 0, 1, 3), UNO_QUERY_THROW);
uno::Reference<table::XCellRange> xCellRangeV(xCellRange->getCellRangeByPosition(maStartX, maStartY, maStartX, maStartY + 2), UNO_QUERY_THROW);
uno::Reference<sheet::XCellSeries> xCellSeriesV(xCellRangeV, UNO_QUERY_THROW);
xCellSeriesV->fillSeries(sheet::FillDirection_TO_BOTTOM,
sheet::FillMode_LINEAR,
sheet::FillDateMode_FILL_DATE_DAY, 2, 8);
uno::Reference<table::XCell> xCellResultV(xCellRange->getCellByPosition(1, 4), UNO_QUERY_THROW);
xCellResultV->setFormula("=SUM(B1:B4)");
CPPUNIT_ASSERT_EQUAL_MESSAGE("Wrong result for fillSeries with TO_BOTTOM and LINEAR", 20., xCellResultV->getValue());
sheet::FillDateMode_FILL_DATE_DAY, 2, 1000);
sal_Int32 sumV = 0;
for(sal_Int32 i = 0; i < 3; i++) {
uno::Reference<table::XCell> xCellResultV(xCellRange->getCellByPosition(maStartX, maStartY + i), UNO_QUERY_THROW);
sumV += xCellResultV->getValue();
}
CPPUNIT_ASSERT_EQUAL_MESSAGE("Wrong result for fillSeries with TO_BOTTOM and LINEAR", maValue * 3 + 6, sumV);
xCellSeriesV->fillSeries(sheet::FillDirection_TO_BOTTOM,
sheet::FillMode_GROWTH,
sheet::FillDateMode_FILL_DATE_DAY, 2, 16);
CPPUNIT_ASSERT_EQUAL_MESSAGE("Wrong result for fillSeries with TO_BOTTOM and GROWTH", 30., xCellResultV->getValue());
sheet::FillDateMode_FILL_DATE_DAY, 2, 1000);
sumV = 0;
for(sal_Int32 i = 0; i < 3; i++) {
uno::Reference<table::XCell> xCellResultV(xCellRange->getCellByPosition(maStartX, maStartY + i), UNO_QUERY_THROW);
sumV += xCellResultV->getValue();
}
CPPUNIT_ASSERT_EQUAL_MESSAGE("Wrong result for fillSeries with TO_BOTTOM and GROWTH", maValue + maValue * 2 + maValue * 4, sumV);
for(sal_Int32 i = 1; i < 3; i++) {
uno::Reference<table::XCell> xCellResultH(xCellRange->getCellByPosition(maStartX + i, maStartY), UNO_QUERY_THROW);
xCellResultH->setFormula("");
uno::Reference<table::XCell> xCellResultV(xCellRange->getCellByPosition(maStartX, maStartY + i), UNO_QUERY_THROW);
xCellResultV->setFormula("");
}
}
}
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */