diff options
Diffstat (limited to 'qadevOOo/tests/java/mod/_dbaccess')
16 files changed, 3325 insertions, 0 deletions
diff --git a/qadevOOo/tests/java/mod/_dbaccess/ConnectionLineAccessibility.java b/qadevOOo/tests/java/mod/_dbaccess/ConnectionLineAccessibility.java new file mode 100644 index 000000000..3cded65a1 --- /dev/null +++ b/qadevOOo/tests/java/mod/_dbaccess/ConnectionLineAccessibility.java @@ -0,0 +1,261 @@ +/* + * 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 . + */ +package mod._dbaccess; + +import java.io.PrintWriter; + +import lib.Status; +import lib.StatusException; +import lib.TestCase; +import lib.TestEnvironment; +import lib.TestParameters; +import util.AccessibilityTools; + +import com.sun.star.accessibility.AccessibleRole; +import com.sun.star.accessibility.XAccessible; +import com.sun.star.awt.PosSize; +import com.sun.star.awt.Rectangle; +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.frame.XModel; +import com.sun.star.frame.XStorable; +import com.sun.star.lang.XComponent; +import com.sun.star.lang.XMultiServiceFactory; +import com.sun.star.sdb.XDocumentDataSource; +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.ucb.XSimpleFileAccess; +import com.sun.star.uno.UnoRuntime; +import com.sun.star.uno.XInterface; +import util.DesktopTools; +import util.utils; + + +/** + * Object implements the following interfaces : + * <ul> + * <li><code>::com::sun::star::accessibility::XAccessible</code></li> + * <li><code>::com::sun::star::accessibility::XAccessibleContext + * </code></li> + * <li><code>::com::sun::star::accessibility::XAccessibleEventBroadcaster + * </code></li> + * </ul><p> + * @see com.sun.star.accessibility.XAccessible + * @see com.sun.star.accessibility.XAccessibleContext + * @see com.sun.star.accessibility.XAccessibleEventBroadcaster + * @see ifc.accessibility._XAccessible + * @see ifc.accessibility._XAccessibleContext + * @see ifc.accessibility._XAccessibleEventBroadcaster + */ +public class ConnectionLineAccessibility extends TestCase +{ + XWindow xWindow = null; + String aFile = ""; + XIsolatedConnection isolConnection = null; + XComponent QueryComponent = null; + String user = ""; + String password=""; + + /** + * Creates a new DataSource and stores it. + * Creates a connection and using it + * creates two tables in database. + * Creates a new query and adds it to DefinitionContainer. + * Opens the QueryComponent.with loadComponentFromURL + * and gets the object with the role UNKNOWN and the implementation + * name that contains ConnectionLine + * @param Param test parameters + * @param log writer to log information while testing + * @return + * @throws StatusException + * @see TestEnvironment + */ + @Override + protected TestEnvironment createTestEnvironment(TestParameters Param, + PrintWriter log) throws Exception + { + XInterface oObj = null; + + Param.getMSF().createInstance("com.sun.star.sdb.DatabaseContext"); + Object oDBSource = Param.getMSF().createInstance("com.sun.star.sdb.DataSource"); + Object newQuery = Param.getMSF().createInstance("com.sun.star.sdb.QueryDefinition"); + Param.getMSF().createInstance("com.sun.star.awt.Toolkit"); + + String mysqlURL = (String) Param.get("mysql.url"); + + if (mysqlURL == null) + { + throw new StatusException(Status.failed( + "Couldn't get 'mysql.url' from ini-file")); + } + + user = (String) Param.get("jdbc.user"); + password = (String) Param.get("jdbc.password"); + + if ((user == null) || (password == null)) + { + throw new StatusException(Status.failed( + "Couldn't get 'jdbc.user' or 'jdbc.password' from ini-file")); + } + + PropertyValue[] info = new PropertyValue[2]; + info[0] = new PropertyValue(); + info[0].Name = "user"; + info[0].Value = user; + info[1] = new PropertyValue(); + info[1].Name = "password"; + info[1].Value = password; + + XPropertySet propSetDBSource = UnoRuntime.queryInterface( + XPropertySet.class, oDBSource); + + propSetDBSource.setPropertyValue("URL", mysqlURL); + propSetDBSource.setPropertyValue("Info", info); + + log.println("writing database file ..."); + XDocumentDataSource xDDS = UnoRuntime.queryInterface(XDocumentDataSource.class, oDBSource); + XStorable store = UnoRuntime.queryInterface(XStorable.class, + xDDS.getDatabaseDocument()); + + aFile = utils.getOfficeTemp(Param.getMSF())+"ConnectionLine.odb"; + log.println("... filename will be "+aFile); + store.storeAsURL(aFile,new PropertyValue[]{}); + log.println("... done"); + + isolConnection = UnoRuntime.queryInterface( + XIsolatedConnection.class, + oDBSource); + + final String tbl_name1 = "tst_table1"; + final String tbl_name2 = "tst_table2"; + final String col_name1 = "id1"; + final String col_name2 = "id2"; + + util.utils.waitForEventIdle(Param.getMSF()); + + XConnection connection = isolConnection.getIsolatedConnection(user, password); + XStatement 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)"); + + XQueryDefinitionsSupplier querySuppl = UnoRuntime.queryInterface( + XQueryDefinitionsSupplier.class, + oDBSource); + + XNameAccess defContainer = querySuppl.getQueryDefinitions(); + + XPropertySet queryProp = UnoRuntime.queryInterface( + XPropertySet.class, newQuery); + + final String query = "select * from " + tbl_name1 + ", " + + tbl_name2 + " where " + tbl_name1 + "." + + col_name1 + "=" + tbl_name2 + "." + + col_name2; + queryProp.setPropertyValue("Command", query); + + XNameContainer queryContainer = UnoRuntime.queryInterface( + XNameContainer.class, + defContainer); + + queryContainer.insertByName("Query1", newQuery); + store.store(); + connection.close(); + + PropertyValue[] loadProps = new PropertyValue[3]; + loadProps[0] = new PropertyValue(); + loadProps[0].Name = "QueryDesignView"; + loadProps[0].Value = Boolean.TRUE; + + loadProps[1] = new PropertyValue(); + loadProps[1].Name = "CurrentQuery"; + loadProps[1].Value = "Query1"; + + loadProps[2] = new PropertyValue(); + loadProps[2].Name = "DataSource"; + loadProps[2].Value = oDBSource; + + QueryComponent = DesktopTools.loadDoc(Param.getMSF(),".component:DB/QueryDesign",loadProps); + + util.utils.waitForEventIdle(Param.getMSF()); + + xWindow = UnoRuntime.queryInterface(XModel.class, QueryComponent). + getCurrentController().getFrame().getContainerWindow(); + + XAccessible xRoot = AccessibilityTools.getAccessibleObject(xWindow); + + AccessibilityTools.printAccessibleTree (log,xRoot, Param.getBool(util.PropertyName.DEBUG_IS_ACTIVE)); + + oObj = AccessibilityTools.getAccessibleObjectForRoleIgnoreShowing(xRoot, AccessibleRole.UNKNOWN, "", "ConnectionLine"); + + log.println("ImplementationName " + util.utils.getImplName(oObj)); + + log.println("creating TestEnvironment"); + + TestEnvironment tEnv = new TestEnvironment(oObj); + + util.utils.waitForEventIdle(Param.getMSF()); + + final XWindow queryWin = xWindow; + + tEnv.addObjRelation("EventProducer", + 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 + + /** + * Closes the DatasourceAdministration dialog and Query Dialog. + */ + @Override + protected void cleanup(TestParameters Param, PrintWriter log) + { + try + { + + log.println("closing QueryComponent ..."); + DesktopTools.closeDoc(QueryComponent); + log.println("... done"); + XMultiServiceFactory xMSF = Param.getMSF(); + Object sfa = xMSF.createInstance("com.sun.star.comp.ucb.SimpleFileAccess"); + XSimpleFileAccess xSFA = UnoRuntime.queryInterface(XSimpleFileAccess.class, sfa); + log.println("deleting database file"); + xSFA.kill(aFile); + log.println("Could delete file "+aFile+": "+!xSFA.exists(aFile)); + } + catch (Exception e) + { + e.printStackTrace(); + } + } +} diff --git a/qadevOOo/tests/java/mod/_dbaccess/DBContentLoader.java b/qadevOOo/tests/java/mod/_dbaccess/DBContentLoader.java new file mode 100644 index 000000000..b37389759 --- /dev/null +++ b/qadevOOo/tests/java/mod/_dbaccess/DBContentLoader.java @@ -0,0 +1,82 @@ +/* + * 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 . + */ + +package mod._dbaccess; + +import java.io.PrintWriter; + +import lib.TestCase; +import lib.TestEnvironment; +import lib.TestParameters; + +import com.sun.star.uno.XInterface; + +/** +* Test for object which is represented by service +* <code>com.sun.star.sdb.ContentLoader</code>. <p> +* Object implements the following interfaces : +* <ul> +* <li> <code>com::sun::star::beans::XPropertySet</code></li> +* <li> <code>com::sun::star::frame::FrameLoader</code></li> +* <li> <code>com::sun::star::frame::XFrameLoader</code></li> +* <li> <code>com::sun::star::lang::XInitialization</code></li> +* </ul> +* This object test <b> is NOT </b> designed to be run in several +* threads concurrently. +* @see com.sun.star.beans.XPropertySet +* @see com.sun.star.frame.FrameLoader +* @see com.sun.star.frame.XSynchronousFrameLoader +* @see com.sun.star.lang.XInitialization +* @see ifc.beans._XPropertySet +* @see ifc.frame._FrameLoader +* @see ifc.frame._XSynchronousFrameLoader +* @see ifc.lang._XInitialization +*/ +public class DBContentLoader extends TestCase { + + /** + * Creating a TestEnvironment for the interfaces to be tested. + * Creates an instance of the service + * <code>com.sun.star.sdb.ContentLoader</code>. <p> + * Object relations created : + * <ul> + * <li> <code>'FrameLoader.URL"'</code> for + * {@link ifc.frame._XFrameLoader} </li> + * </ul> + */ + @Override + public TestEnvironment createTestEnvironment( TestParameters Param, + PrintWriter log ) + throws Exception { + + Object oInterface = Param.getMSF().createInstance + ("com.sun.star.sdb.ContentLoader"); + XInterface oObj = (XInterface) oInterface ; + + log.println("ImplementationName " + util.utils.getImplName(oObj)); + log.println( "creating a new environment for object" ); + TestEnvironment tEnv = new TestEnvironment( oObj ); + + // adding relation for XFrameLoader + tEnv.addObjRelation("FrameLoader.URL", ".component:DB/DataSourceBrowser") ; + + return tEnv; + } // finish method getTestEnvironment + +} + diff --git a/qadevOOo/tests/java/mod/_dbaccess/JoinViewAccessibility.java b/qadevOOo/tests/java/mod/_dbaccess/JoinViewAccessibility.java new file mode 100644 index 000000000..499779ebf --- /dev/null +++ b/qadevOOo/tests/java/mod/_dbaccess/JoinViewAccessibility.java @@ -0,0 +1,254 @@ +/* + * 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 . + */ +package mod._dbaccess; + +import java.io.PrintWriter; + +import lib.Status; +import lib.StatusException; +import lib.TestCase; +import lib.TestEnvironment; +import lib.TestParameters; +import util.AccessibilityTools; + +import com.sun.star.accessibility.AccessibleRole; +import com.sun.star.accessibility.XAccessible; +import com.sun.star.awt.PosSize; +import com.sun.star.awt.Rectangle; +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.frame.XModel; +import com.sun.star.frame.XStorable; +import com.sun.star.lang.XComponent; +import com.sun.star.lang.XMultiServiceFactory; +import com.sun.star.sdb.XDocumentDataSource; +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.ucb.XSimpleFileAccess; +import com.sun.star.uno.UnoRuntime; +import com.sun.star.uno.XInterface; +import util.DesktopTools; +import util.utils; + + +/** +* Object implements the following interfaces : +* <ul> +* <li><code>::com::sun::star::accessibility::XAccessible</code></li> +* <li><code>::com::sun::star::accessibility::XAccessibleContext +* </code></li> +* <li><code>::com::sun::star::accessibility::XAccessibleEventBroadcaster +* </code></li> +* </ul><p> +* @see com.sun.star.accessibility.XAccessible +* @see com.sun.star.accessibility.XAccessibleContext +* @see com.sun.star.accessibility.XAccessibleEventBroadcaster +* @see ifc.accessibility._XAccessible +* @see ifc.accessibility._XAccessibleContext +* @see ifc.accessibility._XAccessibleEventBroadcaster +*/ +public class JoinViewAccessibility extends TestCase { + XWindow xWindow = null; + String aFile = ""; + XIsolatedConnection isolConnection = null; + XComponent QueryComponent = null; + String user = ""; + String password=""; + + /** + * Creates a new DataSource and stores it. + * Creates a connection and using it + * creates two tables in database. + * Creates a new query and adds it to DefinitionContainer. + * Opens the QueryComponent.with loadComponentFromURL + * and gets the object with the role UNKNOWN and the implementation + * name that contains ConnectionLine + * @param Param test parameters + * @param log writer to log information while testing + * @return + * @throws StatusException + * @see TestEnvironment + */ + @Override + protected TestEnvironment createTestEnvironment (TestParameters Param, + PrintWriter log) throws Exception + { + XInterface oObj = null; + + Param.getMSF().createInstance("com.sun.star.sdb.DatabaseContext"); + Object oDBSource = Param.getMSF() + .createInstance("com.sun.star.sdb.DataSource"); + Object newQuery = Param.getMSF().createInstance( + "com.sun.star.sdb.QueryDefinition"); + Param.getMSF().createInstance("com.sun.star.awt.Toolkit"); + + String mysqlURL = (String) Param.get ("mysql.url"); + + if (mysqlURL == null) + { + throw new StatusException (Status.failed ( + "Couldn't get 'mysql.url' from ini-file")); + } + + user = (String) Param.get ("jdbc.user"); + password = (String) Param.get ("jdbc.password"); + + if ((user == null) || (password == null)) + { + throw new StatusException (Status.failed ( + "Couldn't get 'jdbc.user' or 'jdbc.password' from ini-file")); + } + + PropertyValue[] info = new PropertyValue[2]; + info[0] = new PropertyValue (); + info[0].Name = "user"; + info[0].Value = user; + info[1] = new PropertyValue (); + info[1].Name = "password"; + info[1].Value = password; + + XPropertySet propSetDBSource = UnoRuntime.queryInterface ( + XPropertySet.class, oDBSource); + + propSetDBSource.setPropertyValue ("URL", mysqlURL); + propSetDBSource.setPropertyValue ("Info", info); + + log.println ("writing database file ..."); + XDocumentDataSource xDDS = UnoRuntime.queryInterface(XDocumentDataSource.class, oDBSource); + XStorable store = UnoRuntime.queryInterface(XStorable.class, + xDDS.getDatabaseDocument()); + aFile = utils.getOfficeTemp (Param.getMSF ())+"JoinView.odb"; + log.println ("... filename will be "+aFile); + store.storeAsURL (aFile,new PropertyValue[]{}); + log.println ("... done"); + + isolConnection = UnoRuntime.queryInterface ( + XIsolatedConnection.class, + oDBSource); + + final String tbl_name1 = "tst_table1"; + final String tbl_name2 = "tst_table2"; + final String col_name1 = "id1"; + final String col_name2 = "id2"; + + util.utils.waitForEventIdle(Param.getMSF()); + XConnection connection = isolConnection.getIsolatedConnection (user, password); + XStatement 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)"); + + XQueryDefinitionsSupplier querySuppl = UnoRuntime.queryInterface ( + XQueryDefinitionsSupplier.class, + oDBSource); + + XNameAccess defContainer = querySuppl.getQueryDefinitions (); + + XPropertySet queryProp = UnoRuntime.queryInterface ( + XPropertySet.class, newQuery); + + final String query = "select * from " + tbl_name1 + ", " + + tbl_name2 + " where " + tbl_name1 + "." + + col_name1 + "=" + tbl_name2 + "." + + col_name2; + queryProp.setPropertyValue ("Command", query); + + XNameContainer queryContainer = UnoRuntime.queryInterface ( + XNameContainer.class, + defContainer); + + queryContainer.insertByName ("Query1", newQuery); + store.store (); + connection.close (); + + PropertyValue[] loadProps = new PropertyValue[3]; + loadProps[0] = new PropertyValue (); + loadProps[0].Name = "QueryDesignView"; + loadProps[0].Value = Boolean.TRUE; + + loadProps[1] = new PropertyValue (); + loadProps[1].Name = "CurrentQuery"; + loadProps[1].Value = "Query1"; + + loadProps[2] = new PropertyValue (); + loadProps[2].Name = "DataSource"; + loadProps[2].Value = oDBSource; + + QueryComponent = DesktopTools.loadDoc (Param.getMSF (),".component:DB/QueryDesign",loadProps); + + xWindow = UnoRuntime.queryInterface(XModel.class, QueryComponent). + getCurrentController().getFrame().getContainerWindow(); + + XAccessible xRoot = AccessibilityTools.getAccessibleObject (xWindow); + + AccessibilityTools.printAccessibleTree (log,xRoot, Param.getBool(util.PropertyName.DEBUG_IS_ACTIVE)); + + oObj = AccessibilityTools.getAccessibleObjectForRole(xRoot, AccessibleRole.VIEW_PORT); + + log.println("ImplementationName " + util.utils.getImplName(oObj)); + + log.println("creating TestEnvironment"); + + TestEnvironment tEnv = new TestEnvironment(oObj); + + util.utils.waitForEventIdle(Param.getMSF()); + + final XWindow queryWin = xWindow; + + tEnv.addObjRelation("EventProducer", + 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 + + /** + * Closes the DatasourceAdministration dialog and Query Dialog. + */ + @Override + protected void cleanup(TestParameters Param, PrintWriter log) { + try + { + + log.println ("closing QueryComponent ..."); + DesktopTools.closeDoc (QueryComponent); + log.println ("... done"); + XMultiServiceFactory xMSF = Param.getMSF (); + Object sfa = xMSF.createInstance ("com.sun.star.comp.ucb.SimpleFileAccess"); + XSimpleFileAccess xSFA = UnoRuntime.queryInterface (XSimpleFileAccess.class, sfa); + log.println ("deleting database file"); + xSFA.kill (aFile); + log.println ("Could delete file "+aFile+": "+!xSFA.exists (aFile)); + } catch (Exception e) + { + e.printStackTrace (); + } + } +} diff --git a/qadevOOo/tests/java/mod/_dbaccess/OCommandDefinition.java b/qadevOOo/tests/java/mod/_dbaccess/OCommandDefinition.java new file mode 100644 index 000000000..895df264f --- /dev/null +++ b/qadevOOo/tests/java/mod/_dbaccess/OCommandDefinition.java @@ -0,0 +1,65 @@ +/* + * 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 . + */ + +package mod._dbaccess; + +import java.io.PrintWriter; + +import lib.TestCase; +import lib.TestEnvironment; +import lib.TestParameters; + +import com.sun.star.lang.XMultiServiceFactory; +import com.sun.star.uno.XInterface; + +/** +* Test for object which is represented by service +* <code>com.sun.star.sdb.QueryDefinition</code>. <p> +* Object implements the following interfaces : +* <ul> +* <li> <code>com::sun::star::sdb::QueryDefinition</code></li> +* <li> <code>com::sun::star::beans::XPropertySet</code></li> +* </ul> +* This object test <b> can </b> be run in several +* threads concurrently. +* @see com.sun.star.sdb.QueryDefinition +* @see com.sun.star.beans.XPropertySet +* @see ifc.sdb._QueryDefinition +* @see ifc.beans._XPropertySet +*/ +public class OCommandDefinition extends TestCase { + + /** + * Creating a TestEnvironment for the interfaces to be tested. + * Creates service <code>com.sun.star.sdb.QueryDefinition</code>. + */ + @Override + public TestEnvironment createTestEnvironment( TestParameters Param, + PrintWriter log ) + throws Exception { + XMultiServiceFactory xMSF = Param.getMSF(); + Object oInterface = xMSF.createInstance( "com.sun.star.sdb.QueryDefinition" ); + XInterface oObj = (XInterface) oInterface; + + log.println( " creating a new environment for object" ); + TestEnvironment tEnv = new TestEnvironment( oObj ); + + return tEnv; + } // finish method getTestEnvironment +} + diff --git a/qadevOOo/tests/java/mod/_dbaccess/ODatabaseContext.java b/qadevOOo/tests/java/mod/_dbaccess/ODatabaseContext.java new file mode 100644 index 000000000..24b69854b --- /dev/null +++ b/qadevOOo/tests/java/mod/_dbaccess/ODatabaseContext.java @@ -0,0 +1,106 @@ +/* + * 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 . + */ + +package mod._dbaccess; + +import com.sun.star.beans.PropertyValue; +import java.io.PrintWriter; + +import lib.TestCase; +import lib.TestEnvironment; +import lib.TestParameters; + +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 com.sun.star.uno.XNamingService; +import com.sun.star.frame.XStorable; +import com.sun.star.sdb.XDocumentDataSource; +import util.utils; + +/** +* Test for object which is represented by service +* <code>com.sun.star.sdb.DatabaseContext</code>. <p> +* +* Object implements the following interfaces : +* <ul> +* <li> <code>com::sun::star::container::XEnumerationAccess</code></li> +* <li> <code>com::sun::star::container::XNameAccess</code></li> +* <li> <code>com::sun::star::container::XElementAccess</code></li> +* <li> <code>com::sun::star::uno::XNamingService</code></li> +* </ul> +* +* @see com.sun.star.container.XNameAccess +* @see com.sun.star.container.XEnumerationAccess +* @see com.sun.star.container.XElementAccess +* @see com.sun.star.uno.XNamingService +* @see com.sun.star.sdb.DatabaseContext +* @see ifc.container._XNameAccess +* @see ifc.container._XEnumerationAccess +* @see ifc.container._XElementAccess +* @see ifc.uno._XNamingService +*/ +public class ODatabaseContext extends TestCase { + + /** + * Creating a TestEnvironment for the interfaces to be tested. + * Creates service <code>com.sun.star.sdb.DatabaseContext</code>. + * Needed object relations : + * <ul> + * <li> <code>'XNamingService.RegisterObject'</code> for + * {@link ifc.uno._XNamingService} as an + * instance of <code>com.sun.star.sdb.DataSource</code> + * service. </li> + * </ul> + */ + @Override + protected TestEnvironment createTestEnvironment(TestParameters Param, PrintWriter log) throws Exception { + XMultiServiceFactory xMSF = Param.getMSF(); + Object oInterface = xMSF.createInstance( "com.sun.star.sdb.DatabaseContext" ); + XInterface oObj = (XInterface) oInterface; + + log.println( " creating a new environment for object" ); + TestEnvironment tEnv = new TestEnvironment( oObj ); + + // adding obj relation for XNamingService + oInterface = xMSF.createInstance( "com.sun.star.sdb.DataSource" ); + + XPropertySet xDSProps = UnoRuntime.queryInterface(XPropertySet.class, oInterface) ; + + xDSProps.setPropertyValue("URL", "sdbc:dbase:file:///.") ; + + XDocumentDataSource xDDS = UnoRuntime.queryInterface(XDocumentDataSource.class, oInterface); + XStorable store = UnoRuntime.queryInterface(XStorable.class, + xDDS.getDatabaseDocument ()); + String aFile = utils.getOfficeTemp (Param.getMSF ())+"DatabaseContext.odb"; + log.println("store to '" + aFile + "'"); + store.storeAsURL(aFile,new PropertyValue[]{}); + + tEnv.addObjRelation("XNamingService.RegisterObject", oInterface) ; + + tEnv.addObjRelation("INSTANCE", oInterface); + + tEnv.addObjRelation("XContainer.Container", + UnoRuntime.queryInterface( + XNamingService.class, oObj)); + + return tEnv; + } // finish method getTestEnvironment + +} diff --git a/qadevOOo/tests/java/mod/_dbaccess/ODatabaseSource.java b/qadevOOo/tests/java/mod/_dbaccess/ODatabaseSource.java new file mode 100644 index 000000000..1976f5711 --- /dev/null +++ b/qadevOOo/tests/java/mod/_dbaccess/ODatabaseSource.java @@ -0,0 +1,175 @@ +/* + * 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 . + */ + +package mod._dbaccess; + +import com.sun.star.beans.PropertyValue; +import com.sun.star.beans.XPropertySet; +import com.sun.star.frame.XStorable; + + +import com.sun.star.uno.Exception; +import com.sun.star.uno.UnoRuntime; +import com.sun.star.uno.XInterface; +import com.sun.star.uno.XNamingService; +import java.io.PrintWriter; +import lib.StatusException; +import lib.TestCase; +import lib.TestEnvironment; +import lib.TestParameters; +import util.DesktopTools; +import util.utils; + +import com.sun.star.lang.XMultiServiceFactory; +import com.sun.star.sdb.XOfficeDatabaseDocument; +import com.sun.star.task.XInteractionHandler; + +/** +* Test for object which is represented by service +* <code>com.sun.star.sdb.DataSource</code>. <p> +* +* Object implements the following interfaces : +* <ul> +* <li> <code>com::sun::star::sdb::XQueryDefinitionsSupplier</code></li> +* <li> <code>com::sun::star::sdb::DataSource</code></li> +* <li> <code>com::sun::star::sdb::XCompletedConnection</code></li> +* <li> <code>com::sun::star::util::XFlushable</code></li> +* <li> <code>com::sun::star::sdb::XBookmarksSupplier</code></li> +* <li> <code>com::sun::star::beans::XPropertySet</code></li> +* </ul> +* +* @see com.sun.star.sdb.XQueryDefinitionsSupplier +* @see com.sun.star.sdb.XFormDocumentsSupplier +* @see com.sun.star.beans.XPropertySet +* @see com.sun.star.sdb.DataSource +* @see com.sun.star.sdb.XCompletedConnection +* @see com.sun.star.util.XFlushable +* @see com.sun.star.sdb.XReportDocumentsSupplier +* @see ifc.sdb._XQueryDefinitionsSupplier +* @see ifc.sdb._XFormDocumentsSupplier +* @see ifc.beans._XPropertySet +* @see ifc.sdb._DataSource +* @see ifc.sdb._XCompletedConnection +* @see ifc.util._XFlushable +* @see ifc.sdb._XReportDocumentsSupplier +*/ +public class ODatabaseSource extends TestCase { + + private static int uniqueSuffixStat = 0 ; + + private int uniqueSuffix = 0 ; + private XOfficeDatabaseDocument xDBDoc = null; + + /** + * Assigns database's name unique suffix for this object depending + * on static field. For names differs in different object threads. + */ + @Override + protected void initialize ( TestParameters Param, PrintWriter log) throws Exception { + uniqueSuffix = uniqueSuffixStat++ ; + } + + @Override + protected void cleanup(TestParameters tParam, PrintWriter log) { + log.println(" disposing no longer needed docs... "); + DesktopTools.closeDoc(xDBDoc); + } + + + + /** + * Creating a TestEnvironment for the interfaces to be tested. + * + * Creates new <code>DataSource</code> which represents DBase database + * located in temporary directory, and then registers it in service + * <code>com.sun.star.sdb.DatabaseContext</code>. + * + * Created object relations : + * <ul> + * <li> <code>'XCompletedConnection.Handler'</code> for interface test + * <code>XCompletedConnection</code> </li> + * </ul> + * <li> <code>'UserAndPassword'</code> for interface test + * <code>XIsolatedConnection</code> </li> + * </ul> + * @see com.sun.star.sdb.DatabaseContext + * @see com.sun.star.sdb.DataSource + */ + @Override + protected TestEnvironment createTestEnvironment(TestParameters Param, PrintWriter log) throws Exception { + XMultiServiceFactory xMSF = Param.getMSF(); + Object oInterface = xMSF.createInstance( "com.sun.star.sdb.DatabaseContext" ); + + XNamingService xDBContextNameServ = UnoRuntime.queryInterface(XNamingService.class, oInterface) ; + + // retrieving temp directory for database + String tmpDatabaseUrl = utils.getOfficeTempDir(Param.getMSF()); + + tmpDatabaseUrl = "sdbc:dbase:file:///" + tmpDatabaseUrl ; + + XInterface oDatabaseDoc = (XInterface) xMSF.createInstance + ("com.sun.star.sdb.OfficeDatabaseDocument") ; + + if (oDatabaseDoc == null) + throw new StatusException("Could not get service 'com.sun.star.sdb.OfficeDatabaseDocument'", new Exception()); + + xDBDoc = UnoRuntime.queryInterface( + XOfficeDatabaseDocument.class, + oDatabaseDoc); + XInterface oObj = xDBDoc.getDataSource(); + log.println("ImplementationName: " + utils.getImplName(oObj)); + + // Creating new DBase data source in the TEMP directory + + XPropertySet xSrcProp = UnoRuntime.queryInterface(XPropertySet.class, oObj); + + xSrcProp.setPropertyValue("URL", tmpDatabaseUrl) ; + + String databaseName = "NewDatabaseSource" + uniqueSuffix ; + + // make sure that the DatabaseContext isn't already registered + try { + xDBContextNameServ.revokeObject(databaseName) ; + } catch (Exception e) { + log.println("Nothing to be removed - OK"); + } + + // registering source in DatabaseContext + XStorable store = UnoRuntime.queryInterface(XStorable.class, xDBDoc); + String aFile = utils.getOfficeTemp (Param.getMSF ())+"DataSource.odb"; + store.storeAsURL(aFile,new PropertyValue[]{}); + + xDBContextNameServ.registerObject(databaseName, oObj) ; + + log.println( " creating a new environment for object" ); + TestEnvironment tEnv = new TestEnvironment( oObj ); + + // adding obj relation for interface XCompletedConnection + Object handler = Param.getMSF().createInstance + ("com.sun.star.sdb.InteractionHandler") ; + + // dbase does not need user and password + tEnv.addObjRelation("UserAndPassword", new String[]{"",""}) ; + + tEnv.addObjRelation("XCompletedConnection.Handler", + UnoRuntime.queryInterface(XInteractionHandler.class, handler)) ; + + return tEnv; + } // finish method getTestEnvironment + +} diff --git a/qadevOOo/tests/java/mod/_dbaccess/ODatasourceAdministrationDialog.java b/qadevOOo/tests/java/mod/_dbaccess/ODatasourceAdministrationDialog.java new file mode 100644 index 000000000..d229d3eb9 --- /dev/null +++ b/qadevOOo/tests/java/mod/_dbaccess/ODatasourceAdministrationDialog.java @@ -0,0 +1,75 @@ +/* + * 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 . + */ + +package mod._dbaccess; + +import java.io.PrintWriter; + +import lib.TestCase; +import lib.TestEnvironment; +import lib.TestParameters; + +import com.sun.star.uno.XInterface; + +/** +* Test for object which is represented by service +* <code>com.sun.star.sdb.DatasourceAdministrationDialog</code>. <p> +* +* Object implements the following interfaces : +* <ul> +* <li> <code>com::sun::star::lang::XInitialization</code></li> +* <li> <code>com::sun::star::ui::dialogs::XExecutableDialog</code></li> +* <li> <code>com::sun::star::sdb::DatasourceAdministrationDialog</code></li> +* <li> <code>com::sun::star::beans::XPropertySet</code></li> +* </ul> <p> +* +* This object test <b> is NOT </b> designed to be run in several +* threads concurrently. +* +* @see com.sun.star.lang.XInitialization +* @see com.sun.star.ui.dialogs.XExecutableDialog +* @see com.sun.star.sdb.DatasourceAdministrationDialog +* @see com.sun.star.beans.XPropertySet +* @see ifc.lang._XInitialization +* @see ifc.ui.dialogs._XExecutableDialog +* @see ifc.sdb._DatasourceAdministrationDialog +* @see ifc.beans._XPropertySet +*/ +public class ODatasourceAdministrationDialog extends TestCase { + + /** + * Creating a TestEnvironment for the interfaces to be tested. + * Creates an instance of the service + * <code>com.sun.star.sdb.DatasourceAdministrationDialog</code>. + */ + @Override + public TestEnvironment createTestEnvironment( TestParameters Param, + PrintWriter log ) + throws Exception { + Object oInterface = Param.getMSF().createInstance + ("com.sun.star.sdb.DatasourceAdministrationDialog" ); + XInterface oObj = (XInterface) oInterface; + + log.println( " creating a new environment for object" ); + TestEnvironment tEnv = new TestEnvironment( oObj ); + + return tEnv; + } // finish method getTestEnvironment + +} // finish class ODataSourceAdministrationDialog + diff --git a/qadevOOo/tests/java/mod/_dbaccess/ODatasourceBrowser.java b/qadevOOo/tests/java/mod/_dbaccess/ODatasourceBrowser.java new file mode 100644 index 000000000..1ccccf532 --- /dev/null +++ b/qadevOOo/tests/java/mod/_dbaccess/ODatasourceBrowser.java @@ -0,0 +1,297 @@ +/* + * 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 . + */ +package mod._dbaccess; + +import java.io.PrintWriter; + +import lib.TestCase; +import lib.TestEnvironment; +import lib.TestParameters; +import util.DesktopTools; +import util.FormTools; +import util.SOfficeFactory; +import util.WriterTools; + +import com.sun.star.awt.XControl; +import com.sun.star.awt.XControlModel; +import com.sun.star.awt.XWindow; +import com.sun.star.beans.PropertyValue; +import com.sun.star.drawing.XControlShape; +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.lang.XInitialization; +import com.sun.star.text.XTextDocument; +import com.sun.star.uno.UnoRuntime; +import com.sun.star.uno.XInterface; +import com.sun.star.util.URL; +import com.sun.star.util.XCloseable; +import com.sun.star.view.XControlAccess; + + +/** + * Test for object which is represented by service + * <code>com.sun.star.sdb.DataSourceBrowser</code>. <p> + * Object implements the following interfaces : + * <ul> + * <li> <code>com::sun::star::container::XChild</code></li> + * <li> <code>com::sun::star::lang::XInitialization</code></li> + * <li> <code>com::sun::star::util::XModifyBroadcaster</code></li> + * <li> <code>com::sun::star::awt::XTabController</code></li> + * <li> <code>com::sun::star::form::XFormController</code></li> + * <li> <code>com::sun::star::container::XElementAccess</code></li> + * <li> <code>com::sun::star::frame::XDispatchProvider</code></li> + * <li> <code>com::sun::star::container::XEnumerationAccess</code></li> + * <li> <code>com::sun::star::frame::XController</code></li> + * <li> <code>com::sun::star::lang::XComponent</code></li> + * </ul> <p> + * This object test <b> is NOT </b> designed to be run in several + * threads concurrently. + * + * @see com.sun.star.container.XChild + * @see com.sun.star.lang.XInitialization + * @see com.sun.star.util.XModifyBroadcaster + * @see com.sun.star.awt.XTabController + * @see com.sun.star.form.XFormController + * @see com.sun.star.container.XElementAccess + * @see com.sun.star.frame.XDispatchProvider + * @see com.sun.star.container.XEnumerationAccess + * @see com.sun.star.frame.XController + * @see com.sun.star.lang.XComponent + * @see ifc.container._XChild + * @see ifc.lang._XInitialization + * @see ifc.util._XModifyBroadcaster + * @see ifc.awt._XTabController + * @see ifc.form._XFormController + * @see ifc.container._XElementAccess + * @see ifc.frame._XDispatchProvider + * @see ifc.container._XEnumerationAccess + * @see ifc.frame._XController + * @see ifc.lang._XComponent + */ +public class ODatasourceBrowser extends TestCase { + XDesktop xDesktop; + XTextDocument xTextDoc; + + /** + * Creates the Desktop service (<code>com.sun.star.frame.Desktop</code>). + */ + @Override + protected void initialize(TestParameters Param, PrintWriter log) { + xDesktop = DesktopTools.createDesktop(Param.getMSF()); + System.setProperty("hideMe", "false"); + } + + /** + * Disposes the document, if exists, created in + * <code>createTestEnvironment</code> method. + */ + @Override + protected void cleanup(TestParameters Param, PrintWriter log) { + log.println("disposing xTextDoc"); + System.setProperty("hideMe", "true"); + + if (xTextDoc != null) { + log.println(" disposing xTextDoc "); + + try { + XCloseable closer = UnoRuntime.queryInterface( + XCloseable.class, xTextDoc); + closer.close(true); + } catch (com.sun.star.util.CloseVetoException e) { + log.println("couldn't close document"); + } catch (com.sun.star.lang.DisposedException e) { + log.println("couldn't close document"); + } + } + } + + /** + * Creating a TestEnvironment for the interfaces to be tested. + * + * Creates a new text document disposing the old one if it was + * created. Using <code>Desktop</code> service get the frame + * of the document and with its help creates + * <code>DataSourceBrowser</code> dispatching the URL + * <code>'.component:DB/DataSourceBrowser'</code>. The + * component for testing is the controller of the + * <code>Browser</code> and it's got by searching its + * frame with the help of TextDocument frame, and obtaining + * the frame's controller. <p> + * + * <b>Note</b>: after creating the text document a short + * pause is needed to give a possibility to a frame to be + * created for the document. Else + * <code>Desktop.getCurrentFrame()</code> method can return + * <code>null</code> value. <p> + * + * Object relations created : + * <ul> + * <li> <code>'XDispatchProvider.URL'</code> for + * {@link ifc.frame._XDispatchProvider} </li> + * <li> <code>'SecondModel'</code> for + * {@link ifc.frame._XController} : the model of + * the TextDocument. </li> + * <li> <code>'otherWindow'</code> for + * {@link ifc.frame._XController} : the window of + * the added shape. </li> + * <li> <code>'SecondController'</code> for + * {@link ifc.frame._XController} : the controller of + * the TextDocument. </li> + * <li> <code>'HasViewData'</code> for + * {@link ifc.frame._XController} : the + * <code>DataSourceBrowser</code> has no view data. </li> + * <li> <code>'XInitialization.args'</code> for + * {@link ifc.lang._XInitialization} : the arguments for + * the initialization</li> + * </ul> + * + * @see com.sun.star.frame.Desktop + * @see com.sun.star.frame.XModel + * @see com.sun.star.frame.XFrame + * @see com.sun.star.frame.XController + * @see com.sun.star.frame.XDispatchProvider + */ + @Override + protected TestEnvironment createTestEnvironment(TestParameters Param, + PrintWriter log) throws Exception { + log.println("creating a test environment"); + + if (xTextDoc != null) { + log.println(" disposing xTextDoc "); + + try { + XCloseable closer = UnoRuntime.queryInterface( + XCloseable.class, xTextDoc); + closer.close(true); + } catch (com.sun.star.util.CloseVetoException e) { + log.println("couldn't close document"); + } catch (com.sun.star.lang.DisposedException e) { + log.println("couldn't close document"); + } + } + + // get a soffice factory object + SOfficeFactory SOF = SOfficeFactory.getFactory(Param.getMSF()); + + log.println("creating a text document"); + xTextDoc = SOF.createTextDoc(null); + + util.utils.waitForEventIdle(Param.getMSF()); + + XModel aModel1 = UnoRuntime.queryInterface(XModel.class, + xTextDoc); + + XController secondController = aModel1.getCurrentController(); + + XFrame the_frame1 = xDesktop.getCurrentFrame(); + + if (the_frame1 == null) { + log.println("Current frame was not found !!!"); + } + + XDispatchProvider aProv = UnoRuntime.queryInterface( + XDispatchProvider.class, the_frame1); + + XDispatch getting = null; + + log.println("opening DatasourceBrowser"); + + URL the_url = new URL(); + the_url.Complete = ".component:DB/DataSourceBrowser"; + getting = aProv.queryDispatch(the_url, "_beamer", 12); + + PropertyValue[] noArgs = new PropertyValue[0]; + getting.dispatch(the_url, noArgs); + + XFrame the_frame2 = the_frame1.findFrame("_beamer", 4); + + the_frame2.setName("DatasourceBrowser"); + + XInterface oObj = the_frame2.getController(); + + Object[] params = new Object[3]; + PropertyValue param1 = new PropertyValue(); + param1.Name = "DataSourceName"; + param1.Value = "Bibliography"; + params[0] = param1; + + PropertyValue param2 = new PropertyValue(); + param2.Name = "CommandType"; + param2.Value = Integer.valueOf(com.sun.star.sdb.CommandType.TABLE); + params[1] = param2; + + PropertyValue param3 = new PropertyValue(); + param3.Name = "Command"; + param3.Value = "biblio"; + params[2] = param3; + + XInitialization xInit = UnoRuntime.queryInterface( + XInitialization.class, oObj); + xInit.initialize(params); + + util.utils.waitForEventIdle(Param.getMSF()); + + XControlShape aShape = FormTools.createControlShape(xTextDoc, 3000, + 4500, 15000, 10000, + "CommandButton"); + WriterTools.getDrawPage(xTextDoc).add(aShape); + + XControlModel shapeModel = aShape.getControl(); + + XControlAccess xCtrlAccess = UnoRuntime.queryInterface( + XControlAccess.class, + secondController); + XControl xCtrl = null; + + try { + xCtrl = xCtrlAccess.getControl(shapeModel); + } catch (com.sun.star.uno.Exception e) { + // Some exception occurs.FAILED + e.printStackTrace(log); + } + + XWindow docWindow = UnoRuntime.queryInterface(XWindow.class, + xCtrl); + log.println("creating a new environment for ODatasourceBrowser object"); + + TestEnvironment tEnv = new TestEnvironment(oObj); + + + //Adding ObjRelations for XInitialization + tEnv.addObjRelation("XInitialization.args", params); + + + //Adding ObjRelations for XController + tEnv.addObjRelation("Frame", the_frame1); + tEnv.addObjRelation("SecondModel", aModel1); + tEnv.addObjRelation("otherWindow", docWindow); + tEnv.addObjRelation("SecondController", secondController); + tEnv.addObjRelation("HasViewData", Boolean.FALSE); + + + //Adding relation for XDispatchProvider + tEnv.addObjRelation("XDispatchProvider.URL", + ".uno:DataSourceBrowser/FormLetter"); + + return tEnv; + } // finish method getTestEnvironment +} // finish class oDatasourceBrowser diff --git a/qadevOOo/tests/java/mod/_dbaccess/OInteractionHandler.java b/qadevOOo/tests/java/mod/_dbaccess/OInteractionHandler.java new file mode 100644 index 000000000..a5ec54f9e --- /dev/null +++ b/qadevOOo/tests/java/mod/_dbaccess/OInteractionHandler.java @@ -0,0 +1,90 @@ +/* + * 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 . + */ + +package mod._dbaccess; + +import java.io.PrintWriter; + +import lib.TestCase; +import lib.TestEnvironment; +import lib.TestParameters; + +import com.sun.star.sdbc.SQLException; +import com.sun.star.task.XInteractionContinuation; +import com.sun.star.task.XInteractionRequest; +import com.sun.star.uno.XInterface; + +/** +* Test for object which is represented by service +* <code>com.sun.star.sdb.InteractionHandler</code>. <p> +* Object implements the following interfaces : +* <ul> +* <li> <code>com::sun::star::task::XInteractionHandler</code></li> +* </ul> +* This object test <b> is NOT </b> designed to be run in several +* threads concurrently. +* @see com.sun.star.task.XInteractionHandler +* @see com.sun.star.sdb.InteractionHandler +* @see ifc.task._XInteractionHandler +*/ +public class OInteractionHandler extends TestCase { + + + private static class TestRequest implements XInteractionRequest { + public Object getRequest() { + return new SQLException("Test exception") ; + } + + public XInteractionContinuation[] getContinuations() { + return new XInteractionContinuation[0] ; + } + } + + + /** + * Creating a TestEnvironment for the interfaces to be tested. + * Creates an instance of the service + * <code>com.sun.star.sdb.InteractionHandler</code>. + * Object relations created : + * <ul> + * <li> <code>'XInteractionHandler.Request'</code> for + * {@link ifc.task._XInteractionHandler} : this relation + * is <code>com.sun.star.task.XInteractionRequest</code> + * interface implementation which depends on the component + * tested. In this case it emulates SQL error by returning + * <code>SQLException</code> object. </li> + * </ul> + */ + @Override + public TestEnvironment createTestEnvironment( TestParameters Param, + PrintWriter log ) + throws Exception { + Object oInterface = Param.getMSF().createInstance( + "com.sun.star.sdb.InteractionHandler" ); + XInterface oObj = (XInterface) oInterface; + + log.println( " creating a new environment for object" ); + TestEnvironment tEnv = new TestEnvironment( oObj ); + + tEnv.addObjRelation("XInteractionHandler.Request", new TestRequest()) ; + + return tEnv; + } // finish method getTestEnvironment + +} + diff --git a/qadevOOo/tests/java/mod/_dbaccess/OQueryDesign.java b/qadevOOo/tests/java/mod/_dbaccess/OQueryDesign.java new file mode 100644 index 000000000..1124d12f9 --- /dev/null +++ b/qadevOOo/tests/java/mod/_dbaccess/OQueryDesign.java @@ -0,0 +1,224 @@ +/* + * 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 . + */ +package mod._dbaccess; + +import com.sun.star.sdbc.XConnection; +import com.sun.star.uno.Exception; +import java.io.PrintWriter; + +import lib.Status; +import lib.StatusException; +import lib.TestCase; +import lib.TestEnvironment; +import lib.TestParameters; +import util.DesktopTools; + +import com.sun.star.beans.PropertyValue; +import com.sun.star.container.XNameAccess; +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.lang.XInitialization; +import com.sun.star.lang.XMultiServiceFactory; +import com.sun.star.text.XTextDocument; +import com.sun.star.uno.UnoRuntime; +import com.sun.star.uno.XInterface; +import com.sun.star.util.URL; +import util.SOfficeFactory; +import com.sun.star.sdb.XDocumentDataSource; +import com.sun.star.sdbc.XDataSource; + +public class OQueryDesign extends TestCase { + + private static XDesktop xDesk; + private static XFrame xFrame; + private static final String sDataSourceName = "Bibliography"; + private static XConnection xConn; + private static XTextDocument xTextDoc; + + + /** + * Creates the Desktop service (<code>com.sun.star.frame.Desktop</code>). + */ + @Override + protected void initialize(TestParameters Param, PrintWriter log) throws Exception { + xDesk = DesktopTools.createDesktop(Param.getMSF()); + } + + @Override + protected TestEnvironment createTestEnvironment(TestParameters Param, PrintWriter log) throws Exception { + + log.println( "creating a test environment" ); + + XDispatchProvider aProv = UnoRuntime.queryInterface(XDispatchProvider.class,xDesk); + XMultiServiceFactory xMSF = Param.getMSF(); + + // we use the first datasource + XNameAccess xNameAccess = UnoRuntime.queryInterface( + XNameAccess.class, + xMSF.createInstance("com.sun.star.sdb.DatabaseContext")); + XDataSource xDS = UnoRuntime.queryInterface( + XDataSource.class, xNameAccess.getByName( "Bibliography" )); + + log.println("check XMultiServiceFactory"); + + xConn = xDS.getConnection("", ""); + + log.println( "opening QueryDesign" ); + URL the_url = new URL(); + the_url.Complete = ".component:DB/QueryDesign"; + XDispatch getting = aProv.queryDispatch(the_url,"Query",12); + PropertyValue[] Args = new PropertyValue[2]; + PropertyValue param1 = new PropertyValue(); + param1.Name = "DataSourceName"; + param1.Value = "Bibliography"; + Args[0] = param1; + PropertyValue param2 = new PropertyValue(); + param2.Name = "QueryDesignView"; + param2.Value = Boolean.FALSE; + Args[1] = param2; + param1.Name = "ActiveConnection"; + param1.Value = xConn; + Args[1] = param2; + getting.dispatch(the_url,Args); + + util.utils.waitForEventIdle(Param.getMSF()); + + Object oDBC = xMSF.createInstance( "com.sun.star.sdb.DatabaseContext" ); + + Object oDataSource = null; + XNameAccess xNA = UnoRuntime.queryInterface(XNameAccess.class, oDBC); + oDataSource = xNA.getByName(sDataSourceName); + UnoRuntime.queryInterface(XDocumentDataSource.class, oDataSource); + + xFrame = DesktopTools.getCurrentFrame(xMSF); + + SOfficeFactory SOF = null; + + SOF = SOfficeFactory.getFactory( xMSF ); + log.println( "creating a textdocument" ); + xTextDoc = SOF.createTextDoc( null ); + + XModel xDocMod = UnoRuntime.queryInterface(XModel.class, xTextDoc); + + XFrame xTextFrame = xDocMod.getCurrentController().getFrame(); + + Object[] params = new Object[3]; + param1 = new PropertyValue(); + param1.Name = "DataSourceName"; + param1.Value = "Bibliography"; + params[0] = param1; + param2 = new PropertyValue(); + param2.Name = "Frame"; + param2.Value = xTextFrame; + params[1] = param2; + PropertyValue param3 = new PropertyValue(); + param3.Name = "QueryDesignView"; + param3.Value = Boolean.TRUE; + params[2] = param3; + + + XInterface oObj = xFrame.getController(); + + TestEnvironment tEnv = new TestEnvironment(oObj); + + //Adding ObjRelations for XInitialization + tEnv.addObjRelation("XInitialization.args", params); + + Object[] ExceptionParams = new Object[3]; + PropertyValue ExceptionParam1 = new PropertyValue(); + ExceptionParam1.Name = "DataSourceName"; + ExceptionParam1.Value = "Bibliography2"; + ExceptionParams[0] = ExceptionParam1; + PropertyValue ExceptionParam2 = new PropertyValue(); + ExceptionParam2.Name = "Frame"; + ExceptionParam2.Value = null; + ExceptionParams[1] = ExceptionParam2; + PropertyValue ExceptionParam3 = new PropertyValue(); + ExceptionParam3.Name = "QueryDesignView"; + ExceptionParam3.Value = Integer.valueOf(17);//Boolean.TRUE; + ExceptionParams[2] = ExceptionParam3; + + tEnv.addObjRelation("XInitialization.ExceptionArgs", ExceptionParams); + + tEnv.addObjRelation("Frame", xFrame); + + tEnv.addObjRelation("XInitialization.xIni", getUninitializedObj(Param)); + + log.println("ImplementationName: "+util.utils.getImplName(oObj)); + + return tEnv; + + } // finish method getTestEnvironment + + private XInitialization getUninitializedObj(TestParameters Param) throws Exception { + // creating an object which ist not initialized + + // get a model of a DataSource + Object oDBC = null; + XMultiServiceFactory xMSF; + + xMSF = Param.getMSF(); + oDBC = xMSF.createInstance( "com.sun.star.sdb.DatabaseContext" ); + + Object oDataSource = null; + XNameAccess xNA = UnoRuntime.queryInterface(XNameAccess.class, oDBC); + oDataSource = xNA.getByName(sDataSourceName); + + XDocumentDataSource xDDS = UnoRuntime.queryInterface(XDocumentDataSource.class, oDataSource); + XModel xMod = UnoRuntime.queryInterface(XModel.class, xDDS.getDatabaseDocument ()); + + // get an instance of QueryDesign + Object oQueryDesign = xMSF.createInstance("com.sun.star.sdb.QueryDesign"); + + XController xCont = UnoRuntime.queryInterface(XController.class, oQueryDesign); + + // marry them all + boolean bSuccess = xCont.attachModel(xMod); + if (!bSuccess) + { + throw new StatusException (Status.failed ( + "Couldn't attach model")); + } + + xMod.connectController(xCont); + xMod.setCurrentController(xCont); + + return UnoRuntime.queryInterface(XInitialization.class, oQueryDesign); + } + + @Override + protected void cleanup(TestParameters tParam, PrintWriter log) { + try { + xConn.close() ; + DesktopTools.closeDoc(xFrame); + DesktopTools.closeDoc(xTextDoc); + } catch (com.sun.star.uno.Exception e) { + log.println("Can't close the connection") ; + e.printStackTrace(log) ; + } catch (com.sun.star.lang.DisposedException e) { + log.println("Connection was already closed. It's OK.") ; + } + + } + +} // finish class oDatasourceBrowser + diff --git a/qadevOOo/tests/java/mod/_dbaccess/ORowSet.java b/qadevOOo/tests/java/mod/_dbaccess/ORowSet.java new file mode 100644 index 000000000..6e0a758e0 --- /dev/null +++ b/qadevOOo/tests/java/mod/_dbaccess/ORowSet.java @@ -0,0 +1,608 @@ +/* + * 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 . + */ + +package mod._dbaccess; + +import ifc.sdb._XCompletedExecution; + +import java.io.OutputStreamWriter; +import java.io.PrintWriter; +import java.io.UnsupportedEncodingException; +import java.util.ArrayList; +import lib.StatusException; +import lib.TestCase; +import lib.TestEnvironment; +import lib.TestParameters; +import util.DBTools; +import util.utils; +import util.db.DataSource; +import util.db.DataSourceDescriptor; + +import com.sun.star.beans.PropertyValue; +import com.sun.star.beans.XPropertySet; +import com.sun.star.frame.XModel; +import com.sun.star.lang.XComponent; +import com.sun.star.lang.XMultiServiceFactory; +import com.sun.star.sdb.CommandType; +import com.sun.star.sdb.ParametersRequest; +import com.sun.star.sdb.RowChangeEvent; +import com.sun.star.sdb.XInteractionSupplyParameters; +import com.sun.star.sdbc.SQLException; +import com.sun.star.sdbc.XConnection; +import com.sun.star.sdbc.XParameters; +import com.sun.star.sdbc.XResultSet; +import com.sun.star.sdbc.XResultSetUpdate; +import com.sun.star.sdbc.XRow; +import com.sun.star.sdbc.XRowSet; +import com.sun.star.sdbc.XRowUpdate; +import com.sun.star.task.XInteractionAbort; +import com.sun.star.task.XInteractionContinuation; +import com.sun.star.task.XInteractionRequest; +import com.sun.star.ucb.AuthenticationRequest; +import com.sun.star.uno.UnoRuntime; +import com.sun.star.uno.XInterface; +import com.sun.star.util.XCloseable; + +/** + * Test for object which is represented by service + * <code>com.sun.star.sdb.RowSet</code>. <p> + * + * The following files used by this test : + * <ul> + * <li><b> TestDB/TestDB.dbf </b> : the database file with some + * predefined fields described in <code>util.DBTools</code>. + * The copy of this file is always made in temp directory for + * testing purposes.</li> + * </ul> + * The following parameters in ini-file used by this test: + * <ul> + * <li><code>test.db.url</code> - URL to MySQL database. + * For example: <code>mysql://mercury:3306/api_current</code></li> + * <li><code>test.db.user</code> - user for MySQL database</li> + * <li><code>test.db.password</code> - password for MySQL database</li> + * </ul> + * + * @see com.sun.star.sdbc.RowSet + * @see com.sun.star.sdbcx.XRowLocate + * @see com.sun.star.sdbc.XResultSetUpdate + * @see com.sun.star.util.XCancellable + * @see com.sun.star.sdbc.XParameters + * @see com.sun.star.sdbc.XResultSetMetaDataSupplier + * @see com.sun.star.sdbcx.XDeleteRows + * @see com.sun.star.sdbc.XCloseable + * @see com.sun.star.sdbcx.XColumnsSupplier + * @see com.sun.star.sdb.XResultSetAccess + * @see com.sun.star.sdbc.XResultSet + * @see com.sun.star.sdbc.XColumnLocate + * @see com.sun.star.sdbc.XRowSet + * @see com.sun.star.sdb.RowSet + * @see com.sun.star.sdbc.XRowUpdate + * @see com.sun.star.sdb.XRowSetApproveBroadcaster + * @see com.sun.star.beans.XPropertySet + * @see com.sun.star.sdbc.XRow + * @see com.sun.star.sdbc.XWarningsSupplier + * @see com.sun.star.lang.XComponent + * @see com.sun.star.sdbcx.ResultSet + * @see com.sun.star.sdbc.ResultSet + * @see ifc.sdbc._RowSet + * @see ifc.sdbcx._XRowLocate + * @see ifc.sdbc._XResultSetUpdate + * @see ifc.util._XCancellable + * @see ifc.sdbc._XParameters + * @see ifc.sdbc._XResultSetMetaDataSupplier + * @see ifc.sdbcx._XDeleteRows + * @see ifc.sdbc._XCloseable + * @see ifc.sdbcx._XColumnsSupplier + * @see ifc.sdb._XResultSetAccess + * @see ifc.sdbc._XResultSet + * @see ifc.sdbc._XColumnLocate + * @see ifc.sdbc._XRowSet + * @see ifc.sdb._RowSet + * @see ifc.sdbc._XRowUpdate + * @see ifc.sdb._XRowSetApproveBroadcaster + * @see ifc.beans._XPropertySet + * @see ifc.sdbc._XRow + * @see ifc.sdbc._XWarningsSupplier + * @see ifc.lang._XComponent + * @see ifc.sdbcx._ResultSet + * @see ifc.sdbc._ResultSet + */ +public class ORowSet extends TestCase { + + private static int uniqueSuffix = 0 ; + private DBTools dbTools = null ; + private static String origDB = null ; + String tableName = null; + DataSourceDescriptor srcInf = null; + boolean isMySQLDB = false; + protected static final String dbSourceName = "ORowSetDataSource"; + public XConnection m_connection = null; + private Object m_rowSet = null; + private DataSource m_dataSource; + private String m_tableFile; + + /** + * Initializes some class fields. Then creates DataSource, which serves + * as a single source for all tables created in the test. + * This DataSource then registered in the global + * <code>DatabaseContext</code> service. This data source's URL + * points to SOffice temp directory where tables are copied from + * <code>TestDocuments</code> directory on every environment + * creation. + * To create DataSource for MySQL database next parameters required + * in ini-file: + * <ul> + * <li><code>test.db.url</code> - URL to MySQL database. + * For example: <code>mysql://mercury:3306/api_current</code></li> + * <li><code>test.db.user</code> - user for MySQL database</li> + * <li><code>test.db.password</code> - password for MySQL database</li> + * </ul> + * + * @throws StatusException if DataSource can not be created or + * registered. + */ + @Override + protected void initialize ( TestParameters Param, PrintWriter _log) + throws StatusException + { + XMultiServiceFactory orb = Param.getMSF(); + + String tmpDir = utils.getOfficeTemp( orb ); + + origDB = util.utils.getFullTestDocName("TestDB/testDB.dbf"); + + dbTools = new DBTools( orb ); + + // creating DataSource and registering it in DatabaseContext + String dbURL = (String) Param.get("test.db.url"); + String dbUser = (String) Param.get("test.db.user"); + String dbPassword = (String) Param.get("test.db.password"); + + log.println("Creating and registering DataSource ..."); + srcInf = new DataSourceDescriptor( orb ); + if (dbURL != null && dbUser != null && dbPassword != null) + { + isMySQLDB = true; + log.println("dbURL = " + dbURL); + log.println("dbUSER = " + dbUser); + log.println("dbPASSWORD = " + dbPassword); + //DataSource for mysql db + tableName = "soffice_test_table"; + srcInf.URL = "jdbc:" + dbURL; + srcInf.IsPasswordRequired = Boolean.TRUE; + srcInf.Password = dbPassword; + srcInf.User = dbUser; + PropertyValue[] propInfo = new PropertyValue[1]; + propInfo[0] = new PropertyValue(); + propInfo[0].Name = "JavaDriverClass"; + propInfo[0].Value = "org.gjt.mm.mysql.Driver"; + srcInf.Info = propInfo; + } + else + { + srcInf.URL = "sdbc:dbase:" + DBTools.dirToUrl(tmpDir); + } + m_dataSource = srcInf.createDataSource(); + m_dataSource.registerAs( dbSourceName, true ); + } + + /** + * Creating a TestEnvironment for the interfaces to be tested. + * The database (DBF) file is copied from test document directory + * into SOffice temp dir with unique name for each environment + * creation. If the file can't be copied (is not released) + * then another unique name is used (file name suffix incremented + * by 1).<p> + * + * <code>com.sun.star.sdb.RowSet</code> service created and its + * source is all rows from the current copy of the table. Then + * row set command ("select all rows from a table") is executed + * and cursor is positioned to the first row. <p> + * + * Object relations created : + * <ul> + * <li> <code>'ORowSet.Connection'</code> for + * internal component test usage. Is used for + * closing connection when cleaning up environment. </li> + * <li> <code>'XRowSetApproveBroadcaster.ApproveChecker'</code> for + * {@link ifc.sdb._XRowSetApproveBroadcaster} interface + * implementation which made actions required </li> + * <li> <code>'CurrentRowData'</code> for + * {@link ifc.sdbc._XRow}, {@link ifc.sdbc._XRowUpdate} : + * exports types and values of the current row data.</li> + * <li> <code>'XColumnLocate.ColumnName'</code> for + * {@link ifc.sdbc._XColumnLocate} : + * the name of the first column of the table.</li> + * <li> <code>'XParameters.ParamValues'</code> for + * {@link ifc.sdbc._XParameters} : + * Collection of parameter types presented in the query. </li> + * <li> <code>'XRowUpdate.XRow'</code> for + * {@link ifc.sdbc._XRowUpdate} : + * <code>XRow</code> interface of the current component.</li> + * <li> <code>'XResultSetUpdate.UpdateTester'</code> for + * {@link ifc.sdbc._XResultSetUpdate} </li> + * </ul> + * + * @see com.sun.star.sdb.DatabaseContext + * @see com.sun.star.sdb.DataSource + */ + @Override + protected TestEnvironment createTestEnvironment(TestParameters Param, + PrintWriter log) throws Exception + { + XMultiServiceFactory orb = Param.getMSF(); + uniqueSuffix++; + boolean envCreatedOK = false ; + + //initialize test table + if (isMySQLDB) + { + DBTools.DataSourceInfo legacyDescriptor = dbTools.newDataSourceInfo(); + legacyDescriptor.Name = null; + legacyDescriptor.User = srcInf.User; + legacyDescriptor.Password = srcInf.Password; + legacyDescriptor.Info = srcInf.Info; + legacyDescriptor.URL = srcInf.URL; + legacyDescriptor.IsPasswordRequired = srcInf.IsPasswordRequired; + dbTools.initTestTableUsingJDBC(tableName, legacyDescriptor); + } + else + { + String oldF = null ; + String newF = null ; + String tempFolder = utils.getOfficeTemp( orb ); + do + { + tableName = "ORowSet_tmp" + uniqueSuffix ; + oldF = utils.getFullURL(origDB); + newF = tempFolder + tableName + ".dbf"; + } + while ( !utils.tryOverwriteFile( orb, oldF, newF ) ); + m_tableFile = newF; + } + + try + { + m_rowSet = orb.createInstance("com.sun.star.sdb.RowSet"); + + XPropertySet rowSetProps = UnoRuntime.queryInterface( XPropertySet.class, m_rowSet ); + + log.println("Trying to open: " + tableName); + + rowSetProps.setPropertyValue("DataSourceName", dbSourceName); + rowSetProps.setPropertyValue("Command", tableName); + rowSetProps.setPropertyValue("CommandType", + Integer.valueOf(CommandType.TABLE)); + + final XRowSet rowSet = UnoRuntime.queryInterface( XRowSet.class, m_rowSet); + rowSet.execute(); + m_connection = UnoRuntime.queryInterface( XConnection.class, rowSetProps.getPropertyValue("ActiveConnection") ); + + XResultSet xRes = UnoRuntime.queryInterface( XResultSet.class, m_rowSet ); + xRes.first(); + + log.println( "creating a new environment for object" ); + TestEnvironment tEnv = new TestEnvironment( (XInterface)m_rowSet ); + + // Adding obj relation for XRowSetApproveBroadcaster test + { + final XResultSet resultSet = UnoRuntime.queryInterface( XResultSet.class, m_rowSet ); + final XResultSetUpdate resultSetUpdate = UnoRuntime.queryInterface( XResultSetUpdate.class, m_rowSet ); + final XRowUpdate rowUpdate = UnoRuntime.queryInterface(XRowUpdate.class, m_rowSet ); + final PrintWriter logF = log ; + tEnv.addObjRelation( "XRowSetApproveBroadcaster.ApproveChecker", + new ifc.sdb._XRowSetApproveBroadcaster.RowSetApproveChecker() + { + public void moveCursor() + { + try + { + resultSet.beforeFirst(); + resultSet.afterLast(); + resultSet.first(); + } + catch (com.sun.star.sdbc.SQLException e) + { + logF.println("### _XRowSetApproveBroadcaster.RowSetApproveChecker.moveCursor() :"); + e.printStackTrace(logF); + throw new StatusException( "RowSetApproveChecker.moveCursor failed", e ); + } + } + public RowChangeEvent changeRow() + { + try + { + resultSet.first(); + rowUpdate.updateString(1, "ORowSetTest2"); + resultSetUpdate.updateRow(); + } + catch (com.sun.star.sdbc.SQLException e) + { + logF.println("### _XRowSetApproveBroadcaster.RowSetApproveChecker.changeRow() :"); + e.printStackTrace(logF); + throw new StatusException( "RowSetApproveChecker.changeRow failed", e ); + } + RowChangeEvent ev = new RowChangeEvent(); + ev.Action = com.sun.star.sdb.RowChangeAction.UPDATE ; + ev.Rows = 1 ; + + return ev ; + } + public void changeRowSet() + { + try + { + // since we gave the row set a parametrized statement, we need to ensure the + // parameter is actually filled, otherwise we would get an empty result set, + // which would imply some further tests failing + XParameters rowSetParams = UnoRuntime.queryInterface( XParameters.class, resultSet ); + rowSetParams.setString( 1, "String2" ); + rowSet.execute(); + resultSet.first(); + } + catch (com.sun.star.sdbc.SQLException e) + { + logF.println("### _XRowSetApproveBroadcaster.RowSetApproveChecker.changeRowSet() :"); + e.printStackTrace(logF); + throw new StatusException( "RowSetApproveChecker.changeRowSet failed", e ); + } + } + } + ); + } + // Adding relations for XRow as a Vector with all data + // of current row of RowSet. + + ArrayList<Object> rowData = new ArrayList<Object>(); + + for (int i = 0; i < DBTools.TST_TABLE_VALUES[0].length; i++) { + rowData.add(DBTools.TST_TABLE_VALUES[0][i]); + } + + // here XRef must be added + // here XBlob must be added + // here XClob must be added + // here XArray must be added + + tEnv.addObjRelation("CurrentRowData", rowData); + + // Adding relation for XColumnLocate ifc test + tEnv.addObjRelation( "XColumnLocate.ColumnName", DBTools.TST_STRING_F ); + + // Adding relation for XCompletedExecution + tEnv.addObjRelation( "InteractionHandlerChecker", new InteractionHandlerImpl() ); + String sqlCommand = isMySQLDB + ? "SELECT Column0 FROM soffice_test_table WHERE ( ( Column0 = :param1 ) )" + : "SELECT \"_TEXT\" FROM \"" + tableName + "\" WHERE ( ( \"_TEXT\" = :param1 ) )"; + rowSetProps.setPropertyValue( "DataSourceName", dbSourceName ); + rowSetProps.setPropertyValue( "Command", sqlCommand ); + rowSetProps.setPropertyValue( "CommandType", Integer.valueOf(CommandType.COMMAND) ); + + // Adding relation for XParameters ifc test + tEnv.addObjRelation( "XParameters.ParamValues", new ArrayList<String>() ); + + // Adding relation for XRowUpdate + final XRow row = UnoRuntime.queryInterface( XRow.class, m_rowSet ); + tEnv.addObjRelation("XRowUpdate.XRow", row); + + // Adding relation for XResultSetUpdate + { + final XResultSet resultSet = UnoRuntime.queryInterface( XResultSet.class, m_rowSet ); + final XRowUpdate rowUpdate = UnoRuntime.queryInterface( XRowUpdate.class, m_rowSet ); + + tEnv.addObjRelation("XResultSetUpdate.UpdateTester", + new ifc.sdbc._XResultSetUpdate.UpdateTester() + { + String lastUpdate = null ; + + public int rowCount() throws SQLException + { + int prevPos = resultSet.getRow(); + resultSet.last(); + int count = resultSet.getRow(); + resultSet.absolute(prevPos); + + return count ; + } + + public void update() throws SQLException + { + lastUpdate = row.getString(1); + lastUpdate += "_" ; + rowUpdate.updateString(1, lastUpdate); + } + + public boolean wasUpdated() throws SQLException + { + String getStr = row.getString(1); + return lastUpdate.equals(getStr); + } + + public int currentRow() throws SQLException + { + return resultSet.getRow(); + } + } + ); + } + + envCreatedOK = true ; + return tEnv; + + } + finally + { + if (!envCreatedOK) + { + try + { + m_connection.close(); + } + catch(Exception ex) + { + System.out.println("caught exception: " + ex); + } + } + } + + } // finish method getTestEnvironment + + /** + * Closes connection of <code>RowSet</code> instance created. + */ + @Override + protected void cleanup( TestParameters Param, PrintWriter log) + { + String doing = null; + try + { + doing = "revoking data source registration"; + log.println( doing ); + m_dataSource.revokeRegistration(); + + doing = "closing database document"; + log.println( doing ); + XModel databaseDocModel = UnoRuntime.queryInterface( XModel.class, + m_dataSource.getDatabaseDocument().getDatabaseDocument() ); + String documentFile = databaseDocModel.getURL(); + + XCloseable closeModel = UnoRuntime.queryInterface( XCloseable.class, + m_dataSource.getDatabaseDocument().getDatabaseDocument() ); + closeModel.close( true ); + + if ( m_rowSet != null ) + { + doing = "disposing row set"; + log.println( doing ); + XComponent rowSetComponent = UnoRuntime.queryInterface( XComponent.class, m_rowSet ); + rowSetComponent.dispose(); + } + + try + { + doing = "closing connection"; + log.println( doing ); + m_connection.close(); + } + catch (com.sun.star.lang.DisposedException e) + { + log.println( "already closed - okay." ); + } + + doing = "deleting database file (" + documentFile + ")"; + log.println( doing ); + impl_deleteFile( documentFile ); + + if ( m_tableFile != null ) + { + doing = "deleting dBase table file (" + m_tableFile + ")"; + log.println( doing ); + impl_deleteFile( m_tableFile ); + } + } + catch (com.sun.star.uno.Exception e) + { + log.println( "error: "); + e.printStackTrace(log); + } + } + + private final void impl_deleteFile( final String _file ) + { + java.io.File file = new java.io.File( _file ); + + boolean bDeleteOk = file.delete(); + if (!bDeleteOk && file.exists()) + file.deleteOnExit(); + } + + /** + * Implementation of interface _XCompletedExecution.CheckInteractionHandler + * for the XCompletedExecution test + * @see ifc.sdb._XCompletedExecution + */ + private static class InteractionHandlerImpl implements _XCompletedExecution.CheckInteractionHandler { + + private boolean handlerWasUsed = false; + private PrintWriter log; + + InteractionHandlerImpl() throws UnsupportedEncodingException { + log = new PrintWriter(new OutputStreamWriter(System.out, "UTF-8")); + } + + public boolean checkInteractionHandler() { + return handlerWasUsed; + } + + public void handle(XInteractionRequest xInteractionRequest) { + log.println("### _XCompletedExecution.InteractionHandlerImpl: handle called."); + boolean abort = false; + + Object o = xInteractionRequest.getRequest(); + if (o instanceof ParametersRequest) { + } + else if (o instanceof AuthenticationRequest) { + log.println("### The request in XCompletedExecution is of type 'AuthenticationRequest'"); + log.println("### This is not implemented in ORowSet.InteractionHandlerImpl test -> abort."); + abort = true; + } + else { + log.println("### Unknown request:" + o.toString()); + log.println("### This is not implemented in ORowSet.InteractionHandlerImpl test -> abort."); + abort = true; + } + + XInteractionContinuation[]xCont = xInteractionRequest.getContinuations(); + XInteractionSupplyParameters xParamCallback = null; + for(int i=0; i<xCont.length; i++) { + if (abort) { + XInteractionAbort xAbort = null; + xAbort = UnoRuntime.queryInterface(XInteractionAbort.class, xCont[i]); + if (xAbort != null) + xAbort.select(); + return; + } + else { + xParamCallback = UnoRuntime.queryInterface(XInteractionSupplyParameters.class, xCont[i]); + if (xParamCallback != null) + break; + } + } + if (xParamCallback != null) { + log.println("### _XCompletedExecution.InteractionHandlerImpl: supplying parameters."); + handlerWasUsed = true; + PropertyValue[] prop = new PropertyValue[1]; + prop[0] = new PropertyValue(); + prop[0].Name = "param1"; + prop[0].Value = "Hi."; + + xParamCallback.setParameters(prop); + xParamCallback.select(); + } + else { // we should never reach this: abort has to be true first. + log.println("### _XCompletedExecution.InteractionHandlerImpl: Got no " + + "'XInteractionSupplyParameters' and no 'XInteractionAbort'."); + } + } + + public void setLog(PrintWriter log) { + this.log = log; + } + + } +} diff --git a/qadevOOo/tests/java/mod/_dbaccess/OSQLMessageDialog.java b/qadevOOo/tests/java/mod/_dbaccess/OSQLMessageDialog.java new file mode 100644 index 000000000..2fe02240c --- /dev/null +++ b/qadevOOo/tests/java/mod/_dbaccess/OSQLMessageDialog.java @@ -0,0 +1,127 @@ +/* + * 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 . + */ + +package mod._dbaccess; + +import java.io.PrintWriter; + +import lib.TestCase; +import lib.TestEnvironment; +import lib.TestParameters; + +import com.sun.star.uno.UnoRuntime; +import com.sun.star.uno.XInterface; + +/** + * Test for object which is represented by service + * <code>com.sun.star.sdb.ErrorMessageDialog</code>. + * <p> + * Object implements the following interfaces : + * <ul> + * <li> <code>com::sun::star::lang::XInitialization</code></li> + * <li> <code>com::sun::star::sdb::ErrorMessageDialog</code></li> + * <li> <code>com::sun::star::ui::dialogs::XExecutableDialog</code></li> + * <li> <code>com::sun::star::beans::XPropertySet</code></li> + * </ul> <p> + * This object test <b> is NOT </b> designed to be run in several + * threads concurrently. + * + * @see com.sun.star.lang.XInitialization + * @see com.sun.star.sdb.ErrorMessageDialog + * @see com.sun.star.ui.dialogs.XExecutableDialog + * @see com.sun.star.beans.XPropertySet + * @see ifc.lang._XInitialization + * @see ifc.sdb._ErrorMessageDialog + * @see ifc.ui.dialogs._XExecutableDialog + * @see ifc.beans._XPropertySet + */ +public class OSQLMessageDialog extends TestCase { + + /** + * Creating a TestEnvironment for the interfaces to be tested. + * + * Creates an instance of the service + * <code>com.sun.star.sdb.ErrorMessageDialog</code>. Object relations + * created : + * <ul> + * <li> <code>'ERR1', 'ERR2'</code> for {@link ifc.sdb._ErrorMessageDialog}</li> + * </ul> + */ + @Override + public TestEnvironment createTestEnvironment(TestParameters Param, + PrintWriter log) throws Exception { + XInterface oObj = null; + Object oInterface = null; + + Object err1 = null; + Object err2 = null; + + oInterface = Param.getMSF().createInstance( + "com.sun.star.sdb.ErrorMessageDialog"); + + err1 = new com.sun.star.sdbc.SQLException("err1"); + err2 = new com.sun.star.sdbc.SQLException("err2"); + + oObj = (XInterface) oInterface; + + // create XWindow for Object relations... + com.sun.star.awt.XToolkit xToolkit = UnoRuntime.queryInterface( + com.sun.star.awt.XToolkit.class, + Param.getMSF().createInstance("com.sun.star.awt.Toolkit")); + + // Describe the properties of the container window. + com.sun.star.awt.WindowDescriptor aDescriptor = new com.sun.star.awt.WindowDescriptor(); + + aDescriptor.Type = com.sun.star.awt.WindowClass.TOP; + aDescriptor.WindowServiceName = "window"; + aDescriptor.ParentIndex = -1; + aDescriptor.Parent = null; + aDescriptor.Bounds = new com.sun.star.awt.Rectangle(0, 0, 0, 0); + + aDescriptor.WindowAttributes = com.sun.star.awt.WindowAttribute.BORDER + | com.sun.star.awt.WindowAttribute.MOVEABLE + | com.sun.star.awt.WindowAttribute.SIZEABLE + | com.sun.star.awt.WindowAttribute.CLOSEABLE; + + com.sun.star.awt.XWindowPeer xPeer = xToolkit.createWindow(aDescriptor); + + com.sun.star.awt.XWindow xWindow = UnoRuntime.queryInterface( + com.sun.star.awt.XWindow.class, xPeer); + + log.println(" creating a new environment for object"); + TestEnvironment tEnv = new TestEnvironment(oObj); + + log.println("add ObjectRelations err1 and err2 for 'ErrorMessageDialog'"); + tEnv.addObjRelation("ERR1", err1); + tEnv.addObjRelation("ERR2", err2); + tEnv.addObjRelation("ERR_XWindow", xWindow); + + return tEnv; + } // finish method getTestEnvironment + + @Override public void disposeTestEnvironment( + TestEnvironment tEnv, TestParameters tParam) + { + UnoRuntime.queryInterface( + com.sun.star.lang.XComponent.class, + (com.sun.star.awt.XWindow) tEnv.getObjRelation("ERR_XWindow")) + .dispose(); + super.disposeTestEnvironment(tEnv, tParam); + } +} // finish class OSQLMessageDialog + diff --git a/qadevOOo/tests/java/mod/_dbaccess/OSingleSelectQueryComposer.java b/qadevOOo/tests/java/mod/_dbaccess/OSingleSelectQueryComposer.java new file mode 100644 index 000000000..272688f8e --- /dev/null +++ b/qadevOOo/tests/java/mod/_dbaccess/OSingleSelectQueryComposer.java @@ -0,0 +1,245 @@ +/* + * 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 . + */ + +package mod._dbaccess; + +import java.io.PrintWriter; + +import lib.TestCase; +import lib.TestEnvironment; +import lib.TestParameters; +import util.utils; + +import com.sun.star.beans.XPropertySet; +import com.sun.star.container.XNameAccess; +import com.sun.star.lang.XMultiServiceFactory; +import com.sun.star.sdb.CommandType; +import com.sun.star.sdb.XSingleSelectQueryAnalyzer; +import com.sun.star.sdb.XSingleSelectQueryComposer; +import com.sun.star.sdbc.XDataSource; +import com.sun.star.sdbc.XResultSet; +import com.sun.star.sdbcx.XColumnsSupplier; +import com.sun.star.uno.AnyConverter; +import com.sun.star.uno.Type; +import com.sun.star.uno.UnoRuntime; +import com.sun.star.uno.XInterface; + +/** + * Test for object which is represented by service + * <code>com.sun.star.sdb.DataSource</code>. + * <p> + * + * Object implements the following interfaces : + * <ul> + * <li> <code>com::sun::star::sdbc::RowSet</code></li> + * <li> <code>com::sun::star::sdbcx::XRowLocate</code></li> + * <li> <code>com::sun::star::sdbc::XResultSetUpdate</code></li> + * <li> <code>com::sun::star::util::XCancellable</code></li> + * <li> <code>com::sun::star::sdbc::XParameters</code></li> + * <li> <code>com::sun::star::sdbc::XResultSetMetaDataSupplier</code></li> + * <li> <code>com::sun::star::sdbcx::XDeleteRows</code></li> + * <li> <code>com::sun::star::sdbc::XCloseable</code></li> + * <li> <code>com::sun::star::sdbcx::XColumnsSupplier</code></li> + * <li> <code>com::sun::star::sdb::XResultSetAccess</code></li> + * <li> <code>com::sun::star::sdbc::XResultSet</code></li> + * <li> <code>com::sun::star::sdbc::XColumnLocate</code></li> + * <li> <code>com::sun::star::sdbc::XRowSet</code></li> + * <li> <code>com::sun::star::sdb::RowSet</code></li> + * <li> <code>com::sun::star::sdbc::XRowUpdate</code></li> + * <li> <code>com::sun::star::sdb::XRowSetApproveBroadcaster</code></li> + * <li> <code>com::sun::star::beans::XPropertySet</code></li> + * <li> <code>com::sun::star::sdbc::XRow</code></li> + * <li> <code>com::sun::star::sdbc::XWarningsSupplier</code></li> + * <li> <code>com::sun::star::lang::XComponent</code></li> + * <li> <code>com::sun::star::sdbcx::ResultSet</code></li> + * <li> <code>com::sun::star::sdbc::ResultSet</code></li> + * </ul> + * <p> + * The following files used by this test : + * <ul> + * <li><b> TestDB/TestDB.dbf </b> : the database file with some predefined + * fields described in <code>util.DBTools</code>. The copy of this file is + * always made in temp directory for testing purposes.</li> + * </ul> + * <p> + * The following parameters in ini-file used by this test: + * <ul> + * <li><code>test.db.url</code> - URL to MySQL database. For example: + * <code>mysql://mercury:3306/api_current</code></li> + * <li><code>test.db.user</code> - user for MySQL database</li> + * <li><code>test.db.password</code> - password for MySQL database</li> + * </ul> + * <p> + * + * @see com.sun.star.sdbc.RowSet + * @see com.sun.star.sdbcx.XRowLocate + * @see com.sun.star.sdbc.XResultSetUpdate + * @see com.sun.star.util.XCancellable + * @see com.sun.star.sdbc.XParameters + * @see com.sun.star.sdbc.XResultSetMetaDataSupplier + * @see com.sun.star.sdbcx.XDeleteRows + * @see com.sun.star.sdbc.XCloseable + * @see com.sun.star.sdbcx.XColumnsSupplier + * @see com.sun.star.sdb.XResultSetAccess + * @see com.sun.star.sdbc.XResultSet + * @see com.sun.star.sdbc.XColumnLocate + * @see com.sun.star.sdbc.XRowSet + * @see com.sun.star.sdb.RowSet + * @see com.sun.star.sdbc.XRowUpdate + * @see com.sun.star.sdb.XRowSetApproveBroadcaster + * @see com.sun.star.beans.XPropertySet + * @see com.sun.star.sdbc.XRow + * @see com.sun.star.sdbc.XWarningsSupplier + * @see com.sun.star.lang.XComponent + * @see com.sun.star.sdbcx.ResultSet + * @see com.sun.star.sdbc.ResultSet + * @see ifc.sdbc._RowSet + * @see ifc.sdbcx._XRowLocate + * @see ifc.sdbc._XResultSetUpdate + * @see ifc.util._XCancellable + * @see ifc.sdbc._XParameters + * @see ifc.sdbc._XResultSetMetaDataSupplier + * @see ifc.sdbcx._XDeleteRows + * @see ifc.sdbc._XCloseable + * @see ifc.sdbcx._XColumnsSupplier + * @see ifc.sdb._XResultSetAccess + * @see ifc.sdbc._XResultSet + * @see ifc.sdbc._XColumnLocate + * @see ifc.sdbc._XRowSet + * @see ifc.sdb._RowSet + * @see ifc.sdbc._XRowUpdate + * @see ifc.sdb._XRowSetApproveBroadcaster + * @see ifc.beans._XPropertySet + * @see ifc.sdbc._XRow + * @see ifc.sdbc._XWarningsSupplier + * @see ifc.lang._XComponent + * @see ifc.sdbcx._ResultSet + * @see ifc.sdbc._ResultSet + */ +public class OSingleSelectQueryComposer extends TestCase { + + protected static final String dbSourceName = "OSingleSelectQueryComposerDataSource"; + + /** + * Creating a TestEnvironment for the interfaces to be tested. + * + * Object relations created : + * <ul>SingleSelectQueryAnalyzer + + * <li> <code>'xComposer'</code> for + * {@link ifc.sdb._XSingleSelectQueryAnalyzer} interface + * <li> <code>'xQueryAna'</code> for + * {@link ifc.sdb._XSingleSelectQueryComposer} interface + * <li> <code>'xProp'</code> for + * {@link ifc.sdb._XSingleSelectQueryComposer} interface + * <li> <code>'colName'</code> for + * {@link ifc.sdb._XSingleSelectQueryComposer} interface + * <li> <code>'xResultSet'</code> for + * {@link ifc.sdb._XSingleSelectQueryComposer} interface + * </ul> + * + */ + @Override + protected TestEnvironment createTestEnvironment(TestParameters Param, + PrintWriter log) throws Exception { + + XInterface oObj = null; + Object oInterface = null; + XMultiServiceFactory xMSF = null; + xMSF = Param.getMSF(); + + XNameAccess xNameAccess = UnoRuntime.queryInterface(XNameAccess.class, + xMSF.createInstance("com.sun.star.sdb.DatabaseContext")); + // we use the first datasource + XDataSource xDS = UnoRuntime.queryInterface(XDataSource.class, + xNameAccess.getByName("Bibliography")); + + log.println("check XMultiServiceFactory"); + XMultiServiceFactory xConn = UnoRuntime.queryInterface( + XMultiServiceFactory.class, xDS.getConnection("", "")); + + log.println("check getAvailableServiceNames"); + String[] sServiceNames = xConn.getAvailableServiceNames(); + if (!sServiceNames[0] + .equals("com.sun.star.sdb.SingleSelectQueryComposer")) { + log.println("Service 'SingleSelectQueryComposer' not supported"); + } + + oInterface = xConn.createInstance(sServiceNames[0]); + Object oRowSet = xMSF.createInstance("com.sun.star.sdb.RowSet"); + + XPropertySet xSetProp = UnoRuntime.queryInterface(XPropertySet.class, + oRowSet); + + xSetProp.setPropertyValue("DataSourceName", "Bibliography"); + xSetProp.setPropertyValue("Command", "biblio"); + xSetProp.setPropertyValue("CommandType", + Integer.valueOf(CommandType.TABLE)); + + com.sun.star.sdbc.XRowSet xORowSet = UnoRuntime.queryInterface( + com.sun.star.sdbc.XRowSet.class, oRowSet); + + xORowSet.execute(); + + XColumnsSupplier xColSup = UnoRuntime.queryInterface( + XColumnsSupplier.class, oRowSet); + + XNameAccess xCols = xColSup.getColumns(); + + XPropertySet xCol = (XPropertySet) AnyConverter.toObject(new Type( + XPropertySet.class), + xCols.getByName(xCols.getElementNames()[0])); + + XSingleSelectQueryAnalyzer xQueryAna = UnoRuntime.queryInterface( + XSingleSelectQueryAnalyzer.class, oInterface); + + // XSingleSelectQueryComposer + XSingleSelectQueryComposer xComposer = UnoRuntime.queryInterface( + XSingleSelectQueryComposer.class, xQueryAna); + xQueryAna.setQuery("SELECT * FROM \"biblio\""); + + oObj = (XInterface) oInterface; + log.println("ImplementationName: " + utils.getImplName(oObj)); + + log.println(" creating a new environment for object"); + TestEnvironment tEnv = new TestEnvironment(oObj); + + // for XSingleSelectQueryAnalyzer + tEnv.addObjRelation("xComposer", xComposer); + + // for XSingleSelectQueryComposer + tEnv.addObjRelation("xQueryAna", xQueryAna); + + tEnv.addObjRelation("xProp", xCol); + tEnv.addObjRelation("colName", xCols.getElementNames()[0]); + + XResultSet xResultSet = UnoRuntime.queryInterface(XResultSet.class, + oRowSet); + tEnv.addObjRelation("xResultSet", xResultSet); + + return tEnv; + + } // finish method getTestEnvironment + + /** + * Closes connection of <code>RowSet</code> instance created. + */ + @Override + protected void cleanup(TestParameters Param, PrintWriter log) { + } +} diff --git a/qadevOOo/tests/java/mod/_dbaccess/SbaXGridControl.java b/qadevOOo/tests/java/mod/_dbaccess/SbaXGridControl.java new file mode 100644 index 000000000..dafdd9eaf --- /dev/null +++ b/qadevOOo/tests/java/mod/_dbaccess/SbaXGridControl.java @@ -0,0 +1,426 @@ +/* + * 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 . + */ +package mod._dbaccess; + +import java.io.PrintWriter; +import java.util.Comparator; + +import lib.StatusException; +import lib.TestCase; +import lib.TestEnvironment; +import lib.TestParameters; +import util.AccessibilityTools; +import util.FormTools; +import util.SOfficeFactory; +import util.WriterTools; +import util.utils; + +import com.sun.star.accessibility.AccessibleRole; +import com.sun.star.accessibility.XAccessible; +import com.sun.star.accessibility.XAccessibleAction; +import com.sun.star.awt.Point; +import com.sun.star.awt.Size; +import com.sun.star.awt.XControlModel; +import com.sun.star.awt.XDevice; +import com.sun.star.awt.XExtendedToolkit; +import com.sun.star.awt.XGraphics; +import com.sun.star.awt.XToolkit; +import com.sun.star.awt.XWindow; +import com.sun.star.awt.XWindowPeer; +import com.sun.star.beans.XPropertySet; +import com.sun.star.container.XNameContainer; +import com.sun.star.drawing.XControlShape; +import com.sun.star.form.XBoundComponent; +import com.sun.star.form.XGridColumnFactory; +import com.sun.star.form.XLoadable; +import com.sun.star.lang.XComponent; +import com.sun.star.lang.XMultiServiceFactory; +import com.sun.star.sdbc.XResultSetUpdate; +import com.sun.star.text.XTextDocument; +import com.sun.star.uno.UnoRuntime; +import com.sun.star.uno.XInterface; +import com.sun.star.util.URL; +import com.sun.star.util.XCloseable; +import com.sun.star.view.XControlAccess; + + +/** +* Test for object which represents the control of the Grid model. <p> +* Object implements the following interfaces : +* <ul> +* <li> <code>com::sun::star::util::XModifyBroadcaster</code></li> +* <li> <code>com::sun::star::form::XGridFieldDataSupplier</code></li> +* <li> <code>com::sun::star::view::XSelectionSupplier</code></li> +* <li> <code>com::sun::star::form::XGrid</code></li> +* <li> <code>com::sun::star::awt::XControl</code></li> +* <li> <code>com::sun::star::util::XModeSelector</code></li> +* <li> <code>com::sun::star::container::XElementAccess</code></li> +* <li> <code>com::sun::star::awt::XWindow</code></li> +* <li> <code>com::sun::star::form::XUpdateBroadcaster</code></li> +* <li> <code>com::sun::star::frame::XDispatch</code></li> +* <li> <code>com::sun::star::container::XEnumerationAccess</code></li> +* <li> <code>com::sun::star::form::XBoundComponent</code></li> +* <li> <code>com::sun::star::frame::XDispatchProviderInterception</code></li> +* <li> <code>com::sun::star::container::XIndexAccess</code></li> +* <li> <code>com::sun::star::lang::XComponent</code></li> +* <li> <code>com::sun::star::awt::XView</code></li> +* <li> <code>com::sun::star::container::XContainer</code></li> +* </ul> +* This object test <b> is NOT </b> designed to be run in several +* threads concurrently. +* @see com.sun.star.util.XModifyBroadcaster +* @see com.sun.star.form.XGridFieldDataSupplier +* @see com.sun.star.view.XSelectionSupplier +* @see com.sun.star.form.XGrid +* @see com.sun.star.awt.XControl +* @see com.sun.star.util.XModeSelector +* @see com.sun.star.container.XElementAccess +* @see com.sun.star.awt.XWindow +* @see com.sun.star.form.XUpdateBroadcaster +* @see com.sun.star.frame.XDispatch +* @see com.sun.star.container.XEnumerationAccess +* @see com.sun.star.form.XBoundComponent +* @see com.sun.star.frame.XDispatchProviderInterception +* @see com.sun.star.container.XIndexAccess +* @see com.sun.star.lang.XComponent +* @see com.sun.star.awt.XView +* @see com.sun.star.container.XContainer +* @see ifc.util._XModifyBroadcaster +* @see ifc.form._XGridFieldDataSupplier +* @see ifc.view._XSelectionSupplier +* @see ifc.form._XGrid +* @see ifc.awt._XControl +* @see ifc.util._XModeSelector +* @see ifc.container._XElementAccess +* @see ifc.awt._XWindow +* @see ifc.form._XUpdateBroadcaster +* @see ifc.frame._XDispatch +* @see ifc.container._XEnumerationAccess +* @see ifc.form._XBoundComponent +* @see ifc.frame._XDispatchProviderInterception +* @see ifc.container._XIndexAccess +* @see ifc.lang._XComponent +* @see ifc.awt._XView +* @see ifc.container._XContainer +*/ +public class SbaXGridControl extends TestCase { + XTextDocument xTextDoc; + + /** + * Creates Writer document. + */ + @Override + protected void initialize(TestParameters Param, PrintWriter log) throws Exception { + SOfficeFactory SOF = SOfficeFactory.getFactory(Param.getMSF()); + + log.println("creating a textdocument"); + xTextDoc = SOF.createTextDoc(null); + } + + /** + * Disposes Writer document. + */ + @Override + protected void cleanup(TestParameters tParam, PrintWriter log) { + //closing the appearing dialog before disposing the document + XInterface toolkit = null; + + try { + toolkit = (XInterface) tParam.getMSF() + .createInstance("com.sun.star.awt.Toolkit"); + } catch (com.sun.star.uno.Exception e) { + log.println("Couldn't get toolkit"); + e.printStackTrace(log); + throw new StatusException("Couldn't get toolkit", e); + } + + XExtendedToolkit tk = UnoRuntime.queryInterface( + XExtendedToolkit.class, toolkit); + + Object atw = tk.getActiveTopWindow(); + + XWindow xWindow = UnoRuntime.queryInterface(XWindow.class, + atw); + + XAccessible xRoot = AccessibilityTools.getAccessibleObject(xWindow); + + XInterface button = AccessibilityTools.getAccessibleObjectForRole(xRoot, + AccessibleRole.PUSH_BUTTON); + + XAccessibleAction action = UnoRuntime.queryInterface( + XAccessibleAction.class, button); + + try { + action.doAccessibleAction(0); + } catch (com.sun.star.lang.IndexOutOfBoundsException iob) { + log.println("couldn't close dialog"); + } catch (com.sun.star.lang.DisposedException e) { + log.println("couldn't close dialog"); + } + + log.println(" disposing xTextDoc "); + + try { + XCloseable closer = UnoRuntime.queryInterface( + XCloseable.class, xTextDoc); + closer.close(true); + } catch (com.sun.star.util.CloseVetoException e) { + log.println("couldn't close document"); + } catch (com.sun.star.lang.DisposedException e) { + log.println("couldn't close document"); + } + } + + /** + * Creating a TestEnvironment for the interfaces to be tested. + * For object creation first a + * <code>com.sun.star.form.component.GridControl<code> instance + * is added to the <code>ControlShape</code>. Then this model's + * control is retrieved. + * + * Object relations created : + * <ul> + * <li> <code>'GRAPHICS'</code> for + * {@link ifc.awt._XView} test : <code>XGraphics</code> + * object different that belong to the object tested.</li> + * <li> <code>'CONTEXT'</code> for + * {@link ifc.awt._XControl} </li> + * <li> <code>'WINPEER'</code> for + * {@link ifc.awt._XControl} </li> + * <li> <code>'TOOLKIT'</code> for + * {@link ifc.awt._XControl} </li> + * <li> <code>'MODEL'</code> for + * {@link ifc.awt._XControl} </li> + * <li> <code>'XWindow.AnotherWindow'</code> for + * {@link ifc.awt._XWindow} for switching focus.</li> + * <li> <code>'XDispatch.URL'</code> for + * {@link ifc.frame._XDispatch} the url which moves + * DB cursor to the next row (".uno:FormSlots/moveToNext").</li> + * <li> <code>'XContainer.Container'</code> for + * {@link ifc.container._XContainer} as the component created + * doesn't support <code>XContainer</code> itself, but + * it is supported by its model. So this model is passed.</li> + * <li> <code>'INSTANCE'</code> for + * {@link ifc.container._XContainer} the instance to be + * inserted into collection. Is a column instance.</li> + * </ul> + */ + @Override + protected TestEnvironment createTestEnvironment(TestParameters Param, + PrintWriter log) throws Exception { + XInterface oObj = null; + XWindowPeer the_win = null; + XToolkit the_kit = null; + XDevice aDevice = null; + XGraphics aGraphic = null; + XPropertySet aControl = null; + XPropertySet aControl2 = null; + XPropertySet aControl3 = null; + XPropertySet aControl4 = null; + XGridColumnFactory columns = null; + + //Insert a ControlShape and get the ControlModel + XControlShape aShape = createGrid(xTextDoc, 3000, 4500, 15000, 10000); + + XControlModel the_Model = aShape.getControl(); + + WriterTools.getDrawPage(xTextDoc).add(aShape); + + XLoadable formLoader = FormTools.bindForm(xTextDoc); + + //Try to query XControlAccess + XControlAccess the_access = UnoRuntime.queryInterface( + XControlAccess.class, + xTextDoc.getCurrentController()); + + columns = UnoRuntime.queryInterface( + XGridColumnFactory.class, the_Model); + aControl = columns.createColumn("TextField"); + aControl.setPropertyValue("DataField", "Identifier"); + aControl.setPropertyValue("Label", "Identifier"); + aControl2 = columns.createColumn("TextField"); + aControl2.setPropertyValue("DataField", "Publisher"); + aControl2.setPropertyValue("Label", "Publisher"); + aControl3 = columns.createColumn("TextField"); + aControl3.setPropertyValue("DataField", "Author"); + aControl3.setPropertyValue("Label", "Author"); + aControl4 = columns.createColumn("TextField"); + aControl4.setPropertyValue("DataField", "Title"); + aControl4.setPropertyValue("Label", "Title"); + + XNameContainer aContainer = UnoRuntime.queryInterface( + XNameContainer.class, the_Model); + + aContainer.insertByName("First", aControl); + aContainer.insertByName("Second", aControl2); + + //now get the OGridControl + oObj = the_access.getControl(the_Model); + the_win = the_access.getControl(the_Model).getPeer(); + the_kit = the_win.getToolkit(); + aDevice = the_kit.createScreenCompatibleDevice(200, 200); + aGraphic = aDevice.createGraphics(); + + + // creating another window + aShape = FormTools.createControlShape(xTextDoc, 3000, 4500, 15000, + 10000, "TextField"); + + WriterTools.getDrawPage(xTextDoc).add(aShape); + + the_Model = aShape.getControl(); + + + //Try to query XControlAccess + the_access = UnoRuntime.queryInterface( + XControlAccess.class, + xTextDoc.getCurrentController()); + + //now get the TextControl + XWindow win = null; + Object cntrl = null; + + cntrl = the_access.getControl(the_Model); + win = UnoRuntime.queryInterface(XWindow.class, cntrl); + + log.println("creating a new environment for object"); + + TestEnvironment tEnv = new TestEnvironment(oObj); + + + //Relations for XSelectionSupplier + tEnv.addObjRelation("Selections", + new Object[] { + new Object[] { Integer.valueOf(0) }, new Object[] { Integer.valueOf(1) } + }); + tEnv.addObjRelation("Comparer", + new Comparator<Integer>() { + public int compare(Integer o1, Integer o2) { + return o1.compareTo(o2); + } + }); + + + //Relation for XContainer + tEnv.addObjRelation("XContainer.Container", aContainer); + tEnv.addObjRelation("INSTANCE", aControl3); + tEnv.addObjRelation("INSTANCE2", aControl4); + + + //Adding ObjRelation for XView + tEnv.addObjRelation("GRAPHICS", aGraphic); + + + //Adding ObjRelation for XControl + tEnv.addObjRelation("CONTEXT", xTextDoc); + tEnv.addObjRelation("WINPEER", the_win); + tEnv.addObjRelation("TOOLKIT", the_kit); + tEnv.addObjRelation("MODEL", the_Model); + + + // Adding relation for XWindow + tEnv.addObjRelation("XWindow.AnotherWindow", win); + + // Adding relation for XDispatch + URL url = new URL(); + url.Complete = ".uno:FormSlots/moveToNext"; + + + //url.Complete = ".uno:GridSlots/RowHeight"; + //url.Complete = ".uno:GridSlots/RowHeight" ; + tEnv.addObjRelation("XDispatch.URL", url); + + log.println("ImplName: " + utils.getImplName(oObj)); + + FormTools.switchDesignOf(Param.getMSF(), xTextDoc); + + // adding relation for XUpdateBroadcaster + final XInterface ctrl = oObj; + final XLoadable formLoaderF = formLoader; + final XPropertySet ps = UnoRuntime.queryInterface( + XPropertySet.class, aControl2); + tEnv.addObjRelation("XUpdateBroadcaster.Checker", + new ifc.form._XUpdateBroadcaster.UpdateChecker() { + private String lastText = ""; + + public void update() throws com.sun.star.uno.Exception { + if (!formLoaderF.isLoaded()) { + formLoaderF.load(); + } + + lastText = "_" + ps.getPropertyValue("Text"); + ps.setPropertyValue("Text", lastText); + } + + public void commit() throws com.sun.star.sdbc.SQLException { + XBoundComponent bound = UnoRuntime.queryInterface( + XBoundComponent.class, ctrl); + XResultSetUpdate update = UnoRuntime.queryInterface( + XResultSetUpdate.class, + formLoaderF); + + bound.commit(); + update.updateRow(); + } + + public boolean wasCommited() throws com.sun.star.uno.Exception { + String getS = (String) ps.getPropertyValue("Text"); + + return lastText.equals(getS); + } + }); + + return tEnv; + } // finish method getTestEnvironment + + public static XControlShape createGrid(XComponent oDoc, int height, + int width, int x, int y) throws Exception { + Size size = new Size(); + Point position = new Point(); + XControlShape oCShape = null; + XControlModel aControl = null; + + //get MSF + XMultiServiceFactory oDocMSF = UnoRuntime.queryInterface( + XMultiServiceFactory.class, + oDoc); + + Object oInt = oDocMSF.createInstance( + "com.sun.star.drawing.ControlShape"); + Object aCon = oDocMSF.createInstance( + "com.sun.star.form.component.GridControl"); + XPropertySet model_props = UnoRuntime.queryInterface( + XPropertySet.class, aCon); + model_props.setPropertyValue("DefaultControl", + "com.sun.star.form.control.InteractionGridControl"); + aControl = UnoRuntime.queryInterface( + XControlModel.class, aCon); + oCShape = UnoRuntime.queryInterface( + XControlShape.class, oInt); + size.Height = height; + size.Width = width; + position.X = x; + position.Y = y; + oCShape.setSize(size); + oCShape.setPosition(position); + + oCShape.setControl(aControl); + + return oCShape; + } // finish createGrid +}
\ No newline at end of file diff --git a/qadevOOo/tests/java/mod/_dbaccess/TableWindowAccessibility.java b/qadevOOo/tests/java/mod/_dbaccess/TableWindowAccessibility.java new file mode 100644 index 000000000..384edb85b --- /dev/null +++ b/qadevOOo/tests/java/mod/_dbaccess/TableWindowAccessibility.java @@ -0,0 +1,267 @@ +/* + * 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 . + */ +package mod._dbaccess; + +import java.io.PrintWriter; + +import lib.Status; +import lib.StatusException; +import lib.TestCase; +import lib.TestEnvironment; +import lib.TestParameters; +import util.AccessibilityTools; + +import com.sun.star.accessibility.AccessibleRole; +import com.sun.star.accessibility.XAccessible; +import com.sun.star.accessibility.XAccessibleComponent; +import com.sun.star.awt.Point; +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.frame.XModel; +import com.sun.star.frame.XStorable; +import com.sun.star.lang.XComponent; +import com.sun.star.lang.XMultiServiceFactory; +import com.sun.star.sdb.XDocumentDataSource; +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.ucb.XSimpleFileAccess; +import com.sun.star.uno.UnoRuntime; +import com.sun.star.uno.XInterface; +import java.awt.Robot; +import java.awt.event.InputEvent; +import util.DesktopTools; +import util.utils; + +/** + * Object implements the following interfaces : + * <ul> + * <li><code>::com::sun::star::accessibility::XAccessible</code></li> + * <li><code>::com::sun::star::accessibility::XAccessibleContext + * </code></li> + * <li><code>::com::sun::star::accessibility::XAccessibleEventBroadcaster + * </code></li> + * </ul> + * <p> + * + * @see com.sun.star.accessibility.XAccessible + * @see com.sun.star.accessibility.XAccessibleContext + * @see com.sun.star.accessibility.XAccessibleEventBroadcaster + * @see ifc.accessibility._XAccessible + * @see ifc.accessibility._XAccessibleContext + * @see ifc.accessibility._XAccessibleEventBroadcaster + */ +public class TableWindowAccessibility extends TestCase { + XWindow xWindow = null; + String aFile = ""; + XIsolatedConnection isolConnection = null; + XComponent QueryComponent = null; + String user = ""; + String password = ""; + + /** + * Creates a new DataSource and stores it. Creates a connection and using it + * creates two tables in database. Creates a new query and adds it to + * DefinitionContainer. Opens the QueryComponent.with loadComponentFromURL + * and gets the object with the role PANEL and the implementation name that + * contains TabelViewAccessibility + * + * @param Param + * test parameters + * @param log + * writer to log information while testing + * @return + * @throws StatusException + * @see TestEnvironment + */ + @Override + protected TestEnvironment createTestEnvironment(TestParameters Param, + PrintWriter log) throws Exception { + XInterface oObj = null; + + Param.getMSF().createInstance("com.sun.star.sdb.DatabaseContext"); + Object oDBSource = Param.getMSF() + .createInstance("com.sun.star.sdb.DataSource"); + Object newQuery = Param.getMSF().createInstance( + "com.sun.star.sdb.QueryDefinition"); + Param.getMSF().createInstance("com.sun.star.awt.Toolkit"); + + String mysqlURL = (String) Param.get("mysql.url"); + + if (mysqlURL == null) { + throw new StatusException( + Status.failed("Couldn't get 'mysql.url' from ini-file")); + } + + user = (String) Param.get("jdbc.user"); + password = (String) Param.get("jdbc.password"); + + if ((user == null) || (password == null)) { + throw new StatusException( + Status.failed("Couldn't get 'jdbc.user' or 'jdbc.password' from ini-file")); + } + + PropertyValue[] info = new PropertyValue[2]; + info[0] = new PropertyValue(); + info[0].Name = "user"; + info[0].Value = user; + info[1] = new PropertyValue(); + info[1].Name = "password"; + info[1].Value = password; + + XPropertySet propSetDBSource = UnoRuntime.queryInterface( + XPropertySet.class, oDBSource); + + propSetDBSource.setPropertyValue("URL", mysqlURL); + propSetDBSource.setPropertyValue("Info", info); + + log.println("writing database file ..."); + XDocumentDataSource xDDS = UnoRuntime.queryInterface( + XDocumentDataSource.class, oDBSource); + XStorable store = UnoRuntime.queryInterface(XStorable.class, + xDDS.getDatabaseDocument()); + aFile = utils.getOfficeTemp(Param.getMSF()) + "TableWindow.odb"; + log.println("... filename will be " + aFile); + store.storeAsURL(aFile, new PropertyValue[] {}); + log.println("... done"); + + isolConnection = UnoRuntime.queryInterface(XIsolatedConnection.class, + oDBSource); + + final String tbl_name1 = "tst_table1"; + final String tbl_name2 = "tst_table2"; + final String col_name1 = "id1"; + final String col_name2 = "id2"; + + util.utils.waitForEventIdle(Param.getMSF()); + XConnection connection = isolConnection.getIsolatedConnection(user, password); + XStatement 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)"); + + XQueryDefinitionsSupplier querySuppl = UnoRuntime.queryInterface( + XQueryDefinitionsSupplier.class, oDBSource); + + XNameAccess defContainer = querySuppl.getQueryDefinitions(); + + XPropertySet queryProp = UnoRuntime.queryInterface(XPropertySet.class, + newQuery); + + final String query = "select * from " + tbl_name1 + ", " + tbl_name2 + + " where " + tbl_name1 + "." + col_name1 + "=" + tbl_name2 + + "." + col_name2; + queryProp.setPropertyValue("Command", query); + + XNameContainer queryContainer = UnoRuntime.queryInterface( + XNameContainer.class, defContainer); + + queryContainer.insertByName("Query1", newQuery); + store.store(); + connection.close(); + + PropertyValue[] loadProps = new PropertyValue[3]; + loadProps[0] = new PropertyValue(); + loadProps[0].Name = "QueryDesignView"; + loadProps[0].Value = Boolean.TRUE; + + loadProps[1] = new PropertyValue(); + loadProps[1].Name = "CurrentQuery"; + loadProps[1].Value = "Query1"; + + loadProps[2] = new PropertyValue(); + loadProps[2].Name = "DataSource"; + loadProps[2].Value = oDBSource; + + QueryComponent = DesktopTools.loadDoc(Param.getMSF(), + ".component:DB/QueryDesign", loadProps); + + xWindow = UnoRuntime.queryInterface(XModel.class, QueryComponent) + .getCurrentController().getFrame().getContainerWindow(); + + XAccessible xRoot = AccessibilityTools.getAccessibleObject(xWindow); + + AccessibilityTools.printAccessibleTree(log, xRoot, + Param.getBool(util.PropertyName.DEBUG_IS_ACTIVE)); + + oObj = AccessibilityTools.getAccessibleObjectForRole(xRoot, + AccessibleRole.PANEL, "", "TableWindowAccessibility"); + + log.println("ImplementationName " + util.utils.getImplName(oObj)); + + log.println("creating TestEnvironment ... done"); + + TestEnvironment tEnv = new TestEnvironment(oObj); + + util.utils.waitForEventIdle(Param.getMSF()); + + XAccessibleComponent accComp = UnoRuntime.queryInterface( + XAccessibleComponent.class, oObj); + + final Point point = accComp.getLocationOnScreen(); + + tEnv.addObjRelation( + "EventProducer", + new ifc.accessibility._XAccessibleEventBroadcaster.EventProducer() { + public void fireEvent() { + try { + Robot rob = new Robot(); + rob.mouseMove(point.X + 2, point.Y + 7); + rob.mousePress(InputEvent.BUTTON1_MASK); + rob.mouseMove(point.X + 400, point.Y); + rob.mouseRelease(InputEvent.BUTTON1_MASK); + } catch (java.awt.AWTException e) { + System.out.println("desired child doesn't exist"); + } + } + }); + + return tEnv; + } // finish method getTestEnvironment + + /** + * Closes all open documents. + */ + @Override + protected void cleanup(TestParameters Param, PrintWriter log) { + try { + + log.println("closing QueryComponent ..."); + DesktopTools.closeDoc(QueryComponent); + log.println("... done"); + XMultiServiceFactory xMSF = Param.getMSF(); + Object sfa = xMSF + .createInstance("com.sun.star.comp.ucb.SimpleFileAccess"); + XSimpleFileAccess xSFA = UnoRuntime.queryInterface( + XSimpleFileAccess.class, sfa); + log.println("deleting database file"); + xSFA.kill(aFile); + log.println("Could delete file " + aFile + ": " + + !xSFA.exists(aFile)); + } catch (Exception e) { + e.printStackTrace(); + } + } +} diff --git a/qadevOOo/tests/java/mod/_dbaccess/package.html b/qadevOOo/tests/java/mod/_dbaccess/package.html new file mode 100644 index 000000000..d6411c05e --- /dev/null +++ b/qadevOOo/tests/java/mod/_dbaccess/package.html @@ -0,0 +1,23 @@ +<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 3.2//EN"> +<!-- + * 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 . +--> +<HTML> +<BODY> +<P>Contains all test cases for the module 'dbaccess'.</P> +</BODY> +</HTML> |