merge the formfield patch from ooo-build
[ooovba.git] / qadevOOo / tests / java / mod / _sch / AccDataPoint.java
blob5bf13e95dc9dd35a96ba0d20d6d65f880c75fd9c
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: AccDataPoint.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.chart.XChartDocument;
48 import com.sun.star.frame.XModel;
49 import com.sun.star.lang.XMultiServiceFactory;
50 import com.sun.star.uno.UnoRuntime;
51 import com.sun.star.uno.XInterface;
53 public class AccDataPoint extends TestCase {
55 XChartDocument xChartDoc = null;
57 protected TestEnvironment createTestEnvironment(
58 TestParameters Param, PrintWriter log) {
60 if (xChartDoc != null) cleanup(Param, log);
61 log.println( "creating a chart document" );
62 SOfficeFactory SOF = SOfficeFactory.getFactory( (XMultiServiceFactory)Param.getMSF());
63 try {
64 log.println( "creating a chartdocument" );
65 xChartDoc = SOF.createChartDoc(null);
66 } catch (com.sun.star.uno.Exception e) {
67 // Some exception occures.FAILED
68 e.printStackTrace( log );
69 throw new StatusException( "Couldn't create document", e );
72 XInterface oObj = null;
74 XModel aModel = (XModel)
75 UnoRuntime.queryInterface(XModel.class, xChartDoc);
77 AccessibilityTools at = new AccessibilityTools();
79 XWindow xWindow = at.getCurrentWindow((XMultiServiceFactory)Param.getMSF(), aModel);
80 XAccessible xRoot = at.getAccessibleObject(xWindow);
82 at.printAccessibleTree(log, xRoot, Param.getBool(util.PropertyName.DEBUG_IS_ACTIVE));
84 XAccessibleContext cont = at.getAccessibleObjectForRole(
85 xRoot, AccessibleRole.SHAPE, "", "AccDataPoint");
87 oObj = cont;
89 log.println("ImplementationName " + utils.getImplName(oObj));
90 log.println("AccessibleName " + cont.getAccessibleName());
92 TestEnvironment tEnv = new TestEnvironment(oObj);
94 final XAccessibleComponent acc = (XAccessibleComponent)
95 UnoRuntime.queryInterface(
96 XAccessibleComponent.class,oObj);
97 tEnv.addObjRelation("EventProducer",
98 new ifc.accessibility._XAccessibleEventBroadcaster.EventProducer() {
99 public void fireEvent() {
100 acc.grabFocus();
104 return tEnv;
109 * Called while disposing a <code>TestEnvironment</code>.
110 * Disposes text document.
111 * @param tParam test parameters
112 * @param tEnv the environment to cleanup
113 * @param log writer to log information while testing
115 protected void cleanup( TestParameters Param, PrintWriter log) {
116 log.println( " closing xChartDoc " );
117 util.DesktopTools.closeDoc(xChartDoc);