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

tdf#45904 Move Java _XSheetFilterableEx tests to C++

Convert the Java _XSheetFilterableEx tests to C++ and make changes to
the XSubTotalCalculatable::::testApplyRemoveSubTotals(), because
XSheetFilterableEx::testCreateFilterDescriptorByObject() has to work
with the same sheet.

Change-Id: I89c11bc8f10ec8d2ff4b170aeb9df5a00ca98133
Reviewed-on: https://gerrit.libreoffice.org/44512Tested-by: 's avatarJenkins <ci@libreoffice.org>
Reviewed-by: 's avatarJens Carl <j.carl43@gmx.de>
üst fb72ec9b
/* -*- 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_XSHEETFILTERABLEEX_HXX
#define INCLUDED_TEST_SHEET_XSHEETFILTERABLEEX_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 XSheetFilterableEx
{
public:
virtual css::uno::Reference<css::uno::XInterface> init() = 0;
virtual css::uno::Reference<css::uno::XInterface> getXSpreadsheet() = 0;
void testCreateFilterDescriptorByObject();
protected:
~XSheetFilterableEx() {}
};
}
#endif // INCLUDED_TEST_SHEET_XSHEETFILTERABLEEX_HXX
/* vim:set shiftwidth=4 softtabstop=4 expandtab cinoptions=b1,g0,N-s cinkeys+=0=break: */
......@@ -618,7 +618,6 @@ $(eval $(call gb_Jar_add_sourcefiles,OOoRunner,\
qadevOOo/tests/java/ifc/sheet/_XSheetAnnotationsSupplier \
qadevOOo/tests/java/ifc/sheet/_XSheetAuditing \
qadevOOo/tests/java/ifc/sheet/_XSheetCellCursor \
qadevOOo/tests/java/ifc/sheet/_XSheetFilterableEx \
qadevOOo/tests/java/ifc/sheet/_XSpreadsheetView \
qadevOOo/tests/java/ifc/style/_CharacterProperties \
qadevOOo/tests/java/ifc/style/_CharacterPropertiesAsian \
......
......@@ -117,7 +117,6 @@
"ScCellCursorObj";"com::sun::star::style::CharacterPropertiesComplex";"CharLocaleComplex"
"ScCellCursorObj";"com::sun::star::sheet::XFormulaQuery";"queryDependents()"
"ScCellCursorObj";"com::sun::star::sheet::XFormulaQuery";"queryPrecedents()"
"ScCellCursorObj";"com::sun::star::sheet::XSheetFilterableEx";"createFilterDescriptorByObject()"
"ScCellCursorObj";"com::sun::star::sheet::XArrayFormulaRange";"getArrayFormula()"
"ScCellCursorObj";"com::sun::star::sheet::XArrayFormulaRange";"setArrayFormula()"
"ScCellCursorObj";"com::sun::star::sheet::XCellRangeFormula#optional";"getFormulaArray()"
......
......@@ -112,7 +112,6 @@
"ScCellRangeObj";"com::sun::star::style::CharacterPropertiesComplex";"CharLocaleComplex"
"ScCellRangeObj";"com::sun::star::sheet::XFormulaQuery";"queryDependents()"
"ScCellRangeObj";"com::sun::star::sheet::XFormulaQuery";"queryPrecedents()"
"ScCellRangeObj";"com::sun::star::sheet::XSheetFilterableEx";"createFilterDescriptorByObject()"
"ScCellRangeObj";"com::sun::star::sheet::XArrayFormulaRange";"getArrayFormula()"
"ScCellRangeObj";"com::sun::star::sheet::XArrayFormulaRange";"setArrayFormula()"
"ScCellRangeObj";"com::sun::star::sheet::XCellRangeFormula#optional";"getFormulaArray()"
......
......@@ -124,7 +124,6 @@
"ScTableSheetObj";"com::sun::star::util::XProtectable";"isProtected()"
"ScTableSheetObj";"com::sun::star::sheet::XFormulaQuery";"queryDependents()"
"ScTableSheetObj";"com::sun::star::sheet::XFormulaQuery";"queryPrecedents()"
"ScTableSheetObj";"com::sun::star::sheet::XSheetFilterableEx";"createFilterDescriptorByObject()"
"ScTableSheetObj";"com::sun::star::sheet::XArrayFormulaRange";"getArrayFormula()"
"ScTableSheetObj";"com::sun::star::sheet::XArrayFormulaRange";"setArrayFormula()"
"ScTableSheetObj";"com::sun::star::sheet::XCellRangeFormula#optional";"getFormulaArray()"
......
/*
* 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 com.sun.star.sheet.TableFilterField;
import com.sun.star.sheet.XSheetFilterDescriptor;
import com.sun.star.sheet.XSheetFilterable;
import com.sun.star.sheet.XSheetFilterableEx;
import com.sun.star.uno.UnoRuntime;
/**
* Interface test for XSheetFilterableEx
*
* methods:
*
* createFilterDescriptorByObject
*
*/
public class _XSheetFilterableEx extends MultiMethodTest {
public XSheetFilterableEx oObj = null;
/**
* queries a XSheetFilterable from the parent Object and then creates
* a XSheetFilterDescriptor with it.
* Returns OK if the Descriptor isn't null and checkFilterDescriptor returns true
*/
public void _createFilterDescriptorByObject() {
boolean res = true;
Object parent = tEnv.getTestObject();
XSheetFilterable aFilterable = UnoRuntime.queryInterface(
XSheetFilterable.class, parent);
XSheetFilterDescriptor desc = oObj.createFilterDescriptorByObject(
aFilterable);
if (desc != null) {
res &= checkFilterDescriptor(desc);
} else {
log.println("gained XSheetFilterDescriptor is null");
res &= false;
}
tRes.tested("createFilterDescriptorByObject()",res);
}
/**
* returns true if the Method getFilterFields() returns a non empty array
* and all Fields can be gained without exception
*/
public boolean checkFilterDescriptor(XSheetFilterDescriptor desc) {
TableFilterField[] fields = desc.getFilterFields();
boolean res = true;
if (fields.length == 0) {
log.println("The gained Descriptor is empty");
res &= false;
} else {
log.println("Found "+fields.length+" TableFields");
}
for (int k = 0; k < fields.length; k++) {
log.println("StringValue(" + k + "): " + fields[k].StringValue);
log.println("IsNumeric(" + k + "): " + fields[k].IsNumeric);
log.println("NumericValue(" + k + "): " + fields[k].NumericValue);
log.println("Field(" + k + "): " + fields[k].Field);
log.println("Connection(" + k + "): " + fields[k].Connection);
log.println("Operator(" + k + "): " + fields[k].Operator);
}
return res;
}
}
......@@ -11,6 +11,7 @@
#include <test/sheet/xcellseries.hxx>
#include <test/sheet/xsheetcellrange.hxx>
#include <test/sheet/xsheetfilterable.hxx>
#include <test/sheet/xsheetfilterableex.hxx>
#include <test/sheet/xsheetoperation.hxx>
#include <test/sheet/xsubtotalcalculatable.hxx>
#include <test/sheet/xusedareacursor.hxx>
......@@ -25,11 +26,12 @@ using namespace css::uno;
namespace sc_apitest {
#define NUMBER_OF_TESTS 12
#define NUMBER_OF_TESTS 13
class ScCellCursorObj : public CalcUnoApiTest, public apitest::XCellSeries,
public apitest::XSheetCellRange,
public apitest::XSheetFilterable,
public apitest::XSheetFilterableEx,
public apitest::XSheetOperation,
public apitest::XSubTotalCalculatable,
public apitest::XUsedAreaCursor,
......@@ -60,6 +62,9 @@ public:
CPPUNIT_TEST(testCreateFilterDescriptor);
CPPUNIT_TEST(testFilter);
// XSheetFilterableEx
CPPUNIT_TEST(testCreateFilterDescriptorByObject);
// XSheetOperation
CPPUNIT_TEST(testComputeFunction);
CPPUNIT_TEST(testClearContents);
......@@ -91,14 +96,17 @@ uno::Reference< uno::XInterface > ScCellCursorObj::init()
{
OUString aFileURL;
createFileURL("ScCellCursorObj.ods", aFileURL);
if(!mxComponent.is())
if (!mxComponent.is())
mxComponent = loadFromDesktop(aFileURL, "com.sun.star.sheet.SpreadsheetDocument");
CPPUNIT_ASSERT(mxComponent.is());
CPPUNIT_ASSERT_MESSAGE("no calc document", mxComponent.is());
uno::Reference< sheet::XSpreadsheetDocument > xDoc(mxComponent, UNO_QUERY_THROW);
uno::Reference< container::XIndexAccess > xIndex (xDoc->getSheets(), UNO_QUERY_THROW);
uno::Reference< sheet::XSpreadsheet > xSheet( xIndex->getByIndex(0), UNO_QUERY_THROW);
uno::Reference< table::XCellCursor > xCellCursor( xSheet->createCursor(), UNO_QUERY_THROW);
uno::Reference<sheet::XSpreadsheetDocument> xDoc(mxComponent, UNO_QUERY_THROW);
uno::Reference<container::XIndexAccess> xIndex (xDoc->getSheets(), UNO_QUERY_THROW);
uno::Reference<sheet::XSpreadsheet> xSheet(xIndex->getByIndex(0), UNO_QUERY_THROW);
uno::Reference<table::XCellRange> xCellRange = xSheet->getCellRangeByName("$A$1:$D$4");
uno::Reference<sheet::XSheetCellRange> xSheetCellRange(xCellRange, UNO_QUERY_THROW);
uno::Reference<table::XCellCursor> xCellCursor(xSheet->createCursorByRange(xSheetCellRange), UNO_QUERY_THROW);
return xCellCursor;
}
......@@ -107,9 +115,9 @@ uno::Reference< uno::XInterface > ScCellCursorObj::getXSpreadsheet()
{
OUString aFileURL;
createFileURL("ScCellCursorObj.ods", aFileURL);
if(!mxComponent.is())
if (!mxComponent.is())
mxComponent = loadFromDesktop(aFileURL, "com.sun.star.sheet.SpreadsheetDocument");
CPPUNIT_ASSERT(mxComponent.is());
CPPUNIT_ASSERT_MESSAGE("no calc document", mxComponent.is());
uno::Reference< sheet::XSpreadsheetDocument > xDoc(mxComponent, UNO_QUERY_THROW);
uno::Reference< container::XIndexAccess > xIndex (xDoc->getSheets(), UNO_QUERY_THROW);
......
......@@ -14,6 +14,7 @@
#include <test/sheet/xcellseries.hxx>
#include <test/sheet/xsheetcellrange.hxx>
#include <test/sheet/xsheetfilterable.hxx>
#include <test/sheet/xsheetfilterableex.hxx>
#include <test/sheet/xsheetoperation.hxx>
#include <test/sheet/xsubtotalcalculatable.hxx>
#include <test/sheet/xuniquecellformatrangessupplier.hxx>
......@@ -36,12 +37,13 @@
#include <com/sun/star/table/XTableRows.hpp>
#include <com/sun/star/uno/Reference.hxx>
#include <com/sun/star/uno/Sequence.hxx>
using namespace css;
using namespace css::uno;
namespace sc_apitest {
#define NUMBER_OF_TESTS 25
#define NUMBER_OF_TESTS 26
class ScCellRangeObj : public CalcUnoApiTest, public apitest::CellProperties,
public apitest::XCellRangeData,
......@@ -51,6 +53,7 @@ class ScCellRangeObj : public CalcUnoApiTest, public apitest::CellProperties,
public apitest::XSearchable,
public apitest::XSheetCellRange,
public apitest::XSheetFilterable,
public apitest::XSheetFilterableEx,
public apitest::XSheetOperation,
public apitest::XSubTotalCalculatable,
public apitest::XUniqueCellFormatRangesSupplier
......@@ -88,6 +91,9 @@ public:
// XSheetCellRange
CPPUNIT_TEST(testGetSpreadsheet);
// XSheetFilterableEx
CPPUNIT_TEST(testCreateFilterDescriptorByObject);
// XReplaceable
CPPUNIT_TEST(testReplaceAll);
CPPUNIT_TEST(testCreateReplaceDescriptor);
......
......@@ -12,6 +12,7 @@
#include <test/sheet/xprintareas.hxx>
#include <test/sheet/xsheetcellrange.hxx>
#include <test/sheet/xsheetfilterable.hxx>
#include <test/sheet/xsheetfilterableex.hxx>
#include <test/sheet/xsheetlinkable.hxx>
#include <test/sheet/xsheetoperation.hxx>
#include <test/sheet/xsheetpagebreak.hxx>
......@@ -30,7 +31,7 @@ using namespace css::uno;
namespace sc_apitest
{
#define NUMBER_OF_TESTS 23
#define NUMBER_OF_TESTS 24
class ScTableSheetObj : public CalcUnoApiTest, public apitest::XCellSeries,
public apitest::XPrintAreas,
......@@ -38,6 +39,7 @@ class ScTableSheetObj : public CalcUnoApiTest, public apitest::XCellSeries,
public apitest::XSearchable,
public apitest::XSheetCellRange,
public apitest::XSheetFilterable,
public apitest::XSheetFilterableEx,
public apitest::XSheetLinkable,
public apitest::XSheetOperation,
public apitest::XSheetPageBreak,
......@@ -82,6 +84,9 @@ public:
CPPUNIT_TEST(testCreateFilterDescriptor);
CPPUNIT_TEST(testFilter);
// XSheetFilterableEx
CPPUNIT_TEST(testCreateFilterDescriptorByObject);
// XSheetLinkable
CPPUNIT_TEST(testSheetLinkable);
......@@ -126,9 +131,8 @@ ScTableSheetObj::ScTableSheetObj():
uno::Reference< uno::XInterface > ScTableSheetObj::init()
{
//OUString aFileURL;
createFileURL("ScTableSheetObj.ods", maFileURL);
if(!mxComponent.is())
if (!mxComponent.is())
mxComponent = loadFromDesktop(maFileURL, "com.sun.star.sheet.SpreadsheetDocument");
CPPUNIT_ASSERT(mxComponent.is());
......@@ -141,15 +145,14 @@ uno::Reference< uno::XInterface > ScTableSheetObj::init()
uno::Reference< uno::XInterface > ScTableSheetObj::getXSpreadsheet()
{
OUString aFileURL;
createFileURL("ScTableSheetObj.ods", aFileURL);
if(!mxComponent.is())
mxComponent = loadFromDesktop(aFileURL, "com.sun.star.sheet.SpreadsheetDocument");
createFileURL("ScTableSheetObj.ods", maFileURL);
if (!mxComponent.is())
mxComponent = loadFromDesktop(maFileURL, "com.sun.star.sheet.SpreadsheetDocument");
CPPUNIT_ASSERT(mxComponent.is());
uno::Reference< sheet::XSpreadsheetDocument > xDoc(mxComponent, UNO_QUERY_THROW);
uno::Reference< container::XIndexAccess > xIndex (xDoc->getSheets(), UNO_QUERY_THROW);
uno::Reference< sheet::XSpreadsheet > xSheet( xIndex->getByIndex(1), UNO_QUERY_THROW);
uno::Reference< sheet::XSpreadsheet > xSheet( xIndex->getByIndex(0), UNO_QUERY_THROW);
return xSheet;
}
......
......@@ -77,6 +77,7 @@ $(eval $(call gb_Library_add_exception_objects,subsequenttest,\
test/source/sheet/xsheetconditionalentry \
test/source/sheet/xsheetcondition \
test/source/sheet/xsheetfilterable \
test/source/sheet/xsheetfilterableex \
test/source/sheet/xsheetfilterdescriptor \
test/source/sheet/xsheetoutline \
test/source/sheet/xsheetlinkable \
......
/* -*- 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/xsheetfilterableex.hxx>
#include <com/sun/star/sheet/FilterConnection.hpp>
#include <com/sun/star/sheet/FilterOperator.hpp>
#include <com/sun/star/sheet/TableFilterField.hpp>
#include <com/sun/star/sheet/XSheetFilterDescriptor.hpp>
#include <com/sun/star/sheet/XSheetFilterable.hpp>
#include <com/sun/star/sheet/XSheetFilterableEx.hpp>
#include <com/sun/star/sheet/XSpreadsheet.hpp>
#include <com/sun/star/table/XCellCursor.hpp>
#include <com/sun/star/uno/Reference.hxx>
#include <com/sun/star/uno/Sequence.hxx>
#include <cppunit/extensions/HelperMacros.h>
using namespace css;
using namespace css::uno;
namespace apitest
{
void XSheetFilterableEx::testCreateFilterDescriptorByObject()
{
uno::Reference<sheet::XSheetFilterableEx> xSFEx(init(), UNO_QUERY_THROW);
uno::Reference<sheet::XSheetFilterable> xSF(getXSpreadsheet(), UNO_QUERY_THROW);
uno::Reference<sheet::XSheetFilterDescriptor> xSFD = xSFEx->createFilterDescriptorByObject(xSF);
CPPUNIT_ASSERT_MESSAGE("no XSheetFilterDescriptor", xSFD.is());
uno::Sequence<sheet::TableFilterField> xTFF = xSFD->getFilterFields();
CPPUNIT_ASSERT_MESSAGE("The gained XSheetFilterDescriptor is empty", xTFF.getLength() != 0);
for (const auto& field : xTFF)
{
// we don't care about the actual value, just that we can access the fields
CPPUNIT_ASSERT_MESSAGE("Unable to retrieve field: StringValue",
!field.StringValue.isEmpty());
CPPUNIT_ASSERT_MESSAGE("Unable to retrieve field: IsNumeric",
!field.IsNumeric || field.IsNumeric);
CPPUNIT_ASSERT_MESSAGE("Unable to retrieve field: NumericValue",
field.NumericValue != 0.0 || field.NumericValue == 0.0);
CPPUNIT_ASSERT_MESSAGE("Unable to retrieve field: Field",
field.Field != 0 || field.Field == 0);
CPPUNIT_ASSERT_MESSAGE("Unable to retrieve field: Connection",
field.Connection == sheet::FilterConnection_AND
|| field.Connection == sheet::FilterConnection_OR);
CPPUNIT_ASSERT_MESSAGE("Unable to retrieve field: Operator",
field.Operator != sheet::FilterOperator_EMPTY);
}
}
}
/* vim:set shiftwidth=4 softtabstop=4 expandtab cinoptions=b1,g0,N-s cinkeys+=0=break: */
......@@ -48,7 +48,7 @@ void XSubTotalCalculatable::testApplyRemoveSubTotals()
xCols.realloc(1);
xCols[0].Column = 0;
xCols[0].Function = sheet::GeneralFunction_SUM;
xSTD->addNew(xCols, 0);
xSTD->addNew(xCols, 1);
xSheet->getCellByPosition(0, 0)->setFormula("first");
xSheet->getCellByPosition(1, 0)->setFormula("second");
......
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