tdf#130857 qt weld: Implement QtInstanceWidget::strip_mnemonic
[LibreOffice.git] / qadevOOo / tests / java / ifc / frame / _XDispatchProvider.java
blob3cc7c17186c6b9e0240339952663d2f0f64d688b
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.frame;
21 import lib.MultiMethodTest;
22 import util.utils;
24 import com.sun.star.frame.DispatchDescriptor;
25 import com.sun.star.frame.FrameSearchFlag;
26 import com.sun.star.frame.XDispatch;
27 import com.sun.star.frame.XDispatchProvider;
28 import com.sun.star.uno.UnoRuntime;
29 import com.sun.star.util.URL;
30 import com.sun.star.util.XURLTransformer;
32 /**
33 * Testing <code>com.sun.star.frame.XDispatchProvider</code>
34 * interface methods:
35 * <ul>
36 * <li><code> queryDispatch() </code></li>
37 * <li><code> queryDispatches() </code></li>
38 * </ul><p>
39 * This test needs the following object relations :
40 * <ul>
41 * <li> <code>'XDispatchProvider.URL'</code> (of type <code>String</code>):
42 * used to obtain unparsed url of DispatchProvider </li>
43 * </ul> <p>
44 * Test is <b> NOT </b> multithread compliant. <p>
45 * @see com.sun.star.frame.XDispatchProvider
47 public class _XDispatchProvider extends MultiMethodTest {
48 public static XDispatchProvider oObj = null;
49 private String dispatchUrl = null ;
51 /**
52 * Retrieves object relation.
54 @Override
55 public void before() {
56 dispatchUrl = (String) tEnv.getObjRelation("XDispatchProvider.URL") ;
57 if (dispatchUrl == null) {
58 dispatchUrl = utils.getFullTestDocName("index.html");
60 log.println("Using URL: '" + dispatchUrl + "'");
63 /**
64 * Test calls the method. <p>
65 * Has <b> OK </b> status if the method does not return null.
67 public void _queryDispatch() {
68 URL url = new URL();
69 String frameName = "_top";
71 url.Complete = dispatchUrl;
72 try {
73 XURLTransformer xParser=UnoRuntime.queryInterface(XURLTransformer.class,
74 tParam.getMSF().createInstance
75 ("com.sun.star.util.URLTransformer"));
76 // Because it's an in/out parameter we must use an array of
77 // URL objects.
78 URL[] aParseURL = new URL[1];
79 aParseURL[0] = new URL();
80 aParseURL[0].Complete = dispatchUrl;
81 xParser.parseStrict(aParseURL);
82 url = aParseURL[0];
83 } catch (com.sun.star.uno.Exception e) {
84 log.println("Couldn't parse URL");
86 XDispatch xDispatch = oObj.queryDispatch(url,
87 frameName, FrameSearchFlag.ALL);
88 tRes.tested("queryDispatch()", xDispatch != null);
91 /**
92 * Before test calls the method, DispatchDescriptor sequence is defined.<p>
93 * Has <b> OK </b> status if the method does not return null, returned
94 * sequence length is equal to a number of DispatchDescriptors
95 * and returned sequence consists of non-null elements.
97 public void _queryDispatches() {
98 String name1 = "_self";
99 String name2 = "_top";
100 URL url1 = new URL();
101 URL url2 = new URL();
103 url1.Complete = dispatchUrl;
104 url2.Complete = dispatchUrl;
105 try {
106 log.println("Parsing URL");
107 XURLTransformer xParser = UnoRuntime.queryInterface(XURLTransformer.class,
108 tParam.getMSF().createInstance
109 ("com.sun.star.util.URLTransformer"));
110 // Because it's an in/out parameter we must use an array of
111 // URL objects.
112 URL[] aParseURL = new URL[1];
113 aParseURL[0] = new URL();
114 aParseURL[0].Complete = dispatchUrl;
115 xParser.parseStrict(aParseURL);
116 url1 = aParseURL[0];
117 url2 = aParseURL[0];
118 } catch (com.sun.star.uno.Exception e) {
119 log.println("Couldn't parse URL");
121 DispatchDescriptor descs[] = new DispatchDescriptor[] {
122 new DispatchDescriptor(url1, name1, FrameSearchFlag.ALL),
123 new DispatchDescriptor(url2, name2, FrameSearchFlag.ALL)
125 XDispatch[] xDispatches = oObj.queryDispatches(descs);
127 if (xDispatches == null) {
128 log.println("queryDispatches() returned null");
129 tRes.tested("queryDispatches()", false);
130 return;
133 if (xDispatches.length != descs.length) {
134 log.println("queryDispatches() returned "
135 + xDispatches.length
136 + " amount of XDispatch instead of "
137 + descs.length);
138 tRes.tested("queryDispatches()", false);
139 return;
142 for (int i = 0; i < xDispatches.length; i++) {
143 if (xDispatches[i] == null) {
144 log.println("queryDispatches() result contains"
145 + " null object");
146 tRes.tested("queryDispatches()", false);
147 return;
151 tRes.tested("queryDispatches()", true);