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 ifc
.reflection
;
21 import com
.sun
.star
.reflection
.XIdlClass
;
22 import com
.sun
.star
.reflection
.XIdlReflection
;
23 import com
.sun
.star
.uno
.TypeClass
;
24 import lib
.MultiMethodTest
;
27 * Testing <code>com.sun.star.reflection.XIdlReflection</code>
30 * <li><code> forName()</code></li>
31 * <li><code> getType()</code></li>
33 * @see com.sun.star.reflection.XIdlReflection
35 public class _XIdlReflection
extends MultiMethodTest
{
36 public XIdlReflection oObj
= null;
37 protected final static String typeName
= "com.sun.star.container.XNameAccess";
40 * Test calls the method and checks returned interface
41 * <code>com.sun.star.container.XNameAccess</code>: gets the name and the
42 * type and checks it. <p>
43 * Has <b> OK </b> status if returned name is equal to the name of the
44 * interface that was passed as parameter in the method call and if returned
45 * type is equal to <code>com.sun.star.uno.TypeClass.INTERFACE</code>. <p>
47 public void _forName() {
48 boolean result
= true;
49 XIdlClass cls
= oObj
.forName(typeName
);
52 log
.println("Class name: " + cls
.getName());
53 result
&= cls
.getTypeClass() == TypeClass
.INTERFACE
;
54 result
&= typeName
.equals(cls
.getName());
56 log
.println("Method returned null");
60 tRes
.tested("forName()", result
);
64 * Test creates the instance of <code>com.sun.star.io.Pipe</code>,
65 * calls the method using this instance as parameter and checks returned
67 * Has <b> OK </b> status if the instance was created successfully, if
68 * returned value isn't null and no exceptions were thrown. <p>
70 public void _getType() {
74 obj
= tParam
.getMSF().
75 createInstance("com.sun.star.io.Pipe") ;
76 } catch (com
.sun
.star
.uno
.Exception e
) {
77 log
.println("Can't create object");
78 tRes
.tested("getType()", false);
83 log
.println("Object wasn't created !");
84 tRes
.tested("getType()", false);
87 XIdlClass cls
= oObj
.getType(obj
);
89 log
.println("The name is " + cls
.getName());
91 tRes
.tested("getType()", cls
!= null);