Branch libreoffice-5-0-4
[LibreOffice.git] / qadevOOo / tests / java / mod / _sw / SwAccessibleTableCellView.java
blob337d0d60a1f47d782a21b2f0d2cf0bc1c36d24d1
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.accessibility.XAccessibleContext;
34 import com.sun.star.accessibility.XAccessibleSelection;
35 import com.sun.star.awt.XWindow;
36 import com.sun.star.frame.XModel;
37 import com.sun.star.text.XTextDocument;
38 import com.sun.star.text.XTextTable;
39 import com.sun.star.uno.UnoRuntime;
42 /**
43 * Test of accessible object for the table cell of a text document.<p>
44 * Object implements the following interfaces :
45 * <ul>
46 * <li> <code>::com::sun::star::accessibility::XAccessible</code></li>
47 * </ul>
48 * @see com.sun.star.accessibility.XAccessible
50 public class SwAccessibleTableCellView extends TestCase {
51 XTextDocument xTextDoc = null;
53 /**
54 * Called to create an instance of <code>TestEnvironment</code>
55 * with an object to test and related objects.
56 * Creates a text table and inserts it to document. Then obtains accessible
57 * object for one of table cell.
59 * @param Param test parameters
60 * @param log writer to log information while testing
62 * @see TestEnvironment
63 * @see #getTestEnvironment
65 @Override
66 protected TestEnvironment createTestEnvironment(TestParameters Param,
67 PrintWriter log) {
68 XAccessibleContext oObj = null;
69 XTextTable oTable = null;
71 SOfficeFactory.getFactory( Param.getMSF());
73 oTable = SOfficeFactory.createTextTable(xTextDoc);
75 try {
76 SOfficeFactory.insertTextContent(xTextDoc, oTable);
77 } catch (com.sun.star.lang.IllegalArgumentException e) {
78 e.printStackTrace(log);
79 throw new StatusException("Couldn't insert text content :" +
80 e.getMessage(), e);
83 XModel aModel = UnoRuntime.queryInterface(XModel.class,
84 xTextDoc);
86 XWindow xWindow = AccessibilityTools.getCurrentWindow(aModel);
87 XAccessible xRoot = AccessibilityTools.getAccessibleObject(xWindow);
89 oObj = AccessibilityTools.getAccessibleObjectForRole(xRoot, AccessibleRole.TABLE_CELL);
91 log.println("ImplementationName " + utils.getImplName(oObj));
93 AccessibilityTools.printAccessibleTree(log, xRoot, Param.getBool(util.PropertyName.DEBUG_IS_ACTIVE));
94 TestEnvironment tEnv = new TestEnvironment(oObj);
96 final XAccessibleSelection accSel = UnoRuntime.queryInterface(
97 XAccessibleSelection.class,
98 oObj.getAccessibleParent());
100 tEnv.addObjRelation("EventProducer",
101 new ifc.accessibility._XAccessibleEventBroadcaster.EventProducer() {
102 public void fireEvent() {
103 accSel.selectAllAccessibleChildren();
107 return tEnv;
111 * Called while disposing a <code>TestEnvironment</code>.
112 * Disposes text document.
113 * @param Param test parameters
114 * @param log writer to log information while testing
116 @Override
117 protected void cleanup(TestParameters Param, PrintWriter log) {
118 log.println("dispose text document");
119 util.DesktopTools.closeDoc(xTextDoc);
123 * Called while the <code>TestCase</code> initialization.
124 * Creates a text document.
126 * @param Param test parameters
127 * @param log writer to log information while testing
129 * @see #initializeTestCase
131 @Override
132 protected void initialize(TestParameters Param, PrintWriter log) {
133 log.println("creating a text document");
134 xTextDoc = WriterTools.createTextDoc( Param.getMSF());