xref: /aoo42x/main/stoc/test/testproxyfac.cxx (revision 647a425c)
1*647a425cSAndrew Rist /**************************************************************
2cdf0e10cSrcweir  *
3*647a425cSAndrew Rist  * Licensed to the Apache Software Foundation (ASF) under one
4*647a425cSAndrew Rist  * or more contributor license agreements.  See the NOTICE file
5*647a425cSAndrew Rist  * distributed with this work for additional information
6*647a425cSAndrew Rist  * regarding copyright ownership.  The ASF licenses this file
7*647a425cSAndrew Rist  * to you under the Apache License, Version 2.0 (the
8*647a425cSAndrew Rist  * "License"); you may not use this file except in compliance
9*647a425cSAndrew Rist  * with the License.  You may obtain a copy of the License at
10*647a425cSAndrew Rist  *
11*647a425cSAndrew Rist  *   http://www.apache.org/licenses/LICENSE-2.0
12*647a425cSAndrew Rist  *
13*647a425cSAndrew Rist  * Unless required by applicable law or agreed to in writing,
14*647a425cSAndrew Rist  * software distributed under the License is distributed on an
15*647a425cSAndrew Rist  * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
16*647a425cSAndrew Rist  * KIND, either express or implied.  See the License for the
17*647a425cSAndrew Rist  * specific language governing permissions and limitations
18*647a425cSAndrew Rist  * under the License.
19*647a425cSAndrew Rist  *
20*647a425cSAndrew Rist  *************************************************************/
21*647a425cSAndrew Rist 
22*647a425cSAndrew Rist 
23cdf0e10cSrcweir 
24cdf0e10cSrcweir // MARKER(update_precomp.py): autogen include statement, do not remove
25cdf0e10cSrcweir #include "precompiled_stoc.hxx"
26cdf0e10cSrcweir 
27cdf0e10cSrcweir #include "sal/main.h"
28cdf0e10cSrcweir #include "osl/diagnose.h"
29cdf0e10cSrcweir #include "rtl/alloc.h"
30cdf0e10cSrcweir #include "uno/environment.hxx"
31cdf0e10cSrcweir #include "cppuhelper/servicefactory.hxx"
32cdf0e10cSrcweir #include "cppuhelper/implbase1.hxx"
33cdf0e10cSrcweir #include "cppuhelper/implbase3.hxx"
34cdf0e10cSrcweir #include "com/sun/star/uno/XCurrentContext.hpp"
35cdf0e10cSrcweir #include "com/sun/star/lang/DisposedException.hpp"
36cdf0e10cSrcweir #include "com/sun/star/lang/XComponent.hpp"
37cdf0e10cSrcweir #include "com/sun/star/lang/XServiceInfo.hpp"
38cdf0e10cSrcweir #include "com/sun/star/registry/XSimpleRegistry.hpp"
39cdf0e10cSrcweir #include "com/sun/star/registry/XImplementationRegistration.hpp"
40cdf0e10cSrcweir #include "com/sun/star/beans/XPropertySet.hpp"
41cdf0e10cSrcweir #include "com/sun/star/reflection/XProxyFactory.hpp"
42cdf0e10cSrcweir 
43cdf0e10cSrcweir #include <stdio.h>
44cdf0e10cSrcweir 
45cdf0e10cSrcweir 
46cdf0e10cSrcweir using namespace ::rtl;
47cdf0e10cSrcweir using namespace ::osl;
48cdf0e10cSrcweir using namespace ::cppu;
49cdf0e10cSrcweir using namespace ::com::sun::star;
50cdf0e10cSrcweir using namespace ::com::sun::star::uno;
51cdf0e10cSrcweir 
52cdf0e10cSrcweir 
53cdf0e10cSrcweir typedef WeakImplHelper3< lang::XServiceInfo,
54cdf0e10cSrcweir                          XCurrentContext,
55cdf0e10cSrcweir                          reflection::XProxyFactory > t_impl;
56cdf0e10cSrcweir 
57cdf0e10cSrcweir //==============================================================================
58cdf0e10cSrcweir class TargetObject : public t_impl
59cdf0e10cSrcweir {
60cdf0e10cSrcweir public:
61cdf0e10cSrcweir     static int s_obj;
62cdf0e10cSrcweir 
~TargetObject()63cdf0e10cSrcweir 	virtual ~TargetObject() {
64cdf0e10cSrcweir         --s_obj;
65cdf0e10cSrcweir         OSL_TRACE( "~TargetObject()" );
66cdf0e10cSrcweir     }
TargetObject()67cdf0e10cSrcweir     TargetObject()
68cdf0e10cSrcweir         { ++s_obj; }
69cdf0e10cSrcweir 
70cdf0e10cSrcweir     Any SAL_CALL queryInterface( Type const & type )
71cdf0e10cSrcweir         throw (RuntimeException);
72cdf0e10cSrcweir 
73cdf0e10cSrcweir 	// XServiceInfo
getImplementationName()74cdf0e10cSrcweir 	virtual OUString SAL_CALL getImplementationName() throw (RuntimeException)
75cdf0e10cSrcweir 		{ return OUString::createFromAscii( "target" ); }
supportsService(const OUString &)76cdf0e10cSrcweir 	virtual sal_Bool SAL_CALL supportsService( const OUString & /*rServiceName*/ )
77cdf0e10cSrcweir         throw (RuntimeException)
78cdf0e10cSrcweir 		{ return sal_False; }
getSupportedServiceNames()79cdf0e10cSrcweir 	virtual Sequence< OUString > SAL_CALL getSupportedServiceNames()
80cdf0e10cSrcweir         throw (RuntimeException)
81cdf0e10cSrcweir 		{ return Sequence< OUString >(); }
82cdf0e10cSrcweir 	// XProxyFactory
createProxy(const Reference<XInterface> & xTarget)83cdf0e10cSrcweir     virtual Reference< XAggregation > SAL_CALL createProxy(
84cdf0e10cSrcweir         const Reference< XInterface > & xTarget ) throw (RuntimeException)
85cdf0e10cSrcweir 		{ return Reference< XAggregation >( xTarget, UNO_QUERY ); }
86cdf0e10cSrcweir     // XCurrentContext
getValueByName(OUString const & name)87cdf0e10cSrcweir     virtual Any SAL_CALL getValueByName( OUString const & name )
88cdf0e10cSrcweir         throw (RuntimeException)
89cdf0e10cSrcweir         { return makeAny( name ); }
90cdf0e10cSrcweir };
91cdf0e10cSrcweir 
92cdf0e10cSrcweir //______________________________________________________________________________
queryInterface(Type const & type)93cdf0e10cSrcweir Any TargetObject::queryInterface( Type const & type )
94cdf0e10cSrcweir     throw (RuntimeException)
95cdf0e10cSrcweir {
96cdf0e10cSrcweir     Any ret( t_impl::queryInterface( type ) );
97cdf0e10cSrcweir     if (ret.hasValue())
98cdf0e10cSrcweir         return ret;
99cdf0e10cSrcweir     throw lang::DisposedException(
100cdf0e10cSrcweir         OUString( RTL_CONSTASCII_USTRINGPARAM("my test exception") ),
101cdf0e10cSrcweir         static_cast< OWeakObject * >(this) );
102cdf0e10cSrcweir }
103cdf0e10cSrcweir 
104cdf0e10cSrcweir int TargetObject::s_obj = 0;
105cdf0e10cSrcweir 
106cdf0e10cSrcweir 
107cdf0e10cSrcweir //==============================================================================
108cdf0e10cSrcweir class TestMaster : public WeakImplHelper1< lang::XServiceInfo >
109cdf0e10cSrcweir {
110cdf0e10cSrcweir 	Reference< XAggregation > m_xProxyTarget;
111cdf0e10cSrcweir     Reference<lang::XServiceInfo> m_xOtherProxyTargetBeforeSetDelegator;
112cdf0e10cSrcweir 
TestMaster()113cdf0e10cSrcweir     inline TestMaster() { ++s_obj; }
114cdf0e10cSrcweir public:
115cdf0e10cSrcweir     static int s_obj;
116cdf0e10cSrcweir     static Reference< XInterface > create(
117cdf0e10cSrcweir         Reference< reflection::XProxyFactory > const & xProxyFac );
118cdf0e10cSrcweir     static Reference< XInterface > create(
119cdf0e10cSrcweir         Reference< XInterface > const & xTarget,
120cdf0e10cSrcweir         Reference< reflection::XProxyFactory > const & xProxyFac );
121cdf0e10cSrcweir 
~TestMaster()122cdf0e10cSrcweir 	virtual ~TestMaster() {
123cdf0e10cSrcweir         --s_obj;
124cdf0e10cSrcweir         OSL_TRACE( "~TestMaster()" );
125cdf0e10cSrcweir     }
126cdf0e10cSrcweir 
queryInterface(const Type & rType)127cdf0e10cSrcweir     virtual Any SAL_CALL queryInterface( const Type & rType )
128cdf0e10cSrcweir         throw (RuntimeException)
129cdf0e10cSrcweir 	{
130cdf0e10cSrcweir 		Any aRet(
131cdf0e10cSrcweir             WeakImplHelper1< lang::XServiceInfo >::queryInterface( rType ) );
132cdf0e10cSrcweir 		if (aRet.hasValue())
133cdf0e10cSrcweir             return aRet;
134cdf0e10cSrcweir         return m_xProxyTarget->queryAggregation( rType );
135cdf0e10cSrcweir 	}
136cdf0e10cSrcweir 
137cdf0e10cSrcweir 	// XServiceInfo
getImplementationName()138cdf0e10cSrcweir 	virtual OUString SAL_CALL getImplementationName() throw (RuntimeException)
139cdf0e10cSrcweir 		{ return OUString::createFromAscii( "master" ); }
supportsService(const OUString &)140cdf0e10cSrcweir 	virtual sal_Bool SAL_CALL supportsService( const OUString & /*rServiceName*/ )
141cdf0e10cSrcweir         throw (RuntimeException)
142cdf0e10cSrcweir 		{ return sal_False; }
getSupportedServiceNames()143cdf0e10cSrcweir 	virtual Sequence< OUString > SAL_CALL getSupportedServiceNames()
144cdf0e10cSrcweir         throw (RuntimeException)
145cdf0e10cSrcweir 		{ return Sequence< OUString >(); }
146cdf0e10cSrcweir };
147cdf0e10cSrcweir 
148cdf0e10cSrcweir int TestMaster::s_obj = 0;
149cdf0e10cSrcweir 
150cdf0e10cSrcweir 
create(Reference<XInterface> const & xTarget,Reference<reflection::XProxyFactory> const & xProxyFac)151cdf0e10cSrcweir Reference< XInterface > TestMaster::create(
152cdf0e10cSrcweir     Reference< XInterface > const & xTarget,
153cdf0e10cSrcweir     Reference< reflection::XProxyFactory > const & xProxyFac )
154cdf0e10cSrcweir {
155cdf0e10cSrcweir     TestMaster * that = new TestMaster;
156cdf0e10cSrcweir     Reference< XInterface > xRet( static_cast< OWeakObject * >( that ) );
157cdf0e10cSrcweir     {
158cdf0e10cSrcweir         Reference< XAggregation > xAgg( xProxyFac->createProxy( xTarget ) );
159cdf0e10cSrcweir         // ownership take over
160cdf0e10cSrcweir         that->m_xProxyTarget.set( xAgg, UNO_QUERY_THROW );
161cdf0e10cSrcweir         that->m_xOtherProxyTargetBeforeSetDelegator.set(
162cdf0e10cSrcweir             that->m_xProxyTarget, UNO_QUERY );
163cdf0e10cSrcweir     }
164cdf0e10cSrcweir     that->m_xProxyTarget->setDelegator( xRet );
165cdf0e10cSrcweir     return xRet;
166cdf0e10cSrcweir }
167cdf0e10cSrcweir 
create(Reference<reflection::XProxyFactory> const & xProxyFac)168cdf0e10cSrcweir Reference< XInterface > TestMaster::create(
169cdf0e10cSrcweir     Reference< reflection::XProxyFactory > const & xProxyFac )
170cdf0e10cSrcweir {
171cdf0e10cSrcweir     return create(
172cdf0e10cSrcweir         static_cast< OWeakObject * >( new TargetObject ), xProxyFac );
173cdf0e10cSrcweir }
174cdf0e10cSrcweir 
175cdf0e10cSrcweir 
test_proxyfac_(Reference<XInterface> const & xMaster,OUString const & test,Reference<reflection::XProxyFactory> const &)176cdf0e10cSrcweir static void test_proxyfac_(
177cdf0e10cSrcweir     Reference< XInterface > const & xMaster, OUString const & test,
178cdf0e10cSrcweir     Reference< reflection::XProxyFactory > const & /*xProxyFac*/ )
179cdf0e10cSrcweir {
180cdf0e10cSrcweir     (void)test;
181cdf0e10cSrcweir     Reference< lang::XServiceInfo > xMaster_XServiceInfo(
182cdf0e10cSrcweir         xMaster, UNO_QUERY_THROW );
183cdf0e10cSrcweir 	OSL_ASSERT( xMaster_XServiceInfo->getImplementationName().equals( test ) );
184cdf0e10cSrcweir 
185cdf0e10cSrcweir     Reference< reflection::XProxyFactory > xTarget( xMaster, UNO_QUERY_THROW );
186cdf0e10cSrcweir     Reference< XCurrentContext > xTarget_XCurrentContext(
187cdf0e10cSrcweir         xTarget, UNO_QUERY_THROW );
188cdf0e10cSrcweir     Reference< XCurrentContext > xMaster_XCurrentContext(
189cdf0e10cSrcweir         xMaster, UNO_QUERY_THROW );
190cdf0e10cSrcweir 
191cdf0e10cSrcweir     OSL_ASSERT(
192cdf0e10cSrcweir         xTarget_XCurrentContext->getValueByName( test ) == makeAny( test ) );
193cdf0e10cSrcweir     OSL_ASSERT(
194cdf0e10cSrcweir         xMaster_XCurrentContext->getValueByName( test ) == makeAny( test ) );
195cdf0e10cSrcweir 
196cdf0e10cSrcweir     Reference< XAggregation > xFakeAgg( xTarget->createProxy( xTarget ) );
197cdf0e10cSrcweir     if (xFakeAgg.is())
198cdf0e10cSrcweir     {
199cdf0e10cSrcweir         OSL_ASSERT( xTarget == xFakeAgg );
200cdf0e10cSrcweir         OSL_ASSERT( xMaster == xFakeAgg );
201cdf0e10cSrcweir     }
202cdf0e10cSrcweir 
203cdf0e10cSrcweir     Reference< lang::XServiceInfo > xTarget_XServiceInfo(
204cdf0e10cSrcweir         xTarget, UNO_QUERY_THROW );
205cdf0e10cSrcweir 	OSL_ASSERT( xTarget_XServiceInfo->getImplementationName().equals( test ) );
206cdf0e10cSrcweir     Reference< lang::XServiceInfo > xTarget_XServiceInfo2(
207cdf0e10cSrcweir         xTarget, UNO_QUERY_THROW );
208cdf0e10cSrcweir     OSL_ASSERT( xTarget_XServiceInfo2.get() == xTarget_XServiceInfo.get() );
209cdf0e10cSrcweir 
210cdf0e10cSrcweir     OSL_ASSERT( xTarget == xTarget_XCurrentContext );
211cdf0e10cSrcweir     OSL_ASSERT( xTarget_XCurrentContext == xMaster );
212cdf0e10cSrcweir     OSL_ASSERT(
213cdf0e10cSrcweir         xTarget_XCurrentContext.get() == xMaster_XCurrentContext.get() );
214cdf0e10cSrcweir     OSL_ASSERT( xTarget_XCurrentContext == xMaster );
215cdf0e10cSrcweir     OSL_ASSERT( xTarget == xMaster );
216cdf0e10cSrcweir     OSL_ASSERT( xTarget_XServiceInfo.get() == xMaster_XServiceInfo.get() );
217cdf0e10cSrcweir     OSL_ASSERT( xTarget_XServiceInfo == xMaster );
218cdf0e10cSrcweir     OSL_ASSERT( xMaster_XServiceInfo == xMaster );
219cdf0e10cSrcweir 
220cdf0e10cSrcweir     try
221cdf0e10cSrcweir     {
222cdf0e10cSrcweir         Reference< registry::XRegistryKey >(
223cdf0e10cSrcweir             xMaster, UNO_QUERY_THROW );
224cdf0e10cSrcweir     }
225cdf0e10cSrcweir     catch (lang::DisposedException & exc)
226cdf0e10cSrcweir     {
227cdf0e10cSrcweir         if (! exc.Message.equalsAsciiL(
228cdf0e10cSrcweir                 RTL_CONSTASCII_STRINGPARAM("my test exception") ))
229cdf0e10cSrcweir             throw;
230cdf0e10cSrcweir     }
231cdf0e10cSrcweir }
232cdf0e10cSrcweir 
test_proxyfac(Reference<XInterface> const & xMaster,OUString const & test,Reference<reflection::XProxyFactory> const & xProxyFac)233cdf0e10cSrcweir static void test_proxyfac(
234cdf0e10cSrcweir     Reference< XInterface > const & xMaster, OUString const & test,
235cdf0e10cSrcweir     Reference< reflection::XProxyFactory > const & xProxyFac )
236cdf0e10cSrcweir {
237cdf0e10cSrcweir     test_proxyfac_( xMaster, test, xProxyFac );
238cdf0e10cSrcweir     // proxy the proxy...
239cdf0e10cSrcweir     Reference< XInterface > xNew( TestMaster::create( xMaster, xProxyFac ) );
240cdf0e10cSrcweir     test_proxyfac_(
241cdf0e10cSrcweir         xNew, OUString( RTL_CONSTASCII_USTRINGPARAM("master") ), xProxyFac );
242cdf0e10cSrcweir }
243cdf0e10cSrcweir 
SAL_IMPLEMENT_MAIN()244cdf0e10cSrcweir SAL_IMPLEMENT_MAIN()
245cdf0e10cSrcweir {
246cdf0e10cSrcweir     bool success = true;
247cdf0e10cSrcweir 
248cdf0e10cSrcweir     Environment cpp_env;
249cdf0e10cSrcweir     OUString cpp( RTL_CONSTASCII_USTRINGPARAM(
250cdf0e10cSrcweir                       CPPU_CURRENT_LANGUAGE_BINDING_NAME) );
251cdf0e10cSrcweir     uno_getEnvironment(
252cdf0e10cSrcweir         reinterpret_cast< uno_Environment ** >( &cpp_env ),
253cdf0e10cSrcweir         cpp.pData, 0 );
254cdf0e10cSrcweir     OSL_ENSURE( cpp_env.is(), "### cannot get C++ uno env!" );
255cdf0e10cSrcweir 
256cdf0e10cSrcweir 	{
257cdf0e10cSrcweir 		Reference< lang::XMultiServiceFactory > xMgr(
258cdf0e10cSrcweir             createRegistryServiceFactory(
259cdf0e10cSrcweir                 OUString( RTL_CONSTASCII_USTRINGPARAM("stoctest.rdb") ) ) );
260cdf0e10cSrcweir 
261cdf0e10cSrcweir 		try
262cdf0e10cSrcweir 		{
263cdf0e10cSrcweir 			Reference< registry::XImplementationRegistration > xImplReg(
264cdf0e10cSrcweir 				xMgr->createInstance(
265cdf0e10cSrcweir                     OUString(
266cdf0e10cSrcweir                         RTL_CONSTASCII_USTRINGPARAM(
267cdf0e10cSrcweir                             "com.sun.star.registry.ImplementationRegistration")
268cdf0e10cSrcweir                         ) ),
269cdf0e10cSrcweir                 UNO_QUERY );
270cdf0e10cSrcweir 			OSL_ENSURE( xImplReg.is(), "### no impl reg!" );
271cdf0e10cSrcweir 
272cdf0e10cSrcweir 			OUString aLibName(
273cdf0e10cSrcweir                 RTL_CONSTASCII_USTRINGPARAM("proxyfac.uno" SAL_DLLEXTENSION) );
274cdf0e10cSrcweir 			xImplReg->registerImplementation(
275cdf0e10cSrcweir 				OUString(
276cdf0e10cSrcweir                     RTL_CONSTASCII_USTRINGPARAM(
277cdf0e10cSrcweir                         "com.sun.star.loader.SharedLibrary") ),
278cdf0e10cSrcweir                 aLibName, Reference< registry::XSimpleRegistry >() );
279cdf0e10cSrcweir 
280cdf0e10cSrcweir 			Reference< reflection::XProxyFactory > xProxyFac(
281cdf0e10cSrcweir                 xMgr->createInstance(
282cdf0e10cSrcweir                     OUString::createFromAscii(
283cdf0e10cSrcweir                         "com.sun.star.reflection.ProxyFactory") ),
284cdf0e10cSrcweir                 UNO_QUERY_THROW );
285cdf0e10cSrcweir 
286cdf0e10cSrcweir             Reference< XAggregation > x(
287cdf0e10cSrcweir                 xProxyFac->createProxy(
288cdf0e10cSrcweir                     static_cast< OWeakObject * >( new TargetObject ) ) );
289cdf0e10cSrcweir             // no call
290cdf0e10cSrcweir 
291cdf0e10cSrcweir             {
292cdf0e10cSrcweir             Reference< XInterface > xMaster( TestMaster::create( xProxyFac ) );
293cdf0e10cSrcweir 			test_proxyfac(
294cdf0e10cSrcweir                 xMaster,
295cdf0e10cSrcweir                 OUString( RTL_CONSTASCII_USTRINGPARAM("master") ),
296cdf0e10cSrcweir                 xProxyFac );
297cdf0e10cSrcweir             }
298cdf0e10cSrcweir             {
299cdf0e10cSrcweir             Reference< XInterface > xMaster( TestMaster::create( xProxyFac ) );
300cdf0e10cSrcweir             // no call
301cdf0e10cSrcweir             }
302cdf0e10cSrcweir 
303cdf0e10cSrcweir             {
304cdf0e10cSrcweir             Reference< XInterface > xMaster( TestMaster::create( xProxyFac ) );
305cdf0e10cSrcweir             Reference< reflection::XProxyFactory > xSlave_lives_alone(
306cdf0e10cSrcweir                 xMaster, UNO_QUERY_THROW );
307cdf0e10cSrcweir             xMaster.clear();
308cdf0e10cSrcweir 			test_proxyfac(
309cdf0e10cSrcweir                 xSlave_lives_alone,
310cdf0e10cSrcweir                 OUString( RTL_CONSTASCII_USTRINGPARAM("master") ),
311cdf0e10cSrcweir                 xProxyFac );
312cdf0e10cSrcweir             uno_dumpEnvironment( stdout, cpp_env.get(), 0 );
313cdf0e10cSrcweir             }
314cdf0e10cSrcweir             {
315cdf0e10cSrcweir             Reference< XInterface > xMaster( TestMaster::create( xProxyFac ) );
316cdf0e10cSrcweir             Reference< reflection::XProxyFactory > xSlave_lives_alone(
317cdf0e10cSrcweir                 xMaster, UNO_QUERY_THROW );
318cdf0e10cSrcweir             // no call
319cdf0e10cSrcweir             }
320cdf0e10cSrcweir 
321cdf0e10cSrcweir             test_proxyfac(
322cdf0e10cSrcweir                 xProxyFac->createProxy(
323cdf0e10cSrcweir                     static_cast< OWeakObject * >( new TargetObject ) ),
324cdf0e10cSrcweir                 OUString( RTL_CONSTASCII_USTRINGPARAM("target") ),
325cdf0e10cSrcweir                 xProxyFac );
326cdf0e10cSrcweir             uno_dumpEnvironment( stdout, cpp_env.get(), 0 );
327cdf0e10cSrcweir         }
328cdf0e10cSrcweir 		catch (Exception & rExc)
329cdf0e10cSrcweir 		{
330cdf0e10cSrcweir             (void)rExc;
331cdf0e10cSrcweir 			OSL_ENSURE(
332cdf0e10cSrcweir                 ! __FILE__,
333cdf0e10cSrcweir                 OUStringToOString(
334cdf0e10cSrcweir                     rExc.Message, RTL_TEXTENCODING_ASCII_US ).getStr() );
335cdf0e10cSrcweir             success = false;
336cdf0e10cSrcweir 		}
337cdf0e10cSrcweir 
338cdf0e10cSrcweir 
339cdf0e10cSrcweir 		Reference< lang::XComponent > xComp;
340cdf0e10cSrcweir         Reference< beans::XPropertySet >(
341cdf0e10cSrcweir             xMgr, UNO_QUERY_THROW )->getPropertyValue(
342cdf0e10cSrcweir                 OUString( RTL_CONSTASCII_USTRINGPARAM("DefaultContext") ) )
343cdf0e10cSrcweir                     >>= xComp;
344cdf0e10cSrcweir         xComp->dispose();
345cdf0e10cSrcweir 	}
346cdf0e10cSrcweir 
347cdf0e10cSrcweir     if (TestMaster::s_obj != 0)
348cdf0e10cSrcweir         fprintf( stderr, "TestMaster objects: %d\n", TestMaster::s_obj );
349cdf0e10cSrcweir     if (TargetObject::s_obj != 0)
350cdf0e10cSrcweir         fprintf( stderr, "TargetObject objects: %d\n", TargetObject::s_obj );
351cdf0e10cSrcweir 
352cdf0e10cSrcweir     uno_dumpEnvironment( stdout, cpp_env.get(), 0 );
353cdf0e10cSrcweir     void ** ppInterfaces;
354cdf0e10cSrcweir     sal_Int32 len;
355cdf0e10cSrcweir     uno_ExtEnvironment * env = cpp_env.get()->pExtEnv;
356cdf0e10cSrcweir     (*env->getRegisteredInterfaces)(
357cdf0e10cSrcweir         env, &ppInterfaces, &len, rtl_allocateMemory );
358cdf0e10cSrcweir     if (len != 0)
359cdf0e10cSrcweir         fprintf( stderr, "%d registered C++ interfaces left!\n", len );
360cdf0e10cSrcweir 
361cdf0e10cSrcweir     success &= (TestMaster::s_obj == 0 &&
362cdf0e10cSrcweir                 TargetObject::s_obj == 0 &&
363cdf0e10cSrcweir                 len == 0);
364cdf0e10cSrcweir     if (success)
365cdf0e10cSrcweir     {
366cdf0e10cSrcweir         printf( "testproxyfac succeeded.\n" );
367cdf0e10cSrcweir         return 0;
368cdf0e10cSrcweir     }
369cdf0e10cSrcweir     else
370cdf0e10cSrcweir     {
371cdf0e10cSrcweir         fprintf( stderr, "testproxyfac failed!\n" );
372cdf0e10cSrcweir         return 1;
373cdf0e10cSrcweir     }
374cdf0e10cSrcweir }
375cdf0e10cSrcweir 
376