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

tdf#45904 Move Java _XSheetCellRanges tests to C++

Change-Id: I6f6dcbc5368ce034c25553edf8b88c6669074243
Reviewed-on: https://gerrit.libreoffice.org/44194Tested-by: 's avatarJenkins <ci@libreoffice.org>
Reviewed-by: 's avatarJens Carl <j.carl43@gmx.de>
üst 44e96407
/* -*- 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_XSHEETCELLRANGES_HXX
#define INCLUDED_TEST_SHEET_XSHEETCELLRANGES_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 XSheetCellRanges
{
public:
virtual css::uno::Reference< css::uno::XInterface > init() =0;
void testGetCells();
void testGetRangeAddresses();
void testGetRangeAddressesAsString();
protected:
~XSheetCellRanges() {}
};
}
#endif // INCLUDED_TEST_SHEET_XSHEETCELLRANGES_HXX
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
......@@ -620,7 +620,6 @@ $(eval $(call gb_Jar_add_sourcefiles,OOoRunner,\
qadevOOo/tests/java/ifc/sheet/_XSheetCellCursor \
qadevOOo/tests/java/ifc/sheet/_XSheetCellRange \
qadevOOo/tests/java/ifc/sheet/_XSheetCellRangeContainer \
qadevOOo/tests/java/ifc/sheet/_XSheetCellRanges \
qadevOOo/tests/java/ifc/sheet/_XSheetFilterableEx \
qadevOOo/tests/java/ifc/sheet/_XSpreadsheetView \
qadevOOo/tests/java/ifc/style/_CharacterProperties \
......
......@@ -45,9 +45,6 @@
"ScCellRangesObj";"com::sun::star::style::CharacterPropertiesAsian";"ParaIsHangingPunctuation"
"ScCellRangesObj";"com::sun::star::container::XIndexAccess";"getCount()"
"ScCellRangesObj";"com::sun::star::container::XIndexAccess";"getByIndex()"
"ScCellRangesObj";"com::sun::star::sheet::XSheetCellRanges";"getCells()"
"ScCellRangesObj";"com::sun::star::sheet::XSheetCellRanges";"getRangeAddressesAsString()"
"ScCellRangesObj";"com::sun::star::sheet::XSheetCellRanges";"getRangeAddresses()"
"ScCellRangesObj";"com::sun::star::util::XReplaceable";"createReplaceDescriptor()"
"ScCellRangesObj";"com::sun::star::util::XReplaceable";"replaceAll()"
"ScCellRangesObj";"com::sun::star::chart::XChartData";"addChartDataChangeEventListener()"
......
/*
* 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 com.sun.star.container.XEnumeration;
import com.sun.star.sheet.XSheetCellRanges;
import com.sun.star.table.CellRangeAddress;
/**
* Testing <code>com.sun.star.sheet.XSheetCellRanges</code>
* interface methods :
* <ul>
* <li><code> getCells()</code></li>
* <li><code> getRangeAddressesAsString()</code></li>
* <li><code> getRangeAddresses()</code></li>
* </ul> <p>
* @see com.sun.star.sheet.XSheetCellRanges
*/
public class _XSheetCellRanges extends MultiMethodTest{
public XSheetCellRanges oObj = null;
/**
* Test calls the method, creates enumeration of returned value
* and checks that the enumeration has elements. <p>
* Has <b> OK </b> status if gained enumeration has elements. <p>
*/
public void _getCells() {
log.println("Testing getCells ...");
XEnumeration oEnum = oObj.getCells().createEnumeration();
boolean res = oEnum.hasMoreElements();
if (!res) {
log.println(
"The Enumeration gained via getCells() has no Elements");
}
tRes.tested("getCells()", res);
}
/**
* Test calls the method and checks length of returned array. <p>
* Has <b> OK </b> status if length of returned array is greater than 2.<p>
*/
public void _getRangeAddresses() {
log.println("Testing getRangeAddresses ...");
CellRangeAddress[] oRanges = oObj.getRangeAddresses();
int howmuch = oRanges.length;
tRes.tested("getRangeAddresses()", (howmuch > 2) );
}
/**
* Test calls the method and checks returned string. <p>
* Has <b> OK </b> status if returned string starts from 'Sheet'.<p>
*/
public void _getRangeAddressesAsString() {
log.println("Testing getRangeAddressesAsString ...");
String oRanges = oObj.getRangeAddressesAsString();
tRes.tested("getRangeAddressesAsString()",oRanges.indexOf("C1:D4")>0);
}
} // finished class _XSheetCellRanges
......@@ -9,6 +9,7 @@
#include <test/calc_unoapi_test.hxx>
#include <test/sheet/xsheetoperation.hxx>
#include <test/sheet/xsheetcellranges.hxx>
#include <com/sun/star/lang/XMultiServiceFactory.hpp>
#include <com/sun/star/container/XIndexAccess.hpp>
......@@ -25,9 +26,11 @@ using namespace css::uno;
namespace sc_apitest {
#define NUMBER_OF_TESTS 2
#define NUMBER_OF_TESTS 5
class ScCellRangesObj : public CalcUnoApiTest, public apitest::XSheetOperation
class ScCellRangesObj : public CalcUnoApiTest,
public apitest::XSheetCellRanges,
public apitest::XSheetOperation
{
public:
ScCellRangesObj();
......@@ -39,6 +42,11 @@ public:
CPPUNIT_TEST_SUITE(ScCellRangesObj);
// XSheetCellRanges
CPPUNIT_TEST(testGetCells);
CPPUNIT_TEST(testGetRangeAddresses);
CPPUNIT_TEST(testGetRangeAddressesAsString);
// XSheetOperation
CPPUNIT_TEST(testComputeFunction);
CPPUNIT_TEST(testClearContents);
......@@ -72,9 +80,7 @@ uno::Reference< uno::XInterface > ScCellRangesObj::init()
uno::Reference< lang::XMultiServiceFactory > xMSF(xDoc, uno::UNO_QUERY_THROW);
uno::Reference< container::XNameContainer > xRanges(xMSF->createInstance("com.sun.star.sheet.SheetCellRanges"), uno::UNO_QUERY_THROW);
//uno::Reference< container::XNameContainer > xRanges(xSheet, uno::UNO_QUERY_THROW);
uno::Any xCellRange;
xCellRange <<= xSheet->getCellRangeByName("C1:D4");
xRanges->insertByName("Range1", xCellRange);
xCellRange <<= xSheet->getCellRangeByName("E2:F5");
......@@ -84,6 +90,13 @@ uno::Reference< uno::XInterface > ScCellRangesObj::init()
xCellRange <<= xSheet->getCellRangeByName("I7:J8");
xRanges->insertByName("Range4", xCellRange);
for ( int i = 0; i < 10; i++ )
{
for ( int j = 5; j < 10; j++ )
{
xSheet->getCellByPosition(i, j)->setValue(i + j);
}
}
return xRanges;
}
......
......@@ -70,6 +70,7 @@ $(eval $(call gb_Library_add_exception_objects,subsequenttest,\
test/source/sheet/xsheetannotation \
test/source/sheet/xsheetannotations \
test/source/sheet/xsheetannotationshapesupplier \
test/source/sheet/xsheetcellranges \
test/source/sheet/xsheetconditionalentries \
test/source/sheet/xsheetconditionalentry \
test/source/sheet/xsheetcondition \
......
/* -*- 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/xsheetcellranges.hxx>
#include <com/sun/star/container/XEnumeration.hpp>
#include <com/sun/star/container/XEnumerationAccess.hpp>
#include <com/sun/star/sheet/XSheetCellRanges.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 com::sun::star;
using namespace com::sun::star::uno;
namespace apitest {
void XSheetCellRanges::testGetCells()
{
uno::Reference< sheet::XSheetCellRanges > xSheetCellRanges(init(), UNO_QUERY_THROW);
uno::Reference< container::XEnumerationAccess > xEA = xSheetCellRanges->getCells();
CPPUNIT_ASSERT_MESSAGE("Unable to get cells", xEA->hasElements());
}
void XSheetCellRanges::testGetRangeAddresses()
{
uno::Reference< sheet::XSheetCellRanges > xSheetCellRanges(init(), UNO_QUERY_THROW);
uno::Sequence< table::CellRangeAddress > aCellRangeAddress = xSheetCellRanges->getRangeAddresses();
CPPUNIT_ASSERT_MESSAGE("Unable to get RangeAddresses",
aCellRangeAddress.getLength() > 2);
}
void XSheetCellRanges::testGetRangeAddressesAsString()
{
uno::Reference< sheet::XSheetCellRanges > xSheetCellRanges(init(), UNO_QUERY_THROW);
CPPUNIT_ASSERT_MESSAGE("Unable to get RangeAddresses (string)",
xSheetCellRanges->getRangeAddressesAsString().indexOf("C1:D4") > 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