framework/qa/complex/api_internal/api.lst                              |    1 
 qadevOOo/Jar_OOoRunner.mk                                              |    1 
 qadevOOo/objdsc/sw/com.sun.star.comp.office.SwXTextEmbeddedObjects.csv |    7 
 qadevOOo/tests/java/mod/_sw/SwXTextEmbeddedObjects.java                |  121 
----------
 sw/CppunitTest_sw_apitests.mk                                          |    1 
 sw/qa/api/SwXTextEmbeddedObjects.cxx                                   |  100 
++++++++
 sw/qa/unoapi/sw_3.sce                                                  |    1 
 7 files changed, 101 insertions(+), 131 deletions(-)

New commits:
commit 534326bf573ace5877c7d790b37399623aa71d79
Author:     anfanite396 <dipamt1...@gmail.com>
AuthorDate: Thu Aug 24 16:47:30 2023 +0530
Commit:     Tomaž Vajngerl <qui...@gmail.com>
CommitDate: Fri Aug 25 08:27:53 2023 +0200

    tdf#45904: Move SwXTextEmbeddedObjects Java tests to C++
    
    Change-Id: I05ad9e264162e3fb97ebea814f59ed44bf23056a
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/156050
    Tested-by: Jenkins
    Reviewed-by: Tomaž Vajngerl <qui...@gmail.com>

diff --git a/framework/qa/complex/api_internal/api.lst 
b/framework/qa/complex/api_internal/api.lst
index e1f01f7a2fc0..2222f3befca0 100644
--- a/framework/qa/complex/api_internal/api.lst
+++ b/framework/qa/complex/api_internal/api.lst
@@ -165,7 +165,6 @@ job229=sw.SwXTableCellText
 job230=sw.SwXTableRows
 job231=sw.SwXTextColumns
 job232=sw.SwXTextDefaults
-job233=sw.SwXTextEmbeddedObjects
 job234=sw.SwXTextField
 job237=sw.SwXTextFrameText
 job238=sw.SwXTextGraphicObjects
diff --git a/qadevOOo/Jar_OOoRunner.mk b/qadevOOo/Jar_OOoRunner.mk
index 9c0af119c032..de423c3bc624 100644
--- a/qadevOOo/Jar_OOoRunner.mk
+++ b/qadevOOo/Jar_OOoRunner.mk
@@ -1129,7 +1129,6 @@ $(eval $(call gb_Jar_add_sourcefiles,OOoRunner,\
     qadevOOo/tests/java/mod/_sw/SwXTextDefaults \
     qadevOOo/tests/java/mod/_sw/SwXTextDocument \
     qadevOOo/tests/java/mod/_sw/SwXTextEmbeddedObject \
-    qadevOOo/tests/java/mod/_sw/SwXTextEmbeddedObjects \
     qadevOOo/tests/java/mod/_sw/SwXTextField \
     qadevOOo/tests/java/mod/_sw/SwXTextFrame \
     qadevOOo/tests/java/mod/_sw/SwXTextFrameText \
diff --git 
a/qadevOOo/objdsc/sw/com.sun.star.comp.office.SwXTextEmbeddedObjects.csv 
b/qadevOOo/objdsc/sw/com.sun.star.comp.office.SwXTextEmbeddedObjects.csv
deleted file mode 100644
index 89ab2d561f04..000000000000
--- a/qadevOOo/objdsc/sw/com.sun.star.comp.office.SwXTextEmbeddedObjects.csv
+++ /dev/null
@@ -1,7 +0,0 @@
-"SwXTextEmbeddedObjects";"com::sun::star::container::XNameAccess";"getByName()"
-"SwXTextEmbeddedObjects";"com::sun::star::container::XNameAccess";"getElementNames()"
-"SwXTextEmbeddedObjects";"com::sun::star::container::XNameAccess";"hasByName()"
-"SwXTextEmbeddedObjects";"com::sun::star::container::XIndexAccess";"getCount()"
-"SwXTextEmbeddedObjects";"com::sun::star::container::XIndexAccess";"getByIndex()"
-"SwXTextEmbeddedObjects";"com::sun::star::container::XElementAccess";"getElementType()"
-"SwXTextEmbeddedObjects";"com::sun::star::container::XElementAccess";"hasElements()"
diff --git a/qadevOOo/tests/java/mod/_sw/SwXTextEmbeddedObjects.java 
b/qadevOOo/tests/java/mod/_sw/SwXTextEmbeddedObjects.java
deleted file mode 100644
index 4b0e3ae7239b..000000000000
--- a/qadevOOo/tests/java/mod/_sw/SwXTextEmbeddedObjects.java
+++ /dev/null
@@ -1,121 +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 com.sun.star.beans.XPropertySet;
-import java.io.PrintWriter;
-
-import lib.StatusException;
-import lib.TestCase;
-import lib.TestEnvironment;
-import lib.TestParameters;
-import util.SOfficeFactory;
-
-import com.sun.star.lang.XMultiServiceFactory;
-import com.sun.star.text.XTextContent;
-import com.sun.star.text.XTextCursor;
-import com.sun.star.text.XTextDocument;
-import com.sun.star.text.XTextEmbeddedObjectsSupplier;
-import com.sun.star.uno.UnoRuntime;
-import com.sun.star.uno.XInterface;
-
-
-public class SwXTextEmbeddedObjects extends TestCase {
-
-    XTextDocument oDoc;
-
-    /**
-     * in general this method creates a testdocument
-     *
-     *  @param tParam    class which contains additional test parameters
-     *  @param log        class to log the test state and result
-     *
-     *
-     *  @see TestParameters
-     *    @see PrintWriter
-     *
-     */
-    @Override
-    protected void initialize( TestParameters tParam, PrintWriter log ) throws 
Exception {
-        SOfficeFactory SOF = SOfficeFactory.getFactory( tParam.getMSF() );
-        oDoc = SOF.createTextDoc(null);
-    }
-
-    /**
-     * in general this method disposes the testenvironment and document
-     *
-     *  @param tParam    class which contains additional test parameters
-     *  @param log        class to log the test state and result
-     *
-     *
-     *  @see TestParameters
-     *    @see PrintWriter
-     *
-     */
-    @Override
-    protected void cleanup( TestParameters tParam, PrintWriter log ) {
-        log.println( "    disposing xTextDoc " );
-        util.DesktopTools.closeDoc(oDoc);
-    }
-
-
-    /**
-     *    creating a TestEnvironment for the interfaces to be tested
-     *
-     *  @param tParam    class which contains additional test parameters
-     *  @param log        class to log the test state and result
-     *
-     *  @return    Status class
-     *
-     *  @see TestParameters
-     *    @see PrintWriter
-     */
-    @Override
-    public TestEnvironment createTestEnvironment( TestParameters tParam,
-                  PrintWriter log ) throws StatusException {
-
-        XInterface oObj = null;
-
-        // create testobject here
-        XTextCursor xCursor = oDoc.getText().createTextCursor();
-        try {
-            XMultiServiceFactory xMultiServiceFactory = 
UnoRuntime.queryInterface(XMultiServiceFactory.class, oDoc);
-            Object o = 
xMultiServiceFactory.createInstance("com.sun.star.text.TextEmbeddedObject" );
-            XTextContent xTextContent = 
UnoRuntime.queryInterface(XTextContent.class, o);
-            String sChartClassID = "12dcae26-281f-416f-a234-c3086127382e";
-            XPropertySet xPropertySet = 
UnoRuntime.queryInterface(XPropertySet.class, xTextContent);
-            xPropertySet.setPropertyValue( "CLSID", sChartClassID );
-
-            oDoc.getText().insertTextContent( xCursor, xTextContent, false );
-        }
-        catch(com.sun.star.uno.Exception e) {
-            e.printStackTrace(log);
-        }
-
-        XTextEmbeddedObjectsSupplier oTEOS = 
UnoRuntime.queryInterface(XTextEmbeddedObjectsSupplier.class, oDoc);
-
-        oObj = oTEOS.getEmbeddedObjects();
-
-          TestEnvironment tEnv = new TestEnvironment( oObj );
-        return tEnv;
-
-        } // finish method getTestEnvironment
-
-}    // finish class SwXTextEmbeddedObjects
-
diff --git a/sw/CppunitTest_sw_apitests.mk b/sw/CppunitTest_sw_apitests.mk
index 1e70b91dac17..e794d9b2f9c3 100644
--- a/sw/CppunitTest_sw_apitests.mk
+++ b/sw/CppunitTest_sw_apitests.mk
@@ -38,6 +38,7 @@ $(eval $(call 
gb_CppunitTest_add_exception_objects,sw_apitests, \
     sw/qa/api/SwXStyleFamilies \
     sw/qa/api/SwXReferenceMarks \
     sw/qa/api/SwXTableCellText \
+    sw/qa/api/SwXTextEmbeddedObjects \
     sw/qa/api/SwXTextFrame \
     sw/qa/api/SwXTextField \
     sw/qa/api/SwXTextFieldMasters \
diff --git a/sw/qa/api/SwXTextEmbeddedObjects.cxx 
b/sw/qa/api/SwXTextEmbeddedObjects.cxx
new file mode 100644
index 000000000000..4e8a19a702d1
--- /dev/null
+++ b/sw/qa/api/SwXTextEmbeddedObjects.cxx
@@ -0,0 +1,100 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*
+ * 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/unoapi_test.hxx>
+#include <test/container/xnameaccess.hxx>
+#include <test/container/xindexaccess.hxx>
+#include <test/container/xelementaccess.hxx>
+
+#include <com/sun/star/frame/Desktop.hpp>
+
+#include <com/sun/star/lang/XMultiServiceFactory.hpp>
+
+#include <com/sun/star/text/XTextDocument.hpp>
+#include <com/sun/star/beans/XPropertySet.hpp>
+#include <com/sun/star/text/XText.hpp>
+#include <com/sun/star/text/XTextContent.hpp>
+#include <com/sun/star/text/XTextEmbeddedObjectsSupplier.hpp>
+#include <com/sun/star/document/XEmbeddedObjectSupplier.hpp>
+#include <com/sun/star/text/XTextFrame.hpp>
+
+#include <comphelper/processfactory.hxx>
+
+using namespace css;
+using namespace css::uno;
+
+namespace
+{
+/**
+ * Initial tests for SwXTextEmbeddedObjects.
+ */
+class SwXTextEmbeddedObjects final : public UnoApiTest,
+                                     public apitest::XElementAccess,
+                                     public apitest::XIndexAccess,
+                                     public apitest::XNameAccess
+{
+public:
+    SwXTextEmbeddedObjects()
+        : UnoApiTest("")
+        , 
XElementAccess(cppu::UnoType<document::XEmbeddedObjectSupplier>::get())
+        , XIndexAccess(1)
+        , XNameAccess("Object1")
+    {
+    }
+
+    virtual void setUp() override
+    {
+        UnoApiTest::setUp();
+        mxDesktop.set(frame::Desktop::create(mxComponentContext));
+        mxComponent = loadFromDesktop("private:factory/swriter");
+        CPPUNIT_ASSERT(mxComponent.is());
+    }
+
+    Reference<XInterface> init() override
+    {
+        Reference<text::XTextDocument> xTextDocument(mxComponent, 
UNO_QUERY_THROW);
+        Reference<lang::XMultiServiceFactory> xMSF(mxComponent, 
UNO_QUERY_THROW);
+
+        Reference<text::XText> xText = xTextDocument->getText();
+        Reference<text::XTextCursor> xCursor = xText->createTextCursor();
+
+        try
+        {
+            Reference<text::XTextContent> xTextContent(
+                xMSF->createInstance("com.sun.star.text.TextEmbeddedObject"), 
UNO_QUERY_THROW);
+            Reference<beans::XPropertySet> xPropertySet(xTextContent, 
UNO_QUERY_THROW);
+            xPropertySet->setPropertyValue("CLSID",
+                                           
Any(OUString("12dcae26-281f-416f-a234-c3086127382e")));
+
+            xText->insertTextContent(xCursor, xTextContent, false);
+        }
+        catch (Exception&)
+        {
+        }
+
+        Reference<text::XTextEmbeddedObjectsSupplier> xTEOSupp(xTextDocument, 
UNO_QUERY_THROW);
+
+        return Reference<XInterface>(xTEOSupp->getEmbeddedObjects(), 
UNO_QUERY_THROW);
+    }
+
+    CPPUNIT_TEST_SUITE(SwXTextEmbeddedObjects);
+    CPPUNIT_TEST(testGetByName);
+    CPPUNIT_TEST(testGetElementNames);
+    CPPUNIT_TEST(testHasByName);
+    CPPUNIT_TEST(testGetCount);
+    CPPUNIT_TEST(testGetByIndex);
+    CPPUNIT_TEST(testGetElementType);
+    CPPUNIT_TEST(testHasElements);
+    CPPUNIT_TEST_SUITE_END();
+};
+
+CPPUNIT_TEST_SUITE_REGISTRATION(SwXTextEmbeddedObjects);
+}
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/sw/qa/unoapi/sw_3.sce b/sw/qa/unoapi/sw_3.sce
index cfba03cb16ee..aa0b22cd6ff2 100644
--- a/sw/qa/unoapi/sw_3.sce
+++ b/sw/qa/unoapi/sw_3.sce
@@ -20,7 +20,6 @@
 #i89021 -o sw.SwXTextDefaults
 -o sw.SwXTextDocument
 -o sw.SwXTextEmbeddedObject
--o sw.SwXTextEmbeddedObjects
 -o sw.SwXTextField
 -o sw.SwXTextFrame
 -o sw.SwXTextFrameText

Reply via email to