1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
3 * This file is part of the LibreOffice project.
5 * This Source Code Form is subject to the terms of the Mozilla Public
6 * License, v. 2.0. If a copy of the MPL was not distributed with this
7 * file, You can obtain one at http://mozilla.org/MPL/2.0/.
9 * This file incorporates work covered by the following license notice:
11 * Licensed to the Apache Software Foundation (ASF) under one or more
12 * contributor license agreements. See the NOTICE file distributed
13 * with this work for additional information regarding copyright
14 * ownership. The ASF licenses this file to you under the Apache
15 * License, Version 2.0 (the "License"); you may not use this file
16 * except in compliance with the License. You may obtain a copy of
17 * the License at http://www.apache.org/licenses/LICENSE-2.0 .
21 #include <sal/config.h>
24 #include <string_view>
26 #include <o3tl/any.hxx>
27 #include <o3tl/string_view.hxx>
28 #include <osl/diagnose.h>
29 #include <osl/diagnose.hxx>
30 #include <sal/types.h>
31 #include <typelib/typedescription.hxx>
32 #include <uno/dispatcher.hxx>
33 #include <uno/lbnames.h>
34 #include <uno/mapping.hxx>
36 #include <uno/environment.hxx>
38 #include <cppuhelper/factory.hxx>
39 #include <cppuhelper/implbase.hxx>
40 #include <cppuhelper/supportsservice.hxx>
42 #include <com/sun/star/lang/XServiceInfo.hpp>
43 #include <com/sun/star/lang/XMain.hpp>
44 #include <com/sun/star/lang/XSingleComponentFactory.hpp>
45 #include <com/sun/star/bridge/UnoUrlResolver.hpp>
46 #include <com/sun/star/bridge/XUnoUrlResolver.hpp>
47 #include <com/sun/star/uno/RuntimeException.hpp>
48 #include <com/sun/star/uno/Type.hxx>
50 #include <test/testtools/bridgetest/BadConstructorArguments.hpp>
51 #include <test/testtools/bridgetest/TestPolyStruct.hpp>
52 #include <test/testtools/bridgetest/XBridgeTest.hpp>
53 #include <test/testtools/bridgetest/XBridgeTest2.hpp>
55 #include "currentcontextchecker.hxx"
63 using namespace com::sun::star::uno
;
64 using namespace com::sun::star::lang
;
65 using namespace com::sun::star::registry
;
66 using namespace com::sun::star::bridge
;
67 using namespace test::testtools::bridgetest
;
70 constexpr OUStringLiteral SERVICENAME
= u
"com.sun.star.test.bridge.BridgeTest";
71 constexpr OUStringLiteral IMPLNAME
= u
"com.sun.star.comp.bridge.BridgeTest";
73 constexpr OUStringLiteral STRING_TEST_CONSTANT
= u
"\" paco\' chorizo\\\' \"\'";
77 template<typename T
, typename U
= T
>
78 static Sequence
<T
> cloneSequence(const Sequence
<T
>& val
);
81 static Sequence
< OUString
> getSupportedServiceNames()
83 return { SERVICENAME
};
86 static bool check( bool b
, char const * message
)
89 fprintf( stderr
, "%s failed\n" , message
);
95 bool checkEmpty(std::u16string_view string
, char const * message
) {
96 bool ok
= string
.empty();
99 stderr
, "%s failed: %s\n", message
,
100 OUStringToOString(string
, RTL_TEXTENCODING_UTF8
).getStr());
105 class TestBridgeImpl
: public osl::DebugBase
<TestBridgeImpl
>,
106 public WeakImplHelper
< XMain
, XServiceInfo
>
108 Reference
< XComponentContext
> m_xContext
;
111 explicit TestBridgeImpl( const Reference
< XComponentContext
> & xContext
)
112 : m_xContext( xContext
)
116 virtual OUString SAL_CALL
getImplementationName() override
;
117 virtual sal_Bool SAL_CALL
supportsService( const OUString
& rServiceName
) override
;
118 virtual Sequence
< OUString
> SAL_CALL
getSupportedServiceNames() override
;
121 virtual sal_Int32 SAL_CALL
run( const Sequence
< OUString
> & rArgs
) override
;
126 static bool equals( const TestElement
& rData1
, const TestElement
& rData2
)
128 check( rData1
.Bool
== rData2
.Bool
, "### bool does not match!" );
129 check( rData1
.Char
== rData2
.Char
, "### char does not match!" );
130 check( rData1
.Byte
== rData2
.Byte
, "### byte does not match!" );
131 check( rData1
.Short
== rData2
.Short
, "### short does not match!" );
132 check( rData1
.UShort
== rData2
.UShort
, "### unsigned short does not match!" );
133 check( rData1
.Long
== rData2
.Long
, "### long does not match!" );
134 check( rData1
.ULong
== rData2
.ULong
, "### unsigned long does not match!" );
135 check( rData1
.Hyper
== rData2
.Hyper
, "### hyper does not match!" );
136 check( rData1
.UHyper
== rData2
.UHyper
, "### unsigned hyper does not match!" );
137 check( rData1
.Float
== rData2
.Float
, "### float does not match!" );
138 check( rData1
.Double
== rData2
.Double
, "### double does not match!" );
139 check( rData1
.Enum
== rData2
.Enum
, "### enum does not match!" );
140 check( rData1
.String
== rData2
.String
, "### string does not match!" );
141 check( rData1
.Byte2
== rData2
.Byte2
, "### byte2 does not match!" );
142 check( rData1
.Short2
== rData2
.Short2
, "### short2 does not match!" );
143 check( rData1
.Interface
== rData2
.Interface
, "### interface does not match!" );
144 check( rData1
.Any
== rData2
.Any
, "### any does not match!" );
146 return (rData1
.Bool
== rData2
.Bool
&&
147 rData1
.Char
== rData2
.Char
&&
148 rData1
.Byte
== rData2
.Byte
&&
149 rData1
.Short
== rData2
.Short
&&
150 rData1
.UShort
== rData2
.UShort
&&
151 rData1
.Long
== rData2
.Long
&&
152 rData1
.ULong
== rData2
.ULong
&&
153 rData1
.Hyper
== rData2
.Hyper
&&
154 rData1
.UHyper
== rData2
.UHyper
&&
155 rData1
.Float
== rData2
.Float
&&
156 rData1
.Double
== rData2
.Double
&&
157 rData1
.Enum
== rData2
.Enum
&&
158 rData1
.String
== rData2
.String
&&
159 rData1
.Byte2
== rData2
.Byte2
&&
160 rData1
.Short2
== rData2
.Short2
&&
161 rData1
.Interface
== rData2
.Interface
&&
162 rData1
.Any
== rData2
.Any
);
165 static bool equals( const TestData
& rData1
, const TestData
& rData2
)
169 if (rData1
.Sequence
!= rData2
.Sequence
)
171 if (!equals( static_cast<const TestElement
&>(rData1
), static_cast<const TestElement
&>(rData2
) ))
173 nLen
= rData1
.Sequence
.getLength();
174 if (nLen
== rData2
.Sequence
.getLength())
176 // once again by hand sequence ==
177 const TestElement
* pElements1
= rData1
.Sequence
.getConstArray();
178 const TestElement
* pElements2
= rData2
.Sequence
.getConstArray();
181 if (! equals( pElements1
[nLen
], pElements2
[nLen
] ))
183 check( false, "### sequence element did not match!" );
192 static void assign( TestElement
& rData
,
193 bool bBool
, sal_Unicode cChar
, sal_Int8 nByte
,
194 sal_Int16 nShort
, sal_uInt16 nUShort
,
195 sal_Int32 nLong
, sal_uInt32 nULong
,
196 sal_Int64 nHyper
, sal_uInt64 nUHyper
,
197 float fFloat
, double fDouble
,
198 TestEnum eEnum
, const OUString
& rStr
,
199 sal_Int8 nByte2
, sal_Int16 nShort2
,
200 const css::uno::Reference
< css::uno::XInterface
>& xTest
,
201 const css::uno::Any
& rAny
)
206 rData
.Short
= nShort
;
207 rData
.UShort
= nUShort
;
209 rData
.ULong
= nULong
;
210 rData
.Hyper
= nHyper
;
211 rData
.UHyper
= nUHyper
;
212 rData
.Float
= fFloat
;
213 rData
.Double
= fDouble
;
216 rData
.Byte2
= nByte2
;
217 rData
.Short2
= nShort2
;
218 rData
.Interface
= xTest
;
224 template < typename T
>
226 T
const & value
, Reference
< XBridgeTest
> const & xLBT
,
227 char const * typeName
= nullptr)
231 Any any2
= xLBT
->transportAny(any
);
235 stderr
, "any is different after roundtrip: in %s, out %s\n",
237 any
.getValueType().getTypeName(),
238 RTL_TEXTENCODING_ASCII_US
).getStr(),
240 any2
.getValueType().getTypeName(),
241 RTL_TEXTENCODING_ASCII_US
).getStr());
244 if (typeName
!= nullptr
245 && !any2
.getValueType().getTypeName().equalsAscii(typeName
))
248 stderr
, "any has wrong type after roundtrip: %s instead of %s\n",
250 any2
.getValueType().getTypeName(),
251 RTL_TEXTENCODING_ASCII_US
).getStr(),
260 static bool performAnyTest( const Reference
< XBridgeTest
> &xLBT
, const TestData
&data
)
263 bReturn
= testAny( data
.Byte
,xLBT
) && bReturn
;
264 bReturn
= testAny( data
.Short
,xLBT
) && bReturn
;
265 bReturn
= testAny( data
.UShort
,xLBT
) && bReturn
;
266 bReturn
= testAny( data
.Long
,xLBT
) && bReturn
;
267 bReturn
= testAny( data
.ULong
,xLBT
) && bReturn
;
268 bReturn
= testAny( data
.Hyper
,xLBT
) && bReturn
;
269 bReturn
= testAny( data
.UHyper
,xLBT
) && bReturn
;
270 bReturn
= testAny( data
.Float
,xLBT
) && bReturn
;
271 bReturn
= testAny( data
.Double
,xLBT
) && bReturn
;
272 bReturn
= testAny( data
.Enum
,xLBT
) && bReturn
;
273 bReturn
= testAny( data
.String
,xLBT
) && bReturn
;
274 bReturn
= testAny( data
.Byte2
,xLBT
) && bReturn
;
275 bReturn
= testAny( data
.Short2
,xLBT
) && bReturn
;
276 bReturn
= testAny( data
.Interface
,xLBT
) && bReturn
;
277 bReturn
= testAny( data
, xLBT
) && bReturn
;
279 TestPolyStruct
< sal_Unicode
>(' '), xLBT
,
280 "test.testtools.bridgetest.TestPolyStruct<char>");
285 OSL_ASSERT( xLBT
->transportAny( a
) == a
);
290 OSL_ASSERT( xLBT
->transportAny( a
) == a
);
297 static bool performSequenceOfCallTest( const Reference
< XBridgeTest
> &xLBT
)
300 sal_Int32 nGlobalIndex
= 0;
301 const sal_Int32 nWaitTimeSpanMUSec
= 10000;
302 for( nRounds
= 0 ; nRounds
< 10 ; nRounds
++ )
304 for( i
= 0 ; i
< nRounds
; i
++ )
307 xLBT
->callOneway( nGlobalIndex
, nWaitTimeSpanMUSec
);
312 xLBT
->call( nGlobalIndex
, nWaitTimeSpanMUSec
);
316 return xLBT
->sequenceOfCallTestPassed();
321 class ORecursiveCall
: public WeakImplHelper
< XRecursiveCall
>
327 void SAL_CALL
callRecursivly(
328 const css::uno::Reference
< XRecursiveCall
>& xCall
,
329 sal_Int32 nToCall
) override
331 MutexGuard
guard( m_mutex
);
335 xCall
->callRecursivly( this , nToCall
);
343 static bool performRecursiveCallTest( const Reference
< XBridgeTest
> & xLBT
)
345 xLBT
->startRecursiveCall( new ORecursiveCall
, 50 );
346 // on failure, the test would lock up or crash
352 class MyClass
: public osl::DebugBase
<MyClass
>, public OWeakObject
364 static bool performTest(
365 const Reference
<XComponentContext
> & xContext
,
366 const Reference
<XBridgeTest
> & xLBT
,
367 bool noCurrentContext
)
369 check(xLBT
.is(), "### no test interface!");
372 // this data is never ever granted access to by calls other than
373 // equals(), assign()!
374 TestData aData
; // test against this data
375 Reference
< XInterface
> xI(new MyClass
);
377 static_cast<TestElement
&>(aData
), true, '@', 17, 0x1234, 0xFEDC,
378 0x12345678, 0xFEDCBA98, SAL_CONST_INT64(0x123456789ABCDEF0),
379 SAL_CONST_UINT64(0xFEDCBA9876543210), 17.0815f
, M_PI
,
380 TestEnum_LOLA
, STRING_TEST_CONSTANT
, 18, 0x5678, xI
,
381 Any(&xI
, cppu::UnoType
<XInterface
>::get()));
382 bRet
&= check(aData
.Any
== xI
, "### unexpected any!");
383 bRet
&= check(!(aData
.Any
!= xI
), "### unexpected any!");
384 aData
.Sequence
.realloc(2);
385 aData
.Sequence
.getArray()[0] = *static_cast<TestElement
const *>(&aData
);
386 // aData.Sequence[1] is empty
387 // aSetData is a manually copy of aData for first setting:
390 static_cast<TestElement
&>(aSetData
), aData
.Bool
, aData
.Char
,
391 aData
.Byte
, aData
.Short
, aData
.UShort
, aData
.Long
, aData
.ULong
,
392 aData
.Hyper
, aData
.UHyper
, aData
.Float
, aData
.Double
, aData
.Enum
,
393 aData
.String
, aData
.Byte2
, aData
.Short2
, xI
, Any(&xI
, cppu::UnoType
<XInterface
>::get()));
394 aSetData
.Sequence
.realloc(2);
395 aSetData
.Sequence
.getArray()[0] = *static_cast<TestElement
const *>(&aSetData
);
396 // aSetData.Sequence[1] is empty
441 equals(aData
, aRet
) && equals(aData
, aRet2
), "getValues test");
442 // Set last retrieved values:
464 // Check inout sequence order (=> inout sequence parameter was
465 // switched by test objects):
466 auto pRetSequence
= aRet
.Sequence
.getArray();
467 std::swap(pRetSequence
[0], pRetSequence
[1]);
469 equals(aData
, aSV2ret
) && equals(aData
, aRet2
),
473 TwoFloats
aIn(1.1f
, 2.2f
);
474 TwoFloats aOut
= xLBT
->echoTwoFloats(aIn
);
475 bRet
= check( memcmp(&aIn
, &aOut
, sizeof(TwoFloats
)) == 0, "two floats struct test" ) && bRet
;
478 FourFloats
aIn(3.3f
, 4.4f
, 5.5f
, 6.6f
);
479 FourFloats aOut
= xLBT
->echoFourFloats(aIn
);
480 bRet
= check( memcmp(&aIn
, &aOut
, sizeof(FourFloats
)) == 0, "four floats struct test" ) && bRet
;
483 MixedFloatAndInteger
aIn(7.7f
, 8);
484 MixedFloatAndInteger aOut
= xLBT
->echoMixedFloatAndInteger(aIn
);
485 bRet
= check( memcmp(&aIn
, &aOut
, sizeof(MixedFloatAndInteger
)) == 0, "mixed float and integer struct test" ) && bRet
;
488 DoubleHyper
in(10.0, 11);
489 DoubleHyper out
= xLBT
->echoDoubleHyper(in
);
490 bRet
&= check(out
.a
== in
.a
, "double and hyper struct test: double")
491 && check(out
.b
== in
.b
, "double and hyper struct test: hyper");
494 HyperDouble
in(12, 13.0);
495 HyperDouble out
= xLBT
->echoHyperDouble(in
);
496 bRet
&= check(out
.a
== in
.a
, "hyper and double struct test: hyper")
497 && check(out
.b
== in
.b
, "hyper and double struct test: double");
500 FloatFloatLongByte
in(20.0f
, 21.0f
, 22, '3');
501 FloatFloatLongByte out
= xLBT
->echoFloatFloatLongByte(in
);
502 bRet
&= check(out
.a
== in
.a
, "double and hyper struct test: first float")
503 && check(out
.b
== in
.b
, "double and hyper struct test: second float")
504 && check(out
.c
== in
.c
, "double and hyper struct test: long")
505 && check(out
.d
== in
.d
, "double and hyper struct test: byte");
508 ThreeByteStruct
aIn(9, 10, 11);
509 ThreeByteStruct aOut
= xLBT
->echoThreeByteStruct(aIn
);
510 bRet
= check( memcmp(&aIn
, &aOut
, sizeof(ThreeByteStruct
)) == 0, "three byte struct test" ) && bRet
;
537 (equals(aData
, aRet
) && equals(aData
, aRet2
) &&
538 equals(aData
, aGVret
)),
540 // Set last retrieved values:
541 xLBT
->setBool(aRet
.Bool
);
542 xLBT
->setChar(aRet
.Char
);
543 xLBT
->setByte(aRet
.Byte
);
544 xLBT
->setShort(aRet
.Short
);
545 xLBT
->setUShort(aRet
.UShort
);
546 xLBT
->setLong(aRet
.Long
);
547 xLBT
->setULong(aRet
.ULong
);
548 xLBT
->setHyper(aRet
.Hyper
);
549 xLBT
->setUHyper(aRet
.UHyper
);
550 xLBT
->setFloat(aRet
.Float
);
551 xLBT
->setDouble(aRet
.Double
);
552 xLBT
->setEnum(aRet
.Enum
);
553 xLBT
->setString(aRet
.String
);
554 xLBT
->setByte2(aRet
.Byte2
);
555 xLBT
->setShort2(aRet
.Short2
);
556 xLBT
->setInterface(aRet
.Interface
);
557 xLBT
->setAny(aRet
.Any
);
558 xLBT
->setSequence(aRet
.Sequence
);
559 xLBT
->setStruct(aRet2
);
563 aRet
.Hyper
= xLBT
->getHyper();
564 aRet
.UHyper
= xLBT
->getUHyper();
565 aRet
.Float
= xLBT
->getFloat();
566 aRet
.Double
= xLBT
->getDouble();
567 aRet
.Byte
= xLBT
->getByte();
568 aRet
.Char
= xLBT
->getChar();
569 aRet
.Bool
= xLBT
->getBool();
570 aRet
.Short
= xLBT
->getShort();
571 aRet
.UShort
= xLBT
->getUShort();
572 aRet
.Long
= xLBT
->getLong();
573 aRet
.ULong
= xLBT
->getULong();
574 aRet
.Enum
= xLBT
->getEnum();
575 aRet
.String
= xLBT
->getString();
576 aRet
.Byte2
= xLBT
->getByte2();
577 aRet
.Short2
= xLBT
->getShort2();
578 aRet
.Interface
= xLBT
->getInterface();
579 aRet
.Any
= xLBT
->getAny();
580 aRet
.Sequence
= xLBT
->getSequence();
581 TestData
aRet2(xLBT
->getStruct());
583 equals(aData
, aRet
) && equals(aData
, aRet2
),
584 "struct comparison test");
586 SmallStruct
aIn(1, 2);
587 SmallStruct
aOut(xLBT
->echoSmallStruct(aIn
));
589 memcmp(&aIn
, &aOut
, sizeof(SmallStruct
)) == 0,
590 "small struct test");
593 MediumStruct
aIn(1, 2, 3, 4);
594 MediumStruct
aOut(xLBT
->echoMediumStruct(aIn
));
596 memcmp(&aIn
, &aOut
, sizeof(MediumStruct
)) == 0,
597 "medium struct test");
600 BigStruct
aIn(1, 2, 3, 4, 5, 6, 7, 8);
601 BigStruct
aOut(xLBT
->echoBigStruct(aIn
));
603 memcmp(&aIn
, &aOut
, sizeof(BigStruct
)) == 0,
607 sal_Int32 i2
= xLBT
->testPPCAlignment(0, 0, 0, 0, 0xBEAF);
608 bRet
&= check(i2
== 0xBEAF, "ppc-style alignment test");
611 sal_Int32 i1
= xLBT
->testPPC64Alignment(1.0, 2.0, 3.0, 0xBEAF);
612 bRet
&= check(i1
== 0xBEAF, "ppc64-style alignment test");
615 double d1
= xLBT
->testTenDoubles(0.1, 0.2, 0.3, 0.4, 0.5,
616 0.6, 0.7, 0.8, 0.9, 1.0);
617 bRet
&= check(d1
== 5.5, "armhf doubles test");
619 // Test extended attributes that raise exceptions:
621 xLBT
->getRaiseAttr1();
622 bRet
&= check(false, "getRaiseAttr1 did not throw");
623 } catch (const RuntimeException
&) {
625 bRet
&= check(false, "getRaiseAttr1 threw wrong type");
628 xLBT
->setRaiseAttr1(0);
629 bRet
&= check(false, "setRaiseAttr1 did not throw");
630 } catch (const IllegalArgumentException
&) {
632 bRet
&= check(false, "setRaiseAttr1 threw wrong type");
635 xLBT
->getRaiseAttr2();
636 bRet
&= check(false, "getRaiseAttr2 did not throw");
637 } catch (const IllegalArgumentException
&) {
639 bRet
&= check(false, "getRaiseAttr2 threw wrong type");
641 // Test instantiated polymorphic struct types:
644 (xLBT
->transportPolyBoolean(
645 TestPolyStruct
< sal_Bool
>(true)).
647 "transportPolyBoolean");
648 TestPolyStruct
< sal_Int64
> tps1(12345);
649 xLBT
->transportPolyHyper(tps1
);
650 bRet
&= check(tps1
.member
== 12345, "transportPolyHyper");
651 Sequence
< Any
> seq
{ Any(static_cast< sal_uInt32
>(33)), Any(OUString("ABC")) };
652 TestPolyStruct
< Sequence
< Any
> > tps2(seq
);
653 TestPolyStruct
< Sequence
< Any
> > tps3
;
654 xLBT
->transportPolySequence(tps2
, tps3
);
656 tps3
.member
.getLength() == 2,
657 "transportPolySequence, length");
658 sal_uInt32 v0
= sal_uInt32();
659 tps3
.member
[0] >>= v0
;
660 bRet
&= check(v0
== 33, "transportPolySequence, element 0");
662 tps3
.member
[1] >>= v1
;
663 bRet
&= check( v1
== "ABC", "transportPolySequence, element 1" );
665 xLBT
->getNullPolyLong().member
== 0, "getNullPolyLong");
667 xLBT
->getNullPolyString().member
.isEmpty(),
668 "getNullPolyString");
670 xLBT
->getNullPolyType().member
== Type(),
672 Any
nullAny(xLBT
->getNullPolyAny().member
);
673 auto ifc
= o3tl::tryAccess
<Reference
<XInterface
>>(nullAny
);
675 !nullAny
.hasValue() || (ifc
&& !ifc
->is()),
678 !xLBT
->getNullPolySequence().member
.hasElements(),
679 "getNullPolySequence");
681 xLBT
->getNullPolyEnum().member
== TestEnum_TEST
,
684 xLBT
->getNullPolyBadEnum().member
== TestBadEnum_M
,
685 "getNullPolyBadEnum");
687 xLBT
->getNullPolyStruct().member
.member
== 0,
688 "getNullPolyStruct");
690 !xLBT
->getNullPolyInterface().member
.is(),
691 "getNullPolyInterface");
694 bRet
&= check(performAnyTest(xLBT
, aData
), "any test");
695 // Sequence of call test:
697 performSequenceOfCallTest(xLBT
), "sequence of call test");
698 // Recursive call test:
699 bRet
&= check(performRecursiveCallTest(xLBT
), "recursive test");
701 equals(aData
, aRet
) && equals(aData
, aRet2
),
702 "recursive test results");
703 // Multiple inheritance test:
705 testtools::bridgetest::testMulti(xLBT
->getMulti()),
708 xLBT
->testMulti(new testtools::bridgetest::Multi
),
713 Reference
< XBridgeTest2
> xBT2(xLBT
, UNO_QUERY
);
717 // Perform sequence tests (XBridgeTest2); create the sequence which is
718 // compared with the results:
719 sal_Int32 _arLong
[] = {
720 static_cast< sal_Int32
>(0x80000000), 1, 0x7FFFFFFF };
721 sal_Int32 _aInt
= 0xBABEBABE;
722 float _aFloat
= 3.14f
;
724 Any
_any2(&_aInt
, cppu::UnoType
<sal_Int32
>::get());
725 Any
_any3(&_aFloat
, cppu::UnoType
<float>::get());
726 Any _arAny
[] = { _any1
, _any2
, _any3
};
727 Reference
< XInterface
> _arObj
[3];
728 _arObj
[0] = new OWeakObject();
729 _arObj
[1] = new OWeakObject();
730 _arObj
[2] = new OWeakObject();
731 TestElement _arStruct
[3];
733 _arStruct
[0], true, '@', 17, 0x1234, 0xFEDC, 0x12345678, 0xFEDCBA98,
734 SAL_CONST_INT64(0x123456789ABCDEF0),
735 SAL_CONST_UINT64(0xFEDCBA9876543210), 17.0815f
, M_PI
,
736 TestEnum_LOLA
, STRING_TEST_CONSTANT
, 18, 0x5678, _arObj
[0],
737 Any(&_arObj
[0], cppu::UnoType
<XInterface
>::get()));
739 _arStruct
[1], true, 'A', 17, 0x1234, 0xFEDC, 0x12345678, 0xFEDCBA98,
740 SAL_CONST_INT64(0x123456789ABCDEF0),
741 SAL_CONST_UINT64(0xFEDCBA9876543210), 17.0815f
, M_PI
,
742 TestEnum_TWO
, STRING_TEST_CONSTANT
, 18, 0x5678, _arObj
[1],
743 Any(&_arObj
[1], cppu::UnoType
<XInterface
>::get()));
745 _arStruct
[2], true, 'B', 17, 0x1234, 0xFEDC, 0x12345678, 0xFEDCBA98,
746 SAL_CONST_INT64(0x123456789ABCDEF0),
747 SAL_CONST_UINT64(0xFEDCBA9876543210), 17.0815f
, M_PI
,
748 TestEnum_CHECK
, STRING_TEST_CONSTANT
, 18, 0x5678, _arObj
[2],
749 Any(&_arObj
[2], cppu::UnoType
<XInterface
>::get()));
751 Sequence
<sal_Bool
> arBool({true, false, true});
752 Sequence
<sal_Unicode
> arChar({0x0065, 0x0066, 0x0067});
753 Sequence
<sal_Int8
> arByte({1, 2, -1});
754 Sequence
<sal_Int16
> arShort({-0x8000, 1, 0x7FFF});
755 Sequence
<sal_uInt16
> arUShort({0 , 1, 0xFFFF});
756 Sequence
<sal_Int32
> arLong(_arLong
, 3);
757 Sequence
<sal_uInt32
> arULong({0, 1, 0xFFFFFFFF});
758 Sequence
<sal_Int64
> arHyper({
759 static_cast<sal_Int64
>(SAL_CONST_INT64(0x8000000000000000)), 1,
760 SAL_CONST_INT64(0x7FFFFFFFFFFFFFFF)});
761 Sequence
<sal_uInt64
> arUHyper({
762 0, 1, SAL_CONST_UINT64(0xFFFFFFFFFFFFFFFF)});
763 Sequence
<float> arFloat({1.1f
, 2.2f
, 3.3f
});
764 Sequence
<double> arDouble({1.11, 2.22, 3.33});
765 Sequence
<OUString
> arString({
766 OUString("String 1"), OUString("String 2"),
767 OUString("String 3")});
768 Sequence
<Any
> arAny(_arAny
, 3);
769 Sequence
<Reference
<XInterface
> > arObject(_arObj
, 3);
770 Sequence
<TestEnum
> arEnum({
771 TestEnum_ONE
, TestEnum_TWO
, TestEnum_CHECK
});
772 Sequence
<TestElement
> arStruct(_arStruct
, 3);
773 Sequence
<Sequence
<sal_Int32
> > _arSeqLong2
[3];
774 for (int j
= 0; j
!= 3; ++j
) {
775 Sequence
< sal_Int32
> _arSeqLong
[3];
776 for (int i
= 0; i
!= 3; ++i
) {
777 // coverity[overrun-buffer-arg : FALSE] - coverity has difficulty with css::uno::Sequence
778 _arSeqLong
[i
] = Sequence
< sal_Int32
>(_arLong
, 3);
780 _arSeqLong2
[j
] = Sequence
< Sequence
< sal_Int32
> >(
783 Sequence
< Sequence
< Sequence
< sal_Int32
> > > arLong3(
785 Sequence
< Sequence
< sal_Int32
> > seqSeqRet(
786 xBT2
->setDim2(arLong3
[0]));
787 bRet
&= check(seqSeqRet
== arLong3
[0], "sequence test");
788 Sequence
< Sequence
< Sequence
< sal_Int32
> > > seqSeqRet2(
789 xBT2
->setDim3(arLong3
));
790 bRet
&= check(seqSeqRet2
== arLong3
, "sequence test");
791 Sequence
< Any
> seqAnyRet(xBT2
->setSequenceAny(arAny
));
792 bRet
&= check(seqAnyRet
== arAny
, "sequence test");
793 Sequence
< sal_Bool
> seqBoolRet(xBT2
->setSequenceBool(arBool
));
794 bRet
&= check(seqBoolRet
== arBool
, "sequence test");
795 Sequence
< sal_Int8
> seqByteRet(xBT2
->setSequenceByte(arByte
));
796 bRet
&= check(seqByteRet
== arByte
, "sequence test");
797 Sequence
< sal_Unicode
> seqCharRet(xBT2
->setSequenceChar(arChar
));
798 bRet
&= check(seqCharRet
== arChar
, "sequence test");
799 Sequence
< sal_Int16
> seqShortRet(xBT2
->setSequenceShort(arShort
));
800 bRet
&= check(seqShortRet
== arShort
, "sequence test");
801 Sequence
< sal_Int32
> seqLongRet(xBT2
->setSequenceLong(arLong
));
802 bRet
&= check(seqLongRet
== arLong
, "sequence test");
803 Sequence
< sal_Int64
> seqHyperRet(xBT2
->setSequenceHyper(arHyper
));
804 bRet
&= check(seqHyperRet
== arHyper
, "sequence test");
805 Sequence
< float > seqFloatRet(xBT2
->setSequenceFloat(arFloat
));
806 bRet
&= check(seqFloatRet
== arFloat
, "sequence test");
807 Sequence
< double > seqDoubleRet(xBT2
->setSequenceDouble(arDouble
));
808 bRet
&= check(seqDoubleRet
== arDouble
, "sequence test");
809 Sequence
< TestEnum
> seqEnumRet(xBT2
->setSequenceEnum(arEnum
));
810 bRet
&= check(seqEnumRet
== arEnum
, "sequence test");
811 Sequence
< sal_uInt16
> seqUShortRet(
812 xBT2
->setSequenceUShort(arUShort
));
813 bRet
&= check(seqUShortRet
== arUShort
, "sequence test");
814 Sequence
< sal_uInt32
> seqULongRet(xBT2
->setSequenceULong(arULong
));
815 bRet
&= check(seqULongRet
== arULong
, "sequence test");
816 Sequence
< sal_uInt64
> seqUHyperRet(
817 xBT2
->setSequenceUHyper(arUHyper
));
818 bRet
&= check(seqUHyperRet
== arUHyper
, "sequence test");
819 Sequence
< Reference
< XInterface
> > seqObjectRet(
820 xBT2
->setSequenceXInterface(arObject
));
821 bRet
&= check(seqObjectRet
== arObject
, "sequence test");
822 Sequence
< OUString
> seqStringRet(
823 xBT2
->setSequenceString(arString
));
824 bRet
&= check(seqStringRet
== arString
, "sequence test");
825 Sequence
< TestElement
> seqStructRet(
826 xBT2
->setSequenceStruct(arStruct
));
827 bRet
&= check(seqStructRet
== arStruct
, "sequence test");
828 Sequence
< sal_Bool
> arBoolTemp(cloneSequence(arBool
));
829 Sequence
< sal_Unicode
> arCharTemp(cloneSequence
<sal_Unicode
, cppu::UnoCharType
>(arChar
));
830 Sequence
< sal_Int8
> arByteTemp(cloneSequence(arByte
));
831 Sequence
< sal_Int16
> arShortTemp(cloneSequence(arShort
));
832 Sequence
< sal_uInt16
> arUShortTemp(cloneSequence
<sal_uInt16
, cppu::UnoUnsignedShortType
>(arUShort
));
833 Sequence
< sal_Int32
> arLongTemp(cloneSequence(arLong
));
834 Sequence
< sal_uInt32
> arULongTemp(cloneSequence(arULong
));
835 Sequence
< sal_Int64
> arHyperTemp(cloneSequence(arHyper
));
836 Sequence
< sal_uInt64
> arUHyperTemp(cloneSequence(arUHyper
));
837 Sequence
< float > arFloatTemp(cloneSequence(arFloat
));
838 Sequence
< double > arDoubleTemp(cloneSequence(arDouble
));
839 Sequence
< TestEnum
> arEnumTemp(cloneSequence(arEnum
));
840 Sequence
< OUString
> arStringTemp(cloneSequence(arString
));
841 Sequence
< Reference
< XInterface
> > arObjectTemp(
842 cloneSequence(arObject
));
843 Sequence
< Any
> arAnyTemp(cloneSequence(arAny
));
844 Sequence
< Sequence
< sal_Int32
> > arLong2Temp(arLong3
[0]);
845 Sequence
< Sequence
< Sequence
< sal_Int32
> > > arLong3Temp(arLong3
);
846 xBT2
->setSequencesInOut(
847 arBoolTemp
, arCharTemp
, arByteTemp
, arShortTemp
, arUShortTemp
,
848 arLongTemp
,arULongTemp
, arHyperTemp
, arUHyperTemp
, arFloatTemp
,
849 arDoubleTemp
, arEnumTemp
, arStringTemp
, arObjectTemp
, arAnyTemp
,
850 arLong2Temp
, arLong3Temp
);
852 (arBoolTemp
== arBool
&& arCharTemp
== arChar
&&
853 arByteTemp
== arByte
&& arShortTemp
== arShort
&&
854 arUShortTemp
== arUShort
&& arLongTemp
== arLong
&&
855 arULongTemp
== arULong
&& arHyperTemp
== arHyper
&&
856 arUHyperTemp
== arUHyper
&& arFloatTemp
== arFloat
&&
857 arDoubleTemp
== arDouble
&& arEnumTemp
== arEnum
&&
858 arStringTemp
== arString
&& arObjectTemp
== arObject
&&
859 arAnyTemp
== arAny
&& arLong2Temp
== arLong3
[0] &&
860 arLong3Temp
== arLong3
),
862 Sequence
< sal_Bool
> arBoolOut
;
863 Sequence
< sal_Unicode
> arCharOut
;
864 Sequence
< sal_Int8
> arByteOut
;
865 Sequence
< sal_Int16
> arShortOut
;
866 Sequence
< sal_uInt16
> arUShortOut
;
867 Sequence
< sal_Int32
> arLongOut
;
868 Sequence
< sal_uInt32
> arULongOut
;
869 Sequence
< sal_Int64
> arHyperOut
;
870 Sequence
< sal_uInt64
> arUHyperOut
;
871 Sequence
< float > arFloatOut
;
872 Sequence
< double > arDoubleOut
;
873 Sequence
< TestEnum
> arEnumOut
;
874 Sequence
< OUString
> arStringOut
;
875 Sequence
< Reference
< XInterface
> > arObjectOut
;
876 Sequence
< Any
> arAnyOut
;
877 Sequence
< Sequence
< sal_Int32
> > arLong2Out
;
878 Sequence
< Sequence
< Sequence
< sal_Int32
> > > arLong3Out
;
879 xBT2
->setSequencesOut(
880 arBoolOut
, arCharOut
, arByteOut
, arShortOut
, arUShortOut
,
881 arLongOut
,arULongOut
, arHyperOut
, arUHyperOut
, arFloatOut
,
882 arDoubleOut
, arEnumOut
, arStringOut
, arObjectOut
, arAnyOut
,
883 arLong2Out
, arLong3Out
);
885 (arBoolOut
== arBool
&& arCharOut
== arChar
&&
886 arByteOut
== arByte
&& arShortOut
== arShort
&&
887 arUShortOut
== arUShort
&& arLongOut
== arLong
&&
888 arULongOut
== arULong
&& arHyperOut
== arHyper
&&
889 arUHyperOut
== arUHyper
&& arFloatOut
== arFloat
&&
890 arDoubleOut
== arDouble
&& arEnumOut
== arEnum
&&
891 arStringOut
== arString
&& arObjectOut
== arObject
&&
892 arAnyOut
== arAny
&& arLong2Out
== arLong3
[0] &&
893 arLong3Out
== arLong3
),
897 // Test with empty sequences:
898 Sequence
< Sequence
< sal_Int32
> > arLong2
;
899 Sequence
< Sequence
< sal_Int32
> > seqSeqRet(xBT2
->setDim2(arLong2
));
900 bRet
&= check(seqSeqRet
== arLong2
, "sequence test");
901 Sequence
< Sequence
< Sequence
< sal_Int32
> > > arLong3
;
902 Sequence
< Sequence
< Sequence
< sal_Int32
> > > seqSeqRet2(
903 xBT2
->setDim3(arLong3
));
904 bRet
&= check(seqSeqRet2
== arLong3
, "sequence test");
905 Sequence
< Any
> arAny
;
906 Sequence
< Any
> seqAnyRet(xBT2
->setSequenceAny(arAny
));
907 bRet
&= check(seqAnyRet
== arAny
, "sequence test");
908 Sequence
< sal_Bool
> arBool
;
909 Sequence
< sal_Bool
> seqBoolRet(xBT2
->setSequenceBool(arBool
));
910 bRet
&= check(seqBoolRet
== arBool
, "sequence test");
911 Sequence
< sal_Int8
> arByte
;
912 Sequence
< sal_Int8
> seqByteRet(xBT2
->setSequenceByte(arByte
));
913 bRet
&= check(seqByteRet
== arByte
, "sequence test");
914 Sequence
< sal_Unicode
> arChar
;
915 Sequence
< sal_Unicode
> seqCharRet(xBT2
->setSequenceChar(arChar
));
916 bRet
&= check(seqCharRet
== arChar
, "sequence test");
917 Sequence
< sal_Int16
> arShort
;
918 Sequence
< sal_Int16
> seqShortRet(xBT2
->setSequenceShort(arShort
));
919 bRet
&= check(seqShortRet
== arShort
, "sequence test");
920 Sequence
< sal_Int32
> arLong
;
921 Sequence
< sal_Int32
> seqLongRet(xBT2
->setSequenceLong(arLong
));
922 bRet
&= check(seqLongRet
== arLong
, "sequence test");
923 Sequence
< sal_Int64
> arHyper
;
924 Sequence
< sal_Int64
> seqHyperRet(xBT2
->setSequenceHyper(arHyper
));
925 bRet
&= check(seqHyperRet
== arHyper
, "sequence test");
926 Sequence
< float > arFloat
;
927 Sequence
< float > seqFloatRet(xBT2
->setSequenceFloat(arFloat
));
928 bRet
&= check(seqFloatRet
== arFloat
, "sequence test");
929 Sequence
< double > arDouble
;
930 Sequence
< double > seqDoubleRet(xBT2
->setSequenceDouble(arDouble
));
931 bRet
&= check(seqDoubleRet
== arDouble
, "sequence test");
932 Sequence
< TestEnum
> arEnum
;
933 Sequence
< TestEnum
> seqEnumRet(xBT2
->setSequenceEnum(arEnum
));
934 bRet
&= check(seqEnumRet
== arEnum
, "sequence test");
935 Sequence
< sal_uInt16
> arUShort
;
936 Sequence
< sal_uInt16
> seqUShortRet(
937 xBT2
->setSequenceUShort(arUShort
));
938 bRet
&= check(seqUShortRet
== arUShort
, "sequence test");
939 Sequence
< sal_uInt32
> arULong
;
940 Sequence
< sal_uInt32
> seqULongRet(xBT2
->setSequenceULong(arULong
));
941 bRet
&= check(seqULongRet
== arULong
, "sequence test");
942 Sequence
< sal_uInt64
> arUHyper
;
943 Sequence
< sal_uInt64
> seqUHyperRet(
944 xBT2
->setSequenceUHyper(arUHyper
));
945 bRet
&= check(seqUHyperRet
== arUHyper
, "sequence test");
946 Sequence
< Reference
< XInterface
> > arObject
;
947 Sequence
< Reference
< XInterface
> > seqObjectRet(
948 xBT2
->setSequenceXInterface(arObject
));
949 bRet
&= check(seqObjectRet
== arObject
, "sequence test");
950 Sequence
< OUString
> arString
;
951 Sequence
< OUString
> seqStringRet(
952 xBT2
->setSequenceString(arString
));
953 bRet
&= check(seqStringRet
== arString
, "sequence test");
954 Sequence
< TestElement
> arStruct
;
955 Sequence
< TestElement
> seqStructRet(
956 xBT2
->setSequenceStruct(arStruct
));
957 bRet
&= check(seqStructRet
== arStruct
, "sequence test");
959 // Issue #i60341# shows that the most interesting case is were Java
960 // calls the constructors; however, since this client is currently not
961 // available in Java, while the server is, the logic is reversed here:
963 xBT2
->testConstructorsService(xContext
);
964 } catch (const BadConstructorArguments
&) {
967 if (!noCurrentContext
) {
968 if (!(new testtools::bridgetest::CurrentContextChecker
)->perform(
969 xBT2
->getCurrentContextChecker(), 0, 1))
973 if (!(new testtools::bridgetest::CurrentContextChecker
)->perform(
974 xBT2
->getCurrentContextChecker(), 0, 2))
978 if (!(new testtools::bridgetest::CurrentContextChecker
)->perform(
979 xBT2
->getCurrentContextChecker(), 1, 2))
983 if (!(new testtools::bridgetest::CurrentContextChecker
)->perform(
984 xBT2
->getCurrentContextChecker(), 1, 3))
993 static bool raiseOnewayException( const Reference
< XBridgeTest
> & xLBT
)
996 Reference
<XInterface
> const x(xLBT
->getInterface());
999 // Note : the exception may fly or not (e.g. remote scenario).
1000 // When it flies, it must contain the correct elements.
1001 xLBT
->raiseRuntimeExceptionOneway( STRING_TEST_CONSTANT
, x
);
1003 catch( const RuntimeException
& e
)
1006 #if OSL_DEBUG_LEVEL == 0
1007 // java stack traces trash Message
1008 e
.Message
== STRING_TEST_CONSTANT
&&
1010 xLBT
->getInterface() == e
.Context
&&
1017 static bool raiseException( const Reference
< XBridgeTest
> & xLBT
)
1019 sal_Int32 nCount
= 0;
1026 xLBT
->raiseException(
1027 5, STRING_TEST_CONSTANT
,
1028 xLBT
->getInterface() );
1030 catch (const IllegalArgumentException
&rExc
)
1032 if (rExc
.ArgumentPosition
== 5 &&
1033 #if OSL_DEBUG_LEVEL == 0
1034 // java stack traces trash Message
1035 rExc
.Message
.startsWith(STRING_TEST_CONSTANT
) &&
1037 rExc
.Context
== xLBT
->getInterface())
1040 //When we check if a new compiler still works then we must not call
1041 //getRuntimeException because it uses cppu::getCaughtException which
1042 //does only work if all libs are build with the same runtime.
1050 check( false, "### unexpected exception content!" );
1053 /** it is certain, that the RuntimeException testing will fail, if no */
1054 xLBT
->getRuntimeException();
1057 catch (const RuntimeException
& rExc
)
1059 if (rExc
.Context
== xLBT
->getInterface()
1060 #if OSL_DEBUG_LEVEL == 0
1061 // java stack traces trash Message
1062 && rExc
.Message
.startsWith(STRING_TEST_CONSTANT
)
1070 check( false, "### unexpected exception content!" );
1073 /** it is certain, that the RuntimeException testing will fail, if no */
1074 xLBT
->setRuntimeException( 0xcafebabe );
1077 catch (const Exception
& rExc
)
1079 if (rExc
.Context
== xLBT
->getInterface()
1080 #if OSL_DEBUG_LEVEL == 0
1081 // java stack traces trash Message
1082 && rExc
.Message
.startsWith(STRING_TEST_CONSTANT
)
1090 check( false, "### unexpected exception content!" );
1092 return (nCount
== 3);
1097 /* Returns an acquired sequence
1099 static uno_Sequence
* cloneSequence(const uno_Sequence
* val
, const Type
& type
)
1101 TypeDescription
td(type
);
1103 typelib_TypeDescription
* pTdRaw
= td
.get();
1104 typelib_IndirectTypeDescription
* pIndirectTd
=
1105 reinterpret_cast<typelib_IndirectTypeDescription
*>(pTdRaw
);
1107 typelib_TypeDescription
* pTdElem
= pIndirectTd
->pType
->pType
;
1108 std::unique_ptr
<sal_Int8
[]> buf(new sal_Int8
[pTdElem
->nSize
* val
->nElements
]);
1109 sal_Int8
* pBufCur
= buf
.get();
1111 uno_Sequence
* retSeq
= nullptr;
1112 switch (static_cast<TypeClass
>(pTdElem
->eTypeClass
))
1114 case TypeClass_SEQUENCE
:
1116 Type
_tElem(pTdElem
->pWeakRef
);
1117 for (int i
= 0; i
< val
->nElements
; i
++)
1119 sal_Int8
const *pValBuf
= reinterpret_cast<sal_Int8
const *>(&val
->elements
+ i
* pTdElem
->nSize
);
1121 uno_Sequence
* seq
= cloneSequence(
1122 reinterpret_cast<uno_Sequence
const *>(pValBuf
),
1124 *reinterpret_cast<uno_Sequence
**>(pBufCur
) = seq
;
1125 pBufCur
+= pTdElem
->nSize
;
1130 uno_type_sequence_construct(
1131 &retSeq
, type
.getTypeLibType(), const_cast<char *>(val
->elements
),
1132 val
->nElements
, reinterpret_cast< uno_AcquireFunc
>(cpp_acquire
));
1138 template<typename T
, typename U
>
1139 Sequence
<T
> cloneSequence(const Sequence
<T
>& val
)
1141 Sequence
<T
> seq( cloneSequence(val
.get(), cppu::UnoType
<cppu::UnoSequenceType
<U
>>::get()), SAL_NO_ACQUIRE
);
1146 static bool makeSurrogate(
1147 Reference
< T
> & rOut
, Reference
< T
> const & rOriginal
)
1150 if (! rOriginal
.is())
1153 Environment aCppEnv_official
;
1154 Environment aUnoEnv_ano
;
1155 Environment aCppEnv_ano
;
1157 OUString
aCppEnvTypeName(
1158 CPPU_CURRENT_LANGUAGE_BINDING_NAME
);
1159 OUString
aUnoEnvTypeName(
1163 reinterpret_cast< uno_Environment
** >( &aCppEnv_official
),
1164 aCppEnvTypeName
.pData
, nullptr );
1166 uno_createEnvironment(
1167 reinterpret_cast< uno_Environment
** >( &aCppEnv_ano
),
1168 aCppEnvTypeName
.pData
, nullptr );
1169 uno_createEnvironment(
1170 reinterpret_cast< uno_Environment
** >( &aUnoEnv_ano
),
1171 aUnoEnvTypeName
.pData
, nullptr );
1173 UnoInterfaceReference unoI
;
1174 Mapping
cpp2uno( aCppEnv_official
.get(), aUnoEnv_ano
.get() );
1175 Mapping
uno2cpp( aUnoEnv_ano
.get(), aCppEnv_ano
.get() );
1176 if (!cpp2uno
.is() || !uno2cpp
.is())
1178 throw RuntimeException("cannot get C++-UNO mappings!" );
1180 cpp2uno
.mapInterface(
1181 reinterpret_cast< void ** >( &unoI
.m_pUnoI
),
1182 rOriginal
.get(), cppu::UnoType
<decltype(rOriginal
)>::get() );
1185 throw RuntimeException(
1186 "mapping C++ to binary UNO failed!" );
1188 uno2cpp
.mapInterface(
1189 reinterpret_cast< void ** >( &rOut
),
1190 unoI
.get(), cppu::UnoType
<decltype(rOriginal
)>::get() );
1193 throw RuntimeException(
1194 "mapping binary UNO to C++ failed!" );
1201 sal_Int32
TestBridgeImpl::run( const Sequence
< OUString
> & rArgs
)
1206 if (! rArgs
.hasElements())
1208 throw RuntimeException( "no test object specified!\n"
1209 "usage : ServiceName of test object | -u unourl of test object" );
1212 Reference
< XInterface
> xOriginal
;
1215 if( rArgs
.getLength() > 1 && rArgs
[0] == "-u" )
1225 bool noCurrentContext
= false;
1226 if ( i
< rArgs
.getLength() && rArgs
[i
] == "noCurrentContext" )
1228 noCurrentContext
= true;
1231 bool stress
= false;
1232 if ( i
< rArgs
.getLength() && rArgs
[i
] == "stress" )
1239 Reference
< XInterface
> o
;
1241 o
= UnoUrlResolver::create(m_xContext
)->resolve(rArgs
[1]);
1243 o
= m_xContext
->getServiceManager()->createInstanceWithContext(
1244 rArgs
[0], m_xContext
);
1252 if (! xOriginal
.is())
1254 throw RuntimeException( "cannot get test object!" );
1256 Reference
< XBridgeTest
> xTest( xOriginal
, UNO_QUERY_THROW
);
1258 Reference
<XBridgeTest
> xLBT
;
1259 bRet
= check( makeSurrogate( xLBT
, xTest
), "makeSurrogate" );
1261 performTest( m_xContext
, xLBT
, noCurrentContext
), "standard test" )
1263 bRet
= check( raiseException( xLBT
) , "exception test" )&& bRet
;
1264 bRet
= check( raiseOnewayException( xLBT
),
1265 "oneway exception test" ) && bRet
;
1268 throw RuntimeException( "error: test failed!" );
1271 catch (const Exception
& exc
)
1273 OString
cstr( OUStringToOString( exc
.Message
, RTL_TEXTENCODING_ASCII_US
) );
1274 fprintf( stderr
, "exception occurred: %s\n", cstr
.getStr() );
1278 return bRet
? 0 : 1;
1283 OUString
TestBridgeImpl::getImplementationName()
1288 sal_Bool
TestBridgeImpl::supportsService( const OUString
& rServiceName
)
1290 return cppu::supportsService(this, rServiceName
);
1293 Sequence
< OUString
> TestBridgeImpl::getSupportedServiceNames()
1295 return bridge_test::getSupportedServiceNames();
1299 static Reference
< XInterface
> TestBridgeImpl_create(
1300 const Reference
< XComponentContext
> & xContext
)
1302 return Reference
< XInterface
>(
1303 static_cast< OWeakObject
* >( new TestBridgeImpl( xContext
) ) );
1311 SAL_DLLPUBLIC_EXPORT
void * component_getFactory(
1312 const char * pImplName
, void * pServiceManager
,
1313 SAL_UNUSED_PARAMETER
void * )
1315 void * pRet
= nullptr;
1317 if (pServiceManager
&& o3tl::equalsAscii(IMPLNAME
, pImplName
))
1319 Reference
< XInterface
> xFactory(
1320 createSingleComponentFactory(
1321 bridge_test::TestBridgeImpl_create
,
1323 bridge_test::getSupportedServiceNames() ) );
1327 xFactory
->acquire();
1328 pRet
= xFactory
.get();
1336 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */