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

tdf#45904 Move remaining _XCellRangeReferrer Java tests to C++

Move remaining _XCellRangeReferrer tests to C++ and partly fix #i84656.

Change-Id: I77cc8550888f460a6ae265816907a19a81cbe871
Reviewed-on: https://gerrit.libreoffice.org/55732Tested-by: 's avatarJenkins <ci@libreoffice.org>
Reviewed-by: 's avatarJens Carl <j.carl43@gmx.de>
üst 0554e742
......@@ -11,6 +11,9 @@
#define INCLUDED_TEST_SHEET_XCELLRANGEREFERRER_HXX
#include <com/sun/star/table/CellRangeAddress.hpp>
#include <com/sun/star/uno/XInterface.hpp>
#include <com/sun/star/uno/Reference.hxx>
#include <test/testdllapi.hxx>
namespace apitest {
......@@ -18,18 +21,17 @@ namespace apitest {
class OOO_DLLPUBLIC_TEST XCellRangeReferrer
{
public:
XCellRangeReferrer( css::table::CellRangeAddress aCellRange ):
maCellRange( aCellRange ) {}
virtual css::uno::Reference< css::uno::XInterface > init() = 0;
void setCellRange(css::table::CellRangeAddress aCellRange) { m_aCellRange = aCellRange; }
const css::table::CellRangeAddress getCellRange() { return m_aCellRange; }
void testGetReferredCells();
protected:
~XCellRangeReferrer() {}
private:
css::table::CellRangeAddress maCellRange;
css::table::CellRangeAddress m_aCellRange;
};
}
......
......@@ -565,7 +565,6 @@ $(eval $(call gb_Jar_add_sourcefiles,OOoRunner,\
qadevOOo/tests/java/ifc/sheet/_SpreadsheetDocument \
qadevOOo/tests/java/ifc/sheet/_TableAutoFormatField \
qadevOOo/tests/java/ifc/sheet/_XCellRangeData \
qadevOOo/tests/java/ifc/sheet/_XCellRangeReferrer \
qadevOOo/tests/java/ifc/sheet/_XCellRangesQuery \
qadevOOo/tests/java/ifc/sheet/_XDocumentAuditing \
qadevOOo/tests/java/ifc/sheet/_XEnhancedMouseClickBroadcaster \
......
"ScDatabaseRangeObj";"com::sun::star::util::XRefreshable#optional";"refresh()"
"ScDatabaseRangeObj";"com::sun::star::util::XRefreshable#optional";"addRefreshListener()"
"ScDatabaseRangeObj";"com::sun::star::util::XRefreshable#optional";"removeRefreshListener()"
"ScDatabaseRangeObj";"com::sun::star::sheet::XCellRangeReferrer";"getReferredCells()"
"ScDatabaseRangeObj";"com::sun::star::container::XNamed";"getName()"
"ScDatabaseRangeObj";"com::sun::star::container::XNamed";"setName()"
"ScDatabaseRangeObj";"com::sun::star::beans::XPropertySet";"getPropertySetInfo()"
......
"ScNamedRangeObj";"com::sun::star::sheet::XCellRangeReferrer";"getReferredCells()"
"ScNamedRangeObj";"com::sun::star::container::XNamed";"getName()"
"ScNamedRangeObj";"com::sun::star::container::XNamed";"setName()"
......@@ -12,7 +12,6 @@
"ScTabViewObj";"com::sun::star::sheet::XEnhancedMouseClickBroadcaster#optional";"removeEnhancedMouseClickHandler()"
"ScTabViewObj";"com::sun::star::ui::XContextMenuInterception#optional";"registerContextMenuInterceptor()"
"ScTabViewObj";"com::sun::star::ui::XContextMenuInterception#optional";"releaseContextMenuInterceptor()"
"ScTabViewObj";"com::sun::star::sheet::XCellRangeReferrer";"getReferredCells()"
"ScTabViewObj";"com::sun::star::container::XElementAccess";"getElementType()"
"ScTabViewObj";"com::sun::star::container::XElementAccess";"hasElements()"
"ScTabViewObj";"com::sun::star::sheet::XRangeSelection";"startRangeSelection()"
......
"ScViewPaneObj";"com::sun::star::sheet::XCellRangeReferrer";"getReferredCells()"
"ScViewPaneObj";"com::sun::star::view::XControlAccess#optional";"getControl()"
"ScViewPaneObj";"com::sun::star::view::XFormLayerAccess#optional";"getFromController()"
"ScViewPaneObj";"com::sun::star::view::XFormLayerAccess#optional";"isFormDesignMode()"
......
/*
* 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 lib.Status;
import lib.StatusException;
import com.sun.star.sheet.XCellRangeAddressable;
import com.sun.star.sheet.XCellRangeReferrer;
import com.sun.star.table.CellRangeAddress;
import com.sun.star.table.XCellRange;
import com.sun.star.uno.UnoRuntime;
/**
* Testing <code>com.sun.star.sheet.XCellRangeReferrer</code>
* interface methods :
* <ul>
* <li><code> getReferredCells() </code></li>
* </ul> <p>
* This test needs the following object relations :
* <ul>
* <li> <code>'DATAAREA'</code> (of type <code>CellRangeAddress</code>):
* to have cell range address </li>
* <ul> <p>
* @see com.sun.star.sheet.XCellRangeReferrer
* @see com.sun.star.table.CellRangeAddress
*/
public class _XCellRangeReferrer extends MultiMethodTest {
public XCellRangeReferrer oObj = null;
/**
* Test calls the method and compares cell range address of returned cell range
* with cell range address gotten by relation <code>'DATAAREA'</code>. <p>
* Has <b> OK </b> status if all fields of cell range addresses are equal. <p>
*/
public void _getReferredCells() {
boolean bResult = true;
CellRangeAddress oldCRA = (CellRangeAddress)
tEnv.getObjRelation("DATAAREA");
if (oldCRA == null) throw new StatusException(Status.failed
("Relation 'DATAAREA' not found"));
XCellRange cr = oObj.getReferredCells();
if (cr == null) {
log.println("getReferredCells returned NULL.");
tRes.tested("getReferredCells()", false);
return;
}
log.println(cr.toString());
XCellRangeAddressable xCRA = UnoRuntime.queryInterface(XCellRangeAddressable.class, cr);
CellRangeAddress objCRA = xCRA.getRangeAddress();
log.println("The named range was 'ANamedRange A1:B2'");
log.println("Expected CellRangeAddress: (" + oldCRA.Sheet +
"," + oldCRA.StartColumn + "," + oldCRA.StartRow + "," +
oldCRA.EndColumn + "," + objCRA.EndRow + ")");
log.println("CellRangeAddress gotten: (" + objCRA.Sheet + ","
+ objCRA.StartColumn + "," + objCRA.StartRow + "," +
objCRA.EndColumn + "," + objCRA.EndRow + ")");
bResult &= objCRA.EndColumn == oldCRA.EndColumn;
bResult &= objCRA.EndRow == oldCRA.EndRow;
bResult &= objCRA.Sheet == oldCRA.Sheet;
bResult &= objCRA.StartColumn == oldCRA.StartColumn;
bResult &= objCRA.StartRow == oldCRA.StartRow;
tRes.tested("getReferredCells()", bResult);
}
}
......@@ -9,38 +9,37 @@
#include <test/calc_unoapi_test.hxx>
#include <test/sheet/databaserange.hxx>
#include <test/sheet/xcellrangereferrer.hxx>
#include <test/sheet/xdatabaserange.hxx>
#include <com/sun/star/beans/XPropertySet.hpp>
#include <com/sun/star/sheet/XSpreadsheetDocument.hpp>
#include <com/sun/star/container/XNameAccess.hpp>
#include <com/sun/star/sheet/XCellRangeAddressable.hpp>
#include <com/sun/star/sheet/XCellRangeReferrer.hpp>
#include <com/sun/star/sheet/XDatabaseRange.hpp>
#include <com/sun/star/sheet/XSpreadsheetDocument.hpp>
using namespace css;
using namespace css::uno;
namespace sc_apitest {
class ScDatabaseRangeObj : public CalcUnoApiTest, public apitest::DatabaseRange, public apitest::XDatabaseRange
class ScDatabaseRangeObj : public CalcUnoApiTest,
public apitest::DatabaseRange,
public apitest::XCellRangeReferrer,
public apitest::XDatabaseRange
{
public:
virtual void setUp() override;
virtual void tearDown() override;
virtual uno::Reference< uno::XInterface > init() override;
virtual uno::Reference< uno::XInterface > init( const OUString& rDBName ) override;
ScDatabaseRangeObj();
CPPUNIT_TEST_SUITE(ScDatabaseRangeObj);
// XDatabaseRange
CPPUNIT_TEST(testDataArea);
CPPUNIT_TEST(testGetSortDescriptor);
CPPUNIT_TEST(testGetSubtotalDescriptor);
CPPUNIT_TEST(testGetImportDescriptor);
CPPUNIT_TEST(testGetFilterDescriptor);
CPPUNIT_TEST(testRefresh);
// DatabaseRange
CPPUNIT_TEST(testMoveCells);
CPPUNIT_TEST(testKeepFormats);
......@@ -54,6 +53,17 @@ public:
CPPUNIT_TEST(testTotalsRow);
CPPUNIT_TEST(testContainsHeader);
// XCellRangeReferrer
CPPUNIT_TEST(testGetReferredCells);
// XDatabaseRange
CPPUNIT_TEST(testDataArea);
CPPUNIT_TEST(testGetSortDescriptor);
CPPUNIT_TEST(testGetSubtotalDescriptor);
CPPUNIT_TEST(testGetImportDescriptor);
CPPUNIT_TEST(testGetFilterDescriptor);
CPPUNIT_TEST(testRefresh);
CPPUNIT_TEST_SUITE_END();
private:
uno::Reference< lang::XComponent > mxComponent;
......@@ -64,14 +74,25 @@ ScDatabaseRangeObj::ScDatabaseRangeObj()
{
}
uno::Reference<uno::XInterface> ScDatabaseRangeObj::init()
{
return init("DataArea");
}
uno::Reference< uno::XInterface > ScDatabaseRangeObj::init( const OUString& rDBName )
{
uno::Reference< sheet::XSpreadsheetDocument > xDoc(mxComponent, UNO_QUERY_THROW);
uno::Reference< beans::XPropertySet > xPropSet(xDoc, UNO_QUERY_THROW);
uno::Reference< container::XNameAccess > xNameAccess( xPropSet->getPropertyValue("DatabaseRanges"), UNO_QUERY_THROW);
uno::Reference<sheet::XCellRangeReferrer> xCRR(xNameAccess->getByName(rDBName), UNO_QUERY_THROW);
uno::Reference<sheet::XCellRangeAddressable> xCRA(xCRR->getReferredCells(), UNO_QUERY_THROW);
setCellRange(xCRA->getRangeAddress());
uno::Reference< sheet::XDatabaseRange > xDBRange( xNameAccess->getByName(rDBName), UNO_QUERY_THROW);
CPPUNIT_ASSERT(xDBRange.is());
return xDBRange;
}
......
......@@ -8,21 +8,24 @@
*/
#include <test/calc_unoapi_test.hxx>
#include <test/sheet/xnamedrange.hxx>
#include <test/container/xnamed.hxx>
#include <test/sheet/xnamedrange.hxx>
#include <test/sheet/xcellrangereferrer.hxx>
#include <com/sun/star/beans/XPropertySet.hpp>
#include <com/sun/star/sheet/XNamedRanges.hpp>
#include <com/sun/star/sheet/XSpreadsheetDocument.hpp>
#include <com/sun/star/sheet/XSpreadsheet.hpp>
#include <com/sun/star/sheet/XNamedRanges.hpp>
using namespace css;
using namespace css::uno;
namespace sc_apitest {
class ScNamedRangeObj : public CalcUnoApiTest, public apitest::XNamedRange, public apitest::XNamed, public apitest::XCellRangeReferrer
class ScNamedRangeObj : public CalcUnoApiTest,
public apitest::XCellRangeReferrer,
public apitest::XNamed,
public apitest::XNamedRange
{
public:
ScNamedRangeObj();
......@@ -35,15 +38,20 @@ public:
CPPUNIT_TEST_SUITE(ScNamedRangeObj);
// XCellRangeReferrer
CPPUNIT_TEST(testGetReferredCells);
// XNamed
CPPUNIT_TEST(testSetName);
CPPUNIT_TEST(testGetName);
// XNamedRange
CPPUNIT_TEST(testGetContent);
CPPUNIT_TEST(testSetContent);
CPPUNIT_TEST(testGetType);
CPPUNIT_TEST(testSetType);
CPPUNIT_TEST(testGetReferencePosition);
CPPUNIT_TEST(testSetReferencePosition);
CPPUNIT_TEST(testSetName);
CPPUNIT_TEST(testGetName);
CPPUNIT_TEST(testGetReferredCells);
CPPUNIT_TEST_SUITE_END();
private:
......@@ -53,8 +61,7 @@ private:
ScNamedRangeObj::ScNamedRangeObj():
CalcUnoApiTest("/sc/qa/extras/testdocuments"),
apitest::XNamed("NamedRange"),
apitest::XCellRangeReferrer(table::CellRangeAddress(0,1,7,1,7))
apitest::XNamed("NamedRange")
{
}
......@@ -66,6 +73,8 @@ uno::Reference< sheet::XNamedRanges > ScNamedRangeObj::init_impl()
uno::Reference< sheet::XNamedRanges > xNamedRanges(xPropSet->getPropertyValue("NamedRanges"), UNO_QUERY_THROW);
CPPUNIT_ASSERT(xNamedRanges.is());
setCellRange(table::CellRangeAddress(0, 1, 7, 1, 7));
return xNamedRanges;
}
......
......@@ -10,6 +10,7 @@
#include <test/calc_unoapi_test.hxx>
#include <test/sheet/spreadsheetviewsettings.hxx>
#include <test/sheet/xactivationbroadcaster.hxx>
#include <test/sheet/xcellrangereferrer.hxx>
#include <test/sheet/xspreadsheetview.hxx>
#include <test/sheet/xviewfreezable.hxx>
#include <test/sheet/xviewsplitable.hxx>
......@@ -31,6 +32,7 @@ namespace sc_apitest
class ScTabViewObj : public CalcUnoApiTest,
public apitest::SpreadsheetViewSettings,
public apitest::XActivationBroadcaster,
public apitest::XCellRangeReferrer,
public apitest::XSpreadsheetView,
public apitest::XViewFreezable,
public apitest::XViewSplitable
......@@ -52,6 +54,9 @@ public:
// XActivationBroadcaster
CPPUNIT_TEST(testAddRemoveActivationEventListener);
// XCellRangeReferrer
CPPUNIT_TEST(testGetReferredCells);
// XSpreadsheetView
CPPUNIT_TEST(testGetSetActiveSheet);
......@@ -75,9 +80,10 @@ ScTabViewObj::ScTabViewObj()
uno::Reference< uno::XInterface > ScTabViewObj::init()
{
uno::Reference<sheet::XSpreadsheetDocument> xDoc(mxComponent, uno::UNO_QUERY_THROW);
uno::Reference<frame::XModel> xModel(xDoc, uno::UNO_QUERY_THROW);
setCellRange(table::CellRangeAddress(0, 0, 0, 6, 23));
return xModel->getCurrentController();
}
......
......@@ -8,6 +8,7 @@
*/
#include <test/calc_unoapi_test.hxx>
#include <test/sheet/xcellrangereferrer.hxx>
#include <test/sheet/xviewpane.hxx>
#include <com/sun/star/container/XIndexAccess.hpp>
......@@ -23,7 +24,9 @@ using namespace css::uno;
namespace sc_apitest {
class ScViewPaneObj : public CalcUnoApiTest, public apitest::XViewPane
class ScViewPaneObj : public CalcUnoApiTest,
public apitest::XCellRangeReferrer,
public apitest::XViewPane
{
public:
ScViewPaneObj();
......@@ -34,6 +37,9 @@ public:
CPPUNIT_TEST_SUITE(ScViewPaneObj);
// XCellRangeReferrer
CPPUNIT_TEST(testGetReferredCells);
// XViewPane
CPPUNIT_TEST(testFirstVisibleColumn);
CPPUNIT_TEST(testFirstVisibleRow);
......@@ -58,6 +64,9 @@ uno::Reference< uno::XInterface > ScViewPaneObj::init()
uno::Reference< frame::XController > xController = xModel->getCurrentController();
uno::Reference< container::XIndexAccess > xIndexAccess(xController, uno::UNO_QUERY_THROW);
uno::Reference< sheet::XViewPane > xViewPane (xIndexAccess->getByIndex(0), uno::UNO_QUERY_THROW);
setCellRange(xViewPane->getVisibleRange());
return xViewPane;
}
......
......@@ -7,10 +7,13 @@
* file, You can obtain one at http://mozilla.org/MPL/2.0/.
*/
#include <test/cppunitasserthelper.hxx>
#include <test/sheet/xcellrangereferrer.hxx>
#include <com/sun/star/table/XCellRange.hpp>
#include <com/sun/star/sheet/XCellRangeAddressable.hpp>
#include <com/sun/star/sheet/XCellRangeReferrer.hpp>
#include <cppunit/extensions/HelperMacros.h>
using namespace css;
......@@ -26,13 +29,8 @@ void XCellRangeReferrer::testGetReferredCells()
uno::Reference< sheet::XCellRangeAddressable > xAdressable( xReferredRange, UNO_QUERY_THROW );
table::CellRangeAddress aCellRange = xAdressable->getRangeAddress();
CPPUNIT_ASSERT_EQUAL( aCellRange.Sheet, maCellRange.Sheet );
CPPUNIT_ASSERT_EQUAL( aCellRange.StartRow, maCellRange.StartRow );
CPPUNIT_ASSERT_EQUAL( aCellRange.EndRow, maCellRange.EndRow );
CPPUNIT_ASSERT_EQUAL( aCellRange.StartColumn, maCellRange.StartColumn );
CPPUNIT_ASSERT_EQUAL( aCellRange.EndColumn, maCellRange.EndColumn );
CPPUNIT_ASSERT_EQUAL(aCellRange, getCellRange());
}
}
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
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