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

tdf#45904 Move XEnumeration Java tests to C++

Move XEnumeration Java tests to C++
for ScIndexEnumeration_TableChartsEnumeration.

Change-Id: Ibbfcf9ec92c3bae4d6add044d2e62472f32d801e
Reviewed-on: https://gerrit.libreoffice.org/63678
Tested-by: Jenkins
Reviewed-by: 's avatarJens Carl <j.carl43@gmx.de>
üst 8c1540d5
......@@ -94,7 +94,6 @@ job96=sc.ScFilterDescriptorBase
job97=sc.ScFunctionListObj
job98=sc.ScHeaderFieldObj
job99=sc.ScHeaderFieldsObj
job117=sc.ScIndexEnumeration_TableChartsEnumeration
job122=sc.ScLabelRangesObj
job125=sc.ScScenariosObj
job126=sc.ScSheetLinkObj
......
......@@ -993,7 +993,6 @@ $(eval $(call gb_Jar_add_sourcefiles,OOoRunner,\
qadevOOo/tests/java/mod/_sc/ScHeaderFooterTextCursor \
qadevOOo/tests/java/mod/_sc/ScHeaderFooterTextObj \
qadevOOo/tests/java/mod/_sc/ScIndexEnumeration_DataPilotItemsEnumeration \
qadevOOo/tests/java/mod/_sc/ScIndexEnumeration_TableChartsEnumeration \
qadevOOo/tests/java/mod/_sc/ScLabelRangesObj \
qadevOOo/tests/java/mod/_sc/ScModelObj \
qadevOOo/tests/java/mod/_sc/ScNamedRangesObj \
......
"ScIndexEnumeration_TableChartsEnumeration";"com::sun::star::container::XEnumeration";"hasMoreElements()"
"ScIndexEnumeration_TableChartsEnumeration";"com::sun::star::container::XEnumeration";"nextElement()"
/*
* 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.awt.Rectangle;
import com.sun.star.container.XEnumerationAccess;
import com.sun.star.container.XIndexAccess;
import com.sun.star.lang.XComponent;
import com.sun.star.sheet.XCellRangeAddressable;
import com.sun.star.sheet.XSpreadsheet;
import com.sun.star.sheet.XSpreadsheetDocument;
import com.sun.star.sheet.XSpreadsheets;
import com.sun.star.table.CellRangeAddress;
import com.sun.star.table.XCell;
import com.sun.star.table.XCellRange;
import com.sun.star.table.XTableCharts;
import com.sun.star.table.XTableChartsSupplier;
import com.sun.star.uno.AnyConverter;
import com.sun.star.uno.Type;
import com.sun.star.uno.UnoRuntime;
import com.sun.star.uno.XInterface;
public class ScIndexEnumeration_TableChartsEnumeration 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);
}
@Override
protected TestEnvironment createTestEnvironment(TestParameters Param, PrintWriter log) throws Exception {
log.println("Getting spreadsheet") ;
XSpreadsheets oSheets = xSheetDoc.getSheets() ;
XIndexAccess oIndexSheets = UnoRuntime.queryInterface(XIndexAccess.class, oSheets);
XSpreadsheet oSheet = (XSpreadsheet) AnyConverter.toObject(
new Type(XSpreadsheet.class),oIndexSheets.getByIndex(0));
log.println("Creating the Header") ;
insertIntoCell(1,0,"JAN",oSheet,"");
insertIntoCell(2,0,"FEB",oSheet,"");
insertIntoCell(3,0,"MAR",oSheet,"");
insertIntoCell(4,0,"APR",oSheet,"");
insertIntoCell(5,0,"MAI",oSheet,"");
insertIntoCell(6,0,"JUN",oSheet,"");
insertIntoCell(7,0,"JUL",oSheet,"");
insertIntoCell(8,0,"AUG",oSheet,"");
insertIntoCell(9,0,"SEP",oSheet,"");
insertIntoCell(10,0,"OCT",oSheet,"");
insertIntoCell(11,0,"NOV",oSheet,"");
insertIntoCell(12,0,"DEC",oSheet,"");
insertIntoCell(13,0,"SUM",oSheet,"");
log.println("Fill the lines");
insertIntoCell(0,1,"Smith",oSheet,"");
insertIntoCell(1,1,"42",oSheet,"V");
insertIntoCell(2,1,"58.9",oSheet,"V");
insertIntoCell(3,1,"-66.5",oSheet,"V");
insertIntoCell(4,1,"43.4",oSheet,"V");
insertIntoCell(5,1,"44.5",oSheet,"V");
insertIntoCell(6,1,"45.3",oSheet,"V");
insertIntoCell(7,1,"-67.3",oSheet,"V");
insertIntoCell(8,1,"30.5",oSheet,"V");
insertIntoCell(9,1,"23.2",oSheet,"V");
insertIntoCell(10,1,"-97.3",oSheet,"V");
insertIntoCell(11,1,"22.4",oSheet,"V");
insertIntoCell(12,1,"23.5",oSheet,"V");
insertIntoCell(13,1,"=SUM(B2:M2)",oSheet,"");
insertIntoCell(0,2,"Jones",oSheet,"");
insertIntoCell(1,2,"21",oSheet,"V");
insertIntoCell(2,2,"40.9",oSheet,"V");
insertIntoCell(3,2,"-57.5",oSheet,"V");
insertIntoCell(4,2,"-23.4",oSheet,"V");
insertIntoCell(5,2,"34.5",oSheet,"V");
insertIntoCell(6,2,"59.3",oSheet,"V");
insertIntoCell(7,2,"27.3",oSheet,"V");
insertIntoCell(8,2,"-38.5",oSheet,"V");
insertIntoCell(9,2,"43.2",oSheet,"V");
insertIntoCell(10,2,"57.3",oSheet,"V");
insertIntoCell(11,2,"25.4",oSheet,"V");
insertIntoCell(12,2,"28.5",oSheet,"V");
insertIntoCell(13,2,"=SUM(B3:M3)",oSheet,"");
insertIntoCell(0,3,"Brown",oSheet,"");
insertIntoCell(1,3,"31.45",oSheet,"V");
insertIntoCell(2,3,"-20.9",oSheet,"V");
insertIntoCell(3,3,"-117.5",oSheet,"V");
insertIntoCell(4,3,"23.4",oSheet,"V");
insertIntoCell(5,3,"-114.5",oSheet,"V");
insertIntoCell(6,3,"115.3",oSheet,"V");
insertIntoCell(7,3,"-171.3",oSheet,"V");
insertIntoCell(8,3,"89.5",oSheet,"V");
insertIntoCell(9,3,"41.2",oSheet,"V");
insertIntoCell(10,3,"71.3",oSheet,"V");
insertIntoCell(11,3,"25.4",oSheet,"V");
insertIntoCell(12,3,"38.5",oSheet,"V");
insertIntoCell(13,3,"=SUM(A4:L4)",oSheet,"");
// insert a chart
Rectangle oRect = new Rectangle(500, 3000, 25000, 11000);
XCellRange oRange = UnoRuntime.queryInterface(XCellRange.class, oSheet);
XCellRange myRange = oRange.getCellRangeByName("A1:N4");
XCellRangeAddressable oRangeAddr = UnoRuntime.queryInterface(XCellRangeAddressable.class, myRange);
CellRangeAddress myAddr = oRangeAddr.getRangeAddress();
CellRangeAddress[] oAddr = new CellRangeAddress[1];
oAddr[0] = myAddr;
XTableChartsSupplier oSupp = UnoRuntime.queryInterface(XTableChartsSupplier.class, oSheet);
log.println("Insert Chart");
XTableCharts oCharts = oSupp.getCharts();
oCharts.addNewByName("ScChartObj", oRect, oAddr, true, true);
log.println("creating a new environment for object");
XEnumerationAccess ea = UnoRuntime.queryInterface(XEnumerationAccess.class,oCharts);
XInterface oObj = ea.createEnumeration();
TestEnvironment tEnv = new TestEnvironment(oObj);
return tEnv;
}
/**
* Inserts a value or a formula in the cell of the spreasheet.
* @param CellX is the column index of the cell
* @param CellY is the row index of the cell
* @param theValue string representation of the value
* @param TT1 specify the spreadsheet, the interface
* <code>com.sun.star.sheet.XSpreadsheet</code>
* @param flag if it's equal to <code>'V'</code> then the method inserts
* a double-value in the cell else it inserts a formula in the cell
*/
public static void insertIntoCell(
int CellX, int CellY, String theValue, XSpreadsheet TT1, String flag)
throws com.sun.star.lang.IndexOutOfBoundsException {
XCell oCell = TT1.getCellByPosition(CellX, CellY);
if (flag.equals("V")) {
oCell.setValue(Float.parseFloat(theValue));
} else {
oCell.setFormula(theValue);
}
} // end of insertIntoCell
}
# -*- Mode: makefile-gmake; tab-width: 4; indent-tabs-mode: t -*-
#*************************************************************************
#
# 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/.
#
#*************************************************************************
$(eval $(call gb_CppunitTest_CppunitTest,sc_indexenumeration_tablechartsenumeration))
$(eval $(call gb_CppunitTest_use_external,sc_indexenumeration_tablechartsenumeration,boost_headers))
$(eval $(call gb_CppunitTest_add_exception_objects,sc_indexenumeration_tablechartsenumeration, \
sc/qa/extras/scindexenumeration_tablechartsenumeration \
))
$(eval $(call gb_CppunitTest_use_libraries,sc_indexenumeration_tablechartsenumeration, \
comphelper \
cppu \
cppuhelper \
sal \
subsequenttest \
test \
unotest \
))
$(eval $(call gb_CppunitTest_set_include,sc_indexenumeration_tablechartsenumeration,\
$$(INCLUDE) \
))
$(eval $(call gb_CppunitTest_use_sdk_api,sc_indexenumeration_tablechartsenumeration))
$(eval $(call gb_CppunitTest_use_ure,sc_indexenumeration_tablechartsenumeration))
$(eval $(call gb_CppunitTest_use_vcl,sc_indexenumeration_tablechartsenumeration))
$(eval $(call gb_CppunitTest_use_rdb,sc_indexenumeration_tablechartsenumeration,services))
$(eval $(call gb_CppunitTest_use_components,sc_indexenumeration_tablechartsenumeration))
$(eval $(call gb_CppunitTest_use_configuration,sc_indexenumeration_tablechartsenumeration))
# vim: set noet sw=4 ts=4:
......@@ -150,8 +150,9 @@ $(eval $(call gb_Module_add_subsequentcheck_targets,sc,\
CppunitTest_sc_indexenumeration_spreadsheetviewpanesenumeration \
CppunitTest_sc_indexenumeration_subtotalfieldsenumeration \
CppunitTest_sc_indexenumeration_tableautoformatenumeration \
CppunitTest_sc_indexenumeration_tableconditionalentryenumeration \
CppunitTest_sc_indexenumeration_tablechartsenumeration \
CppunitTest_sc_indexenumeration_tablecolumnsenumeration \
CppunitTest_sc_indexenumeration_tableconditionalentryenumeration \
CppunitTest_sc_indexenumeration_tablerowsenumeration \
CppunitTest_sc_indexenumeration_textfieldenumeration \
CppunitTest_sc_importdescriptorbaseobj \
......
/* -*- 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 <iostream>
#include <test/calc_unoapi_test.hxx>
#include <test/container/xenumeration.hxx>
#include <com/sun/star/awt/Rectangle.hpp>
#include <com/sun/star/container/XEnumerationAccess.hpp>
#include <com/sun/star/container/XIndexAccess.hpp>
#include <com/sun/star/lang/XComponent.hpp>
#include <com/sun/star/sheet/XCellRangeAddressable.hpp>
#include <com/sun/star/sheet/XSpreadsheet.hpp>
#include <com/sun/star/sheet/XSpreadsheetDocument.hpp>
#include <com/sun/star/sheet/XSpreadsheets.hpp>
#include <com/sun/star/table/CellRangeAddress.hpp>
#include <com/sun/star/table/XCellRange.hpp>
#include <com/sun/star/table/XTableCharts.hpp>
#include <com/sun/star/table/XTableChartsSupplier.hpp>
#include <com/sun/star/uno/XInterface.hpp>
#include <com/sun/star/uno/Sequence.hxx>
#include <com/sun/star/uno/Reference.hxx>
using namespace css;
using namespace css::uno;
namespace sc_apitest
{
class ScIndexEnumeration_TableChartsEnumeration : public CalcUnoApiTest,
public apitest::XEnumeration
{
public:
ScIndexEnumeration_TableChartsEnumeration();
virtual uno::Reference<uno::XInterface> init() override;
virtual void setUp() override;
virtual void tearDown() override;
CPPUNIT_TEST_SUITE(ScIndexEnumeration_TableChartsEnumeration);
// XEnumeration
CPPUNIT_TEST(testHasMoreElements);
CPPUNIT_TEST(testNextElement);
CPPUNIT_TEST_SUITE_END();
private:
uno::Reference<lang::XComponent> m_xComponent;
};
ScIndexEnumeration_TableChartsEnumeration::ScIndexEnumeration_TableChartsEnumeration()
: CalcUnoApiTest("/sc/qa/extras/testdocuments")
{
}
uno::Reference<uno::XInterface> ScIndexEnumeration_TableChartsEnumeration::init()
{
uno::Reference<sheet::XSpreadsheetDocument> xDoc(m_xComponent, 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::XIndexAccess> xIA(xSheets, uno::UNO_QUERY_THROW);
uno::Reference<sheet::XSpreadsheet> xSheet0(xIA->getByIndex(0), uno::UNO_QUERY_THROW);
xSheet0->getCellByPosition(1, 0)->setFormula("JAN");
xSheet0->getCellByPosition(2, 0)->setFormula("FEB");
xSheet0->getCellByPosition(3, 0)->setFormula("MAR");
xSheet0->getCellByPosition(4, 0)->setFormula("APR");
xSheet0->getCellByPosition(5, 0)->setFormula("MAY");
xSheet0->getCellByPosition(6, 0)->setFormula("JUN");
xSheet0->getCellByPosition(7, 0)->setFormula("JUL");
xSheet0->getCellByPosition(8, 0)->setFormula("AUG");
xSheet0->getCellByPosition(9, 0)->setFormula("SEP");
xSheet0->getCellByPosition(10, 0)->setFormula("OCT");
xSheet0->getCellByPosition(11, 0)->setFormula("NOV");
xSheet0->getCellByPosition(12, 0)->setFormula("DEC");
xSheet0->getCellByPosition(13, 0)->setFormula("SUM");
xSheet0->getCellByPosition(0, 1)->setFormula("Smith");
xSheet0->getCellByPosition(1, 1)->setValue(42);
xSheet0->getCellByPosition(2, 1)->setValue(58.9);
xSheet0->getCellByPosition(3, 1)->setValue(-66.5);
xSheet0->getCellByPosition(4, 1)->setValue(43.4);
xSheet0->getCellByPosition(5, 1)->setValue(44.5);
xSheet0->getCellByPosition(6, 1)->setValue(45.3);
xSheet0->getCellByPosition(7, 1)->setValue(-67.3);
xSheet0->getCellByPosition(8, 1)->setValue(30.5);
xSheet0->getCellByPosition(9, 1)->setValue(23.2);
xSheet0->getCellByPosition(10, 1)->setValue(-97.3);
xSheet0->getCellByPosition(11, 1)->setValue(22.4);
xSheet0->getCellByPosition(11, 1)->setValue(23.5);
xSheet0->getCellByPosition(13, 1)->setFormula("SUM(B2:M2");
xSheet0->getCellByPosition(0, 2)->setFormula("Jones");
xSheet0->getCellByPosition(1, 2)->setValue(21);
xSheet0->getCellByPosition(2, 2)->setValue(40.9);
xSheet0->getCellByPosition(3, 2)->setValue(-57.5);
xSheet0->getCellByPosition(4, 2)->setValue(-23.4);
xSheet0->getCellByPosition(5, 2)->setValue(34.5);
xSheet0->getCellByPosition(6, 2)->setValue(59.3);
xSheet0->getCellByPosition(7, 2)->setValue(27.3);
xSheet0->getCellByPosition(8, 2)->setValue(-38.5);
xSheet0->getCellByPosition(9, 2)->setValue(43.2);
xSheet0->getCellByPosition(10, 2)->setValue(57.3);
xSheet0->getCellByPosition(11, 2)->setValue(25.4);
xSheet0->getCellByPosition(11, 2)->setValue(28.5);
xSheet0->getCellByPosition(13, 2)->setFormula("SUM(B3:M3");
xSheet0->getCellByPosition(0, 3)->setFormula("Brown");
xSheet0->getCellByPosition(1, 3)->setValue(31.45);
xSheet0->getCellByPosition(2, 3)->setValue(-20.9);
xSheet0->getCellByPosition(3, 3)->setValue(-117.5);
xSheet0->getCellByPosition(4, 3)->setValue(23.4);
xSheet0->getCellByPosition(5, 3)->setValue(-114.5);
xSheet0->getCellByPosition(6, 3)->setValue(115.3);
xSheet0->getCellByPosition(7, 3)->setValue(-171.3);
xSheet0->getCellByPosition(8, 3)->setValue(89.5);
xSheet0->getCellByPosition(9, 3)->setValue(41.2);
xSheet0->getCellByPosition(10, 3)->setValue(71.3);
xSheet0->getCellByPosition(11, 3)->setValue(25.4);
xSheet0->getCellByPosition(11, 3)->setValue(38.5);
xSheet0->getCellByPosition(13, 3)->setFormula("SUM(A4:L4");
uno::Reference<table::XCellRange> xCellRange0(xSheet0, uno::UNO_QUERY_THROW);
uno::Reference<table::XCellRange> xCellRange1(xCellRange0->getCellRangeByName("A1:N4"),
uno::UNO_QUERY_THROW);
uno::Reference<sheet::XCellRangeAddressable> xCRA(xCellRange1, uno::UNO_QUERY_THROW);
uno::Sequence<table::CellRangeAddress> aCRA(1);
aCRA[0] = xCRA->getRangeAddress();
uno::Reference<table::XTableChartsSupplier> xTCS(xSheet0, uno::UNO_QUERY_THROW);
uno::Reference<table::XTableCharts> xTC = xTCS->getCharts();
xTC->addNewByName("ScChartObj", awt::Rectangle(500, 3000, 25000, 11000), aCRA, true, false);
uno::Reference<container::XEnumerationAccess> xEA(xTC, uno::UNO_QUERY_THROW);
return xEA->createEnumeration();
}
void ScIndexEnumeration_TableChartsEnumeration::setUp()
{
CalcUnoApiTest::setUp();
m_xComponent = loadFromDesktop("private:factory/scalc");
CPPUNIT_ASSERT_MESSAGE("no component", m_xComponent.is());
}
void ScIndexEnumeration_TableChartsEnumeration::tearDown()
{
closeDocument(m_xComponent);
CalcUnoApiTest::tearDown();
}
CPPUNIT_TEST_SUITE_REGISTRATION(ScIndexEnumeration_TableChartsEnumeration);
} // namespace sc_apitest
CPPUNIT_PLUGIN_IMPLEMENT();
/* vim:set shiftwidth=4 softtabstop=4 expandtab cinoptions=b1,g0,N-s cinkeys+=0=break: */
......@@ -16,4 +16,3 @@
# the License at http://www.apache.org/licenses/LICENSE-2.0 .
#
-o sc.ScIndexEnumeration_DataPilotItemsEnumeration
-o sc.ScIndexEnumeration_TableChartsEnumeration
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