tdf#130857 qt weld: Introduce QtInstanceScrolledWindow
[LibreOffice.git] / qadevOOo / tests / java / mod / _toolkit / AccessibleFixedText.java
blobf7a756685b80acc51c05eae271afc7f40b9dbcac
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.awt.XLayoutConstrains;
30 import com.sun.star.awt.Size;
31 import com.sun.star.lang.XMultiServiceFactory;
32 import com.sun.star.uno.UnoRuntime;
33 import com.sun.star.uno.XInterface;
35 import java.io.PrintWriter;
37 import lib.TestCase;
38 import lib.TestEnvironment;
39 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) throws Exception {
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 /* Set the text control to its preferred size, otherwise it
115 * defaults to the size hard coded in its constructor (100 x 12) */
116 XLayoutConstrains xLCTxt = UnoRuntime.queryInterface(
117 XLayoutConstrains.class, txtControl);
118 Size textSize = xLCTxt.getPreferredSize();
119 XWindow xWinTxt = UnoRuntime.queryInterface(
120 XWindow.class, txtControl);
121 xWinTxt.setPosSize(0, 0, textSize.Width, textSize.Height,
122 PosSize.SIZE);
124 XControlContainer ctrlCont = UnoRuntime.queryInterface(
125 XControlContainer.class,
126 dlgControl);
128 ctrlCont.addControl("Text", txtControl);
130 xWinDlg = UnoRuntime.queryInterface(XWindow.class,
131 dlgControl);
133 xWinDlg.setVisible(true);
135 xWinDlg.setPosSize(0, 0, 200, 100, PosSize.SIZE);
136 } catch (com.sun.star.uno.Exception e) {
137 log.println("Error creating dialog :");
138 e.printStackTrace(log);
141 oObj = (XInterface) Param.getMSF().createInstance(
142 "com.sun.star.awt.Toolkit");
144 util.utils.waitForEventIdle(Param.getMSF());
146 XAccessible xRoot = AccessibilityTools.getAccessibleObject(xWinDlg);
148 AccessibilityTools.printAccessibleTree(log, xRoot, Param.getBool(util.PropertyName.DEBUG_IS_ACTIVE));
150 oObj = AccessibilityTools.getAccessibleObjectForRole(xRoot, AccessibleRole.LABEL);
152 log.println("ImplementationName " + utils.getImplName(oObj));
154 TestEnvironment tEnv = new TestEnvironment(oObj);
156 final XWindow xWin = UnoRuntime.queryInterface(XWindow.class,
157 txtControl);
159 tEnv.addObjRelation("EventProducer",
160 new ifc.accessibility._XAccessibleEventBroadcaster.EventProducer() {
161 public void fireEvent() {
162 xWin.setEnable(false);
163 xWin.setEnable(true);
167 XAccessibleText text = UnoRuntime.queryInterface(
168 XAccessibleText.class, oObj);
170 tEnv.addObjRelation("XAccessibleText.Text", text.getText());
172 tEnv.addObjRelation("EditOnly",
173 "This method isn't supported in this component");
175 tEnv.addObjRelation("LimitedBounds", "yes");
177 return tEnv;
181 * Closes dialog using action of button 'Close'
183 @Override
184 protected void cleanup(TestParameters Param, PrintWriter log) {
185 log.println(" Closing dialog ... ");
186 if (xWinDlg != null)
187 xWinDlg.dispose();