diff options
author | Stephan Bergmann <sbergman@redhat.com> | 2015-07-07 19:09:03 +0200 |
---|---|---|
committer | Stephan Bergmann <sbergman@redhat.com> | 2015-07-07 19:09:03 +0200 |
commit | 375f9460d99a0e2c366318edcc41d64d6170286e (patch) | |
tree | ab887bbcd585b04df528e85056f75288fd540982 /configmgr/qa | |
parent | d62253dee17dc25e6e66512870123b321f34c750 (diff) |
Validate names of elements added via the API
Change-Id: I052f8ca6a8788665acb1bf87456f7cc67d64c365
Diffstat (limited to 'configmgr/qa')
-rw-r--r-- | configmgr/qa/unit/test.cxx | 37 |
1 files changed, 37 insertions, 0 deletions
diff --git a/configmgr/qa/unit/test.cxx b/configmgr/qa/unit/test.cxx index fd004776105a..a6954ada4f55 100644 --- a/configmgr/qa/unit/test.cxx +++ b/configmgr/qa/unit/test.cxx @@ -28,11 +28,13 @@ #include <com/sun/star/beans/XPropertyState.hpp> #include <com/sun/star/configuration/theDefaultProvider.hpp> #include <com/sun/star/container/XHierarchicalNameAccess.hpp> +#include <com/sun/star/container/XNameContainer.hpp> #include <com/sun/star/container/XNameReplace.hpp> #include <com/sun/star/container/XNamed.hpp> #include <com/sun/star/lang/EventObject.hpp> #include <com/sun/star/lang/XComponent.hpp> #include <com/sun/star/lang/XMultiServiceFactory.hpp> +#include <com/sun/star/lang/XSingleServiceFactory.hpp> #include <com/sun/star/uno/Any.hxx> #include <com/sun/star/uno/Reference.hxx> #include <com/sun/star/uno/RuntimeException.hpp> @@ -66,6 +68,7 @@ public: void testKeySet(); void testKeyReset(); void testSetSetMemberName(); + void testInsertSetMember(); void testReadCommands(); #if 0 void testThreads(); @@ -93,6 +96,7 @@ public: CPPUNIT_TEST(testKeySet); CPPUNIT_TEST(testKeyReset); CPPUNIT_TEST(testSetSetMemberName); + CPPUNIT_TEST(testInsertSetMember); CPPUNIT_TEST(testReadCommands); #if 0 CPPUNIT_TEST(testThreads); @@ -286,6 +290,39 @@ void Test::testSetSetMemberName() CPPUNIT_ASSERT( s == "Fontwork Gallery..." ); } +void Test::testInsertSetMember() { + css::uno::Reference<css::container::XNameContainer> access( + createUpdateAccess( + "/org.openoffice.Office.UI.GenericCommands/UserInterface/Commands"), + css::uno::UNO_QUERY_THROW); + css::uno::Reference<css::uno::XInterface> member; + member.set( + css::uno::Reference<css::lang::XSingleServiceFactory>( + access, css::uno::UNO_QUERY_THROW)->createInstance()); + CPPUNIT_ASSERT(member.is()); + access->insertByName("A", css::uno::makeAny(member)); + member.set( + css::uno::Reference<css::lang::XSingleServiceFactory>( + access, css::uno::UNO_QUERY_THROW)->createInstance()); + CPPUNIT_ASSERT(member.is()); + try { + access->insertByName("", css::uno::makeAny(member)); + CPPUNIT_FAIL("expected IllegalArgumentException"); + } catch (css::lang::IllegalArgumentException &) {} + try { + access->insertByName("\x01", css::uno::makeAny(member)); + CPPUNIT_FAIL("expected IllegalArgumentException"); + } catch (css::lang::IllegalArgumentException &) {} + try { + access->insertByName("a/b", css::uno::makeAny(member)); + CPPUNIT_FAIL("expected IllegalArgumentException"); + } catch (css::lang::IllegalArgumentException &) {} + css::uno::Reference<css::util::XChangesBatch>( + access, css::uno::UNO_QUERY_THROW)->commitChanges(); + css::uno::Reference<css::lang::XComponent>( + access, css::uno::UNO_QUERY_THROW)->dispose(); +} + void Test::testReadCommands() { css::uno::Reference< css::container::XNameAccess > access( |