xref: /AOO41X/main/qadevOOo/tests/java/mod/_dbaccess/JoinViewAccessibility.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 JoinViewAccessibility extends TestCase {
80*cdf0e10cSrcweir     XWindow xWindow = null;
81*cdf0e10cSrcweir     Object oDBSource = null;
82*cdf0e10cSrcweir     String aFile = "";
83*cdf0e10cSrcweir     XConnection connection = null;
84*cdf0e10cSrcweir     XIsolatedConnection isolConnection = null;
85*cdf0e10cSrcweir     XComponent QueryComponent = null;
86*cdf0e10cSrcweir     String user = "";
87*cdf0e10cSrcweir     String password="";
88*cdf0e10cSrcweir 
89*cdf0e10cSrcweir     /**
90*cdf0e10cSrcweir      * Creates a new DataSource and stores it.
91*cdf0e10cSrcweir      * Creates a connection and using it
92*cdf0e10cSrcweir      * creates two tables in database.
93*cdf0e10cSrcweir      * Creates a new query and adds it to DefinitionContainer.
94*cdf0e10cSrcweir      * Opens the QueryComponent.with loadComponentFromURL
95*cdf0e10cSrcweir      * and gets the object with the role UNKNOWN and the Impplementation
96*cdf0e10cSrcweir      * name that contains ConnectionLine
97*cdf0e10cSrcweir      * @param Param test parameters
98*cdf0e10cSrcweir      * @param log writer to log information while testing
99*cdf0e10cSrcweir      * @return
100*cdf0e10cSrcweir      * @throws StatusException
101*cdf0e10cSrcweir      * @see TestEnvironment
102*cdf0e10cSrcweir      */
103*cdf0e10cSrcweir     protected TestEnvironment createTestEnvironment (TestParameters Param,
104*cdf0e10cSrcweir     PrintWriter log)
105*cdf0e10cSrcweir     {
106*cdf0e10cSrcweir         XInterface oObj = null;
107*cdf0e10cSrcweir 
108*cdf0e10cSrcweir         Object oDBContext = null;
109*cdf0e10cSrcweir         Object oDBSource = null;
110*cdf0e10cSrcweir         Object newQuery = null;
111*cdf0e10cSrcweir         Object toolkit = null;
112*cdf0e10cSrcweir         XStorable store = null;
113*cdf0e10cSrcweir 
114*cdf0e10cSrcweir         try
115*cdf0e10cSrcweir         {
116*cdf0e10cSrcweir             oDBContext = ((XMultiServiceFactory) Param.getMSF ())
117*cdf0e10cSrcweir             .createInstance ("com.sun.star.sdb.DatabaseContext");
118*cdf0e10cSrcweir             oDBSource = ((XMultiServiceFactory) Param.getMSF ())
119*cdf0e10cSrcweir             .createInstance ("com.sun.star.sdb.DataSource");
120*cdf0e10cSrcweir             newQuery = ((XMultiServiceFactory) Param.getMSF ())
121*cdf0e10cSrcweir             .createInstance ("com.sun.star.sdb.QueryDefinition");
122*cdf0e10cSrcweir             toolkit = ((XMultiServiceFactory) Param.getMSF ())
123*cdf0e10cSrcweir             .createInstance ("com.sun.star.awt.Toolkit");
124*cdf0e10cSrcweir         } catch (com.sun.star.uno.Exception e)
125*cdf0e10cSrcweir         {
126*cdf0e10cSrcweir             e.printStackTrace (log);
127*cdf0e10cSrcweir             throw new StatusException (Status.failed ("Couldn't create instance"));
128*cdf0e10cSrcweir         }
129*cdf0e10cSrcweir 
130*cdf0e10cSrcweir         String mysqlURL = (String) Param.get ("mysql.url");
131*cdf0e10cSrcweir 
132*cdf0e10cSrcweir         if (mysqlURL == null)
133*cdf0e10cSrcweir         {
134*cdf0e10cSrcweir             throw new StatusException (Status.failed (
135*cdf0e10cSrcweir             "Couldn't get 'mysql.url' from ini-file"));
136*cdf0e10cSrcweir         }
137*cdf0e10cSrcweir 
138*cdf0e10cSrcweir         user = (String) Param.get ("jdbc.user");
139*cdf0e10cSrcweir         password = (String) Param.get ("jdbc.password");
140*cdf0e10cSrcweir 
141*cdf0e10cSrcweir         if ((user == null) || (password == null))
142*cdf0e10cSrcweir         {
143*cdf0e10cSrcweir             throw new StatusException (Status.failed (
144*cdf0e10cSrcweir             "Couldn't get 'jdbc.user' or 'jdbc.password' from ini-file"));
145*cdf0e10cSrcweir         }
146*cdf0e10cSrcweir 
147*cdf0e10cSrcweir         PropertyValue[] info = new PropertyValue[2];
148*cdf0e10cSrcweir         info[0] = new PropertyValue ();
149*cdf0e10cSrcweir         info[0].Name = "user";
150*cdf0e10cSrcweir         info[0].Value = user;
151*cdf0e10cSrcweir         info[1] = new PropertyValue ();
152*cdf0e10cSrcweir         info[1].Name = "password";
153*cdf0e10cSrcweir         info[1].Value = password;
154*cdf0e10cSrcweir 
155*cdf0e10cSrcweir         XPropertySet propSetDBSource = (XPropertySet) UnoRuntime.queryInterface (
156*cdf0e10cSrcweir         XPropertySet.class, oDBSource);
157*cdf0e10cSrcweir 
158*cdf0e10cSrcweir         try
159*cdf0e10cSrcweir         {
160*cdf0e10cSrcweir             propSetDBSource.setPropertyValue ("URL", mysqlURL);
161*cdf0e10cSrcweir             propSetDBSource.setPropertyValue ("Info", info);
162*cdf0e10cSrcweir         } catch (com.sun.star.lang.WrappedTargetException e)
163*cdf0e10cSrcweir         {
164*cdf0e10cSrcweir             e.printStackTrace (log);
165*cdf0e10cSrcweir             throw new StatusException (Status.failed (
166*cdf0e10cSrcweir             "Couldn't set property value"));
167*cdf0e10cSrcweir         } catch (com.sun.star.lang.IllegalArgumentException e)
168*cdf0e10cSrcweir         {
169*cdf0e10cSrcweir             e.printStackTrace (log);
170*cdf0e10cSrcweir             throw new StatusException (Status.failed (
171*cdf0e10cSrcweir             "Couldn't set property value"));
172*cdf0e10cSrcweir         } catch (com.sun.star.beans.PropertyVetoException e)
173*cdf0e10cSrcweir         {
174*cdf0e10cSrcweir             e.printStackTrace (log);
175*cdf0e10cSrcweir             throw new StatusException (Status.failed (
176*cdf0e10cSrcweir             "Couldn't set property value"));
177*cdf0e10cSrcweir         } catch (com.sun.star.beans.UnknownPropertyException 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 
184*cdf0e10cSrcweir         try
185*cdf0e10cSrcweir         {
186*cdf0e10cSrcweir             log.println ("writing database file ...");
187*cdf0e10cSrcweir             XDocumentDataSource xDDS = (XDocumentDataSource)
188*cdf0e10cSrcweir             UnoRuntime.queryInterface(XDocumentDataSource.class, oDBSource);
189*cdf0e10cSrcweir             store = (XStorable) UnoRuntime.queryInterface(XStorable.class,
190*cdf0e10cSrcweir                     xDDS.getDatabaseDocument());
191*cdf0e10cSrcweir             aFile = utils.getOfficeTemp ((XMultiServiceFactory) Param.getMSF ())+"JoinView.odb";
192*cdf0e10cSrcweir             log.println ("... filename will be "+aFile);
193*cdf0e10cSrcweir             store.storeAsURL (aFile,new PropertyValue[]
194*cdf0e10cSrcweir             {});
195*cdf0e10cSrcweir             log.println ("... done");
196*cdf0e10cSrcweir         } catch (com.sun.star.uno.Exception e)
197*cdf0e10cSrcweir         {
198*cdf0e10cSrcweir             e.printStackTrace (log);
199*cdf0e10cSrcweir             throw new StatusException (Status.failed ("Couldn't register object"));
200*cdf0e10cSrcweir         }
201*cdf0e10cSrcweir 
202*cdf0e10cSrcweir         isolConnection = (XIsolatedConnection) UnoRuntime.queryInterface (
203*cdf0e10cSrcweir         XIsolatedConnection.class,
204*cdf0e10cSrcweir         oDBSource);
205*cdf0e10cSrcweir 
206*cdf0e10cSrcweir         XConnection connection = null;
207*cdf0e10cSrcweir         XStatement statement = null;
208*cdf0e10cSrcweir 
209*cdf0e10cSrcweir         final String tbl_name1 = "tst_table1";
210*cdf0e10cSrcweir         final String tbl_name2 = "tst_table2";
211*cdf0e10cSrcweir         final String col_name1 = "id1";
212*cdf0e10cSrcweir         final String col_name2 = "id2";
213*cdf0e10cSrcweir 
214*cdf0e10cSrcweir         try
215*cdf0e10cSrcweir         {
216*cdf0e10cSrcweir             connection = isolConnection.getIsolatedConnection (user, password);
217*cdf0e10cSrcweir             statement = connection.createStatement ();
218*cdf0e10cSrcweir             statement.executeUpdate ("drop table if exists " + tbl_name1);
219*cdf0e10cSrcweir             statement.executeUpdate ("drop table if exists " + tbl_name2);
220*cdf0e10cSrcweir             statement.executeUpdate ("create table " + tbl_name1 + " (" +
221*cdf0e10cSrcweir             col_name1 + " int)");
222*cdf0e10cSrcweir             statement.executeUpdate ("create table " + tbl_name2 + " (" +
223*cdf0e10cSrcweir             col_name2 + " int)");
224*cdf0e10cSrcweir         } catch (com.sun.star.sdbc.SQLException e)
225*cdf0e10cSrcweir         {
226*cdf0e10cSrcweir             try
227*cdf0e10cSrcweir             {
228*cdf0e10cSrcweir                 shortWait ();
229*cdf0e10cSrcweir                 connection = isolConnection.getIsolatedConnection (user,
230*cdf0e10cSrcweir                 password);
231*cdf0e10cSrcweir                 statement = connection.createStatement ();
232*cdf0e10cSrcweir                 statement.executeUpdate ("drop table if exists " + tbl_name1);
233*cdf0e10cSrcweir                 statement.executeUpdate ("drop table if exists " + tbl_name2);
234*cdf0e10cSrcweir                 statement.executeUpdate ("create table " + tbl_name1 + " (" +
235*cdf0e10cSrcweir                 col_name1 + " int)");
236*cdf0e10cSrcweir                 statement.executeUpdate ("create table " + tbl_name2 + " (" +
237*cdf0e10cSrcweir                 col_name2 + " int)");
238*cdf0e10cSrcweir             } catch (com.sun.star.sdbc.SQLException e2)
239*cdf0e10cSrcweir             {
240*cdf0e10cSrcweir                 e2.printStackTrace (log);
241*cdf0e10cSrcweir                 throw new StatusException (Status.failed ("SQLException"));
242*cdf0e10cSrcweir             }
243*cdf0e10cSrcweir         }
244*cdf0e10cSrcweir 
245*cdf0e10cSrcweir         XQueryDefinitionsSupplier querySuppl = (XQueryDefinitionsSupplier) UnoRuntime.queryInterface (
246*cdf0e10cSrcweir         XQueryDefinitionsSupplier.class,
247*cdf0e10cSrcweir         oDBSource);
248*cdf0e10cSrcweir 
249*cdf0e10cSrcweir         XNameAccess defContainer = querySuppl.getQueryDefinitions ();
250*cdf0e10cSrcweir 
251*cdf0e10cSrcweir         XPropertySet queryProp = (XPropertySet) UnoRuntime.queryInterface (
252*cdf0e10cSrcweir         XPropertySet.class, newQuery);
253*cdf0e10cSrcweir 
254*cdf0e10cSrcweir         try
255*cdf0e10cSrcweir         {
256*cdf0e10cSrcweir             final String query = "select * from " + tbl_name1 + ", " +
257*cdf0e10cSrcweir             tbl_name2 + " where " + tbl_name1 + "." +
258*cdf0e10cSrcweir             col_name1 + "=" + tbl_name2 + "." +
259*cdf0e10cSrcweir             col_name2;
260*cdf0e10cSrcweir             queryProp.setPropertyValue ("Command", query);
261*cdf0e10cSrcweir         } catch (com.sun.star.lang.WrappedTargetException e)
262*cdf0e10cSrcweir         {
263*cdf0e10cSrcweir             e.printStackTrace (log);
264*cdf0e10cSrcweir             throw new StatusException (Status.failed (
265*cdf0e10cSrcweir             "Couldn't set property value"));
266*cdf0e10cSrcweir         } catch (com.sun.star.lang.IllegalArgumentException e)
267*cdf0e10cSrcweir         {
268*cdf0e10cSrcweir             e.printStackTrace (log);
269*cdf0e10cSrcweir             throw new StatusException (Status.failed (
270*cdf0e10cSrcweir             "Couldn't set property value"));
271*cdf0e10cSrcweir         } catch (com.sun.star.beans.PropertyVetoException e)
272*cdf0e10cSrcweir         {
273*cdf0e10cSrcweir             e.printStackTrace (log);
274*cdf0e10cSrcweir             throw new StatusException (Status.failed (
275*cdf0e10cSrcweir             "Couldn't set property value"));
276*cdf0e10cSrcweir         } catch (com.sun.star.beans.UnknownPropertyException e)
277*cdf0e10cSrcweir         {
278*cdf0e10cSrcweir             e.printStackTrace (log);
279*cdf0e10cSrcweir             throw new StatusException (Status.failed (
280*cdf0e10cSrcweir             "Couldn't set property value"));
281*cdf0e10cSrcweir         }
282*cdf0e10cSrcweir 
283*cdf0e10cSrcweir         XNameContainer queryContainer = (XNameContainer) UnoRuntime.queryInterface (
284*cdf0e10cSrcweir         XNameContainer.class,
285*cdf0e10cSrcweir         defContainer);
286*cdf0e10cSrcweir 
287*cdf0e10cSrcweir         try
288*cdf0e10cSrcweir         {
289*cdf0e10cSrcweir             queryContainer.insertByName ("Query1", newQuery);
290*cdf0e10cSrcweir             store.store ();
291*cdf0e10cSrcweir             connection.close ();
292*cdf0e10cSrcweir         } catch (com.sun.star.lang.WrappedTargetException e)
293*cdf0e10cSrcweir         {
294*cdf0e10cSrcweir             e.printStackTrace (log);
295*cdf0e10cSrcweir             throw new StatusException (Status.failed ("Couldn't insert query"));
296*cdf0e10cSrcweir         } catch (com.sun.star.container.ElementExistException e)
297*cdf0e10cSrcweir         {
298*cdf0e10cSrcweir             e.printStackTrace (log);
299*cdf0e10cSrcweir             throw new StatusException (Status.failed ("Couldn't insert query"));
300*cdf0e10cSrcweir         } catch (com.sun.star.lang.IllegalArgumentException e)
301*cdf0e10cSrcweir         {
302*cdf0e10cSrcweir             e.printStackTrace (log);
303*cdf0e10cSrcweir             throw new StatusException (Status.failed ("Couldn't insert query"));
304*cdf0e10cSrcweir         } catch (com.sun.star.io.IOException e)
305*cdf0e10cSrcweir         {
306*cdf0e10cSrcweir             e.printStackTrace (log);
307*cdf0e10cSrcweir             throw new StatusException (Status.failed ("Couldn't insert query"));
308*cdf0e10cSrcweir         } catch (com.sun.star.sdbc.SQLException e)
309*cdf0e10cSrcweir         {
310*cdf0e10cSrcweir             e.printStackTrace (log);
311*cdf0e10cSrcweir             throw new StatusException (Status.failed ("Couldn't insert query"));
312*cdf0e10cSrcweir         }
313*cdf0e10cSrcweir 
314*cdf0e10cSrcweir         PropertyValue[] loadProps = new PropertyValue[3];
315*cdf0e10cSrcweir         loadProps[0] = new PropertyValue ();
316*cdf0e10cSrcweir         loadProps[0].Name = "QueryDesignView";
317*cdf0e10cSrcweir         loadProps[0].Value = Boolean.TRUE;
318*cdf0e10cSrcweir 
319*cdf0e10cSrcweir         loadProps[1] = new PropertyValue ();
320*cdf0e10cSrcweir         loadProps[1].Name = "CurrentQuery";
321*cdf0e10cSrcweir         loadProps[1].Value = "Query1";
322*cdf0e10cSrcweir 
323*cdf0e10cSrcweir         loadProps[2] = new PropertyValue ();
324*cdf0e10cSrcweir         loadProps[2].Name = "DataSource";
325*cdf0e10cSrcweir         loadProps[2].Value = oDBSource;
326*cdf0e10cSrcweir 
327*cdf0e10cSrcweir         QueryComponent = DesktopTools.loadDoc ((XMultiServiceFactory) Param.getMSF (),".component:DB/QueryDesign",loadProps);
328*cdf0e10cSrcweir 
329*cdf0e10cSrcweir         xWindow = UnoRuntime.queryInterface(XModel.class, QueryComponent).
330*cdf0e10cSrcweir             getCurrentController().getFrame().getContainerWindow();
331*cdf0e10cSrcweir 
332*cdf0e10cSrcweir         XAccessible xRoot = AccessibilityTools.getAccessibleObject (xWindow);
333*cdf0e10cSrcweir 
334*cdf0e10cSrcweir         AccessibilityTools.printAccessibleTree (log,xRoot, Param.getBool(util.PropertyName.DEBUG_IS_ACTIVE));
335*cdf0e10cSrcweir 
336*cdf0e10cSrcweir         oObj = AccessibilityTools.getAccessibleObjectForRole(xRoot, AccessibleRole.VIEW_PORT);
337*cdf0e10cSrcweir 
338*cdf0e10cSrcweir         log.println("ImplementationName " + util.utils.getImplName(oObj));
339*cdf0e10cSrcweir 
340*cdf0e10cSrcweir         log.println("creating TestEnvironment");
341*cdf0e10cSrcweir 
342*cdf0e10cSrcweir         TestEnvironment tEnv = new TestEnvironment(oObj);
343*cdf0e10cSrcweir 
344*cdf0e10cSrcweir         shortWait();
345*cdf0e10cSrcweir 
346*cdf0e10cSrcweir         final XWindow queryWin = xWindow;
347*cdf0e10cSrcweir 
348*cdf0e10cSrcweir         tEnv.addObjRelation("EventProducer",
349*cdf0e10cSrcweir                             new ifc.accessibility._XAccessibleEventBroadcaster.EventProducer() {
350*cdf0e10cSrcweir             public void fireEvent() {
351*cdf0e10cSrcweir                 Rectangle rect = queryWin.getPosSize();
352*cdf0e10cSrcweir                 queryWin.setPosSize(rect.X, rect.Y, rect.Height-5, rect.Width-5, PosSize.POSSIZE);
353*cdf0e10cSrcweir             }
354*cdf0e10cSrcweir         });
355*cdf0e10cSrcweir 
356*cdf0e10cSrcweir         return tEnv;
357*cdf0e10cSrcweir     } // finish method getTestEnvironment
358*cdf0e10cSrcweir 
359*cdf0e10cSrcweir     /**
360*cdf0e10cSrcweir      * Closes the DatasourceAdministration dialog and Query Dialog.
361*cdf0e10cSrcweir      */
362*cdf0e10cSrcweir     protected void cleanup(TestParameters Param, PrintWriter log) {
363*cdf0e10cSrcweir         try
364*cdf0e10cSrcweir         {
365*cdf0e10cSrcweir 
366*cdf0e10cSrcweir             log.println ("closing QueryComponent ...");
367*cdf0e10cSrcweir             DesktopTools.closeDoc (QueryComponent);
368*cdf0e10cSrcweir             log.println ("... done");
369*cdf0e10cSrcweir             XMultiServiceFactory xMSF = (XMultiServiceFactory)Param.getMSF ();
370*cdf0e10cSrcweir             Object sfa = xMSF.createInstance ("com.sun.star.comp.ucb.SimpleFileAccess");
371*cdf0e10cSrcweir             XSimpleFileAccess xSFA = (XSimpleFileAccess) UnoRuntime.queryInterface (XSimpleFileAccess.class, sfa);
372*cdf0e10cSrcweir             log.println ("deleting database file");
373*cdf0e10cSrcweir             xSFA.kill (aFile);
374*cdf0e10cSrcweir             log.println ("Could delete file "+aFile+": "+!xSFA.exists (aFile));
375*cdf0e10cSrcweir         } catch (Exception e)
376*cdf0e10cSrcweir         {
377*cdf0e10cSrcweir             e.printStackTrace ();
378*cdf0e10cSrcweir         }
379*cdf0e10cSrcweir     }
380*cdf0e10cSrcweir 
381*cdf0e10cSrcweir     /**
382*cdf0e10cSrcweir     * Sleeps for 1.5 sec. to allow StarOffice to react on <code>
383*cdf0e10cSrcweir     * reset</code> call.
384*cdf0e10cSrcweir     */
385*cdf0e10cSrcweir     private void shortWait() {
386*cdf0e10cSrcweir         try {
387*cdf0e10cSrcweir             Thread.sleep(1500);
388*cdf0e10cSrcweir         } catch (InterruptedException e) {
389*cdf0e10cSrcweir             log.println("While waiting :" + e);
390*cdf0e10cSrcweir         }
391*cdf0e10cSrcweir     }
392*cdf0e10cSrcweir }
393