1 /*************************************************************************
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
5 * Copyright 2008 by Sun Microsystems, Inc.
7 * OpenOffice.org - a multi-platform office productivity suite
9 * $RCSfile: testcomp.cxx,v $
12 * This file is part of OpenOffice.org.
14 * OpenOffice.org is free software: you can redistribute it and/or modify
15 * it under the terms of the GNU Lesser General Public License version 3
16 * only, as published by the Free Software Foundation.
18 * OpenOffice.org is distributed in the hope that it will be useful,
19 * but WITHOUT ANY WARRANTY; without even the implied warranty of
20 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
21 * GNU Lesser General Public License version 3 for more details
22 * (a copy is included in the LICENSE file that accompanied this code).
24 * You should have received a copy of the GNU Lesser General Public License
25 * version 3 along with OpenOffice.org. If not, see
26 * <http://www.openoffice.org/license.html>
27 * for a copy of the LGPLv3 License.
29 ************************************************************************/
31 // MARKER(update_precomp.py): autogen include statement, do not remove
32 #include "precompiled_bridges.hxx"
33 #if OSL_DEBUG_LEVEL == 0
42 #include <uno/threadpool.h>
44 #include <osl/mutex.hxx>
45 #include <osl/diagnose.h>
47 #include <test/XTestFactory.hpp>
48 #include <cppuhelper/servicefactory.hxx>
50 #include <com/sun/star/bridge/XInstanceProvider.hpp>
52 #include <com/sun/star/registry/XImplementationRegistration.hpp>
54 #include <com/sun/star/test/performance/XPerformanceTest.hpp>
55 #include <com/sun/star/lang/XServiceInfo.hpp>
57 #include <cppuhelper/weak.hxx>
59 using namespace ::test
;
60 using namespace ::rtl
;
61 using namespace ::test
;
62 using namespace ::com::sun::star::uno
;
63 using namespace ::com::sun::star::bridge
;
64 using namespace ::com::sun::star::lang
;
65 using namespace ::com::sun::star::registry
;
66 using namespace ::com::sun::star::test::performance
;
71 void parseCommandLine( char *argv
[] ,
72 ::rtl::OUString
*pConnection
, ::rtl::OUString
*pProtocol
,
73 sal_Bool
*pbLatency
, sal_Bool
*pbReverse
)
75 sal_Int32 nArgIndex
= 1;
76 if( ! strcmp( argv
[1] , "-r" ) )
79 *pbReverse
= sal_True
;
81 else if( ! strcmp( argv
[1] , "-latency" ) )
83 *pbLatency
= sal_True
;
87 OUString sTemp
= OUString::createFromAscii( argv
[nArgIndex
] );
88 sal_Int32 nIndex
= sTemp
.indexOf( ';' );
92 *pProtocol
= OUString( RTL_CONSTASCII_USTRINGPARAM( "iiop" ) );
96 *pConnection
= sTemp
.copy( 0 , nIndex
);
97 *pProtocol
= sTemp
.copy( nIndex
+1, sTemp
.getLength() - (nIndex
+1) );
101 Any
OInstanceProvider::queryInterface( const Type
& aType
) throw ( RuntimeException
)
103 Any a
= ::cppu::queryInterface( aType
,
104 SAL_STATIC_CAST( XInstanceProvider
* , this ) );
109 return OWeakObject::queryInterface( aType
);
112 ::com::sun::star::uno::Reference
< ::com::sun::star::uno::XInterface
>
113 OInstanceProvider::getInstance( const ::rtl::OUString
& sObjectName
)
114 throw(::com::sun::star::container::NoSuchElementException
,
115 ::com::sun::star::uno::RuntimeException
)
117 // Tries to get the PerformanceTestObject
118 if( sObjectName
== OUString( RTL_CONSTASCII_USTRINGPARAM( "TestRemoteObject" ) ) )
120 return m_rSMgr
->createInstance(
121 OUString( RTL_CONSTASCII_USTRINGPARAM("com.sun.star.test.performance.PerformanceTestObject") ) );
123 return Reference
< XInterface
> ( (::cppu::OWeakObject
* ) new OTestFactory() );
127 : public XServiceInfo
128 , public XPerformanceTest
130 OUString _aDummyString
;
132 Sequence
< Reference
< XInterface
> > _aDummySequence
;
133 ComplexTypes _aDummyStruct
;
134 RuntimeException _aDummyRE
;
142 ServiceImpl( const Reference
< XMultiServiceFactory
> & /* xMgr */)
147 virtual ::com::sun::star::uno::Any SAL_CALL
queryInterface( const ::com::sun::star::uno::Type
& aType
) throw(::com::sun::star::uno::RuntimeException
)
149 // execution time remains appr. constant any time
151 if (aType
== ::getCppuType( (const Reference
< XInterface
> *)0 ))
153 void * p
= (XInterface
*)(XPerformanceTest
*)this;
154 aRet
.setValue( &p
, ::getCppuType( (const Reference
< XInterface
> *)0 ) );
156 if (aType
== ::getCppuType( (const Reference
< XPerformanceTest
> *)0 ))
158 void * p
= (XPerformanceTest
*)this;
159 aRet
.setValue( &p
, ::getCppuType( (const Reference
< XPerformanceTest
> *)0 ) );
161 if (! aRet
.hasValue())
163 void * p
= (XPerformanceTest
*)this;
164 Any
aDummy( &p
, ::getCppuType( (const Reference
< XPerformanceTest
> *)0 ) );
168 virtual void SAL_CALL
acquire() throw()
169 { osl_incrementInterlockedCount( &_nRef
); }
170 virtual void SAL_CALL
release() throw()
171 { if (! osl_decrementInterlockedCount( &_nRef
)) delete this; }
174 virtual OUString SAL_CALL
getImplementationName() throw (RuntimeException
);
175 virtual sal_Bool SAL_CALL
supportsService( const OUString
& rServiceName
) throw (RuntimeException
);
176 virtual Sequence
< OUString
> SAL_CALL
getSupportedServiceNames() throw (RuntimeException
);
179 virtual sal_Int32 SAL_CALL
getLong_attr() throw(::com::sun::star::uno::RuntimeException
)
181 virtual void SAL_CALL
setLong_attr( sal_Int32
/* _attributelong */) throw(::com::sun::star::uno::RuntimeException
)
183 virtual sal_Int64 SAL_CALL
getHyper_attr() throw(::com::sun::star::uno::RuntimeException
)
185 virtual void SAL_CALL
setHyper_attr( sal_Int64
/* _attributehyper */) throw(::com::sun::star::uno::RuntimeException
)
187 virtual float SAL_CALL
getFloat_attr() throw(::com::sun::star::uno::RuntimeException
)
189 virtual void SAL_CALL
setFloat_attr( float /* _attributefloat */) throw(::com::sun::star::uno::RuntimeException
)
191 virtual double SAL_CALL
getDouble_attr() throw(::com::sun::star::uno::RuntimeException
)
193 virtual void SAL_CALL
setDouble_attr( double /* _attributedouble */) throw(::com::sun::star::uno::RuntimeException
)
195 virtual OUString SAL_CALL
getString_attr() throw(::com::sun::star::uno::RuntimeException
)
196 { return _aDummyString
; }
197 virtual void SAL_CALL
setString_attr( const ::rtl::OUString
& /* _attributestring */) throw(::com::sun::star::uno::RuntimeException
)
199 virtual Reference
< XInterface
> SAL_CALL
getInterface_attr() throw(::com::sun::star::uno::RuntimeException
)
200 { return Reference
< XInterface
>(); }
201 virtual void SAL_CALL
setInterface_attr( const Reference
< XInterface
>& /* _attributeinterface */) throw(::com::sun::star::uno::RuntimeException
)
203 virtual Any SAL_CALL
getAny_attr() throw(::com::sun::star::uno::RuntimeException
)
204 { return _aDummyAny
; }
205 virtual void SAL_CALL
setAny_attr( const Any
& /* _attributeany */) throw(::com::sun::star::uno::RuntimeException
)
207 virtual Sequence
< Reference
< XInterface
> > SAL_CALL
getSequence_attr() throw(::com::sun::star::uno::RuntimeException
)
208 { return _aDummySequence
; }
209 virtual void SAL_CALL
setSequence_attr( const Sequence
< Reference
< XInterface
> >& /* _attributesequence */) throw(::com::sun::star::uno::RuntimeException
)
211 virtual ComplexTypes SAL_CALL
getStruct_attr() throw(::com::sun::star::uno::RuntimeException
)
212 { return _aDummyStruct
; }
213 virtual void SAL_CALL
setStruct_attr( const ::com::sun::star::test::performance::ComplexTypes
& /* _attributestruct */) throw(::com::sun::star::uno::RuntimeException
)
217 virtual sal_Int32 SAL_CALL
getLong() throw(::com::sun::star::uno::RuntimeException
)
219 virtual void SAL_CALL
setLong( sal_Int32
/* _long */) throw(::com::sun::star::uno::RuntimeException
)
221 virtual sal_Int64 SAL_CALL
getHyper() throw(::com::sun::star::uno::RuntimeException
)
223 virtual void SAL_CALL
setHyper( sal_Int64
/* _hyper */) throw(::com::sun::star::uno::RuntimeException
)
225 virtual float SAL_CALL
getFloat() throw(::com::sun::star::uno::RuntimeException
)
227 virtual void SAL_CALL
setFloat( float /* _float */) throw(::com::sun::star::uno::RuntimeException
)
229 virtual double SAL_CALL
getDouble() throw(::com::sun::star::uno::RuntimeException
)
231 virtual void SAL_CALL
setDouble( double /* _double */) throw(::com::sun::star::uno::RuntimeException
)
233 virtual OUString SAL_CALL
getString() throw(::com::sun::star::uno::RuntimeException
)
234 { return _aDummyString
; }
235 virtual void SAL_CALL
setString( const ::rtl::OUString
& /* _string */) throw(::com::sun::star::uno::RuntimeException
)
237 virtual Reference
< XInterface
> SAL_CALL
getInterface() throw(::com::sun::star::uno::RuntimeException
)
238 { return Reference
< XInterface
>(); }
239 virtual void SAL_CALL
setInterface( const ::com::sun::star::uno::Reference
< ::com::sun::star::uno::XInterface
>& /* _interface */) throw(::com::sun::star::uno::RuntimeException
)
241 virtual Any SAL_CALL
getAny() throw(::com::sun::star::uno::RuntimeException
)
242 { return _aDummyAny
; }
243 virtual void SAL_CALL
setAny( const ::com::sun::star::uno::Any
& /* _any */) throw(::com::sun::star::uno::RuntimeException
)
245 virtual Sequence
< Reference
< XInterface
> > SAL_CALL
getSequence() throw(::com::sun::star::uno::RuntimeException
)
246 { return _aDummySequence
; }
247 virtual void SAL_CALL
setSequence( const Sequence
< Reference
< XInterface
> >& /*_sequence */) throw(::com::sun::star::uno::RuntimeException
)
249 virtual ComplexTypes SAL_CALL
getStruct() throw(::com::sun::star::uno::RuntimeException
)
250 { return _aDummyStruct
; }
251 virtual void SAL_CALL
setStruct( const ::com::sun::star::test::performance::ComplexTypes
& /* c */) throw(::com::sun::star::uno::RuntimeException
)
254 virtual void SAL_CALL
async() throw(::com::sun::star::uno::RuntimeException
);
256 virtual void SAL_CALL
sync() throw(::com::sun::star::uno::RuntimeException
)
258 virtual ComplexTypes SAL_CALL
complex_in( const ::com::sun::star::test::performance::ComplexTypes
& aVal
) throw(::com::sun::star::uno::RuntimeException
)
260 virtual ComplexTypes SAL_CALL
complex_inout( ::com::sun::star::test::performance::ComplexTypes
& aVal
) throw(::com::sun::star::uno::RuntimeException
)
262 virtual void SAL_CALL
complex_oneway( const ::com::sun::star::test::performance::ComplexTypes
& /* aVal */) throw(::com::sun::star::uno::RuntimeException
)
264 virtual void SAL_CALL
complex_noreturn( const ::com::sun::star::test::performance::ComplexTypes
& /* aVal */) throw(::com::sun::star::uno::RuntimeException
)
266 virtual Reference
< XPerformanceTest
> SAL_CALL
createObject() throw(::com::sun::star::uno::RuntimeException
)
267 { return new ServiceImpl(); }
268 virtual void SAL_CALL
raiseRuntimeException( ) throw(::com::sun::star::uno::RuntimeException
)
273 void ServiceImpl::async() throw(::com::sun::star::uno::RuntimeException
)
277 //__________________________________________________________________________________________________
278 OUString
ServiceImpl::getImplementationName()
279 throw (RuntimeException
)
283 //__________________________________________________________________________________________________
284 sal_Bool
ServiceImpl::supportsService( const OUString
& /* rServiceName */)
285 throw (RuntimeException
)
289 //__________________________________________________________________________________________________
290 Sequence
< OUString
> ServiceImpl::getSupportedServiceNames()
291 throw (RuntimeException
)
293 return Sequence
< OUString
> ();
301 Any
OCallMe::queryInterface( const Type
& aType
) throw ( RuntimeException
)
303 Any a
= ::cppu::queryInterface( aType
,
304 SAL_STATIC_CAST( XCallMe
* , this ) );
311 return OWeakObject::queryInterface( aType
);
314 void OCallMe::call( const ::rtl::OUString
& s
, sal_Int32 nToDo
)
315 throw( RuntimeException
, ::test::TestBridgeException
)
319 throw TestBridgeException();
324 OString o
= OUStringToOString( s
,RTL_TEXTENCODING_ASCII_US
);
325 printf( "%s\n" , o
.pData
->buffer
);
327 for( sal_Int32 i
= 0 ; i
< nToDo
; i
++ )
333 void SAL_CALL
OCallMe::drawLine( sal_Int32
/* x1 */, sal_Int32
/* y1 */, sal_Int32
/* x2 */, sal_Int32
/* y2 */)
334 throw(::com::sun::star::uno::RuntimeException
)
339 void OCallMe::callOneway( const ::rtl::OUString
& /* s */, sal_Int32 nToDo
)
340 throw(RuntimeException
)
343 m_nLastToDos
= nToDo
;
351 TimeValue val
= { nToDo
, 0 };
352 osl_waitThread( &val
);
358 ::test::TestTypes SAL_CALL
OCallMe::transport( const ::test::TestTypes
& types
)
359 throw(::com::sun::star::uno::RuntimeException
)
364 ::rtl::OUString
OCallMe::getsAttribute() throw(RuntimeException
)
368 void OCallMe::setsAttribute( const ::rtl::OUString
& _sattribute
)
369 throw(RuntimeException
)
371 m_sAttribute
= _sattribute
;
373 void OCallMe::callAgain( const Reference
< ::test::XCallMe
>& callAgainArg
,
374 sal_Int32 nToCall
) throw(RuntimeException
)
376 ::osl::MutexGuard
guard( m_mutex
);
379 printf( "Deadlocktest pong %" SAL_PRIdINT32
"\n", nToCall
);
383 printf( "Deadlocktest ping %" SAL_PRIdINT32
"\n", nToCall
);
387 callAgainArg
->callAgain( Reference
< XCallMe
> ( (XCallMe
*) this ) , nToCall
-1 );
391 /********************
395 Any
OInterfaceTest::queryInterface( const Type
& aType
) throw ( RuntimeException
)
397 Any a
= ::cppu::queryInterface( aType
,
398 SAL_STATIC_CAST( XInterfaceTest
* , this ) );
403 return OWeakObject::queryInterface( aType
);
407 void OInterfaceTest::setIn(
408 const Reference
< ::test::XCallMe
>& callback
)
409 throw(RuntimeException
)
411 m_rCallMe
= callback
;
415 void OInterfaceTest::setInOut( Reference
< ::test::XCallMe
>& callback
)
416 throw(RuntimeException
)
418 Reference
< XCallMe
> r
= m_rCallMe
;
419 m_rCallMe
= callback
;
425 void OInterfaceTest::getOut( Reference
< ::test::XCallMe
>& callback
)
426 throw(RuntimeException
)
428 callback
= m_rCallMe
;
431 Reference
< ::test::XCallMe
> OInterfaceTest::get( )
432 throw(RuntimeException
)
438 void OInterfaceTest::call()
442 m_rCallMe
->call( OUString( RTL_CONSTASCII_USTRINGPARAM("This is my String during a callback!")) , 5);
447 Any
OTestFactory::queryInterface( const Type
& aType
) throw ( RuntimeException
)
449 Any a
= ::cppu::queryInterface( aType
,
450 SAL_STATIC_CAST( XTestFactory
* , this ) );
457 return OWeakObject::queryInterface( aType
);
460 Reference
< ::test::XCallMe
> OTestFactory::createCallMe( )
461 throw(RuntimeException
)
463 return Reference
< XCallMe
> ( (XCallMe
* ) new OCallMe() );
466 Reference
< ::test::XInterfaceTest
> SAL_CALL
OTestFactory::createInterfaceTest( )
467 throw(RuntimeException
)
469 return Reference
< XInterfaceTest
> ( (XInterfaceTest
* ) new OInterfaceTest() );
475 // class OInstanceProvider :
476 // public ::cppu::OWeakObject,
477 // public XInstanceProvider
480 // OInstanceProvider( ){}
481 // ~OInstanceProvider(){ printf( "instance provider dies\n" );}
484 // Any SAL_CALL queryInterface( const Type & aType);
485 // void SAL_CALL acquire() { OWeakObject::acquire(); }
486 // void SAL_CALL release() { OWeakObject::release(); }
489 // virtual ::com::sun::star::uno::Reference< ::com::sun::star::uno::XInterface > SAL_CALL
490 // getInstance( const ::rtl::OUString& sObjectName )
491 // throw( ::com::sun::star::container::NoSuchElementException,
492 // ::com::sun::star::uno::RuntimeException);
502 double getCallsPerSec( const Reference
< XCallMe
> &rCall
, int nLoops
, int nToDo
)
504 TimeValue aStartTime
, aEndTime
;
505 osl_getSystemTime( &aStartTime
);
506 for( sal_Int32 i
= 0; i
< nLoops
; i
++ )
508 rCall
->call( OUString( RTL_CONSTASCII_USTRINGPARAM("Performance test string")) , nToDo
);
510 osl_getSystemTime( &aEndTime
);
512 double fStart
= (double)aStartTime
.Seconds
+ ((double)aStartTime
.Nanosec
/ 1000000000.0);
513 double fEnd
= (double)aEndTime
.Seconds
+ ((double)aEndTime
.Nanosec
/ 1000000000.0);
517 double getCallsPerSecOneway( const Reference
< XCallMe
> &rCall
,
520 double *pdAfterExecution
523 TimeValue aStartTime
, aEndTime
, aAfterExecution
;
524 osl_getSystemTime( &aStartTime
);
525 for( sal_Int32 i
= 0; i
< nLoops
; i
++ )
527 // rCall->callOneway( OUString( RTL_CONSTASCII_USTRINGPARAM("Performance test string" )), 0 );
528 rCall
->drawLine( 0 , 0 , 500 , 123 );
530 osl_getSystemTime( &aEndTime
);
532 rCall
->call( OUString( RTL_CONSTASCII_USTRINGPARAM("Performance test string")) , nToDo
);
533 osl_getSystemTime( &aAfterExecution
);
535 double fStart
= (double)aStartTime
.Seconds
+ ((double)aStartTime
.Nanosec
/ 1000000000.0);
536 double fEnd
= (double)aEndTime
.Seconds
+ ((double)aEndTime
.Nanosec
/ 1000000000.0);
537 *pdAfterExecution
= (double)aAfterExecution
.Seconds
+
538 ((double)aAfterExecution
.Nanosec
/ 1000000000.0) - fStart
;
542 void testOnewayPerformanceOnTwoInterfaces(
543 const Reference
< XCallMe
> &rRemote1
, const Reference
< XCallMe
> &rRemote2
)
545 printf( "Doing oneway performance test on two interfaces ...\n" );
546 const sal_Int32 nLoops
= 10000;
547 TimeValue aStartTime
, aEndTime
;
548 osl_getSystemTime( &aStartTime
);
549 for( sal_Int32 i
= 0; i
< nLoops
; i
++ )
551 rRemote1
->drawLine( 0 , 0 , 500 , 123 );
552 rRemote2
->drawLine( 0 , 0 , 500 , 123 );
554 osl_getSystemTime( &aEndTime
);
555 double fStart
= (double)aStartTime
.Seconds
+ ((double)aStartTime
.Nanosec
/ 1000000000.0);
556 double fEnd
= (double)aEndTime
.Seconds
+ ((double)aEndTime
.Nanosec
/ 1000000000.0);
558 printf( "Overhead per Call [ms] %g\n" , ((fEnd
-fStart
)/((double)nLoops
/1000 ))/2. );
561 void testPerformance( const Reference
< XCallMe
> &rRemote
,
562 const Reference
< XCallMe
> &rLocal
)
564 OUString aTestString
;
566 sal_Int32 nDoSomething
= 1;
567 sal_Int32 nCalls
= 80000;
568 double dRemote
, dLocal
,dAfterExecution
;
570 printf( "performance test oneway...\n" );
571 dLocal
= getCallsPerSecOneway( rLocal
, nCalls
, nDoSomething
, &dAfterExecution
);
572 dRemote
= getCallsPerSecOneway( rRemote
, nCalls
, nDoSomething
, &dAfterExecution
);
573 printf( "Local=%g s,"
574 "Remote : %g s\n" , dLocal
, dRemote
);
577 printf( "Remote/Local : %g\n", dRemote
/dLocal
);
580 printf( "Overhead per Call [ms] %g\n" , (dRemote
- dLocal
)/((double)nCalls
/1000 ) );
581 printf( "Overhead per Call after completion [ms] %g\n" , (dAfterExecution
- dLocal
)/((double)nCalls
/1000 ) );
585 printf( "Doing performance test ...\n" );
586 dRemote
= getCallsPerSec( rRemote
, nCalls
, nDoSomething
);
587 dLocal
= getCallsPerSec( rLocal
, nCalls
, nDoSomething
);
588 printf( "Local=%g s,\n"
589 "Remote=%g s\n" , dLocal
, dRemote
);
592 printf( "Remote/Local : %g\n", dRemote
/dLocal
);
594 printf( "Overhead per synchron Call [ms] %g\n" , ((dRemote
- dLocal
)/((double)nCalls
/1000 )) );
597 void testException( const Reference
< XCallMe
> &r
)
600 r
->call( OUString( RTL_CONSTASCII_USTRINGPARAM("dummy")) , -1 );
601 assert( ! "no exception flown !" );
603 catch( TestBridgeException
& e
)
605 // Exception flew successfully !
607 catch( Exception
& e
)
609 assert( ! "only base class of exception could be catched!" );
613 assert(! "wrong unknown exception !" );
617 void testSequenceOfCalls( const Reference
< XCallMe
> & rRCallMe
)
619 printf( "Testing sequence of calls\n" );
620 for( sal_Int32 i
= 0 ; i
< 800 ; i
++ )
622 rRCallMe
->callOneway( OUString( RTL_CONSTASCII_USTRINGPARAM("hifuj" )), 0 );
626 void testAllTypes( const Reference
< XCallMe
> & rRCallMe
)
628 printf( "Testing all types\n" );
630 for( sal_Int32 i
= 0; i
< 32 ; i
++ )
634 types
.Bool
= sal_True
;
637 types
.Short
= -32000;
638 types
.UShort
= (sal_uInt16
) (1 << i
);
640 types
.ULong
= 1 << i
;
642 types
.UHyper
= 1 << i
*2;
643 types
.Float
= (float)123.239;
644 types
.Double
= 1279.12490012;
645 types
.String
= OUString( RTL_CONSTASCII_USTRINGPARAM("abcdefghijklmnopqrstuvwxyz"));
646 types
.Interface
= Reference
< XInterface
>( rRCallMe
, UNO_QUERY
);
647 types
.Any
<<= types
.Double
;
649 TestTypes retTypes
= rRCallMe
->transport( types
);
651 OSL_ASSERT( ( types
.Bool
&& retTypes
.Bool
) || ( ! types
.Bool
&& ! retTypes
.Bool
) );
652 OSL_ASSERT( types
.Char
== retTypes
.Char
);
653 OSL_ASSERT( types
.Byte
== retTypes
.Byte
);
654 OSL_ASSERT( types
.Short
== retTypes
.Short
);
655 OSL_ASSERT( types
.UShort
== retTypes
.UShort
);
656 OSL_ASSERT( types
.Long
== retTypes
.Long
);
657 OSL_ASSERT( types
.ULong
== retTypes
.ULong
);
658 OSL_ASSERT( types
.Hyper
== retTypes
.Hyper
);
659 OSL_ASSERT( types
.UHyper
== retTypes
.UHyper
);
660 OSL_ASSERT( types
.Float
== retTypes
.Float
);
661 OSL_ASSERT( types
.Double
== retTypes
.Double
);
662 OSL_ASSERT( types
.String
== retTypes
.String
);
663 OSL_ASSERT( types
.Interface
== retTypes
.Interface
);
664 OSL_ASSERT( types
.Any
== retTypes
.Any
);
669 void testRemote( const Reference
< XInterface
> &rRemote
)
672 getCppuType( (sal_Int8
*)&a
);
674 Reference
< XTestFactory
> rRFact( rRemote
, UNO_QUERY
);
677 printf( "remote object doesn't support XTestFactory\n" );
680 OSL_ASSERT( rRFact
.is() );
681 Reference
< XCallMe
> rLCallMe
= (XCallMe
* ) new OCallMe();
682 Reference
< XCallMe
> rRCallMe
= rRFact
->createCallMe();
684 testAllTypes( rLCallMe
);
685 testAllTypes( rRCallMe
);
687 printf( "Testing exception local ...\n" );
688 testException( rLCallMe
);
689 printf( "Testing exception remote ...\n" );
690 testException( rRCallMe
);
692 //--------------------
694 //----------------------
695 OUString ow
= OUString::createFromAscii( "dum didel dum dideldei" );
696 rLCallMe
->setsAttribute( ow
);
697 OSL_ASSERT( rLCallMe
->getsAttribute() == ow
);
699 rRCallMe
->setsAttribute( ow
);
700 OSL_ASSERT( rRCallMe
->getsAttribute() == ow
);
702 //-------------------
704 //-------------------
705 testPerformance( rRCallMe
, rLCallMe
);
706 testOnewayPerformanceOnTwoInterfaces( rRFact
->createCallMe(), rRCallMe
);
711 testSequenceOfCalls( rRCallMe
);
714 // test triple to check if transporting the same interface multiple
715 // times causes any problems
716 Reference
< XInterfaceTest
> rRTest
= rRFact
->createInterfaceTest();
717 Reference
< XInterfaceTest
> rRTest2
= rRFact
->createInterfaceTest();
718 Reference
< XInterfaceTest
> rRTest3
= rRFact
->createInterfaceTest();
720 rRTest
->setIn( rRCallMe
);
721 rRTest2
->setIn( rRCallMe
);
722 rRTest3
->setIn( rRCallMe
);
724 OSL_ASSERT( rRTest
->get() == rRCallMe
);
725 OSL_ASSERT( rRTest2
->get() == rRCallMe
);
726 OSL_ASSERT( rRTest3
->get() == rRCallMe
);
728 rRTest
->setIn( rLCallMe
);
729 rRTest2
->setIn( rLCallMe
);
730 rRTest3
->setIn( rLCallMe
);
733 Reference
< XCallMe
> rLCallMe1
= (XCallMe
* ) new OCallMe();
734 Reference
< XCallMe
> rLCallMe2
= (XCallMe
* ) new OCallMe();
735 Reference
< XCallMe
> rLCallMe3
= (XCallMe
* ) new OCallMe();
736 rRTest
->setIn( rLCallMe1
);
737 rRTest2
->setIn( rLCallMe2
);
738 rRTest3
->setIn( rLCallMe3
);
739 OSL_ASSERT( rRTest
->get() == rLCallMe1
);
740 OSL_ASSERT( rRTest2
->get() == rLCallMe2
);
741 OSL_ASSERT( rRTest3
->get() == rLCallMe3
);
743 rRTest
->setIn( rLCallMe
);
744 rRTest2
->setIn( rLCallMe
);
745 rRTest3
->setIn( rLCallMe
);
747 OSL_ASSERT( rRTest
->get() == rLCallMe
);
748 OSL_ASSERT( rRTest2
->get() == rLCallMe
);
749 OSL_ASSERT( rRTest3
->get() == rLCallMe
);
752 Reference
< XCallMe
> r
= rRCallMe
;
753 rRTest
->setInOut( r
);
754 OSL_ASSERT( r
== rLCallMe
);
755 OSL_ASSERT( ! ( r
== rRCallMe
) );
757 // test empty references
758 rRTest
->setIn( Reference
< XCallMe
> () );
760 //--------------------------------
761 // test thread deadlocking
762 //--------------------------------
763 rLCallMe
->callAgain( rRCallMe
, 20 );
772 Reference
<XInterface
> createComponent( const ::rtl::OUString
&sService
,
773 const ::rtl::OUString
&sDllName
,
774 const Reference
< XMultiServiceFactory
> &rSMgr
)
776 Reference
< XInterface
> rInterface
;
777 rInterface
= rSMgr
->createInstance( sService
);
779 if( ! rInterface
.is() )
782 Reference
< XImplementationRegistration
> rReg (
783 rSMgr
->createInstance(
784 OUString::createFromAscii( "com.sun.star.registry.ImplementationRegistration" )),
787 OSL_ASSERT( rReg
.is() );
788 OUString aDllName
= sDllName
;
792 rReg
->registerImplementation(
793 OUString::createFromAscii( "com.sun.star.loader.SharedLibrary" ),
795 Reference
< XSimpleRegistry
> () );
796 rInterface
= rSMgr
->createInstance( sService
);
800 printf( "couldn't register dll %s\n" ,
801 OUStringToOString( aDllName
, RTL_TEXTENCODING_ASCII_US
).getStr() );