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

Jens Carl j.carl43 at gmx.de
Fri Mar 9 17:30:59 UTC 2018


 include/test/sheet/sheetlink.hxx                               |   34 +++
 qadevOOo/Jar_OOoRunner.mk                                      |    1 
 qadevOOo/objdsc/sc/com.sun.star.comp.office.ScSheetLinkObj.csv |    3 
 qadevOOo/tests/java/ifc/sheet/_SheetLink.java                  |   77 -------
 sc/CppunitTest_sc_sheetlinkobj.mk                              |  105 ++++++++++
 sc/Module_sc.mk                                                |    1 
 sc/qa/extras/scsheetlinkobj.cxx                                |  103 +++++++++
 test/Library_subsequenttest.mk                                 |    1 
 test/source/sheet/sheetlink.cxx                                |   67 ++++++
 9 files changed, 311 insertions(+), 81 deletions(-)

New commits:
commit b8563d46a03567df0780216173b10156e158b64e
Author: Jens Carl <j.carl43 at gmx.de>
Date:   Fri Mar 9 07:32:31 2018 +0000

    tdf#45904 Move _SheetLink Java tests to C++
    
    Change-Id: I33813be65bcb44c11a35bc97d963057418a28d9e
    Reviewed-on: https://gerrit.libreoffice.org/50984
    Tested-by: Jenkins <ci at libreoffice.org>
    Reviewed-by: Jens Carl <j.carl43 at gmx.de>

diff --git a/include/test/sheet/sheetlink.hxx b/include/test/sheet/sheetlink.hxx
new file mode 100644
index 000000000000..0f9e033a8b68
--- /dev/null
+++ b/include/test/sheet/sheetlink.hxx
@@ -0,0 +1,34 @@
+/* -*- 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_SHEET_SHEETLINK_HXX
+#define INCLUDED_TEST_SHEET_SHEETLINK_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 SheetLink
+{
+public:
+    virtual css::uno::Reference<css::uno::XInterface> init() = 0;
+
+    void testSheetLinkProperties();
+
+protected:
+    ~SheetLink() {}
+};
+}
+
+#endif // INCLUDED_TEST_SHEET_SHEETLINK_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 d57a9e7543fb..4c4b28b8fd7a 100644
--- a/qadevOOo/Jar_OOoRunner.mk
+++ b/qadevOOo/Jar_OOoRunner.mk
@@ -564,7 +564,6 @@ $(eval $(call gb_Jar_add_sourcefiles,OOoRunner,\
     qadevOOo/tests/java/ifc/sdb/_XSingleSelectQueryComposer \
     qadevOOo/tests/java/ifc/sdb/_XSQLErrorBroadcaster \
     qadevOOo/tests/java/ifc/sheet/_FunctionDescription \
-    qadevOOo/tests/java/ifc/sheet/_SheetLink \
     qadevOOo/tests/java/ifc/sheet/_SheetSortDescriptor \
     qadevOOo/tests/java/ifc/sheet/_Spreadsheet \
     qadevOOo/tests/java/ifc/sheet/_SpreadsheetDocument \
diff --git a/qadevOOo/objdsc/sc/com.sun.star.comp.office.ScSheetLinkObj.csv b/qadevOOo/objdsc/sc/com.sun.star.comp.office.ScSheetLinkObj.csv
index 9caf4204d036..fb11276d69cb 100644
--- a/qadevOOo/objdsc/sc/com.sun.star.comp.office.ScSheetLinkObj.csv
+++ b/qadevOOo/objdsc/sc/com.sun.star.comp.office.ScSheetLinkObj.csv
@@ -1,9 +1,6 @@
 "ScSheetLinkObj";"com::sun::star::util::XRefreshable";"refresh()"
 "ScSheetLinkObj";"com::sun::star::util::XRefreshable";"addRefreshListener()"
 "ScSheetLinkObj";"com::sun::star::util::XRefreshable";"removeRefreshListener()"
-"ScSheetLinkObj";"com::sun::star::sheet::SheetLink";"Url"
-"ScSheetLinkObj";"com::sun::star::sheet::SheetLink";"Filter"
-"ScSheetLinkObj";"com::sun::star::sheet::SheetLink";"FilterOptions"
 "ScSheetLinkObj";"com::sun::star::container::XNamed";"getName()"
 "ScSheetLinkObj";"com::sun::star::container::XNamed";"setName()"
 "ScSheetLinkObj";"com::sun::star::beans::XPropertySet";"getPropertySetInfo()"
diff --git a/qadevOOo/tests/java/ifc/sheet/_SheetLink.java b/qadevOOo/tests/java/ifc/sheet/_SheetLink.java
deleted file mode 100644
index 503d13a72864..000000000000
--- a/qadevOOo/tests/java/ifc/sheet/_SheetLink.java
+++ /dev/null
@@ -1,77 +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 ifc.sheet;
-
-import lib.MultiPropertyTest;
-import util.ValueChanger;
-
-/**
-* Testing <code>com.sun.star.sheet.SheetLink</code>
-* service properties :
-* <ul>
-*  <li><code> Url</code></li>
-*  <li><code> Filter</code></li>
-*  <li><code> FilterOptions</code></li>
-* </ul> <p>
-* Properties testing is automated by <code>lib.MultiPropertyTest</code>.
-* @see com.sun.star.sheet.SheetLink
-*/
-public class _SheetLink extends MultiPropertyTest {
-
-    /**
-     *This class is destined to custom test of property <code>Url</code>.
-     */
-    protected PropertyTester UrlTester = new PropertyTester() {
-        @Override
-        protected Object getNewValue(String propName, Object oldValue) {
-            String newValue = (String) ValueChanger.changePValue(oldValue);
-            if ( !newValue.startsWith("file://") ) {
-                newValue = "file://" + newValue;
-            }
-
-            return newValue;
-        }
-    };
-
-    /**
-     * Test property <code>Url</code> using custom <code>PropertyTest</code>.
-     */
-    public void _Url() {
-        testProperty("Url", UrlTester);
-    }
-
-    /**
-     *This class is destined to custom test of property <code>Filter</code>.
-     */
-    protected PropertyTester FilterTester = new PropertyTester() {
-        @Override
-        protected Object getNewValue(String propName, Object oldValue) {
-            return "StarCalc 4.0";
-        }
-    };
-
-    /**
-     * Test property <code>Filter</code> using custom <code>PropertyTest</code>.
-     */
-    public void _Filter() {
-        testProperty("Filter", FilterTester);
-    }
-}
-
-
diff --git a/sc/CppunitTest_sc_sheetlinkobj.mk b/sc/CppunitTest_sc_sheetlinkobj.mk
new file mode 100644
index 000000000000..34e1e8c326b0
--- /dev/null
+++ b/sc/CppunitTest_sc_sheetlinkobj.mk
@@ -0,0 +1,105 @@
+# -*- Mode: makefile-gmake; tab-width: 4; indent-tabs-mode: t -*-
+#*************************************************************************
+#
+# 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/.
+#
+#*************************************************************************
+
+$(eval $(call gb_CppunitTest_CppunitTest,sc_sheetlinkobj))
+
+$(eval $(call gb_CppunitTest_use_external,sc_sheetlinkobj,boost_headers))
+
+$(eval $(call gb_CppunitTest_add_exception_objects,sc_sheetlinkobj, \
+	sc/qa/extras/scsheetlinkobj \
+))
+
+$(eval $(call gb_CppunitTest_use_libraries,sc_sheetlinkobj, \
+	basegfx \
+	comphelper \
+	cppu \
+	cppuhelper \
+	drawinglayer \
+	editeng \
+	for \
+	forui \
+	i18nlangtag \
+	msfilter \
+	oox \
+	sal \
+	salhelper \
+	sax \
+	sb \
+	sc \
+	sfx \
+	sot \
+	subsequenttest \
+	svl \
+	svt \
+	svx \
+	svxcore \
+	test \
+	tk \
+	tl \
+	ucbhelper \
+	unotest \
+	utl \
+	vbahelper \
+	vcl \
+	xo \
+))
+
+$(eval $(call gb_CppunitTest_set_include,sc_sheetlinkobj,\
+	-I$(SRCDIR)/sc/source/ui/inc \
+	-I$(SRCDIR)/sc/inc \
+	$$(INCLUDE) \
+))
+
+$(eval $(call gb_CppunitTest_use_sdk_api,sc_sheetlinkobj))
+
+$(eval $(call gb_CppunitTest_use_ure,sc_sheetlinkobj))
+$(eval $(call gb_CppunitTest_use_vcl,sc_sheetlinkobj))
+
+$(eval $(call gb_CppunitTest_use_components,sc_sheetlinkobj,\
+	basic/util/sb \
+	comphelper/util/comphelp \
+	configmgr/source/configmgr \
+	dbaccess/util/dba \
+	filter/source/config/cache/filterconfig1 \
+	filter/source/storagefilterdetect/storagefd \
+	forms/util/frm \
+	framework/util/fwk \
+	i18npool/util/i18npool \
+	linguistic/source/lng \
+	oox/util/oox \
+	package/source/xstor/xstor \
+	package/util/package2 \
+	sax/source/expatwrap/expwrap \
+	scripting/source/basprov/basprov \
+	scripting/util/scriptframe \
+	sc/util/sc \
+	sc/util/scd \
+	sc/util/scfilt \
+	$(call gb_Helper_optional,SCRIPTING, \
+		sc/util/vbaobj) \
+	sfx2/util/sfx \
+	sot/util/sot \
+	svl/source/fsstor/fsstorage \
+	toolkit/util/tk \
+	ucb/source/core/ucb1 \
+	ucb/source/ucp/file/ucpfile1 \
+	ucb/source/ucp/tdoc/ucptdoc1 \
+	unotools/util/utl \
+	unoxml/source/rdf/unordf \
+	unoxml/source/service/unoxml \
+	uui/util/uui \
+	xmloff/util/xo \
+	svtools/util/svt \
+))
+
+$(eval $(call gb_CppunitTest_use_configuration,sc_sheetlinkobj))
+
+# vim: set noet sw=4 ts=4:
diff --git a/sc/Module_sc.mk b/sc/Module_sc.mk
index 482b77e4e93e..808ce932152a 100644
--- a/sc/Module_sc.mk
+++ b/sc/Module_sc.mk
@@ -153,6 +153,7 @@ $(eval $(call gb_Module_add_subsequentcheck_targets,sc,\
 	CppunitTest_sc_documentconfigurationobj \
 	CppunitTest_sc_spreadsheetsettingsobj \
 	CppunitTest_sc_shapeobj \
+	CppunitTest_sc_sheetlinkobj \
 ))
 
 $(eval $(call gb_Module_add_perfcheck_targets,sc,\
diff --git a/sc/qa/extras/scsheetlinkobj.cxx b/sc/qa/extras/scsheetlinkobj.cxx
new file mode 100644
index 000000000000..57a85cc8009e
--- /dev/null
+++ b/sc/qa/extras/scsheetlinkobj.cxx
@@ -0,0 +1,103 @@
+/* -*- 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/calc_unoapi_test.hxx>
+#include <test/sheet/sheetlink.hxx>
+
+#include <com/sun/star/beans/XPropertySet.hpp>
+#include <com/sun/star/container/XIndexAccess.hpp>
+#include <com/sun/star/container/XNameAccess.hpp>
+#include <com/sun/star/lang/XComponent.hpp>
+#include <com/sun/star/sheet/SheetLinkMode.hpp>
+#include <com/sun/star/sheet/XSheetLinkable.hpp>
+#include <com/sun/star/sheet/XSpreadsheet.hpp>
+#include <com/sun/star/sheet/XSpreadsheetDocument.hpp>
+#include <com/sun/star/sheet/XSpreadsheets.hpp>
+#include <com/sun/star/uno/XInterface.hpp>
+
+#include <com/sun/star/uno/Reference.hxx>
+
+using namespace css;
+using namespace css::uno;
+using namespace com::sun::star;
+
+namespace sc_apitest
+{
+class ScSheetLinkObj : public CalcUnoApiTest, public apitest::SheetLink
+{
+public:
+    ScSheetLinkObj();
+
+    virtual uno::Reference<uno::XInterface> init() override;
+
+    virtual void setUp() override;
+    virtual void tearDown() override;
+
+    CPPUNIT_TEST_SUITE(ScSheetLinkObj);
+
+    // SheetLink
+    CPPUNIT_TEST(testSheetLinkProperties);
+
+    CPPUNIT_TEST_SUITE_END();
+
+private:
+    uno::Reference<lang::XComponent> mxComponent;
+    OUString maUrl;
+};
+
+ScSheetLinkObj::ScSheetLinkObj()
+    : CalcUnoApiTest("/sc/qa/extras/testdocuments")
+{
+}
+
+uno::Reference<uno::XInterface> ScSheetLinkObj::init()
+{
+    uno::Reference<sheet::XSpreadsheetDocument> xDoc(mxComponent, UNO_QUERY_THROW);
+    CPPUNIT_ASSERT_MESSAGE("no calc document", xDoc.is());
+
+    uno::Reference<sheet::XSpreadsheets> xSheets(xDoc->getSheets(), UNO_QUERY_THROW);
+    uno::Reference<container::XIndexAccess> xIA(xSheets, UNO_QUERY_THROW);
+    uno::Reference<sheet::XSpreadsheet> xSheet(xIA->getByIndex(0), UNO_QUERY_THROW);
+
+    uno::Reference<sheet::XSheetLinkable> xSL(xSheet, UNO_QUERY_THROW);
+    OUString aFileURL;
+    createFileURL("ScSheetLinkObj.ods", aFileURL);
+    xSL->link(aFileURL, "Sheet1", "", "", sheet::SheetLinkMode_VALUE);
+
+    uno::Reference<beans::XPropertySet> xPropSet(xDoc, UNO_QUERY_THROW);
+    uno::Reference<container::XNameAccess> sheetLinks;
+    CPPUNIT_ASSERT(xPropSet->getPropertyValue("SheetLinks") >>= sheetLinks);
+    CPPUNIT_ASSERT(sheetLinks.is());
+
+    uno::Any aAny = sheetLinks->getByName(sheetLinks->getElementNames()[0]);
+    uno::Reference<beans::XPropertySet> sheetLink;
+    aAny >>= sheetLink;
+    return sheetLink;
+}
+
+void ScSheetLinkObj::setUp()
+{
+    CalcUnoApiTest::setUp();
+    // create a calc document
+    mxComponent = loadFromDesktop("private:factory/scalc");
+}
+
+void ScSheetLinkObj::tearDown()
+{
+    closeDocument(mxComponent);
+    CalcUnoApiTest::tearDown();
+}
+
+CPPUNIT_TEST_SUITE_REGISTRATION(ScSheetLinkObj);
+
+} // end namespace
+
+CPPUNIT_PLUGIN_IMPLEMENT();
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab cinoptions=b1,g0,N-s cinkeys+=0=break: */
diff --git a/test/Library_subsequenttest.mk b/test/Library_subsequenttest.mk
index 65c638525a07..9aeceaf1e4f4 100644
--- a/test/Library_subsequenttest.mk
+++ b/test/Library_subsequenttest.mk
@@ -58,6 +58,7 @@ $(eval $(call gb_Library_add_exception_objects,subsequenttest,\
 	test/source/sheet/sheetcellrange \
 	test/source/sheet/sheetcellranges \
 	test/source/sheet/sheetfilterdescriptor \
+	test/source/sheet/sheetlink \
 	test/source/sheet/tableautoformat \
 	test/source/sheet/tablevalidation \
 	test/source/sheet/xarealink \
diff --git a/test/source/sheet/sheetlink.cxx b/test/source/sheet/sheetlink.cxx
new file mode 100644
index 000000000000..9d47b5f71e0f
--- /dev/null
+++ b/test/source/sheet/sheetlink.cxx
@@ -0,0 +1,67 @@
+/* -*- 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/sheet/sheetlink.hxx>
+
+#include <com/sun/star/beans/XPropertySet.hpp>
+#include <com/sun/star/uno/Any.hxx>
+#include <com/sun/star/uno/Reference.hxx>
+
+#include <cppunit/extensions/HelperMacros.h>
+
+using namespace com::sun::star;
+using namespace com::sun::star::uno;
+
+namespace apitest
+{
+void SheetLink::testSheetLinkProperties()
+{
+    uno::Reference<beans::XPropertySet> xSheetLink(init(), UNO_QUERY_THROW);
+    OUString propName;
+    uno::Any aNewValue;
+
+    propName = "Url";
+    OUString aUrlGet;
+    OUString aUrlSet;
+    CPPUNIT_ASSERT_MESSAGE("Unable to get PropertyValue Url",
+                           xSheetLink->getPropertyValue(propName) >>= aUrlGet);
+
+    aNewValue <<= OUString("file:///tmp/ScSheetLinkObj.ods");
+    xSheetLink->setPropertyValue(propName, aNewValue);
+    CPPUNIT_ASSERT(xSheetLink->getPropertyValue(propName) >>= aUrlSet);
+    CPPUNIT_ASSERT_EQUAL_MESSAGE("Unable to set PropertyValue Url",
+                                 OUString("file:///tmp/ScSheetLinkObj.ods"), aUrlSet);
+
+    propName = "Filter";
+    OUString aFilterGet;
+    OUString aFilterSet;
+    CPPUNIT_ASSERT_MESSAGE("Unable to get PropertyValue Filter",
+                           xSheetLink->getPropertyValue(propName) >>= aFilterGet);
+
+    aNewValue <<= OUString("Text - txt - csv (StarCalc)");
+    xSheetLink->setPropertyValue(propName, aNewValue);
+    CPPUNIT_ASSERT(xSheetLink->getPropertyValue(propName) >>= aFilterSet);
+    CPPUNIT_ASSERT_EQUAL_MESSAGE("Unable to set PropertyValue Filter",
+                                 OUString("Text - txt - csv (StarCalc)"), aFilterSet);
+
+    propName = "FilterOptions";
+    OUString aFilterOptionsGet;
+    OUString aFilterOptionsSet;
+    CPPUNIT_ASSERT_MESSAGE("Unable to get PropertyValue FilterOptions",
+                           xSheetLink->getPropertyValue(propName) >>= aFilterOptionsGet);
+
+    aNewValue <<= OUString("NewValue");
+    xSheetLink->setPropertyValue(propName, aNewValue);
+    CPPUNIT_ASSERT(xSheetLink->getPropertyValue(propName) >>= aFilterOptionsSet);
+    CPPUNIT_ASSERT_EQUAL_MESSAGE("Unable to set PropertyValue FilterOptions", OUString("NewValue"),
+                                 aFilterOptionsSet);
+}
+}
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab cinoptions=b1,g0,N-s cinkeys+=0=break: */


More information about the Libreoffice-commits mailing list