svx: prefix members of SdrUnoObj
[LibreOffice.git] / qadevOOo / tests / java / mod / _svtools / AccessibleIconChoiceCtrlEntry.java
blob847ae380b006bcbe182be9d7fae38329176bb642
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 mod._svtools;
21 import java.io.PrintWriter;
23 import lib.TestCase;
24 import lib.TestEnvironment;
25 import lib.TestParameters;
26 import util.AccessibilityTools;
27 import util.DesktopTools;
28 import util.SOfficeFactory;
30 import com.sun.star.accessibility.AccessibleRole;
31 import com.sun.star.accessibility.XAccessible;
32 import com.sun.star.accessibility.XAccessibleAction;
33 import com.sun.star.accessibility.XAccessibleContext;
34 import com.sun.star.awt.XExtendedToolkit;
35 import com.sun.star.awt.XWindow;
36 import com.sun.star.beans.PropertyValue;
37 import com.sun.star.frame.XController;
38 import com.sun.star.frame.XDesktop;
39 import com.sun.star.frame.XDispatch;
40 import com.sun.star.frame.XDispatchProvider;
41 import com.sun.star.frame.XModel;
42 import com.sun.star.text.XTextDocument;
43 import com.sun.star.uno.UnoRuntime;
44 import com.sun.star.uno.XInterface;
45 import com.sun.star.util.URL;
46 import com.sun.star.util.XURLTransformer;
48 /**
49 * Test for object that implements the following interfaces :
50 * <ul>
51 * <li><code>
52 * ::com::sun::star::accessibility::XAccessibleContext</code></li>
53 * <li><code>
54 * ::com::sun::star::accessibility::XAccessibleEventBroadcaster
55 * </code></li>
56 * <li><code>
57 * ::com::sun::star::accessibility::XAccessibleComponent</code></li>
58 * <li><code>
59 * ::com::sun::star::accessibility::XAccessibleText</code></li>
60 * </ul> <p>
62 * @see com.sun.star.accessibility.XAccessibleEventBroadcaster
63 * @see com.sun.star.accessibility.XAccessibleContext
64 * @see com.sun.star.accessibility.XAccessibleComponent
65 * @see com.sun.star.accessibility.XAccessibleText
66 * @see ifc.accessibility._XAccessibleEventBroadcaster
67 * @see ifc.accessibility._XAccessibleContext
68 * @see ifc.accessibility._XAccessibleComponent
69 * @see ifc.accessibility._XAccessibleText
71 public class AccessibleIconChoiceCtrlEntry extends TestCase {
73 static XDesktop xDesktop;
74 static XTextDocument xTextDoc;
75 static XAccessibleAction accCloseButton = null;
77 /**
78 * Creates the Desktop service (<code>com.sun.star.frame.Desktop</code>).
80 @Override
81 protected void initialize(TestParameters Param, PrintWriter log) throws Exception {
82 xDesktop = DesktopTools.createDesktop(Param.getMSF());
85 /**
86 * Closes the Hyperlink dialog.
87 * Disposes the document, if exists, created in
88 * <code>createTestEnvironment</code> method.
90 @Override
91 protected void cleanup( TestParameters Param, PrintWriter log) {
93 log.println("closing HyperlinkDialog");
95 try {
96 if (accCloseButton != null) {
97 accCloseButton.doAccessibleAction(0);
99 } catch(com.sun.star.lang.IndexOutOfBoundsException e) {
100 e.printStackTrace(log);
103 log.println("disposing xTextDoc");
105 if (xTextDoc != null) {
106 xTextDoc.dispose();
111 * Creates a text document. Opens the Hyperlink dialog.
112 * Creates an instance of the service
113 * <code>com.sun.star.awt.Toolkit</code> and gets active top window.
114 * Then obtains an accessible object with the role
115 * <code>AccessibleRole.LABEL</code> and with the name
116 * <code>"Internet"</code>.
117 * Object relations created :
118 * <ul>
119 * <li> <code>'EventProducer'</code> for
120 * {@link ifc.accessibility._XAccessibleEventBroadcaster}:
121 * method <code>fireEvent()</code> is empty because object is transient
122 * </li>
123 * <li> <code>'XAccessibleText.Text'</code> for
124 * {@link ifc.accessibility._XAccessibleText}:
125 * the string representation of the item text
126 * </li>
127 * </ul>
129 * @param tParam test parameters
130 * @param log writer to log information while testing
132 * @see com.sun.star.awt.Toolkit
133 * @see com.sun.star.accessibility.AccessibleRole
134 * @see ifc.accessibility._XAccessibleEventBroadcaster
135 * @see com.sun.star.accessibility.XAccessibleEventBroadcaster
137 @Override
138 protected TestEnvironment createTestEnvironment(
139 TestParameters tParam, PrintWriter log) throws Exception {
141 log.println( "creating a test environment" );
143 if (xTextDoc != null) xTextDoc.dispose();
145 // get a soffice factory object
146 SOfficeFactory SOF = SOfficeFactory.getFactory( tParam.getMSF());
148 log.println( "creating a text document" );
149 xTextDoc = SOF.createTextDoc(null);
151 util.utils.waitForEventIdle(tParam.getMSF());
153 XModel aModel1 = UnoRuntime.queryInterface(XModel.class, xTextDoc);
155 XController secondController = aModel1.getCurrentController();
157 XDispatchProvider aProv = UnoRuntime.
158 queryInterface(XDispatchProvider.class, secondController);
160 XInterface transf = (XInterface)tParam.getMSF().createInstance
161 ("com.sun.star.util.URLTransformer");
162 XURLTransformer urlTransf = UnoRuntime.queryInterface
163 (XURLTransformer.class, transf);
165 XDispatch getting = null;
166 log.println( "opening HyperlinkDialog" );
167 URL[] url = new URL[1];
168 url[0] = new URL();
169 url[0].Complete = ".uno:HyperlinkDialog";
170 urlTransf.parseStrict(url);
171 getting = aProv.queryDispatch(url[0], "", 0);
172 PropertyValue[] noArgs = new PropertyValue[0];
173 getting.dispatch(url[0], noArgs);
175 util.utils.waitForEventIdle(tParam.getMSF());
177 XInterface oObj = (XInterface) tParam.getMSF().createInstance
178 ("com.sun.star.awt.Toolkit") ;
180 XExtendedToolkit tk = UnoRuntime.queryInterface(XExtendedToolkit.class, oObj);
182 util.utils.waitForEventIdle(tParam.getMSF());
184 XWindow xWindow = UnoRuntime.queryInterface(XWindow.class, tk.getActiveTopWindow());
186 XAccessible xRoot = AccessibilityTools.getAccessibleObject(xWindow);
188 oObj = AccessibilityTools.getAccessibleObjectForRole(xRoot,
189 AccessibleRole.LABEL, "Internet");
191 XAccessibleContext closeButton = AccessibilityTools.getAccessibleObjectForRole(xRoot,
192 AccessibleRole.PUSH_BUTTON, "Close");
194 accCloseButton = UnoRuntime.queryInterface(XAccessibleAction.class, closeButton);
196 log.println("ImplementationName: "+ util.utils.getImplName(oObj));
198 TestEnvironment tEnv = new TestEnvironment(oObj);
200 tEnv.addObjRelation("EventProducer",
201 new ifc.accessibility._XAccessibleEventBroadcaster.EventProducer(){
202 public void fireEvent() {
206 tEnv.addObjRelation("XAccessibleText.Text", "Internet");
208 tEnv.addObjRelation("EditOnly",
209 "This method isn't supported in this dialog");
211 tEnv.addObjRelation("LimitedBounds",
212 "only delivers senseful values for getCharacterBounds(0,length-1)");
214 return tEnv;