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

Libreoffice Gerrit user logerrit at kemper.freedesktop.org
Tue Dec 18 17:40:04 UTC 2018


 framework/qa/complex/api_internal/api.lst                      |    1 
 include/test/container/xnameaccess.hxx                         |   46 +++
 qadevOOo/Jar_OOoRunner.mk                                      |    1 
 qadevOOo/objdsc/sc/com.sun.star.comp.office.ScScenariosObj.csv |    3 
 qadevOOo/tests/java/mod/_sc/ScScenariosObj.java                |  139 ----------
 sc/qa/extras/scscenariosobj.cxx                                |    8 
 sc/qa/unoapi/sc_6.sce                                          |    1 
 test/Library_subsequenttest.mk                                 |    1 
 test/source/container/xnameaccess.cxx                          |   56 ++++
 9 files changed, 111 insertions(+), 145 deletions(-)

New commits:
commit 5658da22f77a48599bb20cf6c7c37abf0388186e
Author:     Jens Carl <j.carl43 at gmx.de>
AuthorDate: Tue Dec 18 08:23:28 2018 +0000
Commit:     Jens Carl <j.carl43 at gmx.de>
CommitDate: Tue Dec 18 18:39:41 2018 +0100

    tdf#45904 Move XNameAccess Java tests to C++
    
    Move XNameAccess Java tests to C++ for ScScenariosObj.
    
    Change-Id: I73dd65e672e1e98a6839cea03c30cfafb7da4ff4
    Reviewed-on: https://gerrit.libreoffice.org/65313
    Tested-by: Jenkins
    Reviewed-by: Jens Carl <j.carl43 at gmx.de>

diff --git a/framework/qa/complex/api_internal/api.lst b/framework/qa/complex/api_internal/api.lst
index 9a0f6d95e35c..99b6a69eb497 100644
--- a/framework/qa/complex/api_internal/api.lst
+++ b/framework/qa/complex/api_internal/api.lst
@@ -88,7 +88,6 @@ job96=sc.ScFilterDescriptorBase
 job97=sc.ScFunctionListObj
 job98=sc.ScHeaderFieldObj
 job99=sc.ScHeaderFieldsObj
-job125=sc.ScScenariosObj
 job126=sc.ScSheetLinkObj
 job127=sc.ScSheetLinksObj
 job128=sc.ScSpreadsheetSettings
diff --git a/include/test/container/xnameaccess.hxx b/include/test/container/xnameaccess.hxx
new file mode 100644
index 000000000000..960cf67822b9
--- /dev/null
+++ b/include/test/container/xnameaccess.hxx
@@ -0,0 +1,46 @@
+/* -*- 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_CONTAINER_XNAMEACCESS_HXX
+#define INCLUDED_TEST_CONTAINER_XNAMEACCESS_HXX
+
+#include <com/sun/star/uno/XInterface.hpp>
+
+#include <com/sun/star/uno/Reference.hxx>
+
+#include <test/testdllapi.hxx>
+
+namespace apitest
+{
+class OOO_DLLPUBLIC_TEST XNameAccess
+{
+public:
+    XNameAccess(const OUString& rName)
+        : m_aName(rName)
+    {
+    }
+
+    virtual css::uno::Reference<css::uno::XInterface> init() = 0;
+
+    void testGetByName();
+    void testGetElementNames();
+    void testHasByName();
+
+protected:
+    ~XNameAccess() {}
+
+private:
+    OUString const m_aName;
+};
+
+} // namespace apitest
+
+#endif // INCLUDED_TEST_CONTAINER_XNAMEACCESS_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 ba1cd3c87402..204d556676bd 100644
--- a/qadevOOo/Jar_OOoRunner.mk
+++ b/qadevOOo/Jar_OOoRunner.mk
@@ -988,7 +988,6 @@ $(eval $(call gb_Jar_add_sourcefiles,OOoRunner,\
     qadevOOo/tests/java/mod/_sc/ScHeaderFooterTextObj \
     qadevOOo/tests/java/mod/_sc/ScModelObj \
     qadevOOo/tests/java/mod/_sc/ScNamedRangesObj \
-    qadevOOo/tests/java/mod/_sc/ScScenariosObj \
     qadevOOo/tests/java/mod/_sc/ScShapeObj \
     qadevOOo/tests/java/mod/_sc/ScSheetLinkObj \
     qadevOOo/tests/java/mod/_sc/ScSheetLinksObj \
diff --git a/qadevOOo/objdsc/sc/com.sun.star.comp.office.ScScenariosObj.csv b/qadevOOo/objdsc/sc/com.sun.star.comp.office.ScScenariosObj.csv
deleted file mode 100644
index 668c1cc6d36d..000000000000
--- a/qadevOOo/objdsc/sc/com.sun.star.comp.office.ScScenariosObj.csv
+++ /dev/null
@@ -1,3 +0,0 @@
-"ScScenariosObj";"com::sun::star::container::XNameAccess";"getByName()"
-"ScScenariosObj";"com::sun::star::container::XNameAccess";"getElementNames()"
-"ScScenariosObj";"com::sun::star::container::XNameAccess";"hasByName()"
diff --git a/qadevOOo/tests/java/mod/_sc/ScScenariosObj.java b/qadevOOo/tests/java/mod/_sc/ScScenariosObj.java
deleted file mode 100644
index 7df0671c2f42..000000000000
--- a/qadevOOo/tests/java/mod/_sc/ScScenariosObj.java
+++ /dev/null
@@ -1,139 +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.SOfficeFactory;
-
-import com.sun.star.container.XIndexAccess;
-import com.sun.star.lang.XComponent;
-import com.sun.star.sheet.XCellRangeAddressable;
-import com.sun.star.sheet.XScenariosSupplier;
-import com.sun.star.sheet.XSpreadsheet;
-import com.sun.star.sheet.XSpreadsheetDocument;
-import com.sun.star.sheet.XSpreadsheets;
-import com.sun.star.table.CellRangeAddress;
-import com.sun.star.table.XCellRange;
-import com.sun.star.uno.AnyConverter;
-import com.sun.star.uno.Type;
-import com.sun.star.uno.UnoRuntime;
-import com.sun.star.uno.XInterface;
-
-/**
-* Test for object which is represented by service
-* <code>com.sun.star.sheet.Scenarios</code>. <p>
-* Object implements the following interfaces :
-* <ul>
-*  <li> <code>com::sun::star::container::XNameAccess</code></li>
-*  <li> <code>com::sun::star::container::XElementAccess</code></li>
-*  <li> <code>com::sun::star::sheet::XScenarios</code></li>
-* </ul>
-* @see com.sun.star.sheet.Scenarios
-* @see com.sun.star.container.XNameAccess
-* @see com.sun.star.container.XElementAccess
-* @see com.sun.star.sheet.XScenarios
-* @see ifc.container._XNameAccess
-* @see ifc.container._XElementAccess
-* @see ifc.sheet._XScenarios
-*/
-public class ScScenariosObj extends TestCase {
-    private XSpreadsheetDocument xSpreadsheetDoc;
-
-    /**
-    * Creates Spreadsheet document.
-    */
-    @Override
-    public void initialize( TestParameters Param, PrintWriter log ) throws Exception {
-        // get a soffice factory object
-        SOfficeFactory SOF = SOfficeFactory.getFactory( Param.getMSF());
-        log.println("creating a spreadsheetdocument");
-        xSpreadsheetDoc = SOF.createCalcDoc(null);
-    }
-
-    /**
-    * Disposes Spreadsheet document.
-    */
-    @Override
-    protected void cleanup( TestParameters tParam, PrintWriter log ) {
-        log.println( "    disposing xSheetDoc " );
-        XComponent oComp = UnoRuntime.queryInterface (XComponent.class, xSpreadsheetDoc) ;
-        util.DesktopTools.closeDoc(oComp);
-    }
-
-    /**
-    * Creating a TestEnvironment for the interfaces to be tested.
-    * Retrieves a collection of spreadsheets from a document
-    * and takes one of them. Fills some cells of the spreadsheet.
-    * Retrieves the collection of all scenarios using the interface
-    * <code>XScenariosSupplier</code>. Creates a new scenario and adds it to the
-    * collection. This collection is the instance of the service
-    * <code>com.sun.star.sheet.Scenarios</code>.
-    * Object relations created :
-    * <ul>
-    *  <li> <code>'ADDR'</code> for
-    *      {@link ifc.sheet._XScenarios}(the array of cell range addresses
-    *      of the created scenario)</li>
-    * </ul>
-    * @see com.sun.star.sheet.Scenarios
-    * @see com.sun.star.sheet.XScenariosSupplier
-    */
-    @Override
-    protected TestEnvironment createTestEnvironment(TestParameters Param, PrintWriter log) throws Exception {
-
-        log.println("getting sheets");
-        XSpreadsheets xSpreadsheets = xSpreadsheetDoc.getSheets();
-        log.println("getting a sheet");
-        XSpreadsheet oSheet = null;
-        XIndexAccess oIndexAccess = UnoRuntime.queryInterface(XIndexAccess.class, xSpreadsheets);
-        oSheet = (XSpreadsheet)AnyConverter.toObject(
-                new Type(XSpreadsheet.class),oIndexAccess.getByIndex(0));
-
-        log.println("filling some cells");
-        oSheet.getCellByPosition(5, 5).setValue(15);
-        oSheet.getCellByPosition(1, 4).setValue(10);
-        oSheet.getCellByPosition(2, 0).setValue(-5.15);
-
-        XScenariosSupplier xSupp = UnoRuntime.queryInterface(XScenariosSupplier.class, oSheet);
-        XCellRange oRange = UnoRuntime.queryInterface(XCellRange.class, oSheet);
-        XCellRange myRange = oRange.getCellRangeByName("A1:N4");
-        XCellRangeAddressable oRangeAddr = UnoRuntime.queryInterface(XCellRangeAddressable.class, myRange);
-        CellRangeAddress myAddr = oRangeAddr.getRangeAddress();
-
-        CellRangeAddress[] oAddr = new CellRangeAddress[1];
-        oAddr[0] = myAddr;
-
-        xSupp.getScenarios().addNewByName("ScScenarios", oAddr, "Range");
-
-        XInterface oObj = xSupp.getScenarios();
-
-        TestEnvironment tEnv = new TestEnvironment(oObj);
-
-        log.println("adding ObjectRelation for XScenarios");
-        tEnv.addObjRelation("ADDR", oAddr);
-
-        return tEnv;
-    }
-
-
-}    // finish class ScScenariosObj
-
diff --git a/sc/qa/extras/scscenariosobj.cxx b/sc/qa/extras/scscenariosobj.cxx
index cddbf07f8744..22f35f10cb52 100644
--- a/sc/qa/extras/scscenariosobj.cxx
+++ b/sc/qa/extras/scscenariosobj.cxx
@@ -10,6 +10,7 @@
 #include <test/calc_unoapi_test.hxx>
 #include <test/container/xelementaccess.hxx>
 #include <test/container/xenumerationaccess.hxx>
+#include <test/container/xnameaccess.hxx>
 #include <test/container/xindexaccess.hxx>
 #include <test/sheet/xscenarios.hxx>
 
@@ -40,6 +41,7 @@ namespace sc_apitest
 class ScScenariosObj : public CalcUnoApiTest,
                        public apitest::XElementAccess,
                        public apitest::XEnumerationAccess,
+                       public apitest::XNameAccess,
                        public apitest::XIndexAccess,
                        public apitest::XScenarios
 {
@@ -59,6 +61,11 @@ public:
     // XEnumerationAccess
     CPPUNIT_TEST(testCreateEnumeration);
 
+    // XNameAccess
+    CPPUNIT_TEST(testGetByName);
+    CPPUNIT_TEST(testGetElementNames);
+    CPPUNIT_TEST(testHasByName);
+
     // XIndexAccess
     CPPUNIT_TEST(testGetByIndex);
     CPPUNIT_TEST(testGetCount);
@@ -76,6 +83,7 @@ private:
 ScScenariosObj::ScScenariosObj()
     : CalcUnoApiTest("/sc/qa/extras/testdocuments")
     , XElementAccess(cppu::UnoType<sheet::XScenario>::get())
+    , XNameAccess("ScScenarios")
     , XIndexAccess(1)
 {
 }
diff --git a/sc/qa/unoapi/sc_6.sce b/sc/qa/unoapi/sc_6.sce
index c264f0ab4eda..303ce4a53964 100644
--- a/sc/qa/unoapi/sc_6.sce
+++ b/sc/qa/unoapi/sc_6.sce
@@ -17,7 +17,6 @@
 #
 -o sc.ScModelObj
 -o sc.ScNamedRangesObj
-# -o sc.ScScenariosObj
 # -o sc.ScShapeObj
 # -o sc.ScSheetLinkObj
 -o sc.ScSheetLinksObj
diff --git a/test/Library_subsequenttest.mk b/test/Library_subsequenttest.mk
index 1b71ab44270b..1ce96cbd84ae 100644
--- a/test/Library_subsequenttest.mk
+++ b/test/Library_subsequenttest.mk
@@ -47,6 +47,7 @@ $(eval $(call gb_Library_add_exception_objects,subsequenttest,\
 	test/source/container/xenumeration \
 	test/source/container/xenumerationaccess \
 	test/source/container/xindexaccess \
+	test/source/container/xnameaccess \
 	test/source/container/xnamecontainer \
 	test/source/container/xnamed \
 	test/source/container/xnamereplace \
diff --git a/test/source/container/xnameaccess.cxx b/test/source/container/xnameaccess.cxx
new file mode 100644
index 000000000000..34b5e95da668
--- /dev/null
+++ b/test/source/container/xnameaccess.cxx
@@ -0,0 +1,56 @@
+/* -*- 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/container/xnameaccess.hxx>
+#include <rtl/string.hxx>
+
+#include <com/sun/star/container/NoSuchElementException.hpp>
+#include <com/sun/star/container/XNameAccess.hpp>
+
+#include <com/sun/star/uno/Reference.hxx>
+#include <com/sun/star/uno/Sequence.hxx>
+
+#include <cppunit/extensions/HelperMacros.h>
+
+using namespace css;
+using namespace css::uno;
+
+namespace apitest
+{
+void XNameAccess::testGetByName()
+{
+    uno::Reference<container::XNameAccess> xNA(init(), uno::UNO_QUERY_THROW);
+
+    // test with existing name
+    CPPUNIT_ASSERT_NO_THROW(xNA->getByName(m_aName));
+    // test with non-existing name
+    CPPUNIT_ASSERT_THROW(xNA->getByName(m_aName + "UnitTest"), container::NoSuchElementException);
+}
+
+void XNameAccess::testGetElementNames()
+{
+    uno::Reference<container::XNameAccess> xNA(init(), uno::UNO_QUERY_THROW);
+    uno::Sequence<OUString> aNames = xNA->getElementNames();
+
+    CPPUNIT_ASSERT(aNames.getLength());
+}
+
+void XNameAccess::testHasByName()
+{
+    uno::Reference<container::XNameAccess> xNA(init(), uno::UNO_QUERY_THROW);
+
+    // test with existing name
+    CPPUNIT_ASSERT(xNA->hasByName(m_aName));
+    // test with non-existing name
+    CPPUNIT_ASSERT(!xNA->hasByName(m_aName + "UnitTest"));
+}
+
+} // 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