Kaydet (Commit) fe632c86 authored tarafından Jens Carl's avatar Jens Carl

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: 's avatarJens Carl <j.carl43@gmx.de>
üst e1a42835
......@@ -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
......
......@@ -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 \
......
"ScAreaLinkObj";"com::sun::star::util::XRefreshable";"refresh()"
"ScAreaLinkObj";"com::sun::star::util::XRefreshable";"addRefreshListener()"
"ScAreaLinkObj";"com::sun::star::util::XRefreshable";"removeRefreshListener()"
/*
* 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;
}
}
......@@ -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;
......
......@@ -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
......
......@@ -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: */
......@@ -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());
}
}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment