tdf#45904 Move XNamed Java tests to C++

Move XNamed Java tests to C++ for ScSheetLinkObj.

Change-Id: I64904ed6bae1b96767f8b0a65b0850a8694b10c2
Reviewed-on: https://gerrit.libreoffice.org/69907
Tested-by: Jenkins
Reviewed-by: Jens Carl <j.carl43@gmx.de>
diff --git a/include/test/container/xnamed.hxx b/include/test/container/xnamed.hxx
index 1b1a762..de8618c 100644
--- a/include/test/container/xnamed.hxx
+++ b/include/test/container/xnamed.hxx
@@ -30,6 +30,8 @@

    void testGetName();
    void testSetName();
    // special case, here name is equal to links URL
    void testSetNameByScSheetLinkObj();
    void testSetNameThrowsException();

    virtual css::uno::Reference< css::uno::XInterface > init() = 0;
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 2d72f68..63be54e 100644
--- a/qadevOOo/objdsc/sc/com.sun.star.comp.office.ScSheetLinkObj.csv
+++ b/qadevOOo/objdsc/sc/com.sun.star.comp.office.ScSheetLinkObj.csv
@@ -1,5 +1,3 @@
"ScSheetLinkObj";"com::sun::star::container::XNamed";"getName()"
"ScSheetLinkObj";"com::sun::star::container::XNamed";"setName()"
"ScSheetLinkObj";"com::sun::star::beans::XPropertySet";"getPropertySetInfo()"
"ScSheetLinkObj";"com::sun::star::beans::XPropertySet";"setPropertyValue()"
"ScSheetLinkObj";"com::sun::star::beans::XPropertySet";"getPropertyValue()"
diff --git a/sc/qa/extras/scsheetlinkobj.cxx b/sc/qa/extras/scsheetlinkobj.cxx
index 2819c91..5239a32 100644
--- a/sc/qa/extras/scsheetlinkobj.cxx
+++ b/sc/qa/extras/scsheetlinkobj.cxx
@@ -8,6 +8,7 @@
 */

#include <test/calc_unoapi_test.hxx>
#include <test/container/xnamed.hxx>
#include <test/sheet/sheetlink.hxx>
#include <test/util/xrefreshable.hxx>
#include <sfx2/app.hxx>
@@ -31,6 +32,7 @@
{
class ScSheetLinkObj : public CalcUnoApiTest,
                       public apitest::SheetLink,
                       public apitest::XNamed,
                       public apitest::XRefreshable
{
public:
@@ -46,6 +48,10 @@
    // SheetLink
    CPPUNIT_TEST(testSheetLinkProperties);

    // XNamed
    CPPUNIT_TEST(testGetName);
    CPPUNIT_TEST(testSetNameByScSheetLinkObj);

    // XRefreshable
    CPPUNIT_TEST(testRefreshListener);

@@ -57,6 +63,7 @@

ScSheetLinkObj::ScSheetLinkObj()
    : CalcUnoApiTest("/sc/qa/extras/testdocuments")
    , XNamed(m_directories.getURLFromSrc("/sc/qa/extras/testdocuments/ScSheetLinkObj.ods"))
{
}

diff --git a/test/source/container/xnamed.cxx b/test/source/container/xnamed.cxx
index c8234f6..3b8023b 100644
--- a/test/source/container/xnamed.cxx
+++ b/test/source/container/xnamed.cxx
@@ -8,6 +8,7 @@
 */

#include <test/container/xnamed.hxx>
#include <rtl/ustring.hxx>

#include <com/sun/star/container/XNamed.hpp>
#include <com/sun/star/uno/RuntimeException.hpp>
@@ -40,6 +41,19 @@
    CPPUNIT_ASSERT_EQUAL(m_aTestName, xNamed->getName());
}

void XNamed::testSetNameByScSheetLinkObj()
{
    uno::Reference<container::XNamed> xNamed(init(), uno::UNO_QUERY_THROW);
    OUString aTestName(m_aTestName.replaceAll("ScSheetLinkObj", "NewScSheetLinkObj"));

    xNamed->setName(aTestName);
    CPPUNIT_ASSERT_EQUAL(aTestName, xNamed->getName());

    // restore old name
    xNamed->setName(m_aTestName);
    CPPUNIT_ASSERT_EQUAL(m_aTestName, xNamed->getName());
}

void XNamed::testSetNameThrowsException()
{
    uno::Reference<container::XNamed> xNamed(init(), uno::UNO_QUERY_THROW);