tdf#45904 Move XNamed Java tests to C++
Move XNamed Java tests to C++ for ScDDELinkObj and refactor class
XNamed. ScDDELinkObj doesn't allow to set the name, so test that a
exception of type RuntimeException is thrown.
Change-Id: Ie110c3c0ea22d205d4f2c4575f3db3676dda9ce3
Reviewed-on: https://gerrit.libreoffice.org/64497
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 f9f7081..1b1a762 100644
--- a/include/test/container/xnamed.hxx
+++ b/include/test/container/xnamed.hxx
@@ -11,7 +11,11 @@
#define INCLUDED_TEST_CONTAINER_XNAMED_HXX
#include <rtl/ustring.hxx>
#include <com/sun/star/uno/XInterface.hpp>
#include <com/sun/star/uno/Reference.hxx>
#include <test/testdllapi.hxx>
namespace apitest {
@@ -19,16 +23,22 @@
class OOO_DLLPUBLIC_TEST XNamed
{
public:
XNamed(const OUString& rName): maTestName(rName) {}
virtual ~XNamed();
XNamed(const OUString& rTestName)
: m_aTestName(rTestName)
{
}
void testGetName();
void testSetName();
void testSetNameThrowsException();
virtual css::uno::Reference< css::uno::XInterface > init() = 0;
private:
OUString const maTestName;
protected:
~XNamed() {}
private:
OUString const m_aTestName;
};
}
diff --git a/qadevOOo/objdsc/sc/com.sun.star.comp.office.ScDDELinkObj.csv b/qadevOOo/objdsc/sc/com.sun.star.comp.office.ScDDELinkObj.csv
index d66cec2..651b7c6 100644
--- a/qadevOOo/objdsc/sc/com.sun.star.comp.office.ScDDELinkObj.csv
+++ b/qadevOOo/objdsc/sc/com.sun.star.comp.office.ScDDELinkObj.csv
@@ -1,5 +1,3 @@
"ScDDELinkObj";"com::sun::star::util::XRefreshable";"refresh()"
"ScDDELinkObj";"com::sun::star::util::XRefreshable";"addRefreshListener()"
"ScDDELinkObj";"com::sun::star::util::XRefreshable";"removeRefreshListener()"
"ScDDELinkObj";"com::sun::star::container::XNamed";"getName()"
"ScDDELinkObj";"com::sun::star::container::XNamed";"setName()"
diff --git a/sc/qa/extras/scddelinkobj.cxx b/sc/qa/extras/scddelinkobj.cxx
index a9b7358e..2b2263a 100644
--- a/sc/qa/extras/scddelinkobj.cxx
+++ b/sc/qa/extras/scddelinkobj.cxx
@@ -8,6 +8,7 @@
*/
#include <test/calc_unoapi_test.hxx>
#include <test/container/xnamed.hxx>
#include <test/sheet/xddelink.hxx>
#include <com/sun/star/beans/XPropertySet.hpp>
@@ -29,7 +30,7 @@
namespace sc_apitest
{
class ScDDELinkObj : public CalcUnoApiTest, public apitest::XDDELink
class ScDDELinkObj : public CalcUnoApiTest, public apitest::XDDELink, public apitest::XNamed
{
public:
ScDDELinkObj();
@@ -45,6 +46,10 @@
CPPUNIT_TEST(testGetItem);
CPPUNIT_TEST(testGetTopic);
// XNamed
CPPUNIT_TEST(testGetName);
CPPUNIT_TEST(testSetNameThrowsException);
CPPUNIT_TEST_SUITE_END();
private:
@@ -53,6 +58,7 @@
ScDDELinkObj::ScDDELinkObj()
: CalcUnoApiTest("/sc/qa/extras/testdocuments")
, XNamed("soffice|ScDDELinksObj.ods!Sheet.A1")
{
}
diff --git a/test/source/container/xnamed.cxx b/test/source/container/xnamed.cxx
index a405ddc..c8234f6 100644
--- a/test/source/container/xnamed.cxx
+++ b/test/source/container/xnamed.cxx
@@ -7,8 +7,13 @@
* file, You can obtain one at http://mozilla.org/MPL/2.0/.
*/
#include <com/sun/star/container/XNamed.hpp>
#include <test/container/xnamed.hxx>
#include <com/sun/star/container/XNamed.hpp>
#include <com/sun/star/uno/RuntimeException.hpp>
#include <com/sun/star/uno/Reference.hxx>
#include <cppunit/extensions/HelperMacros.h>
using namespace css;
@@ -19,7 +24,7 @@
void XNamed::testGetName()
{
uno::Reference< container::XNamed > xNamed(init(), UNO_QUERY_THROW);
CPPUNIT_ASSERT_EQUAL(maTestName, xNamed->getName());
CPPUNIT_ASSERT_EQUAL(m_aTestName, xNamed->getName());
}
void XNamed::testSetName()
@@ -31,14 +36,17 @@
CPPUNIT_ASSERT_EQUAL(aTestName, xNamed->getName());
// restore old name
xNamed->setName(maTestName);
CPPUNIT_ASSERT_EQUAL(maTestName, xNamed->getName());
xNamed->setName(m_aTestName);
CPPUNIT_ASSERT_EQUAL(m_aTestName, xNamed->getName());
}
XNamed::~XNamed()
void XNamed::testSetNameThrowsException()
{
}
uno::Reference<container::XNamed> xNamed(init(), uno::UNO_QUERY_THROW);
OUString aTestName("NewName");
CPPUNIT_ASSERT_THROW(xNamed->setName(aTestName), uno::RuntimeException);
}
}
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */