Avoid potential negative array index access to cached text.
[LibreOffice.git] / qadevOOo / tests / java / mod / _svx / AccessibleControlShape.java
blob8f55793f09e5e740d1a47f1594b75e6087207a57
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._svx;
21 import java.io.PrintWriter;
23 import lib.TestCase;
24 import lib.TestEnvironment;
25 import lib.TestParameters;
26 import util.AccessibilityTools;
27 import util.FormTools;
28 import util.SOfficeFactory;
29 import util.utils;
31 import com.sun.star.accessibility.AccessibleRole;
32 import com.sun.star.accessibility.XAccessible;
33 import com.sun.star.awt.Size;
34 import com.sun.star.awt.XWindow;
35 import com.sun.star.drawing.XShape;
36 import com.sun.star.frame.XModel;
37 import com.sun.star.lang.XComponent;
38 import com.sun.star.uno.UnoRuntime;
39 import com.sun.star.uno.XInterface;
41 public class AccessibleControlShape extends TestCase {
43 static XComponent xDrawDoc;
44 static XModel aModel;
46 @Override
47 protected void initialize( TestParameters tParam, PrintWriter log ) throws Exception {
48 SOfficeFactory SOF = SOfficeFactory.getFactory( tParam.getMSF() );
49 log.println( "creating a drawdoc" );
50 xDrawDoc = SOF.createDrawDoc(null);
51 aModel = UnoRuntime.queryInterface(XModel.class, xDrawDoc);
54 /**
55 * Disposes the Draw document loaded before.
57 @Override
58 protected void cleanup( TestParameters tParam, PrintWriter log ) {
59 log.println( " disposing xDrawDoc " );
60 util.DesktopTools.closeDoc(xDrawDoc);
63 @Override
64 protected TestEnvironment createTestEnvironment
65 (TestParameters tParam, PrintWriter log)
66 throws com.sun.star.uno.Exception
69 XInterface oObj = null;
71 log.println( "creating a test environment" );
73 final XShape oShape = FormTools.insertControlShape
74 (xDrawDoc,3000,4500,15000,1000,"CommandButton");
76 util.utils.waitForEventIdle(tParam.getMSF());
77 XWindow xWindow = AccessibilityTools.getCurrentWindow (aModel);
78 XAccessible xRoot = AccessibilityTools.getAccessibleObject(xWindow);
80 AccessibilityTools.getAccessibleObjectForRole(xRoot, AccessibleRole.SHAPE);
82 AccessibilityTools.printAccessibleTree(log, xRoot, tParam.getBool(util.PropertyName.DEBUG_IS_ACTIVE));
84 oObj = AccessibilityTools.getAccessibleObjectForRole(xRoot, AccessibleRole.UNKNOWN, "Button");
86 // create test environment here
87 TestEnvironment tEnv = new TestEnvironment( oObj );
89 tEnv.addObjRelation("EventProducer",
90 new ifc.accessibility._XAccessibleEventBroadcaster.EventProducer() {
91 public void fireEvent() {
92 try {
93 Size size = oShape.getSize();
94 size.Width += 100;
95 oShape.setSize(size);
96 } catch(com.sun.star.beans.PropertyVetoException e) {
97 System.out.println("caught exception: " + e);
102 log.println("Implementation Name: " + utils.getImplName(oObj));
104 return tEnv;
105 } // finish method getTestEnvironment