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

tdf#45904 Move _XDataPilotField Java test to C++

Change-Id: I5ba1733a8e675048366651aa5f3affc9c249622c
Reviewed-on: https://gerrit.libreoffice.org/46066Tested-by: 's avatarJenkins <ci@libreoffice.org>
Reviewed-by: 's avatarJens Carl <j.carl43@gmx.de>
üst 87d636a1
/* -*- 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_XDATAPILOTFIELD_HXX
#define INCLUDED_TEST_SHEET_XDATAPILOTFIELD_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 XDataPilotField
{
public:
virtual css::uno::Reference<css::uno::XInterface> init() = 0;
void testGetItems();
protected:
~XDataPilotField() {}
};
}
#endif // INCLUDED_TEST_SHEET_XDATAPILOTFIELD_HXX
/* vim:set shiftwidth=4 softtabstop=4 expandtab cinoptions=b1,g0,N-s cinkeys+=0=break: */
...@@ -596,7 +596,6 @@ $(eval $(call gb_Jar_add_sourcefiles,OOoRunner,\ ...@@ -596,7 +596,6 @@ $(eval $(call gb_Jar_add_sourcefiles,OOoRunner,\
qadevOOo/tests/java/ifc/sheet/_XConsolidatable \ qadevOOo/tests/java/ifc/sheet/_XConsolidatable \
qadevOOo/tests/java/ifc/sheet/_XConsolidationDescriptor \ qadevOOo/tests/java/ifc/sheet/_XConsolidationDescriptor \
qadevOOo/tests/java/ifc/sheet/_XDatabaseRanges \ qadevOOo/tests/java/ifc/sheet/_XDatabaseRanges \
qadevOOo/tests/java/ifc/sheet/_XDataPilotField \
qadevOOo/tests/java/ifc/sheet/_XDDELink \ qadevOOo/tests/java/ifc/sheet/_XDDELink \
qadevOOo/tests/java/ifc/sheet/_XDocumentAuditing \ qadevOOo/tests/java/ifc/sheet/_XDocumentAuditing \
qadevOOo/tests/java/ifc/sheet/_XEnhancedMouseClickBroadcaster \ qadevOOo/tests/java/ifc/sheet/_XEnhancedMouseClickBroadcaster \
......
...@@ -7,4 +7,3 @@ ...@@ -7,4 +7,3 @@
"ScDataPilotFieldObj";"com::sun::star::beans::XPropertySet";"removePropertyChangeListener()" "ScDataPilotFieldObj";"com::sun::star::beans::XPropertySet";"removePropertyChangeListener()"
"ScDataPilotFieldObj";"com::sun::star::beans::XPropertySet";"addVetoableChangeListener()" "ScDataPilotFieldObj";"com::sun::star::beans::XPropertySet";"addVetoableChangeListener()"
"ScDataPilotFieldObj";"com::sun::star::beans::XPropertySet";"removeVetoableChangeListener()" "ScDataPilotFieldObj";"com::sun::star::beans::XPropertySet";"removeVetoableChangeListener()"
"ScDataPilotFieldObj";"com::sun::star::sheet::XDataPilotField#optional";"getItems()"
/*
* 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 com.sun.star.container.XIndexAccess;
import com.sun.star.sheet.XDataPilotField;
import lib.MultiMethodTest;
public class _XDataPilotField extends MultiMethodTest {
public XDataPilotField oObj = null;
public void _getItems() {
XIndexAccess xIA = oObj.getItems();
tRes.tested("getItems()", checkIndexAccess(xIA));
}
/**
* calls the method getCount at the IndexAccess, returns true is it is >0
* and getByIndex() doesn't throw an exception for Indexes between 0 and count
*/
protected boolean checkIndexAccess(XIndexAccess xIA) {
boolean res = true;
int count = xIA.getCount();
log.println("Found " + count + " Elements");
res &= (count > 0);
for (int k = 0; k < count; k++) {
try {
Object element = xIA.getByIndex(k);
log.println("Element " + k + " = " + element);
} catch (com.sun.star.lang.IndexOutOfBoundsException e) {
log.println("Unexpected Exception while getting by Index (" + k +
")" + e.getMessage());
res &= false;
} catch (com.sun.star.lang.WrappedTargetException e) {
log.println("Unexpected Exception while getting by Index (" + k +
")" + e.getMessage());
res &= false;
}
}
return res;
}
}
\ No newline at end of file
...@@ -8,8 +8,10 @@ ...@@ -8,8 +8,10 @@
*/ */
#include <test/calc_unoapi_test.hxx> #include <test/calc_unoapi_test.hxx>
#include <test/sheet/xdatapilotfieldgrouping.hxx>
#include <test/sheet/datapilotfield.hxx> #include <test/sheet/datapilotfield.hxx>
#include <test/sheet/xdatapilotfield.hxx>
#include <test/sheet/xdatapilotfieldgrouping.hxx>
#include <com/sun/star/sheet/XSpreadsheetDocument.hpp> #include <com/sun/star/sheet/XSpreadsheetDocument.hpp>
#include <com/sun/star/sheet/XSpreadsheet.hpp> #include <com/sun/star/sheet/XSpreadsheet.hpp>
...@@ -22,10 +24,11 @@ using namespace css::uno; ...@@ -22,10 +24,11 @@ using namespace css::uno;
namespace sc_apitest { namespace sc_apitest {
#define NUMBER_OF_TESTS 6 #define NUMBER_OF_TESTS 7
class ScDataPilotFieldObj : public CalcUnoApiTest, public apitest::XDataPilotFieldGrouping, class ScDataPilotFieldObj : public CalcUnoApiTest, public apitest::DataPilotField,
public apitest::DataPilotField public apitest::XDataPilotField,
public apitest::XDataPilotFieldGrouping
{ {
public: public:
virtual void setUp() override; virtual void setUp() override;
...@@ -35,15 +38,24 @@ public: ...@@ -35,15 +38,24 @@ public:
ScDataPilotFieldObj(); ScDataPilotFieldObj();
CPPUNIT_TEST_SUITE(ScDataPilotFieldObj); CPPUNIT_TEST_SUITE(ScDataPilotFieldObj);
// DataPilotField
CPPUNIT_TEST(testSortInfo); CPPUNIT_TEST(testSortInfo);
CPPUNIT_TEST(testLayoutInfo); CPPUNIT_TEST(testLayoutInfo);
CPPUNIT_TEST(testAutoShowInfo); CPPUNIT_TEST(testAutoShowInfo);
CPPUNIT_TEST(testReference); CPPUNIT_TEST(testReference);
CPPUNIT_TEST(testIsGroupField); CPPUNIT_TEST(testIsGroupField);
// XDataPilotField
CPPUNIT_TEST(testGetItems);
// XDataPilotFieldGrouping
CPPUNIT_TEST(testCreateNameGroup); CPPUNIT_TEST(testCreateNameGroup);
// see fdo# // see fdo#
//CPPUNIT_TEST(testCreateDateGroup); //CPPUNIT_TEST(testCreateDateGroup);
CPPUNIT_TEST_SUITE_END(); CPPUNIT_TEST_SUITE_END();
private: private:
static sal_Int32 nTest; static sal_Int32 nTest;
static uno::Reference< lang::XComponent > mxComponent; static uno::Reference< lang::XComponent > mxComponent;
......
...@@ -57,6 +57,7 @@ $(eval $(call gb_Library_add_exception_objects,subsequenttest,\ ...@@ -57,6 +57,7 @@ $(eval $(call gb_Library_add_exception_objects,subsequenttest,\
test/source/sheet/xgoalseek \ test/source/sheet/xgoalseek \
test/source/sheet/xdatabaserange \ test/source/sheet/xdatabaserange \
test/source/sheet/xdatapilotdescriptor \ test/source/sheet/xdatapilotdescriptor \
test/source/sheet/xdatapilotfield \
test/source/sheet/xdatapilotfieldgrouping \ test/source/sheet/xdatapilotfieldgrouping \
test/source/sheet/xdatapilottable \ test/source/sheet/xdatapilottable \
test/source/sheet/xdatapilottable2 \ test/source/sheet/xdatapilottable2 \
......
/* -*- 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/xdatapilotfield.hxx>
#include <com/sun/star/container/XIndexAccess.hpp>
#include <com/sun/star/sheet/XDataPilotField.hpp>
#include <com/sun/star/uno/Reference.hxx>
#include <cppunit/extensions/HelperMacros.h>
using namespace css;
using namespace css::uno;
namespace apitest
{
void XDataPilotField::testGetItems()
{
uno::Reference<sheet::XDataPilotField> xDPF(init(), UNO_QUERY_THROW);
uno::Reference<container::XIndexAccess> xIA(xDPF->getItems(), UNO_QUERY_THROW);
const sal_Int32 nCount = xIA->getCount();
CPPUNIT_ASSERT_MESSAGE("No items found", sal_Int32(0) != nCount);
for (auto i = 0; i < nCount; i++)
{
CPPUNIT_ASSERT_NO_THROW_MESSAGE("Unable to access element at position " + std::to_string(i),
xIA->getByIndex(i));
}
}
}
/* vim:set shiftwidth=4 softtabstop=4 expandtab cinoptions=b1,g0,N-s cinkeys+=0=break: */
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