1cdf0e10cSrcweir'*************************************************************************
2cdf0e10cSrcweir'
3*2f3df0e5SAndrew Rist'  Licensed to the Apache Software Foundation (ASF) under one
4*2f3df0e5SAndrew Rist'  or more contributor license agreements.  See the NOTICE file
5*2f3df0e5SAndrew Rist'  distributed with this work for additional information
6*2f3df0e5SAndrew Rist'  regarding copyright ownership.  The ASF licenses this file
7*2f3df0e5SAndrew Rist'  to you under the Apache License, Version 2.0 (the
8*2f3df0e5SAndrew Rist'  "License"); you may not use this file except in compliance
9*2f3df0e5SAndrew Rist'  with the License.  You may obtain a copy of the License at
10*2f3df0e5SAndrew Rist'
11*2f3df0e5SAndrew Rist'    http://www.apache.org/licenses/LICENSE-2.0
12*2f3df0e5SAndrew Rist'
13*2f3df0e5SAndrew Rist'  Unless required by applicable law or agreed to in writing,
14*2f3df0e5SAndrew Rist'  software distributed under the License is distributed on an
15*2f3df0e5SAndrew Rist'  "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
16*2f3df0e5SAndrew Rist'  KIND, either express or implied.  See the License for the
17*2f3df0e5SAndrew Rist'  specific language governing permissions and limitations
18*2f3df0e5SAndrew Rist'  under the License.
19cdf0e10cSrcweir'
20cdf0e10cSrcweir'*************************************************************************
21cdf0e10cSrcweir
22cdf0e10cSrcweir
23cdf0e10cSrcweir
24*2f3df0e5SAndrew Rist
25*2f3df0e5SAndrew Rist
26cdf0e10cSrcweirOption Explicit On
27cdf0e10cSrcweirOption Strict On
28cdf0e10cSrcweir
29cdf0e10cSrcweirimports System
30cdf0e10cSrcweirimports uno
31cdf0e10cSrcweirimports uno.util
32cdf0e10cSrcweirimports unoidl.com.sun.star.lang
33cdf0e10cSrcweirimports unoidl.com.sun.star.uno
34cdf0e10cSrcweir'imports unoidl.com.sun.star.test.bridge
35cdf0e10cSrcweirimports unoidl.test.testtools.bridgetest
36cdf0e10cSrcweirimports System.Windows.Forms
37cdf0e10cSrcweirimports System.Diagnostics
38cdf0e10cSrcweirimports System.Reflection
39cdf0e10cSrcweir
40cdf0e10cSrcweirClass CONSTANTS
41cdf0e10cSrcweirFriend Shared STRING_TEST_CONSTANT As String  = """ paco\' chorizo\\\' ""\'"
42cdf0e10cSrcweirEnd Class
43cdf0e10cSrcweir
44cdf0e10cSrcweirNamespace foo
45cdf0e10cSrcweir
46cdf0e10cSrcweir    Public Interface MyInterface
47cdf0e10cSrcweir    End Interface
48cdf0e10cSrcweirEnd Namespace
49cdf0e10cSrcweir
50cdf0e10cSrcweirNamespace vb_bridetest
51cdf0e10cSrcweirClass ORecursiveCall
52cdf0e10cSrcweir    Inherits WeakBase
53cdf0e10cSrcweir    Implements XRecursiveCall
54cdf0e10cSrcweir
55cdf0e10cSrcweir    Overridable Sub callRecursivly(xCall As XRecursiveCall, nToCall As Integer) _
56cdf0e10cSrcweir    Implements XRecursiveCall.callRecursivly
57cdf0e10cSrcweir		SyncLock Me
58cdf0e10cSrcweir            If nToCall > 0
59cdf0e10cSrcweir                nToCall = nToCall - 1
60cdf0e10cSrcweir                xCall.callRecursivly(Me, nToCall)
61cdf0e10cSrcweir            End If
62cdf0e10cSrcweir       End SyncLock
63cdf0e10cSrcweir    End Sub
64cdf0e10cSrcweirEnd Class
65cdf0e10cSrcweir
66cdf0e10cSrcweir
67cdf0e10cSrcweir
68cdf0e10cSrcweir
69cdf0e10cSrcweirPublic Class BridgeTest
70cdf0e10cSrcweir       Inherits uno.util.WeakBase
71cdf0e10cSrcweir       Implements XMain
72cdf0e10cSrcweir
73cdf0e10cSrcweir    Private m_xContext As XComponentContext
74cdf0e10cSrcweir
75cdf0e10cSrcweir    Public Sub New( xContext As unoidl.com.sun.star.uno.XComponentContext )
76cdf0e10cSrcweir        mybase.New()
77cdf0e10cSrcweir        m_xContext = xContext
78cdf0e10cSrcweir    End Sub
79cdf0e10cSrcweir
80cdf0e10cSrcweir    Private Shared Function check( b As Boolean , message As String  ) As Boolean
81cdf0e10cSrcweir        If Not b
82cdf0e10cSrcweir            Console.WriteLine("{0} failed\n" , message)
83cdf0e10cSrcweir        End If
84cdf0e10cSrcweir        Return b
85cdf0e10cSrcweir    End Function
86cdf0e10cSrcweir
87cdf0e10cSrcweir    Private Shared Sub assign( rData As TestElement, bBool As Boolean, _
88cdf0e10cSrcweir			aChar As Char, nByte As Byte, nShort As Short, nUShort As UInt16, _
89cdf0e10cSrcweir					nLong As Integer, nULong As UInt32, nHyper As Long, _
90cdf0e10cSrcweir                    nUHyper As UInt64, fFloat As Single, fDouble As Double, _
91cdf0e10cSrcweir					eEnum As TestEnum, rStr As String, xTest As Object, _
92cdf0e10cSrcweir					rAny As Any)
93cdf0e10cSrcweir
94cdf0e10cSrcweir    	rData.Bool = bBool
95cdf0e10cSrcweir	    rData.Char = aChar
96cdf0e10cSrcweir	    rData.Byte = nByte
97cdf0e10cSrcweir	    rData.Short = nShort
98cdf0e10cSrcweir	    rData.UShort = nUShort
99cdf0e10cSrcweir	    rData.Long = nLong
100cdf0e10cSrcweir	    rData.ULong = nULong
101cdf0e10cSrcweir	    rData.Hyper = nHyper
102cdf0e10cSrcweir	    rData.UHyper = nUHyper
103cdf0e10cSrcweir	    rData.Float = fFloat
104cdf0e10cSrcweir	    rData.Double = fDouble
105cdf0e10cSrcweir	    rData.Enum = eEnum
106cdf0e10cSrcweir	    rData.String = rStr
107cdf0e10cSrcweir	    rData.Interface = xTest
108cdf0e10cSrcweir	    rData.Any = rAny
109cdf0e10cSrcweir    End Sub
110cdf0e10cSrcweir
111cdf0e10cSrcweir    Private Shared Sub assign( rData As TestDataElements, bBool As Boolean, _
112cdf0e10cSrcweir            aChar As Char, nByte As Byte, nShort As Short, nUShort As UInt16, _
113cdf0e10cSrcweir			nLong As Integer, nULong As UInt32, nHyper As Long, _
114cdf0e10cSrcweir            nUHyper As UInt64, fFloat As Single, fDouble As Double, _
115cdf0e10cSrcweir    		eEnum As TestEnum, rStr As String, xTest As Object, _
116cdf0e10cSrcweir			rAny As Any, rSequence() As TestElement)
117cdf0e10cSrcweir
118cdf0e10cSrcweir    	assign( DirectCast( rData,TestElement), _
119cdf0e10cSrcweir			bBool, aChar, nByte, nShort, nUShort, nLong, nULong, nHyper, _
120cdf0e10cSrcweir            nUHyper, fFloat, fDouble, eEnum, rStr, xTest, rAny )
121cdf0e10cSrcweir	    rData.Sequence = rSequence
122cdf0e10cSrcweir    End Sub
123cdf0e10cSrcweir
124cdf0e10cSrcweir	Private Shared Function compareData(val1 As Object, val2 As Object) As Boolean
125cdf0e10cSrcweir		If val1 Is Nothing And val2 Is Nothing OrElse _
126cdf0e10cSrcweir            val1 Is val2
127cdf0e10cSrcweir			Return True
128cdf0e10cSrcweir        End If
129cdf0e10cSrcweir		If  val1 Is Nothing And Not(val2 Is Nothing)  OrElse _
130cdf0e10cSrcweir		    Not (val1 Is Nothing) And val2 Is Nothing OrElse _
131cdf0e10cSrcweir            Not val1.GetType().Equals( val2.GetType())
132cdf0e10cSrcweir			Return False
133cdf0e10cSrcweir		End If
134cdf0e10cSrcweir
135cdf0e10cSrcweir		Dim ret As Boolean = False
136cdf0e10cSrcweir		Dim t1 As Type = val1.GetType()
137cdf0e10cSrcweir        'Sequence
138cdf0e10cSrcweir		If t1.IsArray()
139cdf0e10cSrcweir			ret = compareSequence(DirectCast( val1, Array), _
140cdf0e10cSrcweir                  DirectCast( val2, Array))
141cdf0e10cSrcweir		'String
142cdf0e10cSrcweir		ElseIf TypeOf val1 Is String
143cdf0e10cSrcweir			ret = DirectCast( val1, string) = DirectCast( val2, string)
144cdf0e10cSrcweir		' Interface implementation
145cdf0e10cSrcweir		ElseIf t1.GetInterfaces().Length > 0 And Not t1.IsValueType
146cdf0e10cSrcweir			ret = val1 Is val2
147cdf0e10cSrcweir		' Struct
148cdf0e10cSrcweir		ElseIf  Not t1.IsValueType
149cdf0e10cSrcweir			ret = compareStruct(val1, val2)
150cdf0e10cSrcweir		ElseIf TypeOf val1 Is Any
151cdf0e10cSrcweir			Dim a1 As Any = DirectCast( val1, Any)
152cdf0e10cSrcweir			Dim a2 As Any = DirectCast( val2, Any)
153cdf0e10cSrcweir			ret = a1.Type.Equals( a2.Type ) And compareData( a1.Value, a2.Value )
154cdf0e10cSrcweir		ElseIf t1.IsValueType
155cdf0e10cSrcweir			'Any, enum, int, bool char, float, double etc.
156cdf0e10cSrcweir			ret = val1.Equals(val2)
157cdf0e10cSrcweir		Else
158cdf0e10cSrcweir			Debug.Assert(False)
159cdf0e10cSrcweir		End If
160cdf0e10cSrcweir		Return ret
161cdf0e10cSrcweir	End Function
162cdf0e10cSrcweir
163cdf0e10cSrcweir	' Arrays have only one dimension
164cdf0e10cSrcweir	Private Shared Function compareSequence( ar1 As Array, ar2 As Array) As Boolean
165cdf0e10cSrcweir		Debug.Assert( Not (ar1 Is Nothing) And Not (ar2 Is Nothing) )
166cdf0e10cSrcweir		Dim t1 As Type  = ar1.GetType()
167cdf0e10cSrcweir		Dim t2 As Type  = ar2.GetType()
168cdf0e10cSrcweir
169cdf0e10cSrcweir		if ( Not(ar1.Rank = 1 And ar2.Rank = 1 _
170cdf0e10cSrcweir			And ar1.Length = ar2.Length And t1.GetElementType().Equals(t2.GetElementType())))
171cdf0e10cSrcweir			return False
172cdf0e10cSrcweir        End If
173cdf0e10cSrcweir		'arrays have same rank and size and element type.
174cdf0e10cSrcweir		Dim len As Integer  = ar1.Length
175cdf0e10cSrcweir		Dim elemType As Type = t1.GetElementType()
176cdf0e10cSrcweir		Dim ret As Boolean = True
177cdf0e10cSrcweir        Dim i As Integer
178cdf0e10cSrcweir		For i = 0 To len - 1
179cdf0e10cSrcweir			If (compareData(ar1.GetValue(i), ar2.GetValue(i)) = False)
180cdf0e10cSrcweir				ret = False
181cdf0e10cSrcweir				Exit For
182cdf0e10cSrcweir			End If
183cdf0e10cSrcweir		Next i
184cdf0e10cSrcweir
185cdf0e10cSrcweir        Return ret
186cdf0e10cSrcweir	End Function
187cdf0e10cSrcweir
188cdf0e10cSrcweir	Private Shared Function compareStruct( val1 As Object, val2 As Object) As Boolean
189cdf0e10cSrcweir		Debug.Assert( Not(val1 Is Nothing) And Not(val2 Is Nothing))
190cdf0e10cSrcweir		Dim t1 As Type = val1.GetType()
191cdf0e10cSrcweir		Dim t2 As Type = val2.GetType()
192cdf0e10cSrcweir		If Not t1.Equals(t2)
193cdf0e10cSrcweir			Return False
194cdf0e10cSrcweir        End If
195cdf0e10cSrcweir		Dim fields() As FieldInfo = t1.GetFields()
196cdf0e10cSrcweir		Dim cFields As Integer = fields.Length
197cdf0e10cSrcweir		Dim ret As Boolean = True
198cdf0e10cSrcweir        Dim i As Integer
199cdf0e10cSrcweir		For i = 0 To cFields - 1
200cdf0e10cSrcweir			Dim fieldVal1 As Object = fields(i).GetValue(val1)
201cdf0e10cSrcweir			Dim fieldVal2 As Object = fields(i).GetValue(val2)
202cdf0e10cSrcweir			If Not compareData(fieldVal1, fieldVal2)
203cdf0e10cSrcweir				ret = False
204cdf0e10cSrcweir				Exit For
205cdf0e10cSrcweir			End If
206cdf0e10cSrcweir		Next i
207cdf0e10cSrcweir		Return ret
208cdf0e10cSrcweir	End Function
209cdf0e10cSrcweir
210cdf0e10cSrcweir
211cdf0e10cSrcweir    Private Shared Function performSequenceTest(xBT As XBridgeTest) As Boolean
212cdf0e10cSrcweir        Dim bRet As Boolean = True
213cdf0e10cSrcweir        'Automati cast ?? like with COM objects
214cdf0e10cSrcweir        Dim xBT2 As XBridgeTest2
215cdf0e10cSrcweir        Try
216cdf0e10cSrcweir            xBT2 = DirectCast(xBT,XBridgeTest2)
217cdf0e10cSrcweir        Catch e As InvalidCastException
218cdf0e10cSrcweir            Return False
219cdf0e10cSrcweir        End Try
220cdf0e10cSrcweir
221cdf0e10cSrcweir        ' perform sequence tests (XBridgeTest2)
222cdf0e10cSrcweir        'create the sequence which are compared with the results
223cdf0e10cSrcweir        Dim arBool() As Boolean = {True, False, True}
224cdf0e10cSrcweir        Dim arChar() As Char = {"A"C,"B"C,"C"C}
225cdf0e10cSrcweir        Dim arByte() As Byte = { 1,  2,  &Hff}
226cdf0e10cSrcweir        Dim arShort() As Short = {Int16.MinValue, 1,  Int16.MaxValue}
227cdf0e10cSrcweir        Dim arUShort() As UInt16 = {Convert.ToUInt16(0), Convert.ToUInt16(1), _
228cdf0e10cSrcweir                                    Convert.ToUInt16(&Hffff)}
229cdf0e10cSrcweir        Dim arLong() As Integer = {Int32.MinValue, 1, Int32.MaxValue}
230cdf0e10cSrcweir        Dim arULong() As UInt32 = {Convert.ToUInt32(0), Convert.ToUInt32(1), _
231cdf0e10cSrcweir                                   Convert.ToUInt32(&HffffffffL)}
232cdf0e10cSrcweir        Dim arHyper() As Long = {Int64.MinValue, 1, Int64.MaxValue}
233cdf0e10cSrcweir        Dim arUHyper() As UInt64 = {Convert.ToUInt64(0), Convert.ToUInt64(1), _
234cdf0e10cSrcweir                                    Convert.ToUInt64(&Hffffffff5L)}
235cdf0e10cSrcweir        Dim arFloat() As Single = {1.1f, 2.2f, 3.3f}
236cdf0e10cSrcweir        Dim arDouble() As Double = {1.11, 2.22, 3.33}
237cdf0e10cSrcweir        Dim arString() As String = {"String 1", "String 2", "String 3"}
238cdf0e10cSrcweir
239cdf0e10cSrcweir        Dim arAny() As Any = {New Any(True), New Any(11111), New Any(3.14)}
240cdf0e10cSrcweir        Dim arObject() As Object = {New WeakBase(), New WeakBase(), New WeakBase()}
241cdf0e10cSrcweir        Dim arEnum() As TestEnum = {TestEnum.ONE, TestEnum.TWO, TestEnum.CHECK}
242cdf0e10cSrcweir
243cdf0e10cSrcweir        Dim arStruct() As TestElement = {New TestElement(), New TestElement(), _
244cdf0e10cSrcweir                               New TestElement()}
245cdf0e10cSrcweir        assign( arStruct(0), True, "@"C, 17, &H1234, Convert.ToUInt16(&Hfedc), _
246cdf0e10cSrcweir            &H12345678, Convert.ToUInt32(&H123456), &H123456789abcdef0, _
247cdf0e10cSrcweir            Convert.ToUInt64(123456788), 17.0815F, 3.1415926359, _
248cdf0e10cSrcweir            TestEnum.LOLA, CONSTANTS.STRING_TEST_CONSTANT, arObject(0), _
249cdf0e10cSrcweir            New Any(GetType(System.Object), arObject(0)))
250cdf0e10cSrcweir        assign( arStruct(1), True, "A"C, 17, &H1234, Convert.ToUInt16(&Hfedc), _
251cdf0e10cSrcweir            &H12345678, Convert.ToUInt32(&H123456), &H123456789abcdef0, _
252cdf0e10cSrcweir            Convert.ToUInt64(12345678), 17.0815F, 3.1415926359, _
253cdf0e10cSrcweir            TestEnum.TWO, CONSTANTS.STRING_TEST_CONSTANT, arObject(1), _
254cdf0e10cSrcweir            New Any(GetType(System.Object), arObject(1)) )
255cdf0e10cSrcweir        assign( arStruct(2), True, "B"C, 17, &H1234, Convert.ToUInt16(&Hfedc), _
256cdf0e10cSrcweir            &H12345678, Convert.ToUInt32(654321), &H123456789abcdef0, _
257cdf0e10cSrcweir            Convert.ToUInt64(87654321), 17.0815F, 3.1415926359, _
258cdf0e10cSrcweir            TestEnum.CHECK, Constants.STRING_TEST_CONSTANT, arObject(2), _
259cdf0e10cSrcweir            New Any(GetType(System.Object), arObject(2)))
260cdf0e10cSrcweir
261cdf0e10cSrcweir
262cdf0e10cSrcweir        Dim arLong3()()() As Integer = New Integer()()() { _
263cdf0e10cSrcweir        New Integer()(){New Integer(){1,2,3},New Integer(){4,5,6}, New Integer(){7,8,9} }, _
264cdf0e10cSrcweir        New Integer ()(){New Integer(){1,2,3},New Integer(){4,5,6}, New Integer(){7,8,9}}, _
265cdf0e10cSrcweir        New Integer()(){New Integer(){1,2,3},New Integer(){4,5,6}, New Integer(){7,8,9}}}
266cdf0e10cSrcweir
267cdf0e10cSrcweir        Dim seqSeqRet()() As Integer = xBT2.setDim2(arLong3(0))
268cdf0e10cSrcweir        bRet = check( compareData(seqSeqRet, arLong3(0)), "sequence test") _
269cdf0e10cSrcweir               And bRet
270cdf0e10cSrcweir        Dim seqSeqRet2()()() As Integer = xBT2.setDim3(arLong3)
271cdf0e10cSrcweir        bRet = check( compareData(seqSeqRet2, arLong3), "sequence test") _
272cdf0e10cSrcweir               And bRet
273cdf0e10cSrcweir        Dim seqAnyRet() As Any = xBT2.setSequenceAny(arAny)
274cdf0e10cSrcweir        bRet = check( compareData(seqAnyRet, arAny), "sequence test") And bRet
275cdf0e10cSrcweir        Dim seqBoolRet() As Boolean = xBT2.setSequenceBool(arBool)
276cdf0e10cSrcweir        bRet = check( compareData(seqBoolRet, arBool), "sequence test") _
277cdf0e10cSrcweir               And bRet
278cdf0e10cSrcweir        Dim seqByteRet() As Byte = xBT2.setSequenceByte(arByte)
279cdf0e10cSrcweir        bRet = check( compareData(seqByteRet, arByte), "sequence test") _
280cdf0e10cSrcweir               And bRet
281cdf0e10cSrcweir        Dim seqCharRet() As Char = xBT2.setSequenceChar(arChar)
282cdf0e10cSrcweir        bRet = check( compareData(seqCharRet, arChar), "sequence test") _
283cdf0e10cSrcweir                   And bRet
284cdf0e10cSrcweir        Dim seqShortRet() As Short = xBT2.setSequenceShort(arShort)
285cdf0e10cSrcweir        bRet = check( compareData(seqShortRet, arShort), "sequence test") _
286cdf0e10cSrcweir               And bRet
287cdf0e10cSrcweir        Dim seqLongRet() As Integer = xBT2.setSequenceLong(arLong)
288cdf0e10cSrcweir        bRet = check( compareData(seqLongRet, arLong), "sequence test") _
289cdf0e10cSrcweir                   And bRet
290cdf0e10cSrcweir        Dim seqHyperRet() As Long = xBT2.setSequenceHyper(arHyper)
291cdf0e10cSrcweir        bRet = check( compareData(seqHyperRet,arHyper), "sequence test") _
292cdf0e10cSrcweir               And bRet
293cdf0e10cSrcweir        Dim seqFloatRet() As Single = xBT2.setSequenceFloat(arFloat)
294cdf0e10cSrcweir        bRet = check( compareData(seqFloatRet, arFloat), "sequence test") _
295cdf0e10cSrcweir               And bRet
296cdf0e10cSrcweir        Dim seqDoubleRet() As Double= xBT2.setSequenceDouble(arDouble)
297cdf0e10cSrcweir        bRet = check( compareData(seqDoubleRet, arDouble), "sequence test") _
298cdf0e10cSrcweir               And bRet
299cdf0e10cSrcweir        Dim seqEnumRet() As TestEnum = xBT2.setSequenceEnum(arEnum)
300cdf0e10cSrcweir        bRet = check( compareData(seqEnumRet, arEnum), "sequence test") _
301cdf0e10cSrcweir               And bRet
302cdf0e10cSrcweir        Dim seqUShortRet() As UInt16 = xBT2.setSequenceUShort(arUShort)
303cdf0e10cSrcweir        bRet = check( compareData(seqUShortRet, arUShort), "sequence test") _
304cdf0e10cSrcweir               And bRet
305cdf0e10cSrcweir        Dim seqULongRet() As UInt32 = xBT2.setSequenceULong(arULong)
306cdf0e10cSrcweir        bRet = check( compareData(seqULongRet, arULong), "sequence test") _
307cdf0e10cSrcweir               And bRet
308cdf0e10cSrcweir        Dim seqUHyperRet() As UInt64 = xBT2.setSequenceUHyper(arUHyper)
309cdf0e10cSrcweir        bRet = check( compareData(seqUHyperRet, arUHyper), "sequence test") _
310cdf0e10cSrcweir               And bRet
311cdf0e10cSrcweir        Dim seqObjectRet() As Object = xBT2.setSequenceXInterface(arObject)
312cdf0e10cSrcweir        bRet = check( compareData(seqObjectRet, arObject), "sequence test") _
313cdf0e10cSrcweir               And bRet
314cdf0e10cSrcweir        Dim seqStringRet() As String = xBT2.setSequenceString(arString)
315cdf0e10cSrcweir        bRet = check( compareData(seqStringRet, arString), "sequence test") _
316cdf0e10cSrcweir               And bRet
317cdf0e10cSrcweir        Dim seqStructRet() As TestElement = xBT2.setSequenceStruct(arStruct)
318cdf0e10cSrcweir        bRet = check( compareData(seqStructRet, arStruct), "sequence test") _
319cdf0e10cSrcweir               And bRet
320cdf0e10cSrcweir
321cdf0e10cSrcweir
322cdf0e10cSrcweir        Dim arBoolTemp() As Boolean = DirectCast(arBool.Clone(), Boolean())
323cdf0e10cSrcweir        Dim arCharTemp() As Char = DirectCast(arChar.Clone(), Char())
324cdf0e10cSrcweir        Dim arByteTemp() As Byte = DirectCast(arByte.Clone(), Byte())
325cdf0e10cSrcweir        Dim arShortTemp() As Short = DirectCast(arShort.Clone(), Short())
326cdf0e10cSrcweir        Dim arUShortTemp() As UInt16 = DirectCast(arUShort.Clone(), UInt16())
327cdf0e10cSrcweir        Dim arLongTemp() As Integer= DirectCast(arLong.Clone(), Integer())
328cdf0e10cSrcweir        Dim arULongTemp() As UInt32 =  DirectCast(arULong.Clone(), UInt32())
329cdf0e10cSrcweir        Dim arHyperTemp() As Long = DirectCast(arHyper.Clone(), Long())
330cdf0e10cSrcweir        Dim arUHyperTemp() As UInt64 = DirectCast(arUHyper.Clone(), UInt64())
331cdf0e10cSrcweir        Dim arFloatTemp() As Single = DirectCast(arFloat.Clone(), Single())
332cdf0e10cSrcweir        Dim arDoubleTemp() As Double = DirectCast(arDouble.Clone(), Double())
333cdf0e10cSrcweir        Dim arEnumTemp() As TestEnum = DirectCast(arEnum.Clone(), TestEnum())
334cdf0e10cSrcweir        Dim arStringTemp() As String = DirectCast(arString.Clone(), String())
335cdf0e10cSrcweir        Dim arObjectTemp() As Object = DirectCast(arObject.Clone(), Object())
336cdf0e10cSrcweir        Dim arAnyTemp() As Any = DirectCast(arAny.Clone(), Any())
337cdf0e10cSrcweir        ' make sure this are has the same contents as arLong3(0)
338cdf0e10cSrcweir        Dim arLong2Temp()() As Integer = New Integer()(){New Integer(){1,2,3}, _
339cdf0e10cSrcweir                                         New Integer(){4,5,6}, New Integer(){7,8,9} }
340cdf0e10cSrcweir        ' make sure this are has the same contents as arLong3
341cdf0e10cSrcweir        Dim arLong3Temp()()() As Integer = New Integer()()(){ _
342cdf0e10cSrcweir            New Integer()(){New Integer(){1,2,3},New Integer(){4,5,6}, New Integer(){7,8,9} }, _
343cdf0e10cSrcweir            New Integer ()(){New Integer(){1,2,3},New Integer(){4,5,6}, New Integer(){7,8,9}}, _
344cdf0e10cSrcweir            New Integer()(){New Integer(){1,2,3},New Integer(){4,5,6}, New Integer(){7,8,9}}}
345cdf0e10cSrcweir
346cdf0e10cSrcweir        xBT2.setSequencesInOut( arBoolTemp, arCharTemp,  arByteTemp, _
347cdf0e10cSrcweir                            arShortTemp,  arUShortTemp,  arLongTemp, _
348cdf0e10cSrcweir                            arULongTemp, arHyperTemp,  arUHyperTemp, _
349cdf0e10cSrcweir                            arFloatTemp, arDoubleTemp,  arEnumTemp, _
350cdf0e10cSrcweir                            arStringTemp,   arObjectTemp, _
351cdf0e10cSrcweir                             arAnyTemp,  arLong2Temp,  arLong3Temp)
352cdf0e10cSrcweir        bRet = check( _
353cdf0e10cSrcweir            compareData(arBoolTemp, arBool) And _
354cdf0e10cSrcweir            compareData(arCharTemp , arChar) And _
355cdf0e10cSrcweir            compareData(arByteTemp , arByte) And _
356cdf0e10cSrcweir            compareData(arShortTemp , arShort) And _
357cdf0e10cSrcweir            compareData(arUShortTemp , arUShort) And _
358cdf0e10cSrcweir            compareData(arLongTemp , arLong) And _
359cdf0e10cSrcweir            compareData(arULongTemp , arULong) And _
360cdf0e10cSrcweir            compareData(arHyperTemp , arHyper) And _
361cdf0e10cSrcweir            compareData(arUHyperTemp , arUHyper) And _
362cdf0e10cSrcweir            compareData(arFloatTemp , arFloat) And _
363cdf0e10cSrcweir            compareData(arDoubleTemp , arDouble) And _
364cdf0e10cSrcweir            compareData(arEnumTemp , arEnum) And _
365cdf0e10cSrcweir            compareData(arStringTemp , arString) And _
366cdf0e10cSrcweir            compareData(arObjectTemp , arObject) And _
367cdf0e10cSrcweir            compareData(arAnyTemp , arAny) And _
368cdf0e10cSrcweir            compareData(arLong2Temp , arLong3(0)) And _
369cdf0e10cSrcweir            compareData(arLong3Temp , arLong3), "sequence test") And bRet
370cdf0e10cSrcweir
371cdf0e10cSrcweir        Dim arBoolOut() As Boolean
372cdf0e10cSrcweir        Dim arCharOut() As Char
373cdf0e10cSrcweir        Dim arByteOut() As Byte
374cdf0e10cSrcweir        Dim arShortOut() As Short
375cdf0e10cSrcweir        Dim arUShortOut() As UInt16
376cdf0e10cSrcweir        Dim arLongOut() As Integer
377cdf0e10cSrcweir        Dim arULongOut() As UInt32
378cdf0e10cSrcweir        Dim arHyperOut() As Long
379cdf0e10cSrcweir        Dim arUHyperOut() As UInt64
380cdf0e10cSrcweir        Dim arFloatOut() As Single
381cdf0e10cSrcweir        Dim arDoubleOut() As Double
382cdf0e10cSrcweir        Dim arEnumOut() As TestEnum
383cdf0e10cSrcweir        Dim arStringOut() As String
384cdf0e10cSrcweir        Dim arObjectOut() As Object
385cdf0e10cSrcweir        Dim arAnyOut() As Any
386cdf0e10cSrcweir        Dim arLong2Out()() As Integer
387cdf0e10cSrcweir        Dim arLong3Out()()() As Integer
388cdf0e10cSrcweir
389cdf0e10cSrcweir        xBT2.setSequencesOut( arBoolOut,  arCharOut,  arByteOut, _
390cdf0e10cSrcweir                             arShortOut,  arUShortOut,  arLongOut, _
391cdf0e10cSrcweir                             arULongOut,  arHyperOut,  arUHyperOut, _
392cdf0e10cSrcweir                             arFloatOut,  arDoubleOut,  arEnumOut, _
393cdf0e10cSrcweir                             arStringOut,  arObjectOut,  arAnyOut, _
394cdf0e10cSrcweir                             arLong2Out,  arLong3Out)
395cdf0e10cSrcweir        bRet = check( _
396cdf0e10cSrcweir            compareData(arBoolOut, arBool) And _
397cdf0e10cSrcweir            compareData(arCharOut, arChar) And _
398cdf0e10cSrcweir            compareData(arByteOut, arByte) And _
399cdf0e10cSrcweir            compareData(arShortOut, arShort) And _
400cdf0e10cSrcweir            compareData(arUShortOut, arUShort) And _
401cdf0e10cSrcweir            compareData(arLongOut, arLong) And _
402cdf0e10cSrcweir            compareData(arULongOut, arULong) And _
403cdf0e10cSrcweir            compareData(arHyperOut, arHyper) And _
404cdf0e10cSrcweir            compareData(arUHyperOut, arUHyper) And _
405cdf0e10cSrcweir            compareData(arFloatOut, arFloat) And _
406cdf0e10cSrcweir            compareData(arDoubleOut, arDouble) And _
407cdf0e10cSrcweir            compareData(arEnumOut, arEnum) And _
408cdf0e10cSrcweir            compareData(arStringOut, arString) And _
409cdf0e10cSrcweir            compareData(arObjectOut, arObject) And _
410cdf0e10cSrcweir            compareData(arAnyOut, arAny) And _
411cdf0e10cSrcweir            compareData(arLong2Out, arLong3(0)) And _
412cdf0e10cSrcweir            compareData(arLong3Out, arLong3), "sequence test") And bRet
413cdf0e10cSrcweir
414cdf0e10cSrcweir
415cdf0e10cSrcweir        'test with empty sequences
416cdf0e10cSrcweir        Dim _arLong2()() As Integer = New Integer()(){}
417cdf0e10cSrcweir        seqSeqRet = xBT2.setDim2(_arLong2)
418cdf0e10cSrcweir        bRet = check( compareData(seqSeqRet, _arLong2), "sequence test") And bRet
419cdf0e10cSrcweir        Dim _arLong3()()() As Integer = New Integer()()(){}
420cdf0e10cSrcweir        seqSeqRet2 = xBT2.setDim3(_arLong3)
421cdf0e10cSrcweir        bRet = check( compareData(seqSeqRet2, _arLong3), "sequence test") And bRet
422cdf0e10cSrcweir        Dim _arAny() As Any = New Any(){}
423cdf0e10cSrcweir        seqAnyRet = xBT2.setSequenceAny(_arAny)
424cdf0e10cSrcweir        bRet = check( compareData(seqAnyRet, _arAny), "sequence test") And bRet
425cdf0e10cSrcweir        Dim _arBool() As Boolean = New Boolean() {}
426cdf0e10cSrcweir        seqBoolRet = xBT2.setSequenceBool(_arBool)
427cdf0e10cSrcweir        bRet = check( compareData(seqBoolRet, _arBool), "sequence test") And bRet
428cdf0e10cSrcweir        Dim _arByte() As Byte = New Byte() {}
429cdf0e10cSrcweir        seqByteRet = xBT2.setSequenceByte(_arByte)
430cdf0e10cSrcweir        bRet = check( compareData(seqByteRet, _arByte), "sequence test") And bRet
431cdf0e10cSrcweir        Dim _arChar() As Char = New Char() {}
432cdf0e10cSrcweir        seqCharRet  = xBT2.setSequenceChar(_arChar)
433cdf0e10cSrcweir        bRet = check( compareData(seqCharRet, _arChar), "sequence test") And bRet
434cdf0e10cSrcweir        Dim _arShort() As Short = New Short() {}
435cdf0e10cSrcweir        seqShortRet = xBT2.setSequenceShort(_arShort)
436cdf0e10cSrcweir        bRet = check( compareData(seqShortRet, _arShort), "sequence test") And bRet
437cdf0e10cSrcweir        Dim _arLong() As Integer = New Integer() {}
438cdf0e10cSrcweir        seqLongRet = xBT2.setSequenceLong(_arLong)
439cdf0e10cSrcweir        bRet = check( compareData(seqLongRet, _arLong), "sequence test") And bRet
440cdf0e10cSrcweir        Dim _arHyper() As Long = New Long(){}
441cdf0e10cSrcweir        seqHyperRet = xBT2.setSequenceHyper(_arHyper)
442cdf0e10cSrcweir        bRet = check( compareData(seqHyperRet, _arHyper), "sequence test") And bRet
443cdf0e10cSrcweir        Dim _arFloat() As Single = New Single(){}
444cdf0e10cSrcweir        seqFloatRet = xBT2.setSequenceFloat(_arFloat)
445cdf0e10cSrcweir        bRet = check( compareData(seqFloatRet, _arFloat), "sequence test") And bRet
446cdf0e10cSrcweir        Dim _arDouble() As Double = New Double(){}
447cdf0e10cSrcweir        seqDoubleRet = xBT2.setSequenceDouble(_arDouble)
448cdf0e10cSrcweir        bRet = check( compareData(seqDoubleRet, _arDouble), "sequence test") And bRet
449cdf0e10cSrcweir        Dim _arEnum() As TestEnum = New TestEnum(){}
450cdf0e10cSrcweir        seqEnumRet = xBT2.setSequenceEnum(_arEnum)
451cdf0e10cSrcweir        bRet = check( compareData(seqEnumRet, _arEnum), "sequence test") And bRet
452cdf0e10cSrcweir        Dim  _arUShort() As UInt16 = New UInt16(){}
453cdf0e10cSrcweir        seqUShortRet = xBT2.setSequenceUShort(_arUShort)
454cdf0e10cSrcweir        bRet = check( compareData(seqUShortRet, _arUShort), "sequence test") And bRet
455cdf0e10cSrcweir        Dim _arULong() As UInt32 = New UInt32(){}
456cdf0e10cSrcweir        seqULongRet = xBT2.setSequenceULong(_arULong)
457cdf0e10cSrcweir        bRet = check( compareData(seqULongRet, _arULong), "sequence test") And bRet
458cdf0e10cSrcweir        Dim  _arUHyper() As UInt64 = New UInt64(){}
459cdf0e10cSrcweir        seqUHyperRet = xBT2.setSequenceUHyper(_arUHyper)
460cdf0e10cSrcweir        bRet = check( compareData(seqUHyperRet, _arUHyper), "sequence test") And bRet
461cdf0e10cSrcweir        Dim _arObject() As Object = New Object(){}
462cdf0e10cSrcweir        seqObjectRet = xBT2.setSequenceXInterface(_arObject)
463cdf0e10cSrcweir        bRet = check( compareData(seqObjectRet, _arObject), "sequence test") And bRet
464cdf0e10cSrcweir        Dim _arString() As String = New String(){}
465cdf0e10cSrcweir        seqStringRet = xBT2.setSequenceString(_arString)
466cdf0e10cSrcweir        bRet = check( compareData(seqStringRet, _arString), "sequence test") And bRet
467cdf0e10cSrcweir        Dim _arStruct() As TestElement = New TestElement(){}
468cdf0e10cSrcweir        seqStructRet = xBT2.setSequenceStruct(_arStruct)
469cdf0e10cSrcweir        bRet = check( compareData(seqStructRet, _arStruct), "sequence test") And bRet
470cdf0e10cSrcweir        Return bRet
471cdf0e10cSrcweir    End Function
472cdf0e10cSrcweir
473cdf0e10cSrcweir    Private Shared Function testAny(typ As Type, value As  Object, _
474cdf0e10cSrcweir                                    xLBT As  XBridgeTest ) As Boolean
475cdf0e10cSrcweir
476cdf0e10cSrcweir	    Dim any As Any
477cdf0e10cSrcweir	    If (typ Is Nothing)
478cdf0e10cSrcweir		    any = New Any(value.GetType(), value)
479cdf0e10cSrcweir	    Else
480cdf0e10cSrcweir		    any = New Any(typ, value)
481cdf0e10cSrcweir        End If
482cdf0e10cSrcweir
483cdf0e10cSrcweir	    Dim any2 As Any = xLBT.transportAny(any)
484cdf0e10cSrcweir	    Dim ret As Boolean = compareData(any, any2)
485cdf0e10cSrcweir	    If ret = False
486cdf0e10cSrcweir            Console.WriteLine("any is different after roundtrip: in {0}, " _
487cdf0e10cSrcweir                              & "out {1}\n", _
488cdf0e10cSrcweir                            any.Type.FullName, any2.Type.FullName)
489cdf0e10cSrcweir        End If
490cdf0e10cSrcweir	    Return ret
491cdf0e10cSrcweir    End Function
492cdf0e10cSrcweir
493cdf0e10cSrcweir    Private Shared Function performAnyTest(xLBT As XBridgeTest, _
494cdf0e10cSrcweir                                           data As TestDataElements) As Boolean
495cdf0e10cSrcweir        Dim bReturn As Boolean = True
496cdf0e10cSrcweir	    bReturn = testAny( Nothing, data.Byte ,xLBT ) And bReturn
497cdf0e10cSrcweir	    bReturn = testAny( Nothing, data.Short,xLBT ) And bReturn
498cdf0e10cSrcweir	    bReturn = testAny(  Nothing, data.UShort,xLBT ) And bReturn
499cdf0e10cSrcweir	    bReturn = testAny(  Nothing, data.Long,xLBT ) And bReturn
500cdf0e10cSrcweir	    bReturn = testAny(  Nothing, data.ULong,xLBT ) And bReturn
501cdf0e10cSrcweir	    bReturn = testAny(  Nothing, data.Hyper,xLBT ) And bReturn
502cdf0e10cSrcweir	    bReturn = testAny(  Nothing,data.UHyper,xLBT ) And bReturn
503cdf0e10cSrcweir	    bReturn = testAny( Nothing, data.Float,xLBT ) And bReturn
504cdf0e10cSrcweir	    bReturn = testAny( Nothing, data.Double,xLBT ) And bReturn
505cdf0e10cSrcweir	    bReturn = testAny( Nothing, data.Enum,xLBT ) And bReturn
506cdf0e10cSrcweir	    bReturn = testAny( Nothing, data.String,xLBT ) And bReturn
507cdf0e10cSrcweir	    bReturn = testAny(GetType(unoidl.com.sun.star.uno.XWeak), _
508cdf0e10cSrcweir                     data.Interface,xLBT ) And bReturn
509cdf0e10cSrcweir	    bReturn = testAny(Nothing, data, xLBT ) And bReturn
510cdf0e10cSrcweir
511cdf0e10cSrcweir        Dim a1 As Any = New Any(True)
512cdf0e10cSrcweir        Dim a2 As Any = xLBT.transportAny( a1 )
513cdf0e10cSrcweir	    bReturn = compareData(a2, a1) And bReturn
514cdf0e10cSrcweir
515cdf0e10cSrcweir        Dim a3 As Any = New Any("A"C)
516cdf0e10cSrcweir	    Dim a4 As Any = xLBT.transportAny(a3)
517cdf0e10cSrcweir	    bReturn = compareData(a4, a3) And bReturn
518cdf0e10cSrcweir
519cdf0e10cSrcweir	    Return bReturn
520cdf0e10cSrcweir    End Function
521cdf0e10cSrcweir
522cdf0e10cSrcweir    Private Shared Function performSequenceOfCallTest(xLBT As XBridgeTest) As Boolean
523cdf0e10cSrcweir
524cdf0e10cSrcweir	    Dim i, nRounds As Integer
525cdf0e10cSrcweir	    Dim nGlobalIndex As Integer = 0
526cdf0e10cSrcweir	    const nWaitTimeSpanMUSec As Integer = 10000
527cdf0e10cSrcweir	    For nRounds = 0 To 9
528cdf0e10cSrcweir		    For i = 0 To  nRounds - 1
529cdf0e10cSrcweir			    ' fire oneways
530cdf0e10cSrcweir			    xLBT.callOneway(nGlobalIndex, nWaitTimeSpanMUSec)
531cdf0e10cSrcweir			    nGlobalIndex = nGlobalIndex + 1
532cdf0e10cSrcweir		    Next
533cdf0e10cSrcweir
534cdf0e10cSrcweir		    ' call synchron
535cdf0e10cSrcweir		    xLBT.call(nGlobalIndex, nWaitTimeSpanMUSec)
536cdf0e10cSrcweir		    nGlobalIndex = nGlobalIndex + 1
537cdf0e10cSrcweir	    Next
538cdf0e10cSrcweir 	    Return xLBT.sequenceOfCallTestPassed()
539cdf0e10cSrcweir    End Function
540cdf0e10cSrcweir
541cdf0e10cSrcweir    Private Shared Function performRecursiveCallTest(xLBT As XBridgeTest) As Boolean
542cdf0e10cSrcweir	    xLBT.startRecursiveCall(new ORecursiveCall(), 50)
543cdf0e10cSrcweir	    ' on failure, the test would lock up or crash
544cdf0e10cSrcweir	    Return True
545cdf0e10cSrcweir    End Function
546cdf0e10cSrcweir
547cdf0e10cSrcweir
548cdf0e10cSrcweir    Private Shared Function performTest(xLBT As XBridgeTest) As Boolean
549cdf0e10cSrcweir	    check( Not xLBT Is Nothing, "### no test interface!" )
550cdf0e10cSrcweir        Dim bRet As Boolean = True
551cdf0e10cSrcweir	    If xLBT Is Nothing
552cdf0e10cSrcweir            Return False
553cdf0e10cSrcweir        End If
554cdf0e10cSrcweir		'this data is never ever granted access to by calls other than equals(), assign()!
555cdf0e10cSrcweir		Dim aData As New TestDataElements' test against this data
556cdf0e10cSrcweir		Dim xI As New WeakBase
557cdf0e10cSrcweir
558cdf0e10cSrcweir        Dim aAny As New Any(GetType(System.Object), xI)
559cdf0e10cSrcweir		assign( DirectCast(aData, TestElement), _
560cdf0e10cSrcweir			True, "@"C, 17, &H1234, Convert.ToUInt16(&HdcS), &H12345678, _
561cdf0e10cSrcweir            Convert.ToUInt32(4294967294), _
562cdf0e10cSrcweir			&H123456789abcdef0, Convert.ToUInt64(14294967294), _
563cdf0e10cSrcweir			17.0815f, 3.1415926359, TestEnum.LOLA, _
564cdf0e10cSrcweir			CONSTANTS.STRING_TEST_CONSTANT, xI, _
565cdf0e10cSrcweir			aAny)
566cdf0e10cSrcweir
567cdf0e10cSrcweir		bRet = check( aData.Any.Value Is xI, "### unexpected any!" ) And bRet
568cdf0e10cSrcweir
569cdf0e10cSrcweir		aData.Sequence = New TestElement(1){}
570cdf0e10cSrcweir        aData.Sequence(0) = New TestElement( _
571cdf0e10cSrcweir			aData.Bool, aData.Char, aData.Byte, aData.Short, _
572cdf0e10cSrcweir			aData.UShort, aData.Long, aData.ULong, _
573cdf0e10cSrcweir			aData.Hyper, aData.UHyper, aData.Float, _
574cdf0e10cSrcweir			aData.Double, aData.Enum, aData.String, _
575cdf0e10cSrcweir			aData.Interface, aData.Any)
576cdf0e10cSrcweir        aData.Sequence(1) = New TestElement 'is empty
577cdf0e10cSrcweir
578cdf0e10cSrcweir		' aData complete
579cdf0e10cSrcweir		'
580cdf0e10cSrcweir		' this is a manually copy of aData for first setting...
581cdf0e10cSrcweir		Dim aSetData As New TestDataElements
582cdf0e10cSrcweir		Dim aAnySet As New Any(GetType(System.Object), xI)
583cdf0e10cSrcweir		assign( DirectCast(aSetData, TestElement), _
584cdf0e10cSrcweir				aData.Bool, aData.Char, aData.Byte, aData.Short, aData.UShort, _
585cdf0e10cSrcweir				aData.Long, aData.ULong, aData.Hyper, aData.UHyper, aData.Float, _
586cdf0e10cSrcweir                aData.Double, aData.Enum, aData.String, xI, aAnySet)
587cdf0e10cSrcweir
588cdf0e10cSrcweir		aSetData.Sequence = New TestElement(1){}
589cdf0e10cSrcweir        aSetData.Sequence(0) = New TestElement( _
590cdf0e10cSrcweir			aSetData.Bool, aSetData.Char, aSetData.Byte, aSetData.Short, _
591cdf0e10cSrcweir			aSetData.UShort, aSetData.Long, aSetData.ULong, _
592cdf0e10cSrcweir			aSetData.Hyper, aSetData.UHyper, aSetData.Float, _
593cdf0e10cSrcweir			aSetData.Double, aSetData.Enum, aSetData.String, _
594cdf0e10cSrcweir			aSetData.Interface, aSetData.Any)
595cdf0e10cSrcweir        aSetData.Sequence(1) = New TestElement ' empty struct
596cdf0e10cSrcweir
597cdf0e10cSrcweir		xLBT.setValues( _
598cdf0e10cSrcweir				aSetData.Bool, aSetData.Char, aSetData.Byte, aSetData.Short, _
599cdf0e10cSrcweir                aSetData.UShort, aSetData.Long, aSetData.ULong, _
600cdf0e10cSrcweir                aSetData.Hyper, aSetData.UHyper, aSetData.Float, _
601cdf0e10cSrcweir                aSetData.Double, aSetData.Enum, aSetData.String, _
602cdf0e10cSrcweir                aSetData.Interface, aSetData.Any, aSetData.Sequence, _
603cdf0e10cSrcweir                aSetData )
604cdf0e10cSrcweir
605cdf0e10cSrcweir
606cdf0e10cSrcweir		Dim aRet As New TestDataElements
607cdf0e10cSrcweir        Dim aRet2 As New TestDataElements
608cdf0e10cSrcweir		xLBT.getValues( _
609cdf0e10cSrcweir			aRet.Bool, aRet.Char, aRet.Byte, aRet.Short, _
610cdf0e10cSrcweir            aRet.UShort, aRet.Long, aRet.ULong, _
611cdf0e10cSrcweir            aRet.Hyper, aRet.UHyper, aRet.Float, _
612cdf0e10cSrcweir            aRet.Double, aRet.Enum, aRet.String, _
613cdf0e10cSrcweir            aRet.Interface, aRet.Any, aRet.Sequence, _
614cdf0e10cSrcweir            aRet2 )
615cdf0e10cSrcweir
616cdf0e10cSrcweir		bRet = check( compareData( aData, aRet ) And _
617cdf0e10cSrcweir                      compareData( aData, aRet2 ) , "getValues test") And bRet
618cdf0e10cSrcweir
619cdf0e10cSrcweir		' set last retrieved values
620cdf0e10cSrcweir		Dim  aSV2ret As TestDataElements= xLBT.setValues2( _
621cdf0e10cSrcweir			aRet.Bool, aRet.Char, aRet.Byte, _
622cdf0e10cSrcweir            aRet.Short, aRet.UShort, aRet.Long, _
623cdf0e10cSrcweir            aRet.ULong, aRet.Hyper, aRet.UHyper, _
624cdf0e10cSrcweir            aRet.Float, aRet.Double, aRet.Enum, _
625cdf0e10cSrcweir            aRet.String, aRet.Interface, aRet.Any, _
626cdf0e10cSrcweir            aRet.Sequence, aRet2 )
627cdf0e10cSrcweir
628cdf0e10cSrcweir        ' check inout sequence order
629cdf0e10cSrcweir        ' => inout sequence parameter was switched by test objects
630cdf0e10cSrcweir		Dim temp As TestElement = aRet.Sequence( 0 )
631cdf0e10cSrcweir        aRet.Sequence( 0 ) = aRet.Sequence( 1 )
632cdf0e10cSrcweir        aRet.Sequence( 1 ) = temp
633cdf0e10cSrcweir
634cdf0e10cSrcweir		bRet = check( _
635cdf0e10cSrcweir            compareData( aData, aSV2ret ) And compareData( aData, aRet2 ), _
636cdf0e10cSrcweir            "getValues2 test") And bRet
637cdf0e10cSrcweir
638cdf0e10cSrcweir
639cdf0e10cSrcweir		aRet = New TestDataElements
640cdf0e10cSrcweir        aRet2 = New TestDataElements
641cdf0e10cSrcweir		Dim  aGVret As TestDataElements= xLBT.getValues( _
642cdf0e10cSrcweir			aRet.Bool, aRet.Char, aRet.Byte, _
643cdf0e10cSrcweir            aRet.Short, aRet.UShort, aRet.Long, _
644cdf0e10cSrcweir            aRet.ULong, aRet.Hyper, aRet.UHyper, _
645cdf0e10cSrcweir            aRet.Float, aRet.Double, aRet.Enum, _
646cdf0e10cSrcweir            aRet.String, aRet.Interface, aRet.Any, _
647cdf0e10cSrcweir            aRet.Sequence, aRet2 )
648cdf0e10cSrcweir
649cdf0e10cSrcweir		bRet = check( compareData( aData, aRet ) And _
650cdf0e10cSrcweir                      compareData( aData, aRet2 ) And _
651cdf0e10cSrcweir                      compareData( aData, aGVret ), "getValues test" ) And bRet
652cdf0e10cSrcweir
653cdf0e10cSrcweir		' set last retrieved values
654cdf0e10cSrcweir		xLBT.Bool = aRet.Bool
655cdf0e10cSrcweir		xLBT.Char = aRet.Char
656cdf0e10cSrcweir		xLBT.Byte = aRet.Byte
657cdf0e10cSrcweir		xLBT.Short = aRet.Short
658cdf0e10cSrcweir		xLBT.UShort = aRet.UShort
659cdf0e10cSrcweir        xLBT.Long = aRet.Long
660cdf0e10cSrcweir		xLBT.ULong = aRet.ULong
661cdf0e10cSrcweir		xLBT.Hyper = aRet.Hyper
662cdf0e10cSrcweir		xLBT.UHyper = aRet.UHyper
663cdf0e10cSrcweir		xLBT.Float = aRet.Float
664cdf0e10cSrcweir		xLBT.Double = aRet.Double
665cdf0e10cSrcweir		xLBT.Enum = aRet.Enum
666cdf0e10cSrcweir		xLBT.String = aRet.String
667cdf0e10cSrcweir		xLBT.Interface = aRet.Interface
668cdf0e10cSrcweir		xLBT.Any = aRet.Any
669cdf0e10cSrcweir		xLBT.Sequence = aRet.Sequence
670cdf0e10cSrcweir		xLBT.Struct = aRet2
671cdf0e10cSrcweir
672cdf0e10cSrcweir
673cdf0e10cSrcweir		aRet = New TestDataElements
674cdf0e10cSrcweir        aRet2 = New TestDataElements
675cdf0e10cSrcweir		aRet.Hyper = xLBT.Hyper
676cdf0e10cSrcweir		aRet.UHyper = xLBT.UHyper
677cdf0e10cSrcweir		aRet.Float = xLBT.Float
678cdf0e10cSrcweir		aRet.Double = xLBT.Double
679cdf0e10cSrcweir		aRet.Byte = xLBT.Byte
680cdf0e10cSrcweir		aRet.Char = xLBT.Char
681cdf0e10cSrcweir		aRet.Bool = xLBT.Bool
682cdf0e10cSrcweir		aRet.Short = xLBT.Short
683cdf0e10cSrcweir		aRet.UShort = xLBT.UShort
684cdf0e10cSrcweir		aRet.Long = xLBT.Long
685cdf0e10cSrcweir		aRet.ULong = xLBT.ULong
686cdf0e10cSrcweir		aRet.Enum = xLBT.Enum
687cdf0e10cSrcweir		aRet.String = xLBT.String
688cdf0e10cSrcweir		aRet.Interface = xLBT.Interface
689cdf0e10cSrcweir		aRet.Any = xLBT.Any
690cdf0e10cSrcweir		aRet.Sequence = xLBT.Sequence
691cdf0e10cSrcweir		aRet2 = xLBT.Struct
692cdf0e10cSrcweir
693cdf0e10cSrcweir		bRet = check( compareData( aData, aRet ) And _
694cdf0e10cSrcweir                      compareData( aData, aRet2 ) , "struct comparison test") _
695cdf0e10cSrcweir                     And bRet
696cdf0e10cSrcweir
697cdf0e10cSrcweir		bRet = check(performSequenceTest(xLBT), "sequence test") And bRet
698cdf0e10cSrcweir
699cdf0e10cSrcweir		' any test
700cdf0e10cSrcweir		bRet = check( performAnyTest( xLBT , aData ) , "any test" ) And bRet
701cdf0e10cSrcweir
702cdf0e10cSrcweir		'sequence of call test
703cdf0e10cSrcweir		bRet = check( performSequenceOfCallTest( xLBT ) , _
704cdf0e10cSrcweir                      "sequence of call test" ) And bRet
705cdf0e10cSrcweir
706cdf0e10cSrcweir		' recursive call test
707cdf0e10cSrcweir		bRet = check( performRecursiveCallTest( xLBT ) , "recursive test" ) _
708cdf0e10cSrcweir                And bRet
709cdf0e10cSrcweir
710cdf0e10cSrcweir		bRet = (compareData( aData, aRet ) And compareData( aData, aRet2 )) _
711cdf0e10cSrcweir                And bRet
712cdf0e10cSrcweir
713cdf0e10cSrcweir        ' check setting of null reference
714cdf0e10cSrcweir        xLBT.Interface = Nothing
715cdf0e10cSrcweir        aRet.Interface = xLBT.Interface
716cdf0e10cSrcweir        bRet = (aRet.Interface Is Nothing) And bRet
717cdf0e10cSrcweir
718cdf0e10cSrcweir        Return bRet
719cdf0e10cSrcweir    End Function
720cdf0e10cSrcweir
721cdf0e10cSrcweir    Private Shared Function raiseException(xLBT As XBridgeTest) As Boolean
722cdf0e10cSrcweir	    Dim nCount As Integer = 0
723cdf0e10cSrcweir	    Try
724cdf0e10cSrcweir		    Try
725cdf0e10cSrcweir			    Try
726cdf0e10cSrcweir				    Dim aRet As TestDataElements = New TestDataElements
727cdf0e10cSrcweir                    Dim aRet2 As TestDataElements = New TestDataElements
728cdf0e10cSrcweir				    xLBT.raiseException( _
729cdf0e10cSrcweir					    5, CONSTANTS.STRING_TEST_CONSTANT, xLBT.Interface )
730cdf0e10cSrcweir			    Catch  rExc As unoidl.com.sun.star.lang.IllegalArgumentException
731cdf0e10cSrcweir				    If rExc.ArgumentPosition = 5 And _
732cdf0e10cSrcweir                        rExc.Context Is xLBT.Interface
733cdf0e10cSrcweir					    nCount = nCount + 1
734cdf0e10cSrcweir				    Else
735cdf0e10cSrcweir					    check( False, "### unexpected exception content!" )
736cdf0e10cSrcweir				    End If
737cdf0e10cSrcweir
738cdf0e10cSrcweir				    'it is certain, that the RuntimeException testing will fail,
739cdf0e10cSrcweir                    '    if no
740cdf0e10cSrcweir				    xLBT.RuntimeException = 0
741cdf0e10cSrcweir			    End Try
742cdf0e10cSrcweir		    Catch rExc As unoidl.com.sun.star.uno.RuntimeException
743cdf0e10cSrcweir			    If rExc.Context Is xLBT.Interface
744cdf0e10cSrcweir			       nCount = nCount + 1
745cdf0e10cSrcweir			    Else
746cdf0e10cSrcweir				    check( False, "### unexpected exception content!" )
747cdf0e10cSrcweir			    End If
748cdf0e10cSrcweir                xLBT.RuntimeException = CType(&Hcafebabe, Integer)
749cdf0e10cSrcweir    	    End Try
750cdf0e10cSrcweir	    Catch rExc As unoidl.com.sun.star.uno.Exception
751cdf0e10cSrcweir		    If rExc.Context Is xLBT.Interface
752cdf0e10cSrcweir		        nCount = nCount + 1
753cdf0e10cSrcweir		    Else
754cdf0e10cSrcweir			    check( False, "### unexpected exception content!" )
755cdf0e10cSrcweir            End If
756cdf0e10cSrcweir		    Return nCount = 3
757cdf0e10cSrcweir	    End Try
758cdf0e10cSrcweir        Return False
759cdf0e10cSrcweir    End Function
760cdf0e10cSrcweir
761cdf0e10cSrcweir    Private Shared Function raiseOnewayException(xLBT As XBridgeTest) As Boolean
762cdf0e10cSrcweir        Dim bReturn As Boolean= True
763cdf0e10cSrcweir	    Dim sCompare As String = CONSTANTS.STRING_TEST_CONSTANT
764cdf0e10cSrcweir	    Try
765cdf0e10cSrcweir		    ' Note : the exception may fly or not (e.g. remote scenario).
766cdf0e10cSrcweir		    '        When it flies, it must contain the correct elements.
767cdf0e10cSrcweir		    xLBT.raiseRuntimeExceptionOneway(sCompare, xLBT.Interface )
768cdf0e10cSrcweir	    Catch e As RuntimeException
769cdf0e10cSrcweir		    bReturn =  xLBT.Interface Is e.Context
770cdf0e10cSrcweir	    End Try
771cdf0e10cSrcweir        Return bReturn
772cdf0e10cSrcweir    End Function
773cdf0e10cSrcweir
774cdf0e10cSrcweir    'Test the System::Object method on the proxy object
775cdf0e10cSrcweir    '
776cdf0e10cSrcweir    Private Shared Function testObjectMethodsImplemention(xLBT As XBridgeTest) As Boolean
777cdf0e10cSrcweir        Dim ret As Boolean = False
778cdf0e10cSrcweir        Dim obj As Object = New Object
779cdf0e10cSrcweir	    Dim xInt As Object = DirectCast(xLBT, Object)
780cdf0e10cSrcweir	    Dim xBase As XBridgeTestBase = DirectCast(xLBT, XBridgeTestBase)
781cdf0e10cSrcweir	    ' Object.Equals
782cdf0e10cSrcweir	    ret = DirectCast(xLBT, Object).Equals(obj) = False
783cdf0e10cSrcweir	    ret = DirectCast(xLBT, Object).Equals(xLBT) And ret
784cdf0e10cSrcweir	    ret = Object.Equals(obj, obj) And ret
785cdf0e10cSrcweir	    ret = Object.Equals(xLBT, xBase) And ret
786cdf0e10cSrcweir	    'Object.GetHashCode
787cdf0e10cSrcweir	    ' Don't know how to verify this. Currently it is not possible to get the object id from a proxy
788cdf0e10cSrcweir	    Dim nHash As Integer = DirectCast(xLBT, Object).GetHashCode()
789cdf0e10cSrcweir	    ret = nHash = DirectCast(xBase, Object).GetHashCode() And ret
790cdf0e10cSrcweir
791cdf0e10cSrcweir	    'Object.ToString
792cdf0e10cSrcweir        ' Don't know how to verify this automatically.
793cdf0e10cSrcweir	    Dim s As String = DirectCast(xLBT, Object).ToString()
794cdf0e10cSrcweir        ret = (s.Length > 0) And ret
795cdf0e10cSrcweir        Return ret
796cdf0e10cSrcweir    End Function
797cdf0e10cSrcweir
798cdf0e10cSrcweir    Private Shared Function performQueryForUnknownType(xLBT As XBridgeTest) As Boolean
799cdf0e10cSrcweir        Dim bRet As Boolean = False
800cdf0e10cSrcweir        ' test queryInterface for an unknown type
801cdf0e10cSrcweir        Try
802cdf0e10cSrcweir            Dim a As foo.MyInterface = DirectCast(xLBT, foo.MyInterface)
803cdf0e10cSrcweir        Catch e As System.InvalidCastException
804cdf0e10cSrcweir            bRet = True
805cdf0e10cSrcweir        End Try
806cdf0e10cSrcweir
807cdf0e10cSrcweir        Return bRet
808cdf0e10cSrcweir    End Function
809cdf0e10cSrcweir
810cdf0e10cSrcweir
811cdf0e10cSrcweir    Private Shared Sub perform_test( xLBT As XBridgeTest)
812cdf0e10cSrcweir        Dim bRet As Boolean = True
813cdf0e10cSrcweir        bRet = check( performTest( xLBT ), "standard test" ) And bRet
814cdf0e10cSrcweir        bRet = check( raiseException( xLBT ) , "exception test" ) And bRet
815cdf0e10cSrcweir        bRet = check( raiseOnewayException( xLBT ), "oneway exception test" ) _
816cdf0e10cSrcweir               And bRet
817cdf0e10cSrcweir        bRet = check( testObjectMethodsImplemention(xLBT), _
818cdf0e10cSrcweir               "object methods test") And bRet
819cdf0e10cSrcweir        bRet = performQueryForUnknownType( xLBT ) And bRet
820cdf0e10cSrcweir        If  Not bRet
821cdf0e10cSrcweir            Throw New unoidl.com.sun.star.uno.RuntimeException( "error: test failed!", Nothing)
822cdf0e10cSrcweir        End If
823cdf0e10cSrcweir    End Sub
824cdf0e10cSrcweir
825cdf0e10cSrcweir
826cdf0e10cSrcweir
827cdf0e10cSrcweir    Public Overridable Function run(args() As String) As Integer _
828cdf0e10cSrcweir	   Implements XMain.run
829cdf0e10cSrcweir        Try
830cdf0e10cSrcweir            If (args.Length < 1)
831cdf0e10cSrcweir                Throw New RuntimeException( _
832cdf0e10cSrcweir                    "missing argument for bridgetest!", Me )
833cdf0e10cSrcweir            End If
834cdf0e10cSrcweir
835cdf0e10cSrcweir            Dim test_obj As Object = _
836cdf0e10cSrcweir                m_xContext.getServiceManager().createInstanceWithContext( _
837cdf0e10cSrcweir                    args( 0 ), m_xContext )
838cdf0e10cSrcweir
839cdf0e10cSrcweir            Debug.WriteLine( _
840cdf0e10cSrcweir                "cli target bridgetest obj: {0}", test_obj.ToString() )
841cdf0e10cSrcweir            Dim xTest As XBridgeTest = DirectCast(test_obj, XBridgeTest)
842cdf0e10cSrcweir            perform_test( xTest )
843cdf0e10cSrcweir            Console.WriteLine("### cli_uno VB bridgetest succeeded.")
844cdf0e10cSrcweir            return 0
845cdf0e10cSrcweir	Catch e as unoidl.com.sun.star.uno.RuntimeException
846cdf0e10cSrcweir	     Throw
847cdf0e10cSrcweir        Catch e as System.Exception
848cdf0e10cSrcweir	      Throw New unoidl.com.sun.star.uno.RuntimeException( _
849cdf0e10cSrcweir		    "cli_vb_bridgetest.vb: unexpected exception occured in XMain::run. " _
850cdf0e10cSrcweir		    & "Original exception: " + e.GetType().Name + "\n Message: " _
851cdf0e10cSrcweir		    & e.Message , Nothing)
852cdf0e10cSrcweir
853cdf0e10cSrcweir        End Try
854cdf0e10cSrcweir    End Function
855cdf0e10cSrcweir
856cdf0e10cSrcweirEnd Class
857cdf0e10cSrcweir
858cdf0e10cSrcweirEnd Namespace
859