tdf#45904: Remove old SwXReferenceMarks Java test

Change-Id: I8830e54fdba98d3cfd1e2844e7faf02e55e7d0ac
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/156044
Tested-by: Jenkins
Reviewed-by: Tomaž Vajngerl <[email protected]>
diff --git a/framework/qa/complex/api_internal/api.lst b/framework/qa/complex/api_internal/api.lst
index 3042200..2d5bcd4 100644
--- a/framework/qa/complex/api_internal/api.lst
+++ b/framework/qa/complex/api_internal/api.lst
@@ -153,7 +153,6 @@ job219=sw.SwXModule
job221=sw.SwXPrintSettings
job222=sw.SwXPropertySet
job223=sw.SwXPropertySetInfo
job225=sw.SwXReferenceMarks
job226=sw.SwXStyle
job228=sw.SwXStyleFamily
job229=sw.SwXTableCellText
diff --git a/qadevOOo/Jar_OOoRunner.mk b/qadevOOo/Jar_OOoRunner.mk
index 60343d0..d71eb77 100644
--- a/qadevOOo/Jar_OOoRunner.mk
+++ b/qadevOOo/Jar_OOoRunner.mk
@@ -1109,7 +1109,6 @@ $(eval $(call gb_Jar_add_sourcefiles,OOoRunner,\
    qadevOOo/tests/java/mod/_sw/SwXPrintSettings \
    qadevOOo/tests/java/mod/_sw/SwXPropertySet \
    qadevOOo/tests/java/mod/_sw/SwXPropertySetInfo \
    qadevOOo/tests/java/mod/_sw/SwXReferenceMarks \
    qadevOOo/tests/java/mod/_sw/SwXShape \
    qadevOOo/tests/java/mod/_sw/SwXStyle \
    qadevOOo/tests/java/mod/_sw/SwXStyleFamily \
diff --git a/qadevOOo/objdsc/sw/com.sun.star.comp.office.SwXReferenceMarks.csv b/qadevOOo/objdsc/sw/com.sun.star.comp.office.SwXReferenceMarks.csv
deleted file mode 100644
index bcc24a0..0000000
--- a/qadevOOo/objdsc/sw/com.sun.star.comp.office.SwXReferenceMarks.csv
+++ /dev/null
@@ -1,7 +0,0 @@
"SwXReferenceMarks";"com::sun::star::container::XNameAccess";"getByName()"
"SwXReferenceMarks";"com::sun::star::container::XNameAccess";"getElementNames()"
"SwXReferenceMarks";"com::sun::star::container::XNameAccess";"hasByName()"
"SwXReferenceMarks";"com::sun::star::container::XIndexAccess";"getCount()"
"SwXReferenceMarks";"com::sun::star::container::XIndexAccess";"getByIndex()"
"SwXReferenceMarks";"com::sun::star::container::XElementAccess";"getElementType()"
"SwXReferenceMarks";"com::sun::star::container::XElementAccess";"hasElements()"
diff --git a/qadevOOo/tests/java/mod/_sw/SwXReferenceMarks.java b/qadevOOo/tests/java/mod/_sw/SwXReferenceMarks.java
deleted file mode 100644
index 40b99ad..0000000
--- a/qadevOOo/tests/java/mod/_sw/SwXReferenceMarks.java
+++ /dev/null
@@ -1,128 +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 mod._sw;

import java.io.PrintWriter;

import lib.TestCase;
import lib.TestEnvironment;
import lib.TestParameters;
import util.SOfficeFactory;

import com.sun.star.container.XNamed;
import com.sun.star.lang.XMultiServiceFactory;
import com.sun.star.text.XReferenceMarksSupplier;
import com.sun.star.text.XText;
import com.sun.star.text.XTextContent;
import com.sun.star.text.XTextCursor;
import com.sun.star.text.XTextDocument;
import com.sun.star.uno.UnoRuntime;
import com.sun.star.uno.XInterface;

/**
 * Test for object which is represented by service
 * <code>com.sun.star.text.ReferenceMarks</code>. <p>
 * Object implements the following interfaces :
 * <ul>
 *  <li> <code>com::sun::star::container::XNameAccess</code></li>
 *  <li> <code>com::sun::star::container::XIndexAccess</code></li>
 *  <li> <code>com::sun::star::container::XElementAccess</code></li>
 * </ul> <p>
 * This object test <b> is NOT </b> designed to be run in several
 * threads concurrently.
 * @see com.sun.star.container.XNameAccess
 * @see com.sun.star.container.XIndexAccess
 * @see com.sun.star.container.XElementAccess
 * @see com.sun.star.text.ReferenceMarks
 * @see ifc.container._XNameAccess
 * @see ifc.container._XIndexAccess
 * @see ifc.container._XElementAccess
 */
public class SwXReferenceMarks extends TestCase {
    XTextDocument xTextDoc;

    /**
    * Creates text document.
    */
    @Override
    protected void initialize( TestParameters tParam, PrintWriter log ) throws Exception {
        SOfficeFactory SOF = SOfficeFactory.getFactory( tParam.getMSF() );
        log.println( "creating a textdocument" );
        xTextDoc = SOF.createTextDoc( null );
    }

    /**
    * Disposes text document.
    */
    @Override
    protected void cleanup( TestParameters tParam, PrintWriter log ) {
        log.println( "    disposing xTextDoc " );
        util.DesktopTools.closeDoc(xTextDoc);
    }

    /**
    * Creating a TestEnvironment for the interfaces to be tested.
    * Creates an instances of the service
    * <code>com.sun.star.text.ReferenceMark</code>, then sets new names to
    * created ReferenceMark's using <code>XNamed</code> interface. Then renamed
    * ReferenceMark's are inserted to a major text of text document. Finally,
    * ReferenceMarks are gotten from text document using
    * <code>XReferenceMarksSupplier</code> interface.
    */
    @Override
    public TestEnvironment createTestEnvironment(
            TestParameters tParam, PrintWriter log ) throws Exception {
        XInterface oObj = null;
        XText oText = null;
        String Name = "SwXReferenceMark01";
        String Name2 = "SwXReferenceMark02";

        log.println( "creating a test environment" );
        oText = xTextDoc.getText();

        XMultiServiceFactory oDocMSF = UnoRuntime.queryInterface(XMultiServiceFactory.class, xTextDoc);

        // Creation and insertion of ReferenceMark01
        oObj = (XInterface)
            oDocMSF.createInstance( "com.sun.star.text.ReferenceMark" );
        XNamed oObjN = UnoRuntime.queryInterface(XNamed.class, oObj);
        oObjN.setName(Name);
        XTextContent oObjTC = UnoRuntime.queryInterface(XTextContent.class, oObj);
        XTextCursor oCursor = oText.createTextCursor();
        oText.insertTextContent(oCursor, oObjTC, false);

        // Creation and insertion of ReferenceMark02
        oObj = (XInterface)
            oDocMSF.createInstance( "com.sun.star.text.ReferenceMark" );
        XNamed oObjN2 = UnoRuntime.queryInterface(XNamed.class, oObj);
        oObjN2.setName(Name2);

        XTextContent oObjTC2 = UnoRuntime.queryInterface(XTextContent.class, oObj);
        oText.insertTextContent(oCursor, oObjTC2, false);

        // getting ReferenceMarks from text document
        XReferenceMarksSupplier oRefSupp = UnoRuntime.queryInterface(XReferenceMarksSupplier.class, xTextDoc);
        oObj = oRefSupp.getReferenceMarks();

        TestEnvironment tEnv = new TestEnvironment( oObj );
        return tEnv;
    } // finish method getTestEnvironment

}    // finish class SwXReferenceMarks

diff --git a/sw/qa/api/SwXReferenceMarks.cxx b/sw/qa/api/SwXReferenceMarks.cxx
index 699647f..1420a04 100644
--- a/sw/qa/api/SwXReferenceMarks.cxx
+++ b/sw/qa/api/SwXReferenceMarks.cxx
@@ -7,11 +7,10 @@
 * file, You can obtain one at http://mozilla.org/MPL/2.0/.
 */

#include <test/bootstrapfixture.hxx>
#include <test/unoapi_test.hxx>
#include <test/container/xelementaccess.hxx>
#include <test/container/xindexaccess.hxx>
#include <test/container/xnameaccess.hxx>
#include <unotest/macros_test.hxx>

#include <com/sun/star/frame/Desktop.hpp>

@@ -30,22 +29,61 @@ using namespace css::uno;
namespace
{
/**
 * Initial tests for SwXReferenceMark.
 * Initial tests for SwXReferenceMarks.
 */
class SwXReferenceMark final : public test::BootstrapFixture,
                               public unotest::MacrosTest,
                               public apitest::XElementAccess,
                               public apitest::XIndexAccess,
                               public apitest::XNameAccess
class SwXReferenceMarks final : public UnoApiTest,
                                public apitest::XElementAccess,
                                public apitest::XIndexAccess,
                                public apitest::XNameAccess
{
public:
    SwXReferenceMark();
    virtual void setUp() override;
    void tearDown() override;
    SwXReferenceMarks()
        : UnoApiTest("")
        , XElementAccess(cppu::UnoType<text::XTextContent>::get())
        , XIndexAccess(2)
        , XNameAccess("SwXReferenceMarks2")
    {
    }

    Reference<XInterface> init() override;
    virtual void setUp() override
    {
        UnoApiTest::setUp();
        mxDesktop.set(frame::Desktop::create(mxComponentContext));
        mxComponent = loadFromDesktop("private:factory/swriter");
        CPPUNIT_ASSERT(mxComponent.is());
    }

    CPPUNIT_TEST_SUITE(SwXReferenceMark);
    Reference<XInterface> init() override
    {
        Reference<text::XTextDocument> xTextDocument(mxComponent, UNO_QUERY_THROW);
        Reference<lang::XMultiServiceFactory> xMSF(xTextDocument, UNO_QUERY_THROW);

        Reference<text::XText> xText = xTextDocument->getText();
        Reference<text::XTextCursor> xCursor = xText->createTextCursor();

        //RefMark 1
        Reference<XInterface> xRefMark1 = xMSF->createInstance("com.sun.star.text.ReferenceMark");
        Reference<container::XNamed> xNamed1(xRefMark1, UNO_QUERY_THROW);
        xNamed1->setName("SwXReferenceMarks1");

        Reference<text::XTextContent> xTextContent1(xRefMark1, UNO_QUERY_THROW);
        xText->insertTextContent(xCursor, xTextContent1, false);

        //RefMark 2
        Reference<XInterface> xRefMark2 = xMSF->createInstance("com.sun.star.text.ReferenceMark");
        Reference<container::XNamed> xNamed2(xRefMark2, UNO_QUERY_THROW);
        xNamed2->setName("SwXReferenceMarks2");

        Reference<text::XTextContent> xTextContent2(xRefMark2, UNO_QUERY_THROW);
        xText->insertTextContent(xCursor, xTextContent2, false);

        // Getting ReferenceMarks from Text Document
        Reference<text::XReferenceMarksSupplier> xRefMarkSupp(xTextDocument, UNO_QUERY_THROW);

        return Reference<XInterface>(xRefMarkSupp->getReferenceMarks(), UNO_QUERY_THROW);
    }

    CPPUNIT_TEST_SUITE(SwXReferenceMarks);
    CPPUNIT_TEST(testGetElementType);
    CPPUNIT_TEST(testHasElements);
    CPPUNIT_TEST(testGetCount);
@@ -54,67 +92,9 @@ public:
    CPPUNIT_TEST(testGetElementNames);
    CPPUNIT_TEST(testHasByName);
    CPPUNIT_TEST_SUITE_END();

private:
    Reference<text::XTextDocument> mxTextDocument;
};

SwXReferenceMark::SwXReferenceMark()
    : XElementAccess(cppu::UnoType<text::XTextContent>::get())
    , XIndexAccess(2)
    , XNameAccess("SwXReferenceMark2")
{
}

void SwXReferenceMark::setUp()
{
    test::BootstrapFixture::setUp();

    mxDesktop.set(frame::Desktop::create(mxComponentContext));
    mxTextDocument = Reference<text::XTextDocument>(
        loadFromDesktop("private:factory/swriter", "com.sun.star.text.TextDocument"),
        uno::UNO_QUERY_THROW);
    CPPUNIT_ASSERT(mxTextDocument.is());
}

void SwXReferenceMark::tearDown()
{
    if (mxTextDocument.is())
        mxTextDocument->dispose();

    test::BootstrapFixture::tearDown();
}

Reference<XInterface> SwXReferenceMark::init()
{
    Reference<lang::XMultiServiceFactory> xMSF(mxTextDocument, UNO_QUERY_THROW);

    Reference<text::XText> xText = mxTextDocument->getText();
    Reference<text::XTextCursor> xCursor = xText->createTextCursor();

    //RefMark 1
    Reference<XInterface> xRefMark1 = xMSF->createInstance("com.sun.star.text.ReferenceMark");
    Reference<container::XNamed> xNamed1(xRefMark1, UNO_QUERY_THROW);
    xNamed1->setName("SwXReferenceMark1");

    Reference<text::XTextContent> xTextContent1(xRefMark1, UNO_QUERY_THROW);
    xText->insertTextContent(xCursor, xTextContent1, false);

    //RefMark 2
    Reference<XInterface> xRefMark2 = xMSF->createInstance("com.sun.star.text.ReferenceMark");
    Reference<container::XNamed> xNamed2(xRefMark2, UNO_QUERY_THROW);
    xNamed2->setName("SwXReferenceMark2");

    Reference<text::XTextContent> xTextContent2(xRefMark2, UNO_QUERY_THROW);
    xText->insertTextContent(xCursor, xTextContent2, false);

    // Getting ReferenceMarks from Text Document
    Reference<text::XReferenceMarksSupplier> xRefMarkSupp(mxTextDocument, UNO_QUERY_THROW);

    return Reference<XInterface>(xRefMarkSupp->getReferenceMarks(), UNO_QUERY_THROW);
}

CPPUNIT_TEST_SUITE_REGISTRATION(SwXReferenceMark);
CPPUNIT_TEST_SUITE_REGISTRATION(SwXReferenceMarks);
}

/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/sw/qa/unoapi/sw_2.sce b/sw/qa/unoapi/sw_2.sce
index 9d6adfd4..0a97578 100644
--- a/sw/qa/unoapi/sw_2.sce
+++ b/sw/qa/unoapi/sw_2.sce
@@ -32,7 +32,6 @@
-o sw.SwXPrintSettings
-o sw.SwXPropertySet
-o sw.SwXPropertySetInfo
-o sw.SwXReferenceMarks
#i111190 -o sw.SwXShape
-o sw.SwXStyleFamily
-o sw.SwXTableCellText