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 .
21 import java
.io
.PrintWriter
;
23 import lib
.StatusException
;
25 import lib
.TestEnvironment
;
26 import lib
.TestParameters
;
27 import util
.AccessibilityTools
;
28 import util
.DesktopTools
;
29 import util
.SOfficeFactory
;
31 import com
.sun
.star
.accessibility
.AccessibleRole
;
32 import com
.sun
.star
.accessibility
.XAccessible
;
33 import com
.sun
.star
.accessibility
.XAccessibleAction
;
34 import com
.sun
.star
.accessibility
.XAccessibleContext
;
35 import com
.sun
.star
.awt
.XExtendedToolkit
;
36 import com
.sun
.star
.awt
.XWindow
;
37 import com
.sun
.star
.beans
.PropertyValue
;
38 import com
.sun
.star
.frame
.XController
;
39 import com
.sun
.star
.frame
.XDesktop
;
40 import com
.sun
.star
.frame
.XDispatch
;
41 import com
.sun
.star
.frame
.XDispatchProvider
;
42 import com
.sun
.star
.frame
.XModel
;
43 import com
.sun
.star
.text
.XTextDocument
;
44 import com
.sun
.star
.uno
.UnoRuntime
;
45 import com
.sun
.star
.uno
.XInterface
;
46 import com
.sun
.star
.util
.URL
;
47 import com
.sun
.star
.util
.XURLTransformer
;
50 * Test for object that implements the following interfaces :
53 * ::com::sun::star::accessibility::XAccessibleContext</code></li>
55 * ::com::sun::star::accessibility::XAccessibleEventBroadcaster
58 * ::com::sun::star::accessibility::XAccessibleComponent</code></li>
60 * ::com::sun::star::accessibility::XAccessibleText</code></li>
63 * @see com.sun.star.accessibility.XAccessibleEventBroadcaster
64 * @see com.sun.star.accessibility.XAccessibleContext
65 * @see com.sun.star.accessibility.XAccessibleComponent
66 * @see com.sun.star.accessibility.XAccessibleText
67 * @see ifc.accessibility._XAccessibleEventBroadcaster
68 * @see ifc.accessibility._XAccessibleContext
69 * @see ifc.accessibility._XAccessibleComponent
70 * @see ifc.accessibility._XAccessibleText
72 public class AccessibleIconChoiceCtrlEntry
extends TestCase
{
74 static XDesktop the_Desk
;
75 static XTextDocument xTextDoc
;
76 static XAccessibleAction accCloseButton
= null;
79 * Creates the Desktop service (<code>com.sun.star.frame.Desktop</code>).
82 protected void initialize(TestParameters Param
, PrintWriter log
) {
83 the_Desk
= UnoRuntime
.queryInterface(
84 XDesktop
.class, DesktopTools
.createDesktop(Param
.getMSF()));
88 * Closes the Hyperlink dialog.
89 * Disposes the document, if exists, created in
90 * <code>createTestEnvironment</code> method.
93 protected void cleanup( TestParameters Param
, PrintWriter log
) {
95 log
.println("closing HyperlinkDialog");
98 if (accCloseButton
!= null) {
99 accCloseButton
.doAccessibleAction(0);
101 } catch(com
.sun
.star
.lang
.IndexOutOfBoundsException e
) {
102 e
.printStackTrace(log
);
105 log
.println("disposing xTextDoc");
107 if (xTextDoc
!= null) {
113 * Creates a text document. Opens the Hyperlink dialog.
114 * Creates an instance of the service
115 * <code>com.sun.star.awt.Toolkit</code> and gets active top window.
116 * Then obtains an accessible object with the role
117 * <code>AccessibleRole.LABEL</code> and with the name
118 * <code>"Internet"</code>.
119 * Object relations created :
121 * <li> <code>'EventProducer'</code> for
122 * {@link ifc.accessibility._XAccessibleEventBroadcaster}:
123 * method <code>fireEvent()</code> is empty because object is transient
125 * <li> <code>'XAccessibleText.Text'</code> for
126 * {@link ifc.accessibility._XAccessibleText}:
127 * the string representation of the item text
131 * @param tParam test parameters
132 * @param log writer to log information while testing
134 * @see com.sun.star.awt.Toolkit
135 * @see com.sun.star.accessibility.AccessibleRole
136 * @see ifc.accessibility._XAccessibleEventBroadcaster
137 * @see com.sun.star.accessibility.XAccessibleEventBroadcaster
140 protected TestEnvironment
createTestEnvironment(
141 TestParameters tParam
, PrintWriter log
) {
143 log
.println( "creating a test environment" );
145 if (xTextDoc
!= null) xTextDoc
.dispose();
147 // get a soffice factory object
148 SOfficeFactory SOF
= SOfficeFactory
.getFactory( tParam
.getMSF());
151 log
.println( "creating a text document" );
152 xTextDoc
= SOF
.createTextDoc(null);
153 } catch ( com
.sun
.star
.uno
.Exception e
) {
154 // Some exception occurs.FAILED
155 e
.printStackTrace( log
);
156 throw new StatusException( "Couldn't create document", e
);
159 util
.utils
.pause(5000);
161 XModel aModel1
= UnoRuntime
.queryInterface(XModel
.class, xTextDoc
);
163 XController secondController
= aModel1
.getCurrentController();
165 XDispatchProvider aProv
= UnoRuntime
.
166 queryInterface(XDispatchProvider
.class, secondController
);
168 XURLTransformer urlTransf
= null;
171 XInterface transf
= (XInterface
)tParam
.getMSF().createInstance
172 ("com.sun.star.util.URLTransformer");
173 urlTransf
= UnoRuntime
.queryInterface
174 (XURLTransformer
.class, transf
);
175 } catch (com
.sun
.star
.uno
.Exception e
) {
176 e
.printStackTrace(log
);
177 throw new StatusException("Couldn't create URLTransformer", e
);
180 XDispatch getting
= null;
181 log
.println( "opening HyperlinkDialog" );
182 URL
[] url
= new URL
[1];
184 url
[0].Complete
= ".uno:HyperlinkDialog";
185 urlTransf
.parseStrict(url
);
186 getting
= aProv
.queryDispatch(url
[0], "", 0);
187 PropertyValue
[] noArgs
= new PropertyValue
[0];
188 getting
.dispatch(url
[0], noArgs
);
190 util
.utils
.pause(5000);
192 XInterface oObj
= null;
194 oObj
= (XInterface
) tParam
.getMSF().createInstance
195 ("com.sun.star.awt.Toolkit") ;
196 } catch (com
.sun
.star
.uno
.Exception e
) {
197 log
.println("Couldn't get toolkit");
198 e
.printStackTrace(log
);
199 throw new StatusException("Couldn't get toolkit", e
);
202 XExtendedToolkit tk
= UnoRuntime
.queryInterface(XExtendedToolkit
.class, oObj
);
204 util
.utils
.pause(5000);
206 XWindow xWindow
= UnoRuntime
.queryInterface(XWindow
.class, tk
.getActiveTopWindow());
208 XAccessible xRoot
= AccessibilityTools
.getAccessibleObject(xWindow
);
210 oObj
= AccessibilityTools
.getAccessibleObjectForRole(xRoot
,
211 AccessibleRole
.LABEL
, "Internet");
213 XAccessibleContext closeButton
= AccessibilityTools
.getAccessibleObjectForRole(xRoot
,
214 AccessibleRole
.PUSH_BUTTON
, "Close");
216 accCloseButton
= UnoRuntime
.queryInterface(XAccessibleAction
.class, closeButton
);
218 log
.println("ImplementationName: "+ util
.utils
.getImplName(oObj
));
220 TestEnvironment tEnv
= new TestEnvironment(oObj
);
222 tEnv
.addObjRelation("EventProducer",
223 new ifc
.accessibility
._XAccessibleEventBroadcaster
.EventProducer(){
224 public void fireEvent() {
228 tEnv
.addObjRelation("XAccessibleText.Text", "Internet");
230 tEnv
.addObjRelation("EditOnly",
231 "This method isn't supported in this dialog");
233 tEnv
.addObjRelation("LimitedBounds",
234 "only delivers senseful values for getCharacterBounds(0,length-1)");