2003-01-27 17:20:08 +00:00
|
|
|
/*************************************************************************
|
|
|
|
*
|
2005-09-09 03:27:31 +00:00
|
|
|
* OpenOffice.org - a multi-platform office productivity suite
|
2003-01-27 17:20:08 +00:00
|
|
|
*
|
2005-09-09 03:27:31 +00:00
|
|
|
* $RCSfile: AccessibleToolBox.java,v $
|
2003-01-27 17:20:08 +00:00
|
|
|
*
|
2005-09-09 03:27:31 +00:00
|
|
|
* $Revision: 1.11 $
|
2003-01-27 17:20:08 +00:00
|
|
|
*
|
2005-09-09 03:27:31 +00:00
|
|
|
* last change: $Author: rt $ $Date: 2005-09-09 04:27:31 $
|
2003-01-27 17:20:08 +00:00
|
|
|
*
|
2005-09-09 03:27:31 +00:00
|
|
|
* The Contents of this file are made available subject to
|
|
|
|
* the terms of GNU Lesser General Public License Version 2.1.
|
2003-01-27 17:20:08 +00:00
|
|
|
*
|
|
|
|
*
|
2005-09-09 03:27:31 +00:00
|
|
|
* GNU Lesser General Public License Version 2.1
|
|
|
|
* =============================================
|
|
|
|
* Copyright 2005 by Sun Microsystems, Inc.
|
|
|
|
* 901 San Antonio Road, Palo Alto, CA 94303, USA
|
2003-01-27 17:20:08 +00:00
|
|
|
*
|
2005-09-09 03:27:31 +00:00
|
|
|
* This library is free software; you can redistribute it and/or
|
|
|
|
* modify it under the terms of the GNU Lesser General Public
|
|
|
|
* License version 2.1, as published by the Free Software Foundation.
|
2003-01-27 17:20:08 +00:00
|
|
|
*
|
2005-09-09 03:27:31 +00:00
|
|
|
* This library is distributed in the hope that it will be useful,
|
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
|
|
|
* Lesser General Public License for more details.
|
2003-01-27 17:20:08 +00:00
|
|
|
*
|
2005-09-09 03:27:31 +00:00
|
|
|
* You should have received a copy of the GNU Lesser General Public
|
|
|
|
* License along with this library; if not, write to the Free Software
|
|
|
|
* Foundation, Inc., 59 Temple Place, Suite 330, Boston,
|
|
|
|
* MA 02111-1307 USA
|
2003-01-27 17:20:08 +00:00
|
|
|
*
|
|
|
|
************************************************************************/
|
|
|
|
package mod._toolkit;
|
|
|
|
|
2003-09-08 12:02:25 +00:00
|
|
|
import com.sun.star.accessibility.AccessibleRole;
|
|
|
|
import com.sun.star.accessibility.XAccessible;
|
|
|
|
import com.sun.star.accessibility.XAccessibleAction;
|
|
|
|
import com.sun.star.awt.XWindow;
|
|
|
|
import com.sun.star.frame.XDesktop;
|
|
|
|
import com.sun.star.frame.XModel;
|
|
|
|
import com.sun.star.lang.XMultiServiceFactory;
|
|
|
|
import com.sun.star.text.XTextDocument;
|
|
|
|
import com.sun.star.uno.UnoRuntime;
|
|
|
|
import com.sun.star.uno.XInterface;
|
|
|
|
|
2004-01-05 19:40:22 +00:00
|
|
|
import java.io.PrintWriter;
|
|
|
|
|
|
|
|
import lib.StatusException;
|
|
|
|
import lib.TestCase;
|
|
|
|
import lib.TestEnvironment;
|
|
|
|
import lib.TestParameters;
|
|
|
|
|
|
|
|
import util.AccessibilityTools;
|
|
|
|
import util.DesktopTools;
|
|
|
|
import util.SOfficeFactory;
|
|
|
|
|
|
|
|
|
2003-01-27 17:20:08 +00:00
|
|
|
/**
|
|
|
|
* Test for object that implements the following interfaces :
|
|
|
|
* <ul>
|
|
|
|
* <li><code>
|
2005-03-01 19:41:11 +00:00
|
|
|
* ::com::sun::star::accessibility::XAccessibleContext</code></li>
|
2003-01-27 17:20:08 +00:00
|
|
|
* <li><code>
|
2005-03-01 19:41:11 +00:00
|
|
|
* ::com::sun::star::accessibility::XAccessibleEventBroadcaster
|
2003-01-27 17:20:08 +00:00
|
|
|
* </code></li>
|
|
|
|
* <li><code>
|
2005-03-01 19:41:11 +00:00
|
|
|
* ::com::sun::star::accessibility::XAccessibleComponent</code></li>
|
2003-01-27 17:20:08 +00:00
|
|
|
* <li><code>
|
2005-03-01 19:41:11 +00:00
|
|
|
* ::com::sun::star::accessibility::XAccessibleExtendedComponent</code></li>
|
2003-01-27 17:20:08 +00:00
|
|
|
* </ul> <p>
|
|
|
|
*
|
2003-04-28 10:27:42 +00:00
|
|
|
* @see com.sun.star.accessibility.XAccessibleEventBroadcaster
|
|
|
|
* @see com.sun.star.accessibility.XAccessibleContext
|
|
|
|
* @see com.sun.star.accessibility.XAccessibleComponent
|
|
|
|
* @see com.sun.star.accessibility.XAccessibleExtendedComponent
|
2003-01-27 17:20:08 +00:00
|
|
|
* @see ifc.accessibility._XAccessibleEventBroadcaster
|
|
|
|
* @see ifc.accessibility._XAccessibleContext
|
|
|
|
* @see ifc.accessibility._XAccessibleComponent
|
|
|
|
* @see ifc.accessibility.XAccessibleExtendedComponent
|
|
|
|
*/
|
|
|
|
public class AccessibleToolBox extends TestCase {
|
|
|
|
XDesktop the_Desk;
|
|
|
|
XTextDocument xTextDoc;
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Creates the Desktop service (<code>com.sun.star.frame.Desktop</code>).
|
|
|
|
*/
|
|
|
|
protected void initialize(TestParameters Param, PrintWriter log) {
|
2004-01-05 19:40:22 +00:00
|
|
|
the_Desk = (XDesktop) UnoRuntime.queryInterface(XDesktop.class,
|
|
|
|
DesktopTools.createDesktop(
|
|
|
|
(XMultiServiceFactory) Param.getMSF()));
|
2003-01-27 17:20:08 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Disposes the document, if exists, created in
|
|
|
|
* <code>createTestEnvironment</code> method.
|
|
|
|
*/
|
2004-01-05 19:40:22 +00:00
|
|
|
protected void cleanup(TestParameters Param, PrintWriter log) {
|
2003-01-27 17:20:08 +00:00
|
|
|
log.println("disposing xTextDoc");
|
|
|
|
|
|
|
|
if (xTextDoc != null) {
|
2004-01-05 19:40:22 +00:00
|
|
|
util.DesktopTools.closeDoc(xTextDoc);
|
|
|
|
;
|
2003-01-27 17:20:08 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Creates a text document.
|
|
|
|
* Then obtains an accessible object with
|
|
|
|
* the role <code>AccessibleRole.TOOLBAR</code>.
|
|
|
|
* Object relations created :
|
|
|
|
* <ul>
|
|
|
|
* <li> <code>'EventProducer'</code> for
|
|
|
|
* {@link ifc.accessibility._XAccessibleEventBroadcaster}:
|
|
|
|
* grabs focus
|
|
|
|
* </li>
|
|
|
|
* </ul>
|
|
|
|
*
|
|
|
|
* @param tParam test parameters
|
|
|
|
* @param log writer to log information while testing
|
|
|
|
*
|
|
|
|
* @see com.sun.star.awt.Toolkit
|
2003-04-28 10:27:42 +00:00
|
|
|
* @see com.sun.star.accessibility.AccessibleRole
|
2003-01-27 17:20:08 +00:00
|
|
|
* @see ifc.accessibility._XAccessibleEventBroadcaster
|
2003-04-28 10:27:42 +00:00
|
|
|
* @see com.sun.star.accessibility.XAccessibleEventBroadcaster
|
2003-01-27 17:20:08 +00:00
|
|
|
*/
|
2004-01-05 19:40:22 +00:00
|
|
|
protected TestEnvironment createTestEnvironment(TestParameters tParam,
|
|
|
|
PrintWriter log) {
|
|
|
|
log.println("creating a test environment");
|
2003-01-27 17:20:08 +00:00
|
|
|
|
2004-01-05 19:40:22 +00:00
|
|
|
if (xTextDoc != null) {
|
|
|
|
util.DesktopTools.closeDoc(xTextDoc);
|
|
|
|
}
|
2003-01-27 17:20:08 +00:00
|
|
|
|
2004-01-05 19:40:22 +00:00
|
|
|
;
|
2003-01-27 17:20:08 +00:00
|
|
|
|
|
|
|
// get a soffice factory object
|
2004-01-05 19:40:22 +00:00
|
|
|
SOfficeFactory SOF = SOfficeFactory.getFactory(
|
|
|
|
(XMultiServiceFactory) tParam.getMSF());
|
2003-01-27 17:20:08 +00:00
|
|
|
|
|
|
|
try {
|
2004-01-05 19:40:22 +00:00
|
|
|
log.println("creating a text document");
|
2003-01-27 17:20:08 +00:00
|
|
|
xTextDoc = SOF.createTextDoc(null);
|
2004-01-05 19:40:22 +00:00
|
|
|
} catch (com.sun.star.uno.Exception e) {
|
2003-01-27 17:20:08 +00:00
|
|
|
// Some exception occures.FAILED
|
2004-01-05 19:40:22 +00:00
|
|
|
e.printStackTrace(log);
|
|
|
|
throw new StatusException("Couldn't create document", e);
|
2003-01-27 17:20:08 +00:00
|
|
|
}
|
|
|
|
|
2004-01-05 19:40:22 +00:00
|
|
|
XModel aModel = (XModel) UnoRuntime.queryInterface(XModel.class,
|
|
|
|
xTextDoc);
|
2003-01-27 17:20:08 +00:00
|
|
|
|
|
|
|
XInterface oObj = null;
|
|
|
|
|
|
|
|
AccessibilityTools at = new AccessibilityTools();
|
|
|
|
|
2004-01-05 19:40:22 +00:00
|
|
|
XWindow xWindow = at.getCurrentWindow(
|
|
|
|
(XMultiServiceFactory) tParam.getMSF(),
|
|
|
|
aModel);
|
2003-01-27 17:20:08 +00:00
|
|
|
|
|
|
|
XAccessible xRoot = at.getAccessibleObject(xWindow);
|
|
|
|
|
|
|
|
|
2004-11-02 11:16:24 +00:00
|
|
|
at.printAccessibleTree(log, xRoot, tParam.getBool(util.PropertyName.DEBUG_IS_ACTIVE));
|
2004-01-05 19:40:22 +00:00
|
|
|
oObj = at.getAccessibleObjectForRole(xRoot, AccessibleRole.TOOL_BAR);
|
2003-01-27 17:20:08 +00:00
|
|
|
|
2004-01-05 19:40:22 +00:00
|
|
|
log.println("ImplementationName: " + util.utils.getImplName(oObj));
|
2003-01-27 17:20:08 +00:00
|
|
|
|
|
|
|
TestEnvironment tEnv = new TestEnvironment(oObj);
|
|
|
|
|
2003-05-22 12:32:43 +00:00
|
|
|
tEnv.addObjRelation("LimitedBounds", "yes");
|
|
|
|
|
2003-09-08 12:02:25 +00:00
|
|
|
XAccessible acc = at.getAccessibleObject(oObj);
|
|
|
|
XAccessible child = null;
|
2004-01-05 19:40:22 +00:00
|
|
|
|
2003-09-08 12:02:25 +00:00
|
|
|
try {
|
|
|
|
child = acc.getAccessibleContext().getAccessibleChild(0);
|
|
|
|
} catch (com.sun.star.lang.IndexOutOfBoundsException e) {
|
|
|
|
}
|
|
|
|
|
|
|
|
util.dbg.printInterfaces(child);
|
|
|
|
|
2004-01-05 19:40:22 +00:00
|
|
|
final XAccessibleAction action = (XAccessibleAction) UnoRuntime.queryInterface(
|
|
|
|
XAccessibleAction.class,
|
|
|
|
child);
|
2003-09-08 12:02:25 +00:00
|
|
|
|
2003-01-27 17:20:08 +00:00
|
|
|
tEnv.addObjRelation("EventProducer",
|
2004-01-05 19:40:22 +00:00
|
|
|
new ifc.accessibility._XAccessibleEventBroadcaster.EventProducer() {
|
|
|
|
public void fireEvent() {
|
|
|
|
try {
|
|
|
|
action.doAccessibleAction(0);
|
|
|
|
} catch (com.sun.star.lang.IndexOutOfBoundsException e) {
|
|
|
|
System.out.println("Couldn't fire event");
|
2003-01-27 17:20:08 +00:00
|
|
|
}
|
2004-01-05 19:40:22 +00:00
|
|
|
}
|
|
|
|
});
|
2003-01-27 17:20:08 +00:00
|
|
|
|
|
|
|
return tEnv;
|
|
|
|
}
|
2003-09-08 12:02:25 +00:00
|
|
|
}
|