summaryrefslogtreecommitdiffstats
path: root/testtools/source/bridgetest/cli
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/cli
parentInitial commit. (diff)
downloadlibreoffice-ed5640d8b587fbcfed7dd7967f3de04b37a76f26.tar.xz
libreoffice-ed5640d8b587fbcfed7dd7967f3de04b37a76f26.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 'testtools/source/bridgetest/cli')
-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
8 files changed, 4878 insertions, 0 deletions
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