xref: /AOO41X/main/testtools/source/bridgetest/bridgetest.cxx (revision cdf0e10c4e3984b49a9502b011690b615761d4a3)
1*cdf0e10cSrcweir /*************************************************************************
2*cdf0e10cSrcweir  *
3*cdf0e10cSrcweir  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4*cdf0e10cSrcweir  *
5*cdf0e10cSrcweir  * Copyright 2000, 2010 Oracle and/or its affiliates.
6*cdf0e10cSrcweir  *
7*cdf0e10cSrcweir  * OpenOffice.org - a multi-platform office productivity suite
8*cdf0e10cSrcweir  *
9*cdf0e10cSrcweir  * This file is part of OpenOffice.org.
10*cdf0e10cSrcweir  *
11*cdf0e10cSrcweir  * OpenOffice.org is free software: you can redistribute it and/or modify
12*cdf0e10cSrcweir  * it under the terms of the GNU Lesser General Public License version 3
13*cdf0e10cSrcweir  * only, as published by the Free Software Foundation.
14*cdf0e10cSrcweir  *
15*cdf0e10cSrcweir  * OpenOffice.org is distributed in the hope that it will be useful,
16*cdf0e10cSrcweir  * but WITHOUT ANY WARRANTY; without even the implied warranty of
17*cdf0e10cSrcweir  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
18*cdf0e10cSrcweir  * GNU Lesser General Public License version 3 for more details
19*cdf0e10cSrcweir  * (a copy is included in the LICENSE file that accompanied this code).
20*cdf0e10cSrcweir  *
21*cdf0e10cSrcweir  * You should have received a copy of the GNU Lesser General Public License
22*cdf0e10cSrcweir  * version 3 along with OpenOffice.org.  If not, see
23*cdf0e10cSrcweir  * <http://www.openoffice.org/license.html>
24*cdf0e10cSrcweir  * for a copy of the LGPLv3 License.
25*cdf0e10cSrcweir  *
26*cdf0e10cSrcweir  ************************************************************************/
27*cdf0e10cSrcweir 
28*cdf0e10cSrcweir // MARKER(update_precomp.py): autogen include statement, do not remove
29*cdf0e10cSrcweir #include "precompiled_testtools.hxx"
30*cdf0e10cSrcweir 
31*cdf0e10cSrcweir #include <stdio.h>
32*cdf0e10cSrcweir #include <string.h>
33*cdf0e10cSrcweir #include <osl/diagnose.h>
34*cdf0e10cSrcweir #include "osl/diagnose.hxx"
35*cdf0e10cSrcweir #include <osl/time.h>
36*cdf0e10cSrcweir #include <sal/types.h>
37*cdf0e10cSrcweir #include "typelib/typedescription.hxx"
38*cdf0e10cSrcweir #include <uno/dispatcher.hxx>
39*cdf0e10cSrcweir #include "uno/mapping.hxx"
40*cdf0e10cSrcweir #include <uno/data.h>
41*cdf0e10cSrcweir #include "uno/environment.hxx"
42*cdf0e10cSrcweir 
43*cdf0e10cSrcweir #include <cppuhelper/factory.hxx>
44*cdf0e10cSrcweir #include <cppuhelper/implbase2.hxx>
45*cdf0e10cSrcweir #include <cppuhelper/implbase1.hxx>
46*cdf0e10cSrcweir 
47*cdf0e10cSrcweir #include <com/sun/star/lang/XServiceInfo.hpp>
48*cdf0e10cSrcweir #include <com/sun/star/lang/XComponent.hpp>
49*cdf0e10cSrcweir #include <com/sun/star/lang/XMain.hpp>
50*cdf0e10cSrcweir #include <com/sun/star/bridge/UnoUrlResolver.hpp>
51*cdf0e10cSrcweir #include <com/sun/star/bridge/XUnoUrlResolver.hpp>
52*cdf0e10cSrcweir #include "com/sun/star/uno/RuntimeException.hpp"
53*cdf0e10cSrcweir #include "com/sun/star/uno/Type.hxx"
54*cdf0e10cSrcweir 
55*cdf0e10cSrcweir #include "test/testtools/bridgetest/BadConstructorArguments.hpp"
56*cdf0e10cSrcweir #include "test/testtools/bridgetest/TestPolyStruct.hpp"
57*cdf0e10cSrcweir #include "test/testtools/bridgetest/XBridgeTest.hpp"
58*cdf0e10cSrcweir #include "test/testtools/bridgetest/XBridgeTest2.hpp"
59*cdf0e10cSrcweir #include "test/testtools/bridgetest/XMulti.hpp"
60*cdf0e10cSrcweir 
61*cdf0e10cSrcweir #include "currentcontextchecker.hxx"
62*cdf0e10cSrcweir #include "multi.hxx"
63*cdf0e10cSrcweir 
64*cdf0e10cSrcweir using namespace rtl;
65*cdf0e10cSrcweir using namespace osl;
66*cdf0e10cSrcweir using namespace cppu;
67*cdf0e10cSrcweir using namespace com::sun::star::uno;
68*cdf0e10cSrcweir using namespace com::sun::star::lang;
69*cdf0e10cSrcweir using namespace com::sun::star::registry;
70*cdf0e10cSrcweir using namespace com::sun::star::bridge;
71*cdf0e10cSrcweir using namespace test::testtools::bridgetest;
72*cdf0e10cSrcweir 
73*cdf0e10cSrcweir #define SERVICENAME		"com.sun.star.test.bridge.BridgeTest"
74*cdf0e10cSrcweir #define IMPLNAME		"com.sun.star.comp.bridge.BridgeTest"
75*cdf0e10cSrcweir 
76*cdf0e10cSrcweir #define OUSTR(x) ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM(x) )
77*cdf0e10cSrcweir #define STRING_TEST_CONSTANT "\" paco\' chorizo\\\' \"\'"
78*cdf0e10cSrcweir 
79*cdf0e10cSrcweir namespace bridge_test
80*cdf0e10cSrcweir {
81*cdf0e10cSrcweir template< class T>
82*cdf0e10cSrcweir Sequence<T> cloneSequence(const Sequence<T>& val);
83*cdf0e10cSrcweir 
84*cdf0e10cSrcweir //--------------------------------------------------------------------------------------------------
85*cdf0e10cSrcweir inline static Sequence< OUString > getSupportedServiceNames()
86*cdf0e10cSrcweir {
87*cdf0e10cSrcweir 	OUString aName( RTL_CONSTASCII_USTRINGPARAM(SERVICENAME) );
88*cdf0e10cSrcweir 	return Sequence< OUString >( &aName, 1 );
89*cdf0e10cSrcweir }
90*cdf0e10cSrcweir 
91*cdf0e10cSrcweir static bool check( bool b , char const * message )
92*cdf0e10cSrcweir {
93*cdf0e10cSrcweir     if ( ! b )
94*cdf0e10cSrcweir         fprintf( stderr, "%s failed\n" , message );
95*cdf0e10cSrcweir     return b;
96*cdf0e10cSrcweir }
97*cdf0e10cSrcweir 
98*cdf0e10cSrcweir namespace {
99*cdf0e10cSrcweir 
100*cdf0e10cSrcweir bool checkEmpty(rtl::OUString const & string, char const * message) {
101*cdf0e10cSrcweir     bool ok = string.getLength() == 0;
102*cdf0e10cSrcweir     if (!ok) {
103*cdf0e10cSrcweir         fprintf(
104*cdf0e10cSrcweir             stderr, "%s failed: %s\n", message,
105*cdf0e10cSrcweir             rtl::OUStringToOString(string, RTL_TEXTENCODING_UTF8).getStr());
106*cdf0e10cSrcweir     }
107*cdf0e10cSrcweir     return ok;
108*cdf0e10cSrcweir }
109*cdf0e10cSrcweir 
110*cdf0e10cSrcweir }
111*cdf0e10cSrcweir 
112*cdf0e10cSrcweir //==================================================================================================
113*cdf0e10cSrcweir class TestBridgeImpl : public osl::DebugBase<TestBridgeImpl>,
114*cdf0e10cSrcweir                        public WeakImplHelper2< XMain, XServiceInfo >
115*cdf0e10cSrcweir {
116*cdf0e10cSrcweir 	Reference< XComponentContext > m_xContext;
117*cdf0e10cSrcweir 
118*cdf0e10cSrcweir public:
119*cdf0e10cSrcweir 	TestBridgeImpl( const Reference< XComponentContext > & xContext )
120*cdf0e10cSrcweir 		: m_xContext( xContext )
121*cdf0e10cSrcweir 		{}
122*cdf0e10cSrcweir     virtual ~TestBridgeImpl()
123*cdf0e10cSrcweir     {
124*cdf0e10cSrcweir     }
125*cdf0e10cSrcweir 
126*cdf0e10cSrcweir 	// XServiceInfo
127*cdf0e10cSrcweir 	virtual OUString SAL_CALL getImplementationName() throw (RuntimeException);
128*cdf0e10cSrcweir 	virtual sal_Bool SAL_CALL supportsService( const OUString & rServiceName ) throw (RuntimeException);
129*cdf0e10cSrcweir 	virtual Sequence< OUString > SAL_CALL getSupportedServiceNames() throw (RuntimeException);
130*cdf0e10cSrcweir 
131*cdf0e10cSrcweir 	// XMain
132*cdf0e10cSrcweir     virtual sal_Int32 SAL_CALL run( const Sequence< OUString > & rArgs ) throw (RuntimeException);
133*cdf0e10cSrcweir };
134*cdf0e10cSrcweir 
135*cdf0e10cSrcweir //==================================================================================================
136*cdf0e10cSrcweir static sal_Bool equals( const TestElement & rData1, const TestElement & rData2 )
137*cdf0e10cSrcweir {
138*cdf0e10cSrcweir 	check( rData1.Bool == rData2.Bool, "### bool does not match!" );
139*cdf0e10cSrcweir 	check( rData1.Char == rData2.Char, "### char does not match!" );
140*cdf0e10cSrcweir 	check( rData1.Byte == rData2.Byte, "### byte does not match!" );
141*cdf0e10cSrcweir 	check( rData1.Short == rData2.Short, "### short does not match!" );
142*cdf0e10cSrcweir 	check( rData1.UShort == rData2.UShort, "### unsigned short does not match!" );
143*cdf0e10cSrcweir 	check( rData1.Long == rData2.Long, "### long does not match!" );
144*cdf0e10cSrcweir 	check( rData1.ULong == rData2.ULong, "### unsigned long does not match!" );
145*cdf0e10cSrcweir 	check( rData1.Hyper == rData2.Hyper, "### hyper does not match!" );
146*cdf0e10cSrcweir 	check( rData1.UHyper == rData2.UHyper, "### unsigned hyper does not match!" );
147*cdf0e10cSrcweir 	check( rData1.Float == rData2.Float, "### float does not match!" );
148*cdf0e10cSrcweir 	check( rData1.Double == rData2.Double, "### double does not match!" );
149*cdf0e10cSrcweir 	check( rData1.Enum == rData2.Enum, "### enum does not match!" );
150*cdf0e10cSrcweir 	check( rData1.String == rData2.String, "### string does not match!" );
151*cdf0e10cSrcweir 	check( rData1.Interface == rData2.Interface, "### interface does not match!" );
152*cdf0e10cSrcweir 	check( rData1.Any == rData2.Any, "### any does not match!" );
153*cdf0e10cSrcweir 
154*cdf0e10cSrcweir 	return (rData1.Bool == rData2.Bool &&
155*cdf0e10cSrcweir 			rData1.Char == rData2.Char &&
156*cdf0e10cSrcweir 			rData1.Byte == rData2.Byte &&
157*cdf0e10cSrcweir 			rData1.Short == rData2.Short &&
158*cdf0e10cSrcweir 			rData1.UShort == rData2.UShort &&
159*cdf0e10cSrcweir 			rData1.Long == rData2.Long &&
160*cdf0e10cSrcweir 			rData1.ULong == rData2.ULong &&
161*cdf0e10cSrcweir 			rData1.Hyper == rData2.Hyper &&
162*cdf0e10cSrcweir 			rData1.UHyper == rData2.UHyper &&
163*cdf0e10cSrcweir 			rData1.Float == rData2.Float &&
164*cdf0e10cSrcweir 			rData1.Double == rData2.Double &&
165*cdf0e10cSrcweir 			rData1.Enum == rData2.Enum &&
166*cdf0e10cSrcweir 			rData1.String == rData2.String &&
167*cdf0e10cSrcweir 			rData1.Interface == rData2.Interface &&
168*cdf0e10cSrcweir 			rData1.Any == rData2.Any);
169*cdf0e10cSrcweir }
170*cdf0e10cSrcweir //==================================================================================================
171*cdf0e10cSrcweir static sal_Bool equals( const TestData & rData1, const TestData & rData2 )
172*cdf0e10cSrcweir {
173*cdf0e10cSrcweir 	sal_Int32 nLen;
174*cdf0e10cSrcweir 
175*cdf0e10cSrcweir 	if ((rData1.Sequence == rData2.Sequence) &&
176*cdf0e10cSrcweir 		equals( (const TestElement &)rData1, (const TestElement &)rData2 ) &&
177*cdf0e10cSrcweir 		(nLen = rData1.Sequence.getLength()) == rData2.Sequence.getLength())
178*cdf0e10cSrcweir 	{
179*cdf0e10cSrcweir 		// once again by hand sequence ==
180*cdf0e10cSrcweir 		const TestElement * pElements1 = rData1.Sequence.getConstArray();
181*cdf0e10cSrcweir 		const TestElement * pElements2 = rData2.Sequence.getConstArray();
182*cdf0e10cSrcweir 		for ( ; nLen--; )
183*cdf0e10cSrcweir 		{
184*cdf0e10cSrcweir 			if (! equals( pElements1[nLen], pElements2[nLen] ))
185*cdf0e10cSrcweir 			{
186*cdf0e10cSrcweir 				check( sal_False, "### sequence element did not match!" );
187*cdf0e10cSrcweir 				return sal_False;
188*cdf0e10cSrcweir 			}
189*cdf0e10cSrcweir 		}
190*cdf0e10cSrcweir 		return sal_True;
191*cdf0e10cSrcweir 	}
192*cdf0e10cSrcweir 	return sal_False;
193*cdf0e10cSrcweir }
194*cdf0e10cSrcweir //==================================================================================================
195*cdf0e10cSrcweir static void assign( TestElement & rData,
196*cdf0e10cSrcweir 					sal_Bool bBool, sal_Unicode cChar, sal_Int8 nByte,
197*cdf0e10cSrcweir 					sal_Int16 nShort, sal_uInt16 nUShort,
198*cdf0e10cSrcweir 					sal_Int32 nLong, sal_uInt32 nULong,
199*cdf0e10cSrcweir 					sal_Int64 nHyper, sal_uInt64 nUHyper,
200*cdf0e10cSrcweir 					float fFloat, double fDouble,
201*cdf0e10cSrcweir 					TestEnum eEnum, const ::rtl::OUString& rStr,
202*cdf0e10cSrcweir 					const ::com::sun::star::uno::Reference< ::com::sun::star::uno::XInterface >& xTest,
203*cdf0e10cSrcweir 					const ::com::sun::star::uno::Any& rAny )
204*cdf0e10cSrcweir {
205*cdf0e10cSrcweir 	rData.Bool = bBool;
206*cdf0e10cSrcweir 	rData.Char = cChar;
207*cdf0e10cSrcweir 	rData.Byte = nByte;
208*cdf0e10cSrcweir 	rData.Short = nShort;
209*cdf0e10cSrcweir 	rData.UShort = nUShort;
210*cdf0e10cSrcweir 	rData.Long = nLong;
211*cdf0e10cSrcweir 	rData.ULong = nULong;
212*cdf0e10cSrcweir 	rData.Hyper = nHyper;
213*cdf0e10cSrcweir 	rData.UHyper = nUHyper;
214*cdf0e10cSrcweir 	rData.Float = fFloat;
215*cdf0e10cSrcweir 	rData.Double = fDouble;
216*cdf0e10cSrcweir 	rData.Enum = eEnum;
217*cdf0e10cSrcweir 	rData.String = rStr;
218*cdf0e10cSrcweir 	rData.Interface = xTest;
219*cdf0e10cSrcweir 	rData.Any = rAny;
220*cdf0e10cSrcweir }
221*cdf0e10cSrcweir 
222*cdf0e10cSrcweir namespace {
223*cdf0e10cSrcweir 
224*cdf0e10cSrcweir template < typename T >
225*cdf0e10cSrcweir bool testAny(
226*cdf0e10cSrcweir     T const & value, Reference< XBridgeTest > const & xLBT,
227*cdf0e10cSrcweir     char const * typeName = 0)
228*cdf0e10cSrcweir {
229*cdf0e10cSrcweir 	Any any;
230*cdf0e10cSrcweir 	any <<=  value;
231*cdf0e10cSrcweir 	Any any2 = xLBT->transportAny(any);
232*cdf0e10cSrcweir     bool success = true;
233*cdf0e10cSrcweir 	if (any != any2) {
234*cdf0e10cSrcweir         fprintf(
235*cdf0e10cSrcweir             stderr, "any is different after roundtrip: in %s, out %s\n",
236*cdf0e10cSrcweir             OUStringToOString(
237*cdf0e10cSrcweir                 any.getValueType().getTypeName(),
238*cdf0e10cSrcweir                 RTL_TEXTENCODING_ASCII_US).getStr(),
239*cdf0e10cSrcweir             OUStringToOString(
240*cdf0e10cSrcweir                 any2.getValueType().getTypeName(),
241*cdf0e10cSrcweir                 RTL_TEXTENCODING_ASCII_US).getStr());
242*cdf0e10cSrcweir         success = false;
243*cdf0e10cSrcweir     }
244*cdf0e10cSrcweir     if (typeName != 0
245*cdf0e10cSrcweir         && !any2.getValueType().getTypeName().equalsAscii(typeName))
246*cdf0e10cSrcweir     {
247*cdf0e10cSrcweir         fprintf(
248*cdf0e10cSrcweir             stderr, "any has wrong type after roundtrip: %s instead of %s\n",
249*cdf0e10cSrcweir             OUStringToOString(
250*cdf0e10cSrcweir                 any2.getValueType().getTypeName(),
251*cdf0e10cSrcweir                 RTL_TEXTENCODING_ASCII_US).getStr(),
252*cdf0e10cSrcweir             typeName);
253*cdf0e10cSrcweir         success = false;
254*cdf0e10cSrcweir     }
255*cdf0e10cSrcweir 	return success;
256*cdf0e10cSrcweir }
257*cdf0e10cSrcweir 
258*cdf0e10cSrcweir }
259*cdf0e10cSrcweir 
260*cdf0e10cSrcweir static sal_Bool performAnyTest( const Reference< XBridgeTest > &xLBT, const TestData &data)
261*cdf0e10cSrcweir {
262*cdf0e10cSrcweir 	bool bReturn = true;
263*cdf0e10cSrcweir 	bReturn = testAny( data.Byte ,xLBT ) && bReturn;
264*cdf0e10cSrcweir 	bReturn = testAny( data.Short,xLBT ) && bReturn;
265*cdf0e10cSrcweir 	bReturn = testAny( data.UShort,xLBT ) && bReturn;
266*cdf0e10cSrcweir 	bReturn = testAny( data.Long,xLBT ) && bReturn;
267*cdf0e10cSrcweir 	bReturn = testAny( data.ULong,xLBT ) && bReturn;
268*cdf0e10cSrcweir 	bReturn = testAny( data.Hyper,xLBT ) && bReturn;
269*cdf0e10cSrcweir 	bReturn = testAny( data.UHyper,xLBT ) && bReturn;
270*cdf0e10cSrcweir 	bReturn = testAny( data.Float,xLBT ) && bReturn;
271*cdf0e10cSrcweir 	bReturn = testAny( data.Double,xLBT ) && bReturn;
272*cdf0e10cSrcweir 	bReturn = testAny( data.Enum,xLBT ) && bReturn;
273*cdf0e10cSrcweir 	bReturn = testAny( data.String,xLBT ) && bReturn;
274*cdf0e10cSrcweir 	bReturn = testAny( data.Interface,xLBT ) && bReturn;
275*cdf0e10cSrcweir 	bReturn = testAny( data, xLBT ) && bReturn;
276*cdf0e10cSrcweir     bReturn &= testAny(
277*cdf0e10cSrcweir         TestPolyStruct< sal_Unicode >(' '), xLBT,
278*cdf0e10cSrcweir         "test.testtools.bridgetest.TestPolyStruct<char>");
279*cdf0e10cSrcweir 
280*cdf0e10cSrcweir 	Any a;
281*cdf0e10cSrcweir 	{
282*cdf0e10cSrcweir 		a.setValue( &(data.Bool) , getCppuBooleanType() );
283*cdf0e10cSrcweir 		Any a2 = xLBT->transportAny( a );
284*cdf0e10cSrcweir 		OSL_ASSERT( a2 == a );
285*cdf0e10cSrcweir 	}
286*cdf0e10cSrcweir 
287*cdf0e10cSrcweir 	{
288*cdf0e10cSrcweir 		a.setValue( &(data.Char) , getCppuCharType() );
289*cdf0e10cSrcweir 		Any a2 = xLBT->transportAny( a );
290*cdf0e10cSrcweir 		OSL_ASSERT( a2 == a );
291*cdf0e10cSrcweir 	}
292*cdf0e10cSrcweir 
293*cdf0e10cSrcweir 	return bReturn;
294*cdf0e10cSrcweir }
295*cdf0e10cSrcweir 
296*cdf0e10cSrcweir //_______________________________________________________________________________________
297*cdf0e10cSrcweir static sal_Bool performSequenceOfCallTest( const Reference < XBridgeTest > &xLBT )
298*cdf0e10cSrcweir {
299*cdf0e10cSrcweir 	sal_Int32 i,nRounds;
300*cdf0e10cSrcweir 	sal_Int32 nGlobalIndex = 0;
301*cdf0e10cSrcweir 	const sal_Int32 nWaitTimeSpanMUSec = 10000;
302*cdf0e10cSrcweir 	for( nRounds = 0 ; nRounds < 10 ; nRounds ++ )
303*cdf0e10cSrcweir 	{
304*cdf0e10cSrcweir 		for( i = 0 ; i < nRounds ; i ++ )
305*cdf0e10cSrcweir 		{
306*cdf0e10cSrcweir 			// fire oneways
307*cdf0e10cSrcweir 			xLBT->callOneway( nGlobalIndex , nWaitTimeSpanMUSec );
308*cdf0e10cSrcweir 			nGlobalIndex ++;
309*cdf0e10cSrcweir 		}
310*cdf0e10cSrcweir 
311*cdf0e10cSrcweir 		// call synchron
312*cdf0e10cSrcweir 		xLBT->call( nGlobalIndex , nWaitTimeSpanMUSec );
313*cdf0e10cSrcweir 		nGlobalIndex ++;
314*cdf0e10cSrcweir 	}
315*cdf0e10cSrcweir 
316*cdf0e10cSrcweir 	return xLBT->sequenceOfCallTestPassed();
317*cdf0e10cSrcweir }
318*cdf0e10cSrcweir 
319*cdf0e10cSrcweir class ORecursiveCall : public WeakImplHelper1< XRecursiveCall >
320*cdf0e10cSrcweir {
321*cdf0e10cSrcweir private:
322*cdf0e10cSrcweir 	Mutex m_mutex;
323*cdf0e10cSrcweir 
324*cdf0e10cSrcweir public:
325*cdf0e10cSrcweir 	void SAL_CALL callRecursivly(
326*cdf0e10cSrcweir 		const ::com::sun::star::uno::Reference< XRecursiveCall >& xCall,
327*cdf0e10cSrcweir 		sal_Int32 nToCall )
328*cdf0e10cSrcweir 		throw(::com::sun::star::uno::RuntimeException)
329*cdf0e10cSrcweir 		{
330*cdf0e10cSrcweir 			MutexGuard guard( m_mutex );
331*cdf0e10cSrcweir 			if( nToCall )
332*cdf0e10cSrcweir 			{
333*cdf0e10cSrcweir 				nToCall --;
334*cdf0e10cSrcweir 				xCall->callRecursivly( this , nToCall );
335*cdf0e10cSrcweir 			}
336*cdf0e10cSrcweir 
337*cdf0e10cSrcweir 		}
338*cdf0e10cSrcweir };
339*cdf0e10cSrcweir 
340*cdf0e10cSrcweir 
341*cdf0e10cSrcweir //_______________________________________________________________________________________
342*cdf0e10cSrcweir static sal_Bool performRecursiveCallTest( const Reference < XBridgeTest > & xLBT )
343*cdf0e10cSrcweir {
344*cdf0e10cSrcweir 	xLBT->startRecursiveCall( new ORecursiveCall , 50 );
345*cdf0e10cSrcweir 	// on failure, the test would lock up or crash
346*cdf0e10cSrcweir 	return sal_True;
347*cdf0e10cSrcweir }
348*cdf0e10cSrcweir 
349*cdf0e10cSrcweir class MyClass : public osl::DebugBase<MyClass>, public OWeakObject
350*cdf0e10cSrcweir {
351*cdf0e10cSrcweir public:
352*cdf0e10cSrcweir     MyClass();
353*cdf0e10cSrcweir     virtual ~MyClass();
354*cdf0e10cSrcweir     virtual void SAL_CALL acquire() throw ();
355*cdf0e10cSrcweir     virtual void SAL_CALL release() throw ();
356*cdf0e10cSrcweir };
357*cdf0e10cSrcweir 
358*cdf0e10cSrcweir //______________________________________________________________________________
359*cdf0e10cSrcweir MyClass::MyClass()
360*cdf0e10cSrcweir {
361*cdf0e10cSrcweir }
362*cdf0e10cSrcweir //______________________________________________________________________________
363*cdf0e10cSrcweir MyClass::~MyClass()
364*cdf0e10cSrcweir {
365*cdf0e10cSrcweir }
366*cdf0e10cSrcweir //______________________________________________________________________________
367*cdf0e10cSrcweir void MyClass::acquire() throw ()
368*cdf0e10cSrcweir {
369*cdf0e10cSrcweir     OWeakObject::acquire();
370*cdf0e10cSrcweir }
371*cdf0e10cSrcweir //______________________________________________________________________________
372*cdf0e10cSrcweir void MyClass::release() throw ()
373*cdf0e10cSrcweir {
374*cdf0e10cSrcweir     OWeakObject::release();
375*cdf0e10cSrcweir }
376*cdf0e10cSrcweir 
377*cdf0e10cSrcweir //==================================================================================================
378*cdf0e10cSrcweir static sal_Bool performTest(
379*cdf0e10cSrcweir     const Reference<XComponentContext> & xContext,
380*cdf0e10cSrcweir     const Reference<XBridgeTest > & xLBT,
381*cdf0e10cSrcweir     bool noCurrentContext )
382*cdf0e10cSrcweir {
383*cdf0e10cSrcweir     check(xLBT.is(), "### no test interface!");
384*cdf0e10cSrcweir     bool bRet = true;
385*cdf0e10cSrcweir     if (xLBT.is()) {
386*cdf0e10cSrcweir         // this data is never ever granted access to by calls other than
387*cdf0e10cSrcweir         // equals(), assign()!
388*cdf0e10cSrcweir         TestData aData; // test against this data
389*cdf0e10cSrcweir         Reference< XInterface > xI(new MyClass);
390*cdf0e10cSrcweir         assign(
391*cdf0e10cSrcweir             (TestElement &) aData, true, '@', 17, 0x1234, 0xFEDC, 0x12345678,
392*cdf0e10cSrcweir             0xFEDCBA98, SAL_CONST_INT64(0x123456789ABCDEF0),
393*cdf0e10cSrcweir             SAL_CONST_UINT64(0xFEDCBA9876543210), 17.0815f, 3.1415926359,
394*cdf0e10cSrcweir             TestEnum_LOLA, OUSTR(STRING_TEST_CONSTANT), xI,
395*cdf0e10cSrcweir             Any(&xI, getCppuType((Reference< XInterface > const *) 0)));
396*cdf0e10cSrcweir         bRet &= check(aData.Any == xI, "### unexpected any!");
397*cdf0e10cSrcweir         bRet &= check(!(aData.Any != xI), "### unexpected any!");
398*cdf0e10cSrcweir         aData.Sequence.realloc(2);
399*cdf0e10cSrcweir         aData.Sequence[0] = *(TestElement const *) &aData;
400*cdf0e10cSrcweir         // aData.Sequence[1] is empty
401*cdf0e10cSrcweir         // aSetData is a manually copy of aData for first setting:
402*cdf0e10cSrcweir         TestData aSetData;
403*cdf0e10cSrcweir         assign(
404*cdf0e10cSrcweir             (TestElement &) aSetData, aData.Bool, aData.Char, aData.Byte,
405*cdf0e10cSrcweir             aData.Short, aData.UShort, aData.Long, aData.ULong, aData.Hyper,
406*cdf0e10cSrcweir             aData.UHyper, aData.Float, aData.Double, aData.Enum, aData.String,
407*cdf0e10cSrcweir             xI, Any(&xI, getCppuType((Reference< XInterface > const *) 0)));
408*cdf0e10cSrcweir         aSetData.Sequence.realloc(2);
409*cdf0e10cSrcweir         aSetData.Sequence[0] = *(TestElement const *) &aSetData;
410*cdf0e10cSrcweir         // aSetData.Sequence[1] is empty
411*cdf0e10cSrcweir         xLBT->setValues(
412*cdf0e10cSrcweir             aSetData.Bool, aSetData.Char, aSetData.Byte, aSetData.Short,
413*cdf0e10cSrcweir             aSetData.UShort, aSetData.Long, aSetData.ULong, aSetData.Hyper,
414*cdf0e10cSrcweir             aSetData.UHyper, aSetData.Float, aSetData.Double, aSetData.Enum,
415*cdf0e10cSrcweir             aSetData.String, aSetData.Interface, aSetData.Any,
416*cdf0e10cSrcweir             aSetData.Sequence, aSetData);
417*cdf0e10cSrcweir         {
418*cdf0e10cSrcweir             TestData aRet;
419*cdf0e10cSrcweir             TestData aRet2;
420*cdf0e10cSrcweir             xLBT->getValues(
421*cdf0e10cSrcweir                 aRet.Bool, aRet.Char, aRet.Byte, aRet.Short, aRet.UShort,
422*cdf0e10cSrcweir                 aRet.Long, aRet.ULong, aRet.Hyper, aRet.UHyper, aRet.Float,
423*cdf0e10cSrcweir                 aRet.Double, aRet.Enum, aRet.String, aRet.Interface, aRet.Any,
424*cdf0e10cSrcweir                 aRet.Sequence, aRet2);
425*cdf0e10cSrcweir             bRet &= check(
426*cdf0e10cSrcweir                 equals(aData, aRet) && equals(aData, aRet2), "getValues test");
427*cdf0e10cSrcweir             // Set last retrieved values:
428*cdf0e10cSrcweir             TestData aSV2ret(
429*cdf0e10cSrcweir                 xLBT->setValues2(
430*cdf0e10cSrcweir                     aRet.Bool, aRet.Char, aRet.Byte, aRet.Short, aRet.UShort,
431*cdf0e10cSrcweir                     aRet.Long, aRet.ULong, aRet.Hyper, aRet.UHyper, aRet.Float,
432*cdf0e10cSrcweir                     aRet.Double, aRet.Enum, aRet.String, aRet.Interface,
433*cdf0e10cSrcweir                     aRet.Any, aRet.Sequence, aRet2));
434*cdf0e10cSrcweir             // Check inout sequence order (=> inout sequence parameter was
435*cdf0e10cSrcweir             // switched by test objects):
436*cdf0e10cSrcweir             TestElement temp(aRet.Sequence[0]);
437*cdf0e10cSrcweir             aRet.Sequence[0] = aRet.Sequence[1];
438*cdf0e10cSrcweir             aRet.Sequence[1] = temp;
439*cdf0e10cSrcweir             bRet &= check(
440*cdf0e10cSrcweir                 equals(aData, aSV2ret) && equals(aData, aRet2),
441*cdf0e10cSrcweir                 "getValues2 test");
442*cdf0e10cSrcweir         }
443*cdf0e10cSrcweir         {
444*cdf0e10cSrcweir             TestData aRet;
445*cdf0e10cSrcweir             TestData aRet2;
446*cdf0e10cSrcweir             TestData aGVret(
447*cdf0e10cSrcweir                 xLBT->getValues(
448*cdf0e10cSrcweir                     aRet.Bool, aRet.Char, aRet.Byte, aRet.Short, aRet.UShort,
449*cdf0e10cSrcweir                     aRet.Long, aRet.ULong, aRet.Hyper, aRet.UHyper, aRet.Float,
450*cdf0e10cSrcweir                     aRet.Double, aRet.Enum, aRet.String, aRet.Interface,
451*cdf0e10cSrcweir                     aRet.Any, aRet.Sequence, aRet2));
452*cdf0e10cSrcweir             bRet &= check(
453*cdf0e10cSrcweir                 (equals(aData, aRet) && equals(aData, aRet2) &&
454*cdf0e10cSrcweir                  equals(aData, aGVret)),
455*cdf0e10cSrcweir                 "getValues test");
456*cdf0e10cSrcweir             // Set last retrieved values:
457*cdf0e10cSrcweir             xLBT->setBool(aRet.Bool);
458*cdf0e10cSrcweir             xLBT->setChar(aRet.Char);
459*cdf0e10cSrcweir             xLBT->setByte(aRet.Byte);
460*cdf0e10cSrcweir             xLBT->setShort(aRet.Short);
461*cdf0e10cSrcweir             xLBT->setUShort(aRet.UShort);
462*cdf0e10cSrcweir             xLBT->setLong(aRet.Long);
463*cdf0e10cSrcweir             xLBT->setULong(aRet.ULong);
464*cdf0e10cSrcweir             xLBT->setHyper(aRet.Hyper);
465*cdf0e10cSrcweir             xLBT->setUHyper(aRet.UHyper);
466*cdf0e10cSrcweir             xLBT->setFloat(aRet.Float);
467*cdf0e10cSrcweir             xLBT->setDouble(aRet.Double);
468*cdf0e10cSrcweir             xLBT->setEnum(aRet.Enum);
469*cdf0e10cSrcweir             xLBT->setString(aRet.String);
470*cdf0e10cSrcweir             xLBT->setInterface(aRet.Interface);
471*cdf0e10cSrcweir             xLBT->setAny(aRet.Any);
472*cdf0e10cSrcweir             xLBT->setSequence(aRet.Sequence);
473*cdf0e10cSrcweir             xLBT->setStruct(aRet2);
474*cdf0e10cSrcweir         }
475*cdf0e10cSrcweir         {
476*cdf0e10cSrcweir             TestData aRet;
477*cdf0e10cSrcweir             aRet.Hyper = xLBT->getHyper();
478*cdf0e10cSrcweir             aRet.UHyper = xLBT->getUHyper();
479*cdf0e10cSrcweir             aRet.Float = xLBT->getFloat();
480*cdf0e10cSrcweir             aRet.Double = xLBT->getDouble();
481*cdf0e10cSrcweir             aRet.Byte = xLBT->getByte();
482*cdf0e10cSrcweir             aRet.Char = xLBT->getChar();
483*cdf0e10cSrcweir             aRet.Bool = xLBT->getBool();
484*cdf0e10cSrcweir             aRet.Short = xLBT->getShort();
485*cdf0e10cSrcweir             aRet.UShort = xLBT->getUShort();
486*cdf0e10cSrcweir             aRet.Long = xLBT->getLong();
487*cdf0e10cSrcweir             aRet.ULong = xLBT->getULong();
488*cdf0e10cSrcweir             aRet.Enum = xLBT->getEnum();
489*cdf0e10cSrcweir             aRet.String = xLBT->getString();
490*cdf0e10cSrcweir             aRet.Interface = xLBT->getInterface();
491*cdf0e10cSrcweir             aRet.Any = xLBT->getAny();
492*cdf0e10cSrcweir             aRet.Sequence = xLBT->getSequence();
493*cdf0e10cSrcweir             TestData aRet2(xLBT->getStruct());
494*cdf0e10cSrcweir             bRet &= check(
495*cdf0e10cSrcweir                 equals(aData, aRet) && equals(aData, aRet2),
496*cdf0e10cSrcweir                 "struct comparison test");
497*cdf0e10cSrcweir             {
498*cdf0e10cSrcweir                 SmallStruct aIn(1, 2);
499*cdf0e10cSrcweir                 SmallStruct aOut(xLBT->echoSmallStruct(aIn));
500*cdf0e10cSrcweir                 bRet &= check(
501*cdf0e10cSrcweir                     memcmp(&aIn, &aOut, sizeof(SmallStruct)) == 0,
502*cdf0e10cSrcweir                     "small struct test");
503*cdf0e10cSrcweir             }
504*cdf0e10cSrcweir             {
505*cdf0e10cSrcweir                 MediumStruct aIn(1, 2, 3, 4);
506*cdf0e10cSrcweir                 MediumStruct aOut(xLBT->echoMediumStruct(aIn));
507*cdf0e10cSrcweir                 bRet &= check(
508*cdf0e10cSrcweir                     memcmp(&aIn, &aOut, sizeof(MediumStruct)) == 0,
509*cdf0e10cSrcweir                     "medium struct test");
510*cdf0e10cSrcweir             }
511*cdf0e10cSrcweir             {
512*cdf0e10cSrcweir                 BigStruct aIn(1, 2, 3, 4, 5, 6, 7, 8);
513*cdf0e10cSrcweir                 BigStruct aOut(xLBT->echoBigStruct(aIn));
514*cdf0e10cSrcweir                 bRet &= check(
515*cdf0e10cSrcweir                     memcmp(&aIn, &aOut, sizeof(BigStruct)) == 0,
516*cdf0e10cSrcweir                     "big struct test");
517*cdf0e10cSrcweir             }
518*cdf0e10cSrcweir             {
519*cdf0e10cSrcweir                 AllFloats aIn(1.1f, 2.2f, 3.3f, 4.4f);
520*cdf0e10cSrcweir                 AllFloats aOut(xLBT->echoAllFloats(aIn));
521*cdf0e10cSrcweir                 bRet &= check(
522*cdf0e10cSrcweir                     memcmp(&aIn, &aOut, sizeof(AllFloats)) == 0,
523*cdf0e10cSrcweir                     "all floats struct test");
524*cdf0e10cSrcweir             }
525*cdf0e10cSrcweir             {
526*cdf0e10cSrcweir                 sal_Int32 i2 = xLBT->testPPCAlignment(0, 0, 0, 0, 0xBEAF);
527*cdf0e10cSrcweir                 bRet &= check(i2 == 0xBEAF, "ppc-style alignment test");
528*cdf0e10cSrcweir             }
529*cdf0e10cSrcweir             // Test extended attributes that raise exceptions:
530*cdf0e10cSrcweir             try {
531*cdf0e10cSrcweir                 xLBT->getRaiseAttr1();
532*cdf0e10cSrcweir                 bRet &= check(false, "getRaiseAttr1 did not throw");
533*cdf0e10cSrcweir             } catch (RuntimeException &) {
534*cdf0e10cSrcweir             } catch (...) {
535*cdf0e10cSrcweir                 bRet &= check(false, "getRaiseAttr1 threw wrong type");
536*cdf0e10cSrcweir             }
537*cdf0e10cSrcweir             try {
538*cdf0e10cSrcweir                 xLBT->setRaiseAttr1(0);
539*cdf0e10cSrcweir                 bRet &= check(false, "setRaiseAttr1 did not throw");
540*cdf0e10cSrcweir             } catch (IllegalArgumentException &) {
541*cdf0e10cSrcweir             } catch (...) {
542*cdf0e10cSrcweir                 bRet &= check(false, "setRaiseAttr1 threw wrong type");
543*cdf0e10cSrcweir             }
544*cdf0e10cSrcweir             try {
545*cdf0e10cSrcweir                 xLBT->getRaiseAttr2();
546*cdf0e10cSrcweir                 bRet &= check(false, "getRaiseAttr2 did not throw");
547*cdf0e10cSrcweir             } catch (IllegalArgumentException &) {
548*cdf0e10cSrcweir             } catch (...) {
549*cdf0e10cSrcweir                 bRet &= check(false, "getRaiseAttr2 threw wrong type");
550*cdf0e10cSrcweir             }
551*cdf0e10cSrcweir             // Test instantiated polymorphic struct types:
552*cdf0e10cSrcweir             {
553*cdf0e10cSrcweir                 bRet &= check(
554*cdf0e10cSrcweir                     (xLBT->transportPolyBoolean(
555*cdf0e10cSrcweir                         TestPolyStruct< sal_Bool >(true)).
556*cdf0e10cSrcweir                      member),
557*cdf0e10cSrcweir                     "transportPolyBoolean");
558*cdf0e10cSrcweir                 TestPolyStruct< sal_Int64 > tps1(12345);
559*cdf0e10cSrcweir                 xLBT->transportPolyHyper(tps1);
560*cdf0e10cSrcweir                 bRet &= check(tps1.member == 12345, "transportPolyHyper");
561*cdf0e10cSrcweir                 Sequence< Any > seq(2);
562*cdf0e10cSrcweir                 seq[0] <<= static_cast< sal_uInt32 >(33);
563*cdf0e10cSrcweir                 seq[1] <<= rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("ABC"));
564*cdf0e10cSrcweir                 TestPolyStruct< Sequence< Any > > tps2(seq);
565*cdf0e10cSrcweir                 TestPolyStruct< Sequence< Any > > tps3;
566*cdf0e10cSrcweir                 xLBT->transportPolySequence(tps2, tps3);
567*cdf0e10cSrcweir                 bRet &= check(
568*cdf0e10cSrcweir                     tps3.member.getLength() == 2,
569*cdf0e10cSrcweir                     "transportPolySequence, length");
570*cdf0e10cSrcweir                 sal_uInt32 v0 = sal_uInt32();
571*cdf0e10cSrcweir                 tps3.member[0] >>= v0;
572*cdf0e10cSrcweir                 bRet &= check(v0 == 33, "transportPolySequence, element 0");
573*cdf0e10cSrcweir                 rtl::OUString v1;
574*cdf0e10cSrcweir                 tps3.member[1] >>= v1;
575*cdf0e10cSrcweir                 bRet &= check(
576*cdf0e10cSrcweir                     v1.equalsAsciiL(RTL_CONSTASCII_STRINGPARAM("ABC")),
577*cdf0e10cSrcweir                     "transportPolySequence, element 1");
578*cdf0e10cSrcweir                 bRet &= check(
579*cdf0e10cSrcweir                     xLBT->getNullPolyLong().member == 0, "getNullPolyLong");
580*cdf0e10cSrcweir                 bRet &= check(
581*cdf0e10cSrcweir                     xLBT->getNullPolyString().member.getLength() == 0,
582*cdf0e10cSrcweir                     "getNullPolyString");
583*cdf0e10cSrcweir                 bRet &= check(
584*cdf0e10cSrcweir                     xLBT->getNullPolyType().member == Type(),
585*cdf0e10cSrcweir                     "getNullPolyType");
586*cdf0e10cSrcweir                 Any nullAny(xLBT->getNullPolyAny().member);
587*cdf0e10cSrcweir                 bRet &= check(
588*cdf0e10cSrcweir                     (((nullAny.getValueTypeName() ==
589*cdf0e10cSrcweir                        rtl::OUString(
590*cdf0e10cSrcweir                            RTL_CONSTASCII_USTRINGPARAM(
591*cdf0e10cSrcweir                                "com.sun.star.uno.XInterface"))) &&
592*cdf0e10cSrcweir                       !static_cast< Reference< XInterface > const * >(
593*cdf0e10cSrcweir                           nullAny.getValue())->is())
594*cdf0e10cSrcweir                      || nullAny == Any()),
595*cdf0e10cSrcweir                     "getNullPolyAny");
596*cdf0e10cSrcweir                 bRet &= check(
597*cdf0e10cSrcweir                     xLBT->getNullPolySequence().member.getLength() == 0,
598*cdf0e10cSrcweir                     "getNullPolySequence");
599*cdf0e10cSrcweir                 bRet &= check(
600*cdf0e10cSrcweir                     xLBT->getNullPolyEnum().member == TestEnum_TEST,
601*cdf0e10cSrcweir                     "getNullPolyEnum");
602*cdf0e10cSrcweir                 bRet &= check(
603*cdf0e10cSrcweir                     xLBT->getNullPolyBadEnum().member == TestBadEnum_M,
604*cdf0e10cSrcweir                     "getNullPolyBadEnum");
605*cdf0e10cSrcweir                 bRet &= check(
606*cdf0e10cSrcweir                     xLBT->getNullPolyStruct().member.member == 0,
607*cdf0e10cSrcweir                     "getNullPolyStruct");
608*cdf0e10cSrcweir                 bRet &= check(
609*cdf0e10cSrcweir                     !xLBT->getNullPolyInterface().member.is(),
610*cdf0e10cSrcweir                     "getNullPolyInterface");
611*cdf0e10cSrcweir             }
612*cdf0e10cSrcweir             // Any test:
613*cdf0e10cSrcweir             bRet &= check(performAnyTest(xLBT , aData), "any test");
614*cdf0e10cSrcweir             // Sequence of call test:
615*cdf0e10cSrcweir             bRet &= check(
616*cdf0e10cSrcweir                 performSequenceOfCallTest(xLBT), "sequence of call test");
617*cdf0e10cSrcweir             // Recursive call test:
618*cdf0e10cSrcweir             bRet &= check(performRecursiveCallTest(xLBT), "recursive test");
619*cdf0e10cSrcweir             bRet &= check(
620*cdf0e10cSrcweir                 equals(aData, aRet) && equals(aData, aRet2),
621*cdf0e10cSrcweir                 "recursive test results");
622*cdf0e10cSrcweir             // Multiple inheritance test:
623*cdf0e10cSrcweir             bRet &= checkEmpty(
624*cdf0e10cSrcweir                 testtools::bridgetest::testMulti(xLBT->getMulti()),
625*cdf0e10cSrcweir                 "remote multi");
626*cdf0e10cSrcweir             bRet &= checkEmpty(
627*cdf0e10cSrcweir                 xLBT->testMulti(new testtools::bridgetest::Multi),
628*cdf0e10cSrcweir                 "local multi");
629*cdf0e10cSrcweir         }
630*cdf0e10cSrcweir     }
631*cdf0e10cSrcweir     {
632*cdf0e10cSrcweir         Reference< XBridgeTest2 > xBT2(xLBT, UNO_QUERY);
633*cdf0e10cSrcweir         if (!xBT2.is()) {
634*cdf0e10cSrcweir             return bRet;
635*cdf0e10cSrcweir         }
636*cdf0e10cSrcweir         // Perform sequence tests (XBridgeTest2); create the sequence which is
637*cdf0e10cSrcweir         // compared with the results:
638*cdf0e10cSrcweir         sal_Bool _arBool[] = { true, false, true };
639*cdf0e10cSrcweir         sal_Unicode _arChar[] = { 0x0065, 0x0066, 0x0067 };
640*cdf0e10cSrcweir         sal_Int8 _arByte[] = { 1, 2, -1 };
641*cdf0e10cSrcweir         sal_Int16 _arShort[] = { -0x8000, 1, 0x7FFF };
642*cdf0e10cSrcweir         sal_uInt16 _arUShort[] = { 0 , 1, 0xFFFF };
643*cdf0e10cSrcweir         sal_Int32 _arLong[] = { 0x80000000, 1, 0x7FFFFFFF };
644*cdf0e10cSrcweir         sal_uInt32 _arULong[] = { 0, 1, 0xFFFFFFFF };
645*cdf0e10cSrcweir         sal_Int64 _arHyper[] = {
646*cdf0e10cSrcweir             SAL_CONST_INT64(0x8000000000000000), 1,
647*cdf0e10cSrcweir             SAL_CONST_INT64(0x7FFFFFFFFFFFFFFF) };
648*cdf0e10cSrcweir         sal_uInt64 _arUHyper[] = { 0, 1, SAL_CONST_UINT64(0xFFFFFFFFFFFFFFFF) };
649*cdf0e10cSrcweir         float _arFloat[] = { 1.1f, 2.2f, 3.3f };
650*cdf0e10cSrcweir         double _arDouble[] = { 1.11, 2.22, 3.33 };
651*cdf0e10cSrcweir         OUString _arString[] = {
652*cdf0e10cSrcweir             OUString(RTL_CONSTASCII_USTRINGPARAM("String 1")),
653*cdf0e10cSrcweir             OUString(RTL_CONSTASCII_USTRINGPARAM("String 2")),
654*cdf0e10cSrcweir             OUString(RTL_CONSTASCII_USTRINGPARAM("String 3")) };
655*cdf0e10cSrcweir         sal_Bool _aBool = true;
656*cdf0e10cSrcweir         sal_Int32 _aInt = 0xBABEBABE;
657*cdf0e10cSrcweir         float _aFloat = 3.14f;
658*cdf0e10cSrcweir         Any _any1(&_aBool, getCppuBooleanType());
659*cdf0e10cSrcweir         Any _any2(&_aInt, getCppuType((sal_Int32 *) 0));
660*cdf0e10cSrcweir         Any _any3(&_aFloat, getCppuType((float *) 0));
661*cdf0e10cSrcweir         Any _arAny[] = { _any1, _any2, _any3 };
662*cdf0e10cSrcweir         Reference< XInterface > _arObj[3];
663*cdf0e10cSrcweir         _arObj[0] = new OWeakObject();
664*cdf0e10cSrcweir         _arObj[1] = new OWeakObject();
665*cdf0e10cSrcweir         _arObj[2] = new OWeakObject();
666*cdf0e10cSrcweir         TestEnum _arEnum[] = { TestEnum_ONE, TestEnum_TWO, TestEnum_CHECK };
667*cdf0e10cSrcweir         TestElement _arStruct[3];
668*cdf0e10cSrcweir         assign(
669*cdf0e10cSrcweir             _arStruct[0], true, '@', 17, 0x1234, 0xFEDC, 0x12345678, 0xFEDCBA98,
670*cdf0e10cSrcweir             SAL_CONST_INT64(0x123456789ABCDEF0),
671*cdf0e10cSrcweir             SAL_CONST_UINT64(0xFEDCBA9876543210), 17.0815f, 3.1415926359,
672*cdf0e10cSrcweir             TestEnum_LOLA, OUSTR(STRING_TEST_CONSTANT), _arObj[0],
673*cdf0e10cSrcweir             Any(&_arObj[0], getCppuType((Reference< XInterface > const *) 0)));
674*cdf0e10cSrcweir         assign(
675*cdf0e10cSrcweir             _arStruct[1], true, 'A', 17, 0x1234, 0xFEDC, 0x12345678, 0xFEDCBA98,
676*cdf0e10cSrcweir             SAL_CONST_INT64(0x123456789ABCDEF0),
677*cdf0e10cSrcweir             SAL_CONST_UINT64(0xFEDCBA9876543210), 17.0815f, 3.1415926359,
678*cdf0e10cSrcweir             TestEnum_TWO, OUSTR(STRING_TEST_CONSTANT), _arObj[1],
679*cdf0e10cSrcweir             Any(&_arObj[1], getCppuType((Reference< XInterface > const *) 0)));
680*cdf0e10cSrcweir         assign(
681*cdf0e10cSrcweir             _arStruct[2], true, 'B', 17, 0x1234, 0xFEDC, 0x12345678, 0xFEDCBA98,
682*cdf0e10cSrcweir             SAL_CONST_INT64(0x123456789ABCDEF0),
683*cdf0e10cSrcweir             SAL_CONST_UINT64(0xFEDCBA9876543210), 17.0815f, 3.1415926359,
684*cdf0e10cSrcweir             TestEnum_CHECK, OUSTR(STRING_TEST_CONSTANT), _arObj[2],
685*cdf0e10cSrcweir             Any(&_arObj[2], getCppuType((Reference< XInterface > const *) 0)));
686*cdf0e10cSrcweir         {
687*cdf0e10cSrcweir             Sequence<sal_Bool> arBool(_arBool, 3);
688*cdf0e10cSrcweir             Sequence<sal_Unicode> arChar( _arChar, 3);
689*cdf0e10cSrcweir             Sequence<sal_Int8> arByte(_arByte, 3);
690*cdf0e10cSrcweir             Sequence<sal_Int16> arShort(_arShort, 3);
691*cdf0e10cSrcweir             Sequence<sal_uInt16> arUShort(_arUShort, 3);
692*cdf0e10cSrcweir             Sequence<sal_Int32> arLong(_arLong, 3);
693*cdf0e10cSrcweir             Sequence<sal_uInt32> arULong(_arULong, 3);
694*cdf0e10cSrcweir             Sequence<sal_Int64> arHyper(_arHyper, 3);
695*cdf0e10cSrcweir             Sequence<sal_uInt64> arUHyper(_arUHyper, 3);
696*cdf0e10cSrcweir             Sequence<float> arFloat(_arFloat, 3);
697*cdf0e10cSrcweir             Sequence<double> arDouble(_arDouble, 3);
698*cdf0e10cSrcweir             Sequence<OUString> arString(_arString, 3);
699*cdf0e10cSrcweir             Sequence<Any> arAny(_arAny, 3);
700*cdf0e10cSrcweir             Sequence<Reference<XInterface> > arObject(_arObj, 3);
701*cdf0e10cSrcweir             Sequence<TestEnum> arEnum(_arEnum, 3);
702*cdf0e10cSrcweir             Sequence<TestElement> arStruct(_arStruct, 3);
703*cdf0e10cSrcweir             Sequence<Sequence<sal_Int32> > _arSeqLong2[3];
704*cdf0e10cSrcweir             for (int j = 0; j != 3; ++j) {
705*cdf0e10cSrcweir                 Sequence< sal_Int32 > _arSeqLong[3];
706*cdf0e10cSrcweir                 for (int i = 0; i != 3; ++i) {
707*cdf0e10cSrcweir                     _arSeqLong[i] = Sequence< sal_Int32 >(_arLong, 3);
708*cdf0e10cSrcweir                 }
709*cdf0e10cSrcweir                 _arSeqLong2[j] = Sequence< Sequence< sal_Int32 > >(
710*cdf0e10cSrcweir                     _arSeqLong, 3);
711*cdf0e10cSrcweir             }
712*cdf0e10cSrcweir             Sequence< Sequence< Sequence< sal_Int32> > > arLong3(
713*cdf0e10cSrcweir                 _arSeqLong2, 3);
714*cdf0e10cSrcweir             Sequence< Sequence< sal_Int32 > > seqSeqRet(
715*cdf0e10cSrcweir                 xBT2->setDim2(arLong3[0]));
716*cdf0e10cSrcweir             bRet &= check(seqSeqRet == arLong3[0], "sequence test");
717*cdf0e10cSrcweir             Sequence< Sequence< Sequence< sal_Int32 > > > seqSeqRet2(
718*cdf0e10cSrcweir                 xBT2->setDim3(arLong3));
719*cdf0e10cSrcweir             bRet &= check(seqSeqRet2 == arLong3, "sequence test");
720*cdf0e10cSrcweir             Sequence< Any > seqAnyRet(xBT2->setSequenceAny(arAny));
721*cdf0e10cSrcweir             bRet &= check(seqAnyRet == arAny, "sequence test");
722*cdf0e10cSrcweir             Sequence< sal_Bool > seqBoolRet(xBT2->setSequenceBool(arBool));
723*cdf0e10cSrcweir             bRet &= check(seqBoolRet == arBool, "sequence test");
724*cdf0e10cSrcweir             Sequence< sal_Int8 > seqByteRet(xBT2->setSequenceByte(arByte));
725*cdf0e10cSrcweir             bRet &= check(seqByteRet == arByte, "sequence test");
726*cdf0e10cSrcweir             Sequence< sal_Unicode > seqCharRet(xBT2->setSequenceChar(arChar));
727*cdf0e10cSrcweir             bRet &= check(seqCharRet == arChar, "sequence test");
728*cdf0e10cSrcweir             Sequence< sal_Int16 > seqShortRet(xBT2->setSequenceShort(arShort));
729*cdf0e10cSrcweir             bRet &= check(seqShortRet == arShort, "sequence test");
730*cdf0e10cSrcweir             Sequence< sal_Int32 > seqLongRet(xBT2->setSequenceLong(arLong));
731*cdf0e10cSrcweir             bRet &= check(seqLongRet == arLong, "sequence test");
732*cdf0e10cSrcweir             Sequence< sal_Int64 > seqHyperRet(xBT2->setSequenceHyper(arHyper));
733*cdf0e10cSrcweir             bRet &= check(seqHyperRet == arHyper, "sequence test");
734*cdf0e10cSrcweir             Sequence< float > seqFloatRet(xBT2->setSequenceFloat(arFloat));
735*cdf0e10cSrcweir             bRet &= check(seqFloatRet == arFloat, "sequence test");
736*cdf0e10cSrcweir             Sequence< double > seqDoubleRet(xBT2->setSequenceDouble(arDouble));
737*cdf0e10cSrcweir             bRet &= check(seqDoubleRet == arDouble, "sequence test");
738*cdf0e10cSrcweir             Sequence< TestEnum > seqEnumRet(xBT2->setSequenceEnum(arEnum));
739*cdf0e10cSrcweir             bRet &= check(seqEnumRet == arEnum, "sequence test");
740*cdf0e10cSrcweir             Sequence< sal_uInt16 > seqUShortRet(
741*cdf0e10cSrcweir                 xBT2->setSequenceUShort(arUShort));
742*cdf0e10cSrcweir             bRet &= check(seqUShortRet == arUShort, "sequence test");
743*cdf0e10cSrcweir             Sequence< sal_uInt32 > seqULongRet(xBT2->setSequenceULong(arULong));
744*cdf0e10cSrcweir             bRet &= check(seqULongRet == arULong, "sequence test");
745*cdf0e10cSrcweir             Sequence< sal_uInt64 > seqUHyperRet(
746*cdf0e10cSrcweir                 xBT2->setSequenceUHyper(arUHyper));
747*cdf0e10cSrcweir             bRet &= check(seqUHyperRet == arUHyper, "sequence test");
748*cdf0e10cSrcweir             Sequence< Reference< XInterface > > seqObjectRet(
749*cdf0e10cSrcweir                 xBT2->setSequenceXInterface(arObject));
750*cdf0e10cSrcweir             bRet &= check(seqObjectRet == arObject, "sequence test");
751*cdf0e10cSrcweir             Sequence< OUString > seqStringRet(
752*cdf0e10cSrcweir                 xBT2->setSequenceString(arString));
753*cdf0e10cSrcweir             bRet &= check(seqStringRet == arString, "sequence test");
754*cdf0e10cSrcweir             Sequence< TestElement > seqStructRet(
755*cdf0e10cSrcweir                 xBT2->setSequenceStruct(arStruct));
756*cdf0e10cSrcweir             bRet &= check(seqStructRet == arStruct, "sequence test");
757*cdf0e10cSrcweir             Sequence< sal_Bool > arBoolTemp(cloneSequence(arBool));
758*cdf0e10cSrcweir             Sequence< sal_Unicode > arCharTemp(cloneSequence(arChar));
759*cdf0e10cSrcweir             Sequence< sal_Int8 > arByteTemp(cloneSequence(arByte));
760*cdf0e10cSrcweir             Sequence< sal_Int16 > arShortTemp(cloneSequence(arShort));
761*cdf0e10cSrcweir             Sequence< sal_uInt16 > arUShortTemp(cloneSequence(arUShort));
762*cdf0e10cSrcweir             Sequence< sal_Int32 > arLongTemp(cloneSequence(arLong));
763*cdf0e10cSrcweir             Sequence< sal_uInt32 > arULongTemp(cloneSequence(arULong));
764*cdf0e10cSrcweir             Sequence< sal_Int64 > arHyperTemp(cloneSequence(arHyper));
765*cdf0e10cSrcweir             Sequence< sal_uInt64 > arUHyperTemp(cloneSequence(arUHyper));
766*cdf0e10cSrcweir             Sequence< float > arFloatTemp(cloneSequence(arFloat));
767*cdf0e10cSrcweir             Sequence< double > arDoubleTemp(cloneSequence(arDouble));
768*cdf0e10cSrcweir             Sequence< TestEnum > arEnumTemp(cloneSequence(arEnum));
769*cdf0e10cSrcweir             Sequence< OUString > arStringTemp(cloneSequence(arString));
770*cdf0e10cSrcweir             Sequence< Reference< XInterface > > arObjectTemp(
771*cdf0e10cSrcweir                 cloneSequence(arObject));
772*cdf0e10cSrcweir             Sequence< Any > arAnyTemp(cloneSequence(arAny));
773*cdf0e10cSrcweir             Sequence< Sequence< sal_Int32 > > arLong2Temp(arLong3[0]);
774*cdf0e10cSrcweir             Sequence< Sequence< Sequence< sal_Int32 > > > arLong3Temp(arLong3);
775*cdf0e10cSrcweir             xBT2->setSequencesInOut(
776*cdf0e10cSrcweir                 arBoolTemp, arCharTemp, arByteTemp, arShortTemp, arUShortTemp,
777*cdf0e10cSrcweir                 arLongTemp,arULongTemp, arHyperTemp, arUHyperTemp, arFloatTemp,
778*cdf0e10cSrcweir                 arDoubleTemp, arEnumTemp, arStringTemp, arObjectTemp, arAnyTemp,
779*cdf0e10cSrcweir                 arLong2Temp, arLong3Temp);
780*cdf0e10cSrcweir             bRet &= check(
781*cdf0e10cSrcweir                 (arBoolTemp == arBool && arCharTemp == arChar &&
782*cdf0e10cSrcweir                  arByteTemp == arByte && arShortTemp == arShort &&
783*cdf0e10cSrcweir                  arUShortTemp == arUShort && arLongTemp == arLong &&
784*cdf0e10cSrcweir                  arULongTemp == arULong && arHyperTemp == arHyper &&
785*cdf0e10cSrcweir                  arUHyperTemp == arUHyper && arFloatTemp == arFloat &&
786*cdf0e10cSrcweir                  arDoubleTemp == arDouble && arEnumTemp == arEnum &&
787*cdf0e10cSrcweir                  arStringTemp == arString && arObjectTemp == arObject &&
788*cdf0e10cSrcweir                  arAnyTemp == arAny && arLong2Temp == arLong3[0] &&
789*cdf0e10cSrcweir                  arLong3Temp == arLong3),
790*cdf0e10cSrcweir                 "sequence test");
791*cdf0e10cSrcweir             Sequence< sal_Bool > arBoolOut;
792*cdf0e10cSrcweir             Sequence< sal_Unicode > arCharOut;
793*cdf0e10cSrcweir             Sequence< sal_Int8 > arByteOut;
794*cdf0e10cSrcweir             Sequence< sal_Int16 > arShortOut;
795*cdf0e10cSrcweir             Sequence< sal_uInt16 > arUShortOut;
796*cdf0e10cSrcweir             Sequence< sal_Int32 > arLongOut;
797*cdf0e10cSrcweir             Sequence< sal_uInt32 > arULongOut;
798*cdf0e10cSrcweir             Sequence< sal_Int64 > arHyperOut;
799*cdf0e10cSrcweir             Sequence< sal_uInt64 > arUHyperOut;
800*cdf0e10cSrcweir             Sequence< float > arFloatOut;
801*cdf0e10cSrcweir             Sequence< double > arDoubleOut;
802*cdf0e10cSrcweir             Sequence< TestEnum > arEnumOut;
803*cdf0e10cSrcweir             Sequence< OUString > arStringOut;
804*cdf0e10cSrcweir             Sequence< Reference< XInterface > > arObjectOut;
805*cdf0e10cSrcweir             Sequence< Any > arAnyOut;
806*cdf0e10cSrcweir             Sequence< Sequence< sal_Int32 > > arLong2Out;
807*cdf0e10cSrcweir             Sequence< Sequence< Sequence< sal_Int32 > > > arLong3Out;
808*cdf0e10cSrcweir             xBT2->setSequencesOut(
809*cdf0e10cSrcweir                 arBoolOut, arCharOut, arByteOut, arShortOut, arUShortOut,
810*cdf0e10cSrcweir                 arLongOut,arULongOut, arHyperOut, arUHyperOut, arFloatOut,
811*cdf0e10cSrcweir                 arDoubleOut, arEnumOut, arStringOut, arObjectOut, arAnyOut,
812*cdf0e10cSrcweir                 arLong2Out, arLong3Out);
813*cdf0e10cSrcweir             bRet &= check(
814*cdf0e10cSrcweir                 (arBoolOut == arBool && arCharOut == arChar &&
815*cdf0e10cSrcweir                  arByteOut == arByte && arShortOut == arShort &&
816*cdf0e10cSrcweir                  arUShortOut == arUShort && arLongOut == arLong &&
817*cdf0e10cSrcweir                  arULongOut == arULong && arHyperOut == arHyper &&
818*cdf0e10cSrcweir                  arUHyperOut == arUHyper && arFloatOut == arFloat &&
819*cdf0e10cSrcweir                  arDoubleOut == arDouble && arEnumOut == arEnum &&
820*cdf0e10cSrcweir                  arStringOut == arString && arObjectOut == arObject &&
821*cdf0e10cSrcweir                  arAnyOut == arAny && arLong2Out == arLong3[0] &&
822*cdf0e10cSrcweir                  arLong3Out == arLong3),
823*cdf0e10cSrcweir                 "sequence test");
824*cdf0e10cSrcweir         }
825*cdf0e10cSrcweir         {
826*cdf0e10cSrcweir             // Test with empty sequences:
827*cdf0e10cSrcweir             Sequence< Sequence< sal_Int32 > > arLong2;
828*cdf0e10cSrcweir             Sequence< Sequence< sal_Int32 > > seqSeqRet(xBT2->setDim2(arLong2));
829*cdf0e10cSrcweir             bRet &= check(seqSeqRet == arLong2, "sequence test");
830*cdf0e10cSrcweir             Sequence< Sequence< Sequence< sal_Int32 > > > arLong3;
831*cdf0e10cSrcweir             Sequence< Sequence< Sequence< sal_Int32 > > > seqSeqRet2(
832*cdf0e10cSrcweir                 xBT2->setDim3(arLong3));
833*cdf0e10cSrcweir             bRet &= check(seqSeqRet2 == arLong3, "sequence test");
834*cdf0e10cSrcweir             Sequence< Any > arAny;
835*cdf0e10cSrcweir             Sequence< Any > seqAnyRet(xBT2->setSequenceAny(arAny));
836*cdf0e10cSrcweir             bRet &= check(seqAnyRet == arAny, "sequence test");
837*cdf0e10cSrcweir             Sequence< sal_Bool > arBool;
838*cdf0e10cSrcweir             Sequence< sal_Bool > seqBoolRet(xBT2->setSequenceBool(arBool));
839*cdf0e10cSrcweir             bRet &= check(seqBoolRet == arBool, "sequence test");
840*cdf0e10cSrcweir             Sequence< sal_Int8 > arByte;
841*cdf0e10cSrcweir             Sequence< sal_Int8 > seqByteRet(xBT2->setSequenceByte(arByte));
842*cdf0e10cSrcweir             bRet &= check(seqByteRet == arByte, "sequence test");
843*cdf0e10cSrcweir             Sequence< sal_Unicode > arChar;
844*cdf0e10cSrcweir             Sequence< sal_Unicode > seqCharRet(xBT2->setSequenceChar(arChar));
845*cdf0e10cSrcweir             bRet &= check(seqCharRet == arChar, "sequence test");
846*cdf0e10cSrcweir             Sequence< sal_Int16 > arShort;
847*cdf0e10cSrcweir             Sequence< sal_Int16 > seqShortRet(xBT2->setSequenceShort(arShort));
848*cdf0e10cSrcweir             bRet &= check(seqShortRet == arShort, "sequence test");
849*cdf0e10cSrcweir             Sequence< sal_Int32 > arLong;
850*cdf0e10cSrcweir             Sequence< sal_Int32 > seqLongRet(xBT2->setSequenceLong(arLong));
851*cdf0e10cSrcweir             bRet &= check(seqLongRet == arLong, "sequence test");
852*cdf0e10cSrcweir             Sequence< sal_Int64 > arHyper;
853*cdf0e10cSrcweir             Sequence< sal_Int64 > seqHyperRet(xBT2->setSequenceHyper(arHyper));
854*cdf0e10cSrcweir             bRet &= check(seqHyperRet == arHyper, "sequence test");
855*cdf0e10cSrcweir             Sequence< float > arFloat;
856*cdf0e10cSrcweir             Sequence< float > seqFloatRet(xBT2->setSequenceFloat(arFloat));
857*cdf0e10cSrcweir             bRet &= check(seqFloatRet == arFloat, "sequence test");
858*cdf0e10cSrcweir             Sequence< double > arDouble;
859*cdf0e10cSrcweir             Sequence< double > seqDoubleRet(xBT2->setSequenceDouble(arDouble));
860*cdf0e10cSrcweir             bRet &= check(seqDoubleRet == arDouble, "sequence test");
861*cdf0e10cSrcweir             Sequence< TestEnum > arEnum;
862*cdf0e10cSrcweir             Sequence< TestEnum > seqEnumRet(xBT2->setSequenceEnum(arEnum));
863*cdf0e10cSrcweir             bRet &= check(seqEnumRet == arEnum, "sequence test");
864*cdf0e10cSrcweir             Sequence< sal_uInt16 > arUShort;
865*cdf0e10cSrcweir             Sequence< sal_uInt16 > seqUShortRet(
866*cdf0e10cSrcweir                 xBT2->setSequenceUShort(arUShort));
867*cdf0e10cSrcweir             bRet &= check(seqUShortRet == arUShort, "sequence test");
868*cdf0e10cSrcweir             Sequence< sal_uInt32 > arULong;
869*cdf0e10cSrcweir             Sequence< sal_uInt32 > seqULongRet(xBT2->setSequenceULong(arULong));
870*cdf0e10cSrcweir             bRet &= check(seqULongRet == arULong, "sequence test");
871*cdf0e10cSrcweir             Sequence< sal_uInt64 > arUHyper;
872*cdf0e10cSrcweir             Sequence< sal_uInt64 > seqUHyperRet(
873*cdf0e10cSrcweir                 xBT2->setSequenceUHyper(arUHyper));
874*cdf0e10cSrcweir             bRet &= check(seqUHyperRet == arUHyper, "sequence test");
875*cdf0e10cSrcweir             Sequence< Reference< XInterface > > arObject;
876*cdf0e10cSrcweir             Sequence< Reference< XInterface > > seqObjectRet(
877*cdf0e10cSrcweir                 xBT2->setSequenceXInterface(arObject));
878*cdf0e10cSrcweir             bRet &= check(seqObjectRet == arObject, "sequence test");
879*cdf0e10cSrcweir             Sequence< OUString > arString;
880*cdf0e10cSrcweir             Sequence< OUString > seqStringRet(
881*cdf0e10cSrcweir                 xBT2->setSequenceString(arString));
882*cdf0e10cSrcweir             bRet &= check(seqStringRet == arString, "sequence test");
883*cdf0e10cSrcweir             Sequence< TestElement > arStruct;
884*cdf0e10cSrcweir             Sequence< TestElement > seqStructRet(
885*cdf0e10cSrcweir                 xBT2->setSequenceStruct(arStruct));
886*cdf0e10cSrcweir             bRet &= check(seqStructRet == arStruct, "sequence test");
887*cdf0e10cSrcweir         }
888*cdf0e10cSrcweir         // Issue #i60341# shows that the most interesting case is were Java
889*cdf0e10cSrcweir         // calls the constructors; however, since this client is currently not
890*cdf0e10cSrcweir         // available in Java, while the server is, the logic is reversed here:
891*cdf0e10cSrcweir         try {
892*cdf0e10cSrcweir             xBT2->testConstructorsService(xContext);
893*cdf0e10cSrcweir         } catch (BadConstructorArguments &) {
894*cdf0e10cSrcweir             bRet = false;
895*cdf0e10cSrcweir         }
896*cdf0e10cSrcweir         if (!noCurrentContext) {
897*cdf0e10cSrcweir             if (!(new testtools::bridgetest::CurrentContextChecker)->perform(
898*cdf0e10cSrcweir                     xBT2->getCurrentContextChecker(), 0, 1))
899*cdf0e10cSrcweir             {
900*cdf0e10cSrcweir                 bRet = false;
901*cdf0e10cSrcweir             }
902*cdf0e10cSrcweir             if (!(new testtools::bridgetest::CurrentContextChecker)->perform(
903*cdf0e10cSrcweir                     xBT2->getCurrentContextChecker(), 0, 2))
904*cdf0e10cSrcweir             {
905*cdf0e10cSrcweir                 bRet = false;
906*cdf0e10cSrcweir             }
907*cdf0e10cSrcweir             if (!(new testtools::bridgetest::CurrentContextChecker)->perform(
908*cdf0e10cSrcweir                     xBT2->getCurrentContextChecker(), 1, 2))
909*cdf0e10cSrcweir             {
910*cdf0e10cSrcweir                 bRet = false;
911*cdf0e10cSrcweir             }
912*cdf0e10cSrcweir             if (!(new testtools::bridgetest::CurrentContextChecker)->perform(
913*cdf0e10cSrcweir                     xBT2->getCurrentContextChecker(), 1, 3))
914*cdf0e10cSrcweir             {
915*cdf0e10cSrcweir                 bRet = false;
916*cdf0e10cSrcweir             }
917*cdf0e10cSrcweir         }
918*cdf0e10cSrcweir     }
919*cdf0e10cSrcweir     return bRet;
920*cdf0e10cSrcweir }
921*cdf0e10cSrcweir 
922*cdf0e10cSrcweir static sal_Bool raiseOnewayException( const Reference < XBridgeTest > & xLBT )
923*cdf0e10cSrcweir {
924*cdf0e10cSrcweir 	sal_Bool bReturn = sal_True;
925*cdf0e10cSrcweir 	OUString sCompare = OUSTR(STRING_TEST_CONSTANT);
926*cdf0e10cSrcweir     Reference<XInterface> const x(xLBT->getInterface());
927*cdf0e10cSrcweir 	try
928*cdf0e10cSrcweir 	{
929*cdf0e10cSrcweir 		// Note : the exception may fly or not (e.g. remote scenario).
930*cdf0e10cSrcweir 		//        When it flies, it must contain the correct elements.
931*cdf0e10cSrcweir 		xLBT->raiseRuntimeExceptionOneway( sCompare, x );
932*cdf0e10cSrcweir 	}
933*cdf0e10cSrcweir 	catch( RuntimeException & e )
934*cdf0e10cSrcweir 	{
935*cdf0e10cSrcweir 		bReturn = (
936*cdf0e10cSrcweir #if OSL_DEBUG_LEVEL == 0
937*cdf0e10cSrcweir             // java stack traces trash Message
938*cdf0e10cSrcweir             e.Message == sCompare &&
939*cdf0e10cSrcweir #endif
940*cdf0e10cSrcweir             xLBT->getInterface() == e.Context &&
941*cdf0e10cSrcweir             x == e.Context );
942*cdf0e10cSrcweir 	}
943*cdf0e10cSrcweir 	return bReturn;
944*cdf0e10cSrcweir }
945*cdf0e10cSrcweir 
946*cdf0e10cSrcweir //==================================================================================================
947*cdf0e10cSrcweir static sal_Bool raiseException( const Reference< XBridgeTest > & xLBT )
948*cdf0e10cSrcweir {
949*cdf0e10cSrcweir 	sal_Int32 nCount = 0;
950*cdf0e10cSrcweir 	try
951*cdf0e10cSrcweir 	{
952*cdf0e10cSrcweir 		try
953*cdf0e10cSrcweir 		{
954*cdf0e10cSrcweir 			try
955*cdf0e10cSrcweir 			{
956*cdf0e10cSrcweir 				TestData aRet, aRet2;
957*cdf0e10cSrcweir 				xLBT->raiseException(
958*cdf0e10cSrcweir 					5, OUSTR(STRING_TEST_CONSTANT),
959*cdf0e10cSrcweir 					xLBT->getInterface() );
960*cdf0e10cSrcweir 			}
961*cdf0e10cSrcweir 			catch (IllegalArgumentException aExc)
962*cdf0e10cSrcweir 			{
963*cdf0e10cSrcweir 				if (aExc.ArgumentPosition == 5 &&
964*cdf0e10cSrcweir #if OSL_DEBUG_LEVEL == 0
965*cdf0e10cSrcweir                     // java stack traces trash Message
966*cdf0e10cSrcweir                     aExc.Message.compareToAscii( STRING_TEST_CONSTANT ) == 0 &&
967*cdf0e10cSrcweir #endif
968*cdf0e10cSrcweir 					aExc.Context == xLBT->getInterface())
969*cdf0e10cSrcweir 				{
970*cdf0e10cSrcweir #ifdef COMPCHECK
971*cdf0e10cSrcweir                     //When we check if a new compiler still works then we must not call
972*cdf0e10cSrcweir                     //getRuntimeException because it uses cppu::getCaughtException which
973*cdf0e10cSrcweir                     //does only work if all libs are build with the same runtime.
974*cdf0e10cSrcweir                     return true;
975*cdf0e10cSrcweir #else
976*cdf0e10cSrcweir 					++nCount;
977*cdf0e10cSrcweir #endif
978*cdf0e10cSrcweir 				}
979*cdf0e10cSrcweir 				else
980*cdf0e10cSrcweir 				{
981*cdf0e10cSrcweir 					check( sal_False, "### unexpected exception content!" );
982*cdf0e10cSrcweir 				}
983*cdf0e10cSrcweir 
984*cdf0e10cSrcweir 				/** it is certain, that the RuntimeException testing will fail, if no */
985*cdf0e10cSrcweir 				xLBT->getRuntimeException();
986*cdf0e10cSrcweir 			}
987*cdf0e10cSrcweir 		}
988*cdf0e10cSrcweir 		catch (const RuntimeException & rExc)
989*cdf0e10cSrcweir 		{
990*cdf0e10cSrcweir 			if (rExc.Context == xLBT->getInterface()
991*cdf0e10cSrcweir #if OSL_DEBUG_LEVEL == 0
992*cdf0e10cSrcweir                     // java stack traces trash Message
993*cdf0e10cSrcweir                 && rExc.Message.compareToAscii( STRING_TEST_CONSTANT ) == 0
994*cdf0e10cSrcweir #endif
995*cdf0e10cSrcweir                 )
996*cdf0e10cSrcweir 			{
997*cdf0e10cSrcweir 				++nCount;
998*cdf0e10cSrcweir 			}
999*cdf0e10cSrcweir 			else
1000*cdf0e10cSrcweir 			{
1001*cdf0e10cSrcweir 				check( sal_False, "### unexpected exception content!" );
1002*cdf0e10cSrcweir 			}
1003*cdf0e10cSrcweir 
1004*cdf0e10cSrcweir 			/** it is certain, that the RuntimeException testing will fail, if no */
1005*cdf0e10cSrcweir 			xLBT->setRuntimeException( 0xcafebabe );
1006*cdf0e10cSrcweir 		}
1007*cdf0e10cSrcweir 	}
1008*cdf0e10cSrcweir 	catch (Exception & rExc)
1009*cdf0e10cSrcweir 	{
1010*cdf0e10cSrcweir 		if (rExc.Context == xLBT->getInterface()
1011*cdf0e10cSrcweir #if OSL_DEBUG_LEVEL == 0
1012*cdf0e10cSrcweir             // java stack traces trash Message
1013*cdf0e10cSrcweir             && rExc.Message.compareToAscii( STRING_TEST_CONSTANT ) == 0
1014*cdf0e10cSrcweir #endif
1015*cdf0e10cSrcweir             )
1016*cdf0e10cSrcweir 		{
1017*cdf0e10cSrcweir 			++nCount;
1018*cdf0e10cSrcweir 		}
1019*cdf0e10cSrcweir 		else
1020*cdf0e10cSrcweir 		{
1021*cdf0e10cSrcweir 			check( sal_False, "### unexpected exception content!" );
1022*cdf0e10cSrcweir 		}
1023*cdf0e10cSrcweir 		return (nCount == 3);
1024*cdf0e10cSrcweir 	}
1025*cdf0e10cSrcweir 	return sal_False;
1026*cdf0e10cSrcweir }
1027*cdf0e10cSrcweir 
1028*cdf0e10cSrcweir /* Returns an acquired sequence
1029*cdf0e10cSrcweir  */
1030*cdf0e10cSrcweir uno_Sequence* cloneSequence(const uno_Sequence* val, const Type& type)
1031*cdf0e10cSrcweir {
1032*cdf0e10cSrcweir     TypeDescription td(type);
1033*cdf0e10cSrcweir     td.makeComplete();
1034*cdf0e10cSrcweir     typelib_TypeDescription* pTdRaw = td.get();
1035*cdf0e10cSrcweir     typelib_IndirectTypeDescription* pIndirectTd =
1036*cdf0e10cSrcweir         (typelib_IndirectTypeDescription*) pTdRaw;
1037*cdf0e10cSrcweir 
1038*cdf0e10cSrcweir     typelib_TypeDescription* pTdElem = pIndirectTd->pType->pType;
1039*cdf0e10cSrcweir     sal_Int8* buf = new sal_Int8[pTdElem->nSize * val->nElements];
1040*cdf0e10cSrcweir     sal_Int8* pBufCur = buf;
1041*cdf0e10cSrcweir 
1042*cdf0e10cSrcweir     uno_Sequence* retSeq = NULL;
1043*cdf0e10cSrcweir     switch (pTdElem->eTypeClass)
1044*cdf0e10cSrcweir     {
1045*cdf0e10cSrcweir     case TypeClass_SEQUENCE:
1046*cdf0e10cSrcweir     {
1047*cdf0e10cSrcweir         Type _tElem(pTdElem->pWeakRef);
1048*cdf0e10cSrcweir         for (int i = 0; i < val->nElements; i++)
1049*cdf0e10cSrcweir         {
1050*cdf0e10cSrcweir             uno_Sequence* seq = cloneSequence(
1051*cdf0e10cSrcweir                 *(uno_Sequence**) (&val->elements + i * pTdElem->nSize),
1052*cdf0e10cSrcweir                 _tElem);
1053*cdf0e10cSrcweir             *((uno_Sequence**) pBufCur) = seq;
1054*cdf0e10cSrcweir             pBufCur += pTdElem->nSize;
1055*cdf0e10cSrcweir         }
1056*cdf0e10cSrcweir         break;
1057*cdf0e10cSrcweir     }
1058*cdf0e10cSrcweir     default:
1059*cdf0e10cSrcweir         uno_type_sequence_construct(
1060*cdf0e10cSrcweir             &retSeq, type.getTypeLibType(), (void*) val->elements,
1061*cdf0e10cSrcweir             val->nElements, reinterpret_cast< uno_AcquireFunc >(cpp_acquire));
1062*cdf0e10cSrcweir         break;
1063*cdf0e10cSrcweir     }
1064*cdf0e10cSrcweir     delete[] buf;
1065*cdf0e10cSrcweir     return retSeq;
1066*cdf0e10cSrcweir }
1067*cdf0e10cSrcweir 
1068*cdf0e10cSrcweir template< class T>
1069*cdf0e10cSrcweir Sequence<T> cloneSequence(const Sequence<T>& val)
1070*cdf0e10cSrcweir {
1071*cdf0e10cSrcweir     Sequence<T> seq( cloneSequence(val.get(), getCppuType(&val)), SAL_NO_ACQUIRE);
1072*cdf0e10cSrcweir     return seq;
1073*cdf0e10cSrcweir }
1074*cdf0e10cSrcweir 
1075*cdf0e10cSrcweir template< class T >
1076*cdf0e10cSrcweir inline bool makeSurrogate(
1077*cdf0e10cSrcweir     Reference< T > & rOut, Reference< T > const & rOriginal )
1078*cdf0e10cSrcweir {
1079*cdf0e10cSrcweir     rOut.clear();
1080*cdf0e10cSrcweir     if (! rOriginal.is())
1081*cdf0e10cSrcweir         return false;
1082*cdf0e10cSrcweir 
1083*cdf0e10cSrcweir     Environment aCppEnv_official;
1084*cdf0e10cSrcweir     Environment aUnoEnv_ano;
1085*cdf0e10cSrcweir     Environment aCppEnv_ano;
1086*cdf0e10cSrcweir 
1087*cdf0e10cSrcweir     OUString aCppEnvTypeName(
1088*cdf0e10cSrcweir         RTL_CONSTASCII_USTRINGPARAM(CPPU_CURRENT_LANGUAGE_BINDING_NAME) );
1089*cdf0e10cSrcweir     OUString aUnoEnvTypeName(
1090*cdf0e10cSrcweir         RTL_CONSTASCII_USTRINGPARAM(UNO_LB_UNO) );
1091*cdf0e10cSrcweir     // official:
1092*cdf0e10cSrcweir     uno_getEnvironment(
1093*cdf0e10cSrcweir         reinterpret_cast< uno_Environment ** >( &aCppEnv_official ),
1094*cdf0e10cSrcweir         aCppEnvTypeName.pData, 0 );
1095*cdf0e10cSrcweir     // anonymous:
1096*cdf0e10cSrcweir     uno_createEnvironment(
1097*cdf0e10cSrcweir         reinterpret_cast< uno_Environment ** >( &aCppEnv_ano ),
1098*cdf0e10cSrcweir         aCppEnvTypeName.pData, 0 );
1099*cdf0e10cSrcweir     uno_createEnvironment(
1100*cdf0e10cSrcweir         reinterpret_cast< uno_Environment ** >( &aUnoEnv_ano ),
1101*cdf0e10cSrcweir         aUnoEnvTypeName.pData, 0 );
1102*cdf0e10cSrcweir 
1103*cdf0e10cSrcweir     UnoInterfaceReference unoI;
1104*cdf0e10cSrcweir     Mapping cpp2uno( aCppEnv_official.get(), aUnoEnv_ano.get() );
1105*cdf0e10cSrcweir     Mapping uno2cpp( aUnoEnv_ano.get(), aCppEnv_ano.get() );
1106*cdf0e10cSrcweir     if (!cpp2uno.is() || !uno2cpp.is())
1107*cdf0e10cSrcweir     {
1108*cdf0e10cSrcweir         throw RuntimeException(
1109*cdf0e10cSrcweir             OUSTR("cannot get C++-UNO mappings!"),
1110*cdf0e10cSrcweir             Reference< XInterface >() );
1111*cdf0e10cSrcweir     }
1112*cdf0e10cSrcweir     cpp2uno.mapInterface(
1113*cdf0e10cSrcweir         reinterpret_cast< void ** >( &unoI.m_pUnoI ),
1114*cdf0e10cSrcweir         rOriginal.get(), ::getCppuType( &rOriginal ) );
1115*cdf0e10cSrcweir     if (! unoI.is())
1116*cdf0e10cSrcweir     {
1117*cdf0e10cSrcweir         throw RuntimeException(
1118*cdf0e10cSrcweir             OUSTR("mapping C++ to binary UNO failed!"),
1119*cdf0e10cSrcweir             Reference< XInterface >() );
1120*cdf0e10cSrcweir     }
1121*cdf0e10cSrcweir     uno2cpp.mapInterface(
1122*cdf0e10cSrcweir         reinterpret_cast< void ** >( &rOut ),
1123*cdf0e10cSrcweir         unoI.get(), ::getCppuType( &rOriginal ) );
1124*cdf0e10cSrcweir     if (! rOut.is())
1125*cdf0e10cSrcweir     {
1126*cdf0e10cSrcweir         throw RuntimeException(
1127*cdf0e10cSrcweir             OUSTR("mapping binary UNO to C++ failed!"),
1128*cdf0e10cSrcweir             Reference< XInterface >() );
1129*cdf0e10cSrcweir     }
1130*cdf0e10cSrcweir 
1131*cdf0e10cSrcweir 	return rOut.is();
1132*cdf0e10cSrcweir }
1133*cdf0e10cSrcweir 
1134*cdf0e10cSrcweir //==================================================================================================
1135*cdf0e10cSrcweir sal_Int32 TestBridgeImpl::run( const Sequence< OUString > & rArgs )
1136*cdf0e10cSrcweir 	throw (RuntimeException)
1137*cdf0e10cSrcweir {
1138*cdf0e10cSrcweir     bool bRet = false;
1139*cdf0e10cSrcweir     try
1140*cdf0e10cSrcweir     {
1141*cdf0e10cSrcweir         if (! rArgs.getLength())
1142*cdf0e10cSrcweir         {
1143*cdf0e10cSrcweir             throw RuntimeException( OUString( RTL_CONSTASCII_USTRINGPARAM(
1144*cdf0e10cSrcweir                                                   "no test object specified!\n"
1145*cdf0e10cSrcweir                                                   "usage : ServiceName of test object | -u unourl of test object\n" ) ),
1146*cdf0e10cSrcweir                                     Reference< XInterface >() );
1147*cdf0e10cSrcweir         }
1148*cdf0e10cSrcweir 
1149*cdf0e10cSrcweir         Reference< XInterface > xOriginal;
1150*cdf0e10cSrcweir         bool remote;
1151*cdf0e10cSrcweir         sal_Int32 i;
1152*cdf0e10cSrcweir         if( rArgs.getLength() > 1 && 0 == rArgs[0].compareToAscii( "-u" ) )
1153*cdf0e10cSrcweir         {
1154*cdf0e10cSrcweir             remote = true;
1155*cdf0e10cSrcweir             i = 2;
1156*cdf0e10cSrcweir         }
1157*cdf0e10cSrcweir         else
1158*cdf0e10cSrcweir         {
1159*cdf0e10cSrcweir             remote = false;
1160*cdf0e10cSrcweir             i = 1;
1161*cdf0e10cSrcweir         }
1162*cdf0e10cSrcweir         bool noCurrentContext = false;
1163*cdf0e10cSrcweir         if (i < rArgs.getLength()
1164*cdf0e10cSrcweir             && rArgs[i].equalsAsciiL(
1165*cdf0e10cSrcweir                 RTL_CONSTASCII_STRINGPARAM("noCurrentContext")))
1166*cdf0e10cSrcweir         {
1167*cdf0e10cSrcweir             noCurrentContext = true;
1168*cdf0e10cSrcweir             ++i;
1169*cdf0e10cSrcweir         }
1170*cdf0e10cSrcweir         bool stress = false;
1171*cdf0e10cSrcweir         if (i < rArgs.getLength()
1172*cdf0e10cSrcweir             && rArgs[i].equalsAsciiL(RTL_CONSTASCII_STRINGPARAM("stress")))
1173*cdf0e10cSrcweir         {
1174*cdf0e10cSrcweir             stress = true;
1175*cdf0e10cSrcweir             ++i;
1176*cdf0e10cSrcweir         }
1177*cdf0e10cSrcweir 
1178*cdf0e10cSrcweir         for (;;) {
1179*cdf0e10cSrcweir             Reference< XInterface > o;
1180*cdf0e10cSrcweir             if (remote) {
1181*cdf0e10cSrcweir                 o = UnoUrlResolver::create(m_xContext)->resolve(rArgs[1]);
1182*cdf0e10cSrcweir             } else {
1183*cdf0e10cSrcweir                 o = m_xContext->getServiceManager()->createInstanceWithContext(
1184*cdf0e10cSrcweir                     rArgs[0], m_xContext);
1185*cdf0e10cSrcweir             }
1186*cdf0e10cSrcweir             if (!stress) {
1187*cdf0e10cSrcweir                 xOriginal = o;
1188*cdf0e10cSrcweir                 break;
1189*cdf0e10cSrcweir             }
1190*cdf0e10cSrcweir         }
1191*cdf0e10cSrcweir 
1192*cdf0e10cSrcweir         if (! xOriginal.is())
1193*cdf0e10cSrcweir         {
1194*cdf0e10cSrcweir             throw RuntimeException(
1195*cdf0e10cSrcweir                 OUString( RTL_CONSTASCII_USTRINGPARAM(
1196*cdf0e10cSrcweir                               "cannot get test object!") ),
1197*cdf0e10cSrcweir                 Reference< XInterface >() );
1198*cdf0e10cSrcweir         }
1199*cdf0e10cSrcweir         Reference< XBridgeTest > xTest( xOriginal, UNO_QUERY );
1200*cdf0e10cSrcweir         if (! xTest.is())
1201*cdf0e10cSrcweir         {
1202*cdf0e10cSrcweir             throw RuntimeException(
1203*cdf0e10cSrcweir                 OUString( RTL_CONSTASCII_USTRINGPARAM("test object does not implement XBridgeTest!") ),
1204*cdf0e10cSrcweir                 Reference< XInterface >() );
1205*cdf0e10cSrcweir         }
1206*cdf0e10cSrcweir 
1207*cdf0e10cSrcweir         Reference<XBridgeTest > xLBT;
1208*cdf0e10cSrcweir         bRet = check( makeSurrogate( xLBT, xTest ), "makeSurrogate" );
1209*cdf0e10cSrcweir         bRet = check(
1210*cdf0e10cSrcweir             performTest( m_xContext, xLBT, noCurrentContext ), "standard test" )
1211*cdf0e10cSrcweir             && bRet;
1212*cdf0e10cSrcweir         bRet = check( raiseException( xLBT ) , "exception test" )&& bRet;
1213*cdf0e10cSrcweir         bRet = check( raiseOnewayException( xLBT ),
1214*cdf0e10cSrcweir                       "oneway exception test" ) && bRet;
1215*cdf0e10cSrcweir         if (! bRet)
1216*cdf0e10cSrcweir         {
1217*cdf0e10cSrcweir             throw RuntimeException(
1218*cdf0e10cSrcweir                 OUString( RTL_CONSTASCII_USTRINGPARAM("error: test failed!") ),
1219*cdf0e10cSrcweir                 Reference< XInterface >() );
1220*cdf0e10cSrcweir         }
1221*cdf0e10cSrcweir 	}
1222*cdf0e10cSrcweir     catch (Exception & exc)
1223*cdf0e10cSrcweir     {
1224*cdf0e10cSrcweir         OString cstr( OUStringToOString( exc.Message, RTL_TEXTENCODING_ASCII_US ) );
1225*cdf0e10cSrcweir         fprintf( stderr, "exception occured: %s\n", cstr.getStr() );
1226*cdf0e10cSrcweir         throw;
1227*cdf0e10cSrcweir     }
1228*cdf0e10cSrcweir 
1229*cdf0e10cSrcweir     if( bRet )
1230*cdf0e10cSrcweir     {
1231*cdf0e10cSrcweir         printf( "\n\n ### test succeeded!\n" );
1232*cdf0e10cSrcweir     }
1233*cdf0e10cSrcweir     else
1234*cdf0e10cSrcweir     {
1235*cdf0e10cSrcweir         printf( "\n> ### test failed!\n" );
1236*cdf0e10cSrcweir     }
1237*cdf0e10cSrcweir 
1238*cdf0e10cSrcweir 	return 0;
1239*cdf0e10cSrcweir }
1240*cdf0e10cSrcweir 
1241*cdf0e10cSrcweir // XServiceInfo
1242*cdf0e10cSrcweir //__________________________________________________________________________________________________
1243*cdf0e10cSrcweir OUString TestBridgeImpl::getImplementationName()
1244*cdf0e10cSrcweir 	throw (RuntimeException)
1245*cdf0e10cSrcweir {
1246*cdf0e10cSrcweir 	return OUString( RTL_CONSTASCII_USTRINGPARAM(IMPLNAME) );
1247*cdf0e10cSrcweir }
1248*cdf0e10cSrcweir //__________________________________________________________________________________________________
1249*cdf0e10cSrcweir sal_Bool TestBridgeImpl::supportsService( const OUString & rServiceName )
1250*cdf0e10cSrcweir 	throw (RuntimeException)
1251*cdf0e10cSrcweir {
1252*cdf0e10cSrcweir 	const Sequence< OUString > & rSNL = getSupportedServiceNames();
1253*cdf0e10cSrcweir 	const OUString * pArray = rSNL.getConstArray();
1254*cdf0e10cSrcweir 	for ( sal_Int32 nPos = rSNL.getLength(); nPos--; )
1255*cdf0e10cSrcweir 	{
1256*cdf0e10cSrcweir 		if (pArray[nPos] == rServiceName)
1257*cdf0e10cSrcweir 			return sal_True;
1258*cdf0e10cSrcweir 	}
1259*cdf0e10cSrcweir 	return sal_False;
1260*cdf0e10cSrcweir }
1261*cdf0e10cSrcweir //__________________________________________________________________________________________________
1262*cdf0e10cSrcweir Sequence< OUString > TestBridgeImpl::getSupportedServiceNames()
1263*cdf0e10cSrcweir 	throw (RuntimeException)
1264*cdf0e10cSrcweir {
1265*cdf0e10cSrcweir 	return bridge_test::getSupportedServiceNames();
1266*cdf0e10cSrcweir }
1267*cdf0e10cSrcweir 
1268*cdf0e10cSrcweir // ...
1269*cdf0e10cSrcweir 
1270*cdf0e10cSrcweir //==================================================================================================
1271*cdf0e10cSrcweir static Reference< XInterface > SAL_CALL TestBridgeImpl_create(
1272*cdf0e10cSrcweir 	const Reference< XComponentContext > & xContext )
1273*cdf0e10cSrcweir {
1274*cdf0e10cSrcweir 	return Reference< XInterface >(
1275*cdf0e10cSrcweir         static_cast< OWeakObject * >( new TestBridgeImpl( xContext ) ) );
1276*cdf0e10cSrcweir }
1277*cdf0e10cSrcweir 
1278*cdf0e10cSrcweir }
1279*cdf0e10cSrcweir 
1280*cdf0e10cSrcweir extern "C"
1281*cdf0e10cSrcweir {
1282*cdf0e10cSrcweir //==================================================================================================
1283*cdf0e10cSrcweir void SAL_CALL component_getImplementationEnvironment(
1284*cdf0e10cSrcweir 	const sal_Char ** ppEnvTypeName, uno_Environment ** )
1285*cdf0e10cSrcweir {
1286*cdf0e10cSrcweir 	*ppEnvTypeName = CPPU_CURRENT_LANGUAGE_BINDING_NAME;
1287*cdf0e10cSrcweir }
1288*cdf0e10cSrcweir //==================================================================================================
1289*cdf0e10cSrcweir void * SAL_CALL component_getFactory(
1290*cdf0e10cSrcweir 	const sal_Char * pImplName, void * pServiceManager, void * )
1291*cdf0e10cSrcweir {
1292*cdf0e10cSrcweir 	void * pRet = 0;
1293*cdf0e10cSrcweir 
1294*cdf0e10cSrcweir 	if (pServiceManager && rtl_str_compare( pImplName, IMPLNAME ) == 0)
1295*cdf0e10cSrcweir 	{
1296*cdf0e10cSrcweir 		Reference< XInterface > xFactory(
1297*cdf0e10cSrcweir             createSingleComponentFactory(
1298*cdf0e10cSrcweir                 bridge_test::TestBridgeImpl_create,
1299*cdf0e10cSrcweir                 OUString( RTL_CONSTASCII_USTRINGPARAM(IMPLNAME) ),
1300*cdf0e10cSrcweir                 bridge_test::getSupportedServiceNames() ) );
1301*cdf0e10cSrcweir 
1302*cdf0e10cSrcweir 		if (xFactory.is())
1303*cdf0e10cSrcweir 		{
1304*cdf0e10cSrcweir 			xFactory->acquire();
1305*cdf0e10cSrcweir 			pRet = xFactory.get();
1306*cdf0e10cSrcweir 		}
1307*cdf0e10cSrcweir 	}
1308*cdf0e10cSrcweir 
1309*cdf0e10cSrcweir 	return pRet;
1310*cdf0e10cSrcweir }
1311*cdf0e10cSrcweir }
1312