xref: /AOO41X/main/qadevOOo/tests/java/mod/_dbaccess/ConnectionLineAccessibility.java (revision cdf0e10c4e3984b49a9502b011690b615761d4a3)
1*cdf0e10cSrcweir /*************************************************************************
2*cdf0e10cSrcweir  *
3*cdf0e10cSrcweir  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4*cdf0e10cSrcweir  *
5*cdf0e10cSrcweir  * Copyright 2000, 2010 Oracle and/or its affiliates.
6*cdf0e10cSrcweir  *
7*cdf0e10cSrcweir  * OpenOffice.org - a multi-platform office productivity suite
8*cdf0e10cSrcweir  *
9*cdf0e10cSrcweir  * This file is part of OpenOffice.org.
10*cdf0e10cSrcweir  *
11*cdf0e10cSrcweir  * OpenOffice.org is free software: you can redistribute it and/or modify
12*cdf0e10cSrcweir  * it under the terms of the GNU Lesser General Public License version 3
13*cdf0e10cSrcweir  * only, as published by the Free Software Foundation.
14*cdf0e10cSrcweir  *
15*cdf0e10cSrcweir  * OpenOffice.org is distributed in the hope that it will be useful,
16*cdf0e10cSrcweir  * but WITHOUT ANY WARRANTY; without even the implied warranty of
17*cdf0e10cSrcweir  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
18*cdf0e10cSrcweir  * GNU Lesser General Public License version 3 for more details
19*cdf0e10cSrcweir  * (a copy is included in the LICENSE file that accompanied this code).
20*cdf0e10cSrcweir  *
21*cdf0e10cSrcweir  * You should have received a copy of the GNU Lesser General Public License
22*cdf0e10cSrcweir  * version 3 along with OpenOffice.org.  If not, see
23*cdf0e10cSrcweir  * <http://www.openoffice.org/license.html>
24*cdf0e10cSrcweir  * for a copy of the LGPLv3 License.
25*cdf0e10cSrcweir  *
26*cdf0e10cSrcweir  ************************************************************************/
27*cdf0e10cSrcweir package mod._dbaccess;
28*cdf0e10cSrcweir 
29*cdf0e10cSrcweir import java.io.PrintWriter;
30*cdf0e10cSrcweir 
31*cdf0e10cSrcweir import lib.Status;
32*cdf0e10cSrcweir import lib.StatusException;
33*cdf0e10cSrcweir import lib.TestCase;
34*cdf0e10cSrcweir import lib.TestEnvironment;
35*cdf0e10cSrcweir import lib.TestParameters;
36*cdf0e10cSrcweir import util.AccessibilityTools;
37*cdf0e10cSrcweir 
38*cdf0e10cSrcweir import com.sun.star.accessibility.AccessibleRole;
39*cdf0e10cSrcweir import com.sun.star.accessibility.XAccessible;
40*cdf0e10cSrcweir import com.sun.star.awt.PosSize;
41*cdf0e10cSrcweir import com.sun.star.awt.Rectangle;
42*cdf0e10cSrcweir import com.sun.star.awt.XWindow;
43*cdf0e10cSrcweir import com.sun.star.beans.PropertyValue;
44*cdf0e10cSrcweir import com.sun.star.beans.XPropertySet;
45*cdf0e10cSrcweir import com.sun.star.container.XNameAccess;
46*cdf0e10cSrcweir import com.sun.star.container.XNameContainer;
47*cdf0e10cSrcweir import com.sun.star.frame.XModel;
48*cdf0e10cSrcweir import com.sun.star.frame.XStorable;
49*cdf0e10cSrcweir import com.sun.star.lang.XComponent;
50*cdf0e10cSrcweir import com.sun.star.lang.XMultiServiceFactory;
51*cdf0e10cSrcweir import com.sun.star.sdb.XDocumentDataSource;
52*cdf0e10cSrcweir import com.sun.star.sdb.XQueryDefinitionsSupplier;
53*cdf0e10cSrcweir import com.sun.star.sdbc.XConnection;
54*cdf0e10cSrcweir import com.sun.star.sdbc.XIsolatedConnection;
55*cdf0e10cSrcweir import com.sun.star.sdbc.XStatement;
56*cdf0e10cSrcweir import com.sun.star.ucb.XSimpleFileAccess;
57*cdf0e10cSrcweir import com.sun.star.uno.UnoRuntime;
58*cdf0e10cSrcweir import com.sun.star.uno.XInterface;
59*cdf0e10cSrcweir import util.DesktopTools;
60*cdf0e10cSrcweir import util.utils;
61*cdf0e10cSrcweir 
62*cdf0e10cSrcweir 
63*cdf0e10cSrcweir /**
64*cdf0e10cSrcweir  * Object implements the following interfaces :
65*cdf0e10cSrcweir  * <ul>
66*cdf0e10cSrcweir  *   <li><code>::com::sun::star::accessibility::XAccessible</code></li>
67*cdf0e10cSrcweir  *   <li><code>::com::sun::star::accessibility::XAccessibleContext
68*cdf0e10cSrcweir  *   </code></li>
69*cdf0e10cSrcweir  *   <li><code>::com::sun::star::accessibility::XAccessibleEventBroadcaster
70*cdf0e10cSrcweir  *   </code></li>
71*cdf0e10cSrcweir  * </ul><p>
72*cdf0e10cSrcweir  * @see com.sun.star.accessibility.XAccessible
73*cdf0e10cSrcweir  * @see com.sun.star.accessibility.XAccessibleContext
74*cdf0e10cSrcweir  * @see com.sun.star.accessibility.XAccessibleEventBroadcaster
75*cdf0e10cSrcweir  * @see ifc.accessibility._XAccessible
76*cdf0e10cSrcweir  * @see ifc.accessibility._XAccessibleContext
77*cdf0e10cSrcweir  * @see ifc.accessibility._XAccessibleEventBroadcaster
78*cdf0e10cSrcweir  */
79*cdf0e10cSrcweir public class ConnectionLineAccessibility extends TestCase
80*cdf0e10cSrcweir {
81*cdf0e10cSrcweir     XWindow xWindow = null;
82*cdf0e10cSrcweir     Object oDBSource = null;
83*cdf0e10cSrcweir     String aFile = "";
84*cdf0e10cSrcweir     XConnection connection = null;
85*cdf0e10cSrcweir     XIsolatedConnection isolConnection = null;
86*cdf0e10cSrcweir     XComponent QueryComponent = null;
87*cdf0e10cSrcweir     String user = "";
88*cdf0e10cSrcweir     String password="";
89*cdf0e10cSrcweir 
90*cdf0e10cSrcweir     /**
91*cdf0e10cSrcweir      * Creates a new DataSource and stores it.
92*cdf0e10cSrcweir      * Creates a connection and using it
93*cdf0e10cSrcweir      * creates two tables in database.
94*cdf0e10cSrcweir      * Creates a new query and adds it to DefinitionContainer.
95*cdf0e10cSrcweir      * Opens the QueryComponent.with loadComponentFromURL
96*cdf0e10cSrcweir      * and gets the object with the role UNKNOWN and the Impplementation
97*cdf0e10cSrcweir      * name that contains ConnectionLine
98*cdf0e10cSrcweir      * @param Param test parameters
99*cdf0e10cSrcweir      * @param log writer to log information while testing
100*cdf0e10cSrcweir      * @return
101*cdf0e10cSrcweir      * @throws StatusException
102*cdf0e10cSrcweir      * @see TestEnvironment
103*cdf0e10cSrcweir      */
104*cdf0e10cSrcweir     protected TestEnvironment createTestEnvironment(TestParameters Param,
105*cdf0e10cSrcweir             PrintWriter log)
106*cdf0e10cSrcweir     {
107*cdf0e10cSrcweir         XInterface oObj = null;
108*cdf0e10cSrcweir 
109*cdf0e10cSrcweir         Object oDBContext = null;
110*cdf0e10cSrcweir         Object oDBSource = null;
111*cdf0e10cSrcweir         Object newQuery = null;
112*cdf0e10cSrcweir         Object toolkit = null;
113*cdf0e10cSrcweir         XStorable store = null;
114*cdf0e10cSrcweir 
115*cdf0e10cSrcweir         try
116*cdf0e10cSrcweir         {
117*cdf0e10cSrcweir             oDBContext = ((XMultiServiceFactory) Param.getMSF())
118*cdf0e10cSrcweir             .createInstance("com.sun.star.sdb.DatabaseContext");
119*cdf0e10cSrcweir             oDBSource = ((XMultiServiceFactory) Param.getMSF())
120*cdf0e10cSrcweir             .createInstance("com.sun.star.sdb.DataSource");
121*cdf0e10cSrcweir             newQuery = ((XMultiServiceFactory) Param.getMSF())
122*cdf0e10cSrcweir             .createInstance("com.sun.star.sdb.QueryDefinition");
123*cdf0e10cSrcweir             toolkit = ((XMultiServiceFactory) Param.getMSF())
124*cdf0e10cSrcweir             .createInstance("com.sun.star.awt.Toolkit");
125*cdf0e10cSrcweir         }
126*cdf0e10cSrcweir         catch (com.sun.star.uno.Exception e)
127*cdf0e10cSrcweir         {
128*cdf0e10cSrcweir             e.printStackTrace(log);
129*cdf0e10cSrcweir             throw new StatusException(Status.failed("Couldn't create instance"));
130*cdf0e10cSrcweir         }
131*cdf0e10cSrcweir 
132*cdf0e10cSrcweir         String mysqlURL = (String) Param.get("mysql.url");
133*cdf0e10cSrcweir 
134*cdf0e10cSrcweir         if (mysqlURL == null)
135*cdf0e10cSrcweir         {
136*cdf0e10cSrcweir             throw new StatusException(Status.failed(
137*cdf0e10cSrcweir                     "Couldn't get 'mysql.url' from ini-file"));
138*cdf0e10cSrcweir         }
139*cdf0e10cSrcweir 
140*cdf0e10cSrcweir         user = (String) Param.get("jdbc.user");
141*cdf0e10cSrcweir         password = (String) Param.get("jdbc.password");
142*cdf0e10cSrcweir 
143*cdf0e10cSrcweir         if ((user == null) || (password == null))
144*cdf0e10cSrcweir         {
145*cdf0e10cSrcweir             throw new StatusException(Status.failed(
146*cdf0e10cSrcweir                     "Couldn't get 'jdbc.user' or 'jdbc.password' from ini-file"));
147*cdf0e10cSrcweir         }
148*cdf0e10cSrcweir 
149*cdf0e10cSrcweir         PropertyValue[] info = new PropertyValue[2];
150*cdf0e10cSrcweir         info[0] = new PropertyValue();
151*cdf0e10cSrcweir         info[0].Name = "user";
152*cdf0e10cSrcweir         info[0].Value = user;
153*cdf0e10cSrcweir         info[1] = new PropertyValue();
154*cdf0e10cSrcweir         info[1].Name = "password";
155*cdf0e10cSrcweir         info[1].Value = password;
156*cdf0e10cSrcweir 
157*cdf0e10cSrcweir         XPropertySet propSetDBSource = (XPropertySet) UnoRuntime.queryInterface(
158*cdf0e10cSrcweir                 XPropertySet.class, oDBSource);
159*cdf0e10cSrcweir 
160*cdf0e10cSrcweir         try
161*cdf0e10cSrcweir         {
162*cdf0e10cSrcweir             propSetDBSource.setPropertyValue("URL", mysqlURL);
163*cdf0e10cSrcweir             propSetDBSource.setPropertyValue("Info", info);
164*cdf0e10cSrcweir         }
165*cdf0e10cSrcweir         catch (com.sun.star.lang.WrappedTargetException e)
166*cdf0e10cSrcweir         {
167*cdf0e10cSrcweir             e.printStackTrace(log);
168*cdf0e10cSrcweir             throw new StatusException(Status.failed(
169*cdf0e10cSrcweir                     "Couldn't set property value"));
170*cdf0e10cSrcweir         }
171*cdf0e10cSrcweir         catch (com.sun.star.lang.IllegalArgumentException e)
172*cdf0e10cSrcweir         {
173*cdf0e10cSrcweir             e.printStackTrace(log);
174*cdf0e10cSrcweir             throw new StatusException(Status.failed(
175*cdf0e10cSrcweir                     "Couldn't set property value"));
176*cdf0e10cSrcweir         }
177*cdf0e10cSrcweir         catch (com.sun.star.beans.PropertyVetoException e)
178*cdf0e10cSrcweir         {
179*cdf0e10cSrcweir             e.printStackTrace(log);
180*cdf0e10cSrcweir             throw new StatusException(Status.failed(
181*cdf0e10cSrcweir                     "Couldn't set property value"));
182*cdf0e10cSrcweir         }
183*cdf0e10cSrcweir         catch (com.sun.star.beans.UnknownPropertyException e)
184*cdf0e10cSrcweir         {
185*cdf0e10cSrcweir             e.printStackTrace(log);
186*cdf0e10cSrcweir             throw new StatusException(Status.failed(
187*cdf0e10cSrcweir                     "Couldn't set property value"));
188*cdf0e10cSrcweir         }
189*cdf0e10cSrcweir 
190*cdf0e10cSrcweir         try
191*cdf0e10cSrcweir         {
192*cdf0e10cSrcweir             log.println("writing database file ...");
193*cdf0e10cSrcweir             XDocumentDataSource xDDS = (XDocumentDataSource)
194*cdf0e10cSrcweir             UnoRuntime.queryInterface(XDocumentDataSource.class, oDBSource);
195*cdf0e10cSrcweir             store = (XStorable) UnoRuntime.queryInterface(XStorable.class,
196*cdf0e10cSrcweir                     xDDS.getDatabaseDocument());
197*cdf0e10cSrcweir 
198*cdf0e10cSrcweir             aFile = utils.getOfficeTemp((XMultiServiceFactory) Param.getMSF())+"ConnectionLine.odb";
199*cdf0e10cSrcweir             log.println("... filename will be "+aFile);
200*cdf0e10cSrcweir             store.storeAsURL(aFile,new PropertyValue[]
201*cdf0e10cSrcweir             {});
202*cdf0e10cSrcweir             log.println("... done");
203*cdf0e10cSrcweir         }
204*cdf0e10cSrcweir         catch (com.sun.star.uno.Exception e)
205*cdf0e10cSrcweir         {
206*cdf0e10cSrcweir             e.printStackTrace(log);
207*cdf0e10cSrcweir             throw new StatusException(Status.failed("Couldn't register object"));
208*cdf0e10cSrcweir         }
209*cdf0e10cSrcweir 
210*cdf0e10cSrcweir         isolConnection = (XIsolatedConnection) UnoRuntime.queryInterface(
211*cdf0e10cSrcweir                 XIsolatedConnection.class,
212*cdf0e10cSrcweir                 oDBSource);
213*cdf0e10cSrcweir 
214*cdf0e10cSrcweir         XConnection connection = null;
215*cdf0e10cSrcweir         XStatement statement = null;
216*cdf0e10cSrcweir 
217*cdf0e10cSrcweir         final String tbl_name1 = "tst_table1";
218*cdf0e10cSrcweir         final String tbl_name2 = "tst_table2";
219*cdf0e10cSrcweir         final String col_name1 = "id1";
220*cdf0e10cSrcweir         final String col_name2 = "id2";
221*cdf0e10cSrcweir 
222*cdf0e10cSrcweir         try
223*cdf0e10cSrcweir         {
224*cdf0e10cSrcweir             connection = isolConnection.getIsolatedConnection(user, password);
225*cdf0e10cSrcweir             statement = connection.createStatement();
226*cdf0e10cSrcweir             statement.executeUpdate("drop table if exists " + tbl_name1);
227*cdf0e10cSrcweir             statement.executeUpdate("drop table if exists " + tbl_name2);
228*cdf0e10cSrcweir             statement.executeUpdate("create table " + tbl_name1 + " (" +
229*cdf0e10cSrcweir                     col_name1 + " int)");
230*cdf0e10cSrcweir             statement.executeUpdate("create table " + tbl_name2 + " (" +
231*cdf0e10cSrcweir                     col_name2 + " int)");
232*cdf0e10cSrcweir         }
233*cdf0e10cSrcweir         catch (com.sun.star.sdbc.SQLException e)
234*cdf0e10cSrcweir         {
235*cdf0e10cSrcweir             try
236*cdf0e10cSrcweir             {
237*cdf0e10cSrcweir                 shortWait();
238*cdf0e10cSrcweir                 connection = isolConnection.getIsolatedConnection(user,
239*cdf0e10cSrcweir                         password);
240*cdf0e10cSrcweir                 statement = connection.createStatement();
241*cdf0e10cSrcweir                 statement.executeUpdate("drop table if exists " + tbl_name1);
242*cdf0e10cSrcweir                 statement.executeUpdate("drop table if exists " + tbl_name2);
243*cdf0e10cSrcweir                 statement.executeUpdate("create table " + tbl_name1 + " (" +
244*cdf0e10cSrcweir                         col_name1 + " int)");
245*cdf0e10cSrcweir                 statement.executeUpdate("create table " + tbl_name2 + " (" +
246*cdf0e10cSrcweir                         col_name2 + " int)");
247*cdf0e10cSrcweir             }
248*cdf0e10cSrcweir             catch (com.sun.star.sdbc.SQLException e2)
249*cdf0e10cSrcweir             {
250*cdf0e10cSrcweir                 e2.printStackTrace(log);
251*cdf0e10cSrcweir                 throw new StatusException(Status.failed("SQLException"));
252*cdf0e10cSrcweir             }
253*cdf0e10cSrcweir         }
254*cdf0e10cSrcweir 
255*cdf0e10cSrcweir         XQueryDefinitionsSupplier querySuppl = (XQueryDefinitionsSupplier) UnoRuntime.queryInterface(
256*cdf0e10cSrcweir                 XQueryDefinitionsSupplier.class,
257*cdf0e10cSrcweir                 oDBSource);
258*cdf0e10cSrcweir 
259*cdf0e10cSrcweir         XNameAccess defContainer = querySuppl.getQueryDefinitions();
260*cdf0e10cSrcweir 
261*cdf0e10cSrcweir         XPropertySet queryProp = (XPropertySet) UnoRuntime.queryInterface(
262*cdf0e10cSrcweir                 XPropertySet.class, newQuery);
263*cdf0e10cSrcweir 
264*cdf0e10cSrcweir         try
265*cdf0e10cSrcweir         {
266*cdf0e10cSrcweir             final String query = "select * from " + tbl_name1 + ", " +
267*cdf0e10cSrcweir                     tbl_name2 + " where " + tbl_name1 + "." +
268*cdf0e10cSrcweir                     col_name1 + "=" + tbl_name2 + "." +
269*cdf0e10cSrcweir                     col_name2;
270*cdf0e10cSrcweir             queryProp.setPropertyValue("Command", query);
271*cdf0e10cSrcweir         }
272*cdf0e10cSrcweir         catch (com.sun.star.lang.WrappedTargetException e)
273*cdf0e10cSrcweir         {
274*cdf0e10cSrcweir             e.printStackTrace(log);
275*cdf0e10cSrcweir             throw new StatusException(Status.failed(
276*cdf0e10cSrcweir                     "Couldn't set property value"));
277*cdf0e10cSrcweir         }
278*cdf0e10cSrcweir         catch (com.sun.star.lang.IllegalArgumentException e)
279*cdf0e10cSrcweir         {
280*cdf0e10cSrcweir             e.printStackTrace(log);
281*cdf0e10cSrcweir             throw new StatusException(Status.failed(
282*cdf0e10cSrcweir                     "Couldn't set property value"));
283*cdf0e10cSrcweir         }
284*cdf0e10cSrcweir         catch (com.sun.star.beans.PropertyVetoException e)
285*cdf0e10cSrcweir         {
286*cdf0e10cSrcweir             e.printStackTrace(log);
287*cdf0e10cSrcweir             throw new StatusException(Status.failed(
288*cdf0e10cSrcweir                     "Couldn't set property value"));
289*cdf0e10cSrcweir         }
290*cdf0e10cSrcweir         catch (com.sun.star.beans.UnknownPropertyException e)
291*cdf0e10cSrcweir         {
292*cdf0e10cSrcweir             e.printStackTrace(log);
293*cdf0e10cSrcweir             throw new StatusException(Status.failed(
294*cdf0e10cSrcweir                     "Couldn't set property value"));
295*cdf0e10cSrcweir         }
296*cdf0e10cSrcweir 
297*cdf0e10cSrcweir         XNameContainer queryContainer = (XNameContainer) UnoRuntime.queryInterface(
298*cdf0e10cSrcweir                 XNameContainer.class,
299*cdf0e10cSrcweir                 defContainer);
300*cdf0e10cSrcweir 
301*cdf0e10cSrcweir         try
302*cdf0e10cSrcweir         {
303*cdf0e10cSrcweir             queryContainer.insertByName("Query1", newQuery);
304*cdf0e10cSrcweir             store.store();
305*cdf0e10cSrcweir             connection.close();
306*cdf0e10cSrcweir         }
307*cdf0e10cSrcweir         catch (com.sun.star.lang.WrappedTargetException e)
308*cdf0e10cSrcweir         {
309*cdf0e10cSrcweir             e.printStackTrace(log);
310*cdf0e10cSrcweir             throw new StatusException(Status.failed("Couldn't insert query"));
311*cdf0e10cSrcweir         }
312*cdf0e10cSrcweir         catch (com.sun.star.container.ElementExistException e)
313*cdf0e10cSrcweir         {
314*cdf0e10cSrcweir             e.printStackTrace(log);
315*cdf0e10cSrcweir             throw new StatusException(Status.failed("Couldn't insert query"));
316*cdf0e10cSrcweir         }
317*cdf0e10cSrcweir         catch (com.sun.star.lang.IllegalArgumentException e)
318*cdf0e10cSrcweir         {
319*cdf0e10cSrcweir             e.printStackTrace(log);
320*cdf0e10cSrcweir             throw new StatusException(Status.failed("Couldn't insert query"));
321*cdf0e10cSrcweir         }
322*cdf0e10cSrcweir         catch (com.sun.star.io.IOException e)
323*cdf0e10cSrcweir         {
324*cdf0e10cSrcweir             e.printStackTrace(log);
325*cdf0e10cSrcweir             throw new StatusException(Status.failed("Couldn't insert query"));
326*cdf0e10cSrcweir         }
327*cdf0e10cSrcweir         catch (com.sun.star.sdbc.SQLException e)
328*cdf0e10cSrcweir         {
329*cdf0e10cSrcweir             e.printStackTrace(log);
330*cdf0e10cSrcweir             throw new StatusException(Status.failed("Couldn't insert query"));
331*cdf0e10cSrcweir         }
332*cdf0e10cSrcweir 
333*cdf0e10cSrcweir         PropertyValue[] loadProps = new PropertyValue[3];
334*cdf0e10cSrcweir         loadProps[0] = new PropertyValue();
335*cdf0e10cSrcweir         loadProps[0].Name = "QueryDesignView";
336*cdf0e10cSrcweir         loadProps[0].Value = Boolean.TRUE;
337*cdf0e10cSrcweir 
338*cdf0e10cSrcweir         loadProps[1] = new PropertyValue();
339*cdf0e10cSrcweir         loadProps[1].Name = "CurrentQuery";
340*cdf0e10cSrcweir         loadProps[1].Value = "Query1";
341*cdf0e10cSrcweir 
342*cdf0e10cSrcweir         loadProps[2] = new PropertyValue();
343*cdf0e10cSrcweir         loadProps[2].Name = "DataSource";
344*cdf0e10cSrcweir         loadProps[2].Value = oDBSource;
345*cdf0e10cSrcweir 
346*cdf0e10cSrcweir         QueryComponent = DesktopTools.loadDoc((XMultiServiceFactory) Param.getMSF(),".component:DB/QueryDesign",loadProps);
347*cdf0e10cSrcweir 
348*cdf0e10cSrcweir         util.utils.shortWait(1000);
349*cdf0e10cSrcweir 
350*cdf0e10cSrcweir         xWindow = UnoRuntime.queryInterface(XModel.class, QueryComponent).
351*cdf0e10cSrcweir             getCurrentController().getFrame().getContainerWindow();
352*cdf0e10cSrcweir 
353*cdf0e10cSrcweir         XAccessible xRoot = AccessibilityTools.getAccessibleObject(xWindow);
354*cdf0e10cSrcweir 
355*cdf0e10cSrcweir         AccessibilityTools.printAccessibleTree (log,xRoot, Param.getBool(util.PropertyName.DEBUG_IS_ACTIVE));
356*cdf0e10cSrcweir 
357*cdf0e10cSrcweir         oObj = AccessibilityTools.getAccessibleObjectForRoleIgnoreShowing(xRoot, AccessibleRole.UNKNOWN, "", "ConnectionLine");
358*cdf0e10cSrcweir 
359*cdf0e10cSrcweir         log.println("ImplementationName " + util.utils.getImplName(oObj));
360*cdf0e10cSrcweir 
361*cdf0e10cSrcweir         log.println("creating TestEnvironment");
362*cdf0e10cSrcweir 
363*cdf0e10cSrcweir         TestEnvironment tEnv = new TestEnvironment(oObj);
364*cdf0e10cSrcweir 
365*cdf0e10cSrcweir         shortWait();
366*cdf0e10cSrcweir 
367*cdf0e10cSrcweir         final XWindow queryWin = xWindow;
368*cdf0e10cSrcweir 
369*cdf0e10cSrcweir         tEnv.addObjRelation("EventProducer",
370*cdf0e10cSrcweir                 new ifc.accessibility._XAccessibleEventBroadcaster.EventProducer()
371*cdf0e10cSrcweir         {
372*cdf0e10cSrcweir             public void fireEvent()
373*cdf0e10cSrcweir             {
374*cdf0e10cSrcweir                 Rectangle rect = queryWin.getPosSize();
375*cdf0e10cSrcweir                 queryWin.setPosSize(rect.X, rect.Y, rect.Height-5, rect.Width-5, PosSize.POSSIZE);
376*cdf0e10cSrcweir             }
377*cdf0e10cSrcweir         });
378*cdf0e10cSrcweir 
379*cdf0e10cSrcweir         return tEnv;
380*cdf0e10cSrcweir     } // finish method getTestEnvironment
381*cdf0e10cSrcweir 
382*cdf0e10cSrcweir     /**
383*cdf0e10cSrcweir      * Closes the DatasourceAdministration dialog and Query Dialog.
384*cdf0e10cSrcweir      */
385*cdf0e10cSrcweir     protected void cleanup(TestParameters Param, PrintWriter log)
386*cdf0e10cSrcweir     {
387*cdf0e10cSrcweir         try
388*cdf0e10cSrcweir         {
389*cdf0e10cSrcweir 
390*cdf0e10cSrcweir             log.println("closing QueryComponent ...");
391*cdf0e10cSrcweir             DesktopTools.closeDoc(QueryComponent);
392*cdf0e10cSrcweir             log.println("... done");
393*cdf0e10cSrcweir             XMultiServiceFactory xMSF = (XMultiServiceFactory)Param.getMSF();
394*cdf0e10cSrcweir             Object sfa = xMSF.createInstance("com.sun.star.comp.ucb.SimpleFileAccess");
395*cdf0e10cSrcweir             XSimpleFileAccess xSFA = (XSimpleFileAccess) UnoRuntime.queryInterface(XSimpleFileAccess.class, sfa);
396*cdf0e10cSrcweir             log.println("deleting database file");
397*cdf0e10cSrcweir             xSFA.kill(aFile);
398*cdf0e10cSrcweir             log.println("Could delete file "+aFile+": "+!xSFA.exists(aFile));
399*cdf0e10cSrcweir         }
400*cdf0e10cSrcweir         catch (Exception e)
401*cdf0e10cSrcweir         {
402*cdf0e10cSrcweir             e.printStackTrace();
403*cdf0e10cSrcweir         }
404*cdf0e10cSrcweir     }
405*cdf0e10cSrcweir 
406*cdf0e10cSrcweir     /**
407*cdf0e10cSrcweir      * Sleeps for 1.5 sec. to allow StarOffice to react on <code>
408*cdf0e10cSrcweir      * reset</code> call.
409*cdf0e10cSrcweir      */
410*cdf0e10cSrcweir     private void shortWait()
411*cdf0e10cSrcweir     {
412*cdf0e10cSrcweir         try
413*cdf0e10cSrcweir         {
414*cdf0e10cSrcweir             Thread.sleep(1500);
415*cdf0e10cSrcweir         }
416*cdf0e10cSrcweir         catch (InterruptedException e)
417*cdf0e10cSrcweir         {
418*cdf0e10cSrcweir             log.println("While waiting :" + e);
419*cdf0e10cSrcweir         }
420*cdf0e10cSrcweir     }
421*cdf0e10cSrcweir }
422