tdf#45904 Move XShapes Java tests to C++

Move XShapes Java tests to C++ for ScDrawPageObj.

Change-Id: I1b65e8ad685c3d387a5023e8e8e9b9e06627af11
Reviewed-on: https://gerrit.libreoffice.org/69904
Tested-by: Jenkins
Reviewed-by: Jens Carl <j.carl43@gmx.de>
diff --git a/include/test/drawing/xshapes.hxx b/include/test/drawing/xshapes.hxx
new file mode 100644
index 0000000..f04131d
--- /dev/null
+++ b/include/test/drawing/xshapes.hxx
@@ -0,0 +1,43 @@
/* -*- 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_DRAWING_XSHAPES_HXX
#define INCLUDED_TEST_DRAWING_XSHAPES_HXX

#include <com/sun/star/drawing/XShape.hpp>
#include <com/sun/star/uno/XInterface.hpp>

#include <com/sun/star/uno/Reference.hxx>

#include <test/testdllapi.hxx>

namespace apitest
{
class OOO_DLLPUBLIC_TEST XShapes
{
public:
    virtual css::uno::Reference<css::uno::XInterface> init() = 0;
    void setShape(const css::uno::Reference<css::drawing::XShape>& r_xShape)
    {
        m_xShape = r_xShape;
    }

    void testAddRemove();

protected:
    ~XShapes() {}

private:
    css::uno::Reference<css::drawing::XShape> m_xShape;
};
} // namespace apitest

#endif // INCLUDED_TEST_DRAWING_XSHAPES_HXX

/* vim:set shiftwidth=4 softtabstop=4 expandtab cinoptions=b1,g0,N-s cinkeys+=0=break: */
diff --git a/qadevOOo/Jar_OOoRunner.mk b/qadevOOo/Jar_OOoRunner.mk
index 4bc4edd..3cb59e2 100644
--- a/qadevOOo/Jar_OOoRunner.mk
+++ b/qadevOOo/Jar_OOoRunner.mk
@@ -961,7 +961,6 @@
    qadevOOo/tests/java/mod/_sc/ScDatabaseRangeObj \
    qadevOOo/tests/java/mod/_sc/ScDataPilotItemObj \
    qadevOOo/tests/java/mod/_sc/ScDocumentConfiguration \
    qadevOOo/tests/java/mod/_sc/ScDrawPageObj \
    qadevOOo/tests/java/mod/_sc/ScHeaderFieldObj \
    qadevOOo/tests/java/mod/_sc/ScHeaderFieldsObj \
    qadevOOo/tests/java/mod/_sc/ScHeaderFooterTextCursor \
diff --git a/qadevOOo/objdsc/sc/com.sun.star.comp.office.ScDrawPageObj.csv b/qadevOOo/objdsc/sc/com.sun.star.comp.office.ScDrawPageObj.csv
deleted file mode 100644
index b39d7b6..0000000
--- a/qadevOOo/objdsc/sc/com.sun.star.comp.office.ScDrawPageObj.csv
+++ /dev/null
@@ -1,2 +0,0 @@
"ScDrawPageObj";"com::sun::star::drawing::XShapes";"add()"
"ScDrawPageObj";"com::sun::star::drawing::XShapes";"remove()"
diff --git a/qadevOOo/tests/java/mod/_sc/ScDrawPageObj.java b/qadevOOo/tests/java/mod/_sc/ScDrawPageObj.java
deleted file mode 100644
index 0619ca7..0000000
--- a/qadevOOo/tests/java/mod/_sc/ScDrawPageObj.java
+++ /dev/null
@@ -1,130 +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._sc;

import java.io.PrintWriter;

import lib.TestCase;
import lib.TestEnvironment;
import lib.TestParameters;
import util.DrawTools;
import util.InstCreator;
import util.SOfficeFactory;
import util.ShapeDsc;

import com.sun.star.drawing.XDrawPage;
import com.sun.star.drawing.XDrawPages;
import com.sun.star.drawing.XDrawPagesSupplier;
import com.sun.star.drawing.XShape;
import com.sun.star.lang.XComponent;
import com.sun.star.sheet.XSpreadsheetDocument;
import com.sun.star.uno.AnyConverter;
import com.sun.star.uno.Type;
import com.sun.star.uno.UnoRuntime;
import com.sun.star.uno.XInterface;

public class ScDrawPageObj extends TestCase {

    private XSpreadsheetDocument xDoc = null;

    /**
     * Creates a new Draw document.
     */
    @Override
    protected void initialize( TestParameters tParam, PrintWriter log ) throws Exception {
        // get a soffice factory object
        SOfficeFactory SOF = SOfficeFactory.getFactory( tParam.getMSF());
        log.println( "creating a sheetdocument" );
        xDoc = SOF.createCalcDoc(null);
    }

    /**
     * Disposes the Draw document created before
     */
    @Override
    protected void cleanup( TestParameters tParam, PrintWriter log ) {
        log.println( "    disposing xSheetDoc " );
        XComponent xComp = UnoRuntime.queryInterface(XComponent.class, xDoc);
        util.DesktopTools.closeDoc(xComp);
    }


    /**
     * Creating a TestEnvironment for the interfaces to be tested.
     * From the Calc document created a collection of its draw
     * pages is obtained. Two new pages are inserted. And one
     * page is obtained as a testing component. A shape is added
     * to this page. <p>
     *
     *     Object relations created :
     * <ul>
     *  <li> <code>'DrawPage'</code> for
     *      {@link ifc.drawing._XShapeGrouper} :
     *      the draw page tested. </li>
     *  <li> <code>'Shape'</code> for
     *      {@link ifc.drawing._XShapes} :
     *      the creator which can create instances of
     *      <code>com.sun.star.drawing.Line</code> service </li>
     * </ul>
     */
    @Override
    protected TestEnvironment createTestEnvironment(TestParameters tParam, PrintWriter log) throws Exception {

        XInterface oObj = null;
        XShape oShape = null ;
        XDrawPages oDP = null;

        XComponent xComp = UnoRuntime.queryInterface(XComponent.class, xDoc);

        // creation of testobject here
        // first we write what we are intend to do to log file
        log.println( "creating a test environment" );
        log.println( "getting Drawpages" );
        XDrawPagesSupplier oDPS = UnoRuntime.queryInterface(XDrawPagesSupplier.class,xDoc);
        oDP = oDPS.getDrawPages();
        oDP.insertNewByIndex(1);
        oDP.insertNewByIndex(2);
        oObj = (XDrawPage) AnyConverter.toObject(
                new Type(XDrawPage.class),oDP.getByIndex(0));

        SOfficeFactory SOF = SOfficeFactory.getFactory( tParam.getMSF());

        oShape = SOF.createShape(xComp,5000,3500,7500,5000,"Rectangle");
        DrawTools.getShapes((XDrawPage) oObj).add(oShape);
        XShape oShape1 = SOF.createShape(xComp,
            5000,5500,5000,5000,"Rectangle");
        DrawTools.getShapes((XDrawPage) oObj).add(oShape1);

        // create test environment here
        TestEnvironment tEnv = new TestEnvironment( oObj );

        // relation for XShapes interface
        ShapeDsc sDsc = new ShapeDsc(5000,3500,7500,10000,"Line");
        tEnv.addObjRelation("Shape", new InstCreator(xDoc, sDsc)) ;

        log.println("ImplementationName: "+util.utils.getImplName(oObj));

        // adding relation for XShapeGrouper
        tEnv.addObjRelation("DrawPage", oObj);

        return tEnv;
    } // finish method getTestEnvironment

}

diff --git a/sc/qa/extras/scdrawpageobj.cxx b/sc/qa/extras/scdrawpageobj.cxx
index 7d50a78..436b5f3 100644
--- a/sc/qa/extras/scdrawpageobj.cxx
+++ b/sc/qa/extras/scdrawpageobj.cxx
@@ -12,6 +12,7 @@
#include <test/container/xelementaccess.hxx>
#include <test/container/xindexaccess.hxx>
#include <test/drawing/xshapegrouper.hxx>
#include <test/drawing/xshapes.hxx>
#include <test/lang/xserviceinfo.hxx>
#include <cppu/unotype.hxx>

@@ -34,7 +35,8 @@
                      public apitest::XElementAccess,
                      public apitest::XIndexAccess,
                      public apitest::XServiceInfo,
                      public apitest::XShapeGrouper
                      public apitest::XShapeGrouper,
                      public apitest::XShapes
{
public:
    ScDrawPageObj();
@@ -62,6 +64,9 @@
    CPPUNIT_TEST(testGroup);
    CPPUNIT_TEST(testUngroup);

    // XShapes
    CPPUNIT_TEST(testAddRemove);

    CPPUNIT_TEST_SUITE_END();

private:
@@ -98,6 +103,8 @@

    // needed for XShapeGrouper tests
    setDrawPage(xDrawPage);
    // needed for XShapes tests
    setShape(apitest::helper::shape::createLine(m_xComponent, 7500, 10000, 5000, 3500));
    return xDrawPage;
}

diff --git a/sc/qa/unoapi/sc_4.sce b/sc/qa/unoapi/sc_4.sce
index 2e467f5..50727b8 100644
--- a/sc/qa/unoapi/sc_4.sce
+++ b/sc/qa/unoapi/sc_4.sce
@@ -18,7 +18,6 @@
-o sc.ScDataPilotItemObj
-o sc.ScDatabaseRangeObj
-o sc.ScDocumentConfiguration
-o sc.ScDrawPageObj
# ported to cppunit -o sc.ScHeaderFieldObj
-o sc.ScHeaderFieldsObj
# The two HeaderFooter tests seem to fail randomly
diff --git a/test/Library_subsequenttest.mk b/test/Library_subsequenttest.mk
index c267a15..65d9d1f 100644
--- a/test/Library_subsequenttest.mk
+++ b/test/Library_subsequenttest.mk
@@ -57,6 +57,7 @@
	test/source/drawing/captionshape \
	test/source/drawing/xdrawpages \
	test/source/drawing/xshapegrouper \
	test/source/drawing/xshapes \
	test/source/lang/xserviceinfo \
	test/source/lang/xcomponent \
	test/source/sheet/cellarealink \
diff --git a/test/source/drawing/xshapes.cxx b/test/source/drawing/xshapes.cxx
new file mode 100644
index 0000000..4fce5cc
--- /dev/null
+++ b/test/source/drawing/xshapes.cxx
@@ -0,0 +1,38 @@
/* -*- 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/drawing/xshapes.hxx>
#include <sal/types.h>

#include <com/sun/star/drawing/XShapes.hpp>
#include <com/sun/star/uno/Reference.hxx>

#include <cppunit/extensions/HelperMacros.h>

using namespace css;

namespace apitest
{
void XShapes::testAddRemove()
{
    uno::Reference<drawing::XShapes> xShapes(init(), uno::UNO_QUERY_THROW);

    const sal_Int32 nCountBeforeAdd = xShapes->getCount();
    xShapes->add(m_xShape);
    const sal_Int32 nCountAfterAdd = xShapes->getCount();
    CPPUNIT_ASSERT_EQUAL(nCountBeforeAdd + 1, nCountAfterAdd);

    xShapes->remove(m_xShape);
    const sal_Int32 nCountAfterRemove = xShapes->getCount();
    CPPUNIT_ASSERT_EQUAL(nCountBeforeAdd, nCountAfterRemove);
}

} // namespace apitest

/* vim:set shiftwidth=4 softtabstop=4 expandtab cinoptions=b1,g0,N-s cinkeys+=0=break: */