2003-01-27 17:20:08 +00:00
|
|
|
/*************************************************************************
|
|
|
|
*
|
2008-04-10 17:59:16 +00:00
|
|
|
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
2003-01-27 17:20:08 +00:00
|
|
|
*
|
2008-04-10 17:59:16 +00:00
|
|
|
* Copyright 2008 by Sun Microsystems, Inc.
|
2003-01-27 17:20:08 +00:00
|
|
|
*
|
2008-04-10 17:59:16 +00:00
|
|
|
* OpenOffice.org - a multi-platform office productivity suite
|
2003-01-27 17:20:08 +00:00
|
|
|
*
|
2008-04-10 17:59:16 +00:00
|
|
|
* $RCSfile: AccessibleTabBar.java,v $
|
|
|
|
* $Revision: 1.8 $
|
2003-01-27 17:20:08 +00:00
|
|
|
*
|
2008-04-10 17:59:16 +00:00
|
|
|
* This file is part of OpenOffice.org.
|
2003-01-27 17:20:08 +00:00
|
|
|
*
|
2008-04-10 17:59:16 +00:00
|
|
|
* OpenOffice.org is free software: you can redistribute it and/or modify
|
|
|
|
* it under the terms of the GNU Lesser General Public License version 3
|
|
|
|
* only, as published by the Free Software Foundation.
|
2003-01-27 17:20:08 +00:00
|
|
|
*
|
2008-04-10 17:59:16 +00:00
|
|
|
* OpenOffice.org 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 version 3 for more details
|
|
|
|
* (a copy is included in the LICENSE file that accompanied this code).
|
2003-01-27 17:20:08 +00:00
|
|
|
*
|
2008-04-10 17:59:16 +00:00
|
|
|
* You should have received a copy of the GNU Lesser General Public License
|
|
|
|
* version 3 along with OpenOffice.org. If not, see
|
|
|
|
* <http://www.openoffice.org/license.html>
|
|
|
|
* for a copy of the LGPLv3 License.
|
2003-01-27 17:20:08 +00:00
|
|
|
*
|
|
|
|
************************************************************************/
|
|
|
|
package mod._svtools;
|
|
|
|
|
|
|
|
import java.io.PrintWriter;
|
|
|
|
|
|
|
|
import lib.StatusException;
|
|
|
|
import lib.TestCase;
|
|
|
|
import lib.TestEnvironment;
|
|
|
|
import lib.TestParameters;
|
|
|
|
import util.AccessibilityTools;
|
|
|
|
import util.SOfficeFactory;
|
|
|
|
|
2003-09-08 11:34:03 +00:00
|
|
|
import com.sun.star.accessibility.AccessibleRole;
|
|
|
|
import com.sun.star.accessibility.XAccessible;
|
|
|
|
import com.sun.star.awt.PosSize;
|
|
|
|
import com.sun.star.awt.XExtendedToolkit;
|
|
|
|
import com.sun.star.awt.XWindow;
|
|
|
|
import com.sun.star.lang.XComponent;
|
|
|
|
import com.sun.star.lang.XMultiServiceFactory;
|
|
|
|
import com.sun.star.uno.UnoRuntime;
|
|
|
|
import com.sun.star.uno.XInterface;
|
|
|
|
import com.sun.star.util.XCloseable;
|
2003-01-27 17:20:08 +00:00
|
|
|
|
|
|
|
|
2003-09-08 11:34:03 +00:00
|
|
|
public class AccessibleTabBar extends TestCase {
|
2003-01-27 17:20:08 +00:00
|
|
|
XComponent xDoc;
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Disposes the document, if exists, created in
|
|
|
|
* <code>createTestEnvironment</code> method.
|
|
|
|
*/
|
2003-09-08 11:34:03 +00:00
|
|
|
protected void cleanup(TestParameters Param, PrintWriter log) {
|
2003-01-27 17:20:08 +00:00
|
|
|
log.println("disposing xCalcDoc");
|
|
|
|
|
|
|
|
if (xDoc != null) {
|
2003-09-08 11:34:03 +00:00
|
|
|
closeDoc(xDoc);
|
2003-01-27 17:20:08 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Creates a spreadsheet document. Then obtains an accessible object with
|
|
|
|
* the role <code>AccessibleRole.PAGETAB</code>.
|
|
|
|
* Object relations created :
|
|
|
|
* <ul>
|
|
|
|
* <li> <code>'EventProducer'</code> for
|
|
|
|
* {@link ifc.accessibility._XAccessibleEventBroadcaster}:
|
|
|
|
* </li>
|
|
|
|
* </ul>
|
|
|
|
*
|
|
|
|
* @param tParam test parameters
|
|
|
|
* @param log writer to log information while testing
|
|
|
|
*
|
|
|
|
* @see com.sun.star.awt.Toolkit
|
2003-04-28 11:31:17 +00:00
|
|
|
* @see com.sun.star.accessibility.AccessibleRole
|
2003-01-27 17:20:08 +00:00
|
|
|
* @see ifc.accessibility._XAccessibleEventBroadcaster
|
2003-04-28 11:31:17 +00:00
|
|
|
* @see com.sun.star.accessibility.XAccessibleEventBroadcaster
|
2003-01-27 17:20:08 +00:00
|
|
|
*/
|
|
|
|
protected TestEnvironment createTestEnvironment(TestParameters tParam,
|
2003-09-08 11:34:03 +00:00
|
|
|
PrintWriter log) {
|
|
|
|
log.println("creating a test environment");
|
2003-01-27 17:20:08 +00:00
|
|
|
|
2003-09-08 11:34:03 +00:00
|
|
|
if (xDoc != null) {
|
|
|
|
closeDoc(xDoc);
|
|
|
|
}
|
2003-01-27 17:20:08 +00:00
|
|
|
|
2003-09-08 11:34:03 +00:00
|
|
|
XMultiServiceFactory msf = (XMultiServiceFactory) tParam.getMSF();
|
2003-01-27 17:20:08 +00:00
|
|
|
|
|
|
|
// get a soffice factory object
|
2003-09-08 11:34:03 +00:00
|
|
|
SOfficeFactory SOF = SOfficeFactory.getFactory(msf);
|
2003-01-27 17:20:08 +00:00
|
|
|
|
|
|
|
try {
|
2005-02-24 16:57:03 +00:00
|
|
|
log.println("creating a calc document");
|
2003-09-08 11:34:03 +00:00
|
|
|
xDoc = (XComponent) UnoRuntime.queryInterface(XComponent.class,
|
|
|
|
SOF.createCalcDoc(
|
|
|
|
null));
|
|
|
|
} catch (com.sun.star.uno.Exception e) {
|
2003-01-27 17:20:08 +00:00
|
|
|
// Some exception occures.FAILED
|
2003-09-08 11:34:03 +00:00
|
|
|
e.printStackTrace(log);
|
|
|
|
throw new StatusException("Couldn't create document", e);
|
2003-01-27 17:20:08 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
shortWait();
|
|
|
|
|
|
|
|
XInterface oObj = null;
|
|
|
|
|
|
|
|
try {
|
2003-09-08 11:34:03 +00:00
|
|
|
oObj = (XInterface) msf.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);
|
2003-09-08 11:34:03 +00:00
|
|
|
throw new StatusException("Couldn't get toolkit", e);
|
2003-01-27 17:20:08 +00:00
|
|
|
}
|
|
|
|
|
2003-09-08 11:34:03 +00:00
|
|
|
XExtendedToolkit tk = (XExtendedToolkit) UnoRuntime.queryInterface(
|
|
|
|
XExtendedToolkit.class, oObj);
|
2003-01-27 17:20:08 +00:00
|
|
|
|
|
|
|
AccessibilityTools at = new AccessibilityTools();
|
|
|
|
|
|
|
|
shortWait();
|
|
|
|
|
2003-09-08 11:34:03 +00:00
|
|
|
XWindow xWindow = (XWindow) UnoRuntime.queryInterface(XWindow.class,
|
|
|
|
tk.getActiveTopWindow());
|
2003-01-27 17:20:08 +00:00
|
|
|
|
|
|
|
XAccessible xRoot = at.getAccessibleObject(xWindow);
|
2004-11-02 11:06:42 +00:00
|
|
|
at.printAccessibleTree(log, xRoot, tParam.getBool(util.PropertyName.DEBUG_IS_ACTIVE));
|
2003-01-27 17:20:08 +00:00
|
|
|
oObj = at.getAccessibleObjectForRole(xRoot, AccessibleRole.PANEL);
|
|
|
|
|
|
|
|
log.println("ImplementationName: " + util.utils.getImplName(oObj));
|
|
|
|
|
2003-09-08 11:34:03 +00:00
|
|
|
TestEnvironment tEnv = new TestEnvironment(oObj);
|
|
|
|
|
|
|
|
final XWindow aWin = xWindow;
|
2003-01-27 17:20:08 +00:00
|
|
|
|
|
|
|
tEnv.addObjRelation("EventProducer",
|
2003-09-08 11:34:03 +00:00
|
|
|
new ifc.accessibility._XAccessibleEventBroadcaster.EventProducer() {
|
|
|
|
public void fireEvent() {
|
|
|
|
aWin.setPosSize(100,100, 500, 500, PosSize.POSSIZE);
|
|
|
|
}
|
|
|
|
});
|
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 {
|
2003-09-08 11:34:03 +00:00
|
|
|
Thread.currentThread().sleep(500);
|
2003-01-27 17:20:08 +00:00
|
|
|
} catch (InterruptedException e) {
|
2003-09-08 11:34:03 +00:00
|
|
|
System.out.println("While waiting :" + e);
|
2003-01-27 17:20:08 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2003-09-08 11:34:03 +00:00
|
|
|
protected void closeDoc(XComponent xDoc) {
|
|
|
|
XCloseable closer = (XCloseable) UnoRuntime.queryInterface(
|
|
|
|
XCloseable.class, xDoc);
|
|
|
|
|
|
|
|
try {
|
|
|
|
closer.close(true);
|
|
|
|
} catch (com.sun.star.util.CloseVetoException e) {
|
|
|
|
log.println("Couldn't close document " + e.getMessage());
|
|
|
|
} catch (java.lang.NullPointerException e) {
|
|
|
|
log.println("Couldn't close document " + e.getMessage());
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|