tdf#45904 Move _Spreadsheet Java tests to C++
Change-Id: Ic540d06899def77313d6dc7e0a5241e1f9eeea54 Reviewed-on: https://gerrit.libreoffice.org/51491 Tested-by: Jenkins <ci@libreoffice.org> Reviewed-by: Jens Carl <j.carl43@gmx.de>
This commit is contained in:
35
include/test/sheet/spreadsheet.hxx
Normal file
35
include/test/sheet/spreadsheet.hxx
Normal file
@@ -0,0 +1,35 @@
|
||||
/* -*- 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_SHEET_SPREADSHEET_HXX
|
||||
#define INCLUDED_TEST_SHEET_SPREADSHEET_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 Spreadsheet
|
||||
{
|
||||
public:
|
||||
virtual css::uno::Reference<css::uno::XInterface> init() = 0;
|
||||
virtual css::uno::Reference<css::uno::XInterface> getXSpreadsheetDocument() = 0;
|
||||
|
||||
void testSpreadsheetProperties();
|
||||
|
||||
protected:
|
||||
~Spreadsheet() {}
|
||||
};
|
||||
}
|
||||
|
||||
#endif // INCLUDED_TEST_SHEET_SPREADSHEET_HXX
|
||||
|
||||
/* vim:set shiftwidth=4 softtabstop=4 expandtab cinoptions=b1,g0,N-s cinkeys+=0=break: */
|
@@ -565,7 +565,6 @@ $(eval $(call gb_Jar_add_sourcefiles,OOoRunner,\
|
||||
qadevOOo/tests/java/ifc/sdb/_XSQLErrorBroadcaster \
|
||||
qadevOOo/tests/java/ifc/sheet/_FunctionDescription \
|
||||
qadevOOo/tests/java/ifc/sheet/_SheetSortDescriptor \
|
||||
qadevOOo/tests/java/ifc/sheet/_Spreadsheet \
|
||||
qadevOOo/tests/java/ifc/sheet/_SpreadsheetDocument \
|
||||
qadevOOo/tests/java/ifc/sheet/_SpreadsheetDocumentSettings \
|
||||
qadevOOo/tests/java/ifc/sheet/_TableAutoFormatField \
|
||||
|
@@ -121,9 +121,6 @@
|
||||
"ScTableSheetObj";"com::sun::star::util::XIndent";"decrementIndent()"
|
||||
"ScTableSheetObj";"com::sun::star::util::XIndent";"incrementIndent()"
|
||||
"ScTableSheetObj";"com::sun::star::table::XAutoFormattable";"autoFormat()"
|
||||
"ScTableSheetObj";"com::sun::star::sheet::Spreadsheet";"IsVisible"
|
||||
"ScTableSheetObj";"com::sun::star::sheet::Spreadsheet";"PageStyle"
|
||||
"ScTableSheetObj";"com::sun::star::sheet::Spreadsheet";"AutomaticPrintArea#optional"
|
||||
"ScTableSheetObj";"com::sun::star::table::XTableChartsSupplier";"getCharts()"
|
||||
"ScTableSheetObj";"com::sun::star::sheet::XCellRangesQuery";"queryVisibleCells()"
|
||||
"ScTableSheetObj";"com::sun::star::sheet::XCellRangesQuery";"queryEmptyCells()"
|
||||
|
|
@@ -1,55 +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 ifc.sheet;
|
||||
|
||||
import lib.MultiPropertyTest;
|
||||
|
||||
/**
|
||||
* Testing <code>com.sun.star.sheet.Spreadsheet</code>
|
||||
* service properties :
|
||||
* <ul>
|
||||
* <li><code> IsVisible</code></li>
|
||||
* <li><code> PageStyle</code></li>
|
||||
* </ul> <p>
|
||||
* Properties testing is automated by <code>lib.MultiPropertyTest</code>.
|
||||
* @see com.sun.star.sheet.Spreadsheet
|
||||
*/
|
||||
public class _Spreadsheet extends MultiPropertyTest {
|
||||
|
||||
/**
|
||||
*This class is destined to custom test of property <code>PageStyle</code>.
|
||||
*/
|
||||
protected PropertyTester styleTester = new PropertyTester() {
|
||||
@Override
|
||||
protected Object getNewValue(String propName, Object oldValue) {
|
||||
String str = "Default";
|
||||
String str2= "Report";
|
||||
return str.equals(oldValue) ? str2 : str;
|
||||
}
|
||||
};
|
||||
|
||||
/**
|
||||
* Test property <code>PageStyle</code> using custom <code>PropertyTest</code>.
|
||||
*/
|
||||
public void _PageStyle() {
|
||||
testProperty("PageStyle", styleTester);
|
||||
}
|
||||
} // finish class _Spreadsheet
|
||||
|
||||
|
@@ -10,6 +10,7 @@
|
||||
#include <test/calc_unoapi_test.hxx>
|
||||
#include <test/sheet/scenario.hxx>
|
||||
#include <test/sheet/sheetcellrange.hxx>
|
||||
#include <test/sheet/spreadsheet.hxx>
|
||||
#include <test/sheet/xcellformatrangessupplier.hxx>
|
||||
#include <test/sheet/xcellrangeaddressable.hxx>
|
||||
#include <test/sheet/xcellseries.hxx>
|
||||
@@ -45,6 +46,7 @@ namespace sc_apitest
|
||||
|
||||
class ScTableSheetObj : public CalcUnoApiTest, public apitest::Scenario,
|
||||
public apitest::SheetCellRange,
|
||||
public apitest::Spreadsheet,
|
||||
public apitest::XCellFormatRangesSupplier,
|
||||
public apitest::XCellRangeAddressable,
|
||||
public apitest::XCellSeries,
|
||||
@@ -76,6 +78,7 @@ public:
|
||||
virtual OUString getFileURL() override;
|
||||
|
||||
virtual uno::Reference< uno::XInterface > init() override;
|
||||
virtual uno::Reference< uno::XInterface > getXSpreadsheetDocument() override;
|
||||
virtual uno::Reference< uno::XInterface > getXSpreadsheet() override;
|
||||
virtual uno::Reference< uno::XInterface > getScenarioSpreadsheet() override;
|
||||
|
||||
@@ -87,6 +90,9 @@ public:
|
||||
// SheetCellRange
|
||||
CPPUNIT_TEST(testSheetCellRangeProperties);
|
||||
|
||||
// Spreadsheet
|
||||
CPPUNIT_TEST(testSpreadsheetProperties);
|
||||
|
||||
// XCellFormatRangesSupplier
|
||||
CPPUNIT_TEST(testGetCellFormatRanges);
|
||||
|
||||
@@ -211,6 +217,13 @@ uno::Reference< uno::XInterface > ScTableSheetObj::init()
|
||||
return xSheet;
|
||||
}
|
||||
|
||||
uno::Reference<uno::XInterface> ScTableSheetObj::getXSpreadsheetDocument()
|
||||
{
|
||||
uno::Reference<sheet::XSpreadsheetDocument> xDoc(mxComponent, UNO_QUERY_THROW);
|
||||
CPPUNIT_ASSERT_MESSAGE("no calc document", xDoc.is());
|
||||
return xDoc;
|
||||
}
|
||||
|
||||
uno::Reference<uno::XInterface> ScTableSheetObj::getScenarioSpreadsheet()
|
||||
{
|
||||
uno::Reference<sheet::XSpreadsheetDocument> xDoc(mxComponent, UNO_QUERY_THROW);
|
||||
|
@@ -59,6 +59,7 @@ $(eval $(call gb_Library_add_exception_objects,subsequenttest,\
|
||||
test/source/sheet/sheetcellranges \
|
||||
test/source/sheet/sheetfilterdescriptor \
|
||||
test/source/sheet/sheetlink \
|
||||
test/source/sheet/spreadsheet \
|
||||
test/source/sheet/tableautoformat \
|
||||
test/source/sheet/tablevalidation \
|
||||
test/source/sheet/xarealink \
|
||||
|
90
test/source/sheet/spreadsheet.cxx
Normal file
90
test/source/sheet/spreadsheet.cxx
Normal file
@@ -0,0 +1,90 @@
|
||||
/* -*- 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/sheet/spreadsheet.hxx>
|
||||
#include <test/unoapi_property_testers.hxx>
|
||||
|
||||
#include <com/sun/star/beans/XPropertySet.hpp>
|
||||
#include <com/sun/star/container/XIndexAccess.hpp>
|
||||
#include <com/sun/star/container/XNameContainer.hpp>
|
||||
#include <com/sun/star/lang/XMultiServiceFactory.hpp>
|
||||
#include <com/sun/star/sheet/XConditionalFormats.hpp>
|
||||
#include <com/sun/star/sheet/XSpreadsheetDocument.hpp>
|
||||
#include <com/sun/star/sheet/XSpreadsheet.hpp>
|
||||
#include <com/sun/star/text/WritingMode2.hpp>
|
||||
#include <com/sun/star/util/Color.hpp>
|
||||
#include <com/sun/star/uno/Any.hxx>
|
||||
#include <com/sun/star/uno/Reference.hxx>
|
||||
|
||||
#include <cppunit/extensions/HelperMacros.h>
|
||||
|
||||
using namespace com::sun::star;
|
||||
using namespace com::sun::star::uno;
|
||||
|
||||
namespace apitest
|
||||
{
|
||||
void Spreadsheet::testSpreadsheetProperties()
|
||||
{
|
||||
uno::Reference<beans::XPropertySet> xSpreadsheet(init(), UNO_QUERY_THROW);
|
||||
OUString propName;
|
||||
uno::Any aNewValue;
|
||||
|
||||
propName = "IsVisible";
|
||||
testBooleanProperty(xSpreadsheet, propName);
|
||||
|
||||
propName = "PageStyle";
|
||||
testStringProperty(xSpreadsheet, propName, "Report");
|
||||
|
||||
propName = "TableLayout";
|
||||
testShortProperty(xSpreadsheet, propName, text::WritingMode2::RL_TB);
|
||||
|
||||
propName = "AutomaticPrintArea";
|
||||
testBooleanProperty(xSpreadsheet, propName);
|
||||
|
||||
propName = "TabColor";
|
||||
util::Color aColorGet;
|
||||
util::Color aColorSet;
|
||||
CPPUNIT_ASSERT_MESSAGE("Unable to get PropertyValue: TabColor",
|
||||
xSpreadsheet->getPropertyValue(propName) >>= aColorGet);
|
||||
|
||||
aNewValue <<= util::Color(42);
|
||||
xSpreadsheet->setPropertyValue(propName, aNewValue);
|
||||
CPPUNIT_ASSERT(xSpreadsheet->getPropertyValue(propName) >>= aColorSet);
|
||||
CPPUNIT_ASSERT_EQUAL_MESSAGE("Unable to set PropertyValue: TabColor", util::Color(42),
|
||||
aColorSet);
|
||||
|
||||
propName = "ConditionalFormats";
|
||||
uno::Reference<sheet::XConditionalFormats> xConditionalFormatsGet;
|
||||
uno::Reference<sheet::XConditionalFormats> xConditionalFormatsSet;
|
||||
CPPUNIT_ASSERT_MESSAGE("Unable to get PropertyValue: ConditionalFormats",
|
||||
xSpreadsheet->getPropertyValue(propName) >>= xConditionalFormatsGet);
|
||||
|
||||
uno::Reference<sheet::XSpreadsheetDocument> xDoc(getXSpreadsheetDocument(), UNO_QUERY_THROW);
|
||||
uno::Reference<container::XIndexAccess> xIA(xDoc->getSheets(), UNO_QUERY_THROW);
|
||||
uno::Reference<sheet::XSpreadsheet> xSheet(xIA->getByIndex(0), UNO_QUERY_THROW);
|
||||
|
||||
uno::Reference<lang::XMultiServiceFactory> xMSF(xDoc, UNO_QUERY_THROW);
|
||||
uno::Reference<container::XNameContainer> xRanges(
|
||||
xMSF->createInstance("com.sun.star.sheet.SheetCellRanges"), UNO_QUERY_THROW);
|
||||
uno::Reference<sheet::XSheetCellRanges> xSheetCellRanges(xRanges, UNO_QUERY_THROW);
|
||||
|
||||
uno::Any xCellRange;
|
||||
xCellRange <<= xSheet->getCellRangeByName("C1:D4");
|
||||
xRanges->insertByName("Range1", xCellRange);
|
||||
xConditionalFormatsGet->createByRange(xSheetCellRanges);
|
||||
|
||||
aNewValue <<= xConditionalFormatsGet;
|
||||
xSpreadsheet->setPropertyValue(propName, aNewValue);
|
||||
CPPUNIT_ASSERT(xSpreadsheet->getPropertyValue(propName) >>= xConditionalFormatsSet);
|
||||
CPPUNIT_ASSERT_EQUAL_MESSAGE("Unable to set PropertyValue: ConditionalFormats", sal_Int32(1),
|
||||
xConditionalFormatsSet->getLength());
|
||||
}
|
||||
}
|
||||
|
||||
/* vim:set shiftwidth=4 softtabstop=4 expandtab cinoptions=b1,g0,N-s cinkeys+=0=break: */
|
Reference in New Issue
Block a user