diff options
author | Jens Carl <j.carl43@gmx.de> | 2017-11-08 21:15:09 +0000 |
---|---|---|
committer | Jens Carl <j.carl43@gmx.de> | 2017-11-09 09:32:21 +0100 |
commit | f1c97e9ff63cb6f120e618b3202260e0f8aefa0e (patch) | |
tree | 86f8615a49a91ab7042e8e0b98ab04a8000232f4 /test/source | |
parent | fb72ec9b6222c8a18445c078c0367e7d507720af (diff) |
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/44512
Tested-by: Jenkins <ci@libreoffice.org>
Reviewed-by: Jens Carl <j.carl43@gmx.de>
Diffstat (limited to 'test/source')
-rw-r--r-- | test/source/sheet/xsheetfilterableex.cxx | 61 | ||||
-rw-r--r-- | test/source/sheet/xsubtotalcalculatable.cxx | 2 |
2 files changed, 62 insertions, 1 deletions
diff --git a/test/source/sheet/xsheetfilterableex.cxx b/test/source/sheet/xsheetfilterableex.cxx new file mode 100644 index 000000000000..d3d23d7ce60f --- /dev/null +++ b/test/source/sheet/xsheetfilterableex.cxx @@ -0,0 +1,61 @@ +/* -*- 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: */ diff --git a/test/source/sheet/xsubtotalcalculatable.cxx b/test/source/sheet/xsubtotalcalculatable.cxx index 05071e95cb64..5bca1dc7498a 100644 --- a/test/source/sheet/xsubtotalcalculatable.cxx +++ b/test/source/sheet/xsubtotalcalculatable.cxx @@ -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"); |