Kaydet (Commit) 5c30493e authored tarafından Jens Carl's avatar Jens Carl

tdf#45904 Move XNameAccess Java tests to C++

Move XNameAccess Java tests to C++ for ScDatabaseRangesObj.

Change-Id: Id54f9bc1a9215a4524be4a1f52800049ce438c8a
Reviewed-on: https://gerrit.libreoffice.org/66250
Tested-by: Jenkins
Reviewed-by: 's avatarJens Carl <j.carl43@gmx.de>
üst 9f77ab80
...@@ -78,7 +78,6 @@ job80=sc.ScAutoFormatsObj ...@@ -78,7 +78,6 @@ job80=sc.ScAutoFormatsObj
job81=sc.ScCellFieldObj job81=sc.ScCellFieldObj
job85=sc.ScCellSearchObj job85=sc.ScCellSearchObj
job88=sc.ScDatabaseRangeObj job88=sc.ScDatabaseRangeObj
job89=sc.ScDatabaseRangesObj
job90=sc.ScDataPilotFieldObj job90=sc.ScDataPilotFieldObj
job91=sc.ScDataPilotFieldsObj job91=sc.ScDataPilotFieldsObj
job92=sc.ScDataPilotTablesObj job92=sc.ScDataPilotTablesObj
......
...@@ -967,7 +967,6 @@ $(eval $(call gb_Jar_add_sourcefiles,OOoRunner,\ ...@@ -967,7 +967,6 @@ $(eval $(call gb_Jar_add_sourcefiles,OOoRunner,\
qadevOOo/tests/java/mod/_sc/ScChartObj \ qadevOOo/tests/java/mod/_sc/ScChartObj \
qadevOOo/tests/java/mod/_sc/ScChartsObj \ qadevOOo/tests/java/mod/_sc/ScChartsObj \
qadevOOo/tests/java/mod/_sc/ScDatabaseRangeObj \ qadevOOo/tests/java/mod/_sc/ScDatabaseRangeObj \
qadevOOo/tests/java/mod/_sc/ScDatabaseRangesObj \
qadevOOo/tests/java/mod/_sc/ScDataPilotFieldGroupItemObj \ qadevOOo/tests/java/mod/_sc/ScDataPilotFieldGroupItemObj \
qadevOOo/tests/java/mod/_sc/ScDataPilotFieldGroupObj \ qadevOOo/tests/java/mod/_sc/ScDataPilotFieldGroupObj \
qadevOOo/tests/java/mod/_sc/ScDataPilotFieldGroupsObj \ qadevOOo/tests/java/mod/_sc/ScDataPilotFieldGroupsObj \
......
"ScDatabaseRangesObj";"com::sun::star::container::XNameAccess";"getByName()"
"ScDatabaseRangesObj";"com::sun::star::container::XNameAccess";"getElementNames()"
"ScDatabaseRangesObj";"com::sun::star::container::XNameAccess";"hasByName()"
/*
* 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.beans.XPropertySet;
import com.sun.star.lang.XComponent;
import com.sun.star.sheet.XDatabaseRanges;
import com.sun.star.sheet.XSpreadsheetDocument;
import com.sun.star.table.CellRangeAddress;
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.sheet.DatabaseRanges</code>. <p>
* Object implements the following interfaces :
* <ul>
* <li> <code>com::sun::star::sheet::XDatabaseRanges</code></li>
* <li> <code>com::sun::star::container::XNameAccess</code></li>
* <li> <code>com::sun::star::container::XElementAccess</code></li>
* </ul>
* @see com.sun.star.sheet.DatabaseRanges
* @see com.sun.star.sheet.XDatabaseRanges
* @see com.sun.star.container.XNameAccess
* @see com.sun.star.container.XElementAccess
* @see ifc.sheet._XDatabaseRanges
* @see ifc.container._XNameAccess
* @see ifc.container._XElementAccess
*/
public class ScDatabaseRangesObj extends TestCase {
private 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 the collection of database ranges in the document.
* If the database range with name <code>'dbRange'</code> doesn't exist
* in the collection then creates new database range and adds it to the
* collection with the name <code>'dbRange'</code> to have one element
* for the test of the interface <code>ElementAccess</code> at least.
* The collection of database ranges is the instance of the service
* <code>com.sun.star.sheet.DatabaseRanges</code>.
* @see com.sun.star.sheet.DatabaseRanges
* @see com.sun.star.container.XElementAccess
*/
@Override
protected TestEnvironment createTestEnvironment(TestParameters Param, PrintWriter log) throws Exception {
XInterface oObj = null;
// creation of testobject here
// first we write what we are intend to do to log file
log.println( "Creating a test environment" );
log.println("Getting test object ") ;
XPropertySet docProps = UnoRuntime.queryInterface(XPropertySet.class, xSheetDoc);
XDatabaseRanges dbRanges = null;
dbRanges = (XDatabaseRanges) AnyConverter.toObject(
new Type(XDatabaseRanges.class),
docProps.getPropertyValue("DatabaseRanges"));
log.println("Adding at least one element for ElementAccess interface");
CellRangeAddress aRange = new CellRangeAddress((short)0, 2, 4, 5, 6);
if (!dbRanges.hasByName("dbRange")) {
dbRanges.addNewByName("dbRange", aRange);
}
oObj = dbRanges;
TestEnvironment tEnv = new TestEnvironment( oObj );
// Other parameters required for interface tests
return tEnv;
}
}
...@@ -11,6 +11,7 @@ ...@@ -11,6 +11,7 @@
#include <test/container/xelementaccess.hxx> #include <test/container/xelementaccess.hxx>
#include <test/container/xenumerationaccess.hxx> #include <test/container/xenumerationaccess.hxx>
#include <test/container/xindexaccess.hxx> #include <test/container/xindexaccess.hxx>
#include <test/container/xnameaccess.hxx>
#include <test/sheet/xdatabaseranges.hxx> #include <test/sheet/xdatabaseranges.hxx>
#include <com/sun/star/beans/XPropertySet.hpp> #include <com/sun/star/beans/XPropertySet.hpp>
...@@ -35,7 +36,8 @@ class ScDatabaseRangesObj : public CalcUnoApiTest, ...@@ -35,7 +36,8 @@ class ScDatabaseRangesObj : public CalcUnoApiTest,
public apitest::XDatabaseRanges, public apitest::XDatabaseRanges,
public apitest::XElementAccess, public apitest::XElementAccess,
public apitest::XEnumerationAccess, public apitest::XEnumerationAccess,
public apitest::XIndexAccess public apitest::XIndexAccess,
public apitest::XNameAccess
{ {
public: public:
ScDatabaseRangesObj(); ScDatabaseRangesObj();
...@@ -60,6 +62,11 @@ public: ...@@ -60,6 +62,11 @@ public:
CPPUNIT_TEST(testGetByIndex); CPPUNIT_TEST(testGetByIndex);
CPPUNIT_TEST(testGetCount); CPPUNIT_TEST(testGetCount);
// XNameAccess
CPPUNIT_TEST(testGetByName);
CPPUNIT_TEST(testGetElementNames);
CPPUNIT_TEST(testHasByName);
CPPUNIT_TEST_SUITE_END(); CPPUNIT_TEST_SUITE_END();
private: private:
...@@ -70,6 +77,7 @@ ScDatabaseRangesObj::ScDatabaseRangesObj() ...@@ -70,6 +77,7 @@ ScDatabaseRangesObj::ScDatabaseRangesObj()
: CalcUnoApiTest("/sc/qa/extras/testdocuments") : CalcUnoApiTest("/sc/qa/extras/testdocuments")
, XElementAccess(cppu::UnoType<sheet::XDatabaseRange>::get()) , XElementAccess(cppu::UnoType<sheet::XDatabaseRange>::get())
, XIndexAccess(1) , XIndexAccess(1)
, XNameAccess("DbRange")
{ {
} }
......
...@@ -19,7 +19,6 @@ ...@@ -19,7 +19,6 @@
-o sc.ScDataPilotItemsObj -o sc.ScDataPilotItemsObj
-o sc.ScDataPilotTablesObj -o sc.ScDataPilotTablesObj
-o sc.ScDatabaseRangeObj -o sc.ScDatabaseRangeObj
# -o sc.ScDatabaseRangesObj
-o sc.ScDocumentConfiguration -o sc.ScDocumentConfiguration
-o sc.ScDrawPageObj -o sc.ScDrawPageObj
-o sc.ScDrawPagesObj -o sc.ScDrawPagesObj
......
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