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

tdf#45904 Move _XScenarios Java test to C++

Change-Id: Ie15243714464cf8343fff27507e4b257846cdebd
Reviewed-on: https://gerrit.libreoffice.org/44638Tested-by: 's avatarJenkins <ci@libreoffice.org>
Reviewed-by: 's avatarJens Carl <j.carl43@gmx.de>
üst b73c6659
/* -*- 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_XSCENARIOS_HXX
#define INCLUDED_TEST_SHEET_XSCENARIOS_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 XScenarios
{
public:
virtual css::uno::Reference<css::uno::XInterface> init() = 0;
void testAddNewByName();
void testRemoveByName();
protected:
~XScenarios() {}
};
}
#endif // INCLUDED_TEST_SHEET_XSCENARIOS_HXX
/* vim:set shiftwidth=4 softtabstop=4 expandtab cinoptions=b1,g0,N-s cinkeys+=0=break: */
......@@ -612,7 +612,6 @@ $(eval $(call gb_Jar_add_sourcefiles,OOoRunner,\
qadevOOo/tests/java/ifc/sheet/_XRecentFunctions \
qadevOOo/tests/java/ifc/sheet/_XScenario \
qadevOOo/tests/java/ifc/sheet/_XScenarioEnhanced \
qadevOOo/tests/java/ifc/sheet/_XScenarios \
qadevOOo/tests/java/ifc/sheet/_XScenariosSupplier \
qadevOOo/tests/java/ifc/sheet/_XSheetAnnotationAnchor \
qadevOOo/tests/java/ifc/sheet/_XSheetAnnotationsSupplier \
......
......@@ -3,8 +3,6 @@
"ScScenariosObj";"com::sun::star::container::XNameAccess";"hasByName()"
"ScScenariosObj";"com::sun::star::container::XIndexAccess";"getCount()"
"ScScenariosObj";"com::sun::star::container::XIndexAccess";"getByIndex()"
"ScScenariosObj";"com::sun::star::sheet::XScenarios";"addNewByName()"
"ScScenariosObj";"com::sun::star::sheet::XScenarios";"removeByName()"
"ScScenariosObj";"com::sun::star::container::XElementAccess";"getElementType()"
"ScScenariosObj";"com::sun::star::container::XElementAccess";"hasElements()"
"ScScenariosObj";"com::sun::star::container::XEnumerationAccess";"createEnumeration()"
/*
* 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 lib.MultiMethodTest;
import lib.Status;
import lib.StatusException;
import com.sun.star.sheet.XScenarios;
import com.sun.star.table.CellRangeAddress;
/**
* Testing <code>com.sun.star.sheet.XScenarios</code>
* interface methods :
* <ul>
* <li><code> addNewByName()</code></li>
* <li><code> removeByName()</code></li>
* </ul> <p>
* This test needs the following object relations :
* <ul>
* <li> <code>'ADDR'</code> (of type <code>CellRangeAddress[]</code>):
* the array of cell range addresses for adding new scenario </li>
* <ul> <p>
* @see com.sun.star.sheet.XScenarios
*/
public class _XScenarios extends MultiMethodTest {
public XScenarios oObj = null;
/**
* Test adds new scenario, stores name of this scenario and checks that
* scenario with this name is present in collection. <p>
* Has <b> OK </b> status if the new scenario is present in collection. <p>
*/
public void _addNewByName() {
CellRangeAddress[] oAddr = (CellRangeAddress[])
tEnv.getObjRelation("ADDR");
if (oAddr == null) throw new StatusException(Status.failed
("Relation 'ADDR' not found"));
oObj.addNewByName("XScenarios", oAddr, "new");
tRes.tested("addNewByName()",oObj.hasByName("XScenarios"));
}
/**
* Test removes the scenario with stored name and checks that scenario
* with this name isn't present in collection. <p>
* Has <b> OK </b> status if the scenario with stored name isn't present in
* collection after it was removed. <p>
* The following method tests are to be completed successfully before :
* <ul>
* <li> <code> addNewByName() </code> : to have name of the scenario </li>
* </ul>
*/
public void _removeByName() {
requiredMethod("addNewByName()");
oObj.removeByName("XScenarios");
tRes.tested("removeByName()",!oObj.hasByName("XScenarios"));
}
} // EOC _XScenarios
# -*- 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_scenariosobj))
$(eval $(call gb_CppunitTest_use_external,sc_scenariosobj,boost_headers))
$(eval $(call gb_CppunitTest_add_exception_objects,sc_scenariosobj, \
sc/qa/extras/scscenariosobj \
))
$(eval $(call gb_CppunitTest_use_libraries,sc_scenariosobj, \
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_scenariosobj,\
-I$(SRCDIR)/sc/source/ui/inc \
-I$(SRCDIR)/sc/inc \
$$(INCLUDE) \
))
$(eval $(call gb_CppunitTest_use_sdk_api,sc_scenariosobj))
$(eval $(call gb_CppunitTest_use_ure,sc_scenariosobj))
$(eval $(call gb_CppunitTest_use_vcl,sc_scenariosobj))
$(eval $(call gb_CppunitTest_use_components,sc_scenariosobj,\
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_scenariosobj))
# vim: set noet sw=4 ts=4:
......@@ -136,6 +136,7 @@ $(eval $(call gb_Module_add_subsequentcheck_targets,sc,\
CppunitTest_sc_tablevalidationobj \
CppunitTest_sc_tableconditionalentryobj \
CppunitTest_sc_tableconditionalformatobj \
CppunitTest_sc_scenariosobj \
))
$(eval $(call gb_Module_add_perfcheck_targets,sc,\
......
/* -*- 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/calc_unoapi_test.hxx>
#include <test/sheet/xscenarios.hxx>
#include <com/sun/star/container/XIndexAccess.hpp>
#include <com/sun/star/lang/XComponent.hpp>
#include <com/sun/star/sheet/XCellRangeAddressable.hpp>
#include <com/sun/star/sheet/XScenariosSupplier.hpp>
#include <com/sun/star/sheet/XSpreadsheetDocument.hpp>
#include <com/sun/star/sheet/XSpreadsheets.hpp>
#include <com/sun/star/sheet/XSpreadsheet.hpp>
#include <com/sun/star/table/XCellRange.hpp>
#include <com/sun/star/table/CellRangeAddress.hpp>
#include <unonames.hxx>
#include <com/sun/star/uno/Reference.hxx>
#include <com/sun/star/uno/Sequence.hxx>
#include <com/sun/star/uno/XInterface.hpp>
using namespace css;
using namespace css::uno;
using namespace com::sun::star;
namespace sc_apitest
{
#define NUMBER_OF_TESTS 2
class ScScenariosObj : public CalcUnoApiTest, public apitest::XScenarios
{
public:
ScScenariosObj();
virtual uno::Reference<uno::XInterface> init() override;
virtual void setUp() override;
virtual void tearDown() override;
CPPUNIT_TEST_SUITE(ScScenariosObj);
// XScenarios
CPPUNIT_TEST(testAddNewByName);
CPPUNIT_TEST(testRemoveByName);
CPPUNIT_TEST_SUITE_END();
private:
static sal_Int32 nTest;
static uno::Reference<lang::XComponent> mxComponent;
};
sal_Int32 ScScenariosObj::nTest = 0;
uno::Reference<lang::XComponent> ScScenariosObj::mxComponent;
ScScenariosObj::ScScenariosObj()
: CalcUnoApiTest("/sc/qa/extras/testdocuments")
{
}
uno::Reference<uno::XInterface> ScScenariosObj::init()
{
// create a calc document
if (!mxComponent.is())
mxComponent = loadFromDesktop("private:factory/scalc");
uno::Reference<sheet::XSpreadsheetDocument> xDoc(mxComponent, uno::UNO_QUERY_THROW);
CPPUNIT_ASSERT_MESSAGE("no calc document", xDoc.is());
uno::Reference<container::XIndexAccess> xIndex(xDoc->getSheets(), uno::UNO_QUERY_THROW);
uno::Reference<sheet::XSpreadsheet> xSheet(xIndex->getByIndex(0), uno::UNO_QUERY_THROW);
xSheet->getCellByPosition(5, 5)->setValue(15);
xSheet->getCellByPosition(1, 4)->setValue(10);
xSheet->getCellByPosition(2, 0)->setValue(-5.15);
uno::Reference<table::XCellRange> xCellRange(xSheet, uno::UNO_QUERY_THROW);
uno::Reference<table::XCellRange> xCellRange2 = xCellRange->getCellRangeByName("A1:N4");
uno::Reference<sheet::XCellRangeAddressable> xCRAddressable(xCellRange2, uno::UNO_QUERY_THROW);
table::CellRangeAddress aCellRangeAddr = xCRAddressable->getRangeAddress();
uno::Sequence<table::CellRangeAddress> aCellRangeAddresses(1);
aCellRangeAddresses[0] = aCellRangeAddr;
uno::Reference<sheet::XScenariosSupplier> xSupplier(xSheet, uno::UNO_QUERY_THROW);
xSupplier->getScenarios()->addNewByName("ScScenarios", aCellRangeAddresses, "Range");
return xSupplier->getScenarios();
}
void ScScenariosObj::setUp()
{
nTest++;
CPPUNIT_ASSERT(nTest <= NUMBER_OF_TESTS);
CalcUnoApiTest::setUp();
}
void ScScenariosObj::tearDown()
{
if (nTest == NUMBER_OF_TESTS)
{
closeDocument(mxComponent);
mxComponent.clear();
}
CalcUnoApiTest::tearDown();
}
CPPUNIT_TEST_SUITE_REGISTRATION(ScScenariosObj);
} // end namespace
CPPUNIT_PLUGIN_IMPLEMENT();
/* vim:set shiftwidth=4 softtabstop=4 expandtab cinoptions=b1,g0,N-s cinkeys+=0=break: */
......@@ -63,6 +63,7 @@ $(eval $(call gb_Library_add_exception_objects,subsequenttest,\
test/source/sheet/xnamedrange \
test/source/sheet/xnamedranges \
test/source/sheet/xprintareas \
test/source/sheet/xscenarios \
test/source/sheet/xspreadsheetdocument \
test/source/sheet/xspreadsheet \
test/source/sheet/xspreadsheets \
......
/* -*- 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/xscenarios.hxx>
#include <com/sun/star/sheet/XScenarios.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 XScenarios::testAddNewByName()
{
uno::Reference<sheet::XScenarios> xScenarios(init(), UNO_QUERY_THROW);
uno::Sequence<table::CellRangeAddress> aCellRangeAddresses(1);
aCellRangeAddresses[0] = table::CellRangeAddress(0, 0, 0, 0, 0);
xScenarios->addNewByName("XScenarios2", aCellRangeAddresses, "new");
CPPUNIT_ASSERT_MESSAGE("Unable to add new XScenario", xScenarios->hasByName("XScenarios2"));
}
void XScenarios::testRemoveByName()
{
uno::Reference<sheet::XScenarios> xScenarios(init(), UNO_QUERY_THROW);
xScenarios->removeByName("XScenarios");
CPPUNIT_ASSERT_MESSAGE("Unable to remove XScenario", !xScenarios->hasByName("XScenario"));
}
}
/* 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