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

tdf#45904 Move _XScenarioEnhanced Java test to C++

Change-Id: Ibc99dc0d50e612bc6cdebaf5f9c5f828e5af859f
Reviewed-on: https://gerrit.libreoffice.org/45123Tested-by: 's avatarJenkins <ci@libreoffice.org>
Reviewed-by: 's avatarJens Carl <j.carl43@gmx.de>
üst d3c607b4
/* -*- 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: */
......@@ -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 \
......
......@@ -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()"
......
/*
* 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);
}
}
......@@ -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);
......
......@@ -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 \
......
/* -*- 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: */
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