summaryrefslogtreecommitdiffstats
path: root/testtools/source/bridgetest
diff options
context:
space:
mode:
authorDaniel Baumann <daniel.baumann@progress-linux.org>2024-04-07 09:06:44 +0000
committerDaniel Baumann <daniel.baumann@progress-linux.org>2024-04-07 09:06:44 +0000
commited5640d8b587fbcfed7dd7967f3de04b37a76f26 (patch)
tree7a5f7c6c9d02226d7471cb3cc8fbbf631b415303 /testtools/source/bridgetest
parentInitial commit. (diff)
downloadlibreoffice-upstream.tar.xz
libreoffice-upstream.zip
Adding upstream version 4:7.4.7.upstream/4%7.4.7upstream
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to '')
-rw-r--r--testtools/source/bridgetest/bridgetest.component25
-rw-r--r--testtools/source/bridgetest/bridgetest.cxx1336
-rw-r--r--testtools/source/bridgetest/cli/cli_bridgetest_inprocess.cs251
-rw-r--r--testtools/source/bridgetest/cli/cli_bridgetest_inprocess.ini3
-rw-r--r--testtools/source/bridgetest/cli/cli_cpp_bridgetest.cxx928
-rw-r--r--testtools/source/bridgetest/cli/cli_cs_bridgetest.cs1100
-rw-r--r--testtools/source/bridgetest/cli/cli_cs_multi.cs110
-rw-r--r--testtools/source/bridgetest/cli/cli_cs_testobj.cs955
-rw-r--r--testtools/source/bridgetest/cli/cli_vb_bridgetest.vb916
-rw-r--r--testtools/source/bridgetest/cli/cli_vb_testobj.vb615
-rw-r--r--testtools/source/bridgetest/constructors.component28
-rw-r--r--testtools/source/bridgetest/constructors.cxx452
-rw-r--r--testtools/source/bridgetest/cppobj.component25
-rw-r--r--testtools/source/bridgetest/cppobj.cxx1220
-rw-r--r--testtools/source/bridgetest/currentcontextchecker.cxx106
-rw-r--r--testtools/source/bridgetest/currentcontextchecker.hxx61
-rw-r--r--testtools/source/bridgetest/dllapi.hxx25
-rw-r--r--testtools/source/bridgetest/idl/bridgetest.idl654
-rw-r--r--testtools/source/bridgetest/idl/com/sun/star/test/performance/XPerformanceTest.idl130
-rw-r--r--testtools/source/bridgetest/multi.cxx224
-rw-r--r--testtools/source/bridgetest/multi.hxx103
-rw-r--r--testtools/source/bridgetest/pyuno/core.py358
-rw-r--r--testtools/source/bridgetest/pyuno/impl.py187
-rw-r--r--testtools/source/bridgetest/pyuno/importer.py69
-rw-r--r--testtools/source/bridgetest/pyuno/main.py40
-rw-r--r--testtools/source/bridgetest/pyuno/makefile.mk117
-rw-r--r--testtools/source/bridgetest/pyuno/pyuno2
-rw-r--r--testtools/source/bridgetest/pyuno/samplecomponent.py189
-rw-r--r--testtools/source/bridgetest/pyuno/testcomp.py31
-rw-r--r--testtools/source/bridgetest/testComponent.component29
30 files changed, 10289 insertions, 0 deletions
diff --git a/testtools/source/bridgetest/bridgetest.component b/testtools/source/bridgetest/bridgetest.component
new file mode 100644
index 000000000..ecbd2e333
--- /dev/null
+++ b/testtools/source/bridgetest/bridgetest.component
@@ -0,0 +1,25 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+ * This file is part of the LibreOffice project.
+ *
+ * This Source Code Form is subject to the terms of the Mozilla Public
+ * License, v. 2.0. If a copy of the MPL was not distributed with this
+ * file, You can obtain one at http://mozilla.org/MPL/2.0/.
+ *
+ * This file incorporates work covered by the following license notice:
+ *
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed
+ * with this work for additional information regarding copyright
+ * ownership. The ASF licenses this file to you under the Apache
+ * License, Version 2.0 (the "License"); you may not use this file
+ * except in compliance with the License. You may obtain a copy of
+ * the License at http://www.apache.org/licenses/LICENSE-2.0 .
+ -->
+
+<component loader="com.sun.star.loader.SharedLibrary" environment="@CPPU_ENV@"
+ xmlns="http://openoffice.org/2010/uno-components">
+ <implementation name="com.sun.star.comp.bridge.BridgeTest">
+ <service name="com.sun.star.test.bridge.BridgeTest"/>
+ </implementation>
+</component>
diff --git a/testtools/source/bridgetest/bridgetest.cxx b/testtools/source/bridgetest/bridgetest.cxx
new file mode 100644
index 000000000..78bcdc6f0
--- /dev/null
+++ b/testtools/source/bridgetest/bridgetest.cxx
@@ -0,0 +1,1336 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*
+ * This file is part of the LibreOffice project.
+ *
+ * This Source Code Form is subject to the terms of the Mozilla Public
+ * License, v. 2.0. If a copy of the MPL was not distributed with this
+ * file, You can obtain one at http://mozilla.org/MPL/2.0/.
+ *
+ * This file incorporates work covered by the following license notice:
+ *
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed
+ * with this work for additional information regarding copyright
+ * ownership. The ASF licenses this file to you under the Apache
+ * License, Version 2.0 (the "License"); you may not use this file
+ * except in compliance with the License. You may obtain a copy of
+ * the License at http://www.apache.org/licenses/LICENSE-2.0 .
+ */
+
+
+#include <sal/config.h>
+#include <stdio.h>
+#include <string.h>
+#include <string_view>
+
+#include <o3tl/any.hxx>
+#include <o3tl/string_view.hxx>
+#include <osl/diagnose.h>
+#include <osl/diagnose.hxx>
+#include <sal/types.h>
+#include <typelib/typedescription.hxx>
+#include <uno/dispatcher.hxx>
+#include <uno/lbnames.h>
+#include <uno/mapping.hxx>
+#include <uno/data.h>
+#include <uno/environment.hxx>
+
+#include <cppuhelper/factory.hxx>
+#include <cppuhelper/implbase.hxx>
+#include <cppuhelper/supportsservice.hxx>
+
+#include <com/sun/star/lang/XServiceInfo.hpp>
+#include <com/sun/star/lang/XMain.hpp>
+#include <com/sun/star/lang/XSingleComponentFactory.hpp>
+#include <com/sun/star/bridge/UnoUrlResolver.hpp>
+#include <com/sun/star/bridge/XUnoUrlResolver.hpp>
+#include <com/sun/star/uno/RuntimeException.hpp>
+#include <com/sun/star/uno/Type.hxx>
+
+#include <test/testtools/bridgetest/BadConstructorArguments.hpp>
+#include <test/testtools/bridgetest/TestPolyStruct.hpp>
+#include <test/testtools/bridgetest/XBridgeTest.hpp>
+#include <test/testtools/bridgetest/XBridgeTest2.hpp>
+
+#include "currentcontextchecker.hxx"
+#include "multi.hxx"
+#include <memory>
+#include <utility>
+#include <cmath>
+
+using namespace osl;
+using namespace cppu;
+using namespace com::sun::star::uno;
+using namespace com::sun::star::lang;
+using namespace com::sun::star::registry;
+using namespace com::sun::star::bridge;
+using namespace test::testtools::bridgetest;
+
+
+constexpr OUStringLiteral SERVICENAME = u"com.sun.star.test.bridge.BridgeTest";
+constexpr OUStringLiteral IMPLNAME = u"com.sun.star.comp.bridge.BridgeTest";
+
+constexpr OUStringLiteral STRING_TEST_CONSTANT = u"\" paco\' chorizo\\\' \"\'";
+
+namespace bridge_test
+{
+template<typename T, typename U = T>
+static Sequence<T> cloneSequence(const Sequence<T>& val);
+
+
+static Sequence< OUString > getSupportedServiceNames()
+{
+ return { SERVICENAME };
+}
+
+static bool check( bool b , char const * message )
+{
+ if ( ! b )
+ fprintf( stderr, "%s failed\n" , message );
+ return b;
+}
+
+namespace {
+
+bool checkEmpty(std::u16string_view string, char const * message) {
+ bool ok = string.empty();
+ if (!ok) {
+ fprintf(
+ stderr, "%s failed: %s\n", message,
+ OUStringToOString(string, RTL_TEXTENCODING_UTF8).getStr());
+ }
+ return ok;
+}
+
+class TestBridgeImpl : public osl::DebugBase<TestBridgeImpl>,
+ public WeakImplHelper< XMain, XServiceInfo >
+{
+ Reference< XComponentContext > m_xContext;
+
+public:
+ explicit TestBridgeImpl( const Reference< XComponentContext > & xContext )
+ : m_xContext( xContext )
+ {}
+
+ // XServiceInfo
+ virtual OUString SAL_CALL getImplementationName() override;
+ virtual sal_Bool SAL_CALL supportsService( const OUString & rServiceName ) override;
+ virtual Sequence< OUString > SAL_CALL getSupportedServiceNames() override;
+
+ // XMain
+ virtual sal_Int32 SAL_CALL run( const Sequence< OUString > & rArgs ) override;
+};
+
+}
+
+static bool equals( const TestElement & rData1, const TestElement & rData2 )
+{
+ check( rData1.Bool == rData2.Bool, "### bool does not match!" );
+ check( rData1.Char == rData2.Char, "### char does not match!" );
+ check( rData1.Byte == rData2.Byte, "### byte does not match!" );
+ check( rData1.Short == rData2.Short, "### short does not match!" );
+ check( rData1.UShort == rData2.UShort, "### unsigned short does not match!" );
+ check( rData1.Long == rData2.Long, "### long does not match!" );
+ check( rData1.ULong == rData2.ULong, "### unsigned long does not match!" );
+ check( rData1.Hyper == rData2.Hyper, "### hyper does not match!" );
+ check( rData1.UHyper == rData2.UHyper, "### unsigned hyper does not match!" );
+ check( rData1.Float == rData2.Float, "### float does not match!" );
+ check( rData1.Double == rData2.Double, "### double does not match!" );
+ check( rData1.Enum == rData2.Enum, "### enum does not match!" );
+ check( rData1.String == rData2.String, "### string does not match!" );
+ check( rData1.Byte2 == rData2.Byte2, "### byte2 does not match!" );
+ check( rData1.Short2 == rData2.Short2, "### short2 does not match!" );
+ check( rData1.Interface == rData2.Interface, "### interface does not match!" );
+ check( rData1.Any == rData2.Any, "### any does not match!" );
+
+ return (rData1.Bool == rData2.Bool &&
+ rData1.Char == rData2.Char &&
+ rData1.Byte == rData2.Byte &&
+ rData1.Short == rData2.Short &&
+ rData1.UShort == rData2.UShort &&
+ rData1.Long == rData2.Long &&
+ rData1.ULong == rData2.ULong &&
+ rData1.Hyper == rData2.Hyper &&
+ rData1.UHyper == rData2.UHyper &&
+ rData1.Float == rData2.Float &&
+ rData1.Double == rData2.Double &&
+ rData1.Enum == rData2.Enum &&
+ rData1.String == rData2.String &&
+ rData1.Byte2 == rData2.Byte2 &&
+ rData1.Short2 == rData2.Short2 &&
+ rData1.Interface == rData2.Interface &&
+ rData1.Any == rData2.Any);
+}
+
+static bool equals( const TestData & rData1, const TestData & rData2 )
+{
+ sal_Int32 nLen;
+
+ if (rData1.Sequence != rData2.Sequence)
+ return false;
+ if (!equals( static_cast<const TestElement &>(rData1), static_cast<const TestElement &>(rData2) ))
+ return false;
+ nLen = rData1.Sequence.getLength();
+ if (nLen == rData2.Sequence.getLength())
+ {
+ // once again by hand sequence ==
+ const TestElement * pElements1 = rData1.Sequence.getConstArray();
+ const TestElement * pElements2 = rData2.Sequence.getConstArray();
+ for ( ; nLen--; )
+ {
+ if (! equals( pElements1[nLen], pElements2[nLen] ))
+ {
+ check( false, "### sequence element did not match!" );
+ return false;
+ }
+ }
+ return true;
+ }
+ return false;
+}
+
+static void assign( TestElement & rData,
+ bool bBool, sal_Unicode cChar, sal_Int8 nByte,
+ sal_Int16 nShort, sal_uInt16 nUShort,
+ sal_Int32 nLong, sal_uInt32 nULong,
+ sal_Int64 nHyper, sal_uInt64 nUHyper,
+ float fFloat, double fDouble,
+ TestEnum eEnum, const OUString& rStr,
+ sal_Int8 nByte2, sal_Int16 nShort2,
+ const css::uno::Reference< css::uno::XInterface >& xTest,
+ const css::uno::Any& rAny )
+{
+ rData.Bool = bBool;
+ rData.Char = cChar;
+ rData.Byte = nByte;
+ rData.Short = nShort;
+ rData.UShort = nUShort;
+ rData.Long = nLong;
+ rData.ULong = nULong;
+ rData.Hyper = nHyper;
+ rData.UHyper = nUHyper;
+ rData.Float = fFloat;
+ rData.Double = fDouble;
+ rData.Enum = eEnum;
+ rData.String = rStr;
+ rData.Byte2 = nByte2;
+ rData.Short2 = nShort2;
+ rData.Interface = xTest;
+ rData.Any = rAny;
+}
+
+namespace {
+
+template < typename T >
+bool testAny(
+ T const & value, Reference< XBridgeTest > const & xLBT,
+ char const * typeName = nullptr)
+{
+ Any any;
+ any <<= value;
+ Any any2 = xLBT->transportAny(any);
+ bool success = true;
+ if (any != any2) {
+ fprintf(
+ stderr, "any is different after roundtrip: in %s, out %s\n",
+ OUStringToOString(
+ any.getValueType().getTypeName(),
+ RTL_TEXTENCODING_ASCII_US).getStr(),
+ OUStringToOString(
+ any2.getValueType().getTypeName(),
+ RTL_TEXTENCODING_ASCII_US).getStr());
+ success = false;
+ }
+ if (typeName != nullptr
+ && !any2.getValueType().getTypeName().equalsAscii(typeName))
+ {
+ fprintf(
+ stderr, "any has wrong type after roundtrip: %s instead of %s\n",
+ OUStringToOString(
+ any2.getValueType().getTypeName(),
+ RTL_TEXTENCODING_ASCII_US).getStr(),
+ typeName);
+ success = false;
+ }
+ return success;
+}
+
+}
+
+static bool performAnyTest( const Reference< XBridgeTest > &xLBT, const TestData &data)
+{
+ bool bReturn = true;
+ bReturn = testAny( data.Byte ,xLBT ) && bReturn;
+ bReturn = testAny( data.Short,xLBT ) && bReturn;
+ bReturn = testAny( data.UShort,xLBT ) && bReturn;
+ bReturn = testAny( data.Long,xLBT ) && bReturn;
+ bReturn = testAny( data.ULong,xLBT ) && bReturn;
+ bReturn = testAny( data.Hyper,xLBT ) && bReturn;
+ bReturn = testAny( data.UHyper,xLBT ) && bReturn;
+ bReturn = testAny( data.Float,xLBT ) && bReturn;
+ bReturn = testAny( data.Double,xLBT ) && bReturn;
+ bReturn = testAny( data.Enum,xLBT ) && bReturn;
+ bReturn = testAny( data.String,xLBT ) && bReturn;
+ bReturn = testAny( data.Byte2 ,xLBT ) && bReturn;
+ bReturn = testAny( data.Short2,xLBT ) && bReturn;
+ bReturn = testAny( data.Interface,xLBT ) && bReturn;
+ bReturn = testAny( data, xLBT ) && bReturn;
+ bReturn &= testAny(
+ TestPolyStruct< sal_Unicode >(' '), xLBT,
+ "test.testtools.bridgetest.TestPolyStruct<char>");
+
+ Any a;
+ {
+ a <<= data.Bool;
+ OSL_ASSERT( xLBT->transportAny( a ) == a );
+ }
+
+ {
+ a <<= data.Char;
+ OSL_ASSERT( xLBT->transportAny( a ) == a );
+ }
+
+ return bReturn;
+}
+
+
+static bool performSequenceOfCallTest( const Reference < XBridgeTest > &xLBT )
+{
+ sal_Int32 i,nRounds;
+ sal_Int32 nGlobalIndex = 0;
+ const sal_Int32 nWaitTimeSpanMUSec = 10000;
+ for( nRounds = 0 ; nRounds < 10 ; nRounds ++ )
+ {
+ for( i = 0 ; i < nRounds ; i ++ )
+ {
+ // fire oneways
+ xLBT->callOneway( nGlobalIndex , nWaitTimeSpanMUSec );
+ nGlobalIndex ++;
+ }
+
+ // call synchron
+ xLBT->call( nGlobalIndex , nWaitTimeSpanMUSec );
+ nGlobalIndex ++;
+ }
+
+ return xLBT->sequenceOfCallTestPassed();
+}
+
+namespace {
+
+class ORecursiveCall : public WeakImplHelper< XRecursiveCall >
+{
+private:
+ Mutex m_mutex;
+
+public:
+ void SAL_CALL callRecursivly(
+ const css::uno::Reference< XRecursiveCall >& xCall,
+ sal_Int32 nToCall ) override
+ {
+ MutexGuard guard( m_mutex );
+ if( nToCall )
+ {
+ nToCall --;
+ xCall->callRecursivly( this , nToCall );
+ }
+
+ }
+};
+
+}
+
+static bool performRecursiveCallTest( const Reference < XBridgeTest > & xLBT )
+{
+ xLBT->startRecursiveCall( new ORecursiveCall , 50 );
+ // on failure, the test would lock up or crash
+ return true;
+}
+
+namespace {
+
+class MyClass : public osl::DebugBase<MyClass>, public OWeakObject
+{
+public:
+ MyClass();
+};
+
+}
+
+MyClass::MyClass()
+{
+}
+
+static bool performTest(
+ const Reference<XComponentContext> & xContext,
+ const Reference<XBridgeTest > & xLBT,
+ bool noCurrentContext )
+{
+ check(xLBT.is(), "### no test interface!");
+ bool bRet = true;
+ if (xLBT.is()) {
+ // this data is never ever granted access to by calls other than
+ // equals(), assign()!
+ TestData aData; // test against this data
+ Reference< XInterface > xI(new MyClass);
+ assign(
+ static_cast<TestElement &>(aData), true, '@', 17, 0x1234, 0xFEDC,
+ 0x12345678, 0xFEDCBA98, SAL_CONST_INT64(0x123456789ABCDEF0),
+ SAL_CONST_UINT64(0xFEDCBA9876543210), 17.0815f, M_PI,
+ TestEnum_LOLA, STRING_TEST_CONSTANT, 18, 0x5678, xI,
+ Any(&xI, cppu::UnoType<XInterface>::get()));
+ bRet &= check(aData.Any == xI, "### unexpected any!");
+ bRet &= check(!(aData.Any != xI), "### unexpected any!");
+ aData.Sequence.realloc(2);
+ aData.Sequence.getArray()[0] = *static_cast<TestElement const *>(&aData);
+ // aData.Sequence[1] is empty
+ // aSetData is a manually copy of aData for first setting:
+ TestData aSetData;
+ assign(
+ static_cast<TestElement &>(aSetData), aData.Bool, aData.Char,
+ aData.Byte, aData.Short, aData.UShort, aData.Long, aData.ULong,
+ aData.Hyper, aData.UHyper, aData.Float, aData.Double, aData.Enum,
+ aData.String, aData.Byte2, aData.Short2, xI, Any(&xI, cppu::UnoType<XInterface>::get()));
+ aSetData.Sequence.realloc(2);
+ aSetData.Sequence.getArray()[0] = *static_cast<TestElement const *>(&aSetData);
+ // aSetData.Sequence[1] is empty
+ xLBT->setValues(
+ aSetData.Bool,
+ aSetData.Char,
+ aSetData.Byte,
+ aSetData.Short,
+ aSetData.UShort,
+ aSetData.Long,
+ aSetData.ULong,
+ aSetData.Hyper,
+ aSetData.UHyper,
+ aSetData.Float,
+ aSetData.Double,
+ aSetData.Enum,
+ aSetData.String,
+ aSetData.Byte2,
+ aSetData.Short2,
+ aSetData.Interface,
+ aSetData.Any,
+ aSetData.Sequence,
+ aSetData);
+ {
+ TestData aRet;
+ TestData aRet2;
+ xLBT->getValues(
+ aRet.Bool,
+ aRet.Char,
+ aRet.Byte,
+ aRet.Short,
+ aRet.UShort,
+ aRet.Long,
+ aRet.ULong,
+ aRet.Hyper,
+ aRet.UHyper,
+ aRet.Float,
+ aRet.Double,
+ aRet.Enum,
+ aRet.String,
+ aRet.Byte2,
+ aRet.Short2,
+ aRet.Interface,
+ aRet.Any,
+ aRet.Sequence,
+ aRet2);
+ bRet &= check(
+ equals(aData, aRet) && equals(aData, aRet2), "getValues test");
+ // Set last retrieved values:
+ TestData aSV2ret(
+ xLBT->setValues2(
+ aRet.Bool,
+ aRet.Char,
+ aRet.Byte,
+ aRet.Short,
+ aRet.UShort,
+ aRet.Long,
+ aRet.ULong,
+ aRet.Hyper,
+ aRet.UHyper,
+ aRet.Float,
+ aRet.Double,
+ aRet.Enum,
+ aRet.String,
+ aRet.Byte2,
+ aRet.Short2,
+ aRet.Interface,
+ aRet.Any,
+ aRet.Sequence,
+ aRet2));
+ // Check inout sequence order (=> inout sequence parameter was
+ // switched by test objects):
+ auto pRetSequence = aRet.Sequence.getArray();
+ std::swap(pRetSequence[0], pRetSequence[1]);
+ bRet &= check(
+ equals(aData, aSV2ret) && equals(aData, aRet2),
+ "getValues2 test");
+ }
+ {
+ TwoFloats aIn(1.1f, 2.2f);
+ TwoFloats aOut = xLBT->echoTwoFloats(aIn);
+ bRet = check( memcmp(&aIn, &aOut, sizeof(TwoFloats)) == 0, "two floats struct test" ) && bRet;
+ }
+ {
+ FourFloats aIn(3.3f, 4.4f, 5.5f, 6.6f);
+ FourFloats aOut = xLBT->echoFourFloats(aIn);
+ bRet = check( memcmp(&aIn, &aOut, sizeof(FourFloats)) == 0, "four floats struct test" ) && bRet;
+ }
+ {
+ MixedFloatAndInteger aIn(7.7f, 8);
+ MixedFloatAndInteger aOut = xLBT->echoMixedFloatAndInteger(aIn);
+ bRet = check( memcmp(&aIn, &aOut, sizeof(MixedFloatAndInteger)) == 0, "mixed float and integer struct test" ) && bRet;
+ }
+ {
+ DoubleHyper in(10.0, 11);
+ DoubleHyper out = xLBT->echoDoubleHyper(in);
+ bRet &= check(out.a == in.a, "double and hyper struct test: double")
+ && check(out.b == in.b, "double and hyper struct test: hyper");
+ }
+ {
+ HyperDouble in(12, 13.0);
+ HyperDouble out = xLBT->echoHyperDouble(in);
+ bRet &= check(out.a == in.a, "hyper and double struct test: hyper")
+ && check(out.b == in.b, "hyper and double struct test: double");
+ }
+ {
+ FloatFloatLongByte in(20.0f, 21.0f, 22, '3');
+ FloatFloatLongByte out = xLBT->echoFloatFloatLongByte(in);
+ bRet &= check(out.a == in.a, "double and hyper struct test: first float")
+ && check(out.b == in.b, "double and hyper struct test: second float")
+ && check(out.c == in.c, "double and hyper struct test: long")
+ && check(out.d == in.d, "double and hyper struct test: byte");
+ }
+ {
+ ThreeByteStruct aIn(9, 10, 11);
+ ThreeByteStruct aOut = xLBT->echoThreeByteStruct(aIn);
+ bRet = check( memcmp(&aIn, &aOut, sizeof(ThreeByteStruct)) == 0, "three byte struct test" ) && bRet;
+ }
+ {
+ TestData aRet;
+ TestData aRet2;
+ TestData aGVret(
+ xLBT->getValues(
+ aRet.Bool,
+ aRet.Char,
+ aRet.Byte,
+ aRet.Short,
+ aRet.UShort,
+ aRet.Long,
+ aRet.ULong,
+ aRet.Hyper,
+ aRet.UHyper,
+ aRet.Float,
+ aRet.Double,
+ aRet.Enum,
+ aRet.String,
+ aRet.Byte2,
+ aRet.Short2,
+ aRet.Interface,
+ aRet.Any,
+ aRet.Sequence,
+ aRet2));
+ bRet &= check(
+ (equals(aData, aRet) && equals(aData, aRet2) &&
+ equals(aData, aGVret)),
+ "getValues test");
+ // Set last retrieved values:
+ xLBT->setBool(aRet.Bool);
+ xLBT->setChar(aRet.Char);
+ xLBT->setByte(aRet.Byte);
+ xLBT->setShort(aRet.Short);
+ xLBT->setUShort(aRet.UShort);
+ xLBT->setLong(aRet.Long);
+ xLBT->setULong(aRet.ULong);
+ xLBT->setHyper(aRet.Hyper);
+ xLBT->setUHyper(aRet.UHyper);
+ xLBT->setFloat(aRet.Float);
+ xLBT->setDouble(aRet.Double);
+ xLBT->setEnum(aRet.Enum);
+ xLBT->setString(aRet.String);
+ xLBT->setByte2(aRet.Byte2);
+ xLBT->setShort2(aRet.Short2);
+ xLBT->setInterface(aRet.Interface);
+ xLBT->setAny(aRet.Any);
+ xLBT->setSequence(aRet.Sequence);
+ xLBT->setStruct(aRet2);
+ }
+ {
+ TestData aRet;
+ aRet.Hyper = xLBT->getHyper();
+ aRet.UHyper = xLBT->getUHyper();
+ aRet.Float = xLBT->getFloat();
+ aRet.Double = xLBT->getDouble();
+ aRet.Byte = xLBT->getByte();
+ aRet.Char = xLBT->getChar();
+ aRet.Bool = xLBT->getBool();
+ aRet.Short = xLBT->getShort();
+ aRet.UShort = xLBT->getUShort();
+ aRet.Long = xLBT->getLong();
+ aRet.ULong = xLBT->getULong();
+ aRet.Enum = xLBT->getEnum();
+ aRet.String = xLBT->getString();
+ aRet.Byte2 = xLBT->getByte2();
+ aRet.Short2 = xLBT->getShort2();
+ aRet.Interface = xLBT->getInterface();
+ aRet.Any = xLBT->getAny();
+ aRet.Sequence = xLBT->getSequence();
+ TestData aRet2(xLBT->getStruct());
+ bRet &= check(
+ equals(aData, aRet) && equals(aData, aRet2),
+ "struct comparison test");
+ {
+ SmallStruct aIn(1, 2);
+ SmallStruct aOut(xLBT->echoSmallStruct(aIn));
+ bRet &= check(
+ memcmp(&aIn, &aOut, sizeof(SmallStruct)) == 0,
+ "small struct test");
+ }
+ {
+ MediumStruct aIn(1, 2, 3, 4);
+ MediumStruct aOut(xLBT->echoMediumStruct(aIn));
+ bRet &= check(
+ memcmp(&aIn, &aOut, sizeof(MediumStruct)) == 0,
+ "medium struct test");
+ }
+ {
+ BigStruct aIn(1, 2, 3, 4, 5, 6, 7, 8);
+ BigStruct aOut(xLBT->echoBigStruct(aIn));
+ bRet &= check(
+ memcmp(&aIn, &aOut, sizeof(BigStruct)) == 0,
+ "big struct test");
+ }
+ {
+ sal_Int32 i2 = xLBT->testPPCAlignment(0, 0, 0, 0, 0xBEAF);
+ bRet &= check(i2 == 0xBEAF, "ppc-style alignment test");
+ }
+ {
+ sal_Int32 i1 = xLBT->testPPC64Alignment(1.0, 2.0, 3.0, 0xBEAF);
+ bRet &= check(i1 == 0xBEAF, "ppc64-style alignment test");
+ }
+ {
+ double d1 = xLBT->testTenDoubles(0.1, 0.2, 0.3, 0.4, 0.5,
+ 0.6, 0.7, 0.8, 0.9, 1.0);
+ bRet &= check(d1 == 5.5, "armhf doubles test");
+ }
+ // Test extended attributes that raise exceptions:
+ try {
+ xLBT->getRaiseAttr1();
+ bRet &= check(false, "getRaiseAttr1 did not throw");
+ } catch (const RuntimeException &) {
+ } catch (...) {
+ bRet &= check(false, "getRaiseAttr1 threw wrong type");
+ }
+ try {
+ xLBT->setRaiseAttr1(0);
+ bRet &= check(false, "setRaiseAttr1 did not throw");
+ } catch (const IllegalArgumentException &) {
+ } catch (...) {
+ bRet &= check(false, "setRaiseAttr1 threw wrong type");
+ }
+ try {
+ xLBT->getRaiseAttr2();
+ bRet &= check(false, "getRaiseAttr2 did not throw");
+ } catch (const IllegalArgumentException &) {
+ } catch (...) {
+ bRet &= check(false, "getRaiseAttr2 threw wrong type");
+ }
+ // Test instantiated polymorphic struct types:
+ {
+ bRet &= check(
+ (xLBT->transportPolyBoolean(
+ TestPolyStruct< sal_Bool >(true)).
+ member),
+ "transportPolyBoolean");
+ TestPolyStruct< sal_Int64 > tps1(12345);
+ xLBT->transportPolyHyper(tps1);
+ bRet &= check(tps1.member == 12345, "transportPolyHyper");
+ Sequence< Any > seq{ Any(static_cast< sal_uInt32 >(33)), Any(OUString("ABC")) };
+ TestPolyStruct< Sequence< Any > > tps2(seq);
+ TestPolyStruct< Sequence< Any > > tps3;
+ xLBT->transportPolySequence(tps2, tps3);
+ bRet &= check(
+ tps3.member.getLength() == 2,
+ "transportPolySequence, length");
+ sal_uInt32 v0 = sal_uInt32();
+ tps3.member[0] >>= v0;
+ bRet &= check(v0 == 33, "transportPolySequence, element 0");
+ OUString v1;
+ tps3.member[1] >>= v1;
+ bRet &= check( v1 == "ABC", "transportPolySequence, element 1" );
+ bRet &= check(
+ xLBT->getNullPolyLong().member == 0, "getNullPolyLong");
+ bRet &= check(
+ xLBT->getNullPolyString().member.isEmpty(),
+ "getNullPolyString");
+ bRet &= check(
+ xLBT->getNullPolyType().member == Type(),
+ "getNullPolyType");
+ Any nullAny(xLBT->getNullPolyAny().member);
+ auto ifc = o3tl::tryAccess<Reference<XInterface>>(nullAny);
+ bRet &= check(
+ !nullAny.hasValue() || (ifc && !ifc->is()),
+ "getNullPolyAny");
+ bRet &= check(
+ !xLBT->getNullPolySequence().member.hasElements(),
+ "getNullPolySequence");
+ bRet &= check(
+ xLBT->getNullPolyEnum().member == TestEnum_TEST,
+ "getNullPolyEnum");
+ bRet &= check(
+ xLBT->getNullPolyBadEnum().member == TestBadEnum_M,
+ "getNullPolyBadEnum");
+ bRet &= check(
+ xLBT->getNullPolyStruct().member.member == 0,
+ "getNullPolyStruct");
+ bRet &= check(
+ !xLBT->getNullPolyInterface().member.is(),
+ "getNullPolyInterface");
+ }
+ // Any test:
+ bRet &= check(performAnyTest(xLBT , aData), "any test");
+ // Sequence of call test:
+ bRet &= check(
+ performSequenceOfCallTest(xLBT), "sequence of call test");
+ // Recursive call test:
+ bRet &= check(performRecursiveCallTest(xLBT), "recursive test");
+ bRet &= check(
+ equals(aData, aRet) && equals(aData, aRet2),
+ "recursive test results");
+ // Multiple inheritance test:
+ bRet &= checkEmpty(
+ testtools::bridgetest::testMulti(xLBT->getMulti()),
+ "remote multi");
+ bRet &= checkEmpty(
+ xLBT->testMulti(new testtools::bridgetest::Multi),
+ "local multi");
+ }
+ }
+ {
+ Reference< XBridgeTest2 > xBT2(xLBT, UNO_QUERY);
+ if (!xBT2.is()) {
+ return bRet;
+ }
+ // Perform sequence tests (XBridgeTest2); create the sequence which is
+ // compared with the results:
+ sal_Int32 _arLong[] = {
+ static_cast< sal_Int32 >(0x80000000), 1, 0x7FFFFFFF };
+ sal_Int32 _aInt = 0xBABEBABE;
+ float _aFloat = 3.14f;
+ Any _any1(true);
+ Any _any2(&_aInt, cppu::UnoType<sal_Int32>::get());
+ Any _any3(&_aFloat, cppu::UnoType<float>::get());
+ Any _arAny[] = { _any1, _any2, _any3 };
+ Reference< XInterface > _arObj[3];
+ _arObj[0] = new OWeakObject();
+ _arObj[1] = new OWeakObject();
+ _arObj[2] = new OWeakObject();
+ TestElement _arStruct[3];
+ assign(
+ _arStruct[0], true, '@', 17, 0x1234, 0xFEDC, 0x12345678, 0xFEDCBA98,
+ SAL_CONST_INT64(0x123456789ABCDEF0),
+ SAL_CONST_UINT64(0xFEDCBA9876543210), 17.0815f, M_PI,
+ TestEnum_LOLA, STRING_TEST_CONSTANT, 18, 0x5678, _arObj[0],
+ Any(&_arObj[0], cppu::UnoType<XInterface>::get()));
+ assign(
+ _arStruct[1], true, 'A', 17, 0x1234, 0xFEDC, 0x12345678, 0xFEDCBA98,
+ SAL_CONST_INT64(0x123456789ABCDEF0),
+ SAL_CONST_UINT64(0xFEDCBA9876543210), 17.0815f, M_PI,
+ TestEnum_TWO, STRING_TEST_CONSTANT, 18, 0x5678, _arObj[1],
+ Any(&_arObj[1], cppu::UnoType<XInterface>::get()));
+ assign(
+ _arStruct[2], true, 'B', 17, 0x1234, 0xFEDC, 0x12345678, 0xFEDCBA98,
+ SAL_CONST_INT64(0x123456789ABCDEF0),
+ SAL_CONST_UINT64(0xFEDCBA9876543210), 17.0815f, M_PI,
+ TestEnum_CHECK, STRING_TEST_CONSTANT, 18, 0x5678, _arObj[2],
+ Any(&_arObj[2], cppu::UnoType<XInterface>::get()));
+ {
+ Sequence<sal_Bool> arBool({true, false, true});
+ Sequence<sal_Unicode> arChar({0x0065, 0x0066, 0x0067});
+ Sequence<sal_Int8> arByte({1, 2, -1});
+ Sequence<sal_Int16> arShort({-0x8000, 1, 0x7FFF});
+ Sequence<sal_uInt16> arUShort({0 , 1, 0xFFFF});
+ Sequence<sal_Int32> arLong(_arLong, 3);
+ Sequence<sal_uInt32> arULong({0, 1, 0xFFFFFFFF});
+ Sequence<sal_Int64> arHyper({
+ static_cast<sal_Int64>(SAL_CONST_INT64(0x8000000000000000)), 1,
+ SAL_CONST_INT64(0x7FFFFFFFFFFFFFFF)});
+ Sequence<sal_uInt64> arUHyper({
+ 0, 1, SAL_CONST_UINT64(0xFFFFFFFFFFFFFFFF)});
+ Sequence<float> arFloat({1.1f, 2.2f, 3.3f});
+ Sequence<double> arDouble({1.11, 2.22, 3.33});
+ Sequence<OUString> arString({
+ OUString("String 1"), OUString("String 2"),
+ OUString("String 3")});
+ Sequence<Any> arAny(_arAny, 3);
+ Sequence<Reference<XInterface> > arObject(_arObj, 3);
+ Sequence<TestEnum> arEnum({
+ TestEnum_ONE, TestEnum_TWO, TestEnum_CHECK});
+ Sequence<TestElement> arStruct(_arStruct, 3);
+ Sequence<Sequence<sal_Int32> > _arSeqLong2[3];
+ for (int j = 0; j != 3; ++j) {
+ Sequence< sal_Int32 > _arSeqLong[3];
+ for (int i = 0; i != 3; ++i) {
+ // coverity[overrun-buffer-arg : FALSE] - coverity has difficulty with css::uno::Sequence
+ _arSeqLong[i] = Sequence< sal_Int32 >(_arLong, 3);
+ }
+ _arSeqLong2[j] = Sequence< Sequence< sal_Int32 > >(
+ _arSeqLong, 3);
+ }
+ Sequence< Sequence< Sequence< sal_Int32> > > arLong3(
+ _arSeqLong2, 3);
+ Sequence< Sequence< sal_Int32 > > seqSeqRet(
+ xBT2->setDim2(arLong3[0]));
+ bRet &= check(seqSeqRet == arLong3[0], "sequence test");
+ Sequence< Sequence< Sequence< sal_Int32 > > > seqSeqRet2(
+ xBT2->setDim3(arLong3));
+ bRet &= check(seqSeqRet2 == arLong3, "sequence test");
+ Sequence< Any > seqAnyRet(xBT2->setSequenceAny(arAny));
+ bRet &= check(seqAnyRet == arAny, "sequence test");
+ Sequence< sal_Bool > seqBoolRet(xBT2->setSequenceBool(arBool));
+ bRet &= check(seqBoolRet == arBool, "sequence test");
+ Sequence< sal_Int8 > seqByteRet(xBT2->setSequenceByte(arByte));
+ bRet &= check(seqByteRet == arByte, "sequence test");
+ Sequence< sal_Unicode > seqCharRet(xBT2->setSequenceChar(arChar));
+ bRet &= check(seqCharRet == arChar, "sequence test");
+ Sequence< sal_Int16 > seqShortRet(xBT2->setSequenceShort(arShort));
+ bRet &= check(seqShortRet == arShort, "sequence test");
+ Sequence< sal_Int32 > seqLongRet(xBT2->setSequenceLong(arLong));
+ bRet &= check(seqLongRet == arLong, "sequence test");
+ Sequence< sal_Int64 > seqHyperRet(xBT2->setSequenceHyper(arHyper));
+ bRet &= check(seqHyperRet == arHyper, "sequence test");
+ Sequence< float > seqFloatRet(xBT2->setSequenceFloat(arFloat));
+ bRet &= check(seqFloatRet == arFloat, "sequence test");
+ Sequence< double > seqDoubleRet(xBT2->setSequenceDouble(arDouble));
+ bRet &= check(seqDoubleRet == arDouble, "sequence test");
+ Sequence< TestEnum > seqEnumRet(xBT2->setSequenceEnum(arEnum));
+ bRet &= check(seqEnumRet == arEnum, "sequence test");
+ Sequence< sal_uInt16 > seqUShortRet(
+ xBT2->setSequenceUShort(arUShort));
+ bRet &= check(seqUShortRet == arUShort, "sequence test");
+ Sequence< sal_uInt32 > seqULongRet(xBT2->setSequenceULong(arULong));
+ bRet &= check(seqULongRet == arULong, "sequence test");
+ Sequence< sal_uInt64 > seqUHyperRet(
+ xBT2->setSequenceUHyper(arUHyper));
+ bRet &= check(seqUHyperRet == arUHyper, "sequence test");
+ Sequence< Reference< XInterface > > seqObjectRet(
+ xBT2->setSequenceXInterface(arObject));
+ bRet &= check(seqObjectRet == arObject, "sequence test");
+ Sequence< OUString > seqStringRet(
+ xBT2->setSequenceString(arString));
+ bRet &= check(seqStringRet == arString, "sequence test");
+ Sequence< TestElement > seqStructRet(
+ xBT2->setSequenceStruct(arStruct));
+ bRet &= check(seqStructRet == arStruct, "sequence test");
+ Sequence< sal_Bool > arBoolTemp(cloneSequence(arBool));
+ Sequence< sal_Unicode > arCharTemp(cloneSequence<sal_Unicode, cppu::UnoCharType>(arChar));
+ Sequence< sal_Int8 > arByteTemp(cloneSequence(arByte));
+ Sequence< sal_Int16 > arShortTemp(cloneSequence(arShort));
+ Sequence< sal_uInt16 > arUShortTemp(cloneSequence<sal_uInt16, cppu::UnoUnsignedShortType>(arUShort));
+ Sequence< sal_Int32 > arLongTemp(cloneSequence(arLong));
+ Sequence< sal_uInt32 > arULongTemp(cloneSequence(arULong));
+ Sequence< sal_Int64 > arHyperTemp(cloneSequence(arHyper));
+ Sequence< sal_uInt64 > arUHyperTemp(cloneSequence(arUHyper));
+ Sequence< float > arFloatTemp(cloneSequence(arFloat));
+ Sequence< double > arDoubleTemp(cloneSequence(arDouble));
+ Sequence< TestEnum > arEnumTemp(cloneSequence(arEnum));
+ Sequence< OUString > arStringTemp(cloneSequence(arString));
+ Sequence< Reference< XInterface > > arObjectTemp(
+ cloneSequence(arObject));
+ Sequence< Any > arAnyTemp(cloneSequence(arAny));
+ Sequence< Sequence< sal_Int32 > > arLong2Temp(arLong3[0]);
+ Sequence< Sequence< Sequence< sal_Int32 > > > arLong3Temp(arLong3);
+ xBT2->setSequencesInOut(
+ arBoolTemp, arCharTemp, arByteTemp, arShortTemp, arUShortTemp,
+ arLongTemp,arULongTemp, arHyperTemp, arUHyperTemp, arFloatTemp,
+ arDoubleTemp, arEnumTemp, arStringTemp, arObjectTemp, arAnyTemp,
+ arLong2Temp, arLong3Temp);
+ bRet &= check(
+ (arBoolTemp == arBool && arCharTemp == arChar &&
+ arByteTemp == arByte && arShortTemp == arShort &&
+ arUShortTemp == arUShort && arLongTemp == arLong &&
+ arULongTemp == arULong && arHyperTemp == arHyper &&
+ arUHyperTemp == arUHyper && arFloatTemp == arFloat &&
+ arDoubleTemp == arDouble && arEnumTemp == arEnum &&
+ arStringTemp == arString && arObjectTemp == arObject &&
+ arAnyTemp == arAny && arLong2Temp == arLong3[0] &&
+ arLong3Temp == arLong3),
+ "sequence test");
+ Sequence< sal_Bool > arBoolOut;
+ Sequence< sal_Unicode > arCharOut;
+ Sequence< sal_Int8 > arByteOut;
+ Sequence< sal_Int16 > arShortOut;
+ Sequence< sal_uInt16 > arUShortOut;
+ Sequence< sal_Int32 > arLongOut;
+ Sequence< sal_uInt32 > arULongOut;
+ Sequence< sal_Int64 > arHyperOut;
+ Sequence< sal_uInt64 > arUHyperOut;
+ Sequence< float > arFloatOut;
+ Sequence< double > arDoubleOut;
+ Sequence< TestEnum > arEnumOut;
+ Sequence< OUString > arStringOut;
+ Sequence< Reference< XInterface > > arObjectOut;
+ Sequence< Any > arAnyOut;
+ Sequence< Sequence< sal_Int32 > > arLong2Out;
+ Sequence< Sequence< Sequence< sal_Int32 > > > arLong3Out;
+ xBT2->setSequencesOut(
+ arBoolOut, arCharOut, arByteOut, arShortOut, arUShortOut,
+ arLongOut,arULongOut, arHyperOut, arUHyperOut, arFloatOut,
+ arDoubleOut, arEnumOut, arStringOut, arObjectOut, arAnyOut,
+ arLong2Out, arLong3Out);
+ bRet &= check(
+ (arBoolOut == arBool && arCharOut == arChar &&
+ arByteOut == arByte && arShortOut == arShort &&
+ arUShortOut == arUShort && arLongOut == arLong &&
+ arULongOut == arULong && arHyperOut == arHyper &&
+ arUHyperOut == arUHyper && arFloatOut == arFloat &&
+ arDoubleOut == arDouble && arEnumOut == arEnum &&
+ arStringOut == arString && arObjectOut == arObject &&
+ arAnyOut == arAny && arLong2Out == arLong3[0] &&
+ arLong3Out == arLong3),
+ "sequence test");
+ }
+ {
+ // Test with empty sequences:
+ Sequence< Sequence< sal_Int32 > > arLong2;
+ Sequence< Sequence< sal_Int32 > > seqSeqRet(xBT2->setDim2(arLong2));
+ bRet &= check(seqSeqRet == arLong2, "sequence test");
+ Sequence< Sequence< Sequence< sal_Int32 > > > arLong3;
+ Sequence< Sequence< Sequence< sal_Int32 > > > seqSeqRet2(
+ xBT2->setDim3(arLong3));
+ bRet &= check(seqSeqRet2 == arLong3, "sequence test");
+ Sequence< Any > arAny;
+ Sequence< Any > seqAnyRet(xBT2->setSequenceAny(arAny));
+ bRet &= check(seqAnyRet == arAny, "sequence test");
+ Sequence< sal_Bool > arBool;
+ Sequence< sal_Bool > seqBoolRet(xBT2->setSequenceBool(arBool));
+ bRet &= check(seqBoolRet == arBool, "sequence test");
+ Sequence< sal_Int8 > arByte;
+ Sequence< sal_Int8 > seqByteRet(xBT2->setSequenceByte(arByte));
+ bRet &= check(seqByteRet == arByte, "sequence test");
+ Sequence< sal_Unicode > arChar;
+ Sequence< sal_Unicode > seqCharRet(xBT2->setSequenceChar(arChar));
+ bRet &= check(seqCharRet == arChar, "sequence test");
+ Sequence< sal_Int16 > arShort;
+ Sequence< sal_Int16 > seqShortRet(xBT2->setSequenceShort(arShort));
+ bRet &= check(seqShortRet == arShort, "sequence test");
+ Sequence< sal_Int32 > arLong;
+ Sequence< sal_Int32 > seqLongRet(xBT2->setSequenceLong(arLong));
+ bRet &= check(seqLongRet == arLong, "sequence test");
+ Sequence< sal_Int64 > arHyper;
+ Sequence< sal_Int64 > seqHyperRet(xBT2->setSequenceHyper(arHyper));
+ bRet &= check(seqHyperRet == arHyper, "sequence test");
+ Sequence< float > arFloat;
+ Sequence< float > seqFloatRet(xBT2->setSequenceFloat(arFloat));
+ bRet &= check(seqFloatRet == arFloat, "sequence test");
+ Sequence< double > arDouble;
+ Sequence< double > seqDoubleRet(xBT2->setSequenceDouble(arDouble));
+ bRet &= check(seqDoubleRet == arDouble, "sequence test");
+ Sequence< TestEnum > arEnum;
+ Sequence< TestEnum > seqEnumRet(xBT2->setSequenceEnum(arEnum));
+ bRet &= check(seqEnumRet == arEnum, "sequence test");
+ Sequence< sal_uInt16 > arUShort;
+ Sequence< sal_uInt16 > seqUShortRet(
+ xBT2->setSequenceUShort(arUShort));
+ bRet &= check(seqUShortRet == arUShort, "sequence test");
+ Sequence< sal_uInt32 > arULong;
+ Sequence< sal_uInt32 > seqULongRet(xBT2->setSequenceULong(arULong));
+ bRet &= check(seqULongRet == arULong, "sequence test");
+ Sequence< sal_uInt64 > arUHyper;
+ Sequence< sal_uInt64 > seqUHyperRet(
+ xBT2->setSequenceUHyper(arUHyper));
+ bRet &= check(seqUHyperRet == arUHyper, "sequence test");
+ Sequence< Reference< XInterface > > arObject;
+ Sequence< Reference< XInterface > > seqObjectRet(
+ xBT2->setSequenceXInterface(arObject));
+ bRet &= check(seqObjectRet == arObject, "sequence test");
+ Sequence< OUString > arString;
+ Sequence< OUString > seqStringRet(
+ xBT2->setSequenceString(arString));
+ bRet &= check(seqStringRet == arString, "sequence test");
+ Sequence< TestElement > arStruct;
+ Sequence< TestElement > seqStructRet(
+ xBT2->setSequenceStruct(arStruct));
+ bRet &= check(seqStructRet == arStruct, "sequence test");
+ }
+ // Issue #i60341# shows that the most interesting case is were Java
+ // calls the constructors; however, since this client is currently not
+ // available in Java, while the server is, the logic is reversed here:
+ try {
+ xBT2->testConstructorsService(xContext);
+ } catch (const BadConstructorArguments &) {
+ bRet = false;
+ }
+ if (!noCurrentContext) {
+ if (!(new testtools::bridgetest::CurrentContextChecker)->perform(
+ xBT2->getCurrentContextChecker(), 0, 1))
+ {
+ bRet = false;
+ }
+ if (!(new testtools::bridgetest::CurrentContextChecker)->perform(
+ xBT2->getCurrentContextChecker(), 0, 2))
+ {
+ bRet = false;
+ }
+ if (!(new testtools::bridgetest::CurrentContextChecker)->perform(
+ xBT2->getCurrentContextChecker(), 1, 2))
+ {
+ bRet = false;
+ }
+ if (!(new testtools::bridgetest::CurrentContextChecker)->perform(
+ xBT2->getCurrentContextChecker(), 1, 3))
+ {
+ bRet = false;
+ }
+ }
+ }
+ return bRet;
+}
+
+static bool raiseOnewayException( const Reference < XBridgeTest > & xLBT )
+{
+ bool bReturn = true;
+ Reference<XInterface> const x(xLBT->getInterface());
+ try
+ {
+ // Note : the exception may fly or not (e.g. remote scenario).
+ // When it flies, it must contain the correct elements.
+ xLBT->raiseRuntimeExceptionOneway( STRING_TEST_CONSTANT, x );
+ }
+ catch( const RuntimeException & e )
+ {
+ bReturn = (
+#if OSL_DEBUG_LEVEL == 0
+ // java stack traces trash Message
+ e.Message == STRING_TEST_CONSTANT &&
+#endif
+ xLBT->getInterface() == e.Context &&
+ x == e.Context );
+ }
+ return bReturn;
+}
+
+
+static bool raiseException( const Reference< XBridgeTest > & xLBT )
+{
+ sal_Int32 nCount = 0;
+ try
+ {
+ try
+ {
+ try
+ {
+ xLBT->raiseException(
+ 5, STRING_TEST_CONSTANT,
+ xLBT->getInterface() );
+ }
+ catch (const IllegalArgumentException &rExc)
+ {
+ if (rExc.ArgumentPosition == 5 &&
+#if OSL_DEBUG_LEVEL == 0
+ // java stack traces trash Message
+ rExc.Message.startsWith(STRING_TEST_CONSTANT) &&
+#endif
+ rExc.Context == xLBT->getInterface())
+ {
+#ifdef COMPCHECK
+ //When we check if a new compiler still works then we must not call
+ //getRuntimeException because it uses cppu::getCaughtException which
+ //does only work if all libs are build with the same runtime.
+ return true;
+#else
+ ++nCount;
+#endif
+ }
+ else
+ {
+ check( false, "### unexpected exception content!" );
+ }
+
+ /** it is certain, that the RuntimeException testing will fail, if no */
+ xLBT->getRuntimeException();
+ }
+ }
+ catch (const RuntimeException & rExc)
+ {
+ if (rExc.Context == xLBT->getInterface()
+#if OSL_DEBUG_LEVEL == 0
+ // java stack traces trash Message
+ && rExc.Message.startsWith(STRING_TEST_CONSTANT)
+#endif
+ )
+ {
+ ++nCount;
+ }
+ else
+ {
+ check( false, "### unexpected exception content!" );
+ }
+
+ /** it is certain, that the RuntimeException testing will fail, if no */
+ xLBT->setRuntimeException( 0xcafebabe );
+ }
+ }
+ catch (const Exception & rExc)
+ {
+ if (rExc.Context == xLBT->getInterface()
+#if OSL_DEBUG_LEVEL == 0
+ // java stack traces trash Message
+ && rExc.Message.startsWith(STRING_TEST_CONSTANT)
+#endif
+ )
+ {
+ ++nCount;
+ }
+ else
+ {
+ check( false, "### unexpected exception content!" );
+ }
+ return (nCount == 3);
+ }
+ return false;
+}
+
+/* Returns an acquired sequence
+ */
+static uno_Sequence* cloneSequence(const uno_Sequence* val, const Type& type)
+{
+ TypeDescription td(type);
+ td.makeComplete();
+ typelib_TypeDescription* pTdRaw = td.get();
+ typelib_IndirectTypeDescription* pIndirectTd =
+ reinterpret_cast<typelib_IndirectTypeDescription*>(pTdRaw);
+
+ typelib_TypeDescription* pTdElem = pIndirectTd->pType->pType;
+ std::unique_ptr<sal_Int8[]> buf(new sal_Int8[pTdElem->nSize * val->nElements]);
+ sal_Int8* pBufCur = buf.get();
+
+ uno_Sequence* retSeq = nullptr;
+ switch (static_cast<TypeClass>(pTdElem->eTypeClass))
+ {
+ case TypeClass_SEQUENCE:
+ {
+ Type _tElem(pTdElem->pWeakRef);
+ for (int i = 0; i < val->nElements; i++)
+ {
+ sal_Int8 const *pValBuf = reinterpret_cast<sal_Int8 const *>(&val->elements + i * pTdElem->nSize);
+
+ uno_Sequence* seq = cloneSequence(
+ reinterpret_cast<uno_Sequence const *>(pValBuf),
+ _tElem);
+ *reinterpret_cast<uno_Sequence**>(pBufCur) = seq;
+ pBufCur += pTdElem->nSize;
+ }
+ break;
+ }
+ default:
+ uno_type_sequence_construct(
+ &retSeq, type.getTypeLibType(), const_cast<char *>(val->elements),
+ val->nElements, reinterpret_cast< uno_AcquireFunc >(cpp_acquire));
+ break;
+ }
+ return retSeq;
+}
+
+template<typename T, typename U>
+Sequence<T> cloneSequence(const Sequence<T>& val)
+{
+ Sequence<T> seq( cloneSequence(val.get(), cppu::UnoType<cppu::UnoSequenceType<U>>::get()), SAL_NO_ACQUIRE);
+ return seq;
+}
+
+template< class T >
+static bool makeSurrogate(
+ Reference< T > & rOut, Reference< T > const & rOriginal )
+{
+ rOut.clear();
+ if (! rOriginal.is())
+ return false;
+
+ Environment aCppEnv_official;
+ Environment aUnoEnv_ano;
+ Environment aCppEnv_ano;
+
+ OUString aCppEnvTypeName(
+ CPPU_CURRENT_LANGUAGE_BINDING_NAME );
+ OUString aUnoEnvTypeName(
+ UNO_LB_UNO );
+ // official:
+ uno_getEnvironment(
+ reinterpret_cast< uno_Environment ** >( &aCppEnv_official ),
+ aCppEnvTypeName.pData, nullptr );
+ // anonymous:
+ uno_createEnvironment(
+ reinterpret_cast< uno_Environment ** >( &aCppEnv_ano ),
+ aCppEnvTypeName.pData, nullptr );
+ uno_createEnvironment(
+ reinterpret_cast< uno_Environment ** >( &aUnoEnv_ano ),
+ aUnoEnvTypeName.pData, nullptr );
+
+ UnoInterfaceReference unoI;
+ Mapping cpp2uno( aCppEnv_official.get(), aUnoEnv_ano.get() );
+ Mapping uno2cpp( aUnoEnv_ano.get(), aCppEnv_ano.get() );
+ if (!cpp2uno.is() || !uno2cpp.is())
+ {
+ throw RuntimeException("cannot get C++-UNO mappings!" );
+ }
+ cpp2uno.mapInterface(
+ reinterpret_cast< void ** >( &unoI.m_pUnoI ),
+ rOriginal.get(), cppu::UnoType<decltype(rOriginal)>::get() );
+ if (! unoI.is())
+ {
+ throw RuntimeException(
+ "mapping C++ to binary UNO failed!" );
+ }
+ uno2cpp.mapInterface(
+ reinterpret_cast< void ** >( &rOut ),
+ unoI.get(), cppu::UnoType<decltype(rOriginal)>::get() );
+ if (! rOut.is())
+ {
+ throw RuntimeException(
+ "mapping binary UNO to C++ failed!" );
+ }
+
+ return rOut.is();
+}
+
+
+sal_Int32 TestBridgeImpl::run( const Sequence< OUString > & rArgs )
+{
+ bool bRet = false;
+ try
+ {
+ if (! rArgs.hasElements())
+ {
+ throw RuntimeException( "no test object specified!\n"
+ "usage : ServiceName of test object | -u unourl of test object" );
+ }
+
+ Reference< XInterface > xOriginal;
+ bool remote;
+ sal_Int32 i;
+ if( rArgs.getLength() > 1 && rArgs[0] == "-u" )
+ {
+ remote = true;
+ i = 2;
+ }
+ else
+ {
+ remote = false;
+ i = 1;
+ }
+ bool noCurrentContext = false;
+ if ( i < rArgs.getLength() && rArgs[i] == "noCurrentContext" )
+ {
+ noCurrentContext = true;
+ ++i;
+ }
+ bool stress = false;
+ if ( i < rArgs.getLength() && rArgs[i] == "stress" )
+ {
+ stress = true;
+ ++i;
+ }
+
+ for (;;) {
+ Reference< XInterface > o;
+ if (remote) {
+ o = UnoUrlResolver::create(m_xContext)->resolve(rArgs[1]);
+ } else {
+ o = m_xContext->getServiceManager()->createInstanceWithContext(
+ rArgs[0], m_xContext);
+ }
+ if (!stress) {
+ xOriginal = o;
+ break;
+ }
+ }
+
+ if (! xOriginal.is())
+ {
+ throw RuntimeException( "cannot get test object!" );
+ }
+ Reference< XBridgeTest > xTest( xOriginal, UNO_QUERY_THROW );
+
+ Reference<XBridgeTest > xLBT;
+ bRet = check( makeSurrogate( xLBT, xTest ), "makeSurrogate" );
+ bRet = check(
+ performTest( m_xContext, xLBT, noCurrentContext ), "standard test" )
+ && bRet;
+ bRet = check( raiseException( xLBT ) , "exception test" )&& bRet;
+ bRet = check( raiseOnewayException( xLBT ),
+ "oneway exception test" ) && bRet;
+ if (! bRet)
+ {
+ throw RuntimeException( "error: test failed!" );
+ }
+ }
+ catch (const Exception & exc)
+ {
+ OString cstr( OUStringToOString( exc.Message, RTL_TEXTENCODING_ASCII_US ) );
+ fprintf( stderr, "exception occurred: %s\n", cstr.getStr() );
+ throw;
+ }
+
+ return bRet ? 0 : 1;
+}
+
+// XServiceInfo
+
+OUString TestBridgeImpl::getImplementationName()
+{
+ return IMPLNAME;
+}
+
+sal_Bool TestBridgeImpl::supportsService( const OUString & rServiceName )
+{
+ return cppu::supportsService(this, rServiceName);
+}
+
+Sequence< OUString > TestBridgeImpl::getSupportedServiceNames()
+{
+ return bridge_test::getSupportedServiceNames();
+}
+
+
+static Reference< XInterface > TestBridgeImpl_create(
+ const Reference< XComponentContext > & xContext )
+{
+ return Reference< XInterface >(
+ static_cast< OWeakObject * >( new TestBridgeImpl( xContext ) ) );
+}
+
+}
+
+extern "C"
+{
+
+SAL_DLLPUBLIC_EXPORT void * component_getFactory(
+ const char * pImplName, void * pServiceManager,
+ SAL_UNUSED_PARAMETER void * )
+{
+ void * pRet = nullptr;
+
+ if (pServiceManager && o3tl::equalsAscii(IMPLNAME, pImplName))
+ {
+ Reference< XInterface > xFactory(
+ createSingleComponentFactory(
+ bridge_test::TestBridgeImpl_create,
+ IMPLNAME,
+ bridge_test::getSupportedServiceNames() ) );
+
+ if (xFactory.is())
+ {
+ xFactory->acquire();
+ pRet = xFactory.get();
+ }
+ }
+
+ return pRet;
+}
+}
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/testtools/source/bridgetest/cli/cli_bridgetest_inprocess.cs b/testtools/source/bridgetest/cli/cli_bridgetest_inprocess.cs
new file mode 100644
index 000000000..7518e569d
--- /dev/null
+++ b/testtools/source/bridgetest/cli/cli_bridgetest_inprocess.cs
@@ -0,0 +1,251 @@
+/*
+ * This file is part of the LibreOffice project.
+ *
+ * This Source Code Form is subject to the terms of the Mozilla Public
+ * License, v. 2.0. If a copy of the MPL was not distributed with this
+ * file, You can obtain one at http://mozilla.org/MPL/2.0/.
+ *
+ * This file incorporates work covered by the following license notice:
+ *
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed
+ * with this work for additional information regarding copyright
+ * ownership. The ASF licenses this file to you under the Apache
+ * License, Version 2.0 (the "License"); you may not use this file
+ * except in compliance with the License. You may obtain a copy of
+ * the License at http://www.apache.org/licenses/LICENSE-2.0 .
+ */
+
+using System;
+using System.Collections;
+using uno;
+using uno.util;
+using unoidl.com.sun.star.uno;
+using unoidl.com.sun.star.lang;
+using unoidl.com.sun.star.container;
+
+
+
+internal class Factory :
+ WeakComponentBase, XSingleComponentFactory, XServiceInfo
+{
+ private String m_service;
+ private Type m_type;
+ private System.Reflection.ConstructorInfo m_ctor;
+
+ public Factory( Type type, String service )
+ {
+ m_service = service;
+ m_type = type;
+ m_ctor = type.GetConstructor(
+ new Type [] { typeof (XComponentContext) } );
+ }
+
+ public Object createInstanceWithContext( XComponentContext xContext )
+ {
+ return m_ctor.Invoke( new Object [] { xContext } );
+ }
+
+ public Object createInstanceWithArgumentsAndContext(
+ uno.Any [] args, XComponentContext xContext )
+ {
+ return m_ctor.Invoke( new Object [] { xContext } );
+ }
+
+ public bool supportsService( String name )
+ {
+ return m_service.Equals( name );
+ }
+
+ public String [] getSupportedServiceNames()
+ {
+ return new String [] { m_service };
+ }
+
+ public String getImplementationName()
+ {
+ return m_type.ToString();
+ }
+}
+
+
+/** This executable does the same as the batch file starting via uno.exe,
+ but via bootstrapping native UNO.
+*/
+public class BridgeTest
+{
+ public static int Main( String [] args )
+ {
+// System.Diagnostics.Debugger.Launch();
+ try
+ {
+ string bootstrap_ini = "cli_bridgetest_inprocess.ini";
+ if (args.Length > 0)
+ {
+ if (args[0] == "/?")
+ {
+ Console.WriteLine(
+ "\n\ncli_bridgetest_inprocess [bootstrap file] \n\n"
+ + "bootstrap file \n"
+ + "\t contains the entries UNO_TYPES and UNO_SERVICES.\n"
+ + "\t If a file is not provided then it is assumed that a\n"
+ + "\t cli_bridgetest_inprocess.ini file can be found in the\n "
+ + "\t current working directory.\n"
+ );
+ return 0;
+ }
+ else
+ {
+ bootstrap_ini = args[0];
+ }
+ }
+
+ // bootstrap native UNO
+ XComponentContext xContext =
+ Bootstrap.defaultBootstrap_InitialComponentContext(
+ bootstrap_ini, null );
+
+ using (new uno.util.DisposeGuard( (XComponent) xContext ))
+ {
+ XSet xSet = (XSet) xContext.getServiceManager();
+ xSet.insert(
+ new uno.Any(
+ typeof (XSingleComponentFactory),
+ new Factory(
+ typeof (cs_testobj.BridgeTestObject),
+ "com.sun.star.test.bridge.cli_uno.CsTestObject" ) ) );
+ xSet.insert(
+ new uno.Any(
+ typeof (XSingleComponentFactory),
+ new Factory(
+ typeof (vb_testobj.VBBridgeTestObject),
+ "com.sun.star.test.bridge.cli_uno.VbTestObject" ) ) );
+ xSet.insert(
+ new uno.Any(
+ typeof (XSingleComponentFactory),
+ new Factory(
+ typeof (cpp_bridgetest.BridgeTest),
+ "com.sun.star.test.bridge.cli_uno.CppBridgeTest" ) ) );
+ xSet.insert(
+ new uno.Any(
+ typeof (XSingleComponentFactory),
+ new Factory(
+ typeof (cs_testobj.BridgeTest),
+ "com.sun.star.test.bridge.cli_uno.CsBridgeTest" ) ) );
+ xSet.insert(
+ new uno.Any(
+ typeof (XSingleComponentFactory),
+ new Factory(
+ typeof (vb_bridetest.BridgeTest),
+ "com.sun.star.test.bridge.cli_uno.VbBridgeTest" ) ) );
+
+ // I.
+ // direct unbridged test
+ // get client object via singleton entry
+ Object test_client;
+ XMain xClient;
+ test_client = new cs_testobj.BridgeTest( xContext );
+ xClient = (XMain) test_client;
+ Console.WriteLine(
+ "\n[cli bridgetest] 1. C# client calls C# object");
+ // run with CLI target object
+ xClient.run(
+ new String [] {
+ "com.sun.star.test.bridge.cli_uno.CsTestObject" } );
+
+ // II:
+ // uno -ro uno_services.rdb -ro uno_types.rdb
+ // -s com.sun.star.test.bridge.BridgeTest
+ // -- com.sun.star.test.bridge.cli_uno.TestObject
+
+ // get native client
+ test_client =
+ xContext.getServiceManager().createInstanceWithContext(
+ "com.sun.star.test.bridge.BridgeTest", xContext );
+ xClient = (XMain) test_client;
+ Console.WriteLine(
+ "\n[cli bridgetest] 2. C++ client (native) calls C# object");
+ // run with CLI target object
+ xClient.run(
+ new String [] {
+ "com.sun.star.test.bridge.cli_uno.CsTestObject",
+ "noCurrentContext"} );
+
+ // III:
+ // uno -ro uno_services.rdb -ro uno_types.rdb
+ // -s com.sun.star.test.bridge.cli_uno.BridgeTest
+ // -- com.sun.star.test.bridge.CppTestObject
+
+ // get CLI client
+ test_client =
+ xContext.getServiceManager().createInstanceWithContext(
+ "com.sun.star.test.bridge.cli_uno.CsBridgeTest",
+ xContext );
+ xClient = (XMain) test_client;
+ Console.WriteLine(
+ "\n[cli bridgetest] 3. C# client calls C++ object (native)");
+ // run with native target object
+ xClient.run(
+ new String [] { "com.sun.star.test.bridge.CppTestObject" } );
+
+ // IV:
+ // uno -ro uno_services.rdb -ro uno_types.rdb
+ // -s com.sun.star.test.bridge.cli_uno.VbBridgeTest
+ // -- com.sun.star.test.bridge.CppTestObject
+ // get CLI client
+ test_client =
+ xContext.getServiceManager().createInstanceWithContext(
+ "com.sun.star.test.bridge.cli_uno.VbBridgeTest",
+ xContext );
+ xClient = (XMain) test_client;
+ Console.WriteLine(
+ "\n[cli bridgetest] 4. Visual Basic client calls C++ (native) object" );
+ // run with native target object
+ xClient.run(
+ new String [] { "com.sun.star.test.bridge.CppTestObject" } );
+
+ // V:
+ // uno -ro uno_services.rdb -ro uno_types.rdb
+ // -s com.sun.star.test.bridge.BridgeTest
+ // -- com.sun.star.test.bridge.cli_uno.VbTestObject
+ // get CLI client
+// test_client =
+// xContext.getServiceManager().createInstanceWithContext(
+// "com.sun.star.test.bridge.BridgeTest", xContext );
+// xClient = (XMain) test_client;
+// Console.WriteLine(
+// "[cli bridgetest] Visual Basic client: {0}",
+// xClient.ToString() );
+// // run with native target object
+// xClient.run(
+// new String [] {
+// "com.sun.star.test.bridge.cli_uno.VbTestObject" } );
+
+ // VI:
+ // uno -ro uno_services.rdb -ro uno_types.rdb
+ // -s com.sun.star.test.bridge.cli_uno.CppBridgeTest
+ // -- com.sun.star.test.bridge.CppTestObject
+ test_client =
+ xContext.getServiceManager().createInstanceWithContext(
+ "com.sun.star.test.bridge.cli_uno.CppBridgeTest",
+ xContext );
+ xClient = (XMain) test_client;
+ Console.WriteLine(
+ "\n[cli bridgetest] 6. CLI C++ client calls C++ object (native)");
+ // run with native target object
+ xClient.run(
+ new String [] { "com.sun.star.test.bridge.CppTestObject" } );
+ }
+ }
+ catch (System.Exception exc)
+ {
+ GC.WaitForPendingFinalizers();
+ System.Console.WriteLine( exc );
+ return -1;
+ }
+
+ GC.WaitForPendingFinalizers();
+ System.Console.WriteLine( "====> all tests ok." );
+ return 0;
+ }
+}
diff --git a/testtools/source/bridgetest/cli/cli_bridgetest_inprocess.ini b/testtools/source/bridgetest/cli/cli_bridgetest_inprocess.ini
new file mode 100644
index 000000000..bb7c56fcf
--- /dev/null
+++ b/testtools/source/bridgetest/cli/cli_bridgetest_inprocess.ini
@@ -0,0 +1,3 @@
+[Bootstrap]
+UNO_TYPES=$SYSBINDIR/uno_types.rdb
+UNO_SERVICES=$SYSBINDIR/uno_services.rdb
diff --git a/testtools/source/bridgetest/cli/cli_cpp_bridgetest.cxx b/testtools/source/bridgetest/cli/cli_cpp_bridgetest.cxx
new file mode 100644
index 000000000..04d9b3066
--- /dev/null
+++ b/testtools/source/bridgetest/cli/cli_cpp_bridgetest.cxx
@@ -0,0 +1,928 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*
+ * This file is part of the LibreOffice project.
+ *
+ * This Source Code Form is subject to the terms of the Mozilla Public
+ * License, v. 2.0. If a copy of the MPL was not distributed with this
+ * file, You can obtain one at http://mozilla.org/MPL/2.0/.
+ *
+ * This file incorporates work covered by the following license notice:
+ *
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed
+ * with this work for additional information regarding copyright
+ * ownership. The ASF licenses this file to you under the Apache
+ * License, Version 2.0 (the "License"); you may not use this file
+ * except in compliance with the License. You may obtain a copy of
+ * the License at http://www.apache.org/licenses/LICENSE-2.0 .
+ */
+
+
+#using <mscorlib.dll>
+#using <System.dll>
+#using <cli_basetypes.dll>
+#using <cli_uretypes.dll>
+#using <cli_ure.dll>
+#using <cli_types_bridgetest.dll>
+#include <cmath>
+
+using namespace System;
+using namespace System::Diagnostics;
+using namespace System::Reflection;
+using namespace System::Threading;
+using namespace uno;
+using namespace uno::util;
+using namespace unoidl::com::sun::star::uno;
+using namespace unoidl::com::sun::star::lang;
+using namespace unoidl::test::testtools::bridgetest;
+namespace foo
+{
+ public __gc __interface MyInterface
+ {
+ };
+}
+
+namespace cpp_bridgetest
+{
+ __gc class ORecursiveCall: public WeakBase, public XRecursiveCall
+ {
+ public:
+ void callRecursivly(XRecursiveCall * xCall, int nToCall)
+ {
+ Monitor::Enter(this);
+ try
+ {
+ {
+ if (nToCall > 0)
+ {
+ nToCall --;
+ xCall->callRecursivly(this, nToCall);
+ }
+ }
+ }
+ __finally
+ {
+ Monitor::Exit(this);
+ }
+
+ }
+ };
+
+public __gc class Constants
+{
+public:
+ static String* STRING_TEST_CONSTANT = new String(S"\" paco\' chorizo\\\' \"\'");
+};
+
+public __gc class BridgeTest : public WeakBase, public XMain
+{
+ static bool compareData(Object* val1, Object* val2)
+ {
+ if (val1 == 0 && val2 == 0 || val1 == val2)
+ return true;
+ if ((val1 == 0 && val2 != 0) ||
+ (val1 != 0 && val2 == 0) || val1->GetType() != val2->GetType())
+ return false;
+
+ bool ret = false;
+ Type* t1 = val1->GetType();
+ //Sequence
+ if (t1->IsArray)
+ {
+ ret = compareSequence(static_cast<Array*>(val1),
+ static_cast<Array*>(val2));
+ }
+ //String
+ else if (t1 == __typeof(String))
+ {
+ ret = val1->Equals(val2);
+ }
+ // Interface implementation
+ else if (t1->GetInterfaces()->Length > 0 && ! t1->IsValueType)
+ {
+ ret = val1 == val2;
+ }
+ // Struct
+ else if ( ! t1->IsValueType)
+ {
+ ret = compareStruct(val1, val2);
+ }
+ else if (t1 == __typeof(Any))
+ {
+ Any a1 = (Any) val1;
+ Any a2 = (Any) val2;
+ ret = a1.Type == a2.Type && compareData(a1.Value, a2.Value);
+ }
+ else
+ {
+ //Any, enum, int, bool char, float, double etc.
+ ret = val1->Equals(val2);
+ }
+ return ret;
+ }
+
+ // Arrays have only one dimension
+ static bool compareSequence(Array* ar1, Array* ar2)
+ {
+ Debug::Assert(ar1 != 0 && ar2 != 0);
+ Type* t1 = ar1->GetType();
+ Type* t2 = ar2->GetType();
+
+ if (!(ar1->Rank == 1 && ar2->Rank == 1
+ && ar1->Length == ar2->Length && t1->GetElementType() == t2->GetElementType()))
+ return false;
+
+ //arrays have same rank and size and element type.
+ int len = ar1->Length;
+ bool ret = true;
+ for (int i = 0; i < len; i++)
+ {
+ if (compareData(ar1->GetValue(i), ar2->GetValue(i)) == false)
+ {
+ ret = false;
+ break;
+ }
+ }
+ return ret;
+ }
+
+ static bool compareStruct(Object* val1, Object* val2)
+ {
+ Debug::Assert(val1 != 0 && val2 != 0);
+ Type* t1 = val1->GetType();
+ Type* t2 = val2->GetType();
+ if (t1 != t2)
+ return false;
+ FieldInfo* fields[] = t1->GetFields();
+ int cFields = fields->Length;
+ bool ret = true;
+ for (int i = 0; i < cFields; i++)
+ {
+ Object* fieldVal1 = fields[i]->GetValue(val1);
+ Object* fieldVal2 = fields[i]->GetValue(val2);
+ if ( ! compareData(fieldVal1, fieldVal2))
+ {
+ ret = false;
+ break;
+ }
+ }
+ return ret;
+ }
+
+ static bool check( bool b , String* message )
+ {
+ if ( ! b)
+ Console::WriteLine("{0} failed\n" , message);
+ return b;
+ }
+
+ static bool equals(TestElement* rData1, TestElement* rData2)
+ {
+ check( rData1->Bool == rData2->Bool, "### bool does not match!" );
+ check( rData1->Char == rData2->Char, "### char does not match!" );
+ check( rData1->Byte == rData2->Byte, "### byte does not match!" );
+ check( rData1->Short == rData2->Short, "### short does not match!" );
+ check( rData1->UShort == rData2->UShort, "### unsigned short does not match!" );
+ check( rData1->Long == rData2->Long, "### long does not match!" );
+ check( rData1->ULong == rData2->ULong, "### unsigned long does not match!" );
+ check( rData1->Hyper == rData2->Hyper, "### hyper does not match!" );
+ check( rData1->UHyper == rData2->UHyper, "### unsigned hyper does not match!" );
+ check( rData1->Float == rData2->Float, "### float does not match!" );
+ check( rData1->Double == rData2->Double, "### double does not match!" );
+ check( rData1->Enum == rData2->Enum, "### enum does not match!" );
+ check( rData1->String == rData2->String, "### string does not match!" );
+ check( rData1->Byte2 == rData2->Byte2, "### byte2 does not match!" );
+ check( rData1->Short2 == rData2->Short2, "### short2 does not match!" );
+ check( rData1->Interface == rData2->Interface, "### interface does not match!" );
+ check( compareData(__box(rData1->Any), __box(rData2->Any)), "### any does not match!" );
+
+ return (rData1->Bool == rData2->Bool &&
+ rData1->Char == rData2->Char &&
+ rData1->Byte == rData2->Byte &&
+ rData1->Short == rData2->Short &&
+ rData1->UShort == rData2->UShort &&
+ rData1->Long == rData2->Long &&
+ rData1->ULong == rData2->ULong &&
+ rData1->Hyper == rData2->Hyper &&
+ rData1->UHyper == rData2->UHyper &&
+ rData1->Float == rData2->Float &&
+ rData1->Double == rData2->Double &&
+ rData1->Enum == rData2->Enum &&
+ rData1->String == rData2->String &&
+ rData1->Byte2 == rData2->Byte2 &&
+ rData1->Short2 == rData2->Short2 &&
+ rData1->Interface == rData2->Interface &&
+ compareData(__box(rData1->Any), __box(rData2->Any)));
+ }
+
+static void assign( TestElement* rData,
+ bool bBool, Char cChar, Byte nByte,
+ Int16 nShort, UInt16 nUShort,
+ Int32 nLong, UInt32 nULong,
+ Int64 nHyper, UInt64 nUHyper,
+ float fFloat, double fDouble,
+ TestEnum eEnum, String* rStr,
+ Byte nByte2, Int16 nShort2,
+ Object* xTest,
+ uno::Any rAny )
+{
+ rData->Bool = bBool;
+ rData->Char = cChar;
+ rData->Byte = nByte;
+ rData->Short = nShort;
+ rData->UShort = nUShort;
+ rData->Long = nLong;
+ rData->ULong = nULong;
+ rData->Hyper = nHyper;
+ rData->UHyper = nUHyper;
+ rData->Float = fFloat;
+ rData->Double = fDouble;
+ rData->Enum = eEnum;
+ rData->String = rStr;
+ rData->Byte2 = nByte2;
+ rData->Short2 = nShort2;
+ rData->Interface = xTest;
+ rData->Any = rAny;
+}
+
+static void assign( TestDataElements* rData,
+ bool bBool, Char cChar, Byte nByte,
+ Int16 nShort, UInt16 nUShort,
+ Int32 nLong, UInt32 nULong,
+ Int64 nHyper, UInt64 nUHyper,
+ float fFloat, double fDouble,
+ TestEnum eEnum, String* rStr,
+ Byte nByte2, Int16 nShort2,
+ Object* xTest,
+ Any rAny,
+ TestElement* rSequence[])
+{
+ assign( static_cast<TestElement*>(rData),
+ bBool, cChar, nByte, nShort, nUShort, nLong, nULong, nHyper, nUHyper, fFloat, fDouble,
+ eEnum, rStr, nByte2, nShort2, xTest, rAny );
+ rData->Sequence = rSequence;
+}
+
+static bool testAny(Type* typ, Object* value, XBridgeTest* xLBT )
+{
+ Any any;
+ if (typ == 0)
+ any = Any(value->GetType(), value);
+ else
+ any = Any(typ, value);
+
+ Any any2 = xLBT->transportAny(any);
+ bool ret = compareData(__box(any), __box(any2));
+ if (!ret)
+ {
+ Console::WriteLine("any is different after roundtrip: in {0}, out {1}\n",
+ any.Type->FullName, any2.Type->FullName);
+ }
+ return ret;
+}
+
+
+static bool performAnyTest(XBridgeTest* xLBT, TestDataElements* data)
+{
+ bool bReturn = true;
+ bReturn = testAny( 0, __box(data->Byte), xLBT ) && bReturn;
+ bReturn = testAny( 0, __box(data->Short), xLBT ) && bReturn;
+ bReturn = testAny( 0, __box(data->UShort), xLBT ) && bReturn;
+ bReturn = testAny( 0, __box(data->Long), xLBT ) && bReturn;
+ bReturn = testAny( 0, __box(data->ULong), xLBT ) && bReturn;
+ bReturn = testAny( 0, __box(data->Hyper), xLBT ) && bReturn;
+ bReturn = testAny( 0, __box(data->UHyper), xLBT ) && bReturn;
+ bReturn = testAny( 0, __box(data->Float), xLBT ) && bReturn;
+ bReturn = testAny( 0, __box(data->Double),xLBT ) && bReturn;
+ bReturn = testAny( 0, __box(data->Enum), xLBT ) && bReturn;
+ bReturn = testAny( 0, data->String,xLBT ) && bReturn;
+ bReturn = testAny( 0, data->Byte2,xLBT ) && bReturn;
+ bReturn = testAny( 0, data->Short2,xLBT ) && bReturn;
+ bReturn = testAny(__typeof(XWeak), data->Interface,xLBT ) && bReturn;
+ bReturn = testAny(0, data, xLBT ) && bReturn;
+
+ {
+ Any a1(true);
+ Any a2 = xLBT->transportAny( a1 );
+ bReturn = compareData(__box(a2), __box(a1)) && bReturn;
+ }
+
+ {
+ Any a1('A');
+ Any a2 = xLBT->transportAny(a1);
+ bReturn = compareData( __box(a2), __box(a1)) && bReturn;
+ }
+ return bReturn;
+}
+
+static bool performSequenceOfCallTest(XBridgeTest* xLBT)
+{
+ int i,nRounds;
+ int nGlobalIndex = 0;
+ const int nWaitTimeSpanMUSec = 10000;
+ for( nRounds = 0 ; nRounds < 10 ; nRounds ++ )
+ {
+ for( i = 0 ; i < nRounds ; i ++ )
+ {
+ // fire oneways
+ xLBT->callOneway(nGlobalIndex, nWaitTimeSpanMUSec);
+ nGlobalIndex++;
+ }
+
+ // call synchron
+ xLBT->call(nGlobalIndex, nWaitTimeSpanMUSec);
+ nGlobalIndex++;
+ }
+ return xLBT->sequenceOfCallTestPassed();
+}
+
+
+static bool performRecursiveCallTest(XBridgeTest* xLBT)
+{
+ xLBT->startRecursiveCall(new ORecursiveCall(), 50);
+ // on failure, the test would lock up or crash
+ return true;
+}
+
+static bool performQueryForUnknownType(XBridgeTest* xLBT)
+{
+ bool bRet = false;
+ // test queryInterface for an unknown type
+ try
+ {
+ __try_cast<foo::MyInterface*>(xLBT);
+ }
+ catch( System::InvalidCastException*)
+ {
+ bRet = true;
+ }
+
+ return bRet;
+}
+
+
+static bool performTest(XBridgeTest* xLBT)
+{
+ check( xLBT != 0, "### no test interface!" );
+ bool bRet = true;
+ if (xLBT != 0)
+ {
+ // this data is never ever granted access to by calls other than equals(), assign()!
+ TestDataElements* aData = new TestDataElements(); // test against this data
+
+ Object* xI= new WeakBase();
+
+ Any aAny( __typeof(Object), xI);
+ assign( static_cast<TestElement*>(aData),
+ true, '@', 17, 0x1234, 0xfedc, 0x12345678, 0xfedcba98,
+ 0x123456789abcdef0, 0xfedcba9876543210,
+ 17.0815f, M_PI, TestEnum::LOLA,
+ Constants::STRING_TEST_CONSTANT, xI,
+ aAny);
+
+ bRet = check( aData->Any.Value == xI, "### unexpected any!" ) && bRet;
+ bRet = check( !(aData->Any.Value != xI), "### unexpected any!" ) && bRet;
+
+ aData->Sequence = new TestElement*[2];
+ aData->Sequence[0] = new TestElement(
+ aData->Bool, aData->Char, aData->Byte, aData->Short,
+ aData->UShort, aData->Long, aData->ULong,
+ aData->Hyper, aData->UHyper, aData->Float,
+ aData->Double, aData->Enum, aData->String,
+ aData->Byte2, aData->Short2,
+ aData->Interface, aData->Any); //(TestElement) aData;
+ aData->Sequence[1] = new TestElement(); //is empty
+
+ // aData complete
+
+ // this is a manually copy of aData for first setting...
+ TestDataElements* aSetData = new TestDataElements;
+ Any aAnySet(__typeof(Object), xI);
+ assign( static_cast<TestElement*>(aSetData),
+ aData->Bool,
+ aData->Char,
+ aData->Byte,
+ aData->Short,
+ aData->UShort,
+ aData->Long, aData->ULong, aData->Hyper, aData->UHyper, aData->Float, aData->Double,
+ aData->Enum,
+ aData->String,
+ aData->Byte2,
+ aData->Short2,
+ xI,
+ aAnySet);
+
+ aSetData->Sequence = new TestElement*[2];
+ aSetData->Sequence[0] = new TestElement(
+ aSetData->Bool, aSetData->Char, aSetData->Byte, aSetData->Short,
+ aSetData->UShort, aSetData->Long, aSetData->ULong,
+ aSetData->Hyper, aSetData->UHyper, aSetData->Float,
+ aSetData->Double, aSetData->Enum, aSetData->String,
+ aSetData->Byte2, aSetData->Short2,
+ aSetData->Interface, aSetData->Any); //TestElement) aSetData;
+ aSetData->Sequence[1] = new TestElement(); // empty struct
+
+ xLBT->setValues(
+ aSetData->Bool,
+ aSetData->Char,
+ aSetData->Byte,
+ aSetData->Short,
+ aSetData->UShort,
+ aSetData->Long,
+ aSetData->ULong,
+ aSetData->Hyper,
+ aSetData->UHyper,
+ aSetData->Float,
+ aSetData->Double,
+ aSetData->Enum,
+ aSetData->String,
+ aSetData->Byte2,
+ aSetData->Short2,
+ aSetData->Interface,
+ aSetData->Any,
+ aSetData->Sequence,
+ aSetData );
+
+ {
+ TestDataElements* aRet = new TestDataElements();
+ TestDataElements* aRet2 = new TestDataElements();
+ xLBT->getValues(
+ & aRet->Bool,
+ & aRet->Char,
+ & aRet->Byte,
+ & aRet->Short,
+ & aRet->UShort,
+ & aRet->Long,
+ & aRet->ULong,
+ & aRet->Hyper,
+ & aRet->UHyper,
+ & aRet->Float,
+ & aRet->Double,
+ & aRet->Enum,
+ & aRet->String,
+ & aRet->Byte2,
+ & aRet->Short2,
+ & aRet->Interface,
+ & aRet->Any,
+ & aRet->Sequence,
+ & aRet2 );
+
+ bRet = check( compareData( aData, aRet ) && compareData( aData, aRet2 ) , "getValues test") && bRet;
+
+ // set last retrieved values
+ TestDataElements* aSV2ret = xLBT->setValues2(
+ & aRet->Bool,
+ & aRet->Char,
+ & aRet->Byte,
+ & aRet->Short,
+ & aRet->UShort,
+ & aRet->Long,
+ & aRet->ULong,
+ & aRet->Hyper,
+ & aRet->UHyper,
+ & aRet->Float,
+ & aRet->Double,
+ & aRet->Enum,
+ & aRet->String,
+ & aRet->Byte2,
+ & aRet->Short2,
+ & aRet->Interface,
+ & aRet->Any,
+ & aRet->Sequence,
+ & aRet2 );
+
+ // check inout sequence order
+ // => inout sequence parameter was switched by test objects
+ TestElement* temp = aRet->Sequence[ 0 ];
+ aRet->Sequence[ 0 ] = aRet->Sequence[ 1 ];
+ aRet->Sequence[ 1 ] = temp;
+
+ bRet = check(
+ compareData( aData, aSV2ret ) && compareData( aData, aRet2 ),
+ "getValues2 test") && bRet;
+ }
+ {
+ TestDataElements* aRet = new TestDataElements();
+ TestDataElements* aRet2 = new TestDataElements();
+ TestDataElements* aGVret = xLBT->getValues(
+ & aRet->Bool,
+ & aRet->Char,
+ & aRet->Byte,
+ & aRet->Short,
+ & aRet->UShort,
+ & aRet->Long,
+ & aRet->ULong,
+ & aRet->Hyper,
+ & aRet->UHyper,
+ & aRet->Float,
+ & aRet->Double,
+ & aRet->Enum,
+ & aRet->String,
+ & aRet->Byte2,
+ & aRet->Short2,
+ & aRet->Interface,
+ & aRet->Any,
+ & aRet->Sequence,
+ & aRet2 );
+
+ bRet = check( compareData( aData, aRet ) && compareData( aData, aRet2 ) && compareData( aData, aGVret ), "getValues test" ) && bRet;
+
+ // set last retrieved values
+ xLBT->Bool = aRet->Bool;
+ xLBT->Char = aRet->Char;
+ xLBT->Byte = aRet->Byte;
+ xLBT->Short = aRet->Short;
+ xLBT->UShort = aRet->UShort;
+ xLBT->Long = aRet->Long;
+ xLBT->ULong = aRet->ULong;
+ xLBT->Hyper = aRet->Hyper;
+ xLBT->UHyper = aRet->UHyper;
+ xLBT->Float = aRet->Float;
+ xLBT->Double = aRet->Double;
+ xLBT->Enum = aRet->Enum;
+ xLBT->String = aRet->String;
+ xLBT->Byte2 = aRet->Byte2;
+ xLBT->Short2 = aRet->Short2;
+ xLBT->Interface = aRet->Interface;
+ xLBT->Any = aRet->Any;
+ xLBT->Sequence = aRet->Sequence;
+ xLBT->Struct = aRet2;
+ }
+ {
+ TestDataElements* aRet = new TestDataElements();
+ TestDataElements* aRet2 = new TestDataElements();
+ aRet->Hyper = xLBT->Hyper;
+ aRet->UHyper = xLBT->UHyper;
+ aRet->Float = xLBT->Float;
+ aRet->Double = xLBT->Double;
+ aRet->Byte = xLBT->Byte;
+ aRet->Char = xLBT->Char;
+ aRet->Bool = xLBT->Bool;
+ aRet->Short = xLBT->Short;
+ aRet->UShort = xLBT->UShort;
+ aRet->Long = xLBT->Long;
+ aRet->ULong = xLBT->ULong;
+ aRet->Enum = xLBT->Enum;
+ aRet->String = xLBT->String;
+ aRet->Byte2 = xLBT->Byte2;
+ aRet->Short2 = xLBT->Short2;
+ aRet->Interface = xLBT->Interface;
+ aRet->Any = xLBT->Any;
+ aRet->Sequence = xLBT->Sequence;
+ aRet2 = xLBT->Struct;
+
+ bRet = check( compareData( aData, aRet ) && compareData( aData, aRet2 ) , "struct comparison test") && bRet;
+
+ bRet = check(performSequenceTest(xLBT), "sequence test") && bRet;
+
+ // any test
+ bRet = check( performAnyTest( xLBT , aData ) , "any test" ) && bRet;
+
+ // sequence of call test
+ bRet = check( performSequenceOfCallTest( xLBT ) , "sequence of call test" ) && bRet;
+
+ // recursive call test
+ bRet = check( performRecursiveCallTest( xLBT ) , "recursive test" ) && bRet;
+
+ bRet = (compareData( aData, aRet ) && compareData( aData, aRet2 )) && bRet ;
+
+ // check setting of null reference
+ xLBT->Interface = 0;
+ aRet->Interface = xLBT->Interface;
+ bRet = (aRet->Interface == 0) && bRet;
+
+ }
+
+
+ }
+ return bRet;
+ }
+static bool performSequenceTest(XBridgeTest* xBT)
+{
+ bool bRet = true;
+ XBridgeTest2* xBT2 = dynamic_cast<XBridgeTest2*>(xBT);
+ if ( xBT2 == 0)
+ return false;
+
+ // perform sequence tests (XBridgeTest2)
+ // create the sequence which are compared with the results
+ bool arBool __gc[] = new bool __gc [3];
+ arBool[0] = true; arBool[1] = false; arBool[2] = true;
+ Char arChar[] = new Char[3];
+ arChar[0] = 'A'; arChar[1] = 'B'; arChar[2] = 'C';
+ Byte arByte[] = new Byte[3];
+ arByte[0] = 1; arByte[1] = 2; arByte[2] = 0xff;
+ Int16 arShort[] = new Int16[3];
+ arShort[0] = Int16::MinValue; arShort[1] = 1; arShort[2] = Int16::MaxValue;
+ UInt16 arUShort[] = new UInt16[3];
+ arUShort[0] = UInt16::MinValue; arUShort[1] = 1; arUShort[2] = UInt16::MaxValue;
+ Int32 arLong[] = new Int32[3];
+ arLong[0] = Int32::MinValue; arLong[1] = 1; arLong[2] = Int32::MaxValue;
+ UInt32 arULong[] = new UInt32[3];
+ arULong[0] = UInt32::MinValue; arULong[1] = 1; arULong[2] = UInt32::MaxValue;
+ Int64 arHyper[] = new Int64[3];
+ arHyper[0] = Int64::MinValue; arHyper[1] = 1; arHyper[2] = Int64::MaxValue;
+ UInt64 arUHyper[] = new UInt64[3];
+ arUHyper[0] = UInt64::MinValue; arUHyper[1] = 1;
+ arUHyper[2] = UInt64::MaxValue;
+ Single arFloat[] = new Single[3];
+ arFloat[0] = 1.1f; arFloat[1] = 2.2f; arFloat[2] = 3.3f;
+ Double arDouble[] = new Double[3];
+ arDouble[0] = 1.11; arDouble[1] = 2.22; arDouble[2] = 3.33;
+ String* arString[] = new String*[3];
+ arString[0] = new String("String 1");
+ arString[1] = new String("String 2");
+ arString[2] = new String("String 3");
+
+ Any arAny[] = new Any[3];
+ arAny[0] = Any(true); arAny[1] = Any(11111); arAny[2] = Any(3.14);
+ Object* arObject[] = new Object*[3];
+ arObject[0] = new WeakBase(); arObject[1] = new WeakBase();
+ arObject[1] = new WeakBase();
+
+ Console::WriteLine(new String("cli_cpp_bridgetest: Workaround for C++ compiler bug:"
+ " using Array of Int32 instead of Array of enums w"));
+ Int32 arEnum[] = new Int32[3];
+ arEnum[0] = static_cast<Int32>(TestEnum::ONE);
+ arEnum[1] = static_cast<Int32>(TestEnum::TWO);
+ arEnum[2] = static_cast<Int32>(TestEnum::CHECK);
+
+ TestElement* arStruct[] = new TestElement*[3];
+ arStruct[0] = new TestElement(); arStruct[1] = new TestElement();
+ arStruct[2] = new TestElement();
+ assign( arStruct[0], true, '@', 17, 0x1234, 0xfedc, 0x12345678, 0xfedcba98,
+ 0x123456789abcdef0, 0xfedcba9876543210, 17.0815f, M_PI,
+ TestEnum::LOLA, Constants::STRING_TEST_CONSTANT, 18, 0x5678, arObject[0],
+ Any( __typeof(Object), arObject[0]) );
+ assign( arStruct[1], true, 'A', 17, 0x1234, 0xfedc, 0x12345678, 0xfedcba98,
+ 0x123456789abcdef0, 0xfedcba9876543210, 17.0815f, M_PI,
+ TestEnum::TWO, Constants::STRING_TEST_CONSTANT, 18, 0x5678, arObject[1],
+ Any( __typeof(Object), arObject[1]) );
+ assign( arStruct[2], true, 'B', 17, 0x1234, 0xfedc, 0x12345678, 0xfedcba98,
+ 0x123456789abcdef0, 0xfedcba9876543210, 17.0815f, M_PI,
+ TestEnum::CHECK, Constants::STRING_TEST_CONSTANT, 18, 0x5678, arObject[2],
+ Any( __typeof(Object), arObject[2] ) );
+ {
+ Any seqAnyRet[] = xBT2->setSequenceAny(arAny);
+ bRet = check( compareData(seqAnyRet, arAny), "sequence test") && bRet;
+ Boolean seqBoolRet[] = xBT2->setSequenceBool(arBool);
+ bRet = check( compareData(seqBoolRet, arBool), "sequence test") && bRet;
+ Byte seqByteRet[] = xBT2->setSequenceByte(arByte);
+ bRet = check( compareData(seqByteRet, arByte), "sequence test") && bRet;
+ Char seqCharRet[] = xBT2->setSequenceChar(arChar);
+ bRet = check( compareData(seqCharRet, arChar), "sequence test") && bRet;
+ Int16 seqShortRet[] = xBT2->setSequenceShort(arShort);
+ bRet = check( compareData(seqShortRet, arShort), "sequence test") && bRet;
+ Int32 seqLongRet[] = xBT2->setSequenceLong(arLong);
+ bRet = check( compareData(seqLongRet, arLong), "sequence test") && bRet;
+ Int64 seqHyperRet[] = xBT2->setSequenceHyper(arHyper);
+ bRet = check( compareData(seqHyperRet,arHyper), "sequence test") && bRet;
+ Single seqFloatRet[] = xBT2->setSequenceFloat(arFloat);
+ bRet = check( compareData(seqFloatRet, arFloat), "sequence test") && bRet;
+ Double seqDoubleRet[] = xBT2->setSequenceDouble(arDouble);
+ bRet = check( compareData(seqDoubleRet, arDouble), "sequence test") && bRet;
+ xBT2->setSequenceEnum(arEnum);
+ //comparing seqEnumRet with arEnum will fail since they are of different
+ //types because of workaround. arEnum is Int32[].
+ Console::WriteLine(new String("cli_cpp_bridgetest: Test omitted because "
+ "of C++ compiler bug. XBridgeTest2::setSequenceEnum(sequence<TestEnum>)"));
+ UInt16 seqUShortRet[] = xBT2->setSequenceUShort(arUShort);
+ bRet = check( compareData(seqUShortRet, arUShort), "sequence test") && bRet;
+ UInt32 seqULongRet[] = xBT2->setSequenceULong(arULong);
+ bRet = check( compareData(seqULongRet, arULong), "sequence test") && bRet;
+ UInt64 seqUHyperRet[] = xBT2->setSequenceUHyper(arUHyper);
+ bRet = check( compareData(seqUHyperRet, arUHyper), "sequence test") && bRet;
+ Object* seqObjectRet[] = xBT2->setSequenceXInterface(arObject);
+ bRet = check( compareData(seqObjectRet, arObject), "sequence test") && bRet;
+ String* seqStringRet[] = xBT2->setSequenceString(arString);
+ bRet = check( compareData(seqStringRet, arString), "sequence test") && bRet;
+ TestElement* seqStructRet[] = xBT2->setSequenceStruct(arStruct);
+ bRet = check( compareData(seqStructRet, arStruct), "sequence test") && bRet;
+ }
+ {
+ Console::WriteLine(new String("cli_cpp_bridgetest: no test of "
+ "XBridgeTest2::setSequencesInOut and XBridgeTest2.setSequencesOut "
+ "because jagged arrays are not supported by C++ compiler"));
+ }
+ {
+ Any _arAny[] = new Any[0];
+ Any seqAnyRet[] = xBT2->setSequenceAny(_arAny);
+ bRet = check( compareData(seqAnyRet, _arAny), "sequence test") && bRet;
+ Boolean _arBool[] = new Boolean[0];
+ Boolean seqBoolRet[] = xBT2->setSequenceBool(_arBool);
+ bRet = check( compareData(seqBoolRet, _arBool), "sequence test") && bRet;
+ Byte _arByte[] = new Byte[0];
+ Byte seqByteRet[] = xBT2->setSequenceByte(_arByte);
+ bRet = check( compareData(seqByteRet, _arByte), "sequence test") && bRet;
+ Char _arChar[] = new Char[0];
+ Char seqCharRet[] = xBT2->setSequenceChar(_arChar);
+ bRet = check( compareData(seqCharRet, _arChar), "sequence test") && bRet;
+ Int16 _arShort[] = new Int16[0];
+ Int16 seqShortRet[] = xBT2->setSequenceShort(_arShort);
+ bRet = check( compareData(seqShortRet, _arShort), "sequence test") && bRet;
+ Int32 _arLong[] = new Int32[0];
+ Int32 seqLongRet[] = xBT2->setSequenceLong(_arLong);
+ bRet = check( compareData(seqLongRet, _arLong), "sequence test") && bRet;
+ Int64 _arHyper[] = new Int64[0];
+ Int64 seqHyperRet[] = xBT2->setSequenceHyper(_arHyper);
+ bRet = check( compareData(seqHyperRet, _arHyper), "sequence test") && bRet;
+ Single _arFloat[] = new Single[0];
+ Single seqFloatRet[] = xBT2->setSequenceFloat(_arFloat);
+ bRet = check( compareData(seqFloatRet, _arFloat), "sequence test") && bRet;
+ Double _arDouble[] = new Double[0];
+ Double seqDoubleRet[] = xBT2->setSequenceDouble(_arDouble);
+ bRet = check( compareData(seqDoubleRet, _arDouble), "sequence test") && bRet;
+ TestEnum _arEnum[] = new TestEnum[0];
+ xBT2->setSequenceEnum(_arEnum);
+ UInt16 _arUShort[] = new UInt16[0];
+ UInt16 seqUShortRet[] = xBT2->setSequenceUShort(_arUShort);
+ bRet = check( compareData(seqUShortRet, _arUShort), "sequence test") && bRet;
+ UInt32 _arULong[] = new UInt32[0];
+ UInt32 seqULongRet[] = xBT2->setSequenceULong(_arULong);
+ bRet = check( compareData(seqULongRet, _arULong), "sequence test") && bRet;
+ UInt64 _arUHyper[] = new UInt64[0];
+ UInt64 seqUHyperRet[] = xBT2->setSequenceUHyper(_arUHyper);
+ bRet = check( compareData(seqUHyperRet, _arUHyper), "sequence test") && bRet;
+ Object* _arObject[] = new Object*[0];
+ Object* seqObjectRet[] = xBT2->setSequenceXInterface(_arObject);
+ bRet = check( compareData(seqObjectRet, _arObject), "sequence test") && bRet;
+ String* _arString[] = new String*[0];
+ String* seqStringRet[] = xBT2->setSequenceString(_arString);
+ bRet = check( compareData(seqStringRet, _arString), "sequence test") && bRet;
+ TestElement* _arStruct[] = new TestElement*[0];
+ TestElement* seqStructRet[] = xBT2->setSequenceStruct(_arStruct);
+ bRet = check( compareData(seqStructRet, _arStruct), "sequence test") && bRet;
+
+ }
+ return bRet;
+}
+/** Test the System::Object method on the proxy object
+ */
+static bool testObjectMethodsImplementation(XBridgeTest* xLBT)
+{
+ bool ret = false;
+ Object* obj = new Object();
+ XBridgeTestBase* xBase = dynamic_cast<XBridgeTestBase*>(xLBT);
+ if (xBase == 0)
+ return false;
+ // Object.Equals
+ ret = xLBT->Equals(obj) == false;
+ ret = xLBT->Equals(xLBT) && ret;
+ ret = Object::Equals(obj, obj) && ret;
+ ret = Object::Equals(xLBT, xBase) && ret;
+ //Object.GetHashCode
+ // Don't know how to verify this. Currently it is not possible to get the object id from a proxy
+ int nHash = xLBT->GetHashCode();
+ ret = nHash == xBase->GetHashCode() && ret;
+
+ //Object.ToString
+ // Don't know how to verify this automatically.
+ String* s = xLBT->ToString();
+ ret = (s->Length > 0) && ret;
+ return ret;
+}
+
+
+static bool raiseOnewayException(XBridgeTest* xLBT)
+{
+ bool bReturn = true;
+ String* sCompare = Constants::STRING_TEST_CONSTANT;
+ try
+ {
+ // Note : the exception may fly or not (e.g. remote scenario).
+ // When it flies, it must contain the correct elements.
+ xLBT->raiseRuntimeExceptionOneway(sCompare, xLBT->Interface );
+ }
+ catch (RuntimeException* e )
+ {
+ bReturn = ( xLBT->Interface == e->Context );
+ }
+ return bReturn;
+}
+
+
+static bool raiseException(XBridgeTest* xLBT )
+{
+ int nCount = 0;
+ try
+ {
+ try
+ {
+ try
+ {
+ xLBT->raiseException(
+ 5, Constants::STRING_TEST_CONSTANT, xLBT->Interface );
+ }
+ catch (unoidl::com::sun::star::lang::IllegalArgumentException* aExc)
+ {
+ if (aExc->ArgumentPosition == 5 &&
+ aExc->Context == xLBT->Interface)
+ {
+ ++nCount;
+ }
+ else
+ {
+ check( false, "### unexpected exception content!" );
+ }
+
+ /** it is certain, that the RuntimeException testing will fail,
+ if no */
+ xLBT->RuntimeException = 0;
+ }
+ }
+ catch (unoidl::com::sun::star::uno::RuntimeException* rExc)
+ {
+ if (rExc->Context == xLBT->Interface )
+ {
+ ++nCount;
+ }
+ else
+ {
+ check( false, "### unexpected exception content!" );
+ }
+
+ /** it is certain, that the RuntimeException testing will fail, if no */
+ xLBT->RuntimeException = (int) 0xcafebabe;
+ }
+ }
+ catch (unoidl::com::sun::star::uno::Exception* rExc)
+ {
+ if (rExc->Context == xLBT->Interface)
+ {
+ ++nCount;
+ }
+ else
+
+ {
+ check( false, "### unexpected exception content!" );
+ }
+ return (nCount == 3);
+ }
+ return false;
+}
+
+ static private void perform_test( XBridgeTest* xLBT )
+ {
+ bool bRet= true;
+ bRet = check( performTest( xLBT ), "standard test" ) && bRet;
+ bRet = check( raiseException( xLBT ) , "exception test" )&& bRet;
+ bRet = check( raiseOnewayException( xLBT ), "oneway exception test" ) && bRet;
+ bRet = check( testObjectMethodsImplementation(xLBT), "object methods test") && bRet;
+ bRet = performQueryForUnknownType( xLBT ) && bRet;
+ if (! bRet)
+ {
+ throw new unoidl::com::sun::star::uno::RuntimeException(
+ new String("error: test failed!"), 0);
+ }
+ }
+ XComponentContext* m_xContext;
+
+ public:
+ explicit BridgeTest( XComponentContext* xContext )
+ {
+ m_xContext = xContext;
+ }
+
+
+ int run( String* args[] )
+ {
+ try
+ {
+ if (args->Length < 1)
+ {
+ throw new RuntimeException(
+ "missing argument for bridgetest!", this );
+ }
+ Object* test_obj =
+ m_xContext->getServiceManager()->createInstanceWithContext(
+ args[ 0 ], m_xContext );
+ if (test_obj == 0)
+ test_obj = m_xContext->getValueByName( args[ 0 ] ).Value;
+
+ Console::WriteLine(
+ "cli target bridgetest obj: {0}", test_obj->ToString() );
+ XBridgeTest* xTest = __try_cast<XBridgeTest*>(test_obj) ;
+ perform_test( xTest );
+ Console::WriteLine( "\n### cli_uno C++ bridgetest succeeded." );
+ return 0;
+ }
+ catch (unoidl::com::sun::star::uno::RuntimeException* )
+ {
+ throw;
+ }
+ catch (System::Exception* exc)
+ {
+ System::Text::StringBuilder* s = new System::Text::StringBuilder();
+ s->Append(S"cli_cpp_bridgetest: unexpected exception occurred in XMain::run. Original exception: ");
+ s->Append(exc->GetType()->Name);
+ s->Append(S"\n Message: ");
+ s->Append(exc->Message);
+ throw new unoidl::com::sun::star::uno::RuntimeException(
+ s->ToString(), 0);
+ }
+ }
+};
+
+}
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/testtools/source/bridgetest/cli/cli_cs_bridgetest.cs b/testtools/source/bridgetest/cli/cli_cs_bridgetest.cs
new file mode 100644
index 000000000..3552f3f73
--- /dev/null
+++ b/testtools/source/bridgetest/cli/cli_cs_bridgetest.cs
@@ -0,0 +1,1100 @@
+/*
+ * This file is part of the LibreOffice project.
+ *
+ * This Source Code Form is subject to the terms of the Mozilla Public
+ * License, v. 2.0. If a copy of the MPL was not distributed with this
+ * file, You can obtain one at http://mozilla.org/MPL/2.0/.
+ *
+ * This file incorporates work covered by the following license notice:
+ *
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed
+ * with this work for additional information regarding copyright
+ * ownership. The ASF licenses this file to you under the Apache
+ * License, Version 2.0 (the "License"); you may not use this file
+ * except in compliance with the License. You may obtain a copy of
+ * the License at http://www.apache.org/licenses/LICENSE-2.0 .
+ */
+
+using System;
+using System.Diagnostics;
+using System.Reflection;
+using uno;
+using uno.util;
+using unoidl.com.sun.star.uno;
+using unoidl.com.sun.star.lang;
+//using unoidl.com.sun.star.test.bridge;
+using unoidl.test.testtools.bridgetest;
+
+namespace foo
+{
+ public interface MyInterface
+ {
+ }
+}
+
+namespace cs_testobj
+{
+ class ORecursiveCall: WeakBase, XRecursiveCall
+ {
+ public void callRecursivly(XRecursiveCall xCall, int nToCall)
+ {
+ lock (this)
+ {
+ if (nToCall > 0)
+ {
+ nToCall --;
+ xCall.callRecursivly(this, nToCall);
+ }
+ }
+ }
+ };
+
+class Constants
+{
+ public const string STRING_TEST_CONSTANT = "\" paco\' chorizo\\\' \"\'";
+}
+
+public class BridgeTest : WeakBase, XMain
+{
+ static bool compareData(Object val1, Object val2)
+ {
+ if (val1 == null && val2 == null || val1 == val2)
+ return true;
+ if ((val1 == null && val2 != null) ||
+ (val1 != null && val2 == null) || val1.GetType() != val2.GetType())
+ return false;
+
+ bool ret = false;
+ Type t1 = val1.GetType();
+ //Sequence
+ if (t1.IsArray)
+ {
+ ret = compareSequence((Array) val1, (Array) val2);
+ }
+ //String
+ else if (t1 == typeof(string))
+ {
+ ret = (string) val1 == (string) val2;
+ }
+ // Interface implementation
+ else if (t1.GetInterfaces().Length > 0 && ! t1.IsValueType)
+ {
+ ret = val1 == val2;
+ }
+ // Struct
+ else if ( ! t1.IsValueType)
+ {
+ ret = compareStruct(val1, val2);
+ }
+ else if (t1 == typeof(Any))
+ {
+ Any a1 = (Any) val1;
+ Any a2 = (Any) val2;
+ ret = a1.Type == a2.Type && compareData(a1.Value, a2.Value);
+ }
+ else if (t1.IsValueType)
+ {
+ //Any, enum, int, bool char, float, double etc.
+ ret = val1.Equals(val2);
+ }
+ else
+ {
+ Debug.Assert(false);
+ }
+ return ret;
+ }
+
+ // Arrays have only one dimension
+ static bool compareSequence(Array ar1, Array ar2)
+ {
+ Debug.Assert(ar1 != null && ar2 != null);
+ Type t1 = ar1.GetType();
+ Type t2 = ar2.GetType();
+
+ if (!(ar1.Rank == 1 && ar2.Rank == 1
+ && ar1.Length == ar2.Length && t1.GetElementType() == t2.GetElementType()))
+ return false;
+
+ //arrays have same rank and size and element type.
+ int len = ar1.Length;
+ Type elemType = t1.GetElementType();
+ bool ret = true;
+ for (int i = 0; i < len; i++)
+ {
+ if (compareData(ar1.GetValue(i), ar2.GetValue(i)) == false)
+ {
+ ret = false;
+ break;
+ }
+ }
+ return ret;
+ }
+
+ static bool compareStruct(Object val1, Object val2)
+ {
+ Debug.Assert(val1 != null && val2 != null);
+ Type t1 = val1.GetType();
+ Type t2 = val2.GetType();
+ if (t1 != t2)
+ return false;
+ FieldInfo[] fields = t1.GetFields();
+ int cFields = fields.Length;
+ bool ret = true;
+ for (int i = 0; i < cFields; i++)
+ {
+ Object fieldVal1 = fields[i].GetValue(val1);
+ Object fieldVal2 = fields[i].GetValue(val2);
+ if ( ! compareData(fieldVal1, fieldVal2))
+ {
+ ret = false;
+ break;
+ }
+ }
+ return ret;
+ }
+
+ static bool check( bool b , string message )
+ {
+ if ( ! b)
+ Console.WriteLine("{0} failed\n" , message);
+ return b;
+ }
+
+ static bool equals(TestElement rData1, TestElement rData2)
+ {
+ check( rData1.Bool == rData2.Bool, "### bool does not match!" );
+ check( rData1.Char == rData2.Char, "### char does not match!" );
+ check( rData1.Byte == rData2.Byte, "### byte does not match!" );
+ check( rData1.Short == rData2.Short, "### short does not match!" );
+ check( rData1.UShort == rData2.UShort, "### unsigned short does not match!" );
+ check( rData1.Long == rData2.Long, "### long does not match!" );
+ check( rData1.ULong == rData2.ULong, "### unsigned long does not match!" );
+ check( rData1.Hyper == rData2.Hyper, "### hyper does not match!" );
+ check( rData1.UHyper == rData2.UHyper, "### unsigned hyper does not match!" );
+ check( rData1.Float == rData2.Float, "### float does not match!" );
+ check( rData1.Double == rData2.Double, "### double does not match!" );
+ check( rData1.Enum == rData2.Enum, "### enum does not match!" );
+ check( rData1.String == rData2.String, "### string does not match!" );
+ check( rData1.Byte2 == rData2.Byte2, "### byte2 does not match!" );
+ check( rData1.Short2 == rData2.Short2, "### short2 does not match!" );
+ check( rData1.Interface == rData2.Interface, "### interface does not match!" );
+ check( compareData(rData1.Any, rData2.Any), "### any does not match!" );
+
+ return (rData1.Bool == rData2.Bool &&
+ rData1.Char == rData2.Char &&
+ rData1.Byte == rData2.Byte &&
+ rData1.Short == rData2.Short &&
+ rData1.UShort == rData2.UShort &&
+ rData1.Long == rData2.Long &&
+ rData1.ULong == rData2.ULong &&
+ rData1.Hyper == rData2.Hyper &&
+ rData1.UHyper == rData2.UHyper &&
+ rData1.Float == rData2.Float &&
+ rData1.Double == rData2.Double &&
+ rData1.Enum == rData2.Enum &&
+ rData1.String == rData2.String &&
+ rData1.Byte2 == rData2.Byte2 &&
+ rData1.Short2 == rData2.Short2 &&
+ rData1.Interface == rData2.Interface &&
+ compareData(rData1.Any, rData2.Any));
+ }
+
+static void assign( TestElement rData,
+ bool bBool, char cChar, byte nByte,
+ short nShort, ushort nUShort,
+ int nLong, uint nULong,
+ long nHyper, ulong nUHyper,
+ float fFloat, double fDouble,
+ TestEnum eEnum, string rStr,
+ byte nByte2, short nShort2,
+ Object xTest,
+ Any rAny )
+{
+ rData.Bool = bBool;
+ rData.Char = cChar;
+ rData.Byte = nByte;
+ rData.Short = nShort;
+ rData.UShort = nUShort;
+ rData.Long = nLong;
+ rData.ULong = nULong;
+ rData.Hyper = nHyper;
+ rData.UHyper = nUHyper;
+ rData.Float = fFloat;
+ rData.Double = fDouble;
+ rData.Enum = eEnum;
+ rData.String = rStr;
+ rData.Byte2 = nByte2;
+ rData.Short2 = nShort2;
+ rData.Interface = xTest;
+ rData.Any = rAny;
+}
+
+static void assign( TestDataElements rData,
+ bool bBool, char cChar, byte nByte,
+ short nShort, ushort nUShort,
+ int nLong, uint nULong,
+ long nHyper, ulong nUHyper,
+ float fFloat, double fDouble,
+ TestEnum eEnum, string rStr,
+ byte nByte2, short nShort2,
+ Object xTest,
+ Any rAny,
+ TestElement[] rSequence)
+{
+ assign( (TestElement) rData,
+ bBool, cChar, nByte, nShort, nUShort, nLong, nULong, nHyper, nUHyper, fFloat, fDouble,
+ eEnum, rStr, nByte2, nShort2, xTest, rAny );
+ rData.Sequence = rSequence;
+}
+
+// template < class type >
+static bool testAny(Type typ, Object value, XBridgeTest xLBT )
+{
+ Any any;
+ if (typ == null)
+ any = new Any(value.GetType(), value);
+ else
+ any = new Any(typ, value);
+
+ Any any2 = xLBT.transportAny(any);
+ bool ret;
+ if( ! (ret= compareData(any, any2)))
+ {
+ Console.WriteLine("any is different after roundtrip: in {0}, out {1}\n",
+ any.Type.FullName, any2.Type.FullName);
+ }
+ return ret;
+}
+
+
+
+static bool performAnyTest(XBridgeTest xLBT, TestDataElements data)
+{
+ bool bReturn = true;
+ bReturn = testAny( null, data.Byte ,xLBT ) && bReturn;
+ bReturn = testAny( null, data.Short,xLBT ) && bReturn;
+ bReturn = testAny( null, data.UShort,xLBT ) && bReturn;
+ bReturn = testAny( null, data.Long,xLBT ) && bReturn;
+ bReturn = testAny( null, data.ULong,xLBT ) && bReturn;
+ bReturn = testAny( null, data.Hyper,xLBT ) && bReturn;
+ bReturn = testAny( null,data.UHyper,xLBT ) && bReturn;
+ bReturn = testAny( null, data.Float,xLBT ) && bReturn;
+ bReturn = testAny( null, data.Double,xLBT ) && bReturn;
+ bReturn = testAny( null, data.Enum,xLBT ) && bReturn;
+ bReturn = testAny( null, data.String,xLBT ) && bReturn;
+ bReturn = testAny( null, data.Byte2 ,xLBT ) && bReturn;
+ bReturn = testAny( null, data.Short2,xLBT ) && bReturn;
+ bReturn = testAny(typeof(XWeak), data.Interface,xLBT ) && bReturn;
+ bReturn = testAny(null, data, xLBT ) && bReturn;
+
+ {
+ Any a1= new Any(true);
+ Any a2 = xLBT.transportAny( a1 );
+ bReturn = compareData(a2, a1) && bReturn;
+ }
+
+ {
+ Any a1= new Any('A');
+ Any a2 = xLBT.transportAny(a1);
+ bReturn = compareData(a2, a1) && bReturn;
+ }
+ return bReturn;
+}
+
+static bool performSequenceOfCallTest(XBridgeTest xLBT)
+{
+ int i,nRounds;
+ int nGlobalIndex = 0;
+ const int nWaitTimeSpanMUSec = 10000;
+ for( nRounds = 0 ; nRounds < 10 ; nRounds ++ )
+ {
+ for( i = 0 ; i < nRounds ; i ++ )
+ {
+ // fire oneways
+ xLBT.callOneway(nGlobalIndex, nWaitTimeSpanMUSec);
+ nGlobalIndex++;
+ }
+
+ // call synchron
+ xLBT.call(nGlobalIndex, nWaitTimeSpanMUSec);
+ nGlobalIndex++;
+ }
+ return xLBT.sequenceOfCallTestPassed();
+}
+
+
+
+
+static bool performRecursiveCallTest(XBridgeTest xLBT)
+{
+ xLBT.startRecursiveCall(new ORecursiveCall(), 50);
+ // on failure, the test would lock up or crash
+ return true;
+}
+
+static bool performQueryForUnknownType(XBridgeTest xLBT)
+{
+ bool bRet = false;
+ // test queryInterface for an unknown type
+ try
+ {
+ foo.MyInterface a = (foo.MyInterface) xLBT;
+ }
+ catch( System.InvalidCastException)
+ {
+ bRet = true;
+ }
+
+ return bRet;
+}
+
+
+bool performTest(XBridgeTest xLBT)
+{
+ check( xLBT != null, "### no test interface!" );
+ bool bRet = true;
+ if (xLBT == null)
+ return false;
+
+ // this data is never ever granted access to by calls other than equals(), assign()!
+ TestDataElements aData = new TestDataElements(); // test against this data
+
+ Object xI= new WeakBase();
+
+ Any aAny = new Any( typeof(Object), xI);
+ assign( (TestElement)aData,
+ true, '@', 17, 0x1234, 0xfedc, 0x12345678, 0xfedcba98,
+ 0x123456789abcdef0, 0xfedcba9876543210,
+ 17.0815f, 3.1415926359, TestEnum.LOLA,
+ Constants.STRING_TEST_CONSTANT, xI,
+ aAny);
+
+ bRet = check( aData.Any.Value == xI, "### unexpected any!" ) && bRet;
+ bRet = check( !(aData.Any.Value != xI), "### unexpected any!" ) && bRet;
+
+ aData.Sequence = new TestElement[2];
+ aData.Sequence[0] = new TestElement(
+ aData.Bool, aData.Char, aData.Byte, aData.Short,
+ aData.UShort, aData.Long, aData.ULong,
+ aData.Hyper, aData.UHyper, aData.Float,
+ aData.Double, aData.Enum, aData.String,
+ aData.Byte2, aData.Short2,
+ aData.Interface, aData.Any); //(TestElement) aData;
+ aData.Sequence[1] = new TestElement(); //is empty
+
+ // aData complete
+
+ // this is a manually copy of aData for first setting...
+ TestDataElements aSetData = new TestDataElements();
+ Any aAnySet= new Any(typeof(Object), xI);
+ assign( (TestElement)aSetData,
+ aData.Bool, aData.Char, aData.Byte, aData.Short, aData.UShort,
+ aData.Long, aData.ULong, aData.Hyper, aData.UHyper, aData.Float, aData.Double,
+ aData.Enum, aData.String, aData.Byte2, aData.Short2, xI,
+ aAnySet);
+
+ aSetData.Sequence = new TestElement[2];
+ aSetData.Sequence[0] = new TestElement(
+ aSetData.Bool, aSetData.Char, aSetData.Byte, aSetData.Short,
+ aSetData.UShort, aSetData.Long, aSetData.ULong,
+ aSetData.Hyper, aSetData.UHyper, aSetData.Float,
+ aSetData.Double, aSetData.Enum, aSetData.String,
+ aSetData.Byte2, aSetData.Short2,
+ aSetData.Interface, aSetData.Any); //TestElement) aSetData;
+ aSetData.Sequence[1] = new TestElement(); // empty struct
+
+ xLBT.setValues(
+ aSetData.Bool,
+ aSetData.Char,
+ aSetData.Byte,
+ aSetData.Short,
+ aSetData.UShort,
+ aSetData.Long,
+ aSetData.ULong,
+ aSetData.Hyper,
+ aSetData.UHyper,
+ aSetData.Float,
+ aSetData.Double,
+ aSetData.Enum,
+ aSetData.String,
+ aSetData.Byte2,
+ aSetData.Short2,
+ aSetData.Interface,
+ aSetData.Any,
+ aSetData.Sequence,
+ aSetData );
+
+ {
+ TestDataElements aRet = new TestDataElements();
+ TestDataElements aRet2 = new TestDataElements();
+ xLBT.getValues(
+ out aRet.Bool,
+ out aRet.Char,
+ out aRet.Byte,
+ out aRet.Short,
+ out aRet.UShort,
+ out aRet.Long,
+ out aRet.ULong,
+ out aRet.Hyper,
+ out aRet.UHyper,
+ out aRet.Float,
+ out aRet.Double,
+ out aRet.Enum,
+ out aRet.String,
+ out aRet.Byte2,
+ out aRet.Short2,
+ out aRet.Interface,
+ out aRet.Any,
+ out aRet.Sequence,
+ out aRet2 );
+
+ bRet = check( compareData( aData, aRet ) && compareData( aData, aRet2 ) , "getValues test") && bRet;
+
+ // set last retrieved values
+ TestDataElements aSV2ret = xLBT.setValues2(
+ ref aRet.Bool,
+ ref aRet.Char,
+ ref aRet.Byte,
+ ref aRet.Short,
+ ref aRet.UShort,
+ ref aRet.Long,
+ ref aRet.ULong,
+ ref aRet.Hyper,
+ ref aRet.UHyper,
+ ref aRet.Float,
+ ref aRet.Double,
+ ref aRet.Enum,
+ ref aRet.String,
+ ref aRet.Byte2,
+ ref aRet.Short2,
+ ref aRet.Interface,
+ ref aRet.Any,
+ ref aRet.Sequence,
+ ref aRet2 );
+
+ // check inout sequence order
+ // => inout sequence parameter was switched by test objects
+ TestElement temp = aRet.Sequence[ 0 ];
+ aRet.Sequence[ 0 ] = aRet.Sequence[ 1 ];
+ aRet.Sequence[ 1 ] = temp;
+
+ bRet = check(
+ compareData( aData, aSV2ret ) && compareData( aData, aRet2 ),
+ "getValues2 test") && bRet;
+ }
+ {
+ TestDataElements aRet = new TestDataElements();
+ TestDataElements aRet2 = new TestDataElements();
+ TestDataElements aGVret = xLBT.getValues(
+ out aRet.Bool,
+ out aRet.Char,
+ out aRet.Byte,
+ out aRet.Short,
+ out aRet.UShort,
+ out aRet.Long,
+ out aRet.ULong,
+ out aRet.Hyper,
+ out aRet.UHyper,
+ out aRet.Float,
+ out aRet.Double,
+ out aRet.Enum,
+ out aRet.String,
+ out aRet.Byte2,
+ out aRet.Short2,
+ out aRet.Interface,
+ out aRet.Any,
+ out aRet.Sequence,
+ out aRet2 );
+
+ bRet = check( compareData( aData, aRet ) && compareData( aData, aRet2 ) && compareData( aData, aGVret ), "getValues test" ) && bRet;
+
+ // set last retrieved values
+ xLBT.Bool = aRet.Bool;
+ xLBT.Char = aRet.Char;
+ xLBT.Byte = aRet.Byte;
+ xLBT.Short = aRet.Short;
+ xLBT.UShort = aRet.UShort;
+ xLBT.Long = aRet.Long;
+ xLBT.ULong = aRet.ULong;
+ xLBT.Hyper = aRet.Hyper;
+ xLBT.UHyper = aRet.UHyper;
+ xLBT.Float = aRet.Float;
+ xLBT.Double = aRet.Double;
+ xLBT.Enum = aRet.Enum;
+ xLBT.String = aRet.String;
+ xLBT.Byte2 = aRet.Byte2;
+ xLBT.Short2 = aRet.Short2;
+ xLBT.Interface = aRet.Interface;
+ xLBT.Any = aRet.Any;
+ xLBT.Sequence = aRet.Sequence;
+ xLBT.Struct = aRet2;
+ }
+ {
+ TestDataElements aRet = new TestDataElements();
+ TestDataElements aRet2 = new TestDataElements();
+ aRet.Hyper = xLBT.Hyper;
+ aRet.UHyper = xLBT.UHyper;
+ aRet.Float = xLBT.Float;
+ aRet.Double = xLBT.Double;
+ aRet.Byte = xLBT.Byte;
+ aRet.Char = xLBT.Char;
+ aRet.Bool = xLBT.Bool;
+ aRet.Short = xLBT.Short;
+ aRet.UShort = xLBT.UShort;
+ aRet.Long = xLBT.Long;
+ aRet.ULong = xLBT.ULong;
+ aRet.Enum = xLBT.Enum;
+ aRet.String = xLBT.String;
+ aRet.Byte2 = xLBT.Byte2;
+ aRet.Short2 = xLBT.Short2;
+ aRet.Interface = xLBT.Interface;
+ aRet.Any = xLBT.Any;
+ aRet.Sequence = xLBT.Sequence;
+ aRet2 = xLBT.Struct;
+
+ bRet = check( compareData( aData, aRet ) && compareData( aData, aRet2 ) , "struct comparison test") && bRet;
+
+ bRet = check(performSequenceTest(xLBT), "sequence test") && bRet;
+
+ // any test
+ bRet = check( performAnyTest( xLBT , aData ) , "any test" ) && bRet;
+
+ // sequence of call test
+ bRet = check( performSequenceOfCallTest( xLBT ) , "sequence of call test" ) && bRet;
+
+ // recursive call test
+ bRet = check( performRecursiveCallTest( xLBT ) , "recursive test" ) && bRet;
+
+ bRet = (compareData( aData, aRet ) && compareData( aData, aRet2 )) && bRet ;
+
+ // check setting of null reference
+ xLBT.Interface = null;
+ aRet.Interface = xLBT.Interface;
+ bRet = (aRet.Interface == null) && bRet;
+
+ }
+ // Test extended attributes that raise exceptions:
+ try {
+ int i = xLBT.RaiseAttr1;
+ bRet &= check(false, "getRaiseAttr1 did not throw");
+ } catch (RuntimeException )
+ {
+ }
+ catch (System.Exception) {
+ bRet &= check(false, "getRaiseAttr1 threw wrong type");
+ }
+ try {
+ xLBT.RaiseAttr1 = 0;
+ bRet &= check(false, "setRaiseAttr1 did not throw");
+ } catch (IllegalArgumentException) {
+ } catch (System.Exception) {
+ bRet &= check(false, "setRaiseAttr1 threw wrong type");
+ }
+ try {
+ int i = xLBT.RaiseAttr2;
+ bRet &= check(false, "getRaiseAttr2 did not throw");
+ } catch (IllegalArgumentException ) {
+ } catch (System.Exception) {
+ bRet &= check(false, "getRaiseAttr2 threw wrong type");
+ }
+
+ // Test instantiated polymorphic struct types:
+ {
+ TestPolyStruct poly = new TestPolyStruct(true);
+ bRet &= check(
+ (bool) xLBT.transportPolyBoolean(poly).member,
+ "transportPolyBoolean");
+ poly = new TestPolyStruct(12345L);
+ xLBT.transportPolyHyper(ref poly);
+ bRet &= check((long)poly.member == 12345L, "transportPolyUnsignedHyper");
+
+ Any[] seq = { new Any(33), new Any("ABC")};
+ poly = new TestPolyStruct(seq);
+ TestPolyStruct poly2;
+ xLBT.transportPolySequence(poly, out poly2);
+ try {
+ Any[] ar = (Any[]) poly2.member;
+ bRet &= check(
+ ar.Length == 2, "transportPolySequence, length");
+
+ int v0;
+ v0 = (int) ar[0].Value;
+ bRet &= check(v0 == 33, "transportPolySequence, element 0");
+
+ string v1 = (string) ar[1].Value;
+ bRet &= check(
+ v1.Equals("ABC"),
+ "transportPolySequence, element 1");
+ } catch (InvalidCastException )
+ {
+ bRet &= check(false, "transportPolySequence");
+ }
+
+ try {
+ //When the test object is a cli object then them member is null
+ //otherwise the bridge has provided a default value.
+ TestPolyStruct s = xLBT.getNullPolyLong();
+ if (s.member != null)
+ bRet &= check(((int) s.member) == 0, "getNullPolyLong");
+
+ s = xLBT.getNullPolyString();
+ if (s.member != null)
+ bRet &= check(((string) s.member).Length == 0,
+ "getNullPolyString");
+ s = xLBT.getNullPolyType();
+ if (s.member != null)
+ bRet &= check(((Type) s.member) == typeof(void),
+ "getNullPolyType");
+ s = xLBT.getNullPolyAny();
+ if (s.member != null)
+ {
+ Any nullAny = (Any) s.member;
+ //???
+ bRet &= check(nullAny.Type == typeof(void),
+ "getNullPolyAny");
+ }
+ s = xLBT.getNullPolySequence();
+ if (s.member != null)
+ bRet &= check(((bool[]) s.member).Length == 0,
+ "getNullPolySequence");
+ s = xLBT.getNullPolyEnum();
+ if (s.member != null)
+ bRet &= check(((TestEnum) s.member) == TestEnum.TEST,
+ "getNullPolyEnum");
+ s = xLBT.getNullPolyStruct();
+ if (s.member != null)
+ bRet &= check(((TestStruct) s.member).member == 0,
+ "getNullPolyStruct");
+ s = xLBT.getNullPolyInterface();
+ bRet &= check(s.member == null, "getNullPolyInterface");
+
+ s = xLBT.getNullPolyBadEnum();
+ bRet &= check(((TestBadEnum)s.member) == TestBadEnum.M, "getNullPolyBadEnum");
+
+ } catch(InvalidCastException)
+ {
+ bRet &= check(false, "getNullPolyXXX, InvalidCastException");
+ }
+
+ }
+
+ XBridgeTest2 xBT2 = xLBT as XBridgeTest2;
+ if (xBT2 != null) {
+ try {
+ xBT2.testConstructorsService(m_xContext);
+ } catch (BadConstructorArguments) {
+ bRet = false;
+ }
+ }
+
+ return bRet;
+}
+static bool performSequenceTest(XBridgeTest xBT)
+{
+ bool bRet = true;
+ XBridgeTest2 xBT2 = xBT as XBridgeTest2;
+ if ( xBT2 == null)
+ return false;
+
+ // perform sequence tests (XBridgeTest2)
+ // create the sequence which are compared with the results
+ bool[] arBool = {true, false, true};
+ char[] arChar = {'A','B','C'};
+ byte[] arByte = { 1, 2, 0xff};
+ short[] arShort = {Int16.MinValue, 1, Int16.MaxValue};
+ UInt16[] arUShort = {UInt16.MinValue , 1, UInt16.MaxValue};
+ int[] arLong = {Int32.MinValue, 1, Int32.MaxValue};
+ UInt32[] arULong = {UInt32.MinValue, 1, UInt32.MaxValue};
+ long[] arHyper = {Int64.MinValue, 1, Int64.MaxValue};
+ UInt64[] arUHyper = {UInt64.MinValue, 1, UInt64.MaxValue};
+ float[] arFloat = {1.1f, 2.2f, 3.3f};
+ double[] arDouble = {1.11, 2.22, 3.33};
+ string[] arString = {"String 1", "String 2", "String 3"};
+
+ Any[] arAny = {new Any(true), new Any(11111), new Any(3.14)};
+ Object[] arObject = {new WeakBase(), new WeakBase(), new WeakBase()};
+ TestEnum[] arEnum = {TestEnum.ONE, TestEnum.TWO, TestEnum.CHECK};
+
+ TestElement[] arStruct = {new TestElement(), new TestElement(),
+ new TestElement()};
+ assign( arStruct[0], true, '@', 17, 0x1234, 0xfedc, 0x12345678, 0xfedcba98,
+ 0x123456789abcdef0, 0xfedcba9876543210, 17.0815f, 3.1415926359,
+ TestEnum.LOLA, Constants.STRING_TEST_CONSTANT, arObject[0],
+ new Any( typeof(Object), arObject[0]) );
+ assign( arStruct[1], true, 'A', 17, 0x1234, 0xfedc, 0x12345678, 0xfedcba98,
+ 0x123456789abcdef0, 0xfedcba9876543210, 17.0815f, 3.1415926359,
+ TestEnum.TWO, Constants.STRING_TEST_CONSTANT, arObject[1],
+ new Any( typeof(Object), arObject[1]) );
+ assign( arStruct[2], true, 'B', 17, 0x1234, 0xfedc, 0x12345678, 0xfedcba98,
+ 0x123456789abcdef0, 0xfedcba9876543210, 17.0815f, 3.1415926359,
+ TestEnum.CHECK, Constants.STRING_TEST_CONSTANT, arObject[2],
+ new Any( typeof(Object), arObject[2] ) );
+
+
+ int[][][] arLong3 = new int[][][]{
+ new int[][]{new int[]{1,2,3},new int[]{4,5,6}, new int[]{7,8,9} },
+ new int [][]{new int[]{1,2,3},new int[]{4,5,6}, new int[]{7,8,9}},
+ new int[][]{new int[]{1,2,3},new int[]{4,5,6}, new int[]{7,8,9}}};
+
+ {
+ int[][] seqSeqRet = xBT2.setDim2(arLong3[0]);
+ bRet = check( compareData(seqSeqRet, arLong3[0]), "sequence test") && bRet;
+ int[][][] seqSeqRet2 = xBT2.setDim3(arLong3);
+ bRet = check( compareData(seqSeqRet2, arLong3), "sequence test") && bRet;
+ Any[] seqAnyRet = xBT2.setSequenceAny(arAny);
+ bRet = check( compareData(seqAnyRet, arAny), "sequence test") && bRet;
+ bool[] seqBoolRet = xBT2.setSequenceBool(arBool);
+ bRet = check( compareData(seqBoolRet, arBool), "sequence test") && bRet;
+ byte[] seqByteRet = xBT2.setSequenceByte(arByte);
+ bRet = check( compareData(seqByteRet, arByte), "sequence test") && bRet;
+ char[] seqCharRet = xBT2.setSequenceChar(arChar);
+ bRet = check( compareData(seqCharRet, arChar), "sequence test") && bRet;
+ short[] seqShortRet = xBT2.setSequenceShort(arShort);
+ bRet = check( compareData(seqShortRet, arShort), "sequence test") && bRet;
+ int[] seqLongRet = xBT2.setSequenceLong(arLong);
+ bRet = check( compareData(seqLongRet, arLong), "sequence test") && bRet;
+ long[] seqHyperRet = xBT2.setSequenceHyper(arHyper);
+ bRet = check( compareData(seqHyperRet,arHyper), "sequence test") && bRet;
+ float[] seqFloatRet = xBT2.setSequenceFloat(arFloat);
+ bRet = check( compareData(seqFloatRet, arFloat), "sequence test") && bRet;
+ double[] seqDoubleRet = xBT2.setSequenceDouble(arDouble);
+ bRet = check( compareData(seqDoubleRet, arDouble), "sequence test") && bRet;
+ TestEnum[] seqEnumRet = xBT2.setSequenceEnum(arEnum);
+ bRet = check( compareData(seqEnumRet, arEnum), "sequence test") && bRet;
+ UInt16[] seqUShortRet = xBT2.setSequenceUShort(arUShort);
+ bRet = check( compareData(seqUShortRet, arUShort), "sequence test") && bRet;
+ UInt32[] seqULongRet = xBT2.setSequenceULong(arULong);
+ bRet = check( compareData(seqULongRet, arULong), "sequence test") && bRet;
+ UInt64[] seqUHyperRet = xBT2.setSequenceUHyper(arUHyper);
+ bRet = check( compareData(seqUHyperRet, arUHyper), "sequence test") && bRet;
+ Object[] seqObjectRet = xBT2.setSequenceXInterface(arObject);
+ bRet = check( compareData(seqObjectRet, arObject), "sequence test") && bRet;
+ string[] seqStringRet = xBT2.setSequenceString(arString);
+ bRet = check( compareData(seqStringRet, arString), "sequence test") && bRet;
+ TestElement[] seqStructRet = xBT2.setSequenceStruct(arStruct);
+ bRet = check( compareData(seqStructRet, arStruct), "sequence test") && bRet;
+ }
+ {
+ bool[] arBoolTemp = (bool[]) arBool.Clone();
+ char[] arCharTemp = (char[]) arChar.Clone();
+ byte[] arByteTemp = (byte[]) arByte.Clone();
+ short[] arShortTemp = (short[]) arShort.Clone();
+ UInt16[] arUShortTemp = (UInt16[]) arUShort.Clone();
+ int[] arLongTemp = (int[]) arLong.Clone();
+ UInt32[] arULongTemp = (UInt32[]) arULong.Clone();
+ long[] arHyperTemp = (long[]) arHyper.Clone();
+ UInt64[] arUHyperTemp = (UInt64[]) arUHyper.Clone();
+ float[] arFloatTemp = (float[]) arFloat.Clone();
+ double[] arDoubleTemp = (double[]) arDouble.Clone();
+ TestEnum[] arEnumTemp = (TestEnum[]) arEnum.Clone();
+ string[] arStringTemp = (string[]) arString.Clone();
+ Object[] arObjectTemp = (Object[]) arObject.Clone();
+ Any[] arAnyTemp = (Any[]) arAny.Clone();
+ // make sure this are has the same contents as arLong3[0]
+ int[][] arLong2Temp = new int[][]{new int[]{1,2,3},new int[]{4,5,6}, new int[]{7,8,9} };
+ // make sure this are has the same contents as arLong3
+ int[][][] arLong3Temp = new int[][][]{
+ new int[][]{new int[]{1,2,3},new int[]{4,5,6}, new int[]{7,8,9} },
+ new int [][]{new int[]{1,2,3},new int[]{4,5,6}, new int[]{7,8,9}},
+ new int[][]{new int[]{1,2,3},new int[]{4,5,6}, new int[]{7,8,9}}};
+
+ xBT2.setSequencesInOut(ref arBoolTemp, ref arCharTemp, ref arByteTemp,
+ ref arShortTemp, ref arUShortTemp, ref arLongTemp,
+ ref arULongTemp,ref arHyperTemp, ref arUHyperTemp,
+ ref arFloatTemp,ref arDoubleTemp, ref arEnumTemp,
+ ref arStringTemp, ref arObjectTemp,
+ ref arAnyTemp, ref arLong2Temp, ref arLong3Temp);
+ bRet = check(
+ compareData(arBoolTemp, arBool) &&
+ compareData(arCharTemp , arChar) &&
+ compareData(arByteTemp , arByte) &&
+ compareData(arShortTemp , arShort) &&
+ compareData(arUShortTemp , arUShort) &&
+ compareData(arLongTemp , arLong) &&
+ compareData(arULongTemp , arULong) &&
+ compareData(arHyperTemp , arHyper) &&
+ compareData(arUHyperTemp , arUHyper) &&
+ compareData(arFloatTemp , arFloat) &&
+ compareData(arDoubleTemp , arDouble) &&
+ compareData(arEnumTemp , arEnum) &&
+ compareData(arStringTemp , arString) &&
+ compareData(arObjectTemp , arObject) &&
+ compareData(arAnyTemp , arAny) &&
+ compareData(arLong2Temp , arLong3[0]) &&
+ compareData(arLong3Temp , arLong3), "sequence test") && bRet;
+
+ bool[] arBoolOut;
+ char[] arCharOut;
+ byte[] arByteOut;
+ short[] arShortOut;
+ UInt16[] arUShortOut;
+ int[] arLongOut;
+ UInt32[] arULongOut;
+ long[] arHyperOut;
+ UInt64[] arUHyperOut;
+ float[] arFloatOut;
+ double[] arDoubleOut;
+ TestEnum[] arEnumOut;
+ string[] arStringOut;
+ Object[] arObjectOut;
+ Any[] arAnyOut;
+ int[][] arLong2Out;
+ int[][][] arLong3Out;
+
+ xBT2.setSequencesOut(out arBoolOut, out arCharOut, out arByteOut,
+ out arShortOut, out arUShortOut, out arLongOut,
+ out arULongOut, out arHyperOut, out arUHyperOut,
+ out arFloatOut, out arDoubleOut, out arEnumOut,
+ out arStringOut, out arObjectOut, out arAnyOut,
+ out arLong2Out, out arLong3Out);
+ bRet = check(
+ compareData(arBoolOut, arBool) &&
+ compareData(arCharOut, arChar) &&
+ compareData(arByteOut, arByte) &&
+ compareData(arShortOut, arShort) &&
+ compareData(arUShortOut, arUShort) &&
+ compareData(arLongOut, arLong) &&
+ compareData(arULongOut, arULong) &&
+ compareData(arHyperOut, arHyper) &&
+ compareData(arUHyperOut, arUHyper) &&
+ compareData(arFloatOut, arFloat) &&
+ compareData(arDoubleOut, arDouble) &&
+ compareData(arEnumOut, arEnum) &&
+ compareData(arStringOut, arString) &&
+ compareData(arObjectOut, arObject) &&
+ compareData(arAnyOut, arAny) &&
+ compareData(arLong2Out, arLong3[0]) &&
+ compareData(arLong3Out, arLong3), "sequence test") && bRet;
+ }
+ {
+ //test with empty sequences
+ int[][] _arLong2 = new int[0][];
+ int[][] seqSeqRet = xBT2.setDim2(_arLong2);
+ bRet = check( compareData(seqSeqRet, _arLong2), "sequence test") && bRet;
+ int[][][] _arLong3 = new int[0][][];
+ int[][][] seqSeqRet2 = xBT2.setDim3(_arLong3);
+ bRet = check( compareData(seqSeqRet2, _arLong3), "sequence test") && bRet;
+ Any[] _arAny = new Any[0];
+ Any[] seqAnyRet = xBT2.setSequenceAny(_arAny);
+ bRet = check( compareData(seqAnyRet, _arAny), "sequence test") && bRet;
+ bool[] _arBool = new bool[0];
+ bool[] seqBoolRet = xBT2.setSequenceBool(_arBool);
+ bRet = check( compareData(seqBoolRet, _arBool), "sequence test") && bRet;
+ byte[] _arByte = new byte[0];
+ byte[] seqByteRet = xBT2.setSequenceByte(_arByte);
+ bRet = check( compareData(seqByteRet, _arByte), "sequence test") && bRet;
+ char[] _arChar = new char[0];
+ char[] seqCharRet = xBT2.setSequenceChar(_arChar);
+ bRet = check( compareData(seqCharRet, _arChar), "sequence test") && bRet;
+ short[] _arShort = new short[0];
+ short[] seqShortRet = xBT2.setSequenceShort(_arShort);
+ bRet = check( compareData(seqShortRet, _arShort), "sequence test") && bRet;
+ int[] _arLong = new int[0];
+ int[] seqLongRet = xBT2.setSequenceLong(_arLong);
+ bRet = check( compareData(seqLongRet, _arLong), "sequence test") && bRet;
+ long[] _arHyper = new long[0];
+ long[] seqHyperRet = xBT2.setSequenceHyper(_arHyper);
+ bRet = check( compareData(seqHyperRet, _arHyper), "sequence test") && bRet;
+ float[] _arFloat = new float[0];
+ float[] seqFloatRet = xBT2.setSequenceFloat(_arFloat);
+ bRet = check( compareData(seqFloatRet, _arFloat), "sequence test") && bRet;
+ double[] _arDouble = new double[0];
+ double[] seqDoubleRet = xBT2.setSequenceDouble(_arDouble);
+ bRet = check( compareData(seqDoubleRet, _arDouble), "sequence test") && bRet;
+ TestEnum[] _arEnum = new TestEnum[0];
+ TestEnum[] seqEnumRet = xBT2.setSequenceEnum(_arEnum);
+ bRet = check( compareData(seqEnumRet, _arEnum), "sequence test") && bRet;
+ UInt16[] _arUShort = new UInt16[0];
+ UInt16[] seqUShortRet = xBT2.setSequenceUShort(_arUShort);
+ bRet = check( compareData(seqUShortRet, _arUShort), "sequence test") && bRet;
+ UInt32[] _arULong = new UInt32[0];
+ UInt32[] seqULongRet = xBT2.setSequenceULong(_arULong);
+ bRet = check( compareData(seqULongRet, _arULong), "sequence test") && bRet;
+ UInt64[] _arUHyper = new UInt64[0];
+ UInt64[] seqUHyperRet = xBT2.setSequenceUHyper(_arUHyper);
+ bRet = check( compareData(seqUHyperRet, _arUHyper), "sequence test") && bRet;
+ Object[] _arObject = new Object[0];
+ Object[] seqObjectRet = xBT2.setSequenceXInterface(_arObject);
+ bRet = check( compareData(seqObjectRet, _arObject), "sequence test") && bRet;
+ string[] _arString = new string[0];
+ string[] seqStringRet = xBT2.setSequenceString(_arString);
+ bRet = check( compareData(seqStringRet, _arString), "sequence test") && bRet;
+ TestElement[] _arStruct = new TestElement[0];
+ TestElement[] seqStructRet = xBT2.setSequenceStruct(_arStruct);
+ bRet = check( compareData(seqStructRet, _arStruct), "sequence test") && bRet;
+
+ }
+
+
+ return bRet;
+}
+/** Test the System::Object method on the proxy object
+ */
+static bool testObjectMethodsImplementetion(XBridgeTest xLBT)
+{
+ bool ret = false;
+ Object obj = new Object();
+ Object xInt = (Object) xLBT;
+ XBridgeTestBase xBase = xLBT as XBridgeTestBase;
+ if (xBase == null)
+ return false;
+ // Object.Equals
+ ret = xLBT.Equals(obj) == false;
+ ret = xLBT.Equals(xLBT) && ret;
+ ret = Object.Equals(obj, obj) && ret;
+ ret = Object.Equals(xLBT, xBase) && ret;
+ //Object.GetHashCode
+ // Don't know how to verify this. Currently it is not possible to get the object id from a proxy
+ int nHash = xLBT.GetHashCode();
+ ret = nHash == xBase.GetHashCode() && ret;
+
+ //Object.ToString
+ // Don't know how to verify this automatically.
+ string s = xLBT.ToString();
+ ret = (s.Length > 0) && ret;
+ return ret;
+}
+
+
+static bool raiseOnewayException(XBridgeTest xLBT)
+{
+ bool bReturn = true;
+ string sCompare = Constants.STRING_TEST_CONSTANT;
+ try
+ {
+ // Note : the exception may fly or not (e.g. remote scenario).
+ // When it flies, it must contain the correct elements.
+ xLBT.raiseRuntimeExceptionOneway(sCompare, xLBT.Interface );
+ }
+ catch (RuntimeException e )
+ {
+ bReturn = ( xLBT.Interface == e.Context );
+ }
+ return bReturn;
+}
+
+
+static bool raiseException(XBridgeTest xLBT )
+{
+ int nCount = 0;
+ try
+ {
+ try
+ {
+ try
+ {
+ TestDataElements aRet = new TestDataElements();
+ TestDataElements aRet2 = new TestDataElements();
+ xLBT.raiseException(
+ 5, Constants.STRING_TEST_CONSTANT, xLBT.Interface );
+ }
+ catch (unoidl.com.sun.star.lang.IllegalArgumentException aExc)
+ {
+ if (aExc.ArgumentPosition == 5 &&
+ aExc.Context == xLBT.Interface)
+ {
+ ++nCount;
+ }
+ else
+ {
+ check( false, "### unexpected exception content!" );
+ }
+
+ /** it is certain, that the RuntimeException testing will fail,
+ if no */
+ xLBT.RuntimeException = 0;
+ }
+ }
+ catch (unoidl.com.sun.star.uno.RuntimeException rExc)
+ {
+ if (rExc.Context == xLBT.Interface )
+ {
+ ++nCount;
+ }
+ else
+ {
+ check( false, "### unexpected exception content!" );
+ }
+
+ /** it is certain, that the RuntimeException testing will fail, if no */
+ unchecked
+ {
+ xLBT.RuntimeException = (int) 0xcafebabe;
+ }
+ }
+ }
+ catch (unoidl.com.sun.star.uno.Exception rExc)
+ {
+ if (rExc.Context == xLBT.Interface)
+ {
+ ++nCount;
+ }
+ else
+
+ {
+ check( false, "### unexpected exception content!" );
+ }
+ return (nCount == 3);
+ }
+ return false;
+}
+
+ private void perform_test( XBridgeTest xLBT )
+ {
+ bool bRet= true;
+ bRet = check( performTest( xLBT ), "standard test" ) && bRet;
+ bRet = check( raiseException( xLBT ) , "exception test" )&& bRet;
+ bRet = check( raiseOnewayException( xLBT ), "oneway exception test" ) && bRet;
+ bRet = check( testObjectMethodsImplementetion(xLBT), "object methods test") && bRet;
+ bRet = performQueryForUnknownType( xLBT ) && bRet;
+ if ( ! bRet)
+ {
+ throw new unoidl.com.sun.star.uno.RuntimeException( "error (cli_cs_bridgetest.cs): test failed!", null);
+ }
+ }
+
+ public BridgeTest( XComponentContext xContext )
+ {
+ m_xContext = xContext;
+ }
+
+ private XComponentContext m_xContext;
+
+ public int run( String [] args )
+ {
+ Debug.AutoFlush = true;
+// System.Diagnostics.Debugger.Launch();
+ try
+ {
+ if (args.Length < 1)
+ {
+ throw new RuntimeException(
+ "missing argument for bridgetest!", this );
+ }
+ Object test_obj =
+ m_xContext.getServiceManager().createInstanceWithContext(
+ args[ 0 ], m_xContext );
+
+ Debug.WriteLine(
+ "Calling object: {0}", test_obj.ToString() );
+
+ XBridgeTest xTest = (XBridgeTest) test_obj ;
+ perform_test( xTest );
+ Console.WriteLine( "\n### cli_uno C# bridgetest succeeded." );
+ return 0;
+ }
+ catch (unoidl.com.sun.star.uno.RuntimeException)
+ {
+ throw;
+ }
+ catch (System.Exception exc)
+ {
+ throw new unoidl.com.sun.star.uno.RuntimeException(
+ "cli_cs_bridgetest.cs: unexpected exception occurred in XMain::run. Original exception: " +
+ exc.GetType().Name + "\n Message: " + exc.Message , null);
+ }
+ }
+}
+
+}
diff --git a/testtools/source/bridgetest/cli/cli_cs_multi.cs b/testtools/source/bridgetest/cli/cli_cs_multi.cs
new file mode 100644
index 000000000..3fd5a4975
--- /dev/null
+++ b/testtools/source/bridgetest/cli/cli_cs_multi.cs
@@ -0,0 +1,110 @@
+/*
+ * This file is part of the LibreOffice project.
+ *
+ * This Source Code Form is subject to the terms of the Mozilla Public
+ * License, v. 2.0. If a copy of the MPL was not distributed with this
+ * file, You can obtain one at http://mozilla.org/MPL/2.0/.
+ *
+ * This file incorporates work covered by the following license notice:
+ *
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed
+ * with this work for additional information regarding copyright
+ * ownership. The ASF licenses this file to you under the Apache
+ * License, Version 2.0 (the "License"); you may not use this file
+ * except in compliance with the License. You may obtain a copy of
+ * the License at http://www.apache.org/licenses/LICENSE-2.0 .
+ */
+
+namespace testtools::bridgetest::cli_cs {
+
+public class Multi: unoidl.test.testtools.bridgetest.XMulti
+{
+ public Multi()
+ {
+ }
+
+ public double att1
+ {
+ get { return _att1; }
+ set { _att1 = value; }
+ }
+
+ public int fn11(int arg)
+ {
+ return 11 * arg;
+ }
+
+ public string fn12(string arg)
+ {
+ return "12" + arg;
+ }
+
+ public int fn21(int arg)
+ {
+ return 21 * arg;
+ }
+
+ public string fn22(string arg)
+ {
+ return "22" + arg;
+ }
+
+ public double att3
+ {
+ get { return _att3; }
+ set { _att3 = value; }
+ }
+
+ public int fn31(int arg)
+ {
+ return 31 * arg;
+ }
+
+ public string fn32(string arg)
+ {
+ return "32" + arg;
+ }
+
+ public int fn33()
+ {
+ return 33;
+ }
+
+ public int fn41(int arg)
+ {
+ return 41 * arg;
+ }
+
+ public int fn61(int arg)
+ {
+ return 61 * arg;
+ }
+
+ public string fn62(string arg)
+ {
+ return "62" + arg;
+ }
+
+ public int fn71(int arg)
+ {
+ return 71 * arg;
+ }
+
+ public string fn72(string arg)
+ {
+ return "72" + arg;
+ }
+
+ public int fn73()
+ {
+ return 73;
+ }
+
+ private double _att1;
+ private double _att3;
+};
+
+} } }
+
+
diff --git a/testtools/source/bridgetest/cli/cli_cs_testobj.cs b/testtools/source/bridgetest/cli/cli_cs_testobj.cs
new file mode 100644
index 000000000..8d209ec44
--- /dev/null
+++ b/testtools/source/bridgetest/cli/cli_cs_testobj.cs
@@ -0,0 +1,955 @@
+/*
+ * This file is part of the LibreOffice project.
+ *
+ * This Source Code Form is subject to the terms of the Mozilla Public
+ * License, v. 2.0. If a copy of the MPL was not distributed with this
+ * file, You can obtain one at http://mozilla.org/MPL/2.0/.
+ *
+ * This file incorporates work covered by the following license notice:
+ *
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed
+ * with this work for additional information regarding copyright
+ * ownership. The ASF licenses this file to you under the Apache
+ * License, Version 2.0 (the "License"); you may not use this file
+ * except in compliance with the License. You may obtain a copy of
+ * the License at http://www.apache.org/licenses/LICENSE-2.0 .
+ */
+
+using System;
+using System.Diagnostics;
+using System.Threading;
+using System.Runtime.CompilerServices;
+using uno;
+using uno.util;
+using unoidl.com.sun.star.uno;
+using unoidl.com.sun.star.lang;
+using unoidl.test.testtools.bridgetest;
+
+namespace cs_testobj
+{
+
+class CheckFailed: System.Exception {
+ public CheckFailed(string message): base(message) {}
+}
+
+public class BridgeTestObject : WeakBase, XRecursiveCall, XBridgeTest2
+{
+ private XComponentContext m_xContext;
+
+ public BridgeTestObject( XComponentContext xContext )
+ {
+ m_xContext = xContext;
+ }
+ public BridgeTestObject()
+ {
+ }
+
+ private bool _bool;
+ private char _char;
+ private byte _byte;
+ private short _short;
+ private ushort _ushort;
+ private int _long;
+ private uint _ulong;
+ private long _hyper;
+ private ulong _uhyper;
+ private float _float;
+ private double _double;
+ private String _string;
+ private byte _byte2;
+ private short _short2;
+ private Object _xInterface;
+ private Any _any;
+ private TestEnum _testEnum = TestEnum.TEST;
+ private TestElement[] _testElements = new TestElement[0];
+ private TestDataElements _testDataElements = new TestDataElements();
+ private int _nLastCallId = 0;
+ private bool _bFirstCall = true;
+ private bool _bSequenceOfCallTestPassed = true;
+
+ private bool[] _arBool;
+ private char[] _arChar;
+ private byte[] _arByte;
+ private short[]_arShort;
+ private int[] _arLong;
+ private long[] _arHyper;
+ private UInt16[] _arUShort;
+ private UInt32[] _arULong;
+ private UInt64[] _arUHyper;
+ private string[] _arString;
+ private float[] _arFloat;
+ private double[] _arDouble;
+ private TestEnum[] _arEnum;
+ private Object[] _arObject;
+ private int[][] _arLong2;
+ private int[][][] _arLong3;
+ private Any[] _arAny;
+
+// private int _raiseAttr1;
+
+
+ public void setValues(
+ bool bBool,
+ char cChar,
+ byte nByte,
+ short nShort,
+ ushort nUShort,
+ int nLong,
+ uint nULong,
+ long nHyper,
+ ulong nUHyper,
+ float fFloat,
+ double fDouble,
+ TestEnum testEnum,
+ String str,
+ byte nByte2,
+ short nShort2,
+ Object xInterface,
+ Any any,
+ TestElement [] testElements,
+ TestDataElements testDataElements )
+ {
+ Debug.WriteLine( "##### " + GetType().FullName + ".setValues:" + any );
+
+ _bool = bBool;
+ _char = cChar;
+ _byte = nByte;
+ _short = nShort;
+ _ushort = nUShort;
+ _long = nLong;
+ _ulong = nULong;
+ _hyper = nHyper;
+ _uhyper = nUHyper;
+ _float = fFloat;
+ _double = fDouble;
+ _testEnum = testEnum;
+ _string = str;
+ _byte2 = nByte2;
+ _short2 = nShort2;
+ _xInterface = xInterface;
+ _any = any;
+ _testElements = testElements;
+ _testDataElements = testDataElements;
+ }
+
+ public TestDataElements setValues2(
+ /*INOUT*/ref bool io_bool,
+ /*INOUT*/ref char io_char,
+ /*INOUT*/ref byte io_byte,
+ /*INOUT*/ref short io_short,
+ /*INOUT*/ref ushort io_ushort,
+ /*INOUT*/ref int io_long,
+ /*INOUT*/ref uint io_ulong,
+ /*INOUT*/ref long io_hyper,
+ /*INOUT*/ref ulong io_uhyper,
+ /*INOUT*/ref float io_float,
+ /*INOUT*/ref double io_double,
+ /*INOUT*/ref TestEnum io_testEnum,
+ /*INOUT*/ref String io_string,
+ /*INOUT*/ref byte io_byte2,
+ /*INOUT*/ref short io_short2,
+ /*INOUT*/ref Object io_xInterface,
+ /*INOUT*/ref Any io_any,
+ /*INOUT*/ref TestElement[] io_testElements,
+ /*INOUT*/ref TestDataElements io_testDataElements )
+ {
+ Debug.WriteLine( "##### " + GetType().FullName + ".setValues2:" + io_any );
+
+ _bool = io_bool;
+ _char = io_char;
+ _byte = io_byte;
+ _short = io_short;
+ _ushort = io_ushort;
+ _long = io_long;
+ _ulong = io_ulong;
+ _hyper = io_hyper;
+ _uhyper = io_uhyper;
+ _float = io_float;
+ _double = io_double;
+ _testEnum = io_testEnum;
+ _string = io_string;
+ _byte2 = io_byte2;
+ _short2 = io_short2;
+ _xInterface = io_xInterface;
+ _any = io_any;
+ _testElements = (TestElement[]) io_testElements.Clone();
+ _testDataElements = io_testDataElements;
+
+ TestElement temp = io_testElements[ 0 ];
+ io_testElements[ 0 ] = io_testElements[ 1 ];
+ io_testElements[ 1 ] = temp;
+
+ return _testDataElements;
+ }
+
+ public TestDataElements getValues(
+ /*OUT*/out bool o_bool,
+ /*OUT*/out char o_char,
+ /*OUT*/out byte o_byte,
+ /*OUT*/out short o_short,
+ /*OUT*/out ushort o_ushort,
+ /*OUT*/out int o_long,
+ /*OUT*/out uint o_ulong,
+ /*OUT*/out long o_hyper,
+ /*OUT*/out ulong o_uhyper,
+ /*OUT*/out float o_float,
+ /*OUT*/out double o_double,
+ /*OUT*/out TestEnum o_testEnum,
+ /*OUT*/out String o_string,
+ /*OUT*/out byte o_byte2,
+ /*OUT*/out short o_short2,
+ /*OUT*/out Object o_xInterface,
+ /*OUT*/out Any o_any,
+ /*OUT*/out TestElement[] o_testElements,
+ /*OUT*/out TestDataElements o_testDataElements )
+ {
+ Debug.WriteLine( "##### " + GetType().FullName + ".getValues" );
+
+ o_bool = _bool;
+ o_char = _char;
+ o_byte = _byte;
+ o_short = _short;
+ o_ushort = _ushort;
+ o_long = _long;
+ o_ulong = _ulong;
+ o_hyper = _hyper;
+ o_uhyper = _uhyper;
+ o_float = _float;
+ o_double = _double;
+ o_testEnum = _testEnum;
+ o_string = _string;
+ o_byte2 = _byte2;
+ o_short2 = _short2;
+ o_xInterface = _xInterface;
+ o_any = _any;
+ o_testElements = _testElements;
+ o_testDataElements = _testDataElements;
+
+ return _testDataElements;
+ }
+
+ public SmallStruct echoSmallStruct(/*[in]*/SmallStruct arg)
+ {
+ return arg;
+ }
+
+ public MediumStruct echoMediumStruct(/*[in]*/MediumStruct arg)
+ {
+ return arg;
+ }
+
+ public BigStruct echoBigStruct(/*[in]*/BigStruct arg)
+ {
+ return arg;
+ }
+
+ public TwoFloats echoTwoFloats(/*[in]*/TwoFloats arg)
+ {
+ return arg;
+ }
+
+ public FourFloats echoFourFloats(/*[in]*/FourFloats arg)
+ {
+ return arg;
+ }
+
+ public MixedFloatAndInteger echoMixedFloatAndInteger(/*[in]*/MixedFloatAndInteger arg)
+ {
+ return arg;
+ }
+
+ public DoubleHyper echoDoubleHyper(Mix s) { return s; }
+
+ public HyperDouble echoHyperDouble(Mix s) { return s; }
+
+ public FloatFloatLongByte echoFloatFloatLongByte(Mix s) { return s; }
+
+ public ThreeByteStruct echoThreeByteStruct(/*[in]*/ThreeByteStruct arg)
+ {
+ return arg;
+ }
+
+ public int testPPCAlignment( long l1, long l2, int i1, long l3, int i2 )
+ {
+ return i2;
+ }
+
+ public int testPPC64Alignment( double d1, double d2, double d3, int i1 )
+ {
+ return i1;
+ }
+
+ public double testTenDoubles( double d1, double d2, double d3, double d4, double d5, double d6, double d7, double d8, double d9, double d10 )
+ {
+ return d1 + d2 + d3 + d4 + d5 + d6 + d7 + d8 + d9 + d10;
+ }
+
+ // Attributes
+ public bool Bool
+ {
+ get { return _bool; }
+ set { _bool = value; }
+ }
+ public byte Byte
+ {
+ get { return _byte; }
+ set { _byte = value; }
+ }
+ public char Char
+ {
+ get { return _char; }
+ set { _char = value; }
+ }
+ public short Short
+ {
+ get { return _short; }
+ set { _short = value; }
+ }
+ public ushort UShort
+ {
+ get { return _ushort; }
+ set { _ushort = value; }
+ }
+ public int Long
+ {
+ get { return _long; }
+ set { _long = value; }
+ }
+ public uint ULong
+ {
+ get { return _ulong; }
+ set { _ulong = value; }
+ }
+ public long Hyper
+ {
+ get { return _hyper; }
+ set { _hyper = value; }
+ }
+ public ulong UHyper
+ {
+ get { return _uhyper; }
+ set { _uhyper = value; }
+ }
+ public float Float
+ {
+ get { return _float; }
+ set { _float = value; }
+ }
+ public double Double
+ {
+ get { return _double; }
+ set { _double = value; }
+ }
+ public TestEnum Enum
+ {
+ get { return _testEnum; }
+ set { _testEnum = value; }
+ }
+ public String String
+ {
+ get { return _string; }
+ set { _string = value; }
+ }
+ public byte Byte2
+ {
+ get { return _byte2; }
+ set { _byte2 = value; }
+ }
+ public short Short2
+ {
+ get { return _short2; }
+ set { _short2 = value; }
+ }
+ public Object Interface
+ {
+ get { return _xInterface; }
+ set { _xInterface = value; }
+ }
+ public uno.Any Any
+ {
+ get {
+
+ Debug.WriteLine( "##### " + GetType().FullName + ".Any" );
+ return _any;
+ }
+ set {
+ Debug.WriteLine( "##### " + GetType().FullName + ".Any:" + value );
+ _any = value;
+ }
+ }
+ public TestElement [] Sequence
+ {
+ get { return _testElements; }
+ set { _testElements = value; }
+ }
+ public TestDataElements Struct
+ {
+ get { return _testDataElements; }
+ set { _testDataElements = value; }
+ }
+ public Any transportAny(Any value)
+ {
+ return value;
+ }
+ public void call(int nCallId , int nWaitMUSEC)
+ {
+ Thread.Sleep(nWaitMUSEC / 10000);
+
+ if(_bFirstCall)
+ _bFirstCall = false;
+
+ else
+ _bSequenceOfCallTestPassed = _bSequenceOfCallTestPassed && (nCallId > _nLastCallId);
+
+ _nLastCallId = nCallId;
+ }
+ public void callOneway( int nCallId , int nWaitMUSEC )
+ {
+ Thread.Sleep(nWaitMUSEC / 10000);
+
+ _bSequenceOfCallTestPassed = _bSequenceOfCallTestPassed && (nCallId > _nLastCallId);
+ _nLastCallId = nCallId;
+ }
+ public bool sequenceOfCallTestPassed()
+ {
+ return _bSequenceOfCallTestPassed;
+ }
+ [MethodImpl( MethodImplOptions.Synchronized )]
+ public void callRecursivly( XRecursiveCall xCall, int nToCall )
+ {
+ lock (this)
+ {
+ if(nToCall != 0)
+ {
+ nToCall --;
+ xCall.callRecursivly(this , nToCall);
+ }
+ }
+ }
+ [MethodImpl( MethodImplOptions.Synchronized )]
+ public void startRecursiveCall( XRecursiveCall xCall, int nToCall )
+ {
+ lock (this)
+ {
+ if(nToCall != 0)
+ {
+ nToCall --;
+ xCall.callRecursivly( this , nToCall );
+ }
+ }
+ }
+
+ // XBridgeTest
+ public TestDataElements raiseException(
+ short nArgumentPos, String rMsg, Object xContext )
+ {
+ throw new IllegalArgumentException(rMsg, xContext, nArgumentPos);
+ }
+ public void raiseRuntimeExceptionOneway( String rMsg, Object xContext )
+ {
+ throw new RuntimeException(rMsg, xContext);
+ }
+
+ private void dothrow( System.Exception e )
+ {
+ throw e;
+ }
+ public int RuntimeException
+ {
+ get {
+ try
+ {
+ dothrow( new RuntimeException(_string, _xInterface) );
+ return 0; // dummy
+ }
+ catch (System.Exception exc)
+ {
+ throw exc;
+ }
+ }
+ set { throw new RuntimeException(_string, _xInterface); }
+ }
+
+ // XBridgeTest2
+ public int[][] setDim2(int[][] val)
+ {
+ _arLong2 = val;
+ return val;
+ }
+
+ public int[][][] setDim3(int[][][] val)
+ {
+ _arLong3 = val;
+ return val;
+ }
+
+ public Any[] setSequenceAny(Any[] val)
+ {
+ _arAny = val;
+ return val;
+ }
+
+ public bool[] setSequenceBool(bool[] val)
+ {
+ _arBool = val;
+ return val;
+ }
+
+ public byte[] setSequenceByte(byte[] val)
+ {
+ _arByte = val;
+ return val;
+ }
+
+ public char[] setSequenceChar(char[] val)
+ {
+ _arChar = val;
+ return val;
+ }
+
+ public short[] setSequenceShort(short[] val)
+ {
+ _arShort = val;
+ return val;
+ }
+
+ public int[] setSequenceLong(int[] val)
+ {
+ _arLong = val;
+ return val;
+ }
+
+ public long[] setSequenceHyper(long[] val)
+ {
+ _arHyper = val;
+ return val;
+ }
+
+ public float[] setSequenceFloat(float[] val)
+ {
+ _arFloat = val;
+ return val;
+ }
+
+ public double[] setSequenceDouble(double[] val)
+ {
+ _arDouble = val;
+ return val;
+ }
+
+ public TestEnum[] setSequenceEnum(TestEnum[] val)
+ {
+ _arEnum = val;
+ return val;
+ }
+
+ public UInt16[] setSequenceUShort(UInt16[] val)
+ {
+ _arUShort = val;
+ return val;
+ }
+
+ public UInt32[] setSequenceULong(UInt32[] val)
+ {
+ _arULong = val;
+ return val;
+ }
+
+ public UInt64[] setSequenceUHyper(UInt64[] val)
+ {
+ _arUHyper = val;
+ return val;
+ }
+
+ public Object[] setSequenceXInterface(Object[] val)
+ {
+ _arObject = val;
+ return val;
+ }
+
+ public string[] setSequenceString(string[] val)
+ {
+ _arString = val;
+ return val;
+ }
+
+ public TestElement[] setSequenceStruct(TestElement[] val)
+ {
+ _testElements = val;
+ return val;
+ }
+
+ public void setSequencesInOut(ref bool[] aSeqBoolean,
+ ref char[] aSeqChar,
+ ref byte[] aSeqByte,
+ ref short[] aSeqShort,
+ ref UInt16[] aSeqUShort,
+ ref int[] aSeqLong,
+ ref UInt32[] aSeqULong,
+ ref long[] aSeqHyper,
+ ref UInt64[] aSeqUHyper,
+ ref float[] aSeqFloat,
+ ref double[] aSeqDouble,
+ ref TestEnum[] aSeqTestEnum,
+ ref string[] aSeqString,
+ ref object[] aSeqXInterface,
+ ref Any[] aSeqAny,
+ ref int[][] aSeqDim2,
+ ref int[][][] aSeqDim3)
+ {
+ _arBool = aSeqBoolean;
+ _arChar = aSeqChar;
+ _arByte = aSeqByte;
+ _arShort = aSeqShort;
+ _arUShort = aSeqUShort;
+ _arLong = aSeqLong;
+ _arULong = aSeqULong;
+ _arHyper = aSeqHyper;
+ _arUHyper = aSeqUHyper;
+ _arFloat = aSeqFloat;
+ _arDouble = aSeqDouble;
+ _arEnum = aSeqTestEnum;
+ _arString = aSeqString;
+ _arObject = aSeqXInterface;
+ _arAny = aSeqAny;
+ _arLong2 = aSeqDim2;
+ _arLong3 = aSeqDim3;
+ }
+
+ public void setSequencesOut(out bool[] aSeqBoolean,
+ out char[] aSeqChar,
+ out byte[] aSeqByte,
+ out short[] aSeqShort,
+ out UInt16[] aSeqUShort,
+ out int[] aSeqLong,
+ out UInt32[] aSeqULong,
+ out long[] aSeqHyper,
+ out UInt64[] aSeqUHyper,
+ out float[] aSeqFloat,
+ out double[] aSeqDouble,
+ out TestEnum[] aSeqTestEnum,
+ out string[] aSeqString,
+ out object[] aSeqXInterface,
+ out Any[] aSeqAny,
+ out int[][] aSeqDim2,
+ out int[][][] aSeqDim3)
+ {
+ aSeqBoolean = _arBool;
+ aSeqChar = _arChar;
+ aSeqByte = _arByte;
+ aSeqShort = _arShort;
+ aSeqUShort = _arUShort;
+ aSeqLong = _arLong;
+ aSeqULong = _arULong;
+ aSeqHyper = _arHyper;
+ aSeqUHyper = _arUHyper;
+ aSeqFloat = _arFloat;
+ aSeqDouble = _arDouble;
+ aSeqTestEnum = _arEnum;
+ aSeqString = _arString;
+ aSeqXInterface = _arObject;
+ aSeqAny = _arAny;
+ aSeqDim2 = _arLong2;
+ aSeqDim3 = _arLong3;
+
+ }
+
+ /* Attention: Debugging this code (probably in mixed mode) may lead to exceptions
+ * which do not occur when running normally (Visual Studio 2003)
+ */
+ public void testConstructorsService(XComponentContext context)
+ {
+ Constructors.create1(context,
+ true,
+ 0x80, // -128 in C++,
+ Int16.MinValue,
+ UInt16.MaxValue,
+ Int32.MinValue,
+ UInt32.MaxValue,
+ Int64.MinValue,
+ UInt64.MaxValue,
+ 0.123f,
+ 0.456,
+ 'X',
+ "test",
+ typeof(Any),
+ new Any(true),
+ new bool[] { true },
+ new byte[] { 0x80}, // in C++ the value is compared with SAL_MIN_INT8 which is -128
+ new short[] { Int16.MinValue },
+ new UInt16[] { UInt16.MaxValue },
+ new Int32[] {Int32.MinValue},
+ new UInt32[] { UInt32.MaxValue },
+ new long[] { Int64.MinValue },
+ new UInt64[] { UInt64.MaxValue },
+ new float[] { 0.123f },
+ new double[] { 0.456 },
+ new char[] { 'X' },
+ new string[] { "test" },
+ new Type[] { typeof(Any) },
+ new Any[] { new Any(true) },
+ new bool[][] { new bool[] { true } },
+ new Any[][] { new Any[] { new Any(true) } },
+ new TestEnum[] { TestEnum.TWO },
+ new TestStruct[] { new TestStruct(10) },
+ new TestPolyStruct[] { new TestPolyStruct(true) },
+ new TestPolyStruct[] { new TestPolyStruct(new Any(true)) },
+ new object[] { null },
+ TestEnum.TWO,
+ new TestStruct(10),
+ new TestPolyStruct(true),
+ new TestPolyStruct(new Any(true)),
+ null
+ );
+
+ Constructors.create2(context,
+ new Any(true),
+ new Any((System.Byte) 0x80),
+ new Any(Int16.MinValue),
+ new Any(UInt16.MaxValue),
+ new Any(Int32.MinValue),
+ new Any(UInt32.MaxValue),
+ new Any(Int64.MinValue),
+ new Any(UInt64.MaxValue),
+ new Any(0.123f),
+ new Any(0.456),
+ new Any('X'),
+ new Any("test"),
+ new Any(typeof(Any)),
+ new Any(true),
+ new Any(typeof(bool[]), new bool[] { true }),
+ new Any(typeof(byte[]), new byte[] { (System.Byte) 0x80}),
+ new Any(typeof(short[]), new short[] { Int16.MinValue }),
+ new Any(typeof(UInt16[]), new UInt16[] { UInt16.MaxValue }),
+ new Any(typeof(int[]), new int[] { Int32.MinValue }),
+ new Any(typeof(UInt32[]), new UInt32[] { UInt32.MaxValue }),
+ new Any(typeof(long[]), new long[] { Int64.MinValue }),
+ new Any(typeof(UInt64[]), new UInt64[] { UInt64.MaxValue }),
+ new Any(typeof(float[]), new float[] { 0.123f }),
+ new Any(typeof(double[]), new double[] { 0.456 }),
+ new Any(typeof(char[]), new char[] { 'X' }),
+ new Any(typeof(string[]), new string[] { "test" }),
+ new Any(typeof(Type[]), new Type[] { typeof(Any) }),
+ new Any(typeof(Any[]), new Any[] { new Any(true) }),
+ new Any(typeof(bool[][]), new bool[][] { new bool[] { true } }),
+ new Any(
+ typeof(Any[][]), new Any[][] { new Any[] { new Any(true) } }),
+ new Any(typeof(TestEnum[]), new TestEnum[] { TestEnum.TWO }),
+ new Any(
+ typeof(TestStruct[]), new TestStruct[] { new TestStruct(10) }),
+ new Any(
+ PolymorphicType.GetType(
+ typeof(TestPolyStruct[]),
+ "unoidl.test.testtools.bridgetest.TestPolyStruct<System.Boolean>[]"),
+ new TestPolyStruct[] { new TestPolyStruct(true) }) ,
+ new Any(
+ PolymorphicType.GetType(
+ typeof(TestPolyStruct[]),
+ "unoidl.test.testtools.bridgetest.TestPolyStruct<uno.Any>[]"),
+ new TestPolyStruct[] { new TestPolyStruct(new Any(true)) }),
+ new Any(typeof(object[])/*TODO*/, new object[] { null }),
+ new Any(typeof(TestEnum), TestEnum.TWO),
+ new Any(typeof(TestStruct), new TestStruct(10)),
+ new Any(
+ PolymorphicType.GetType(
+ typeof(TestPolyStruct),
+ "unoidl.test.testtools.bridgetest.TestPolyStruct<System.Boolean>"),
+ new TestPolyStruct(true)),
+ new Any(
+ PolymorphicType.GetType(
+ typeof(TestPolyStruct),
+ "unoidl.test.testtools.bridgetest.TestPolyStruct<uno.Any>"),
+ new TestPolyStruct(new Any(true))),
+ new Any(typeof(object), null)
+ );
+
+
+ XMultiBase1 xMulti = Constructors2.create1(
+ context,
+ new TestPolyStruct(typeof(int)),
+ new TestPolyStruct(new Any(true)),
+ new TestPolyStruct(true),
+ new TestPolyStruct((Byte) 0x80),
+ new TestPolyStruct(Int16.MinValue),
+ new TestPolyStruct(Int32.MinValue),
+ new TestPolyStruct(Int64.MinValue),
+ new TestPolyStruct('X'),
+ new TestPolyStruct("test"),
+ new TestPolyStruct(0.123f),
+ new TestPolyStruct(0.456d),
+ new TestPolyStruct(new object()),
+ new TestPolyStruct(new uno.util.WeakComponentBase()),
+ new TestPolyStruct(TestEnum.TWO),
+ new TestPolyStruct(new TestPolyStruct2('X', new Any(true))),
+ new TestPolyStruct(new TestPolyStruct2(new TestPolyStruct2('X', new Any(true)), "test")),
+ new TestPolyStruct2("test", new TestPolyStruct2('X', new TestPolyStruct(new Any(true)))),
+ new TestPolyStruct2( new TestPolyStruct2('X', new Any(true)), new TestPolyStruct('X')),
+ new TestPolyStruct(new Type[] { typeof(int)}),
+ new TestPolyStruct(new Any[] { new Any(true) }),
+ new TestPolyStruct(new bool[] {true}),
+ new TestPolyStruct(new byte[] {0x80}),
+ new TestPolyStruct(new short[] {Int16.MinValue}),
+ new TestPolyStruct(new int[] {Int32.MinValue}),
+ new TestPolyStruct(new long[] {Int64.MinValue}),
+ new TestPolyStruct(new char[] {'X'}),
+ new TestPolyStruct(new string[] {"test"}),
+ new TestPolyStruct(new float[] {0.123f}),
+ new TestPolyStruct(new double[] {0.456d}),
+ new TestPolyStruct(new object[] {new object()}),
+ new TestPolyStruct(new unoidl.com.sun.star.lang.XComponent[] {new uno.util.WeakComponentBase()}),
+ new TestPolyStruct(new TestEnum[] {TestEnum.TWO}),
+ new TestPolyStruct(new TestPolyStruct2[] {new TestPolyStruct2('X', new Any[] {new Any(true)})}),
+ new TestPolyStruct(new TestPolyStruct2[] {
+ new TestPolyStruct2(new TestPolyStruct('X'), new Any[] {new Any(true)})}),
+ new TestPolyStruct(new int[][] { new int[] {Int32.MinValue} }),
+ new TestPolyStruct[]{ new TestPolyStruct(Int32.MinValue)},
+ new TestPolyStruct[]{new TestPolyStruct(new TestPolyStruct2('X', new Any(true)))},
+ new TestPolyStruct[]{new TestPolyStruct(new TestPolyStruct2(new TestPolyStruct2('X', new Any(true)), "test"))},
+ new TestPolyStruct2[]{new TestPolyStruct2("test", new TestPolyStruct2('X', new TestPolyStruct(new Any(true))))},
+ new TestPolyStruct2[]{new TestPolyStruct2(new TestPolyStruct2('X', new Any(true)),new TestPolyStruct('X'))},
+ new TestPolyStruct[][]{new TestPolyStruct[]{new TestPolyStruct('X')}},
+ new TestPolyStruct[][]{new TestPolyStruct[]{new TestPolyStruct(new TestPolyStruct2('X', new Any(true)))}},
+ new TestPolyStruct[][]{new TestPolyStruct[] {new TestPolyStruct(new TestPolyStruct2(new TestPolyStruct2('X',new Any(true)), "test"))}},
+ new TestPolyStruct2[][]{new TestPolyStruct2[]{new TestPolyStruct2("test", new TestPolyStruct2('X',new TestPolyStruct(new Any(true))))}},
+ new TestPolyStruct2[][]{new TestPolyStruct2[]{new TestPolyStruct2(new TestPolyStruct2('X',new Any(true)),new TestPolyStruct('X'))}}
+ );
+
+ //test the returned interface
+ xMulti.fn11(1);
+
+
+ }
+
+ public XCurrentContextChecker getCurrentContextChecker()
+ {
+ return null; //TODO: not yet tested in CLI UNO
+ }
+
+ public TestPolyStruct transportPolyBoolean(/*[in]*/TestPolyStruct arg)
+ {
+ return arg;
+ }
+
+ public void transportPolyHyper(/*[in][out]*/ ref TestPolyStruct arg)
+ {
+ }
+
+ public void transportPolySequence(TestPolyStruct arg1,
+ out TestPolyStruct arg2)
+ {
+ arg2 = arg1;
+ }
+
+ public TestPolyStruct getNullPolyBadEnum()
+ {
+ return new TestPolyStruct(unoidl.test.testtools.bridgetest.TestBadEnum.M);
+ }
+
+ public TestPolyStruct getNullPolyLong()
+ {
+ return new TestPolyStruct();
+ }
+
+ public TestPolyStruct getNullPolyString()
+ {
+ return new TestPolyStruct();
+ }
+
+ public TestPolyStruct getNullPolyType()
+ {
+ return new TestPolyStruct();
+ }
+
+ public TestPolyStruct getNullPolyAny()
+ {
+ return new TestPolyStruct();
+ }
+
+ public TestPolyStruct getNullPolySequence()
+ {
+ return new TestPolyStruct();
+ }
+
+ public TestPolyStruct getNullPolyEnum()
+ {
+ return new TestPolyStruct();
+ }
+
+ public TestPolyStruct getNullPolyStruct()
+ {
+ return new TestPolyStruct();
+ }
+
+ public TestPolyStruct getNullPolyInterface()
+ {
+ return new TestPolyStruct();
+ }
+
+ public XMulti getMulti()
+ {
+ return new testtools.bridgetest.cli_cs.Multi();
+ }
+
+ private static void checkEqual(int value, int argument) {
+ if (argument != value) {
+ throw new CheckFailed(value + " != " + argument);
+ }
+ }
+
+ private static void checkEqual(double value, double argument) {
+ if (argument != value) {
+ throw new CheckFailed(value + " != " + argument);
+ }
+ }
+
+ private static void checkEqual(string value, string argument) {
+ if (argument != value) {
+ throw new CheckFailed(value + " != " + argument);
+ }
+ }
+
+ public string testMulti(XMulti multi)
+ {
+ try {
+ checkEqual(0.0, multi.att1);
+ multi.att1 = 0.1;
+ checkEqual(0.1, multi.att1);
+ checkEqual(11 * 1, multi.fn11(1));
+ checkEqual("12" + "abc", multi.fn12("abc"));
+ checkEqual(21 * 2, multi.fn21(2));
+ checkEqual("22" + "de", multi.fn22("de"));
+ checkEqual(0.0, multi.att3);
+ multi.att3 = 0.3;
+ checkEqual(0.3, multi.att3);
+ checkEqual(31 * 3, multi.fn31(3));
+ checkEqual("32" + "f", multi.fn32("f"));
+ checkEqual(33, multi.fn33());
+ checkEqual(41 * 4, multi.fn41(4));
+ checkEqual(61 * 6, multi.fn61(6));
+ checkEqual("62" + "", multi.fn62(""));
+ checkEqual(71 * 7, multi.fn71(7));
+ checkEqual("72" + "g", multi.fn72("g"));
+ checkEqual(73, multi.fn73());
+ } catch (CheckFailed f) {
+ return f.Message;
+ }
+ return "";
+ }
+
+ public int RaiseAttr1
+ {
+ get { throw new RuntimeException(); }
+ set { throw new IllegalArgumentException(); }
+ }
+
+ public int RaiseAttr2
+ {
+ get { throw new IllegalArgumentException(); }
+ set { throw new IllegalArgumentException(); }
+ }
+
+
+}
+
+}
diff --git a/testtools/source/bridgetest/cli/cli_vb_bridgetest.vb b/testtools/source/bridgetest/cli/cli_vb_bridgetest.vb
new file mode 100644
index 000000000..18abd584b
--- /dev/null
+++ b/testtools/source/bridgetest/cli/cli_vb_bridgetest.vb
@@ -0,0 +1,916 @@
+'
+' This file is part of the LibreOffice project.
+'
+' This Source Code Form is subject to the terms of the Mozilla Public
+' License, v. 2.0. If a copy of the MPL was not distributed with this
+' file, You can obtain one at http://mozilla.org/MPL/2.0/.
+'
+' This file incorporates work covered by the following license notice:
+'
+' Licensed to the Apache Software Foundation (ASF) under one or more
+' contributor license agreements. See the NOTICE file distributed
+' with this work for additional information regarding copyright
+' ownership. The ASF licenses this file to you under the Apache
+' License, Version 2.0 (the "License"); you may not use this file
+' except in compliance with the License. You may obtain a copy of
+' the License at http://www.apache.org/licenses/LICENSE-2.0 .
+'
+
+Option Explicit On
+Option Strict On
+
+imports System
+imports uno
+imports uno.util
+imports unoidl.com.sun.star.lang
+imports unoidl.com.sun.star.uno
+'imports unoidl.com.sun.star.test.bridge
+imports unoidl.test.testtools.bridgetest
+imports System.Windows.Forms
+imports System.Diagnostics
+imports System.Reflection
+
+Class CONSTANTS
+Friend Shared STRING_TEST_CONSTANT As String = """ paco\' chorizo\\\' ""\'"
+End Class
+
+Namespace foo
+
+ Public Interface MyInterface
+ End Interface
+End Namespace
+
+Namespace vb_bridetest
+Class ORecursiveCall
+ Inherits WeakBase
+ Implements XRecursiveCall
+
+ Overridable Sub callRecursivly(xCall As XRecursiveCall, nToCall As Integer) _
+ Implements XRecursiveCall.callRecursivly
+ SyncLock Me
+ If nToCall > 0
+ nToCall = nToCall - 1
+ xCall.callRecursivly(Me, nToCall)
+ End If
+ End SyncLock
+ End Sub
+End Class
+
+
+
+
+Public Class BridgeTest
+ Inherits uno.util.WeakBase
+ Implements XMain
+
+ Private m_xContext As XComponentContext
+
+ Public Sub New( xContext As unoidl.com.sun.star.uno.XComponentContext )
+ mybase.New()
+ m_xContext = xContext
+ End Sub
+
+ Private Shared Function check( b As Boolean , message As String ) As Boolean
+ If Not b
+ Console.WriteLine("{0} failed\n" , message)
+ End If
+ Return b
+ End Function
+
+ Private Shared Sub assign( rData As TestElement, bBool As Boolean, _
+ aChar As Char, nByte As Byte, nShort As Short, nUShort As UInt16, _
+ nLong As Integer, nULong As UInt32, nHyper As Long, _
+ UHyper As UInt64, fFloat As Single, fDouble As Double, _
+ eEnum As TestEnum, rStr As String, _
+ nByte2 As Byte, nShort2 As Short, _
+ xTest As Object, _
+ rAny As Any)
+
+ rData.Bool = bBool
+ rData.Char = aChar
+ rData.Byte = nByte
+ rData.Short = nShort
+ rData.UShort = nUShort
+ rData.Long = nLong
+ rData.ULong = nULong
+ rData.Hyper = nHyper
+ rData.UHyper = nUHyper
+ rData.Float = fFloat
+ rData.Double = fDouble
+ rData.Enum = eEnum
+ rData.String = rStr
+ rData.Byte2 = nByte2
+ rData.Short2 = nShort2
+ rData.Interface = xTest
+ rData.Any = rAny
+ End Sub
+
+ Private Shared Sub assign( rData As TestDataElements, bBool As Boolean, _
+ aChar As Char, nByte As Byte, nShort As Short, nUShort As UInt16, _
+ nLong As Integer, nULong As UInt32, nHyper As Long, _
+ nUHyper As UInt64, fFloat As Single, fDouble As Double, _
+ eEnum As TestEnum, rStr As String, _
+ nByte2 As Byte, nShort2 As Short, _
+ xTest As Object, _
+ rAny As Any, rSequence() As TestElement)
+
+ assign( DirectCast( rData,TestElement), _
+ bBool, aChar, nByte, nShort, nUShort, nLong, nULong, nHyper, _
+ nUHyper, fFloat, fDouble, eEnum, rStr, nByte2, nShort2, xTest, rAny )
+ rData.Sequence = rSequence
+ End Sub
+
+ Private Shared Function compareData(val1 As Object, val2 As Object) As Boolean
+ If val1 Is Nothing And val2 Is Nothing OrElse _
+ val1 Is val2
+ Return True
+ End If
+ If val1 Is Nothing And Not(val2 Is Nothing) OrElse _
+ Not (val1 Is Nothing) And val2 Is Nothing OrElse _
+ Not val1.GetType().Equals( val2.GetType())
+ Return False
+ End If
+
+ Dim ret As Boolean = False
+ Dim t1 As Type = val1.GetType()
+ 'Sequence
+ If t1.IsArray()
+ ret = compareSequence(DirectCast( val1, Array), _
+ DirectCast( val2, Array))
+ 'String
+ ElseIf TypeOf val1 Is String
+ ret = DirectCast( val1, string) = DirectCast( val2, string)
+ ' Interface implementation
+ ElseIf t1.GetInterfaces().Length > 0 And Not t1.IsValueType
+ ret = val1 Is val2
+ ' Struct
+ ElseIf Not t1.IsValueType
+ ret = compareStruct(val1, val2)
+ ElseIf TypeOf val1 Is Any
+ Dim a1 As Any = DirectCast( val1, Any)
+ Dim a2 As Any = DirectCast( val2, Any)
+ ret = a1.Type.Equals( a2.Type ) And compareData( a1.Value, a2.Value )
+ ElseIf t1.IsValueType
+ 'Any, enum, int, bool char, float, double etc.
+ ret = val1.Equals(val2)
+ Else
+ Debug.Assert(False)
+ End If
+ Return ret
+ End Function
+
+ ' Arrays have only one dimension
+ Private Shared Function compareSequence( ar1 As Array, ar2 As Array) As Boolean
+ Debug.Assert( Not (ar1 Is Nothing) And Not (ar2 Is Nothing) )
+ Dim t1 As Type = ar1.GetType()
+ Dim t2 As Type = ar2.GetType()
+
+ if ( Not(ar1.Rank = 1 And ar2.Rank = 1 _
+ And ar1.Length = ar2.Length And t1.GetElementType().Equals(t2.GetElementType())))
+ return False
+ End If
+ 'arrays have same rank and size and element type.
+ Dim len As Integer = ar1.Length
+ Dim elemType As Type = t1.GetElementType()
+ Dim ret As Boolean = True
+ Dim i As Integer
+ For i = 0 To len - 1
+ If (compareData(ar1.GetValue(i), ar2.GetValue(i)) = False)
+ ret = False
+ Exit For
+ End If
+ Next i
+
+ Return ret
+ End Function
+
+ Private Shared Function compareStruct( val1 As Object, val2 As Object) As Boolean
+ Debug.Assert( Not(val1 Is Nothing) And Not(val2 Is Nothing))
+ Dim t1 As Type = val1.GetType()
+ Dim t2 As Type = val2.GetType()
+ If Not t1.Equals(t2)
+ Return False
+ End If
+ Dim fields() As FieldInfo = t1.GetFields()
+ Dim cFields As Integer = fields.Length
+ Dim ret As Boolean = True
+ Dim i As Integer
+ For i = 0 To cFields - 1
+ Dim fieldVal1 As Object = fields(i).GetValue(val1)
+ Dim fieldVal2 As Object = fields(i).GetValue(val2)
+ If Not compareData(fieldVal1, fieldVal2)
+ ret = False
+ Exit For
+ End If
+ Next i
+ Return ret
+ End Function
+
+
+ Private Shared Function performSequenceTest(xBT As XBridgeTest) As Boolean
+ Dim bRet As Boolean = True
+ 'Automati cast ?? like with COM objects
+ Dim xBT2 As XBridgeTest2
+ Try
+ xBT2 = DirectCast(xBT,XBridgeTest2)
+ Catch e As InvalidCastException
+ Return False
+ End Try
+
+ ' perform sequence tests (XBridgeTest2)
+ 'create the sequence which are compared with the results
+ Dim arBool() As Boolean = {True, False, True}
+ Dim arChar() As Char = {"A"C,"B"C,"C"C}
+ Dim arByte() As Byte = { 1, 2, &Hff}
+ Dim arShort() As Short = {Int16.MinValue, 1, Int16.MaxValue}
+ Dim arUShort() As UInt16 = {Convert.ToUInt16(0), Convert.ToUInt16(1), _
+ Convert.ToUInt16(&Hffff)}
+ Dim arLong() As Integer = {Int32.MinValue, 1, Int32.MaxValue}
+ Dim arULong() As UInt32 = {Convert.ToUInt32(0), Convert.ToUInt32(1), _
+ Convert.ToUInt32(&HffffffffL)}
+ Dim arHyper() As Long = {Int64.MinValue, 1, Int64.MaxValue}
+ Dim arUHyper() As UInt64 = {Convert.ToUInt64(0), Convert.ToUInt64(1), _
+ Convert.ToUInt64(&Hffffffff5L)}
+ Dim arFloat() As Single = {1.1f, 2.2f, 3.3f}
+ Dim arDouble() As Double = {1.11, 2.22, 3.33}
+ Dim arString() As String = {"String 1", "String 2", "String 3"}
+
+ Dim arAny() As Any = {New Any(True), New Any(11111), New Any(3.14)}
+ Dim arObject() As Object = {New WeakBase(), New WeakBase(), New WeakBase()}
+ Dim arEnum() As TestEnum = {TestEnum.ONE, TestEnum.TWO, TestEnum.CHECK}
+
+ Dim arStruct() As TestElement = {New TestElement(), New TestElement(), _
+ New TestElement()}
+ assign( arStruct(0), True, "@"C, 17, &H1234, Convert.ToUInt16(&Hfedc), _
+ &H12345678, Convert.ToUInt32(&H123456), &H123456789abcdef0, _
+ Convert.ToUInt64(123456788), 17.0815F, 3.1415926359, _
+ TestEnum.LOLA, CONSTANTS.STRING_TEST_CONSTANT, 18, &H5678, arObject(0), _
+ New Any(GetType(System.Object), arObject(0)))
+ assign( arStruct(1), True, "A"C, 17, &H1234, Convert.ToUInt16(&Hfedc), _
+ &H12345678, Convert.ToUInt32(&H123456), &H123456789abcdef0, _
+ Convert.ToUInt64(12345678), 17.0815F, 3.1415926359, _
+ TestEnum.TWO, CONSTANTS.STRING_TEST_CONSTANT, 18, &H5678, arObject(1), _
+ New Any(GetType(System.Object), arObject(1)) )
+ assign( arStruct(2), True, "B"C, 17, &H1234, Convert.ToUInt16(&Hfedc), _
+ &H12345678, Convert.ToUInt32(654321), &H123456789abcdef0, _
+ Convert.ToUInt64(87654321), 17.0815F, 3.1415926359, _
+ TestEnum.CHECK, Constants.STRING_TEST_CONSTANT, 18, &H5678, arObject(2), _
+ New Any(GetType(System.Object), arObject(2)))
+
+
+ Dim arLong3()()() As Integer = New Integer()()() { _
+ New Integer()(){New Integer(){1,2,3},New Integer(){4,5,6}, New Integer(){7,8,9} }, _
+ New Integer ()(){New Integer(){1,2,3},New Integer(){4,5,6}, New Integer(){7,8,9}}, _
+ New Integer()(){New Integer(){1,2,3},New Integer(){4,5,6}, New Integer(){7,8,9}}}
+
+ Dim seqSeqRet()() As Integer = xBT2.setDim2(arLong3(0))
+ bRet = check( compareData(seqSeqRet, arLong3(0)), "sequence test") _
+ And bRet
+ Dim seqSeqRet2()()() As Integer = xBT2.setDim3(arLong3)
+ bRet = check( compareData(seqSeqRet2, arLong3), "sequence test") _
+ And bRet
+ Dim seqAnyRet() As Any = xBT2.setSequenceAny(arAny)
+ bRet = check( compareData(seqAnyRet, arAny), "sequence test") And bRet
+ Dim seqBoolRet() As Boolean = xBT2.setSequenceBool(arBool)
+ bRet = check( compareData(seqBoolRet, arBool), "sequence test") _
+ And bRet
+ Dim seqByteRet() As Byte = xBT2.setSequenceByte(arByte)
+ bRet = check( compareData(seqByteRet, arByte), "sequence test") _
+ And bRet
+ Dim seqCharRet() As Char = xBT2.setSequenceChar(arChar)
+ bRet = check( compareData(seqCharRet, arChar), "sequence test") _
+ And bRet
+ Dim seqShortRet() As Short = xBT2.setSequenceShort(arShort)
+ bRet = check( compareData(seqShortRet, arShort), "sequence test") _
+ And bRet
+ Dim seqLongRet() As Integer = xBT2.setSequenceLong(arLong)
+ bRet = check( compareData(seqLongRet, arLong), "sequence test") _
+ And bRet
+ Dim seqHyperRet() As Long = xBT2.setSequenceHyper(arHyper)
+ bRet = check( compareData(seqHyperRet,arHyper), "sequence test") _
+ And bRet
+ Dim seqFloatRet() As Single = xBT2.setSequenceFloat(arFloat)
+ bRet = check( compareData(seqFloatRet, arFloat), "sequence test") _
+ And bRet
+ Dim seqDoubleRet() As Double= xBT2.setSequenceDouble(arDouble)
+ bRet = check( compareData(seqDoubleRet, arDouble), "sequence test") _
+ And bRet
+ Dim seqEnumRet() As TestEnum = xBT2.setSequenceEnum(arEnum)
+ bRet = check( compareData(seqEnumRet, arEnum), "sequence test") _
+ And bRet
+ Dim seqUShortRet() As UInt16 = xBT2.setSequenceUShort(arUShort)
+ bRet = check( compareData(seqUShortRet, arUShort), "sequence test") _
+ And bRet
+ Dim seqULongRet() As UInt32 = xBT2.setSequenceULong(arULong)
+ bRet = check( compareData(seqULongRet, arULong), "sequence test") _
+ And bRet
+ Dim seqUHyperRet() As UInt64 = xBT2.setSequenceUHyper(arUHyper)
+ bRet = check( compareData(seqUHyperRet, arUHyper), "sequence test") _
+ And bRet
+ Dim seqObjectRet() As Object = xBT2.setSequenceXInterface(arObject)
+ bRet = check( compareData(seqObjectRet, arObject), "sequence test") _
+ And bRet
+ Dim seqStringRet() As String = xBT2.setSequenceString(arString)
+ bRet = check( compareData(seqStringRet, arString), "sequence test") _
+ And bRet
+ Dim seqStructRet() As TestElement = xBT2.setSequenceStruct(arStruct)
+ bRet = check( compareData(seqStructRet, arStruct), "sequence test") _
+ And bRet
+
+
+ Dim arBoolTemp() As Boolean = DirectCast(arBool.Clone(), Boolean())
+ Dim arCharTemp() As Char = DirectCast(arChar.Clone(), Char())
+ Dim arByteTemp() As Byte = DirectCast(arByte.Clone(), Byte())
+ Dim arShortTemp() As Short = DirectCast(arShort.Clone(), Short())
+ Dim arUShortTemp() As UInt16 = DirectCast(arUShort.Clone(), UInt16())
+ Dim arLongTemp() As Integer= DirectCast(arLong.Clone(), Integer())
+ Dim arULongTemp() As UInt32 = DirectCast(arULong.Clone(), UInt32())
+ Dim arHyperTemp() As Long = DirectCast(arHyper.Clone(), Long())
+ Dim arUHyperTemp() As UInt64 = DirectCast(arUHyper.Clone(), UInt64())
+ Dim arFloatTemp() As Single = DirectCast(arFloat.Clone(), Single())
+ Dim arDoubleTemp() As Double = DirectCast(arDouble.Clone(), Double())
+ Dim arEnumTemp() As TestEnum = DirectCast(arEnum.Clone(), TestEnum())
+ Dim arStringTemp() As String = DirectCast(arString.Clone(), String())
+ Dim arObjectTemp() As Object = DirectCast(arObject.Clone(), Object())
+ Dim arAnyTemp() As Any = DirectCast(arAny.Clone(), Any())
+ ' make sure this are has the same contents as arLong3(0)
+ Dim arLong2Temp()() As Integer = New Integer()(){New Integer(){1,2,3}, _
+ New Integer(){4,5,6}, New Integer(){7,8,9} }
+ ' make sure this are has the same contents as arLong3
+ Dim arLong3Temp()()() As Integer = New Integer()()(){ _
+ New Integer()(){New Integer(){1,2,3},New Integer(){4,5,6}, New Integer(){7,8,9} }, _
+ New Integer ()(){New Integer(){1,2,3},New Integer(){4,5,6}, New Integer(){7,8,9}}, _
+ New Integer()(){New Integer(){1,2,3},New Integer(){4,5,6}, New Integer(){7,8,9}}}
+
+ xBT2.setSequencesInOut( arBoolTemp, arCharTemp, arByteTemp, _
+ arShortTemp, arUShortTemp, arLongTemp, _
+ arULongTemp, arHyperTemp, arUHyperTemp, _
+ arFloatTemp, arDoubleTemp, arEnumTemp, _
+ arStringTemp, arObjectTemp, _
+ arAnyTemp, arLong2Temp, arLong3Temp)
+ bRet = check( _
+ compareData(arBoolTemp, arBool) And _
+ compareData(arCharTemp , arChar) And _
+ compareData(arByteTemp , arByte) And _
+ compareData(arShortTemp , arShort) And _
+ compareData(arUShortTemp , arUShort) And _
+ compareData(arLongTemp , arLong) And _
+ compareData(arULongTemp , arULong) And _
+ compareData(arHyperTemp , arHyper) And _
+ compareData(arUHyperTemp , arUHyper) And _
+ compareData(arFloatTemp , arFloat) And _
+ compareData(arDoubleTemp , arDouble) And _
+ compareData(arEnumTemp , arEnum) And _
+ compareData(arStringTemp , arString) And _
+ compareData(arObjectTemp , arObject) And _
+ compareData(arAnyTemp , arAny) And _
+ compareData(arLong2Temp , arLong3(0)) And _
+ compareData(arLong3Temp , arLong3), "sequence test") And bRet
+
+ Dim arBoolOut() As Boolean
+ Dim arCharOut() As Char
+ Dim arByteOut() As Byte
+ Dim arShortOut() As Short
+ Dim arUShortOut() As UInt16
+ Dim arLongOut() As Integer
+ Dim arULongOut() As UInt32
+ Dim arHyperOut() As Long
+ Dim arUHyperOut() As UInt64
+ Dim arFloatOut() As Single
+ Dim arDoubleOut() As Double
+ Dim arEnumOut() As TestEnum
+ Dim arStringOut() As String
+ Dim arObjectOut() As Object
+ Dim arAnyOut() As Any
+ Dim arLong2Out()() As Integer
+ Dim arLong3Out()()() As Integer
+
+ xBT2.setSequencesOut( arBoolOut, arCharOut, arByteOut, _
+ arShortOut, arUShortOut, arLongOut, _
+ arULongOut, arHyperOut, arUHyperOut, _
+ arFloatOut, arDoubleOut, arEnumOut, _
+ arStringOut, arObjectOut, arAnyOut, _
+ arLong2Out, arLong3Out)
+ bRet = check( _
+ compareData(arBoolOut, arBool) And _
+ compareData(arCharOut, arChar) And _
+ compareData(arByteOut, arByte) And _
+ compareData(arShortOut, arShort) And _
+ compareData(arUShortOut, arUShort) And _
+ compareData(arLongOut, arLong) And _
+ compareData(arULongOut, arULong) And _
+ compareData(arHyperOut, arHyper) And _
+ compareData(arUHyperOut, arUHyper) And _
+ compareData(arFloatOut, arFloat) And _
+ compareData(arDoubleOut, arDouble) And _
+ compareData(arEnumOut, arEnum) And _
+ compareData(arStringOut, arString) And _
+ compareData(arObjectOut, arObject) And _
+ compareData(arAnyOut, arAny) And _
+ compareData(arLong2Out, arLong3(0)) And _
+ compareData(arLong3Out, arLong3), "sequence test") And bRet
+
+
+ 'test with empty sequences
+ Dim _arLong2()() As Integer = New Integer()(){}
+ seqSeqRet = xBT2.setDim2(_arLong2)
+ bRet = check( compareData(seqSeqRet, _arLong2), "sequence test") And bRet
+ Dim _arLong3()()() As Integer = New Integer()()(){}
+ seqSeqRet2 = xBT2.setDim3(_arLong3)
+ bRet = check( compareData(seqSeqRet2, _arLong3), "sequence test") And bRet
+ Dim _arAny() As Any = New Any(){}
+ seqAnyRet = xBT2.setSequenceAny(_arAny)
+ bRet = check( compareData(seqAnyRet, _arAny), "sequence test") And bRet
+ Dim _arBool() As Boolean = New Boolean() {}
+ seqBoolRet = xBT2.setSequenceBool(_arBool)
+ bRet = check( compareData(seqBoolRet, _arBool), "sequence test") And bRet
+ Dim _arByte() As Byte = New Byte() {}
+ seqByteRet = xBT2.setSequenceByte(_arByte)
+ bRet = check( compareData(seqByteRet, _arByte), "sequence test") And bRet
+ Dim _arChar() As Char = New Char() {}
+ seqCharRet = xBT2.setSequenceChar(_arChar)
+ bRet = check( compareData(seqCharRet, _arChar), "sequence test") And bRet
+ Dim _arShort() As Short = New Short() {}
+ seqShortRet = xBT2.setSequenceShort(_arShort)
+ bRet = check( compareData(seqShortRet, _arShort), "sequence test") And bRet
+ Dim _arLong() As Integer = New Integer() {}
+ seqLongRet = xBT2.setSequenceLong(_arLong)
+ bRet = check( compareData(seqLongRet, _arLong), "sequence test") And bRet
+ Dim _arHyper() As Long = New Long(){}
+ seqHyperRet = xBT2.setSequenceHyper(_arHyper)
+ bRet = check( compareData(seqHyperRet, _arHyper), "sequence test") And bRet
+ Dim _arFloat() As Single = New Single(){}
+ seqFloatRet = xBT2.setSequenceFloat(_arFloat)
+ bRet = check( compareData(seqFloatRet, _arFloat), "sequence test") And bRet
+ Dim _arDouble() As Double = New Double(){}
+ seqDoubleRet = xBT2.setSequenceDouble(_arDouble)
+ bRet = check( compareData(seqDoubleRet, _arDouble), "sequence test") And bRet
+ Dim _arEnum() As TestEnum = New TestEnum(){}
+ seqEnumRet = xBT2.setSequenceEnum(_arEnum)
+ bRet = check( compareData(seqEnumRet, _arEnum), "sequence test") And bRet
+ Dim _arUShort() As UInt16 = New UInt16(){}
+ seqUShortRet = xBT2.setSequenceUShort(_arUShort)
+ bRet = check( compareData(seqUShortRet, _arUShort), "sequence test") And bRet
+ Dim _arULong() As UInt32 = New UInt32(){}
+ seqULongRet = xBT2.setSequenceULong(_arULong)
+ bRet = check( compareData(seqULongRet, _arULong), "sequence test") And bRet
+ Dim _arUHyper() As UInt64 = New UInt64(){}
+ seqUHyperRet = xBT2.setSequenceUHyper(_arUHyper)
+ bRet = check( compareData(seqUHyperRet, _arUHyper), "sequence test") And bRet
+ Dim _arObject() As Object = New Object(){}
+ seqObjectRet = xBT2.setSequenceXInterface(_arObject)
+ bRet = check( compareData(seqObjectRet, _arObject), "sequence test") And bRet
+ Dim _arString() As String = New String(){}
+ seqStringRet = xBT2.setSequenceString(_arString)
+ bRet = check( compareData(seqStringRet, _arString), "sequence test") And bRet
+ Dim _arStruct() As TestElement = New TestElement(){}
+ seqStructRet = xBT2.setSequenceStruct(_arStruct)
+ bRet = check( compareData(seqStructRet, _arStruct), "sequence test") And bRet
+ Return bRet
+ End Function
+
+ Private Shared Function testAny(typ As Type, value As Object, _
+ xLBT As XBridgeTest ) As Boolean
+
+ Dim any As Any
+ If (typ Is Nothing)
+ any = New Any(value.GetType(), value)
+ Else
+ any = New Any(typ, value)
+ End If
+
+ Dim any2 As Any = xLBT.transportAny(any)
+ Dim ret As Boolean = compareData(any, any2)
+ If ret = False
+ Console.WriteLine("any is different after roundtrip: in {0}, " _
+ & "out {1}\n", _
+ any.Type.FullName, any2.Type.FullName)
+ End If
+ Return ret
+ End Function
+
+ Private Shared Function performAnyTest(xLBT As XBridgeTest, _
+ data As TestDataElements) As Boolean
+ Dim bReturn As Boolean = True
+ bReturn = testAny( Nothing, data.Byte ,xLBT ) And bReturn
+ bReturn = testAny( Nothing, data.Short,xLBT ) And bReturn
+ bReturn = testAny( Nothing, data.UShort,xLBT ) And bReturn
+ bReturn = testAny( Nothing, data.Long,xLBT ) And bReturn
+ bReturn = testAny( Nothing, data.ULong,xLBT ) And bReturn
+ bReturn = testAny( Nothing, data.Hyper,xLBT ) And bReturn
+ bReturn = testAny( Nothing,data.UHyper,xLBT ) And bReturn
+ bReturn = testAny( Nothing, data.Float,xLBT ) And bReturn
+ bReturn = testAny( Nothing, data.Double,xLBT ) And bReturn
+ bReturn = testAny( Nothing, data.Enum,xLBT ) And bReturn
+ bReturn = testAny( Nothing, data.String,xLBT ) And bReturn
+ bReturn = testAny( Nothing, data.Byte2 ,xLBT ) And bReturn
+ bReturn = testAny( Nothing, data.Short2,xLBT ) And bReturn
+ bReturn = testAny(GetType(unoidl.com.sun.star.uno.XWeak), _
+ data.Interface,xLBT ) And bReturn
+ bReturn = testAny(Nothing, data, xLBT ) And bReturn
+
+ Dim a1 As Any = New Any(True)
+ Dim a2 As Any = xLBT.transportAny( a1 )
+ bReturn = compareData(a2, a1) And bReturn
+
+ Dim a3 As Any = New Any("A"C)
+ Dim a4 As Any = xLBT.transportAny(a3)
+ bReturn = compareData(a4, a3) And bReturn
+
+ Return bReturn
+ End Function
+
+ Private Shared Function performSequenceOfCallTest(xLBT As XBridgeTest) As Boolean
+
+ Dim i, nRounds As Integer
+ Dim nGlobalIndex As Integer = 0
+ const nWaitTimeSpanMUSec As Integer = 10000
+ For nRounds = 0 To 9
+ For i = 0 To nRounds - 1
+ ' fire oneways
+ xLBT.callOneway(nGlobalIndex, nWaitTimeSpanMUSec)
+ nGlobalIndex = nGlobalIndex + 1
+ Next
+
+ ' call synchron
+ xLBT.call(nGlobalIndex, nWaitTimeSpanMUSec)
+ nGlobalIndex = nGlobalIndex + 1
+ Next
+ Return xLBT.sequenceOfCallTestPassed()
+ End Function
+
+ Private Shared Function performRecursiveCallTest(xLBT As XBridgeTest) As Boolean
+ xLBT.startRecursiveCall(new ORecursiveCall(), 50)
+ ' on failure, the test would lock up or crash
+ Return True
+ End Function
+
+
+ Private Shared Function performTest(xLBT As XBridgeTest) As Boolean
+ check( Not xLBT Is Nothing, "### no test interface!" )
+ Dim bRet As Boolean = True
+ If xLBT Is Nothing
+ Return False
+ End If
+ 'this data is never ever granted access to by calls other than equals(), assign()!
+ Dim aData As New TestDataElements' test against this data
+ Dim xI As New WeakBase
+
+ Dim aAny As New Any(GetType(System.Object), xI)
+ assign( DirectCast(aData, TestElement), _
+ True, "@"C, 17, &H1234, Convert.ToUInt16(&HdcS), &H12345678, _
+ Convert.ToUInt32(4294967294), _
+ &H123456789abcdef0, Convert.ToUInt64(14294967294), _
+ 17.0815f, 3.1415926359, TestEnum.LOLA, _
+ CONSTANTS.STRING_TEST_CONSTANT, xI, _
+ aAny)
+
+ bRet = check( aData.Any.Value Is xI, "### unexpected any!" ) And bRet
+
+ aData.Sequence = New TestElement(1){}
+ aData.Sequence(0) = New TestElement( _
+ aData.Bool, aData.Char, aData.Byte, aData.Short, _
+ aData.UShort, aData.Long, aData.ULong, _
+ aData.Hyper, aData.UHyper, aData.Float, _
+ aData.Double, aData.Enum, aData.String, _
+ aData.Interface, aData.Any)
+ aData.Sequence(1) = New TestElement 'is empty
+
+ ' aData complete
+ '
+ ' this is a manually copy of aData for first setting...
+ Dim aSetData As New TestDataElements
+ Dim aAnySet As New Any(GetType(System.Object), xI)
+ assign( DirectCast(aSetData, TestElement), _
+ aData.Bool, aData.Char, aData.Byte, aData.Short, aData.UShort, _
+ aData.Long, aData.ULong, aData.Hyper, aData.UHyper, aData.Float, _
+ aData.Double, aData.Enum, aData.String, xI, aAnySet)
+
+ aSetData.Sequence = New TestElement(1){}
+ aSetData.Sequence(0) = New TestElement( _
+ aSetData.Bool, aSetData.Char, aSetData.Byte, aSetData.Short, _
+ aSetData.UShort, aSetData.Long, aSetData.ULong, _
+ aSetData.Hyper, aSetData.UHyper, aSetData.Float, _
+ aSetData.Double, aSetData.Enum, aSetData.String, _
+ aSetData.Byte2, aSetData.Short2, _
+ aSetData.Interface, aSetData.Any)
+ aSetData.Sequence(1) = New TestElement ' empty struct
+
+ xLBT.setValues( _
+ aSetData.Bool, _
+ aSetData.Char, _
+ aSetData.Byte, _
+ aSetData.Short, _
+ aSetData.UShort, _
+ aSetData.Long, _
+ aSetData.ULong, _
+ aSetData.Hyper, _
+ aSetData.UHyper, _
+ aSetData.Float, _
+ aSetData.Double, _
+ aSetData.Enum, _
+ aSetData.String, _
+ aSetData.Byte2, _
+ aSetData.Short2, _
+ aSetData.Interface, _
+ aSetData.Any, _
+ aSetData.Sequence, _
+ aSetData )
+
+
+ Dim aRet As New TestDataElements
+ Dim aRet2 As New TestDataElements
+ xLBT.getValues( _
+ aRet.Bool, _
+ aRet.Char, _
+ aRet.Byte, _
+ aRet.Short, _
+ aRet.UShort, _
+ aRet.Long, _
+ aRet.ULong, _
+ aRet.Hyper, _
+ aRet.UHyper, _
+ aRet.Float, _
+ aRet.Double, _
+ aRet.Enum, _
+ aRet.String, _
+ aRet.Byte2, _
+ aRet.Short2, _
+ aRet.Interface, _
+ aRet.Any, _
+ aRet.Sequence, _
+ aRet2 )
+
+ bRet = check( compareData( aData, aRet ) And _
+ compareData( aData, aRet2 ) , "getValues test") And bRet
+
+ ' set last retrieved values
+ Dim aSV2ret As TestDataElements= xLBT.setValues2( _
+ aRet.Bool, _
+ aRet.Char, _
+ aRet.Byte, _
+ aRet.Short, _
+ aRet.UShort, _
+ aRet.Long, _
+ aRet.ULong, _
+ aRet.Hyper, _
+ aRet.UHyper, _
+ aRet.Float, _
+ aRet.Double, _
+ aRet.Enum, _
+ aRet.String, _
+ aRet.Byte2, _
+ aRet.Short2, _
+ aRet.Interface, _
+ aRet.Any, _
+ aRet.Sequence, _
+ aRet2 )
+
+ ' check inout sequence order
+ ' => inout sequence parameter was switched by test objects
+ Dim temp As TestElement = aRet.Sequence( 0 )
+ aRet.Sequence( 0 ) = aRet.Sequence( 1 )
+ aRet.Sequence( 1 ) = temp
+
+ bRet = check( _
+ compareData( aData, aSV2ret ) And compareData( aData, aRet2 ), _
+ "getValues2 test") And bRet
+
+
+ aRet = New TestDataElements
+ aRet2 = New TestDataElements
+ Dim aGVret As TestDataElements= xLBT.getValues( _
+ aRet.Bool, _
+ aRet.Char, _
+ aRet.Byte, _
+ aRet.Short, _
+ aRet.UShort, _
+ aRet.Long, _
+ aRet.ULong, _
+ aRet.Hyper, _
+ aRet.UHyper, _
+ aRet.Float, _
+ aRet.Double, _
+ aRet.Enum, _
+ aRet.String, _
+ aRet.Byte2, _
+ aRet.Short2, _
+ aRet.Interface, _
+ aRet.Any, _
+ aRet.Sequence, _
+ aRet2 )
+
+ bRet = check( compareData( aData, aRet ) And _
+ compareData( aData, aRet2 ) And _
+ compareData( aData, aGVret ), "getValues test" ) And bRet
+
+ ' set last retrieved values
+ xLBT.Bool = aRet.Bool
+ xLBT.Char = aRet.Char
+ xLBT.Byte = aRet.Byte
+ xLBT.Short = aRet.Short
+ xLBT.UShort = aRet.UShort
+ xLBT.Long = aRet.Long
+ xLBT.ULong = aRet.ULong
+ xLBT.Hyper = aRet.Hyper
+ xLBT.UHyper = aRet.UHyper
+ xLBT.Float = aRet.Float
+ xLBT.Double = aRet.Double
+ xLBT.Enum = aRet.Enum
+ xLBT.String = aRet.String
+ xLBT.Byte2 = aRet.Byte2
+ xLBT.Short2 = aRet.Short2
+ xLBT.Interface = aRet.Interface
+ xLBT.Any = aRet.Any
+ xLBT.Sequence = aRet.Sequence
+ xLBT.Struct = aRet2
+
+
+ aRet = New TestDataElements
+ aRet2 = New TestDataElements
+ aRet.Hyper = xLBT.Hyper
+ aRet.UHyper = xLBT.UHyper
+ aRet.Float = xLBT.Float
+ aRet.Double = xLBT.Double
+ aRet.Byte = xLBT.Byte
+ aRet.Char = xLBT.Char
+ aRet.Bool = xLBT.Bool
+ aRet.Short = xLBT.Short
+ aRet.UShort = xLBT.UShort
+ aRet.Long = xLBT.Long
+ aRet.ULong = xLBT.ULong
+ aRet.Enum = xLBT.Enum
+ aRet.String = xLBT.String
+ aRet.Byte2 = xLBT.Byte2
+ aRet.Short2 = xLBT.Short2
+ aRet.Interface = xLBT.Interface
+ aRet.Any = xLBT.Any
+ aRet.Sequence = xLBT.Sequence
+ aRet2 = xLBT.Struct
+
+ bRet = check( compareData( aData, aRet ) And _
+ compareData( aData, aRet2 ) , "struct comparison test") _
+ And bRet
+
+ bRet = check(performSequenceTest(xLBT), "sequence test") And bRet
+
+ ' any test
+ bRet = check( performAnyTest( xLBT , aData ) , "any test" ) And bRet
+
+ 'sequence of call test
+ bRet = check( performSequenceOfCallTest( xLBT ) , _
+ "sequence of call test" ) And bRet
+
+ ' recursive call test
+ bRet = check( performRecursiveCallTest( xLBT ) , "recursive test" ) _
+ And bRet
+
+ bRet = (compareData( aData, aRet ) And compareData( aData, aRet2 )) _
+ And bRet
+
+ ' check setting of null reference
+ xLBT.Interface = Nothing
+ aRet.Interface = xLBT.Interface
+ bRet = (aRet.Interface Is Nothing) And bRet
+
+ Return bRet
+ End Function
+
+ Private Shared Function raiseException(xLBT As XBridgeTest) As Boolean
+ Dim nCount As Integer = 0
+ Try
+ Try
+ Try
+ Dim aRet As TestDataElements = New TestDataElements
+ Dim aRet2 As TestDataElements = New TestDataElements
+ xLBT.raiseException( _
+ 5, CONSTANTS.STRING_TEST_CONSTANT, xLBT.Interface )
+ Catch rExc As unoidl.com.sun.star.lang.IllegalArgumentException
+ If rExc.ArgumentPosition = 5 And _
+ rExc.Context Is xLBT.Interface
+ nCount = nCount + 1
+ Else
+ check( False, "### unexpected exception content!" )
+ End If
+
+ 'it is certain, that the RuntimeException testing will fail,
+ ' if no
+ xLBT.RuntimeException = 0
+ End Try
+ Catch rExc As unoidl.com.sun.star.uno.RuntimeException
+ If rExc.Context Is xLBT.Interface
+ nCount = nCount + 1
+ Else
+ check( False, "### unexpected exception content!" )
+ End If
+ xLBT.RuntimeException = CType(&Hcafebabe, Integer)
+ End Try
+ Catch rExc As unoidl.com.sun.star.uno.Exception
+ If rExc.Context Is xLBT.Interface
+ nCount = nCount + 1
+ Else
+ check( False, "### unexpected exception content!" )
+ End If
+ Return nCount = 3
+ End Try
+ Return False
+ End Function
+
+ Private Shared Function raiseOnewayException(xLBT As XBridgeTest) As Boolean
+ Dim bReturn As Boolean= True
+ Dim sCompare As String = CONSTANTS.STRING_TEST_CONSTANT
+ Try
+ ' Note : the exception may fly or not (e.g. remote scenario).
+ ' When it flies, it must contain the correct elements.
+ xLBT.raiseRuntimeExceptionOneway(sCompare, xLBT.Interface )
+ Catch e As RuntimeException
+ bReturn = xLBT.Interface Is e.Context
+ End Try
+ Return bReturn
+ End Function
+
+ 'Test the System::Object method on the proxy object
+ '
+ Private Shared Function testObjectMethodsImplementation(xLBT As XBridgeTest) As Boolean
+ Dim ret As Boolean = False
+ Dim obj As Object = New Object
+ Dim xInt As Object = DirectCast(xLBT, Object)
+ Dim xBase As XBridgeTestBase = DirectCast(xLBT, XBridgeTestBase)
+ ' Object.Equals
+ ret = DirectCast(xLBT, Object).Equals(obj) = False
+ ret = DirectCast(xLBT, Object).Equals(xLBT) And ret
+ ret = Object.Equals(obj, obj) And ret
+ ret = Object.Equals(xLBT, xBase) And ret
+ 'Object.GetHashCode
+ ' Don't know how to verify this. Currently it is not possible to get the object id from a proxy
+ Dim nHash As Integer = DirectCast(xLBT, Object).GetHashCode()
+ ret = nHash = DirectCast(xBase, Object).GetHashCode() And ret
+
+ 'Object.ToString
+ ' Don't know how to verify this automatically.
+ Dim s As String = DirectCast(xLBT, Object).ToString()
+ ret = (s.Length > 0) And ret
+ Return ret
+ End Function
+
+ Private Shared Function performQueryForUnknownType(xLBT As XBridgeTest) As Boolean
+ Dim bRet As Boolean = False
+ ' test queryInterface for an unknown type
+ Try
+ Dim a As foo.MyInterface = DirectCast(xLBT, foo.MyInterface)
+ Catch e As System.InvalidCastException
+ bRet = True
+ End Try
+
+ Return bRet
+ End Function
+
+
+ Private Shared Sub perform_test( xLBT As XBridgeTest)
+ Dim bRet As Boolean = True
+ bRet = check( performTest( xLBT ), "standard test" ) And bRet
+ bRet = check( raiseException( xLBT ) , "exception test" ) And bRet
+ bRet = check( raiseOnewayException( xLBT ), "oneway exception test" ) _
+ And bRet
+ bRet = check( testObjectMethodsImplementation(xLBT), _
+ "object methods test") And bRet
+ bRet = performQueryForUnknownType( xLBT ) And bRet
+ If Not bRet
+ Throw New unoidl.com.sun.star.uno.RuntimeException( "error: test failed!", Nothing)
+ End If
+ End Sub
+
+
+
+ Public Overridable Function run(args() As String) As Integer _
+ Implements XMain.run
+ Try
+ If (args.Length < 1)
+ Throw New RuntimeException( _
+ "missing argument for bridgetest!", Me )
+ End If
+
+ Dim test_obj As Object = _
+ m_xContext.getServiceManager().createInstanceWithContext( _
+ args( 0 ), m_xContext )
+
+ Debug.WriteLine( _
+ "cli target bridgetest obj: {0}", test_obj.ToString() )
+ Dim xTest As XBridgeTest = DirectCast(test_obj, XBridgeTest)
+ perform_test( xTest )
+ Console.WriteLine("### cli_uno VB bridgetest succeeded.")
+ return 0
+ Catch e as unoidl.com.sun.star.uno.RuntimeException
+ Throw
+ Catch e as System.Exception
+ Throw New unoidl.com.sun.star.uno.RuntimeException( _
+ "cli_vb_bridgetest.vb: unexpected exception occurred in XMain::run. " _
+ & "Original exception: " + e.GetType().Name + "\n Message: " _
+ & e.Message , Nothing)
+
+ End Try
+ End Function
+
+End Class
+
+End Namespace
diff --git a/testtools/source/bridgetest/cli/cli_vb_testobj.vb b/testtools/source/bridgetest/cli/cli_vb_testobj.vb
new file mode 100644
index 000000000..d90b94e4a
--- /dev/null
+++ b/testtools/source/bridgetest/cli/cli_vb_testobj.vb
@@ -0,0 +1,615 @@
+'
+' This file is part of the LibreOffice project.
+'
+' This Source Code Form is subject to the terms of the Mozilla Public
+' License, v. 2.0. If a copy of the MPL was not distributed with this
+' file, You can obtain one at http://mozilla.org/MPL/2.0/.
+'
+' This file incorporates work covered by the following license notice:
+'
+' Licensed to the Apache Software Foundation (ASF) under one or more
+' contributor license agreements. See the NOTICE file distributed
+' with this work for additional information regarding copyright
+' ownership. The ASF licenses this file to you under the Apache
+' License, Version 2.0 (the "License"); you may not use this file
+' except in compliance with the License. You may obtain a copy of
+' the License at http://www.apache.org/licenses/LICENSE-2.0 .
+'
+
+Option Explicit On
+Option Strict On
+
+imports System
+imports uno
+imports uno.util
+imports unoidl.com.sun.star.lang
+imports unoidl.com.sun.star.uno
+imports unoidl.com.sun.star.test.bridge
+imports System.Windows.Forms
+imports System.Diagnostics
+imports System.Reflection
+
+
+Namespace vb_testobj
+Public Class VBBridgeTestObject
+ Inherits WeakBase
+ Implements XRecursiveCall, XBridgeTest2
+
+ Private m_xContext As XComponentContext
+
+ Public Sub New (xContext As XComponentContext)
+ MyBase.New
+ m_xContext = xContext
+ End Sub
+
+ Private m_bool As Boolean
+ Private m_char As Char
+ Private m_byte As Byte
+ Private m_short As Short
+ Private m_ushort As UInt16
+ Private m_long As Integer
+ Private m_ulong As UInt32
+ Private m_hyper As Long
+ Private m_uhyper As UInt64
+ Private m_float As Single
+ Private m_double As Double
+ Private m_string As String
+ Private m_xInterface As Object
+ Private m_any As Any
+ Private m_testEnum As TestEnum = TestEnum.TEST
+ Private m_testElements() As TestElement = New TestElement(){}
+ Private m_testDataElements As TestDataElements = New TestDataElements
+ Private m_nLastCallId As Integer = 0
+ Private m_bFirstCall As Boolean = True
+ Private m_bSequenceOfCallTestPassed As Boolean = True
+
+ Private m_arBool() As Boolean
+ Private m_arChar() As Char
+ Private m_arByte() As Byte
+ Private m_arShort() As Short
+ Private m_arLong() As Integer
+ Private m_arHyper() As Long
+ Private m_arUShort() As UInt16
+ Private m_arULong() As UInt32
+ Private m_arUHyper() As UInt64
+ Private m_arString() As String
+ Private m_arFloat() As Single
+ Private m_arDouble() As Double
+ Private m_arEnum() As TestEnum
+ Private m_arObject() As Object
+ Private m_arLong2()() As Integer
+ Private m_arLong3()()() As Integer
+ Private m_arAny() As Any
+
+ Public Overridable Sub setValues( _
+ bBool As Boolean, aChar As Char, nByte As Byte, nShort As Short, _
+ nUShort As UInt16, nLong As Integer, nULong As UInt32, _
+ nHyper As Long, nUHyper As UInt64, fFloat As Single, _
+ fDouble As Double, testEnum As TestEnum, str As String, _
+ xInterface As Object, any As Any, testElements() As TestElement, _
+ testDataElements As TestDataElements) _
+ Implements XBridgeTest2.setValues
+#if DEBUG
+ ' Console.WriteLine( "##### " + GetType().FullName + ".setValues:" + any )
+#endif
+ m_bool = bBool
+ m_char = aChar
+ m_byte = nByte
+ m_short = nShort
+ m_ushort = nUShort
+ m_long = nLong
+ m_ulong = nULong
+ m_hyper = nHyper
+ m_uhyper = nUHyper
+ m_float = fFloat
+ m_double = fDouble
+ m_testEnum = testEnum
+ m_string = str
+ m_xInterface = xInterface
+ m_any = any
+ m_testElements = testElements
+ m_testDataElements = testDataElements
+ End Sub
+
+ Public Overridable Function setValues2( _
+ ByRef io_bool As Boolean, ByRef io_char As Char, _
+ ByRef io_byte As Byte, ByRef io_short As Short, _
+ ByRef io_ushort As UInt16, ByRef io_long As Integer, _
+ ByRef io_ulong As UInt32, ByRef io_hyper As Long, _
+ ByRef io_uhyper As UInt64, ByRef io_float As Single, _
+ ByRef io_double As Double, ByRef io_testEnum As TestEnum, _
+ ByRef io_string As String, ByRef io_xInterface As Object, _
+ ByRef io_any As Any, ByRef io_testElements() As TestElement, _
+ ByRef io_testDataElements As TestDataElements) As TestDataElements _
+ Implements XBridgeTest2.setValues2
+
+#if DEBUG
+ 'Console.WriteLine( "##### " + GetType().FullName + ".setValues2:" + io_any )
+#endif
+
+ m_bool = io_bool
+ m_char = io_char
+ m_byte = io_byte
+ m_short = io_short
+ m_ushort = io_ushort
+ m_long = io_long
+ m_ulong = io_ulong
+ m_hyper = io_hyper
+ m_uhyper = io_uhyper
+ m_float = io_float
+ m_double = io_double
+ m_testEnum = io_testEnum
+ m_string = io_string
+ m_xInterface = io_xInterface
+ m_any = io_any
+ m_testElements = DirectCast(io_testElements.Clone(), TestElement())
+ m_testDataElements = io_testDataElements
+
+ Dim temp As TestElement = io_testElements(0)
+ io_testElements(0) = io_testElements(1)
+ io_testElements(1) = temp
+
+ Return m_testDataElements
+ End Function
+
+ Public Overridable Function getValues( _
+ ByRef o_bool As Boolean, ByRef o_char As Char, _
+ ByRef o_byte As Byte, ByRef o_short As Short, _
+ ByRef o_ushort As UInt16, ByRef o_long As Integer, _
+ ByRef o_ulong As UInt32, ByRef o_hyper As Long, _
+ ByRef o_uhyper As UInt64, ByRef o_float As Single, _
+ ByRef o_double As Double, ByRef o_testEnum As TestEnum, _
+ ByRef o_string As String, ByRef o_xInterface As Object, _
+ ByRef o_any As Any, ByRef o_testElements() As TestElement, _
+ ByRef o_testDataElements As TestDataElements) As TestDataElements _
+ Implements XBridgeTest2.getValues
+#if DEBUG
+ 'Console.WriteLine( "##### " + GetType().FullName + ".getValues" )
+#endif
+
+ o_bool = m_bool
+ o_char = m_char
+ o_byte = m_byte
+ o_short = m_short
+ o_ushort = m_ushort
+ o_long = m_long
+ o_ulong = m_ulong
+ o_hyper = m_hyper
+ o_uhyper = m_uhyper
+ o_float = m_float
+ o_double = m_double
+ o_testEnum = m_testEnum
+ o_string = m_string
+ o_xInterface = m_xInterface
+ o_any = m_any
+ o_testElements = m_testElements
+ o_testDataElements = m_testDataElements
+
+ Return m_testDataElements
+ End Function
+
+ ' Attributes ---------------------------------------------------------
+ Public Overridable Property Bool As Boolean _
+ Implements XBridgeTest2.Bool
+ Get
+ Return m_bool
+ End Get
+ Set (Value As Boolean)
+ m_bool = value
+ End Set
+ End Property
+
+ Public Overridable Property [Byte] As Byte _
+ Implements XBridgeTest2.Byte
+ Get
+ Return m_byte
+ End Get
+ Set (Value As Byte)
+ m_byte = value
+ End Set
+ End Property
+
+ Public Overridable Property [Char] As Char _
+ Implements XBridgeTest2.Char
+ Get
+ Return m_char
+ End Get
+ Set (Value As Char)
+ m_char = value
+ End Set
+ End Property
+
+ Public Overridable Property [Short] As Short _
+ Implements XBridgeTest2.Short
+ Get
+ Return m_short
+ End Get
+ Set (Value As Short)
+ m_short = value
+ End Set
+ End Property
+
+ Public Overridable Property [UShort] As UInt16 _
+ Implements XBridgeTest2.UShort
+ Get
+ Return m_ushort
+ End Get
+ Set (Value As UInt16)
+ m_ushort = value
+ End Set
+ End Property
+
+ Public Overridable Property [Long] As Integer _
+ Implements XBridgeTest2.Long
+ Get
+ Return m_long
+ End Get
+ Set (Value As Integer)
+ m_long = value
+ End Set
+ End Property
+
+ Public Overridable Property [ULong]() As UInt32 _
+ Implements XBridgeTest2.ULong
+ Get
+ Return m_ulong
+ End Get
+ Set (Value As UInt32)
+ m_ulong = value
+ End Set
+ End Property
+
+ Public Overridable Property Hyper As Long _
+ Implements XBridgeTest2.Hyper
+ Get
+ Return m_hyper
+ End Get
+ Set (Value As Long)
+ m_hyper = value
+ End Set
+ End Property
+
+ Public Overridable Property UHyper As UInt64 _
+ Implements XBridgeTest2.UHyper
+ Get
+ Return m_uhyper
+ End Get
+ Set (Value As UInt64)
+ m_uhyper = value
+ End Set
+ End Property
+
+ Public Overridable Property Float As Single _
+ Implements XBridgeTest2.Float
+ Get
+ Return m_float
+ End Get
+ Set (Value As Single)
+ m_float = value
+ End Set
+ End Property
+
+ Public Overridable Property [Double] As Double _
+ Implements XBridgeTest2.Double
+ Get
+ Return m_double
+ End Get
+ Set (Value As Double)
+ m_double = value
+ End Set
+ End Property
+
+ Public Overridable Property [Enum] As TestEnum _
+ Implements XBridgeTest2.Enum
+ Get
+ Return m_testEnum
+ End Get
+ Set (Value As TestEnum)
+ m_testEnum = value
+ End Set
+ End Property
+
+ Public Overridable Property [String] As String _
+ Implements XBridgeTest2.String
+ Get
+ Return m_string
+ End Get
+ Set (Value As String)
+ m_string = value
+ End Set
+ End Property
+
+ Public Overridable Property [Interface] As Object _
+ Implements XBridgeTest2.Interface
+ Get
+ Return m_xInterface
+ End Get
+ Set (Value As Object)
+ m_xInterface = value
+ End Set
+ End Property
+
+ Public Overridable Property Any As uno.Any _
+ Implements XBridgeTest2.Any
+ Get
+#if DEBUG
+' Console.WriteLine( "##### " + GetType().FullName + ".Any" )
+#endif
+ Return m_any
+ End Get
+ Set (Value As Any)
+#if DEBUG
+ 'Console.WriteLine( "##### " + GetType().FullName + ".Any:" + value )
+#endif
+ m_any = value
+ End Set
+ End Property
+
+ Public Overridable Property Sequence As TestElement() _
+ Implements XBridgeTest2.Sequence
+ Get
+ Return m_testElements
+ End Get
+ Set (Value() As TestElement)
+ m_testElements = value
+ End Set
+ End Property
+
+ Public Overridable Property Struct As TestDataElements _
+ Implements XBridgeTest2.Struct
+ Get
+ Return m_testDataElements
+ End Get
+ Set (Value As TestDataElements)
+ m_testDataElements = value
+ End Set
+ End Property
+
+ Public Overridable Function transportAny(value As Any) As Any _
+ Implements XBridgeTest2.transportAny
+ Return value
+ End Function
+
+ Public Overridable Sub [call](nCallId As Integer, nWaitMUSEC As Integer) _
+ Implements XBridgeTest2.call
+
+ Threading.Thread.Sleep(CType(nWaitMUSEC / 10000, Integer))
+ If m_bFirstCall = True
+ m_bFirstCall = False
+ Else
+ m_bSequenceOfCallTestPassed = m_bSequenceOfCallTestPassed And (nCallId > m_nLastCallId)
+ End If
+ m_nLastCallId = nCallId
+ End Sub
+
+ Public Overridable Sub callOneway(nCallId As Integer, nWaitMUSEC As Integer) _
+ Implements XBridgeTest2.callOneway
+
+ Threading.Thread.Sleep(CType(nWaitMUSEC / 10000, Integer))
+ m_bSequenceOfCallTestPassed = m_bSequenceOfCallTestPassed And (nCallId > m_nLastCallId)
+ m_nLastCallId = nCallId
+ End Sub
+
+ Public Overridable Function sequenceOfCallTestPassed() As Boolean _
+ Implements XBridgeTest2.sequenceOfCallTestPassed
+ Return m_bSequenceOfCallTestPassed
+ End Function
+
+ Public Overridable Sub callRecursivly(xCall As XRecursiveCall, nToCall As Integer) _
+ Implements XRecursiveCall.callRecursivly
+ SyncLock (Me)
+ If nToCall <> 0
+ nToCall = nToCall - 1
+ xCall.callRecursivly(Me , nToCall)
+ End If
+ End SyncLock
+ End Sub
+
+ Public Overridable Sub startRecursiveCall(xCall As XRecursiveCall, nToCall As Integer) _
+ Implements XBridgeTest2.startRecursiveCall
+ SyncLock (Me)
+ If nToCall <> 0
+ nToCall = nToCall - 1
+ xCall.callRecursivly(Me , nToCall )
+ End If
+ End SyncLock
+ End Sub
+
+ ' XBridgeTest
+ Public Overridable Function raiseException( _
+ nArgumentPos As Short, rMsg As String, xContext As Object) As TestDataElements _
+ Implements XBridgeTest2.raiseException
+ Throw New IllegalArgumentException(rMsg, xContext, nArgumentPos)
+ End Function
+
+ Public Overridable Sub raiseRuntimeExceptionOneway(rMsg As String , xContext As Object) _
+ Implements XBridgeTest2.raiseRuntimeExceptionOneway
+ Throw New RuntimeException(rMsg, xContext)
+ End Sub
+
+ Public Overridable Property RuntimeException As Integer _
+ Implements XBridgeTest2.RuntimeException
+ Get
+ Throw New RuntimeException(m_string, m_xInterface)
+ End Get
+ Set (Value As Integer)
+ Throw New RuntimeException(m_string, m_xInterface)
+ End Set
+ End Property
+
+ ' XBridgeTest2
+ Public Overridable Function setDim2(val()() As Integer) As Integer()() _
+ Implements XBridgeTest2.setDim2
+ m_arLong2 = val
+ Return val
+ End Function
+
+ Public Overridable Function setDim3(val()()() As Integer) As Integer()()() _
+ Implements XBridgeTest2.setDim3
+ m_arLong3 = val
+ Return val
+ End Function
+
+ Public Overridable Function setSequenceAny(val() As Any) As Any() _
+ Implements XBridgeTest2.setSequenceAny
+ m_arAny = val
+ Return val
+ End Function
+
+ Public Overridable Function setSequenceBool(val() As Boolean) As Boolean() _
+ Implements XBridgeTest2.setSequenceBool
+ m_arBool = val
+ Return val
+ End Function
+
+ Public Overridable Function setSequenceByte(val() As Byte) As Byte() _
+ Implements XBridgeTest2.setSequenceByte
+ m_arByte = val
+ Return val
+ End Function
+
+ Public Overridable Function setSequenceChar(val() As Char) As Char() _
+ Implements XBridgeTest2.setSequenceChar
+ m_arChar = val
+ Return val
+ End Function
+
+ Public Overridable Function setSequenceShort(val() As Short) As Short() _
+ Implements XBridgeTest2.setSequenceShort
+ m_arShort = val
+ Return val
+ End Function
+
+ Public Overridable Function setSequenceLong(val() As Integer) As Integer() _
+ Implements XBridgeTest2.setSequenceLong
+
+ m_arLong = val
+ Return val
+ End Function
+
+ Public Overridable Function setSequenceHyper(val() As Long) As Long() _
+ Implements XBridgeTest2.setSequenceHyper
+ m_arHyper = val
+ Return val
+ End Function
+
+ Public Overridable Function setSequenceFloat(val() As Single) As Single() _
+ Implements XBridgeTest2.setSequenceFloat
+ m_arFloat = val
+ Return val
+ End Function
+
+ Public Overridable Function setSequenceDouble(val() As Double) As Double() _
+ Implements XBridgeTest2.setSequenceDouble
+ m_arDouble = val
+ Return val
+ End Function
+
+ Public Overridable Function setSequenceEnum(val() As TestEnum) As TestEnum() _
+ Implements XBridgeTest2.setSequenceEnum
+ m_arEnum = val
+ Return val
+ End Function
+
+ Public Overridable Function setSequenceUShort(val() As UInt16) As UInt16() _
+ Implements XBridgeTest2.setSequenceUShort
+ m_arUShort = val
+ Return val
+ End Function
+
+ Public Overridable Function setSequenceULong(val() As UInt32) As UInt32() _
+ Implements XBridgeTest2.setSequenceULong
+ m_arULong = val
+ Return val
+ End Function
+
+ Public Overridable Function setSequenceUHyper(val() As UInt64) As UInt64() _
+ Implements XBridgeTest2.setSequenceUHyper
+ m_arUHyper = val
+ Return val
+ End Function
+
+ Public Overridable Function setSequenceXInterface(val() As Object ) As Object() _
+ Implements XBridgeTest2.setSequenceXInterface
+ m_arObject = val
+ Return val
+ End Function
+
+ Public Overridable Function setSequenceString(val() As String) As String() _
+ Implements XBridgeTest2.setSequenceString
+ m_arString = val
+ Return val
+ End Function
+
+ Public Overridable Function setSequenceStruct(val() As TestElement) As TestElement() _
+ Implements XBridgeTest2.setSequenceStruct
+ m_testElements = val
+ Return val
+ End Function
+
+ Public Overridable Sub setSequencesInOut( _
+ ByRef aSeqBoolean() As Boolean, ByRef aSeqChar() As Char, _
+ ByRef aSeqByte() As Byte, ByRef aSeqShort() As Short, _
+ ByRef aSeqUShort() As UInt16, ByRef aSeqLong() As Integer, _
+ ByRef aSeqULong() As UInt32, ByRef aSeqHyper() As Long, _
+ ByRef aSeqUHyper() As UInt64, ByRef aSeqFloat() As Single, _
+ ByRef aSeqDouble() As Double, ByRef aSeqTestEnum() As TestEnum, _
+ ByRef aSeqString() As String, ByRef aSeqXInterface() As Object, _
+ ByRef aSeqAny() As Any, ByRef aSeqDim2()() As Integer, _
+ ByRef aSeqDim3()()() As Integer) _
+ Implements XBridgeTest2.setSequencesInOut
+
+ m_arBool = aSeqBoolean
+ m_arChar = aSeqChar
+ m_arByte = aSeqByte
+ m_arShort = aSeqShort
+ m_arUShort = aSeqUShort
+ m_arLong = aSeqLong
+ m_arULong = aSeqULong
+ m_arHyper = aSeqHyper
+ m_arUHyper = aSeqUHyper
+ m_arFloat = aSeqFloat
+ m_arDouble = aSeqDouble
+ m_arEnum = aSeqTestEnum
+ m_arString = aSeqString
+ m_arObject = aSeqXInterface
+ m_arAny = aSeqAny
+ m_arLong2 = aSeqDim2
+ m_arLong3 = aSeqDim3
+ End Sub
+
+ Public Overridable Sub setSequencesOut( _
+ ByRef aSeqBoolean() As Boolean, ByRef aSeqChar() As Char, _
+ ByRef aSeqByte() As Byte, ByRef aSeqShort() As Short, _
+ ByRef aSeqUShort() As UInt16, ByRef aSeqLong() As Integer, _
+ ByRef aSeqULong() As UInt32, ByRef aSeqHyper() As Long, _
+ ByRef aSeqUHyper() As UInt64, ByRef aSeqFloat() As Single, _
+ ByRef aSeqDouble() As Double, ByRef aSeqTestEnum() As TestEnum, _
+ ByRef aSeqString() As String, ByRef aSeqXInterface() As Object, _
+ ByRef aSeqAny() As Any, ByRef aSeqDim2()() As Integer, _
+ ByRef aSeqDim3()()() As Integer) _
+ Implements XBridgeTest2.setSequencesOut
+
+ aSeqBoolean = m_arBool
+ aSeqChar = m_arChar
+ aSeqByte = m_arByte
+ aSeqShort = m_arShort
+ aSeqUShort = m_arUShort
+ aSeqLong = m_arLong
+ aSeqULong = m_arULong
+ aSeqHyper = m_arHyper
+ aSeqUHyper = m_arUHyper
+ aSeqFloat = m_arFloat
+ aSeqDouble = m_arDouble
+ aSeqTestEnum = m_arEnum
+ aSeqString = m_arString
+ aSeqXInterface = m_arObject
+ aSeqAny = m_arAny
+ aSeqDim2 = m_arLong2
+ aSeqDim3 = m_arLong3
+
+ End Sub
+
+End Class
+
+End Namespace
diff --git a/testtools/source/bridgetest/constructors.component b/testtools/source/bridgetest/constructors.component
new file mode 100644
index 000000000..ddde08316
--- /dev/null
+++ b/testtools/source/bridgetest/constructors.component
@@ -0,0 +1,28 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+ * This file is part of the LibreOffice project.
+ *
+ * This Source Code Form is subject to the terms of the Mozilla Public
+ * License, v. 2.0. If a copy of the MPL was not distributed with this
+ * file, You can obtain one at http://mozilla.org/MPL/2.0/.
+ *
+ * This file incorporates work covered by the following license notice:
+ *
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed
+ * with this work for additional information regarding copyright
+ * ownership. The ASF licenses this file to you under the Apache
+ * License, Version 2.0 (the "License"); you may not use this file
+ * except in compliance with the License. You may obtain a copy of
+ * the License at http://www.apache.org/licenses/LICENSE-2.0 .
+ -->
+
+<component loader="com.sun.star.loader.SharedLibrary" environment="@CPPU_ENV@"
+ xmlns="http://openoffice.org/2010/uno-components">
+ <implementation name="comp.test.testtools.bridgetest.Constructors">
+ <service name="test.testtools.bridgetest.Constructors"/>
+ </implementation>
+ <implementation name="comp.test.testtools.bridgetest.Constructors2">
+ <service name="test.testtools.bridgetest.Constructors2"/>
+ </implementation>
+</component>
diff --git a/testtools/source/bridgetest/constructors.cxx b/testtools/source/bridgetest/constructors.cxx
new file mode 100644
index 000000000..04b953fff
--- /dev/null
+++ b/testtools/source/bridgetest/constructors.cxx
@@ -0,0 +1,452 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*
+ * This file is part of the LibreOffice project.
+ *
+ * This Source Code Form is subject to the terms of the Mozilla Public
+ * License, v. 2.0. If a copy of the MPL was not distributed with this
+ * file, You can obtain one at http://mozilla.org/MPL/2.0/.
+ *
+ * This file incorporates work covered by the following license notice:
+ *
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed
+ * with this work for additional information regarding copyright
+ * ownership. The ASF licenses this file to you under the Apache
+ * License, Version 2.0 (the "License"); you may not use this file
+ * except in compliance with the License. You may obtain a copy of
+ * the License at http://www.apache.org/licenses/LICENSE-2.0 .
+ */
+
+
+#include <sal/config.h>
+
+#include <com/sun/star/lang/XInitialization.hpp>
+#include <com/sun/star/lang/XComponent.hpp>
+#include <com/sun/star/uno/Any.hxx>
+#include <com/sun/star/uno/Reference.hxx>
+#include <com/sun/star/uno/Sequence.hxx>
+#include <com/sun/star/uno/Type.hxx>
+#include <com/sun/star/uno/XComponentContext.hpp>
+#include <com/sun/star/uno/XInterface.hpp>
+#include <cppu/unotype.hxx>
+#include <cppuhelper/factory.hxx>
+#include <cppuhelper/implbase.hxx>
+#include <cppuhelper/implementationentry.hxx>
+#include <cppuhelper/weak.hxx>
+#include <rtl/ustring.hxx>
+#include <sal/types.h>
+#include <test/testtools/bridgetest/BadConstructorArguments.hpp>
+#include <test/testtools/bridgetest/TestEnum.hpp>
+#include <test/testtools/bridgetest/TestStruct.hpp>
+#include <test/testtools/bridgetest/TestPolyStruct.hpp>
+#include <test/testtools/bridgetest/TestPolyStruct2.hpp>
+#include <test/testtools/bridgetest/XMultiBase1.hpp>
+
+namespace {
+
+namespace ttb = ::test::testtools::bridgetest;
+class Impl:
+ public cppu::WeakImplHelper<css::lang::XInitialization>
+{
+public:
+ Impl() {}
+ Impl(const Impl&) = delete;
+ Impl& operator=(const Impl&) = delete;
+
+private:
+ virtual ~Impl() override {}
+
+ virtual void SAL_CALL initialize(
+ css::uno::Sequence< css::uno::Any > const & arguments) override;
+};
+
+void Impl::initialize(css::uno::Sequence< css::uno::Any > const & arguments)
+{
+ bool arg0;
+ ::sal_Int8 arg1 = sal_Int8();
+ ::sal_Int16 arg2 = sal_Int16();
+ ::sal_uInt16 arg3 = sal_uInt16();
+ ::sal_Int32 arg4 = sal_Int32();
+ ::sal_uInt32 arg5 = sal_uInt32();
+ ::sal_Int64 arg6 = sal_Int64();
+ ::sal_uInt64 arg7 = sal_uInt64();
+ float arg8 = float();
+ double arg9 = double();
+ sal_Unicode arg10 = sal_Unicode();
+ OUString arg11;
+ css::uno::Type arg12;
+ bool arg13;
+ css::uno::Sequence< sal_Bool > arg14;
+ css::uno::Sequence< ::sal_Int8 > arg15;
+ css::uno::Sequence< ::sal_Int16 > arg16;
+ css::uno::Sequence< ::sal_uInt16 > arg17;
+ css::uno::Sequence< ::sal_Int32 > arg18;
+ css::uno::Sequence< ::sal_uInt32 > arg19;
+ css::uno::Sequence< ::sal_Int64 > arg20;
+ css::uno::Sequence< ::sal_uInt64 > arg21;
+ css::uno::Sequence< float > arg22;
+ css::uno::Sequence< double > arg23;
+ css::uno::Sequence< sal_Unicode > arg24;
+ css::uno::Sequence< OUString > arg25;
+ css::uno::Sequence< css::uno::Type > arg26;
+ css::uno::Sequence< css::uno::Any > arg27;
+ bool arg27b;
+ css::uno::Sequence< css::uno::Sequence< sal_Bool > > arg28;
+ css::uno::Sequence< css::uno::Sequence< css::uno::Any > > arg29;
+ bool arg29b;
+ css::uno::Sequence< ::test::testtools::bridgetest::TestEnum > arg30;
+ css::uno::Sequence< ::test::testtools::bridgetest::TestStruct > arg31;
+ css::uno::Sequence<
+ ::test::testtools::bridgetest::TestPolyStruct< sal_Bool > > arg32;
+ css::uno::Sequence<
+ ::test::testtools::bridgetest::TestPolyStruct< css::uno::Any > > arg33;
+ bool arg33b;
+ css::uno::Sequence< css::uno::Reference< css::uno::XInterface > > arg34;
+ ::test::testtools::bridgetest::TestEnum arg35;
+ ::test::testtools::bridgetest::TestStruct arg36;
+ ::test::testtools::bridgetest::TestPolyStruct< sal_Bool > arg37;
+ ::test::testtools::bridgetest::TestPolyStruct< css::uno::Any > arg38;
+ bool arg38b;
+ css::uno::Reference< css::uno::XInterface > arg39;
+ bool ok = (arguments.getLength() == 40
+ && (arguments[0] >>= arg0) && arg0
+ && (arguments[1] >>= arg1) && arg1 == SAL_MIN_INT8
+ && (arguments[2] >>= arg2) && arg2 == SAL_MIN_INT16
+ && (arguments[3] >>= arg3) && arg3 == SAL_MAX_UINT16
+ && (arguments[4] >>= arg4) && arg4 == SAL_MIN_INT32
+ && (arguments[5] >>= arg5) && arg5 == SAL_MAX_UINT32
+ && (arguments[6] >>= arg6) && arg6 == SAL_MIN_INT64
+ && (arguments[7] >>= arg7) && arg7 == SAL_MAX_UINT64
+ && (arguments[8] >>= arg8) && arg8 == 0.123f
+ && (arguments[9] >>= arg9) && arg9 == 0.456
+ && (arguments[10] >>= arg10) && arg10 == 'X'
+ && (arguments[11] >>= arg11)
+ && arg11 == "test"
+ && (arguments[12] >>= arg12)
+ && arg12 == ::cppu::UnoType< css::uno::Any >::get()
+ && (arguments[13] >>= arg13) && arg13
+ && (arguments[14] >>= arg14) && arg14.getLength() == 1 && arg14[0]
+ && (arguments[15] >>= arg15) && arg15.getLength() == 1
+ && arg15[0] == SAL_MIN_INT8
+ && (arguments[16] >>= arg16) && arg16.getLength() == 1
+ && arg16[0] == SAL_MIN_INT16
+ && (arguments[17] >>= arg17) && arg17.getLength() == 1
+ && arg17[0] == SAL_MAX_UINT16
+ && (arguments[18] >>= arg18) && arg18.getLength() == 1
+ && arg18[0] == SAL_MIN_INT32
+ && (arguments[19] >>= arg19) && arg19.getLength() == 1
+ && arg19[0] == SAL_MAX_UINT32
+ && (arguments[20] >>= arg20) && arg20.getLength() == 1
+ && arg20[0] == SAL_MIN_INT64
+ && (arguments[21] >>= arg21) && arg21.getLength() == 1
+ && arg21[0] == SAL_MAX_UINT64
+ && (arguments[22] >>= arg22) && arg22.getLength() == 1
+ && arg22[0] == 0.123f
+ && (arguments[23] >>= arg23) && arg23.getLength() == 1
+ && arg23[0] == 0.456
+ && (arguments[24] >>= arg24) && arg24.getLength() == 1
+ && arg24[0] == 'X'
+ && (arguments[25] >>= arg25) && arg25.getLength() == 1
+ && arg25[0] == "test"
+ && (arguments[26] >>= arg26) && arg26.getLength() == 1
+ && arg26[0] == ::cppu::UnoType< css::uno::Any >::get()
+ && (arguments[27] >>= arg27) && arg27.getLength() == 1
+ && (arg27[0] >>= arg27b) && arg27b
+ && (arguments[28] >>= arg28) && arg28.getLength() == 1
+ && arg28[0].getLength() == 1 && arg28[0][0]
+ && (arguments[29] >>= arg29) && arg29.getLength() == 1
+ && arg29[0].getLength() == 1 && (arg29[0][0] >>= arg29b) && arg29b
+ && (arguments[30] >>= arg30) && arg30.getLength() == 1
+ && arg30[0] == ::test::testtools::bridgetest::TestEnum_TWO
+ && (arguments[31] >>= arg31) && arg31.getLength() == 1
+ && arg31[0].member == 10
+ && (arguments[32] >>= arg32) && arg32.getLength() == 1
+ && arg32[0].member
+ && (arguments[33] >>= arg33) && arg33.getLength() == 1
+ && (arg33[0].member >>= arg33b) && arg33b
+ && (arguments[34] >>= arg34) && arg34.getLength() == 1
+ && !arg34[0].is()
+ && (arguments[35] >>= arg35)
+ && arg35 == ::test::testtools::bridgetest::TestEnum_TWO
+ && (arguments[36] >>= arg36) && arg36.member == 10
+ && (arguments[37] >>= arg37) && arg37.member
+ && (arguments[38] >>= arg38) && (arg38.member >>= arg38b) && arg38b
+ && (arguments[39] >>= arg39) && !arg39.is());
+ if (!ok)
+ {
+ throw ::test::testtools::bridgetest::BadConstructorArguments();
+ }
+}
+
+
+class Impl2: public ::cppu::WeakImplHelper<
+ css::lang::XInitialization, ttb::XMultiBase1 >
+{
+public:
+ Impl2(): m_attr1(0.0) {}
+
+private:
+ virtual ~Impl2() override {}
+
+ virtual void SAL_CALL initialize(
+ css::uno::Sequence< css::uno::Any > const & arguments) override;
+
+ //XMultiBase1
+ virtual double SAL_CALL getatt1() override;
+ virtual void SAL_CALL setatt1( double _att1 ) override;
+ virtual ::sal_Int32 SAL_CALL fn11( ::sal_Int32 arg ) override;
+ virtual OUString SAL_CALL fn12( const OUString& arg ) override;
+
+
+ double m_attr1;
+};
+
+void Impl2::initialize(css::uno::Sequence< css::uno::Any > const & arguments)
+{
+ ttb::TestPolyStruct< css::uno::Type > arg0;
+ ttb::TestPolyStruct< css::uno::Any > arg1;
+ css::uno::Any arg1b(true);
+ ttb::TestPolyStruct< sal_Bool > arg2;
+ ttb::TestPolyStruct< ::sal_Int8 > arg3;
+ ttb::TestPolyStruct< ::sal_Int16 > arg4;
+ ttb::TestPolyStruct< ::sal_Int32 > arg5;
+ ttb::TestPolyStruct< ::sal_Int64 > arg6;
+ ttb::TestPolyStruct< ::sal_Unicode > arg7;
+ ttb::TestPolyStruct< OUString > arg8;
+ ttb::TestPolyStruct< float > arg9;
+ ttb::TestPolyStruct< double > arg10;
+ ttb::TestPolyStruct<css::uno::Reference<css::uno::XInterface> > arg11;
+ ttb::TestPolyStruct<css::uno::Reference< css::lang::XComponent> > arg12;
+ ttb::TestPolyStruct<ttb::TestEnum> arg13;
+ ttb::TestPolyStruct<
+ ttb::TestPolyStruct2<sal_Unicode, css::uno::Any> > arg14;
+ ttb::TestPolyStruct< ttb::TestPolyStruct2 <
+ ttb::TestPolyStruct2< sal_Unicode, css::uno::Any >,
+ OUString > > arg15;
+ ttb::TestPolyStruct2< OUString,ttb::TestPolyStruct2 <
+ ::sal_Unicode, ttb::TestPolyStruct < css::uno::Any > > > arg16;
+ ttb::TestPolyStruct2< ttb::TestPolyStruct2<sal_Unicode, css::uno::Any >,
+ ttb::TestPolyStruct<sal_Unicode> > arg17;
+ ttb::TestPolyStruct<css::uno::Sequence< css::uno::Type > > arg18;
+ ttb::TestPolyStruct<css::uno::Sequence<css::uno::Any> > arg19;
+ ttb::TestPolyStruct<css::uno::Sequence< sal_Bool > > arg20;
+ ttb::TestPolyStruct<css::uno::Sequence< ::sal_Int8 > > arg21;
+ ttb::TestPolyStruct<css::uno::Sequence< ::sal_Int16 > > arg22;
+ ttb::TestPolyStruct<css::uno::Sequence< ::sal_Int32 > > arg23;
+ ttb::TestPolyStruct<css::uno::Sequence< ::sal_Int64 > > arg24;
+ ttb::TestPolyStruct<css::uno::Sequence< sal_Unicode> > arg25;
+ ttb::TestPolyStruct<css::uno::Sequence< OUString > > arg26;
+ ttb::TestPolyStruct<css::uno::Sequence<float> > arg27;
+ ttb::TestPolyStruct<css::uno::Sequence<double> > arg28;
+ ttb::TestPolyStruct<css::uno::Sequence<css::uno::Reference<css::uno::XInterface> > > arg29;
+ ttb::TestPolyStruct<css::uno::Sequence<css::uno::Reference<css::lang::XComponent> > > arg30;
+ ttb::TestPolyStruct<css::uno::Sequence<ttb::TestEnum> > arg31;
+ ttb::TestPolyStruct<css::uno::Sequence<ttb::TestPolyStruct2<
+ ::sal_Unicode, css::uno::Sequence<css::uno::Any> > > > arg32;
+ bool arg32a = false;
+ ttb::TestPolyStruct<css::uno::Sequence<ttb::TestPolyStruct2<
+ ttb::TestPolyStruct< ::sal_Unicode>, css::uno::Sequence<css::uno::Any> > > > arg33;
+ ttb::TestPolyStruct<css::uno::Sequence<css::uno::Sequence< ::sal_Int32> > > arg34;
+ css::uno::Sequence<ttb::TestPolyStruct< ::sal_Int32> > arg35;
+ css::uno::Sequence<ttb::TestPolyStruct<ttb::TestPolyStruct2< ::sal_Unicode, css::uno::Any> > > arg36;
+ css::uno::Sequence<ttb::TestPolyStruct<ttb::TestPolyStruct2<
+ ttb::TestPolyStruct2< ::sal_Unicode,css::uno::Any >, OUString> > > arg37;
+ css::uno::Sequence<ttb::TestPolyStruct2< OUString, ttb::TestPolyStruct2<
+ ::sal_Unicode, ttb::TestPolyStruct<css::uno::Any> > > > arg38;
+ css::uno::Sequence<ttb::TestPolyStruct2<ttb::TestPolyStruct2<
+ ::sal_Unicode, css::uno::Any>, ttb::TestPolyStruct< ::sal_Unicode> > > arg39;
+ css::uno::Sequence<css::uno::Sequence<ttb::TestPolyStruct< ::sal_Unicode> > > arg40;
+ css::uno::Sequence<css::uno::Sequence<ttb::TestPolyStruct<ttb::TestPolyStruct2< ::sal_Unicode, css::uno::Any> > > >arg41;
+ css::uno::Sequence<css::uno::Sequence<ttb::TestPolyStruct<
+ ttb::TestPolyStruct2<ttb::TestPolyStruct2<sal_Unicode, css::uno::Any>, OUString> > > > arg42;
+ css::uno::Sequence<css::uno::Sequence<ttb::TestPolyStruct2<
+ OUString, ttb::TestPolyStruct2< ::sal_Unicode, ttb::TestPolyStruct<css::uno::Any> > > > > arg43;
+ css::uno::Sequence<css::uno::Sequence<ttb::TestPolyStruct2<
+ ttb::TestPolyStruct2< ::sal_Unicode, css::uno::Any>, ttb::TestPolyStruct<
+ ::sal_Unicode> > > > arg44;
+
+ if (!(arguments.getLength() == 45
+ && (arguments[0] >>= arg0) && arg0.member == cppu::UnoType<sal_Int32>::get()
+ && (arguments[1] >>= arg1) && arg1.member == arg1b
+ && (arguments[2] >>= arg2) && arg2.member
+ && (arguments[3] >>= arg3) && arg3.member == SAL_MIN_INT8
+ && (arguments[4] >>= arg4) && arg4.member == SAL_MIN_INT16
+ && (arguments[5] >>= arg5) && arg5.member == SAL_MIN_INT32
+ && (arguments[6] >>= arg6) && arg6.member == SAL_MIN_INT64
+ && (arguments[7] >>= arg7) && arg7.member == 'X'
+ && (arguments[8] >>= arg8) && arg8.member == "test"
+ && (arguments[9] >>= arg9) && arg9.member == 0.123f
+ && (arguments[10] >>= arg10) && arg10.member == 0.456
+ && (arguments[11] >>= arg11)
+ && (arguments[12] >>= arg12)
+ && (arguments[13] >>= arg13) && arg13.member == ttb::TestEnum_TWO
+ && (arguments[14] >>= arg14) && arg14.member.member1 == 'X' && arg14.member.member2 == arg1b
+ && (arguments[15] >>= arg15) && arg15.member.member1.member1 == 'X'
+ && arg15.member.member1.member2 == arg1b
+ && arg15.member.member2 == "test"
+ && (arguments[16] >>= arg16) && arg16.member1 == "test"
+ && arg16.member2.member1 == 'X'
+ && arg16.member2.member2.member == arg1b
+ && (arguments[17] >>= arg17) && arg17.member1.member1 == 'X'
+ && arg17.member1.member2 == arg1b
+ && arg17.member2.member == 'X'
+ && (arguments[18] >>= arg18) && arg18.member.getLength() == 1
+ && arg18.member[0] == ::cppu::UnoType<sal_Int32>::get()
+ && (arguments[19] >>= arg19) && arg19.member.getLength() == 1
+ && arg19.member[0] == arg1b
+ && (arguments[20] >>= arg20) && arg20.member.getLength() == 1
+ && arg20.member[0]
+ && (arguments[21] >>= arg21) && arg21.member.getLength() == 1
+ && arg21.member[0] == SAL_MIN_INT8
+ && (arguments[22] >>= arg22) && arg22.member.getLength() == 1
+ && arg22.member[0] == SAL_MIN_INT16
+ && (arguments[23] >>= arg23) && arg23.member.getLength() == 1
+ && arg23.member[0] == SAL_MIN_INT32
+ && (arguments[24] >>= arg24) && arg24.member.getLength() == 1
+ && arg24.member[0] == SAL_MIN_INT64
+ && (arguments[25] >>= arg25) && arg25.member.getLength() == 1
+ && arg25.member[0] == 'X'
+ && (arguments[26] >>= arg26) && arg26.member.getLength() == 1
+ && arg26.member[0] == "test"
+ && (arguments[27] >>= arg27) && arg27.member.getLength() == 1
+ && arg27.member[0] == 0.123f
+ && (arguments[28] >>= arg28) && arg28.member.getLength() == 1
+ && arg28.member[0] == 0.456
+ && (arguments[29] >>= arg29) && arg29.member.getLength() == 1
+ && arg29.member[0] != nullptr
+ && (arguments[30] >>= arg30) && arg30.member.getLength() == 1
+ && arg30.member[0] != nullptr
+ && (arguments[31] >>= arg31) && arg31.member.getLength() == 1
+ && arg31.member[0] == ttb::TestEnum_TWO
+ && (arguments[32] >>= arg32) && arg32.member.getLength() == 1
+ && arg32.member[0].member1 == 'X'
+ && arg32.member[0].member2.getLength() == 1
+ && (arg32.member[0].member2[0] >>= arg32a) && arg32a
+ && (arguments[33] >>= arg33) && arg33.member.getLength() == 1
+ && arg33.member[0].member1.member == 'X'
+ && arg33.member[0].member2.getLength() == 1
+ && arg33.member[0].member2[0] == arg1b
+ && (arguments[34] >>= arg34) && arg34.member.getLength() == 1
+ && arg34.member[0].getLength() == 1 && arg34.member[0][0] == SAL_MIN_INT32
+ && (arguments[35] >>= arg35) && arg35.getLength() == 1
+ && arg35[0].member == SAL_MIN_INT32
+ && (arguments[36] >>= arg36) && arg36.getLength() == 1
+ && arg36[0].member.member1 == 'X'
+ && arg36[0].member.member2 == arg1b
+ && (arguments[37] >>= arg37) && arg37.getLength() == 1
+ && arg37[0].member.member1.member1 == 'X'
+ && arg37[0].member.member1.member2 == arg1b
+ && arg37[0].member.member2 == "test"
+ && (arguments[38] >>= arg38) && arg38.getLength() == 1
+ && arg38[0].member1 == "test"
+ && arg38[0].member2.member1 == 'X'
+ && arg38[0].member2.member2.member == arg1b
+ && (arguments[39] >>= arg39) && arg39.getLength() == 1
+ && arg39[0].member1.member1 == 'X'
+ && arg39[0].member1.member2 == arg1b
+ && arg39[0].member2.member == 'X'
+ && (arguments[40] >>= arg40) && arg40.getLength() == 1
+ && arg40[0].getLength() == 1
+ && arg40[0][0].member == 'X'
+ && (arguments[41] >>= arg41) && arg41.getLength() == 1
+ && arg41[0].getLength() == 1
+ && arg41[0][0].member.member1 == 'X'
+ && arg41[0][0].member.member2 == arg1b
+ && (arguments[42] >>= arg42) && arg42.getLength() == 1
+ && arg42[0].getLength() == 1
+ && arg42[0][0].member.member1.member1 == 'X'
+ && arg42[0][0].member.member1.member2 == arg1b
+ && arg42[0][0].member.member2 == "test"
+ && (arguments[43] >>= arg43) && arg43.getLength() == 1
+ && arg43[0].getLength() == 1
+ && arg43[0][0].member1 == "test"
+ && arg43[0][0].member2.member1 == 'X'
+ && arg43[0][0].member2.member2.member == arg1b
+ && (arguments[44] >>= arg44) && arg44.getLength() == 1
+ && arg44[0].getLength() == 1
+ && arg44[0][0].member1.member1 == 'X'
+ && arg44[0][0].member1.member2 == arg1b
+ && arg44[0][0].member2.member == 'X'
+ ))
+ {
+ throw ::test::testtools::bridgetest::BadConstructorArguments();
+ }
+
+ //check if interfaces work
+ arg11.member->acquire();
+ arg11.member->release();
+ arg12.member->acquire();
+ arg12.member->release();
+ arg29.member[0]->acquire();
+ arg29.member[0]->release();
+
+}
+
+//XMultiBase1
+double Impl2::getatt1()
+{
+ return m_attr1;
+}
+
+void Impl2::setatt1( double _att1 )
+{
+ m_attr1 = _att1;
+}
+
+::sal_Int32 Impl2::fn11( ::sal_Int32 arg )
+{
+ return 11 * arg;
+}
+
+OUString Impl2::fn12( const OUString& arg )
+{
+ return "12" + arg;
+}
+
+css::uno::Reference< css::uno::XInterface > create(
+ SAL_UNUSED_PARAMETER css::uno::Reference< css::uno::XComponentContext >
+ const &)
+{
+ return static_cast< ::cppu::OWeakObject * >(new Impl);
+}
+
+OUString getImplementationName() {
+ return
+ "comp.test.testtools.bridgetest.Constructors";
+}
+
+css::uno::Sequence< OUString > getSupportedServiceNames() {
+ return { "test.testtools.bridgetest.Constructors" };
+}
+
+css::uno::Reference< css::uno::XInterface > create2(
+ SAL_UNUSED_PARAMETER css::uno::Reference< css::uno::XComponentContext >
+ const &)
+{
+ return static_cast< ::cppu::OWeakObject * >(new Impl2);
+}
+
+OUString getImplementationName2() {
+ return "comp.test.testtools.bridgetest.Constructors2";
+}
+
+css::uno::Sequence< OUString > getSupportedServiceNames2() {
+ return { "test.testtools.bridgetest.Constructors2" };
+}
+
+::cppu::ImplementationEntry const entries[] = {
+ { &create, &getImplementationName, &getSupportedServiceNames,
+ &::cppu::createSingleComponentFactory, nullptr, 0 },
+ { &create2, &getImplementationName2, &getSupportedServiceNames2,
+ &::cppu::createSingleComponentFactory, nullptr, 0 },
+ { nullptr, nullptr, nullptr, nullptr, nullptr, 0 } };
+}
+
+extern "C" SAL_DLLPUBLIC_EXPORT void * component_getFactory(
+ char const * implName, void * serviceManager, void * registryKey)
+{
+ return ::cppu::component_getFactoryHelper(
+ implName, serviceManager, registryKey, entries);
+}
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/testtools/source/bridgetest/cppobj.component b/testtools/source/bridgetest/cppobj.component
new file mode 100644
index 000000000..5b11d8df3
--- /dev/null
+++ b/testtools/source/bridgetest/cppobj.component
@@ -0,0 +1,25 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+ * This file is part of the LibreOffice project.
+ *
+ * This Source Code Form is subject to the terms of the Mozilla Public
+ * License, v. 2.0. If a copy of the MPL was not distributed with this
+ * file, You can obtain one at http://mozilla.org/MPL/2.0/.
+ *
+ * This file incorporates work covered by the following license notice:
+ *
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed
+ * with this work for additional information regarding copyright
+ * ownership. The ASF licenses this file to you under the Apache
+ * License, Version 2.0 (the "License"); you may not use this file
+ * except in compliance with the License. You may obtain a copy of
+ * the License at http://www.apache.org/licenses/LICENSE-2.0 .
+ -->
+
+<component loader="com.sun.star.loader.SharedLibrary" environment="@CPPU_ENV@"
+ xmlns="http://openoffice.org/2010/uno-components">
+ <implementation name="com.sun.star.comp.bridge.CppTestObject">
+ <service name="com.sun.star.test.bridge.CppTestObject"/>
+ </implementation>
+</component>
diff --git a/testtools/source/bridgetest/cppobj.cxx b/testtools/source/bridgetest/cppobj.cxx
new file mode 100644
index 000000000..13eb1e644
--- /dev/null
+++ b/testtools/source/bridgetest/cppobj.cxx
@@ -0,0 +1,1220 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*
+ * This file is part of the LibreOffice project.
+ *
+ * This Source Code Form is subject to the terms of the Mozilla Public
+ * License, v. 2.0. If a copy of the MPL was not distributed with this
+ * file, You can obtain one at http://mozilla.org/MPL/2.0/.
+ *
+ * This file incorporates work covered by the following license notice:
+ *
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed
+ * with this work for additional information regarding copyright
+ * ownership. The ASF licenses this file to you under the Apache
+ * License, Version 2.0 (the "License"); you may not use this file
+ * except in compliance with the License. You may obtain a copy of
+ * the License at http://www.apache.org/licenses/LICENSE-2.0 .
+ */
+
+#include <utility>
+
+#include <cppu/unotype.hxx>
+#include <o3tl/string_view.hxx>
+#include <osl/diagnose.h>
+#include <osl/diagnose.hxx>
+#include <osl/thread.hxx>
+#include <osl/mutex.hxx>
+
+#include <cppuhelper/implbase.hxx>
+#include <cppuhelper/factory.hxx>
+#include <cppuhelper/exc_hlp.hxx>
+#include <cppuhelper/compbase_ex.hxx>
+#include <cppuhelper/supportsservice.hxx>
+#include <com/sun/star/lang/IllegalArgumentException.hpp>
+#include <com/sun/star/lang/XServiceInfo.hpp>
+#include <com/sun/star/lang/XComponent.hpp>
+#include <com/sun/star/lang/XSingleServiceFactory.hpp>
+#include <com/sun/star/uno/Any.hxx>
+#include <com/sun/star/uno/RuntimeException.hpp>
+#include <com/sun/star/uno/Sequence.hxx>
+
+#include <test/testtools/bridgetest/Constructors.hpp>
+#include <test/testtools/bridgetest/Constructors2.hpp>
+#include <test/testtools/bridgetest/TestPolyStruct.hpp>
+#include <test/testtools/bridgetest/TestPolyStruct2.hpp>
+#include <test/testtools/bridgetest/XBridgeTest2.hpp>
+#include <test/testtools/bridgetest/XMulti.hpp>
+
+#include "currentcontextchecker.hxx"
+#include "multi.hxx"
+
+using namespace osl;
+using namespace cppu;
+using namespace com::sun::star::uno;
+using namespace com::sun::star::lang;
+using namespace com::sun::star::registry;
+using namespace test::testtools::bridgetest;
+
+#ifdef _MSC_VER
+#pragma warning (disable : 4503) // irrelevant for test code
+#endif
+
+constexpr OUStringLiteral SERVICENAME = u"com.sun.star.test.bridge.CppTestObject";
+constexpr OUStringLiteral IMPLNAME = u"com.sun.star.comp.bridge.CppTestObject";
+
+namespace bridge_object
+{
+
+
+static Sequence< OUString > getSupportedServiceNames()
+{
+ return { SERVICENAME };
+}
+
+
+static void assign( TestElement & rData,
+ bool bBool, sal_Unicode cChar, sal_Int8 nByte,
+ sal_Int16 nShort, sal_uInt16 nUShort,
+ sal_Int32 nLong, sal_uInt32 nULong,
+ sal_Int64 nHyper, sal_uInt64 nUHyper,
+ float fFloat, double fDouble,
+ TestEnum eEnum, const OUString& rStr,
+ sal_Int8 nByte2, sal_Int16 nShort2,
+ const css::uno::Reference< css::uno::XInterface >& xTest,
+ const css::uno::Any& rAny )
+{
+ rData.Bool = bBool;
+ rData.Char = cChar;
+ rData.Byte = nByte;
+ rData.Short = nShort;
+ rData.UShort = nUShort;
+ rData.Long = nLong;
+ rData.ULong = nULong;
+ rData.Hyper = nHyper;
+ rData.UHyper = nUHyper;
+ rData.Float = fFloat;
+ rData.Double = fDouble;
+ rData.Enum = eEnum;
+ rData.String = rStr;
+ rData.Byte2 = nByte2;
+ rData.Short2 = nShort2;
+ rData.Interface = xTest;
+ rData.Any = rAny;
+}
+
+static void assign( TestData & rData,
+ bool bBool, sal_Unicode cChar, sal_Int8 nByte,
+ sal_Int16 nShort, sal_uInt16 nUShort,
+ sal_Int32 nLong, sal_uInt32 nULong,
+ sal_Int64 nHyper, sal_uInt64 nUHyper,
+ float fFloat, double fDouble,
+ TestEnum eEnum, const OUString& rStr,
+ sal_Int8 nByte2, sal_Int16 nShort2,
+ const css::uno::Reference< css::uno::XInterface >& xTest,
+ const css::uno::Any& rAny,
+ const css::uno::Sequence< TestElement >& rSequence )
+{
+ assign( static_cast<TestElement &>(rData),
+ bBool, cChar, nByte, nShort, nUShort, nLong, nULong, nHyper, nUHyper, fFloat, fDouble,
+ eEnum, rStr, nByte2, nShort2, xTest, rAny );
+ rData.Sequence = rSequence;
+}
+
+namespace {
+
+class Test_Impl :
+ public osl::DebugBase<Test_Impl>,
+ public WeakImplHelper< XBridgeTest2, XServiceInfo , XRecursiveCall >
+{
+ TestData _aData, _aStructData;
+ sal_Int32 m_nLastCallId;
+ bool m_bFirstCall;
+ bool m_bSequenceOfCallTestPassed;
+ Mutex m_mutex;
+
+ Sequence<sal_Bool> _arBool;
+ Sequence<sal_Unicode> _arChar;
+ Sequence<sal_Int8> _arByte;
+ Sequence<sal_Int16> _arShort;
+ Sequence<sal_uInt16> _arUShort;
+ Sequence<sal_Int32> _arLong;
+ Sequence<sal_uInt32> _arULong;
+ Sequence<sal_Int64> _arHyper;
+ Sequence<sal_uInt64> _arUHyper;
+ Sequence<OUString> _arString;
+ Sequence<float> _arFloat;
+ Sequence<double> _arDouble;
+ Sequence<TestEnum> _arEnum;
+ Sequence<Reference<XInterface> > _arObject;
+ Sequence<Sequence<sal_Int32> > _arLong2;
+ Sequence<Sequence<Sequence<sal_Int32> > > _arLong3;
+ Sequence<Any> _arAny;
+ Sequence<TestElement> _arStruct;
+
+public:
+ Test_Impl() : m_nLastCallId( 0 ),
+ m_bFirstCall( true ),
+ m_bSequenceOfCallTestPassed( true )
+ {}
+
+ void SAL_CALL acquire() noexcept override
+ {
+ OWeakObject::acquire();
+ }
+ void SAL_CALL release() noexcept override
+ {
+ OWeakObject::release();
+ }
+
+ // XServiceInfo
+ virtual OUString SAL_CALL getImplementationName() override;
+ virtual sal_Bool SAL_CALL supportsService( const OUString & rServiceName ) override;
+ virtual Sequence< OUString > SAL_CALL getSupportedServiceNames() override;
+
+ // XLBTestBase
+ virtual void SAL_CALL setValues( sal_Bool bBool,
+ sal_Unicode cChar,
+ sal_Int8 nByte,
+ sal_Int16 nShort,
+ sal_uInt16 nUShort,
+ sal_Int32 nLong,
+ sal_uInt32 nULong,
+ sal_Int64 nHyper,
+ sal_uInt64 nUHyper,
+ float fFloat,
+ double fDouble,
+ TestEnum eEnum,
+ const OUString& rStr,
+ sal_Int8 nByte2,
+ sal_Int16 nShort2,
+ const css::uno::Reference< css::uno::XInterface >& xTest,
+ const css::uno::Any& rAny,
+ const css::uno::Sequence<TestElement >& rSequence,
+ const ::test::testtools::bridgetest::TestDataElements& rStruct ) override;
+
+ virtual ::test::testtools::bridgetest::TestDataElements SAL_CALL setValues2( sal_Bool& bBool,
+ sal_Unicode& cChar,
+ sal_Int8& nByte,
+ sal_Int16& nShort,
+ sal_uInt16& nUShort,
+ sal_Int32& nLong,
+ sal_uInt32& nULong,
+ sal_Int64& nHyper,
+ sal_uInt64& nUHyper,
+ float& fFloat,
+ double& fDouble,
+ TestEnum& eEnum,
+ OUString& rStr,
+ sal_Int8& nByte2,
+ sal_Int16& nShort2,
+ css::uno::Reference< css::uno::XInterface >& xTest,
+ css::uno::Any& rAny,
+ css::uno::Sequence<TestElement >& rSequence,
+ ::test::testtools::bridgetest::TestDataElements& rStruct ) override;
+
+ virtual ::test::testtools::bridgetest::TestDataElements SAL_CALL getValues( sal_Bool& bBool,
+ sal_Unicode& cChar,
+ sal_Int8& nByte,
+ sal_Int16& nShort,
+ sal_uInt16& nUShort,
+ sal_Int32& nLong,
+ sal_uInt32& nULong,
+ sal_Int64& nHyper,
+ sal_uInt64& nUHyper,
+ float& fFloat,
+ double& fDouble,
+ TestEnum& eEnum,
+ OUString& rStr,
+ sal_Int8& nByte2,
+ sal_Int16& nShort2,
+ css::uno::Reference< css::uno::XInterface >& xTest,
+ css::uno::Any& rAny,
+ css::uno::Sequence< TestElement >& rSequence,
+ ::test::testtools::bridgetest::TestDataElements& rStruct ) override;
+
+ virtual SmallStruct SAL_CALL echoSmallStruct(const SmallStruct& rStruct) override
+ { return rStruct; }
+ virtual MediumStruct SAL_CALL echoMediumStruct(const MediumStruct& rStruct) override
+ { return rStruct; }
+ virtual BigStruct SAL_CALL echoBigStruct(const BigStruct& rStruct) override
+ { return rStruct; }
+ virtual TwoFloats SAL_CALL echoTwoFloats(const TwoFloats& rStruct) override
+ { return rStruct; }
+ virtual FourFloats SAL_CALL echoFourFloats(const FourFloats& rStruct) override
+ { return rStruct; }
+ virtual MixedFloatAndInteger SAL_CALL echoMixedFloatAndInteger(const MixedFloatAndInteger& rStruct) override
+ { return rStruct; }
+ virtual DoubleHyper SAL_CALL echoDoubleHyper(DoubleHyper const & s) override { return s; }
+ virtual HyperDouble SAL_CALL echoHyperDouble(HyperDouble const & s) override { return s; }
+ virtual FloatFloatLongByte SAL_CALL echoFloatFloatLongByte(FloatFloatLongByte const & s)
+ override
+ { return s; }
+ virtual ThreeByteStruct SAL_CALL echoThreeByteStruct(const ThreeByteStruct& rStruct) override
+ { return rStruct; }
+ virtual sal_Int32 SAL_CALL testPPCAlignment( sal_Int64, sal_Int64, sal_Int32, sal_Int64, sal_Int32 i2 ) override
+ { return i2; }
+ virtual sal_Int32 SAL_CALL testPPC64Alignment( double , double , double , sal_Int32 i1 ) override
+ { return i1; }
+ virtual double SAL_CALL testTenDoubles( double d1, double d2, double d3, double d4, double d5, double d6, double d7, double d8, double d9, double d10 ) override
+ { return d1 + d2 + d3 + d4 + d5 + d6 + d7 + d8 + d9 + d10; }
+ virtual sal_Bool SAL_CALL getBool() override
+ { return _aData.Bool; }
+ virtual sal_Int8 SAL_CALL getByte() override
+ { return _aData.Byte; }
+ virtual sal_Unicode SAL_CALL getChar() override
+ { return _aData.Char; }
+ virtual sal_Int16 SAL_CALL getShort() override
+ { return _aData.Short; }
+ virtual sal_uInt16 SAL_CALL getUShort() override
+ { return _aData.UShort; }
+ virtual sal_Int32 SAL_CALL getLong() override
+ { return _aData.Long; }
+ virtual sal_uInt32 SAL_CALL getULong() override
+ { return _aData.ULong; }
+ virtual sal_Int64 SAL_CALL getHyper() override
+ { return _aData.Hyper; }
+ virtual sal_uInt64 SAL_CALL getUHyper() override
+ { return _aData.UHyper; }
+ virtual float SAL_CALL getFloat() override
+ { return _aData.Float; }
+ virtual double SAL_CALL getDouble() override
+ { return _aData.Double; }
+ virtual TestEnum SAL_CALL getEnum() override
+ { return _aData.Enum; }
+ virtual OUString SAL_CALL getString() override
+ { return _aData.String; }
+ virtual sal_Int8 SAL_CALL getByte2() override
+ { return _aData.Byte2; }
+ virtual sal_Int16 SAL_CALL getShort2() override
+ { return _aData.Short2; }
+ virtual css::uno::Reference< css::uno::XInterface > SAL_CALL getInterface( ) override
+ { return _aData.Interface; }
+ virtual css::uno::Any SAL_CALL getAny() override
+ { return _aData.Any; }
+ virtual css::uno::Sequence< TestElement > SAL_CALL getSequence() override
+ { return _aData.Sequence; }
+ virtual ::test::testtools::bridgetest::TestDataElements SAL_CALL getStruct() override
+ { return _aStructData; }
+
+ virtual void SAL_CALL setBool( sal_Bool _bool ) override
+ { _aData.Bool = _bool; }
+ virtual void SAL_CALL setByte( sal_Int8 _byte ) override
+ { _aData.Byte = _byte; }
+ virtual void SAL_CALL setChar( sal_Unicode _char ) override
+ { _aData.Char = _char; }
+ virtual void SAL_CALL setShort( sal_Int16 _short ) override
+ { _aData.Short = _short; }
+ virtual void SAL_CALL setUShort( sal_uInt16 _ushort ) override
+ { _aData.UShort = _ushort; }
+ virtual void SAL_CALL setLong( sal_Int32 _long ) override
+ { _aData.Long = _long; }
+ virtual void SAL_CALL setULong( sal_uInt32 _ulong ) override
+ { _aData.ULong = _ulong; }
+ virtual void SAL_CALL setHyper( sal_Int64 _hyper ) override
+ { _aData.Hyper = _hyper; }
+ virtual void SAL_CALL setUHyper( sal_uInt64 _uhyper ) override
+ { _aData.UHyper = _uhyper; }
+ virtual void SAL_CALL setFloat( float _float ) override
+ { _aData.Float = _float; }
+ virtual void SAL_CALL setDouble( double _double ) override
+ { _aData.Double = _double; }
+ virtual void SAL_CALL setEnum( TestEnum _enum ) override
+ { _aData.Enum = _enum; }
+ virtual void SAL_CALL setString( const OUString& _string ) override
+ { _aData.String = _string; }
+ virtual void SAL_CALL setByte2( sal_Int8 _byte ) override
+ { _aData.Byte2 = _byte; }
+ virtual void SAL_CALL setShort2( sal_Int16 _short ) override
+ { _aData.Short2 = _short; }
+ virtual void SAL_CALL setInterface( const css::uno::Reference< css::uno::XInterface >& _interface ) override
+ { _aData.Interface = _interface; }
+ virtual void SAL_CALL setAny( const css::uno::Any& _any ) override
+ { _aData.Any = _any; }
+ virtual void SAL_CALL setSequence( const css::uno::Sequence<TestElement >& _sequence ) override
+ { _aData.Sequence = _sequence; }
+ virtual void SAL_CALL setStruct( const ::test::testtools::bridgetest::TestDataElements& _struct ) override
+ { _aStructData = _struct; }
+
+ virtual sal_Int32 SAL_CALL getRaiseAttr1() override
+ { throw RuntimeException(); }
+
+ virtual void SAL_CALL setRaiseAttr1(sal_Int32) override
+ { throw IllegalArgumentException(); }
+
+ virtual sal_Int32 SAL_CALL getRaiseAttr2() override
+ { throw IllegalArgumentException(); }
+
+ virtual TestPolyStruct< sal_Bool > SAL_CALL transportPolyBoolean(
+ TestPolyStruct< sal_Bool > const & arg) override
+ { return arg; }
+
+ virtual void SAL_CALL transportPolyHyper(TestPolyStruct< sal_Int64 > &) override {}
+
+ virtual void SAL_CALL transportPolySequence(
+ TestPolyStruct< Sequence< Any > > const & arg1,
+ TestPolyStruct< Sequence< Any > > & arg2) override
+ { arg2 = arg1; }
+
+ virtual TestPolyStruct< sal_Int32 > SAL_CALL getNullPolyLong() override
+ { return TestPolyStruct< sal_Int32 >(0); /* work around MS compiler bug */ }
+
+ virtual TestPolyStruct< OUString > SAL_CALL getNullPolyString() override
+ { return TestPolyStruct< OUString >(); }
+
+ virtual TestPolyStruct< Type > SAL_CALL getNullPolyType() override
+ { return TestPolyStruct< Type >(); }
+
+ virtual TestPolyStruct< Any > SAL_CALL getNullPolyAny() override
+ { return TestPolyStruct< Any >(); }
+
+ virtual TestPolyStruct< Sequence< sal_Bool > > SAL_CALL
+ getNullPolySequence() override
+ { return TestPolyStruct< Sequence< sal_Bool > >(); }
+
+ virtual TestPolyStruct< TestEnum > SAL_CALL getNullPolyEnum() override
+ { return TestPolyStruct< TestEnum >(
+ test::testtools::bridgetest::TestEnum_TEST);
+ /* work around MS compiler bug */ }
+
+ virtual TestPolyStruct< TestBadEnum > SAL_CALL getNullPolyBadEnum() override
+ { return TestPolyStruct< TestBadEnum >(
+ test::testtools::bridgetest::TestBadEnum_M);
+ /* explicitly instantiate with default enumerator */ }
+
+ virtual TestPolyStruct< TestStruct > SAL_CALL getNullPolyStruct() override
+ { return TestPolyStruct< TestStruct >(); }
+
+ virtual TestPolyStruct< Reference< XBridgeTestBase > > SAL_CALL
+ getNullPolyInterface() override
+ { return TestPolyStruct< Reference< XBridgeTestBase > >(); }
+
+ virtual css::uno::Any SAL_CALL transportAny(
+ const css::uno::Any& value ) override;
+
+ virtual void SAL_CALL call( sal_Int32 nCallId, sal_Int32 nWaitMUSEC ) override;
+ virtual void SAL_CALL callOneway( sal_Int32 nCallId, sal_Int32 nWaitMUSEC ) override;
+ virtual sal_Bool SAL_CALL sequenceOfCallTestPassed( ) override;
+ virtual void SAL_CALL startRecursiveCall(
+ const css::uno::Reference< XRecursiveCall >& xCall, sal_Int32 nToCall ) override;
+
+ virtual Reference< XMulti > SAL_CALL getMulti() override;
+
+ virtual OUString SAL_CALL testMulti(Reference< XMulti > const & multi) override;
+
+public: // XBridgeTest
+ virtual ::test::testtools::bridgetest::TestDataElements SAL_CALL raiseException( sal_Int16 nArgumentPos, const OUString & rMsg, const Reference< XInterface > & xCOntext ) override;
+
+ virtual void SAL_CALL raiseRuntimeExceptionOneway(
+ const OUString& Message, const css::uno::Reference< css::uno::XInterface >& Context ) override;
+
+ virtual sal_Int32 SAL_CALL getRuntimeException() override;
+ virtual void SAL_CALL setRuntimeException( sal_Int32 _runtimeexception ) override;
+
+ // XBridgeTest2
+ virtual Sequence< sal_Bool > SAL_CALL setSequenceBool(
+ const Sequence< sal_Bool >& aSeq ) override;
+ virtual Sequence< sal_Unicode > SAL_CALL setSequenceChar(
+ const Sequence< sal_Unicode >& aSeq ) override;
+ virtual Sequence< sal_Int8 > SAL_CALL setSequenceByte(
+ const Sequence< sal_Int8 >& aSeq ) override;
+ virtual Sequence< sal_Int16 > SAL_CALL setSequenceShort(
+ const Sequence< sal_Int16 >& aSeq ) override;
+ virtual Sequence< sal_uInt16 > SAL_CALL setSequenceUShort(
+ const Sequence< sal_uInt16 >& aSeq ) override;
+ virtual Sequence< sal_Int32 > SAL_CALL setSequenceLong(
+ const Sequence< sal_Int32 >& aSeq ) override;
+ virtual Sequence< sal_uInt32 > SAL_CALL setSequenceULong(
+ const Sequence< sal_uInt32 >& aSeq ) override;
+ virtual Sequence< sal_Int64 > SAL_CALL setSequenceHyper(
+ const Sequence< sal_Int64 >& aSeq ) override;
+ virtual Sequence< sal_uInt64 > SAL_CALL setSequenceUHyper(
+ const Sequence< sal_uInt64 >& aSeq ) override;
+ virtual Sequence< float > SAL_CALL setSequenceFloat(
+ const Sequence< float >& aSeq ) override;
+ virtual Sequence< double > SAL_CALL setSequenceDouble(
+ const Sequence< double >& aSeq ) override;
+ virtual Sequence< TestEnum > SAL_CALL setSequenceEnum(
+ const Sequence< TestEnum >& aSeq ) override ;
+ virtual Sequence< OUString > SAL_CALL setSequenceString(
+ const Sequence< OUString >& aString ) override;
+ virtual Sequence< Reference< XInterface > > SAL_CALL setSequenceXInterface(
+ const Sequence< Reference< XInterface > >& aSeq ) override;
+ virtual Sequence<Any > SAL_CALL setSequenceAny(
+ const Sequence<Any >& aSeq ) override;
+ virtual Sequence<TestElement > SAL_CALL setSequenceStruct(
+ const Sequence< TestElement >& aSeq ) override;
+ virtual Sequence< Sequence< sal_Int32 > > SAL_CALL setDim2(
+ const Sequence<Sequence< sal_Int32 > >& aSeq ) override;
+ virtual Sequence< Sequence< Sequence< sal_Int32 > > > SAL_CALL setDim3(
+ const Sequence< Sequence< Sequence< sal_Int32 > > >& aSeq ) override;
+ virtual void SAL_CALL setSequencesInOut(Sequence< sal_Bool >& aSeqBoolean,
+ Sequence< sal_Unicode >& aSeqChar,
+ Sequence< sal_Int8 >& aSeqByte,
+ Sequence< sal_Int16 >& aSeqShort,
+ Sequence< sal_uInt16 >& aSeqUShort,
+ Sequence< sal_Int32 >& aSeqLong,
+ Sequence< sal_uInt32 >& aSeqULong,
+ Sequence< sal_Int64 >& aSeqHyper,
+ Sequence< sal_uInt64 >& aSeqUHyper,
+ Sequence< float >& aSeqFloat,
+ Sequence< double >& aSeqDouble,
+ Sequence< TestEnum >& aSeqTestEnum,
+ Sequence< OUString >& aSeqString,
+ Sequence<Reference<XInterface > >& aSeqXInterface,
+ Sequence< Any >& aSeqAny,
+ Sequence< Sequence< sal_Int32 > >& aSeqDim2,
+ Sequence< Sequence< Sequence< sal_Int32 > > >& aSeqDim3 ) override;
+ virtual void SAL_CALL setSequencesOut( Sequence< sal_Bool >& aSeqBoolean,
+ Sequence< sal_Unicode >& aSeqChar,
+ Sequence< sal_Int8 >& aSeqByte,
+ Sequence< sal_Int16 >& aSeqShort,
+ Sequence< sal_uInt16 >& aSeqUShort,
+ Sequence< sal_Int32 >& aSeqLong,
+ Sequence< sal_uInt32 >& aSeqULong,
+ Sequence< sal_Int64 >& aSeqHyper,
+ Sequence< sal_uInt64 >& aSeqUHyper,
+ Sequence< float >& aSeqFloat,
+ Sequence< double >& aSeqDouble,
+ Sequence< TestEnum >& aSeqEnum,
+ Sequence< OUString >& aSeqString,
+ Sequence< Reference< XInterface > >& aSeqXInterface,
+ Sequence< Any >& aSeqAny,
+ Sequence< Sequence< sal_Int32 > >& aSeqDim2,
+ Sequence< Sequence< Sequence< sal_Int32 > > >& aSeqDim3 ) override;
+ virtual void SAL_CALL testConstructorsService(
+ Reference< XComponentContext > const & context) override;
+ virtual Reference< XCurrentContextChecker > SAL_CALL
+ getCurrentContextChecker() override;
+
+public:
+ virtual void SAL_CALL callRecursivly( const css::uno::Reference< XRecursiveCall >& xCall, sal_Int32 nToCall ) override;
+};
+
+//Dummy class for XComponent implementation
+class Dummy : public osl::DebugBase<Dummy>,
+ public WeakComponentImplHelperBase
+{
+public:
+ Dummy(): WeakComponentImplHelperBase(*Mutex::getGlobalMutex()){}
+
+};
+
+}
+
+Any Test_Impl::transportAny( const Any & value )
+{
+ return value;
+}
+
+
+namespace {
+
+void wait(sal_Int32 microSeconds) {
+ OSL_ASSERT(microSeconds >= 0 && microSeconds <= SAL_MAX_INT32 / 1000);
+ osl::Thread::wait(std::chrono::microseconds(microSeconds));
+}
+
+}
+
+void Test_Impl::call( sal_Int32 nCallId , sal_Int32 nWaitMUSEC )
+{
+ wait(nWaitMUSEC);
+ if( m_bFirstCall )
+ {
+ m_bFirstCall = false;
+ }
+ else
+ {
+ m_bSequenceOfCallTestPassed = m_bSequenceOfCallTestPassed && (nCallId > m_nLastCallId);
+ }
+ m_nLastCallId = nCallId;
+}
+
+
+void Test_Impl::callOneway( sal_Int32 nCallId , sal_Int32 nWaitMUSEC )
+{
+ wait(nWaitMUSEC);
+ m_bSequenceOfCallTestPassed = m_bSequenceOfCallTestPassed && (nCallId > m_nLastCallId);
+ m_nLastCallId = nCallId;
+}
+
+
+sal_Bool Test_Impl::sequenceOfCallTestPassed()
+{
+ return m_bSequenceOfCallTestPassed;
+}
+
+
+void SAL_CALL Test_Impl::startRecursiveCall(
+ const css::uno::Reference< XRecursiveCall >& xCall, sal_Int32 nToCall )
+{
+ MutexGuard guard( m_mutex );
+ if( nToCall )
+ {
+ nToCall --;
+ xCall->callRecursivly( this , nToCall );
+ }
+}
+
+
+void SAL_CALL Test_Impl::callRecursivly(
+ const css::uno::Reference< XRecursiveCall >& xCall,
+ sal_Int32 nToCall )
+{
+ MutexGuard guard( m_mutex );
+ if( nToCall )
+ {
+ nToCall --;
+ xCall->callRecursivly( this , nToCall );
+ }
+}
+
+Reference< XMulti > Test_Impl::getMulti() {
+ return new testtools::bridgetest::Multi;
+}
+
+OUString Test_Impl::testMulti(Reference< XMulti > const & multi)
+{
+ return testtools::bridgetest::testMulti(multi);
+}
+
+
+void Test_Impl::setValues( sal_Bool bBool,
+ sal_Unicode cChar,
+ sal_Int8 nByte,
+ sal_Int16 nShort,
+ sal_uInt16 nUShort,
+ sal_Int32 nLong,
+ sal_uInt32 nULong,
+ sal_Int64 nHyper,
+ sal_uInt64 nUHyper,
+ float fFloat,
+ double fDouble,
+ TestEnum eEnum,
+ const OUString& rStr,
+ sal_Int8 nByte2,
+ sal_Int16 nShort2,
+ const css::uno::Reference< css::uno::XInterface >& xTest,
+ const css::uno::Any& rAny,
+ const css::uno::Sequence<TestElement >& rSequence,
+ const ::test::testtools::bridgetest::TestDataElements& rStruct )
+{
+ assign( _aData,
+ bBool, cChar, nByte, nShort, nUShort, nLong, nULong, nHyper, nUHyper, fFloat, fDouble,
+ eEnum, rStr, nByte2, nShort2, xTest, rAny, rSequence );
+ _aStructData = rStruct;
+}
+
+::test::testtools::bridgetest::TestDataElements Test_Impl::setValues2( sal_Bool& bBool,
+ sal_Unicode& cChar,
+ sal_Int8& nByte,
+ sal_Int16& nShort,
+ sal_uInt16& nUShort,
+ sal_Int32& nLong,
+ sal_uInt32& nULong,
+ sal_Int64& nHyper,
+ sal_uInt64& nUHyper,
+ float& fFloat,
+ double& fDouble,
+ TestEnum& eEnum,
+ OUString& rStr,
+ sal_Int8& nByte2,
+ sal_Int16& nShort2,
+ css::uno::Reference< css::uno::XInterface >& xTest,
+ css::uno::Any& rAny,
+ css::uno::Sequence<TestElement >& rSequence,
+ ::test::testtools::bridgetest::TestDataElements& rStruct )
+{
+ assign( _aData,
+ bBool, cChar, nByte, nShort, nUShort, nLong, nULong, nHyper, nUHyper, fFloat, fDouble,
+ eEnum, rStr, nByte2, nShort2, xTest, rAny, rSequence );
+ _aStructData = rStruct;
+
+ auto pSequence = rSequence.getArray();
+ std::swap(pSequence[ 0 ], pSequence[ 1 ]);
+
+ return _aStructData;
+}
+
+::test::testtools::bridgetest::TestDataElements Test_Impl::getValues( sal_Bool& bBool,
+ sal_Unicode& cChar,
+ sal_Int8& nByte,
+ sal_Int16& nShort,
+ sal_uInt16& nUShort,
+ sal_Int32& nLong,
+ sal_uInt32& nULong,
+ sal_Int64& nHyper,
+ sal_uInt64& nUHyper,
+ float& fFloat,
+ double& fDouble,
+ TestEnum& eEnum,
+ OUString& rStr,
+ sal_Int8& nByte2,
+ sal_Int16& nShort2,
+ css::uno::Reference< css::uno::XInterface >& xTest,
+ css::uno::Any& rAny,
+ css::uno::Sequence<TestElement >& rSequence,
+ ::test::testtools::bridgetest::TestDataElements& rStruct )
+{
+ bBool = _aData.Bool;
+ cChar = _aData.Char;
+ nByte = _aData.Byte;
+ nShort = _aData.Short;
+ nUShort = _aData.UShort;
+ nLong = _aData.Long;
+ nULong = _aData.ULong;
+ nHyper = _aData.Hyper;
+ nUHyper = _aData.UHyper;
+ fFloat = _aData.Float;
+ fDouble = _aData.Double;
+ eEnum = _aData.Enum;
+ rStr = _aData.String;
+ nByte2 = _aData.Byte2;
+ nShort2 = _aData.Short2;
+ xTest = _aData.Interface;
+ rAny = _aData.Any;
+ rSequence = _aData.Sequence;
+ rStruct = _aStructData;
+ return _aStructData;
+}
+
+::test::testtools::bridgetest::TestDataElements Test_Impl::raiseException( sal_Int16 nArgumentPos, const OUString & rMsg, const Reference< XInterface > & xContext )
+{
+ IllegalArgumentException aExc;
+ aExc.ArgumentPosition = nArgumentPos;
+ aExc.Message = _aData.String = rMsg;
+ aExc.Context = _aData.Interface = xContext;
+ throw aExc;
+}
+
+void Test_Impl::raiseRuntimeExceptionOneway( const OUString & rMsg, const Reference< XInterface > & xContext )
+{
+ RuntimeException aExc;
+ aExc.Message = _aData.String = rMsg;
+ aExc.Context = _aData.Interface = xContext;
+ throw aExc;
+}
+
+static void dothrow2(const RuntimeException& e)
+{
+ throw e;
+}
+static void dothrow(const RuntimeException& e)
+{
+#if defined _MSC_VER
+ // currently only for MSVC:
+ // just to test whether all bridges fall back to a RuntimeException
+ // in case of a thrown non-UNO exception:
+ try
+ {
+ throw ::std::bad_alloc();
+ }
+ catch (...)
+ {
+ try
+ {
+ Any a( getCaughtException() );
+ RuntimeException exc;
+ OSL_VERIFY( a >>= exc );
+ }
+ catch (...) // never throws anything
+ {
+ fprintf( stderr, "\ngetCaughtException() failed!\n" );
+ exit( 1 );
+ }
+ }
+#endif
+ dothrow2( e );
+}
+
+sal_Int32 Test_Impl::getRuntimeException()
+{
+ try
+ {
+ dothrow( RuntimeException( _aData.String, _aData.Interface ) );
+ }
+ catch (Exception &)
+ {
+ Any a( getCaughtException() );
+ throwException( a );
+ }
+ return 0; // for dummy
+}
+
+void Test_Impl::setRuntimeException( sal_Int32 )
+{
+ RuntimeException aExc;
+ aExc.Message = _aData.String;
+ aExc.Context = _aData.Interface;
+ throwException( Any( aExc ) );
+}
+
+// XBridgeTest2 -------------------------------------------------------------
+Sequence< sal_Bool > SAL_CALL Test_Impl::setSequenceBool(
+ const Sequence< sal_Bool >& aSeq )
+{
+ _arBool = aSeq;
+ return aSeq;
+}
+
+Sequence< sal_Unicode > SAL_CALL Test_Impl::setSequenceChar(
+ const Sequence< sal_Unicode >& aSeq )
+{
+ _arChar = aSeq;
+ return aSeq;
+}
+
+Sequence< sal_Int8 > SAL_CALL Test_Impl::setSequenceByte(
+ const Sequence< sal_Int8 >& aSeq )
+{
+ _arByte = aSeq;
+ return aSeq;
+}
+
+Sequence< sal_Int16 > SAL_CALL Test_Impl::setSequenceShort(
+ const Sequence< sal_Int16 >& aSeq )
+{
+ _arShort = aSeq;
+ return aSeq;
+}
+
+Sequence< sal_uInt16 > SAL_CALL Test_Impl::setSequenceUShort(
+ const Sequence< sal_uInt16 >& aSeq )
+{
+ _arUShort = aSeq;
+ return aSeq;
+}
+
+Sequence< sal_Int32 > SAL_CALL Test_Impl::setSequenceLong(
+ const Sequence< sal_Int32 >& aSeq )
+{
+ _arLong = aSeq;
+ return aSeq;
+}
+
+Sequence< sal_uInt32 > SAL_CALL Test_Impl::setSequenceULong(
+ const Sequence< sal_uInt32 >& aSeq )
+{
+ _arULong = aSeq;
+ return aSeq;
+}
+
+Sequence< sal_Int64 > SAL_CALL Test_Impl::setSequenceHyper(
+ const Sequence< sal_Int64 >& aSeq )
+{
+ _arHyper = aSeq;
+ return aSeq;
+}
+
+Sequence< sal_uInt64 > SAL_CALL Test_Impl::setSequenceUHyper(
+ const Sequence< sal_uInt64 >& aSeq )
+{
+ _arUHyper = aSeq;
+ return aSeq;
+}
+
+Sequence< float > SAL_CALL Test_Impl::setSequenceFloat(
+ const Sequence< float >& aSeq )
+{
+ _arFloat = aSeq;
+ return aSeq;
+}
+
+Sequence< double > SAL_CALL Test_Impl::setSequenceDouble(
+ const Sequence< double >& aSeq )
+{
+ _arDouble = aSeq;
+ return aSeq;
+}
+
+Sequence< TestEnum > SAL_CALL Test_Impl::setSequenceEnum(
+ const Sequence< TestEnum >& aSeq )
+{
+ _arEnum = aSeq;
+ return aSeq;
+}
+
+Sequence< OUString > SAL_CALL Test_Impl::setSequenceString(
+ const Sequence< OUString >& aSeq )
+{
+ _arString = aSeq;
+ return aSeq;
+}
+
+Sequence< Reference< XInterface > > SAL_CALL Test_Impl::setSequenceXInterface(
+ const Sequence< Reference< XInterface > >& aSeq )
+{
+ _arObject = aSeq;
+ return aSeq;
+}
+
+Sequence<Any > SAL_CALL Test_Impl::setSequenceAny(
+ const Sequence<Any >& aSeq )
+{
+ _arAny = aSeq;
+ return aSeq;
+}
+
+Sequence<TestElement > SAL_CALL Test_Impl::setSequenceStruct(
+ const Sequence< TestElement >& aSeq )
+{
+ _arStruct = aSeq;
+ return aSeq;
+}
+
+Sequence< Sequence< sal_Int32 > > SAL_CALL Test_Impl::setDim2(
+ const Sequence<Sequence< sal_Int32 > >& aSeq )
+{
+ _arLong2 = aSeq;
+ return aSeq;
+}
+
+Sequence< Sequence< Sequence< sal_Int32 > > > SAL_CALL Test_Impl::setDim3(
+ const Sequence< Sequence< Sequence< sal_Int32 > > >& aSeq )
+{
+ _arLong3 = aSeq;
+ return aSeq;
+}
+
+void SAL_CALL Test_Impl::setSequencesInOut(Sequence< sal_Bool >& aSeqBoolean,
+ Sequence< sal_Unicode >& aSeqChar,
+ Sequence< sal_Int8 >& aSeqByte,
+ Sequence< sal_Int16 >& aSeqShort,
+ Sequence< sal_uInt16 >& aSeqUShort,
+ Sequence< sal_Int32 >& aSeqLong,
+ Sequence< sal_uInt32 >& aSeqULong,
+ Sequence< sal_Int64 >& aSeqHyper,
+ Sequence< sal_uInt64 >& aSeqUHyper,
+ Sequence< float >& aSeqFloat,
+ Sequence< double >& aSeqDouble,
+ Sequence< TestEnum >& aSeqTestEnum,
+ Sequence< OUString >& aSeqString,
+ Sequence<Reference<XInterface > >& aSeqXInterface,
+ Sequence< Any >& aSeqAny,
+ Sequence< Sequence< sal_Int32 > >& aSeqDim2,
+ Sequence< Sequence< Sequence< sal_Int32 > > >& aSeqDim3 )
+{
+ _arBool = aSeqBoolean;
+ _arChar = aSeqChar;
+ _arByte = aSeqByte;
+ _arShort = aSeqShort;
+ _arUShort = aSeqUShort;
+ _arLong = aSeqLong;
+ _arULong = aSeqULong;
+ _arHyper = aSeqHyper;
+ _arUHyper = aSeqUHyper;
+ _arFloat = aSeqFloat;
+ _arDouble = aSeqDouble;
+ _arEnum = aSeqTestEnum;
+ _arString = aSeqString;
+ _arObject = aSeqXInterface;
+ _arAny = aSeqAny;
+ _arLong2 = aSeqDim2;
+ _arLong3 = aSeqDim3;
+}
+
+void SAL_CALL Test_Impl::setSequencesOut( Sequence< sal_Bool >& aSeqBoolean,
+ Sequence< sal_Unicode >& aSeqChar,
+ Sequence< sal_Int8 >& aSeqByte,
+ Sequence< sal_Int16 >& aSeqShort,
+ Sequence< sal_uInt16 >& aSeqUShort,
+ Sequence< sal_Int32 >& aSeqLong,
+ Sequence< sal_uInt32 >& aSeqULong,
+ Sequence< sal_Int64 >& aSeqHyper,
+ Sequence< sal_uInt64 >& aSeqUHyper,
+ Sequence< float >& aSeqFloat,
+ Sequence< double >& aSeqDouble,
+ Sequence< TestEnum >& aSeqEnum,
+ Sequence< OUString >& aSeqString,
+ Sequence< Reference< XInterface > >& aSeqXInterface,
+ Sequence< Any >& aSeqAny,
+ Sequence< Sequence< sal_Int32 > >& aSeqDim2,
+ Sequence< Sequence< Sequence< sal_Int32 > > >& aSeqDim3 )
+{
+ aSeqBoolean = _arBool;
+ aSeqChar = _arChar;
+ aSeqByte = _arByte;
+ aSeqShort = _arShort;
+ aSeqUShort = _arUShort;
+ aSeqLong = _arLong;
+ aSeqULong = _arULong;
+ aSeqHyper = _arHyper;
+ aSeqUHyper = _arUHyper;
+ aSeqFloat = _arFloat;
+ aSeqDouble = _arDouble;
+ aSeqEnum = _arEnum;
+ aSeqString = _arString;
+ aSeqXInterface = _arObject;
+ aSeqAny = _arAny;
+ aSeqDim2 = _arLong2;
+ aSeqDim3 = _arLong3;
+}
+
+void Test_Impl::testConstructorsService(
+ Reference< XComponentContext > const & context)
+{
+ Sequence< sal_Bool > arg14{ true };
+ Sequence< sal_Int8 > arg15{ SAL_MIN_INT8 };
+ Sequence< sal_Int16 > arg16{ SAL_MIN_INT16 };
+ Sequence< sal_uInt16 > arg17{ SAL_MAX_UINT16 };
+ Sequence< sal_Int32 > arg18{ SAL_MIN_INT32 };
+ Sequence< sal_uInt32 > arg19{ SAL_MAX_UINT32 };
+ Sequence< sal_Int64 > arg20{ SAL_MIN_INT64 };
+ Sequence< sal_uInt64 > arg21{ SAL_MAX_UINT64 };
+ Sequence< float > arg22{ 0.123f };
+ Sequence< double > arg23{ 0.456 };
+ Sequence< sal_Unicode > arg24{ 'X' };
+ Sequence< OUString > arg25 { "test" };
+ Sequence< Type > arg26{ UnoType< Any >::get() };
+ Sequence< Any > arg27{ Any(true) };
+ Sequence< Sequence< sal_Bool > > arg28{ { true } };
+ Sequence< Sequence< Any > > arg29{ { Any(true) } };
+ Sequence< TestEnum > arg30{ TestEnum_TWO };
+ Sequence< TestStruct > arg31(1); arg31.getArray()[0].member = 10;
+ Sequence< TestPolyStruct< sal_Bool > > arg32{ { true } };
+ Sequence< TestPolyStruct< Any > > arg33(1); arg33.getArray()[0].member <<= true;
+ Sequence< Reference< XInterface > > arg34(1);
+ Constructors::create1(context,
+ true,
+ SAL_MIN_INT8,
+ SAL_MIN_INT16,
+ SAL_MAX_UINT16,
+ SAL_MIN_INT32,
+ SAL_MAX_UINT32,
+ SAL_MIN_INT64,
+ SAL_MAX_UINT64,
+ 0.123f,
+ 0.456,
+ 'X',
+ "test",
+ UnoType< Any >::get(),
+ Any(true),
+ arg14,
+ arg15,
+ arg16,
+ arg17,
+ arg18,
+ arg19,
+ arg20,
+ arg21,
+ arg22,
+ arg23,
+ arg24,
+ arg25,
+ arg26,
+ arg27,
+ arg28,
+ arg29,
+ arg30,
+ arg31,
+ arg32,
+ arg33,
+ arg34,
+ TestEnum_TWO,
+ TestStruct(10),
+ TestPolyStruct< sal_Bool >(true),
+ TestPolyStruct< Any >(Any(true)),
+ Reference< XInterface >(nullptr));
+ Sequence< Any > args{
+ Any(true),
+ Any(SAL_MIN_INT8),
+ Any(SAL_MIN_INT16),
+ Any(SAL_MAX_UINT16),
+ Any(SAL_MIN_INT32),
+ Any(SAL_MAX_UINT32),
+ Any(SAL_MIN_INT64),
+ Any(SAL_MAX_UINT64),
+ Any(0.123f),
+ Any(0.456),
+ Any(u'X'),
+ Any(OUString("test")),
+ Any(UnoType< Any >::get()),
+ Any(true),
+ Any(arg14),
+ Any(arg15),
+ Any(arg16),
+ Any(arg17),
+ Any(arg18),
+ Any(arg19),
+ Any(arg20),
+ Any(arg21),
+ Any(arg22),
+ Any(arg23),
+ Any(arg24),
+ Any(arg25),
+ Any(arg26),
+ Any(arg27),
+ Any(arg28),
+ Any(arg29),
+ Any(arg30),
+ Any(arg31),
+ Any(arg32),
+ Any(arg33),
+ Any(arg34),
+ Any(TestEnum_TWO),
+ Any(TestStruct(10)),
+ Any(TestPolyStruct< sal_Bool >(true)),
+ Any(TestPolyStruct< Any >(Any(true))),
+ Any(Reference< XInterface >(nullptr))
+ };
+ assert(args.getLength() == 40);
+ Constructors::create2(context, args);
+
+ Sequence<Type> argSeq1{ cppu::UnoType<sal_Int32>::get() };
+ Sequence<Reference<XInterface> > argSeq2 { static_cast<XComponent*>(new Dummy()) };
+ Sequence<Reference<XComponent> > argSeq2a { static_cast<XComponent*>(new Dummy()) };
+
+ Sequence<TestPolyStruct2<sal_Unicode, Sequence<Any> > > argSeq3
+ { TestPolyStruct2<sal_Unicode, Sequence<Any> >('X', arg27) };
+ Sequence<TestPolyStruct2<TestPolyStruct<sal_Unicode>, Sequence<Any> > > argSeq4
+ { TestPolyStruct2<TestPolyStruct<sal_Unicode>, Sequence<Any> >(
+ TestPolyStruct<sal_Unicode>('X'), arg27) };
+ Sequence<Sequence<sal_Int32> > argSeq5{ { SAL_MIN_INT32 } };
+ Sequence<TestPolyStruct<sal_Int32> > argSeq6{ TestPolyStruct<sal_Int32>(SAL_MIN_INT32) };
+ Sequence<TestPolyStruct<TestPolyStruct2<sal_Unicode, Any> > > argSeq7
+ { TestPolyStruct<TestPolyStruct2<sal_Unicode, Any> >(
+ TestPolyStruct2<sal_Unicode, Any>('X', Any(true))) };
+ Sequence<TestPolyStruct<TestPolyStruct2<TestPolyStruct2<sal_Unicode, Any>,OUString> > > argSeq8
+ { TestPolyStruct<TestPolyStruct2<TestPolyStruct2<sal_Unicode, Any>,OUString> > (
+ TestPolyStruct2<TestPolyStruct2<sal_Unicode, Any>,OUString>(
+ TestPolyStruct2<sal_Unicode, Any>('X', Any(true)), OUString("test"))) };
+ Sequence<TestPolyStruct2<OUString, TestPolyStruct2<sal_Unicode, TestPolyStruct<Any> > > > argSeq9
+ { TestPolyStruct2<OUString, TestPolyStruct2<sal_Unicode, TestPolyStruct<Any> > >(
+ OUString("test"), TestPolyStruct2<sal_Unicode, TestPolyStruct<Any> >(
+ 'X', TestPolyStruct<Any>(Any(true)))) };
+ Sequence<TestPolyStruct2<TestPolyStruct2<sal_Unicode, Any>, TestPolyStruct<sal_Unicode> > > argSeq10
+ { TestPolyStruct2<TestPolyStruct2<sal_Unicode, Any>, TestPolyStruct<sal_Unicode> >(
+ TestPolyStruct2<sal_Unicode, Any>('X', Any(true)), TestPolyStruct<sal_Unicode>('X')) };
+ Sequence<Sequence<TestPolyStruct<sal_Unicode > > > argSeq11
+ { { TestPolyStruct<sal_Unicode>('X') } };
+ Sequence<Sequence<TestPolyStruct<TestPolyStruct2<sal_Unicode,Any> > > > argSeq12
+ { { TestPolyStruct<TestPolyStruct2<sal_Unicode,Any> >(
+ TestPolyStruct2<sal_Unicode,Any>('X', Any(true))) } };
+ Sequence<Sequence<TestPolyStruct<TestPolyStruct2<TestPolyStruct2<sal_Unicode,Any>,OUString> > > > argSeq13
+ { {TestPolyStruct<TestPolyStruct2<TestPolyStruct2<sal_Unicode,Any>,OUString> >(
+ TestPolyStruct2<TestPolyStruct2<sal_Unicode,Any>,OUString>(
+ TestPolyStruct2<sal_Unicode,Any>('X', Any(true)), OUString("test")))} };
+ Sequence<Sequence<TestPolyStruct2<OUString, TestPolyStruct2<sal_Unicode, TestPolyStruct<Any> > > > > argSeq14
+ { { TestPolyStruct2<OUString, TestPolyStruct2<sal_Unicode, TestPolyStruct<Any> > >(
+ OUString("test"), TestPolyStruct2<sal_Unicode, TestPolyStruct<Any> >(
+ 'X', TestPolyStruct<Any>(Any(true)))) } };
+ Sequence<Sequence<TestPolyStruct2<TestPolyStruct2<sal_Unicode,Any>, TestPolyStruct<sal_Unicode> > > > argSeq15
+ { { TestPolyStruct2<TestPolyStruct2<sal_Unicode,Any>, TestPolyStruct<sal_Unicode> >(
+ TestPolyStruct2<sal_Unicode,Any>('X',Any(true)), TestPolyStruct<sal_Unicode>('X')) } };
+
+ Constructors2::create1(
+ context,
+ TestPolyStruct<Type>(cppu::UnoType<sal_Int32>::get()),
+ TestPolyStruct<Any>(Any(true)),
+ TestPolyStruct<sal_Bool>(true),
+ TestPolyStruct<sal_Int8>(SAL_MIN_INT8),
+ TestPolyStruct<sal_Int16>(SAL_MIN_INT16),
+ TestPolyStruct<sal_Int32>(SAL_MIN_INT32),
+ TestPolyStruct<sal_Int64>(SAL_MIN_INT64),
+ TestPolyStruct<sal_Unicode>('X'),
+ TestPolyStruct<OUString>(OUString("test")),
+ TestPolyStruct<float>(0.123f),
+ TestPolyStruct<double>(0.456),
+ TestPolyStruct<Reference<XInterface> >(static_cast<XBridgeTest2*>(this)),
+ TestPolyStruct<Reference<XComponent> >(static_cast<XComponent*>(new Dummy())),
+ TestPolyStruct<TestEnum>(TestEnum_TWO),
+ TestPolyStruct<TestPolyStruct2<sal_Unicode, Any> >(
+ TestPolyStruct2<sal_Unicode, Any>('X', Any(true))),
+ TestPolyStruct<TestPolyStruct2<TestPolyStruct2<sal_Unicode, Any>,OUString> > (
+ TestPolyStruct2<TestPolyStruct2<sal_Unicode, Any>,OUString>(
+ TestPolyStruct2<sal_Unicode, Any>('X', Any(true)), OUString("test"))),
+ TestPolyStruct2<OUString, TestPolyStruct2<sal_Unicode,TestPolyStruct<Any> > >(
+ OUString("test"),
+ TestPolyStruct2<sal_Unicode, TestPolyStruct<Any> >('X', TestPolyStruct<Any>(Any(true)))),
+ TestPolyStruct2<TestPolyStruct2<sal_Unicode, Any>, TestPolyStruct<sal_Unicode> >(
+ TestPolyStruct2<sal_Unicode, Any>('X', Any(true)),
+ TestPolyStruct<sal_Unicode>('X')),
+ TestPolyStruct<Sequence<Type> >(argSeq1),
+ TestPolyStruct<Sequence<Any> >(arg27),
+ TestPolyStruct<Sequence<sal_Bool> >(arg14),
+ TestPolyStruct<Sequence<sal_Int8> >(arg15),
+ TestPolyStruct<Sequence<sal_Int16> >(arg16),
+ TestPolyStruct<Sequence<sal_Int32> >(arg18),
+ TestPolyStruct<Sequence<sal_Int64> >(arg20),
+ TestPolyStruct<Sequence<sal_Unicode> >(arg24),
+ TestPolyStruct<Sequence<OUString> >(arg25),
+ TestPolyStruct<Sequence<float> >(arg22),
+ TestPolyStruct<Sequence<double> >(arg23),
+ TestPolyStruct<Sequence<Reference<XInterface> > >(argSeq2),
+ TestPolyStruct<Sequence<Reference<XComponent> > >(argSeq2a),
+ TestPolyStruct<Sequence<TestEnum> >(arg30),
+ TestPolyStruct<Sequence<TestPolyStruct2<sal_Unicode, Sequence<Any> > > >(argSeq3),
+ TestPolyStruct<Sequence<TestPolyStruct2<TestPolyStruct<sal_Unicode>, Sequence<Any> > > > (argSeq4),
+ TestPolyStruct<Sequence<Sequence<sal_Int32> > >(argSeq5),
+ argSeq6,
+ argSeq7,
+ argSeq8,
+ argSeq9,
+ argSeq10,
+ argSeq11,
+ argSeq12,
+ argSeq13,
+ argSeq14,
+ argSeq15);
+}
+
+Reference< XCurrentContextChecker > Test_Impl::getCurrentContextChecker()
+{
+ return new testtools::bridgetest::CurrentContextChecker;
+}
+
+// XServiceInfo
+
+OUString Test_Impl::getImplementationName()
+{
+ return IMPLNAME;
+}
+
+sal_Bool Test_Impl::supportsService( const OUString & rServiceName )
+{
+ return cppu::supportsService(this, rServiceName);
+}
+
+Sequence< OUString > Test_Impl::getSupportedServiceNames()
+{
+ return bridge_object::getSupportedServiceNames();
+}
+
+
+static Reference< XInterface > Test_Impl_create(
+ SAL_UNUSED_PARAMETER const Reference< XMultiServiceFactory > & )
+{
+ return Reference< XInterface >( static_cast<XBridgeTest *>(new Test_Impl()) );
+}
+
+}
+
+extern "C"
+{
+SAL_DLLPUBLIC_EXPORT void * component_getFactory(
+ const char * pImplName, SAL_UNUSED_PARAMETER void * pServiceManager,
+ SAL_UNUSED_PARAMETER void * )
+{
+ void * pRet = nullptr;
+
+ if (pServiceManager && o3tl::equalsAscii(IMPLNAME, pImplName))
+ {
+ Reference< XSingleServiceFactory > xFactory( createSingleFactory(
+ static_cast< XMultiServiceFactory * >( pServiceManager ),
+ IMPLNAME,
+ bridge_object::Test_Impl_create,
+ bridge_object::getSupportedServiceNames() ) );
+
+ if (xFactory.is())
+ {
+ xFactory->acquire();
+ pRet = xFactory.get();
+ }
+ }
+
+ return pRet;
+}
+}
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/testtools/source/bridgetest/currentcontextchecker.cxx b/testtools/source/bridgetest/currentcontextchecker.cxx
new file mode 100644
index 000000000..5852f85b9
--- /dev/null
+++ b/testtools/source/bridgetest/currentcontextchecker.cxx
@@ -0,0 +1,106 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*
+ * This file is part of the LibreOffice project.
+ *
+ * This Source Code Form is subject to the terms of the Mozilla Public
+ * License, v. 2.0. If a copy of the MPL was not distributed with this
+ * file, You can obtain one at http://mozilla.org/MPL/2.0/.
+ *
+ * This file incorporates work covered by the following license notice:
+ *
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed
+ * with this work for additional information regarding copyright
+ * ownership. The ASF licenses this file to you under the Apache
+ * License, Version 2.0 (the "License"); you may not use this file
+ * except in compliance with the License. You may obtain a copy of
+ * the License at http://www.apache.org/licenses/LICENSE-2.0 .
+ */
+
+
+#include <sal/config.h>
+
+#include "currentcontextchecker.hxx"
+
+#include <com/sun/star/uno/Any.hxx>
+#include <com/sun/star/uno/Reference.hxx>
+#include <com/sun/star/uno/XCurrentContext.hpp>
+#include <cppu/unotype.hxx>
+#include <cppuhelper/implbase.hxx>
+#include <osl/diagnose.h>
+#include <osl/diagnose.hxx>
+#include <rtl/ustring.hxx>
+#include <sal/types.h>
+#include <test/testtools/bridgetest/XCurrentContextChecker.hpp>
+#include <uno/current_context.hxx>
+
+namespace {
+
+constexpr OUStringLiteral KEY = u"testtools.bridgetest.Key";
+constexpr OUStringLiteral VALUE = u"good";
+
+class CurrentContext:
+ public ::osl::DebugBase< CurrentContext >,
+ public ::cppu::WeakImplHelper< css::uno::XCurrentContext >
+{
+public:
+ CurrentContext();
+
+ CurrentContext(const CurrentContext&) = delete;
+ CurrentContext& operator=(const CurrentContext&) = delete;
+
+ virtual css::uno::Any SAL_CALL getValueByName(OUString const & Name) override;
+};
+
+CurrentContext::CurrentContext() {}
+
+css::uno::Any CurrentContext::getValueByName(OUString const & Name)
+{
+ return Name == KEY ? css::uno::Any(OUString(VALUE)) : css::uno::Any();
+}
+
+}
+
+testtools::bridgetest::CurrentContextChecker::CurrentContextChecker() {}
+
+testtools::bridgetest::CurrentContextChecker::~CurrentContextChecker() {}
+
+sal_Bool testtools::bridgetest::CurrentContextChecker::perform(
+ css::uno::Reference<
+ ::test::testtools::bridgetest::XCurrentContextChecker > const & other,
+ ::sal_Int32 setSteps, ::sal_Int32 checkSteps)
+{
+ if (setSteps == 0) {
+ css::uno::ContextLayer layer(new CurrentContext);
+ return performCheck(other, setSteps, checkSteps);
+ } else {
+ return performCheck(other, setSteps, checkSteps);
+ }
+}
+
+bool testtools::bridgetest::CurrentContextChecker::performCheck(
+ css::uno::Reference<
+ ::test::testtools::bridgetest::XCurrentContextChecker > const & other,
+ ::sal_Int32 setSteps, ::sal_Int32 checkSteps)
+{
+ OSL_ASSERT(other.is() && checkSteps >= 0);
+ if (checkSteps == 0) {
+ css::uno::Reference< css::uno::XCurrentContext > context(
+ css::uno::getCurrentContext());
+ if (!context.is()) {
+ return false;
+ }
+ css::uno::Any a(context->getValueByName(KEY));
+ if (a.getValueType() != ::cppu::UnoType< OUString >::get()) {
+ return false;
+ }
+ OUString s;
+ OSL_VERIFY(a >>= s);
+ return s == VALUE;
+ } else {
+ return other->perform(
+ this, setSteps >= 0 ? setSteps - 1 : -1, checkSteps - 1);
+ }
+}
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/testtools/source/bridgetest/currentcontextchecker.hxx b/testtools/source/bridgetest/currentcontextchecker.hxx
new file mode 100644
index 000000000..df4bea64e
--- /dev/null
+++ b/testtools/source/bridgetest/currentcontextchecker.hxx
@@ -0,0 +1,61 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*
+ * This file is part of the LibreOffice project.
+ *
+ * This Source Code Form is subject to the terms of the Mozilla Public
+ * License, v. 2.0. If a copy of the MPL was not distributed with this
+ * file, You can obtain one at http://mozilla.org/MPL/2.0/.
+ *
+ * This file incorporates work covered by the following license notice:
+ *
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed
+ * with this work for additional information regarding copyright
+ * ownership. The ASF licenses this file to you under the Apache
+ * License, Version 2.0 (the "License"); you may not use this file
+ * except in compliance with the License. You may obtain a copy of
+ * the License at http://www.apache.org/licenses/LICENSE-2.0 .
+ */
+
+#ifndef INCLUDED_TESTTOOLS_SOURCE_BRIDGETEST_CURRENTCONTEXTCHECKER_HXX
+#define INCLUDED_TESTTOOLS_SOURCE_BRIDGETEST_CURRENTCONTEXTCHECKER_HXX
+
+#include <sal/config.h>
+#include <com/sun/star/uno/Reference.hxx>
+#include <cppuhelper/implbase.hxx>
+#include <osl/diagnose.hxx>
+#include <sal/types.h>
+#include <test/testtools/bridgetest/XCurrentContextChecker.hpp>
+
+#include "dllapi.hxx"
+
+namespace testtools::bridgetest {
+
+class LO_DLLPUBLIC_TESTTOOLS CurrentContextChecker :
+ public ::osl::DebugBase< CurrentContextChecker >,
+ public ::cppu::WeakImplHelper<
+ ::test::testtools::bridgetest::XCurrentContextChecker >
+{
+public:
+ CurrentContextChecker();
+
+ virtual ~CurrentContextChecker() override;
+
+ virtual sal_Bool SAL_CALL perform(
+ css::uno::Reference< ::test::testtools::bridgetest::XCurrentContextChecker > const & other,
+ ::sal_Int32 setSteps, ::sal_Int32 checkSteps) override;
+
+private:
+ CurrentContextChecker(CurrentContextChecker const &) = delete;
+ void operator =(CurrentContextChecker const &) = delete;
+
+ SAL_DLLPRIVATE bool performCheck(
+ css::uno::Reference< ::test::testtools::bridgetest::XCurrentContextChecker > const & other,
+ ::sal_Int32 setSteps, ::sal_Int32 checkSteps);
+};
+
+}
+
+#endif
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/testtools/source/bridgetest/dllapi.hxx b/testtools/source/bridgetest/dllapi.hxx
new file mode 100644
index 000000000..8777a934a
--- /dev/null
+++ b/testtools/source/bridgetest/dllapi.hxx
@@ -0,0 +1,25 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*
+ * This file is part of the LibreOffice project.
+ *
+ * This Source Code Form is subject to the terms of the Mozilla Public
+ * License, v. 2.0. If a copy of the MPL was not distributed with this
+ * file, You can obtain one at http://mozilla.org/MPL/2.0/.
+ */
+
+#ifndef INCLUDED_TESTTOOLS_SOURCE_BRIDGETEST_DLLAPI_HXX
+#define INCLUDED_TESTTOOLS_SOURCE_BRIDGETEST_DLLAPI_HXX
+
+#include <sal/config.h>
+
+#include <sal/types.h>
+
+#if defined LO_DLLIMPLEMENTATION_TESTTOOLS
+#define LO_DLLPUBLIC_TESTTOOLS SAL_DLLPUBLIC_EXPORT
+#else
+#define LO_DLLPUBLIC_TESTTOOLS SAL_DLLPUBLIC_IMPORT
+#endif
+
+#endif
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab cinoptions=b1,g0,N-s cinkeys+=0=break: */
diff --git a/testtools/source/bridgetest/idl/bridgetest.idl b/testtools/source/bridgetest/idl/bridgetest.idl
new file mode 100644
index 000000000..82d63c37e
--- /dev/null
+++ b/testtools/source/bridgetest/idl/bridgetest.idl
@@ -0,0 +1,654 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*
+ * This file is part of the LibreOffice project.
+ *
+ * This Source Code Form is subject to the terms of the Mozilla Public
+ * License, v. 2.0. If a copy of the MPL was not distributed with this
+ * file, You can obtain one at http://mozilla.org/MPL/2.0/.
+ *
+ * This file incorporates work covered by the following license notice:
+ *
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed
+ * with this work for additional information regarding copyright
+ * ownership. The ASF licenses this file to you under the Apache
+ * License, Version 2.0 (the "License"); you may not use this file
+ * except in compliance with the License. You may obtain a copy of
+ * the License at http://www.apache.org/licenses/LICENSE-2.0 .
+ */
+
+#include <com/sun/star/lang/IllegalArgumentException.idl>
+#include <com/sun/star/lang/XComponent.idl>
+#include <com/sun/star/uno/XComponentContext.idl>
+#include <com/sun/star/uno/XInterface.idl>
+
+module test { module testtools { module bridgetest {
+
+enum TestEnum
+{
+ TEST,
+ ONE,
+ TWO,
+ CHECK,
+ LOLA,
+ PALOO,
+ ZA
+};
+
+enum TestBadEnum { M = 1 };
+
+struct TestStruct
+{
+ long member;
+};
+
+/**
+ * simple types
+ */
+struct TestSimple
+{
+ boolean Bool;
+ char Char;
+ byte Byte;
+ byte Byte2;
+ short Short;
+ short Short2;
+ unsigned short UShort;
+ long Long;
+ unsigned long ULong;
+ hyper Hyper;
+ unsigned hyper UHyper;
+ float Float;
+ double Double;
+ TestEnum Enum;
+};
+/**
+ * equal to max size returned in registers on x86_64
+ */
+struct SmallStruct
+{
+ hyper a;
+ hyper b;
+};
+/**
+ * equal to max size returned in registers on ia64
+ */
+struct MediumStruct
+{
+ hyper a;
+ hyper b;
+ hyper c;
+ hyper d;
+};
+/**
+ * bigger than max size returned in registers on ia64
+ */
+struct BigStruct
+{
+ hyper a;
+ hyper b;
+ hyper c;
+ hyper d;
+ hyper e;
+ hyper f;
+ hyper g;
+ hyper h;
+};
+/**
+ * two floats, BSDs/MacOSX on intel handle returning small
+ * structs differently than Linux
+ */
+struct TwoFloats
+{
+ float a;
+ float b;
+};
+/**
+ * all floats, ia64 handles them specially
+ */
+struct FourFloats
+{
+ float a;
+ float b;
+ float c;
+ float d;
+};
+/**
+ * Small struct with mixed float and integers.
+ * Should return in registers on BSDs/MACOSx
+ */
+struct MixedFloatAndInteger
+{
+ float a;
+ long b;
+};
+struct DoubleHyper {
+ double a;
+ hyper b;
+};
+struct HyperDouble {
+ hyper a;
+ double b;
+};
+struct FloatFloatLongByte {
+ float a;
+ float b;
+ long c;
+ byte d;
+};
+/**
+ * Small struct with three bytes. Should *not* return in registers on
+ * BSDs/MACOSx
+ */
+struct ThreeByteStruct
+{
+ byte a;
+ byte b;
+ byte c;
+};
+/**
+ * complex types adding string, interface, any
+ */
+struct TestElement : TestSimple
+{
+ string String;
+ com::sun::star::uno::XInterface Interface;
+ any Any;
+};
+/**
+ * adding even more complexity, sequence< TestElement >
+ */
+struct TestDataElements : TestElement
+{
+ sequence< TestElement > Sequence;
+};
+
+/**
+ * typedef used in interface
+ */
+typedef TestDataElements TestData;
+
+struct TestPolyStruct<T> { T member; };
+struct TestPolyStruct2<T,C> {
+ T member1;
+ C member2;
+};
+
+interface XRecursiveCall : com::sun::star::uno::XInterface
+{
+ /***
+ * @param nToCall If nToCall is 0, the method returns immediately.
+ * Otherwise, call the given interface with nToCall -1
+ *
+ ***/
+ void callRecursivly( [in] XRecursiveCall xCall , [in] long nToCall );
+};
+
+interface XMultiBase1 {
+ [attribute] double att1; // initially 0.0
+ long fn11([in] long arg); // return 11 * arg
+ string fn12([in] string arg); // return "12" + arg
+};
+
+interface XMultiBase2: XMultiBase1 {
+ long fn21([in] long arg); // return 21 * arg
+ string fn22([in] string arg); // return "22" + arg
+};
+
+interface XMultiBase3 {
+ [attribute] double att3; // initially 0.0
+ long fn31([in] long arg); // return 31 * arg
+ string fn32([in] string arg); // return "32" + arg
+ long fn33(); // return 33
+};
+
+interface XMultiBase3a: XMultiBase3 {};
+
+interface XMultiBase4 {
+ long fn41([in] long arg); // return 41 * arg
+};
+
+interface XMultiBase5 {
+ interface XMultiBase3;
+ interface XMultiBase4;
+ interface XMultiBase1;
+};
+
+interface XMultiBase6 {
+ interface XMultiBase2;
+ interface XMultiBase3a;
+ interface XMultiBase5;
+ long fn61([in] long arg); // return 61 * arg
+ string fn62([in] string arg); // return "62" + arg
+};
+
+interface XMultiBase7 {
+ long fn71([in] long arg); // return 71 * arg
+ string fn72([in] string arg); // return "72" + arg
+ long fn73(); // return 73
+};
+
+interface XMulti {
+ interface XMultiBase6;
+ interface XMultiBase7;
+};
+
+/**
+ * Monster test interface to test bridge calls.
+ * An implementation of this object has to store given values and return whenever there
+ * is an out param or return value.
+ */
+interface XBridgeTestBase : com::sun::star::uno::XInterface
+{
+ /**
+ * in parameter test, tests by calls reference also (complex types)
+ */
+ void setValues( [in] boolean bBool,
+ [in] char cChar,
+ [in] byte nByte,
+ [in] short nShort,
+ [in] unsigned short nUShort,
+ [in] long nLong,
+ [in] unsigned long nULong,
+ [in] hyper nHyper,
+ [in] unsigned hyper nUHyper,
+ [in] float fFloat,
+ [in] double fDouble,
+ [in] TestEnum eEnum,
+ [in] string aString,
+ [in] byte aByte2,
+ [in] short aShort2,
+ [in] com::sun::star::uno::XInterface xInterface,
+ [in] any aAny,
+ [in] sequence< TestElement > aSequence,
+ [in] TestData aStruct );
+ /**
+ * inout parameter test
+ *
+ * @return aStruct. The out parameter contain the values, that were previously set
+ * by setValues or (if not called before) default constructed values.
+ *
+ */
+ TestData setValues2( [inout] boolean bBool,
+ [inout] char cChar,
+ [inout] byte nByte,
+ [inout] short nShort,
+ [inout] unsigned short nUShort,
+ [inout] long nLong,
+ [inout] unsigned long nULong,
+ [inout] hyper nHyper,
+ [inout] unsigned hyper nUHyper,
+ [inout] float fFloat,
+ [inout] double fDouble,
+ [inout] TestEnum eEnum,
+ [inout] string aString,
+ [inout] byte aByte2,
+ [inout] short aShort2,
+ [inout] com::sun::star::uno::XInterface xInterface,
+ [inout] any aAny,
+ [inout] sequence< TestElement > aSequence,
+ [inout] TestData aStruct );
+
+ /**
+ * out parameter test
+ */
+ TestData getValues( [out] boolean bBool,
+ [out] char cChar,
+ [out] byte nByte,
+ [out] short nShort,
+ [out] unsigned short nUShort,
+ [out] long nLong,
+ [out] unsigned long nULong,
+ [out] hyper nHyper,
+ [out] unsigned hyper nUHyper,
+ [out] float fFloat,
+ [out] double fDouble,
+ [out] TestEnum eEnum,
+ [out] string aString,
+ [out] byte aByte2,
+ [out] short aShort2,
+ [out] com::sun::star::uno::XInterface xInterface,
+ [out] any aAny,
+ [out] sequence< TestElement > aSequence,
+ [out] TestData aStruct );
+
+ /**
+ * register return test 1
+ */
+ SmallStruct echoSmallStruct( [in] SmallStruct aStruct );
+
+ /**
+ * register return test 2
+ */
+ MediumStruct echoMediumStruct( [in] MediumStruct aStruct );
+
+ /**
+ * register return test 3
+ */
+ BigStruct echoBigStruct( [in] BigStruct aStruct );
+
+ /**
+ * register return test 4
+ */
+ TwoFloats echoTwoFloats( [in] TwoFloats aStruct );
+
+ /**
+ * register return test 5
+ */
+ FourFloats echoFourFloats( [in] FourFloats aStruct );
+
+ /**
+ * register return test 6
+ */
+ MixedFloatAndInteger echoMixedFloatAndInteger( [in] MixedFloatAndInteger aStruct );
+
+ DoubleHyper echoDoubleHyper([in] DoubleHyper s);
+
+ HyperDouble echoHyperDouble([in] HyperDouble s);
+
+ FloatFloatLongByte echoFloatFloatLongByte([in] FloatFloatLongByte s);
+
+ /**
+ * register return test 7
+ */
+ ThreeByteStruct echoThreeByteStruct( [in] ThreeByteStruct aStruct );
+
+ /**
+ * PPC Alignment test (#i107182#)
+ */
+ long testPPCAlignment( [in] hyper l1, [in] hyper l2, [in] long i1, [in] hyper l3, [in] long i2 );
+
+ /**
+ * PPC64 Alignment test
+ */
+ long testPPC64Alignment( [in] double d1, [in] double d2, [in] double d3, [in] long i1 );
+
+
+ /**
+ * VFP ABI (armhf) doubles test
+ */
+ double testTenDoubles( [in] double d1, [in] double d2, [in] double d3, [in] double d4, [in] double d5, [in] double d6, [in] double d7, [in] double d8, [in] double d9, [in] double d10 );
+
+ [attribute] boolean Bool;
+ [attribute] byte Byte;
+ [attribute] char Char;
+ [attribute] short Short;
+ [attribute] unsigned short UShort;
+ [attribute] long Long;
+ [attribute] unsigned long ULong;
+ [attribute] hyper Hyper;
+ [attribute] unsigned hyper UHyper;
+ [attribute] float Float;
+ [attribute] double Double;
+ [attribute] TestEnum Enum;
+ [attribute] string String;
+ [attribute] byte Byte2;
+ [attribute] short Short2;
+ [attribute] com::sun::star::uno::XInterface Interface;
+ [attribute] any Any;
+ [attribute] sequence< TestElement > Sequence;
+ [attribute] TestData Struct;
+
+ [attribute] long RaiseAttr1 {
+ set raises (com::sun::star::lang::IllegalArgumentException);
+ };
+ [attribute, readonly] long RaiseAttr2 {
+ get raises (com::sun::star::lang::IllegalArgumentException);
+ };
+
+ TestPolyStruct<boolean> transportPolyBoolean(
+ [in] TestPolyStruct<boolean> arg);
+ void transportPolyHyper([inout] TestPolyStruct<hyper> arg);
+ void transportPolySequence(
+ [in] TestPolyStruct<sequence<any> > arg1,
+ [out] TestPolyStruct<sequence<any> > arg2);
+
+ TestPolyStruct<long> getNullPolyLong();
+ TestPolyStruct<string> getNullPolyString();
+ TestPolyStruct<type> getNullPolyType();
+ TestPolyStruct<any> getNullPolyAny();
+ TestPolyStruct<sequence<boolean> > getNullPolySequence();
+ TestPolyStruct<TestEnum> getNullPolyEnum();
+ TestPolyStruct<TestBadEnum> getNullPolyBadEnum();
+ TestPolyStruct<TestStruct> getNullPolyStruct();
+ TestPolyStruct<XBridgeTestBase> getNullPolyInterface();
+
+ /***
+ * This method returns the parameter value.
+ * Method to extensively test anys.
+ ****/
+ any transportAny( [in] any value );
+
+ /***
+ * methods to check sequence of calls. Call call() and callOneway
+ * in an arbitrary sequence. Increase the callId for every call.
+ * The testobject sets an error flag.
+
+ @see testSequencePassed
+ ***/
+ void call( [in] long nCallId, [in] long nWaitMUSEC );
+ void callOneway( [in] long nCallId, [in] long nWaitMUSEC );
+ boolean sequenceOfCallTestPassed();
+
+ /****
+ * methods to check, if threads thread identity is holded.
+ *
+ ***/
+ void startRecursiveCall( [in] XRecursiveCall xCall , [in] long nToCall );
+
+ XMulti getMulti();
+ string testMulti([in] XMulti multi);
+};
+
+
+/**
+ * Inheriting from monster; adds raiseException(), attribute raising RuntimeException.
+ */
+interface XBridgeTest : XBridgeTestBase
+{
+ /**
+ * the exception struct returned has to be filled with given arguments.
+ * return value is for dummy.
+ */
+ TestData raiseException( [in] short ArgumentPosition,
+ [in] string Message,
+ [in] com::sun::star::uno::XInterface Context )
+ raises( com::sun::star::lang::IllegalArgumentException );
+
+
+ /**
+ * Throws runtime exception.
+ * check remote bridges handle exceptions during oneway calls properly.
+ * Note that on client side the exception may fly or not. When it flies, it should
+ * have the proper message and context.
+ ***/
+ void raiseRuntimeExceptionOneway( [in] string Message,
+ [in] com::sun::star::uno::XInterface Context );
+
+ /**
+ * raises runtime exception;
+ * the exception struct returned has to be filled with formerly set test data.
+ */
+ [attribute] long RuntimeException;
+};
+
+
+exception BadConstructorArguments: com::sun::star::uno::Exception {};
+
+service Constructors: com::sun::star::uno::XInterface {
+ create1(
+ [in] boolean arg0,
+ [in] byte arg1,
+ [in] short arg2,
+ [in] unsigned short arg3,
+ [in] long arg4,
+ [in] unsigned long arg5,
+ [in] hyper arg6,
+ [in] unsigned hyper arg7,
+ [in] float arg8,
+ [in] double arg9,
+ [in] char arg10,
+ [in] string arg11,
+ [in] type arg12,
+ [in] any arg13,
+ [in] sequence< boolean > arg14,
+ [in] sequence< byte > arg15,
+ [in] sequence< short > arg16,
+ [in] sequence< unsigned short > arg17,
+ [in] sequence< long > arg18,
+ [in] sequence< unsigned long > arg19,
+ [in] sequence< hyper > arg20,
+ [in] sequence< unsigned hyper > arg21,
+ [in] sequence< float > arg22,
+ [in] sequence< double > arg23,
+ [in] sequence< char > arg24,
+ [in] sequence< string > arg25,
+ [in] sequence< type > arg26,
+ [in] sequence< any > arg27,
+ [in] sequence< sequence< boolean > > arg28,
+ [in] sequence< sequence< any > > arg29,
+ [in] sequence< TestEnum > arg30,
+ [in] sequence< TestStruct > arg31,
+ [in] sequence< TestPolyStruct< boolean > > arg32,
+ [in] sequence< TestPolyStruct< any > > arg33,
+ [in] sequence< com::sun::star::uno::XInterface > arg34,
+ [in] TestEnum arg35,
+ [in] TestStruct arg36,
+ [in] TestPolyStruct< boolean > arg37,
+ [in] TestPolyStruct< any > arg38,
+ [in] com::sun::star::uno::XInterface arg39)
+ raises (BadConstructorArguments);
+
+ create2([in] any... args) raises (BadConstructorArguments);
+
+};
+
+service Constructors2: XMultiBase1 {
+
+ create1(
+ [in] TestPolyStruct<type> arg1,
+ [in] TestPolyStruct<any> arg2,
+ [in] TestPolyStruct<boolean> arg3,
+ [in] TestPolyStruct<byte> arg4,
+ [in] TestPolyStruct<short> arg5,
+ [in] TestPolyStruct<long> arg6,
+ [in] TestPolyStruct<hyper> arg7,
+ [in] TestPolyStruct<char> arg8,
+ [in] TestPolyStruct<string> arg9,
+ [in] TestPolyStruct<float> arg10,
+ [in] TestPolyStruct<double> arg11,
+ [in] TestPolyStruct<com::sun::star::uno::XInterface> arg12,
+ [in] TestPolyStruct<com::sun::star::lang::XComponent> arg13,
+ [in] TestPolyStruct<TestEnum> arg14,
+ [in] TestPolyStruct<TestPolyStruct2<char,any> > arg15,
+ [in] TestPolyStruct<TestPolyStruct2<TestPolyStruct2<char,any>,string> > arg16,
+ [in] TestPolyStruct2<string, TestPolyStruct2<char, TestPolyStruct<any> > > arg17,
+ [in] TestPolyStruct2<TestPolyStruct2<char,any>, TestPolyStruct<char> > arg18,
+ [in] TestPolyStruct<sequence<type> > arg19,
+ [in] TestPolyStruct<sequence<any> > arg20,
+ [in] TestPolyStruct<sequence<boolean> > arg21,
+ [in] TestPolyStruct<sequence<byte> > arg22,
+ [in] TestPolyStruct<sequence<short> > arg23,
+ [in] TestPolyStruct<sequence<long> > arg24,
+ [in] TestPolyStruct<sequence<hyper> > arg25,
+ [in] TestPolyStruct<sequence<char> > arg26,
+ [in] TestPolyStruct<sequence<string> > arg27,
+ [in] TestPolyStruct<sequence<float> > arg28,
+ [in] TestPolyStruct<sequence<double> > arg29,
+ [in] TestPolyStruct<sequence<com::sun::star::uno::XInterface> > arg30,
+ [in] TestPolyStruct<sequence<com::sun::star::lang::XComponent> > arg31,
+ [in] TestPolyStruct<sequence<TestEnum> > arg32,
+ [in] TestPolyStruct<sequence<TestPolyStruct2<char, sequence<any> > > > arg33,
+ [in] TestPolyStruct<sequence<TestPolyStruct2<TestPolyStruct<char>, sequence<any> > > > arg34,
+ [in] TestPolyStruct<sequence<sequence<long> > > arg35,
+ [in] sequence<TestPolyStruct<long > > arg36,
+ [in] sequence<TestPolyStruct<TestPolyStruct2<char,any> > > arg37,
+ [in] sequence<TestPolyStruct<TestPolyStruct2<TestPolyStruct2<char,any>,string> > > arg38,
+ [in] sequence<TestPolyStruct2<string, TestPolyStruct2<char, TestPolyStruct<any> > > > arg39,
+ [in] sequence<TestPolyStruct2<TestPolyStruct2<char,any>, TestPolyStruct<char> > > arg40,
+ [in] sequence<sequence<TestPolyStruct< char > > > arg41,
+ [in] sequence<sequence<TestPolyStruct<TestPolyStruct2<char,any> > > >arg42,
+ [in] sequence<sequence<TestPolyStruct<TestPolyStruct2<TestPolyStruct2<char,any>,string> > > > arg43,
+ [in] sequence<sequence<TestPolyStruct2<string, TestPolyStruct2<char, TestPolyStruct<any> > > > > arg44,
+ [in] sequence<sequence<TestPolyStruct2<TestPolyStruct2<char,any>, TestPolyStruct<char> > > > arg45
+ );
+};
+
+interface XCurrentContextChecker {
+ boolean perform(
+ [in] XCurrentContextChecker other, [in] long setSteps,
+ [in] long checkSteps);
+};
+
+/** Extended tests with sequences.
+ */
+interface XBridgeTest2 : XBridgeTest
+{
+ sequence< boolean > setSequenceBool( [in] sequence< boolean > aSeq);
+ sequence< char > setSequenceChar( [in] sequence< char > aSeq);
+ sequence< byte> setSequenceByte( [in] sequence< byte > aSeq);
+ sequence< short> setSequenceShort( [in] sequence< short > aSeq);
+ sequence< unsigned short > setSequenceUShort( [in] sequence< unsigned short > aSeq);
+ sequence< long > setSequenceLong( [in] sequence< long > aSeq);
+ sequence< unsigned long > setSequenceULong( [in] sequence< unsigned long > aSeq);
+ sequence< hyper > setSequenceHyper( [in] sequence< hyper > aSeq);
+ sequence< unsigned hyper > setSequenceUHyper( [in] sequence< unsigned hyper > aSeq);
+ sequence< float > setSequenceFloat( [in] sequence< float > aSeq);
+ sequence< double > setSequenceDouble( [in] sequence< double > aSeq);
+ sequence< TestEnum > setSequenceEnum( [in] sequence< TestEnum > aSeq);
+ sequence< string > setSequenceString( [in] sequence< string > aString);
+ sequence< com::sun::star::uno::XInterface > setSequenceXInterface(
+ [in] sequence< com::sun::star::uno::XInterface > aSeq);
+ sequence< any > setSequenceAny( [in] sequence< any > aSeq);
+ sequence< TestElement > setSequenceStruct( [in] sequence< TestElement > aSeq);
+
+ sequence< sequence< long > > setDim2( [in] sequence< sequence< long > > aSeq);
+ sequence< sequence < sequence < long > > > setDim3(
+ [in] sequence< sequence < sequence < long > > > aSeq);
+
+ void setSequencesInOut( [inout] sequence< boolean > aSeqBoolean,
+ [inout] sequence< char > aSeqChar,
+ [inout] sequence< byte > aSeqByte,
+ [inout] sequence< short > aSeqShort,
+ [inout] sequence< unsigned short> aSeqUShort,
+ [inout] sequence< long > aSeqLong,
+ [inout] sequence< unsigned long > aSeqULong,
+ [inout] sequence< hyper > aSeqHyper,
+ [inout] sequence< unsigned hyper > aSeqUHyper,
+ [inout] sequence< float > aSeqFloat,
+ [inout] sequence< double > aSeqDouble,
+ [inout] sequence< TestEnum > aSeqEnum,
+ [inout] sequence< string > aSeqString,
+ [inout] sequence< com::sun::star::uno::XInterface > aSeqXInterface,
+ [inout] sequence< any > aSeqAny,
+ [inout] sequence< sequence< long > > aSeqDim2,
+ [inout] sequence< sequence < sequence < long > > > aSeqDim3);
+
+ void setSequencesOut( [out] sequence< boolean > aSeqBoolean,
+ [out] sequence< char > aSeqChar,
+ [out] sequence< byte > aSeqByte,
+ [out] sequence< short > aSeqShort,
+ [out] sequence< unsigned short> aSeqUShort,
+ [out] sequence< long > aSeqLong,
+ [out] sequence< unsigned long > aSeqULong,
+ [out] sequence< hyper > aSeqHyper,
+ [out] sequence< unsigned hyper > aSeqUHyper,
+ [out] sequence< float > aSeqFloat,
+ [out] sequence< double > aSeqDouble,
+ [out] sequence< TestEnum > aSeqEnum,
+ [out] sequence< string > aSeqString,
+ [out] sequence< com::sun::star::uno::XInterface > aSeqXInterface,
+ [out] sequence< any > aSeqAny,
+ [out] sequence< sequence< long > > aSeqDim2,
+ [out] sequence< sequence < sequence < long > > > aSeqDim3);
+
+ void testConstructorsService(
+ [in] com::sun::star::uno::XComponentContext context)
+ raises (BadConstructorArguments);
+
+ XCurrentContextChecker getCurrentContextChecker();
+};
+
+}; }; };
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/testtools/source/bridgetest/idl/com/sun/star/test/performance/XPerformanceTest.idl b/testtools/source/bridgetest/idl/com/sun/star/test/performance/XPerformanceTest.idl
new file mode 100644
index 000000000..b92b7b4c3
--- /dev/null
+++ b/testtools/source/bridgetest/idl/com/sun/star/test/performance/XPerformanceTest.idl
@@ -0,0 +1,130 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*
+ * This file is part of the LibreOffice project.
+ *
+ * This Source Code Form is subject to the terms of the Mozilla Public
+ * License, v. 2.0. If a copy of the MPL was not distributed with this
+ * file, You can obtain one at http://mozilla.org/MPL/2.0/.
+ *
+ * This file incorporates work covered by the following license notice:
+ *
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed
+ * with this work for additional information regarding copyright
+ * ownership. The ASF licenses this file to you under the Apache
+ * License, Version 2.0 (the "License"); you may not use this file
+ * except in compliance with the License. You may obtain a copy of
+ * the License at http://www.apache.org/licenses/LICENSE-2.0 .
+ */
+#ifndef __com_sun_star_test_performance_XPerformanceTest_idl__
+#define __com_sun_star_test_performance_XPerformanceTest_idl__
+
+#include <com/sun/star/uno/XInterface.idl>
+
+module com
+{
+module sun
+{
+module star
+{
+module test
+{
+module performance
+{
+
+/** struct of simple types to be carried
+*/
+published struct SimpleTypes
+{
+ boolean Bool;
+ char Char;
+ byte Byte;
+ short Short;
+ unsigned short UShort;
+ long Long;
+ unsigned long ULong;
+ hyper Hyper;
+ unsigned hyper UHyper;
+ float Float;
+ double Double;
+};
+/** struct ComplexTypes adding Sequence, String, Interface, Any to SimpleTypes
+*/
+published struct ComplexTypes : SimpleTypes
+{
+ sequence< long > Sequence;
+ string String;
+ com::sun::star::uno::XInterface Interface;
+ any Any;
+};
+
+/** A performance test object has to be implemented in a special way, that:
+ <ul>
+ <li>queryInterface() execution times remain (nearly) static</li>
+ <li>functions kept simple, thus there is (nearly) no execution time of the function itself</li>
+ <li>no dynamic data is ever returned except of createObject(), so return 0, empty strings etc.</li>
+ </ul>
+ The interface is divided into three sections:
+ <ul>
+ <li>measuring asynchron/ synchron calls</li>
+ <li>complex data calls with/out return value; in/out parameters</li>
+ <li>single data types like long, float, string etc.</li>
+ <li>method calls versa attribute calls</li>
+ <li>raising RuntimeException</li>
+ </ul>
+*/
+published interface XPerformanceTest : com::sun::star::uno::XInterface
+{
+ void async();
+ void sync();
+
+ ComplexTypes complexIn( [in] ComplexTypes aVal );
+ ComplexTypes complexInout( [inout] ComplexTypes aVal );
+
+ void complexOneway( [in] ComplexTypes aVal );
+ void complexNoreturn( [in] ComplexTypes aVal );
+
+ XPerformanceTest createObject();
+
+ [attribute] long Long_attr;
+ [attribute] hyper Hyper_attr;
+ [attribute] float Float_attr;
+ [attribute] double Double_attr;
+ [attribute] string String_attr;
+ [attribute] com::sun::star::uno::XInterface Interface_attr;
+ [attribute] any Any_attr;
+ [attribute] sequence< com::sun::star::uno::XInterface > Sequence_attr;
+ [attribute] ComplexTypes Struct_attr;
+
+ long getLong();
+ void setLong( [in] long n );
+ hyper getHyper();
+ void setHyper( [in] hyper n );
+ float getFloat();
+ void setFloat( [in] float f );
+ double getDouble();
+ void setDouble( [in] double f );
+ string getString();
+ void setString( [in] string s );
+ com::sun::star::uno::XInterface getInterface();
+ void setInterface( [in] com::sun::star::uno::XInterface x );
+ any getAny();
+ void setAny( [in] any a );
+ sequence< com::sun::star::uno::XInterface > getSequence();
+ void setSequence( [in] sequence< com::sun::star::uno::XInterface > seq );
+ ComplexTypes getStruct();
+ void setStruct( [in] ComplexTypes c );
+
+ void raiseRuntimeException();
+};
+
+
+};
+};
+};
+};
+};
+
+#endif
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/testtools/source/bridgetest/multi.cxx b/testtools/source/bridgetest/multi.cxx
new file mode 100644
index 000000000..1bfbfb415
--- /dev/null
+++ b/testtools/source/bridgetest/multi.cxx
@@ -0,0 +1,224 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*
+ * This file is part of the LibreOffice project.
+ *
+ * This Source Code Form is subject to the terms of the Mozilla Public
+ * License, v. 2.0. If a copy of the MPL was not distributed with this
+ * file, You can obtain one at http://mozilla.org/MPL/2.0/.
+ *
+ * This file incorporates work covered by the following license notice:
+ *
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed
+ * with this work for additional information regarding copyright
+ * ownership. The ASF licenses this file to you under the Apache
+ * License, Version 2.0 (the "License"); you may not use this file
+ * except in compliance with the License. You may obtain a copy of
+ * the License at http://www.apache.org/licenses/LICENSE-2.0 .
+ */
+
+
+#include <sal/config.h>
+
+#include "multi.hxx"
+
+#include <rtl/textenc.h>
+#include <rtl/ustring.hxx>
+
+#include <sstream>
+#include <string_view>
+
+namespace {
+
+struct CheckFailed {
+ explicit CheckFailed(OUString const & theMessage): message(theMessage)
+ {}
+
+ OUString message;
+};
+
+template< typename T > void checkEqual(T const & value, T const & argument) {
+ if (argument != value) {
+ std::ostringstream s;
+ s << value << " != " << argument;
+ throw CheckFailed(
+ OStringToOUString(
+ std::string_view(s.str()), RTL_TEXTENCODING_UTF8));
+ }
+}
+
+}
+
+namespace testtools::bridgetest {
+
+OUString testMulti( css::uno::Reference< test::testtools::bridgetest::XMulti > const & multi )
+{
+ try {
+ checkEqual(
+ 0.0,
+ css::uno::Reference< test::testtools::bridgetest::XMultiBase1 >(
+ multi, css::uno::UNO_QUERY_THROW)->getatt1());
+ checkEqual(
+ 0.0,
+ static_cast< test::testtools::bridgetest::XMultiBase2 * >(
+ multi.get())->getatt1());
+ checkEqual(
+ 0.0,
+ css::uno::Reference< test::testtools::bridgetest::XMultiBase2 >(
+ multi, css::uno::UNO_QUERY_THROW)->getatt1());
+ checkEqual(
+ 0.0,
+ static_cast< test::testtools::bridgetest::XMultiBase5 * >(
+ multi.get())->getatt1());
+ checkEqual(
+ 0.0,
+ css::uno::Reference< test::testtools::bridgetest::XMultiBase5 >(
+ multi, css::uno::UNO_QUERY_THROW)->getatt1());
+ css::uno::Reference< test::testtools::bridgetest::XMultiBase5 >(
+ multi, css::uno::UNO_QUERY_THROW)->setatt1(0.1);
+ checkEqual(
+ 0.1,
+ css::uno::Reference< test::testtools::bridgetest::XMultiBase1 >(
+ multi, css::uno::UNO_QUERY_THROW)->getatt1());
+ checkEqual(
+ 0.1,
+ static_cast< test::testtools::bridgetest::XMultiBase2 * >(
+ multi.get())->getatt1());
+ checkEqual(
+ 0.1,
+ css::uno::Reference< test::testtools::bridgetest::XMultiBase2 >(
+ multi, css::uno::UNO_QUERY_THROW)->getatt1());
+ checkEqual(
+ 0.1,
+ static_cast< test::testtools::bridgetest::XMultiBase5 * >(
+ multi.get())->getatt1());
+ checkEqual(
+ 0.1,
+ css::uno::Reference< test::testtools::bridgetest::XMultiBase5 >(
+ multi, css::uno::UNO_QUERY_THROW)->getatt1());
+ checkEqual< sal_Int32 >(
+ 11 * 1,
+ css::uno::Reference< test::testtools::bridgetest::XMultiBase1 >(
+ multi, css::uno::UNO_QUERY_THROW)->fn11(1));
+ checkEqual< sal_Int32 >(
+ 11 * 1,
+ static_cast< test::testtools::bridgetest::XMultiBase2 * >(
+ multi.get())->fn11(1));
+ checkEqual< sal_Int32 >(
+ 11 * 2,
+ css::uno::Reference< test::testtools::bridgetest::XMultiBase2 >(
+ multi, css::uno::UNO_QUERY_THROW)->fn11(2));
+ checkEqual< sal_Int32 >(
+ 11 * 1,
+ static_cast< test::testtools::bridgetest::XMultiBase5 * >(
+ multi.get())->fn11(1));
+ checkEqual< sal_Int32 >(
+ 11 * 5,
+ css::uno::Reference< test::testtools::bridgetest::XMultiBase5 >(
+ multi, css::uno::UNO_QUERY_THROW)->fn11(5));
+ checkEqual(
+ OUString("12" "abc"),
+ css::uno::Reference< test::testtools::bridgetest::XMultiBase1 >(
+ multi, css::uno::UNO_QUERY_THROW)->fn12(
+ "abc"));
+ checkEqual(
+ OUString("12" "abc-2"),
+ static_cast< test::testtools::bridgetest::XMultiBase2 * >(
+ multi.get())->fn12("abc-2"));
+ checkEqual(
+ OUString("12" "abc-2"),
+ css::uno::Reference< test::testtools::bridgetest::XMultiBase2 >(
+ multi, css::uno::UNO_QUERY_THROW)->fn12("abc-2"));
+ checkEqual(
+ OUString("12" "abc-5"),
+ static_cast< test::testtools::bridgetest::XMultiBase5 * >(
+ multi.get())->fn12("abc-5"));
+ checkEqual(
+ OUString("12" "abc-5"),
+ css::uno::Reference< test::testtools::bridgetest::XMultiBase5 >(
+ multi, css::uno::UNO_QUERY_THROW)->fn12("abc-5"));
+ checkEqual< sal_Int32 >(21 * 2, multi->fn21(2));
+ checkEqual(
+ OUString("22" "de"),
+ multi->fn22("de"));
+ checkEqual< sal_Int32 >(
+ 31 * 3,
+ css::uno::Reference< test::testtools::bridgetest::XMultiBase3 >(
+ multi, css::uno::UNO_QUERY_THROW)->fn31(3));
+ checkEqual< sal_Int32 >(
+ 31 * 5,
+ static_cast< test::testtools::bridgetest::XMultiBase5 * >(
+ multi.get())->fn31(5));
+ checkEqual< sal_Int32 >(
+ 31 * 5,
+ css::uno::Reference< test::testtools::bridgetest::XMultiBase5 >(
+ multi, css::uno::UNO_QUERY_THROW)->fn31(5));
+ checkEqual(
+ 0.0,
+ css::uno::Reference< test::testtools::bridgetest::XMultiBase3 >(
+ multi, css::uno::UNO_QUERY_THROW)->getatt3());
+ checkEqual(
+ 0.0,
+ static_cast< test::testtools::bridgetest::XMultiBase5 * >(
+ multi.get())->getatt3());
+ checkEqual(
+ 0.0,
+ css::uno::Reference< test::testtools::bridgetest::XMultiBase5 >(
+ multi, css::uno::UNO_QUERY_THROW)->getatt3());
+ css::uno::Reference< test::testtools::bridgetest::XMultiBase3 >(
+ multi, css::uno::UNO_QUERY_THROW)->setatt3(0.3);
+ checkEqual(
+ 0.3,
+ css::uno::Reference< test::testtools::bridgetest::XMultiBase3 >(
+ multi, css::uno::UNO_QUERY_THROW)->getatt3());
+ checkEqual(
+ 0.3,
+ static_cast< test::testtools::bridgetest::XMultiBase5 * >(
+ multi.get())->getatt3());
+ checkEqual(
+ 0.3,
+ css::uno::Reference< test::testtools::bridgetest::XMultiBase5 >(
+ multi, css::uno::UNO_QUERY_THROW)->getatt3());
+ checkEqual(
+ OUString("32" "f"),
+ css::uno::Reference< test::testtools::bridgetest::XMultiBase3 >(
+ multi, css::uno::UNO_QUERY_THROW)->fn32("f"));
+ checkEqual(
+ OUString("32" "f-5"),
+ static_cast< test::testtools::bridgetest::XMultiBase5 * >(
+ multi.get())->fn32("f-5"));
+ checkEqual(
+ OUString("32" "f-5"),
+ css::uno::Reference< test::testtools::bridgetest::XMultiBase5 >(
+ multi, css::uno::UNO_QUERY_THROW)->fn32("f-5"));
+ checkEqual< sal_Int32 >(
+ 33,
+ css::uno::Reference< test::testtools::bridgetest::XMultiBase3 >(
+ multi, css::uno::UNO_QUERY_THROW)->fn33());
+ checkEqual< sal_Int32 >(
+ 33,
+ static_cast< test::testtools::bridgetest::XMultiBase5 * >(
+ multi.get())->fn33());
+ checkEqual< sal_Int32 >(
+ 33,
+ css::uno::Reference< test::testtools::bridgetest::XMultiBase5 >(
+ multi, css::uno::UNO_QUERY_THROW)->fn33());
+ checkEqual< sal_Int32 >(41 * 4, multi->fn41(4));
+ checkEqual< sal_Int32 >(61 * 6, multi->fn61(6));
+ checkEqual(
+ OUString("62" ""),
+ multi->fn62(OUString()));
+ checkEqual< sal_Int32 >(71 * 7, multi->fn71(7));
+ checkEqual(
+ OUString("72" "g"),
+ multi->fn72("g"));
+ checkEqual< sal_Int32 >(73, multi->fn73());
+ } catch (CheckFailed const & f) {
+ return f.message;
+ }
+ return OUString();
+}
+
+}
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/testtools/source/bridgetest/multi.hxx b/testtools/source/bridgetest/multi.hxx
new file mode 100644
index 000000000..c4171e8ee
--- /dev/null
+++ b/testtools/source/bridgetest/multi.hxx
@@ -0,0 +1,103 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*
+ * This file is part of the LibreOffice project.
+ *
+ * This Source Code Form is subject to the terms of the Mozilla Public
+ * License, v. 2.0. If a copy of the MPL was not distributed with this
+ * file, You can obtain one at http://mozilla.org/MPL/2.0/.
+ *
+ * This file incorporates work covered by the following license notice:
+ *
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed
+ * with this work for additional information regarding copyright
+ * ownership. The ASF licenses this file to you under the Apache
+ * License, Version 2.0 (the "License"); you may not use this file
+ * except in compliance with the License. You may obtain a copy of
+ * the License at http://www.apache.org/licenses/LICENSE-2.0 .
+ */
+
+#ifndef INCLUDED_TESTTOOLS_SOURCE_BRIDGETEST_MULTI_HXX
+#define INCLUDED_TESTTOOLS_SOURCE_BRIDGETEST_MULTI_HXX
+
+#include <sal/config.h>
+
+#include <com/sun/star/uno/Reference.hxx>
+#include <cppuhelper/implbase.hxx>
+#include <rtl/ustring.hxx>
+#include <sal/types.h>
+#include <test/testtools/bridgetest/XMulti.hpp>
+
+#include "dllapi.hxx"
+
+namespace testtools::bridgetest {
+
+class Multi: public cppu::WeakImplHelper< test::testtools::bridgetest::XMulti >
+{
+public:
+ Multi(): m_attribute1(0.0), m_attribute3(0.0) {}
+
+ virtual double SAL_CALL getatt1() override
+ { return m_attribute1; }
+
+ virtual void SAL_CALL setatt1(double value) override
+ { m_attribute1 = value; }
+
+ virtual sal_Int32 SAL_CALL fn11(sal_Int32 arg) override
+ { return 11 * arg; }
+
+ virtual OUString SAL_CALL fn12(OUString const & arg) override
+ { return "12" + arg; }
+
+ virtual sal_Int32 SAL_CALL fn21(sal_Int32 arg) override
+ { return 21 * arg; }
+
+ virtual OUString SAL_CALL fn22(OUString const & arg) override
+ { return "22" + arg; }
+
+ virtual double SAL_CALL getatt3() override
+ { return m_attribute3; }
+
+ virtual void SAL_CALL setatt3(double value) override
+ { m_attribute3 = value; }
+
+ virtual sal_Int32 SAL_CALL fn31(sal_Int32 arg) override
+ { return 31 * arg; }
+
+ virtual OUString SAL_CALL fn32(OUString const & arg) override
+ { return "32" + arg; }
+
+ virtual sal_Int32 SAL_CALL fn33() override
+ { return 33; }
+
+ virtual sal_Int32 SAL_CALL fn41(sal_Int32 arg) override
+ { return 41 * arg; }
+
+ virtual sal_Int32 SAL_CALL fn61(sal_Int32 arg) override
+ { return 61 * arg; }
+
+ virtual OUString SAL_CALL fn62(OUString const & arg) override
+ { return "62" + arg; }
+
+ virtual sal_Int32 SAL_CALL fn71(sal_Int32 arg) override
+ { return 71 * arg; }
+
+ virtual OUString SAL_CALL fn72(OUString const & arg) override
+ { return "72" + arg; }
+
+ virtual sal_Int32 SAL_CALL fn73() override
+ { return 73; }
+
+private:
+ double m_attribute1;
+ double m_attribute3;
+};
+
+LO_DLLPUBLIC_TESTTOOLS
+OUString testMulti( css::uno::Reference< test::testtools::bridgetest::XMulti > const & multi);
+
+}
+
+#endif
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/testtools/source/bridgetest/pyuno/core.py b/testtools/source/bridgetest/pyuno/core.py
new file mode 100644
index 000000000..c56e9f144
--- /dev/null
+++ b/testtools/source/bridgetest/pyuno/core.py
@@ -0,0 +1,358 @@
+#
+# This file is part of the LibreOffice project.
+#
+# This Source Code Form is subject to the terms of the Mozilla Public
+# License, v. 2.0. If a copy of the MPL was not distributed with this
+# file, You can obtain one at http://mozilla.org/MPL/2.0/.
+#
+# This file incorporates work covered by the following license notice:
+#
+# Licensed to the Apache Software Foundation (ASF) under one or more
+# contributor license agreements. See the NOTICE file distributed
+# with this work for additional information regarding copyright
+# ownership. The ASF licenses this file to you under the Apache
+# License, Version 2.0 (the "License"); you may not use this file
+# except in compliance with the License. You may obtain a copy of
+# the License at http://www.apache.org/licenses/LICENSE-2.0 .
+#
+import pyuno
+import uno
+import unittest
+import exceptions
+import types
+
+def suite(ctx):
+ suite = unittest.TestSuite()
+ suite.addTest(TestCase("testErrors",ctx))
+ suite.addTest(TestCase("testBaseTypes",ctx))
+ suite.addTest(TestCase("testOutparam",ctx))
+ suite.addTest(TestCase("testStruct",ctx))
+ suite.addTest(TestCase("testType",ctx))
+ suite.addTest(TestCase("testEnum",ctx))
+ suite.addTest(TestCase("testBool",ctx))
+ suite.addTest(TestCase("testChar",ctx))
+ suite.addTest(TestCase("testUnicode",ctx))
+ suite.addTest(TestCase("testConstant",ctx))
+ suite.addTest(TestCase("testExceptions",ctx))
+ suite.addTest(TestCase("testInterface",ctx))
+ suite.addTest(TestCase("testByteSequence",ctx))
+ suite.addTest(TestCase("testInvoke",ctx))
+ return suite
+
+def equalsEps( a,b,eps ):
+ if a - eps <= b and a+eps >= b:
+ return 1
+ return 0
+
+def assign( rData, bBool, cChar, nByte, nShort, nUShort, nLong, nULong, nHyper,\
+ nUHyper, fFloat, fDouble, eEnum, rStr, xTest, rAny ):
+ rData.Bool = bBool;
+ rData.Char = cChar;
+ rData.Byte = nByte;
+ rData.Short = nShort;
+ rData.UShort = nUShort;
+ rData.Long = nLong;
+ rData.ULong = nULong;
+ rData.Hyper = nHyper;
+ rData.UHyper = nUHyper;
+ rData.Float = fFloat;
+ rData.Double = fDouble;
+ rData.Enum = eEnum;
+ rData.String = rStr;
+ rData.Interface = xTest;
+ rData.Any = rAny;
+
+
+class PythonTransporter:
+ def __init__( self ):
+ pass
+
+ def transportAny( self, arg ):
+ return arg
+
+class TestCase( unittest.TestCase):
+
+ def __init__(self,method,ctx):
+ unittest.TestCase.__init__(self,method)
+ self.ctx = ctx
+
+ def setUp(self):
+ # the testcomponent from the testtools project
+ self.tobj = self.ctx.ServiceManager.createInstanceWithContext(
+ 'com.sun.star.test.bridge.CppTestObject' , self.ctx )
+
+ self.tobj.Bool = 1
+ self.tobj.Char = 'h'
+ self.tobj.Byte = 43
+ self.tobj.Short = -42
+ self.tobj.UShort = 44
+ self.tobj.Long = 42
+ self.tobj.ULong = 41
+ self.tobj.Hyper = 46
+ self.tobj.UHyper = 47
+ self.tobj.Float = 4.3
+ self.tobj.Double = 4.2
+ self.tobj.Enum = 4
+ self.tobj.String = "yabadabadoo"
+ self.tobj.Interface = self.ctx
+ self.tobj.Any = self.tobj.String
+ mystruct = uno.createUnoStruct( "test.testtools.bridgetest.TestData" )
+ assign( mystruct, 1, 'h', 43, -42,44,42,41,46,47,4.3,4.2,4,"yabadabadoo",self.ctx,"yabadabadoo")
+ self.tobj.Struct = mystruct
+
+ self.testElement = uno.createUnoStruct( "test.testtools.bridgetest.TestElement" )
+ self.testElement.String = "foo"
+ self.testElement2 = uno.createUnoStruct( "test.testtools.bridgetest.TestElement" )
+ self.testElement2.String = "42"
+ self.tobj.Sequence = (self.testElement,self.testElement2)
+
+ def testBaseTypes(self):
+ self.failUnless( 42 == self.tobj.Long , "Long attribute" )
+ self.failUnless( 41 == self.tobj.ULong , "ULong attribute" )
+ self.failUnless( 43 == self.tobj.Byte , "Byte attribute" )
+ self.failUnless( 44 == self.tobj.UShort , "UShort attribute" )
+ self.failUnless( -42 == self.tobj.Short , "Short attribute" )
+ self.failUnless( 46 == self.tobj.Hyper , "Hyper attribute" )
+ self.failUnless( 47 == self.tobj.UHyper , "UHyper attribute" )
+ self.failUnless( self.tobj.Bool , "Bool attribute2" )
+ self.failUnless( "yabadabadoo" == self.tobj.String , "String attribute" )
+ self.failUnless( self.tobj.Sequence[0] == self.testElement , "Sequence test")
+ self.failUnless( self.tobj.Sequence[1] == self.testElement2 , "Sequence2 test")
+ self.failUnless( equalsEps( 4.3,self.tobj.Float,0.0001) , "float test" )
+ self.failUnless( 4.2 == self.tobj.Double , "double test" )
+ self.failUnless( self.ctx == self.tobj.Interface ,
+ "object identity test with C++ object" )
+ self.failUnless( not self.ctx == self.tobj , "object not identical test " )
+ self.failUnless( 42 == self.tobj.transportAny( 42 ), "transportAny long" )
+ self.failUnless( "woo, this is python" == self.tobj.transportAny( "woo, this is python" ), \
+ "string roundtrip via any test" )
+
+ def testEnum( self ):
+ e1 = uno.Enum( "com.sun.star.uno.TypeClass" , "LONG" )
+ e2 = uno.Enum( "com.sun.star.uno.TypeClass" , "LONG" )
+ e3 = uno.Enum( "com.sun.star.uno.TypeClass" , "UNSIGNED_LONG" )
+ e4 = uno.Enum( "test.testtools.bridgetest.TestEnum" , "TWO" )
+ self.failUnless( e1 == e2 , "equal enum test" )
+ self.failUnless( not (e1 == e3) , "different enums test" )
+ self.failUnless( self.tobj.transportAny( e3 ) == e3, "enum roundtrip test" )
+ self.tobj.Enum = e4
+ self.failUnless( e4 == self.tobj.Enum , "enum assignment failed" )
+
+ def testType(self ):
+ t1 = uno.getTypeByName( "com.sun.star.lang.XComponent" )
+ t2 = uno.getTypeByName( "com.sun.star.lang.XComponent" )
+ t3 = uno.getTypeByName( "com.sun.star.lang.EventObject" )
+ self.failUnless( t1.typeClass == \
+ uno.Enum( "com.sun.star.uno.TypeClass", "INTERFACE" ), "typeclass of type test" )
+ self.failUnless( t3.typeClass == \
+ uno.Enum( "com.sun.star.uno.TypeClass", "STRUCT" ), "typeclass of type test")
+ self.failUnless( t1 == t2 , "equal type test" )
+ self.failUnless( t1 == t2 , "equal type test" )
+ self.failUnless( t1 == self.tobj.transportAny( t1 ), "type roundtrip test" )
+
+ def testBool( self ):
+ self.failUnless( uno.Bool(1) , "uno.Bool true test" )
+ self.failUnless( not uno.Bool(0) , "uno.Bool false test" )
+ self.failUnless( uno.Bool( "true") , "uno.Bool true1 test" )
+ self.failUnless( not uno.Bool( "false") , "uno.Bool true1 test" )
+
+ self.tobj.Bool = uno.Bool(1)
+ self.failUnless( self.tobj.Bool , "bool true attribute test" )
+ self.tobj.Bool = uno.Bool(0)
+ self.failUnless( not self.tobj.Bool , "bool true attribute test" )
+
+ # new boolean semantic
+ self.failUnless( id( self.tobj.transportAny( True ) ) == id(True) , "boolean preserve test")
+ self.failUnless( id( self.tobj.transportAny( False ) ) == id(False) , "boolean preserve test" )
+ self.failUnless( id( self.tobj.transportAny(1) ) != id( True ), "boolean preserve test" )
+ self.failUnless( id( self.tobj.transportAny(0) ) != id( False ), "boolean preserve test" )
+
+ def testChar( self ):
+ self.tobj.Char = uno.Char( u'h' )
+ self.failUnless( self.tobj.Char == uno.Char( u'h' ), "char type test" )
+ self.failUnless( isinstance( self.tobj.transportAny( uno.Char(u'h') ),uno.Char),"char preserve test" )
+
+ def testStruct( self ):
+ mystruct = uno.createUnoStruct( "test.testtools.bridgetest.TestData" )
+ assign( mystruct, 1, 'h', 43, -42,44,42,41,46,47,4.3,4.2,4,"yabadabadoo",self.ctx,"yabadabadoo")
+ self.tobj.Struct = mystruct
+ aSecondStruct = self.tobj.Struct
+
+ self.failUnless( self.tobj.Struct == mystruct, "struct roundtrip for equality test" )
+ self.failUnless( aSecondStruct == mystruct, "struct roundtrip for equality test2" )
+ aSecondStruct.Short = 720
+ self.failUnless( not aSecondStruct == mystruct , "different structs equality test" )
+ self.failUnless( not self.ctx == mystruct , "object is not equal to struct test" )
+ self.failUnless( mystruct == self.tobj.transportAny( mystruct ), "struct roundtrip with any test" )
+ my2ndstruct = uno.createUnoStruct( "test.testtools.bridgetest.TestData", \
+ 1, 'h', 43, -42,44,42,41,46,47,4.3,4.2,4,"yabadabadoo",self.ctx,"yabadabadoo",())
+ self.failUnless( my2ndstruct == mystruct, "struct non-default ctor test" )
+ def testUnicode( self ):
+ uni = u'\0148'
+ self.tobj.String = uni
+ self.failUnless( uni == self.tobj.String )
+
+
+ self.tobj.String = u'dubidu'
+ self.failUnless( u'dubidu' == self.tobj.String , "unicode comparison test")
+ self.failUnless( 'dubidu' == self.tobj.String , "unicode vs. string comparison test" )
+
+ def testConstant( self ):
+ self.failUnless( uno.getConstantByName( "com.sun.star.beans.PropertyConcept.ATTRIBUTES" ) == 4,\
+ "constant retrieval test" )
+
+ def testExceptions( self ):
+ unoExc = uno.getClass( "com.sun.star.uno.Exception" )
+ ioExc = uno.getClass( "com.sun.star.io.IOException" )
+ dispExc = uno.getClass( "com.sun.star.lang.DisposedException" )
+ wasHere = 0
+ try:
+ raise ioExc( "huhuh" , self.tobj )
+ except unoExc , instance:
+ wasHere = 1
+ self.failUnless( wasHere , "exception test 1" )
+
+ wasHere = 0
+ try:
+ raise ioExc
+ except ioExc:
+ wasHere = 1
+ else:
+ self.failUnless( wasHere, "exception test 2" )
+
+ wasHere = 0
+ try:
+ raise dispExc
+ except ioExc:
+ pass
+ except unoExc:
+ wasHere = 1
+ self.failUnless(wasHere, "exception test 3")
+
+ illegalArg = uno.getClass( "com.sun.star.lang.IllegalArgumentException" )
+ wasHere = 0
+ try:
+ self.tobj.raiseException( 1 , "foo" , self.tobj )
+ self.failUnless( 0 , "exception test 5a" )
+ except ioExc:
+ self.failUnless( 0 , "exception test 5b" )
+ except illegalArg, i:
+ self.failUnless( 1 == i.ArgumentPosition , "exception member test" )
+ self.failUnless( "foo" == i.Message , "exception member test 2 " )
+ wasHere = 1
+ else:
+ self.failUnless( 0, "except test 5c" )
+ self.failUnless( wasHere, "illegal argument exception test failed" )
+
+ def testInterface(self):
+ clazz = uno.getClass( "com.sun.star.lang.XComponent" )
+ self.failUnless( "com.sun.star.lang.XComponent" == clazz.__pyunointerface__ )
+ self.failUnless( issubclass( clazz, uno.getClass( "com.sun.star.uno.XInterface" ) ) )
+ self.tobj.Interface = None
+
+
+ def testOutparam( self):
+ # outparameter
+ struct, mybool,mychar,mybyte,myshort,myushort,mylong,myulong,myhyper,myuhyper,myfloat, \
+ mydouble,myenum,mystring,myinterface,myany,myseq,my2ndstruct = self.tobj.getValues( \
+ None,None,None,None,None,None,None,None,None,None, \
+ None,None,None,None,None,None,None)
+ self.failUnless(struct == self.tobj.Struct, "outparam 1 test")
+ self.failUnless(self.tobj.Bool, "outparam 2 test")
+ self.failUnless(mychar == self.tobj.Char, "outparam 3 test")
+ self.failUnless(mybyte == self.tobj.Byte, "outparam 4 test")
+ self.failUnless(myshort == self.tobj.Short, "outparam 5 test")
+ self.failUnless(myushort == self.tobj.UShort, "outparam 6 test")
+ self.failUnless(mylong == self.tobj.Long, "outparam 7 test")
+ self.failUnless(myulong == self.tobj.ULong, "outparam 8 test")
+ self.failUnless(myhyper == self.tobj.Hyper, "outparam 9 test")
+ self.failUnless(myuhyper == self.tobj.UHyper, "outparam 10 test")
+ self.failUnless(myfloat == self.tobj.Float, "outparam 11 test")
+ self.failUnless(mydouble == self.tobj.Double, "outparam 12 test")
+ self.failUnless(myenum == self.tobj.Enum, "outparam 13 test")
+ self.failUnless(mystring == self.tobj.String, "outparam 14 test")
+ self.failUnless(myinterface == self.tobj.Interface, "outparam 15 test")
+ self.failUnless(myany == self.tobj.Any, "outparam 16 test")
+ self.failUnless(myseq == self.tobj.Sequence, "outparam 17 test")
+ self.failUnless(my2ndstruct == struct, "outparam 18 test")
+
+# should work, debug on windows, why not
+# struct, mybool,mychar,mybyte,myshort,myushort,mylong,myulong,myhyper,myuhyper,myfloat,\
+# mydouble,myenum,mystring,myinterface,myany,myseq,my2ndstruct = self.tobj.setValues2( \
+# mybool,mychar,mybyte,myshort,myushort,mylong,myulong,myhyper,myuhyper,myfloat,\
+# mydouble,myenum,mystring,myinterface,myany,myseq,my2ndstruct)
+# self.failUnless(struct == self.tobj.Struct, "outparam 1 test")
+# self.failUnless( mybool and self.tobj.Bool, "outparam 2 test")
+# self.failUnless(mychar == self.tobj.Char, "outparam 3 test")
+# self.failUnless(mybyte == self.tobj.Byte, "outparam 4 test")
+# self.failUnless(myshort == self.tobj.Short, "outparam 5 test")
+# self.failUnless(myushort == self.tobj.UShort, "outparam 6 test")
+# self.failUnless(mylong == self.tobj.Long, "outparam 7 test")
+# self.failUnless(myulong == self.tobj.ULong, "outparam 8 test")
+# self.failUnless(myhyper == self.tobj.Hyper, "outparam 9 test")
+# self.failUnless(myuhyper == self.tobj.UHyper, "outparam 10 test")
+# self.failUnless(myfloat == self.tobj.Float, "outparam 11 test")
+# self.failUnless(mydouble == self.tobj.Double, "outparam 12 test")
+# self.failUnless(myenum == self.tobj.Enum, "outparam 13 test")
+# self.failUnless(mystring == self.tobj.String, "outparam 14 test")
+# self.failUnless(myinterface == self.tobj.Interface, "outparam 15 test")
+# self.failUnless(myany == self.tobj.Any, "outparam 16 test")
+# self.failUnless(myseq == self.tobj.Sequence, "outparam 17 test")
+# self.failUnless(my2ndstruct == struct, "outparam 18 test")
+
+ def testErrors( self ):
+
+ wasHere = 0
+ try:
+ self.tobj.a = 5
+ self.fail("attribute a shouldn't exist")
+ except AttributeError:
+ wasHere = 1
+ except IllegalArgumentException:
+ wasHere = 1
+ self.failUnless( wasHere, "wrong attribute test" )
+
+ IllegalArgumentException = uno.getClass("com.sun.star.lang.IllegalArgumentException" )
+ RuntimeException = uno.getClass("com.sun.star.uno.RuntimeException" )
+
+# TODO: Remove this once it is done
+# wrong number of arguments bug !?
+ self.failUnlessRaises( IllegalArgumentException, self.tobj.transportAny, 42, 43 )
+ self.failUnlessRaises( IllegalArgumentException, self.tobj.transportAny )
+ self.failUnlessRaises( RuntimeException, uno.getClass, "a.b" )
+ self.failUnlessRaises( RuntimeException, uno.getClass, "com.sun.star.uno.TypeClass" )
+
+ self.failUnlessRaises( RuntimeException, uno.Enum, "a" , "b" )
+ self.failUnlessRaises( RuntimeException, uno.Enum, "com.sun.star.uno.TypeClass" , "b" )
+ self.failUnlessRaises( RuntimeException, uno.Enum, "com.sun.star.uno.XInterface" , "b" )
+
+ tcInterface =uno.Enum( "com.sun.star.uno.TypeClass" , "INTERFACE" )
+ self.failUnlessRaises( RuntimeException, uno.Type, "a", tcInterface )
+ self.failUnlessRaises( RuntimeException, uno.Type, "com.sun.star.uno.Exception", tcInterface )
+
+ self.failUnlessRaises( (RuntimeException,exceptions.RuntimeError), uno.getTypeByName, "a" )
+
+ self.failUnlessRaises( (RuntimeException), uno.getConstantByName, "a" )
+ self.failUnlessRaises( (RuntimeException), uno.getConstantByName, "com.sun.star.uno.XInterface" )
+
+ def testByteSequence( self ):
+ s = uno.ByteSequence( b"ab" )
+ self.failUnless( s == uno.ByteSequence( b"ab" ) )
+ self.failUnless( uno.ByteSequence( b"abc" ) == s + uno.ByteSequence( b"c" ) )
+ self.failUnless( uno.ByteSequence( b"abc" ) == s + "c" )
+ self.failUnless( s + "c" == "abc" )
+ self.failUnless( s == uno.ByteSequence( s ) )
+ self.failUnless( s[0] == 'a' )
+ self.failUnless( s[1] == 'b' )
+
+
+ def testInvoke( self ):
+ self.failUnless( 5 == uno.invoke( self.tobj , "transportAny" , (uno.Any("byte", 5),) ) )
+ self.failUnless( 5 == uno.invoke(
+ PythonTransporter(), "transportAny" , (uno.Any( "byte", 5 ),) ) )
+ t = uno.getTypeByName( "long" )
+ mystruct = uno.createUnoStruct(
+ "com.sun.star.beans.PropertyValue", "foo",0,uno.Any(t,2),0 )
+ mystruct.Value = uno.Any(t, 1)
+
+
diff --git a/testtools/source/bridgetest/pyuno/impl.py b/testtools/source/bridgetest/pyuno/impl.py
new file mode 100644
index 000000000..7fe940424
--- /dev/null
+++ b/testtools/source/bridgetest/pyuno/impl.py
@@ -0,0 +1,187 @@
+#
+# This file is part of the LibreOffice project.
+#
+# This Source Code Form is subject to the terms of the Mozilla Public
+# License, v. 2.0. If a copy of the MPL was not distributed with this
+# file, You can obtain one at http://mozilla.org/MPL/2.0/.
+#
+# This file incorporates work covered by the following license notice:
+#
+# Licensed to the Apache Software Foundation (ASF) under one or more
+# contributor license agreements. See the NOTICE file distributed
+# with this work for additional information regarding copyright
+# ownership. The ASF licenses this file to you under the Apache
+# License, Version 2.0 (the "License"); you may not use this file
+# except in compliance with the License. You may obtain a copy of
+# the License at http://www.apache.org/licenses/LICENSE-2.0 .
+#
+"tests bridging python implementations of UNO objects"
+import unittest
+import uno
+import unohelper
+import os
+import sys
+
+from com.sun.star.io import XOutputStream, XInputStream, typeOfXOutputStream, typeOfXInputStream
+from com.sun.star.lang import XTypeProvider, typeOfXTypeProvider, XEventListener
+from com.sun.star.uno import XCurrentContext
+
+class SequenceOutputStream( unohelper.Base, XOutputStream ):
+ def __init__( self ):
+ self.s = uno.ByteSequence("")
+ self.closed = 0
+
+ def closeOutput(self):
+ self.closed = 1
+
+ def writeBytes( self, seq ):
+ self.s = self.s + seq
+
+ def flush( self ):
+ pass
+
+ def getSequence( self ):
+ return self.s
+
+
+class SequenceInputStream( XInputStream, unohelper.Base ):
+ def __init__( self, seq ):
+ self.s = seq
+ self.nIndex = 0
+ self.closed = 0
+
+ def closeInput( self):
+ self.closed = 1
+ self.s = None
+
+ def skipBytes( self, nByteCount ):
+ if( nByteCount + self.nIndex > len(self.s) ):
+ nByteCount = len(self.s) - self.nIndex
+ self.nIndex += nByteCount
+
+ def readBytes( self, retSeq, nByteCount ):
+ nRet = 0
+ if( self.nIndex + nByteCount > len(self.s) ):
+ nRet = len(self.s) - self.nIndex
+ else:
+ nRet = nByteCount
+ retSeq = uno.ByteSequence(self.s.value[self.nIndex : self.nIndex + nRet ])
+ self.nIndex = self.nIndex + nRet
+ return nRet, retSeq
+
+ def readSomeBytes( self, retSeq , nByteCount ):
+ #as we never block !
+ return readBytes( retSeq, nByteCount )
+
+ def available( self ):
+ return len( self.s ) - self.nIndex
+
+class SequenceInputStream2( SequenceInputStream ):
+ def __init__( self, seq ):
+ SequenceInputStream.__init__( self, seq )
+
+class TestCase(unittest.TestCase):
+ def __init__(self,method,ctx):
+ unittest.TestCase.__init__(self,method)
+ self.ctx = ctx
+
+ def setUp(self):
+ self.tobj = self.ctx.ServiceManager.createInstanceWithContext( \
+ "com.sun.star.test.bridge.CppTestObject",self.ctx)
+ self.pipe = self.ctx.ServiceManager.createInstanceWithContext( \
+ "com.sun.star.io.Pipe" , self.ctx )
+
+ def testStandard( self ):
+ dataOut = self.ctx.ServiceManager.createInstanceWithContext( \
+ "com.sun.star.io.DataOutputStream", self.ctx )
+ streamOut = SequenceOutputStream()
+ dataOut.setOutputStream( streamOut )
+ dataOut.writeShort( 42 )
+ dataOut.writeLong( 43 )
+ dataOut.closeOutput()
+
+ dataInput = self.ctx.ServiceManager.createInstanceWithContext( \
+ "com.sun.star.io.DataInputStream", self.ctx )
+
+ dataInput.setInputStream( SequenceInputStream2( streamOut.getSequence() ) )
+
+ self.failUnless( 42 == dataInput.readShort() )
+ self.failUnless( 43 == dataInput.readLong() )
+ self.failUnless( self.tobj.transportAny( streamOut ) == streamOut )
+
+
+class NullDevice:
+ def write( self, string ):
+ pass
+
+
+class EventListener( unohelper.Base, XEventListener ):
+ def __init__( self ):
+ self.disposingCalled = False
+
+ def disposing( self , eventObject ):
+ self.disposingCalled = True
+
+class TestHelperCase( unittest.TestCase ):
+
+ def __init__(self,method):
+ unittest.TestCase.__init__(self,method)
+
+ def testUrlHelper( self ):
+ systemPath = os.getcwd()
+ if systemPath.startswith( "/" ):
+ self.failUnless( "/tmp" == unohelper.fileUrlToSystemPath( "file:///tmp" ) )
+ self.failUnless( "file:///tmp" == unohelper.systemPathToFileUrl( "/tmp" ))
+ else:
+ self.failUnless( "c:\\temp" == unohelper.fileUrlToSystemPath( "file:///c:/temp" ) )
+ self.failUnless( "file:///c:/temp" == unohelper.systemPathToFileUrl( "c:\\temp" ) )
+
+ systemPath = unohelper.systemPathToFileUrl( systemPath )
+ self.failUnless( systemPath + "/a" == unohelper.absolutize( systemPath, "a" ) )
+ def testInspect( self ):
+ dev = NullDevice()
+# dev = sys.stdout
+ unohelper.inspect( uno.getComponentContext() , dev )
+ unohelper.inspect( uno.getComponentContext().ServiceManager , dev )
+ unohelper.inspect( uno.getTypeByName( "com.sun.star.lang.XComponent" ) , dev )
+
+ def testListener( self ):
+ smgr = uno.getComponentContext().ServiceManager.createInstance(
+ "com.sun.star.lang.ServiceManager" )
+
+ # check, whether listeners
+ listener = EventListener()
+ smgr.addEventListener( listener )
+ smgr.dispose()
+ self.failUnless( listener.disposingCalled )
+
+ # check, whether listeners can be removed
+ smgr = uno.getComponentContext().ServiceManager.createInstance(
+ "com.sun.star.lang.ServiceManager" )
+ listener = EventListener()
+ smgr.addEventListener( listener )
+ smgr.removeEventListener( listener )
+ smgr.dispose()
+ self.failUnless( not listener.disposingCalled )
+
+ def testCurrentContext( self ):
+ oldContext = uno.getCurrentContext()
+ try:
+ uno.setCurrentContext(
+ unohelper.CurrentContext( oldContext,{"My42":42}) )
+ self.failUnless( 42 == uno.getCurrentContext().getValueByName( "My42" ) )
+ self.failUnless( None == uno.getCurrentContext().getValueByName( "My43" ) )
+ finally:
+ uno.setCurrentContext( oldContext )
+
+
+
+def suite( ctx ):
+ suite = unittest.TestSuite()
+ suite.addTest(TestCase("testStandard",ctx))
+ suite.addTest(TestHelperCase( "testUrlHelper" ))
+ suite.addTest(TestHelperCase( "testInspect" ))
+ suite.addTest(TestHelperCase( "testListener" ) )
+ suite.addTest(TestHelperCase( "testCurrentContext" ) )
+ return suite
+
diff --git a/testtools/source/bridgetest/pyuno/importer.py b/testtools/source/bridgetest/pyuno/importer.py
new file mode 100644
index 000000000..c4ce8c175
--- /dev/null
+++ b/testtools/source/bridgetest/pyuno/importer.py
@@ -0,0 +1,69 @@
+#
+# This file is part of the LibreOffice project.
+#
+# This Source Code Form is subject to the terms of the Mozilla Public
+# License, v. 2.0. If a copy of the MPL was not distributed with this
+# file, You can obtain one at http://mozilla.org/MPL/2.0/.
+#
+# This file incorporates work covered by the following license notice:
+#
+# Licensed to the Apache Software Foundation (ASF) under one or more
+# contributor license agreements. See the NOTICE file distributed
+# with this work for additional information regarding copyright
+# ownership. The ASF licenses this file to you under the Apache
+# License, Version 2.0 (the "License"); you may not use this file
+# except in compliance with the License. You may obtain a copy of
+# the License at http://www.apache.org/licenses/LICENSE-2.0 .
+#
+import unittest
+import uno
+import unohelper
+
+from com.sun.star.lang import EventObject,IllegalArgumentException,typeOfIllegalArgumentException
+from test.testtools.bridgetest.TestEnum import TWO
+from com.sun.star.uno.TypeClass import UNSIGNED_LONG,EXCEPTION
+class ImporterTestCase(unittest.TestCase):
+ def __init__(self,method,ctx):
+ unittest.TestCase.__init__(self,method)
+ self.ctx = ctx
+
+ def setUp(self):
+ self.tobj = self.ctx.ServiceManager.createInstanceWithContext( \
+ "com.sun.star.test.bridge.CppTestObject",self.ctx)
+
+ def testStandard( self ):
+ self.failUnless( IllegalArgumentException != None, "none-test" )
+ self.failUnlessRaises( IllegalArgumentException, self.tobj.raiseException, 1,"foo",self.tobj)
+
+ self.failUnless( TWO == uno.Enum( "test.testtools.bridgetest.TestEnum","TWO"), "enum" )
+ self.failUnless( UNSIGNED_LONG == uno.Enum( "com.sun.star.uno.TypeClass", "UNSIGNED_LONG" ) )
+ self.failUnless( typeOfIllegalArgumentException ==
+ uno.Type( "com.sun.star.lang.IllegalArgumentException", EXCEPTION) )
+
+ # should not throw an exception
+ e = EventObject()
+ e.Source = self.ctx
+ e = EventObject( self.ctx )
+ e = EventObject( e )
+
+ def testDynamicComponentRegistration( self ):
+ ctx = uno.getComponentContext()
+ self.failUnless(
+ not ("com.sun.star.connection.Acceptor" in ctx.ServiceManager.getAvailableServiceNames()),
+ "precondition for dynamic component registration test is not fulfilled" )
+ self.failUnless(
+ not ("com.sun.star.connection.Connector" in ctx.ServiceManager.getAvailableServiceNames()),
+ "precondition for dynamic component registration test is not fulfilled" )
+ unohelper.addComponentsToContext(
+ ctx , ctx, ("acceptor.uno","connector.uno"), "com.sun.star.loader.SharedLibrary" )
+ self.failUnless(
+ ("com.sun.star.connection.Acceptor" in ctx.ServiceManager.getAvailableServiceNames()) )
+ self.failUnless(
+ ("com.sun.star.connection.Connector" in ctx.ServiceManager.getAvailableServiceNames()))
+
+def suite( ctx ):
+ suite = unittest.TestSuite()
+ suite.addTest(ImporterTestCase("testStandard",ctx))
+ suite.addTest(ImporterTestCase("testDynamicComponentRegistration",ctx))
+ return suite
+
diff --git a/testtools/source/bridgetest/pyuno/main.py b/testtools/source/bridgetest/pyuno/main.py
new file mode 100644
index 000000000..9dc101a2e
--- /dev/null
+++ b/testtools/source/bridgetest/pyuno/main.py
@@ -0,0 +1,40 @@
+#
+# This file is part of the LibreOffice project.
+#
+# This Source Code Form is subject to the terms of the Mozilla Public
+# License, v. 2.0. If a copy of the MPL was not distributed with this
+# file, You can obtain one at http://mozilla.org/MPL/2.0/.
+#
+# This file incorporates work covered by the following license notice:
+#
+# Licensed to the Apache Software Foundation (ASF) under one or more
+# contributor license agreements. See the NOTICE file distributed
+# with this work for additional information regarding copyright
+# ownership. The ASF licenses this file to you under the Apache
+# License, Version 2.0 (the "License"); you may not use this file
+# except in compliance with the License. You may obtain a copy of
+# the License at http://www.apache.org/licenses/LICENSE-2.0 .
+#
+import uno
+import unohelper
+import importer
+import unittest
+import core
+import impl
+import os
+import sys
+
+ctx = uno.getComponentContext()
+# needed for the tests
+unohelper.addComponentsToContext(ctx,ctx,(os.environ["FOO"]+"/cppobj.uno",os.environ["FOO"]+"/bridgetest.uno","streams.uno","bootstrap.uno"),"com.sun.star.loader.SharedLibrary")
+
+unohelper.addComponentsToContext(ctx,ctx,("vnd.openoffice.pymodule:samplecomponent",),"com.sun.star.loader.Python")
+
+runner = unittest.TextTestRunner(sys.stderr,1,2)
+
+suite = unittest.TestSuite()
+suite.addTest(importer.suite(ctx))
+suite.addTest(core.suite(ctx))
+suite.addTest(impl.suite(ctx))
+
+runner.run(suite)
diff --git a/testtools/source/bridgetest/pyuno/makefile.mk b/testtools/source/bridgetest/pyuno/makefile.mk
new file mode 100644
index 000000000..112be23c9
--- /dev/null
+++ b/testtools/source/bridgetest/pyuno/makefile.mk
@@ -0,0 +1,117 @@
+#
+# This file is part of the LibreOffice project.
+#
+# This Source Code Form is subject to the terms of the Mozilla Public
+# License, v. 2.0. If a copy of the MPL was not distributed with this
+# file, You can obtain one at http://mozilla.org/MPL/2.0/.
+#
+# This file incorporates work covered by the following license notice:
+#
+# Licensed to the Apache Software Foundation (ASF) under one or more
+# contributor license agreements. See the NOTICE file distributed
+# with this work for additional information regarding copyright
+# ownership. The ASF licenses this file to you under the Apache
+# License, Version 2.0 (the "License"); you may not use this file
+# except in compliance with the License. You may obtain a copy of
+# the License at http://www.apache.org/licenses/LICENSE-2.0 .
+#
+
+PRJ=..$/..$/..
+
+PRJNAME=pyuno
+TARGET=test
+LIBTARGET=NO
+TARGETTYPE=CUI
+ENABLE_EXCEPTIONS=TRUE
+
+my_components = pythonloader
+
+# --- Settings -----------------------------------------------------
+
+.INCLUDE : settings.mk
+
+.IF "$(CROSS_COMPILING)"=="YES"
+
+all:
+# nothing
+
+.ENDIF
+
+# --- Files --------------------------------------------------------
+.IF "$(DISABLE_PYTHON)" != "TRUE"
+.IF "$(L10N_framework)"==""
+PYEXC=$(DLLDEST)$/python$(EXECPOST)
+REGEXC=$(DLLDEST)$/regcomp$(EXECPOST)
+
+.IF "$(SYSTEM_PYTHON)"!="YES"
+PYTHON=$(AUGMENT_LIBRARY_PATH) $(WRAPCMD) $(SOLARBINDIR)/python
+.ELSE # "$(SYSTEM_PYTHON)"!="YES"
+PYTHON=$(AUGMENT_LIBRARY_PATH) $(WRAPCMD) $(PYTHON_FOR_BUILD)
+.ENDIF # "$(SYSTEM_PYTHON)"!="YES"
+.IF "$(OS)"=="WNT"
+PYTHONPATH:=$(SOLARLIBDIR)$/pyuno;$(PWD);$(SOLARLIBDIR);$(SOLARLIBDIR)$/python;$(SOLARLIBDIR)$/python$/lib-dynload
+.ELSE # "$(OS)"=="WNT"
+PYTHONPATH:=$(SOLARLIBDIR)$/pyuno:$(PWD):$(SOLARLIBDIR):$(SOLARLIBDIR)$/python:$(SOLARLIBDIR)$/python$/lib-dynload
+.ENDIF # "$(OS)"=="WNT"
+.EXPORT: PYTHONPATH
+
+.IF "$(OS)"!="WNT"
+TEST_ENV=export FOO=file://$(shell @pwd)$/$(DLLDEST) \
+ UNO_TYPES=uno_types.rdb UNO_SERVICES=pyuno_services.rdb
+.ELSE # "$(OS)" != "WNT"
+# aaaaaa, how to get the current working directory on windows ???
+CWD_TMP=$(strip $(shell @echo "import os;print os.getcwd()" | $(PYTHON)))
+TEST_ENV=export FOO=file:///$(strip $(subst,\,/ $(CWD_TMP)$/$(DLLDEST))) && \
+ export UNO_TYPES=uno_types.rdb && export UNO_SERVICES=pyuno_services.rdb
+.ENDIF # "$(OS)"!="WNT"
+PYFILES = \
+ $(DLLDEST)$/core.py \
+ $(DLLDEST)$/importer.py \
+ $(DLLDEST)$/main.py \
+ $(DLLDEST)$/impl.py \
+ $(DLLDEST)$/samplecomponent.py \
+ $(DLLDEST)$/testcomp.py \
+
+PYCOMPONENTS = \
+ samplecomponent
+
+ALL : \
+ $(PYFILES) \
+ $(DLLDEST)/pyuno_services.rdb \
+ doc \
+ ALLTAR
+.ENDIF # L10N_framework
+.ENDIF # DISABLE_PYTHON
+
+.INCLUDE : target.mk
+
+.IF "$(DISABLE_PYTHON)" != "TRUE"
+.IF "$(L10N_framework)"==""
+$(DLLDEST)$/%.py: %.py
+ cp $? $@
+
+$(DLLDEST)$/python$(EXECPOST) : $(SOLARBINDIR)$/python$(EXECPOST)
+ cp $? $@
+
+$(DLLDEST)$/regcomp$(EXECPOST) : $(SOLARBINDIR)$/regcomp$(EXECPOST)
+ cp $? $@
+
+$(DLLDEST)$/pyuno_services.rdb .ERRREMOVE : \
+ $(SOLARENV)/bin/packcomponents.xslt $(MISC)/pyuno_services.input \
+ $(my_components:^"$(SOLARXMLDIR)/":+".component")
+ $(XSLTPROC) --nonet --stringparam prefix $(SOLARXMLDIR)/ -o $@ \
+ $(SOLARENV)/bin/packcomponents.xslt $(MISC)/pyuno_services.input
+
+$(MISC)/pyuno_services.input :
+ echo \
+ '<list>$(my_components:^"<filename>":+".component</filename>")</list>' \
+ > $@
+
+doc .PHONY:
+ @echo start test with dmake runtest
+
+runtest : ALL
+ cd $(DLLDEST) && $(TEST_ENV) && $(PYTHON) main.py
+.ENDIF # L10N_framework
+.ENDIF # DISABLE_PYTHON
+
diff --git a/testtools/source/bridgetest/pyuno/pyuno b/testtools/source/bridgetest/pyuno/pyuno
new file mode 100644
index 000000000..cf2da2cad
--- /dev/null
+++ b/testtools/source/bridgetest/pyuno/pyuno
@@ -0,0 +1,2 @@
+UNO_TYPES=uno_types.rdb
+UNO_SERVICES=pyuno_services.rdb
diff --git a/testtools/source/bridgetest/pyuno/samplecomponent.py b/testtools/source/bridgetest/pyuno/samplecomponent.py
new file mode 100644
index 000000000..4778a7602
--- /dev/null
+++ b/testtools/source/bridgetest/pyuno/samplecomponent.py
@@ -0,0 +1,189 @@
+#
+# This file is part of the LibreOffice project.
+#
+# This Source Code Form is subject to the terms of the Mozilla Public
+# License, v. 2.0. If a copy of the MPL was not distributed with this
+# file, You can obtain one at http://mozilla.org/MPL/2.0/.
+#
+# This file incorporates work covered by the following license notice:
+#
+# Licensed to the Apache Software Foundation (ASF) under one or more
+# contributor license agreements. See the NOTICE file distributed
+# with this work for additional information regarding copyright
+# ownership. The ASF licenses this file to you under the Apache
+# License, Version 2.0 (the "License"); you may not use this file
+# except in compliance with the License. You may obtain a copy of
+# the License at http://www.apache.org/licenses/LICENSE-2.0 .
+#
+import uno
+import unohelper
+
+from com.sun.star.lang import IllegalArgumentException,XServiceInfo
+from com.sun.star.uno import RuntimeException
+from com.sun.star.beans import UnknownPropertyException
+from test.testtools.bridgetest import TestData,XRecursiveCall,XBridgeTestBase
+
+g_ImplementationHelper = unohelper.ImplementationHelper()
+g_implName = "org.openoffice.comp.pyuno.PythonTestObject"
+
+g_attribs = "RuntimeException", "Bool", "Char", "Byte", "Short", "UShort", \
+ "Long", "ULong", "Hyper", "UHyper", "Float", "Double", "Enum", \
+ "String", "Interface", "Any" , "Sequence" , "Struct"
+
+def assign( rData, bBool, cChar, nByte, nShort, nUShort, nLong, nULong, nHyper,\
+ nUHyper, fFloat, fDouble, eEnum, rStr, xTest, rAny ):
+ rData.Bool = bBool;
+ rData.Char = cChar;
+ rData.Byte = nByte;
+ rData.Short = nShort;
+ rData.UShort = nUShort;
+ rData.Long = nLong;
+ rData.ULong = nULong;
+ rData.Hyper = nHyper;
+ rData.UHyper = nUHyper;
+ rData.Float = fFloat;
+ rData.Double = fDouble;
+ rData.Enum = eEnum;
+ rData.String = rStr;
+ rData.Interface = xTest;
+ rData.Any = rAny;
+
+class MyRecursiveCall( XRecursiveCall, unohelper.Base ):
+ def callRecursivly( xCall, nToCall ):
+ if nToCall:
+ xCall.callRecursivly( self, nToCall -1 )
+
+class SampleUnoComponent( XBridgeTestBase,XServiceInfo ):
+ def __init__(self,ctx):
+ self.__dict__["callid"] = 0
+ self.__dict__["sequenceBroken"] = 0
+
+ def transportAny( self, value ):
+ return value
+
+ def raiseException( self, ArgumentPosition, Message, Context ):
+ raise IllegalArgumentException( Message, Context, ArgumentPosition )
+
+ def raiseRuntimeExceptionOneway(self, Message, Context ):
+ raise RuntimeException( Message, Context )
+
+ def setValues( self, \
+ bBool, \
+ cChar, \
+ nByte, \
+ nShort, \
+ nUShort, \
+ nLong, \
+ nULong, \
+ nHyper, \
+ nUHyper, \
+ fFloat, \
+ fDouble, \
+ eEnum, \
+ aString, \
+ xInterface, \
+ aAny, \
+ aSequence, \
+ aStruct ):
+ self.__dict__["data"] = TestDataElements( bBool, cChar, nByte, nShort, nUShort, nLong,
+ nULong, nHyper, nUHyper, fFloat, fDouble, eEnum, aStruct, xInterface,
+ aAny, aSequence )
+ self.__dict__["Struct"] = aStruct
+
+ def setValues2( self, \
+ bBool, \
+ cChar, \
+ nByte, \
+ nShort, \
+ nUShort, \
+ nLong, \
+ nULong,\
+ nHyper, \
+ nUHyper, \
+ fFloat, \
+ fDouble, \
+ eEnum, \
+ aString, \
+ xInterface, \
+ aAny, \
+ aSequence, \
+ aStruct ):
+ self.__dict__["Struct"] = TestData( cChar, nByte, nShort, nUShort, nLong, nULong, nHyper,\
+ nUHyper, fFloat, fDouble, eEnum, aStruct, xInterface,\
+ aAny, aSequence )
+ self.__dict__["Struct"] = aStruct
+ return bBool, cChar, nByte, nShort, nUShort, nLong, nULong, nHyper, nUHyper, nULong, \
+ nHyper, nUHyper, fFloat, fDouble, eEnum, aStruct, xInterface, aAny, \
+ (aSequence[1],aSequence[0]), aStruct
+
+ def getValues(self, \
+ a, \
+ b, \
+ c, \
+ d, \
+ e, \
+ f, \
+ g, \
+ h, \
+ i, \
+ j, \
+ k, \
+ l, \
+ m, \
+ n):
+ v = self.__dict__["data"]
+ return self.__dict__["Struct"],v.Bool, v.Char, v.Byte, v.Short, v.UShort, v.Long, \
+ v.ULong, v.Hyper, v.UHyper, v.Float, v.Double, v.Enum, v.String, v.Interface, \
+ v.Any, v.Sequence, self.__dict__["Struct"]
+
+ def call( self, callid, nWaitMUSEC ):
+ if self.__dict__["callid"] >= callid:
+ self.__dict__["sequenceBroken"] = 1
+ else:
+ self.__dict__["callid"] = callid
+
+ def callOneway( self, nCallId, nWaitMUSEC ):
+ call( nCallId, nWaitMUSEC )
+
+ def sequenceOfCallTestPassed():
+ return self.__dict__["sequenceBroken"]
+
+ def startRecursiveCall( xCall , nToCall ):
+ if nToCall:
+ xCall.callRecursivly( MyRecursiveCall(), nToCall -1 )
+
+ def checkExistence( self, name ):
+ found = 0
+ for x in g_attribs:
+ if x == name:
+ found = 1
+ break
+ if not found:
+ raise UnknownPropertyException( "Property "+name+" is unknown", self )
+
+ def __setattr__( self, name, value ):
+ checkExistence( name )
+ self.__dict__[name] = value
+
+ def __getattr__( self, name ):
+ checkExistence( name )
+ return self.__dict__[name]
+
+ def getSupportedServices( self ):
+ return g_ImplementationHelper.getSupportedServices(g_implName)
+ def supportsService( self, ServiceName ):
+ return g_ImplementationHelper.supportsService( g_implName, ServiceName )
+ def getImplementationName(self):
+ return g_implName
+
+
+g_ImplementationHelper.addImplementation( \
+ SampleUnoComponent,g_implName,("com.sun.star.test.bridge.PythonTestObject",),)
+
+#g_ImplementationEntries = \
+# unohelper.ImplementationEntry( \
+# "org.openoffice.comp.SamplePythonComponent", \
+# ("com.sun.star.test.bridge.PythonTestObject",), \
+# SampleUnoComponent) \
+# ,
+
diff --git a/testtools/source/bridgetest/pyuno/testcomp.py b/testtools/source/bridgetest/pyuno/testcomp.py
new file mode 100644
index 000000000..e519d5e8e
--- /dev/null
+++ b/testtools/source/bridgetest/pyuno/testcomp.py
@@ -0,0 +1,31 @@
+#
+# This file is part of the LibreOffice project.
+#
+# This Source Code Form is subject to the terms of the Mozilla Public
+# License, v. 2.0. If a copy of the MPL was not distributed with this
+# file, You can obtain one at http://mozilla.org/MPL/2.0/.
+#
+# This file incorporates work covered by the following license notice:
+#
+# Licensed to the Apache Software Foundation (ASF) under one or more
+# contributor license agreements. See the NOTICE file distributed
+# with this work for additional information regarding copyright
+# ownership. The ASF licenses this file to you under the Apache
+# License, Version 2.0 (the "License"); you may not use this file
+# except in compliance with the License. You may obtain a copy of
+# the License at http://www.apache.org/licenses/LICENSE-2.0 .
+#
+import uno
+import pythonloader
+
+ctx = uno.getComponentContext()
+
+loader = pythonloader.Loader( ctx )
+comp = loader.activate( "org.openoffice.comp.pyuno.PythonTestObject" , "", "samplecomponent", ctx )
+ctx.ServiceManager.insert( comp)
+
+bridgetest = ctx.ServiceManager.createInstanceWithContext( "com.sun.star.test.bridge.BridgeTest", ctx )
+#bridgetest.run( "com.sun.star.test.bridge.PythonTestObject" )
+
+
+
diff --git a/testtools/source/bridgetest/testComponent.component b/testtools/source/bridgetest/testComponent.component
new file mode 100644
index 000000000..e488f702d
--- /dev/null
+++ b/testtools/source/bridgetest/testComponent.component
@@ -0,0 +1,29 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+ * This file is part of the LibreOffice project.
+ *
+ * This Source Code Form is subject to the terms of the Mozilla Public
+ * License, v. 2.0. If a copy of the MPL was not distributed with this
+ * file, You can obtain one at http://mozilla.org/MPL/2.0/.
+ *
+ * This file incorporates work covered by the following license notice:
+ *
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed
+ * with this work for additional information regarding copyright
+ * ownership. The ASF licenses this file to you under the Apache
+ * License, Version 2.0 (the "License"); you may not use this file
+ * except in compliance with the License. You may obtain a copy of
+ * the License at http://www.apache.org/licenses/LICENSE-2.0 .
+ -->
+
+<component loader="com.sun.star.loader.Java2"
+ xmlns="http://openoffice.org/2010/uno-components">
+ <implementation
+ name="com.sun.star.comp.bridge.TestComponent$_PerformancTestObject">
+ <service name="com.sun.star.comp.benchmark.JavaTestObject"/>
+ </implementation>
+ <implementation name="com.sun.star.comp.bridge.TestComponent$_TestObject">
+ <service name="com.sun.star.test.bridge.JavaTestObject"/>
+ </implementation>
+</component>