Kaydet (Commit) e48c0ac4 authored tarafından Rüdiger Timm's avatar Rüdiger Timm

INTEGRATION: CWS qadev11 (1.4.14); FILE MERGED

2003/09/03 15:32:47 sw 1.4.14.1: #112049#
üst 9d0d14da
......@@ -2,9 +2,9 @@
*
* $RCSfile: JoinViewAccessibility.java,v $
*
* $Revision: 1.4 $
* $Revision: 1.5 $
*
* last change:$Date: 2003-05-27 12:36:09 $
* last change:$Date: 2003-09-08 11:41:48 $
*
* The Contents of this file are made available subject to the terms of
* either of the following licenses
......@@ -58,39 +58,41 @@
*
*
************************************************************************/
package mod._dbaccess;
import com.sun.star.beans.XPropertySet;
import com.sun.star.lang.XMultiServiceFactory;
import com.sun.star.uno.UnoRuntime;
import com.sun.star.uno.XInterface;
import java.io.PrintWriter;
import lib.Status;
import lib.StatusException;
import lib.TestCase;
import lib.TestEnvironment;
import lib.TestParameters;
import com.sun.star.beans.PropertyValue;
import util.DBTools;
import com.sun.star.uno.XNamingService;
import com.sun.star.container.XNameAccess;
import com.sun.star.sdbc.XIsolatedConnection;
import com.sun.star.sdbc.XConnection;
import com.sun.star.sdbc.XStatement;
import com.sun.star.sdb.XQueryDefinitionsSupplier;
import com.sun.star.container.XNameContainer;
import com.sun.star.ui.dialogs.XExecutableDialog;
import com.sun.star.lang.XComponent;
import com.sun.star.awt.XExtendedToolkit;
import util.AccessibilityTools;
import com.sun.star.awt.XWindow;
import util.DBTools;
import com.sun.star.accessibility.AccessibleRole;
import com.sun.star.accessibility.XAccessible;
import com.sun.star.accessibility.XAccessibleAction;
import com.sun.star.accessibility.XAccessibleContext;
import com.sun.star.accessibility.AccessibleRole;
import com.sun.star.accessibility.XAccessibleSelection;
import com.sun.star.accessibility.XAccessibleComponent;
import com.sun.star.awt.PosSize;
import com.sun.star.awt.Rectangle;
import com.sun.star.awt.XExtendedToolkit;
import com.sun.star.awt.XWindow;
import com.sun.star.beans.PropertyValue;
import com.sun.star.beans.XPropertySet;
import com.sun.star.container.XNameAccess;
import com.sun.star.container.XNameContainer;
import com.sun.star.lang.XMultiServiceFactory;
import com.sun.star.sdb.XQueryDefinitionsSupplier;
import com.sun.star.sdbc.XConnection;
import com.sun.star.sdbc.XIsolatedConnection;
import com.sun.star.sdbc.XStatement;
import com.sun.star.ui.dialogs.XExecutableDialog;
import com.sun.star.uno.UnoRuntime;
import com.sun.star.uno.XInterface;
import com.sun.star.uno.XNamingService;
/**
* Object implements the following interfaces :
......@@ -109,9 +111,8 @@ import com.sun.star.accessibility.XAccessibleComponent;
* @see ifc.accessibility._XAccessibleEventBroadcaster
*/
public class JoinViewAccessibility extends TestCase {
XAccessibleAction actionCancel = null;
XWindow queryWindow = null;
XWindow xWindow = null;
Object[] savedObj = null;
String[] elNames = null;
XNamingService namingService = null;
......@@ -133,37 +134,42 @@ public class JoinViewAccessibility extends TestCase {
* @throws StatusException
* @see TestEnvironment
*/
protected TestEnvironment createTestEnvironment(TestParameters Param, PrintWriter log) {
protected TestEnvironment createTestEnvironment(TestParameters Param,
PrintWriter log) {
XInterface oObj = null;
Object oDBContext = null, oDBSource = null, newQuery = null;
Object oDBContext = null;
Object oDBSource = null;
Object newQuery = null;
Object toolkit = null;
try {
oDBContext = ((XMultiServiceFactory)Param.getMSF()).createInstance(
"com.sun.star.sdb.DatabaseContext");
oDBSource = ((XMultiServiceFactory)Param.getMSF()).createInstance(
"com.sun.star.sdb.DataSource");
newQuery = ((XMultiServiceFactory)Param.getMSF()).createInstance(
"com.sun.star.sdb.QueryDefinition");
toolkit = ((XMultiServiceFactory)Param.getMSF()).createInstance(
"com.sun.star.awt.Toolkit");
} catch(com.sun.star.uno.Exception e) {
oDBContext = ((XMultiServiceFactory) Param.getMSF())
.createInstance("com.sun.star.sdb.DatabaseContext");
oDBSource = ((XMultiServiceFactory) Param.getMSF())
.createInstance("com.sun.star.sdb.DataSource");
newQuery = ((XMultiServiceFactory) ((XMultiServiceFactory) Param.getMSF()))
.createInstance("com.sun.star.sdb.QueryDefinition");
toolkit = ((XMultiServiceFactory) ((XMultiServiceFactory) Param.getMSF()))
.createInstance("com.sun.star.awt.Toolkit");
} catch (com.sun.star.uno.Exception e) {
e.printStackTrace(log);
throw new StatusException(
Status.failed("Couldn't create instance"));
throw new StatusException(Status.failed("Couldn't create instance"));
}
String jdbcURL = (String) Param.get("jdbc.url");
if (jdbcURL == null) {
throw new StatusException(Status.failed(
"Couldn't get 'jdbc.url' from ini-file"));
"Couldn't get 'jdbc.url' from ini-file"));
}
String user = (String) Param.get("jdbc.user");
String password = (String) Param.get("jdbc.password");
if (user == null || password == null) {
if ((user == null) || (password == null)) {
throw new StatusException(Status.failed(
"Couldn't get 'jdbc.user' or 'jdbc.password' from ini-file"));
"Couldn't get 'jdbc.user' or 'jdbc.password' from ini-file"));
}
PropertyValue[] info = new PropertyValue[3];
......@@ -177,44 +183,45 @@ public class JoinViewAccessibility extends TestCase {
info[2].Name = "password";
info[2].Value = password;
XPropertySet propSetDBSource = (XPropertySet)UnoRuntime.queryInterface
(XPropertySet.class, oDBSource);
XPropertySet propSetDBSource = (XPropertySet) UnoRuntime.queryInterface(
XPropertySet.class, oDBSource);
try {
propSetDBSource.setPropertyValue("URL", "jdbc:" + jdbcURL);
propSetDBSource.setPropertyValue("Info", info);
} catch(com.sun.star.lang.WrappedTargetException e) {
} catch (com.sun.star.lang.WrappedTargetException e) {
e.printStackTrace(log);
throw new StatusException(Status.failed(
"Couldn't set property value"));
} catch(com.sun.star.lang.IllegalArgumentException e) {
"Couldn't set property value"));
} catch (com.sun.star.lang.IllegalArgumentException e) {
e.printStackTrace(log);
throw new StatusException(Status.failed(
"Couldn't set property value"));
} catch(com.sun.star.beans.PropertyVetoException e) {
"Couldn't set property value"));
} catch (com.sun.star.beans.PropertyVetoException e) {
e.printStackTrace(log);
throw new StatusException(Status.failed(
"Couldn't set property value"));
} catch(com.sun.star.beans.UnknownPropertyException e) {
"Couldn't set property value"));
} catch (com.sun.star.beans.UnknownPropertyException e) {
e.printStackTrace(log);
throw new StatusException(Status.failed(
"Couldn't set property value"));
"Couldn't set property value"));
}
namingService = (XNamingService)
UnoRuntime.queryInterface(XNamingService.class, oDBContext);
XNameAccess nameAccess = (XNameAccess)
UnoRuntime.queryInterface(XNameAccess.class, oDBContext);
namingService = (XNamingService) UnoRuntime.queryInterface(
XNamingService.class, oDBContext);
XNameAccess nameAccess = (XNameAccess) UnoRuntime.queryInterface(
XNameAccess.class, oDBContext);
final String sourceName = "AAADBSource for dbu-accessibility";
if (nameAccess.hasByName(sourceName)) {
try {
namingService.revokeObject(sourceName);
} catch(com.sun.star.uno.Exception e) {
} catch (com.sun.star.uno.Exception e) {
e.printStackTrace(log);
throw new StatusException(
Status.failed("Couldn't revoke object"));
throw new StatusException(Status.failed(
"Couldn't revoke object"));
}
}
......@@ -222,14 +229,14 @@ public class JoinViewAccessibility extends TestCase {
try {
namingService.registerObject(sourceName, oDBSource);
} catch(com.sun.star.uno.Exception e) {
} catch (com.sun.star.uno.Exception e) {
e.printStackTrace(log);
throw new StatusException(
Status.failed("Couldn't register object"));
throw new StatusException(Status.failed("Couldn't register object"));
}
XIsolatedConnection isolConnection = (XIsolatedConnection)
UnoRuntime.queryInterface(XIsolatedConnection.class, oDBSource);
XIsolatedConnection isolConnection = (XIsolatedConnection) UnoRuntime.queryInterface(
XIsolatedConnection.class,
oDBSource);
XConnection connection = null;
XStatement statement = null;
......@@ -241,150 +248,166 @@ public class JoinViewAccessibility extends TestCase {
try {
connection = isolConnection.getIsolatedConnection(user, password);
statement = connection.createStatement();
statement = connection.createStatement();
statement.executeUpdate("drop table if exists " + tbl_name1);
statement.executeUpdate("drop table if exists " + tbl_name2);
statement.executeUpdate("create table " + tbl_name1 + " (" +
col_name1 + " int)");
col_name1 + " int)");
statement.executeUpdate("create table " + tbl_name2 + " (" +
col_name2 + " int)");
} catch(com.sun.star.sdbc.SQLException e) {
e.printStackTrace(log);
throw new StatusException(Status.failed("SQLException"));
col_name2 + " int)");
} catch (com.sun.star.sdbc.SQLException e) {
try {
shortWait();
System.out.println("Try it again");
connection = isolConnection.getIsolatedConnection(user,
password);
statement = connection.createStatement();
statement.executeUpdate("drop table if exists " + tbl_name1);
statement.executeUpdate("drop table if exists " + tbl_name2);
statement.executeUpdate("create table " + tbl_name1 + " (" +
col_name1 + " int)");
statement.executeUpdate("create table " + tbl_name2 + " (" +
col_name2 + " int)");
} catch (com.sun.star.sdbc.SQLException e2) {
e2.printStackTrace(log);
throw new StatusException(Status.failed("SQLException"));
}
}
XQueryDefinitionsSupplier querySuppl = (XQueryDefinitionsSupplier)
UnoRuntime.queryInterface(
XQueryDefinitionsSupplier.class, oDBSource);
XQueryDefinitionsSupplier querySuppl = (XQueryDefinitionsSupplier) UnoRuntime.queryInterface(
XQueryDefinitionsSupplier.class,
oDBSource);
XNameAccess defContainer = querySuppl.getQueryDefinitions();
XPropertySet queryProp = (XPropertySet)
UnoRuntime.queryInterface(XPropertySet.class, newQuery);
XPropertySet queryProp = (XPropertySet) UnoRuntime.queryInterface(
XPropertySet.class, newQuery);
try {
final String query = "select * from " + tbl_name1 + ", " +
tbl_name2 + " where " + tbl_name1 + "." + col_name1 + "=" +
tbl_name2 + "." + col_name2;
tbl_name2 + " where " + tbl_name1 + "." +
col_name1 + "=" + tbl_name2 + "." +
col_name2;
queryProp.setPropertyValue("Command", query);
} catch(com.sun.star.lang.WrappedTargetException e) {
} catch (com.sun.star.lang.WrappedTargetException e) {
e.printStackTrace(log);
throw new StatusException(Status.failed(
"Couldn't set property value"));
} catch(com.sun.star.lang.IllegalArgumentException e) {
"Couldn't set property value"));
} catch (com.sun.star.lang.IllegalArgumentException e) {
e.printStackTrace(log);
throw new StatusException(Status.failed(
"Couldn't set property value"));
} catch(com.sun.star.beans.PropertyVetoException e) {
"Couldn't set property value"));
} catch (com.sun.star.beans.PropertyVetoException e) {
e.printStackTrace(log);
throw new StatusException(Status.failed(
"Couldn't set property value"));
} catch(com.sun.star.beans.UnknownPropertyException e) {
"Couldn't set property value"));
} catch (com.sun.star.beans.UnknownPropertyException e) {
e.printStackTrace(log);
throw new StatusException(Status.failed(
"Couldn't set property value"));
"Couldn't set property value"));
}
XNameContainer queryContainer = (XNameContainer)
UnoRuntime.queryInterface(XNameContainer.class, defContainer);
XNameContainer queryContainer = (XNameContainer) UnoRuntime.queryInterface(
XNameContainer.class,
defContainer);
try {
queryContainer.insertByName("Query1", newQuery);
} catch(com.sun.star.lang.WrappedTargetException e) {
} catch (com.sun.star.lang.WrappedTargetException e) {
e.printStackTrace(log);
throw new StatusException(Status.failed("Couldn't insert query"));
} catch(com.sun.star.container.ElementExistException e) {
} catch (com.sun.star.container.ElementExistException e) {
e.printStackTrace(log);
throw new StatusException(Status.failed("Couldn't insert query"));
} catch(com.sun.star.lang.IllegalArgumentException e) {
} catch (com.sun.star.lang.IllegalArgumentException e) {
e.printStackTrace(log);
throw new StatusException(Status.failed("Couldn't insert query"));
}
DiagThread Diag = new DiagThread((XMultiServiceFactory)Param.getMSF());
DiagThread Diag = new DiagThread(((XMultiServiceFactory) ((XMultiServiceFactory) Param.getMSF())));
Diag.start();
shortWait();
XExtendedToolkit tk = (XExtendedToolkit)
UnoRuntime.queryInterface(XExtendedToolkit.class, toolkit);
XExtendedToolkit tk = (XExtendedToolkit) UnoRuntime.queryInterface(
XExtendedToolkit.class, toolkit);
AccessibilityTools at = new AccessibilityTools();
Object atw = tk.getActiveTopWindow();
XWindow xWindow = (XWindow)
UnoRuntime.queryInterface(XWindow.class, atw);
xWindow = (XWindow) UnoRuntime.queryInterface(XWindow.class,
atw);
XAccessible xRoot = at.getAccessibleObject(xWindow);
XAccessible xRoot = AccessibilityTools.getAccessibleObject(xWindow);
XAccessibleContext accContextCancel = at.getAccessibleObjectForRole
(xRoot, AccessibleRole.PUSH_BUTTON, "Cancel");
actionCancel = (XAccessibleAction)UnoRuntime.queryInterface
(XAccessibleAction.class, accContextCancel);
XAccessibleContext accContextCancel = AccessibilityTools.getAccessibleObjectForRole(
xRoot,
AccessibleRole.PUSH_BUTTON,
"Cancel");
actionCancel = (XAccessibleAction) UnoRuntime.queryInterface(
XAccessibleAction.class, accContextCancel);
XAccessibleContext accContextTabList = at.getAccessibleObjectForRole(
xRoot, AccessibleRole.PAGE_TAB_LIST);
XAccessibleSelection tabListSelection = (XAccessibleSelection)
UnoRuntime.queryInterface(XAccessibleSelection.class,
accContextTabList);
XAccessibleContext accContextTabList = AccessibilityTools.getAccessibleObjectForRole(
xRoot,
AccessibleRole.PAGE_TAB_LIST);
XAccessibleSelection tabListSelection = (XAccessibleSelection) UnoRuntime.queryInterface(
XAccessibleSelection.class,
accContextTabList);
final int queriesChildNum = 3;
try {
tabListSelection.selectAccessibleChild(queriesChildNum);
} catch(com.sun.star.lang.IndexOutOfBoundsException e) {
} catch (com.sun.star.lang.IndexOutOfBoundsException e) {
e.printStackTrace(log);
throw new StatusException(Status.failed(
"Couldn't select child " + queriesChildNum));
throw new StatusException(Status.failed("Couldn't select child " + queriesChildNum));
}
shortWait();
XAccessibleContext acEditQuery = at.getAccessibleObjectForRole(
xRoot, AccessibleRole.PUSH_BUTTON, "Edit Query");
XAccessibleAction actionEditQuery = (XAccessibleAction)
UnoRuntime.queryInterface(XAccessibleAction.class, acEditQuery);
XAccessibleContext acEditQuery = AccessibilityTools.getAccessibleObjectForRole(xRoot,
AccessibleRole.PUSH_BUTTON,
"Edit Query");
XAccessibleAction actionEditQuery = (XAccessibleAction) UnoRuntime.queryInterface(
XAccessibleAction.class,
acEditQuery);
try {
actionEditQuery.doAccessibleAction(0);
} catch(com.sun.star.lang.IndexOutOfBoundsException e) {
} catch (com.sun.star.lang.IndexOutOfBoundsException e) {
e.printStackTrace(log);
throw new StatusException(Status.failed(
"Couldn't do accessible action"));
"Couldn't do accessible action"));
}
shortWait();
atw = tk.getActiveTopWindow();
xWindow = (XWindow)
UnoRuntime.queryInterface(XWindow.class, atw);
queryWindow = xWindow;
xWindow = (XWindow) UnoRuntime.queryInterface(XWindow.class, atw);
xRoot = at.getAccessibleObject(xWindow);
xRoot = AccessibilityTools.getAccessibleObject(xWindow);
// at.printAccessibleTree(log, xRoot);
oObj = at.getAccessibleObjectForRole(
xRoot, AccessibleRole.VIEW_PORT);
// at.printAccessibleTree(log, xRoot);
oObj = AccessibilityTools.getAccessibleObjectForRole(xRoot, AccessibleRole.VIEW_PORT);
log.println("ImplementationName " + util.utils.getImplName(oObj));
log.println( " creating a new environment for object" );
TestEnvironment tEnv = new TestEnvironment( oObj );
log.println(" creating a new environment for object");
final XAccessibleComponent acc = (XAccessibleComponent)
UnoRuntime.queryInterface(XAccessibleComponent.class, oObj);
TestEnvironment tEnv = new TestEnvironment(oObj);
final XWindow queryWin = xWindow;
tEnv.addObjRelation("EventProducer",
new ifc.accessibility._XAccessibleEventBroadcaster.EventProducer(){
public void fireEvent() {
acc.grabFocus();
}
});
new ifc.accessibility._XAccessibleEventBroadcaster.EventProducer() {
public void fireEvent() {
Rectangle rect = queryWin.getPosSize();
queryWin.setPosSize(rect.X, rect.Y, rect.Height-5, rect.Width-5, PosSize.POSSIZE);
}
});
return tEnv;
} // finish method getTestEnvironment
......@@ -392,20 +415,31 @@ public class JoinViewAccessibility extends TestCase {
/**
* Closes the DatasourceAdministration dialog and Query Dialog.
*/
protected void cleanup( TestParameters Param, PrintWriter log) {
try {
queryWindow.dispose();
} catch ( com.sun.star.lang.DisposedException de) {}
protected void cleanup(TestParameters Param, PrintWriter log) {
shortWait();
try {
actionCancel.doAccessibleAction(0);
} catch(com.sun.star.lang.IndexOutOfBoundsException e) {
} catch (com.sun.star.lang.IndexOutOfBoundsException e) {
e.printStackTrace(log);
throw new StatusException(Status.failed(
"Couldn't do accessible action"));
"Couldn't do accessible action"));
}
xWindow.dispose();
}
/**
* Sleeps for 0.5 sec. to allow StarOffice to react on <code>
* reset</code> call.
*/
private void shortWait() {
try {
Thread.sleep(1500);
} catch (InterruptedException e) {
log.println("While waiting :" + e);
}
}
......@@ -424,26 +458,15 @@ public class JoinViewAccessibility extends TestCase {
try {
dbAdminDlg = msf.createInstance(
"com.sun.star.sdb.DatasourceAdministrationDialog");
} catch(com.sun.star.uno.Exception e) {}
"com.sun.star.sdb.DatasourceAdministrationDialog");
} catch (com.sun.star.uno.Exception e) {
}
XExecutableDialog adminDlg = (XExecutableDialog)
UnoRuntime.queryInterface(XExecutableDialog.class, dbAdminDlg);
XExecutableDialog adminDlg = (XExecutableDialog) UnoRuntime.queryInterface(
XExecutableDialog.class,
dbAdminDlg);
adminDlg.execute();
}
}
/**
* Sleeps for 0.5 sec. to allow StarOffice to react on <code>
* reset</code> call.
*/
private void shortWait() {
try {
Thread.sleep(1500) ;
} catch (InterruptedException e) {
log.println("While waiting :" + e) ;
}
}
}
}
\ No newline at end of file
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment