summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJens Carl <j.carl43@gmx.de>2019-03-11 04:34:16 +0000
committerJens Carl <j.carl43@gmx.de>2019-03-11 06:44:13 +0100
commitdc28443e1ae7d160127e0ccbc7362b9756660152 (patch)
tree6d7eeedc959b2f89bb6581ebc4490ace4ec0074a
parent17eb345d999ce8db78453e804af678384846acbc (diff)
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.carl43@gmx.de>
-rw-r--r--qadevOOo/objdsc/sc/com.sun.star.comp.office.ScStyleFamilyObj.csv2
-rw-r--r--sc/qa/extras/scstylefamilyobj.cxx14
-rw-r--r--test/source/container/xnamecontainer.cxx25
3 files changed, 31 insertions, 10 deletions
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()