[Libreoffice-commits] core.git: include/test qadevOOo/Jar_OOoRunner.mk qadevOOo/objdsc qadevOOo/tests sc/qa test/Library_subsequenttest.mk test/source

Jens Carl (via logerrit) logerrit at kemper.freedesktop.org
Thu Mar 28 23:46:12 UTC 2019


 include/test/drawing/xshapes.hxx                              |   43 +++
 qadevOOo/Jar_OOoRunner.mk                                     |    1 
 qadevOOo/objdsc/sc/com.sun.star.comp.office.ScDrawPageObj.csv |    2 
 qadevOOo/tests/java/mod/_sc/ScDrawPageObj.java                |  130 ----------
 sc/qa/extras/scdrawpageobj.cxx                                |    9 
 sc/qa/unoapi/sc_4.sce                                         |    1 
 test/Library_subsequenttest.mk                                |    1 
 test/source/drawing/xshapes.cxx                               |   38 ++
 8 files changed, 90 insertions(+), 135 deletions(-)

New commits:
commit b99ea0ff33b78ba76d1ae436895efac490252e0f
Author:     Jens Carl <j.carl43 at gmx.de>
AuthorDate: Thu Mar 28 21:24:35 2019 +0000
Commit:     Jens Carl <j.carl43 at gmx.de>
CommitDate: Fri Mar 29 00:45:46 2019 +0100

    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 at gmx.de>

diff --git a/include/test/drawing/xshapes.hxx b/include/test/drawing/xshapes.hxx
new file mode 100644
index 000000000000..f04131dc41f7
--- /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 4bc4edde3ba3..3cb59e2c61de 100644
--- a/qadevOOo/Jar_OOoRunner.mk
+++ b/qadevOOo/Jar_OOoRunner.mk
@@ -961,7 +961,6 @@ $(eval $(call gb_Jar_add_sourcefiles,OOoRunner,\
     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 b39d7b6062be..000000000000
--- 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 0619ca7533c4..000000000000
--- 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 7d50a783d9d5..436b5f33c8ed 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 @@ class ScDrawPageObj : public CalcUnoApiTest,
                       public apitest::XElementAccess,
                       public apitest::XIndexAccess,
                       public apitest::XServiceInfo,
-                      public apitest::XShapeGrouper
+                      public apitest::XShapeGrouper,
+                      public apitest::XShapes
 {
 public:
     ScDrawPageObj();
@@ -62,6 +64,9 @@ public:
     CPPUNIT_TEST(testGroup);
     CPPUNIT_TEST(testUngroup);
 
+    // XShapes
+    CPPUNIT_TEST(testAddRemove);
+
     CPPUNIT_TEST_SUITE_END();
 
 private:
@@ -98,6 +103,8 @@ uno::Reference<uno::XInterface> ScDrawPageObj::init()
 
     // 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 2e467f5433e9..50727b8425fa 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 c267a1570d1f..65d9d1f7efd8 100644
--- a/test/Library_subsequenttest.mk
+++ b/test/Library_subsequenttest.mk
@@ -57,6 +57,7 @@ $(eval $(call gb_Library_add_exception_objects,subsequenttest,\
 	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 000000000000..4fce5cc748ec
--- /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: */


More information about the Libreoffice-commits mailing list