[Libreoffice-commits] core.git: include/test qadevOOo/Jar_OOoRunner.mk qadevOOo/tests sc/qa test/Library_subsequenttest.mk test/source
Paul Trojahn
paul.trojahn at gmail.com
Thu Jun 8 00:46:15 UTC 2017
include/test/sheet/xcellseries.hxx | 30 +++
qadevOOo/Jar_OOoRunner.mk | 1
qadevOOo/tests/java/ifc/sheet/_XCellSeries.java | 237 ------------------------
sc/qa/extras/sctablesheetobj.cxx | 6
sc/qa/extras/testdocuments/ScTableSheetObj.ods |binary
test/Library_subsequenttest.mk | 1
test/source/sheet/xcellseries.cxx | 74 +++++++
7 files changed, 110 insertions(+), 239 deletions(-)
New commits:
commit f1454b474d9248d7ef2cb84f396a974184e5167e
Author: Paul Trojahn <paul.trojahn at gmail.com>
Date: Sat May 27 22:38:15 2017 +0200
tdf#45904 Move java XCellSeries test to c++
Change-Id: Iedc1023b67138727061c2da13bebdb75af370ec6
Reviewed-on: https://gerrit.libreoffice.org/38105
Tested-by: Jenkins <ci at libreoffice.org>
Reviewed-by: Markus Mohrhard <markus.mohrhard at googlemail.com>
diff --git a/include/test/sheet/xcellseries.hxx b/include/test/sheet/xcellseries.hxx
new file mode 100644
index 000000000000..79fc4c7ea43d
--- /dev/null
+++ b/include/test/sheet/xcellseries.hxx
@@ -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
diff --git a/qadevOOo/Jar_OOoRunner.mk b/qadevOOo/Jar_OOoRunner.mk
index 869d17a9a1d5..da5822fcd1bd 100644
--- a/qadevOOo/Jar_OOoRunner.mk
+++ b/qadevOOo/Jar_OOoRunner.mk
@@ -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 \
diff --git a/qadevOOo/tests/java/ifc/sheet/_XCellSeries.java b/qadevOOo/tests/java/ifc/sheet/_XCellSeries.java
deleted file mode 100644
index 72e078e9c0cb..000000000000
--- a/qadevOOo/tests/java/ifc/sheet/_XCellSeries.java
+++ /dev/null
@@ -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();
- }
-}
\ No newline at end of file
diff --git a/sc/qa/extras/sctablesheetobj.cxx b/sc/qa/extras/sctablesheetobj.cxx
index f154240d7ee6..d5bcde236bf5 100644
--- a/sc/qa/extras/sctablesheetobj.cxx
+++ b/sc/qa/extras/sctablesheetobj.cxx
@@ -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:
diff --git a/sc/qa/extras/testdocuments/ScTableSheetObj.ods b/sc/qa/extras/testdocuments/ScTableSheetObj.ods
index 86d027c437f8..a18b1e7d5a2e 100644
Binary files a/sc/qa/extras/testdocuments/ScTableSheetObj.ods and b/sc/qa/extras/testdocuments/ScTableSheetObj.ods differ
diff --git a/test/Library_subsequenttest.mk b/test/Library_subsequenttest.mk
index 7ef8ca836e87..e5ab18b166f2 100644
--- a/test/Library_subsequenttest.mk
+++ b/test/Library_subsequenttest.mk
@@ -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 \
diff --git a/test/source/sheet/xcellseries.cxx b/test/source/sheet/xcellseries.cxx
new file mode 100644
index 000000000000..a1ccd87c3235
--- /dev/null
+++ b/test/source/sheet/xcellseries.cxx
@@ -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());
+}
+
+}
More information about the Libreoffice-commits
mailing list