include/test/sheet/cellarealink.hxx | 18 + qadevOOo/Jar_OOoRunner.mk | 1 qadevOOo/objdsc/sc/com.sun.star.comp.office.ScAreaLinkObj.csv | 3 qadevOOo/tests/java/mod/_sc/ScAreaLinkObj.java | 117 ---------- sc/qa/extras/scarealinkobj.cxx | 11 sc/qa/extras/testdocuments/scarealinkobj.ods |binary sc/qa/unoapi/sc_2.sce | 1 test/source/sheet/cellarealink.cxx | 44 ++- test/source/sheet/xarealink.cxx | 13 - 9 files changed, 56 insertions(+), 152 deletions(-)
New commits: commit fe632c86aa250bb355a59ce6acf4dd75eae7afe0 Author: Jens Carl <j.car...@gmx.de> AuthorDate: Fri Mar 8 22:48:04 2019 +0000 Commit: Jens Carl <j.car...@gmx.de> CommitDate: Sat Mar 9 02:52:05 2019 +0100 tdf#45904 Move XRefreshable Java tests to C++ Move XRefreshable Java tests to C++ for ScAreaLinkObj. To make this test work, had to provide parameter aSourceArea (in this case file sc/qa/extras/testdocuments/scarealinkobj.ods). All the other depended tests of ScAreaLinkObj had to adjusted to the new test environment. Also fixes i84711, because the XRefreshable test runs independent from the other tests, as mentioned in the bug description. Change-Id: I8847813431e2fdd60ed95be0f7d115bcaeafe500 Reviewed-on: https://gerrit.libreoffice.org/68949 Tested-by: Jenkins Reviewed-by: Jens Carl <j.car...@gmx.de> diff --git a/include/test/sheet/cellarealink.hxx b/include/test/sheet/cellarealink.hxx index a5f63747d316..6eff944ae7be 100644 --- a/include/test/sheet/cellarealink.hxx +++ b/include/test/sheet/cellarealink.hxx @@ -11,15 +11,22 @@ #define INCLUDED_TEST_SHEET_CELLAREALINK_HXX #include <com/sun/star/uno/XInterface.hpp> + #include <com/sun/star/uno/Reference.hxx> -#include <test/testdllapi.hxx> -namespace apitest { +#include <test/testdllapi.hxx> +#include <rtl/string.hxx> +namespace apitest +{ class OOO_DLLPUBLIC_TEST CellAreaLink { public: - virtual css::uno::Reference< css::uno::XInterface > init() = 0; + CellAreaLink(const OUString& rFileURL) + : m_aFileURL(rFileURL) + { + } + virtual css::uno::Reference<css::uno::XInterface> init() = 0; void testUrl(); void testFilter(); @@ -29,9 +36,12 @@ public: protected: ~CellAreaLink() {} + +private: + OUString const m_aFileURL; }; -} +} // namespace apitest #endif // INCLUDED_TEST_SHEET_CELLAREALINK_HXX diff --git a/qadevOOo/Jar_OOoRunner.mk b/qadevOOo/Jar_OOoRunner.mk index 2e025ea03057..d592ff21e77a 100644 --- a/qadevOOo/Jar_OOoRunner.mk +++ b/qadevOOo/Jar_OOoRunner.mk @@ -950,7 +950,6 @@ $(eval $(call gb_Jar_add_sourcefiles,OOoRunner,\ qadevOOo/tests/java/mod/_sc/ScAccessibleSpreadsheet \ qadevOOo/tests/java/mod/_sc/ScAnnotationShapeObj \ qadevOOo/tests/java/mod/_sc/ScAnnotationTextCursor \ - qadevOOo/tests/java/mod/_sc/ScAreaLinkObj \ qadevOOo/tests/java/mod/_sc/ScAutoFormatFieldObj \ qadevOOo/tests/java/mod/_sc/ScAutoFormatObj \ qadevOOo/tests/java/mod/_sc/ScAutoFormatsObj \ diff --git a/qadevOOo/objdsc/sc/com.sun.star.comp.office.ScAreaLinkObj.csv b/qadevOOo/objdsc/sc/com.sun.star.comp.office.ScAreaLinkObj.csv deleted file mode 100644 index d5d82c8483f0..000000000000 --- a/qadevOOo/objdsc/sc/com.sun.star.comp.office.ScAreaLinkObj.csv +++ /dev/null @@ -1,3 +0,0 @@ -"ScAreaLinkObj";"com::sun::star::util::XRefreshable";"refresh()" -"ScAreaLinkObj";"com::sun::star::util::XRefreshable";"addRefreshListener()" -"ScAreaLinkObj";"com::sun::star::util::XRefreshable";"removeRefreshListener()" diff --git a/qadevOOo/tests/java/mod/_sc/ScAreaLinkObj.java b/qadevOOo/tests/java/mod/_sc/ScAreaLinkObj.java deleted file mode 100644 index f40eea8a509f..000000000000 --- a/qadevOOo/tests/java/mod/_sc/ScAreaLinkObj.java +++ /dev/null @@ -1,117 +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.beans.XPropertySet; -import com.sun.star.lang.XComponent; -import com.sun.star.sheet.XAreaLinks; -import com.sun.star.sheet.XSpreadsheetDocument; -import com.sun.star.table.CellAddress; -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.CellAreaLink</code>. -* This object reflects some cell range (this range -* can also be from another saved document) in -* any range (of the same size) of the current -* document.<p> -* Object implements the following interfaces : -* <ul> -* <li> <code>com::sun::star::sheet::XAreaLink</code></li> -* <li> <code>com::sun::star::util::XRefreshable</code></li> -* <li> <code>com::sun::star::sheet::CellAreaLink</code></li> -* <li> <code>com::sun::star::beans::XPropertySet</code></li> -* </ul> -* This object test <b> is NOT </b> designed to be run in several -* threads concurrently. -* @see com.sun.star.sheet.XAreaLink -* @see com.sun.star.util.XRefreshable -* @see com.sun.star.sheet.CellAreaLink -* @see com.sun.star.beans.XPropertySet -* @see ifc.sheet._XAreaLink -* @see ifc.util._XRefreshable -* @see ifc.sheet._CellAreaLink -* @see ifc.beans._XPropertySet -*/ -public class ScAreaLinkObj extends TestCase { - private XSpreadsheetDocument xSheetDoc = null; - - /** - * Creates Spreadsheet document. - */ - @Override - protected void initialize( TestParameters tParam, PrintWriter log ) throws Exception { - SOfficeFactory SOF = SOfficeFactory.getFactory( tParam.getMSF() ); - log.println( "creating a Spreadsheet document" ); - xSheetDoc = SOF.createCalcDoc(null); - } - - /** - * Disposes Spreadsheet document. - */ - @Override - protected void cleanup( TestParameters tParam, PrintWriter log ) { - log.println( " disposing xSheetDoc " ); - XComponent oComp = UnoRuntime.queryInterface - (XComponent.class, xSheetDoc) ; - util.DesktopTools.closeDoc(oComp); - } - - - /** - * Creating a TestEnvironment for the interfaces to be tested. - * Retrieves a collection of Area Links using the 'AreaLinks' - * property of the Spreadsheet document. Adds a new link to this - * collection, which has a source in the same document. This - * link is passed as a tested object. - */ - @Override - public TestEnvironment createTestEnvironment - ( TestParameters Param, PrintWriter log ) throws Exception { - - XInterface oObj = null; - - // creation of testobject here - XPropertySet props = UnoRuntime.queryInterface - (XPropertySet.class, xSheetDoc); - XAreaLinks links = (XAreaLinks) AnyConverter.toObject( - new Type(XAreaLinks.class),props.getPropertyValue("AreaLinks")) ; - CellAddress addr = new CellAddress ((short) 1,2,3) ; - String aSourceArea = util.utils.getFullTestURL("calcshapes.sxc"); - links.insertAtPosition (addr, aSourceArea, "a2:b5", "", "") ; - - oObj = (XInterface) AnyConverter.toObject( - new Type(XInterface.class), links.getByIndex(0)) ; - - TestEnvironment tEnv = new TestEnvironment(oObj) ; - - return tEnv; - } -} diff --git a/sc/qa/extras/scarealinkobj.cxx b/sc/qa/extras/scarealinkobj.cxx index 5584747b1242..6a704120834d 100644 --- a/sc/qa/extras/scarealinkobj.cxx +++ b/sc/qa/extras/scarealinkobj.cxx @@ -11,6 +11,8 @@ #include <test/beans/xpropertyset.hxx> #include <test/sheet/cellarealink.hxx> #include <test/sheet/xarealink.hxx> +#include <test/util/xrefreshable.hxx> +#include <sfx2/app.hxx> #include <com/sun/star/beans/XPropertySet.hpp> #include <com/sun/star/lang/XComponent.hpp> @@ -29,7 +31,8 @@ namespace sc_apitest class ScAreaLinkObj : public CalcUnoApiTest, public apitest::CellAreaLink, public apitest::XAreaLink, - public apitest::XPropertySet + public apitest::XPropertySet, + public apitest::XRefreshable { public: ScAreaLinkObj(); @@ -60,6 +63,9 @@ public: CPPUNIT_TEST(testPropertyChangeListener); CPPUNIT_TEST(testVetoableChangeListener); + // XRefreshable + CPPUNIT_TEST(testRefreshListener); + CPPUNIT_TEST_SUITE_END(); private: @@ -68,6 +74,7 @@ private: ScAreaLinkObj::ScAreaLinkObj() : CalcUnoApiTest("/sc/qa/extras/testdocuments") + , CellAreaLink(m_directories.getURLFromSrc("/sc/qa/extras/testdocuments/scarealinkobj.ods")) { } @@ -80,7 +87,7 @@ uno::Reference<uno::XInterface> ScAreaLinkObj::init() uno::UNO_QUERY_THROW); table::CellAddress aCellAddress(1, 2, 3); - xLinks->insertAtPosition(aCellAddress, "", "a1:c1", "", ""); + xLinks->insertAtPosition(aCellAddress, m_directories.getURLFromSrc("/sc/qa/extras/testdocuments/scarealinkobj.ods"), "a2:b5", "", ""); uno::Reference<sheet::XAreaLink> xLink(xLinks->getByIndex(0), uno::UNO_QUERY_THROW); return xLink; diff --git a/sc/qa/extras/testdocuments/scarealinkobj.ods b/sc/qa/extras/testdocuments/scarealinkobj.ods new file mode 100644 index 000000000000..7f09e0d978eb Binary files /dev/null and b/sc/qa/extras/testdocuments/scarealinkobj.ods differ diff --git a/sc/qa/unoapi/sc_2.sce b/sc/qa/unoapi/sc_2.sce index 21c1671d9e91..0bc25a0d4cda 100644 --- a/sc/qa/unoapi/sc_2.sce +++ b/sc/qa/unoapi/sc_2.sce @@ -22,7 +22,6 @@ # fdo#45337 -o sc.ScAccessibleSpreadsheet # FIXME_REMOVE_WHEN_RE_BASE_COMPLETE # -o sc.ScAnnotationShapeObj --o sc.ScAreaLinkObj -o sc.ScAutoFormatFieldObj -o sc.ScAutoFormatObj -o sc.ScAutoFormatsObj diff --git a/test/source/sheet/cellarealink.cxx b/test/source/sheet/cellarealink.cxx index 80ece911e122..7e64561ab3fc 100644 --- a/test/source/sheet/cellarealink.cxx +++ b/test/source/sheet/cellarealink.cxx @@ -8,6 +8,7 @@ */ #include <test/sheet/cellarealink.hxx> +#include <sfx2/app.hxx> #include <com/sun/star/beans/XPropertySet.hpp> #include <com/sun/star/sheet/XAreaLink.hpp> @@ -15,22 +16,19 @@ #include <cppunit/extensions/HelperMacros.h> -using namespace com::sun::star; -using namespace com::sun::star::uno; - -namespace apitest { +using namespace css; +namespace apitest +{ void CellAreaLink::testUrl() { - uno::Reference< beans::XPropertySet > xCellAreaLink(init(), UNO_QUERY_THROW); + uno::Reference<beans::XPropertySet> xCellAreaLink(init(), uno::UNO_QUERY_THROW); const OUString propName("Url"); OUString aUrl; CPPUNIT_ASSERT(xCellAreaLink->getPropertyValue(propName) >>= aUrl); - // FIXME: set a value in ScAreaLinkObj (if nothing is used it points to the home directory - // of the user) - //CPPUNIT_ASSERT_EQUAL_MESSAGE("Default Url already changed", OUString("file:///home/"), aUrl); + CPPUNIT_ASSERT_EQUAL_MESSAGE("Default Url already changed", m_aFileURL, aUrl); uno::Any aNewUrl; aNewUrl <<= OUString("file:///tmp"); @@ -41,13 +39,13 @@ void CellAreaLink::testUrl() void CellAreaLink::testFilter() { - uno::Reference< beans::XPropertySet > xCellAreaLink(init(), UNO_QUERY_THROW); + uno::Reference<beans::XPropertySet> xCellAreaLink(init(), uno::UNO_QUERY_THROW); const OUString propName("Filter"); OUString aFilter; CPPUNIT_ASSERT(xCellAreaLink->getPropertyValue(propName) >>= aFilter); - CPPUNIT_ASSERT_EQUAL_MESSAGE("Default Filter already changed", OUString(""), aFilter); + CPPUNIT_ASSERT_EQUAL_MESSAGE("Default Filter already changed", OUString("calc8"), aFilter); uno::Any aNewFilter; aNewFilter <<= OUString("UnitTest"); @@ -58,55 +56,61 @@ void CellAreaLink::testFilter() void CellAreaLink::testFilterOptions() { - uno::Reference< beans::XPropertySet > xCellAreaLink(init(), UNO_QUERY_THROW); + uno::Reference<beans::XPropertySet> xCellAreaLink(init(), uno::UNO_QUERY_THROW); const OUString propName("FilterOptions"); OUString aFilterOptions; CPPUNIT_ASSERT(xCellAreaLink->getPropertyValue(propName) >>= aFilterOptions); - CPPUNIT_ASSERT_EQUAL_MESSAGE("Default FilterOptions already changed", OUString(""), aFilterOptions); + CPPUNIT_ASSERT_EQUAL_MESSAGE("Default FilterOptions already changed", OUString(""), + aFilterOptions); uno::Any aNewFilterOptions; aNewFilterOptions <<= OUString("UnitTest"); xCellAreaLink->setPropertyValue(propName, aNewFilterOptions); CPPUNIT_ASSERT(xCellAreaLink->getPropertyValue(propName) >>= aFilterOptions); - CPPUNIT_ASSERT_EQUAL_MESSAGE("Value of FilterOptions wasn't changed", OUString("UnitTest"), aFilterOptions); + CPPUNIT_ASSERT_EQUAL_MESSAGE("Value of FilterOptions wasn't changed", OUString("UnitTest"), + aFilterOptions); } void CellAreaLink::testRefreshDelay() { - uno::Reference< beans::XPropertySet > xCellAreaLink(init(), UNO_QUERY_THROW); + uno::Reference<beans::XPropertySet> xCellAreaLink(init(), uno::UNO_QUERY_THROW); const OUString propName("RefreshDelay"); sal_Int32 aRefreshDelay = 0; CPPUNIT_ASSERT(xCellAreaLink->getPropertyValue(propName) >>= aRefreshDelay); - CPPUNIT_ASSERT_EQUAL_MESSAGE("Default RefreshDelay already changed", sal_Int32(0), aRefreshDelay); + CPPUNIT_ASSERT_EQUAL_MESSAGE("Default RefreshDelay already changed", sal_Int32(0), + aRefreshDelay); uno::Any aNewRefreshDelay; aNewRefreshDelay <<= static_cast<sal_Int32>(42); xCellAreaLink->setPropertyValue(propName, aNewRefreshDelay); CPPUNIT_ASSERT(xCellAreaLink->getPropertyValue(propName) >>= aRefreshDelay); - CPPUNIT_ASSERT_EQUAL_MESSAGE("Value of RefreshDelay wasn't changed", sal_Int32(42), aRefreshDelay); + CPPUNIT_ASSERT_EQUAL_MESSAGE("Value of RefreshDelay wasn't changed", sal_Int32(42), + aRefreshDelay); } void CellAreaLink::testRefreshPeriod() { - uno::Reference< beans::XPropertySet > xCellAreaLink(init(), UNO_QUERY_THROW); + uno::Reference<beans::XPropertySet> xCellAreaLink(init(), uno::UNO_QUERY_THROW); const OUString propName("RefreshPeriod"); sal_Int32 aRefreshPeriod = 0; CPPUNIT_ASSERT(xCellAreaLink->getPropertyValue(propName) >>= aRefreshPeriod); - CPPUNIT_ASSERT_EQUAL_MESSAGE("Default RefreshPeriod already changed", sal_Int32(0), aRefreshPeriod); + CPPUNIT_ASSERT_EQUAL_MESSAGE("Default RefreshPeriod already changed", sal_Int32(0), + aRefreshPeriod); uno::Any aNewRefreshPeriod; aNewRefreshPeriod <<= static_cast<sal_Int32>(42); xCellAreaLink->setPropertyValue(propName, aNewRefreshPeriod); CPPUNIT_ASSERT(xCellAreaLink->getPropertyValue(propName) >>= aRefreshPeriod); - CPPUNIT_ASSERT_EQUAL_MESSAGE("Value of RefreshPeriod wasn't changed", sal_Int32(42), aRefreshPeriod); + CPPUNIT_ASSERT_EQUAL_MESSAGE("Value of RefreshPeriod wasn't changed", sal_Int32(42), + aRefreshPeriod); } -} +} // namespace apitest /* vim:set shiftwidth=4 softtabstop=4 expandtab cinoptions=b1,g0,N-s cinkeys+=0=break: */ diff --git a/test/source/sheet/xarealink.cxx b/test/source/sheet/xarealink.cxx index ec7ce49a01f8..18c15e725bdb 100644 --- a/test/source/sheet/xarealink.cxx +++ b/test/source/sheet/xarealink.cxx @@ -26,8 +26,13 @@ void XAreaLink::testSetDestArea() uno::Reference< sheet::XAreaLink > xAreaLink(init(), UNO_QUERY_THROW); xAreaLink->setDestArea(table::CellRangeAddress(1,3,4,5,8)); - CPPUNIT_ASSERT_EQUAL_MESSAGE("Couldn't set new dest area", - table::CellRangeAddress(1,3,4,5,8), xAreaLink->getDestArea()); + // After setting the the destination area, the link is refreshed and the area + // is adjusted to the size of the source data. + // Only test the 'Sheet', 'StartCol', and 'StartRow' + table::CellRangeAddress aDestArea = xAreaLink->getDestArea(); + CPPUNIT_ASSERT_EQUAL_MESSAGE("Couldn't set new DestArea (Sheet)", sal_Int16(1), aDestArea.Sheet); + CPPUNIT_ASSERT_EQUAL_MESSAGE("Couldn't set new DestArea (StartCol)", sal_Int32(3), aDestArea.StartColumn); + CPPUNIT_ASSERT_EQUAL_MESSAGE("Couldn't set new DestArea (StartRow)", sal_Int32(4), aDestArea.StartRow); } void XAreaLink::testSetSourceArea() @@ -44,7 +49,7 @@ void XAreaLink::testGetDestArea() uno::Reference< sheet::XAreaLink > xAreaLink(init(), UNO_QUERY_THROW); CPPUNIT_ASSERT_EQUAL_MESSAGE("Couldn't get dest area", - table::CellRangeAddress(1,2,3,2,3), xAreaLink->getDestArea()); + table::CellRangeAddress(1,2,3,3,6), xAreaLink->getDestArea()); } void XAreaLink::testGetSourceArea() @@ -52,7 +57,7 @@ void XAreaLink::testGetSourceArea() uno::Reference< sheet::XAreaLink > xAreaLink(init(), UNO_QUERY_THROW); CPPUNIT_ASSERT_EQUAL_MESSAGE("Couldn't get source area", - OUString("a1:c1"), xAreaLink->getSourceArea()); + OUString("a2:b5"), xAreaLink->getSourceArea()); } } _______________________________________________ Libreoffice-commits mailing list libreoffice-comm...@lists.freedesktop.org https://lists.freedesktop.org/mailman/listinfo/libreoffice-commits