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
.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
.accessibility
.XAccessibleText
;
36 import com
.sun
.star
.awt
.XExtendedToolkit
;
37 import com
.sun
.star
.awt
.XWindow
;
38 import com
.sun
.star
.beans
.PropertyValue
;
39 import com
.sun
.star
.lang
.XComponent
;
40 import com
.sun
.star
.lang
.XMultiServiceFactory
;
41 import com
.sun
.star
.uno
.UnoRuntime
;
42 import com
.sun
.star
.uno
.XInterface
;
44 public class ScAccessibleCsvRuler
extends TestCase
{
46 Thread lThread
= null;
47 static XAccessibleAction accAction
= null;
50 * Called to create an instance of <code>TestEnvironment</code> with an
51 * object to test and related objects. Subclasses should implement this
52 * method to provide the implementation and related objects. The method is
53 * called from <code>getTestEnvironment()</code>.
55 * @param Param test parameters
56 * @param log writer to log information while testing
58 * @see TestEnvironment
59 * @see #getTestEnvironment
61 protected TestEnvironment
createTestEnvironment(TestParameters Param
,
63 XInterface oObj
= null;
67 XMultiServiceFactory msf
= (XMultiServiceFactory
) Param
.getMSF();
70 oObj
= (XInterface
) msf
.createInstance("com.sun.star.awt.Toolkit");
71 } catch (com
.sun
.star
.uno
.Exception e
) {
72 log
.println("Couldn't get toolkit");
73 e
.printStackTrace(log
);
74 throw new StatusException("Couldn't get toolkit", e
);
77 XExtendedToolkit tk
= UnoRuntime
.queryInterface(
78 XExtendedToolkit
.class, oObj
);
80 XWindow xWindow
= UnoRuntime
.queryInterface(XWindow
.class,
81 tk
.getActiveTopWindow());
83 XAccessible xRoot
= AccessibilityTools
.getAccessibleObject(xWindow
);
85 oObj
= AccessibilityTools
.getAccessibleObjectForRole(xRoot
, AccessibleRole
.PUSH_BUTTON
,
88 accAction
= UnoRuntime
.queryInterface(
89 XAccessibleAction
.class, oObj
);
91 XAccessibleContext acc
= AccessibilityTools
.getAccessibleObjectForRole(xRoot
,
92 AccessibleRole
.RADIO_BUTTON
);
94 log
.println("Click on: " + acc
.getAccessibleName());
96 XAccessibleAction accAction2
= UnoRuntime
.queryInterface(
97 XAccessibleAction
.class, acc
);
100 accAction2
.doAccessibleAction(0);
101 } catch (com
.sun
.star
.lang
.IndexOutOfBoundsException iae
) {
105 //util.dbg.printInterfaces(oObj);
106 AccessibilityTools
.printAccessibleTree(log
, xRoot
);
107 oObj
= AccessibilityTools
.getAccessibleObjectForRole(xRoot
, AccessibleRole
.TEXT
,
110 log
.println("ImplementationName " + utils
.getImplName(oObj
));
112 TestEnvironment tEnv
= new TestEnvironment(oObj
);
114 tEnv
.addObjRelation("EditOnly",
115 "This method isn't supported in this dialog");
117 XAccessibleText text
= UnoRuntime
.queryInterface(
118 XAccessibleText
.class, oObj
);
122 for (int i
= 0; i
< 1000; i
++) {
124 text
.getCharacterBounds(i
);
125 } catch (com
.sun
.star
.lang
.IndexOutOfBoundsException e
) {
132 tEnv
.addObjRelation("LimitedBounds", new Integer(lastone
));
133 tEnv
.addObjRelation("PreviousUsed",new int[]{11,22,33,44,55,66,77,88,99});
139 * Called while disposing a <code>TestEnvironment</code>.
140 * Disposes calc document.
141 * @param Param test parameters
142 * @param log writer to log information while testing
144 protected void cleanup( TestParameters Param
, PrintWriter log
) {
145 /* log.println( " closing Dialog " );
147 accAction.doAccessibleAction(0);
148 } catch (com.sun.star.lang.IndexOutOfBoundsException iae) {
149 log.println("Couldn't close dialog");
154 * Called while the <code>TestCase</code> initialization. In the
155 * implementation does nothing. Subclasses can override to initialize
156 * objects shared among all <code>TestEnvironment</code>s.
158 * @param Param test parameters
159 * @param log writer to log information while testing
161 * @see #initializeTestCase
163 protected void initialize(TestParameters Param
, PrintWriter log
) {
164 // get a soffice factory object
165 SOfficeFactory SOF
= SOfficeFactory
.getFactory( (XMultiServiceFactory
)Param
.getMSF());
167 log
.println("opening dialog");
169 PropertyValue
[] args
= new PropertyValue
[1];
171 args
[0] = new PropertyValue();
172 args
[0].Name
= "InteractionHandler";
173 args
[0].Value
= ((XMultiServiceFactory
)Param
.getMSF()).createInstance(
174 "com.sun.star.comp.uui.UUIInteractionHandler");
175 } catch(com
.sun
.star
.uno
.Exception e
) {
178 lThread
= new loadThread(SOF
, args
);
185 * Sleeps for 2 sec. to allow StarOffice to react on <code>
188 private void shortWait() {
191 } catch (InterruptedException e
) {
192 log
.println("While waiting :" + e
) ;
196 public class loadThread
extends Thread
{
198 private SOfficeFactory SOF
= null ;
199 private PropertyValue
[] args
= null;
200 public XComponent xSpreadSheedDoc
= null;
202 public loadThread(SOfficeFactory SOF
, PropertyValue
[] Args
) {
209 String url
= utils
.getFullTestURL("10test.csv");
210 log
.println("loading "+url
);
211 SOF
.loadDocument(url
,args
);
212 } catch (com
.sun
.star
.uno
.Exception e
) {
214 throw new StatusException( "Couldn't create document ", e
);