1 /**************************************************************
2  *
3  * Licensed to the Apache Software Foundation (ASF) under one
4  * or more contributor license agreements.  See the NOTICE file
5  * distributed with this work for additional information
6  * regarding copyright ownership.  The ASF licenses this file
7  * to you under the Apache License, Version 2.0 (the
8  * "License"); you may not use this file except in compliance
9  * with the License.  You may obtain a copy of the License at
10  *
11  *   http://www.apache.org/licenses/LICENSE-2.0
12  *
13  * Unless required by applicable law or agreed to in writing,
14  * software distributed under the License is distributed on an
15  * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
16  * KIND, either express or implied.  See the License for the
17  * specific language governing permissions and limitations
18  * under the License.
19  *
20  *************************************************************/
21 
22 
23 
24 // MARKER(update_precomp.py): autogen include statement, do not remove
25 #include "precompiled_cppuhelper.hxx"
26 
27 #include "sal/config.h"
28 
29 #include "test/cppuhelper/propertysetmixin/CppSupplier.hpp"
30 #include "test/cppuhelper/propertysetmixin/JavaSupplier.hpp"
31 #include "test/cppuhelper/propertysetmixin/XSupplier.hpp"
32 #include "test/cppuhelper/propertysetmixin/XTest3.hpp"
33 
34 #include "com/sun/star/beans/Ambiguous.hpp"
35 #include "com/sun/star/beans/Defaulted.hpp"
36 #include "com/sun/star/beans/Optional.hpp"
37 #include "com/sun/star/beans/Property.hpp"
38 #include "com/sun/star/beans/PropertyAttribute.hpp"
39 #include "com/sun/star/beans/PropertyChangeEvent.hpp"
40 #include "com/sun/star/beans/PropertyState.hpp"
41 #include "com/sun/star/beans/PropertyValue.hpp"
42 #include "com/sun/star/beans/PropertyVetoException.hpp"
43 #include "com/sun/star/beans/UnknownPropertyException.hpp"
44 #include "com/sun/star/beans/XFastPropertySet.hpp"
45 #include "com/sun/star/beans/XPropertyAccess.hpp"
46 #include "com/sun/star/beans/XPropertyChangeListener.hpp"
47 #include "com/sun/star/beans/XPropertySet.hpp"
48 #include "com/sun/star/beans/XPropertySetInfo.hpp"
49 #include "com/sun/star/beans/XVetoableChangeListener.hpp"
50 #include "com/sun/star/lang/XComponent.hpp"
51 #include "com/sun/star/uno/Any.hxx"
52 #include "com/sun/star/uno/Reference.hxx"
53 #include "com/sun/star/uno/RuntimeException.hpp"
54 #include "com/sun/star/uno/Sequence.hxx"
55 #include "com/sun/star/uno/Type.hxx"
56 #include "com/sun/star/uno/XComponentContext.hpp"
57 #include "cppuhelper/bootstrap.hxx"
58 #include "cppuhelper/implbase1.hxx"
59 #include "gtest/gtest.h"
60 #include "osl/mutex.hxx"
61 #include "rtl/ref.hxx"
62 #include "rtl/string.h"
63 #include "rtl/textenc.h"
64 #include "rtl/ustring.h"
65 #include "rtl/ustring.hxx"
66 #include "sal/types.h"
67 #include "osl/process.h"
68 
69 #include <limits>
70 #include <ostream>
71 
72 namespace com { namespace sun { namespace star {
73     struct EventObject;
74 } } }
75 
76 namespace css = com::sun::star;
77 
78 namespace {
79 
operator <<(std::ostream & out,rtl::OUString const & value)80 std::ostream & operator <<(std::ostream & out, rtl::OUString const & value) {
81     return out << rtl::OUStringToOString(value, RTL_TEXTENCODING_UTF8).getStr();
82 }
83 
operator <<(std::ostream & out,css::uno::Type const & value)84 std::ostream & operator <<(std::ostream & out, css::uno::Type const & value) {
85     return out << "com::sun::star::uno::Type[" << value.getTypeName() << ']';
86 }
87 
operator <<(std::ostream & out,css::uno::Any const & value)88 std::ostream & operator <<(std::ostream & out, css::uno::Any const & value) {
89     return
90         out << "com::sun::star::uno::Any[" << value.getValueType() << ", ...]";
91 }
92 
93 class BoundListener:
94     public cppu::WeakImplHelper1< css::beans::XPropertyChangeListener >
95 {
96 public:
BoundListener()97     BoundListener(): m_count(0) {}
98 
count() const99     int count() const {
100         osl::MutexGuard g(m_mutex);
101         return m_count;
102     }
103 
disposing(css::lang::EventObject const &)104     virtual void SAL_CALL disposing(css::lang::EventObject const &)
105         throw (css::uno::RuntimeException)
106     {
107         osl::MutexGuard g(m_mutex);
108         ASSERT_TRUE(m_count < std::numeric_limits< int >::max());
109         ++m_count;
110     }
111 
propertyChange(css::beans::PropertyChangeEvent const &)112     virtual void SAL_CALL propertyChange(
113         css::beans::PropertyChangeEvent const &)
114         throw (css::uno::RuntimeException)
115     { FAIL() << "BoundListener::propertyChange called"; }
116 
117 private:
118     BoundListener(BoundListener &); // not defined
119     void operator =(BoundListener &); // not defined
120 
~BoundListener()121     virtual ~BoundListener() {}
122 
123     mutable osl::Mutex m_mutex;
124     int m_count;
125 };
126 
127 class VetoListener:
128     public cppu::WeakImplHelper1< css::beans::XVetoableChangeListener >
129 {
130 public:
VetoListener()131     VetoListener(): m_count(0) {}
132 
count() const133     int count() const {
134         osl::MutexGuard g(m_mutex);
135         return m_count;
136     }
137 
disposing(css::lang::EventObject const &)138     virtual void SAL_CALL disposing(css::lang::EventObject const &)
139         throw (css::uno::RuntimeException)
140     {
141         osl::MutexGuard g(m_mutex);
142         ASSERT_TRUE(m_count < std::numeric_limits< int >::max());
143         ++m_count;
144     }
145 
vetoableChange(css::beans::PropertyChangeEvent const &)146     virtual void SAL_CALL vetoableChange(
147         css::beans::PropertyChangeEvent const &)
148         throw (css::beans::PropertyVetoException, css::uno::RuntimeException)
149     { FAIL() << "VetoListener::vetoableChange called"; }
150 
151 private:
152     VetoListener(VetoListener &); // not defined
153     void operator =(VetoListener &); // not defined
154 
~VetoListener()155     virtual ~VetoListener() {}
156 
157     mutable osl::Mutex m_mutex;
158     int m_count;
159 };
160 
161 class Test: public ::testing::Test {
162 public:
163     virtual void SetUp();
164 
165     virtual void TearDown();
166 
167 protected:
168     css::uno::Reference< test::cppuhelper::propertysetmixin::XSupplier >
169     getCppSupplier() const;
170 
171     css::uno::Reference< test::cppuhelper::propertysetmixin::XSupplier >
172     getJavaSupplier() const;
173 
174     void testEmpty1(
175         css::uno::Reference< test::cppuhelper::propertysetmixin::XSupplier >
176         const & supplier) const;
177 
178     void testEmpty2(
179         css::uno::Reference< test::cppuhelper::propertysetmixin::XSupplier >
180         const & supplier) const;
181 
182     void testFull(
183         css::uno::Reference< test::cppuhelper::propertysetmixin::XSupplier >
184         const & supplier) const;
185 
186     css::uno::Reference< css::uno::XComponentContext > m_context;
187 };
188 
SetUp()189 void Test::SetUp() {
190     m_context = cppu::defaultBootstrap_InitialComponentContext();
191     ASSERT_TRUE(m_context.is());
192 }
193 
TearDown()194 void Test::TearDown() {
195     css::uno::Reference< css::lang::XComponent >(
196         m_context, css::uno::UNO_QUERY_THROW)->dispose();
197 }
198 
199 css::uno::Reference< test::cppuhelper::propertysetmixin::XSupplier >
getCppSupplier() const200 Test::getCppSupplier() const
201 {
202     return test::cppuhelper::propertysetmixin::CppSupplier::create(m_context);
203 }
204 
205 css::uno::Reference< test::cppuhelper::propertysetmixin::XSupplier >
getJavaSupplier() const206 Test::getJavaSupplier() const
207 {
208     return test::cppuhelper::propertysetmixin::JavaSupplier::create(m_context);
209 }
210 
testEmpty1(css::uno::Reference<test::cppuhelper::propertysetmixin::XSupplier> const & supplier) const211 void Test::testEmpty1(
212     css::uno::Reference< test::cppuhelper::propertysetmixin::XSupplier >
213     const & supplier) const
214 {
215     css::uno::Reference< css::lang::XComponent > empty1(
216         supplier->getEmpty1(), css::uno::UNO_QUERY_THROW);
217     ASSERT_TRUE(
218         !css::uno::Reference< css::beans::XPropertySet >(
219             empty1, css::uno::UNO_QUERY).is());
220     ASSERT_TRUE(
221         !css::uno::Reference< css::beans::XFastPropertySet >(
222             empty1, css::uno::UNO_QUERY).is());
223     ASSERT_TRUE(
224         !css::uno::Reference< css::beans::XPropertyAccess >(
225             empty1, css::uno::UNO_QUERY).is());
226     empty1->dispose();
227 }
228 
testEmpty2(css::uno::Reference<test::cppuhelper::propertysetmixin::XSupplier> const & supplier) const229 void Test::testEmpty2(
230     css::uno::Reference< test::cppuhelper::propertysetmixin::XSupplier >
231     const & supplier) const
232 {
233     css::uno::Reference< css::lang::XComponent > empty2(
234         supplier->getEmpty2(), css::uno::UNO_QUERY_THROW);
235     css::uno::Reference< css::beans::XPropertySet > empty2p(
236         empty2, css::uno::UNO_QUERY);
237     ASSERT_TRUE(empty2p.is());
238     css::uno::Reference< css::beans::XPropertySetInfo > info(
239         empty2p->getPropertySetInfo());
240     ASSERT_TRUE(info.is());
241     ASSERT_EQ(
242         static_cast< sal_Int32 >(0), info->getProperties().getLength());
243     try {
244         info->getPropertyByName(
245             rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("any")));
246         FAIL() << "exception expected";
247     } catch (css::beans::UnknownPropertyException &) {}
248     ASSERT_TRUE(
249         !info->hasPropertyByName(
250             rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("any"))));
251     try {
252         empty2p->setPropertyValue(
253             rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("any")), css::uno::Any());
254         FAIL() << "exception expected";
255     } catch (css::beans::UnknownPropertyException &) {}
256     try {
257         empty2p->getPropertyValue(
258             rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("any")));
259         FAIL() << "exception expected";
260     } catch (css::beans::UnknownPropertyException &) {}
261     rtl::Reference< BoundListener > boundListener1(new BoundListener);
262     empty2p->addPropertyChangeListener(rtl::OUString(), boundListener1.get());
263     empty2p->addPropertyChangeListener(rtl::OUString(), boundListener1.get());
264     rtl::Reference< BoundListener > boundListener2(new BoundListener);
265     empty2p->removePropertyChangeListener(
266         rtl::OUString(), boundListener2.get());
267     rtl::Reference< VetoListener > vetoListener1(new VetoListener);
268     empty2p->addVetoableChangeListener(rtl::OUString(), vetoListener1.get());
269     empty2p->addVetoableChangeListener(rtl::OUString(), vetoListener1.get());
270     rtl::Reference< VetoListener > vetoListener2(new VetoListener);
271     empty2p->addVetoableChangeListener(rtl::OUString(), vetoListener2.get());
272     empty2p->removeVetoableChangeListener(rtl::OUString(), vetoListener2.get());
273     css::uno::Reference< css::beans::XFastPropertySet > empty2f(
274         empty2, css::uno::UNO_QUERY);
275     ASSERT_TRUE(empty2f.is());
276     try {
277         empty2f->setFastPropertyValue(-1, css::uno::Any());
278         FAIL() << "exception expected";
279     } catch (css::beans::UnknownPropertyException &) {}
280     try {
281         empty2f->setFastPropertyValue(0, css::uno::Any());
282         FAIL() << "exception expected";
283     } catch (css::beans::UnknownPropertyException &) {}
284     try {
285         empty2f->getFastPropertyValue(-1);
286         FAIL() << "exception expected";
287     } catch (css::beans::UnknownPropertyException &) {}
288     try {
289         empty2f->getFastPropertyValue(0);
290         FAIL() << "exception expected";
291     } catch (css::beans::UnknownPropertyException &) {}
292     css::uno::Reference< css::beans::XPropertyAccess > empty2a(
293         empty2, css::uno::UNO_QUERY);
294     ASSERT_TRUE(empty2a.is());
295     ASSERT_EQ(
296         static_cast< sal_Int32 >(0), empty2a->getPropertyValues().getLength());
297     empty2a->setPropertyValues(
298         css::uno::Sequence< css::beans::PropertyValue >());
299     css::uno::Sequence< css::beans::PropertyValue > vs(2);
300     vs[0].Name = rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("any1"));
301     vs[0].Handle = -1;
302     vs[0].State = css::beans::PropertyState_DIRECT_VALUE;
303     vs[0].Name = rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("any2"));
304     vs[0].Handle = -1;
305     vs[0].State = css::beans::PropertyState_DIRECT_VALUE;
306     try {
307         empty2a->setPropertyValues(vs);
308         FAIL() << "exception expected";
309     } catch (css::beans::UnknownPropertyException &) {}
310     ASSERT_EQ(0, boundListener1->count());
311     ASSERT_EQ(0, boundListener2->count());
312     ASSERT_EQ(0, vetoListener1->count());
313     ASSERT_EQ(0, vetoListener2->count());
314     empty2->dispose();
315     ASSERT_EQ(2, boundListener1->count());
316     ASSERT_EQ(0, boundListener2->count());
317     ASSERT_EQ(2, vetoListener1->count());
318     ASSERT_EQ(0, vetoListener2->count());
319     empty2p->removePropertyChangeListener(
320         rtl::OUString(), boundListener1.get());
321     empty2p->removePropertyChangeListener(
322         rtl::OUString(), boundListener2.get());
323     empty2p->removeVetoableChangeListener(rtl::OUString(), vetoListener1.get());
324     empty2p->removeVetoableChangeListener(rtl::OUString(), vetoListener2.get());
325     empty2p->addPropertyChangeListener(rtl::OUString(), boundListener1.get());
326     empty2p->addPropertyChangeListener(rtl::OUString(), boundListener2.get());
327     empty2p->addVetoableChangeListener(rtl::OUString(), vetoListener1.get());
328     empty2p->addVetoableChangeListener(rtl::OUString(), vetoListener2.get());
329     try {
330         empty2p->addPropertyChangeListener(
331             rtl::OUString(),
332             css::uno::Reference< css::beans::XPropertyChangeListener >());
333     } catch (css::uno::RuntimeException &) {}
334     try {
335         empty2p->addVetoableChangeListener(
336             rtl::OUString(),
337             css::uno::Reference< css::beans::XVetoableChangeListener >());
338     } catch (css::uno::RuntimeException &) {}
339     ASSERT_EQ(3, boundListener1->count());
340     ASSERT_EQ(1, boundListener2->count());
341     ASSERT_EQ(3, vetoListener1->count());
342     ASSERT_EQ(1, vetoListener2->count());
343 }
344 
testFull(css::uno::Reference<test::cppuhelper::propertysetmixin::XSupplier> const & supplier) const345 void Test::testFull(
346     css::uno::Reference< test::cppuhelper::propertysetmixin::XSupplier >
347     const & supplier) const
348 {
349     css::uno::Reference< test::cppuhelper::propertysetmixin::XTest3 > full(
350         supplier->getFull(), css::uno::UNO_QUERY_THROW);
351     css::uno::Reference< css::beans::XPropertySet > fullp(
352         full, css::uno::UNO_QUERY);
353     ASSERT_TRUE(fullp.is());
354     css::uno::Reference< css::beans::XPropertySetInfo > info(
355         fullp->getPropertySetInfo());
356     ASSERT_TRUE(info.is());
357     ASSERT_EQ(
358         static_cast< sal_Int32 >(3), info->getProperties().getLength());
359     css::beans::Property prop(
360         info->getPropertyByName(
361             rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("First"))));
362     ASSERT_EQ(
363         rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("First")), prop.Name);
364     ASSERT_EQ(static_cast< sal_Int32 >(0), prop.Handle);
365     ASSERT_EQ(getCppuType(static_cast< sal_Int32 * >(0)), prop.Type);
366     ASSERT_EQ(static_cast< sal_Int16 >(0), prop.Attributes);
367     prop = info->getPropertyByName(
368         rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("Second")));
369     ASSERT_EQ(
370         rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("Second")), prop.Name);
371     ASSERT_EQ(static_cast< sal_Int32 >(1), prop.Handle);
372     ASSERT_EQ(getCppuType(static_cast< sal_Int32 * >(0)), prop.Type);
373     ASSERT_EQ(
374         static_cast< sal_Int16 >(
375             css::beans::PropertyAttribute::MAYBEVOID
376             | css::beans::PropertyAttribute::BOUND
377             | css::beans::PropertyAttribute::CONSTRAINED
378             | css::beans::PropertyAttribute::MAYBEAMBIGUOUS
379             | css::beans::PropertyAttribute::MAYBEDEFAULT
380             | css::beans::PropertyAttribute::OPTIONAL),
381         prop.Attributes);
382     try {
383         info->getPropertyByName(
384             rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("Third")));
385         FAIL() << "exception expected";
386     } catch (css::beans::UnknownPropertyException &) {}
387     prop = info->getPropertyByName(
388         rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("Fourth")));
389     ASSERT_EQ(
390         rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("Fourth")), prop.Name);
391     ASSERT_EQ(static_cast< sal_Int32 >(3), prop.Handle);
392     ASSERT_EQ(getCppuType(static_cast< sal_Int32 * >(0)), prop.Type);
393     ASSERT_EQ(
394         static_cast< sal_Int16 >(css::beans::PropertyAttribute::OPTIONAL),
395         prop.Attributes);
396     try {
397         info->getPropertyByName(
398             rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("first")));
399         FAIL() << "exception expected";
400     } catch (css::beans::UnknownPropertyException &) {}
401     ASSERT_TRUE(
402         info->hasPropertyByName(
403             rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("First"))));
404     ASSERT_TRUE(
405         info->hasPropertyByName(
406             rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("Second"))));
407     ASSERT_TRUE(
408         !info->hasPropertyByName(
409             rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("Third"))));
410     ASSERT_TRUE(
411         info->hasPropertyByName(
412             rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("Fourth"))));
413     ASSERT_TRUE(
414         !info->hasPropertyByName(
415             rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("first"))));
416     ASSERT_EQ(
417         css::uno::makeAny(static_cast< sal_Int32 >(0)),
418         fullp->getPropertyValue(
419             rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("First"))));
420     fullp->setPropertyValue(
421         rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("First")),
422         css::uno::makeAny(static_cast< sal_Int32 >(-100)));
423     ASSERT_EQ(
424         css::uno::makeAny(static_cast< sal_Int32 >(-100)),
425         fullp->getPropertyValue(
426             rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("First"))));
427     css::uno::Any voidAny;
428     ASSERT_EQ(
429         voidAny,
430         fullp->getPropertyValue(
431             rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("Second"))));
432     fullp->setPropertyValue(
433         rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("Second")),
434         css::uno::makeAny(static_cast< sal_Int32 >(100)));
435     ASSERT_EQ(
436         css::uno::makeAny(static_cast< sal_Int32 >(100)),
437         fullp->getPropertyValue(
438             rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("Second"))));
439     ASSERT_TRUE(full->getSecond().Value.Value.IsPresent);
440     ASSERT_EQ(
441         static_cast< sal_Int32 >(100), full->getSecond().Value.Value.Value);
442     ASSERT_TRUE(!full->getSecond().Value.IsDefaulted);
443     ASSERT_TRUE(!full->getSecond().IsAmbiguous);
444     fullp->setPropertyValue(
445         rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("Second")),
446         css::uno::Any());
447     ASSERT_EQ(
448         voidAny,
449         fullp->getPropertyValue(
450             rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("Second"))));
451     ASSERT_TRUE(!full->getSecond().Value.Value.IsPresent);
452     ASSERT_TRUE(!full->getSecond().Value.IsDefaulted);
453     ASSERT_TRUE(!full->getSecond().IsAmbiguous);
454     try {
455         fullp->setPropertyValue(
456             rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("Third")),
457             css::uno::makeAny(static_cast< sal_Int32 >(100)));
458         FAIL() << "exception expected";
459     } catch (css::beans::UnknownPropertyException &) {}
460     try {
461         fullp->getPropertyValue(
462             rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("Third")));
463         FAIL() << "exception expected";
464     } catch (css::beans::UnknownPropertyException &) {}
465     try {
466         fullp->setPropertyValue(
467             rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("Fourth")),
468             css::uno::makeAny(static_cast< sal_Int32 >(100)));
469         FAIL() << "exception expected";
470     } catch (css::beans::UnknownPropertyException &) {}
471     try {
472         fullp->getPropertyValue(
473             rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("Fourth")));
474         FAIL() << "exception expected";
475     } catch (css::beans::UnknownPropertyException &) {}
476     try {
477         fullp->setPropertyValue(
478             rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("first")),
479             css::uno::Any());
480         FAIL() << "exception expected";
481     } catch (css::beans::UnknownPropertyException &) {}
482     try {
483         fullp->getPropertyValue(
484             rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("first")));
485         FAIL() << "exception expected";
486     } catch (css::beans::UnknownPropertyException &) {}
487     css::uno::Reference< css::beans::XFastPropertySet > fullf(
488         full, css::uno::UNO_QUERY);
489     ASSERT_TRUE(fullf.is());
490     ASSERT_EQ(
491         css::uno::makeAny(static_cast< sal_Int32 >(-100)),
492         fullf->getFastPropertyValue(0));
493     fullf->setFastPropertyValue(
494         0, css::uno::makeAny(static_cast< sal_Int32 >(0)));
495     ASSERT_EQ(
496         css::uno::makeAny(static_cast< sal_Int32 >(0)),
497         fullf->getFastPropertyValue(0));
498     try {
499         fullf->getFastPropertyValue(-1);
500     } catch (css::beans::UnknownPropertyException &) {}
501     try {
502         fullf->setFastPropertyValue(-1, css::uno::Any());
503     } catch (css::beans::UnknownPropertyException &) {}
504     css::uno::Reference< css::beans::XPropertyAccess > fulla(
505         full, css::uno::UNO_QUERY);
506     ASSERT_TRUE(fulla.is());
507     css::uno::Sequence< css::beans::PropertyValue > vs(
508         fulla->getPropertyValues());
509     ASSERT_EQ(static_cast< sal_Int32 >(2), vs.getLength());
510     ASSERT_EQ(
511         rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("First")), vs[0].Name);
512     ASSERT_EQ(static_cast< sal_Int32 >(0), vs[0].Handle);
513     ASSERT_EQ(
514         css::uno::makeAny(static_cast< sal_Int32 >(0)), vs[0].Value);
515     ASSERT_EQ(css::beans::PropertyState_DIRECT_VALUE, vs[0].State);
516     ASSERT_EQ(
517         rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("Second")), vs[1].Name);
518     ASSERT_EQ(static_cast< sal_Int32 >(1), vs[1].Handle);
519     ASSERT_EQ(voidAny, vs[1].Value);
520     ASSERT_EQ(css::beans::PropertyState_DIRECT_VALUE, vs[1].State);
521     vs[0].Value <<= static_cast< sal_Int32 >(-100);
522     vs[1].Value <<= static_cast< sal_Int32 >(100);
523     vs[1].State = css::beans::PropertyState_AMBIGUOUS_VALUE;
524     fulla->setPropertyValues(vs);
525     vs = fulla->getPropertyValues();
526     ASSERT_EQ(static_cast< sal_Int32 >(2), vs.getLength());
527     ASSERT_EQ(
528         rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("First")), vs[0].Name);
529     ASSERT_EQ(
530         css::uno::makeAny(static_cast< sal_Int32 >(-100)), vs[0].Value);
531     ASSERT_EQ(css::beans::PropertyState_DIRECT_VALUE, vs[0].State);
532     ASSERT_EQ(
533         rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("Second")), vs[1].Name);
534     ASSERT_EQ(
535         css::uno::makeAny(static_cast< sal_Int32 >(100)), vs[1].Value);
536     ASSERT_EQ(
537         css::beans::PropertyState_AMBIGUOUS_VALUE, vs[1].State);
538     ASSERT_TRUE(full->getSecond().Value.Value.IsPresent);
539     ASSERT_EQ(
540         static_cast< sal_Int32 >(100), full->getSecond().Value.Value.Value);
541     ASSERT_TRUE(!full->getSecond().Value.IsDefaulted);
542     ASSERT_TRUE(full->getSecond().IsAmbiguous);
543     css::uno::Reference< css::beans::XPropertyChangeListener > boundListener(
544         new BoundListener);
545     fullp->addPropertyChangeListener(
546         rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("First")), boundListener);
547     fullp->removePropertyChangeListener(
548         rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("First")), boundListener);
549     fullp->addPropertyChangeListener(
550         rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("Second")), boundListener);
551     fullp->removePropertyChangeListener(
552         rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("Second")), boundListener);
553     try {
554         fullp->addPropertyChangeListener(
555             rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("Third")),
556             boundListener);
557         FAIL() << "exception expected";
558     } catch (css::beans::UnknownPropertyException &) {}
559     try {
560         fullp->removePropertyChangeListener(
561             rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("Third")),
562             boundListener);
563         FAIL() << "exception expected";
564     } catch (css::beans::UnknownPropertyException &) {}
565     fullp->addPropertyChangeListener(
566         rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("Fourth")), boundListener);
567     fullp->removePropertyChangeListener(
568         rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("Fourth")), boundListener);
569     try {
570         fullp->addPropertyChangeListener(
571             rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("Fifth")),
572             boundListener);
573         FAIL() << "exception expected";
574     } catch (css::beans::UnknownPropertyException &) {}
575     try {
576         fullp->removePropertyChangeListener(
577             rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("Fifth")),
578             boundListener);
579         FAIL() << "exception expected";
580     } catch (css::beans::UnknownPropertyException &) {}
581     css::uno::Reference< css::beans::XVetoableChangeListener > vetoListener(
582         new VetoListener);
583     fullp->addVetoableChangeListener(
584         rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("First")), vetoListener);
585     fullp->removeVetoableChangeListener(
586         rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("First")), vetoListener);
587     fullp->addVetoableChangeListener(
588         rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("Second")), vetoListener);
589     fullp->removeVetoableChangeListener(
590         rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("Second")), vetoListener);
591     try {
592         fullp->addVetoableChangeListener(
593             rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("Third")),
594             vetoListener);
595         FAIL() << "exception expected";
596     } catch (css::beans::UnknownPropertyException &) {}
597     try {
598         fullp->removeVetoableChangeListener(
599             rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("Third")),
600             vetoListener);
601         FAIL() << "exception expected";
602     } catch (css::beans::UnknownPropertyException &) {}
603     fullp->addVetoableChangeListener(
604         rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("Fourth")), vetoListener);
605     fullp->removeVetoableChangeListener(
606         rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("Fourth")), vetoListener);
607     try {
608         fullp->addVetoableChangeListener(
609             rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("Fifth")),
610             vetoListener);
611         FAIL() << "exception expected";
612     } catch (css::beans::UnknownPropertyException &) {}
613     try {
614         fullp->removeVetoableChangeListener(
615             rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("Fifth")),
616             vetoListener);
617         FAIL() << "exception expected";
618     } catch (css::beans::UnknownPropertyException &) {}
619 }
620 
TEST_F(Test,testCppEmpty1)621 TEST_F(Test, testCppEmpty1) { testEmpty1(getCppSupplier()); }
622 
TEST_F(Test,testCppEmpty2)623 TEST_F(Test, testCppEmpty2) { testEmpty2(getCppSupplier()); }
624 
TEST_F(Test,testCppFull)625 TEST_F(Test, testCppFull) { testFull(getCppSupplier()); }
626 
TEST_F(Test,testJavaEmpty1)627 TEST_F(Test, testJavaEmpty1) { testEmpty1(getJavaSupplier()); }
628 
TEST_F(Test,testJavaEmpty2)629 TEST_F(Test, testJavaEmpty2) { testEmpty2(getJavaSupplier()); }
630 
TEST_F(Test,testJavaFull)631 TEST_F(Test, testJavaFull) { testFull(getJavaSupplier()); }
632 
633 
634 
635 }
636 
main(int argc,char ** argv)637 int main(int argc, char **argv)
638 {
639     osl_setCommandArgs(argc, argv);
640     ::testing::InitGoogleTest(&argc, argv);
641     return RUN_ALL_TESTS();
642 }
643 
644