tdf#45904 Move XIndexAccess Java tests to C++

Move XIndexAccess Java tests to C++ for ScAutoFormatObj.

Change-Id: Ifa88b55b4691accb19c18a8c5f9c880d26a3d078
Reviewed-on: https://gerrit.libreoffice.org/70094
Tested-by: Jenkins
Reviewed-by: Jens Carl <j.carl43@gmx.de>
diff --git a/qadevOOo/objdsc/sc/com.sun.star.comp.office.ScAutoFormatObj.csv b/qadevOOo/objdsc/sc/com.sun.star.comp.office.ScAutoFormatObj.csv
index c4a036d..694fd81 100644
--- a/qadevOOo/objdsc/sc/com.sun.star.comp.office.ScAutoFormatObj.csv
+++ b/qadevOOo/objdsc/sc/com.sun.star.comp.office.ScAutoFormatObj.csv
@@ -1,5 +1,3 @@
"ScAutoFormatObj";"com::sun::star::container::XIndexAccess";"getCount()"
"ScAutoFormatObj";"com::sun::star::container::XIndexAccess";"getByIndex()"
"ScAutoFormatObj";"com::sun::star::container::XElementAccess";"getElementType()"
"ScAutoFormatObj";"com::sun::star::container::XElementAccess";"hasElements()"
"ScAutoFormatObj";"com::sun::star::container::XNamed";"getName()"
diff --git a/sc/qa/extras/scautoformatobj.cxx b/sc/qa/extras/scautoformatobj.cxx
index 518b967..8f86f46 100644
--- a/sc/qa/extras/scautoformatobj.cxx
+++ b/sc/qa/extras/scautoformatobj.cxx
@@ -9,6 +9,7 @@

#include <test/calc_unoapi_test.hxx>
#include <test/container/xenumerationaccess.hxx>
#include <test/container/xindexaccess.hxx>
#include <test/sheet/tableautoformat.hxx>

#include <com/sun/star/beans/XPropertySet.hpp>
@@ -21,15 +22,13 @@
#include <com/sun/star/uno/Reference.hxx>

using namespace css;
using namespace css::uno;
using namespace com::sun::star;

namespace sc_apitest
{
class ScAutoFormatObj : public CalcUnoApiTest,
                        public apitest::TableAutoFormat,
                        public apitest::XEnumerationAccess,
                        public apitest::TableAutoFormat

                        public apitest::XIndexAccess
{
public:
    ScAutoFormatObj();
@@ -40,11 +39,15 @@

    CPPUNIT_TEST_SUITE(ScAutoFormatObj);

    // TableAutoFormat
    CPPUNIT_TEST(testTableAutoFormatProperties);

    // XEnumerationAccess
    CPPUNIT_TEST(testCreateEnumeration);

    // TableAutoFormat
    CPPUNIT_TEST(testTableAutoFormatProperties);
    // XIndexAccess
    CPPUNIT_TEST(testGetByIndex);
    CPPUNIT_TEST(testGetCount);

    CPPUNIT_TEST_SUITE_END();

@@ -54,19 +57,20 @@

ScAutoFormatObj::ScAutoFormatObj()
    : CalcUnoApiTest("/sc/qa/extras/testdocuments")
    , XIndexAccess(16)
{
}

uno::Reference<uno::XInterface> ScAutoFormatObj::init()
{
    uno::Reference<sheet::XSpreadsheetDocument> xDoc(mxComponent, UNO_QUERY_THROW);
    uno::Reference<sheet::XSpreadsheetDocument> xDoc(mxComponent, uno::UNO_QUERY_THROW);

    uno::Reference<lang::XMultiServiceFactory> xMSF(xDoc, UNO_QUERY_THROW);
    uno::Reference<lang::XMultiServiceFactory> xMSF(xDoc, uno::UNO_QUERY_THROW);
    uno::Reference<container::XIndexAccess> xIA(
        xMSF->createInstance("com.sun.star.sheet.TableAutoFormats"), UNO_QUERY_THROW);
        xMSF->createInstance("com.sun.star.sheet.TableAutoFormats"), uno::UNO_QUERY_THROW);

    uno::Reference<beans::XPropertySet> xTableAutoFormat(xIA->getByIndex(xIA->getCount() - 1),
                                                         UNO_QUERY_THROW);
                                                         uno::UNO_QUERY_THROW);
    return xTableAutoFormat;
}

@@ -84,7 +88,7 @@

CPPUNIT_TEST_SUITE_REGISTRATION(ScAutoFormatObj);

} // end namespace
} // namespace sc_apitest

CPPUNIT_PLUGIN_IMPLEMENT();