merge the formfield patch from ooo-build
[ooovba.git] / qadevOOo / tests / java / mod / _svx / AccessibleControlShape.java
blob6fe5bf3fc36514e532b26b93e67b318b6c03a561
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: AccessibleControlShape.java,v $
10 * $Revision: 1.9.8.2 $
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 ************************************************************************/
31 package mod._svx;
33 import java.io.PrintWriter;
35 import lib.StatusException;
36 import lib.TestCase;
37 import lib.TestEnvironment;
38 import lib.TestParameters;
39 import util.AccessibilityTools;
40 import util.FormTools;
41 import util.SOfficeFactory;
42 import util.utils;
44 import com.sun.star.accessibility.AccessibleRole;
45 import com.sun.star.accessibility.XAccessible;
46 import com.sun.star.awt.Size;
47 import com.sun.star.awt.XWindow;
48 import com.sun.star.drawing.XShape;
49 import com.sun.star.frame.XModel;
50 import com.sun.star.lang.XComponent;
51 import com.sun.star.lang.XMultiServiceFactory;
52 import com.sun.star.uno.UnoRuntime;
53 import com.sun.star.uno.XInterface;
55 public class AccessibleControlShape extends TestCase {
57 static XComponent xDrawDoc;
58 static XModel aModel;
60 protected void initialize( TestParameters tParam, PrintWriter log ) {
62 SOfficeFactory SOF = SOfficeFactory.getFactory( (XMultiServiceFactory)tParam.getMSF() );
64 try {
65 log.println( "creating a drawdoc" );
66 xDrawDoc = SOF.createDrawDoc(null);
67 aModel = (XModel)
68 UnoRuntime.queryInterface(XModel.class, xDrawDoc);
70 } catch ( com.sun.star.uno.Exception e ) {
71 // Some exception occures.FAILED
72 e.printStackTrace( log );
73 throw new StatusException( "Couldn't create document", e );
77 /**
78 * Disposes the Draw document loaded before.
80 protected void cleanup( TestParameters tParam, PrintWriter log ) {
81 log.println( " disposing xDrawDoc " );
82 util.DesktopTools.closeDoc(xDrawDoc);
85 protected TestEnvironment createTestEnvironment
86 (TestParameters tParam, PrintWriter log) {
88 XInterface oObj = null;
90 log.println( "creating a test environment" );
92 final XShape oShape = FormTools.insertControlShape
93 (xDrawDoc,3000,4500,15000,1000,"CommandButton");
95 AccessibilityTools at = new AccessibilityTools();
96 utils.shortWait(5000);
97 XWindow xWindow = at.getCurrentWindow ((XMultiServiceFactory)tParam.getMSF(),aModel);
98 XAccessible xRoot = at.getAccessibleObject(xWindow);
100 at.getAccessibleObjectForRole(xRoot, AccessibleRole.SHAPE);
102 at.printAccessibleTree(log, xRoot, tParam.getBool(util.PropertyName.DEBUG_IS_ACTIVE));
104 // oObj = at.getAccessibleObjectForRole(xRoot, AccessibleRole.SHAPE,
105 // "Button");
106 oObj = at.getAccessibleObjectForRole(xRoot, AccessibleRole.UNKNOWN, "Button");
108 // create test environment here
109 TestEnvironment tEnv = new TestEnvironment( oObj );
111 tEnv.addObjRelation("EventProducer",
112 new ifc.accessibility._XAccessibleEventBroadcaster.EventProducer() {
113 public void fireEvent() {
114 try {
115 Size size = oShape.getSize();
116 size.Width += 100;
117 oShape.setSize(size);
118 } catch(com.sun.star.beans.PropertyVetoException e) {}
122 log.println("Implementation Name: " + utils.getImplName(oObj));
124 return tEnv;
125 } // finish method getTestEnvironment