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

tdf#45904 Move XCellRange Java tests to C++

Move XCellRange Java tests to C++ for ScTableRowObj.

Change-Id: I2735779cae777c5af4e622bc1b538df2d8bf70df
Reviewed-on: https://gerrit.libreoffice.org/70163
Tested-by: Jenkins
Reviewed-by: 's avatarJens Carl <j.carl43@gmx.de>
üst cc9a8c13
......@@ -80,7 +80,6 @@ job99=sc.ScHeaderFieldsObj
job126=sc.ScSheetLinkObj
job132=sc.ScStyleObj
job134=sc.ScTableColumnObj
job138=sc.ScTableRowObj
job140=sc.XMLContentExporter
job141=sc.XMLContentImporter
job142=sc.XMLImporter
......
/* -*- 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_TABLE_XCELLRANGE_HXX
#define INCLUDED_TEST_TABLE_XCELLRANGE_HXX
#include <test/testdllapi.hxx>
#include <rtl/ustring.h>
#include <com/sun/star/uno/XInterface.hpp>
#include <com/sun/star/uno/Reference.hxx>
namespace apitest
{
class OOO_DLLPUBLIC_TEST XCellRange
{
public:
XCellRange()
: m_aRangeName("A1:A1")
{
}
XCellRange(const OUString& aRangeName)
: m_aRangeName(aRangeName)
{
}
virtual css::uno::Reference<css::uno::XInterface> init() = 0;
void testGetCellByPosition();
void testGetCellRangeByName();
void testGetCellRangeByPosition();
protected:
~XCellRange() {}
private:
OUString const m_aRangeName;
};
} // namespace apitest
#endif // INCLUDED_TEST_TABLE_XCELLRANGE_HXX
/* vim:set shiftwidth=4 softtabstop=4 expandtab cinoptions=b1,g0,N-s cinkeys+=0=break: */
......@@ -969,7 +969,6 @@ $(eval $(call gb_Jar_add_sourcefiles,OOoRunner,\
qadevOOo/tests/java/mod/_sc/ScSheetLinkObj \
qadevOOo/tests/java/mod/_sc/ScStyleObj \
qadevOOo/tests/java/mod/_sc/ScTableColumnObj \
qadevOOo/tests/java/mod/_sc/ScTableRowObj \
qadevOOo/tests/java/mod/_sc/ScTableSheetObj \
qadevOOo/tests/java/mod/_sc/ScTableSheetsObj \
qadevOOo/tests/java/mod/_sc/ScTabViewObj \
......
"ScTableRowObj";"com::sun::star::table::XCellRange";"getCellByPosition()"
"ScTableRowObj";"com::sun::star::table::XCellRange";"getCellRangeByPosition()"
"ScTableRowObj";"com::sun::star::table::XCellRange";"getCellRangeByName()"
/*
* 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 mod._sc;
import java.io.PrintWriter;
import lib.TestCase;
import lib.TestEnvironment;
import lib.TestParameters;
import util.SOfficeFactory;
import com.sun.star.container.XIndexAccess;
import com.sun.star.container.XNameAccess;
import com.sun.star.lang.XComponent;
import com.sun.star.sheet.XSpreadsheet;
import com.sun.star.sheet.XSpreadsheetDocument;
import com.sun.star.sheet.XSpreadsheets;
import com.sun.star.table.XColumnRowRange;
import com.sun.star.table.XTableRows;
import com.sun.star.uno.AnyConverter;
import com.sun.star.uno.Type;
import com.sun.star.uno.UnoRuntime;
import com.sun.star.uno.XInterface;
/**
* Test for object which is represented by service
* <code>com.sun.star.table.TableRow</code>. <p>
* Object implements the following interfaces :
* <ul>
* <li> <code>com::sun::star::table::TableRow</code></li>
* <li> <code>com::sun::star::table::XCellRange</code></li>
* <li> <code>com::sun::star::beans::XPropertySet</code></li>
* </ul>
* @see com.sun.star.table.TableRow
* @see com.sun.star.table.XCellRange
* @see com.sun.star.beans.XPropertySet
* @see ifc.table._TableRow
* @see ifc.table._XCellRange
* @see ifc.beans._XPropertySet
*/
public class ScTableRowObj extends TestCase {
private XSpreadsheetDocument xSheetDoc = null;
/**
* Creates Spreadsheet document.
*/
@Override
protected void initialize( TestParameters tParam, PrintWriter log ) throws Exception {
// get a soffice factory object
SOfficeFactory SOF = SOfficeFactory.getFactory( tParam.getMSF());
log.println( "creating a sheetdocument" );
xSheetDoc = SOF.createCalcDoc(null);
}
/**
* Disposes Spreadsheet document.
*/
@Override
protected void cleanup( TestParameters tParam, PrintWriter log ) {
log.println( " disposing xSheetDoc " );
XComponent oComp = UnoRuntime.queryInterface (XComponent.class, xSheetDoc) ;
util.DesktopTools.closeDoc(oComp);
}
/**
* Creating a TestEnvironment for the interfaces to be tested.
* Retrieves a collection of spreadsheets from the document and takes one of
* them. Obtains the collection of rows using the interface
* <code>XColumnRowRange</code>. Obtains the row with index 6 from the
* collection and this is the instance of the service
* <code>com.sun.star.table.TableRow</code>.
* Object relations created :
* <ul>
* <li> <code>'ValidRange'</code> for
* {@link ifc.table._XCellRange} </li>
* </ul>
* @see com.sun.star.table.XColumnRowRange
* @see com.sun.star.table.TableRow
*/
@Override
protected TestEnvironment createTestEnvironment(TestParameters Param, PrintWriter log) throws Exception {
XInterface oObj = null;
// creation of the testobject here
// first we write what we are intend to do to log file
log.println("creating a test environment");
XSpreadsheet xSpreadsheet = null;
XSpreadsheets xSpreadsheets = xSheetDoc.getSheets();
XNameAccess oNames = UnoRuntime.queryInterface( XNameAccess.class, xSpreadsheets );
xSpreadsheet = (XSpreadsheet) AnyConverter.toObject(
new Type(XSpreadsheet.class),
oNames.getByName(oNames.getElementNames()[0]));
XColumnRowRange oColumnRowRange = UnoRuntime.queryInterface(XColumnRowRange.class, xSpreadsheet);
XTableRows oRows = oColumnRowRange.getRows();
XIndexAccess oIndexAccess = UnoRuntime.queryInterface(XIndexAccess.class, oRows);
oObj = (XInterface) AnyConverter.toObject(
new Type(XInterface.class),oIndexAccess.getByIndex(6));
log.println("creating a new environment for object");
TestEnvironment tEnv = new TestEnvironment(oObj);
tEnv.addObjRelation("ValidRange","A7:A7");
return tEnv;
}
}
......@@ -10,6 +10,7 @@
#include <test/calc_unoapi_test.hxx>
#include <test/beans/xpropertyset.hxx>
#include <test/table/tablerow.hxx>
#include <test/table/xcellrange.hxx>
#include <com/sun/star/container/XIndexAccess.hpp>
#include <com/sun/star/lang/XComponent.hpp>
......@@ -26,7 +27,10 @@ using namespace css;
namespace sc_apitest
{
class ScTableRowObj : public CalcUnoApiTest, public apitest::TableRow, public apitest::XPropertySet
class ScTableRowObj : public CalcUnoApiTest,
public apitest::TableRow,
public apitest::XCellRange,
public apitest::XPropertySet
{
public:
ScTableRowObj();
......@@ -40,6 +44,11 @@ public:
// TableRow
CPPUNIT_TEST(testTableRowProperties);
// XCellRange
CPPUNIT_TEST(testGetCellByPosition);
CPPUNIT_TEST(testGetCellRangeByName);
CPPUNIT_TEST(testGetCellRangeByPosition);
// XPropertySet
CPPUNIT_TEST(testGetPropertySetInfo);
CPPUNIT_TEST(testGetPropertyValue);
......@@ -55,6 +64,7 @@ private:
ScTableRowObj::ScTableRowObj()
: CalcUnoApiTest("/sc/qa/extras/testdocuments")
, XCellRange("A7:A7")
, XPropertySet({ "BottomBorder",
"BottomBorder2",
"CellProtection",
......
......@@ -18,7 +18,6 @@
# -o sc.ScStyleObj
# # i84656 -o sc.ScTabViewObj
# -o sc.ScTableColumnObj
# -o sc.ScTableRowObj
# -o sc.ScTableSheetObj
# -o sc.ScTableSheetsObj
# #i89411 -o sc.XMLContentExporter
......
......@@ -165,6 +165,7 @@ $(eval $(call gb_Library_add_exception_objects,subsequenttest,\
test/source/table/tablerow \
test/source/table/xcell \
test/source/table/xcellcursor \
test/source/table/xcellrange \
test/source/table/xcolumnrowrange \
test/source/table/xtablechart \
test/source/table/xtablecharts \
......
/* -*- 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/table/xcellrange.hxx>
#include <com/sun/star/lang/IndexOutOfBoundsException.hpp>
#include <com/sun/star/table/XCell.hpp>
#include <com/sun/star/table/XCellRange.hpp>
#include <com/sun/star/uno/Reference.hxx>
#include <cppunit/extensions/HelperMacros.h>
using namespace css;
namespace apitest
{
void XCellRange::testGetCellByPosition()
{
uno::Reference<table::XCellRange> xCR(init(), uno::UNO_QUERY_THROW);
uno::Reference<table::XCell> xCell(xCR->getCellByPosition(0, 0), uno::UNO_QUERY_THROW);
CPPUNIT_ASSERT(xCell.is());
CPPUNIT_ASSERT_THROW(xCR->getCellByPosition(-1, 1), lang::IndexOutOfBoundsException);
}
void XCellRange::testGetCellRangeByName()
{
uno::Reference<table::XCellRange> xCR(init(), uno::UNO_QUERY_THROW);
uno::Reference<table::XCellRange> xCellRange(xCR->getCellRangeByName(m_aRangeName),
uno::UNO_QUERY_THROW);
CPPUNIT_ASSERT(xCellRange.is());
}
void XCellRange::testGetCellRangeByPosition()
{
uno::Reference<table::XCellRange> xCR(init(), uno::UNO_QUERY_THROW);
uno::Reference<table::XCellRange> xCellRange(xCR->getCellRangeByPosition(0, 0, 0, 0),
uno::UNO_QUERY_THROW);
CPPUNIT_ASSERT(xCellRange.is());
CPPUNIT_ASSERT_THROW(xCR->getCellRangeByPosition(-1, 0, -1, 1),
lang::IndexOutOfBoundsException);
}
} // namespace apitest
/* 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