2003-01-27 17:20:08 +00:00
|
|
|
/*************************************************************************
|
|
|
|
*
|
2005-09-09 03:23:50 +00:00
|
|
|
* OpenOffice.org - a multi-platform office productivity suite
|
2003-01-27 17:20:08 +00:00
|
|
|
*
|
2005-09-09 03:23:50 +00:00
|
|
|
* $RCSfile: AccessibleRadioButton.java,v $
|
2003-01-27 17:20:08 +00:00
|
|
|
*
|
2005-09-09 03:23:50 +00:00
|
|
|
* $Revision: 1.12 $
|
2003-01-27 17:20:08 +00:00
|
|
|
*
|
2005-09-09 03:23:50 +00:00
|
|
|
* last change: $Author: rt $ $Date: 2005-09-09 04:23:50 $
|
2003-01-27 17:20:08 +00:00
|
|
|
*
|
2005-09-09 03:23:50 +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:23:50 +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:23:50 +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:23:50 +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:23:50 +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:01:22 +00:00
|
|
|
import com.sun.star.accessibility.AccessibleRole;
|
|
|
|
import com.sun.star.accessibility.XAccessible;
|
|
|
|
import com.sun.star.accessibility.XAccessibleAction;
|
|
|
|
import com.sun.star.accessibility.XAccessibleComponent;
|
|
|
|
import com.sun.star.accessibility.XAccessibleContext;
|
|
|
|
import com.sun.star.accessibility.XAccessibleSelection;
|
|
|
|
import com.sun.star.accessibility.XAccessibleValue;
|
|
|
|
import com.sun.star.awt.XExtendedToolkit;
|
2003-01-27 17:20:08 +00:00
|
|
|
import com.sun.star.awt.XWindow;
|
|
|
|
import com.sun.star.beans.PropertyValue;
|
|
|
|
import com.sun.star.frame.XController;
|
|
|
|
import com.sun.star.frame.XDesktop;
|
|
|
|
import com.sun.star.frame.XDispatch;
|
|
|
|
import com.sun.star.frame.XDispatchProvider;
|
|
|
|
import com.sun.star.frame.XModel;
|
2003-05-28 09:03:37 +00:00
|
|
|
import com.sun.star.lang.XMultiServiceFactory;
|
2003-09-08 12:01:22 +00:00
|
|
|
import com.sun.star.text.XTextDocument;
|
2003-01-27 17:20:08 +00:00
|
|
|
import com.sun.star.uno.UnoRuntime;
|
|
|
|
import com.sun.star.uno.XInterface;
|
|
|
|
import com.sun.star.util.URL;
|
2003-09-08 12:01:22 +00:00
|
|
|
import com.sun.star.util.XCloseable;
|
2003-01-27 17:20:08 +00:00
|
|
|
import com.sun.star.util.XURLTransformer;
|
|
|
|
|
2004-01-05 19:38:00 +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:39:44 +00:00
|
|
|
* ::com::sun::star::accessibility::XAccessibleContext</code></li>
|
2003-01-27 17:20:08 +00:00
|
|
|
* <li><code>
|
2005-03-01 19:39:44 +00:00
|
|
|
* ::com::sun::star::accessibility::XAccessibleEventBroadcaster
|
2003-01-27 17:20:08 +00:00
|
|
|
* </code></li>
|
|
|
|
* <li><code>
|
2005-03-01 19:39:44 +00:00
|
|
|
* ::com::sun::star::accessibility::XAccessibleComponent</code></li>
|
2003-01-27 17:20:08 +00:00
|
|
|
* <li><code>
|
2005-03-01 19:39:44 +00:00
|
|
|
* ::com::sun::star::accessibility::XAccessibleExtendedComponent
|
2003-01-27 17:20:08 +00:00
|
|
|
* </code></li>
|
|
|
|
* <li><code>
|
2005-03-01 19:39:44 +00:00
|
|
|
* ::com::sun::star::accessibility::XAccessibleValue</code></li>
|
2003-01-27 17:20:08 +00:00
|
|
|
* <li><code>
|
2005-03-01 19:39:44 +00:00
|
|
|
* ::com::sun::star::accessibility::XAccessibleText</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
|
|
|
|
* @see com.sun.star.accessibility.XAccessibleValue
|
|
|
|
* @see com.sun.star.accessibility.XAccessibleText
|
2003-01-27 17:20:08 +00:00
|
|
|
* @see ifc.accessibility._XAccessibleEventBroadcaster
|
|
|
|
* @see ifc.accessibility._XAccessibleContext
|
|
|
|
* @see ifc.accessibility._XAccessibleComponent
|
|
|
|
* @see ifc.accessibility.XAccessibleExtendedComponent
|
|
|
|
* @see ifc.accessibility.XAccessibleValue
|
|
|
|
* @see ifc.accessibility.XAccessibleText
|
|
|
|
*/
|
|
|
|
public class AccessibleRadioButton extends TestCase {
|
|
|
|
XDesktop the_Desk;
|
|
|
|
XTextDocument xTextDoc;
|
|
|
|
XAccessibleAction accCloseButton = null;
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Creates the Desktop service (<code>com.sun.star.frame.Desktop</code>).
|
|
|
|
*/
|
|
|
|
protected void initialize(TestParameters Param, PrintWriter log) {
|
2004-01-05 19:38:00 +00:00
|
|
|
the_Desk = (XDesktop) UnoRuntime.queryInterface(XDesktop.class,
|
|
|
|
DesktopTools.createDesktop(
|
|
|
|
(XMultiServiceFactory) Param.getMSF()));
|
2003-01-27 17:20:08 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Closes a Hyperlink dialog, disposes the document, if exists, created in
|
|
|
|
* <code>createTestEnvironment</code> method.
|
|
|
|
*/
|
2004-01-05 19:38:00 +00:00
|
|
|
protected void cleanup(TestParameters Param, PrintWriter log) {
|
2003-01-27 17:20:08 +00:00
|
|
|
try {
|
|
|
|
if (accCloseButton != null) {
|
|
|
|
log.println("closing HyperlinkDialog");
|
|
|
|
accCloseButton.doAccessibleAction(0);
|
|
|
|
}
|
2004-01-05 19:38:00 +00:00
|
|
|
} catch (com.sun.star.lang.IndexOutOfBoundsException e) {
|
2003-01-27 17:20:08 +00:00
|
|
|
e.printStackTrace(log);
|
2004-01-05 19:38:00 +00:00
|
|
|
} catch (com.sun.star.lang.DisposedException de) {
|
2003-03-31 12:23:39 +00:00
|
|
|
log.println("Already disposed");
|
2003-01-27 17:20:08 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
log.println("disposing xTextDoc");
|
|
|
|
|
|
|
|
if (xTextDoc != null) {
|
2003-09-08 12:01:22 +00:00
|
|
|
closeDoc();
|
2003-01-27 17:20:08 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Creates a text document, opens a hypelink dialog, selects a first item
|
|
|
|
* in IconChoiceCtrl.
|
|
|
|
* Then obtains an accessible object with
|
|
|
|
* the role <code>AccessibleRole.RADIOBUTTON</code> with the name <code>
|
|
|
|
* "Internet"</code>.
|
|
|
|
* Object relations created :
|
|
|
|
* <ul>
|
|
|
|
* <li> <code>'EventProducer'</code> for
|
|
|
|
* {@link ifc.accessibility._XAccessibleEventBroadcaster}:
|
|
|
|
* grabs focus </li>
|
|
|
|
* <li> <code>'XAccessibleText.Text'</code> for
|
|
|
|
* {@link ifc.accessibility._XAccessibleText}:
|
|
|
|
* the text of the component </li>
|
|
|
|
* <li> <code>'XAccessibleValue.anotherFromGroup'</code> for
|
|
|
|
* {@link ifc.accessibility._XAccessibleValue}:
|
|
|
|
* <code>'FTP'</code> button </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
|
|
|
|
* @see ifc.accessibility._XAccessibleText
|
2003-04-28 10:27:42 +00:00
|
|
|
* @see com.sun.star.accessibility.XAccessibleEventBroadcaster
|
|
|
|
* @see com.sun.star.accessibility.XAccessibleText
|
2003-01-27 17:20:08 +00:00
|
|
|
*/
|
2004-01-05 19:38:00 +00:00
|
|
|
protected TestEnvironment createTestEnvironment(TestParameters tParam,
|
|
|
|
PrintWriter log) {
|
|
|
|
log.println("creating a test environment");
|
2003-01-27 17:20:08 +00:00
|
|
|
|
|
|
|
try {
|
|
|
|
if (accCloseButton != null) {
|
|
|
|
log.println("closing HyperlinkDialog");
|
|
|
|
accCloseButton.doAccessibleAction(0);
|
|
|
|
}
|
2004-01-05 19:38:00 +00:00
|
|
|
} catch (com.sun.star.lang.IndexOutOfBoundsException e) {
|
2003-01-27 17:20:08 +00:00
|
|
|
e.printStackTrace(log);
|
2004-01-05 19:38:00 +00:00
|
|
|
} catch (com.sun.star.lang.DisposedException de) {
|
2003-03-31 12:23:39 +00:00
|
|
|
log.println("already disposed");
|
2003-01-27 17:20:08 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
if (xTextDoc != null) {
|
|
|
|
log.println("dispose a text document");
|
2003-09-08 12:01:22 +00:00
|
|
|
closeDoc();
|
2003-01-27 17:20:08 +00:00
|
|
|
xTextDoc = null;
|
|
|
|
}
|
|
|
|
|
|
|
|
// get a soffice factory object
|
2004-01-05 19:38:00 +00:00
|
|
|
SOfficeFactory SOF = SOfficeFactory.getFactory(
|
|
|
|
(XMultiServiceFactory) tParam.getMSF());
|
2003-01-27 17:20:08 +00:00
|
|
|
|
|
|
|
try {
|
2004-01-05 19:38:00 +00:00
|
|
|
log.println("creating a text document");
|
2003-01-27 17:20:08 +00:00
|
|
|
xTextDoc = SOF.createTextDoc(null);
|
2004-01-05 19:38:00 +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:38:00 +00:00
|
|
|
e.printStackTrace(log);
|
|
|
|
throw new StatusException("Couldn't create document", e);
|
2003-01-27 17:20:08 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
shortWait();
|
|
|
|
|
2004-01-05 19:38:00 +00:00
|
|
|
XModel aModel1 = (XModel) UnoRuntime.queryInterface(XModel.class,
|
|
|
|
xTextDoc);
|
2003-01-27 17:20:08 +00:00
|
|
|
|
|
|
|
XController secondController = aModel1.getCurrentController();
|
|
|
|
|
2004-01-05 19:38:00 +00:00
|
|
|
XDispatchProvider aProv = (XDispatchProvider) UnoRuntime.queryInterface(
|
|
|
|
XDispatchProvider.class,
|
|
|
|
secondController);
|
2003-01-27 17:20:08 +00:00
|
|
|
|
|
|
|
XURLTransformer urlTransf = null;
|
|
|
|
|
|
|
|
try {
|
2004-01-05 19:38:00 +00:00
|
|
|
XInterface transf = (XInterface) ((XMultiServiceFactory) tParam.getMSF()).createInstance(
|
|
|
|
"com.sun.star.util.URLTransformer");
|
|
|
|
urlTransf = (XURLTransformer) UnoRuntime.queryInterface(
|
|
|
|
XURLTransformer.class, transf);
|
2003-01-27 17:20:08 +00:00
|
|
|
} catch (com.sun.star.uno.Exception e) {
|
|
|
|
e.printStackTrace(log);
|
2004-01-05 19:38:00 +00:00
|
|
|
throw new StatusException("Couldn't create URLTransformer", e);
|
2003-01-27 17:20:08 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
XDispatch getting = null;
|
2004-01-05 19:38:00 +00:00
|
|
|
log.println("opening HyperlinkDialog");
|
|
|
|
|
2003-01-27 17:20:08 +00:00
|
|
|
URL[] url = new URL[1];
|
|
|
|
url[0] = new URL();
|
|
|
|
url[0].Complete = ".uno:HyperlinkDialog";
|
|
|
|
urlTransf.parseStrict(url);
|
|
|
|
getting = aProv.queryDispatch(url[0], "", 0);
|
2004-01-05 19:38:00 +00:00
|
|
|
|
2003-01-27 17:20:08 +00:00
|
|
|
PropertyValue[] noArgs = new PropertyValue[0];
|
|
|
|
getting.dispatch(url[0], noArgs);
|
|
|
|
|
|
|
|
shortWait();
|
|
|
|
|
|
|
|
XInterface oObj = null;
|
2004-01-05 19:38:00 +00:00
|
|
|
|
2003-01-27 17:20:08 +00:00
|
|
|
try {
|
2004-01-05 19:38:00 +00:00
|
|
|
oObj = (XInterface) ((XMultiServiceFactory) tParam.getMSF()).createInstance(
|
|
|
|
"com.sun.star.awt.Toolkit");
|
2003-01-27 17:20:08 +00:00
|
|
|
} catch (com.sun.star.uno.Exception e) {
|
|
|
|
log.println("Couldn't get toolkit");
|
|
|
|
e.printStackTrace(log);
|
2004-01-05 19:38:00 +00:00
|
|
|
throw new StatusException("Couldn't get toolkit", e);
|
2003-01-27 17:20:08 +00:00
|
|
|
}
|
|
|
|
|
2004-01-05 19:38:00 +00:00
|
|
|
XExtendedToolkit tk = (XExtendedToolkit) UnoRuntime.queryInterface(
|
|
|
|
XExtendedToolkit.class, oObj);
|
2003-01-27 17:20:08 +00:00
|
|
|
|
|
|
|
AccessibilityTools at = new AccessibilityTools();
|
|
|
|
|
|
|
|
shortWait();
|
|
|
|
|
2004-01-05 19:38:00 +00:00
|
|
|
XWindow xWindow = (XWindow) UnoRuntime.queryInterface(XWindow.class,
|
|
|
|
tk.getActiveTopWindow());
|
2003-01-27 17:20:08 +00:00
|
|
|
|
|
|
|
XAccessible xRoot = at.getAccessibleObject(xWindow);
|
|
|
|
|
|
|
|
XAccessibleContext iconChoiceCtrl = at.getAccessibleObjectForRole(
|
2004-01-05 19:38:00 +00:00
|
|
|
xRoot, AccessibleRole.TREE,
|
|
|
|
"IconChoiceControl");
|
2003-01-27 17:20:08 +00:00
|
|
|
|
2004-01-05 19:38:00 +00:00
|
|
|
XAccessibleSelection sel = (XAccessibleSelection) UnoRuntime.queryInterface(
|
|
|
|
XAccessibleSelection.class,
|
|
|
|
iconChoiceCtrl);
|
2003-01-27 17:20:08 +00:00
|
|
|
|
|
|
|
try {
|
|
|
|
sel.selectAccessibleChild(0);
|
2004-01-05 19:38:00 +00:00
|
|
|
} catch (com.sun.star.lang.IndexOutOfBoundsException e) {
|
2003-01-27 17:20:08 +00:00
|
|
|
log.println("Unexpected exception");
|
|
|
|
e.printStackTrace(log);
|
|
|
|
}
|
|
|
|
|
|
|
|
oObj = at.getAccessibleObjectForRole(xRoot,
|
2004-01-05 19:38:00 +00:00
|
|
|
AccessibleRole.RADIO_BUTTON,
|
|
|
|
"Web");
|
2003-01-27 17:20:08 +00:00
|
|
|
|
|
|
|
XAccessibleContext anotherButton = at.getAccessibleObjectForRole(xRoot,
|
2004-01-05 19:38:00 +00:00
|
|
|
AccessibleRole.RADIO_BUTTON,
|
|
|
|
"FTP");
|
2003-01-27 17:20:08 +00:00
|
|
|
|
|
|
|
XAccessibleContext closeButton = at.getAccessibleObjectForRole(xRoot,
|
2004-01-05 19:38:00 +00:00
|
|
|
AccessibleRole.PUSH_BUTTON,
|
|
|
|
"Close");
|
2003-01-27 17:20:08 +00:00
|
|
|
|
2004-01-05 19:38:00 +00:00
|
|
|
accCloseButton = (XAccessibleAction) UnoRuntime.queryInterface(
|
|
|
|
XAccessibleAction.class, closeButton);
|
2003-01-27 17:20:08 +00:00
|
|
|
|
2004-01-05 19:38:00 +00:00
|
|
|
log.println("ImplementationName: " + util.utils.getImplName(oObj));
|
2003-01-27 17:20:08 +00:00
|
|
|
|
|
|
|
TestEnvironment tEnv = new TestEnvironment(oObj);
|
|
|
|
|
2003-03-31 12:23:39 +00:00
|
|
|
tEnv.addObjRelation("EditOnly",
|
2004-01-05 19:38:00 +00:00
|
|
|
"This method isn't supported in this component");
|
2003-03-31 12:23:39 +00:00
|
|
|
|
2003-05-22 12:32:15 +00:00
|
|
|
tEnv.addObjRelation("LimitedBounds", "yes");
|
|
|
|
|
2004-01-05 19:38:00 +00:00
|
|
|
final XAccessibleComponent acomp = (XAccessibleComponent) UnoRuntime.queryInterface(
|
|
|
|
XAccessibleComponent.class,
|
|
|
|
oObj);
|
2003-01-27 17:20:08 +00:00
|
|
|
|
|
|
|
tEnv.addObjRelation("EventProducer",
|
2004-01-05 19:38:00 +00:00
|
|
|
new ifc.accessibility._XAccessibleEventBroadcaster.EventProducer() {
|
|
|
|
public void fireEvent() {
|
|
|
|
acomp.grabFocus();
|
|
|
|
}
|
|
|
|
});
|
2003-01-27 17:20:08 +00:00
|
|
|
|
2003-10-06 12:34:13 +00:00
|
|
|
tEnv.addObjRelation("XAccessibleText.Text", "Web");
|
2003-01-27 17:20:08 +00:00
|
|
|
|
2004-01-05 19:38:00 +00:00
|
|
|
tEnv.addObjRelation("EditOnly",
|
|
|
|
"Can't change or select Text in AccessibleRadioButton");
|
2003-03-31 12:23:39 +00:00
|
|
|
|
2004-01-05 19:38:00 +00:00
|
|
|
XAccessibleValue anotherButtonValue = (XAccessibleValue) UnoRuntime.queryInterface(
|
|
|
|
XAccessibleValue.class,
|
|
|
|
anotherButton);
|
2003-01-27 17:20:08 +00:00
|
|
|
|
|
|
|
tEnv.addObjRelation("XAccessibleValue.anotherFromGroup",
|
2004-01-05 19:38:00 +00:00
|
|
|
anotherButtonValue);
|
2003-01-27 17:20:08 +00:00
|
|
|
|
|
|
|
return tEnv;
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Sleeps for 0.5 sec. to allow StarOffice to react on <code>
|
|
|
|
* reset</code> call.
|
|
|
|
*/
|
|
|
|
private void shortWait() {
|
|
|
|
try {
|
2004-01-05 19:38:00 +00:00
|
|
|
Thread.currentThread().sleep(2000);
|
2003-01-27 17:20:08 +00:00
|
|
|
} catch (InterruptedException e) {
|
2004-01-05 19:38:00 +00:00
|
|
|
System.out.println("While waiting :" + e);
|
2003-01-27 17:20:08 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2003-09-08 12:01:22 +00:00
|
|
|
protected void closeDoc() {
|
2004-01-05 19:38:00 +00:00
|
|
|
util.DesktopTools.closeDoc(xTextDoc);
|
2003-09-08 12:01:22 +00:00
|
|
|
}
|
|
|
|
}
|