tdf#130857 qt weld: Introduce QtInstanceScrolledWindow
[LibreOffice.git] / qadevOOo / tests / java / mod / _toolkit / AccessibleToolBoxItem.java
blobc92a14b61f94058608e2f1e4cafae17290a3197e
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._toolkit;
20 import com.sun.star.accessibility.AccessibleRole;
21 import com.sun.star.accessibility.XAccessible;
22 import com.sun.star.accessibility.XAccessibleAction;
23 import com.sun.star.awt.XWindow;
24 import com.sun.star.frame.XModel;
25 import com.sun.star.text.XTextDocument;
26 import com.sun.star.uno.UnoRuntime;
27 import com.sun.star.uno.XInterface;
29 import java.io.PrintWriter;
31 import lib.TestCase;
32 import lib.TestEnvironment;
33 import lib.TestParameters;
34 import util.AccessibilityTools;
35 import util.SOfficeFactory;
38 /**
39 * Test for object that implements the following interfaces :
40 * <ul>
41 * <li><code>
42 * ::com::sun::star::accessibility::XAccessibleContext</code></li>
43 * <li><code>
44 * ::com::sun::star::accessibility::XAccessibleEventBroadcaster
45 * </code></li>
46 * <li><code>
47 * ::com::sun::star::accessibility::XAccessibleComponent</code></li>
48 * <li><code>
49 * ::com::sun::star::accessibility::XAccessibleExtendedComponent
50 * </code></li>
51 * <li><code>
52 * ::com::sun::star::accessibility::XAccessibleAction</code></li>
53 * <li><code>
54 * ::com::sun::star::accessibility::XAccessibleText</code></li>
55 * <li><code>
56 * ::com::sun::star::accessibility::XAccessibleValue</code></li>
57 * </ul> <p>
59 * @see com.sun.star.accessibility.XAccessibleEventBroadcaster
60 * @see com.sun.star.accessibility.XAccessibleContext
61 * @see com.sun.star.accessibility.XAccessibleComponent
62 * @see com.sun.star.accessibility.XAccessibleExtendedComponent
63 * @see com.sun.star.accessibility.XAccessibleAction
64 * @see com.sun.star.accessibility.XAccessibleText
65 * @see com.sun.star.accessibility.XAccessibleValue
66 * @see ifc.accessibility._XAccessibleEventBroadcaster
67 * @see ifc.accessibility._XAccessibleContext
68 * @see ifc.accessibility._XAccessibleComponent
69 * @see ifc.accessibility._XAccessibleExtendedComponent
70 * @see ifc.accessibility._XAccessibleAction
71 * @see ifc.accessibility._XAccessibleText
72 * @see ifc.accessibility._XAccessibleValue
74 public class AccessibleToolBoxItem extends TestCase {
75 private static XTextDocument xTextDoc;
77 /**
78 * Disposes the document, if exists, created in
79 * <code>createTestEnvironment</code> method.
81 @Override
82 protected void cleanup(TestParameters Param, PrintWriter log) {
83 log.println("disposing xTextDoc");
85 if (xTextDoc != null) {
86 closeDoc();
90 /**
91 * Creates a text document.
92 * Then obtains an accessible object with
93 * the role <code>AccessibleRole.PUSHBUTTON</code> and with the name
94 * <code>"Bold"</code>.
95 * Object relations created :
96 * <ul>
97 * <li> <code>'EventProducer'</code> for
98 * {@link ifc.accessibility._XAccessibleEventBroadcaster}</li>
99 * <li> <code>'XAccessibleText.Text'</code> for
100 * {@link ifc.accessibility._XAccessibleText}: the name of button</li>
101 * </ul>
103 * @param tParam test parameters
104 * @param log writer to log information while testing
106 * @see com.sun.star.awt.Toolkit
107 * @see com.sun.star.accessibility.AccessibleRole
108 * @see ifc.accessibility._XAccessibleEventBroadcaster
109 * @see ifc.accessibility._XAccessibleText
110 * @see com.sun.star.accessibility.XAccessibleEventBroadcaster
111 * @see com.sun.star.accessibility.XAccessibleText
113 @Override
114 protected TestEnvironment createTestEnvironment(TestParameters tParam,
115 PrintWriter log) throws Exception {
116 log.println("creating a test environment");
118 if (xTextDoc != null) {
119 closeDoc();
122 // get a soffice factory object
123 SOfficeFactory SOF = SOfficeFactory.getFactory(
124 tParam.getMSF());
126 log.println("creating a text document");
127 xTextDoc = SOF.createTextDoc(null);
129 XModel aModel = UnoRuntime.queryInterface(XModel.class,
130 xTextDoc);
132 XInterface oObj = null;
134 XWindow xWindow = AccessibilityTools.getCurrentContainerWindow(
135 aModel);
137 XAccessible xRoot = AccessibilityTools.getAccessibleObject(xWindow);
140 AccessibilityTools.printAccessibleTree(log, xRoot, tParam.getBool(util.PropertyName.DEBUG_IS_ACTIVE));
141 oObj = AccessibilityTools.getAccessibleObjectForRole(xRoot,
142 AccessibleRole.TOGGLE_BUTTON,
143 "Bold");
145 log.println("ImplementationName: " + util.utils.getImplName(oObj));
147 TestEnvironment tEnv = new TestEnvironment(oObj);
149 tEnv.addObjRelation("EditOnly",
150 "This method isn't supported in this dialog");
152 tEnv.addObjRelation("LimitedBounds", "yes");
154 final XAccessibleAction oAction = UnoRuntime.queryInterface(
155 XAccessibleAction.class,
156 oObj);
158 tEnv.addObjRelation("EventProducer",
159 new ifc.accessibility._XAccessibleEventBroadcaster.EventProducer() {
160 public void fireEvent() {
161 try {
162 oAction.doAccessibleAction(0);
163 } catch (com.sun.star.lang.IndexOutOfBoundsException e) {
168 tEnv.addObjRelation("XAccessibleText.Text", "Bold");
170 return tEnv;
173 protected void closeDoc() {
174 util.DesktopTools.closeDoc(xTextDoc);