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: Jens Carl <[email protected]>
diff --git a/framework/qa/complex/api_internal/api.lst b/framework/qa/complex/api_internal/api.lst
index a159f3a..4e4166e 100644
--- a/framework/qa/complex/api_internal/api.lst
+++ b/framework/qa/complex/api_internal/api.lst
@@ -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
diff --git a/include/test/table/xcellrange.hxx b/include/test/table/xcellrange.hxx
new file mode 100644
index 0000000..eec00c8
--- /dev/null
+++ b/include/test/table/xcellrange.hxx
@@ -0,0 +1,50 @@
/* -*- 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: */
diff --git a/qadevOOo/Jar_OOoRunner.mk b/qadevOOo/Jar_OOoRunner.mk
index 3815a06..c9e63df 100644
--- a/qadevOOo/Jar_OOoRunner.mk
+++ b/qadevOOo/Jar_OOoRunner.mk
@@ -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 \
diff --git a/qadevOOo/objdsc/sc/com.sun.star.comp.office.ScTableRowObj.csv b/qadevOOo/objdsc/sc/com.sun.star.comp.office.ScTableRowObj.csv
deleted file mode 100644
index 3b6fe97..0000000
--- a/qadevOOo/objdsc/sc/com.sun.star.comp.office.ScTableRowObj.csv
+++ /dev/null
@@ -1,3 +0,0 @@
"ScTableRowObj";"com::sun::star::table::XCellRange";"getCellByPosition()"
"ScTableRowObj";"com::sun::star::table::XCellRange";"getCellRangeByPosition()"
"ScTableRowObj";"com::sun::star::table::XCellRange";"getCellRangeByName()"
diff --git a/qadevOOo/tests/java/mod/_sc/ScTableRowObj.java b/qadevOOo/tests/java/mod/_sc/ScTableRowObj.java
deleted file mode 100644
index 6a1434e..0000000
--- a/qadevOOo/tests/java/mod/_sc/ScTableRowObj.java
+++ /dev/null
@@ -1,124 +0,0 @@
/*
* 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;
}
}
diff --git a/sc/qa/extras/sctablerowobj.cxx b/sc/qa/extras/sctablerowobj.cxx
index d264d24..45a974a 100644
--- a/sc/qa/extras/sctablerowobj.cxx
+++ b/sc/qa/extras/sctablerowobj.cxx
@@ -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",
diff --git a/sc/qa/unoapi/sc_7.sce b/sc/qa/unoapi/sc_7.sce
index 82b38d8..8fdce40 100644
--- a/sc/qa/unoapi/sc_7.sce
+++ b/sc/qa/unoapi/sc_7.sce
@@ -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
diff --git a/test/Library_subsequenttest.mk b/test/Library_subsequenttest.mk
index 796fbce..5eb1367 100644
--- a/test/Library_subsequenttest.mk
+++ b/test/Library_subsequenttest.mk
@@ -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 \
diff --git a/test/source/table/xcellrange.cxx b/test/source/table/xcellrange.cxx
new file mode 100644
index 0000000..c3b58f0
--- /dev/null
+++ b/test/source/table/xcellrange.cxx
@@ -0,0 +1,56 @@
/* -*- 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: */