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
.awt
.XExtendedToolkit
;
36 import com
.sun
.star
.awt
.XWindow
;
37 import com
.sun
.star
.beans
.PropertyValue
;
38 import com
.sun
.star
.uno
.UnoRuntime
;
39 import com
.sun
.star
.uno
.XInterface
;
41 public class ScAccessibleCsvCell
extends TestCase
{
43 Thread lThread
= null;
44 static XAccessibleAction accAction
= null;
47 * Called to create an instance of <code>TestEnvironment</code> with an
48 * object to test and related objects. Subclasses should implement this
49 * method to provide the implementation and related objects. The method is
50 * called from <code>getTestEnvironment()</code>.
52 * @param tParam test parameters
53 * @param log writer to log information while testing
55 * @see TestEnvironment
56 * @see #getTestEnvironment
59 protected TestEnvironment
createTestEnvironment(TestParameters tParam
, PrintWriter log
) {
60 XInterface oObj
= null;
62 util
.utils
.pause(2000);
65 oObj
= (XInterface
) tParam
.getMSF().createInstance
66 ("com.sun.star.awt.Toolkit") ;
67 } catch (com
.sun
.star
.uno
.Exception e
) {
68 log
.println("Couldn't get toolkit");
69 e
.printStackTrace(log
);
70 throw new StatusException("Couldn't get toolkit", e
);
74 XExtendedToolkit tk
= UnoRuntime
.queryInterface(XExtendedToolkit
.class,oObj
);
76 XWindow xWindow
= UnoRuntime
.queryInterface(XWindow
.class,tk
.getActiveTopWindow());
78 XAccessible xRoot
= AccessibilityTools
.getAccessibleObject(xWindow
);
80 AccessibilityTools
.printAccessibleTree(log
, xRoot
, tParam
.getBool(util
.PropertyName
.DEBUG_IS_ACTIVE
));
81 oObj
= AccessibilityTools
.getAccessibleObjectForRole
82 (xRoot
, AccessibleRole
.PUSH_BUTTON
, "Cancel");
84 accAction
= UnoRuntime
.queryInterface(XAccessibleAction
.class, oObj
);
86 oObj
= AccessibilityTools
.getAccessibleObjectForRole
87 (xRoot
, AccessibleRole
.TABLE
, true);
89 XAccessibleContext cont
= UnoRuntime
.queryInterface(XAccessibleContext
.class, oObj
);
93 XAccessible acc
= cont
.getAccessibleChild(3);
94 name
= acc
.getAccessibleContext().getAccessibleName();
95 log
.println("Child: "+ name
);
96 log
.println("ImplementationName " + utils
.getImplName(acc
));
99 catch(com
.sun
.star
.lang
.IndexOutOfBoundsException e
) {}
101 TestEnvironment tEnv
= new TestEnvironment(oObj
);
103 tEnv
.addObjRelation("EditOnly",
104 "This method isn't supported in this dialog");
106 tEnv
.addObjRelation("XAccessibleText.Text", name
);
112 * Called while disposing a <code>TestEnvironment</code>.
113 * Disposes calc document.
114 * @param Param test parameters
115 * @param log writer to log information while testing
118 protected void cleanup( TestParameters Param
, PrintWriter log
) {
119 log
.println( " closing Dialog " );
121 accAction
.doAccessibleAction(0);
122 } catch (com
.sun
.star
.lang
.IndexOutOfBoundsException iae
) {
123 log
.println("Couldn't close dialog");
128 * Called while the <code>TestCase</code> initialization. In the
129 * implementation does nothing. Subclasses can override to initialize
130 * objects shared among all <code>TestEnvironment</code>s.
132 * @param Param test parameters
133 * @param log writer to log information while testing
135 * @see #initializeTestCase
138 protected void initialize(TestParameters Param
, PrintWriter log
) {
139 // get a soffice factory object
140 SOfficeFactory SOF
= SOfficeFactory
.getFactory( Param
.getMSF());
142 log
.println("opening dialog");
144 PropertyValue
[] args
= new PropertyValue
[1];
146 args
[0] = new PropertyValue();
147 args
[0].Name
= "InteractionHandler";
148 args
[0].Value
= Param
.getMSF().createInstance(
149 "com.sun.star.comp.uui.UUIInteractionHandler");
150 } catch(com
.sun
.star
.uno
.Exception e
) {
153 lThread
= new loadThread(SOF
, args
);
155 util
.utils
.pause(2000);
158 private class loadThread
extends Thread
{
160 private final SOfficeFactory SOF
;
161 private final PropertyValue
[] args
;
163 private loadThread(SOfficeFactory SOF
, PropertyValue
[] Args
) {
171 String url
= utils
.getFullTestURL("10test.csv");
172 log
.println("loading "+url
);
173 SOF
.loadDocument(url
,args
);
174 } catch (com
.sun
.star
.uno
.Exception e
) {
176 throw new StatusException( "Couldn't create document ", e
);