merge the formfield patch from ooo-build
[ooovba.git] / qadevOOo / tests / java / mod / _sch / AccFloor.java
blobf812c0a42596510365767b641e09db062f5d4008
1 /*************************************************************************
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4 *
5 * Copyright 2008 by Sun Microsystems, Inc.
7 * OpenOffice.org - a multi-platform office productivity suite
9 * $RCSfile: AccFloor.java,v $
10 * $Revision: 1.8 $
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 ************************************************************************/
30 package mod._sch;
32 import java.io.PrintWriter;
34 import lib.StatusException;
35 import lib.TestCase;
36 import lib.TestEnvironment;
37 import lib.TestParameters;
38 import util.AccessibilityTools;
39 import util.SOfficeFactory;
40 import util.utils;
42 import com.sun.star.accessibility.AccessibleRole;
43 import com.sun.star.accessibility.XAccessible;
44 import com.sun.star.accessibility.XAccessibleComponent;
45 import com.sun.star.accessibility.XAccessibleContext;
46 import com.sun.star.awt.XWindow;
47 import com.sun.star.beans.XPropertySet;
48 import com.sun.star.chart.XChartDocument;
49 import com.sun.star.frame.XModel;
50 import com.sun.star.lang.XMultiServiceFactory;
51 import com.sun.star.uno.UnoRuntime;
52 import com.sun.star.uno.XInterface;
54 public class AccFloor extends TestCase {
56 XChartDocument xChartDoc = null;
58 protected TestEnvironment createTestEnvironment(
59 TestParameters Param, PrintWriter log) {
61 if (xChartDoc != null) cleanup(Param, log);
62 log.println( "creating a chart document" );
63 SOfficeFactory SOF = SOfficeFactory.getFactory( (XMultiServiceFactory)Param.getMSF());
64 try {
65 log.println( "creating a chartdocument" );
66 xChartDoc = SOF.createChartDoc(null);
67 } catch (com.sun.star.uno.Exception e) {
68 // Some exception occures.FAILED
69 e.printStackTrace( log );
70 throw new StatusException( "Couldn't create document", e );
73 log.println("Change Diagram to 3D");
74 XPropertySet ChartProps = (XPropertySet)
75 UnoRuntime.queryInterface( XPropertySet.class, xChartDoc.getDiagram() );
76 try {
77 ChartProps.setPropertyValue("Dim3D", new Boolean(true));
78 } catch(com.sun.star.lang.WrappedTargetException e) {
79 log.println("Couldn't change Diagram to 3D");
80 e.printStackTrace(log);
81 throw new StatusException("Couldn't change Diagram to 3D", e);
82 } catch(com.sun.star.lang.IllegalArgumentException e) {
83 log.println("Couldn't change Diagram to 3D");
84 e.printStackTrace(log);
85 throw new StatusException("Couldn't change Diagram to 3D", e);
86 } catch(com.sun.star.beans.PropertyVetoException e) {
87 log.println("Couldn't change Diagram to 3D");
88 e.printStackTrace(log);
89 throw new StatusException("Couldn't change Diagram to 3D", e);
90 } catch(com.sun.star.beans.UnknownPropertyException e) {
91 log.println("Couldn't change Diagram to 3D");
92 e.printStackTrace(log);
93 throw new StatusException("Couldn't change Diagram to 3D", e);
96 XInterface oObj = null;
98 XModel aModel = (XModel)
99 UnoRuntime.queryInterface(XModel.class, xChartDoc);
101 AccessibilityTools at = new AccessibilityTools();
103 XWindow xWindow = at.getCurrentWindow((XMultiServiceFactory)Param.getMSF(), aModel);
104 XAccessible xRoot = at.getAccessibleObject(xWindow);
106 at.printAccessibleTree(log, xRoot, Param.getBool(util.PropertyName.DEBUG_IS_ACTIVE));
108 XAccessibleContext cont = at.getAccessibleObjectForRole(
109 xRoot, AccessibleRole.SHAPE, "", "AccFloor");
112 oObj = cont;
114 log.println("ImplementationName " + utils.getImplName(oObj));
115 log.println("AccessibleName " + cont.getAccessibleName());
117 TestEnvironment tEnv = new TestEnvironment(oObj);
119 final XAccessibleComponent acc = (XAccessibleComponent)
120 UnoRuntime.queryInterface(
121 XAccessibleComponent.class,oObj);
122 tEnv.addObjRelation("EventProducer",
123 new ifc.accessibility._XAccessibleEventBroadcaster.EventProducer() {
124 public void fireEvent() {
125 acc.grabFocus();
129 return tEnv;
134 * Called while disposing a <code>TestEnvironment</code>.
135 * Disposes text document.
136 * @param tParam test parameters
137 * @param tEnv the environment to cleanup
138 * @param log writer to log information while testing
140 protected void cleanup( TestParameters Param, PrintWriter log) {
141 log.println( " closing xChartDoc " );
142 util.DesktopTools.closeDoc(xChartDoc);