bump product version to 5.0.4.1
[LibreOffice.git] / testtools / source / bridgetest / cli / cli_vb_testobj.vb
blobd90b94e4a4b5e7f5f9703eb51c106a782d8425f5
2 ' This file is part of the LibreOffice project.
4 ' This Source Code Form is subject to the terms of the Mozilla Public
5 ' License, v. 2.0. If a copy of the MPL was not distributed with this
6 ' file, You can obtain one at http://mozilla.org/MPL/2.0/.
8 ' This file incorporates work covered by the following license notice:
10 ' Licensed to the Apache Software Foundation (ASF) under one or more
11 ' contributor license agreements. See the NOTICE file distributed
12 ' with this work for additional information regarding copyright
13 ' ownership. The ASF licenses this file to you under the Apache
14 ' License, Version 2.0 (the "License"); you may not use this file
15 ' except in compliance with the License. You may obtain a copy of
16 ' the License at http://www.apache.org/licenses/LICENSE-2.0 .
19 Option Explicit On
20 Option Strict On
22 imports System
23 imports uno
24 imports uno.util
25 imports unoidl.com.sun.star.lang
26 imports unoidl.com.sun.star.uno
27 imports unoidl.com.sun.star.test.bridge
28 imports System.Windows.Forms
29 imports System.Diagnostics
30 imports System.Reflection
33 Namespace vb_testobj
34 Public Class VBBridgeTestObject
35 Inherits WeakBase
36 Implements XRecursiveCall, XBridgeTest2
38 Private m_xContext As XComponentContext
40 Public Sub New (xContext As XComponentContext)
41 MyBase.New
42 m_xContext = xContext
43 End Sub
45 Private m_bool As Boolean
46 Private m_char As Char
47 Private m_byte As Byte
48 Private m_short As Short
49 Private m_ushort As UInt16
50 Private m_long As Integer
51 Private m_ulong As UInt32
52 Private m_hyper As Long
53 Private m_uhyper As UInt64
54 Private m_float As Single
55 Private m_double As Double
56 Private m_string As String
57 Private m_xInterface As Object
58 Private m_any As Any
59 Private m_testEnum As TestEnum = TestEnum.TEST
60 Private m_testElements() As TestElement = New TestElement(){}
61 Private m_testDataElements As TestDataElements = New TestDataElements
62 Private m_nLastCallId As Integer = 0
63 Private m_bFirstCall As Boolean = True
64 Private m_bSequenceOfCallTestPassed As Boolean = True
66 Private m_arBool() As Boolean
67 Private m_arChar() As Char
68 Private m_arByte() As Byte
69 Private m_arShort() As Short
70 Private m_arLong() As Integer
71 Private m_arHyper() As Long
72 Private m_arUShort() As UInt16
73 Private m_arULong() As UInt32
74 Private m_arUHyper() As UInt64
75 Private m_arString() As String
76 Private m_arFloat() As Single
77 Private m_arDouble() As Double
78 Private m_arEnum() As TestEnum
79 Private m_arObject() As Object
80 Private m_arLong2()() As Integer
81 Private m_arLong3()()() As Integer
82 Private m_arAny() As Any
84 Public Overridable Sub setValues( _
85 bBool As Boolean, aChar As Char, nByte As Byte, nShort As Short, _
86 nUShort As UInt16, nLong As Integer, nULong As UInt32, _
87 nHyper As Long, nUHyper As UInt64, fFloat As Single, _
88 fDouble As Double, testEnum As TestEnum, str As String, _
89 xInterface As Object, any As Any, testElements() As TestElement, _
90 testDataElements As TestDataElements) _
91 Implements XBridgeTest2.setValues
92 #if DEBUG
93 ' Console.WriteLine( "##### " + GetType().FullName + ".setValues:" + any )
94 #endif
95 m_bool = bBool
96 m_char = aChar
97 m_byte = nByte
98 m_short = nShort
99 m_ushort = nUShort
100 m_long = nLong
101 m_ulong = nULong
102 m_hyper = nHyper
103 m_uhyper = nUHyper
104 m_float = fFloat
105 m_double = fDouble
106 m_testEnum = testEnum
107 m_string = str
108 m_xInterface = xInterface
109 m_any = any
110 m_testElements = testElements
111 m_testDataElements = testDataElements
112 End Sub
114 Public Overridable Function setValues2( _
115 ByRef io_bool As Boolean, ByRef io_char As Char, _
116 ByRef io_byte As Byte, ByRef io_short As Short, _
117 ByRef io_ushort As UInt16, ByRef io_long As Integer, _
118 ByRef io_ulong As UInt32, ByRef io_hyper As Long, _
119 ByRef io_uhyper As UInt64, ByRef io_float As Single, _
120 ByRef io_double As Double, ByRef io_testEnum As TestEnum, _
121 ByRef io_string As String, ByRef io_xInterface As Object, _
122 ByRef io_any As Any, ByRef io_testElements() As TestElement, _
123 ByRef io_testDataElements As TestDataElements) As TestDataElements _
124 Implements XBridgeTest2.setValues2
126 #if DEBUG
127 'Console.WriteLine( "##### " + GetType().FullName + ".setValues2:" + io_any )
128 #endif
130 m_bool = io_bool
131 m_char = io_char
132 m_byte = io_byte
133 m_short = io_short
134 m_ushort = io_ushort
135 m_long = io_long
136 m_ulong = io_ulong
137 m_hyper = io_hyper
138 m_uhyper = io_uhyper
139 m_float = io_float
140 m_double = io_double
141 m_testEnum = io_testEnum
142 m_string = io_string
143 m_xInterface = io_xInterface
144 m_any = io_any
145 m_testElements = DirectCast(io_testElements.Clone(), TestElement())
146 m_testDataElements = io_testDataElements
148 Dim temp As TestElement = io_testElements(0)
149 io_testElements(0) = io_testElements(1)
150 io_testElements(1) = temp
152 Return m_testDataElements
153 End Function
155 Public Overridable Function getValues( _
156 ByRef o_bool As Boolean, ByRef o_char As Char, _
157 ByRef o_byte As Byte, ByRef o_short As Short, _
158 ByRef o_ushort As UInt16, ByRef o_long As Integer, _
159 ByRef o_ulong As UInt32, ByRef o_hyper As Long, _
160 ByRef o_uhyper As UInt64, ByRef o_float As Single, _
161 ByRef o_double As Double, ByRef o_testEnum As TestEnum, _
162 ByRef o_string As String, ByRef o_xInterface As Object, _
163 ByRef o_any As Any, ByRef o_testElements() As TestElement, _
164 ByRef o_testDataElements As TestDataElements) As TestDataElements _
165 Implements XBridgeTest2.getValues
166 #if DEBUG
167 'Console.WriteLine( "##### " + GetType().FullName + ".getValues" )
168 #endif
170 o_bool = m_bool
171 o_char = m_char
172 o_byte = m_byte
173 o_short = m_short
174 o_ushort = m_ushort
175 o_long = m_long
176 o_ulong = m_ulong
177 o_hyper = m_hyper
178 o_uhyper = m_uhyper
179 o_float = m_float
180 o_double = m_double
181 o_testEnum = m_testEnum
182 o_string = m_string
183 o_xInterface = m_xInterface
184 o_any = m_any
185 o_testElements = m_testElements
186 o_testDataElements = m_testDataElements
188 Return m_testDataElements
189 End Function
191 ' Attributes ---------------------------------------------------------
192 Public Overridable Property Bool As Boolean _
193 Implements XBridgeTest2.Bool
194 Get
195 Return m_bool
196 End Get
197 Set (Value As Boolean)
198 m_bool = value
199 End Set
200 End Property
202 Public Overridable Property [Byte] As Byte _
203 Implements XBridgeTest2.Byte
204 Get
205 Return m_byte
206 End Get
207 Set (Value As Byte)
208 m_byte = value
209 End Set
210 End Property
212 Public Overridable Property [Char] As Char _
213 Implements XBridgeTest2.Char
215 Return m_char
216 End Get
217 Set (Value As Char)
218 m_char = value
219 End Set
220 End Property
222 Public Overridable Property [Short] As Short _
223 Implements XBridgeTest2.Short
224 Get
225 Return m_short
226 End Get
227 Set (Value As Short)
228 m_short = value
229 End Set
230 End Property
232 Public Overridable Property [UShort] As UInt16 _
233 Implements XBridgeTest2.UShort
235 Return m_ushort
236 End Get
237 Set (Value As UInt16)
238 m_ushort = value
239 End Set
240 End Property
242 Public Overridable Property [Long] As Integer _
243 Implements XBridgeTest2.Long
245 Return m_long
246 End Get
247 Set (Value As Integer)
248 m_long = value
249 End Set
250 End Property
252 Public Overridable Property [ULong]() As UInt32 _
253 Implements XBridgeTest2.ULong
255 Return m_ulong
256 End Get
257 Set (Value As UInt32)
258 m_ulong = value
259 End Set
260 End Property
262 Public Overridable Property Hyper As Long _
263 Implements XBridgeTest2.Hyper
265 Return m_hyper
266 End Get
267 Set (Value As Long)
268 m_hyper = value
269 End Set
270 End Property
272 Public Overridable Property UHyper As UInt64 _
273 Implements XBridgeTest2.UHyper
274 Get
275 Return m_uhyper
276 End Get
277 Set (Value As UInt64)
278 m_uhyper = value
279 End Set
280 End Property
282 Public Overridable Property Float As Single _
283 Implements XBridgeTest2.Float
285 Return m_float
286 End Get
287 Set (Value As Single)
288 m_float = value
289 End Set
290 End Property
292 Public Overridable Property [Double] As Double _
293 Implements XBridgeTest2.Double
295 Return m_double
296 End Get
297 Set (Value As Double)
298 m_double = value
299 End Set
300 End Property
302 Public Overridable Property [Enum] As TestEnum _
303 Implements XBridgeTest2.Enum
304 Get
305 Return m_testEnum
306 End Get
307 Set (Value As TestEnum)
308 m_testEnum = value
309 End Set
310 End Property
312 Public Overridable Property [String] As String _
313 Implements XBridgeTest2.String
315 Return m_string
316 End Get
317 Set (Value As String)
318 m_string = value
319 End Set
320 End Property
322 Public Overridable Property [Interface] As Object _
323 Implements XBridgeTest2.Interface
324 Get
325 Return m_xInterface
326 End Get
327 Set (Value As Object)
328 m_xInterface = value
329 End Set
330 End Property
332 Public Overridable Property Any As uno.Any _
333 Implements XBridgeTest2.Any
335 #if DEBUG
336 ' Console.WriteLine( "##### " + GetType().FullName + ".Any" )
337 #endif
338 Return m_any
339 End Get
340 Set (Value As Any)
341 #if DEBUG
342 'Console.WriteLine( "##### " + GetType().FullName + ".Any:" + value )
343 #endif
344 m_any = value
345 End Set
346 End Property
348 Public Overridable Property Sequence As TestElement() _
349 Implements XBridgeTest2.Sequence
351 Return m_testElements
352 End Get
353 Set (Value() As TestElement)
354 m_testElements = value
355 End Set
356 End Property
358 Public Overridable Property Struct As TestDataElements _
359 Implements XBridgeTest2.Struct
361 Return m_testDataElements
362 End Get
363 Set (Value As TestDataElements)
364 m_testDataElements = value
365 End Set
366 End Property
368 Public Overridable Function transportAny(value As Any) As Any _
369 Implements XBridgeTest2.transportAny
370 Return value
371 End Function
373 Public Overridable Sub [call](nCallId As Integer, nWaitMUSEC As Integer) _
374 Implements XBridgeTest2.call
376 Threading.Thread.Sleep(CType(nWaitMUSEC / 10000, Integer))
377 If m_bFirstCall = True
378 m_bFirstCall = False
379 Else
380 m_bSequenceOfCallTestPassed = m_bSequenceOfCallTestPassed And (nCallId > m_nLastCallId)
381 End If
382 m_nLastCallId = nCallId
383 End Sub
385 Public Overridable Sub callOneway(nCallId As Integer, nWaitMUSEC As Integer) _
386 Implements XBridgeTest2.callOneway
388 Threading.Thread.Sleep(CType(nWaitMUSEC / 10000, Integer))
389 m_bSequenceOfCallTestPassed = m_bSequenceOfCallTestPassed And (nCallId > m_nLastCallId)
390 m_nLastCallId = nCallId
391 End Sub
393 Public Overridable Function sequenceOfCallTestPassed() As Boolean _
394 Implements XBridgeTest2.sequenceOfCallTestPassed
395 Return m_bSequenceOfCallTestPassed
396 End Function
398 Public Overridable Sub callRecursivly(xCall As XRecursiveCall, nToCall As Integer) _
399 Implements XRecursiveCall.callRecursivly
400 SyncLock (Me)
401 If nToCall <> 0
402 nToCall = nToCall - 1
403 xCall.callRecursivly(Me , nToCall)
404 End If
405 End SyncLock
406 End Sub
408 Public Overridable Sub startRecursiveCall(xCall As XRecursiveCall, nToCall As Integer) _
409 Implements XBridgeTest2.startRecursiveCall
410 SyncLock (Me)
411 If nToCall <> 0
412 nToCall = nToCall - 1
413 xCall.callRecursivly(Me , nToCall )
414 End If
415 End SyncLock
416 End Sub
418 ' XBridgeTest
419 Public Overridable Function raiseException( _
420 nArgumentPos As Short, rMsg As String, xContext As Object) As TestDataElements _
421 Implements XBridgeTest2.raiseException
422 Throw New IllegalArgumentException(rMsg, xContext, nArgumentPos)
423 End Function
425 Public Overridable Sub raiseRuntimeExceptionOneway(rMsg As String , xContext As Object) _
426 Implements XBridgeTest2.raiseRuntimeExceptionOneway
427 Throw New RuntimeException(rMsg, xContext)
428 End Sub
430 Public Overridable Property RuntimeException As Integer _
431 Implements XBridgeTest2.RuntimeException
433 Throw New RuntimeException(m_string, m_xInterface)
434 End Get
435 Set (Value As Integer)
436 Throw New RuntimeException(m_string, m_xInterface)
437 End Set
438 End Property
440 ' XBridgeTest2
441 Public Overridable Function setDim2(val()() As Integer) As Integer()() _
442 Implements XBridgeTest2.setDim2
443 m_arLong2 = val
444 Return val
445 End Function
447 Public Overridable Function setDim3(val()()() As Integer) As Integer()()() _
448 Implements XBridgeTest2.setDim3
449 m_arLong3 = val
450 Return val
451 End Function
453 Public Overridable Function setSequenceAny(val() As Any) As Any() _
454 Implements XBridgeTest2.setSequenceAny
455 m_arAny = val
456 Return val
457 End Function
459 Public Overridable Function setSequenceBool(val() As Boolean) As Boolean() _
460 Implements XBridgeTest2.setSequenceBool
461 m_arBool = val
462 Return val
463 End Function
465 Public Overridable Function setSequenceByte(val() As Byte) As Byte() _
466 Implements XBridgeTest2.setSequenceByte
467 m_arByte = val
468 Return val
469 End Function
471 Public Overridable Function setSequenceChar(val() As Char) As Char() _
472 Implements XBridgeTest2.setSequenceChar
473 m_arChar = val
474 Return val
475 End Function
477 Public Overridable Function setSequenceShort(val() As Short) As Short() _
478 Implements XBridgeTest2.setSequenceShort
479 m_arShort = val
480 Return val
481 End Function
483 Public Overridable Function setSequenceLong(val() As Integer) As Integer() _
484 Implements XBridgeTest2.setSequenceLong
486 m_arLong = val
487 Return val
488 End Function
490 Public Overridable Function setSequenceHyper(val() As Long) As Long() _
491 Implements XBridgeTest2.setSequenceHyper
492 m_arHyper = val
493 Return val
494 End Function
496 Public Overridable Function setSequenceFloat(val() As Single) As Single() _
497 Implements XBridgeTest2.setSequenceFloat
498 m_arFloat = val
499 Return val
500 End Function
502 Public Overridable Function setSequenceDouble(val() As Double) As Double() _
503 Implements XBridgeTest2.setSequenceDouble
504 m_arDouble = val
505 Return val
506 End Function
508 Public Overridable Function setSequenceEnum(val() As TestEnum) As TestEnum() _
509 Implements XBridgeTest2.setSequenceEnum
510 m_arEnum = val
511 Return val
512 End Function
514 Public Overridable Function setSequenceUShort(val() As UInt16) As UInt16() _
515 Implements XBridgeTest2.setSequenceUShort
516 m_arUShort = val
517 Return val
518 End Function
520 Public Overridable Function setSequenceULong(val() As UInt32) As UInt32() _
521 Implements XBridgeTest2.setSequenceULong
522 m_arULong = val
523 Return val
524 End Function
526 Public Overridable Function setSequenceUHyper(val() As UInt64) As UInt64() _
527 Implements XBridgeTest2.setSequenceUHyper
528 m_arUHyper = val
529 Return val
530 End Function
532 Public Overridable Function setSequenceXInterface(val() As Object ) As Object() _
533 Implements XBridgeTest2.setSequenceXInterface
534 m_arObject = val
535 Return val
536 End Function
538 Public Overridable Function setSequenceString(val() As String) As String() _
539 Implements XBridgeTest2.setSequenceString
540 m_arString = val
541 Return val
542 End Function
544 Public Overridable Function setSequenceStruct(val() As TestElement) As TestElement() _
545 Implements XBridgeTest2.setSequenceStruct
546 m_testElements = val
547 Return val
548 End Function
550 Public Overridable Sub setSequencesInOut( _
551 ByRef aSeqBoolean() As Boolean, ByRef aSeqChar() As Char, _
552 ByRef aSeqByte() As Byte, ByRef aSeqShort() As Short, _
553 ByRef aSeqUShort() As UInt16, ByRef aSeqLong() As Integer, _
554 ByRef aSeqULong() As UInt32, ByRef aSeqHyper() As Long, _
555 ByRef aSeqUHyper() As UInt64, ByRef aSeqFloat() As Single, _
556 ByRef aSeqDouble() As Double, ByRef aSeqTestEnum() As TestEnum, _
557 ByRef aSeqString() As String, ByRef aSeqXInterface() As Object, _
558 ByRef aSeqAny() As Any, ByRef aSeqDim2()() As Integer, _
559 ByRef aSeqDim3()()() As Integer) _
560 Implements XBridgeTest2.setSequencesInOut
562 m_arBool = aSeqBoolean
563 m_arChar = aSeqChar
564 m_arByte = aSeqByte
565 m_arShort = aSeqShort
566 m_arUShort = aSeqUShort
567 m_arLong = aSeqLong
568 m_arULong = aSeqULong
569 m_arHyper = aSeqHyper
570 m_arUHyper = aSeqUHyper
571 m_arFloat = aSeqFloat
572 m_arDouble = aSeqDouble
573 m_arEnum = aSeqTestEnum
574 m_arString = aSeqString
575 m_arObject = aSeqXInterface
576 m_arAny = aSeqAny
577 m_arLong2 = aSeqDim2
578 m_arLong3 = aSeqDim3
579 End Sub
581 Public Overridable Sub setSequencesOut( _
582 ByRef aSeqBoolean() As Boolean, ByRef aSeqChar() As Char, _
583 ByRef aSeqByte() As Byte, ByRef aSeqShort() As Short, _
584 ByRef aSeqUShort() As UInt16, ByRef aSeqLong() As Integer, _
585 ByRef aSeqULong() As UInt32, ByRef aSeqHyper() As Long, _
586 ByRef aSeqUHyper() As UInt64, ByRef aSeqFloat() As Single, _
587 ByRef aSeqDouble() As Double, ByRef aSeqTestEnum() As TestEnum, _
588 ByRef aSeqString() As String, ByRef aSeqXInterface() As Object, _
589 ByRef aSeqAny() As Any, ByRef aSeqDim2()() As Integer, _
590 ByRef aSeqDim3()()() As Integer) _
591 Implements XBridgeTest2.setSequencesOut
593 aSeqBoolean = m_arBool
594 aSeqChar = m_arChar
595 aSeqByte = m_arByte
596 aSeqShort = m_arShort
597 aSeqUShort = m_arUShort
598 aSeqLong = m_arLong
599 aSeqULong = m_arULong
600 aSeqHyper = m_arHyper
601 aSeqUHyper = m_arUHyper
602 aSeqFloat = m_arFloat
603 aSeqDouble = m_arDouble
604 aSeqTestEnum = m_arEnum
605 aSeqString = m_arString
606 aSeqXInterface = m_arObject
607 aSeqAny = m_arAny
608 aSeqDim2 = m_arLong2
609 aSeqDim3 = m_arLong3
611 End Sub
613 End Class
615 End Namespace