Files
libreoffice/qadevOOo/tests/java/mod/_svtools/AccessibleTabBar.java

132 lines
4.5 KiB
Java
Raw Normal View History

/*
* This file is part of the LibreOffice project.
*
* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/.
*
* This file incorporates work covered by the following license notice:
*
* Licensed to the Apache Software Foundation (ASF) under one or more
* contributor license agreements. See the NOTICE file distributed
* with this work for additional information regarding copyright
* ownership. The ASF licenses this file to you under the Apache
* License, Version 2.0 (the "License"); you may not use this file
* except in compliance with the License. You may obtain a copy of
* the License at http://www.apache.org/licenses/LICENSE-2.0 .
*/
2003-01-27 17:20:08 +00:00
package mod._svtools;
import java.io.PrintWriter;
import lib.TestCase;
import lib.TestEnvironment;
import lib.TestParameters;
import util.AccessibilityTools;
import util.SOfficeFactory;
import com.sun.star.accessibility.AccessibleRole;
import com.sun.star.accessibility.XAccessible;
import com.sun.star.awt.PosSize;
import com.sun.star.awt.XWindow;
import com.sun.star.frame.XModel;
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
public class AccessibleTabBar extends TestCase {
2008-09-30 07:44:27 +00:00
static XComponent xDoc;
2003-01-27 17:20:08 +00:00
/**
* Disposes the document, if exists, created in
* <code>createTestEnvironment</code> method.
*/
@Override
protected void cleanup(TestParameters Param, PrintWriter log) {
2003-01-27 17:20:08 +00:00
log.println("disposing xCalcDoc");
if (xDoc != null) {
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
*/
@Override
2003-01-27 17:20:08 +00:00
protected TestEnvironment createTestEnvironment(TestParameters tParam,
PrintWriter log) throws Exception {
log.println("creating a test environment");
2003-01-27 17:20:08 +00:00
if (xDoc != null) {
closeDoc(xDoc);
}
2003-01-27 17:20:08 +00:00
XMultiServiceFactory msf = tParam.getMSF();
2003-01-27 17:20:08 +00:00
// get a soffice factory object
SOfficeFactory SOF = SOfficeFactory.getFactory(msf);
2003-01-27 17:20:08 +00:00
log.println("creating a calc document");
xDoc = UnoRuntime.queryInterface(XComponent.class,
SOF.createCalcDoc(
null));
2003-01-27 17:20:08 +00:00
util.utils.waitForEventIdle(tParam.getMSF());
2003-01-27 17:20:08 +00:00
XInterface oObj = null;
XWindow xWindow = UnoRuntime.queryInterface(XModel.class, xDoc).
getCurrentController().getFrame().getContainerWindow();
2003-01-27 17:20:08 +00:00
XAccessible xRoot = AccessibilityTools.getAccessibleObject(xWindow);
AccessibilityTools.printAccessibleTree(log, xRoot, tParam.getBool(util.PropertyName.DEBUG_IS_ACTIVE));
oObj = AccessibilityTools.getAccessibleObjectForRole(xRoot, AccessibleRole.PANEL);
2003-01-27 17:20:08 +00:00
log.println("ImplementationName: " + util.utils.getImplName(oObj));
TestEnvironment tEnv = new TestEnvironment(oObj);
final XWindow aWin = xWindow;
2003-01-27 17:20:08 +00:00
tEnv.addObjRelation("EventProducer",
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;
}
protected void closeDoc(XComponent xDoc) {
XCloseable closer = 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 (NullPointerException e) {
log.println("Couldn't close document " + e.getMessage());
}
}
}