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
.awt
.XExtendedToolkit
;
35 import com
.sun
.star
.awt
.XWindow
;
36 import com
.sun
.star
.beans
.PropertyValue
;
37 import com
.sun
.star
.uno
.UnoRuntime
;
38 import com
.sun
.star
.uno
.XInterface
;
40 public class ScAccessibleCsvGrid
extends TestCase
{
42 Thread lThread
= null;
43 static XAccessibleAction accAction
= null;
46 * Called to create an instance of <code>TestEnvironment</code> with an
47 * object to test and related objects. Subclasses should implement this
48 * method to provide the implementation and related objects. The method is
49 * called from <code>getTestEnvironment()</code>.
51 * @param Param test parameters
52 * @param log writer to log information while testing
54 * @see TestEnvironment
55 * @see #getTestEnvironment
58 protected TestEnvironment
createTestEnvironment(TestParameters Param
, PrintWriter log
) {
60 XInterface oObj
= null;
62 util
.utils
.pause(2000);
65 oObj
= (XInterface
) Param
.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
);
77 XWindow xWindow
= UnoRuntime
.queryInterface(XWindow
.class,tk
.getActiveTopWindow());
79 XAccessible xRoot
= AccessibilityTools
.getAccessibleObject(xWindow
);
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 log
.println("ImplementationName " + utils
.getImplName(oObj
));
91 TestEnvironment tEnv
= new TestEnvironment(oObj
);
97 * Called while disposing a <code>TestEnvironment</code>.
98 * Disposes calc document.
99 * @param Param test parameters
100 * @param log writer to log information while testing
103 protected void cleanup( TestParameters Param
, PrintWriter log
) {
104 log
.println( " closing Dialog " );
106 accAction
.doAccessibleAction(0);
107 } catch (com
.sun
.star
.lang
.IndexOutOfBoundsException iae
) {
108 log
.println("Couldn't close dialog");
113 * Called while the <code>TestCase</code> initialization. In the
114 * implementation does nothing. Subclasses can override to initialize
115 * objects shared among all <code>TestEnvironment</code>s.
117 * @param Param test parameters
118 * @param log writer to log information while testing
120 * @see #initializeTestCase
123 protected void initialize(TestParameters Param
, PrintWriter log
) {
124 // get a soffice factory object
125 SOfficeFactory SOF
= SOfficeFactory
.getFactory( Param
.getMSF());
127 log
.println("opening dialog");
129 PropertyValue
[] args
= new PropertyValue
[1];
131 args
[0] = new PropertyValue();
132 args
[0].Name
= "InteractionHandler";
133 args
[0].Value
= Param
.getMSF().createInstance(
134 "com.sun.star.comp.uui.UUIInteractionHandler");
135 } catch(com
.sun
.star
.uno
.Exception e
) {
138 lThread
= new loadThread(SOF
, args
);
140 util
.utils
.pause(2000);
144 private class loadThread
extends Thread
{
146 private final SOfficeFactory SOF
;
147 private final PropertyValue
[] args
;
149 private loadThread(SOfficeFactory SOF
, PropertyValue
[] Args
) {
157 String url
= utils
.getFullTestURL("10test.csv");
158 log
.println("loading "+url
);
159 SOF
.loadDocument(url
,args
);
160 } catch (com
.sun
.star
.uno
.Exception e
) {
162 throw new StatusException( "Couldn't create document ", e
);