Kaydet (Commit) 27cbca2c authored tarafından Jens Carl's avatar Jens Carl Kaydeden (comit) Markus Mohrhard

tdf#45904 Move Java _XUsedAreaCursor tests to C++

Change-Id: I6a288fa333d6805540156f63040468f07967c0c6
Reviewed-on: https://gerrit.libreoffice.org/40817Tested-by: 's avatarJenkins <ci@libreoffice.org>
Reviewed-by: 's avatarMarkus Mohrhard <markus.mohrhard@googlemail.com>
üst 0bd57d62
/* -*- 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_XUSEDAREACURSOR_HXX
#define INCLUDED_TEST_SHEET_XUSEDAREACURSOR_HXX
#include <com/sun/star/uno/XInterface.hpp>
#include <com/sun/star/uno/Reference.hxx>
#include <test/testdllapi.hxx>
using namespace css;
using namespace css::uno;
namespace apitest {
class OOO_DLLPUBLIC_TEST XUsedAreaCursor
{
public:
virtual uno::Reference< uno::XInterface > init() = 0;
virtual ~XUsedAreaCursor(){}
void testGotoStartOfUsedArea();
void testGotoEndOfUsedArea();
};
}
#endif // INCLUDED_TEST_SHEET_XUSEDAREACURSOR_HXX
/* vim:set shiftwidth=4 softtabstop=4 expandtab cinoptions=b1,g0,N-s cinkeys+=0=break: */
......@@ -651,7 +651,6 @@ $(eval $(call gb_Jar_add_sourcefiles,OOoRunner,\
qadevOOo/tests/java/ifc/sheet/_XSubTotalDescriptor \
qadevOOo/tests/java/ifc/sheet/_XSubTotalField \
qadevOOo/tests/java/ifc/sheet/_XUniqueCellFormatRangesSupplier \
qadevOOo/tests/java/ifc/sheet/_XUsedAreaCursor \
qadevOOo/tests/java/ifc/sheet/_XViewFreezable \
qadevOOo/tests/java/ifc/style/_CharacterProperties \
qadevOOo/tests/java/ifc/style/_CharacterPropertiesAsian \
......
......@@ -55,8 +55,6 @@
"ScCellCursorObj";"com::sun::star::chart::XChartData";"removeChartDataChangeEventListener()"
"ScCellCursorObj";"com::sun::star::chart::XChartData";"getNotANumber()"
"ScCellCursorObj";"com::sun::star::chart::XChartData";"isNotANumber()"
"ScCellCursorObj";"com::sun::star::sheet::XUsedAreaCursor";"gotoStartOfUsedArea()"
"ScCellCursorObj";"com::sun::star::sheet::XUsedAreaCursor";"gotoEndOfUsedArea()"
"ScCellCursorObj";"com::sun::star::style::ParagraphProperties";"ParaAdjust"
"ScCellCursorObj";"com::sun::star::style::ParagraphProperties";"ParaLineSpacing#optional"
"ScCellCursorObj";"com::sun::star::style::ParagraphProperties";"ParaBackColor#optional"
......
/*
* 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.sheet.XCellRangeAddressable;
import com.sun.star.sheet.XUsedAreaCursor;
import com.sun.star.table.CellRangeAddress;
import com.sun.star.uno.UnoRuntime;
/**
* Testing <code>com.sun.star.sheet.XUsedAreaCursor</code>
* interface methods :
* <ul>
* <li><code> gotoStartOfUsedArea()</code></li>
* <li><code> gotoEndOfUsedArea()</code></li>
* </ul> <p>
* Component must also implement the following interfaces :
* <ul>
* <li> <code> com.sun.star.XCellRangeAddressable </code> : to check the current
* position of the cursor </li>
* <ul> <p>
* @see com.sun.star.sheet.XUsedAreaCursor
*/
public class _XUsedAreaCursor extends MultiMethodTest {
public XUsedAreaCursor oObj = null;
CellRangeAddress sAddr = null;
/**
* Test points the cursor to the start of used area, expands cursor to the
* end of the used area, gets and checks current range address, then
* points the cursor to the end of the used area, gets and checks current
* range address again. <p>
* Has <b> OK </b> status if the range address expands at all used area
* in first case and if the range address just points to the cell at the end
* of the used area in second case. <p>
*/
public void _gotoEndOfUsedArea() {
boolean result = true ;
XCellRangeAddressable oAddr = UnoRuntime.queryInterface (XCellRangeAddressable.class, oObj) ;
// first with true argument
oObj.gotoStartOfUsedArea(false);
oObj.gotoEndOfUsedArea(true);
sAddr = oAddr.getRangeAddress();
result &= (sAddr.StartColumn == 1);
result &= (sAddr.StartRow == 1);
result &= (sAddr.EndColumn == 4);
result &= (sAddr.EndRow == 5);
oObj.gotoEndOfUsedArea(false);
sAddr = oAddr.getRangeAddress();
result &= (sAddr.StartColumn == 4);
result &= (sAddr.StartRow == 5);
result &= (sAddr.EndColumn == 4);
result &= (sAddr.EndRow == 5);
tRes.tested("gotoEndOfUsedArea()", result) ;
}
/**
* Test points the cursor to the end of used area, expands cursor to the
* start of the used area, gets and checks current range address, then
* points the cursor to the start of the used area, gets and checks current
* range address again. <p>
* Has <b> OK </b> status if the range address expands at all used area
* in first case and if the range address just points to the cell at the
* start of the used area in second case. <p>
*/
public void _gotoStartOfUsedArea() {
XCellRangeAddressable oAddr = UnoRuntime.queryInterface (XCellRangeAddressable.class, oObj) ;
boolean result = true ;
// with true parameter first
oObj.gotoEndOfUsedArea(false);
oObj.gotoStartOfUsedArea(true);
sAddr = oAddr.getRangeAddress();
result &= (sAddr.StartColumn == 1);
result &= (sAddr.StartRow == 1);
result &= (sAddr.EndColumn == 4);
result &= (sAddr.EndRow == 5);
// now testing with false parameter
oObj.gotoStartOfUsedArea(false);
sAddr = oAddr.getRangeAddress();
result &= (sAddr.StartColumn == 1);
result &= (sAddr.StartRow == 1);
result &= (sAddr.EndColumn == 1);
result &= (sAddr.EndRow == 1);
tRes.tested("gotoStartOfUsedArea()", result) ;
} // finished gotoStartOfUsedArea
/**
* Forces object environment recreation.
*/
@Override
protected void after() {
this.disposeEnvironment();
}
} // finished class _XUsedAreaCursor
......@@ -9,8 +9,8 @@
#include <test/calc_unoapi_test.hxx>
#include <test/sheet/xcellseries.hxx>
#include <test/sheet/xusedareacursor.hxx>
#include <com/sun/star/table/XCellCursor.hpp>
#include <com/sun/star/sheet/XSpreadsheetDocument.hpp>
#include <com/sun/star/sheet/XSpreadsheet.hpp>
......@@ -19,9 +19,9 @@ using namespace css::uno;
namespace sc_apitest {
#define NUMBER_OF_TESTS 2
#define NUMBER_OF_TESTS 4
class ScCellCursorObj : public CalcUnoApiTest, private apitest::XCellSeries
class ScCellCursorObj : public CalcUnoApiTest, private apitest::XCellSeries, public apitest::XUsedAreaCursor
{
public:
ScCellCursorObj();
......@@ -31,8 +31,15 @@ public:
virtual uno::Reference< uno::XInterface > init() override;
CPPUNIT_TEST_SUITE(ScCellCursorObj);
// XUsedAreaCursor
CPPUNIT_TEST(testGotoStartOfUsedArea);
CPPUNIT_TEST(testGotoEndOfUsedArea);
// XCellSeries
CPPUNIT_TEST(testFillAuto);
CPPUNIT_TEST(testFillSeries);
CPPUNIT_TEST_SUITE_END();
private:
......@@ -60,9 +67,8 @@ uno::Reference< uno::XInterface > ScCellCursorObj::init()
uno::Reference< sheet::XSpreadsheetDocument > xDoc(mxComponent, 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::Reference< table::XCellCursor > xCellCursor( xSheet->createCursor(), UNO_QUERY_THROW);
return xCellCursor;
return xSheet;
}
void ScCellCursorObj::setUp()
......
......@@ -66,6 +66,7 @@ $(eval $(call gb_Library_add_exception_objects,subsequenttest,\
test/source/sheet/xsheetannotationshapesupplier \
test/source/sheet/xsheetoutline \
test/source/sheet/xstyleloader \
test/source/sheet/xusedareacursor \
test/source/sheet/xviewpane \
test/source/sheet/xviewsplitable \
test/source/text/xtext \
......
......@@ -10,6 +10,7 @@
#include <test/sheet/xcellseries.hxx>
#include <com/sun/star/sheet/XCellSeries.hpp>
#include <com/sun/star/sheet/XSpreadsheet.hpp>
#include <com/sun/star/table/XCellRange.hpp>
#include "cppunit/extensions/HelperMacros.h"
......@@ -21,7 +22,8 @@ namespace apitest {
void XCellSeries::testFillAuto()
{
uno::Reference<table::XCellRange> xCellRange(init(), UNO_QUERY_THROW);
uno::Reference< sheet::XSpreadsheet > xSheet(init(), UNO_QUERY_THROW);
uno::Reference<table::XCellRange> xCellRange(xSheet->createCursor(), UNO_QUERY_THROW);
sal_Int32 maValue = xCellRange->getCellByPosition(maStartX, maStartY)->getValue();
uno::Reference<table::XCellRange> xCellRangeH(xCellRange->getCellRangeByPosition(maStartX, maStartY, maStartX + 2, maStartY), UNO_QUERY_THROW);
......@@ -54,7 +56,8 @@ void XCellSeries::testFillAuto()
void XCellSeries::testFillSeries()
{
uno::Reference<table::XCellRange> xCellRange(init(), UNO_QUERY_THROW);
uno::Reference< sheet::XSpreadsheet > xSheet(init(), UNO_QUERY_THROW);
uno::Reference<table::XCellRange> xCellRange(xSheet->createCursor(), UNO_QUERY_THROW);
sal_Int32 maValue = xCellRange->getCellByPosition(maStartX, maStartY)->getValue();
uno::Reference<table::XCellRange> xCellRangeH(xCellRange->getCellRangeByPosition(maStartX, maStartY, maStartX + 2, maStartY), UNO_QUERY_THROW);
......
/* -*- 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/xusedareacursor.hxx>
#include <com/sun/star/sheet/XCellRangeAddressable.hpp>
#include <com/sun/star/sheet/XSheetCellCursor.hpp>
#include <com/sun/star/sheet/XSpreadsheet.hpp>
#include <com/sun/star/sheet/XUsedAreaCursor.hpp>
#include <com/sun/star/table/CellRangeAddress.hpp>
#include "cppunit/extensions/HelperMacros.h"
using namespace com::sun::star;
using namespace com::sun::star::uno;
namespace apitest {
void XUsedAreaCursor::testGotoStartOfUsedArea()
{
uno::Reference< sheet::XSpreadsheet > xSheet(init(), UNO_QUERY_THROW);
uno::Reference< sheet::XSheetCellCursor > xSheetCellCursor(xSheet->createCursor(), UNO_QUERY_THROW);
uno::Reference< sheet::XCellRangeAddressable> xCellRangeAddressable(xSheetCellCursor, UNO_QUERY_THROW);
uno::Reference< sheet::XUsedAreaCursor > xUsedAreaCursor(xSheetCellCursor, UNO_QUERY_THROW);
xUsedAreaCursor->gotoStartOfUsedArea(false);
xUsedAreaCursor->gotoEndOfUsedArea(true);
table::CellRangeAddress cellRangeAddress = xCellRangeAddressable->getRangeAddress();
CPPUNIT_ASSERT_EQUAL_MESSAGE("Wrong start column",
sal_Int32(0), cellRangeAddress.StartColumn);
CPPUNIT_ASSERT_EQUAL_MESSAGE("Wrong end column",
sal_Int32(2), cellRangeAddress.EndColumn);
CPPUNIT_ASSERT_EQUAL_MESSAGE("Wrong start row",
sal_Int32(0), cellRangeAddress.StartRow);
CPPUNIT_ASSERT_EQUAL_MESSAGE("Wrong end column",
sal_Int32(0), cellRangeAddress.EndRow);
xUsedAreaCursor->gotoEndOfUsedArea(false);
cellRangeAddress = xCellRangeAddressable->getRangeAddress();
CPPUNIT_ASSERT_EQUAL_MESSAGE("Wrong start column",
sal_Int32(2), cellRangeAddress.StartColumn);
CPPUNIT_ASSERT_EQUAL_MESSAGE("Wrong end column",
sal_Int32(2), cellRangeAddress.EndColumn);
CPPUNIT_ASSERT_EQUAL_MESSAGE("Wrong start row",
sal_Int32(0), cellRangeAddress.StartRow);
CPPUNIT_ASSERT_EQUAL_MESSAGE("Wrong end column",
sal_Int32(0), cellRangeAddress.EndRow);
}
void XUsedAreaCursor::testGotoEndOfUsedArea()
{
uno::Reference< sheet::XSpreadsheet > xSheet(init(), UNO_QUERY_THROW);
uno::Reference< sheet::XSheetCellCursor > xSheetCellCursor(xSheet->createCursor(), UNO_QUERY_THROW);
uno::Reference< sheet::XCellRangeAddressable> xCellRangeAddressable(xSheetCellCursor, UNO_QUERY_THROW);
uno::Reference< sheet::XUsedAreaCursor > xUsedAreaCursor(xSheetCellCursor, UNO_QUERY_THROW);
xUsedAreaCursor->gotoEndOfUsedArea(false);
xUsedAreaCursor->gotoStartOfUsedArea(true);
table::CellRangeAddress cellRangeAddress = xCellRangeAddressable->getRangeAddress();
CPPUNIT_ASSERT_EQUAL_MESSAGE("Wrong start column",
sal_Int32(0), cellRangeAddress.StartColumn);
CPPUNIT_ASSERT_EQUAL_MESSAGE("Wrong end column",
sal_Int32(2), cellRangeAddress.EndColumn);
CPPUNIT_ASSERT_EQUAL_MESSAGE("Wrong start row",
sal_Int32(0), cellRangeAddress.StartRow);
CPPUNIT_ASSERT_EQUAL_MESSAGE("Wrong end column",
sal_Int32(0), cellRangeAddress.EndRow);
xUsedAreaCursor->gotoStartOfUsedArea(false);
cellRangeAddress = xCellRangeAddressable->getRangeAddress();
CPPUNIT_ASSERT_EQUAL_MESSAGE("Wrong start column",
sal_Int32(0), cellRangeAddress.StartColumn);
CPPUNIT_ASSERT_EQUAL_MESSAGE("Wrong end column",
sal_Int32(0), cellRangeAddress.EndColumn);
CPPUNIT_ASSERT_EQUAL_MESSAGE("Wrong start row",
sal_Int32(0), cellRangeAddress.StartRow);
CPPUNIT_ASSERT_EQUAL_MESSAGE("Wrong end column",
sal_Int32(0), cellRangeAddress.EndRow);
}
}
/* 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