bump product version to 5.0.4.1
[LibreOffice.git] / qadevOOo / tests / java / mod / _toolkit / AccessibleFixedText.java
blob873d643a96c2cbecaa6d9ef66e58c36f648c0ff3
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.XAccessibleText;
23 import com.sun.star.awt.PosSize;
24 import com.sun.star.awt.XControl;
25 import com.sun.star.awt.XControlContainer;
26 import com.sun.star.awt.XControlModel;
27 import com.sun.star.awt.XFixedText;
28 import com.sun.star.awt.XWindow;
29 import com.sun.star.lang.XMultiServiceFactory;
30 import com.sun.star.uno.UnoRuntime;
31 import com.sun.star.uno.XInterface;
33 import java.io.PrintWriter;
35 import lib.StatusException;
36 import lib.TestCase;
37 import lib.TestEnvironment;
38 import lib.TestParameters;
40 import util.AccessibilityTools;
41 import util.utils;
44 /**
45 * Test for object which is represented by accessible component
46 * of the fixed text label in 'Hyperlink' Dialog. <p>
48 * Object implements the following interfaces :
49 * <ul>
50 * <li> <code>::com::sun::star::accessibility::XAccessibleExtendedComponent</code></li>
51 * <li> <code>::com::sun::star::accessibility::XAccessibleEventBroadcaster</code></li>
52 * <li> <code>::com::sun::star::accessibility::XAccessibleComponent</code></li>
53 * <li> <code>::com::sun::star::accessibility::XAccessibleContext</code></li>
54 * <li> <code>::com::sun::star::accessibility::XAccessibleText</code></li>
55 * </ul> <p>
57 * @see com.sun.star.accessibility.XAccessibleExtendedComponent
58 * @see com.sun.star.accessibility.XAccessibleEventBroadcaster
59 * @see com.sun.star.accessibility.XAccessibleComponent
60 * @see com.sun.star.accessibility.XAccessibleContext
61 * @see com.sun.star.accessibility.XAccessibleText
62 * @see ifc.accessibility._XAccessibleExtendedComponent
63 * @see ifc.accessibility._XAccessibleEventBroadcaster
64 * @see ifc.accessibility._XAccessibleComponent
65 * @see ifc.accessibility._XAccessibleContext
66 * @see ifc.accessibility._XAccessibleText
68 public class AccessibleFixedText extends TestCase {
69 private static XWindow xWinDlg = null;
71 /**
72 * Creates a new dialog adds fixed text control to it and
73 * displays it. Then the text's accessible component is
74 * obtained.
76 @Override
77 protected TestEnvironment createTestEnvironment(TestParameters Param,
78 PrintWriter log) {
79 XInterface oObj = null;
80 XMultiServiceFactory xMSF = Param.getMSF();
81 XControlModel dlgModel = null;
83 XControl txtControl = null;
84 XControlModel txtModel = null;
86 try {
87 dlgModel = UnoRuntime.queryInterface(
88 XControlModel.class,
89 xMSF.createInstance(
90 "com.sun.star.awt.UnoControlDialogModel"));
92 XControl dlgControl = UnoRuntime.queryInterface(
93 XControl.class,
94 xMSF.createInstance(
95 "com.sun.star.awt.UnoControlDialog"));
97 dlgControl.setModel(dlgModel);
99 txtModel = UnoRuntime.queryInterface(
100 XControlModel.class,
101 xMSF.createInstance(
102 "com.sun.star.awt.UnoControlFixedTextModel"));
104 txtControl = UnoRuntime.queryInterface(XControl.class,
105 xMSF.createInstance(
106 "com.sun.star.awt.UnoControlFixedText"));
108 txtControl.setModel(txtModel);
110 XFixedText xFT = UnoRuntime.queryInterface(
111 XFixedText.class, txtControl);
112 xFT.setText("FxedText");
114 XControlContainer ctrlCont = UnoRuntime.queryInterface(
115 XControlContainer.class,
116 dlgControl);
118 ctrlCont.addControl("Text", txtControl);
120 xWinDlg = UnoRuntime.queryInterface(XWindow.class,
121 dlgControl);
123 xWinDlg.setVisible(true);
125 xWinDlg.setPosSize(0, 0, 200, 100, PosSize.SIZE);
126 } catch (com.sun.star.uno.Exception e) {
127 log.println("Error creating dialog :");
128 e.printStackTrace(log);
131 try {
132 oObj = (XInterface) Param.getMSF().createInstance(
133 "com.sun.star.awt.Toolkit");
134 } catch (com.sun.star.uno.Exception e) {
135 log.println("Couldn't get toolkit");
136 e.printStackTrace(log);
137 throw new StatusException("Couldn't get toolkit", e);
140 util.utils.pause(500);
142 XAccessible xRoot = AccessibilityTools.getAccessibleObject(xWinDlg);
144 AccessibilityTools.printAccessibleTree(log, xRoot, Param.getBool(util.PropertyName.DEBUG_IS_ACTIVE));
146 oObj = AccessibilityTools.getAccessibleObjectForRole(xRoot, AccessibleRole.LABEL);
148 log.println("ImplementationName " + utils.getImplName(oObj));
150 TestEnvironment tEnv = new TestEnvironment(oObj);
152 final XWindow xWin = UnoRuntime.queryInterface(XWindow.class,
153 txtControl);
155 tEnv.addObjRelation("EventProducer",
156 new ifc.accessibility._XAccessibleEventBroadcaster.EventProducer() {
157 public void fireEvent() {
158 xWin.setEnable(false);
159 xWin.setEnable(true);
163 XAccessibleText text = UnoRuntime.queryInterface(
164 XAccessibleText.class, oObj);
166 tEnv.addObjRelation("XAccessibleText.Text", text.getText());
168 tEnv.addObjRelation("EditOnly",
169 "This method isn't supported in this component");
171 tEnv.addObjRelation("LimitedBounds", "yes");
173 return tEnv;
177 * Closes dialog using action of button 'Close'
179 @Override
180 protected void cleanup(TestParameters Param, PrintWriter log) {
181 log.println(" Closing dialog ... ");
182 xWinDlg.dispose();