bump product version to 4.2.0.1
[LibreOffice.git] / qadevOOo / tests / java / mod / _sw / SwAccessibleTableView.java
blobe54a1599f96f27322fd9376a7ea94734f0a07b9c
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._sw;
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.WriterTools;
29 import util.utils;
31 import com.sun.star.accessibility.AccessibleRole;
32 import com.sun.star.accessibility.XAccessible;
33 import com.sun.star.awt.XWindow;
34 import com.sun.star.beans.XPropertySet;
35 import com.sun.star.frame.XController;
36 import com.sun.star.frame.XModel;
37 import com.sun.star.lang.XMultiServiceFactory;
38 import com.sun.star.text.XTextDocument;
39 import com.sun.star.text.XTextTable;
40 import com.sun.star.uno.UnoRuntime;
41 import com.sun.star.uno.XInterface;
42 import com.sun.star.view.XViewSettingsSupplier;
44 /**
45 * Test of accessible object for the table of a text document.<p>
46 * Object implements the following interfaces :
47 * <ul>
48 * <li> <code>::com::sun::star::accessibility::XAccessible</code></li>
49 * </ul>
50 * @see com.sun.star.accessibility.XAccessible
52 public class SwAccessibleTableView extends TestCase {
54 XTextDocument xTextDoc = null;
56 /**
57 * Called to create an instance of <code>TestEnvironment</code>
58 * with an object to test and related objects.
59 * Creates a text table and inserts it into the document.
60 * Then obtains accessible object for the table.
62 * @param Param test parameters
63 * @param log writer to log information while testing
65 * @see TestEnvironment
66 * @see #getTestEnvironment
68 protected TestEnvironment createTestEnvironment(
69 TestParameters Param, PrintWriter log) {
71 XInterface oObj = null;
72 XTextTable oTable = null;
74 SOfficeFactory SOF = SOfficeFactory.getFactory((XMultiServiceFactory)Param.getMSF());
75 try {
76 oTable = SOfficeFactory.createTextTable( xTextDoc );
77 } catch ( com.sun.star.uno.Exception e ) {
78 e.printStackTrace( log );
79 throw new StatusException("Couldn't create TextTable : " +
80 e.getMessage(), e);
83 try {
84 SOfficeFactory.insertTextContent(xTextDoc, oTable );
85 } catch ( com.sun.star.lang.IllegalArgumentException e ) {
86 e.printStackTrace( log );
87 throw new StatusException("Couldn't insert text content :"
88 + e.getMessage(), e);
91 XModel aModel = UnoRuntime.queryInterface(XModel.class, xTextDoc);
93 AccessibilityTools at = new AccessibilityTools();
95 XWindow xWindow = AccessibilityTools.getCurrentWindow((XMultiServiceFactory)Param.getMSF(), aModel);
96 XAccessible xRoot = AccessibilityTools.getAccessibleObject(xWindow);
98 oObj = AccessibilityTools.getAccessibleObjectForRole(xRoot, AccessibleRole.TABLE);
100 log.println("ImplementationName " + utils.getImplName(oObj));
101 AccessibilityTools.printAccessibleTree(log, xRoot, Param.getBool(util.PropertyName.DEBUG_IS_ACTIVE));
103 TestEnvironment tEnv = new TestEnvironment(oObj);
105 XController xController = xTextDoc.getCurrentController();
106 XViewSettingsSupplier xViewSetSup = UnoRuntime.queryInterface(XViewSettingsSupplier.class,
107 xController);
109 final XPropertySet PropSet = xViewSetSup.getViewSettings();
111 tEnv.addObjRelation("EventProducer",
112 new ifc.accessibility._XAccessibleEventBroadcaster.EventProducer() {
113 public void fireEvent() {
114 try {
115 //change zoom value to 15%
116 PropSet.setPropertyValue("ZoomValue", new Short("15"));
117 //and back to 100%
118 PropSet.setPropertyValue("ZoomValue", new Short("100"));
119 } catch ( com.sun.star.lang.WrappedTargetException e ) {
121 } catch ( com.sun.star.lang.IllegalArgumentException e ) {
123 } catch ( com.sun.star.beans.PropertyVetoException e ) {
125 } catch ( com.sun.star.beans.UnknownPropertyException e ) {
131 return tEnv;
136 * Called while disposing a <code>TestEnvironment</code>.
137 * Disposes text document.
138 * @param Param test parameters
139 * @param log writer to log information while testing
141 protected void cleanup( TestParameters Param, PrintWriter log) {
142 log.println("dispose text document");
143 util.DesktopTools.closeDoc(xTextDoc);
147 * Called while the <code>TestCase</code> initialization.
148 * Creates a text document.
150 * @param Param test parameters
151 * @param log writer to log information while testing
153 * @see #initializeTestCase
155 protected void initialize(TestParameters Param, PrintWriter log) {
156 log.println( "creating a text document" );
157 xTextDoc = WriterTools.createTextDoc((XMultiServiceFactory)Param.getMSF());