tdf#130857 qt weld: Implement QtInstanceWidget::strip_mnemonic
[LibreOffice.git] / qadevOOo / tests / java / ifc / lang / _XMultiComponentFactory.java
blob424e3d5764701d7f2dbabd4aa3fd55d12cce7a4d
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.lang;
21 import lib.MultiMethodTest;
23 import com.sun.star.lang.XMultiComponentFactory;
24 import com.sun.star.uno.XComponentContext;
25 import com.sun.star.uno.XInterface;
27 /**
28 * Testing <code>com.sun.star.lang.XMultiComponentFactory</code>
29 * interface methods :
30 * <ul>
31 * <li><code> createInstanceWithContext()</code></li>
32 * <li><code> createInstanceWithArgumentsAndContext()</code></li>
33 * <li><code> getAvailableServiceNames()</code></li>
34 * </ul> <p>
35 * Test is <b> NOT </b> multithread compliant. <p>
36 * @see com.sun.star.lang.XMultiComponentFactory
38 public class _XMultiComponentFactory extends MultiMethodTest {
39 public XMultiComponentFactory oObj = null;
41 public XComponentContext xContext = null;
42 private String[] availableServiceNames = null;
44 @Override
45 public void before(){
46 xContext = (XComponentContext)tEnv.getObjRelation("DC");
47 availableServiceNames = (String[])tEnv.getObjRelation("XMultiComponentFactory.ServiceNames");
50 /**
51 * Calls the method with one of the available service names
52 * obtained by method getAvailableServiceNames. <p>
53 * Has <b> OK </b> status if no runtime exceptions occurred
54 * and returned value is not null.
56 public void _createInstanceWithContext() {
57 requiredMethod("getAvailableServiceNames()");
58 boolean result = true;
60 try {
61 XInterface component = (XInterface)
62 oObj.createInstanceWithContext(
63 availableServiceNames[0], xContext);
64 result = (component != null);
65 } catch (com.sun.star.uno.Exception e) {
66 log.println("Couldn't create instance " + availableServiceNames[0]);
67 result = false;
70 tRes.tested("createInstanceWithContext()", result);
73 /**
74 * Calls the method with one of the available service names
75 * obtained by method getAvailableServiceNames. <p>
76 * Has <b> OK </b> status if no runtime exceptions occurred
77 * and returned value is not null.
79 public void _createInstanceWithArgumentsAndContext() {
80 requiredMethod("getAvailableServiceNames()");
81 boolean result = true;
82 XInterface component = null;
84 try {
85 component = (XInterface)oObj.createInstanceWithArgumentsAndContext(
86 availableServiceNames[0], new Object[0], xContext);
87 result = (component != null);
88 } catch (com.sun.star.uno.Exception e) {
89 log.println("Couldn't create instance " + availableServiceNames[0]);
90 result = false;
93 tRes.tested("createInstanceWithArgumentsAndContext()", result);
96 /**
97 * Just calls the method. <p>
98 * Has <b> OK </b> status if no runtime exceptions occurred
99 * and returned value is not null.
101 public void _getAvailableServiceNames() {
102 boolean result = true;
103 if (availableServiceNames == null) {
104 availableServiceNames = oObj.getAvailableServiceNames();
105 result = (availableServiceNames != null);
107 else { // if service names are given, ignore result
108 String[]erg = oObj.getAvailableServiceNames();
109 result = (erg != null);
112 log.println("Available service names:");
113 if (availableServiceNames != null) {
114 for(int i = 0; i < availableServiceNames.length; i++) {
115 log.println(" " + availableServiceNames[i]);
119 tRes.tested("getAvailableServiceNames()", result);