1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
3 * This file is part of the LibreOffice project.
5 * This Source Code Form is subject to the terms of the Mozilla Public
6 * License, v. 2.0. If a copy of the MPL was not distributed with this
7 * file, You can obtain one at http://mozilla.org/MPL/2.0/.
9 * This file incorporates work covered by the following license notice:
11 * Licensed to the Apache Software Foundation (ASF) under one or more
12 * contributor license agreements. See the NOTICE file distributed
13 * with this work for additional information regarding copyright
14 * ownership. The ASF licenses this file to you under the Apache
15 * License, Version 2.0 (the "License"); you may not use this file
16 * except in compliance with the License. You may obtain a copy of
17 * the License at http://www.apache.org/licenses/LICENSE-2.0 .
20 #include <sal/types.h>
22 #include "test/cppuhelper/propertysetmixin/CppSupplier.hpp"
23 #include "test/cppuhelper/propertysetmixin/JavaSupplier.hpp"
24 #include "test/cppuhelper/propertysetmixin/XSupplier.hpp"
25 #include "test/cppuhelper/propertysetmixin/XTest3.hpp"
27 #include "com/sun/star/beans/Ambiguous.hpp"
28 #include "com/sun/star/beans/Defaulted.hpp"
29 #include "com/sun/star/beans/Optional.hpp"
30 #include "com/sun/star/beans/Property.hpp"
31 #include "com/sun/star/beans/PropertyAttribute.hpp"
32 #include "com/sun/star/beans/PropertyChangeEvent.hpp"
33 #include "com/sun/star/beans/PropertyState.hpp"
34 #include "com/sun/star/beans/PropertyValue.hpp"
35 #include "com/sun/star/beans/PropertyVetoException.hpp"
36 #include "com/sun/star/beans/UnknownPropertyException.hpp"
37 #include "com/sun/star/beans/XFastPropertySet.hpp"
38 #include "com/sun/star/beans/XPropertyAccess.hpp"
39 #include "com/sun/star/beans/XPropertyChangeListener.hpp"
40 #include "com/sun/star/beans/XPropertySet.hpp"
41 #include "com/sun/star/beans/XPropertySetInfo.hpp"
42 #include "com/sun/star/beans/XVetoableChangeListener.hpp"
43 #include "com/sun/star/lang/XComponent.hpp"
44 #include "com/sun/star/uno/Any.hxx"
45 #include "com/sun/star/uno/Reference.hxx"
46 #include "com/sun/star/uno/RuntimeException.hpp"
47 #include "com/sun/star/uno/Sequence.hxx"
48 #include "com/sun/star/uno/Type.hxx"
49 #include "com/sun/star/uno/XComponentContext.hpp"
50 #include "cppuhelper/bootstrap.hxx"
51 #include "cppuhelper/implbase1.hxx"
52 #include "cppunit/TestAssert.h"
53 #include "cppunit/TestFixture.h"
54 #include "cppunit/extensions/HelperMacros.h"
55 #include "cppunit/plugin/TestPlugIn.h"
56 #include "osl/mutex.hxx"
57 #include "rtl/ref.hxx"
58 #include "rtl/string.h"
59 #include "rtl/textenc.h"
60 #include "rtl/ustring.h"
61 #include "rtl/ustring.hxx"
62 #include "sal/types.h"
67 namespace com
{ namespace sun
{ namespace star
{
73 std::ostream
& operator <<(std::ostream
& out
, rtl::OUString
const & value
) {
74 return out
<< rtl::OUStringToOString(value
, RTL_TEXTENCODING_UTF8
).getStr();
77 std::ostream
& operator <<(std::ostream
& out
, css::uno::Type
const & value
) {
78 return out
<< "com::sun::star::uno::Type[" << value
.getTypeName() << ']';
81 std::ostream
& operator <<(std::ostream
& out
, css::uno::Any
const & value
) {
83 out
<< "com::sun::star::uno::Any[" << value
.getValueType() << ", ...]";
87 public cppu::WeakImplHelper1
< css::beans::XPropertyChangeListener
>
90 BoundListener(): m_count(0) {}
93 osl::MutexGuard
g(m_mutex
);
97 virtual void SAL_CALL
disposing(css::lang::EventObject
const &)
98 throw (css::uno::RuntimeException
)
100 osl::MutexGuard
g(m_mutex
);
101 CPPUNIT_ASSERT(m_count
< std::numeric_limits
< int >::max());
105 virtual void SAL_CALL
propertyChange(
106 css::beans::PropertyChangeEvent
const &)
107 throw (css::uno::RuntimeException
)
108 { CPPUNIT_FAIL("BoundListener::propertyChange called"); }
111 BoundListener(BoundListener
&); // not defined
112 void operator =(BoundListener
&); // not defined
114 virtual ~BoundListener() {}
116 mutable osl::Mutex m_mutex
;
121 public cppu::WeakImplHelper1
< css::beans::XVetoableChangeListener
>
124 VetoListener(): m_count(0) {}
127 osl::MutexGuard
g(m_mutex
);
131 virtual void SAL_CALL
disposing(css::lang::EventObject
const &)
132 throw (css::uno::RuntimeException
)
134 osl::MutexGuard
g(m_mutex
);
135 CPPUNIT_ASSERT(m_count
< std::numeric_limits
< int >::max());
139 virtual void SAL_CALL
vetoableChange(
140 css::beans::PropertyChangeEvent
const &)
141 throw (css::beans::PropertyVetoException
, css::uno::RuntimeException
)
142 { CPPUNIT_FAIL("VetoListener::vetoableChange called"); }
145 VetoListener(VetoListener
&); // not defined
146 void operator =(VetoListener
&); // not defined
148 virtual ~VetoListener() {}
150 mutable osl::Mutex m_mutex
;
154 class Test
: public CppUnit::TestFixture
{
156 virtual void setUp();
158 virtual void tearDown();
160 void testCppEmpty1() { testEmpty1(getCppSupplier()); }
162 void testCppEmpty2() { testEmpty2(getCppSupplier()); }
164 void testCppFull() { testFull(getCppSupplier()); }
166 void testJavaEmpty1() { testEmpty1(getJavaSupplier()); }
168 void testJavaEmpty2() { testEmpty2(getJavaSupplier()); }
170 void testJavaFull() { testFull(getJavaSupplier()); }
172 CPPUNIT_TEST_SUITE(Test
);
173 CPPUNIT_TEST(testCppEmpty1
);
174 CPPUNIT_TEST(testCppEmpty2
);
175 CPPUNIT_TEST(testCppFull
);
176 CPPUNIT_TEST(testJavaEmpty1
);
177 CPPUNIT_TEST(testJavaEmpty2
);
178 CPPUNIT_TEST(testJavaFull
);
179 CPPUNIT_TEST_SUITE_END();
182 css::uno::Reference
< test::cppuhelper::propertysetmixin::XSupplier
>
183 getCppSupplier() const;
185 css::uno::Reference
< test::cppuhelper::propertysetmixin::XSupplier
>
186 getJavaSupplier() const;
189 css::uno::Reference
< test::cppuhelper::propertysetmixin::XSupplier
>
190 const & supplier
) const;
193 css::uno::Reference
< test::cppuhelper::propertysetmixin::XSupplier
>
194 const & supplier
) const;
197 css::uno::Reference
< test::cppuhelper::propertysetmixin::XSupplier
>
198 const & supplier
) const;
200 css::uno::Reference
< css::uno::XComponentContext
> m_context
;
204 m_context
= cppu::defaultBootstrap_InitialComponentContext();
205 CPPUNIT_ASSERT(m_context
.is());
208 void Test::tearDown() {
209 css::uno::Reference
< css::lang::XComponent
>(
210 m_context
, css::uno::UNO_QUERY_THROW
)->dispose();
213 css::uno::Reference
< test::cppuhelper::propertysetmixin::XSupplier
>
214 Test::getCppSupplier() const
216 return test::cppuhelper::propertysetmixin::CppSupplier::create(m_context
);
219 css::uno::Reference
< test::cppuhelper::propertysetmixin::XSupplier
>
220 Test::getJavaSupplier() const
222 return test::cppuhelper::propertysetmixin::JavaSupplier::create(m_context
);
225 void Test::testEmpty1(
226 css::uno::Reference
< test::cppuhelper::propertysetmixin::XSupplier
>
227 const & supplier
) const
229 css::uno::Reference
< css::lang::XComponent
> empty1(
230 supplier
->getEmpty1(), css::uno::UNO_QUERY_THROW
);
232 !css::uno::Reference
< css::beans::XPropertySet
>(
233 empty1
, css::uno::UNO_QUERY
).is());
235 !css::uno::Reference
< css::beans::XFastPropertySet
>(
236 empty1
, css::uno::UNO_QUERY
).is());
238 !css::uno::Reference
< css::beans::XPropertyAccess
>(
239 empty1
, css::uno::UNO_QUERY
).is());
243 void Test::testEmpty2(
244 css::uno::Reference
< test::cppuhelper::propertysetmixin::XSupplier
>
245 const & supplier
) const
247 css::uno::Reference
< css::lang::XComponent
> empty2(
248 supplier
->getEmpty2(), css::uno::UNO_QUERY_THROW
);
249 css::uno::Reference
< css::beans::XPropertySet
> empty2p(
250 empty2
, css::uno::UNO_QUERY
);
251 CPPUNIT_ASSERT(empty2p
.is());
252 css::uno::Reference
< css::beans::XPropertySetInfo
> info(
253 empty2p
->getPropertySetInfo());
254 CPPUNIT_ASSERT(info
.is());
255 CPPUNIT_ASSERT_EQUAL(
256 static_cast< sal_Int32
>(0), info
->getProperties().getLength());
258 info
->getPropertyByName(
259 rtl::OUString("any"));
260 CPPUNIT_FAIL("exception expected");
261 } catch (css::beans::UnknownPropertyException
&) {}
263 !info
->hasPropertyByName(
264 rtl::OUString("any")));
266 empty2p
->setPropertyValue(
267 rtl::OUString("any"), css::uno::Any());
268 CPPUNIT_FAIL("exception expected");
269 } catch (css::beans::UnknownPropertyException
&) {}
271 empty2p
->getPropertyValue(
272 rtl::OUString("any"));
273 CPPUNIT_FAIL("exception expected");
274 } catch (css::beans::UnknownPropertyException
&) {}
275 rtl::Reference
< BoundListener
> boundListener1(new BoundListener
);
276 empty2p
->addPropertyChangeListener(rtl::OUString(), boundListener1
.get());
277 empty2p
->addPropertyChangeListener(rtl::OUString(), boundListener1
.get());
278 rtl::Reference
< BoundListener
> boundListener2(new BoundListener
);
279 empty2p
->removePropertyChangeListener(
280 rtl::OUString(), boundListener2
.get());
281 rtl::Reference
< VetoListener
> vetoListener1(new VetoListener
);
282 empty2p
->addVetoableChangeListener(rtl::OUString(), vetoListener1
.get());
283 empty2p
->addVetoableChangeListener(rtl::OUString(), vetoListener1
.get());
284 rtl::Reference
< VetoListener
> vetoListener2(new VetoListener
);
285 empty2p
->addVetoableChangeListener(rtl::OUString(), vetoListener2
.get());
286 empty2p
->removeVetoableChangeListener(rtl::OUString(), vetoListener2
.get());
287 css::uno::Reference
< css::beans::XFastPropertySet
> empty2f(
288 empty2
, css::uno::UNO_QUERY
);
289 CPPUNIT_ASSERT(empty2f
.is());
291 empty2f
->setFastPropertyValue(-1, css::uno::Any());
292 CPPUNIT_FAIL("exception expected");
293 } catch (css::beans::UnknownPropertyException
&) {}
295 empty2f
->setFastPropertyValue(0, css::uno::Any());
296 CPPUNIT_FAIL("exception expected");
297 } catch (css::beans::UnknownPropertyException
&) {}
299 empty2f
->getFastPropertyValue(-1);
300 CPPUNIT_FAIL("exception expected");
301 } catch (css::beans::UnknownPropertyException
&) {}
303 empty2f
->getFastPropertyValue(0);
304 CPPUNIT_FAIL("exception expected");
305 } catch (css::beans::UnknownPropertyException
&) {}
306 css::uno::Reference
< css::beans::XPropertyAccess
> empty2a(
307 empty2
, css::uno::UNO_QUERY
);
308 CPPUNIT_ASSERT(empty2a
.is());
309 CPPUNIT_ASSERT_EQUAL(
310 static_cast< sal_Int32
>(0), empty2a
->getPropertyValues().getLength());
311 empty2a
->setPropertyValues(
312 css::uno::Sequence
< css::beans::PropertyValue
>());
313 css::uno::Sequence
< css::beans::PropertyValue
> vs(2);
314 vs
[0].Name
= rtl::OUString("any1");
316 vs
[0].State
= css::beans::PropertyState_DIRECT_VALUE
;
317 vs
[0].Name
= rtl::OUString("any2");
319 vs
[0].State
= css::beans::PropertyState_DIRECT_VALUE
;
321 empty2a
->setPropertyValues(vs
);
322 CPPUNIT_FAIL("exception expected");
323 } catch (css::beans::UnknownPropertyException
&) {}
324 CPPUNIT_ASSERT_EQUAL(0, boundListener1
->count());
325 CPPUNIT_ASSERT_EQUAL(0, boundListener2
->count());
326 CPPUNIT_ASSERT_EQUAL(0, vetoListener1
->count());
327 CPPUNIT_ASSERT_EQUAL(0, vetoListener2
->count());
329 CPPUNIT_ASSERT_EQUAL(2, boundListener1
->count());
330 CPPUNIT_ASSERT_EQUAL(0, boundListener2
->count());
331 CPPUNIT_ASSERT_EQUAL(2, vetoListener1
->count());
332 CPPUNIT_ASSERT_EQUAL(0, vetoListener2
->count());
333 empty2p
->removePropertyChangeListener(
334 rtl::OUString(), boundListener1
.get());
335 empty2p
->removePropertyChangeListener(
336 rtl::OUString(), boundListener2
.get());
337 empty2p
->removeVetoableChangeListener(rtl::OUString(), vetoListener1
.get());
338 empty2p
->removeVetoableChangeListener(rtl::OUString(), vetoListener2
.get());
339 empty2p
->addPropertyChangeListener(rtl::OUString(), boundListener1
.get());
340 empty2p
->addPropertyChangeListener(rtl::OUString(), boundListener2
.get());
341 empty2p
->addVetoableChangeListener(rtl::OUString(), vetoListener1
.get());
342 empty2p
->addVetoableChangeListener(rtl::OUString(), vetoListener2
.get());
344 empty2p
->addPropertyChangeListener(
346 css::uno::Reference
< css::beans::XPropertyChangeListener
>());
347 } catch (css::uno::RuntimeException
&) {}
349 empty2p
->addVetoableChangeListener(
351 css::uno::Reference
< css::beans::XVetoableChangeListener
>());
352 } catch (css::uno::RuntimeException
&) {}
353 CPPUNIT_ASSERT_EQUAL(3, boundListener1
->count());
354 CPPUNIT_ASSERT_EQUAL(1, boundListener2
->count());
355 CPPUNIT_ASSERT_EQUAL(3, vetoListener1
->count());
356 CPPUNIT_ASSERT_EQUAL(1, vetoListener2
->count());
360 css::uno::Reference
< test::cppuhelper::propertysetmixin::XSupplier
>
361 const & supplier
) const
363 css::uno::Reference
< test::cppuhelper::propertysetmixin::XTest3
> full(
364 supplier
->getFull(), css::uno::UNO_QUERY_THROW
);
365 css::uno::Reference
< css::beans::XPropertySet
> fullp(
366 full
, css::uno::UNO_QUERY
);
367 CPPUNIT_ASSERT(fullp
.is());
368 css::uno::Reference
< css::beans::XPropertySetInfo
> info(
369 fullp
->getPropertySetInfo());
370 CPPUNIT_ASSERT(info
.is());
371 CPPUNIT_ASSERT_EQUAL(
372 static_cast< sal_Int32
>(3), info
->getProperties().getLength());
373 css::beans::Property
prop(
374 info
->getPropertyByName(
375 rtl::OUString("First")));
376 CPPUNIT_ASSERT_EQUAL(
377 rtl::OUString("First"), prop
.Name
);
378 CPPUNIT_ASSERT_EQUAL(static_cast< sal_Int32
>(0), prop
.Handle
);
379 CPPUNIT_ASSERT_EQUAL(getCppuType(static_cast< sal_Int32
* >(0)), prop
.Type
);
380 CPPUNIT_ASSERT_EQUAL(static_cast< sal_Int16
>(0), prop
.Attributes
);
381 prop
= info
->getPropertyByName(
382 rtl::OUString("Second"));
383 CPPUNIT_ASSERT_EQUAL(
384 rtl::OUString("Second"), prop
.Name
);
385 CPPUNIT_ASSERT_EQUAL(static_cast< sal_Int32
>(1), prop
.Handle
);
386 CPPUNIT_ASSERT_EQUAL(getCppuType(static_cast< sal_Int32
* >(0)), prop
.Type
);
387 CPPUNIT_ASSERT_EQUAL(
388 static_cast< sal_Int16
>(
389 css::beans::PropertyAttribute::MAYBEVOID
390 | css::beans::PropertyAttribute::BOUND
391 | css::beans::PropertyAttribute::CONSTRAINED
392 | css::beans::PropertyAttribute::MAYBEAMBIGUOUS
393 | css::beans::PropertyAttribute::MAYBEDEFAULT
394 | css::beans::PropertyAttribute::OPTIONAL
),
397 info
->getPropertyByName(
398 rtl::OUString("Third"));
399 CPPUNIT_FAIL("exception expected");
400 } catch (css::beans::UnknownPropertyException
&) {}
401 prop
= info
->getPropertyByName(
402 rtl::OUString("Fourth"));
403 CPPUNIT_ASSERT_EQUAL(
404 rtl::OUString("Fourth"), prop
.Name
);
405 CPPUNIT_ASSERT_EQUAL(static_cast< sal_Int32
>(3), prop
.Handle
);
406 CPPUNIT_ASSERT_EQUAL(getCppuType(static_cast< sal_Int32
* >(0)), prop
.Type
);
407 CPPUNIT_ASSERT_EQUAL(
408 static_cast< sal_Int16
>(css::beans::PropertyAttribute::OPTIONAL
),
411 info
->getPropertyByName(
412 rtl::OUString("first"));
413 CPPUNIT_FAIL("exception expected");
414 } catch (css::beans::UnknownPropertyException
&) {}
416 info
->hasPropertyByName(
417 rtl::OUString("First")));
419 info
->hasPropertyByName(
420 rtl::OUString("Second")));
422 !info
->hasPropertyByName(
423 rtl::OUString("Third")));
425 info
->hasPropertyByName(
426 rtl::OUString("Fourth")));
428 !info
->hasPropertyByName(
429 rtl::OUString("first")));
430 CPPUNIT_ASSERT_EQUAL(
431 css::uno::makeAny(static_cast< sal_Int32
>(0)),
432 fullp
->getPropertyValue(
433 rtl::OUString("First")));
434 fullp
->setPropertyValue(
435 rtl::OUString("First"),
436 css::uno::makeAny(static_cast< sal_Int32
>(-100)));
437 CPPUNIT_ASSERT_EQUAL(
438 css::uno::makeAny(static_cast< sal_Int32
>(-100)),
439 fullp
->getPropertyValue(
440 rtl::OUString("First")));
441 css::uno::Any voidAny
;
442 CPPUNIT_ASSERT_EQUAL(
444 fullp
->getPropertyValue(
445 rtl::OUString("Second")));
446 fullp
->setPropertyValue(
447 rtl::OUString("Second"),
448 css::uno::makeAny(static_cast< sal_Int32
>(100)));
449 CPPUNIT_ASSERT_EQUAL(
450 css::uno::makeAny(static_cast< sal_Int32
>(100)),
451 fullp
->getPropertyValue(
452 rtl::OUString("Second")));
453 CPPUNIT_ASSERT(full
->getSecond().Value
.Value
.IsPresent
);
454 CPPUNIT_ASSERT_EQUAL(
455 static_cast< sal_Int32
>(100), full
->getSecond().Value
.Value
.Value
);
456 CPPUNIT_ASSERT(!full
->getSecond().Value
.IsDefaulted
);
457 CPPUNIT_ASSERT(!full
->getSecond().IsAmbiguous
);
458 fullp
->setPropertyValue(
459 rtl::OUString("Second"),
461 CPPUNIT_ASSERT_EQUAL(
463 fullp
->getPropertyValue(
464 rtl::OUString("Second")));
465 CPPUNIT_ASSERT(!full
->getSecond().Value
.Value
.IsPresent
);
466 CPPUNIT_ASSERT(!full
->getSecond().Value
.IsDefaulted
);
467 CPPUNIT_ASSERT(!full
->getSecond().IsAmbiguous
);
469 fullp
->setPropertyValue(
470 rtl::OUString("Third"),
471 css::uno::makeAny(static_cast< sal_Int32
>(100)));
472 CPPUNIT_FAIL("exception expected");
473 } catch (css::beans::UnknownPropertyException
&) {}
475 fullp
->getPropertyValue(
476 rtl::OUString("Third"));
477 CPPUNIT_FAIL("exception expected");
478 } catch (css::beans::UnknownPropertyException
&) {}
480 fullp
->setPropertyValue(
481 rtl::OUString("Fourth"),
482 css::uno::makeAny(static_cast< sal_Int32
>(100)));
483 CPPUNIT_FAIL("exception expected");
484 } catch (css::beans::UnknownPropertyException
&) {}
486 fullp
->getPropertyValue(
487 rtl::OUString("Fourth"));
488 CPPUNIT_FAIL("exception expected");
489 } catch (css::beans::UnknownPropertyException
&) {}
491 fullp
->setPropertyValue(
492 rtl::OUString("first"),
494 CPPUNIT_FAIL("exception expected");
495 } catch (css::beans::UnknownPropertyException
&) {}
497 fullp
->getPropertyValue(
498 rtl::OUString("first"));
499 CPPUNIT_FAIL("exception expected");
500 } catch (css::beans::UnknownPropertyException
&) {}
501 css::uno::Reference
< css::beans::XFastPropertySet
> fullf(
502 full
, css::uno::UNO_QUERY
);
503 CPPUNIT_ASSERT(fullf
.is());
504 CPPUNIT_ASSERT_EQUAL(
505 css::uno::makeAny(static_cast< sal_Int32
>(-100)),
506 fullf
->getFastPropertyValue(0));
507 fullf
->setFastPropertyValue(
508 0, css::uno::makeAny(static_cast< sal_Int32
>(0)));
509 CPPUNIT_ASSERT_EQUAL(
510 css::uno::makeAny(static_cast< sal_Int32
>(0)),
511 fullf
->getFastPropertyValue(0));
513 fullf
->getFastPropertyValue(-1);
514 } catch (css::beans::UnknownPropertyException
&) {}
516 fullf
->setFastPropertyValue(-1, css::uno::Any());
517 } catch (css::beans::UnknownPropertyException
&) {}
518 css::uno::Reference
< css::beans::XPropertyAccess
> fulla(
519 full
, css::uno::UNO_QUERY
);
520 CPPUNIT_ASSERT(fulla
.is());
521 css::uno::Sequence
< css::beans::PropertyValue
> vs(
522 fulla
->getPropertyValues());
523 CPPUNIT_ASSERT_EQUAL(static_cast< sal_Int32
>(2), vs
.getLength());
524 CPPUNIT_ASSERT_EQUAL(
525 rtl::OUString("First"), vs
[0].Name
);
526 CPPUNIT_ASSERT_EQUAL(static_cast< sal_Int32
>(0), vs
[0].Handle
);
527 CPPUNIT_ASSERT_EQUAL(
528 css::uno::makeAny(static_cast< sal_Int32
>(0)), vs
[0].Value
);
529 CPPUNIT_ASSERT_EQUAL(css::beans::PropertyState_DIRECT_VALUE
, vs
[0].State
);
530 CPPUNIT_ASSERT_EQUAL(
531 rtl::OUString("Second"), vs
[1].Name
);
532 CPPUNIT_ASSERT_EQUAL(static_cast< sal_Int32
>(1), vs
[1].Handle
);
533 CPPUNIT_ASSERT_EQUAL(voidAny
, vs
[1].Value
);
534 CPPUNIT_ASSERT_EQUAL(css::beans::PropertyState_DIRECT_VALUE
, vs
[1].State
);
535 vs
[0].Value
<<= static_cast< sal_Int32
>(-100);
536 vs
[1].Value
<<= static_cast< sal_Int32
>(100);
537 vs
[1].State
= css::beans::PropertyState_AMBIGUOUS_VALUE
;
538 fulla
->setPropertyValues(vs
);
539 vs
= fulla
->getPropertyValues();
540 CPPUNIT_ASSERT_EQUAL(static_cast< sal_Int32
>(2), vs
.getLength());
541 CPPUNIT_ASSERT_EQUAL(
542 rtl::OUString("First"), vs
[0].Name
);
543 CPPUNIT_ASSERT_EQUAL(
544 css::uno::makeAny(static_cast< sal_Int32
>(-100)), vs
[0].Value
);
545 CPPUNIT_ASSERT_EQUAL(css::beans::PropertyState_DIRECT_VALUE
, vs
[0].State
);
546 CPPUNIT_ASSERT_EQUAL(
547 rtl::OUString("Second"), vs
[1].Name
);
548 CPPUNIT_ASSERT_EQUAL(
549 css::uno::makeAny(static_cast< sal_Int32
>(100)), vs
[1].Value
);
550 CPPUNIT_ASSERT_EQUAL(
551 css::beans::PropertyState_AMBIGUOUS_VALUE
, vs
[1].State
);
552 CPPUNIT_ASSERT(full
->getSecond().Value
.Value
.IsPresent
);
553 CPPUNIT_ASSERT_EQUAL(
554 static_cast< sal_Int32
>(100), full
->getSecond().Value
.Value
.Value
);
555 CPPUNIT_ASSERT(!full
->getSecond().Value
.IsDefaulted
);
556 CPPUNIT_ASSERT(full
->getSecond().IsAmbiguous
);
557 css::uno::Reference
< css::beans::XPropertyChangeListener
> boundListener(
559 fullp
->addPropertyChangeListener(
560 rtl::OUString("First"), boundListener
);
561 fullp
->removePropertyChangeListener(
562 rtl::OUString("First"), boundListener
);
563 fullp
->addPropertyChangeListener(
564 rtl::OUString("Second"), boundListener
);
565 fullp
->removePropertyChangeListener(
566 rtl::OUString("Second"), boundListener
);
568 fullp
->addPropertyChangeListener(
569 rtl::OUString("Third"),
571 CPPUNIT_FAIL("exception expected");
572 } catch (css::beans::UnknownPropertyException
&) {}
574 fullp
->removePropertyChangeListener(
575 rtl::OUString("Third"),
577 CPPUNIT_FAIL("exception expected");
578 } catch (css::beans::UnknownPropertyException
&) {}
579 fullp
->addPropertyChangeListener(
580 rtl::OUString("Fourth"), boundListener
);
581 fullp
->removePropertyChangeListener(
582 rtl::OUString("Fourth"), boundListener
);
584 fullp
->addPropertyChangeListener(
585 rtl::OUString("Fifth"),
587 CPPUNIT_FAIL("exception expected");
588 } catch (css::beans::UnknownPropertyException
&) {}
590 fullp
->removePropertyChangeListener(
591 rtl::OUString("Fifth"),
593 CPPUNIT_FAIL("exception expected");
594 } catch (css::beans::UnknownPropertyException
&) {}
595 css::uno::Reference
< css::beans::XVetoableChangeListener
> vetoListener(
597 fullp
->addVetoableChangeListener(
598 rtl::OUString("First"), vetoListener
);
599 fullp
->removeVetoableChangeListener(
600 rtl::OUString("First"), vetoListener
);
601 fullp
->addVetoableChangeListener(
602 rtl::OUString("Second"), vetoListener
);
603 fullp
->removeVetoableChangeListener(
604 rtl::OUString("Second"), vetoListener
);
606 fullp
->addVetoableChangeListener(
607 rtl::OUString("Third"),
609 CPPUNIT_FAIL("exception expected");
610 } catch (css::beans::UnknownPropertyException
&) {}
612 fullp
->removeVetoableChangeListener(
613 rtl::OUString("Third"),
615 CPPUNIT_FAIL("exception expected");
616 } catch (css::beans::UnknownPropertyException
&) {}
617 fullp
->addVetoableChangeListener(
618 rtl::OUString("Fourth"), vetoListener
);
619 fullp
->removeVetoableChangeListener(
620 rtl::OUString("Fourth"), vetoListener
);
622 fullp
->addVetoableChangeListener(
623 rtl::OUString("Fifth"),
625 CPPUNIT_FAIL("exception expected");
626 } catch (css::beans::UnknownPropertyException
&) {}
628 fullp
->removeVetoableChangeListener(
629 rtl::OUString("Fifth"),
631 CPPUNIT_FAIL("exception expected");
632 } catch (css::beans::UnknownPropertyException
&) {}
635 CPPUNIT_TEST_SUITE_REGISTRATION(Test
);
639 CPPUNIT_PLUGIN_IMPLEMENT();
641 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */