merge the formfield patch from ooo-build
[ooovba.git] / testtools / source / bridgetest / cli / cli_vb_testobj.vb
blob1d9482a07b58445af6068647eccb9d8a284bf98f
1 '*************************************************************************
3 ' DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4 '
5 ' Copyright 2008 by Sun Microsystems, Inc.
7 ' OpenOffice.org - a multi-platform office productivity suite
9 ' $RCSfile: cli_vb_testobj.vb,v $
11 ' $Revision: 1.5 $
13 ' This file is part of OpenOffice.org.
15 ' OpenOffice.org is free software: you can redistribute it and/or modify
16 ' it under the terms of the GNU Lesser General Public License version 3
17 ' only, as published by the Free Software Foundation.
19 ' OpenOffice.org is distributed in the hope that it will be useful,
20 ' but WITHOUT ANY WARRANTY; without even the implied warranty of
21 ' MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
22 ' GNU Lesser General Public License version 3 for more details
23 ' (a copy is included in the LICENSE file that accompanied this code).
25 ' You should have received a copy of the GNU Lesser General Public License
26 ' version 3 along with OpenOffice.org. If not, see
27 ' <http://www.openoffice.org/license.html>
28 ' for a copy of the LGPLv3 License.
30 '*************************************************************************
32 Option Explicit On
33 Option Strict On
35 imports System
36 imports uno
37 imports uno.util
38 imports unoidl.com.sun.star.lang
39 imports unoidl.com.sun.star.uno
40 imports unoidl.com.sun.star.test.bridge
41 imports System.Windows.Forms
42 imports System.Diagnostics
43 imports System.Reflection
46 Namespace vb_testobj
47 Public Class VBBridgeTestObject
48 Inherits WeakBase
49 Implements XRecursiveCall, XBridgeTest2
51 Private m_xContext As XComponentContext
53 Public Sub New (xContext As XComponentContext)
54 MyBase.New
55 m_xContext = xContext
56 End Sub
58 Private m_bool As Boolean
59 Private m_char As Char
60 Private m_byte As Byte
61 Private m_short As Short
62 Private m_ushort As UInt16
63 Private m_long As Integer
64 Private m_ulong As UInt32
65 Private m_hyper As Long
66 Private m_uhyper As UInt64
67 Private m_float As Single
68 Private m_double As Double
69 Private m_string As String
70 Private m_xInterface As Object
71 Private m_any As Any
72 Private m_testEnum As TestEnum = TestEnum.TEST
73 Private m_testElements() As TestElement = New TestElement(){}
74 Private m_testDataElements As TestDataElements = New TestDataElements
75 Private m_nLastCallId As Integer = 0
76 Private m_bFirstCall As Boolean = True
77 Private m_bSequenceOfCallTestPassed As Boolean = True
79 Private m_arBool() As Boolean
80 Private m_arChar() As Char
81 Private m_arByte() As Byte
82 Private m_arShort() As Short
83 Private m_arLong() As Integer
84 Private m_arHyper() As Long
85 Private m_arUShort() As UInt16
86 Private m_arULong() As UInt32
87 Private m_arUHyper() As UInt64
88 Private m_arString() As String
89 Private m_arFloat() As Single
90 Private m_arDouble() As Double
91 Private m_arEnum() As TestEnum
92 Private m_arObject() As Object
93 Private m_arLong2()() As Integer
94 Private m_arLong3()()() As Integer
95 Private m_arAny() As Any
97 Public Overridable Sub setValues( _
98 bBool As Boolean, aChar As Char, nByte As Byte, nShort As Short, _
99 nUShort As UInt16, nLong As Integer, nULong As UInt32, _
100 nHyper As Long, nUHyper As UInt64, fFloat As Single, _
101 fDouble As Double, testEnum As TestEnum, str As String, _
102 xInterface As Object, any As Any, testElements() As TestElement, _
103 testDataElements As TestDataElements) _
104 Implements XBridgeTest2.setValues
105 #if DEBUG
106 ' Console.WriteLine( "##### " + GetType().FullName + ".setValues:" + any )
107 #endif
108 m_bool = bBool
109 m_char = aChar
110 m_byte = nByte
111 m_short = nShort
112 m_ushort = nUShort
113 m_long = nLong
114 m_ulong = nULong
115 m_hyper = nHyper
116 m_uhyper = nUHyper
117 m_float = fFloat
118 m_double = fDouble
119 m_testEnum = testEnum
120 m_string = str
121 m_xInterface = xInterface
122 m_any = any
123 m_testElements = testElements
124 m_testDataElements = testDataElements
125 End Sub
127 Public Overridable Function setValues2( _
128 ByRef io_bool As Boolean, ByRef io_char As Char, _
129 ByRef io_byte As Byte, ByRef io_short As Short, _
130 ByRef io_ushort As UInt16, ByRef io_long As Integer, _
131 ByRef io_ulong As UInt32, ByRef io_hyper As Long, _
132 ByRef io_uhyper As UInt64, ByRef io_float As Single, _
133 ByRef io_double As Double, ByRef io_testEnum As TestEnum, _
134 ByRef io_string As String, ByRef io_xInterface As Object, _
135 ByRef io_any As Any, ByRef io_testElements() As TestElement, _
136 ByRef io_testDataElements As TestDataElements) As TestDataElements _
137 Implements XBridgeTest2.setValues2
139 #if DEBUG
140 'Console.WriteLine( "##### " + GetType().FullName + ".setValues2:" + io_any )
141 #endif
143 m_bool = io_bool
144 m_char = io_char
145 m_byte = io_byte
146 m_short = io_short
147 m_ushort = io_ushort
148 m_long = io_long
149 m_ulong = io_ulong
150 m_hyper = io_hyper
151 m_uhyper = io_uhyper
152 m_float = io_float
153 m_double = io_double
154 m_testEnum = io_testEnum
155 m_string = io_string
156 m_xInterface = io_xInterface
157 m_any = io_any
158 m_testElements = DirectCast(io_testElements.Clone(), TestElement())
159 m_testDataElements = io_testDataElements
161 Dim temp As TestElement = io_testElements(0)
162 io_testElements(0) = io_testElements(1)
163 io_testElements(1) = temp
165 Return m_testDataElements
166 End Function
168 Public Overridable Function getValues( _
169 ByRef o_bool As Boolean, ByRef o_char As Char, _
170 ByRef o_byte As Byte, ByRef o_short As Short, _
171 ByRef o_ushort As UInt16, ByRef o_long As Integer, _
172 ByRef o_ulong As UInt32, ByRef o_hyper As Long, _
173 ByRef o_uhyper As UInt64, ByRef o_float As Single, _
174 ByRef o_double As Double, ByRef o_testEnum As TestEnum, _
175 ByRef o_string As String, ByRef o_xInterface As Object, _
176 ByRef o_any As Any, ByRef o_testElements() As TestElement, _
177 ByRef o_testDataElements As TestDataElements) As TestDataElements _
178 Implements XBridgeTest2.getValues
179 #if DEBUG
180 'Console.WriteLine( "##### " + GetType().FullName + ".getValues" )
181 #endif
183 o_bool = m_bool
184 o_char = m_char
185 o_byte = m_byte
186 o_short = m_short
187 o_ushort = m_ushort
188 o_long = m_long
189 o_ulong = m_ulong
190 o_hyper = m_hyper
191 o_uhyper = m_uhyper
192 o_float = m_float
193 o_double = m_double
194 o_testEnum = m_testEnum
195 o_string = m_string
196 o_xInterface = m_xInterface
197 o_any = m_any
198 o_testElements = m_testElements
199 o_testDataElements = m_testDataElements
201 Return m_testDataElements
202 End Function
204 ' Attributes ---------------------------------------------------------
205 Public Overridable Property Bool As Boolean _
206 Implements XBridgeTest2.Bool
207 Get
208 Return m_bool
209 End Get
210 Set (Value As Boolean)
211 m_bool = value
212 End Set
213 End Property
215 Public Overridable Property [Byte] As Byte _
216 Implements XBridgeTest2.Byte
217 Get
218 Return m_byte
219 End Get
220 Set (Value As Byte)
221 m_byte = value
222 End Set
223 End Property
225 Public Overridable Property [Char] As Char _
226 Implements XBridgeTest2.Char
228 Return m_char
229 End Get
230 Set (Value As Char)
231 m_char = value
232 End Set
233 End Property
235 Public Overridable Property [Short] As Short _
236 Implements XBridgeTest2.Short
237 Get
238 Return m_short
239 End Get
240 Set (Value As Short)
241 m_short = value
242 End Set
243 End Property
245 Public Overridable Property [UShort] As UInt16 _
246 Implements XBridgeTest2.UShort
248 Return m_ushort
249 End Get
250 Set (Value As UInt16)
251 m_ushort = value
252 End Set
253 End Property
255 Public Overridable Property [Long] As Integer _
256 Implements XBridgeTest2.Long
258 Return m_long
259 End Get
260 Set (Value As Integer)
261 m_long = value
262 End Set
263 End Property
265 Public Overridable Property [ULong]() As UInt32 _
266 Implements XBridgeTest2.ULong
268 Return m_ulong
269 End Get
270 Set (Value As UInt32)
271 m_ulong = value
272 End Set
273 End Property
275 Public Overridable Property Hyper As Long _
276 Implements XBridgeTest2.Hyper
278 Return m_hyper
279 End Get
280 Set (Value As Long)
281 m_hyper = value
282 End Set
283 End Property
285 Public Overridable Property UHyper As UInt64 _
286 Implements XBridgeTest2.UHyper
287 Get
288 Return m_uhyper
289 End Get
290 Set (Value As UInt64)
291 m_uhyper = value
292 End Set
293 End Property
295 Public Overridable Property Float As Single _
296 Implements XBridgeTest2.Float
298 Return m_float
299 End Get
300 Set (Value As Single)
301 m_float = value
302 End Set
303 End Property
305 Public Overridable Property [Double] As Double _
306 Implements XBridgeTest2.Double
308 Return m_double
309 End Get
310 Set (Value As Double)
311 m_double = value
312 End Set
313 End Property
315 Public Overridable Property [Enum] As TestEnum _
316 Implements XBridgeTest2.Enum
317 Get
318 Return m_testEnum
319 End Get
320 Set (Value As TestEnum)
321 m_testEnum = value
322 End Set
323 End Property
325 Public Overridable Property [String] As String _
326 Implements XBridgeTest2.String
328 Return m_string
329 End Get
330 Set (Value As String)
331 m_string = value
332 End Set
333 End Property
335 Public Overridable Property [Interface] As Object _
336 Implements XBridgeTest2.Interface
337 Get
338 Return m_xInterface
339 End Get
340 Set (Value As Object)
341 m_xInterface = value
342 End Set
343 End Property
345 Public Overridable Property Any As uno.Any _
346 Implements XBridgeTest2.Any
348 #if DEBUG
349 ' Console.WriteLine( "##### " + GetType().FullName + ".Any" )
350 #endif
351 Return m_any
352 End Get
353 Set (Value As Any)
354 #if DEBUG
355 'Console.WriteLine( "##### " + GetType().FullName + ".Any:" + value )
356 #endif
357 m_any = value
358 End Set
359 End Property
361 Public Overridable Property Sequence As TestElement() _
362 Implements XBridgeTest2.Sequence
364 Return m_testElements
365 End Get
366 Set (Value() As TestElement)
367 m_testElements = value
368 End Set
369 End Property
371 Public Overridable Property Struct As TestDataElements _
372 Implements XBridgeTest2.Struct
374 Return m_testDataElements
375 End Get
376 Set (Value As TestDataElements)
377 m_testDataElements = value
378 End Set
379 End Property
381 Public Overridable Function transportAny(value As Any) As Any _
382 Implements XBridgeTest2.transportAny
383 Return value
384 End Function
386 Public Overridable Sub [call](nCallId As Integer, nWaitMUSEC As Integer) _
387 Implements XBridgeTest2.call
389 Threading.Thread.Sleep(CType(nWaitMUSEC / 10000, Integer))
390 If m_bFirstCall = True
391 m_bFirstCall = False
392 Else
393 m_bSequenceOfCallTestPassed = m_bSequenceOfCallTestPassed And (nCallId > m_nLastCallId)
394 End If
395 m_nLastCallId = nCallId
396 End Sub
398 Public Overridable Sub callOneway(nCallId As Integer, nWaitMUSEC As Integer) _
399 Implements XBridgeTest2.callOneway
401 Threading.Thread.Sleep(CType(nWaitMUSEC / 10000, Integer))
402 m_bSequenceOfCallTestPassed = m_bSequenceOfCallTestPassed And (nCallId > m_nLastCallId)
403 m_nLastCallId = nCallId
404 End Sub
406 Public Overridable Function sequenceOfCallTestPassed() As Boolean _
407 Implements XBridgeTest2.sequenceOfCallTestPassed
408 Return m_bSequenceOfCallTestPassed
409 End Function
411 Public Overridable Sub callRecursivly(xCall As XRecursiveCall, nToCall As Integer) _
412 Implements XRecursiveCall.callRecursivly
413 SyncLock (Me)
414 If nToCall <> 0
415 nToCall = nToCall - 1
416 xCall.callRecursivly(Me , nToCall)
417 End If
418 End SyncLock
419 End Sub
421 Public Overridable Sub startRecursiveCall(xCall As XRecursiveCall, nToCall As Integer) _
422 Implements XBridgeTest2.startRecursiveCall
423 SyncLock (Me)
424 If nToCall <> 0
425 nToCall = nToCall - 1
426 xCall.callRecursivly(Me , nToCall )
427 End If
428 End SyncLock
429 End Sub
431 ' XBridgeTest
432 Public Overridable Function raiseException( _
433 nArgumentPos As Short, rMsg As String, xContext As Object) As TestDataElements _
434 Implements XBridgeTest2.raiseException
435 Throw New IllegalArgumentException(rMsg, xContext, nArgumentPos)
436 End Function
438 Public Overridable Sub raiseRuntimeExceptionOneway(rMsg As String , xContext As Object) _
439 Implements XBridgeTest2.raiseRuntimeExceptionOneway
440 Throw New RuntimeException(rMsg, xContext)
441 End Sub
443 Public Overridable Property RuntimeException As Integer _
444 Implements XBridgeTest2.RuntimeException
446 Throw New RuntimeException(m_string, m_xInterface)
447 End Get
448 Set (Value As Integer)
449 Throw New RuntimeException(m_string, m_xInterface)
450 End Set
451 End Property
453 ' XBridgeTest2
454 Public Overridable Function setDim2(val()() As Integer) As Integer()() _
455 Implements XBridgeTest2.setDim2
456 m_arLong2 = val
457 Return val
458 End Function
460 Public Overridable Function setDim3(val()()() As Integer) As Integer()()() _
461 Implements XBridgeTest2.setDim3
462 m_arLong3 = val
463 Return val
464 End Function
466 Public Overridable Function setSequenceAny(val() As Any) As Any() _
467 Implements XBridgeTest2.setSequenceAny
468 m_arAny = val
469 Return val
470 End Function
472 Public Overridable Function setSequenceBool(val() As Boolean) As Boolean() _
473 Implements XBridgeTest2.setSequenceBool
474 m_arBool = val
475 Return val
476 End Function
478 Public Overridable Function setSequenceByte(val() As Byte) As Byte() _
479 Implements XBridgeTest2.setSequenceByte
480 m_arByte = val
481 Return val
482 End Function
484 Public Overridable Function setSequenceChar(val() As Char) As Char() _
485 Implements XBridgeTest2.setSequenceChar
486 m_arChar = val
487 Return val
488 End Function
490 Public Overridable Function setSequenceShort(val() As Short) As Short() _
491 Implements XBridgeTest2.setSequenceShort
492 m_arShort = val
493 Return val
494 End Function
496 Public Overridable Function setSequenceLong(val() As Integer) As Integer() _
497 Implements XBridgeTest2.setSequenceLong
499 m_arLong = val
500 Return val
501 End Function
503 Public Overridable Function setSequenceHyper(val() As Long) As Long() _
504 Implements XBridgeTest2.setSequenceHyper
505 m_arHyper = val
506 Return val
507 End Function
509 Public Overridable Function setSequenceFloat(val() As Single) As Single() _
510 Implements XBridgeTest2.setSequenceFloat
511 m_arFloat = val
512 Return val
513 End Function
515 Public Overridable Function setSequenceDouble(val() As Double) As Double() _
516 Implements XBridgeTest2.setSequenceDouble
517 m_arDouble = val
518 Return val
519 End Function
521 Public Overridable Function setSequenceEnum(val() As TestEnum) As TestEnum() _
522 Implements XBridgeTest2.setSequenceEnum
523 m_arEnum = val
524 Return val
525 End Function
527 Public Overridable Function setSequenceUShort(val() As UInt16) As UInt16() _
528 Implements XBridgeTest2.setSequenceUShort
529 m_arUShort = val
530 Return val
531 End Function
533 Public Overridable Function setSequenceULong(val() As UInt32) As UInt32() _
534 Implements XBridgeTest2.setSequenceULong
535 m_arULong = val
536 Return val
537 End Function
539 Public Overridable Function setSequenceUHyper(val() As UInt64) As UInt64() _
540 Implements XBridgeTest2.setSequenceUHyper
541 m_arUHyper = val
542 Return val
543 End Function
545 Public Overridable Function setSequenceXInterface(val() As Object ) As Object() _
546 Implements XBridgeTest2.setSequenceXInterface
547 m_arObject = val
548 Return val
549 End Function
551 Public Overridable Function setSequenceString(val() As String) As String() _
552 Implements XBridgeTest2.setSequenceString
553 m_arString = val
554 Return val
555 End Function
557 Public Overridable Function setSequenceStruct(val() As TestElement) As TestElement() _
558 Implements XBridgeTest2.setSequenceStruct
559 m_testElements = val
560 Return val
561 End Function
563 Public Overridable Sub setSequencesInOut( _
564 ByRef aSeqBoolean() As Boolean, ByRef aSeqChar() As Char, _
565 ByRef aSeqByte() As Byte, ByRef aSeqShort() As Short, _
566 ByRef aSeqUShort() As UInt16, ByRef aSeqLong() As Integer, _
567 ByRef aSeqULong() As UInt32, ByRef aSeqHyper() As Long, _
568 ByRef aSeqUHyper() As UInt64, ByRef aSeqFloat() As Single, _
569 ByRef aSeqDouble() As Double, ByRef aSeqTestEnum() As TestEnum, _
570 ByRef aSeqString() As String, ByRef aSeqXInterface() As Object, _
571 ByRef aSeqAny() As Any, ByRef aSeqDim2()() As Integer, _
572 ByRef aSeqDim3()()() As Integer) _
573 Implements XBridgeTest2.setSequencesInOut
575 m_arBool = aSeqBoolean
576 m_arChar = aSeqChar
577 m_arByte = aSeqByte
578 m_arShort = aSeqShort
579 m_arUShort = aSeqUShort
580 m_arLong = aSeqLong
581 m_arULong = aSeqULong
582 m_arHyper = aSeqHyper
583 m_arUHyper = aSeqUHyper
584 m_arFloat = aSeqFloat
585 m_arDouble = aSeqDouble
586 m_arEnum = aSeqTestEnum
587 m_arString = aSeqString
588 m_arObject = aSeqXInterface
589 m_arAny = aSeqAny
590 m_arLong2 = aSeqDim2
591 m_arLong3 = aSeqDim3
592 End Sub
594 Public Overridable Sub setSequencesOut( _
595 ByRef aSeqBoolean() As Boolean, ByRef aSeqChar() As Char, _
596 ByRef aSeqByte() As Byte, ByRef aSeqShort() As Short, _
597 ByRef aSeqUShort() As UInt16, ByRef aSeqLong() As Integer, _
598 ByRef aSeqULong() As UInt32, ByRef aSeqHyper() As Long, _
599 ByRef aSeqUHyper() As UInt64, ByRef aSeqFloat() As Single, _
600 ByRef aSeqDouble() As Double, ByRef aSeqTestEnum() As TestEnum, _
601 ByRef aSeqString() As String, ByRef aSeqXInterface() As Object, _
602 ByRef aSeqAny() As Any, ByRef aSeqDim2()() As Integer, _
603 ByRef aSeqDim3()()() As Integer) _
604 Implements XBridgeTest2.setSequencesOut
606 aSeqBoolean = m_arBool
607 aSeqChar = m_arChar
608 aSeqByte = m_arByte
609 aSeqShort = m_arShort
610 aSeqUShort = m_arUShort
611 aSeqLong = m_arLong
612 aSeqULong = m_arULong
613 aSeqHyper = m_arHyper
614 aSeqUHyper = m_arUHyper
615 aSeqFloat = m_arFloat
616 aSeqDouble = m_arDouble
617 aSeqTestEnum = m_arEnum
618 aSeqString = m_arString
619 aSeqXInterface = m_arObject
620 aSeqAny = m_arAny
621 aSeqDim2 = m_arLong2
622 aSeqDim3 = m_arLong3
624 End Sub
626 End Class
628 End Namespace