diff options
author | Jens Carl <j.carl43@gmx.de> | 2018-12-04 07:27:25 +0000 |
---|---|---|
committer | Jens Carl <j.carl43@gmx.de> | 2018-12-04 10:18:55 +0100 |
commit | e01b46b4229bfb7ba54127f590dec837d798ebd4 (patch) | |
tree | 1874907a71d96c5c67bfee137a1b3140161c6a18 | |
parent | 88b46b8383019d331ae0ddc76afcd5739f511936 (diff) |
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>
-rw-r--r-- | include/test/container/xnamed.hxx | 18 | ||||
-rw-r--r-- | qadevOOo/objdsc/sc/com.sun.star.comp.office.ScDDELinkObj.csv | 2 | ||||
-rw-r--r-- | sc/qa/extras/scddelinkobj.cxx | 8 | ||||
-rw-r--r-- | test/source/container/xnamed.cxx | 20 |
4 files changed, 35 insertions, 13 deletions
diff --git a/include/test/container/xnamed.hxx b/include/test/container/xnamed.hxx index f9f708114f68..1b1a762ef8b4 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 @@ namespace apitest { 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 d66cec243583..651b7c6ffebd 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 a9b7358e54da..2b2263af5df6 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 @@ using namespace com::sun::star; 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 @@ public: CPPUNIT_TEST(testGetItem); CPPUNIT_TEST(testGetTopic); + // XNamed + CPPUNIT_TEST(testGetName); + CPPUNIT_TEST(testSetNameThrowsException); + CPPUNIT_TEST_SUITE_END(); private: @@ -53,6 +58,7 @@ private: 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 a405ddc60a66..c8234f6dde4f 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 @@ namespace apitest { 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 @@ void XNamed::testSetName() 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: */ |