bump product version to 4.2.0.1
[LibreOffice.git] / qadevOOo / tests / java / ifc / reflection / _XIdlReflection.java
blob306c25883fe6675b3308c330112a0931dc62d190
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 ifc.reflection;
21 import com.sun.star.lang.XMultiServiceFactory;
22 import com.sun.star.reflection.XIdlClass;
23 import com.sun.star.reflection.XIdlReflection;
24 import com.sun.star.uno.TypeClass;
25 import lib.MultiMethodTest;
27 /**
28 * Testing <code>com.sun.star.reflection.XIdlReflection</code>
29 * interface methods :
30 * <ul>
31 * <li><code> forName()</code></li>
32 * <li><code> getType()</code></li>
33 * </ul> <p>
34 * @see com.sun.star.reflection.XIdlReflection
36 public class _XIdlReflection extends MultiMethodTest{
37 public XIdlReflection oObj = null;
38 protected final static String typeName = "com.sun.star.container.XNameAccess";
40 /**
41 * Test calls the method and checks returned interface
42 * <code>com.sun.star.container.XNameAccess</code>: gets the name and the
43 * type and checks it. <p>
44 * Has <b> OK </b> status if returned name is equal to the name of the
45 * interface that was passed as parameter in the method call and if returned
46 * type is equal to <code>com.sun.star.uno.TypeClass.INTERFACE</code>. <p>
48 public void _forName() {
49 boolean result = true;
50 XIdlClass cls = oObj.forName(typeName);
52 if (cls != null) {
53 log.println("Class name: " + cls.getName());
54 result &= cls.getTypeClass() == TypeClass.INTERFACE;
55 result &= typeName.equals(cls.getName());
56 } else {
57 log.println("Method returned null");
58 result = false;
61 tRes.tested("forName()", result);
64 /**
65 * Test creates the instance of <code>com.sun.star.io.Pipe</code>,
66 * calls the method using this instance as parameter and checks returned
67 * value. <p>
68 * Has <b> OK </b> status if the instance was created successfully, if
69 * returned value isn't null and no exceptions were thrown. <p>
71 public void _getType() {
72 Object obj = null;
74 try {
75 obj = ((XMultiServiceFactory)tParam.getMSF()).
76 createInstance("com.sun.star.io.Pipe") ;
77 } catch (com.sun.star.uno.Exception e) {
78 log.println("Can't create object");
79 tRes.tested("getType()", false);
80 return;
83 if (obj == null) {
84 log.println("Object wasn't created !");
85 tRes.tested("getType()", false);
88 XIdlClass cls = oObj.getType(obj);
90 log.println("The name is " + cls.getName());
92 tRes.tested("getType()", cls != null);