[Libreoffice-commits] core.git: include/test qadevOOo/Jar_OOoRunner.mk qadevOOo/objdsc qadevOOo/tests sc/qa test/Library_subsequenttest.mk test/source
Jens Carl
j.carl43 at gmx.de
Thu Nov 23 08:52:16 UTC 2017
include/test/sheet/xscenarioenhanced.hxx | 34 ++++
qadevOOo/Jar_OOoRunner.mk | 1
qadevOOo/objdsc/sc/com.sun.star.comp.office.ScTableSheetObj.csv | 1
qadevOOo/tests/java/ifc/sheet/_XScenarioEnhanced.java | 80 ----------
sc/qa/extras/sctablesheetobj.cxx | 40 ++++-
test/Library_subsequenttest.mk | 1
test/source/sheet/xscenarioenhanced.cxx | 39 ++++
7 files changed, 113 insertions(+), 83 deletions(-)
New commits:
commit a8681f24d786a5498844e29a3029cf9e60e74ca3
Author: Jens Carl <j.carl43 at gmx.de>
Date: Thu Nov 23 07:24:25 2017 +0000
tdf#45904 Move _XScenarioEnhanced Java test to C++
Change-Id: Ibc99dc0d50e612bc6cdebaf5f9c5f828e5af859f
Reviewed-on: https://gerrit.libreoffice.org/45123
Tested-by: Jenkins <ci at libreoffice.org>
Reviewed-by: Jens Carl <j.carl43 at gmx.de>
diff --git a/include/test/sheet/xscenarioenhanced.hxx b/include/test/sheet/xscenarioenhanced.hxx
new file mode 100644
index 000000000000..ff5261f31d50
--- /dev/null
+++ b/include/test/sheet/xscenarioenhanced.hxx
@@ -0,0 +1,34 @@
+/* -*- 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/.
+ */
+
+#ifndef INCLUDED_TEST_SHEET_XSCENARIOENHANCED_HXX
+#define INCLUDED_TEST_SHEET_XSCENARIOENHANCED_HXX
+
+#include <com/sun/star/uno/XInterface.hpp>
+#include <com/sun/star/uno/Reference.hxx>
+
+#include <test/testdllapi.hxx>
+
+namespace apitest
+{
+class OOO_DLLPUBLIC_TEST XScenarioEnhanced
+{
+public:
+ virtual css::uno::Reference<css::uno::XInterface> getScenarioSpreadsheet() = 0;
+
+ void testGetRanges();
+
+protected:
+ ~XScenarioEnhanced() {}
+};
+}
+
+#endif // INCLUDED_TEST_SHEET_XSCENARIOENHANCED_HXX
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab cinoptions=b1,g0,N-s cinkeys+=0=break: */
diff --git a/qadevOOo/Jar_OOoRunner.mk b/qadevOOo/Jar_OOoRunner.mk
index f8d6b4a5ecd8..4ee5633c5650 100644
--- a/qadevOOo/Jar_OOoRunner.mk
+++ b/qadevOOo/Jar_OOoRunner.mk
@@ -609,7 +609,6 @@ $(eval $(call gb_Jar_add_sourcefiles,OOoRunner,\
qadevOOo/tests/java/ifc/sheet/_XRangeSelection \
qadevOOo/tests/java/ifc/sheet/_XRecentFunctions \
qadevOOo/tests/java/ifc/sheet/_XScenario \
- qadevOOo/tests/java/ifc/sheet/_XScenarioEnhanced \
qadevOOo/tests/java/ifc/sheet/_XSheetAnnotationAnchor \
qadevOOo/tests/java/ifc/sheet/_XSheetCellCursor \
qadevOOo/tests/java/ifc/style/_CharacterProperties \
diff --git a/qadevOOo/objdsc/sc/com.sun.star.comp.office.ScTableSheetObj.csv b/qadevOOo/objdsc/sc/com.sun.star.comp.office.ScTableSheetObj.csv
index 6f434c9b484c..4438b3b4d7c9 100644
--- a/qadevOOo/objdsc/sc/com.sun.star.comp.office.ScTableSheetObj.csv
+++ b/qadevOOo/objdsc/sc/com.sun.star.comp.office.ScTableSheetObj.csv
@@ -226,7 +226,6 @@
"ScTableSheetObj";"com::sun::star::beans::XPropertySet";"removeVetoableChangeListener()"
"ScTableSheetObj";"com::sun::star::sheet::XCellRangeData";"getDataArray()"
"ScTableSheetObj";"com::sun::star::sheet::XCellRangeData";"setDataArray()"
-"ScTableSheetObj";"com::sun::star::sheet::XScenarioEnhanced#optional";"getRanges()"
"ScTableSheetObj";"com::sun::star::chart::XChartDataArray";"getData()"
"ScTableSheetObj";"com::sun::star::chart::XChartDataArray";"setData()"
"ScTableSheetObj";"com::sun::star::chart::XChartDataArray";"getRowDescriptions()"
diff --git a/qadevOOo/tests/java/ifc/sheet/_XScenarioEnhanced.java b/qadevOOo/tests/java/ifc/sheet/_XScenarioEnhanced.java
deleted file mode 100644
index e573ea45f63d..000000000000
--- a/qadevOOo/tests/java/ifc/sheet/_XScenarioEnhanced.java
+++ /dev/null
@@ -1,80 +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 com.sun.star.sheet.XScenarioEnhanced;
-import com.sun.star.table.CellRangeAddress;
-import com.sun.star.uno.UnoRuntime;
-
-import lib.MultiMethodTest;
-
-public class _XScenarioEnhanced extends MultiMethodTest {
- public XScenarioEnhanced oObj = null;
-
- @Override
- public void before() {
- oObj = UnoRuntime.queryInterface(
- XScenarioEnhanced.class,
- tEnv.getObjRelation("ScenarioSheet"));
- }
-
- public void _getRanges() {
- boolean res = true;
- CellRangeAddress[] getting = oObj.getRanges();
- System.out.println("Count " + getting.length);
-
- CellRangeAddress first = getting[0];
-
- if (first.Sheet != 1) {
- log.println(
- "wrong RangeAddress is returned, expected Sheet=0 and got " +
- first.Sheet);
- res = false;
- }
-
- if (first.StartColumn != 0) {
- log.println(
- "wrong RangeAddress is returned, expected StartColumn=0 and got " +
- first.StartColumn);
- res = false;
- }
-
- if (first.EndColumn != 10) {
- log.println(
- "wrong RangeAddress is returned, expected EndColumn=10 and got " +
- first.EndColumn);
- res = false;
- }
-
- if (first.StartRow != 0) {
- log.println(
- "wrong RangeAddress is returned, expected StartRow=0 and got " +
- first.StartRow);
- res = false;
- }
-
- if (first.EndRow != 10) {
- log.println(
- "wrong RangeAddress is returned, expected EndRow=10 and got " +
- first.EndRow);
- res = false;
- }
-
- tRes.tested("getRanges()", res);
- }
-}
diff --git a/sc/qa/extras/sctablesheetobj.cxx b/sc/qa/extras/sctablesheetobj.cxx
index 27fb9a297fb4..b06765b539c8 100644
--- a/sc/qa/extras/sctablesheetobj.cxx
+++ b/sc/qa/extras/sctablesheetobj.cxx
@@ -10,6 +10,7 @@
#include <test/calc_unoapi_test.hxx>
#include <test/sheet/xcellseries.hxx>
#include <test/sheet/xprintareas.hxx>
+#include <test/sheet/xscenarioenhanced.hxx>
#include <test/sheet/xscenariossupplier.hxx>
#include <test/sheet/xsheetannotationssupplier.hxx>
#include <test/sheet/xsheetauditing.hxx>
@@ -25,8 +26,10 @@
#include <test/util/xreplaceable.hxx>
#include <test/util/xsearchable.hxx>
+#include <com/sun/star/sheet/XScenariosSupplier.hpp>
#include <com/sun/star/sheet/XSpreadsheetDocument.hpp>
#include <com/sun/star/sheet/XSpreadsheet.hpp>
+#include <com/sun/star/table/CellRangeAddress.hpp>
using namespace css;
using namespace css::uno;
@@ -34,11 +37,12 @@ using namespace css::uno;
namespace sc_apitest
{
-#define NUMBER_OF_TESTS 30
+#define NUMBER_OF_TESTS 31
class ScTableSheetObj : public CalcUnoApiTest, public apitest::XCellSeries,
public apitest::XPrintAreas,
public apitest::XReplaceable,
+ public apitest::XScenarioEnhanced,
public apitest::XScenariosSupplier,
public apitest::XSearchable,
public apitest::XSheetAnnotationsSupplier,
@@ -63,6 +67,7 @@ public:
virtual uno::Reference< uno::XInterface > init() override;
virtual uno::Reference< uno::XInterface > getXSpreadsheet() override;
+ virtual uno::Reference< uno::XInterface > getScenarioSpreadsheet() override;
CPPUNIT_TEST_SUITE(ScTableSheetObj);
@@ -78,6 +83,9 @@ public:
CPPUNIT_TEST(testReplaceAll);
CPPUNIT_TEST(testCreateReplaceDescriptor);
+ // XScenarioEnhanced
+ CPPUNIT_TEST(testGetRanges);
+
// XScenariosSupplier
CPPUNIT_TEST(testGetScenarios);
@@ -158,6 +166,7 @@ uno::Reference< uno::XInterface > ScTableSheetObj::init()
CPPUNIT_ASSERT_MESSAGE("no calc document", mxComponent.is());
uno::Reference< sheet::XSpreadsheetDocument > xDoc(mxComponent, UNO_QUERY_THROW);
+ uno::Reference<sheet::XSpreadsheets> xSheets(xDoc->getSheets(), UNO_QUERY_THROW);
uno::Reference< container::XIndexAccess > xIndex (xDoc->getSheets(), UNO_QUERY_THROW);
uno::Reference< sheet::XSpreadsheet > xSheet( xIndex->getByIndex(0), UNO_QUERY_THROW);
@@ -166,9 +175,38 @@ uno::Reference< uno::XInterface > ScTableSheetObj::init()
xSheet->getCellByPosition(8, 6)->setFormula("= SUM(G7:H7)");
xSheet->getCellByPosition(9, 6)->setFormula("= G7*I7");
+ uno::Sequence<table::CellRangeAddress> aCellRangeAddr(1);
+ aCellRangeAddr[0] = table::CellRangeAddress(0, 0, 0, 10, 10);
+ uno::Reference<sheet::XScenariosSupplier> xScence(xSheet, UNO_QUERY_THROW);
+ xScence->getScenarios()->addNewByName("Scenario", aCellRangeAddr, "Comment");
+ xSheets->getByName("Scenario");
+
return xSheet;
}
+uno::Reference<uno::XInterface> ScTableSheetObj::getScenarioSpreadsheet()
+{
+ createFileURL("ScTableSheetObj.ods", maFileURL);
+ if (!mxComponent.is())
+ mxComponent = loadFromDesktop(maFileURL, "com.sun.star.sheet.SpreadsheetDocument");
+ CPPUNIT_ASSERT_MESSAGE("no calc document", mxComponent.is());
+
+ uno::Reference<sheet::XSpreadsheetDocument> xDoc(mxComponent, UNO_QUERY_THROW);
+ uno::Reference<sheet::XSpreadsheets> xSheets(xDoc->getSheets(), 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::Sequence<table::CellRangeAddress> aCellRangeAddr(1);
+ aCellRangeAddr[0] = table::CellRangeAddress(0, 0, 0, 10, 10);
+
+ uno::Reference<sheet::XScenariosSupplier> xScence(xSheet, UNO_QUERY_THROW);
+ xScence->getScenarios()->addNewByName("Scenario", aCellRangeAddr, "Comment");
+ uno::Reference<sheet::XSpreadsheet> sSheet(xSheets->getByName("Scenario"), UNO_QUERY_THROW);
+
+ return sSheet;
+}
+
uno::Reference< uno::XInterface > ScTableSheetObj::getXSpreadsheet()
{
createFileURL("ScTableSheetObj.ods", maFileURL);
diff --git a/test/Library_subsequenttest.mk b/test/Library_subsequenttest.mk
index b9a033d73326..a2bee04955d0 100644
--- a/test/Library_subsequenttest.mk
+++ b/test/Library_subsequenttest.mk
@@ -65,6 +65,7 @@ $(eval $(call gb_Library_add_exception_objects,subsequenttest,\
test/source/sheet/xnamedrange \
test/source/sheet/xnamedranges \
test/source/sheet/xprintareas \
+ test/source/sheet/xscenarioenhanced \
test/source/sheet/xscenarios \
test/source/sheet/xscenariossupplier \
test/source/sheet/xspreadsheetdocument \
diff --git a/test/source/sheet/xscenarioenhanced.cxx b/test/source/sheet/xscenarioenhanced.cxx
new file mode 100644
index 000000000000..6f8b80cbe40c
--- /dev/null
+++ b/test/source/sheet/xscenarioenhanced.cxx
@@ -0,0 +1,39 @@
+/* -*- 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/sheet/xscenarioenhanced.hxx>
+#include <test/cppunitasserthelper.hxx>
+
+#include <com/sun/star/sheet/XScenarios.hpp>
+#include <com/sun/star/sheet/XScenarioEnhanced.hpp>
+#include <com/sun/star/table/CellRangeAddress.hpp>
+
+#include <com/sun/star/uno/Reference.hxx>
+#include <com/sun/star/uno/Sequence.hxx>
+
+#include <cppunit/extensions/HelperMacros.h>
+
+using namespace css;
+using namespace css::uno;
+
+namespace apitest
+{
+void XScenarioEnhanced::testGetRanges()
+{
+ uno::Reference<sheet::XScenarioEnhanced> xSE(getScenarioSpreadsheet(), UNO_QUERY_THROW);
+
+ uno::Sequence<table::CellRangeAddress> aCellRangeAddr = xSE->getRanges();
+ CPPUNIT_ASSERT_MESSAGE("No ranges found", aCellRangeAddr.getLength() != 0);
+
+ CPPUNIT_ASSERT_EQUAL_MESSAGE("Wrong CellRangeAddres", table::CellRangeAddress(1, 0, 0, 10, 10),
+ aCellRangeAddr[0]);
+}
+}
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab cinoptions=b1,g0,N-s cinkeys+=0=break: */
More information about the Libreoffice-commits
mailing list