Kaydet (Commit) dc28443e authored tarafından Jens Carl's avatar Jens Carl

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: 's avatarJens Carl <j.carl43@gmx.de>
üst 17eb345d
"ScStyleFamilyObj";"com::sun::star::container::XNameReplace#optional";"replaceByName()" "ScStyleFamilyObj";"com::sun::star::container::XNameReplace#optional";"replaceByName()"
"ScStyleFamilyObj";"com::sun::star::container::XNameContainer#optional";"insertByName()"
"ScStyleFamilyObj";"com::sun::star::container::XNameContainer#optional";"removeByName()"
...@@ -11,6 +11,7 @@ ...@@ -11,6 +11,7 @@
#include <test/container/xelementaccess.hxx> #include <test/container/xelementaccess.hxx>
#include <test/container/xindexaccess.hxx> #include <test/container/xindexaccess.hxx>
#include <test/container/xnameaccess.hxx> #include <test/container/xnameaccess.hxx>
#include <test/container/xnamecontainer.hxx>
#include <cppu/unotype.hxx> #include <cppu/unotype.hxx>
#include <com/sun/star/container/XIndexAccess.hpp> #include <com/sun/star/container/XIndexAccess.hpp>
...@@ -32,7 +33,8 @@ namespace sc_apitest ...@@ -32,7 +33,8 @@ namespace sc_apitest
class ScStyleFamilyObj : public CalcUnoApiTest, class ScStyleFamilyObj : public CalcUnoApiTest,
public apitest::XElementAccess, public apitest::XElementAccess,
public apitest::XIndexAccess, public apitest::XIndexAccess,
public apitest::XNameAccess public apitest::XNameAccess,
public apitest::XNameContainer
{ {
public: public:
ScStyleFamilyObj(); ScStyleFamilyObj();
...@@ -56,6 +58,13 @@ public: ...@@ -56,6 +58,13 @@ public:
CPPUNIT_TEST(testGetElementNames); CPPUNIT_TEST(testGetElementNames);
CPPUNIT_TEST(testHasByName); CPPUNIT_TEST(testHasByName);
// XNameContainer
CPPUNIT_TEST(testInsertByName);
CPPUNIT_TEST(testInsertByNameDuplicate);
CPPUNIT_TEST(testInsertByNameEmptyName);
CPPUNIT_TEST(testRemoveByName);
CPPUNIT_TEST(testRemoveByNameNoneExistingElement);
CPPUNIT_TEST_SUITE_END(); CPPUNIT_TEST_SUITE_END();
private: private:
...@@ -67,6 +76,7 @@ ScStyleFamilyObj::ScStyleFamilyObj() ...@@ -67,6 +76,7 @@ ScStyleFamilyObj::ScStyleFamilyObj()
, XElementAccess(cppu::UnoType<style::XStyle>::get()) , XElementAccess(cppu::UnoType<style::XStyle>::get())
, XIndexAccess(19) , XIndexAccess(19)
, XNameAccess("Default") , XNameAccess("Default")
, XNameContainer("Default")
{ {
} }
...@@ -82,6 +92,8 @@ uno::Reference<uno::XInterface> ScStyleFamilyObj::init() ...@@ -82,6 +92,8 @@ uno::Reference<uno::XInterface> ScStyleFamilyObj::init()
uno::Reference<lang::XMultiServiceFactory> xMSF(m_xComponent, uno::UNO_QUERY_THROW); uno::Reference<lang::XMultiServiceFactory> xMSF(m_xComponent, uno::UNO_QUERY_THROW);
uno::Reference<uno::XInterface> xCS(xMSF->createInstance("com.sun.star.style.CellStyle"), uno::Reference<uno::XInterface> xCS(xMSF->createInstance("com.sun.star.style.CellStyle"),
uno::UNO_QUERY_THROW); 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); uno::Reference<container::XNameContainer> xNC(xNA_SF, uno::UNO_QUERY_THROW);
xNC->insertByName("ScStyleFamilyObj", uno::makeAny(xCS)); xNC->insertByName("ScStyleFamilyObj", uno::makeAny(xCS));
......
...@@ -56,13 +56,24 @@ void XNameContainer::testInsertByNameDuplicate() ...@@ -56,13 +56,24 @@ void XNameContainer::testInsertByNameDuplicate()
{ {
uno::Reference<container::XNameContainer> xNameContainer(init(), uno::UNO_QUERY_THROW); uno::Reference<container::XNameContainer> xNameContainer(init(), uno::UNO_QUERY_THROW);
uno::Any aAny; CPPUNIT_ASSERT(!xNameContainer->hasByName(m_aName + "Duplicate"));
CPPUNIT_ASSERT(!xNameContainer->hasByName(m_aName)); xNameContainer->insertByName(m_aName + "Duplicate", m_aElement);
xNameContainer->insertByName(m_aName, aAny); CPPUNIT_ASSERT(xNameContainer->hasByName(m_aName + "Duplicate"));
CPPUNIT_ASSERT(xNameContainer->hasByName(m_aName));
bool bExceptionThrown = false;
CPPUNIT_ASSERT_THROW(xNameContainer->insertByName(m_aName, aAny), try
container::ElementExistException); {
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() void XNameContainer::testRemoveByName()
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment