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

173 lines
5.8 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.DesktopTools;
import util.SOfficeFactory;
import com.sun.star.accessibility.AccessibleRole;
import com.sun.star.accessibility.XAccessible;
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.XFrame;
import com.sun.star.frame.XModel;
import com.sun.star.text.XTextDocument;
import com.sun.star.uno.UnoRuntime;
import com.sun.star.uno.XInterface;
import com.sun.star.util.URL;
2008-09-30 07:44:27 +00:00
import com.sun.star.view.XSelectionSupplier;
2003-01-27 17:20:08 +00:00
public class AccessibleBrowseBox extends TestCase {
static XDesktop xDesktop;
2008-09-30 07:44:27 +00:00
static XTextDocument xTextDoc;
2003-01-27 17:20:08 +00:00
/**
* Creates the Desktop service (<code>com.sun.star.frame.Desktop</code>).
*/
@Override
protected void initialize(TestParameters Param, PrintWriter log) throws Exception {
xDesktop = DesktopTools.createDesktop(Param.getMSF());
2003-01-27 17:20:08 +00:00
}
/**
* Disposes the document, if exists, created in
* <code>createTestEnvironment</code> method.
*/
@Override
2008-09-30 07:44:27 +00:00
protected void cleanup(TestParameters Param, PrintWriter log) {
2003-01-27 17:20:08 +00:00
log.println("disposing xTextDoc");
if (xTextDoc != null) {
xTextDoc.dispose();
}
}
/**
* Called to create an instance of <code>TestEnvironment</code> with an
* object to test and related objects. Subclasses should implement this
* method to provide the implementation and related objects. The method is
* called from <code>getTestEnvironment()</code>.
*
* @param tParam test parameters
* @param log writer to log information while testing
*
* @see TestEnvironment
* @see #getTestEnvironment
2003-01-27 17:20:08 +00:00
*/
@Override
protected TestEnvironment createTestEnvironment(TestParameters tParam, PrintWriter log) throws Exception {
2003-01-27 17:20:08 +00:00
2008-09-30 07:44:27 +00:00
log.println("creating a test environment");
2003-01-27 17:20:08 +00:00
2008-09-30 07:44:27 +00:00
if (xTextDoc != null) {
xTextDoc.dispose(); // get a soffice factory object
}
SOfficeFactory SOF = SOfficeFactory.getFactory(tParam.getMSF());
2003-01-27 17:20:08 +00:00
log.println("creating a text document");
xTextDoc = SOF.createTextDoc(null);
2003-01-27 17:20:08 +00:00
util.utils.waitForEventIdle(tParam.getMSF());
2003-01-27 17:20:08 +00:00
XModel aModel1 = UnoRuntime.queryInterface(XModel.class, xTextDoc);
2003-01-27 17:20:08 +00:00
XController secondController = aModel1.getCurrentController();
XDispatchProvider aProv = UnoRuntime.queryInterface(XDispatchProvider.class,
2008-09-30 07:44:27 +00:00
secondController);
2003-01-27 17:20:08 +00:00
XDispatch getting = null;
2008-09-30 07:44:27 +00:00
log.println("opening DatasourceBrowser");
2003-01-27 17:20:08 +00:00
URL the_url = new URL();
the_url.Complete = ".component:DB/DataSourceBrowser";
2008-09-30 07:44:27 +00:00
getting = aProv.queryDispatch(the_url, "_beamer", 12);
2003-01-27 17:20:08 +00:00
PropertyValue[] noArgs = new PropertyValue[0];
2008-09-30 07:44:27 +00:00
getting.dispatch(the_url, noArgs);
2003-01-27 17:20:08 +00:00
util.utils.waitForEventIdle(tParam.getMSF());
2003-01-27 17:20:08 +00:00
XFrame the_frame1 = xDesktop.getCurrentFrame();
2003-01-27 17:20:08 +00:00
if (the_frame1 == null) {
log.println("Current frame was not found !!!");
}
2008-09-30 07:44:27 +00:00
XFrame the_frame2 = the_frame1.findFrame("_beamer", 4);
2003-01-27 17:20:08 +00:00
the_frame2.setName("DatasourceBrowser");
XInterface oObj = null;
final XSelectionSupplier xSelect = UnoRuntime.queryInterface(
2008-09-30 07:44:27 +00:00
XSelectionSupplier.class, the_frame2.getController());
PropertyValue[] params = new PropertyValue[]{new PropertyValue(), new PropertyValue(), new PropertyValue()};
params[0].Name = "DataSourceName";
params[0].Value = "Bibliography";
params[1].Name = "CommandType";
params[1].Value = Integer.valueOf(com.sun.star.sdb.CommandType.TABLE);
2008-09-30 07:44:27 +00:00
params[2].Name = "Command";
params[2].Value = "biblio";
final PropertyValue[] fParams = params;
2003-01-27 17:20:08 +00:00
util.utils.waitForEventIdle(tParam.getMSF());
2003-01-27 17:20:08 +00:00
XWindow xWindow = secondController.getFrame().getContainerWindow();
2003-01-27 17:20:08 +00:00
XAccessible xRoot = AccessibilityTools.getAccessibleObject(xWindow);
2003-01-27 17:20:08 +00:00
AccessibilityTools.printAccessibleTree(log, xRoot, tParam.getBool(util.PropertyName.DEBUG_IS_ACTIVE));
2003-01-27 17:20:08 +00:00
oObj = AccessibilityTools.getAccessibleObjectForRole(xRoot, AccessibleRole.PANEL, "", "AccessibleBrowseBox");
2003-01-27 17:20:08 +00:00
2008-09-30 07:44:27 +00:00
log.println("ImplementationName: " + util.utils.getImplName(oObj));
2003-01-27 17:20:08 +00:00
2008-09-30 07:44:27 +00:00
TestEnvironment tEnv = new TestEnvironment(oObj);
2003-01-27 17:20:08 +00:00
tEnv.addObjRelation("EventProducer",
2008-09-30 07:44:27 +00:00
new ifc.accessibility._XAccessibleEventBroadcaster.EventProducer() {
2003-01-27 17:20:08 +00:00
public void fireEvent() {
try {
2008-09-30 07:44:27 +00:00
xSelect.select(fParams);
} catch (com.sun.star.lang.IllegalArgumentException e) {
2003-01-27 17:20:08 +00:00
e.printStackTrace();
}
}
});
return tEnv;
}
}