qadevOOo/objdsc/sc/com.sun.star.comp.office.ScStyleFamilyObj.csv | 2 sc/qa/extras/scstylefamilyobj.cxx | 14 +++++ test/source/container/xnamecontainer.cxx | 25 +++++++--- 3 files changed, 31 insertions(+), 10 deletions(-)
New commits: commit dc28443e1ae7d160127e0ccbc7362b9756660152 Author: Jens Carl <j.car...@gmx.de> AuthorDate: Mon Mar 11 04:34:16 2019 +0000 Commit: Jens Carl <j.car...@gmx.de> CommitDate: Mon Mar 11 06:44:13 2019 +0100 tdf#45904 Move XNameContainer Java tests to C++ Move XNameContainer Java tests to C++ for ScStyleFamilyObj. Change-Id: I8ff465262258ef5277d470369cc05f48bba25ce4 Reviewed-on: https://gerrit.libreoffice.org/69029 Tested-by: Jenkins Reviewed-by: Jens Carl <j.car...@gmx.de> diff --git a/qadevOOo/objdsc/sc/com.sun.star.comp.office.ScStyleFamilyObj.csv b/qadevOOo/objdsc/sc/com.sun.star.comp.office.ScStyleFamilyObj.csv index 4c5519b5b7f8..10e3d65acd85 100644 --- a/qadevOOo/objdsc/sc/com.sun.star.comp.office.ScStyleFamilyObj.csv +++ b/qadevOOo/objdsc/sc/com.sun.star.comp.office.ScStyleFamilyObj.csv @@ -1,3 +1 @@ "ScStyleFamilyObj";"com::sun::star::container::XNameReplace#optional";"replaceByName()" -"ScStyleFamilyObj";"com::sun::star::container::XNameContainer#optional";"insertByName()" -"ScStyleFamilyObj";"com::sun::star::container::XNameContainer#optional";"removeByName()" diff --git a/sc/qa/extras/scstylefamilyobj.cxx b/sc/qa/extras/scstylefamilyobj.cxx index c9df85f5cc92..2ca381c92d33 100644 --- a/sc/qa/extras/scstylefamilyobj.cxx +++ b/sc/qa/extras/scstylefamilyobj.cxx @@ -11,6 +11,7 @@ #include <test/container/xelementaccess.hxx> #include <test/container/xindexaccess.hxx> #include <test/container/xnameaccess.hxx> +#include <test/container/xnamecontainer.hxx> #include <cppu/unotype.hxx> #include <com/sun/star/container/XIndexAccess.hpp> @@ -32,7 +33,8 @@ namespace sc_apitest class ScStyleFamilyObj : public CalcUnoApiTest, public apitest::XElementAccess, public apitest::XIndexAccess, - public apitest::XNameAccess + public apitest::XNameAccess, + public apitest::XNameContainer { public: ScStyleFamilyObj(); @@ -56,6 +58,13 @@ public: CPPUNIT_TEST(testGetElementNames); CPPUNIT_TEST(testHasByName); + // XNameContainer + CPPUNIT_TEST(testInsertByName); + CPPUNIT_TEST(testInsertByNameDuplicate); + CPPUNIT_TEST(testInsertByNameEmptyName); + CPPUNIT_TEST(testRemoveByName); + CPPUNIT_TEST(testRemoveByNameNoneExistingElement); + CPPUNIT_TEST_SUITE_END(); private: @@ -67,6 +76,7 @@ ScStyleFamilyObj::ScStyleFamilyObj() , XElementAccess(cppu::UnoType<style::XStyle>::get()) , XIndexAccess(19) , XNameAccess("Default") + , XNameContainer("Default") { } @@ -82,6 +92,8 @@ uno::Reference<uno::XInterface> ScStyleFamilyObj::init() uno::Reference<lang::XMultiServiceFactory> xMSF(m_xComponent, uno::UNO_QUERY_THROW); uno::Reference<uno::XInterface> xCS(xMSF->createInstance("com.sun.star.style.CellStyle"), uno::UNO_QUERY_THROW); + // XNameContainer + setElement(uno::makeAny(xMSF->createInstance("com.sun.star.style.CellStyle"))); uno::Reference<container::XNameContainer> xNC(xNA_SF, uno::UNO_QUERY_THROW); xNC->insertByName("ScStyleFamilyObj", uno::makeAny(xCS)); diff --git a/test/source/container/xnamecontainer.cxx b/test/source/container/xnamecontainer.cxx index c871debaecce..e5e8d8dead8e 100644 --- a/test/source/container/xnamecontainer.cxx +++ b/test/source/container/xnamecontainer.cxx @@ -56,13 +56,24 @@ void XNameContainer::testInsertByNameDuplicate() { uno::Reference<container::XNameContainer> xNameContainer(init(), uno::UNO_QUERY_THROW); - uno::Any aAny; - CPPUNIT_ASSERT(!xNameContainer->hasByName(m_aName)); - xNameContainer->insertByName(m_aName, aAny); - CPPUNIT_ASSERT(xNameContainer->hasByName(m_aName)); - - CPPUNIT_ASSERT_THROW(xNameContainer->insertByName(m_aName, aAny), - container::ElementExistException); + CPPUNIT_ASSERT(!xNameContainer->hasByName(m_aName + "Duplicate")); + xNameContainer->insertByName(m_aName + "Duplicate", m_aElement); + CPPUNIT_ASSERT(xNameContainer->hasByName(m_aName + "Duplicate")); + + bool bExceptionThrown = false; + try + { + xNameContainer->insertByName(m_aName + "Duplicate", m_aElement); + } + catch (const container::ElementExistException&) + { + bExceptionThrown = true; + } + catch (const lang::IllegalArgumentException&) + { + bExceptionThrown = true; + } + CPPUNIT_ASSERT(bExceptionThrown); } void XNameContainer::testRemoveByName() _______________________________________________ Libreoffice-commits mailing list libreoffice-comm...@lists.freedesktop.org https://lists.freedesktop.org/mailman/listinfo/libreoffice-commits