Version 6.4.0.0.beta1, tag libreoffice-6.4.0.0.beta1
[LibreOffice.git] / cli_ure / qa / climaker / climaker.cs
blob37e46bf0e1eeb7a8425628ccae61e02d8132067f
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 using System;
20 using System.Reflection;
21 using System.Diagnostics;
22 using uno;
25 using unoidl.test.cliure.climaker;
26 //using unoidl.com.sun.star.uno;
27 using ucss=unoidl.com.sun.star;
29 /** This class is for testing the generated code in the uno services
32 public class Context: ucss.uno.XComponentContext
34 public enum test_kind {
35 NORMAL,
36 NO_FACTORY,
37 TEST_EXCEPTION,
38 CREATION_FAILED
41 public Context(test_kind k, params object[] args)
43 kind = k;
44 factory = new Factory(k, args);
47 public ucss.lang.XMultiComponentFactory getServiceManager()
49 if (kind == test_kind.NO_FACTORY)
50 return null;
51 return factory;
54 public Any getValueByName(string Name)
56 if (kind == test_kind.NORMAL)
58 if (Name == "/singletons/unoidl.test.cliure.climaker.S4")
60 Component c = new Component(this);
61 return new Any(typeof(object), c);
64 else if (kind == test_kind.CREATION_FAILED)
66 return new Any();
68 return new Any();
71 class Factory: ucss.lang.XMultiComponentFactory
73 public Factory(Context.test_kind k, params object[] args) {
74 kind2 = k;
75 if (k == Context.test_kind.TEST_EXCEPTION)
76 exception = (ucss.uno.Exception) args[0];
78 public object createInstanceWithArgumentsAndContext(
79 string ServiceSpecifier,
80 uno.Any[] Arguments,
81 unoidl.com.sun.star.uno.XComponentContext Context) {
82 switch (kind2) {
83 case test_kind.NORMAL:
84 return new Component(Context, Arguments);
85 case test_kind.CREATION_FAILED :
86 return null;
87 case test_kind.TEST_EXCEPTION:
88 throw exception;
89 default:
90 throw new Exception("Factory not properly initialized");
93 public object createInstanceWithContext(
94 string aServiceSpecifier,
95 unoidl.com.sun.star.uno.XComponentContext Context) {
96 switch (kind2) {
97 case test_kind.NORMAL:
98 return new Component(Context);
99 case test_kind.CREATION_FAILED:
100 return null;
101 case test_kind.TEST_EXCEPTION:
102 throw exception;
103 default:
104 throw new Exception("Factory not properly initialized");
108 public string[] getAvailableServiceNames()
110 return new string[]{};
112 ucss.uno.Exception exception;
113 test_kind kind2;
117 Factory factory;
118 test_kind kind;
122 public class Logger
124 String m_sFunction;
125 int m_nErrors;
126 public Logger() {
129 public String Function
133 m_sFunction = value;
137 return m_sFunction;
141 public void assure(bool b) {
142 if (b == false)
144 Console.WriteLine(m_sFunction + " failed!");
145 m_nErrors++;
149 public void printStatus() {
150 Console.WriteLine("\n=====================================");
153 String msg;
154 if (m_nErrors > 0)
155 msg = "Test failed! " + m_nErrors.ToString() + " Errors.";
156 else
157 msg = "Test succeeded!";
159 Console.WriteLine(msg + "\n=====================================");
162 public int Errors
166 return m_nErrors;
171 public sealed class Test
173 public static int Main(String[] args)
176 // System.Diagnostics.Debugger.Launch();
179 Logger log = new Logger();
180 Test t = new Test();
181 t.testEnum1(log);
182 t.testEnum2(log);
183 t.testPolyStruct(log);
184 t.testEmptyStruct2(log);
185 t.testFullStruct2(log);
186 t.testS1(log);
187 t.testSingletons(log);
188 t.testAttributes(log);
189 t.testPolyStructAttributes(log);
190 t.testPolymorphicType(log);
191 t.testInterface(log);
192 t.testAny(log);
193 log.printStatus();
194 if (log.Errors == 0)
195 return 0;
196 return -1;
198 catch(Exception e)
200 Console.Write(e.Message);
202 return -1;
207 public void testEnum1(Logger l) {
208 l.Function = "testEnum1";
209 l.assure(((int)Enum1.VALUE1) == -100);
210 l.assure(((int)Enum1.VALUE2) == 100);
213 public void testEnum2(Logger l) {
214 l.Function = "testEnum2";
215 l.assure( ((int) Enum2.VALUE0) == 0);
216 l.assure( ((int) Enum2.VALUE1) == 1);
217 l.assure( ((int) Enum2.VALUE2) == 2);
218 l.assure( ((int) Enum2.VALUE4) == 4);
221 public void testPolyStruct(Logger l) {
222 l.Function = "testPolyStruct";
223 PolyStruct s = new PolyStruct();
224 l.assure(s.member1 == null);
225 l.assure(s.member2 == 0);
226 s = new PolyStruct("ABC", 5);
227 l.assure(s.member1.Equals("ABC"));
228 l.assure(s.member2 == 5);
231 public void testEmptyStruct2(Logger l) {
232 l.Function = "testEmptyStruct2";
233 Struct2 s = new Struct2();
234 l.assure(s.p1 == false);
235 l.assure(s.p2 == 0);
236 l.assure(s.p3 == 0);
237 l.assure(s.p4 == 0);
238 l.assure(s.p5 == 0);
239 l.assure(s.p6 == 0);
240 l.assure(s.p7 == 0L);
241 l.assure(s.p8 == 0L);
242 l.assure(s.p9 == 0.0f);
243 l.assure(s.p10 == 0.0);
244 l.assure(s.p11 == '\u0000');
245 l.assure(s.p12.Equals(""));
246 l.assure(s.p13.Equals(typeof(void)));
247 l.assure(s.p14.Equals(Any.VOID));
248 l.assure(s.p15 == Enum2.VALUE0);
249 l.assure(s.p16.member1 == 0);
250 l.assure(s.p17 == null);
251 l.assure(s.p18 == null);
252 l.assure(s.t1 == false);
253 l.assure(s.t2 == 0);
254 l.assure(s.t3 == 0);
255 l.assure(s.t4 == 0);
256 l.assure(s.t5 == 0);
257 l.assure(s.t6 == 0);
258 l.assure(s.t7 == 0L);
259 l.assure(s.t8 == 0L);
260 l.assure(s.t9 == 0.0f);
261 l.assure(s.t10 == 0.0);
262 l.assure(s.t11 == '\u0000');
263 l.assure(s.t12.Equals(""));
264 l.assure(s.t13.Equals(typeof(void)));
265 l.assure(s.t14.Equals(Any.VOID));
266 l.assure(s.t15 == Enum2.VALUE0);
267 l.assure(s.t16.member1 == 0);
268 l.assure(s.t17 == null);
269 l.assure(s.t18 == null);
270 l.assure(s.a1.Length == 0);
271 l.assure(s.a2.Length == 0);
272 l.assure(s.a3.Length == 0);
273 l.assure(s.a4.Length == 0);
274 l.assure(s.a5.Length == 0);
275 l.assure(s.a6.Length == 0);
276 l.assure(s.a7.Length == 0);
277 l.assure(s.a8.Length == 0);
278 l.assure(s.a9.Length == 0);
279 l.assure(s.a10.Length == 0);
280 l.assure(s.a11.Length == 0);
281 l.assure(s.a12.Length == 0);
282 l.assure(s.a13.Length == 0);
283 l.assure(s.a14.Length == 0);
284 l.assure(s.a15.Length == 0);
285 l.assure(s.a16.Length == 0);
286 l.assure(s.a17.Length == 0);
287 l.assure(s.a18.Length == 0);
288 l.assure(s.aa1.Length == 0);
289 l.assure(s.aa2.Length == 0);
290 l.assure(s.aa3.Length == 0);
291 l.assure(s.aa4.Length == 0);
292 l.assure(s.aa5.Length == 0);
293 l.assure(s.aa6.Length == 0);
294 l.assure(s.aa7.Length == 0);
295 l.assure(s.aa8.Length == 0);
296 l.assure(s.aa9.Length == 0);
297 l.assure(s.aa10.Length == 0);
298 l.assure(s.aa11.Length == 0);
299 l.assure(s.aa12.Length == 0);
300 l.assure(s.aa13.Length == 0);
301 l.assure(s.aa14.Length == 0);
302 l.assure(s.aa15.Length == 0);
303 l.assure(s.aa16.Length == 0);
304 l.assure(s.aa17.Length == 0);
305 l.assure(s.aa18.Length == 0);
306 l.assure(s.at1.Length == 0);
307 l.assure(s.at2.Length == 0);
308 l.assure(s.at3.Length == 0);
309 l.assure(s.at4.Length == 0);
310 l.assure(s.at5.Length == 0);
311 l.assure(s.at6.Length == 0);
312 l.assure(s.at7.Length == 0);
313 l.assure(s.at8.Length == 0);
314 l.assure(s.at9.Length == 0);
315 l.assure(s.at10.Length == 0);
316 l.assure(s.at11.Length == 0);
317 l.assure(s.at12.Length == 0);
318 l.assure(s.at13.Length == 0);
319 l.assure(s.at14.Length == 0);
320 l.assure(s.at15.Length == 0);
321 l.assure(s.at16.Length == 0);
322 l.assure(s.at17.Length == 0);
323 l.assure(s.at18.Length == 0);
326 public void testFullStruct2(Logger l) {
327 //TODO:
328 Struct2 s = new Struct2(
329 true, (byte) 1, (short) 2, (ushort) 3, 4, 5, 6L, 7L, 0.8f, 0.9d, 'A',
330 "BCD", typeof(ulong), new Any(22), Enum2.VALUE4,
331 new Struct1(1), null, null, false, (byte) 0, (short) 0, (ushort) 0,
332 0, 0, 0L, 0L, 0.0f, 0.0, '\u0000', "", typeof(void), Any.VOID,
333 Enum2.VALUE0, new Struct1(), null, null,
334 new bool[] { false, true }, new byte[] { (byte) 1, (byte) 2 },
335 new short[0], new ushort[0], new int[0], new uint[0],
336 new long[0], new ulong[0], new float[0], new double[0], new char[0],
337 new String[0], new Type[0], new Any[0], new Enum2[0],
338 new Struct1[] { new Struct1(1), new Struct1(2) }, new Object[0],
339 new ucss.uno.XNamingService[0], new bool[0][], new byte[0][],
340 new short[0][], new ushort[0][], new int[0][], new uint[0][],
341 new long[0][], new ulong[0][], new float[0][], new double[0][],
342 new char[0][], new String[0][], new Type[0][], new Any[0][],
343 new Enum2[0][], new Struct1[0][], new Object[0][],
344 new ucss.uno.XNamingService[0][], new bool[0][], new byte[0][],
345 new short[0][], new ushort[0][], new int[0][], new uint[0][],
346 new long[0][], new ulong[0][], new float[0][], new double[0][],
347 new char[0][], new String[0][], new Type[0][], new Any[0][],
348 new Enum2[0][], new Struct1[0][], new Object[0][],
349 new ucss.uno.XNamingService[0][]);
350 l.assure(s.p1 == true);
351 l.assure(s.p2 == 1);
352 l.assure(s.p3 == 2);
353 l.assure(s.p4 == 3);
354 l.assure(s.p5 == 4);
355 l.assure(s.p6 == 5);
356 l.assure(s.p7 == 6L);
357 l.assure(s.p8 == 7L);
358 l.assure(s.p9 == 0.8f);
359 l.assure(s.p10 == 0.9);
360 l.assure(s.p11 == 'A');
361 l.assure(s.p12.Equals("BCD"));
362 l.assure(s.p13.Equals(typeof(ulong)));
363 l.assure(s.p14.Equals(new Any(22)));
364 l.assure(s.p15 == Enum2.VALUE4);
365 l.assure(s.p16.member1 == 1);
366 l.assure(s.p17 == null);
367 l.assure(s.p18 == null);
368 l.assure(s.t1 == false);
369 l.assure(s.t2 == 0);
370 l.assure(s.t3 == 0);
371 l.assure(s.t4 == 0);
372 l.assure(s.t5 == 0);
373 l.assure(s.t6 == 0);
374 l.assure(s.t7 == 0L);
375 l.assure(s.t8 == 0L);
376 l.assure(s.t9 == 0.0f);
377 l.assure(s.t10 == 0.0);
378 l.assure(s.t11 == '\u0000');
379 l.assure(s.t12.Equals(""));
380 l.assure(s.t13.Equals(typeof(void)));
381 l.assure(s.t14.Equals(Any.VOID));
382 l.assure(s.t15 == Enum2.VALUE0);
383 l.assure(s.t16.member1 == 0);
384 l.assure(s.t17 == null);
385 l.assure(s.t18 == null);
386 l.assure(s.a1.Length == 2);
387 l.assure(s.a1[0] == false);
388 l.assure(s.a1[1] == true);
389 l.assure(s.a2.Length == 2);
390 l.assure(s.a2[0] == 1);
391 l.assure(s.a2[1] == 2);
392 l.assure(s.a3.Length == 0);
393 l.assure(s.a4.Length == 0);
394 l.assure(s.a5.Length == 0);
395 l.assure(s.a6.Length == 0);
396 l.assure(s.a7.Length == 0);
397 l.assure(s.a8.Length == 0);
398 l.assure(s.a9.Length == 0);
399 l.assure(s.a10.Length == 0);
400 l.assure(s.a11.Length == 0);
401 l.assure(s.a12.Length == 0);
402 l.assure(s.a13.Length == 0);
403 l.assure(s.a14.Length == 0);
404 l.assure(s.a15.Length == 0);
405 l.assure(s.a16.Length == 2);
406 l.assure(s.a16[0].member1 == 1);
407 l.assure(s.a16[1].member1 == 2);
408 l.assure(s.a17.Length == 0);
409 l.assure(s.a18.Length == 0);
410 l.assure(s.aa1.Length == 0);
411 l.assure(s.aa2.Length == 0);
412 l.assure(s.aa3.Length == 0);
413 l.assure(s.aa4.Length == 0);
414 l.assure(s.aa5.Length == 0);
415 l.assure(s.aa6.Length == 0);
416 l.assure(s.aa7.Length == 0);
417 l.assure(s.aa8.Length == 0);
418 l.assure(s.aa9.Length == 0);
419 l.assure(s.aa10.Length == 0);
420 l.assure(s.aa11.Length == 0);
421 l.assure(s.aa12.Length == 0);
422 l.assure(s.aa13.Length == 0);
423 l.assure(s.aa14.Length == 0);
424 l.assure(s.aa15.Length == 0);
425 l.assure(s.aa16.Length == 0);
426 l.assure(s.aa17.Length == 0);
427 l.assure(s.aa18.Length == 0);
428 l.assure(s.at1.Length == 0);
429 l.assure(s.at2.Length == 0);
430 l.assure(s.at3.Length == 0);
431 l.assure(s.at4.Length == 0);
432 l.assure(s.at5.Length == 0);
433 l.assure(s.at6.Length == 0);
434 l.assure(s.at7.Length == 0);
435 l.assure(s.at8.Length == 0);
436 l.assure(s.at9.Length == 0);
437 l.assure(s.at10.Length == 0);
438 l.assure(s.at11.Length == 0);
439 l.assure(s.at12.Length == 0);
440 l.assure(s.at13.Length == 0);
441 l.assure(s.at14.Length == 0);
442 l.assure(s.at15.Length == 0);
443 l.assure(s.at16.Length == 0);
444 l.assure(s.at17.Length == 0);
445 l.assure(s.at18.Length == 0);
448 public void testS1(Logger l) {
449 l.Function = "testS1";
450 object obj = new Object();
451 ucss.uno.RuntimeException excRuntime =
452 new ucss.uno.RuntimeException("RuntimeException", obj);
453 ucss.uno.Exception excException =
454 new ucss.uno.Exception("Exception", obj);
455 ucss.lang.IllegalAccessException excIllegalAccess =
456 new ucss.lang.IllegalAccessException("IllegalAccessException", obj);
457 ucss.uno.DeploymentException excDeployment =
458 new ucss.uno.DeploymentException("DeploymentException", obj);
459 ucss.lang.InvalidListenerException excInvalidListener =
460 new ucss.lang.InvalidListenerException("ListenerException", obj);
462 /* create1 does not specify exceptions. Therefore RuntimeExceptions
463 fly through and other exceptions cause a DeploymentException.
465 try {
466 S1.create1(new Context(Context.test_kind.TEST_EXCEPTION, excRuntime));
467 } catch (ucss.uno.RuntimeException e) {
468 l.assure(e.Message == excRuntime.Message
469 && e.Context == obj);
470 } catch (System.Exception) {
471 l.assure(false);
474 Context c = new Context(Context.test_kind.TEST_EXCEPTION, excException);
475 try {
476 S1.create1(c);
477 } catch (ucss.uno.DeploymentException e) {
478 //The message of the original exception should be contained
479 // in the Deploymentexception
480 l.assure(e.Message.IndexOf(excException.Message) != -1 && e.Context == c);
481 } catch (System.Exception) {
482 l.assure(false);
485 /* create2 specifies many exceptions, including RuntimeException and Exception.
486 Because Exception is specified all exceptions are allowed, hence all thrown
487 exceptions fly through.
489 try {
490 S1.create2(new Context(Context.test_kind.TEST_EXCEPTION, excRuntime));
491 } catch (ucss.uno.RuntimeException e) {
492 l.assure(e.Message == excRuntime.Message
493 && e.Context == obj);
494 } catch (System.Exception) {
495 l.assure(false);
498 try {
499 S1.create2(new Context(Context.test_kind.TEST_EXCEPTION, excIllegalAccess));
500 } catch (ucss.lang.IllegalAccessException e) {
501 l.assure(e.Message == excIllegalAccess.Message
502 && e.Context == obj);
503 } catch (System.Exception) {
504 l.assure(false);
507 try {
508 S1.create2(new Context(Context.test_kind.TEST_EXCEPTION, excException));
509 } catch (ucss.uno.Exception e) {
510 l.assure(e.Message == excException.Message
511 && e.Context == obj);
512 } catch (System.Exception) {
513 l.assure(false);
516 /* create3 specifies exceptions but no com.sun.star.uno.Exception. RuntimeException
517 and derived fly through. Other specified exceptions are rethrown and all other
518 exceptions cause a DeploymentException.
520 try {
521 S1.create3(new Context(Context.test_kind.TEST_EXCEPTION, excDeployment),
522 new Any[]{});
523 } catch (ucss.uno.DeploymentException e) {
524 l.assure(e.Message == excDeployment.Message
525 && e.Context == obj);
526 } catch (System.Exception) {
527 l.assure(false);
530 try {
531 S1.create3(new Context(Context.test_kind.TEST_EXCEPTION, excIllegalAccess),
532 new Any[0]);
533 } catch (ucss.lang.IllegalAccessException e) {
534 l.assure(e.Message == excIllegalAccess.Message
535 && e.Context == obj);
536 } catch (System.Exception) {
537 l.assure(false);
540 c = new Context(Context.test_kind.TEST_EXCEPTION, excInvalidListener);
541 try {
542 S1.create3(c, new Any[0]);
543 } catch (ucss.uno.DeploymentException e) {
544 l.assure(e.Message.IndexOf(excInvalidListener.Message) != -1
545 && e.Context == c);
546 } catch (System.Exception) {
547 l.assure(false);
550 /* test the case when the context cannot provide a service manager.
552 try {
553 S1.create2(new Context(Context.test_kind.NO_FACTORY));
554 } catch (ucss.uno.DeploymentException e) {
555 l.assure(e.Message.Length > 0);
556 } catch (System.Exception) {
557 l.assure(false);
560 /* When the service manager returns a null pointer then a DeploymentException
561 * is to be thrown.
563 try {
564 S1.create2(new Context(Context.test_kind.CREATION_FAILED));
565 } catch (ucss.uno.DeploymentException e) {
566 l.assure(e.Message.Length > 0);
567 } catch (System.Exception) {
568 l.assure(false);
572 /** Test creation of components and if the passing of parameters works.
574 c = new Context(Context.test_kind.NORMAL);
575 try {
576 XTest xTest = S1.create1(c);
577 Component cobj = (Component) xTest;
578 l.assure(cobj.Args[0].Value == c);
580 Any a1 = new Any("bla");
581 Any a2 = new Any(3.14f);
582 Any a3 = new Any(3.145d);
583 xTest = S1.create2(c, a1, a2, a3);
584 cobj = (Component) xTest;
585 l.assure(cobj.Args[0].Value == c
586 && a1.Equals(cobj.Args[1])
587 && a2.Equals(cobj.Args[2])
588 && a3.Equals(cobj.Args[3]));
590 bool b1 = true;
591 byte b2 = 1;
592 short b3 = 2;
593 ushort b4 = 3;
594 int b5 = 4;
595 uint b6 = 5;
596 long b7 = 6;
597 ulong b8 = 7;
598 float b9 = 0.8f;
599 double b10 = 0.9;
600 char b11 = 'A';
601 string b12 = "BCD";
602 Type b13 = typeof(ulong);
603 Any b14 = new Any(22);
604 Enum2 b15 = Enum2.VALUE4;
605 Struct1 b16 = new Struct1(1);
606 PolyStruct b17 = new PolyStruct('A', 1);
607 PolyStruct b18 = new PolyStruct(new Any(true), 1);
608 object b19 = new uno.util.WeakComponentBase();
609 ucss.lang.XComponent b20 = (ucss.lang.XComponent) b19;
610 bool b21 = b1;
611 byte b22 = b2;
612 short b23 = b3;
613 ushort b24 = b4;
614 int b25 = b5;
615 uint b26 = b6;
616 long b27 = b7;
617 ulong b28 = b8;
618 float b29 = b9;
619 double b30 = b10;
620 char b31 = b11;
621 string b32 = b12;
622 Type b33 = b13;
623 Any b34 = b14;
624 Enum2 b35 = b15;
625 Struct1 b36 = b16;
626 object b37 = b19;
627 ucss.lang.XComponent b38 = b20;
628 bool[] b39 = new bool[] { false, true };
629 byte[] b40 = new byte[] { (byte) 1, (byte) 2 };
630 short[] b41 = new short[] { (short) 123, (short) 456};
631 ushort[] b42 = new ushort[] { (ushort) 789, (ushort) 101};
632 int[] b43 = new int[] {1, 2, 3};
633 uint[] b44 = new uint[] {4, 5, 6};
634 long[] b45 = new long[] {7,8,9};
635 ulong[] b46 = new ulong[] {123, 4356};
636 float[] b47 = new float[] {2435f,87f};
637 double[] b48 = new double[] {234d,45.2134d};
638 char[] b49 = new char[] {'\u1234', 'A'};
639 string[] b50 = new string[] {"a","bc"};
640 Type[] b51 = new Type[] {typeof(int), typeof(long)};
641 Any[] b52 = new Any[] {new Any(1), new Any("adf")};
642 Enum2[] b53 = new Enum2[] {Enum2.VALUE2};
643 Struct1[] b54 = new Struct1[] {new Struct1(11), new Struct1(22)};
644 object[] b55 = new object[0];
645 ucss.lang.XComponent[] b56 = new ucss.lang.XComponent[]{
646 new uno.util.WeakComponentBase(), new uno.util.WeakComponentBase()};
647 bool[][] b57 = new bool[][] {new bool[]{true,false}, new bool[] {true}};
648 byte[][] b58 = new byte[][]{new byte[] {(byte) 1}, new byte[]{(byte) 2}};
649 short[][] b59 = new short[][] {new short[]{(short)6, (short)7}, new short[] {(short)9}};
650 ushort[][] b60 = new ushort[][] { new ushort[]{(ushort) 11}};
651 int[][] b61 = new int[][] {new int[]{1}, new int[]{2,3}, new int[]{4,5,6}};
652 uint[][] b62 = new uint[][] {new uint[]{10U}, new uint[]{20U,30U}, new uint[]{40U,50U,60}};
653 long[][] b63 = new long[][] {new long[]{10L}, new long[]{20L,30}, new long[]{40,50,60}};
654 ulong[][] b64 = new ulong[][] { new ulong[]{10L}, new ulong[]{20L, 30L}, new ulong[]{40,50,60}};
655 float[][] b65 = new float[][] {new float[]{10f}, new float[]{20f,30f}, new float[]{40f,50f,60f}};
656 double[][] b66 = new double[][]{new double[]{10d}, new double[]{20d,30d}};
657 char[][] b67 = new char[][] {new char[]{'a'}, new char[]{'b', 'c'}};
658 string[][] b68 = new String[][] {new string[]{"a"}, new string[]{"ad", "lkj"}};
659 Type[][] b69 = new Type[][] {new Type[]{typeof(byte), typeof(long)}, new Type[]{typeof(Any)}};
660 Any[][] b70 = new Any[][] {new Any[]{new Any(1f), new Any(2d)}, new Any[]{new Any(34U)}};
661 Enum2[][] b71 = new Enum2[][] {new Enum2[]{Enum2.VALUE2}};
662 Struct1[][] b72 = new Struct1[][] {new Struct1[]{new Struct1(2), new Struct1(3)}};
663 object[][] b73 = new Object[0][];
664 ucss.lang.XComponent[][] b74 = new uno.util.WeakComponentBase[0][];
665 bool[][] b75 = b57;
666 byte[][] b76 = b58;
667 short[][] b77 = b59;
668 ushort[][] b78 = b60;
669 int[][] b79 = b61;
670 uint[][] b80 = b62;
671 long[][] b81 = b63;
672 ulong[][] b82 = b64;
673 float[][] b83 = b65;
674 double[][] b84 = b66;
675 char[][] b85 = b67;
676 String[][] b86 = b68;
677 Type[][] b87 =b69;
678 Any[][] b88 = b70;
679 Enum2[][] b89 = b71;
680 Struct1[][] b90 = b72;
681 Object[][] b91 = b73;
682 ucss.lang.XComponent[][] b92 = b74;
684 xTest = S1.create5(
686 b1, b2, b3, b4, b5, b6, b7 ,b8, b9, b10,
687 b11, b12, b13,
688 b14,
689 b15, b16, b17, b18, b19, b20,
690 b21, b22, b23, b24, b25, b26, b27, b28, b29, b30,
691 b31, b32, b33,
692 b34,
693 b35, b36, b37, b38, b39, b40,
694 b41, b42, b43, b44, b45, b46, b47, b48, b49, b50,
695 b51, b52, b53, b54, b55, b56, b57, b58, b59, b60,
696 b61, b62, b63, b64, b65, b66, b67, b68, b69, b70,
697 b71, b72, b73, b74, b75, b76, b77, b78, b79, b80,
698 b81, b82, b83, b84, b85, b86, b87, b88, b89, b90,
699 b91, b92
702 cobj = (Component) xTest;
703 l.assure(cobj.Args[0].Value == c);
704 l.assure(b1.Equals(cobj.Args[1].Value));
705 l.assure(b2.Equals(cobj.Args[2].Value));
706 l.assure(b3.Equals(cobj.Args[3].Value));
707 l.assure(b4.Equals(cobj.Args[4].Value));
708 l.assure(b5.Equals(cobj.Args[5].Value));
709 l.assure(b6.Equals(cobj.Args[6].Value));
710 l.assure(b7.Equals(cobj.Args[7].Value));
711 l.assure(b8.Equals(cobj.Args[8].Value));
712 l.assure(b9.Equals(cobj.Args[9].Value));
713 l.assure(b10.Equals(cobj.Args[10].Value));
714 l.assure(b11.Equals(cobj.Args[11].Value));
715 l.assure(b12.Equals(cobj.Args[12].Value));
716 l.assure(b13.Equals(cobj.Args[13].Value));
717 //Anys are not wrapped by the generated code
718 l.assure(b14.Equals(cobj.Args[14]));
719 l.assure(b15.Equals(cobj.Args[15].Value));
720 l.assure(b16.Equals(cobj.Args[16].Value));
721 l.assure(b17.Equals(cobj.Args[17].Value));
722 l.assure(b18.Equals(cobj.Args[18].Value));
723 l.assure(b19.Equals(cobj.Args[19].Value));
724 l.assure(b20.Equals(cobj.Args[20].Value));
725 l.assure(b21.Equals(cobj.Args[21].Value));
726 l.assure(b22.Equals(cobj.Args[22].Value));
727 l.assure(b23.Equals(cobj.Args[23].Value));
728 l.assure(b24.Equals(cobj.Args[24].Value));
729 l.assure(b25.Equals(cobj.Args[25].Value));
730 l.assure(b26.Equals(cobj.Args[26].Value));
731 l.assure(b27.Equals(cobj.Args[27].Value));
732 l.assure(b28.Equals(cobj.Args[28].Value));
733 l.assure(b29.Equals(cobj.Args[29].Value));
734 l.assure(b30.Equals(cobj.Args[30].Value));
735 l.assure(b31.Equals(cobj.Args[31].Value));
736 l.assure(b32.Equals(cobj.Args[32].Value));
737 l.assure(b33.Equals(cobj.Args[33].Value));
738 //Anys are not wrapped by the generated code
739 l.assure(b34.Equals(cobj.Args[34]));
740 l.assure(b35.Equals(cobj.Args[35].Value));
741 l.assure(b36.Equals(cobj.Args[36].Value));
742 l.assure(b37.Equals(cobj.Args[37].Value));
743 l.assure(b38.Equals(cobj.Args[38].Value));
744 l.assure(b39.Equals(cobj.Args[39].Value));
745 l.assure(b40.Equals(cobj.Args[40].Value));
746 l.assure(b41.Equals(cobj.Args[41].Value));
747 l.assure(b42.Equals(cobj.Args[42].Value));
748 l.assure(b43.Equals(cobj.Args[43].Value));
749 l.assure(b44.Equals(cobj.Args[44].Value));
750 l.assure(b45.Equals(cobj.Args[45].Value));
751 l.assure(b46.Equals(cobj.Args[46].Value));
752 l.assure(b47.Equals(cobj.Args[47].Value));
753 l.assure(b48.Equals(cobj.Args[48].Value));
754 l.assure(b49.Equals(cobj.Args[49].Value));
755 l.assure(b50.Equals(cobj.Args[50].Value));
756 l.assure(b51.Equals(cobj.Args[51].Value));
757 l.assure(b52.Equals(cobj.Args[52].Value));
758 l.assure(b53.Equals(cobj.Args[53].Value));
759 l.assure(b54.Equals(cobj.Args[54].Value));
760 l.assure(b55.Equals(cobj.Args[55].Value));
761 l.assure(b56.Equals(cobj.Args[56].Value));
762 l.assure(b57.Equals(cobj.Args[57].Value));
763 l.assure(b58.Equals(cobj.Args[58].Value));
764 l.assure(b59.Equals(cobj.Args[59].Value));
765 l.assure(b60.Equals(cobj.Args[60].Value));
766 l.assure(b61.Equals(cobj.Args[61].Value));
767 l.assure(b62.Equals(cobj.Args[62].Value));
768 l.assure(b63.Equals(cobj.Args[63].Value));
769 l.assure(b64.Equals(cobj.Args[64].Value));
770 l.assure(b65.Equals(cobj.Args[65].Value));
771 l.assure(b66.Equals(cobj.Args[66].Value));
772 l.assure(b67.Equals(cobj.Args[67].Value));
773 l.assure(b68.Equals(cobj.Args[68].Value));
774 l.assure(b69.Equals(cobj.Args[69].Value));
775 l.assure(b70.Equals(cobj.Args[70].Value));
776 l.assure(b71.Equals(cobj.Args[71].Value));
777 l.assure(b72.Equals(cobj.Args[72].Value));
778 l.assure(b73.Equals(cobj.Args[73].Value));
779 l.assure(b74.Equals(cobj.Args[74].Value));
780 l.assure(b75.Equals(cobj.Args[75].Value));
781 l.assure(b76.Equals(cobj.Args[76].Value));
782 l.assure(b77.Equals(cobj.Args[77].Value));
783 l.assure(b78.Equals(cobj.Args[78].Value));
784 l.assure(b79.Equals(cobj.Args[79].Value));
785 l.assure(b80.Equals(cobj.Args[80].Value));
786 l.assure(b81.Equals(cobj.Args[81].Value));
787 l.assure(b82.Equals(cobj.Args[82].Value));
788 l.assure(b83.Equals(cobj.Args[83].Value));
789 l.assure(b84.Equals(cobj.Args[84].Value));
790 l.assure(b85.Equals(cobj.Args[85].Value));
791 l.assure(b86.Equals(cobj.Args[86].Value));
792 l.assure(b87.Equals(cobj.Args[87].Value));
793 l.assure(b88.Equals(cobj.Args[88].Value));
794 l.assure(b89.Equals(cobj.Args[89].Value));
795 l.assure(b90.Equals(cobj.Args[90].Value));
796 l.assure(b91.Equals(cobj.Args[91].Value));
797 l.assure(b92.Equals(cobj.Args[92].Value));
799 } catch (Exception) {
800 l.assure(false);
803 //test
804 c = new Context(Context.test_kind.NORMAL);
805 try {
807 PolyStruct2 arg1 = new PolyStruct2(typeof(PolyStruct2), 1);
808 PolyStruct2 arg2 = new PolyStruct2(new Any(true), 1);
809 PolyStruct2 arg3 = new PolyStruct2(true, 1);
810 PolyStruct2 arg4 = new PolyStruct2((Byte)8, 1);
811 PolyStruct2 arg5 = new PolyStruct2('c', 1);
812 PolyStruct2 arg6 = new PolyStruct2((Int16)10, 1);
813 PolyStruct2 arg7 = new PolyStruct2(11, 1);
814 PolyStruct2 arg8 = new PolyStruct2(12L, 1);
815 PolyStruct2 arg9 = new PolyStruct2("Hello", 1);
816 PolyStruct2 arg10 = new PolyStruct2(1.3, 1);
817 PolyStruct2 arg11 = new PolyStruct2(1.3d, 1);
818 PolyStruct2 arg12 = new PolyStruct2(new Object(), 1);
819 PolyStruct2 arg13 = new PolyStruct2(new uno.util.WeakComponentBase(), 1);
820 PolyStruct2 arg14 = new PolyStruct2(
821 new PolyStruct('A', 1), 1);
822 PolyStruct2 arg15 = new PolyStruct2(
823 new PolyStruct(new PolyStruct('A',1),1),1);
824 PolyStruct arg16 = new PolyStruct("Hallo", 1);
825 PolyStruct arg17 = new PolyStruct(
826 new PolyStruct('A',1),1);
828 Type[] arType = {typeof(PolyStruct), typeof(PolyStruct2)};
829 PolyStruct2 arg101 = new PolyStruct2(arType,1);
830 PolyStruct2 arg102 = new PolyStruct2(
831 new Any[] {new Any(true)},1);
832 PolyStruct2 arg103 = new PolyStruct2(new bool[]{true}, 1);
833 PolyStruct2 arg104 = new PolyStruct2(new byte[] { (byte) 1}, 1);
834 PolyStruct2 arg105 = new PolyStruct2(new char[] {'\u1234', 'A'}, 1);
835 PolyStruct2 arg106 = new PolyStruct2(new short[] {(short)1}, 1);
836 PolyStruct2 arg107 = new PolyStruct2(new int[] {1}, 1);
837 PolyStruct2 arg108 = new PolyStruct2(new long[] {1}, 1);
838 PolyStruct2 arg109 = new PolyStruct2(new string[]{"Hallo"}, 1);
839 PolyStruct2 arg110 = new PolyStruct2(new float[]{1.3f}, 1);
840 PolyStruct2 arg111 = new PolyStruct2(new double[] {1.3d}, 1);
841 PolyStruct2 arg112 = new PolyStruct2(
842 new Object[] { new Object()}, 1);
843 PolyStruct2 arg113 = new PolyStruct2(
844 new uno.util.WeakComponentBase[] {
845 new uno.util.WeakComponentBase()}, 1);
846 PolyStruct2 arg114 = new PolyStruct2(
847 new PolyStruct[]{
848 new PolyStruct('A',1)} ,1);
849 PolyStruct2 arg115 = new PolyStruct2(
850 new PolyStruct[] {
851 new PolyStruct( new PolyStruct2('A',1),1)}
852 ,1);
853 PolyStruct2 arg201 = new PolyStruct2(new char[][] { new char[]{'A'},
854 new char[]{'B'}}, 1);
856 PolyStruct2[] arg301 = new PolyStruct2[] {new PolyStruct2('A', 1)};
857 PolyStruct2[] arg302 = new PolyStruct2[] {new PolyStruct2(
858 new PolyStruct('A', 1), 1)};
859 PolyStruct2[] arg303 = new PolyStruct2[] {new PolyStruct2(
860 new PolyStruct(new PolyStruct('A',1),1),1)};
861 PolyStruct[] arg304 = new PolyStruct[] {new PolyStruct("Hallo", 1)};
862 PolyStruct[] arg305 = new PolyStruct[] {new PolyStruct(
863 new PolyStruct('A',1),1)};
865 PolyStruct2[][] arg401 = new PolyStruct2[][] {new PolyStruct2[] {new PolyStruct2('A', 1)}};
866 PolyStruct2[][] arg402 = new PolyStruct2[][] {new PolyStruct2[] {new PolyStruct2(
867 new PolyStruct('A', 1), 1)}};
868 PolyStruct2[][] arg403 = new PolyStruct2[][] {new PolyStruct2[] {new PolyStruct2(
869 new PolyStruct(new PolyStruct('A',1),1),1)}};
870 PolyStruct[][] arg404 = new PolyStruct[][] {new PolyStruct[] {new PolyStruct("Hallo", 1)}};
871 PolyStruct[][] arg405 = new PolyStruct[][] {new PolyStruct[] {new PolyStruct(
872 new PolyStruct('A',1),1)}};
875 XTest xTest = S1.create6(c,
876 arg1,arg2,arg3,arg4,arg5,arg6,arg7,arg8,arg9,arg10,
877 arg11,arg12,arg13,arg14,arg15,arg16,arg17,
878 arg101,arg102,arg103,arg104,arg105,arg106,arg107,arg108,arg109,arg110,
879 arg111,arg112,arg113,arg114,arg115,
880 arg201,
881 arg301, arg302, arg303, arg304, arg305,
882 arg401, arg402, arg403, arg404, arg405);
883 Component cobj = (Component) xTest;
884 l.assure(cobj.Args[0].Value == c);
885 //arg1 - arg17
886 string sType = ((PolymorphicType) cobj.Args[1].Type).PolymorphicName;
887 l.assure( sType == "unoidl.test.cliure.climaker.PolyStruct2<System.Type>");
888 sType = ((PolymorphicType) cobj.Args[2].Type).PolymorphicName;
889 l.assure( sType == "unoidl.test.cliure.climaker.PolyStruct2<uno.Any>");
890 sType = ((PolymorphicType) cobj.Args[3].Type).PolymorphicName;
891 l.assure( sType == "unoidl.test.cliure.climaker.PolyStruct2<System.Boolean>");
892 sType = ((PolymorphicType) cobj.Args[4].Type).PolymorphicName;
893 l.assure( sType == "unoidl.test.cliure.climaker.PolyStruct2<System.Byte>");
894 sType = ((PolymorphicType) cobj.Args[5].Type).PolymorphicName;
895 l.assure( sType == "unoidl.test.cliure.climaker.PolyStruct2<System.Char>");
896 sType = ((PolymorphicType) cobj.Args[6].Type).PolymorphicName;
897 l.assure( sType == "unoidl.test.cliure.climaker.PolyStruct2<System.Int16>");
898 sType = ((PolymorphicType) cobj.Args[7].Type).PolymorphicName;
899 l.assure( sType == "unoidl.test.cliure.climaker.PolyStruct2<System.Int32>");
900 sType = ((PolymorphicType) cobj.Args[8].Type).PolymorphicName;
901 l.assure( sType == "unoidl.test.cliure.climaker.PolyStruct2<System.Int64>");
902 sType = ((PolymorphicType) cobj.Args[9].Type).PolymorphicName;
903 l.assure( sType == "unoidl.test.cliure.climaker.PolyStruct2<System.String>");
904 sType = ((PolymorphicType) cobj.Args[10].Type).PolymorphicName;
905 l.assure( sType == "unoidl.test.cliure.climaker.PolyStruct2<System.Single>");
906 sType = ((PolymorphicType) cobj.Args[11].Type).PolymorphicName;
907 l.assure( sType == "unoidl.test.cliure.climaker.PolyStruct2<System.Double>");
908 sType = ((PolymorphicType) cobj.Args[12].Type).PolymorphicName;
909 l.assure( sType == "unoidl.test.cliure.climaker.PolyStruct2<System.Object>");
910 sType = ((PolymorphicType) cobj.Args[13].Type).PolymorphicName;
911 l.assure( sType == "unoidl.test.cliure.climaker.PolyStruct2<unoidl.com.sun.star.lang.XComponent>");
912 sType = ((PolymorphicType) cobj.Args[14].Type).PolymorphicName;
913 l.assure( sType == "unoidl.test.cliure.climaker.PolyStruct2<unoidl.test.cliure.climaker.PolyStruct<System.Char,uno.Any>>");
914 sType = ((PolymorphicType) cobj.Args[15].Type).PolymorphicName;
915 l.assure( sType == "unoidl.test.cliure.climaker.PolyStruct2<" +
916 "unoidl.test.cliure.climaker.PolyStruct<" +
917 "unoidl.test.cliure.climaker.PolyStruct<" +
918 "System.Char,uno.Any>,System.String>>");
919 sType = ((PolymorphicType) cobj.Args[16].Type).PolymorphicName;
920 l.assure( sType == "unoidl.test.cliure.climaker.PolyStruct<" +
921 "System.String,unoidl.test.cliure.climaker.PolyStruct<" +
922 "System.Char,unoidl.test.cliure.climaker.PolyStruct2<" +
923 "uno.Any>>>");
924 sType = ((PolymorphicType) cobj.Args[17].Type).PolymorphicName;
925 l.assure( sType == "unoidl.test.cliure.climaker.PolyStruct<" +
926 "unoidl.test.cliure.climaker.PolyStruct<System.Char,uno.Any>," +
927 "unoidl.test.cliure.climaker.PolyStruct2<System.Char>>");
928 //arg101 - arg115
929 sType = ((PolymorphicType) cobj.Args[18].Type).PolymorphicName;
930 l.assure( sType == "unoidl.test.cliure.climaker.PolyStruct2<System.Type[]>");
931 sType = ((PolymorphicType) cobj.Args[19].Type).PolymorphicName;
932 l.assure( sType == "unoidl.test.cliure.climaker.PolyStruct2<uno.Any[]>");
933 sType = ((PolymorphicType) cobj.Args[20].Type).PolymorphicName;
934 l.assure( sType == "unoidl.test.cliure.climaker.PolyStruct2<System.Boolean[]>");
935 sType = ((PolymorphicType) cobj.Args[21].Type).PolymorphicName;
936 l.assure( sType == "unoidl.test.cliure.climaker.PolyStruct2<System.Byte[]>");
937 sType = ((PolymorphicType) cobj.Args[22].Type).PolymorphicName;
938 l.assure( sType == "unoidl.test.cliure.climaker.PolyStruct2<System.Char[]>");
939 sType = ((PolymorphicType) cobj.Args[23].Type).PolymorphicName;
940 l.assure( sType == "unoidl.test.cliure.climaker.PolyStruct2<System.Int16[]>");
941 sType = ((PolymorphicType) cobj.Args[24].Type).PolymorphicName;
942 l.assure( sType == "unoidl.test.cliure.climaker.PolyStruct2<System.Int32[]>");
943 sType = ((PolymorphicType) cobj.Args[25].Type).PolymorphicName;
944 l.assure( sType == "unoidl.test.cliure.climaker.PolyStruct2<System.Int64[]>");
945 sType = ((PolymorphicType) cobj.Args[26].Type).PolymorphicName;
946 l.assure( sType == "unoidl.test.cliure.climaker.PolyStruct2<System.String[]>");
947 sType = ((PolymorphicType) cobj.Args[27].Type).PolymorphicName;
948 l.assure( sType == "unoidl.test.cliure.climaker.PolyStruct2<System.Single[]>");
949 sType = ((PolymorphicType) cobj.Args[28].Type).PolymorphicName;
950 l.assure( sType == "unoidl.test.cliure.climaker.PolyStruct2<System.Double[]>");
951 sType = ((PolymorphicType) cobj.Args[29].Type).PolymorphicName;
952 l.assure( sType == "unoidl.test.cliure.climaker.PolyStruct2<System.Object[]>");
953 sType = ((PolymorphicType) cobj.Args[30].Type).PolymorphicName;
954 l.assure( sType == "unoidl.test.cliure.climaker.PolyStruct2<unoidl.com.sun.star.lang.XComponent[]>");
955 sType = ((PolymorphicType) cobj.Args[31].Type).PolymorphicName;
956 l.assure( sType == "unoidl.test.cliure.climaker.PolyStruct2<" +
957 "unoidl.test.cliure.climaker.PolyStruct<System.Char,uno.Any[]>[]>");
958 sType = ((PolymorphicType) cobj.Args[32].Type).PolymorphicName;
959 l.assure( sType == "unoidl.test.cliure.climaker.PolyStruct2<" +
960 "unoidl.test.cliure.climaker.PolyStruct<" +
961 "unoidl.test.cliure.climaker.PolyStruct2<" +
962 "System.Char>,uno.Any[]>[]>");
963 //arg 201
964 sType = ((PolymorphicType) cobj.Args[33].Type).PolymorphicName;
965 l.assure( sType == "unoidl.test.cliure.climaker.PolyStruct2<" +
966 "System.Char[][]>");
967 //arg 301 - arg305
968 sType = ((PolymorphicType) cobj.Args[34].Type).PolymorphicName;
969 l.assure (sType == "unoidl.test.cliure.climaker.PolyStruct2<System.Char>[]");
970 sType = ((PolymorphicType) cobj.Args[35].Type).PolymorphicName;
971 l.assure( sType == "unoidl.test.cliure.climaker.PolyStruct2<unoidl.test.cliure.climaker.PolyStruct<System.Char,uno.Any>>[]");
972 sType = ((PolymorphicType) cobj.Args[36].Type).PolymorphicName;
973 l.assure( sType == "unoidl.test.cliure.climaker.PolyStruct2<" +
974 "unoidl.test.cliure.climaker.PolyStruct<" +
975 "unoidl.test.cliure.climaker.PolyStruct<" +
976 "System.Char,uno.Any>,System.String>>[]");
977 sType = ((PolymorphicType) cobj.Args[37].Type).PolymorphicName;
978 l.assure( sType == "unoidl.test.cliure.climaker.PolyStruct<" +
979 "System.String,unoidl.test.cliure.climaker.PolyStruct<" +
980 "System.Char,unoidl.test.cliure.climaker.PolyStruct2<" +
981 "uno.Any>>>[]");
982 sType = ((PolymorphicType) cobj.Args[38].Type).PolymorphicName;
983 l.assure( sType == "unoidl.test.cliure.climaker.PolyStruct<" +
984 "unoidl.test.cliure.climaker.PolyStruct<System.Char,uno.Any>," +
985 "unoidl.test.cliure.climaker.PolyStruct2<System.Char>>[]");
986 //arg 401 - arg405
987 sType = ((PolymorphicType) cobj.Args[39].Type).PolymorphicName;
988 l.assure( sType == "unoidl.test.cliure.climaker.PolyStruct2<System.Char>[][]");
989 sType = ((PolymorphicType) cobj.Args[40].Type).PolymorphicName;
990 l.assure( sType == "unoidl.test.cliure.climaker.PolyStruct2<" +
991 "unoidl.test.cliure.climaker.PolyStruct<System.Char,uno.Any>>[][]");
992 sType = ((PolymorphicType) cobj.Args[41].Type).PolymorphicName;
993 l.assure( sType == "unoidl.test.cliure.climaker.PolyStruct2<" +
994 "unoidl.test.cliure.climaker.PolyStruct<" +
995 "unoidl.test.cliure.climaker.PolyStruct<" +
996 "System.Char,uno.Any>,System.String>>[][]");
997 sType = ((PolymorphicType) cobj.Args[42].Type).PolymorphicName;
998 l.assure( sType == "unoidl.test.cliure.climaker.PolyStruct<" +
999 "System.String,unoidl.test.cliure.climaker.PolyStruct<" +
1000 "System.Char,unoidl.test.cliure.climaker.PolyStruct2<" +
1001 "uno.Any>>>[][]");
1002 sType = ((PolymorphicType) cobj.Args[43].Type).PolymorphicName;
1003 l.assure( sType == "unoidl.test.cliure.climaker.PolyStruct<" +
1004 "unoidl.test.cliure.climaker.PolyStruct<System.Char,uno.Any>," +
1005 "unoidl.test.cliure.climaker.PolyStruct2<System.Char>>[][]");
1011 catch (Exception)
1013 l.assure(false);
1017 void testSingletons(Logger l)
1019 l.Function = "testSingletons";
1020 Context c = new Context(Context.test_kind.NORMAL);
1021 try {
1022 XTest obj = S4.get(c);
1023 l.assure(obj != null);
1024 } catch (Exception) {
1025 l.assure(false);
1028 /** Case context fails to provide singleton, a DeploymentException should be thrown.
1030 c = new Context(Context.test_kind.CREATION_FAILED);
1031 try {
1032 XTest obj = S4.get(c);
1033 l.assure(obj != null);
1034 } catch (ucss.uno.DeploymentException e) {
1035 Type t = typeof(unoidl.test.cliure.climaker.S4);
1036 l.assure( e.Message.IndexOf(t.FullName) != -1);
1037 } catch (System.Exception) {
1038 l.assure(false);
1042 void testAttributes(Logger l)
1044 l.Function = "testAttributes";
1045 //oneway attribute
1046 Type typeXTest = typeof(unoidl.test.cliure.climaker.XTest);
1047 object[] arAttr = typeXTest.GetMethod("testOneway").GetCustomAttributes(false);
1048 if (arAttr.Length == 1)
1049 l.assure(typeof(uno.OnewayAttribute).Equals(arAttr[0].GetType()));
1050 else
1051 l.assure(false);
1053 //test exceptions
1054 arAttr = typeXTest.GetMethod("testExceptions").GetCustomAttributes(false);
1055 if (arAttr.Length == 1 && arAttr[0].GetType() == typeof(uno.ExceptionAttribute))
1057 uno.ExceptionAttribute attr = arAttr[0] as uno.ExceptionAttribute;
1058 if (attr != null && attr.Raises.Length == 2)
1060 l.assure(attr.Raises[0] == typeof(unoidl.com.sun.star.uno.Exception));
1061 l.assure(attr.Raises[1] == typeof(unoidl.com.sun.star.lang.ClassNotFoundException));
1063 else
1064 l.assure(false);
1066 else
1067 l.assure(false);
1069 //function test must not have the oneway attribute and Exception attribute
1070 arAttr = typeXTest.GetMethod("test").GetCustomAttributes(false);
1071 l.assure(arAttr.Length == 0);
1073 //test exceptions on service constructor methods
1074 Type typeS1 = typeof(unoidl.test.cliure.climaker.S1);
1075 arAttr = typeS1.GetMethod("create3").GetCustomAttributes(false);
1076 if (arAttr.Length == 1 && arAttr[0].GetType() == typeof(uno.ExceptionAttribute))
1078 uno.ExceptionAttribute attr = arAttr[0] as uno.ExceptionAttribute;
1079 if (attr != null && attr.Raises.Length == 4)
1081 l.assure(attr.Raises[0] == typeof(unoidl.com.sun.star.uno.RuntimeException));
1082 l.assure(attr.Raises[1] == typeof(unoidl.com.sun.star.lang.ClassNotFoundException));
1083 l.assure(attr.Raises[2] == typeof(unoidl.com.sun.star.lang.IllegalAccessException));
1084 l.assure(attr.Raises[3] == typeof(unoidl.com.sun.star.uno.DeploymentException));
1086 else
1087 l.assure(false);
1089 else
1090 l.assure(false);
1092 //create1 does not have exceptions
1093 arAttr = typeS1.GetMethod("create1").GetCustomAttributes(false);
1094 l.assure(arAttr.Length == 0);
1096 //test exceptions of UNO interface attributes
1097 arAttr = typeXTest.GetProperty("A3").GetGetMethod().GetCustomAttributes(false);
1098 if (arAttr.Length == 1)
1100 uno.ExceptionAttribute attr = arAttr[0] as uno.ExceptionAttribute;
1101 if (attr != null && attr.Raises.Length == 2)
1103 l.assure(attr.Raises[0] == typeof(unoidl.com.sun.star.uno.Exception));
1104 l.assure(attr.Raises[1] == typeof(unoidl.com.sun.star.lang.ClassNotFoundException));
1106 else
1107 l.assure(false);
1109 else
1110 l.assure(false);
1112 arAttr = typeXTest.GetProperty("A3").GetSetMethod().GetCustomAttributes(false);
1113 if (arAttr.Length == 1)
1115 uno.ExceptionAttribute attr = arAttr[0] as uno.ExceptionAttribute;
1116 if (attr != null && attr.Raises.Length == 1)
1117 l.assure(attr.Raises[0] == typeof(unoidl.com.sun.star.uno.RuntimeException));
1118 else
1119 l.assure(false);
1121 else
1122 l.assure(false);
1124 //attribute A1 must have the ExceptionAttribute
1125 l.assure(typeXTest.GetProperty("A1").GetGetMethod().GetCustomAttributes(false).Length == 0);
1126 l.assure(typeXTest.GetProperty("A1").GetSetMethod().GetCustomAttributes(false).Length == 0);
1128 //Test BoundAttribute
1129 BoundAttribute bound = (BoundAttribute) Attribute.GetCustomAttribute(
1130 typeXTest.GetProperty("A1"), typeof(BoundAttribute));
1131 l.assure(bound != null);
1133 bound = (BoundAttribute) Attribute.GetCustomAttribute(
1134 typeXTest.GetProperty("A3"), typeof(BoundAttribute));
1135 l.assure(bound == null);
1138 void testPolyStructAttributes(Logger l)
1140 l.Function = "testPolyStructAttributes";
1141 //Test polymorphic struct
1142 Type typeStruct = typeof(unoidl.test.cliure.climaker.PolyStruct);
1143 object[] arAttr = typeStruct.GetCustomAttributes(false);
1144 if (arAttr.Length == 1)
1146 try {
1147 uno.TypeParametersAttribute attr = (uno.TypeParametersAttribute) arAttr[0];
1148 string[] arNames = new string[]{"if", "else"};
1149 l.assure(attr != null && attr.Parameters.ToString().Equals(arNames.ToString()));
1150 }catch(Exception ) {
1151 l.assure(false);
1154 else
1155 l.assure(false);
1156 l.assure(typeof(unoidl.test.cliure.climaker.Struct1).GetCustomAttributes(false).Length == 0);
1157 //member of a polymorphic struct with a parameterized type have also an attribute
1158 arAttr = typeStruct.GetField("member1").GetCustomAttributes(false);
1159 if (arAttr.Length == 1)
1161 uno.ParameterizedTypeAttribute attr = arAttr[0] as uno.ParameterizedTypeAttribute;
1162 l.assure(attr != null && attr.Type == "if");
1164 else
1165 l.assure(false);
1168 //test instantiated polymorphic struct: return value
1169 // Type typeXTest = typeof(XTest);
1170 // arAttr = typeXTest.GetMethod("testPolyStruct").ReturnTypeCustomAttributes.GetCustomAttributes(false);
1171 // if (arAttr.Length == 1)
1172 // {
1173 // uno.TypeArgumentsAttribute attr = arAttr[0] as uno.TypeArgumentsAttribute;
1174 // l.assure(attr != null && attr.Arguments.Length == 2
1175 // &&attr.Arguments[0] == typeof(char)
1176 // && attr.Arguments[1] == typeof(int));
1177 // }
1178 // else
1179 // l.assure(false);
1180 // arAttr = typeXTest.GetMethod("testPolyStruct").GetCustomAttributes(false);
1183 // private XComponentContext context;
1185 void testPolymorphicType(Logger l)
1187 l.Function = "testPolymorphicType";
1188 string name = "unoidl.test.cliure.climaker.PolyStruct<System.Int32,System.Int32>";
1190 uno.PolymorphicType t1 = PolymorphicType.GetType(
1191 typeof(unoidl.test.cliure.climaker.PolyStruct), name);
1193 uno.PolymorphicType t2 = PolymorphicType.GetType(
1194 typeof(unoidl.test.cliure.climaker.PolyStruct ), name);
1196 l.assure(t1 == t2);
1197 l.assure(t1.PolymorphicName == name);
1198 l.assure(t1.OriginalType == typeof(unoidl.test.cliure.climaker.PolyStruct));
1202 void testInterface(Logger l)
1204 l.Function = "testInterface";
1205 try {
1206 Context c = new Context(Context.test_kind.NORMAL);
1207 XTest obj = S1.create1(c);
1208 bool aBool = true;
1209 byte aByte = 0xff;
1210 short aShort = 0x7fff;
1211 ushort aUShort = 0xffff;
1212 int aInt = 0x7fffffff;
1213 uint aUInt = 0xffffffff;
1214 long aLong = 0x7fffffffffffffff;
1215 ulong aULong = 0xffffffffffffffff;
1216 float aFloat = 0.314f;
1217 double aDouble = 0.314d;
1218 char aChar = 'A';
1219 string aString = "Hello World";
1220 Type aType = typeof(XTest);
1221 Any aAny = new Any(typeof(XTest), obj);
1222 Enum2 aEnum2 = Enum2.VALUE2;
1223 Struct1 aStruct1 = new Struct1();
1224 object aXInterface = new object();
1225 ucss.lang.XComponent aXComponent = (ucss.lang.XComponent) obj;
1226 bool[] aSeqBool = {true, false, true};
1228 obj.inParameters(aBool, aByte, aShort, aUShort,
1229 aInt, aUInt, aLong, aULong,
1230 aFloat, aDouble, aChar, aString,
1231 aType, aAny,aEnum2, aStruct1,
1232 aXInterface, aXComponent, aSeqBool);
1234 bool outBool;
1235 byte outByte;
1236 short outShort;
1237 ushort outUShort;
1238 int outInt;
1239 uint outUInt;
1240 long outLong;
1241 ulong outULong;
1242 float outFloat;
1243 double outDouble;
1244 char outChar;
1245 string outString;
1246 Type outType;
1247 Any outAny;
1248 Enum2 outEnum2;
1249 Struct1 outStruct1;
1250 object outXInterface;
1251 ucss.lang.XComponent outXComponent;
1252 bool[] outSeqBool;
1254 obj.outParameters(out outBool, out outByte, out outShort, out outUShort,
1255 out outInt, out outUInt, out outLong, out outULong,
1256 out outFloat, out outDouble, out outChar, out outString,
1257 out outType, out outAny, out outEnum2, out outStruct1,
1258 out outXInterface, out outXComponent, out outSeqBool);
1260 l.assure(aBool == outBool);
1261 l.assure(aByte == outByte);
1262 l.assure(aShort == outShort);
1263 l.assure(aUShort == outUShort);
1264 l.assure(aInt == outInt);
1265 l.assure(aUInt == outUInt);
1266 l.assure(aLong == outLong);
1267 l.assure(aULong == outULong);
1268 l.assure(aFloat == outFloat);
1269 l.assure(aDouble == outDouble);
1270 l.assure(aChar == outChar);
1271 l.assure(aString == outString);
1272 l.assure(aType == outType);
1273 l.assure(aAny.Equals(outAny));
1274 l.assure(aEnum2 == outEnum2);
1275 l.assure(aStruct1 == outStruct1);
1276 l.assure(aXInterface == outXInterface);
1277 l.assure(aXComponent == outXComponent);
1278 l.assure(aSeqBool == outSeqBool);
1280 bool inoutBool = false;
1281 byte inoutByte = 10;
1282 short inoutShort = 11;
1283 ushort inoutUShort = 12;
1284 int inoutInt = 13;
1285 uint inoutUInt = 14;
1286 long inoutLong = 15;
1287 ulong inoutULong = 16;
1288 float inoutFloat = 4.134f;
1289 double inoutDouble = 5.135;
1290 char inoutChar = 'B';
1291 string inoutString = "Hello Hamburg";
1292 Type inoutType = typeof(int);
1293 Any inoutAny = new Any(inoutInt);
1294 Enum2 inoutEnum2 = Enum2.VALUE4;
1295 Struct1 inoutStruct1 = new Struct1();
1296 object inoutXInterface = new object();
1297 ucss.lang.XComponent inoutXComponent = (ucss.lang.XComponent) S1.create1(c);
1298 bool[] inoutSeqBool = {false, true, false};
1301 obj.inoutParameters(ref inoutBool, ref inoutByte, ref inoutShort, ref inoutUShort,
1302 ref inoutInt, ref inoutUInt, ref inoutLong, ref inoutULong,
1303 ref inoutFloat, ref inoutDouble, ref inoutChar, ref inoutString,
1304 ref inoutType, ref inoutAny, ref inoutEnum2, ref inoutStruct1,
1305 ref inoutXInterface, ref inoutXComponent, ref inoutSeqBool);
1307 l.assure(aBool == inoutBool);
1308 l.assure(aByte == inoutByte);
1309 l.assure(aShort == inoutShort);
1310 l.assure(aUShort == inoutUShort);
1311 l.assure(aInt == inoutInt);
1312 l.assure(aUInt == inoutUInt);
1313 l.assure(aLong == inoutLong);
1314 l.assure(aULong == inoutULong);
1315 l.assure(aFloat == inoutFloat);
1316 l.assure(aDouble == inoutDouble);
1317 l.assure(aChar == inoutChar);
1318 l.assure(aString == inoutString);
1319 l.assure(aType == inoutType);
1320 l.assure(aAny.Equals(inoutAny));
1321 l.assure(aEnum2 == inoutEnum2);
1322 l.assure(aStruct1 == inoutStruct1);
1323 l.assure(aXInterface == inoutXInterface);
1324 l.assure(aXComponent == inoutXComponent);
1325 l.assure(aSeqBool == inoutSeqBool);
1328 //now check the return values
1329 obj.inParameters(aBool, aByte, aShort, aUShort,
1330 aInt, aUInt, aLong, aULong,
1331 aFloat, aDouble, aChar, aString,
1332 aType, aAny,aEnum2, aStruct1,
1333 aXInterface, aXComponent, aSeqBool);
1335 l.assure(obj.retBoolean() == aBool);
1336 l.assure(obj.retByte() == aByte);
1337 l.assure(obj.retShort() == aShort);
1338 l.assure(obj.retUShort() == aUShort);
1339 l.assure(obj.retLong() == aInt);
1340 l.assure(obj.retULong() == aUInt);
1341 l.assure(obj.retHyper() == aLong);
1342 l.assure(obj.retUHyper() == aULong);
1343 l.assure(obj.retFloat() == aFloat);
1344 l.assure(obj.retDouble() == aDouble);
1345 l.assure(obj.retChar() == aChar);
1346 l.assure(obj.retString() == aString);
1347 l.assure(obj.retType() == aType);
1348 l.assure(obj.retAny().Equals(aAny));
1349 l.assure(obj.retEnum() == aEnum2);
1350 l.assure(obj.retStruct1() == aStruct1);
1351 l.assure(obj.retXInterface() == aXInterface);
1352 l.assure(obj.retXComponent() == aXComponent);
1353 l.assure(obj.retSeqBool() == aSeqBool);
1356 obj = S1.create1(c);
1357 obj.attrBoolean = true;
1358 l.assure(obj.attrBoolean == true);
1359 obj.attrByte = aByte;
1360 l.assure(obj.attrByte == aByte);
1361 obj.attrShort = aShort;
1362 l.assure(obj.attrShort == aShort);
1363 obj.attrUShort = aUShort;
1364 l.assure(obj.attrUShort == aUShort);
1365 obj.attrLong = aInt;
1366 l.assure(obj.attrLong == aInt);
1367 obj.attrULong = aUInt;
1368 l.assure(obj.attrULong == aUInt);
1369 obj.attrHyper = aLong;
1370 l.assure(obj.attrHyper == aLong);
1371 obj.attrUHyper = aULong;
1372 l.assure(obj.attrUHyper == aULong);
1373 obj.attrFloat = aFloat;
1374 l.assure(obj.attrFloat == aFloat);
1375 obj.attrDouble = aDouble;
1376 l.assure(obj.attrDouble == aDouble);
1377 obj.attrChar = aChar;
1378 l.assure(obj.attrChar == aChar);
1379 obj.attrString = aString;
1380 l.assure(obj.attrString == aString);
1381 obj.attrType = aType;
1382 l.assure(obj.attrType == aType);
1383 obj.attrAny = aAny;
1384 l.assure(obj.attrAny.Equals(aAny));
1385 obj.attrEnum2 = aEnum2;
1386 l.assure(obj.attrEnum2 == aEnum2);
1387 obj.attrStruct1 = aStruct1;
1388 l.assure(obj.attrStruct1 == aStruct1);
1389 obj.attrXInterface = aXInterface;
1390 l.assure(obj.attrXInterface == aXInterface);
1391 obj.attrXComponent = aXComponent;
1392 l.assure(obj.attrXComponent == aXComponent);
1393 obj.attrSeqBoolean = aSeqBool;
1394 l.assure(obj.attrSeqBoolean == aSeqBool);
1395 } catch (Exception )
1397 l.assure(false);
1401 public void testAny(Logger l)
1403 l.Function = "testAny";
1404 //create any with valid and invalid arguments
1407 Any a = new Any(null, null);
1408 l.assure(false);
1410 catch(System.Exception e)
1412 l.assure(e.Message.IndexOf("Any") != -1);
1416 Any a = new Any(typeof(int), null);
1417 l.assure(false);
1419 catch(System.Exception e)
1421 l.assure(e.Message.IndexOf("Any") != -1);
1427 Any a = new Any(typeof(unoidl.com.sun.star.uno.XComponentContext), null);
1428 a = new Any('a');
1429 a = new Any((sbyte)1);
1431 catch (System.Exception)
1433 l.assure(false);
1436 //test polymorphic struct
1439 Any a = new Any(typeof(unoidl.test.cliure.climaker.PolyStruct),
1440 new PolyStruct());
1441 l.assure(false);
1443 catch (System.Exception e)
1445 l.assure(e.Message.IndexOf("Any") != -1);
1449 Any a = new Any(uno.PolymorphicType.GetType(
1450 typeof(unoidl.test.cliure.climaker.PolyStruct),
1451 "unoidl.test.cliure.climaker.PolyStruct<System.Char>"),
1452 new PolyStruct('A', 10));
1454 catch (System.Exception )
1456 l.assure(false);
1459 //test Any.Equals
1461 Any aVoid = Any.VOID;
1462 l.assure(aVoid.Equals((object) Any.VOID));
1463 l.assure(aVoid.Equals(Any.VOID));
1465 l.assure(aVoid.Equals(new Any("")) == false);
1467 Any a1 = new Any(10);
1468 Any a2 = a1;
1469 l.assure(a1.Equals(a2));
1471 a1 = new Any(typeof(unoidl.com.sun.star.uno.XComponentContext), null);
1472 l.assure(a1.Equals(a2) == false);
1473 a2 = a1;
1474 l.assure(a1.Equals(a2));
1475 l.assure(a1.Equals(null) == false);
1476 l.assure(a1.Equals(new object()) == false);