bump product version to 4.2.0.1
[LibreOffice.git] / qadevOOo / tests / java / mod / _sch / AccessibleDocumentView.java
blobb4a52f19a4e8c7f401db89928126c7a7e2866e94
1 /*
2 * This file is part of the LibreOffice project.
4 * This Source Code Form is subject to the terms of the Mozilla Public
5 * License, v. 2.0. If a copy of the MPL was not distributed with this
6 * file, You can obtain one at http://mozilla.org/MPL/2.0/.
8 * This file incorporates work covered by the following license notice:
10 * Licensed to the Apache Software Foundation (ASF) under one or more
11 * contributor license agreements. See the NOTICE file distributed
12 * with this work for additional information regarding copyright
13 * ownership. The ASF licenses this file to you under the Apache
14 * License, Version 2.0 (the "License"); you may not use this file
15 * except in compliance with the License. You may obtain a copy of
16 * the License at http://www.apache.org/licenses/LICENSE-2.0 .
18 package mod._sch;
20 import java.io.PrintWriter;
22 import lib.StatusException;
23 import lib.TestCase;
24 import lib.TestEnvironment;
25 import lib.TestParameters;
26 import util.AccessibilityTools;
27 import util.SOfficeFactory;
28 import util.utils;
30 import com.sun.star.accessibility.AccessibleRole;
31 import com.sun.star.accessibility.XAccessible;
32 import com.sun.star.awt.PosSize;
33 import com.sun.star.awt.Rectangle;
34 import com.sun.star.awt.XWindow;
35 import com.sun.star.chart.XChartDocument;
36 import com.sun.star.frame.XModel;
37 import com.sun.star.lang.XMultiServiceFactory;
38 import com.sun.star.uno.UnoRuntime;
39 import com.sun.star.uno.XInterface;
41 public class AccessibleDocumentView extends TestCase {
43 XChartDocument xChartDoc = null;
45 protected TestEnvironment createTestEnvironment(
46 TestParameters Param, PrintWriter log) {
48 XInterface oObj = null;
50 XModel aModel = UnoRuntime.queryInterface(XModel.class, xChartDoc);
52 AccessibilityTools at = new AccessibilityTools();
54 XWindow xWindow = AccessibilityTools.getCurrentWindow((XMultiServiceFactory)Param.getMSF(), aModel);
55 XAccessible xRoot = AccessibilityTools.getAccessibleObject(xWindow);
57 oObj = AccessibilityTools.getAccessibleObjectForRole(xRoot, AccessibleRole.DOCUMENT);
59 if (oObj == null) {
60 log.println("DocumentView hasn't the role 'Document'");
61 log.println("trying the role 'Shape'");
62 oObj = AccessibilityTools.getAccessibleObjectForRole(xRoot, AccessibleRole.SHAPE);
65 log.println("ImplementationName " + utils.getImplName(oObj));
67 TestEnvironment tEnv = new TestEnvironment(oObj);
69 final XWindow xDocWin = xWindow;
70 tEnv.addObjRelation("EventProducer",
71 new ifc.accessibility._XAccessibleEventBroadcaster.EventProducer() {
72 public void fireEvent() {
73 Rectangle rect = xDocWin.getPosSize();
74 xDocWin.setPosSize(100,100,100,100,PosSize.POSSIZE);
75 xDocWin.setPosSize(rect.X,rect.Y,rect.Width,rect.Height,
76 PosSize.POSSIZE);
78 });
80 return tEnv;
84 /**
85 * Called while disposing a <code>TestEnvironment</code>.
86 * Disposes text document.
87 * @param Param test parameters
88 * @param log writer to log information while testing
90 protected void cleanup( TestParameters Param, PrintWriter log) {
91 if( xChartDoc!=null ) {
92 log.println( " closing xChartDoc" );
93 util.DesktopTools.closeDoc(xChartDoc);
94 xChartDoc = null;
98 /**
99 * Called while the <code>TestCase</code> initialization.
100 * Creates a chart document.
102 * @param Param test parameters
103 * @param log writer to log information while testing
105 * @see #initializeTestCase
107 protected void initialize(TestParameters Param, PrintWriter log) {
108 log.println( "creating a text document" );
109 SOfficeFactory SOF = SOfficeFactory.getFactory( (XMultiServiceFactory)Param.getMSF());
110 try {
111 log.println( "creating a chartdocument" );
112 xChartDoc = SOF.createChartDoc(null);
113 } catch (com.sun.star.uno.Exception e) {
114 // Some exception occurs.FAILED
115 e.printStackTrace( log );
116 throw new StatusException( "Couldn't create document", e );