merge the formfield patch from ooo-build
[ooovba.git] / qadevOOo / tests / java / mod / _sch / AccessibleDocumentView.java
blobfcc756d7f183eb008cbd435b396238253077c11f
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: AccessibleDocumentView.java,v $
10 * $Revision: 1.7 $
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.awt.PosSize;
45 import com.sun.star.awt.Rectangle;
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 AccessibleDocumentView extends TestCase {
55 XChartDocument xChartDoc = null;
57 protected TestEnvironment createTestEnvironment(
58 TestParameters Param, PrintWriter log) {
60 XInterface oObj = null;
62 XModel aModel = (XModel)
63 UnoRuntime.queryInterface(XModel.class, xChartDoc);
65 AccessibilityTools at = new AccessibilityTools();
67 XWindow xWindow = at.getCurrentWindow((XMultiServiceFactory)Param.getMSF(), aModel);
68 XAccessible xRoot = at.getAccessibleObject(xWindow);
70 at.getAccessibleObjectForRole(xRoot, AccessibleRole.DOCUMENT);
72 oObj = AccessibilityTools.SearchedContext;
74 if (oObj == null) {
75 log.println("DocumentView hasn't the role 'Document'");
76 log.println("trying the role 'Shape'");
77 at.getAccessibleObjectForRole(xRoot, AccessibleRole.SHAPE);
78 oObj = AccessibilityTools.SearchedContext;
81 log.println("ImplementationName " + utils.getImplName(oObj));
83 TestEnvironment tEnv = new TestEnvironment(oObj);
85 final XWindow xDocWin = xWindow;
86 tEnv.addObjRelation("EventProducer",
87 new ifc.accessibility._XAccessibleEventBroadcaster.EventProducer() {
88 public void fireEvent() {
89 Rectangle rect = xDocWin.getPosSize();
90 xDocWin.setPosSize(100,100,100,100,PosSize.POSSIZE);
91 xDocWin.setPosSize(rect.X,rect.Y,rect.Width,rect.Height,
92 PosSize.POSSIZE);
94 });
96 return tEnv;
101 * Called while disposing a <code>TestEnvironment</code>.
102 * Disposes text document.
103 * @param tParam test parameters
104 * @param tEnv the environment to cleanup
105 * @param log writer to log information while testing
107 protected void cleanup( TestParameters Param, PrintWriter log) {
108 log.println( " closing xChartDoc " );
109 util.DesktopTools.closeDoc(xChartDoc);
113 * Called while the <code>TestCase</code> initialization.
114 * Creates a chart document.
116 * @param tParam test parameters
117 * @param log writer to log information while testing
119 * @see #initializeTestCase()
121 protected void initialize(TestParameters Param, PrintWriter log) {
122 log.println( "creating a text document" );
123 SOfficeFactory SOF = SOfficeFactory.getFactory( (XMultiServiceFactory)Param.getMSF());
124 try {
125 log.println( "creating a chartdocument" );
126 xChartDoc = SOF.createChartDoc(null);
127 } catch (com.sun.star.uno.Exception e) {
128 // Some exception occures.FAILED
129 e.printStackTrace( log );
130 throw new StatusException( "Couldn't create document", e );