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