tdf#130857 qt weld: Implement QtInstanceWidget::strip_mnemonic
[LibreOffice.git] / qadevOOo / tests / java / ifc / script / _XInvocationAdapterFactory.java
blob1475b7380db5d9257aaed49b7ca742bb3f23d52d
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.script;
21 import lib.MultiMethodTest;
22 import lib.StatusException;
24 import com.sun.star.io.XInputStream;
25 import com.sun.star.lang.XMultiServiceFactory;
26 import com.sun.star.lang.XSingleServiceFactory;
27 import com.sun.star.script.XInvocation;
28 import com.sun.star.script.XInvocationAdapterFactory;
29 import com.sun.star.uno.Type;
30 import com.sun.star.uno.UnoRuntime;
31 import com.sun.star.uno.XInterface;
33 /**
34 * Testing <code>com.sun.star.script.XInvocationAdapterFactory</code>
35 * interface methods :
36 * <ul>
37 * <li><code> createAdapter()</code></li>
38 * </ul> <p>
39 * Test is <b> NOT </b> multithread compliant. <p>
40 * @see com.sun.star.script.XInvocationAdapterFactory
42 public class _XInvocationAdapterFactory extends MultiMethodTest {
44 /**
45 * oObj filled by MultiMethodTest
47 public XInvocationAdapterFactory oObj = null;
49 /**
50 * First an invocation object of <code>com.sun.star.io.Pipe</code>
51 * instance is created using <code>com.sun.star.script.Invocation
52 * </code> service. Then trying to create an adapter of this
53 * invocation for <code>com.sun.star.io.XInputStream</code>
54 * interface. <p>
55 * Has <b>OK</b> status if the adapter returned is successfully
56 * queried for <code>com.sun.star.io.XInputStream</code>
57 * interface.
58 * @see com.sun.star.script.Invocation
59 * @see com.sun.star.script.XInvocation
60 * @see com.sun.star.io.Pipe
62 public void _createAdapter() {
63 XInvocation xInv = null ;
64 XMultiServiceFactory xMSF = null;
65 try {
66 xMSF = tParam.getMSF();
67 Object[] args = {xMSF.createInstance
68 ("com.sun.star.io.Pipe")};
70 Object oInvFac = xMSF.createInstance
71 ("com.sun.star.script.Invocation") ;
73 XSingleServiceFactory xInvFac = UnoRuntime.
74 queryInterface(XSingleServiceFactory.class, oInvFac) ;
76 Object oInv = xInvFac.createInstanceWithArguments(args) ;
78 xInv = UnoRuntime.queryInterface
79 (XInvocation.class, oInv) ;
81 } catch (com.sun.star.uno.Exception e) {
82 e.printStackTrace(log) ;
83 throw new StatusException("Can't create invocation for object", e) ;
86 XInterface xInStr = null ;
88 Object adp = oObj.createAdapter(xInv,
89 new Type(XInputStream.class)) ;
91 xInStr = UnoRuntime.queryInterface
92 (XInputStream.class, adp) ;
95 if (xInStr != null)
96 tRes.tested("createAdapter()", true) ;
97 else {
98 log.println("Adapter created doesn't implement required interface") ;
99 tRes.tested("createAdapter()", false) ;