tdf#130857 qt weld: Implement QtInstanceWidget::strip_mnemonic
[LibreOffice.git] / testtools / com / sun / star / comp / bridge / TestComponent.java
blob9180d9cb010af23433502d400b129c911577c610
1 /*
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 package com.sun.star.comp.bridge;
21 import com.sun.star.comp.loader.FactoryHelper;
23 import com.sun.star.lang.XServiceInfo;
24 import com.sun.star.lang.XTypeProvider;
26 import com.sun.star.test.performance.ComplexTypes;
27 import com.sun.star.test.performance.XPerformanceTest;
29 import test.testtools.bridgetest.BadConstructorArguments;
30 import test.testtools.bridgetest.Constructors;
31 import test.testtools.bridgetest.Constructors2;
32 import test.testtools.bridgetest.TestDataElements;
33 import test.testtools.bridgetest.TestElement;
34 import test.testtools.bridgetest.TestEnum;
35 import test.testtools.bridgetest.TestPolyStruct;
36 import test.testtools.bridgetest.TestPolyStruct2;
37 import test.testtools.bridgetest.TestStruct;
38 import test.testtools.bridgetest.SmallStruct;
39 import test.testtools.bridgetest.MediumStruct;
40 import test.testtools.bridgetest.BigStruct;
41 import test.testtools.bridgetest.TwoFloats;
42 import test.testtools.bridgetest.FourFloats;
43 import test.testtools.bridgetest.MixedFloatAndInteger;
44 import test.testtools.bridgetest.DoubleHyper;
45 import test.testtools.bridgetest.HyperDouble;
46 import test.testtools.bridgetest.FloatFloatLongByte;
47 import test.testtools.bridgetest.ThreeByteStruct;
48 import test.testtools.bridgetest.XBridgeTest;
49 import test.testtools.bridgetest.XBridgeTest2;
50 import test.testtools.bridgetest.XCurrentContextChecker;
51 import test.testtools.bridgetest.XMulti;
52 import test.testtools.bridgetest.XRecursiveCall;
55 import com.sun.star.lang.IllegalArgumentException;
56 import com.sun.star.lang.XMultiServiceFactory;
57 import com.sun.star.lang.XSingleServiceFactory;
59 import com.sun.star.registry.XRegistryKey;
61 import com.sun.star.uno.Any;
62 import com.sun.star.uno.Type;
63 import com.sun.star.uno.XComponentContext;
64 import com.sun.star.uno.XInterface;
66 @SuppressWarnings("unchecked")
67 public class TestComponent {
68 public static final boolean DEBUG = false;
70 public static class _PerformancTestObject implements XPerformanceTest, XServiceInfo, XTypeProvider {
71 private static final String __serviceName = "com.sun.star.comp.benchmark.JavaTestObject";
73 private int _long;
74 private long _hyper;
75 private float _float;
76 private double _double;
77 private String _string = "";
78 private Object _xInterface;
79 private Object _any;
80 private Object _interface_sequence[] = new Object[0];
81 private ComplexTypes _complexTypes = new ComplexTypes();
83 // Attributes
84 public int getLong_attr() throws com.sun.star.uno.RuntimeException {
85 return _long;
88 public void setLong_attr( int _long_attr ) throws com.sun.star.uno.RuntimeException {
89 _long = _long_attr;
92 public long getHyper_attr() throws com.sun.star.uno.RuntimeException {
93 return _hyper;
96 public void setHyper_attr( long _hyper_attr ) throws com.sun.star.uno.RuntimeException {
97 _hyper = _hyper_attr;
100 public float getFloat_attr() throws com.sun.star.uno.RuntimeException {
101 return _float;
104 public void setFloat_attr( float _float_attr ) throws com.sun.star.uno.RuntimeException {
105 _float = _float_attr;
108 public double getDouble_attr() throws com.sun.star.uno.RuntimeException {
109 return _double;
112 public void setDouble_attr( double _double_attr ) throws com.sun.star.uno.RuntimeException {
113 _double = _double_attr;
116 public String getString_attr() throws com.sun.star.uno.RuntimeException {
117 return _string;
120 public void setString_attr( String _string_attr ) throws com.sun.star.uno.RuntimeException {
121 _string = _string_attr;
124 public Object getInterface_attr() throws com.sun.star.uno.RuntimeException {
125 return _xInterface;
128 public void setInterface_attr( java.lang.Object _interface_attr ) throws com.sun.star.uno.RuntimeException {
129 _xInterface = _interface_attr;
132 public Object getAny_attr() throws com.sun.star.uno.RuntimeException {
133 return _any;
136 public void setAny_attr(Object _any_attr ) throws com.sun.star.uno.RuntimeException {
137 _any = _any_attr;
140 public Object[] getSequence_attr() throws com.sun.star.uno.RuntimeException {
141 return _interface_sequence;
144 public void setSequence_attr(Object[] _sequence_attr ) throws com.sun.star.uno.RuntimeException {
145 _interface_sequence = _sequence_attr;
148 public ComplexTypes getStruct_attr() throws com.sun.star.uno.RuntimeException {
149 return _complexTypes;
152 public void setStruct_attr( ComplexTypes _struct_attr ) throws com.sun.star.uno.RuntimeException {
153 _complexTypes = _struct_attr;
157 // Methods
158 public void async() throws com.sun.star.uno.RuntimeException {
161 public void sync( ) throws com.sun.star.uno.RuntimeException {
164 public ComplexTypes complexIn( /*IN*/ComplexTypes aVal ) throws com.sun.star.uno.RuntimeException {
165 return aVal;
168 public ComplexTypes complexInout( /*INOUT*/ComplexTypes[] aVal ) throws com.sun.star.uno.RuntimeException {
169 return aVal[0];
172 public void complexOneway( /*IN*/ComplexTypes aVal ) throws com.sun.star.uno.RuntimeException {
175 public void complexNoreturn( /*IN*/ComplexTypes aVal ) throws com.sun.star.uno.RuntimeException {
178 public XPerformanceTest createObject( ) throws com.sun.star.uno.RuntimeException {
179 return new _PerformancTestObject();
182 public int getLong() throws com.sun.star.uno.RuntimeException {
183 return _long;
186 public void setLong(/*IN*/int n) throws com.sun.star.uno.RuntimeException {
187 _long = n;
190 public long getHyper() throws com.sun.star.uno.RuntimeException {
191 return _hyper;
194 public void setHyper(/*IN*/long n) throws com.sun.star.uno.RuntimeException {
195 _hyper = n;
198 public float getFloat() throws com.sun.star.uno.RuntimeException {
199 return _float;
202 public void setFloat( /*IN*/float f ) throws com.sun.star.uno.RuntimeException {
203 _float = f;
206 public double getDouble( ) throws com.sun.star.uno.RuntimeException {
207 return _double;
210 public void setDouble( /*IN*/double f ) throws com.sun.star.uno.RuntimeException {
211 _double = f;
214 public String getString( ) throws com.sun.star.uno.RuntimeException {
215 return _string;
218 public void setString( /*IN*/String s ) throws com.sun.star.uno.RuntimeException {
219 _string = s;
222 public Object getInterface( ) throws com.sun.star.uno.RuntimeException {
223 return _xInterface;
226 public void setInterface( /*IN*/Object x ) throws com.sun.star.uno.RuntimeException {
227 _xInterface = x;
230 public Object getAny( ) throws com.sun.star.uno.RuntimeException {
231 return _any;
234 public void setAny( /*IN*/java.lang.Object a ) throws com.sun.star.uno.RuntimeException {
235 _any = a;
238 public Object[] getSequence( ) throws com.sun.star.uno.RuntimeException {
239 return _interface_sequence;
242 public void setSequence( /*IN*/Object[] seq ) throws com.sun.star.uno.RuntimeException {
243 if(DEBUG) System.err.println("#### " + getClass().getName() + ".setSequence:" + seq);
245 _interface_sequence = seq;
248 public ComplexTypes getStruct( ) throws com.sun.star.uno.RuntimeException {
249 return _complexTypes;
252 public void setStruct( /*IN*/ComplexTypes c ) throws com.sun.star.uno.RuntimeException {
253 _complexTypes = c;
256 public void raiseRuntimeException( ) throws com.sun.star.uno.RuntimeException {
257 throw new com.sun.star.uno.RuntimeException();
260 // XServiceInfo
261 public String getImplementationName() throws com.sun.star.uno.RuntimeException {
262 return __serviceName;
265 public boolean supportsService(String rServiceName) throws com.sun.star.uno.RuntimeException {
266 String rSNL[] = getSupportedServiceNames();
268 for(int nPos = rSNL.length; (nPos--) != 0;) {
269 if (rSNL[nPos].equals(rServiceName))
270 return true;
273 return false;
276 public String [] getSupportedServiceNames() throws com.sun.star.uno.RuntimeException {
277 return new String[]{__serviceName};
280 // XTypeProvider
281 public Type[] getTypes() throws com.sun.star.uno.RuntimeException {
282 try {
283 return new Type[]{new Type(XPerformanceTest.class), new Type(XServiceInfo.class), new Type(XTypeProvider.class)};
285 catch(Exception exception) {
286 throw new com.sun.star.uno.RuntimeException(exception);
290 public byte[] getImplementationId() throws com.sun.star.uno.RuntimeException {
291 return new byte[0];
295 public static class _TestObject implements XBridgeTest2, XRecursiveCall, XServiceInfo, XTypeProvider {
296 private static final String __serviceName = "com.sun.star.test.bridge.JavaTestObject";
298 private boolean _bool;
299 private char _char;
300 private byte _byte;
301 private short _short;
302 private short _ushort;
303 private int _long;
304 private int _ulong;
305 private long _hyper;
306 private long _uhyper;
307 private float _float;
308 private double _double;
309 private String _string;
310 private byte _byte2;
311 private short _short2;
312 private Object _xInterface;
313 private Object _any;
314 private TestEnum _testEnum = TestEnum.TEST;
315 private TestElement _testElements[] = new TestElement[0];
316 private TestDataElements _testDataElements = new TestDataElements();
318 private int _nLastCallId;
319 private boolean _bFirstCall;
320 private boolean _bSequenceOfCallTestPassed;
322 private boolean[] arBool;
323 private char[] arChar;
324 private byte[] arByte;
325 private short[] arShort;
326 private short[] arUShort;
327 private int[] arLong;
328 private int[] arULong;
329 private long[] arHyper;
330 private long[] arUHyper;
331 private float[] arFloat;
332 private double[] arDouble;
333 private String[] arString;
334 private Object[] arObject;
335 private Object[] arAny;
336 private TestEnum[] arEnum;
337 private int[][] arLong2;
338 private int[][][] arLong3;
339 public _TestObject(XMultiServiceFactory xMultiServiceFactory) {
340 if(DEBUG) System.err.println("##### " + getClass().getName() + ".<init> " + xMultiServiceFactory);
342 _nLastCallId = 0;
343 _bFirstCall = true;
344 _bSequenceOfCallTestPassed = true;
348 public void setValues(boolean bBool,
349 char cChar,
350 byte nByte,
351 short nShort,
352 short nUShort,
353 int nLong,
354 int nULong,
355 long nHyper,
356 long nUHyper,
357 float fFloat,
358 double fDouble,
359 TestEnum testEnum,
360 String string,
361 byte nByte2,
362 short nShort2,
363 Object xInterface,
364 Object any,
365 TestElement testElements[],
366 TestDataElements testDataElements) throws com.sun.star.uno.RuntimeException
368 if(DEBUG) System.err.println("##### " + getClass().getName() + ".setValues:" + any);
370 _bool = bBool;
371 _char = cChar;
372 _byte = nByte;
373 _short = nShort;
374 _ushort = nUShort;
375 _long = nLong;
376 _ulong = nULong;
377 _hyper = nHyper;
378 _uhyper = nUHyper;
379 _float = fFloat;
380 _double = fDouble;
381 _testEnum = testEnum;
382 _string = string;
383 _byte2 = nByte2;
384 _short2 = nShort2;
385 _xInterface = xInterface;
386 _any = any;
387 _testElements = testElements;
388 _testDataElements = testDataElements;
393 public TestDataElements setValues2(/*INOUT*/boolean[] io_bool,
394 /*INOUT*/char[] io_char,
395 /*INOUT*/byte[] io_byte,
396 /*INOUT*/short[] io_short,
397 /*INOUT*/short[] io_ushort,
398 /*INOUT*/int[] io_long,
399 /*INOUT*/int[] io_ulong,
400 /*INOUT*/long[] io_hyper,
401 /*INOUT*/long[] io_uhyper,
402 /*INOUT*/float[] io_float,
403 /*INOUT*/double[] io_double,
404 /*INOUT*/TestEnum[] io_testEnum,
405 /*INOUT*/String[] io_string,
406 /*INOUT*/byte[] io_byte2,
407 /*INOUT*/short[] io_short2,
408 /*INOUT*/Object[] io_xInterface,
409 /*INOUT*/Object[] io_any,
410 /*INOUT*/TestElement[][] io_testElements,
411 /*INOUT*/TestDataElements[] io_testDataElements) throws com.sun.star.uno.RuntimeException
413 if(DEBUG) System.err.println("##### " + getClass().getName() + ".setValues2:" + io_any[0]);
415 _bool = io_bool[0];
416 _char = io_char[0];
417 _byte = io_byte[0];
418 _short = io_short[0];
419 _ushort = io_ushort[0];
420 _long = io_long[0];
421 _ulong = io_ulong[0];
422 _hyper = io_hyper[0];
423 _uhyper = io_uhyper[0];
424 _float = io_float[0];
425 _double = io_double[0];
426 _testEnum = io_testEnum[0];
427 _string = io_string[0];
428 _byte2 = io_byte2[0];
429 _short2 = io_short2[0];
430 _xInterface = io_xInterface[0];
431 _any = io_any[0];
432 _testElements = io_testElements[0];
433 _testDataElements = io_testDataElements[0];
435 io_testElements[ 0 ] =
436 new TestElement [] { io_testElements[ 0 ][ 1 ], io_testElements[ 0 ][ 0 ] };
438 return _testDataElements;
441 public TestDataElements getValues(/*OUT*/boolean[] o_bool,
442 /*OUT*/char[] o_char,
443 /*OUT*/byte[] o_byte,
444 /*OUT*/short[] o_short,
445 /*OUT*/short[] o_ushort,
446 /*OUT*/int[] o_long,
447 /*OUT*/int[] o_ulong,
448 /*OUT*/long[] o_hyper,
449 /*OUT*/long[] o_uhyper,
450 /*OUT*/float[] o_float,
451 /*OUT*/double[] o_double,
452 /*OUT*/TestEnum[] o_testEnum,
453 /*OUT*/String[] o_string,
454 /*OUT*/byte[] o_byte2,
455 /*OUT*/short[] o_short2,
456 /*OUT*/Object[] o_xInterface,
457 /*OUT*/Object[] o_any,
458 /*OUT*/TestElement[][] o_testElements,
459 /*OUT*/TestDataElements[] o_testDataElements) throws com.sun.star.uno.RuntimeException
461 if(DEBUG) System.err.println("##### " + getClass().getName() + ".getValues:" + _any);
463 o_bool[0] = _bool;
464 o_char[0] = _char;
465 o_byte[0] = _byte;
466 o_short[0] = _short;
467 o_ushort[0] = _ushort;
468 o_long[0] = _long;
469 o_ulong[0] = _ulong;
470 o_hyper[0] = _hyper;
471 o_uhyper[0] = _uhyper;
472 o_float[0] = _float;
473 o_double[0] = _double;
474 o_testEnum[0] = _testEnum;
475 o_string[0] = _string;
476 o_byte2[0] = _byte2;
477 o_short2[0] = _short2;
478 o_xInterface[0] = _xInterface;
479 o_any[0] = _any;
480 o_testElements[0] = _testElements;
481 o_testDataElements[0] = _testDataElements;
483 return _testDataElements;
486 public SmallStruct echoSmallStruct( SmallStruct i_Struct) throws com.sun.star.uno.RuntimeException {
487 return i_Struct;
490 public MediumStruct echoMediumStruct( MediumStruct i_Struct) throws com.sun.star.uno.RuntimeException {
491 return i_Struct;
494 public BigStruct echoBigStruct( BigStruct i_Struct) throws com.sun.star.uno.RuntimeException {
495 return i_Struct;
498 public TwoFloats echoTwoFloats( TwoFloats i_Struct) throws com.sun.star.uno.RuntimeException {
499 return i_Struct;
502 public FourFloats echoFourFloats( FourFloats i_Struct) throws com.sun.star.uno.RuntimeException {
503 return i_Struct;
506 public MixedFloatAndInteger echoMixedFloatAndInteger( MixedFloatAndInteger i_Struct) throws com.sun.star.uno.RuntimeException {
507 return i_Struct;
510 public DoubleHyper echoDoubleHyper(DoubleHyper s) throws com.sun.star.uno.RuntimeException {
511 return s;
514 public HyperDouble echoHyperDouble(HyperDouble s) throws com.sun.star.uno.RuntimeException {
515 return s;
518 public FloatFloatLongByte echoFloatFloatLongByte(FloatFloatLongByte s)
519 throws com.sun.star.uno.RuntimeException
521 return s;
524 public ThreeByteStruct echoThreeByteStruct( ThreeByteStruct i_Struct) throws com.sun.star.uno.RuntimeException {
525 return i_Struct;
528 public int testPPCAlignment( long l1, long l2, int i1, long l3, int i2 ) throws com.sun.star.uno.RuntimeException {
529 return i2;
532 public int testPPC64Alignment( double d1, double d2, double d3, int i1 ) throws com.sun.star.uno.RuntimeException {
533 return i1;
536 public double testTenDoubles( double d1, double d2, double d3, double d4, double d5, double d6, double d7, double d8, double d9, double d10 ) {
537 return d1 + d2 + d3 + d4 + d5 + d6 + d7 + d8 + d9 + d10;
540 // Attributes
541 public boolean getBool() throws com.sun.star.uno.RuntimeException {
542 return _bool;
545 public void setBool(boolean bool) throws com.sun.star.uno.RuntimeException {
546 _bool = bool;
549 public byte getByte() throws com.sun.star.uno.RuntimeException {
550 return _byte;
553 public void setByte(byte zbyte) throws com.sun.star.uno.RuntimeException {
554 _byte = zbyte;
557 public char getChar() throws com.sun.star.uno.RuntimeException {
558 return _char;
561 public void setChar(char zchar) throws com.sun.star.uno.RuntimeException {
562 _char = zchar;
565 public short getShort() throws com.sun.star.uno.RuntimeException {
566 return _short;
569 public void setShort(short zshort) throws com.sun.star.uno.RuntimeException {
570 _short = zshort;
573 public short getUShort() throws com.sun.star.uno.RuntimeException {
574 return _ushort;
577 public void setUShort(short ushort) throws com.sun.star.uno.RuntimeException {
578 _ushort = ushort;
581 public int getLong() throws com.sun.star.uno.RuntimeException {
582 return _long;
585 public void setLong(int zint) throws com.sun.star.uno.RuntimeException {
586 _long = zint;
589 public int getULong() throws com.sun.star.uno.RuntimeException {
590 return _ulong;
593 public void setULong(int uint) throws com.sun.star.uno.RuntimeException {
594 _ulong = uint;
597 public long getHyper() throws com.sun.star.uno.RuntimeException {
598 return _hyper;
601 public void setHyper(long hyper) throws com.sun.star.uno.RuntimeException {
602 _hyper = hyper;
605 public long getUHyper() throws com.sun.star.uno.RuntimeException {
606 return _uhyper;
609 public void setUHyper(long uhyper) throws com.sun.star.uno.RuntimeException {
610 _uhyper = uhyper;
613 public float getFloat() throws com.sun.star.uno.RuntimeException {
614 return _float;
617 public void setFloat(float zfloat) throws com.sun.star.uno.RuntimeException {
618 _float = zfloat;
621 public double getDouble() throws com.sun.star.uno.RuntimeException {
622 return _double;
625 public void setDouble(double zdouble) throws com.sun.star.uno.RuntimeException {
626 _double = zdouble;
629 public TestEnum getEnum() throws com.sun.star.uno.RuntimeException {
630 return _testEnum;
633 public void setEnum(TestEnum testEnum) throws com.sun.star.uno.RuntimeException {
634 _testEnum = testEnum;
637 public String getString() throws com.sun.star.uno.RuntimeException {
638 return _string;
641 public void setString(String string) throws com.sun.star.uno.RuntimeException {
642 _string = string;
645 public byte getByte2() throws com.sun.star.uno.RuntimeException {
646 return _byte2;
649 public void setByte2(byte zbyte) throws com.sun.star.uno.RuntimeException {
650 _byte2 = zbyte;
653 public short getShort2() throws com.sun.star.uno.RuntimeException {
654 return _short2;
657 public void setShort2(short zshort) throws com.sun.star.uno.RuntimeException {
658 _short2 = zshort;
661 public Object getInterface() throws com.sun.star.uno.RuntimeException {
662 return _xInterface;
665 public void setInterface(Object zinterface) throws com.sun.star.uno.RuntimeException {
666 _xInterface = zinterface;
669 public Object getAny() throws com.sun.star.uno.RuntimeException {
670 if(DEBUG) System.err.println("##### " + getClass().getName() + ".setAny:" + _any);
672 return _any;
675 public void setAny(Object any) throws com.sun.star.uno.RuntimeException {
676 if(DEBUG) System.err.println("##### " + getClass().getName() + ".setAny:" + any);
678 _any = any;
681 public TestElement[] getSequence() throws com.sun.star.uno.RuntimeException {
682 return _testElements;
685 public void setSequence(TestElement testElements[]) throws com.sun.star.uno.RuntimeException {
686 _testElements = testElements;
689 public TestDataElements getStruct() throws com.sun.star.uno.RuntimeException {
690 return _testDataElements;
693 public void setStruct(TestDataElements testDataElements) throws com.sun.star.uno.RuntimeException {
694 _testDataElements = testDataElements;
697 public int getRaiseAttr1() {
698 throw new com.sun.star.uno.RuntimeException();
701 public void setRaiseAttr1(int n) throws IllegalArgumentException {
702 throw new IllegalArgumentException();
705 public int getRaiseAttr2() throws IllegalArgumentException {
706 throw new IllegalArgumentException();
709 public TestPolyStruct transportPolyBoolean(TestPolyStruct arg) {
710 Boolean dummy = (Boolean) arg.member;
711 return arg;
714 public void transportPolyHyper(TestPolyStruct[] arg) {
715 Long dummy = (Long) arg[0].member;
718 public void transportPolySequence(
719 TestPolyStruct arg1, TestPolyStruct[] arg2)
721 Object[] dummy = (Object[]) arg1.member;
722 arg2[0] = arg1;
725 public TestPolyStruct getNullPolyLong() {
726 return new TestPolyStruct();
729 public TestPolyStruct getNullPolyString() {
730 return new TestPolyStruct();
733 public TestPolyStruct getNullPolyType() {
734 return new TestPolyStruct();
737 public TestPolyStruct getNullPolyAny() {
738 return new TestPolyStruct();
741 public TestPolyStruct getNullPolySequence() {
742 return new TestPolyStruct();
745 public TestPolyStruct getNullPolyEnum() {
746 return new TestPolyStruct();
749 public TestPolyStruct getNullPolyBadEnum() {
750 return new TestPolyStruct();
753 public TestPolyStruct getNullPolyStruct() {
754 return new TestPolyStruct();
757 public TestPolyStruct getNullPolyInterface() {
758 return new TestPolyStruct();
761 public Object transportAny(Object value) throws com.sun.star.uno.RuntimeException {
762 return value;
765 public void call(int nCallId , int nWaitMUSEC) throws com.sun.star.uno.RuntimeException {
766 try {
767 Thread.sleep(nWaitMUSEC / 10000);
769 catch(InterruptedException interruptedException) {
770 throw new com.sun.star.uno.RuntimeException(interruptedException);
773 if(_bFirstCall)
774 _bFirstCall = false;
776 else
777 _bSequenceOfCallTestPassed = _bSequenceOfCallTestPassed && (nCallId > _nLastCallId);
779 _nLastCallId = nCallId;
782 public void callOneway( int nCallId , int nWaitMUSEC ) throws com.sun.star.uno.RuntimeException {
783 try {
784 Thread.sleep(nWaitMUSEC / 10000);
786 catch(InterruptedException interruptedException) {
787 throw new com.sun.star.uno.RuntimeException(interruptedException);
790 _bSequenceOfCallTestPassed = _bSequenceOfCallTestPassed && (nCallId > _nLastCallId);
791 _nLastCallId = nCallId;
794 public boolean sequenceOfCallTestPassed() throws com.sun.star.uno.RuntimeException {
795 return _bSequenceOfCallTestPassed;
798 public synchronized void callRecursivly(XRecursiveCall xCall, int nToCall) throws com.sun.star.uno.RuntimeException {
799 if(nToCall != 0)
801 nToCall --;
802 xCall.callRecursivly(this , nToCall);
806 public synchronized void startRecursiveCall(XRecursiveCall xCall, int nToCall) throws com.sun.star.uno.RuntimeException {
807 if(nToCall != 0)
809 nToCall --;
810 xCall.callRecursivly( this , nToCall );
814 public XMulti getMulti() {
815 return new XMulti() {
816 public double getatt1() {
817 return attribute1;
820 public void setatt1(double value) {
821 attribute1 = value;
824 public int fn11(int arg) {
825 return 11 * arg;
828 public String fn12(String arg) {
829 return "12" + arg;
832 public int fn21(int arg) {
833 return 21 * arg;
836 public String fn22(String arg) {
837 return "22" + arg;
840 public double getatt3() {
841 return attribute3;
844 public void setatt3(double value) {
845 attribute3 = value;
848 public int fn31(int arg) {
849 return 31 * arg;
852 public String fn32(String arg) {
853 return "32" + arg;
856 public int fn33() {
857 return 33;
860 public int fn41(int arg) {
861 return 41 * arg;
864 public int fn61(int arg) {
865 return 61 * arg;
868 public String fn62(String arg) {
869 return "62" + arg;
872 public int fn71(int arg) {
873 return 71 * arg;
876 public String fn72(String arg) {
877 return "72" + arg;
880 public int fn73() {
881 return 73;
884 private double attribute1 = 0.0;
885 private double attribute3 = 0.0;
889 private static final class CheckFailed extends Exception {
890 CheckFailed(String message) {
891 super(message);
895 private static void checkEqual(int value, int argument)
896 throws CheckFailed
898 if (argument != value) {
899 throw new CheckFailed(value + " != " + argument);
903 private static void checkEqual(double value, double argument)
904 throws CheckFailed
906 if (argument != value) {
907 throw new CheckFailed(value + " != " + argument);
911 private static void checkEqual(String value, String argument)
912 throws CheckFailed
914 if (!argument.equals(value)) {
915 throw new CheckFailed(value + " != " + argument);
919 public String testMulti(XMulti multi) {
920 try {
921 checkEqual(0.0, multi.getatt1());
922 multi.setatt1(0.1);
923 checkEqual(0.1, multi.getatt1());
924 checkEqual(11 * 1, multi.fn11(1));
925 checkEqual("12" + "abc", multi.fn12("abc"));
926 checkEqual(21 * 2, multi.fn21(2));
927 checkEqual("22" + "de", multi.fn22("de"));
928 checkEqual(0.0, multi.getatt3());
929 multi.setatt3(0.3);
930 checkEqual(0.3, multi.getatt3());
931 checkEqual(31 * 3, multi.fn31(3));
932 checkEqual("32" + "f", multi.fn32("f"));
933 checkEqual(33, multi.fn33());
934 checkEqual(41 * 4, multi.fn41(4));
935 checkEqual(61 * 6, multi.fn61(6));
936 checkEqual("62", multi.fn62(""));
937 checkEqual(71 * 7, multi.fn71(7));
938 checkEqual("72" + "g", multi.fn72("g"));
939 checkEqual(73, multi.fn73());
940 } catch (CheckFailed f) {
941 return f.getMessage();
943 return "";
946 // XBridgeTest
947 public TestDataElements raiseException(short nArgumentPos, String rMsg, Object xContext)
948 throws com.sun.star.lang.IllegalArgumentException,
949 com.sun.star.uno.RuntimeException
951 throw new com.sun.star.lang.IllegalArgumentException(rMsg, xContext, nArgumentPos);
954 public void raiseRuntimeExceptionOneway(String rMsg, Object xContext) throws com.sun.star.uno.RuntimeException {
955 throw new com.sun.star.uno.RuntimeException(rMsg, xContext);
958 private void dothrow( com.sun.star.uno.RuntimeException t )
959 throws com.sun.star.uno.RuntimeException
961 throw t;
963 public int getRuntimeException()
964 throws com.sun.star.uno.RuntimeException
966 dothrow( new com.sun.star.uno.RuntimeException(
967 _string, _xInterface ) );
968 return 0; // dummy
971 public void setRuntimeException(int _runtimeexception) throws com.sun.star.uno.RuntimeException {
972 throw new com.sun.star.uno.RuntimeException(_string, _xInterface);
977 // XServiceInfo
978 public String getImplementationName() throws com.sun.star.uno.RuntimeException {
979 return __serviceName;
982 public boolean supportsService(String rServiceName) throws com.sun.star.uno.RuntimeException {
983 String rSNL[] = getSupportedServiceNames();
985 for(int nPos = rSNL.length; (nPos--) != 0;) {
986 if (rSNL[nPos].equals(rServiceName))
987 return true;
990 return false;
993 public String [] getSupportedServiceNames() throws com.sun.star.uno.RuntimeException {
994 return new String[]{__serviceName};
997 // XTypeProvider
998 public Type[] getTypes() throws com.sun.star.uno.RuntimeException {
999 try {
1000 return new Type[]{new Type(XBridgeTest.class), new Type(XRecursiveCall.class), new Type(XServiceInfo.class), new Type(XTypeProvider.class)};
1002 catch(Exception exception) {
1003 throw new com.sun.star.uno.RuntimeException(exception);
1007 public byte[] getImplementationId() throws com.sun.star.uno.RuntimeException {
1008 return new byte[0];
1011 //XBridgeTest2
1012 public boolean[] setSequenceBool( /*IN*/boolean[] aSeq )
1014 arBool = aSeq;
1015 return aSeq;
1017 public char[] setSequenceChar( /*IN*/char[] aSeq )
1019 arChar = aSeq;
1020 return aSeq;
1022 public byte[] setSequenceByte( /*IN*/byte[] aSeq )
1024 arByte = aSeq;
1025 return aSeq;
1027 public short[] setSequenceShort( /*IN*/short[] aSeq )
1029 arShort = aSeq;
1030 return aSeq;
1032 public short[] setSequenceUShort( /*IN*/short[] aSeq )
1034 arUShort = aSeq;
1035 return aSeq;
1037 public int[] setSequenceLong( /*IN*/int[] aSeq )
1039 arLong = aSeq;
1040 return aSeq;
1042 public int[] setSequenceULong( /*IN*/int[] aSeq )
1044 arULong = aSeq;
1045 return aSeq;
1047 public long[] setSequenceHyper( /*IN*/long[] aSeq )
1049 arHyper = aSeq;
1050 return aSeq;
1052 public long[] setSequenceUHyper( /*IN*/long[] aSeq )
1054 arUHyper = aSeq;
1055 return aSeq;
1057 public float[] setSequenceFloat( /*IN*/float[] aSeq )
1059 arFloat = aSeq;
1060 return aSeq;
1062 public double[] setSequenceDouble( /*IN*/double[] aSeq )
1064 arDouble = aSeq;
1065 return aSeq;
1067 public TestEnum[] setSequenceEnum( /*IN*/TestEnum[] aSeq )
1069 arEnum = aSeq;
1070 return aSeq;
1072 public String[] setSequenceString( /*IN*/String[] aSeq )
1074 arString = aSeq;
1075 return aSeq;
1077 public java.lang.Object[] setSequenceXInterface( /*IN*/java.lang.Object[] aSeq )
1079 arObject = aSeq;
1080 return aSeq;
1082 public java.lang.Object[] setSequenceAny( /*IN*/java.lang.Object[] aSeq )
1084 arAny = aSeq;
1085 return aSeq;
1087 public TestElement[] setSequenceStruct( /*IN*/TestElement[] aSeq )
1089 _testElements = aSeq;
1090 return aSeq;
1092 public int[][] setDim2( /*IN*/int[][] aSeq )
1094 arLong2 = aSeq;
1095 return aSeq;
1097 public int[][][] setDim3( /*IN*/int[][][] aSeq )
1099 arLong3 = aSeq;
1100 return aSeq;
1102 public void setSequencesInOut( /*INOUT*/boolean[][] aSeqBoolean,
1103 /*INOUT*/char[][] aSeqChar, /*INOUT*/byte[][] aSeqByte,
1104 /*INOUT*/short[][] aSeqShort, /*INOUT*/short[][] aSeqUShort,
1105 /*INOUT*/int[][] aSeqLong, /*INOUT*/int[][] aSeqULong,
1106 /*INOUT*/long[][] aSeqHyper, /*INOUT*/long[][] aSeqUHyper,
1107 /*INOUT*/float[][] aSeqFloat, /*INOUT*/double[][] aSeqDouble,
1108 /*INOUT*/TestEnum[][] aSeqEnum, /*INOUT*/String[][] aSeqString,
1109 /*INOUT*/java.lang.Object[][] aSeqXInterface,
1110 /*INOUT*/java.lang.Object[][] aSeqAny,
1111 /*INOUT*/int[][][] aSeqDim2, /*INOUT*/int[][][][] aSeqDim3 )
1113 arBool = aSeqBoolean[0];
1114 arChar = aSeqChar[0];
1115 arByte = aSeqByte[0];
1116 arShort = aSeqShort[0];
1117 arUShort = aSeqUShort[0];
1118 arLong = aSeqLong[0];
1119 arULong = aSeqULong[0];
1120 arFloat = aSeqFloat[0];
1121 arDouble = aSeqDouble[0];
1122 arEnum = aSeqEnum[0];
1123 arString = aSeqString[0];
1124 arObject = aSeqXInterface[0];
1125 arAny = aSeqAny[0];
1126 arLong2 = aSeqDim2[0];
1127 arLong3 = aSeqDim3[0];
1129 public void setSequencesOut( /*OUT*/boolean[][] aSeqBoolean, /*OUT*/char[][] aSeqChar,
1130 /*OUT*/byte[][] aSeqByte, /*OUT*/short[][] aSeqShort,
1131 /*OUT*/short[][] aSeqUShort, /*OUT*/int[][] aSeqLong,
1132 /*OUT*/int[][] aSeqULong, /*OUT*/long[][] aSeqHyper,
1133 /*OUT*/long[][] aSeqUHyper, /*OUT*/float[][] aSeqFloat,
1134 /*OUT*/double[][] aSeqDouble, /*OUT*/TestEnum[][] aSeqEnum,
1135 /*OUT*/String[][] aSeqString,
1136 /*OUT*/java.lang.Object[][] aSeqXInterface,
1137 /*OUT*/java.lang.Object[][] aSeqAny, /*OUT*/int[][][] aSeqDim2,
1138 /*OUT*/int[][][][] aSeqDim3 )
1140 aSeqBoolean[0] = arBool;
1141 aSeqChar[0] = arChar;
1142 aSeqByte[0] = arByte;
1143 aSeqShort[0] = arShort;
1144 aSeqUShort[0] = arUShort;
1145 aSeqLong[0] = arLong;
1146 aSeqULong[0] = arULong;
1147 aSeqHyper[0] = arHyper;
1148 aSeqUHyper[0] = arUHyper;
1149 aSeqFloat[0] = arFloat;
1150 aSeqDouble[0] = arDouble;
1151 aSeqEnum[0] = arEnum;
1152 aSeqString[0] = arString;
1153 aSeqXInterface[0] = arObject;
1154 aSeqAny[0] = arAny;
1155 aSeqDim2[0] = arLong2;
1156 aSeqDim3[0] = arLong3;
1159 public void testConstructorsService(XComponentContext context)
1160 throws BadConstructorArguments
1162 Constructors.create1(context,
1163 true,
1164 Byte.MIN_VALUE,
1165 Short.MIN_VALUE,
1166 (short) -1,
1167 Integer.MIN_VALUE,
1169 Long.MIN_VALUE,
1170 -1L,
1171 0.123f,
1172 0.456,
1173 'X',
1174 "test",
1175 Type.ANY,
1176 new Any(Type.BOOLEAN, Boolean.TRUE),
1177 new boolean[] { true },
1178 new byte[] { Byte.MIN_VALUE },
1179 new short[] { Short.MIN_VALUE },
1180 new short[] { (short) -1 },
1181 new int[] { Integer.MIN_VALUE },
1182 new int[] { -1 },
1183 new long[] { Long.MIN_VALUE },
1184 new long[] { -1L },
1185 new float[] { 0.123f },
1186 new double[] { 0.456 },
1187 new char[] { 'X' },
1188 new String[] { "test" },
1189 new Type[] { Type.ANY },
1190 new Boolean[] { Boolean.TRUE },
1191 new boolean[][] { new boolean[] { true } },
1192 new Object[][] {
1193 new Object[] { new Any(Type.BOOLEAN, Boolean.TRUE) } },
1194 new TestEnum[] { TestEnum.TWO },
1195 new TestStruct[] { new TestStruct(10) },
1196 new TestPolyStruct[] { new TestPolyStruct(Boolean.TRUE) },
1197 new TestPolyStruct[] {
1198 new TestPolyStruct(new Any(Type.BOOLEAN, Boolean.TRUE)) },
1199 new Object[] { null },
1200 TestEnum.TWO,
1201 new TestStruct(10),
1202 new TestPolyStruct(Boolean.TRUE),
1203 new TestPolyStruct(new Any(Type.BOOLEAN, Boolean.TRUE)),
1204 null);
1205 Constructors.create2(context, new Object[] {
1206 Boolean.TRUE,
1207 Byte.valueOf(Byte.MIN_VALUE),
1208 Short.valueOf(Short.MIN_VALUE),
1209 new Any(Type.UNSIGNED_SHORT, Short.valueOf((short) -1)),
1210 Integer.valueOf(Integer.MIN_VALUE),
1211 new Any(Type.UNSIGNED_LONG, Integer.valueOf(-1)),
1212 Long.valueOf(Long.MIN_VALUE),
1213 new Any(Type.UNSIGNED_HYPER, Long.valueOf(-1L)),
1214 Float.valueOf(0.123f),
1215 Double.valueOf(0.456),
1216 Character.valueOf('X'),
1217 "test",
1218 Type.ANY,
1219 new Any(Type.BOOLEAN, Boolean.TRUE),
1220 new boolean[] { true },
1221 new byte[] { Byte.MIN_VALUE },
1222 new short[] { Short.MIN_VALUE },
1223 new Any(
1224 new Type("[]unsigned short"), new short[] { (short) -1 }),
1225 new int[] { Integer.MIN_VALUE },
1226 new Any(new Type("[]unsigned long"), new int[] { -1 }),
1227 new long[] { Long.MIN_VALUE },
1228 new Any(new Type("[]unsigned hyper"), new long[] { -1L }),
1229 new float[] { 0.123f },
1230 new double[] { 0.456 },
1231 new char[] { 'X' },
1232 new String[] { "test" },
1233 new Type[] { Type.ANY },
1234 new Any(new Type("[]any"), new Boolean[] { Boolean.TRUE }),
1235 new boolean[][] { new boolean[] { true } },
1236 new Object[][] {
1237 new Object[] { new Any(Type.BOOLEAN, Boolean.TRUE) } },
1238 new TestEnum[] { TestEnum.TWO },
1239 new TestStruct[] { new TestStruct(10) },
1240 new Any(
1241 new Type(
1242 "[]test.testtools.bridgetest.TestPolyStruct<boolean>"),
1243 new TestPolyStruct[] { new TestPolyStruct(Boolean.TRUE) }),
1244 new Any(
1245 new Type("[]test.testtools.bridgetest.TestPolyStruct<any>"),
1246 new TestPolyStruct[] {
1247 new TestPolyStruct(new Any(Type.BOOLEAN, Boolean.TRUE))
1249 new XInterface[] { null },
1250 TestEnum.TWO,
1251 new TestStruct(10),
1252 new Any(
1253 new Type(
1254 "test.testtools.bridgetest.TestPolyStruct<boolean>"),
1255 new TestPolyStruct(Boolean.TRUE)),
1256 new Any(
1257 new Type("test.testtools.bridgetest.TestPolyStruct<any>"),
1258 new TestPolyStruct(new Any(Type.BOOLEAN, Boolean.TRUE))),
1259 null });
1260 Constructors2.create1(
1261 context,
1262 new TestPolyStruct(Type.LONG),
1263 new TestPolyStruct(new Any(Type.BOOLEAN, Boolean.TRUE)),
1264 new TestPolyStruct(Boolean.TRUE),
1265 new TestPolyStruct(Byte.valueOf(Byte.MIN_VALUE)),
1266 new TestPolyStruct(Short.valueOf(Short.MIN_VALUE)),
1267 new TestPolyStruct(Integer.valueOf(Integer.MIN_VALUE)),
1268 new TestPolyStruct(Long.valueOf(Long.MIN_VALUE)),
1269 new TestPolyStruct(Character.valueOf('X')),
1270 new TestPolyStruct("test"),
1271 new TestPolyStruct(Float.valueOf(0.123f)),
1272 new TestPolyStruct(Double.valueOf(0.456)),
1273 new TestPolyStruct(new com.sun.star.lib.uno.helper.ComponentBase()),
1274 new TestPolyStruct(new com.sun.star.lib.uno.helper.ComponentBase()),
1275 new TestPolyStruct(TestEnum.TWO),
1276 new TestPolyStruct(new TestPolyStruct2(Character.valueOf('X'),
1277 new Any(Type.BOOLEAN, Boolean.TRUE))),
1278 new TestPolyStruct(new TestPolyStruct2(new TestPolyStruct2(
1279 Character.valueOf('X'), new Any(Type.BOOLEAN, Boolean.TRUE)), "test")),
1280 new TestPolyStruct2("test", new TestPolyStruct2(Character.valueOf('X'),
1281 new TestPolyStruct(new Any(Type.BOOLEAN, Boolean.TRUE)))),
1282 new TestPolyStruct2( new TestPolyStruct2(Character.valueOf('X'),
1283 new Any(Type.BOOLEAN, Boolean.TRUE)), new TestPolyStruct(Character.valueOf('X'))),
1284 new TestPolyStruct(new Type[] { Type.LONG}),
1285 new TestPolyStruct(new Any[] { new Any(Type.BOOLEAN, Boolean.TRUE) }),
1286 new TestPolyStruct(new boolean[] {true}),
1287 new TestPolyStruct(new byte[] {Byte.MIN_VALUE}),
1288 new TestPolyStruct(new short[] {Short.MIN_VALUE}),
1289 new TestPolyStruct(new int[] {Integer.MIN_VALUE}),
1290 new TestPolyStruct(new long[] {Long.MIN_VALUE}),
1291 new TestPolyStruct(new char[] {'X'}),
1292 new TestPolyStruct(new String[] {"test"}),
1293 new TestPolyStruct(new float[] {0.123f}),
1294 new TestPolyStruct(new double[] {0.456d}),
1295 new TestPolyStruct(new Object[] {new com.sun.star.lib.uno.helper.ComponentBase()}),
1296 new TestPolyStruct(new com.sun.star.lang.XComponent[] {new com.sun.star.lib.uno.helper.ComponentBase()}),
1297 new TestPolyStruct(new TestEnum[] {TestEnum.TWO}),
1298 new TestPolyStruct(new TestPolyStruct2[] {new TestPolyStruct2(
1299 Character.valueOf('X'), new Any[] {new Any(Type.BOOLEAN, Boolean.TRUE)})}),
1300 new TestPolyStruct(new TestPolyStruct2[] {new TestPolyStruct2(
1301 new TestPolyStruct(Character.valueOf('X')), new Any[] {new Any(Type.BOOLEAN, Boolean.TRUE)})}),
1302 new TestPolyStruct(new int[][] { new int[] {Integer.MIN_VALUE} }),
1303 new TestPolyStruct[]{ new TestPolyStruct(Integer.valueOf(Integer.MIN_VALUE))},
1304 new TestPolyStruct[]{new TestPolyStruct(new TestPolyStruct2(
1305 Character.valueOf('X'), new Any(Type.BOOLEAN, Boolean.TRUE)))},
1306 new TestPolyStruct[]{new TestPolyStruct(new TestPolyStruct2(
1307 new TestPolyStruct2(Character.valueOf('X'), new Any(Type.BOOLEAN, Boolean.TRUE)), "test"))},
1308 new TestPolyStruct2[]{new TestPolyStruct2("test", new TestPolyStruct2(
1309 Character.valueOf('X'), new TestPolyStruct(new Any(Type.BOOLEAN, Boolean.TRUE))))},
1310 new TestPolyStruct2[]{new TestPolyStruct2(new TestPolyStruct2(Character.valueOf('X'), new Any(
1311 Type.BOOLEAN, Boolean.TRUE)),new TestPolyStruct(Character.valueOf('X')))},
1312 new TestPolyStruct[][]{new TestPolyStruct[]{new TestPolyStruct(Character.valueOf('X'))}},
1313 new TestPolyStruct[][]{new TestPolyStruct[]{
1314 new TestPolyStruct(new TestPolyStruct2(Character.valueOf('X'), new Any(Type.BOOLEAN, Boolean.TRUE)))}},
1315 new TestPolyStruct[][]{new TestPolyStruct[] {new TestPolyStruct(new TestPolyStruct2(
1316 new TestPolyStruct2(Character.valueOf('X'),new Any(Type.BOOLEAN, Boolean.TRUE)), "test"))}},
1317 new TestPolyStruct2[][]{new TestPolyStruct2[]{new TestPolyStruct2(
1318 "test", new TestPolyStruct2(Character.valueOf('X'),new TestPolyStruct(new Any(Type.BOOLEAN, Boolean.TRUE))))}},
1319 new TestPolyStruct2[][]{new TestPolyStruct2[]{new TestPolyStruct2(
1320 new TestPolyStruct2(Character.valueOf('X'),new Any(Type.BOOLEAN, Boolean.TRUE)),
1321 new TestPolyStruct(Character.valueOf('X')))}});
1324 public XCurrentContextChecker getCurrentContextChecker() {
1325 return new CurrentContextChecker();
1330 * Gives a factory for creating the service.
1331 * This method is called by the <code>JavaLoader</code>
1332 * <p>
1333 * @return returns a <code>XSingleServiceFactory</code> for creating the component
1334 * @param implName the name of the implementation for which a service is desired
1335 * @param multiFactory the service manager to be uses if needed
1336 * @param regKey the registryKey
1337 * @see com.sun.star.comp.loader.JavaLoader
1339 public static XSingleServiceFactory __getServiceFactory(String implName,
1340 XMultiServiceFactory multiFactory,
1341 XRegistryKey regKey)
1343 XSingleServiceFactory xSingleServiceFactory = null;
1345 if(implName.equals(_TestObject.class.getName()))
1346 xSingleServiceFactory = FactoryHelper.getServiceFactory(_TestObject.class,
1347 _TestObject.__serviceName,
1348 multiFactory,
1349 regKey);
1351 else if(implName.equals(_PerformancTestObject.class.getName()))
1352 xSingleServiceFactory = FactoryHelper.getServiceFactory(_PerformancTestObject.class,
1353 _PerformancTestObject.__serviceName,
1354 multiFactory,
1355 regKey);
1357 return xSingleServiceFactory;