tdf#45904 Move java XCellSeries test to c++

Change-Id: Iedc1023b67138727061c2da13bebdb75af370ec6
Reviewed-on: https://gerrit.libreoffice.org/38105
Tested-by: Jenkins <ci@libreoffice.org>
Reviewed-by: Markus Mohrhard <markus.mohrhard@googlemail.com>
This commit is contained in:
Paul Trojahn
2017-05-27 22:38:15 +02:00
committed by Markus Mohrhard
parent a87b001abd
commit f1454b474d
7 changed files with 110 additions and 239 deletions

View File

@@ -0,0 +1,30 @@
/* -*- 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_XCELLSERIES_HXX
#define INCLUDED_TEST_SHEET_XCELLSERIES_HXX
#include <com/sun/star/uno/XInterface.hpp>
#include <test/testdllapi.hxx>
namespace apitest {
class OOO_DLLPUBLIC_TEST XCellSeries
{
public:
virtual css::uno::Reference< css::uno::XInterface > init() = 0;
virtual ~XCellSeries(){}
void testFillAuto();
void testFillSeries();
};
}
#endif // INCLUDED_TEST_SHEET_XCELLSERIES_HXX

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

@@ -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

@@ -11,6 +11,7 @@
#include <test/util/xreplaceable.hxx>
#include <test/util/xsearchable.hxx>
#include <test/sheet/xprintareas.hxx>
#include <test/sheet/xcellseries.hxx>
#include <com/sun/star/sheet/XSpreadsheetDocument.hpp>
#include <com/sun/star/sheet/XSpreadsheet.hpp>
@@ -21,7 +22,7 @@ using namespace css::uno;
namespace sc_apitest
{
class ScTableSheetObj : public CalcUnoApiTest, public apitest::XSearchable, public apitest::XReplaceable, public apitest::XPrintAreas
class ScTableSheetObj : public CalcUnoApiTest, public apitest::XSearchable, public apitest::XReplaceable, public apitest::XPrintAreas, public apitest::XCellSeries
{
public:
ScTableSheetObj();
@@ -39,6 +40,9 @@ public:
// XPrintAreas
CPPUNIT_TEST(testSetAndGetPrintTitleColumns);
CPPUNIT_TEST(testSetAndGetPrintTitleRows);
// XCellSeries
CPPUNIT_TEST(testFillAuto);
CPPUNIT_TEST(testFillSeries);
CPPUNIT_TEST_SUITE_END();
private:

View File

@@ -47,6 +47,7 @@ $(eval $(call gb_Library_add_exception_objects,subsequenttest,\
test/source/sheet/xcellrangedata \
test/source/sheet/xcellrangereferrer \
test/source/sheet/xcellrangesquery \
test/source/sheet/xcellseries \
test/source/sheet/xgoalseek \
test/source/sheet/xdatabaserange \
test/source/sheet/xdatapilotdescriptor \

View File

@@ -0,0 +1,74 @@
/* -*- 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/sheet/xcellseries.hxx>
#include <com/sun/star/sheet/XCellSeries.hpp>
#include <com/sun/star/table/XCellRange.hpp>
#include "cppunit/extensions/HelperMacros.h"
using namespace com::sun::star;
using namespace com::sun::star::uno;
namespace apitest {
void XCellSeries::testFillAuto()
{
uno::Reference<table::XCellRange> xCellRange(init(), UNO_QUERY_THROW);
uno::Reference<table::XCellRange> xCellRangeH(xCellRange->getCellRangeByPosition(1, 0, 4, 0), 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());
uno::Reference<table::XCellRange> xCellRangeV(xCellRange->getCellRangeByPosition(1, 0, 1, 3), 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());
}
void XCellSeries::testFillSeries()
{
uno::Reference<table::XCellRange> xCellRange(init(), UNO_QUERY_THROW);
uno::Reference<table::XCellRange> xCellRangeH(xCellRange->getCellRangeByPosition(1, 0, 4, 0), 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());
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());
uno::Reference<table::XCellRange> xCellRangeV(xCellRange->getCellRangeByPosition(1, 0, 1, 3), 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());
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());
}
}