tdf#130857 qt weld: Introduce QtInstanceScrolledWindow
[LibreOffice.git] / qadevOOo / tests / java / mod / _basctl / AccessibleShape.java
blob8a2bd9917607f56a2655e5ee6336a3bae39ccd13
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 .
20 package mod._basctl;
22 import com.sun.star.accessibility.AccessibleRole;
23 import com.sun.star.accessibility.XAccessible;
24 import com.sun.star.awt.PosSize;
25 import com.sun.star.awt.Rectangle;
26 import com.sun.star.awt.XWindow;
27 import com.sun.star.beans.PropertyValue;
28 import com.sun.star.frame.XDesktop;
29 import com.sun.star.frame.XDispatchHelper;
30 import com.sun.star.frame.XDispatchProvider;
31 import com.sun.star.frame.XFrame;
32 import com.sun.star.frame.XModel;
33 import com.sun.star.lang.XMultiServiceFactory;
34 import com.sun.star.text.XTextDocument;
35 import com.sun.star.uno.UnoRuntime;
36 import com.sun.star.uno.XInterface;
37 import java.io.PrintWriter;
38 import lib.TestCase;
39 import lib.TestEnvironment;
40 import lib.TestParameters;
41 import util.AccessibilityTools;
42 import util.DesktopTools;
43 import util.WriterTools;
44 import util.utils;
46 public class AccessibleShape extends TestCase {
48 XTextDocument xTextDoc = null;
49 XInterface oObj = null;
51 @Override
52 protected void cleanup(TestParameters Param, PrintWriter log) {
53 log.println("Cleaning up");
54 DesktopTools.closeDoc(xTextDoc);
55 try {
56 XMultiServiceFactory xMSF = Param.getMSF();
57 Object o = xMSF.createInstance("com.sun.star.frame.Desktop");
58 XDesktop xDesk = UnoRuntime.queryInterface(XDesktop.class, o);
59 DesktopTools.closeDoc(xDesk.getCurrentFrame());
60 } catch (Exception e) {
61 log.println("Couldn't close IDE");
65 @Override
66 protected TestEnvironment createTestEnvironment(final TestParameters tParam, PrintWriter log) throws Exception {
67 XMultiServiceFactory xMSF = tParam.getMSF();
68 log.println( "creating a test environment" );
69 String aURL=utils.getFullTestURL("basDialog.odt");
70 xTextDoc = WriterTools.loadTextDoc(xMSF,aURL);
71 XModel xModel = UnoRuntime.queryInterface(XModel.class, xTextDoc);
72 XFrame xFrame = xModel.getCurrentController().getFrame();
73 XDispatchProvider xDPP = UnoRuntime.queryInterface(XDispatchProvider.class, xFrame);
75 log.println( "opening the basic dialog editor" );
76 Object o = xMSF.createInstance("com.sun.star.frame.DispatchHelper");
77 XDispatchHelper xDPH = UnoRuntime.queryInterface(XDispatchHelper.class, o);
78 PropertyValue[] aArgs = new PropertyValue[4];
79 aArgs[0] = new PropertyValue();
80 aArgs[0].Name = "Document";
81 aArgs[0].Value = aURL;
82 aArgs[1] = new PropertyValue();
83 aArgs[1].Name = "LibName";
84 aArgs[1].Value = "basctl";
85 aArgs[2] = new PropertyValue();
86 aArgs[2].Name = "Name";
87 aArgs[2].Value = "Dialog1";
88 aArgs[3] = new PropertyValue();
89 aArgs[3].Name = "Type";
90 aArgs[3].Value = "Dialog";
91 xDPH.executeDispatch(xDPP, ".uno:BasicIDEAppear", "", 0, aArgs);
93 util.utils.waitForEventIdle(tParam.getMSF());
95 oObj = (XInterface) tParam.getMSF().createInstance
96 ("com.sun.star.awt.Toolkit") ;
98 final XWindow basicIDE = xFrame.getContainerWindow();
100 XAccessible xRoot = AccessibilityTools.getAccessibleObject(basicIDE);
102 AccessibilityTools.printAccessibleTree(log, xRoot, tParam.getBool(util.PropertyName.DEBUG_IS_ACTIVE));
104 oObj = AccessibilityTools.getAccessibleObjectForRole(xRoot, AccessibleRole.SHAPE);
106 // create test environment here
107 TestEnvironment tEnv = new TestEnvironment( oObj );
109 log.println("Implementation Name: " + utils.getImplName(oObj));
111 tEnv.addObjRelation("Destroy", Boolean.TRUE);
113 tEnv.addObjRelation("EventProducer",
114 new ifc.accessibility._XAccessibleEventBroadcaster.EventProducer() {
115 public void fireEvent() {
116 Rectangle oldPosSize = basicIDE.getPosSize();
117 Rectangle newPosSize = new Rectangle();
118 newPosSize.Width = oldPosSize.Width/2;
119 newPosSize.Height = oldPosSize.Height/2;
120 newPosSize.X = oldPosSize.X + 20;
121 newPosSize.Y = oldPosSize.Y + 20;
122 basicIDE.setPosSize(newPosSize.X, newPosSize.Y, newPosSize.Width,
123 newPosSize.Height, PosSize.POSSIZE);
124 util.utils.waitForEventIdle(tParam.getMSF());
125 basicIDE.setPosSize(oldPosSize.X, oldPosSize.Y, oldPosSize.Width,
126 oldPosSize.Height, PosSize.POSSIZE);
130 return tEnv;