framework/qa/complex/api_internal/api.lst                           |    1 
 qadevOOo/Jar_OOoRunner.mk                                           |    1 
 qadevOOo/objdsc/sw/com.sun.star.comp.office.SwXTextFieldMasters.csv |    5 
 qadevOOo/tests/java/mod/_sw/SwXTextFieldMasters.java                |  125 
----------
 sw/CppunitTest_sw_apitests.mk                                       |    1 
 sw/qa/api/SwXTextFieldMasters.cxx                                   |   86 
++++++
 sw/qa/unoapi/sw_3.sce                                               |    1 
 7 files changed, 87 insertions(+), 133 deletions(-)

New commits:
commit 0440f57a096c2d8da704b3bc409ecfd74202ac8f
Author:     anfanite396 <[email protected]>
AuthorDate: Thu Aug 24 17:09:56 2023 +0530
Commit:     Tomaž Vajngerl <[email protected]>
CommitDate: Fri Aug 25 08:24:06 2023 +0200

    tdf#45904: Move SwXTextFieldMasters Java tests to C++
    
    Change-Id: Ifa185b24fe49f2c88e4d3687a09ebce5987503a0
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/156051
    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 6e1d1cbe8d65..bcabcb80168d 100644
--- a/framework/qa/complex/api_internal/api.lst
+++ b/framework/qa/complex/api_internal/api.lst
@@ -168,7 +168,6 @@ job231=sw.SwXTextColumns
 job232=sw.SwXTextDefaults
 job233=sw.SwXTextEmbeddedObjects
 job234=sw.SwXTextField
-job235=sw.SwXTextFieldMasters
 job237=sw.SwXTextFrameText
 job238=sw.SwXTextGraphicObjects
 job239=sw.SwXTextPortionEnumeration
diff --git a/qadevOOo/Jar_OOoRunner.mk b/qadevOOo/Jar_OOoRunner.mk
index cb0422a1dbe3..3d5e9824b413 100644
--- a/qadevOOo/Jar_OOoRunner.mk
+++ b/qadevOOo/Jar_OOoRunner.mk
@@ -1132,7 +1132,6 @@ $(eval $(call gb_Jar_add_sourcefiles,OOoRunner,\
     qadevOOo/tests/java/mod/_sw/SwXTextEmbeddedObject \
     qadevOOo/tests/java/mod/_sw/SwXTextEmbeddedObjects \
     qadevOOo/tests/java/mod/_sw/SwXTextField \
-    qadevOOo/tests/java/mod/_sw/SwXTextFieldMasters \
     qadevOOo/tests/java/mod/_sw/SwXTextFrame \
     qadevOOo/tests/java/mod/_sw/SwXTextFrameText \
     qadevOOo/tests/java/mod/_sw/SwXTextGraphicObject \
diff --git 
a/qadevOOo/objdsc/sw/com.sun.star.comp.office.SwXTextFieldMasters.csv 
b/qadevOOo/objdsc/sw/com.sun.star.comp.office.SwXTextFieldMasters.csv
deleted file mode 100644
index 4cc2e926c4eb..000000000000
--- a/qadevOOo/objdsc/sw/com.sun.star.comp.office.SwXTextFieldMasters.csv
+++ /dev/null
@@ -1,5 +0,0 @@
-"SwXTextFieldMasters";"com::sun::star::container::XNameAccess";"getByName()"
-"SwXTextFieldMasters";"com::sun::star::container::XNameAccess";"getElementNames()"
-"SwXTextFieldMasters";"com::sun::star::container::XNameAccess";"hasByName()"
-"SwXTextFieldMasters";"com::sun::star::container::XElementAccess";"getElementType()"
-"SwXTextFieldMasters";"com::sun::star::container::XElementAccess";"hasElements()"
diff --git a/qadevOOo/tests/java/mod/_sw/SwXTextFieldMasters.java 
b/qadevOOo/tests/java/mod/_sw/SwXTextFieldMasters.java
deleted file mode 100644
index 3f6d70705a41..000000000000
--- a/qadevOOo/tests/java/mod/_sw/SwXTextFieldMasters.java
+++ /dev/null
@@ -1,125 +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.StatusException;
-import lib.TestCase;
-import lib.TestEnvironment;
-import lib.TestParameters;
-import util.SOfficeFactory;
-
-import com.sun.star.text.XTextDocument;
-import com.sun.star.text.XTextFieldsSupplier;
-import com.sun.star.uno.UnoRuntime;
-import com.sun.star.uno.XInterface;
-
-/**
- *
- * initial description
- * @see com.sun.star.container.XContainer
- * @see com.sun.star.container.XElementAccess
- * @see com.sun.star.container.XNameAccess
- * @see com.sun.star.container.XNameContainer
- * @see com.sun.star.container.XNameReplace
- *
- */
-public class SwXTextFieldMasters extends TestCase {
-
-    XTextDocument xTextDoc;
-
-    /**
-     * 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() );
-        log.println( "creating a textdocument" );
-        xTextDoc = 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(xTextDoc);
-    }
-
-
-    /**
-     *    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;
-
-        // creation of testobject here
-        // first we write what we are intend to do to log file
-        log.println( "creating a test environment" );
-
-
-        // create testobject here
-        try {
-            XTextFieldsSupplier oTFS = UnoRuntime.queryInterface( 
XTextFieldsSupplier.class, xTextDoc );
-
-            oObj = oTFS.getTextFieldMasters();
-
-        }
-        catch (Exception ex) {
-            log.println("Couldn't create instance");
-            ex.printStackTrace(log);
-        }
-
-        log.println( "creating a new environment for FieldMasters object" );
-        TestEnvironment tEnv = new TestEnvironment( oObj );
-
-        return tEnv;
-    } // finish method getTestEnvironment
-}    // finish class SwXTextFieldMasters
-
diff --git a/sw/CppunitTest_sw_apitests.mk b/sw/CppunitTest_sw_apitests.mk
index 15589d269252..1e70b91dac17 100644
--- a/sw/CppunitTest_sw_apitests.mk
+++ b/sw/CppunitTest_sw_apitests.mk
@@ -40,6 +40,7 @@ $(eval $(call 
gb_CppunitTest_add_exception_objects,sw_apitests, \
     sw/qa/api/SwXTableCellText \
     sw/qa/api/SwXTextFrame \
     sw/qa/api/SwXTextField \
+    sw/qa/api/SwXTextFieldMasters \
     sw/qa/api/SwXTextFieldTypes \
     sw/qa/api/SwXTextSections \
     sw/qa/api/SwXTextTable \
diff --git a/sw/qa/api/SwXTextFieldMasters.cxx 
b/sw/qa/api/SwXTextFieldMasters.cxx
new file mode 100644
index 000000000000..a5d5042dcffa
--- /dev/null
+++ b/sw/qa/api/SwXTextFieldMasters.cxx
@@ -0,0 +1,86 @@
+/* -*- 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/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/text/XTextFieldsSupplier.hpp>
+#include <com/sun/star/beans/XPropertySet.hpp>
+// #include <com/sun/star/container/XNameAccess.hpp>
+
+#include <comphelper/processfactory.hxx>
+
+using namespace css;
+using namespace css::uno;
+
+namespace
+{
+/**
+ * Initial tests for SwXTextFieldMasters.
+ */
+class SwXTextFieldMasters final : public UnoApiTest,
+                                  public apitest::XElementAccess,
+                                  public apitest::XNameAccess
+{
+public:
+    SwXTextFieldMasters()
+        : UnoApiTest("")
+        , XElementAccess(cppu::UnoType<beans::XPropertySet>::get())
+        , 
XNameAccess("com.sun.star.text.fieldmaster.SetExpression.Illustration")
+    {
+    }
+
+    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<text::XTextFieldsSupplier> xTFS;
+
+        try
+        {
+            xTFS = Reference<text::XTextFieldsSupplier>(xTextDocument, 
UNO_QUERY_THROW);
+        }
+        catch (Exception&)
+        {
+        }
+
+        // Reference<container::XNameAccess> xNA = xTFS->getTextFieldMasters();
+        // Sequence<OUString> aNames = xNA->getElementNames();
+        // std::cout << aNames[0] << std::endl;
+
+        return Reference<XInterface>(xTFS->getTextFieldMasters(), 
UNO_QUERY_THROW);
+    }
+
+    CPPUNIT_TEST_SUITE(SwXTextFieldMasters);
+    CPPUNIT_TEST(testGetByName);
+    CPPUNIT_TEST(testGetElementNames);
+    CPPUNIT_TEST(testHasByName);
+    CPPUNIT_TEST(testGetElementType);
+    CPPUNIT_TEST(testHasElements);
+    CPPUNIT_TEST_SUITE_END();
+};
+
+CPPUNIT_TEST_SUITE_REGISTRATION(SwXTextFieldMasters);
+}
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/sw/qa/unoapi/sw_3.sce b/sw/qa/unoapi/sw_3.sce
index 759419baebb0..cfba03cb16ee 100644
--- a/sw/qa/unoapi/sw_3.sce
+++ b/sw/qa/unoapi/sw_3.sce
@@ -22,7 +22,6 @@
 -o sw.SwXTextEmbeddedObject
 -o sw.SwXTextEmbeddedObjects
 -o sw.SwXTextField
--o sw.SwXTextFieldMasters
 -o sw.SwXTextFrame
 -o sw.SwXTextFrameText
 -o sw.SwXTextGraphicObject

Reply via email to