1 /*************************************************************************
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
5 * Copyright 2008 by Sun Microsystems, Inc.
7 * OpenOffice.org - a multi-platform office productivity suite
9 * $RCSfile: ScAccessibleCsvGrid.java,v $
12 * This file is part of OpenOffice.org.
14 * OpenOffice.org is free software: you can redistribute it and/or modify
15 * it under the terms of the GNU Lesser General Public License version 3
16 * only, as published by the Free Software Foundation.
18 * OpenOffice.org is distributed in the hope that it will be useful,
19 * but WITHOUT ANY WARRANTY; without even the implied warranty of
20 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
21 * GNU Lesser General Public License version 3 for more details
22 * (a copy is included in the LICENSE file that accompanied this code).
24 * You should have received a copy of the GNU Lesser General Public License
25 * version 3 along with OpenOffice.org. If not, see
26 * <http://www.openoffice.org/license.html>
27 * for a copy of the LGPLv3 License.
29 ************************************************************************/
33 import java
.io
.PrintWriter
;
35 import lib
.StatusException
;
37 import lib
.TestEnvironment
;
38 import lib
.TestParameters
;
39 import util
.AccessibilityTools
;
40 import util
.SOfficeFactory
;
43 import com
.sun
.star
.accessibility
.AccessibleRole
;
44 import com
.sun
.star
.accessibility
.XAccessible
;
45 import com
.sun
.star
.accessibility
.XAccessibleAction
;
46 import com
.sun
.star
.awt
.XExtendedToolkit
;
47 import com
.sun
.star
.awt
.XWindow
;
48 import com
.sun
.star
.beans
.PropertyValue
;
49 import com
.sun
.star
.lang
.XComponent
;
50 import com
.sun
.star
.lang
.XMultiServiceFactory
;
51 import com
.sun
.star
.uno
.UnoRuntime
;
52 import com
.sun
.star
.uno
.XInterface
;
54 public class ScAccessibleCsvGrid
extends TestCase
{
56 Thread lThread
= null;
57 static XAccessibleAction accAction
= null;
60 * Called to create an instance of <code>TestEnvironment</code> with an
61 * object to test and related objects. Subclasses should implement this
62 * method to provide the implementation and related objects. The method is
63 * called from <code>getTestEnvironment()</code>.
65 * @param tParam test parameters
66 * @param log writer to log information while testing
68 * @see TestEnvironment
69 * @see #getTestEnvironment()
71 protected TestEnvironment
createTestEnvironment(TestParameters Param
, PrintWriter log
) {
73 XInterface oObj
= null;
78 oObj
= (XInterface
) ((XMultiServiceFactory
)Param
.getMSF()).createInstance
79 ("com.sun.star.awt.Toolkit") ;
80 } catch (com
.sun
.star
.uno
.Exception e
) {
81 log
.println("Couldn't get toolkit");
82 e
.printStackTrace(log
);
83 throw new StatusException("Couldn't get toolkit", e
);
87 XExtendedToolkit tk
= (XExtendedToolkit
)
88 UnoRuntime
.queryInterface(XExtendedToolkit
.class,oObj
);
91 XWindow xWindow
= (XWindow
)
92 UnoRuntime
.queryInterface(XWindow
.class,tk
.getActiveTopWindow());
94 XAccessible xRoot
= AccessibilityTools
.getAccessibleObject(xWindow
);
96 oObj
= AccessibilityTools
.getAccessibleObjectForRole
97 (xRoot
, AccessibleRole
.PUSH_BUTTON
, "Cancel");
99 accAction
= (XAccessibleAction
) UnoRuntime
.queryInterface(XAccessibleAction
.class, oObj
);
101 /*int count = accAction.getAccessibleActionCount();
103 for (int i = 0; i<count; i++) {
105 System.out.println(i+": "+accAction.getAccessibleActionDescription(i));
106 } catch (com.sun.star.lang.IndexOutOfBoundsException iae) {}
109 //util.dbg.printInterfaces(oObj);
111 //AccessibilityTools.printAccessibleTree(log, xRoot);
113 oObj
= AccessibilityTools
.getAccessibleObjectForRole
114 (xRoot
, AccessibleRole
.TABLE
, true);
116 log
.println("ImplementationName " + utils
.getImplName(oObj
));
118 TestEnvironment tEnv
= new TestEnvironment(oObj
);
124 * Called while disposing a <code>TestEnvironment</code>.
125 * Disposes calc document.
126 * @param tParam test parameters
127 * @param tEnv the environment to cleanup
128 * @param log writer to log information while testing
130 protected void cleanup( TestParameters Param
, PrintWriter log
) {
131 log
.println( " closing Dialog " );
133 accAction
.doAccessibleAction(0);
134 } catch (com
.sun
.star
.lang
.IndexOutOfBoundsException iae
) {
135 log
.println("Couldn't close dialog");
140 * Called while the <code>TestCase</code> initialization. In the
141 * implementation does nothing. Subclasses can override to initialize
142 * objects shared among all <code>TestEnvironment</code>s.
144 * @param tParam test parameters
145 * @param log writer to log information while testing
147 * @see #initializeTestCase()
149 protected void initialize(TestParameters Param
, PrintWriter log
) {
150 // get a soffice factory object
151 SOfficeFactory SOF
= SOfficeFactory
.getFactory( (XMultiServiceFactory
)Param
.getMSF());
153 log
.println("opening dialog");
155 PropertyValue
[] args
= new PropertyValue
[1];
157 args
[0] = new PropertyValue();
158 args
[0].Name
= "InteractionHandler";
159 args
[0].Value
= ((XMultiServiceFactory
)Param
.getMSF()).createInstance(
160 "com.sun.star.comp.uui.UUIInteractionHandler");
161 } catch(com
.sun
.star
.uno
.Exception e
) {
164 lThread
= new loadThread(SOF
, args
);
171 * Sleeps for 2 sec. to allow StarOffice to react on <code>
174 private void shortWait() {
177 } catch (InterruptedException e
) {
178 log
.println("While waiting :" + e
) ;
182 public class loadThread
extends Thread
{
184 private SOfficeFactory SOF
= null ;
185 private PropertyValue
[] args
= null;
186 public XComponent xSpreadSheedDoc
= null;
188 public loadThread(SOfficeFactory SOF
, PropertyValue
[] Args
) {
195 String url
= utils
.getFullTestURL("10test.csv");
196 log
.println("loading "+url
);
197 SOF
.loadDocument(url
,args
);
198 } catch (com
.sun
.star
.uno
.Exception e
) {
200 throw new StatusException( "Couldn't create document ", e
);