Version 6.4.0.0.beta1, tag libreoffice-6.4.0.0.beta1
[LibreOffice.git] / qadevOOo / tests / java / mod / _sm / SmEditAccessible.java
blob7b7a2c28d25a1bffd6b79635c06c047cbd5c3bd4
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 .
19 package mod._sm;
21 import java.io.PrintWriter;
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.accessibility.XAccessibleContext;
33 import com.sun.star.awt.XWindow;
34 import com.sun.star.beans.XPropertySet;
35 import com.sun.star.frame.XModel;
36 import com.sun.star.lang.XComponent;
37 import com.sun.star.uno.UnoRuntime;
38 import com.sun.star.uno.XInterface;
40 /**
41 * Object implements the following interfaces :
42 * <ul>
43 * <li> <code>::com::sun::star::accessibility::XAccessible</code></li>
44 * <li> <code>::com::sun::star::accessibility::XAccessibleComponent</code></li>
45 * <li> <code>::com::sun::star::accessibility::XAccessibleContext</code></li>
46 * <li> <code>::com::sun::star::accessibility::XAccessibleEventBroadcaster</code></li>
47 * <li> <code>::com::sun::star::accessibility::XAccessibleText</code></li>
48 * </ul> <p>
50 * @see com.sun.star.accessibility.XAccessible
51 * @see com.sun.star.accessibility.XAccessibleComponent
52 * @see com.sun.star.accessibility.XAccessibleContext
53 * @see com.sun.star.accessibility.XAccessibleEventBroadcaster
54 * @see com.sun.star.accessibility.XAccessibleText
55 * @see ifc.accessibility._XAccessible
56 * @see ifc.accessibility._XAccessibleComponent
57 * @see ifc.accessibility._XAccessibleContext
58 * @see ifc.accessibility._XAccessibleEventBroadcaster
59 * @see ifc.accessibility._XAccessibleText
61 public class SmEditAccessible extends TestCase {
62 XComponent xMathDoc;
64 /**
65 * Creates a <code>StarMath</code> document and obtains an accessibility
66 * component with the role <code>AccessibleRole.TEXT_FRAME</code>.
68 @Override
69 protected TestEnvironment createTestEnvironment(final TestParameters Param, PrintWriter log) throws Exception {
71 SOfficeFactory SOF = SOfficeFactory.getFactory( Param.getMSF() );
72 xMathDoc = SOF.openDoc("smath","_blank");
74 // setting a formula in document
75 final String expFormula = "sum hat a";
76 final XPropertySet xPS = UnoRuntime.queryInterface
77 (XPropertySet.class, xMathDoc);
78 xPS.setPropertyValue("Formula", expFormula);
80 XInterface oObj = null;
82 XModel aModel = UnoRuntime.queryInterface(XModel.class, xMathDoc);
85 XWindow xWindow = AccessibilityTools.getCurrentWindow(aModel);
86 XAccessible xRoot = AccessibilityTools.getAccessibleObject(xWindow);
88 oObj = AccessibilityTools.getAccessibleObjectForRole
89 (xRoot, AccessibleRole.TEXT_FRAME, "", "SmEditAccessible");
91 log.println("ImplementationName " + utils.getImplName(oObj));
92 AccessibilityTools.printAccessibleTree(log, xRoot, Param.getBool(util.PropertyName.DEBUG_IS_ACTIVE));
93 TestEnvironment tEnv = new TestEnvironment(oObj);
95 tEnv.addObjRelation("Destroy", Boolean.TRUE);
97 final XAccessibleContext con = UnoRuntime.queryInterface(XAccessibleContext.class, oObj);
98 tEnv.addObjRelation("EventProducer",
99 new ifc.accessibility._XAccessibleEventBroadcaster.EventProducer(){
100 public void fireEvent() {
101 try {
102 System.out.println("Children "+con.getAccessibleChildCount());
103 xPS.setPropertyValue("Formula", "sum hat x \n int a \n sum b");
104 util.utils.waitForEventIdle(Param.getMSF());
105 System.out.println("Children "+con.getAccessibleChildCount());
106 xPS.setPropertyValue("Formula", expFormula);
107 util.utils.waitForEventIdle(Param.getMSF());
108 } catch(com.sun.star.lang.WrappedTargetException e) {
109 } catch(com.sun.star.lang.IllegalArgumentException e) {
110 } catch(com.sun.star.beans.PropertyVetoException e) {
111 } catch(com.sun.star.beans.UnknownPropertyException e) {
116 return tEnv;
120 * Disposes the document created in <code>createTestEnvironment</code>
121 * method.
123 @Override
124 protected void cleanup( TestParameters Param, PrintWriter log) {
126 log.println( " disposing xMathDoc " );
127 xMathDoc.dispose();
129 } // finish class SmModel