1*61dff127SAndrew Rist /************************************************************** 2cdf0e10cSrcweir * 3*61dff127SAndrew Rist * Licensed to the Apache Software Foundation (ASF) under one 4*61dff127SAndrew Rist * or more contributor license agreements. See the NOTICE file 5*61dff127SAndrew Rist * distributed with this work for additional information 6*61dff127SAndrew Rist * regarding copyright ownership. The ASF licenses this file 7*61dff127SAndrew Rist * to you under the Apache License, Version 2.0 (the 8*61dff127SAndrew Rist * "License"); you may not use this file except in compliance 9*61dff127SAndrew Rist * with the License. You may obtain a copy of the License at 10*61dff127SAndrew Rist * 11*61dff127SAndrew Rist * http://www.apache.org/licenses/LICENSE-2.0 12*61dff127SAndrew Rist * 13*61dff127SAndrew Rist * Unless required by applicable law or agreed to in writing, 14*61dff127SAndrew Rist * software distributed under the License is distributed on an 15*61dff127SAndrew Rist * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 16*61dff127SAndrew Rist * KIND, either express or implied. See the License for the 17*61dff127SAndrew Rist * specific language governing permissions and limitations 18*61dff127SAndrew Rist * under the License. 19*61dff127SAndrew Rist * 20*61dff127SAndrew Rist *************************************************************/ 21*61dff127SAndrew Rist 22*61dff127SAndrew Rist 23cdf0e10cSrcweir 24cdf0e10cSrcweir // MARKER(update_precomp.py): autogen include statement, do not remove 25cdf0e10cSrcweir #include "precompiled_bridges.hxx" 26cdf0e10cSrcweir #include <string.h> 27cdf0e10cSrcweir #include <stdlib.h> 28cdf0e10cSrcweir #include <osl/time.h> 29cdf0e10cSrcweir 30cdf0e10cSrcweir #include <uno/threadpool.h> 31cdf0e10cSrcweir 32cdf0e10cSrcweir #include <osl/mutex.hxx> 33cdf0e10cSrcweir #include <osl/diagnose.h> 34cdf0e10cSrcweir 35cdf0e10cSrcweir #include <test/XTestFactory.hpp> 36cdf0e10cSrcweir #include <cppuhelper/servicefactory.hxx> 37cdf0e10cSrcweir 38cdf0e10cSrcweir #include <com/sun/star/bridge/XInstanceProvider.hpp> 39cdf0e10cSrcweir 40cdf0e10cSrcweir #include <com/sun/star/registry/XImplementationRegistration.hpp> 41cdf0e10cSrcweir 42cdf0e10cSrcweir #include <com/sun/star/test/performance/XPerformanceTest.hpp> 43cdf0e10cSrcweir #include <com/sun/star/lang/XServiceInfo.hpp> 44cdf0e10cSrcweir 45cdf0e10cSrcweir #include <cppuhelper/weak.hxx> 46cdf0e10cSrcweir 47cdf0e10cSrcweir using namespace ::test; 48cdf0e10cSrcweir using namespace ::rtl; 49cdf0e10cSrcweir using namespace ::test; 50cdf0e10cSrcweir using namespace ::com::sun::star::uno; 51cdf0e10cSrcweir using namespace ::com::sun::star::bridge; 52cdf0e10cSrcweir using namespace ::com::sun::star::lang; 53cdf0e10cSrcweir using namespace ::com::sun::star::registry; 54cdf0e10cSrcweir using namespace ::com::sun::star::test::performance; 55cdf0e10cSrcweir 56cdf0e10cSrcweir #include "testcomp.h" 57cdf0e10cSrcweir 58cdf0e10cSrcweir 59cdf0e10cSrcweir void parseCommandLine( char *argv[] , 60cdf0e10cSrcweir ::rtl::OUString *pConnection , ::rtl::OUString *pProtocol , 61cdf0e10cSrcweir sal_Bool *pbLatency , sal_Bool *pbReverse) 62cdf0e10cSrcweir { 63cdf0e10cSrcweir sal_Int32 nArgIndex = 1; 64cdf0e10cSrcweir if( ! strcmp( argv[1] , "-r" ) ) 65cdf0e10cSrcweir { 66cdf0e10cSrcweir nArgIndex = 2; 67cdf0e10cSrcweir *pbReverse = sal_True; 68cdf0e10cSrcweir } 69cdf0e10cSrcweir else if( ! strcmp( argv[1] , "-latency" ) ) 70cdf0e10cSrcweir { 71cdf0e10cSrcweir *pbLatency = sal_True; 72cdf0e10cSrcweir nArgIndex = 2; 73cdf0e10cSrcweir } 74cdf0e10cSrcweir 75cdf0e10cSrcweir OUString sTemp = OUString::createFromAscii( argv[nArgIndex] ); 76cdf0e10cSrcweir sal_Int32 nIndex = sTemp.indexOf( ';' ); 77cdf0e10cSrcweir if( -1 == nIndex ) 78cdf0e10cSrcweir { 79cdf0e10cSrcweir *pConnection = sTemp; 80cdf0e10cSrcweir *pProtocol = OUString( RTL_CONSTASCII_USTRINGPARAM( "iiop" ) ); 81cdf0e10cSrcweir } 82cdf0e10cSrcweir else 83cdf0e10cSrcweir { 84cdf0e10cSrcweir *pConnection = sTemp.copy( 0 , nIndex ); 85cdf0e10cSrcweir *pProtocol = sTemp.copy( nIndex+1, sTemp.getLength() - (nIndex+1) ); 86cdf0e10cSrcweir } 87cdf0e10cSrcweir } 88cdf0e10cSrcweir 89cdf0e10cSrcweir Any OInstanceProvider::queryInterface( const Type & aType ) throw ( RuntimeException ) 90cdf0e10cSrcweir { 91cdf0e10cSrcweir Any a = ::cppu::queryInterface( aType , 92cdf0e10cSrcweir SAL_STATIC_CAST( XInstanceProvider * , this ) ); 93cdf0e10cSrcweir if( a.hasValue() ) 94cdf0e10cSrcweir { 95cdf0e10cSrcweir return a; 96cdf0e10cSrcweir } 97cdf0e10cSrcweir return OWeakObject::queryInterface( aType ); 98cdf0e10cSrcweir } 99cdf0e10cSrcweir 100cdf0e10cSrcweir ::com::sun::star::uno::Reference< ::com::sun::star::uno::XInterface > 101cdf0e10cSrcweir OInstanceProvider::getInstance( const ::rtl::OUString& sObjectName ) 102cdf0e10cSrcweir throw(::com::sun::star::container::NoSuchElementException, 103cdf0e10cSrcweir ::com::sun::star::uno::RuntimeException) 104cdf0e10cSrcweir { 105cdf0e10cSrcweir // Tries to get the PerformanceTestObject 106cdf0e10cSrcweir if( sObjectName == OUString( RTL_CONSTASCII_USTRINGPARAM( "TestRemoteObject" ) ) ) 107cdf0e10cSrcweir { 108cdf0e10cSrcweir return m_rSMgr->createInstance( 109cdf0e10cSrcweir OUString( RTL_CONSTASCII_USTRINGPARAM("com.sun.star.test.performance.PerformanceTestObject") ) ); 110cdf0e10cSrcweir } 111cdf0e10cSrcweir return Reference < XInterface > ( (::cppu::OWeakObject * ) new OTestFactory() ); 112cdf0e10cSrcweir } 113cdf0e10cSrcweir 114cdf0e10cSrcweir class ServiceImpl 115cdf0e10cSrcweir : public XServiceInfo 116cdf0e10cSrcweir , public XPerformanceTest 117cdf0e10cSrcweir { 118cdf0e10cSrcweir OUString _aDummyString; 119cdf0e10cSrcweir Any _aDummyAny; 120cdf0e10cSrcweir Sequence< Reference< XInterface > > _aDummySequence; 121cdf0e10cSrcweir ComplexTypes _aDummyStruct; 122cdf0e10cSrcweir RuntimeException _aDummyRE; 123cdf0e10cSrcweir 124cdf0e10cSrcweir sal_Int32 _nRef; 125cdf0e10cSrcweir 126cdf0e10cSrcweir public: 127cdf0e10cSrcweir ServiceImpl() 128cdf0e10cSrcweir : _nRef( 0 ) 129cdf0e10cSrcweir {} 130cdf0e10cSrcweir ServiceImpl( const Reference< XMultiServiceFactory > & /* xMgr */) 131cdf0e10cSrcweir : _nRef( 0 ) 132cdf0e10cSrcweir {} 133cdf0e10cSrcweir 134cdf0e10cSrcweir // XInterface 135cdf0e10cSrcweir virtual ::com::sun::star::uno::Any SAL_CALL queryInterface( const ::com::sun::star::uno::Type& aType ) throw(::com::sun::star::uno::RuntimeException) 136cdf0e10cSrcweir { 137cdf0e10cSrcweir // execution time remains appr. constant any time 138cdf0e10cSrcweir Any aRet; 139cdf0e10cSrcweir if (aType == ::getCppuType( (const Reference< XInterface > *)0 )) 140cdf0e10cSrcweir { 141cdf0e10cSrcweir void * p = (XInterface *)(XPerformanceTest *)this; 142cdf0e10cSrcweir aRet.setValue( &p, ::getCppuType( (const Reference< XInterface > *)0 ) ); 143cdf0e10cSrcweir } 144cdf0e10cSrcweir if (aType == ::getCppuType( (const Reference< XPerformanceTest > *)0 )) 145cdf0e10cSrcweir { 146cdf0e10cSrcweir void * p = (XPerformanceTest *)this; 147cdf0e10cSrcweir aRet.setValue( &p, ::getCppuType( (const Reference< XPerformanceTest > *)0 ) ); 148cdf0e10cSrcweir } 149cdf0e10cSrcweir if (! aRet.hasValue()) 150cdf0e10cSrcweir { 151cdf0e10cSrcweir void * p = (XPerformanceTest *)this; 152cdf0e10cSrcweir Any aDummy( &p, ::getCppuType( (const Reference< XPerformanceTest > *)0 ) ); 153cdf0e10cSrcweir } 154cdf0e10cSrcweir return aRet; 155cdf0e10cSrcweir } 156cdf0e10cSrcweir virtual void SAL_CALL acquire() throw() 157cdf0e10cSrcweir { osl_incrementInterlockedCount( &_nRef ); } 158cdf0e10cSrcweir virtual void SAL_CALL release() throw() 159cdf0e10cSrcweir { if (! osl_decrementInterlockedCount( &_nRef )) delete this; } 160cdf0e10cSrcweir 161cdf0e10cSrcweir // XServiceInfo 162cdf0e10cSrcweir virtual OUString SAL_CALL getImplementationName() throw (RuntimeException); 163cdf0e10cSrcweir virtual sal_Bool SAL_CALL supportsService( const OUString & rServiceName ) throw (RuntimeException); 164cdf0e10cSrcweir virtual Sequence< OUString > SAL_CALL getSupportedServiceNames() throw (RuntimeException); 165cdf0e10cSrcweir 166cdf0e10cSrcweir // Attributes 167cdf0e10cSrcweir virtual sal_Int32 SAL_CALL getLong_attr() throw(::com::sun::star::uno::RuntimeException) 168cdf0e10cSrcweir { return 0; } 169cdf0e10cSrcweir virtual void SAL_CALL setLong_attr( sal_Int32 /* _attributelong */) throw(::com::sun::star::uno::RuntimeException) 170cdf0e10cSrcweir {} 171cdf0e10cSrcweir virtual sal_Int64 SAL_CALL getHyper_attr() throw(::com::sun::star::uno::RuntimeException) 172cdf0e10cSrcweir { return 0; } 173cdf0e10cSrcweir virtual void SAL_CALL setHyper_attr( sal_Int64 /* _attributehyper */) throw(::com::sun::star::uno::RuntimeException) 174cdf0e10cSrcweir {} 175cdf0e10cSrcweir virtual float SAL_CALL getFloat_attr() throw(::com::sun::star::uno::RuntimeException) 176cdf0e10cSrcweir { return 0.0; } 177cdf0e10cSrcweir virtual void SAL_CALL setFloat_attr( float /* _attributefloat */) throw(::com::sun::star::uno::RuntimeException) 178cdf0e10cSrcweir {} 179cdf0e10cSrcweir virtual double SAL_CALL getDouble_attr() throw(::com::sun::star::uno::RuntimeException) 180cdf0e10cSrcweir { return 0.0; } 181cdf0e10cSrcweir virtual void SAL_CALL setDouble_attr( double /* _attributedouble */) throw(::com::sun::star::uno::RuntimeException) 182cdf0e10cSrcweir {} 183cdf0e10cSrcweir virtual OUString SAL_CALL getString_attr() throw(::com::sun::star::uno::RuntimeException) 184cdf0e10cSrcweir { return _aDummyString; } 185cdf0e10cSrcweir virtual void SAL_CALL setString_attr( const ::rtl::OUString& /* _attributestring */) throw(::com::sun::star::uno::RuntimeException) 186cdf0e10cSrcweir {} 187cdf0e10cSrcweir virtual Reference< XInterface > SAL_CALL getInterface_attr() throw(::com::sun::star::uno::RuntimeException) 188cdf0e10cSrcweir { return Reference< XInterface >(); } 189cdf0e10cSrcweir virtual void SAL_CALL setInterface_attr( const Reference< XInterface >& /* _attributeinterface */) throw(::com::sun::star::uno::RuntimeException) 190cdf0e10cSrcweir {} 191cdf0e10cSrcweir virtual Any SAL_CALL getAny_attr() throw(::com::sun::star::uno::RuntimeException) 192cdf0e10cSrcweir { return _aDummyAny; } 193cdf0e10cSrcweir virtual void SAL_CALL setAny_attr( const Any& /* _attributeany */) throw(::com::sun::star::uno::RuntimeException) 194cdf0e10cSrcweir {} 195cdf0e10cSrcweir virtual Sequence< Reference< XInterface > > SAL_CALL getSequence_attr() throw(::com::sun::star::uno::RuntimeException) 196cdf0e10cSrcweir { return _aDummySequence; } 197cdf0e10cSrcweir virtual void SAL_CALL setSequence_attr( const Sequence< Reference< XInterface > >& /* _attributesequence */) throw(::com::sun::star::uno::RuntimeException) 198cdf0e10cSrcweir {} 199cdf0e10cSrcweir virtual ComplexTypes SAL_CALL getStruct_attr() throw(::com::sun::star::uno::RuntimeException) 200cdf0e10cSrcweir { return _aDummyStruct; } 201cdf0e10cSrcweir virtual void SAL_CALL setStruct_attr( const ::com::sun::star::test::performance::ComplexTypes& /* _attributestruct */) throw(::com::sun::star::uno::RuntimeException) 202cdf0e10cSrcweir {} 203cdf0e10cSrcweir 204cdf0e10cSrcweir // Methods 205cdf0e10cSrcweir virtual sal_Int32 SAL_CALL getLong() throw(::com::sun::star::uno::RuntimeException) 206cdf0e10cSrcweir { return 0; } 207cdf0e10cSrcweir virtual void SAL_CALL setLong( sal_Int32 /* _long */) throw(::com::sun::star::uno::RuntimeException) 208cdf0e10cSrcweir {} 209cdf0e10cSrcweir virtual sal_Int64 SAL_CALL getHyper() throw(::com::sun::star::uno::RuntimeException) 210cdf0e10cSrcweir { return 0; } 211cdf0e10cSrcweir virtual void SAL_CALL setHyper( sal_Int64 /* _hyper */) throw(::com::sun::star::uno::RuntimeException) 212cdf0e10cSrcweir {} 213cdf0e10cSrcweir virtual float SAL_CALL getFloat() throw(::com::sun::star::uno::RuntimeException) 214cdf0e10cSrcweir { return 0; } 215cdf0e10cSrcweir virtual void SAL_CALL setFloat( float /* _float */) throw(::com::sun::star::uno::RuntimeException) 216cdf0e10cSrcweir {} 217cdf0e10cSrcweir virtual double SAL_CALL getDouble() throw(::com::sun::star::uno::RuntimeException) 218cdf0e10cSrcweir { return 0; } 219cdf0e10cSrcweir virtual void SAL_CALL setDouble( double /* _double */) throw(::com::sun::star::uno::RuntimeException) 220cdf0e10cSrcweir {} 221cdf0e10cSrcweir virtual OUString SAL_CALL getString() throw(::com::sun::star::uno::RuntimeException) 222cdf0e10cSrcweir { return _aDummyString; } 223cdf0e10cSrcweir virtual void SAL_CALL setString( const ::rtl::OUString& /* _string */) throw(::com::sun::star::uno::RuntimeException) 224cdf0e10cSrcweir {} 225cdf0e10cSrcweir virtual Reference< XInterface > SAL_CALL getInterface() throw(::com::sun::star::uno::RuntimeException) 226cdf0e10cSrcweir { return Reference< XInterface >(); } 227cdf0e10cSrcweir virtual void SAL_CALL setInterface( const ::com::sun::star::uno::Reference< ::com::sun::star::uno::XInterface >& /* _interface */) throw(::com::sun::star::uno::RuntimeException) 228cdf0e10cSrcweir {} 229cdf0e10cSrcweir virtual Any SAL_CALL getAny() throw(::com::sun::star::uno::RuntimeException) 230cdf0e10cSrcweir { return _aDummyAny; } 231cdf0e10cSrcweir virtual void SAL_CALL setAny( const ::com::sun::star::uno::Any& /* _any */) throw(::com::sun::star::uno::RuntimeException) 232cdf0e10cSrcweir {} 233cdf0e10cSrcweir virtual Sequence< Reference< XInterface > > SAL_CALL getSequence() throw(::com::sun::star::uno::RuntimeException) 234cdf0e10cSrcweir { return _aDummySequence; } 235cdf0e10cSrcweir virtual void SAL_CALL setSequence( const Sequence< Reference< XInterface > >& /*_sequence */) throw(::com::sun::star::uno::RuntimeException) 236cdf0e10cSrcweir {} 237cdf0e10cSrcweir virtual ComplexTypes SAL_CALL getStruct() throw(::com::sun::star::uno::RuntimeException) 238cdf0e10cSrcweir { return _aDummyStruct; } 239cdf0e10cSrcweir virtual void SAL_CALL setStruct( const ::com::sun::star::test::performance::ComplexTypes& /* c */) throw(::com::sun::star::uno::RuntimeException) 240cdf0e10cSrcweir {} 241cdf0e10cSrcweir 242cdf0e10cSrcweir virtual void SAL_CALL async() throw(::com::sun::star::uno::RuntimeException); 243cdf0e10cSrcweir 244cdf0e10cSrcweir virtual void SAL_CALL sync() throw(::com::sun::star::uno::RuntimeException) 245cdf0e10cSrcweir {} 246cdf0e10cSrcweir virtual ComplexTypes SAL_CALL complex_in( const ::com::sun::star::test::performance::ComplexTypes& aVal ) throw(::com::sun::star::uno::RuntimeException) 247cdf0e10cSrcweir { return aVal; } 248cdf0e10cSrcweir virtual ComplexTypes SAL_CALL complex_inout( ::com::sun::star::test::performance::ComplexTypes& aVal ) throw(::com::sun::star::uno::RuntimeException) 249cdf0e10cSrcweir { return aVal; } 250cdf0e10cSrcweir virtual void SAL_CALL complex_oneway( const ::com::sun::star::test::performance::ComplexTypes& /* aVal */) throw(::com::sun::star::uno::RuntimeException) 251cdf0e10cSrcweir {} 252cdf0e10cSrcweir virtual void SAL_CALL complex_noreturn( const ::com::sun::star::test::performance::ComplexTypes& /* aVal */) throw(::com::sun::star::uno::RuntimeException) 253cdf0e10cSrcweir {} 254cdf0e10cSrcweir virtual Reference< XPerformanceTest > SAL_CALL createObject() throw(::com::sun::star::uno::RuntimeException) 255cdf0e10cSrcweir { return new ServiceImpl(); } 256cdf0e10cSrcweir virtual void SAL_CALL raiseRuntimeException( ) throw(::com::sun::star::uno::RuntimeException) 257cdf0e10cSrcweir { throw _aDummyRE; } 258cdf0e10cSrcweir }; 259cdf0e10cSrcweir 260cdf0e10cSrcweir 261cdf0e10cSrcweir void ServiceImpl::async() throw(::com::sun::star::uno::RuntimeException) 262cdf0e10cSrcweir {} 263cdf0e10cSrcweir 264cdf0e10cSrcweir // XServiceInfo 265cdf0e10cSrcweir //__________________________________________________________________________________________________ 266cdf0e10cSrcweir OUString ServiceImpl::getImplementationName() 267cdf0e10cSrcweir throw (RuntimeException) 268cdf0e10cSrcweir { 269cdf0e10cSrcweir return OUString( ); 270cdf0e10cSrcweir } 271cdf0e10cSrcweir //__________________________________________________________________________________________________ 272cdf0e10cSrcweir sal_Bool ServiceImpl::supportsService( const OUString & /* rServiceName */) 273cdf0e10cSrcweir throw (RuntimeException) 274cdf0e10cSrcweir { 275cdf0e10cSrcweir return sal_False; 276cdf0e10cSrcweir } 277cdf0e10cSrcweir //__________________________________________________________________________________________________ 278cdf0e10cSrcweir Sequence< OUString > ServiceImpl::getSupportedServiceNames() 279cdf0e10cSrcweir throw (RuntimeException) 280cdf0e10cSrcweir { 281cdf0e10cSrcweir return Sequence< OUString > (); 282cdf0e10cSrcweir } 283cdf0e10cSrcweir 284cdf0e10cSrcweir /****************** 285cdf0e10cSrcweir * OCallMe 286cdf0e10cSrcweir * 287cdf0e10cSrcweir *****************/ 288cdf0e10cSrcweir 289cdf0e10cSrcweir Any OCallMe::queryInterface( const Type & aType ) throw ( RuntimeException ) 290cdf0e10cSrcweir { 291cdf0e10cSrcweir Any a = ::cppu::queryInterface( aType, 292cdf0e10cSrcweir SAL_STATIC_CAST( XCallMe * , this ) ); 293cdf0e10cSrcweir 294cdf0e10cSrcweir if( a.hasValue() ) 295cdf0e10cSrcweir { 296cdf0e10cSrcweir return a; 297cdf0e10cSrcweir } 298cdf0e10cSrcweir 299cdf0e10cSrcweir return OWeakObject::queryInterface( aType ); 300cdf0e10cSrcweir } 301cdf0e10cSrcweir 302cdf0e10cSrcweir void OCallMe::call( const ::rtl::OUString& s, sal_Int32 nToDo ) 303cdf0e10cSrcweir throw( RuntimeException, ::test::TestBridgeException) 304cdf0e10cSrcweir { 305cdf0e10cSrcweir if( nToDo < 0 ) 306cdf0e10cSrcweir { 307cdf0e10cSrcweir throw TestBridgeException(); 308cdf0e10cSrcweir } 309cdf0e10cSrcweir 310cdf0e10cSrcweir OUString sDummy; 311cdf0e10cSrcweir if( ! nToDo ) { 312cdf0e10cSrcweir OString o = OUStringToOString( s,RTL_TEXTENCODING_ASCII_US); 313cdf0e10cSrcweir printf( "%s\n" , o.pData->buffer ); 314cdf0e10cSrcweir } 315cdf0e10cSrcweir for( sal_Int32 i = 0 ; i < nToDo ; i ++ ) 316cdf0e10cSrcweir { 317cdf0e10cSrcweir sDummy += s; 318cdf0e10cSrcweir } 319cdf0e10cSrcweir } 320cdf0e10cSrcweir 321cdf0e10cSrcweir void SAL_CALL OCallMe::drawLine( sal_Int32 /* x1 */, sal_Int32 /* y1 */, sal_Int32 /* x2 */, sal_Int32 /* y2 */) 322cdf0e10cSrcweir throw(::com::sun::star::uno::RuntimeException) 323cdf0e10cSrcweir { 324cdf0e10cSrcweir // do nothings 325cdf0e10cSrcweir } 326cdf0e10cSrcweir 327cdf0e10cSrcweir void OCallMe::callOneway( const ::rtl::OUString& /* s */, sal_Int32 nToDo ) 328cdf0e10cSrcweir throw(RuntimeException) 329cdf0e10cSrcweir { 330cdf0e10cSrcweir OUString sDummy; 331cdf0e10cSrcweir m_nLastToDos = nToDo; 332cdf0e10cSrcweir 333cdf0e10cSrcweir 334cdf0e10cSrcweir if( nToDo ) 335cdf0e10cSrcweir { 336cdf0e10cSrcweir printf( "+" ); 337cdf0e10cSrcweir fflush( stdout ); 338cdf0e10cSrcweir 339cdf0e10cSrcweir TimeValue val = { nToDo , 0 }; 340cdf0e10cSrcweir osl_waitThread( &val ); 341cdf0e10cSrcweir printf( "-\n" ); 342cdf0e10cSrcweir } 343cdf0e10cSrcweir 344cdf0e10cSrcweir } 345cdf0e10cSrcweir 346cdf0e10cSrcweir ::test::TestTypes SAL_CALL OCallMe::transport( const ::test::TestTypes& types ) 347cdf0e10cSrcweir throw(::com::sun::star::uno::RuntimeException) 348cdf0e10cSrcweir { 349cdf0e10cSrcweir return types; 350cdf0e10cSrcweir } 351cdf0e10cSrcweir 352cdf0e10cSrcweir ::rtl::OUString OCallMe::getsAttribute() throw(RuntimeException) 353cdf0e10cSrcweir { 354cdf0e10cSrcweir return m_sAttribute; 355cdf0e10cSrcweir } 356cdf0e10cSrcweir void OCallMe::setsAttribute( const ::rtl::OUString& _sattribute ) 357cdf0e10cSrcweir throw(RuntimeException) 358cdf0e10cSrcweir { 359cdf0e10cSrcweir m_sAttribute = _sattribute; 360cdf0e10cSrcweir } 361cdf0e10cSrcweir void OCallMe::callAgain( const Reference< ::test::XCallMe >& callAgainArg, 362cdf0e10cSrcweir sal_Int32 nToCall ) throw(RuntimeException) 363cdf0e10cSrcweir { 364cdf0e10cSrcweir ::osl::MutexGuard guard( m_mutex ); 365cdf0e10cSrcweir if( nToCall %2 ) 366cdf0e10cSrcweir { 367cdf0e10cSrcweir printf( "Deadlocktest pong %" SAL_PRIdINT32 "\n", nToCall ); 368cdf0e10cSrcweir } 369cdf0e10cSrcweir else 370cdf0e10cSrcweir { 371cdf0e10cSrcweir printf( "Deadlocktest ping %" SAL_PRIdINT32 "\n", nToCall ); 372cdf0e10cSrcweir } 373cdf0e10cSrcweir if( nToCall ) 374cdf0e10cSrcweir { 375cdf0e10cSrcweir callAgainArg->callAgain( Reference< XCallMe > ( (XCallMe *) this ) , nToCall -1 ); 376cdf0e10cSrcweir } 377cdf0e10cSrcweir } 378cdf0e10cSrcweir 379cdf0e10cSrcweir /******************** 380cdf0e10cSrcweir * OInterfaceTest 381cdf0e10cSrcweir * 382cdf0e10cSrcweir *******************/ 383cdf0e10cSrcweir Any OInterfaceTest::queryInterface( const Type & aType ) throw ( RuntimeException ) 384cdf0e10cSrcweir { 385cdf0e10cSrcweir Any a = ::cppu::queryInterface( aType, 386cdf0e10cSrcweir SAL_STATIC_CAST( XInterfaceTest * , this ) ); 387cdf0e10cSrcweir if( a.hasValue() ) 388cdf0e10cSrcweir { 389cdf0e10cSrcweir return a; 390cdf0e10cSrcweir } 391cdf0e10cSrcweir return OWeakObject::queryInterface( aType ); 392cdf0e10cSrcweir } 393cdf0e10cSrcweir 394cdf0e10cSrcweir 395cdf0e10cSrcweir void OInterfaceTest::setIn( 396cdf0e10cSrcweir const Reference< ::test::XCallMe >& callback ) 397cdf0e10cSrcweir throw(RuntimeException) 398cdf0e10cSrcweir { 399cdf0e10cSrcweir m_rCallMe = callback; 400cdf0e10cSrcweir call(); 401cdf0e10cSrcweir } 402cdf0e10cSrcweir 403cdf0e10cSrcweir void OInterfaceTest::setInOut( Reference< ::test::XCallMe >& callback ) 404cdf0e10cSrcweir throw(RuntimeException) 405cdf0e10cSrcweir { 406cdf0e10cSrcweir Reference< XCallMe > r = m_rCallMe; 407cdf0e10cSrcweir m_rCallMe = callback; 408cdf0e10cSrcweir callback = r; 409cdf0e10cSrcweir call(); 410cdf0e10cSrcweir } 411cdf0e10cSrcweir 412cdf0e10cSrcweir 413cdf0e10cSrcweir void OInterfaceTest::getOut( Reference< ::test::XCallMe >& callback ) 414cdf0e10cSrcweir throw(RuntimeException) 415cdf0e10cSrcweir { 416cdf0e10cSrcweir callback = m_rCallMe; 417cdf0e10cSrcweir } 418cdf0e10cSrcweir 419cdf0e10cSrcweir Reference< ::test::XCallMe > OInterfaceTest::get( ) 420cdf0e10cSrcweir throw(RuntimeException) 421cdf0e10cSrcweir { 422cdf0e10cSrcweir call(); 423cdf0e10cSrcweir return m_rCallMe; 424cdf0e10cSrcweir } 425cdf0e10cSrcweir 426cdf0e10cSrcweir void OInterfaceTest::call() 427cdf0e10cSrcweir { 428cdf0e10cSrcweir if( m_rCallMe.is() ) 429cdf0e10cSrcweir { 430cdf0e10cSrcweir m_rCallMe->call( OUString( RTL_CONSTASCII_USTRINGPARAM("This is my String during a callback!")) , 5); 431cdf0e10cSrcweir } 432cdf0e10cSrcweir } 433cdf0e10cSrcweir 434cdf0e10cSrcweir 435cdf0e10cSrcweir Any OTestFactory::queryInterface( const Type & aType ) throw ( RuntimeException ) 436cdf0e10cSrcweir { 437cdf0e10cSrcweir Any a = ::cppu::queryInterface( aType, 438cdf0e10cSrcweir SAL_STATIC_CAST( XTestFactory * , this ) ); 439cdf0e10cSrcweir 440cdf0e10cSrcweir if( a.hasValue() ) 441cdf0e10cSrcweir { 442cdf0e10cSrcweir return a; 443cdf0e10cSrcweir } 444cdf0e10cSrcweir 445cdf0e10cSrcweir return OWeakObject::queryInterface( aType ); 446cdf0e10cSrcweir } 447cdf0e10cSrcweir 448cdf0e10cSrcweir Reference< ::test::XCallMe > OTestFactory::createCallMe( ) 449cdf0e10cSrcweir throw(RuntimeException) 450cdf0e10cSrcweir { 451cdf0e10cSrcweir return Reference< XCallMe > ( (XCallMe * ) new OCallMe() ); 452cdf0e10cSrcweir } 453cdf0e10cSrcweir 454cdf0e10cSrcweir Reference< ::test::XInterfaceTest > SAL_CALL OTestFactory::createInterfaceTest( ) 455cdf0e10cSrcweir throw(RuntimeException) 456cdf0e10cSrcweir { 457cdf0e10cSrcweir return Reference < XInterfaceTest > ( (XInterfaceTest * ) new OInterfaceTest() ); 458cdf0e10cSrcweir } 459cdf0e10cSrcweir 460cdf0e10cSrcweir 461cdf0e10cSrcweir 462cdf0e10cSrcweir 463cdf0e10cSrcweir // class OInstanceProvider : 464cdf0e10cSrcweir // public ::cppu::OWeakObject, 465cdf0e10cSrcweir // public XInstanceProvider 466cdf0e10cSrcweir // { 467cdf0e10cSrcweir // public: 468cdf0e10cSrcweir // OInstanceProvider( ){} 469cdf0e10cSrcweir // ~OInstanceProvider(){ printf( "instance provider dies\n" );} 470cdf0e10cSrcweir // public: 471cdf0e10cSrcweir // // XInterface 472cdf0e10cSrcweir // Any SAL_CALL queryInterface( const Type & aType); 473cdf0e10cSrcweir // void SAL_CALL acquire() { OWeakObject::acquire(); } 474cdf0e10cSrcweir // void SAL_CALL release() { OWeakObject::release(); } 475cdf0e10cSrcweir 476cdf0e10cSrcweir // public: 477cdf0e10cSrcweir // virtual ::com::sun::star::uno::Reference< ::com::sun::star::uno::XInterface > SAL_CALL 478cdf0e10cSrcweir // getInstance( const ::rtl::OUString& sObjectName ) 479cdf0e10cSrcweir // throw( ::com::sun::star::container::NoSuchElementException, 480cdf0e10cSrcweir // ::com::sun::star::uno::RuntimeException); 481cdf0e10cSrcweir // }; 482cdf0e10cSrcweir 483cdf0e10cSrcweir 484cdf0e10cSrcweir 485cdf0e10cSrcweir 486cdf0e10cSrcweir 487cdf0e10cSrcweir 488cdf0e10cSrcweir 489cdf0e10cSrcweir 490cdf0e10cSrcweir double getCallsPerSec( const Reference < XCallMe > &rCall , int nLoops, int nToDo ) 491cdf0e10cSrcweir { 492cdf0e10cSrcweir TimeValue aStartTime, aEndTime; 493cdf0e10cSrcweir osl_getSystemTime( &aStartTime ); 494cdf0e10cSrcweir for( sal_Int32 i = 0; i < nLoops; i ++ ) 495cdf0e10cSrcweir { 496cdf0e10cSrcweir rCall->call( OUString( RTL_CONSTASCII_USTRINGPARAM("Performance test string")) , nToDo ); 497cdf0e10cSrcweir } 498cdf0e10cSrcweir osl_getSystemTime( &aEndTime ); 499cdf0e10cSrcweir 500cdf0e10cSrcweir double fStart = (double)aStartTime.Seconds + ((double)aStartTime.Nanosec / 1000000000.0); 501cdf0e10cSrcweir double fEnd = (double)aEndTime.Seconds + ((double)aEndTime.Nanosec / 1000000000.0); 502cdf0e10cSrcweir return fEnd-fStart; 503cdf0e10cSrcweir } 504cdf0e10cSrcweir 505cdf0e10cSrcweir double getCallsPerSecOneway( const Reference < XCallMe > &rCall , 506cdf0e10cSrcweir int nLoops, 507cdf0e10cSrcweir int nToDo, 508cdf0e10cSrcweir double *pdAfterExecution 509cdf0e10cSrcweir ) 510cdf0e10cSrcweir { 511cdf0e10cSrcweir TimeValue aStartTime, aEndTime, aAfterExecution; 512cdf0e10cSrcweir osl_getSystemTime( &aStartTime ); 513cdf0e10cSrcweir for( sal_Int32 i = 0; i < nLoops; i ++ ) 514cdf0e10cSrcweir { 515cdf0e10cSrcweir // rCall->callOneway( OUString( RTL_CONSTASCII_USTRINGPARAM("Performance test string" )), 0 ); 516cdf0e10cSrcweir rCall->drawLine( 0 , 0 , 500 , 123 ); 517cdf0e10cSrcweir } 518cdf0e10cSrcweir osl_getSystemTime( &aEndTime ); 519cdf0e10cSrcweir 520cdf0e10cSrcweir rCall->call( OUString( RTL_CONSTASCII_USTRINGPARAM("Performance test string")) , nToDo ); 521cdf0e10cSrcweir osl_getSystemTime( &aAfterExecution ); 522cdf0e10cSrcweir 523cdf0e10cSrcweir double fStart = (double)aStartTime.Seconds + ((double)aStartTime.Nanosec / 1000000000.0); 524cdf0e10cSrcweir double fEnd = (double)aEndTime.Seconds + ((double)aEndTime.Nanosec / 1000000000.0); 525cdf0e10cSrcweir *pdAfterExecution = (double)aAfterExecution.Seconds + 526cdf0e10cSrcweir ((double)aAfterExecution.Nanosec / 1000000000.0) - fStart; 527cdf0e10cSrcweir return fEnd-fStart; 528cdf0e10cSrcweir } 529cdf0e10cSrcweir 530cdf0e10cSrcweir void testOnewayPerformanceOnTwoInterfaces( 531cdf0e10cSrcweir const Reference < XCallMe > &rRemote1, const Reference < XCallMe > &rRemote2 ) 532cdf0e10cSrcweir { 533cdf0e10cSrcweir printf( "Doing oneway performance test on two interfaces ...\n" ); 534cdf0e10cSrcweir const sal_Int32 nLoops = 10000; 535cdf0e10cSrcweir TimeValue aStartTime, aEndTime; 536cdf0e10cSrcweir osl_getSystemTime( &aStartTime ); 537cdf0e10cSrcweir for( sal_Int32 i = 0; i < nLoops ; i ++ ) 538cdf0e10cSrcweir { 539cdf0e10cSrcweir rRemote1->drawLine( 0 , 0 , 500 , 123 ); 540cdf0e10cSrcweir rRemote2->drawLine( 0 , 0 , 500 , 123 ); 541cdf0e10cSrcweir } 542cdf0e10cSrcweir osl_getSystemTime( &aEndTime ); 543cdf0e10cSrcweir double fStart = (double)aStartTime.Seconds + ((double)aStartTime.Nanosec / 1000000000.0); 544cdf0e10cSrcweir double fEnd = (double)aEndTime.Seconds + ((double)aEndTime.Nanosec / 1000000000.0); 545cdf0e10cSrcweir 546cdf0e10cSrcweir printf( "Overhead per Call [ms] %g\n" , ((fEnd-fStart)/((double)nLoops/1000 ))/2. ); 547cdf0e10cSrcweir } 548cdf0e10cSrcweir 549cdf0e10cSrcweir void testPerformance( const Reference < XCallMe > &rRemote, 550cdf0e10cSrcweir const Reference < XCallMe > &rLocal ) 551cdf0e10cSrcweir { 552cdf0e10cSrcweir OUString aTestString; 553cdf0e10cSrcweir 554cdf0e10cSrcweir sal_Int32 nDoSomething = 1; 555cdf0e10cSrcweir sal_Int32 nCalls = 80000; 556cdf0e10cSrcweir double dRemote, dLocal,dAfterExecution; 557cdf0e10cSrcweir 558cdf0e10cSrcweir printf( "performance test oneway...\n" ); 559cdf0e10cSrcweir dLocal = getCallsPerSecOneway( rLocal , nCalls , nDoSomething , &dAfterExecution); 560cdf0e10cSrcweir dRemote = getCallsPerSecOneway( rRemote , nCalls , nDoSomething , &dAfterExecution); 561cdf0e10cSrcweir printf( "Local=%g s," 562cdf0e10cSrcweir "Remote : %g s\n" , dLocal, dRemote ); 563cdf0e10cSrcweir if( dLocal > 0. ) 564cdf0e10cSrcweir { 565cdf0e10cSrcweir printf( "Remote/Local : %g\n", dRemote/dLocal ); 566cdf0e10cSrcweir } 567cdf0e10cSrcweir 568cdf0e10cSrcweir printf( "Overhead per Call [ms] %g\n" , (dRemote - dLocal)/((double)nCalls/1000 ) ); 569cdf0e10cSrcweir printf( "Overhead per Call after completion [ms] %g\n" , (dAfterExecution - dLocal)/((double)nCalls/1000 ) ); 570cdf0e10cSrcweir 571cdf0e10cSrcweir nCalls = 2000; 572cdf0e10cSrcweir 573cdf0e10cSrcweir printf( "Doing performance test ...\n" ); 574cdf0e10cSrcweir dRemote = getCallsPerSec( rRemote , nCalls , nDoSomething ); 575cdf0e10cSrcweir dLocal = getCallsPerSec( rLocal , nCalls , nDoSomething ); 576cdf0e10cSrcweir printf( "Local=%g s,\n" 577cdf0e10cSrcweir "Remote=%g s\n" , dLocal, dRemote ); 578cdf0e10cSrcweir if( dLocal > 0. ) 579cdf0e10cSrcweir { 580cdf0e10cSrcweir printf( "Remote/Local : %g\n", dRemote/dLocal ); 581cdf0e10cSrcweir } 582cdf0e10cSrcweir printf( "Overhead per synchron Call [ms] %g\n" , ((dRemote - dLocal)/((double)nCalls/1000 )) ); 583cdf0e10cSrcweir } 584cdf0e10cSrcweir 585cdf0e10cSrcweir void testException( const Reference < XCallMe > &r ) 586cdf0e10cSrcweir { 587cdf0e10cSrcweir try { 588cdf0e10cSrcweir r->call( OUString( RTL_CONSTASCII_USTRINGPARAM("dummy")) , -1 ); 589cdf0e10cSrcweir OSL_ASSERT( ! "no exception flown !" ); 590cdf0e10cSrcweir } 591cdf0e10cSrcweir catch( TestBridgeException & e ) 592cdf0e10cSrcweir { 593cdf0e10cSrcweir // Exception flew successfully ! 594cdf0e10cSrcweir } 595cdf0e10cSrcweir catch( Exception & e ) 596cdf0e10cSrcweir { 597cdf0e10cSrcweir OSL_ASSERT( ! "only base class of exception could be catched!" ); 598cdf0e10cSrcweir } 599cdf0e10cSrcweir catch(...) 600cdf0e10cSrcweir { 601cdf0e10cSrcweir OSL_ASSERT(! "wrong unknown exception !" ); 602cdf0e10cSrcweir } 603cdf0e10cSrcweir } 604cdf0e10cSrcweir 605cdf0e10cSrcweir void testSequenceOfCalls( const Reference< XCallMe > & rRCallMe ) 606cdf0e10cSrcweir { 607cdf0e10cSrcweir printf( "Testing sequence of calls\n" ); 608cdf0e10cSrcweir for( sal_Int32 i = 0 ; i < 800 ; i ++ ) 609cdf0e10cSrcweir { 610cdf0e10cSrcweir rRCallMe->callOneway( OUString( RTL_CONSTASCII_USTRINGPARAM("hifuj" )), 0 ); 611cdf0e10cSrcweir } 612cdf0e10cSrcweir } 613cdf0e10cSrcweir 614cdf0e10cSrcweir void testAllTypes( const Reference < XCallMe > & rRCallMe ) 615cdf0e10cSrcweir { 616cdf0e10cSrcweir printf( "Testing all types\n" ); 617cdf0e10cSrcweir 618cdf0e10cSrcweir for( sal_Int32 i = 0; i < 32 ; i ++ ) 619cdf0e10cSrcweir { 620cdf0e10cSrcweir 621cdf0e10cSrcweir TestTypes types; 622cdf0e10cSrcweir types.Bool = sal_True; 623cdf0e10cSrcweir types.Char = L'i'; 624cdf0e10cSrcweir types.Byte = -12; 625cdf0e10cSrcweir types.Short = -32000; 626cdf0e10cSrcweir types.UShort = (sal_uInt16 ) (1 << i); 627cdf0e10cSrcweir types.Long = -123; 628cdf0e10cSrcweir types.ULong = 1 << i; 629cdf0e10cSrcweir types.Hyper = 50; 630cdf0e10cSrcweir types.UHyper = 1 << i*2; 631cdf0e10cSrcweir types.Float = (float)123.239; 632cdf0e10cSrcweir types.Double = 1279.12490012; 633cdf0e10cSrcweir types.String = OUString( RTL_CONSTASCII_USTRINGPARAM("abcdefghijklmnopqrstuvwxyz")); 634cdf0e10cSrcweir types.Interface = Reference< XInterface >( rRCallMe , UNO_QUERY); 635cdf0e10cSrcweir types.Any <<= types.Double; 636cdf0e10cSrcweir 637cdf0e10cSrcweir TestTypes retTypes = rRCallMe->transport( types ); 638cdf0e10cSrcweir 639cdf0e10cSrcweir OSL_ASSERT( ( types.Bool && retTypes.Bool ) || ( ! types.Bool && ! retTypes.Bool ) ); 640cdf0e10cSrcweir OSL_ASSERT( types.Char == retTypes.Char ); 641cdf0e10cSrcweir OSL_ASSERT( types.Byte == retTypes.Byte ); 642cdf0e10cSrcweir OSL_ASSERT( types.Short == retTypes.Short ); 643cdf0e10cSrcweir OSL_ASSERT( types.UShort == retTypes.UShort ); 644cdf0e10cSrcweir OSL_ASSERT( types.Long == retTypes.Long ); 645cdf0e10cSrcweir OSL_ASSERT( types.ULong == retTypes.ULong ); 646cdf0e10cSrcweir OSL_ASSERT( types.Hyper == retTypes.Hyper ); 647cdf0e10cSrcweir OSL_ASSERT( types.UHyper == retTypes.UHyper ); 648cdf0e10cSrcweir OSL_ASSERT( types.Float == retTypes.Float ); 649cdf0e10cSrcweir OSL_ASSERT( types.Double == retTypes.Double ); 650cdf0e10cSrcweir OSL_ASSERT( types.String == retTypes.String ); 651cdf0e10cSrcweir OSL_ASSERT( types.Interface == retTypes.Interface ); 652cdf0e10cSrcweir OSL_ASSERT( types.Any == retTypes.Any ); 653cdf0e10cSrcweir } 654cdf0e10cSrcweir 655cdf0e10cSrcweir } 656cdf0e10cSrcweir 657cdf0e10cSrcweir void testRemote( const Reference< XInterface > &rRemote ) 658cdf0e10cSrcweir { 659cdf0e10cSrcweir char a; 660cdf0e10cSrcweir getCppuType( (sal_Int8*)&a ); 661cdf0e10cSrcweir 662cdf0e10cSrcweir Reference< XTestFactory > rRFact( rRemote , UNO_QUERY ); 663cdf0e10cSrcweir if( ! rRFact.is() ) 664cdf0e10cSrcweir { 665cdf0e10cSrcweir printf( "remote object doesn't support XTestFactory\n" ); 666cdf0e10cSrcweir return; 667cdf0e10cSrcweir } 668cdf0e10cSrcweir OSL_ASSERT( rRFact.is() ); 669cdf0e10cSrcweir Reference< XCallMe > rLCallMe = (XCallMe * ) new OCallMe(); 670cdf0e10cSrcweir Reference< XCallMe > rRCallMe = rRFact->createCallMe(); 671cdf0e10cSrcweir 672cdf0e10cSrcweir testAllTypes( rLCallMe ); 673cdf0e10cSrcweir testAllTypes( rRCallMe ); 674cdf0e10cSrcweir 675cdf0e10cSrcweir printf( "Testing exception local ...\n" ); 676cdf0e10cSrcweir testException( rLCallMe ); 677cdf0e10cSrcweir printf( "Testing exception remote ...\n" ); 678cdf0e10cSrcweir testException( rRCallMe ); 679cdf0e10cSrcweir 680cdf0e10cSrcweir //-------------------- 681cdf0e10cSrcweir // Test attributes 682cdf0e10cSrcweir //---------------------- 683cdf0e10cSrcweir OUString ow = OUString::createFromAscii( "dum didel dum dideldei" ); 684cdf0e10cSrcweir rLCallMe->setsAttribute( ow ); 685cdf0e10cSrcweir OSL_ASSERT( rLCallMe->getsAttribute() == ow ); 686cdf0e10cSrcweir 687cdf0e10cSrcweir rRCallMe->setsAttribute( ow ); 688cdf0e10cSrcweir OSL_ASSERT( rRCallMe->getsAttribute() == ow ); 689cdf0e10cSrcweir 690cdf0e10cSrcweir //------------------- 691cdf0e10cSrcweir // Performance test 692cdf0e10cSrcweir //------------------- 693cdf0e10cSrcweir testPerformance( rRCallMe , rLCallMe ); 694cdf0e10cSrcweir testOnewayPerformanceOnTwoInterfaces( rRFact->createCallMe(), rRCallMe ); 695cdf0e10cSrcweir 696cdf0e10cSrcweir //---------------- 697cdf0e10cSrcweir // Test sequence 698cdf0e10cSrcweir //---------------- 699cdf0e10cSrcweir testSequenceOfCalls( rRCallMe ); 700cdf0e10cSrcweir 701cdf0e10cSrcweir 702cdf0e10cSrcweir // test triple to check if transporting the same interface multiple 703cdf0e10cSrcweir // times causes any problems 704cdf0e10cSrcweir Reference< XInterfaceTest > rRTest = rRFact->createInterfaceTest(); 705cdf0e10cSrcweir Reference< XInterfaceTest > rRTest2 = rRFact->createInterfaceTest(); 706cdf0e10cSrcweir Reference< XInterfaceTest > rRTest3 = rRFact->createInterfaceTest(); 707cdf0e10cSrcweir 708cdf0e10cSrcweir rRTest->setIn( rRCallMe ); 709cdf0e10cSrcweir rRTest2->setIn( rRCallMe ); 710cdf0e10cSrcweir rRTest3->setIn( rRCallMe ); 711cdf0e10cSrcweir 712cdf0e10cSrcweir OSL_ASSERT( rRTest->get() == rRCallMe ); 713cdf0e10cSrcweir OSL_ASSERT( rRTest2->get() == rRCallMe ); 714cdf0e10cSrcweir OSL_ASSERT( rRTest3->get() == rRCallMe ); 715cdf0e10cSrcweir 716cdf0e10cSrcweir rRTest->setIn( rLCallMe ); 717cdf0e10cSrcweir rRTest2->setIn( rLCallMe ); 718cdf0e10cSrcweir rRTest3->setIn( rLCallMe ); 719cdf0e10cSrcweir 720cdf0e10cSrcweir { 721cdf0e10cSrcweir Reference< XCallMe > rLCallMe1 = (XCallMe * ) new OCallMe(); 722cdf0e10cSrcweir Reference< XCallMe > rLCallMe2 = (XCallMe * ) new OCallMe(); 723cdf0e10cSrcweir Reference< XCallMe > rLCallMe3 = (XCallMe * ) new OCallMe(); 724cdf0e10cSrcweir rRTest->setIn( rLCallMe1 ); 725cdf0e10cSrcweir rRTest2->setIn( rLCallMe2 ); 726cdf0e10cSrcweir rRTest3->setIn( rLCallMe3 ); 727cdf0e10cSrcweir OSL_ASSERT( rRTest->get() == rLCallMe1 ); 728cdf0e10cSrcweir OSL_ASSERT( rRTest2->get() == rLCallMe2 ); 729cdf0e10cSrcweir OSL_ASSERT( rRTest3->get() == rLCallMe3 ); 730cdf0e10cSrcweir 731cdf0e10cSrcweir rRTest->setIn( rLCallMe ); 732cdf0e10cSrcweir rRTest2->setIn( rLCallMe ); 733cdf0e10cSrcweir rRTest3->setIn( rLCallMe ); 734cdf0e10cSrcweir 735cdf0e10cSrcweir OSL_ASSERT( rRTest->get() == rLCallMe ); 736cdf0e10cSrcweir OSL_ASSERT( rRTest2->get() == rLCallMe ); 737cdf0e10cSrcweir OSL_ASSERT( rRTest3->get() == rLCallMe ); 738cdf0e10cSrcweir } 739cdf0e10cSrcweir 740cdf0e10cSrcweir Reference < XCallMe > r = rRCallMe; 741cdf0e10cSrcweir rRTest->setInOut( r ); 742cdf0e10cSrcweir OSL_ASSERT( r == rLCallMe ); 743cdf0e10cSrcweir OSL_ASSERT( ! ( r == rRCallMe ) ); 744cdf0e10cSrcweir 745cdf0e10cSrcweir // test empty references 746cdf0e10cSrcweir rRTest->setIn( Reference < XCallMe > () ); 747cdf0e10cSrcweir 748cdf0e10cSrcweir //-------------------------------- 749cdf0e10cSrcweir // test thread deadlocking 750cdf0e10cSrcweir //-------------------------------- 751cdf0e10cSrcweir rLCallMe->callAgain( rRCallMe, 20 ); 752cdf0e10cSrcweir 753cdf0e10cSrcweir } 754cdf0e10cSrcweir 755cdf0e10cSrcweir 756cdf0e10cSrcweir 757cdf0e10cSrcweir 758cdf0e10cSrcweir 759cdf0e10cSrcweir 760cdf0e10cSrcweir Reference <XInterface > createComponent( const ::rtl::OUString &sService , 761cdf0e10cSrcweir const ::rtl::OUString &sDllName, 762cdf0e10cSrcweir const Reference < XMultiServiceFactory > &rSMgr ) 763cdf0e10cSrcweir { 764cdf0e10cSrcweir Reference< XInterface > rInterface; 765cdf0e10cSrcweir rInterface = rSMgr->createInstance( sService ); 766cdf0e10cSrcweir 767cdf0e10cSrcweir if( ! rInterface.is() ) 768cdf0e10cSrcweir { 769cdf0e10cSrcweir // erst registrieren 770cdf0e10cSrcweir Reference < XImplementationRegistration > rReg ( 771cdf0e10cSrcweir rSMgr->createInstance( 772cdf0e10cSrcweir OUString::createFromAscii( "com.sun.star.registry.ImplementationRegistration" )), 773cdf0e10cSrcweir UNO_QUERY ); 774cdf0e10cSrcweir 775cdf0e10cSrcweir OSL_ASSERT( rReg.is() ); 776cdf0e10cSrcweir OUString aDllName = sDllName; 777cdf0e10cSrcweir 778cdf0e10cSrcweir try 779cdf0e10cSrcweir { 780cdf0e10cSrcweir rReg->registerImplementation( 781cdf0e10cSrcweir OUString::createFromAscii( "com.sun.star.loader.SharedLibrary" ), 782cdf0e10cSrcweir aDllName, 783cdf0e10cSrcweir Reference< XSimpleRegistry > () ); 784cdf0e10cSrcweir rInterface = rSMgr->createInstance( sService ); 785cdf0e10cSrcweir } 786cdf0e10cSrcweir catch( Exception & ) 787cdf0e10cSrcweir { 788cdf0e10cSrcweir printf( "couldn't register dll %s\n" , 789cdf0e10cSrcweir OUStringToOString( aDllName, RTL_TEXTENCODING_ASCII_US ).getStr() ); 790cdf0e10cSrcweir } 791cdf0e10cSrcweir } 792cdf0e10cSrcweir return rInterface; 793cdf0e10cSrcweir } 794cdf0e10cSrcweir 795cdf0e10cSrcweir 796