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