tdf#45904 Move XTableRows Java tests to C++
Move XTableRows Java tests to C++ for ScTableRowsObj. Change-Id: I765d213e0a3e95a3925f1fc179a8a3f6c6611739 Reviewed-on: https://gerrit.libreoffice.org/65398 Tested-by: Jenkins Reviewed-by: Jens Carl <j.carl43@gmx.de>
This commit is contained in:
38
include/test/table/xtablerows.hxx
Normal file
38
include/test/table/xtablerows.hxx
Normal file
@@ -0,0 +1,38 @@
|
||||
/* -*- 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_XTABLEROWS_HXX
|
||||
#define INCLUDED_TEST_TABLE_XTABLEROWS_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 XTableRows
|
||||
{
|
||||
public:
|
||||
virtual css::uno::Reference<css::uno::XInterface> init() = 0;
|
||||
virtual css::uno::Reference<css::uno::XInterface> getXCellRange() = 0;
|
||||
|
||||
virtual void testInsertByIndex();
|
||||
virtual void testRemoveByIndex();
|
||||
|
||||
protected:
|
||||
~XTableRows() {}
|
||||
};
|
||||
|
||||
} // namespace apitest
|
||||
|
||||
#endif // INCLUDED_TEST_TABLE_XTABLEROWS_HXX
|
||||
|
||||
/* vim:set shiftwidth=4 softtabstop=4 expandtab cinoptions=b1,g0,N-s cinkeys+=0=break: */
|
@@ -1001,7 +1001,6 @@ $(eval $(call gb_Jar_add_sourcefiles,OOoRunner,\
|
||||
qadevOOo/tests/java/mod/_sc/ScTableColumnsObj \
|
||||
qadevOOo/tests/java/mod/_sc/ScTableConditionalFormat \
|
||||
qadevOOo/tests/java/mod/_sc/ScTableRowObj \
|
||||
qadevOOo/tests/java/mod/_sc/ScTableRowsObj \
|
||||
qadevOOo/tests/java/mod/_sc/ScTableSheetObj \
|
||||
qadevOOo/tests/java/mod/_sc/ScTableSheetsObj \
|
||||
qadevOOo/tests/java/mod/_sc/ScTableValidationObj \
|
||||
|
@@ -1,2 +0,0 @@
|
||||
"ScTableRowsObj";"com::sun::star::table::XTableRows";"insertByIndex()"
|
||||
"ScTableRowsObj";"com::sun::star::table::XTableRows";"removeByIndex()"
|
|
@@ -1,120 +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.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.XCellRange;
|
||||
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.TableRows</code>. <p>
|
||||
* Object implements the following interfaces :
|
||||
* <ul>
|
||||
* <li> <code>com::sun::star::container::XIndexAccess</code></li>
|
||||
* <li> <code>com::sun::star::container::XElementAccess</code></li>
|
||||
* <li> <code>com::sun::star::table::XTableRows</code></li>
|
||||
* </ul>
|
||||
* @see com.sun.star.table.TableRows
|
||||
* @see com.sun.star.container.XIndexAccess
|
||||
* @see com.sun.star.container.XElementAccess
|
||||
* @see com.sun.star.table.XTableRows
|
||||
* @see ifc.container._XIndexAccess
|
||||
* @see ifc.container._XElementAccess
|
||||
* @see ifc.table._XTableRows
|
||||
*/
|
||||
public class ScTableRowsObj extends TestCase {
|
||||
XSpreadsheetDocument xSheetDoc = null;
|
||||
|
||||
/**
|
||||
* Creates Spreadsheet document.
|
||||
*/
|
||||
@Override
|
||||
protected void initialize( TestParameters tParam, PrintWriter log ) throws Exception {
|
||||
SOfficeFactory SOF = SOfficeFactory.getFactory( tParam.getMSF() );
|
||||
|
||||
log.println( "creating a Spreadsheet document" );
|
||||
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>. The obtained collection is the instance of
|
||||
* the service <code>com.sun.star.table.TableRows</code>.
|
||||
* @see com.sun.star.table.XColumnRowRange
|
||||
* @see com.sun.star.table.TableRows
|
||||
*/
|
||||
@Override
|
||||
protected TestEnvironment createTestEnvironment(TestParameters Param, PrintWriter log) throws Exception {
|
||||
|
||||
XInterface oObj = null;
|
||||
|
||||
log.println("getting row");
|
||||
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();
|
||||
oObj = oRows;
|
||||
|
||||
log.println("creating a new environment for object");
|
||||
TestEnvironment tEnv = new TestEnvironment(oObj);
|
||||
|
||||
// adding relation for XTableRows
|
||||
tEnv.addObjRelation("XTableRows.XCellRange",
|
||||
UnoRuntime.queryInterface(XCellRange.class, xSpreadsheet));
|
||||
|
||||
return tEnv;
|
||||
}
|
||||
} // finish class ScTableRowsObj
|
||||
|
@@ -11,6 +11,7 @@
|
||||
#include <test/container/xelementaccess.hxx>
|
||||
#include <test/container/xenumerationaccess.hxx>
|
||||
#include <test/container/xindexaccess.hxx>
|
||||
#include <test/table/xtablerows.hxx>
|
||||
|
||||
#include <com/sun/star/container/XNameAccess.hpp>
|
||||
#include <com/sun/star/lang/XComponent.hpp>
|
||||
@@ -34,12 +35,14 @@ namespace sc_apitest
|
||||
class ScTableRowsObj : public CalcUnoApiTest,
|
||||
public apitest::XElementAccess,
|
||||
public apitest::XEnumerationAccess,
|
||||
public apitest::XIndexAccess
|
||||
public apitest::XIndexAccess,
|
||||
public apitest::XTableRows
|
||||
{
|
||||
public:
|
||||
ScTableRowsObj();
|
||||
|
||||
virtual uno::Reference<uno::XInterface> init() override;
|
||||
virtual uno::Reference<uno::XInterface> getXCellRange() override;
|
||||
virtual void setUp() override;
|
||||
virtual void tearDown() override;
|
||||
|
||||
@@ -56,6 +59,10 @@ public:
|
||||
CPPUNIT_TEST(testGetByIndex);
|
||||
CPPUNIT_TEST(testGetCount);
|
||||
|
||||
// XTableRows
|
||||
CPPUNIT_TEST(testInsertByIndex);
|
||||
CPPUNIT_TEST(testRemoveByIndex);
|
||||
|
||||
CPPUNIT_TEST_SUITE_END();
|
||||
|
||||
private:
|
||||
@@ -85,6 +92,20 @@ uno::Reference<uno::XInterface> ScTableRowsObj::init()
|
||||
return xTR;
|
||||
}
|
||||
|
||||
uno::Reference<uno::XInterface> ScTableRowsObj::getXCellRange()
|
||||
{
|
||||
uno::Reference<sheet::XSpreadsheetDocument> xDoc(m_xCompoment, uno::UNO_QUERY_THROW);
|
||||
CPPUNIT_ASSERT_MESSAGE("no calc document", xDoc.is());
|
||||
|
||||
uno::Reference<sheet::XSpreadsheets> xSheets(xDoc->getSheets(), uno::UNO_QUERY_THROW);
|
||||
uno::Reference<container::XNameAccess> xNA(xSheets, uno::UNO_QUERY_THROW);
|
||||
uno::Reference<sheet::XSpreadsheet> xSheet0(xSheets->getByName(xNA->getElementNames()[0]),
|
||||
uno::UNO_QUERY_THROW);
|
||||
|
||||
uno::Reference<table::XCellRange> xCR(xSheet0, uno::UNO_QUERY_THROW);
|
||||
return xCR;
|
||||
}
|
||||
|
||||
void ScTableRowsObj::setUp()
|
||||
{
|
||||
CalcUnoApiTest::setUp();
|
||||
|
@@ -22,7 +22,6 @@
|
||||
-o sc.ScTableColumnsObj
|
||||
-o sc.ScTableConditionalFormat
|
||||
# -o sc.ScTableRowObj
|
||||
-o sc.ScTableRowsObj
|
||||
# -o sc.ScTableSheetObj
|
||||
# -o sc.ScTableSheetsObj
|
||||
-o sc.ScTableValidationObj
|
||||
|
@@ -157,6 +157,7 @@ $(eval $(call gb_Library_add_exception_objects,subsequenttest,\
|
||||
test/source/table/xcellcursor \
|
||||
test/source/table/xcolumnrowrange \
|
||||
test/source/table/xtablechartssupplier \
|
||||
test/source/table/xtablerows \
|
||||
test/source/text/xtext \
|
||||
test/source/text/xtextcontent \
|
||||
test/source/text/xtextfield \
|
||||
|
55
test/source/table/xtablerows.cxx
Normal file
55
test/source/table/xtablerows.cxx
Normal file
@@ -0,0 +1,55 @@
|
||||
/* -*- 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/xtablerows.hxx>
|
||||
|
||||
#include <com/sun/star/table/XCellRange.hpp>
|
||||
#include <com/sun/star/table/XTableRows.hpp>
|
||||
#include <com/sun/star/uno/RuntimeException.hpp>
|
||||
|
||||
#include <com/sun/star/uno/Reference.hxx>
|
||||
|
||||
#include <cppunit/extensions/HelperMacros.h>
|
||||
|
||||
using namespace css;
|
||||
using namespace css::uno;
|
||||
|
||||
namespace apitest
|
||||
{
|
||||
void XTableRows::testInsertByIndex()
|
||||
{
|
||||
uno::Reference<table::XCellRange> xCellRange(getXCellRange(), uno::UNO_QUERY_THROW);
|
||||
xCellRange->getCellByPosition(0, 0)->setValue(17);
|
||||
xCellRange->getCellByPosition(0, 1)->setValue(15);
|
||||
|
||||
uno::Reference<table::XTableRows> xTableRows(init(), uno::UNO_QUERY_THROW);
|
||||
xTableRows->removeByIndex(0, 1);
|
||||
|
||||
xTableRows->insertByIndex(0, 1);
|
||||
CPPUNIT_ASSERT_DOUBLES_EQUAL(xCellRange->getCellByPosition(0, 1)->getValue(), 15.0, 0.1);
|
||||
|
||||
CPPUNIT_ASSERT_THROW(xTableRows->insertByIndex(-1, 1), uno::RuntimeException);
|
||||
}
|
||||
|
||||
void XTableRows::testRemoveByIndex()
|
||||
{
|
||||
uno::Reference<table::XCellRange> xCellRange(getXCellRange(), uno::UNO_QUERY_THROW);
|
||||
xCellRange->getCellByPosition(0, 0)->setValue(17);
|
||||
xCellRange->getCellByPosition(0, 1)->setValue(15);
|
||||
|
||||
uno::Reference<table::XTableRows> xTableRows(init(), uno::UNO_QUERY_THROW);
|
||||
xTableRows->removeByIndex(0, 1);
|
||||
CPPUNIT_ASSERT_DOUBLES_EQUAL(xCellRange->getCellByPosition(0, 0)->getValue(), 15.0, 0.1);
|
||||
|
||||
CPPUNIT_ASSERT_THROW(xTableRows->removeByIndex(-1, 1), uno::RuntimeException);
|
||||
}
|
||||
|
||||
} // namespace apitest
|
||||
|
||||
/* vim:set shiftwidth=4 softtabstop=4 expandtab cinoptions=b1,g0,N-s cinkeys+=0=break: */
|
Reference in New Issue
Block a user