diff options
Diffstat (limited to 'qadevOOo/tests/java/mod/_forms')
42 files changed, 9099 insertions, 0 deletions
diff --git a/qadevOOo/tests/java/mod/_forms/GenericModelTest.java b/qadevOOo/tests/java/mod/_forms/GenericModelTest.java new file mode 100644 index 000000000000..dce88234885f --- /dev/null +++ b/qadevOOo/tests/java/mod/_forms/GenericModelTest.java @@ -0,0 +1,565 @@ +/************************************************************************* + * + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * Copyright 2000, 2010 Oracle and/or its affiliates. + * + * OpenOffice.org - a multi-platform office productivity suite + * + * This file is part of OpenOffice.org. + * + * OpenOffice.org is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License version 3 + * only, as published by the Free Software Foundation. + * + * OpenOffice.org is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License version 3 for more details + * (a copy is included in the LICENSE file that accompanied this code). + * + * You should have received a copy of the GNU Lesser General Public License + * version 3 along with OpenOffice.org. If not, see + * <http://www.openoffice.org/license.html> + * for a copy of the LGPLv3 License. + * + ************************************************************************/ +package mod._forms; +import com.sun.star.beans.NamedValue; +import com.sun.star.beans.PropertyValue; +import java.io.PrintWriter; + +import lib.StatusException; +import lib.TestCase; +import lib.TestEnvironment; +import lib.TestParameters; +import util.DBTools; +import util.FormTools; +import util.WriterTools; + +import com.sun.star.beans.XPropertySet; +import com.sun.star.drawing.XControlShape; +import com.sun.star.drawing.XShape; +import com.sun.star.form.XBoundComponent; +import com.sun.star.form.XForm; +import com.sun.star.form.XLoadable; +import com.sun.star.lang.XMultiServiceFactory; +import com.sun.star.lang.XComponent; +import com.sun.star.sdbc.XConnection; +import com.sun.star.sdbc.XResultSetUpdate; +import com.sun.star.sdb.XDocumentDataSource; +import com.sun.star.text.XTextDocument; +import com.sun.star.uno.AnyConverter; +import com.sun.star.uno.Type; +import com.sun.star.uno.UnoRuntime; +import com.sun.star.uno.XInterface; +import com.sun.star.util.XCloseable; +import java.util.ArrayList; +import lib.Status; +import util.utils; + + +/** +* Test for object which is represented by service +* <code>com.sun.star.form.component.DateField</code>. <p> +* Object implements the following interfaces : +* <ul> +* <li> <code>com::sun::star::io::XPersistObject</code></li> +* <li> <code>com::sun::star::awt::UnoControlDateFieldModel</code></li> +* <li> <code>com::sun::star::form::XReset</code></li> +* <li> <code>com::sun::star::form::XBoundComponent</code></li> +* <li> <code>com::sun::star::form::FormComponent</code></li> +* <li> <code>com::sun::star::form::component::DateField</code></li> +* <li> <code>com::sun::star::beans::XFastPropertySet</code></li> +* <li> <code>com::sun::star::beans::XMultiPropertySet</code></li> +* <li> <code>com::sun::star::form::XUpdateBroadcaster</code></li> +* <li> <code>com::sun::star::form::DataAwareControlModel</code></li> +* <li> <code>com::sun::star::beans::XPropertyState</code></li> +* <li> <code>com::sun::star::form::FormControlModel</code></li> +* <li> <code>com::sun::star::container::XNamed</code></li> +* <li> <code>com::sun::star::lang::XComponent</code></li> +* <li> <code>com::sun::star::lang::XEventListener</code></li> +* <li> <code>com::sun::star::beans::XPropertyAccess</code></li> +* <li> <code>com::sun::star::beans::XPropertyContainer</code></li> +* <li> <code>com::sun::star::beans::XPropertySet</code></li> +* <li> <code>com::sun::star::form::XLoadListener</code></li> +* <li> <code>com::sun::star::container::XChild</code></li> +* </ul> +* The following files used by this test : +* <ul> +* <li><b> TestDB </b> (directory) : directory with test database </li> +* <li><b> TestDB/TestDB.dbf </b> : table file. See +* {@link util.DBTools DBTools} class for more information.</li> +* </ul> <p> +* This object test <b> is NOT </b> designed to be run in several +* threads concurently. +* @see com.sun.star.io.XPersistObject +* @see com.sun.star.awt.UnoControlDateFieldModel +* @see com.sun.star.form.XReset +* @see com.sun.star.form.XBoundComponent +* @see com.sun.star.form.FormComponent +* @see com.sun.star.form.component.DateField +* @see com.sun.star.beans.XFastPropertySet +* @see com.sun.star.beans.XMultiPropertySet +* @see com.sun.star.form.XUpdateBroadcaster +* @see com.sun.star.form.DataAwareControlModel +* @see com.sun.star.beans.XPropertyState +* @see com.sun.star.form.FormControlModel +* @see com.sun.star.container.XNamed +* @see com.sun.star.lang.XComponent +* @see com.sun.star.lang.XEventListener +* @see com.sun.star.beans.XPropertyAccess +* @see com.sun.star.beans.XPropertyContainer +* @see com.sun.star.beans.XPropertySet +* @see com.sun.star.form.XLoadListener +* @see com.sun.star.container.XChild +* @see ifc.io._XPersistObject +* @see ifc.awt._UnoControlDateFieldModel +* @see ifc.form._XReset +* @see ifc.form._XBoundComponent +* @see ifc.form._FormComponent +* @see ifc.form.component._DateField +* @see ifc.beans._XFastPropertySet +* @see ifc.beans._XMultiPropertySet +* @see ifc.form._XUpdateBroadcaster +* @see ifc.form._DataAwareControlModel +* @see ifc.beans._XPropertyState +* @see ifc.form._FormControlModel +* @see ifc.container._XNamed +* @see ifc.lang._XComponent +* @see ifc.lang._XEventListener +* @see ifc.beans._XPropertySet +* @see ifc.form._XLoadListener +* @see ifc.container._XChild +*/ +public class GenericModelTest extends TestCase { + private static XTextDocument m_xTextDoc; + private static Object m_dbSrc = null; + private static DBTools.DataSourceInfo m_srcInf = null; + /** + * This is the name of the Data Base which the test uses: "APITestDatabase" + */ + protected final static String m_dbSourceName = "APITestDatabase"; + protected final static String m_TestDB = "TestDB"; + private DBTools m_dbTools = null; + + private static boolean m_ConnectionColsed = false; + + /** + * descibes the kind of the shape which should be created. + * Example: m_kindOfshape=DateFiled + */ + public static String m_kindOfControl = null; + + /** + * If your object needs some special propery values you can specify them with this + * <CODE>ArrayList</CODE>. You have to add a <CODE>NamedValue</CODE> to this list. + * Example: + * NamedValue myProp = new NamedValue(); + * myProp.Name = "Test"; + * myProp.Value = "My special Value"; + * m_propertiesToSet.add(myProp); + */ + public static ArrayList m_propertiesToSet = new ArrayList(); + + /** + * This variable contains the name of the property which should be changed while + * interface <CODE>com::sun::star::form::XUpdateBroadcaster</CODE> is tested. The + * interface test needs the <CODE>ObjectRelation</CODE> + * "XUpdateBroadcaster.Checker" which is a <CODE>ifc.form._XUpdateBroadcaster.UpdateChecker</CODE>. + * @see ifc.form._XUpdateBroadcaster.UpdateChecker + * @see ifc.form._XUpdateBroadcaster + */ + public static String m_ChangePropertyName = null; + /** + * This variable contains the value the property should be set while + * interface <CODE>com::sun::star::form::XUpdateBroadcaster</CODE> is tested. + * The interface test needs the <CODE>ObjectRelation</CODE> + * "XUpdateBroadcaster.Checker" which is a <CODE>ifc.form._XUpdateBroadcaster.UpdateChecker</CODE>. + * Normaly the <CODE>Checker</CODE> uses <CODE>util.ValueChanger</CODE> to change + * the value of the property. If the current of this property is NULL the + * <CODE>ValueChanger</CODE> is unable to change the value. In this case the value + * of this variable was used. + */ + public static Object m_ChangePropertyValue = null; + + /** + * This variable contains the implelemtation name of the object. + */ + public static String m_ObjectName = null; + + /** + * For local implementaions of <CODE>Checker</CODE> this variable contains the + * <CODE>FormLoader</CODE> + */ + protected static XLoadable m_XFormLoader = null; + /** + * For local implementaions of <CODE>Checker</CODE> this variable contains the + * <CODE>XPropertySet</CODE> + */ + protected static XPropertySet m_XPS = null; + /** + * For local implementaions of <CODE>Checker</CODE> this variable contains the + * <CODE>Control</CODE> + */ + protected static XInterface m_XCtrl = null; + /** + * The insterface test of <CODE>ifc.form._DataWareControlModel</CODE> expects an + * object relation <CODE>'LC'</CODE>. This is a <CODE>XControlModel</CODE> of a shape. + * This variable contains the kind of shape to create for the interface test, + * f.e. "FixedText" + * @see ifc.form._DataAwareControlModel + */ + protected static String m_LCShape_Type = null; + + protected static String m_XPropertyAccess_propertyToChange = "HelpText"; + + protected static String m_XPropertyContainer_propertyNotRemovable = "HelpText"; + /** + * If this variable is true some more debug info was logged. It was setted by the parameter variable + * <code>debug_is_active</code> + */ + protected static boolean debug = false; + + /** + * Creates Writer document where controls are placed. + * @param tParam the test paremter + * @param log the log writer + */ + protected void initialize(TestParameters tParam, PrintWriter log) { + log.println("creating a textdocument"); + m_xTextDoc = WriterTools.createTextDoc(((XMultiServiceFactory) tParam.getMSF())); + m_ConnectionColsed = false; + debug = tParam.getBool(util.PropertyName.DEBUG_IS_ACTIVE); + m_propertiesToSet.clear(); + } + + /** + * close the connection + * close the data source + * close the document + * revoke the data source + * @param tParam the test parameter + * @param log the log writer + */ + protected void cleanup(TestParameters tParam, PrintWriter log) { + log.println("closing connection..."); + + // some interface tests call cleanup to reset the environment. If such + // a test is the last one cleanup was called twice. The second call + // causes then nasty exceptions... + if (m_ConnectionColsed) return; + + try { + XForm myForm = (XForm) AnyConverter.toObject(new Type(XForm.class), + (FormTools.getForms( + WriterTools.getDrawPage( + m_xTextDoc))) + .getByName("Standard")); + + if (debug){ + if (myForm == null){ + log.println("ERROR: could not get 'Standard' from drawpage!"); + } + log.println("the draw page contains folowing elemtens:"); + String[] elements = FormTools.getForms(WriterTools.getDrawPage(m_xTextDoc)).getElementNames(); + for (int i = 0; i< elements.length; i++){ + log.println("Element[" + i + "] :" + elements[i]); + } + + } + + XPropertySet xSetProp = (XPropertySet) UnoRuntime.queryInterface( + XPropertySet.class, myForm); + XConnection connection = (XConnection) AnyConverter.toObject( + new Type(XConnection.class), + xSetProp.getPropertyValue("ActiveConnection")); + if (debug && connection == null){ + log.println("ERROR: could not get property 'ActiveConnection' from the XForm"); + } + + connection.close(); + } catch (Exception e) { + log.println("ERROR: Can't close the connection: " + e.toString()); + } + + log.println("closing data source..."); + try { + XCloseable closer = (XCloseable) UnoRuntime.queryInterface( + XCloseable.class, m_dbSrc); + if ( closer == null ) + { + XDocumentDataSource dataSource = (XDocumentDataSource)UnoRuntime.queryInterface( + XDocumentDataSource.class, m_dbSrc); + if ( dataSource != null ) + closer = (XCloseable) UnoRuntime.queryInterface( + XCloseable.class, dataSource.getDatabaseDocument() ); + } + if (debug && closer==null){ + log.println("ERROR: couldn't get 'XCloseable' from DataSource"); + } + closer.close(true); + } catch (com.sun.star.util.CloseVetoException e) { + log.println("ERROR: couldn't close data source: " + e.toString()); + } catch (com.sun.star.lang.DisposedException e) { + log.println("ERROR: couldn't close data source: " + e.toString()); + } catch (Exception e) { + log.println("ERROR: couldn't close data source: " + e.toString()); + } + + log.println("disposing data source..."); + try { + XComponent dataSourceComp = (XComponent)UnoRuntime.queryInterface( + XComponent.class, m_dbSrc); + dataSourceComp.dispose(); + } + catch (Exception e) { + log.println("couldn't dispose the data source"); + } + + log.println("closing document..."); + + try { + XCloseable closer = (XCloseable) UnoRuntime.queryInterface( + XCloseable.class, m_xTextDoc); + closer.close(true); + } catch (com.sun.star.util.CloseVetoException e) { + log.println("ERROR: couldn't close document: " + e.toString()); + } catch (com.sun.star.lang.DisposedException e) { + log.println("ERROR: couldn't close document: " + e.toString()); + } catch (Exception e) { + log.println("ERROR: couldn't close document: " + e.toString()); + } + + log.println("revoking data source..."); + try { + m_dbTools.revokeDB(m_dbSourceName); + } catch (com.sun.star.container.NoSuchElementException e){ + } catch (com.sun.star.uno.Exception e) { + log.println("ERROR: Error while object test cleaning up: " + e.toString()); + } + + m_ConnectionColsed = true; + } + + /** + * Creating a Testenvironment for the interfaces to be tested. + * First <code>TestDB</code> database is registered. + * Creates DateField in the Form, then binds it to TestDB + * database and returns Field's control. <p> + * Object relations created : + * <ul> + * <li> <code>'OBJNAME'</code> for + * {@link ifc.io._XPersistObject} : name of service which is + * represented by this object. </li> + * <li> <code>'LC'</code> for {@link ifc.form._DataAwareControlModel}. + * Specifies the value for LabelControl property. It is + * <code>FixedText</code> component added to the document.</li> + * <li> <code>'FL'</code> for + * {@link ifc.form._DataAwareControlModel} interface. + * Specifies XLoadable implementation which connects form to + * the data source.</li> + * <li> <code>'XUpdateBroadcaster.Checker'</code> : <code> + * _XUpdateBroadcaster.UpdateChecker</code> interface implementation + * which can update, commit data and check if the data was successfully + * commited.</li> + * <li> <code>'DataAwareControlModel.NewFieldName'</code> : for + * <code>com.sun.star.form.DataAwareControlModel</code> service + * which contains new name of the field ('_DATE') to bind control to. + * </li> + * <li> <code>'XFastPropertySet.ExcludeProps'</code> : for + * <code>com.sun.star.beans.XFastPropertySet</code> interface + * the property FormatKey can have only restricted set of values. + * </li> + * </ul> + * @see ifc.form._XUpdateBroadcaster + * @param Param the test parameter + * @param log the log writer + * @return a test environment + */ + protected synchronized TestEnvironment createTestEnvironment(TestParameters Param, + PrintWriter log) { + XInterface oObj = null; + XControlShape aShape = null; + XMultiServiceFactory xMSF = (XMultiServiceFactory) Param.getMSF(); + + try{ + log.println("adding contol shape '" + m_kindOfControl + "'"); + aShape = FormTools.createControlShape(m_xTextDoc, 3000, + 4500, 15000, 10000, + m_kindOfControl); + } catch (Exception e){ + e.printStackTrace(log); + throw new StatusException("Couldn't create following control shape (m_kindOfControl): '" + + m_kindOfControl + "': ", e); + + } + + WriterTools.getDrawPage(m_xTextDoc).add((XShape) aShape); + oObj = aShape.getControl(); + + log.println("Implementation name: " + util.utils.getImplName(oObj)); + + try { + String sourceTestDB = utils.getFullURL(utils.getFullTestDocName("TestDB/testDB.dbf")); + String destTestDB = utils.getOfficeTemp(xMSF); + destTestDB = utils.getFullURL(destTestDB + "testDB.dbf"); + + log.println("copy '"+sourceTestDB + "' -> '" + destTestDB + "'"); + utils.copyFile(xMSF, sourceTestDB, destTestDB); + + m_dbTools = new DBTools( xMSF, log ); + String tmpDir = utils.getOfficeTemp((xMSF)); + + m_srcInf = m_dbTools.newDataSourceInfo(); + m_srcInf.URL = "sdbc:dbase:" + DBTools.dirToUrl(tmpDir); + log.println("data source: " + m_srcInf.URL); + + m_dbSrc = m_srcInf.getDataSourceService(); + m_dbTools.reRegisterDB(m_dbSourceName, m_dbSrc); + + m_XFormLoader = FormTools.bindForm(m_xTextDoc, m_dbSourceName, + m_TestDB); + } catch (com.sun.star.uno.Exception e) { + log.println("!!! Can't access TestDB !!!"); + e.printStackTrace(log); + throw new StatusException("Can't access TestDB", e); + } + + log.println("creating a new environment for object"); + + TestEnvironment tEnv = new TestEnvironment(oObj); + + tEnv.addObjRelation("OBJNAME", m_ObjectName); + + log.println("adding shape '" + m_LCShape_Type +"' for DataAwareControlModel test"); + aShape = FormTools.createControlShape(m_xTextDoc, 6000, 4500, 15000, + 10000, m_LCShape_Type); + WriterTools.getDrawPage(m_xTextDoc).add((XShape) aShape); + + m_XPS = (XPropertySet) UnoRuntime.queryInterface( + XPropertySet.class, oObj); + + int i = 0; + NamedValue prop = null; + try { + for (i = 0; i < m_propertiesToSet.size(); i++){ + prop = (NamedValue) m_propertiesToSet.get(i); + + log.println("setting property: '"+prop.Name+"' to value '"+prop.Value.toString()+"'"); + + m_XPS.setPropertyValue(prop.Name, prop.Value); + } + } catch (com.sun.star.lang.WrappedTargetException e) { + e.printStackTrace(log); + throw new StatusException("Couldn't set property '" + prop.Name + "': ", e); + } catch (com.sun.star.lang.IllegalArgumentException e) { + e.printStackTrace(log); + throw new StatusException("Couldn't set property '" + prop.Name + "': ", e); + } catch (com.sun.star.beans.PropertyVetoException e) { + e.printStackTrace(log); + throw new StatusException("Couldn't set property '" + prop.Name + "': ", e); + } catch (com.sun.star.beans.UnknownPropertyException e) { + e.printStackTrace(log); + throw new StatusException("Couldn't set property '" + prop.Name + "': ", e); + } catch (java.lang.ClassCastException e) { + e.printStackTrace(log); + throw new StatusException("Couldn't get property on index '" + i + "': ", e); + } + + // added LabelControl for 'DataAwareControlModel' + tEnv.addObjRelation("LC", aShape.getControl()); + + // added FormLoader for 'DataAwareControlModel' + tEnv.addObjRelation("FL", m_XFormLoader); + + // adding relation for XUpdateBroadcaster + m_XCtrl = oObj; + + tEnv.addObjRelation("XUpdateBroadcaster.Checker", + new Checker(m_XFormLoader, m_XPS, m_XCtrl, m_ChangePropertyName, m_ChangePropertyValue)); + + // adding relation for DataAwareControlModel service + tEnv.addObjRelation("DataAwareControlModel.NewFieldName", + DBTools.TST_DATE_F); + + //adding ObjRelation for XPersistObject + tEnv.addObjRelation("PSEUDOPERSISTENT", new Boolean(true)); + + // adding relation for XFastPropertySet + java.util.HashSet exclude = new java.util.HashSet(); + exclude.add("FormatKey"); + tEnv.addObjRelation("XFastPropertySet.ExcludeProps", exclude); + + PropertyValue propVal = new PropertyValue(); + propVal.Name = m_XPropertyAccess_propertyToChange; + propVal.Value = "Text since XPropertyAccess"; + tEnv.addObjRelation("XPropertyAccess.propertyToChange", propVal); + tEnv.addObjRelation("XPropertyContainer.propertyNotRemovable", m_XPropertyContainer_propertyNotRemovable); + + + return tEnv; + } // finish method getTestEnvironment + + + static class Checker implements ifc.form._XUpdateBroadcaster.UpdateChecker { + private Object lastValue = null; + XLoadable formLoaderF = null; + XPropertySet ps = null; + XInterface ctrl = null; + String ChangePropertyName = null; + Object ChangePropertyValue = null; + + public Checker(XLoadable xl, XPropertySet ps, XInterface ctrl, String ChangePropertyName, Object ChangePropertyValue) { + formLoaderF = xl; + this.ps = ps; + this.ctrl = ctrl; + this.ChangePropertyName=ChangePropertyName; + this.ChangePropertyValue=ChangePropertyValue; + } + + public void update() throws com.sun.star.uno.Exception { + if (!formLoaderF.isLoaded()) { + formLoaderF.load(); + } + + lastValue = util.ValueChanger.changePValue(ps.getPropertyValue(ChangePropertyName)); + + if (lastValue == null){ + + if (ChangePropertyValue != null){ + + lastValue = ChangePropertyValue; + + } else { + + String msg = "The initial value of the property '" + ChangePropertyName + "' is NULL\n"; + msg += "The member variable 'm_ChangePropertyValue' is NULL\n"; + msg += "Could not change Property."; + + throw new StatusException(Status.failed(msg)); + } + } + ps.setPropertyValue(ChangePropertyName, lastValue); + } + + public void commit() throws com.sun.star.sdbc.SQLException { + XBoundComponent bound = (XBoundComponent) UnoRuntime.queryInterface( + XBoundComponent.class, ctrl); + XResultSetUpdate update = (XResultSetUpdate) UnoRuntime.queryInterface( + XResultSetUpdate.class, + formLoaderF); + + bound.commit(); + update.updateRow(); + } + + public boolean wasCommited() throws com.sun.star.uno.Exception { + formLoaderF.reload(); + + Object newValue = ps.getPropertyValue(ChangePropertyName); + + return (newValue != null) && (util.ValueComparer.equalValue(lastValue, newValue)); + } + } +} // finish class GenericModelTest diff --git a/qadevOOo/tests/java/mod/_forms/OButtonControl.java b/qadevOOo/tests/java/mod/_forms/OButtonControl.java new file mode 100644 index 000000000000..d6bff70496db --- /dev/null +++ b/qadevOOo/tests/java/mod/_forms/OButtonControl.java @@ -0,0 +1,223 @@ +/************************************************************************* + * + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * Copyright 2000, 2010 Oracle and/or its affiliates. + * + * OpenOffice.org - a multi-platform office productivity suite + * + * This file is part of OpenOffice.org. + * + * OpenOffice.org is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License version 3 + * only, as published by the Free Software Foundation. + * + * OpenOffice.org is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License version 3 for more details + * (a copy is included in the LICENSE file that accompanied this code). + * + * You should have received a copy of the GNU Lesser General Public License + * version 3 along with OpenOffice.org. If not, see + * <http://www.openoffice.org/license.html> + * for a copy of the LGPLv3 License. + * + ************************************************************************/ +package mod._forms; + +import java.io.PrintWriter; + +import lib.StatusException; +import lib.TestCase; +import lib.TestEnvironment; +import lib.TestParameters; +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.XDevice; +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.drawing.XControlShape; +import com.sun.star.drawing.XShape; +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.XCloseable; +import com.sun.star.view.XControlAccess; + + +/** + * Test for object which is represented by default controller + * of the <code>com.sun.star.form.component.CommandButton</code> + * component. <p> + * + * Object implements the following interfaces : + * <ul> + * <li> <code>com::sun::star::lang::XComponent</code></li> + * <li> <code>com::sun::star::awt::XWindow</code></li> + * <li> <code>com::sun::star::form::XApproveActionBroadcaster</code></li> + * <li> <code>com::sun::star::awt::XControl</code></li> + * <li> <code>com::sun::star::awt::XLayoutConstrains</code></li> + * <li> <code>com::sun::star::awt::XButton</code></li> + * <li> <code>com::sun::star::awt::XView</code></li> + * </ul> <p> + * + * This object test <b> is NOT </b> designed to be run in several + * threads concurently. + * + * @see com.sun.star.lang.XComponent + * @see com.sun.star.awt.XWindow + * @see com.sun.star.form.XApproveActionBroadcaster + * @see com.sun.star.awt.XControl + * @see com.sun.star.awt.XLayoutConstrains + * @see com.sun.star.awt.XButton + * @see com.sun.star.awt.XView + * @see ifc.lang._XComponent + * @see ifc.awt._XWindow + * @see ifc.form._XApproveActionBroadcaster + * @see ifc.awt._XControl + * @see ifc.awt._XLayoutConstrains + * @see ifc.awt._XButton + * @see ifc.awt._XView + */ +public class OButtonControl extends TestCase { + XTextDocument xTextDoc; + + /** + * Creates a text document. + */ + protected void initialize(TestParameters Param, PrintWriter log) { + SOfficeFactory SOF = SOfficeFactory.getFactory((XMultiServiceFactory) Param.getMSF()); + + try { + log.println("creating a textdocument"); + xTextDoc = SOF.createTextDoc(null); + } catch (com.sun.star.uno.Exception e) { + // Some exception occures.FAILED + e.printStackTrace(log); + throw new StatusException("Couldn't create document", e); + } + } + + /** + * Disposes the text document created before + */ + protected void cleanup(TestParameters tParam, PrintWriter log) { + log.println(" disposing xTextDoc "); + + try { + XCloseable closer = (XCloseable) 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"); + } + } + + /** + * Creates two components and inserts them to the form of + * text document. One component + * (<code>com.sun.star.form.component.CommandButton</code>) is created + * for testing, another to be passed as relation. Using a controller + * of the text document the controller of the first component is + * obtained and returned in environment as a test object. <p> + * + * Object relations created : + * <ul> + * <li> <code>'GRAPHICS'</code> for + * {@link ifc.awt._XView} : a graphics component + * created using screen device of the window peer of + * the controller tested. </li> + * <li> <code>'CONTEXT'</code> for + * {@link ifc.awt._XControl} : the text document + * where the component is inserted. </li> + * <li> <code>'WINPEER'</code> for + * {@link ifc.awt._XControl} : Window peer of the + * controller tested. </li> + * <li> <code>'TOOLKIT'</code> for + * {@link ifc.awt._XControl} : toolkit of the component.</li> + * <li> <code>'MODEL'</code> for + * {@link ifc.awt._XControl} : the model of the controller.</li> + * <li> <code>'XWindow.AnotherWindow'</code> for + * {@link ifc.awt._XWindow} : the controller of another + * component. </li> + * </ul> + */ + protected TestEnvironment createTestEnvironment(TestParameters Param, + PrintWriter log) { + XInterface oObj = null; + XWindowPeer the_win = null; + XToolkit the_kit = null; + XDevice aDevice = null; + XGraphics aGraphic = null; + XControl aControl = null; + + //Insert a ControlShape and get the ControlModel + XControlShape aShape = FormTools.createControlShape(xTextDoc, 3000, + 4500, 15000, 10000, + "CommandButton"); + + WriterTools.getDrawPage(xTextDoc).add((XShape) aShape); + + XControlModel the_Model = aShape.getControl(); + + XControlShape aShape2 = FormTools.createControlShape(xTextDoc, 3000, + 4500, 5000, 10000, + "TextField"); + + WriterTools.getDrawPage(xTextDoc).add((XShape) aShape2); + + XControlModel the_Model2 = aShape2.getControl(); + + //Try to query XControlAccess + XControlAccess the_access = (XControlAccess) UnoRuntime.queryInterface( + XControlAccess.class, + xTextDoc.getCurrentController()); + + //now get the OButtonControl + try { + oObj = the_access.getControl(the_Model); + aControl = the_access.getControl(the_Model2); + the_win = the_access.getControl(the_Model).getPeer(); + the_kit = the_win.getToolkit(); + aDevice = the_kit.createScreenCompatibleDevice(200, 200); + aGraphic = aDevice.createGraphics(); + } catch (com.sun.star.container.NoSuchElementException e) { + log.println("Couldn't get OButtonControl"); + e.printStackTrace(log); + throw new StatusException("Couldn't get OButtonControl", e); + } + + log.println("creating a new environment for OButtonControl object"); + + TestEnvironment tEnv = new TestEnvironment(oObj); + + + //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); + + XWindow forObjRel = (XWindow) UnoRuntime.queryInterface(XWindow.class, + aControl); + + tEnv.addObjRelation("XWindow.AnotherWindow", forObjRel); + tEnv.addObjRelation("XWindow.ControlShape", aShape); + + return tEnv; + } // finish method getTestEnvironment +} // finish class OButtonControl diff --git a/qadevOOo/tests/java/mod/_forms/OButtonModel.java b/qadevOOo/tests/java/mod/_forms/OButtonModel.java new file mode 100644 index 000000000000..5c5618f5167e --- /dev/null +++ b/qadevOOo/tests/java/mod/_forms/OButtonModel.java @@ -0,0 +1,134 @@ +/************************************************************************* + * + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * Copyright 2000, 2010 Oracle and/or its affiliates. + * + * OpenOffice.org - a multi-platform office productivity suite + * + * This file is part of OpenOffice.org. + * + * OpenOffice.org is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License version 3 + * only, as published by the Free Software Foundation. + * + * OpenOffice.org is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License version 3 for more details + * (a copy is included in the LICENSE file that accompanied this code). + * + * You should have received a copy of the GNU Lesser General Public License + * version 3 along with OpenOffice.org. If not, see + * <http://www.openoffice.org/license.html> + * for a copy of the LGPLv3 License. + * + ************************************************************************/ + +package mod._forms; + +import java.io.PrintWriter; +import lib.TestEnvironment; +import lib.TestParameters; + +/** + * Test for object which is represented by service + * <code>com.sun.star.com.sun.star.form.component.CommandButton</code>. + * <p> + * Object implements the following interfaces : + * <ul> + * <li> <code>com::sun::star::io::XPersistObject</code></li> + * <li> <code>com::sun::star::container::XChild</code></li> + * <li> <code>com::sun::star::form::FormControlModel</code></li> + * <li> <code>com::sun::star::form::XImageProducerSupplier</code></li> + * <li> <code>com::sun::star::form::FormComponent</code></li> + * <li> <code>com::sun::star::beans::XPropertyAccess</code></li> +* <li> <code>com::sun::star::beans::XPropertyContainer</code></li> +* <li> <code>com::sun::star::beans::XPropertySet</code></li> + * <li> <code>com::sun::star::beans::XFastPropertySet</code></li> + * <li> <code>com::sun::star::beans::XPropertyState</code></li> + * <li> <code>com::sun::star::awt::UnoControlButtonModel</code></li> + * <li> <code>com::sun::star::form::component::CommandButton</code></li> + * <li> <code>com::sun::star::container::XNamed</code></li> + * <li> <code>com::sun::star::beans::XMultiPropertySet</code></li> + * <li> <code>com::sun::star::lang::XComponent</code></li> + * </ul> + * This object test <b> is NOT </b> designed to be run in several + * threads concurently. + * + * @see com.sun.star.io.XPersistObject + * @see com.sun.star.container.XChild + * @see com.sun.star.form.FormControlModel + * @see com.sun.star.form.XImageProducerSupplier + * @see com.sun.star.form.FormComponent + * @see com.sun.star.beans.XPropertyAccess +* @see com.sun.star.beans.XPropertyContainer +* @see com.sun.star.beans.XPropertySet + * @see com.sun.star.beans.XFastPropertySet + * @see com.sun.star.beans.XPropertyState + * @see com.sun.star.awt.UnoControlButtonModel + * @see com.sun.star.form.component.CommandButton + * @see com.sun.star.container.XNamed + * @see com.sun.star.beans.XMultiPropertySet + * @see com.sun.star.lang.XComponent + * @see ifc.io._XPersistObject + * @see ifc.container._XChild + * @see ifc.form._FormControlModel + * @see ifc.form._XImageProducerSupplier + * @see ifc.form._FormComponent + * @see ifc.beans._XPropertySet + * @see ifc.beans._XFastPropertySet + * @see ifc.beans._XPropertyState + * @see ifc.awt._UnoControlButtonModel + * @see ifc.form.component._CommandButton + * @see ifc.container._XNamed + * @see ifc.beans._XMultiPropertySet + * @see ifc.lang._XComponent + */ +public class OButtonModel extends GenericModelTest { + + /** + * Set some member variable of the super class <CODE>GenericModelTest</CODE>: + * <pre> + * super.m_kindOfControl="CommandButton"; + * super.m_ObjectName = "com.sun.star.form.component.CommandButton"; + * super.m_LCShape_Type = "CommandButton"; + * </pre> + * Then <CODE>super.initialize()</CODE> was called. + * @param tParam the test parameter + * @param log the log writer + */ + + protected void initialize(TestParameters tParam, PrintWriter log) { + + super.initialize(tParam, log); + + super.m_kindOfControl="CommandButton"; + + super.m_ObjectName = "stardiv.one.form.component.CommandButton"; + + super.m_LCShape_Type = "CommandButton"; + + } + /** + * calls <CODE>cleanup()</CODE> from it's super class + * @param tParam the test parameter + * @param log the log writer + */ + protected void cleanup(TestParameters tParam, PrintWriter log) { + super.cleanup(tParam, log); + } + + + /** + * calls <CODE>createTestEnvironment()</CODE> from it's super class + * @param Param the test parameter + * @param log the log writer + * @return lib.TestEnvironment + */ + protected synchronized TestEnvironment createTestEnvironment(TestParameters Param, + PrintWriter log) { + return super.createTestEnvironment(Param, log); + } + +} // finish class OButtonModelold diff --git a/qadevOOo/tests/java/mod/_forms/OCheckBoxControl.java b/qadevOOo/tests/java/mod/_forms/OCheckBoxControl.java new file mode 100644 index 000000000000..fc01ddfc9c04 --- /dev/null +++ b/qadevOOo/tests/java/mod/_forms/OCheckBoxControl.java @@ -0,0 +1,237 @@ +/************************************************************************* + * + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * Copyright 2000, 2010 Oracle and/or its affiliates. + * + * OpenOffice.org - a multi-platform office productivity suite + * + * This file is part of OpenOffice.org. + * + * OpenOffice.org is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License version 3 + * only, as published by the Free Software Foundation. + * + * OpenOffice.org is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License version 3 for more details + * (a copy is included in the LICENSE file that accompanied this code). + * + * You should have received a copy of the GNU Lesser General Public License + * version 3 along with OpenOffice.org. If not, see + * <http://www.openoffice.org/license.html> + * for a copy of the LGPLv3 License. + * + ************************************************************************/ + +package mod._forms; + +import java.io.PrintWriter; + +import lib.StatusException; +import lib.TestCase; +import lib.TestEnvironment; +import lib.TestParameters; +import util.FormTools; +import util.SOfficeFactory; +import util.WriterTools; + +import com.sun.star.awt.XCheckBox; +import com.sun.star.awt.XControl; +import com.sun.star.awt.XControlModel; +import com.sun.star.awt.XDevice; +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.drawing.XControlShape; +import com.sun.star.drawing.XShape; +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.XCloseable; +import com.sun.star.view.XControlAccess; + + +/** + * Test for object which is represented by default controller + * of the <code>com.sun.star.form.component.CheckBox</code> + * component. <p> + * + * Object implements the following interfaces : + * <ul> + * <li> <code>com::sun::star::awt::XView</code></li> + * <li> <code>com::sun::star::form::XBoundControl</code></li> + * <li> <code>com::sun::star::awt::XControl</code></li> + * <li> <code>com::sun::star::awt::XLayoutConstrains</code></li> + * <li> <code>com::sun::star::awt::XItemListener</code></li> + * <li> <code>com::sun::star::awt::XWindow</code></li> + * <li> <code>com::sun::star::awt::XCheckBox</code></li> + * <li> <code>com::sun::star::lang::XComponent</code></li> + * <li> <code>com::sun::star::lang::XEventListener</code></li> + * </ul> <p> + * This object test <b> is NOT </b> designed to be run in several + * threads concurently. + * + * @see com.sun.star.awt.XView + * @see com.sun.star.form.XBoundControl + * @see com.sun.star.awt.XControl + * @see com.sun.star.awt.XLayoutConstrains + * @see com.sun.star.awt.XItemListener + * @see com.sun.star.awt.XWindow + * @see com.sun.star.awt.XCheckBox + * @see com.sun.star.lang.XComponent + * @see com.sun.star.lang.XEventListener + * @see ifc.awt._XView + * @see ifc.form._XBoundControl + * @see ifc.awt._XControl + * @see ifc.awt._XLayoutConstrains + * @see ifc.awt._XItemListener + * @see ifc.awt._XWindow + * @see ifc.awt._XCheckBox + * @see ifc.lang._XComponent + * @see ifc.lang._XEventListener + */ +public class OCheckBoxControl extends TestCase { + + XTextDocument xTextDoc; + + /** + * Creates a new text document. + */ + protected void initialize ( TestParameters Param, PrintWriter log) { + SOfficeFactory SOF = SOfficeFactory.getFactory( ((XMultiServiceFactory)Param.getMSF()) ); + + try { + log.println( "creating a textdocument" ); + xTextDoc = SOF.createTextDoc( null ); + } catch ( com.sun.star.uno.Exception e ) { + // Some exception occures.FAILED + e.printStackTrace( log ); + throw new StatusException( "Couldn't create document", e ); + } + } + + /** + * Disposes the text document created before + */ + protected void cleanup(TestParameters tParam, PrintWriter log) { + log.println(" disposing xTextDoc "); + + try { + XCloseable closer = (XCloseable) 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"); + } + } + + /** + * Creates two components and inserts them to the form of + * text document. One component + * (<code>com.sun.star.form.component.CheckBox</code>) is created + * for testing, another to be passed as relation. Using a controller + * of the text document the controller of the first component is + * obtained and returned in environment as a test object. <p> + * + * Object relations created : + * <ul> + * <li> <code>'GRAPHICS'</code> for + * {@link ifc.awt._XView} : a graphics component + * created using screen device of the window peer of + * the controller tested. </li> + * <li> <code>'CONTEXT'</code> for + * {@link ifc.awt._XControl} : the text document + * where the component is inserted. </li> + * <li> <code>'WINPEER'</code> for + * {@link ifc.awt._XControl} : Window peer of the + * controller tested. </li> + * <li> <code>'TOOLKIT'</code> for + * {@link ifc.awt._XControl} : toolkit of the component.</li> + * <li> <code>'MODEL'</code> for + * {@link ifc.awt._XControl} : the model of the controller.</li> + * <li> <code>'XWindow.AnotherWindow'</code> for + * {@link ifc.awt._XWindow} : the controller of another + * component. </li> + * <li> <code>'TestItemListener'</code> for + * {@link ifc.awt._XItemListener} : listener implementation is + * registered here and passed as relation. </li> + * </ul> + */ + protected TestEnvironment createTestEnvironment(TestParameters Param, PrintWriter log) { + XInterface oObj = null; + XWindowPeer the_win = null; + XToolkit the_kit = null; + XDevice aDevice = null; + XGraphics aGraphic = null; + XControl aControl = null; + //Insert a ControlShape and get the ControlModel + XControlShape aShape = FormTools.createControlShape( + xTextDoc,3000,4500,15000,10000,"CheckBox"); + + WriterTools.getDrawPage(xTextDoc).add((XShape) aShape); + + XControlModel the_Model = aShape.getControl(); + + XControlShape aShape2 = FormTools.createControlShape( + xTextDoc,3000,4500,5000,10000,"TextField"); + + WriterTools.getDrawPage(xTextDoc).add((XShape) aShape2); + + XControlModel the_Model2 = aShape2.getControl(); + + //Try to query XControlAccess + XControlAccess the_access = (XControlAccess) UnoRuntime.queryInterface( + XControlAccess.class,xTextDoc.getCurrentController()); + + //now get the OButtonControl + try { + oObj = the_access.getControl(the_Model); + aControl = the_access.getControl(the_Model2); + the_win = the_access.getControl(the_Model).getPeer(); + the_kit = the_win.getToolkit(); + aDevice = the_kit.createScreenCompatibleDevice(200,200); + aGraphic = aDevice.createGraphics(); + } catch (com.sun.star.container.NoSuchElementException e) { + log.println("Couldn't get OCheckBoxControl"); + e.printStackTrace(log); + throw new StatusException("Couldn't get OCheckBoxControl", e ); + } + + log.println( "creating a new environment for OCheckBoxControl object" ); + TestEnvironment tEnv = new TestEnvironment( oObj ); + + //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 XItemListener + ifc.awt._XItemListener.TestItemListener listener = + new ifc.awt._XItemListener.TestItemListener() ; + XCheckBox box = (XCheckBox) UnoRuntime.queryInterface + (XCheckBox.class, oObj) ; + box.addItemListener(listener) ; + tEnv.addObjRelation("TestItemListener", listener) ; + + // Adding relation for XWindow + XWindow forObjRel = (XWindow) + UnoRuntime.queryInterface(XWindow.class,aControl); + + tEnv.addObjRelation("XWindow.AnotherWindow",forObjRel); + + return tEnv; + } // finish method getTestEnvironment + +} // finish class OButtonControl + + diff --git a/qadevOOo/tests/java/mod/_forms/OCheckBoxModel.java b/qadevOOo/tests/java/mod/_forms/OCheckBoxModel.java new file mode 100644 index 000000000000..9a569c833470 --- /dev/null +++ b/qadevOOo/tests/java/mod/_forms/OCheckBoxModel.java @@ -0,0 +1,149 @@ +/************************************************************************* + * + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * Copyright 2000, 2010 Oracle and/or its affiliates. + * + * OpenOffice.org - a multi-platform office productivity suite + * + * This file is part of OpenOffice.org. + * + * OpenOffice.org is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License version 3 + * only, as published by the Free Software Foundation. + * + * OpenOffice.org is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License version 3 for more details + * (a copy is included in the LICENSE file that accompanied this code). + * + * You should have received a copy of the GNU Lesser General Public License + * version 3 along with OpenOffice.org. If not, see + * <http://www.openoffice.org/license.html> + * for a copy of the LGPLv3 License. + * + ************************************************************************/ +package mod._forms; + +import java.io.PrintWriter; + +import lib.TestEnvironment; +import lib.TestParameters; + + + +/** +* Test for object which is represented by service +* <code>com.sun.star.form.component.CheckBox</code>. <p> +* Object implements the following interfaces : +* <ul> +* <li> <code>com::sun::star::beans::XFastPropertySet</code></li> +* <li> <code>com::sun::star::io::XPersistObject</code></li> +* <li> <code>com::sun::star::form::XReset</code></li> +* <li> <code>com::sun::star::form::FormComponent</code></li> +* <li> <code>com::sun::star::form::component::CheckBox</code></li> +* <li> <code>com::sun::star::beans::XMultiPropertySet</code></li> +* <li> <code>com::sun::star::form::DataAwareControlModel</code></li> +* <li> <code>com::sun::star::form::XUpdateBroadcaster</code></li> +* <li> <code>com::sun::star::beans::XPropertyState</code></li> +* <li> <code>com::sun::star::form::FormControlModel</code></li> +* <li> <code>com::sun::star::awt::UnoControlCheckBoxModel</code></li> +* <li> <code>com::sun::star::container::XNamed</code></li> +* <li> <code>com::sun::star::form::XBoundComponent</code></li> +* <li> <code>com::sun::star::lang::XComponent</code></li> +* <li> <code>com::sun::star::lang::XEventListener</code></li> +* <li> <code>com::sun::star::beans::XPropertyAccess</code></li> +* <li> <code>com::sun::star::beans::XPropertyContainer</code></li> +* <li> <code>com::sun::star::beans::XPropertySet</code></li> +* <li> <code>com::sun::star::form::XLoadListener</code></li> +* <li> <code>com::sun::star::container::XChild</code></li> +* </ul> +* This object test <b> is NOT </b> designed to be run in several +* threads concurently. +* +* @see com.sun.star.beans.XFastPropertySet +* @see com.sun.star.io.XPersistObject +* @see com.sun.star.form.XReset +* @see com.sun.star.form.FormComponent +* @see com.sun.star.form.component.CheckBox +* @see com.sun.star.beans.XMultiPropertySet +* @see com.sun.star.form.DataAwareControlModel +* @see com.sun.star.form.XUpdateBroadcaster +* @see com.sun.star.beans.XPropertyState +* @see com.sun.star.form.FormControlModel +* @see com.sun.star.awt.UnoControlCheckBoxModel +* @see com.sun.star.container.XNamed +* @see com.sun.star.form.XBoundComponent +* @see com.sun.star.lang.XComponent +* @see com.sun.star.lang.XEventListener +* @see com.sun.star.beans.XPropertyAccess +* @see com.sun.star.beans.XPropertyContainer +* @see com.sun.star.beans.XPropertySet +* @see com.sun.star.form.XLoadListener +* @see com.sun.star.container.XChild +* @see ifc.beans._XFastPropertySet +* @see ifc.io._XPersistObject +* @see ifc.form._XReset +* @see ifc.form._FormComponent +* @see ifc.form.component._CheckBox +* @see ifc.beans._XMultiPropertySet +* @see ifc.form._DataAwareControlModel +* @see ifc.form._XUpdateBroadcaster +* @see ifc.beans._XPropertyState +* @see ifc.form._FormControlModel +* @see ifc.awt._UnoControlCheckBoxModel +* @see ifc.container._XNamed +* @see ifc.form._XBoundComponent +* @see ifc.lang._XComponent +* @see ifc.lang._XEventListener +* @see ifc.beans._XPropertySet +* @see ifc.form._XLoadListener +* @see ifc.container._XChild +*/ +public class OCheckBoxModel extends GenericModelTest { + + /** + * Set some member variable of the super class <CODE>GenericModelTest</CODE>: + * <pre> + * super.m_kindOfControl="CheckBox"; + * super.m_ObjectName = "stardiv.one.form.component.CheckBox"; + * super.m_LCShape_Type = "FixedText"; + * </pre> + * Then <CODE>super.initialize()</CODE> was called. + * @param tParam the test parameter + * @param log the log writer + */ + protected void initialize(TestParameters tParam, PrintWriter log) { + + super.initialize(tParam, log); + + super.m_kindOfControl= "CheckBox"; + + super.m_ObjectName = "stardiv.one.form.component.CheckBox"; + + super.m_LCShape_Type = "FixedText"; + + } + /** + * calls <CODE>cleanup()</CODE> from it's super class + * @param tParam the test parameter + * @param log the log writer + */ + protected void cleanup(TestParameters tParam, PrintWriter log) { + super.cleanup(tParam, log); + } + + + /** + * calls <CODE>createTestEnvironment()</CODE> from it's super class + * @param Param the test parameter + * @param log the log writer + * @return lib.TestEnvironment + */ + protected synchronized TestEnvironment createTestEnvironment(TestParameters Param, + PrintWriter log) { + return super.createTestEnvironment(Param, log); + } +} // finish class OCheckBoxModel + diff --git a/qadevOOo/tests/java/mod/_forms/OComboBoxControl.java b/qadevOOo/tests/java/mod/_forms/OComboBoxControl.java new file mode 100644 index 000000000000..bc9c315e9443 --- /dev/null +++ b/qadevOOo/tests/java/mod/_forms/OComboBoxControl.java @@ -0,0 +1,244 @@ +/************************************************************************* + * + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * Copyright 2000, 2010 Oracle and/or its affiliates. + * + * OpenOffice.org - a multi-platform office productivity suite + * + * This file is part of OpenOffice.org. + * + * OpenOffice.org is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License version 3 + * only, as published by the Free Software Foundation. + * + * OpenOffice.org is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License version 3 for more details + * (a copy is included in the LICENSE file that accompanied this code). + * + * You should have received a copy of the GNU Lesser General Public License + * version 3 along with OpenOffice.org. If not, see + * <http://www.openoffice.org/license.html> + * for a copy of the LGPLv3 License. + * + ************************************************************************/ +package mod._forms; + +import java.io.PrintWriter; + +import lib.StatusException; +import lib.TestCase; +import lib.TestEnvironment; +import lib.TestParameters; +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.XDevice; +import com.sun.star.awt.XGraphics; +import com.sun.star.awt.XTextComponent; +import com.sun.star.awt.XToolkit; +import com.sun.star.awt.XWindow; +import com.sun.star.awt.XWindowPeer; +import com.sun.star.drawing.XControlShape; +import com.sun.star.drawing.XShape; +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.XCloseable; +import com.sun.star.view.XControlAccess; + + +/** + * Test for object which is represented by default controller + * of the <code>com.sun.star.form.component.ComboBox</code> + * component. <p> + * + * Object implements the following interfaces : + * <ul> + * <li> <code>com::sun::star::awt::XView</code></li> + * <li> <code>com::sun::star::form::XBoundControl</code></li> + * <li> <code>com::sun::star::awt::XControl</code></li> + * <li> <code>com::sun::star::awt::XTextComponent</code></li> + * <li> <code>com::sun::star::awt::XComboBox</code></li> + * <li> <code>com::sun::star::awt::XLayoutConstrains</code></li> + * <li> <code>com::sun::star::awt::XTextListener</code></li> + * <li> <code>com::sun::star::awt::XWindow</code></li> + * <li> <code>com::sun::star::lang::XComponent</code></li> + * <li> <code>com::sun::star::awt::XTextLayoutConstrains</code></li> + * <li> <code>com::sun::star::lang::XEventListener</code></li> + * </ul> <p> + * This object test <b> is NOT </b> designed to be run in several + * threads concurently. + * + * @see com.sun.star.awt.XView + * @see com.sun.star.form.XBoundControl + * @see com.sun.star.awt.XControl + * @see com.sun.star.awt.XTextComponent + * @see com.sun.star.awt.XComboBox + * @see com.sun.star.awt.XLayoutConstrains + * @see com.sun.star.awt.XTextListener + * @see com.sun.star.awt.XWindow + * @see com.sun.star.lang.XComponent + * @see com.sun.star.awt.XTextLayoutConstrains + * @see com.sun.star.lang.XEventListener + * @see ifc.awt._XView + * @see ifc.form._XBoundControl + * @see ifc.awt._XControl + * @see ifc.awt._XTextComponent + * @see ifc.awt._XComboBox + * @see ifc.awt._XLayoutConstrains + * @see ifc.awt._XTextListener + * @see ifc.awt._XWindow + * @see ifc.lang._XComponent + * @see ifc.awt._XTextLayoutConstrains + * @see ifc.lang._XEventListener + */ +public class OComboBoxControl extends TestCase { + XTextDocument xTextDoc; + + /** + * Creates a new text document. + */ + protected void initialize(TestParameters Param, PrintWriter log) { + SOfficeFactory SOF = SOfficeFactory.getFactory(((XMultiServiceFactory) Param.getMSF())); + + try { + log.println("creating a textdocument"); + xTextDoc = SOF.createTextDoc(null); + } catch (com.sun.star.uno.Exception e) { + // Some exception occures.FAILED + e.printStackTrace(log); + throw new StatusException("Couldn't create document", e); + } + } + + /** + * Disposes the text document created before + */ + protected void cleanup(TestParameters tParam, PrintWriter log) { + log.println(" disposing xTextDoc "); + + try { + XCloseable closer = (XCloseable) 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"); + } + } + + /** + * Creates two components and inserts them to the form of + * text document. One component + * (<code>com.sun.star.form.component.ComboBox</code>) is created + * for testing, another to be passed as relation. Using a controller + * of the text document the controller of the first component is + * obtained and returned in environment as a test object. <p> + * + * Object relations created : + * <ul> + * <li> <code>'GRAPHICS'</code> for + * {@link ifc.awt._XView} : a graphics component + * created using screen device of the window peer of + * the controller tested. </li> + * <li> <code>'CONTEXT'</code> for + * {@link ifc.awt._XControl} : the text document + * where the component is inserted. </li> + * <li> <code>'WINPEER'</code> for + * {@link ifc.awt._XControl} : Window peer of the + * controller tested. </li> + * <li> <code>'TOOLKIT'</code> for + * {@link ifc.awt._XControl} : toolkit of the component.</li> + * <li> <code>'MODEL'</code> for + * {@link ifc.awt._XControl} : the model of the controller.</li> + * <li> <code>'XWindow.AnotherWindow'</code> for + * {@link ifc.awt._XWindow} : the controller of another + * component. </li> + * </ul> + */ + protected TestEnvironment createTestEnvironment(TestParameters Param, + PrintWriter log) { + XInterface oObj = null; + XWindowPeer the_win = null; + XToolkit the_kit = null; + XDevice aDevice = null; + XGraphics aGraphic = null; + XControl aControl = null; + + //Insert a ControlShape and get the ControlModel + XControlShape aShape = FormTools.createControlShape(xTextDoc, 3000, + 4500, 15000, 10000, + "ComboBox"); + + WriterTools.getDrawPage(xTextDoc).add((XShape) aShape); + + XControlModel the_Model = aShape.getControl(); + + XControlShape aShape2 = FormTools.createControlShape(xTextDoc, 3000, + 4500, 5000, 10000, + "TextField"); + + WriterTools.getDrawPage(xTextDoc).add((XShape) aShape2); + + XControlModel the_Model2 = aShape2.getControl(); + + //Try to query XControlAccess + XControlAccess the_access = (XControlAccess) UnoRuntime.queryInterface( + XControlAccess.class, + xTextDoc.getCurrentController()); + + //now get the OButtonControl + try { + oObj = the_access.getControl(the_Model); + aControl = the_access.getControl(the_Model2); + the_win = the_access.getControl(the_Model).getPeer(); + the_kit = the_win.getToolkit(); + aDevice = the_kit.createScreenCompatibleDevice(200, 200); + aGraphic = aDevice.createGraphics(); + } catch (com.sun.star.container.NoSuchElementException e) { + log.println("Couldn't get OCheckBoxControl"); + e.printStackTrace(log); + throw new StatusException("Couldn't get OComboBoxControl", e); + } + + log.println("creating a new environment for OComboBoxControl object"); + + TestEnvironment tEnv = new TestEnvironment(oObj); + + + //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 + XWindow forObjRel = (XWindow) UnoRuntime.queryInterface(XWindow.class, + aControl); + + tEnv.addObjRelation("XWindow.AnotherWindow", forObjRel); + tEnv.addObjRelation("XWindow.ControlShape", aShape); + + // Adding relation for XTextListener + ifc.awt._XTextListener.TestTextListener listener = + new ifc.awt._XTextListener.TestTextListener(); + XTextComponent textComp = (XTextComponent) UnoRuntime.queryInterface( + XTextComponent.class, oObj); + textComp.addTextListener(listener); + tEnv.addObjRelation("TestTextListener", listener); + + return tEnv; + } // finish method getTestEnvironment +} // finish class OButtonControl diff --git a/qadevOOo/tests/java/mod/_forms/OComboBoxModel.java b/qadevOOo/tests/java/mod/_forms/OComboBoxModel.java new file mode 100644 index 000000000000..4f3b256fa982 --- /dev/null +++ b/qadevOOo/tests/java/mod/_forms/OComboBoxModel.java @@ -0,0 +1,164 @@ +/************************************************************************* + * + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * Copyright 2000, 2010 Oracle and/or its affiliates. + * + * OpenOffice.org - a multi-platform office productivity suite + * + * This file is part of OpenOffice.org. + * + * OpenOffice.org is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License version 3 + * only, as published by the Free Software Foundation. + * + * OpenOffice.org is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License version 3 for more details + * (a copy is included in the LICENSE file that accompanied this code). + * + * You should have received a copy of the GNU Lesser General Public License + * version 3 along with OpenOffice.org. If not, see + * <http://www.openoffice.org/license.html> + * for a copy of the LGPLv3 License. + * + ************************************************************************/ +package mod._forms; +import com.sun.star.beans.NamedValue; +import java.io.PrintWriter; + +import lib.TestEnvironment; +import lib.TestParameters; + +import util.DBTools; + + +/** +* Test for object which is represented by service +* <code>com.sun.star.form.component.ComboBox</code>. <p> +* Object implements the following interfaces : +* <ul> +* <li> <code>com::sun::star::beans::XFastPropertySet</code></li> +* <li> <code>com::sun::star::io::XPersistObject</code></li> +* <li> <code>com::sun::star::form::XReset</code></li> +* <li> <code>com::sun::star::form::FormComponent</code></li> +* <li> <code>com::sun::star::awt::UnoControlComboBoxModel</code></li> +* <li> <code>com::sun::star::beans::XMultiPropertySet</code></li> +* <li> <code>com::sun::star::form::XUpdateBroadcaster</code></li> +* <li> <code>com::sun::star::form::DataAwareControlModel</code></li> +* <li> <code>com::sun::star::form::component::DatabaseComboBox</code></li> +* <li> <code>com::sun::star::beans::XPropertyState</code></li> +* <li> <code>com::sun::star::form::FormControlModel</code></li> +* <li> <code>com::sun::star::container::XNamed</code></li> +* <li> <code>com::sun::star::form::XBoundComponent</code></li> +* <li> <code>com::sun::star::form::component::ComboBox</code></li> +* <li> <code>com::sun::star::lang::XComponent</code></li> +* <li> <code>com::sun::star::lang::XEventListener</code></li> +* <li> <code>com::sun::star::beans::XPropertyAccess</code></li> +* <li> <code>com::sun::star::beans::XPropertyContainer</code></li> +* <li> <code>com::sun::star::beans::XPropertySet</code></li> +* <li> <code>com::sun::star::form::XLoadListener</code></li> +* <li> <code>com::sun::star::container::XChild</code></li> +* </ul> +* This object test <b> is NOT </b> designed to be run in several +* threads concurently. +* @see com.sun.star.beans.XFastPropertySet +* @see com.sun.star.io.XPersistObject +* @see com.sun.star.form.XReset +* @see com.sun.star.form.FormComponent +* @see com.sun.star.awt.UnoControlComboBoxModel +* @see com.sun.star.beans.XMultiPropertySet +* @see com.sun.star.form.XUpdateBroadcaster +* @see com.sun.star.form.DataAwareControlModel +* @see com.sun.star.form.component.DatabaseComboBox +* @see com.sun.star.beans.XPropertyState +* @see com.sun.star.form.FormControlModel +* @see com.sun.star.container.XNamed +* @see com.sun.star.form.XBoundComponent +* @see com.sun.star.form.component.ComboBox +* @see com.sun.star.lang.XComponent +* @see com.sun.star.lang.XEventListener +* @see com.sun.star.beans.XPropertyAccess +* @see com.sun.star.beans.XPropertyContainer +* @see com.sun.star.beans.XPropertySet +* @see com.sun.star.form.XLoadListener +* @see com.sun.star.container.XChild +* @see ifc.beans._XFastPropertySet +* @see ifc.io._XPersistObject +* @see ifc.form._XReset +* @see ifc.form._FormComponent +* @see ifc.awt._UnoControlComboBoxModel +* @see ifc.beans._XMultiPropertySet +* @see ifc.form._XUpdateBroadcaster +* @see ifc.form._DataAwareControlModel +* @see ifc.form.component._DatabaseComboBox +* @see ifc.beans._XPropertyState +* @see ifc.form._FormControlModel +* @see ifc.container._XNamed +* @see ifc.form._XBoundComponent +* @see ifc.form.component._ComboBox +* @see ifc.lang._XComponent +* @see ifc.lang._XEventListener +* @see ifc.beans._XPropertySet +* @see ifc.form._XLoadListener +* @see ifc.container._XChild +*/ +public class OComboBoxModel extends GenericModelTest { + /** + * Set some member variable of the super class <CODE>GenericModelTest</CODE>: + * <pre> + * super.m_ChangePropertyName = "Text"; + * super.m_kindOfControl="ComboBox"; + * super.m_ObjectName = "stardiv.one.form.component.ComboBox"; + * + * NamedValue DataField = new NamedValue(); + * DataField.Name = "DataField"; + * DataField.Value = DBTools.TST_STRING_F; + * super.m_propertiesToSet.add(DataField); + * super.m_LCShape_Type = "FixedText"; + * </pre> + * Then <CODE>super.initialize()</CODE> was called. + * @param tParam the test parameter + * @param log the log writer + */ + protected void initialize(TestParameters tParam, PrintWriter log) { + + super.initialize(tParam, log); + + super.m_ChangePropertyName = "Text"; + + super.m_kindOfControl="ComboBox"; + + super.m_ObjectName = "stardiv.one.form.component.ComboBox"; + + NamedValue DataField = new NamedValue(); + DataField.Name = "DataField"; + DataField.Value = DBTools.TST_STRING_F; + super.m_propertiesToSet.add(DataField); + + super.m_LCShape_Type = "FixedText"; + + } + /** + * calls <CODE>cleanup()</CODE> from it's super class + * @param tParam the test parameter + * @param log the log writer + */ + protected void cleanup(TestParameters tParam, PrintWriter log) { + super.cleanup(tParam, log); + } + + + /** + * calls <CODE>createTestEnvironment()</CODE> from it's super class + * @param Param the test parameter + * @param log the log writer + * @return lib.TestEnvironment + */ + protected synchronized TestEnvironment createTestEnvironment(TestParameters Param, + PrintWriter log) { + return super.createTestEnvironment(Param, log); + } + +} // finish class OComboBoxModel diff --git a/qadevOOo/tests/java/mod/_forms/OCurrencyControl.java b/qadevOOo/tests/java/mod/_forms/OCurrencyControl.java new file mode 100644 index 000000000000..6cbcb2de6bce --- /dev/null +++ b/qadevOOo/tests/java/mod/_forms/OCurrencyControl.java @@ -0,0 +1,251 @@ +/************************************************************************* + * + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * Copyright 2000, 2010 Oracle and/or its affiliates. + * + * OpenOffice.org - a multi-platform office productivity suite + * + * This file is part of OpenOffice.org. + * + * OpenOffice.org is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License version 3 + * only, as published by the Free Software Foundation. + * + * OpenOffice.org is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License version 3 for more details + * (a copy is included in the LICENSE file that accompanied this code). + * + * You should have received a copy of the GNU Lesser General Public License + * version 3 along with OpenOffice.org. If not, see + * <http://www.openoffice.org/license.html> + * for a copy of the LGPLv3 License. + * + ************************************************************************/ +package mod._forms; + +import java.io.PrintWriter; + +import lib.StatusException; +import lib.TestCase; +import lib.TestEnvironment; +import lib.TestParameters; +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.XDevice; +import com.sun.star.awt.XGraphics; +import com.sun.star.awt.XTextComponent; +import com.sun.star.awt.XToolkit; +import com.sun.star.awt.XWindow; +import com.sun.star.awt.XWindowPeer; +import com.sun.star.drawing.XControlShape; +import com.sun.star.drawing.XShape; +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.XCloseable; +import com.sun.star.view.XControlAccess; + + +/** + * Test for object which is represented by default controller + * of the <code>com.sun.star.form.component.CurrencyField</code> + * component. <p> + * + * Object implements the following interfaces : + * <ul> + * <li> <code>com::sun::star::awt::XView</code></li> + * <li> <code>com::sun::star::form::XBoundControl</code></li> + * <li> <code>com::sun::star::awt::XControl</code></li> + * <li> <code>com::sun::star::awt::XTextComponent</code></li> + * <li> <code>com::sun::star::awt::XLayoutConstrains</code></li> + * <li> <code>com::sun::star::awt::XTextListener</code></li> + * <li> <code>com::sun::star::awt::XWindow</code></li> + * <li> <code>com::sun::star::awt::XCurrencyField</code></li> + * <li> <code>com::sun::star::lang::XComponent</code></li> + * <li> <code>com::sun::star::awt::XTextLayoutConstrains</code></li> + * <li> <code>com::sun::star::lang::XEventListener</code></li> + * </ul> <p> + * This object test <b> is NOT </b> designed to be run in several + * threads concurently. + * + * @see com.sun.star.awt.XView + * @see com.sun.star.form.XBoundControl + * @see com.sun.star.awt.XControl + * @see com.sun.star.awt.XTextComponent + * @see com.sun.star.awt.XLayoutConstrains + * @see com.sun.star.awt.XTextListener + * @see com.sun.star.awt.XWindow + * @see com.sun.star.awt.XCurrencyField + * @see com.sun.star.lang.XComponent + * @see com.sun.star.awt.XTextLayoutConstrains + * @see com.sun.star.lang.XEventListener + * @see ifc.awt._XView + * @see ifc.form._XBoundControl + * @see ifc.awt._XControl + * @see ifc.awt._XTextComponent + * @see ifc.awt._XLayoutConstrains + * @see ifc.awt._XTextListener + * @see ifc.awt._XWindow + * @see ifc.awt._XCurrencyField + * @see ifc.lang._XComponent + * @see ifc.awt._XTextLayoutConstrains + * @see ifc.lang._XEventListener + */ +public class OCurrencyControl extends TestCase { + XTextDocument xTextDoc; + + /** + * Creates a new text document. + */ + protected void initialize(TestParameters Param, PrintWriter log) { + SOfficeFactory SOF = SOfficeFactory.getFactory((XMultiServiceFactory) Param.getMSF()); + + try { + log.println("creating a textdocument"); + xTextDoc = SOF.createTextDoc(null); + } catch (com.sun.star.uno.Exception e) { + // Some exception occures.FAILED + e.printStackTrace(log); + throw new StatusException("Couldn't create document", e); + } + } + + /** + * Disposes the text document created before + */ + protected void cleanup(TestParameters tParam, PrintWriter log) { + log.println(" disposing xTextDoc "); + + try { + XCloseable closer = (XCloseable) 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"); + } + } + + /** + * Creates two components and inserts them to the form of + * text document. One component + * (<code>com.sun.star.form.component.CurrencyField</code>) is created + * for testing, another to be passed as relation. Using a controller + * of the text document the controller of the first component is + * obtained and returned in environment as a test object. <p> + * + * Object relations created : + * <ul> + * <li> <code>'GRAPHICS'</code> for + * {@link ifc.awt._XView} : a graphics component + * created using screen device of the window peer of + * the controller tested. </li> + * <li> <code>'CONTEXT'</code> for + * {@link ifc.awt._XControl} : the text document + * where the component is inserted. </li> + * <li> <code>'WINPEER'</code> for + * {@link ifc.awt._XControl} : Window peer of the + * controller tested. </li> + * <li> <code>'TOOLKIT'</code> for + * {@link ifc.awt._XControl} : toolkit of the component.</li> + * <li> <code>'MODEL'</code> for + * {@link ifc.awt._XControl} : the model of the controller.</li> + * <li> <code>'XWindow.AnotherWindow'</code> for + * {@link ifc.awt._XWindow} : the controller of another + * component. </li> + * <li> <code>'XTextComponent.onlyNumbers'</code> for + * {@link ifc.awt._XTextComponent} : as the currency field + * can have only numeric values the relation must be specified. </li> + * </ul> + */ + protected TestEnvironment createTestEnvironment(TestParameters Param, + PrintWriter log) { + XInterface oObj = null; + XWindowPeer the_win = null; + XToolkit the_kit = null; + XDevice aDevice = null; + XGraphics aGraphic = null; + XControl aControl = null; + + //Insert a ControlShape and get the ControlModel + XControlShape aShape = FormTools.createControlShape(xTextDoc, 3000, + 4500, 15000, 10000, + "CurrencyField"); + + WriterTools.getDrawPage(xTextDoc).add((XShape) aShape); + + XControlModel the_Model = aShape.getControl(); + + XControlShape aShape2 = FormTools.createControlShape(xTextDoc, 3000, + 4500, 5000, 10000, + "TextField"); + + WriterTools.getDrawPage(xTextDoc).add((XShape) aShape2); + + XControlModel the_Model2 = aShape2.getControl(); + + //Try to query XControlAccess + XControlAccess the_access = (XControlAccess) UnoRuntime.queryInterface( + XControlAccess.class, + xTextDoc.getCurrentController()); + + //now get the OCurrencyControl + try { + oObj = the_access.getControl(the_Model); + aControl = the_access.getControl(the_Model2); + the_win = the_access.getControl(the_Model).getPeer(); + the_kit = the_win.getToolkit(); + aDevice = the_kit.createScreenCompatibleDevice(200, 200); + aGraphic = aDevice.createGraphics(); + } catch (com.sun.star.container.NoSuchElementException e) { + log.println("Couldn't get OCurrencyControl"); + e.printStackTrace(log); + throw new StatusException("Couldn't get OCurrencyControl", e); + } + + log.println("creating a new environment for OCurrencyControl object"); + + TestEnvironment tEnv = new TestEnvironment(oObj); + + + //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 XTextComponent + tEnv.addObjRelation("XTextComponent.onlyNumbers", new Object()); + + // Adding relation for XWindow + XWindow forObjRel = (XWindow) UnoRuntime.queryInterface(XWindow.class, + aControl); + + tEnv.addObjRelation("XWindow.AnotherWindow", forObjRel); + tEnv.addObjRelation("XWindow.ControlShape", aShape); + + // Adding relation for XTextListener + ifc.awt._XTextListener.TestTextListener listener = + new ifc.awt._XTextListener.TestTextListener(); + XTextComponent textComp = (XTextComponent) UnoRuntime.queryInterface( + XTextComponent.class, oObj); + textComp.addTextListener(listener); + tEnv.addObjRelation("TestTextListener", listener); + + return tEnv; + } // finish method getTestEnvironment +} // finish class OCurrencyControl diff --git a/qadevOOo/tests/java/mod/_forms/OCurrencyModel.java b/qadevOOo/tests/java/mod/_forms/OCurrencyModel.java new file mode 100644 index 000000000000..319e1a90a502 --- /dev/null +++ b/qadevOOo/tests/java/mod/_forms/OCurrencyModel.java @@ -0,0 +1,159 @@ +/************************************************************************* + * + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * Copyright 2000, 2010 Oracle and/or its affiliates. + * + * OpenOffice.org - a multi-platform office productivity suite + * + * This file is part of OpenOffice.org. + * + * OpenOffice.org is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License version 3 + * only, as published by the Free Software Foundation. + * + * OpenOffice.org is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License version 3 for more details + * (a copy is included in the LICENSE file that accompanied this code). + * + * You should have received a copy of the GNU Lesser General Public License + * version 3 along with OpenOffice.org. If not, see + * <http://www.openoffice.org/license.html> + * for a copy of the LGPLv3 License. + * + ************************************************************************/ +package mod._forms; +import com.sun.star.beans.NamedValue; +import java.io.PrintWriter; + +import lib.TestEnvironment; +import lib.TestParameters; + + +/** +* Test for object which is represented by service +* <code>com.sun.star.form.component.CurrencyField</code>. <p> +* Object implements the following interfaces : +* <ul> +* <li> <code>com::sun::star::io::XPersistObject</code></li> +* <li> <code>com::sun::star::form::XReset</code></li> +* <li> <code>com::sun::star::form::XBoundComponent</code></li> +* <li> <code>com::sun::star::form::FormComponent</code></li> +* <li> <code>com::sun::star::beans::XFastPropertySet</code></li> +* <li> <code>com::sun::star::beans::XMultiPropertySet</code></li> +* <li> <code>com::sun::star::form::XUpdateBroadcaster</code></li> +* <li> <code>com::sun::star::form::DataAwareControlModel</code></li> +* <li> <code>com::sun::star::awt::UnoControlCurrencyFieldModel</code></li> +* <li> <code>com::sun::star::beans::XPropertyState</code></li> +* <li> <code>com::sun::star::form::FormControlModel</code></li> +* <li> <code>com::sun::star::container::XNamed</code></li> +* <li> <code>com::sun::star::lang::XComponent</code></li> +* <li> <code>com::sun::star::lang::XEventListener</code></li> +* <li> <code>com::sun::star::beans::XPropertyAccess</code></li> +* <li> <code>com::sun::star::beans::XPropertyContainer</code></li> +* <li> <code>com::sun::star::beans::XPropertySet</code></li> +* <li> <code>com::sun::star::form::XLoadListener</code></li> +* <li> <code>com::sun::star::container::XChild</code></li> +* <li> <code>com::sun::star::form::component::CurrencyField</code></li> +* </ul> +* This object test <b> is NOT </b> designed to be run in several +* threads concurently. +* @see com.sun.star.io.XPersistObject +* @see com.sun.star.form.XReset +* @see com.sun.star.form.XBoundComponent +* @see com.sun.star.form.FormComponent +* @see com.sun.star.beans.XFastPropertySet +* @see com.sun.star.beans.XMultiPropertySet +* @see com.sun.star.form.XUpdateBroadcaster +* @see com.sun.star.form.DataAwareControlModel +* @see com.sun.star.awt.UnoControlCurrencyFieldModel +* @see com.sun.star.beans.XPropertyState +* @see com.sun.star.form.FormControlModel +* @see com.sun.star.container.XNamed +* @see com.sun.star.lang.XComponent +* @see com.sun.star.lang.XEventListener +* @see com.sun.star.beans.XPropertyAccess +* @see com.sun.star.beans.XPropertyContainer +* @see com.sun.star.beans.XPropertySet +* @see com.sun.star.form.XLoadListener +* @see com.sun.star.container.XChild +* @see com.sun.star.form.component.CurrencyField +* @see ifc.io._XPersistObject +* @see ifc.form._XReset +* @see ifc.form._XBoundComponent +* @see ifc.form._FormComponent +* @see ifc.beans._XFastPropertySet +* @see ifc.beans._XMultiPropertySet +* @see ifc.form._XUpdateBroadcaster +* @see ifc.form._DataAwareControlModel +* @see ifc.awt._UnoControlCurrencyFieldModel +* @see ifc.beans._XPropertyState +* @see ifc.form._FormControlModel +* @see ifc.container._XNamed +* @see ifc.lang._XComponent +* @see ifc.lang._XEventListener +* @see ifc.beans._XPropertySet +* @see ifc.form._XLoadListener +* @see ifc.container._XChild +* @see ifc.form.component._CurrencyField +*/ +public class OCurrencyModel extends GenericModelTest { + + /** + * Set some member variable of the super class <CODE>GenericModelTest</CODE>: + * <pre> + * super.m_ChangePropertyName = "Value"; + * super.m_kindOfControl="CurrencyField"; + * super.m_ObjectName = "stardiv.one.form.component.CurrencyField"; + * NamedValue myProp = new NamedValue(); + * myProp.Name = "DataField"; + * myProp.Value = "Identifier"; + * super.m_propertiesToSet.add(myProp); + * super.m_LCShape_Type = "FixedText"; + * </pre> + * Then <CODE>super.initialize()</CODE> was called. + * @param tParam the test parameter + * @param log the log writer + */ + protected void initialize(TestParameters tParam, PrintWriter log) { + + super.initialize(tParam, log); + + super.m_ObjectName = "stardiv.one.form.component.CurrencyField"; + + super.m_kindOfControl="CurrencyField"; + + NamedValue myProp = new NamedValue(); + myProp.Name = "DataField"; + myProp.Value = "Identifier"; + super.m_propertiesToSet.add(myProp); + + super.m_ChangePropertyName = "Value"; + super.m_ChangePropertyValue = new Double(0); + + super.m_LCShape_Type = "FixedText"; + + } + /** + * calls <CODE>cleanup()</CODE> from it's super class + * @param tParam the test parameter + * @param log the log writer + */ + protected void cleanup(TestParameters tParam, PrintWriter log) { + super.cleanup(tParam, log); + } + + + /** + * calls <CODE>createTestEnvironment()</CODE> from it's super class + * @param Param the test parameter + * @param log the log writer + * @return lib.TestEnvironment + */ + protected synchronized TestEnvironment createTestEnvironment(TestParameters Param, + PrintWriter log) { + return super.createTestEnvironment(Param, log); + } +} // finish class OCurrencyModel diff --git a/qadevOOo/tests/java/mod/_forms/ODatabaseForm.java b/qadevOOo/tests/java/mod/_forms/ODatabaseForm.java new file mode 100644 index 000000000000..4b360e20fd10 --- /dev/null +++ b/qadevOOo/tests/java/mod/_forms/ODatabaseForm.java @@ -0,0 +1,901 @@ +/************************************************************************* + * + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * Copyright 2000, 2010 Oracle and/or its affiliates. + * + * OpenOffice.org - a multi-platform office productivity suite + * + * This file is part of OpenOffice.org. + * + * OpenOffice.org is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License version 3 + * only, as published by the Free Software Foundation. + * + * OpenOffice.org is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License version 3 for more details + * (a copy is included in the LICENSE file that accompanied this code). + * + * You should have received a copy of the GNU Lesser General Public License + * version 3 along with OpenOffice.org. If not, see + * <http://www.openoffice.org/license.html> + * for a copy of the LGPLv3 License. + * + ************************************************************************/ +package mod._forms; + +import java.io.PrintWriter; +import java.util.Vector; + +import lib.Status; +import lib.StatusException; +import lib.TestCase; +import lib.TestEnvironment; +import lib.TestParameters; +import util.DBTools; +import util.DrawTools; +import util.FormTools; +import util.WriterTools; +import util.utils; + +import com.sun.star.awt.XControl; +import com.sun.star.awt.XControlModel; +import com.sun.star.beans.PropertyValue; +import com.sun.star.beans.XPropertySet; +import com.sun.star.container.XIndexAccess; +import com.sun.star.container.XNameContainer; +import com.sun.star.container.XNamed; +import com.sun.star.drawing.XControlShape; +import com.sun.star.drawing.XShape; +import com.sun.star.drawing.XShapes; +import com.sun.star.form.DatabaseParameterEvent; +import com.sun.star.form.XForm; +import com.sun.star.form.XLoadable; +import com.sun.star.lang.EventObject; +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.sdbc.SQLException; +import com.sun.star.sdbc.XConnection; +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.XInteractionRequest; +import com.sun.star.text.XTextDocument; +import com.sun.star.uno.Any; +import com.sun.star.uno.AnyConverter; +import com.sun.star.uno.Type; +import com.sun.star.uno.UnoRuntime; +import com.sun.star.uno.XInterface; +import com.sun.star.util.Date; +import com.sun.star.util.DateTime; +import com.sun.star.util.Time; +import com.sun.star.util.XCloseable; +import com.sun.star.view.XControlAccess; +import ifc.form._XDatabaseParameterBroadcaster; +import ifc.sdb._XCompletedExecution; + + +/** + * Test for object which is represented by service + * <code>com.sun.star.form.component.DatabaseForm</code>. <p> + * + * Object implements the following interfaces : + * <ul> + * <li> <code>com::sun::star::script::XEventAttacherManager</code></li> + * <li> <code>com::sun::star::container::XElementAccess</code></li> + * <li> <code>com::sun::star::sdbcx::ResultSet</code></li> + * <li> <code>com::sun::star::container::XChild</code></li> + * <li> <code>com::sun::star::sdbc::XResultSetUpdate</code></li> + * <li> <code>com::sun::star::sdb::XResultSetAccess</code></li> + * <li> <code>com::sun::star::form::FormComponent</code></li> + * <li> <code>com::sun::star::form::component::DataForm</code></li> + * <li> <code>com::sun::star::sdbc::XResultSetMetaDataSupplier</code></li> + * <li> <code>com::sun::star::container::XEnumerationAccess</code></li> + * <li> <code>com::sun::star::sdbcx::XDeleteRows</code></li> + * <li> <code>com::sun::star::sdb::RowSet</code></li> + * <li> <code>com::sun::star::lang::XComponent</code></li> + * <li> <code>com::sun::star::sdbc::XRowSet</code></li> + * <li> <code>com::sun::star::sdbc::XRowUpdate</code></li> + * <li> <code>com::sun::star::form::XLoadable</code></li> + * <li> <code>com::sun::star::container::XNamed</code></li> + * <li> <code>com::sun::star::container::XIndexReplace</code></li> + * <li> <code>com::sun::star::io::XPersistObject</code></li> + * <li> <code>com::sun::star::container::XNameReplace</code></li> + * <li> <code>com::sun::star::container::XIndexContainer</code></li> + * <li> <code>com::sun::star::container::XNameAccess</code></li> + * <li> <code>com::sun::star::sdbc::XParameters</code></li> + * <li> <code>com::sun::star::util::XCancellable</code></li> + * <li> <code>com::sun::star::form::XReset</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::XRowSetApproveBroadcaster</code></li> + * <li> <code>com::sun::star::sdbc::ResultSet</code></li> + * <li> <code>com::sun::star::sdbc::XResultSet</code></li> + * <li> <code>com::sun::star::sdbc::XRow</code></li> + * <li> <code>com::sun::star::sdbc::XColumnLocate</code></li> + * <li> <code>com::sun::star::awt::XTabControllerModel</code></li> + * <li> <code>com::sun::star::container::XIndexAccess</code></li> + * <li> <code>com::sun::star::form::XSubmit</code></li> + * <li> <code>com::sun::star::form::component::HTMLForm</code></li> + * <li> <code>com::sun::star::sdbcx::XRowLocate</code></li> + * <li> <code>com::sun::star::sdbc::XWarningsSupplier</code></li> + * <li> <code>com::sun::star::container::XNameContainer</code></li> + * <li> <code>com::sun::star::beans::XPropertyAccess</code></li> + * <li> <code>com::sun::star::beans::XPropertyContainer</code></li> + * <li> <code>com::sun::star::beans::XPropertySet</code></li> + * <li> <code>com::sun::star::sdbc::RowSet</code></li> + * </ul> <p> + * + * This object test <b> is NOT </b> designed to be run in several + * threads concurently. + * 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.script.XEventAttacherManager + * @see com.sun.star.container.XElementAccess + * @see com.sun.star.sdbcx.ResultSet + * @see com.sun.star.container.XChild + * @see com.sun.star.sdbc.XResultSetUpdate + * @see com.sun.star.sdb.XResultSetAccess + * @see com.sun.star.form.FormComponent + * @see com.sun.star.form.component.DataForm + * @see com.sun.star.sdbc.XResultSetMetaDataSupplier + * @see com.sun.star.container.XEnumerationAccess + * @see com.sun.star.sdbcx.XDeleteRows + * @see com.sun.star.sdb.RowSet + * @see com.sun.star.lang.XComponent + * @see com.sun.star.sdbc.XRowSet + * @see com.sun.star.sdbc.XRowUpdate + * @see com.sun.star.form.XLoadable + * @see com.sun.star.container.XNamed + * @see com.sun.star.container.XIndexReplace + * @see com.sun.star.io.XPersistObject + * @see com.sun.star.container.XNameReplace + * @see com.sun.star.container.XIndexContainer + * @see com.sun.star.container.XNameAccess + * @see com.sun.star.sdbc.XParameters + * @see com.sun.star.util.XCancellable + * @see com.sun.star.form.XReset + * @see com.sun.star.sdbc.XCloseable + * @see com.sun.star.sdbcx.XColumnsSupplier + * @see com.sun.star.sdb.XRowSetApproveBroadcaster + * @see com.sun.star.sdbc.ResultSet + * @see com.sun.star.sdbc.XResultSet + * @see com.sun.star.sdbc.XRow + * @see com.sun.star.sdbc.XColumnLocate + * @see com.sun.star.awt.XTabControllerModel + * @see com.sun.star.container.XIndexAccess + * @see com.sun.star.form.XSubmit + * @see com.sun.star.form.component.HTMLForm + * @see com.sun.star.sdbcx.XRowLocate + * @see com.sun.star.sdbc.XWarningsSupplier + * @see com.sun.star.container.XNameContainer + * @see com.sun.star.beans.XPropertySet + * @see com.sun.star.sdbc.RowSet + * @see ifc.script._XEventAttacherManager + * @see ifc.container._XElementAccess + * @see ifc.sdbcx._ResultSet + * @see ifc.container._XChild + * @see ifc.sdbc._XResultSetUpdate + * @see ifc.sdb._XResultSetAccess + * @see ifc.form._FormComponent + * @see ifc.form.component._DataForm + * @see ifc.sdbc._XResultSetMetaDataSupplier + * @see ifc.container._XEnumerationAccess + * @see ifc.sdbcx._XDeleteRows + * @see ifc.sdb._RowSet + * @see ifc.lang._XComponent + * @see ifc.sdbc._XRowSet + * @see ifc.sdbc._XRowUpdate + * @see ifc.form._XLoadable + * @see ifc.container._XNamed + * @see ifc.container._XIndexReplace + * @see ifc.io._XPersistObject + * @see ifc.container._XNameReplace + * @see ifc.container._XIndexContainer + * @see ifc.container._XNameAccess + * @see ifc.sdbc._XParameters + * @see ifc.util._XCancellable + * @see ifc.form._XReset + * @see ifc.sdbc._XCloseable + * @see ifc.sdbcx._XColumnsSupplier + * @see ifc.sdb._XRowSetApproveBroadcaster + * @see ifc.sdbc._ResultSet + * @see ifc.sdbc._XResultSet + * @see ifc.sdbc._XRow + * @see ifc.sdbc._XColumnLocate + * @see ifc.awt._XTabControllerModel + * @see ifc.container._XIndexAccess + * @see ifc.form._XSubmit + * @see ifc.form.component._HTMLForm + * @see ifc.sdbcx._XRowLocate + * @see ifc.sdbc._XWarningsSupplier + * @see ifc.container._XNameContainer + * @see ifc.beans._XPropertyAccess + * @see ifc.beans._XPropertyContainer + * @see ifc.beans._XPropertySet + * @see ifc.sdbc._RowSet + */ +public class ODatabaseForm extends TestCase { + protected final static String dbSourceName = "ODatabaseFormDataSource"; + private static int uniqueSuffix = 0; + private static String origDB = null; + private static String tmpDir = null; + protected XTextDocument xTextDoc = null; + private DBTools dbTools = null; + String tableName = null; + DBTools.DataSourceInfo srcInf = null; + boolean isMySQLDB = false; + protected XConnection conn = null; + private Object dbSrc = null; + + protected void initialize(TestParameters tParam, PrintWriter log) { + //log.println( "creating a draw document" ); + //xTextDoc = WriterTools.createTextDoc(t((XMultiServiceFactory) Param.getMSF)); + tmpDir = utils.getOfficeTemp(((XMultiServiceFactory) tParam.getMSF())); + + origDB = util.utils.getFullTestDocName("TestDB/testDB.dbf"); + + dbTools = new DBTools( (XMultiServiceFactory)tParam.getMSF(), log ); + + // creating DataSource and registering it in DatabaseContext + String dbURL = (String) tParam.get("test.db.url"); + String dbUser = (String) tParam.get("test.db.user"); + String dbPassword = (String) tParam.get("test.db.password"); + + log.println("Creating and registering DataSource ..."); + srcInf = dbTools.newDataSourceInfo(); + + 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 + try { + tableName = "soffice_test_table"; + srcInf.URL = "jdbc:" + dbURL; + srcInf.IsPasswordRequired = new 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"; + propInfo[0].Value = "util.dddriver.Driver"; + srcInf.Info = propInfo; + + dbSrc = srcInf.getDataSourceService(); + dbTools.reRegisterDB(dbSourceName, dbSrc); + } catch (com.sun.star.uno.Exception e) { + log.println("Error while object test initialization :"); + e.printStackTrace(log); + throw new StatusException("Error while object test" + + " initialization", e); + } + } else { + //DataSource for sdbc db + try { + String myDbUrl = "sdbc:dbase:" + DBTools.dirToUrl(tmpDir); + srcInf.URL = myDbUrl; + + log.println("try to register '"+myDbUrl+"' as '"+dbSourceName+"'"); + + dbSrc = srcInf.getDataSourceService(); + dbTools.reRegisterDB(dbSourceName, dbSrc); + } catch (com.sun.star.uno.Exception e) { + log.println("Error while object test initialization :"); + e.printStackTrace(log); + throw new StatusException( + "Error while object test initialization", e); + } + + String oldF = null; + String newF = null; + + do { + tableName = "ODatabaseForm_tmp" + uniqueSuffix; + oldF = utils.getFullURL(origDB); + newF = utils.getOfficeTemp((XMultiServiceFactory) tParam.getMSF()) + tableName + + ".dbf"; + } while (!utils.tryOverwriteFile(((XMultiServiceFactory) tParam.getMSF()), oldF, newF) && + (uniqueSuffix++ < 50)); + } + } + + /** + * * creating a Testenvironment for the interfaces to be tested + */ + protected synchronized TestEnvironment createTestEnvironment(TestParameters Param, + PrintWriter log) { + if (xTextDoc != null) { + try { + XCloseable closer = (XCloseable) 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"); + } + + log.println("Existing document disposed"); + } + + log.println("creating a text document"); + xTextDoc = WriterTools.createTextDoc(((XMultiServiceFactory) Param.getMSF())); + + //initialize test table + if (isMySQLDB) { + try { + dbTools.initTestTableUsingJDBC(tableName, srcInf); + } catch (java.sql.SQLException e) { + e.printStackTrace(log); + throw new StatusException(Status.failed("Couldn't " + " init test table. SQLException...")); + } catch (java.lang.ClassNotFoundException e) { + throw new StatusException(Status.failed("Couldn't " + "register mysql driver")); + } + } + + XInterface oObj = null; + XShapes oShapes = null; + XInterface oInstance = null; + XConnection connection = null; + + + // creation of testobject here + // first we write what we are intend to do to log file + log.println("creating a test environment"); + + XNameContainer forms = FormTools.getForms(WriterTools.getDrawPage( + xTextDoc)); + + try { + String[] formNames = forms.getElementNames(); + + for (int i = 0; i < formNames.length; i++) { + log.println("Removing form '" + formNames[i] + "' ..."); + forms.removeByName(formNames[i]); + } + } catch (com.sun.star.lang.WrappedTargetException e) { + e.printStackTrace(log); + } catch (com.sun.star.container.NoSuchElementException e) { + e.printStackTrace(log); + } + + String[] formNames = forms.getElementNames(); + FormTools.insertForm(xTextDoc, forms, "MyForm"); + formNames = forms.getElementNames(); + + XLoadable formLoader = null; + + try { + formLoader = FormTools.bindForm(xTextDoc, "MyForm", dbSourceName, + tableName); + } catch (com.sun.star.uno.Exception e) { + log.println("Cann't bind the form to source '" + dbSourceName + + "', table '" + tableName + "' :"); + e.printStackTrace(log); + throw new StatusException("Cann't bind a form", e); + } + + + // DEBUG + log.println("Forms before adding controls : "); + formNames = forms.getElementNames(); + + for (int i = 0; i < formNames.length; i++) { + log.println(" '" + formNames[i] + "'"); + } + + XControlShape shape1 = null; + XControlShape shape2 = null; + + try { + + log.println("Elements in the 'MyForm' :"); + + XIndexAccess formElements1 = (XIndexAccess) UnoRuntime.queryInterface( + XIndexAccess.class, + forms.getByName("MyForm")); + + for (int i = 0; i < formElements1.getCount(); i++) { + XNamed elemName = (XNamed) UnoRuntime.queryInterface( + XNamed.class, + formElements1.getByIndex(i)); + log.println(" '" + elemName.getName() + "'"); + } + + + // END DEBUG + //put something on the drawpage + log.println("inserting some ControlShapes"); + oShapes = DrawTools.getShapes(WriterTools.getDrawPage(xTextDoc)); + shape1 = FormTools.createControlShape(xTextDoc, 3000, 4500, 15000, + 1000, "CommandButton"); + shape2 = FormTools.createControlShape(xTextDoc, 5000, 3500, 7500, + 5000, "TextField"); + + XControlShape shape3 = FormTools.createControlShape(xTextDoc, 2000, + 1500, 1000, + 1000, + "CheckBox"); + oShapes.add((XShape) shape1); + oShapes.add((XShape) shape2); + oShapes.add(shape3); + } catch (Exception e) { + e.printStackTrace(log); + } + + log.println("Forms after adding controls : "); + formNames = forms.getElementNames(); + + for (int i = 0; i < formNames.length; i++) { + log.println(" '" + formNames[i] + "'"); + } + + try { + log.println("Elements in the 'MyForm' :"); + + XIndexAccess formElements1 = (XIndexAccess) UnoRuntime.queryInterface( + XIndexAccess.class, + forms.getByName("MyForm")); + + for (int i = 0; i < formElements1.getCount(); i++) { + XNamed elemName = (XNamed) UnoRuntime.queryInterface( + XNamed.class, + formElements1.getByIndex(i)); + log.println(" '" + elemName.getName() + "'"); + } + } catch (Exception e) { + e.printStackTrace(log); + } + + formLoader.load(); + + try { + oObj = (XForm) AnyConverter.toObject(new Type(XForm.class), + (FormTools.getForms( + WriterTools.getDrawPage( + xTextDoc))) + .getByName("MyForm")); + + XPropertySet xSetProp = (XPropertySet) UnoRuntime.queryInterface( + XPropertySet.class, oObj); + connection = (XConnection) AnyConverter.toObject( + new Type(XConnection.class), + xSetProp.getPropertyValue("ActiveConnection")); + } catch (com.sun.star.uno.Exception e) { + log.println("Couldn't get Form"); + e.printStackTrace(log); + } + + + // get a control + oInstance = FormTools.createControl(xTextDoc, "TextField"); + + log.println("creating a new environment for drawpage object"); + + TestEnvironment tEnv = new TestEnvironment(oObj); + + + // adding relation for closing connection while environment disposing. + this.conn = connection; + + // adding relation for XSubmit + XControlModel the_Model = shape2.getControl(); + XControlAccess the_access = (XControlAccess) UnoRuntime.queryInterface( + XControlAccess.class, + xTextDoc.getCurrentController()); + XControl cntrl = null; + + //now get the OEditControl + try { + cntrl = the_access.getControl(the_Model); + log.println(cntrl.getClass().getName()); + } catch (com.sun.star.container.NoSuchElementException e) { + log.println("Couldn't get OEditControl"); + e.printStackTrace(log); + throw new StatusException("Couldn't get OEditControl", e); + } + + XResultSet the_set = (XResultSet) UnoRuntime.queryInterface( + XResultSet.class, oObj); + + try { + the_set.first(); + } catch (SQLException e) { + log.println("Cann't move cursor to the first row."); + e.printStackTrace(); + throw new StatusException("Can't move cursor to the first row.", e); + } + + tEnv.addObjRelation("Model1", shape1.getControl()); + tEnv.addObjRelation("Model2", shape2.getControl()); + + + // adding an object for XNameReplace testing + log.println("adding oInstace as obj relation to environment"); + tEnv.addObjRelation("INSTANCE", oInstance); + + + // INDEX : _XNameContainer + log.println("adding INDEX as obj relation to environment"); + tEnv.addObjRelation("INDEX", "0"); + + + // INDEX : _XNameReplace + log.println("adding NameReplaceIndex as obj relation to environment"); + tEnv.addObjRelation("XNameReplaceINDEX", "2"); + + + // INSTANCEn : _XNameContainer; _XNameReplace + log.println("adding INSTANCEn as obj relation to environment"); + + //XComponent xComp = (XComponent) + // UnoRuntime.queryInterface(XComponent.class, xDrawDoc); + String tc = (String) Param.get("THRCNT"); + int THRCNT = 1; + + if (tc != null) { + THRCNT = Integer.parseInt(tc); + } + + for (int n = 1; n < (2 * (THRCNT + 1)); n++) { + log.println("adding INSTANCE" + n + + " as obj relation to environment"); + tEnv.addObjRelation("INSTANCE" + n, + FormTools.createControl(xTextDoc, "CheckBox")); + } + + + // adding relation for XNameContainer + tEnv.addObjRelation("XNameContainer.AllowDuplicateNames", new Object()); + + + // adding relation for XPersistObject + tEnv.addObjRelation("OBJNAME", "stardiv.one.form.component.Form"); + + if (the_set != null) { + log.println("The Form has a not empty ResultSet"); + } + + // Adding obj relation for XRowSetApproveBroadcaster test + final XResultSet xResSet = (XResultSet) UnoRuntime.queryInterface( + XResultSet.class, oObj); + final XResultSetUpdate xResSetUpdate = (XResultSetUpdate) UnoRuntime.queryInterface( + XResultSetUpdate.class, + oObj); + final XRowSet xRowSet = (XRowSet) UnoRuntime.queryInterface( + XRowSet.class, oObj); + final PrintWriter logF = log; + tEnv.addObjRelation("XRowSetApproveBroadcaster.ApproveChecker", + new ifc.sdb._XRowSetApproveBroadcaster.RowSetApproveChecker() { + public void moveCursor() { + try { + xResSet.beforeFirst(); + xResSet.afterLast(); + } catch (com.sun.star.sdbc.SQLException e) { + logF.println("### _XRowSetApproveBroadcaster." + "RowSetApproveChecker.moveCursor() :"); + e.printStackTrace(logF); + } + } + + public RowChangeEvent changeRow() { + try { + xResSet.first(); + + XRowUpdate row = (XRowUpdate) UnoRuntime.queryInterface( + XRowUpdate.class, xResSet); + row.updateString(1, "1"); + xResSetUpdate.updateRow(); + } catch (com.sun.star.sdbc.SQLException e) { + logF.println("### _XRowSetApproveBroadcaster." + "RowSetApproveChecker.changeRow() :"); + e.printStackTrace(logF); + } + + RowChangeEvent ev = new RowChangeEvent(); + ev.Action = com.sun.star.sdb.RowChangeAction.UPDATE; + ev.Rows = 1; + + return ev; + } + + public void changeRowSet() { + try { + xRowSet.execute(); + } catch (com.sun.star.sdbc.SQLException e) { + logF.println("### _XRowSetApproveBroadcaster." + "RowSetApproveChecker.changeRowSet() :"); + e.printStackTrace(logF); + } + } + }); + + + // Adding relation for XColumnLocate test + tEnv.addObjRelation("XColumnLocate.ColumnName", DBTools.TST_STRING_F); + + // Adding relation for XParameters ifc test + Vector params = new Vector(); + + + /***** statement parameter types and their initial + values must be added here as relation. */ + params.add(new String("SAU99")) ; + params.add(new Boolean(false)) ; + params.add(new Byte((byte) 123)) ; + params.add(new Short((short) 234)) ; + params.add(new Integer(12345)) ; + params.add(new Long(23456)) ; + params.add(new Float(1.234)) ; + params.add(new Double(2.345)) ; + params.add(new byte[] {1, 2, 3}) ; + Date d = new Date(); + d.Day = 26; d.Month = 1; d.Year = 2001; + params.add(d) ; + Time t = new Time(); + t.Hours = 1; t.HundredthSeconds = 12; t.Minutes = 25; t.Seconds = 14; + params.add(t) ; + DateTime dt = new DateTime(); + dt.Day = 26; dt.Month = 1; dt.Year = 2001; dt.Hours = 1; + dt.HundredthSeconds = 12; dt.Minutes = 25; dt.Seconds = 14; + params.add(dt) ; + tEnv.addObjRelation("XParameters.ParamValues", params); + + // Adding relation for XCompletedExecution + tEnv.addObjRelation("InteractionHandlerChecker", new InteractionHandlerImpl()); + + // Adding for XWarningSupplier + tEnv.addObjRelation("CheckWarningsSupplier", new Boolean(isMySQLDB)); + + // Adding relation for XDatabaseParameterBroadcaster + tEnv.addObjRelation("ParameterListenerChecker", new ODatabaseForm.ParameterListenerImpl()); + XPropertySet xSetProp = (XPropertySet) UnoRuntime.queryInterface + (XPropertySet.class, oObj) ; + try { + xSetProp.setPropertyValue("DataSourceName", dbSourceName) ; + if(isMySQLDB) { + xSetProp.setPropertyValue("Command", "SELECT Column0 FROM soffice_test_table WHERE ( ( Column0 = :param1 ) )"); + } + else { + xSetProp.setPropertyValue("Command", "SELECT \"_TEXT\" FROM \"ODatabaseForm_tmp0\" WHERE ( ( \"_TEXT\" = :param1 ) )"); + } + + xSetProp.setPropertyValue("CommandType", + new Integer(CommandType.COMMAND)) ; + } + catch(Exception e) { + } + + // Adding relation for XResultSetUpdate + final XRowUpdate xRowUpdate = (XRowUpdate) UnoRuntime.queryInterface( + XRowUpdate.class, oObj); + final XRow xRow = (XRow) UnoRuntime.queryInterface(XRow.class, oObj); + + tEnv.addObjRelation("XResultSetUpdate.UpdateTester", + new ifc.sdbc._XResultSetUpdate.UpdateTester() { + String lastUpdate = null; + + public int rowCount() throws SQLException { + int prevPos = xResSet.getRow(); + xResSet.last(); + + int count = xResSet.getRow(); + xResSet.absolute(prevPos); + + return count; + } + + public void update() throws SQLException { + lastUpdate = xRow.getString(1); + lastUpdate += "_"; + xRowUpdate.updateString(1, lastUpdate); + } + + public boolean wasUpdated() throws SQLException { + String getStr = xRow.getString(1); + + return lastUpdate.equals(getStr); + } + + public int currentRow() throws SQLException { + return xResSet.getRow(); + } + }); + + // Adding relations for XRow as a Vector with all data + // of current row of RowSet. + + Vector rowData = new Vector(); + + for (int i = 0; i < DBTools.TST_TABLE_VALUES[0].length; i++) { + rowData.add(DBTools.TST_TABLE_VALUES[0][i]); + } + + tEnv.addObjRelation("CurrentRowData", rowData); + + // Adding relation for XRowUpdate + XRow row = (XRow) UnoRuntime.queryInterface(XRow.class, oObj); + tEnv.addObjRelation("XRowUpdate.XRow", row); + + + tEnv.addObjRelation("XPropertyContainer.propertyNotRemovable", "Cycle"); + + PropertyValue propVal = new PropertyValue(); + propVal.Name = "Name"; + propVal.Value = "Text since XPropertyAccess"; + + tEnv.addObjRelation("XPropertyAccess.propertyToChange", propVal); + + return tEnv; + } // finish method getTestEnvironment + + /** + * Closes connection of <code>RowSet</code> instance created. + */ + protected void cleanup(TestParameters Param, PrintWriter log) { + log.println("closing connection..."); + try { + conn.close(); + } 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."); + } + + + log.println("closing data source..."); + try { + XCloseable closer = (XCloseable) UnoRuntime.queryInterface( + XCloseable.class, dbSrc); + closer.close(true); + } catch (com.sun.star.util.CloseVetoException e) { + log.println("couldn't close data source"); + } catch (com.sun.star.lang.DisposedException e) { + log.println("couldn't close data source"); + } + + + log.println("closing document..."); + + try { + XCloseable closer = (XCloseable) 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"); + } + + log.println("revoking data source..."); + try { + dbTools.revokeDB(dbSourceName); + } catch (com.sun.star.container.NoSuchElementException e){ + } catch (com.sun.star.uno.Exception e) { + log.println("Error while object test cleaning up :"); + e.printStackTrace(log); + throw new StatusException("Error while object test cleaning up", e); + } + } + + /** + * Implementation of interface _XDatabaseParameterBroadcaster.CheckParameterListener + * for the XDatabaseParameterBroadcaster test + * @see ifc.form._XDatabaseParameterBroadcaster + */ + public class ParameterListenerImpl implements _XDatabaseParameterBroadcaster.CheckParameterListener { + boolean listenerWasCalled = false; + PrintWriter log = new PrintWriter(System.out); + + /** + * Return true, if the listener was called, false otherwise. + * @return True, if any other method of the listener was called. + */ + public boolean checkListener() { + return listenerWasCalled; + } + + /** + * Take the DataBaseParameterEvent and fill it with a meaningful value. + * @param e The database parameter that will be filled with a value. + * @return True, if the value could be filled. + */ + public boolean approveParameter(DatabaseParameterEvent e) { + log.println("### ParameterListenerImpl: approve called."); + XIndexAccess params = e.Parameters; + int count = params.getCount(); + try { + for(int i=0; i<count; i++) { + log.println("### _XDatabaseParameterBroadcaster.ParameterListenerImpl: Parameter "+i+": "+params.getByIndex(i)); + XPropertySet xProp = (XPropertySet)UnoRuntime.queryInterface(XPropertySet.class, params.getByIndex(i)); + log.println("### _XDatabaseParameterBroadcaster.ParameterListenerImpl: Parameter Name: '"+xProp.getPropertyValue("Name") + "' is set to Value '1'"); + xProp.setPropertyValue("Value", new Integer(1)); + listenerWasCalled = true; + } + } + catch(Exception eI) { + log.println("### _XDatabaseParameterBroadcaster.ParameterListenerImpl: Exception!"); + eI.printStackTrace(log); + return false; + } + return true; + } + + /** + * Dummy implemetnation. Do nothing, just log + * @param o Ignore. + */ + public void disposing(EventObject o) { + log.println("### _XDatabaseParameterBroadcaster.ParameterListenerImpl: disposing"); + } + + /** + * Set a log writer, so messages go to log instead of Standard.out + * @param log The log messages get printed to. + */ + public void setLog(PrintWriter log) { + this.log = log; + } + + } + + + /** + * Implementation of interface _XCompletedExecution.CheckInteractionHandler + * for the XCompletedExecution test + * @see ifc.sdb._XCompletedExecution + */ + public class InteractionHandlerImpl implements _XCompletedExecution.CheckInteractionHandler { + private boolean handlerWasUsed = false; + private PrintWriter log = new PrintWriter(System.out); + + public boolean checkInteractionHandler() { + return handlerWasUsed; + } + + public void handle(XInteractionRequest xInteractionRequest) { + log.println("### _XCompletedExecution.InteractionHandlerImpl: handle called."); + handlerWasUsed = true; + + Object o = xInteractionRequest.getRequest(); + ParametersRequest req = (ParametersRequest)o; + XIndexAccess params = req.Parameters; + int count = params.getCount(); + try { + for(int i=0; i<count; i++) { + Object aObject = params.getByIndex(i); + Any any = (Any)aObject; + log.println("### _XCompletedExecution.InteractionHandlerImpl: Parameter "+i+": "+params.getByIndex(i)); + XPropertySet xProp = (XPropertySet)UnoRuntime.queryInterface(XPropertySet.class, params.getByIndex(i)); + log.println("### _XCompletedExecution.InteractionHandlerImpl: Parameter Name: '"+xProp.getPropertyValue("Name") + "' is set to Value '1'"); + xProp.setPropertyValue("Value", new Integer(1)); + handlerWasUsed = true; + } + } + catch(Exception eI) { + log.println("### _XCompletedExecution.InteractionHandlerImpl: Exception!"); + eI.printStackTrace(log); + } + } + + public void setLog(PrintWriter log) { + this.log = log; + } + + } +} // finish class ODatabaseForm diff --git a/qadevOOo/tests/java/mod/_forms/ODateControl.java b/qadevOOo/tests/java/mod/_forms/ODateControl.java new file mode 100644 index 000000000000..e143929fa19d --- /dev/null +++ b/qadevOOo/tests/java/mod/_forms/ODateControl.java @@ -0,0 +1,243 @@ +/************************************************************************* + * + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * Copyright 2000, 2010 Oracle and/or its affiliates. + * + * OpenOffice.org - a multi-platform office productivity suite + * + * This file is part of OpenOffice.org. + * + * OpenOffice.org is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License version 3 + * only, as published by the Free Software Foundation. + * + * OpenOffice.org is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License version 3 for more details + * (a copy is included in the LICENSE file that accompanied this code). + * + * You should have received a copy of the GNU Lesser General Public License + * version 3 along with OpenOffice.org. If not, see + * <http://www.openoffice.org/license.html> + * for a copy of the LGPLv3 License. + * + ************************************************************************/ +package mod._forms; + +import java.io.PrintWriter; + +import lib.StatusException; +import lib.TestCase; +import lib.TestEnvironment; +import lib.TestParameters; +import util.FormTools; +import util.SOfficeFactory; +import util.WriterTools; + +import com.sun.star.awt.XControlModel; +import com.sun.star.awt.XDevice; +import com.sun.star.awt.XGraphics; +import com.sun.star.awt.XTextComponent; +import com.sun.star.awt.XToolkit; +import com.sun.star.awt.XWindow; +import com.sun.star.awt.XWindowPeer; +import com.sun.star.drawing.XControlShape; +import com.sun.star.drawing.XShape; +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.XCloseable; +import com.sun.star.view.XControlAccess; + + +/** + * Test for object which is represented by default controller + * of the <code>com.sun.star.form.component.DateField</code> + * component. <p> + * + * Object implements the following interfaces : + * <ul> + * <li> <code>com::sun::star::awt::XView</code></li> + * <li> <code>com::sun::star::form::XBoundControl</code></li> + * <li> <code>com::sun::star::awt::XControl</code></li> + * <li> <code>com::sun::star::awt::XTextComponent</code></li> + * <li> <code>com::sun::star::awt::XLayoutConstrains</code></li> + * <li> <code>com::sun::star::awt::XDateField</code></li> + * <li> <code>com::sun::star::awt::XTextListener</code></li> + * <li> <code>com::sun::star::awt::XWindow</code></li> + * <li> <code>com::sun::star::lang::XComponent</code></li> + * <li> <code>com::sun::star::awt::XTextLayoutConstrains</code></li> + * <li> <code>com::sun::star::lang::XEventListener</code></li> + * </ul> <p> + * This object test <b> is NOT </b> designed to be run in several + * threads concurently. + * + * @see com.sun.star.awt.XView + * @see com.sun.star.form.XBoundControl + * @see com.sun.star.awt.XControl + * @see com.sun.star.awt.XTextComponent + * @see com.sun.star.awt.XLayoutConstrains + * @see com.sun.star.awt.XDateField + * @see com.sun.star.awt.XTextListener + * @see com.sun.star.awt.XWindow + * @see com.sun.star.lang.XComponent + * @see com.sun.star.awt.XTextLayoutConstrains + * @see com.sun.star.lang.XEventListener + * @see ifc.awt._XView + * @see ifc.form._XBoundControl + * @see ifc.awt._XControl + * @see ifc.awt._XTextComponent + * @see ifc.awt._XLayoutConstrains + * @see ifc.awt._XDateField + * @see ifc.awt._XTextListener + * @see ifc.awt._XWindow + * @see ifc.lang._XComponent + * @see ifc.awt._XTextLayoutConstrains + * @see ifc.lang._XEventListener + */ +public class ODateControl extends TestCase { + XTextDocument xTextDoc; + + /** + * Creates a new text document. + */ + protected void initialize(TestParameters Param, PrintWriter log) { + SOfficeFactory SOF = SOfficeFactory.getFactory(((XMultiServiceFactory) Param.getMSF())); + + try { + log.println("creating a textdocument"); + xTextDoc = SOF.createTextDoc(null); + } catch (com.sun.star.uno.Exception e) { + // Some exception occures.FAILED + e.printStackTrace(log); + throw new StatusException("Couldn't create document", e); + } + } + + /** + * Disposes the text document created before + */ + protected void cleanup(TestParameters tParam, PrintWriter log) { + log.println(" disposing xTextDoc "); + + try { + XCloseable closer = (XCloseable) 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"); + } + } + + /** + * Creates two components and inserts them to the form of + * text document. One component + * (<code>com.sun.star.form.component.DateField</code>) is created + * for testing, another to be passed as relation. Using a controller + * of the text document the controller of the first component is + * obtained and returned in environment as a test object. <p> + * + * Object relations created : + * <ul> + * <li> <code>'GRAPHICS'</code> for + * {@link ifc.awt._XView} : a graphics component + * created using screen device of the window peer of + * the controller tested. </li> + * <li> <code>'CONTEXT'</code> for + * {@link ifc.awt._XControl} : the text document + * where the component is inserted. </li> + * <li> <code>'WINPEER'</code> for + * {@link ifc.awt._XControl} : Window peer of the + * controller tested. </li> + * <li> <code>'TOOLKIT'</code> for + * {@link ifc.awt._XControl} : toolkit of the component.</li> + * <li> <code>'MODEL'</code> for + * {@link ifc.awt._XControl} : the model of the controller.</li> + * <li> <code>'XWindow.AnotherWindow'</code> for + * {@link ifc.awt._XWindow} : the controller of another + * component. </li> + * </ul> + */ + protected TestEnvironment createTestEnvironment(TestParameters Param, + PrintWriter log) { + XInterface oObj = null; + Object anotherCtrl = null; + XWindowPeer the_win = null; + XToolkit the_kit = null; + XDevice aDevice = null; + XGraphics aGraphic = null; + + //Insert a ControlShape and get the ControlModel + XControlShape aShape = FormTools.createControlShape(xTextDoc, 3000, + 4500, 15000, 10000, + "DateField"); + + WriterTools.getDrawPage(xTextDoc).add((XShape) aShape); + + XControlModel the_Model = aShape.getControl(); + + XControlShape aShape2 = FormTools.createControlShape(xTextDoc, 3000, + 4500, 5000, 10000, + "TextField"); + + WriterTools.getDrawPage(xTextDoc).add((XShape) aShape2); + + XControlModel the_Model2 = aShape2.getControl(); + + //Try to query XControlAccess + XControlAccess the_access = (XControlAccess) UnoRuntime.queryInterface( + XControlAccess.class, + xTextDoc.getCurrentController()); + + //now get the ODateControl + try { + oObj = the_access.getControl(the_Model); + anotherCtrl = the_access.getControl(the_Model2); + the_win = the_access.getControl(the_Model).getPeer(); + the_kit = the_win.getToolkit(); + aDevice = the_kit.createScreenCompatibleDevice(200, 200); + aGraphic = aDevice.createGraphics(); + } catch (com.sun.star.container.NoSuchElementException e) { + log.println("Couldn't get ODateControl"); + e.printStackTrace(log); + throw new StatusException("Couldn't get ODateControl", e); + } + + log.println("creating a new environment for ODateControl object"); + + TestEnvironment tEnv = new TestEnvironment(oObj); + + + //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 + XWindow forObjRel = (XWindow) UnoRuntime.queryInterface(XWindow.class, + anotherCtrl); + + tEnv.addObjRelation("XWindow.AnotherWindow", forObjRel); + tEnv.addObjRelation("XWindow.ControlShape", aShape); + + // Adding relation for XTextListener + ifc.awt._XTextListener.TestTextListener listener = + new ifc.awt._XTextListener.TestTextListener(); + XTextComponent textComp = (XTextComponent) UnoRuntime.queryInterface( + XTextComponent.class, oObj); + textComp.addTextListener(listener); + tEnv.addObjRelation("TestTextListener", listener); + + return tEnv; + } // finish method getTestEnvironment +} // finish class ODateControl diff --git a/qadevOOo/tests/java/mod/_forms/ODateModel.java b/qadevOOo/tests/java/mod/_forms/ODateModel.java new file mode 100644 index 000000000000..297c5088937e --- /dev/null +++ b/qadevOOo/tests/java/mod/_forms/ODateModel.java @@ -0,0 +1,178 @@ +/************************************************************************* + * + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * Copyright 2000, 2010 Oracle and/or its affiliates. + * + * OpenOffice.org - a multi-platform office productivity suite + * + * This file is part of OpenOffice.org. + * + * OpenOffice.org is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License version 3 + * only, as published by the Free Software Foundation. + * + * OpenOffice.org is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License version 3 for more details + * (a copy is included in the LICENSE file that accompanied this code). + * + * You should have received a copy of the GNU Lesser General Public License + * version 3 along with OpenOffice.org. If not, see + * <http://www.openoffice.org/license.html> + * for a copy of the LGPLv3 License. + * + ************************************************************************/ +package mod._forms; + +import com.sun.star.beans.NamedValue; +import java.io.PrintWriter; + +import lib.TestEnvironment; +import lib.TestParameters; +import util.DBTools; + + + +/** +* Test for object which is represented by service +* <code>com.sun.star.form.component.DateField</code>. <p> +* Object implements the following interfaces : +* <ul> +* <li> <code>com::sun::star::io::XPersistObject</code></li> +* <li> <code>com::sun::star::awt::UnoControlDateFieldModel</code></li> +* <li> <code>com::sun::star::form::XReset</code></li> +* <li> <code>com::sun::star::form::XBoundComponent</code></li> +* <li> <code>com::sun::star::form::FormComponent</code></li> +* <li> <code>com::sun::star::form::component::DateField</code></li> +* <li> <code>com::sun::star::beans::XFastPropertySet</code></li> +* <li> <code>com::sun::star::beans::XMultiPropertySet</code></li> +* <li> <code>com::sun::star::form::XUpdateBroadcaster</code></li> +* <li> <code>com::sun::star::form::DataAwareControlModel</code></li> +* <li> <code>com::sun::star::beans::XPropertyState</code></li> +* <li> <code>com::sun::star::form::FormControlModel</code></li> +* <li> <code>com::sun::star::container::XNamed</code></li> +* <li> <code>com::sun::star::lang::XComponent</code></li> +* <li> <code>com::sun::star::lang::XEventListener</code></li> +* <li> <code>com::sun::star::beans::XPropertyAccess</code></li> +* <li> <code>com::sun::star::beans::XPropertyContainer</code></li> +* <li> <code>com::sun::star::beans::XPropertySet</code></li> +* <li> <code>com::sun::star::form::XLoadListener</code></li> +* <li> <code>com::sun::star::container::XChild</code></li> +* </ul> +* The following files used by this test : +* <ul> +* <li><b> TestDB </b> (directory) : directory with test database </li> +* <li><b> TestDB/TestDB.dbf </b> : table file. See +* {@link util.DBTools DBTools} class for more information.</li> +* </ul> <p> +* This object test <b> is NOT </b> designed to be run in several +* threads concurently. +* @see com.sun.star.io.XPersistObject +* @see com.sun.star.awt.UnoControlDateFieldModel +* @see com.sun.star.form.XReset +* @see com.sun.star.form.XBoundComponent +* @see com.sun.star.form.FormComponent +* @see com.sun.star.form.component.DateField +* @see com.sun.star.beans.XFastPropertySet +* @see com.sun.star.beans.XMultiPropertySet +* @see com.sun.star.form.XUpdateBroadcaster +* @see com.sun.star.form.DataAwareControlModel +* @see com.sun.star.beans.XPropertyState +* @see com.sun.star.form.FormControlModel +* @see com.sun.star.container.XNamed +* @see com.sun.star.lang.XComponent +* @see com.sun.star.lang.XEventListener +* @see com.sun.star.beans.XPropertyAccess +* @see com.sun.star.beans.XPropertyContainer +* @see com.sun.star.beans.XPropertySet +* @see com.sun.star.form.XLoadListener +* @see com.sun.star.container.XChild +* @see ifc.io._XPersistObject +* @see ifc.awt._UnoControlDateFieldModel +* @see ifc.form._XReset +* @see ifc.form._XBoundComponent +* @see ifc.form._FormComponent +* @see ifc.form.component._DateField +* @see ifc.beans._XFastPropertySet +* @see ifc.beans._XMultiPropertySet +* @see ifc.form._XUpdateBroadcaster +* @see ifc.form._DataAwareControlModel +* @see ifc.beans._XPropertyState +* @see ifc.form._FormControlModel +* @see ifc.container._XNamed +* @see ifc.lang._XComponent +* @see ifc.lang._XEventListener +* @see ifc.beans._XPropertySet +* @see ifc.form._XLoadListener +* @see ifc.container._XChild +*/ +public class ODateModel extends GenericModelTest { + + /** + * Set some member variable of the super class <CODE>GenericModelTest</CODE>: + * <pre> + * super.m_ChangePropertyName = "Date"; + * super.m_kindOfControl="DateField"; + * super.m_ObjectName = "stardiv.one.form.component.DateField"; + * + * NamedValue DataField = new NamedValue(); + * DataField.Name = "DataField"; + * DataField.Value = DBTools.TST_DATE_F; + * super.m_propertiesToSet.add(DataField); + * + * NamedValue Date = new NamedValue(); + * Date.Name = "Date"; + * Date.Value = new Integer(DBTools.TST_DATE); + * super.m_propertiesToSet.add(Date); + * super.m_LCShape_Type = "FixedText"; + * </pre> + * Then <CODE>super.initialize()</CODE> was called. + * @param tParam the test parameter + * @param log the log writer + */ + protected void initialize(TestParameters tParam, PrintWriter log) { + + super.initialize(tParam, log); + + super.m_ChangePropertyName = "Date"; + + super.m_kindOfControl="DateField"; + + super.m_ObjectName = "stardiv.one.form.component.DateField"; + + NamedValue DataField = new NamedValue(); + DataField.Name = "DataField"; + DataField.Value = DBTools.TST_DATE_F; + super.m_propertiesToSet.add(DataField); + + NamedValue Date = new NamedValue(); + Date.Name = "Date"; + Date.Value = new Integer(DBTools.TST_DATE); + super.m_propertiesToSet.add(Date); + + super.m_LCShape_Type = "FixedText"; + + } + /** + * calls <CODE>cleanup()</CODE> from it's super class + * @param tParam the test parameter + * @param log the log writer + */ + protected void cleanup(TestParameters tParam, PrintWriter log) { + super.cleanup(tParam, log); + } + + + /** + * calls <CODE>createTestEnvironment()</CODE> from it's super class + * @param Param the test parameter + * @param log the log writer + * @return lib.TestEnvironment + */ + protected synchronized TestEnvironment createTestEnvironment(TestParameters Param, + PrintWriter log) { + return super.createTestEnvironment(Param, log); + } +} // finish class ODateModel diff --git a/qadevOOo/tests/java/mod/_forms/OEditControl.java b/qadevOOo/tests/java/mod/_forms/OEditControl.java new file mode 100644 index 000000000000..ac56d9f0cf93 --- /dev/null +++ b/qadevOOo/tests/java/mod/_forms/OEditControl.java @@ -0,0 +1,261 @@ +/************************************************************************* + * + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * Copyright 2000, 2010 Oracle and/or its affiliates. + * + * OpenOffice.org - a multi-platform office productivity suite + * + * This file is part of OpenOffice.org. + * + * OpenOffice.org is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License version 3 + * only, as published by the Free Software Foundation. + * + * OpenOffice.org is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License version 3 for more details + * (a copy is included in the LICENSE file that accompanied this code). + * + * You should have received a copy of the GNU Lesser General Public License + * version 3 along with OpenOffice.org. If not, see + * <http://www.openoffice.org/license.html> + * for a copy of the LGPLv3 License. + * + ************************************************************************/ +package mod._forms; + +import java.io.PrintWriter; + +import lib.StatusException; +import lib.TestCase; +import lib.TestEnvironment; +import lib.TestParameters; +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.XDevice; +import com.sun.star.awt.XGraphics; +import com.sun.star.awt.XTextComponent; +import com.sun.star.awt.XToolkit; +import com.sun.star.awt.XWindow; +import com.sun.star.awt.XWindowPeer; +import com.sun.star.drawing.XControlShape; +import com.sun.star.drawing.XShape; +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.XCloseable; +import com.sun.star.view.XControlAccess; + + +/** + * Test for object which is represented by default controller + * of the <code>com.sun.star.form.component.TextField</code> + * component. <p> + * + * Object implements the following interfaces : + * <ul> + * <li> <code>com::sun::star::awt::XView</code></li> + * <li> <code>com::sun::star::form::XBoundControl</code></li> + * <li> <code>com::sun::star::awt::XControl</code></li> + * <li> <code>com::sun::star::awt::XTextComponent</code></li> + * <li> <code>com::sun::star::awt::XLayoutConstrains</code></li> + * <li> <code>com::sun::star::awt::XTextListener</code></li> + * <li> <code>com::sun::star::form::XChangeBroadcaster</code></li> + * <li> <code>com::sun::star::awt::XWindow</code></li> + * <li> <code>com::sun::star::lang::XComponent</code></li> + * <li> <code>com::sun::star::awt::XTextLayoutConstrains</code></li> + * <li> <code>com::sun::star::lang::XEventListener</code></li> + * </ul> <p> + * This object test <b> is NOT </b> designed to be run in several + * threads concurently. + * + * @see com.sun.star.awt.XView + * @see com.sun.star.form.XBoundControl + * @see com.sun.star.awt.XControl + * @see com.sun.star.awt.XTextComponent + * @see com.sun.star.awt.XLayoutConstrains + * @see com.sun.star.awt.XTextListener + * @see com.sun.star.form.XChangeBroadcaster + * @see com.sun.star.awt.XWindow + * @see com.sun.star.lang.XComponent + * @see com.sun.star.awt.XTextLayoutConstrains + * @see com.sun.star.lang.XEventListener + * @see ifc.awt._XView + * @see ifc.form._XBoundControl + * @see ifc.awt._XControl + * @see ifc.awt._XTextComponent + * @see ifc.awt._XLayoutConstrains + * @see ifc.awt._XTextListener + * @see ifc.form._XChangeBroadcaster + * @see ifc.awt._XWindow + * @see ifc.lang._XComponent + * @see ifc.awt._XTextLayoutConstrains + * @see ifc.lang._XEventListener + */ +public class OEditControl extends TestCase { + XTextDocument xTextDoc; + + /** + * Creates a new text document. + */ + protected void initialize(TestParameters Param, PrintWriter log) { + SOfficeFactory SOF = SOfficeFactory.getFactory(((XMultiServiceFactory) Param.getMSF())); + + try { + log.println("creating a textdocument"); + xTextDoc = SOF.createTextDoc(null); + } catch (com.sun.star.uno.Exception e) { + // Some exception occures.FAILED + e.printStackTrace(log); + throw new StatusException("Couldn't create document", e); + } + } + + /** + * Disposes the text document created before + */ + protected void cleanup(TestParameters tParam, PrintWriter log) { + log.println(" disposing xTextDoc "); + + try { + XCloseable closer = (XCloseable) 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"); + } + } + + /** + * Creates two components and inserts them to the form of + * text document. One component + * (<code>com.sun.star.form.component.TextField</code>) is created + * for testing, another to be passed as relation. Using a controller + * of the text document the controller of the first component is + * obtained and returned in environment as a test object. <p> + * + * Object relations created : + * <ul> + * <li> <code>'GRAPHICS'</code> for + * {@link ifc.awt._XView} : a graphics component + * created using screen device of the window peer of + * the controller tested. </li> + * <li> <code>'CONTEXT'</code> for + * {@link ifc.awt._XControl} : the text document + * where the component is inserted. </li> + * <li> <code>'WINPEER'</code> for + * {@link ifc.awt._XControl} : Window peer of the + * controller tested. </li> + * <li> <code>'TOOLKIT'</code> for + * {@link ifc.awt._XControl} : toolkit of the component.</li> + * <li> <code>'MODEL'</code> for + * {@link ifc.awt._XControl} : the model of the controller.</li> + * <li> <code>'XWindow.AnotherWindow'</code> for + * {@link ifc.awt._XWindow} : the controller of another + * component. </li> + * <li> <code>'Win1'</code> for + * {@link ifc.form.XChangeBroadcaster} : the window (controller) + * of the tested component. </li> + * <li> <code>'Win2'</code> for + * {@link ifc.form.XChangeBroadcaster} : the window (controller) + * of another component. </li> + * <li> <code>'CONTROL'</code> for + * {@link ifc.form.XChangeBroadcaster} : the controller + * of another component. </li> + * </ul> + */ + protected TestEnvironment createTestEnvironment(TestParameters Param, + PrintWriter log) { + XInterface oObj = null; + XControl aControl = null; + XWindowPeer the_win = null; + XToolkit the_kit = null; + XDevice aDevice = null; + XGraphics aGraphic = null; + + //Insert a ControlShape and get the ControlModel + XControlShape aShape = FormTools.createControlShape(xTextDoc, 3000, + 4500, 15000, 10000, + "TextField"); + + WriterTools.getDrawPage(xTextDoc).add((XShape) aShape); + + XControlModel the_Model = aShape.getControl(); + + XControlShape aShape2 = FormTools.createControlShape(xTextDoc, 3000, + 4500, 5000, 10000, + "TextField"); + + WriterTools.getDrawPage(xTextDoc).add((XShape) aShape2); + + XControlModel the_Model2 = aShape2.getControl(); + + //Try to query XControlAccess + XControlAccess the_access = (XControlAccess) UnoRuntime.queryInterface( + XControlAccess.class, + xTextDoc.getCurrentController()); + + //now get the OEditControl + try { + oObj = the_access.getControl(the_Model); + aControl = the_access.getControl(the_Model2); + the_win = the_access.getControl(the_Model).getPeer(); + the_kit = the_win.getToolkit(); + aDevice = the_kit.createScreenCompatibleDevice(200, 200); + aGraphic = aDevice.createGraphics(); + } catch (com.sun.star.container.NoSuchElementException e) { + log.println("Couldn't get OEditControl"); + e.printStackTrace(log); + throw new StatusException("Couldn't get OEditControl", e); + } + + log.println("creating a new environment for OEditControl object"); + + TestEnvironment tEnv = new TestEnvironment(oObj); + + + //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); + + // relations for XChangeBroadcaster + XWindow forObjRel = (XWindow) UnoRuntime.queryInterface(XWindow.class, + aControl); + + tEnv.addObjRelation("Win1", + (XWindow) UnoRuntime.queryInterface(XWindow.class, + oObj)); + tEnv.addObjRelation("Win2", forObjRel); + tEnv.addObjRelation("CONTROL", aControl); + + + // relation for XWindow + tEnv.addObjRelation("XWindow.AnotherWindow", forObjRel); + tEnv.addObjRelation("XWindow.ControlShape", aShape); + + // Adding relation for XTextListener + ifc.awt._XTextListener.TestTextListener listener = + new ifc.awt._XTextListener.TestTextListener(); + XTextComponent textComp = (XTextComponent) UnoRuntime.queryInterface( + XTextComponent.class, oObj); + textComp.addTextListener(listener); + tEnv.addObjRelation("TestTextListener", listener); + + return tEnv; + } // finish method getTestEnvironment +} // finish class OEditControl diff --git a/qadevOOo/tests/java/mod/_forms/OEditModel.java b/qadevOOo/tests/java/mod/_forms/OEditModel.java new file mode 100644 index 000000000000..4004b68d13a1 --- /dev/null +++ b/qadevOOo/tests/java/mod/_forms/OEditModel.java @@ -0,0 +1,170 @@ +/************************************************************************* + * + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * Copyright 2000, 2010 Oracle and/or its affiliates. + * + * OpenOffice.org - a multi-platform office productivity suite + * + * This file is part of OpenOffice.org. + * + * OpenOffice.org is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License version 3 + * only, as published by the Free Software Foundation. + * + * OpenOffice.org is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License version 3 for more details + * (a copy is included in the LICENSE file that accompanied this code). + * + * You should have received a copy of the GNU Lesser General Public License + * version 3 along with OpenOffice.org. If not, see + * <http://www.openoffice.org/license.html> + * for a copy of the LGPLv3 License. + * + ************************************************************************/ +package mod._forms; + +import com.sun.star.beans.NamedValue; +import java.io.PrintWriter; + +import lib.TestEnvironment; +import lib.TestParameters; +import util.DBTools; + + + +/** +* Test for object which is represented by service +* <code>com.sun.star.form.component.TextField</code>. <p> +* Object implements the following interfaces : +* <ul> +* <li> <code>com::sun::star::io::XPersistObject</code></li> +* <li> <code>com::sun::star::form::XReset</code></li> +* <li> <code>com::sun::star::form::XBoundComponent</code></li> +* <li> <code>com::sun::star::form::FormComponent</code></li> +* <li> <code>com::sun::star::beans::XFastPropertySet</code></li> +* <li> <code>com::sun::star::beans::XMultiPropertySet</code></li> +* <li> <code>com::sun::star::form::XUpdateBroadcaster</code></li> +* <li> <code>com::sun::star::form::component::TextField</code></li> +* <li> <code>com::sun::star::form::DataAwareControlModel</code></li> +* <li> <code>com::sun::star::beans::XPropertyState</code></li> +* <li> <code>com::sun::star::form::FormControlModel</code></li> +* <li> <code>com::sun::star::container::XNamed</code></li> +* <li> <code>com::sun::star::awt::UnoControlEditModel</code></li> +* <li> <code>com::sun::star::form::component::DatabaseTextField</code></li> +* <li> <code>com::sun::star::lang::XComponent</code></li> +* <li> <code>com::sun::star::lang::XEventListener</code></li> +* <li> <code>com::sun::star::beans::XPropertyAccess</code></li> +* <li> <code>com::sun::star::beans::XPropertyContainer</code></li> +* <li> <code>com::sun::star::beans::XPropertySet</code></li> +* <li> <code>com::sun::star::form::XLoadListener</code></li> +* <li> <code>com::sun::star::container::XChild</code></li> +* </ul> +* The following files used by this test : +* <ul> +* <li><b> TestDB </b> (directory) : directory with test database </li> +* <li><b> TestDB/TestDB.dbf </b> : table file. See +* {@link util.DBTools DBTools} class for more information.</li> +* </ul> <p> +* This object test <b> is NOT </b> designed to be run in several +* threads concurently. +* @see com.sun.star.io.XPersistObject +* @see com.sun.star.form.XReset +* @see com.sun.star.form.XBoundComponent +* @see com.sun.star.form.FormComponent +* @see com.sun.star.beans.XFastPropertySet +* @see com.sun.star.beans.XMultiPropertySet +* @see com.sun.star.form.XUpdateBroadcaster +* @see com.sun.star.form.component.TextField +* @see com.sun.star.form.DataAwareControlModel +* @see com.sun.star.beans.XPropertyState +* @see com.sun.star.form.FormControlModel +* @see com.sun.star.container.XNamed +* @see com.sun.star.awt.UnoControlEditModel +* @see com.sun.star.form.component.DatabaseTextField +* @see com.sun.star.lang.XComponent +* @see com.sun.star.lang.XEventListener +* @see com.sun.star.beans.XPropertyAccess +* @see com.sun.star.beans.XPropertyContainer +* @see com.sun.star.beans.XPropertySet +* @see com.sun.star.form.XLoadListener +* @see com.sun.star.container.XChild +* @see ifc.io._XPersistObject +* @see ifc.form._XReset +* @see ifc.form._XBoundComponent +* @see ifc.form._FormComponent +* @see ifc.beans._XFastPropertySet +* @see ifc.beans._XMultiPropertySet +* @see ifc.form._XUpdateBroadcaster +* @see ifc.form.component._TextField +* @see ifc.form._DataAwareControlModel +* @see ifc.beans._XPropertyState +* @see ifc.form._FormControlModel +* @see ifc.container._XNamed +* @see ifc.awt._UnoControlEditModel +* @see ifc.form.component._DatabaseTextField +* @see ifc.lang._XComponent +* @see ifc.lang._XEventListener +* @see ifc.beans._XPropertySet +* @see ifc.form._XLoadListener +* @see ifc.container._XChild +*/ +public class OEditModel extends GenericModelTest { + + /** + * Set some member variable of the super class <CODE>GenericModelTest</CODE>: + * <pre> + * <super.m_ChangePropertyName</CODE> = "Text"; + * super.m_kindOfControl</CODE>="TextField"; + * super.m_ObjectName</CODE> = "Edit"; + * NamedValue myProp = new NamedValue(); + * myProp.Name = "DataField"; + * myProp.Value = DBTools.TST_STRING_F; + * super.m_propertiesToSet.add(myProp); + * super.m_LCShape_Type = "FixedText"; + * </pre> + * Then <CODE>super.initialize()</CODE> was called. + * @param tParam the test parameter + * @param log the log writer + */ + + protected void initialize(TestParameters tParam, PrintWriter log) { + + super.initialize(tParam, log); + + super.m_kindOfControl="TextField"; + + super.m_ObjectName = "stardiv.one.form.component.Edit"; + + NamedValue myProp = new NamedValue(); + myProp.Name = "DataField"; + myProp.Value = DBTools.TST_STRING_F; + super.m_propertiesToSet.add(myProp); + + super.m_LCShape_Type = "FixedText"; + + super.m_ChangePropertyName = "Text"; + } + /** + * calls <CODE>cleanup()</CODE> from it's super class + * @param tParam the test parameter + * @param log the log writer + */ + protected void cleanup(TestParameters tParam, PrintWriter log) { + super.cleanup(tParam, log); + } + + + /** + * calls <CODE>createTestEnvironment()</CODE> from it's super class + * @param Param the test parameter + * @param log the log writer + * @return lib.TestEnvironment + */ + protected synchronized TestEnvironment createTestEnvironment(TestParameters Param, + PrintWriter log) { + return super.createTestEnvironment(Param, log); + } +} // finish class OEditModel diff --git a/qadevOOo/tests/java/mod/_forms/OFileControlModel.java b/qadevOOo/tests/java/mod/_forms/OFileControlModel.java new file mode 100644 index 000000000000..3ece2f3a359e --- /dev/null +++ b/qadevOOo/tests/java/mod/_forms/OFileControlModel.java @@ -0,0 +1,210 @@ +/************************************************************************* + * + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * Copyright 2000, 2010 Oracle and/or its affiliates. + * + * OpenOffice.org - a multi-platform office productivity suite + * + * This file is part of OpenOffice.org. + * + * OpenOffice.org is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License version 3 + * only, as published by the Free Software Foundation. + * + * OpenOffice.org is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License version 3 for more details + * (a copy is included in the LICENSE file that accompanied this code). + * + * You should have received a copy of the GNU Lesser General Public License + * version 3 along with OpenOffice.org. If not, see + * <http://www.openoffice.org/license.html> + * for a copy of the LGPLv3 License. + * + ************************************************************************/ +package mod._forms; + +import java.io.PrintWriter; + +import lib.Status; +import lib.StatusException; +import lib.TestCase; +import lib.TestEnvironment; +import lib.TestParameters; +import util.DrawTools; +import util.SOfficeFactory; + +import com.sun.star.awt.Point; +import com.sun.star.awt.Size; +import com.sun.star.awt.XControlModel; +import com.sun.star.beans.PropertyValue; +import com.sun.star.drawing.XControlShape; +import com.sun.star.drawing.XShape; +import com.sun.star.lang.XComponent; +import com.sun.star.lang.XMultiServiceFactory; +import com.sun.star.uno.UnoRuntime; +import com.sun.star.uno.XInterface; +import com.sun.star.util.XCloseable; + + +/** + * Test for object which is represented by service + * <code>com.sun.star.form.component.FileControl</code>. <p> + * Object implements the following interfaces : + * <ul> + * <li> <code>com::sun::star::io::XPersistObject</code></li> + * <li> <code>com::sun::star::container::XChild</code></li> + * <li> <code>com::sun::star::form::FormControlModel</code></li> + * <li> <code>com::sun::star::awt::UnoControlFileControlModel</code></li> + * <li> <code>com::sun::star::form::FormComponent</code></li> + * <li> <code>com::sun::star::beans::XPropertyAccess</code></li> +* <li> <code>com::sun::star::beans::XPropertyContainer</code></li> +* <li> <code>com::sun::star::beans::XPropertySet</code></li> + * <li> <code>com::sun::star::beans::XFastPropertySet</code></li> + * <li> <code>com::sun::star::beans::XPropertyState</code></li> + * <li> <code>com::sun::star::container::XNamed</code></li> + * <li> <code>com::sun::star::beans::XMultiPropertySet</code></li> + * <li> <code>com::sun::star::lang::XComponent</code></li> + * <li> <code>com::sun::star::form::component::FileControl</code></li> + * </ul> + * This object test <b> is NOT </b> designed to be run in several + * threads concurently. + * @see com.sun.star.io.XPersistObject + * @see com.sun.star.container.XChild + * @see com.sun.star.form.FormControlModel + * @see com.sun.star.awt.UnoControlFileControlModel + * @see com.sun.star.form.FormComponent + * @see com.sun.star.beans.XPropertyAccess +* @see com.sun.star.beans.XPropertyContainer +* @see com.sun.star.beans.XPropertySet + * @see com.sun.star.beans.XFastPropertySet + * @see com.sun.star.beans.XPropertyState + * @see com.sun.star.container.XNamed + * @see com.sun.star.beans.XMultiPropertySet + * @see com.sun.star.lang.XComponent + * @see com.sun.star.form.component.FileControl + * @see ifc.io._XPersistObject + * @see ifc.container._XChild + * @see ifc.form._FormControlModel + * @see ifc.awt._UnoControlFileControlModel + * @see ifc.form._FormComponent + * @see ifc.beans._XPropertySet + * @see ifc.beans._XFastPropertySet + * @see ifc.beans._XPropertyState + * @see ifc.container._XNamed + * @see ifc.beans._XMultiPropertySet + * @see ifc.lang._XComponent + * @see ifc.form.component._FileControl + */ +public class OFileControlModel extends TestCase { + XComponent xDrawDoc; + + /** + * Creates Draw document where controls are placed. + */ + protected void initialize(TestParameters tParam, PrintWriter log) { + SOfficeFactory SOF = SOfficeFactory.getFactory(((XMultiServiceFactory) tParam.getMSF())); + + try { + log.println("creating a draw document"); + xDrawDoc = SOF.createDrawDoc(null); + } catch (com.sun.star.uno.Exception e) { + log.println("Can't create a document :"); + e.printStackTrace(log); + throw new StatusException(Status.failed("Can't create a document")); + } + } + + /** + * Disposes Draw document. + */ + protected void cleanup(TestParameters tParam, PrintWriter log) { + log.println(" disposing xDrawDoc "); + + try { + XCloseable closer = (XCloseable) UnoRuntime.queryInterface( + XCloseable.class, xDrawDoc); + 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 FileControl in the Form. <p> + * Object relations created : + * <ul> + * <li> <code>'OBJNAME'</code> for + * {@link ifc.io._XPersistObject} : name of service which is + * represented by this object. </li> + * </ul> + */ + protected synchronized TestEnvironment createTestEnvironment(TestParameters Param, + PrintWriter log) { + XInterface oObj = null; + + + // creation of testobject here + // first we write what we are intend to do to log file + log.println("creating a test environment"); + + //get FileControlModel + String objName = "FileControl"; + + XControlShape aShape = null; + + Size size = new Size(); + Point position = new Point(); + XControlModel aControl = null; + + //get MSF + XMultiServiceFactory oDocMSF = (XMultiServiceFactory) UnoRuntime.queryInterface( + XMultiServiceFactory.class, + xDrawDoc); + + try { + Object oInt = oDocMSF.createInstance( + "com.sun.star.drawing.ControlShape"); + Object aCon = oDocMSF.createInstance( + "com.sun.star.form.component." + objName); + aControl = (XControlModel) UnoRuntime.queryInterface( + XControlModel.class, aCon); + aShape = (XControlShape) UnoRuntime.queryInterface( + XControlShape.class, oInt); + size.Height = 1500; + size.Width = 3000; + position.X = 1000; + position.Y = 1000; + aShape.setSize(size); + aShape.setPosition(position); + } catch (com.sun.star.uno.Exception e) { + // Some exception occures.FAILED + log.println("Couldn't create a component " + e); + throw new StatusException(Status.failed("Can't create component")); + } + + aShape.setControl(aControl); + + DrawTools.getDrawPage(xDrawDoc, 0).add((XShape) aShape); + oObj = aShape.getControl(); + + log.println("creating a new environment for drawpage object"); + + TestEnvironment tEnv = new TestEnvironment(oObj); + + tEnv.addObjRelation("OBJNAME", "stardiv.one.form.component." + + objName); + PropertyValue prop = new PropertyValue(); + prop.Name = "HelpText"; + prop.Value = "new Help Text since XPropertyAccess"; + tEnv.addObjRelation("XPropertyAccess.propertyToChange", prop); + tEnv.addObjRelation("XPropertyContainer.propertyNotRemovable", "HelpText"); + + return tEnv; + } // finish method getTestEnvironment +} // finish class OFileControlModel diff --git a/qadevOOo/tests/java/mod/_forms/OFixedTextModel.java b/qadevOOo/tests/java/mod/_forms/OFixedTextModel.java new file mode 100644 index 000000000000..5753da62d75a --- /dev/null +++ b/qadevOOo/tests/java/mod/_forms/OFixedTextModel.java @@ -0,0 +1,128 @@ +/************************************************************************* + * + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * Copyright 2000, 2010 Oracle and/or its affiliates. + * + * OpenOffice.org - a multi-platform office productivity suite + * + * This file is part of OpenOffice.org. + * + * OpenOffice.org is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License version 3 + * only, as published by the Free Software Foundation. + * + * OpenOffice.org is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License version 3 for more details + * (a copy is included in the LICENSE file that accompanied this code). + * + * You should have received a copy of the GNU Lesser General Public License + * version 3 along with OpenOffice.org. If not, see + * <http://www.openoffice.org/license.html> + * for a copy of the LGPLv3 License. + * + ************************************************************************/ +package mod._forms; + +import java.io.PrintWriter; + +import lib.TestEnvironment; +import lib.TestParameters; + + +/** +* Test for object which is represented by service +* <code>com.sun.star.form.component.FixedText</code>. <p> +* Object implements the following interfaces : +* <ul> +* <li> <code>com::sun::star::io::XPersistObject</code></li> +* <li> <code>com::sun::star::container::XChild</code></li> +* <li> <code>com::sun::star::form::FormControlModel</code></li> +* <li> <code>com::sun::star::form::FormComponent</code></li> +* <li> <code>com::sun::star::beans::XPropertyAccess</code></li> +* <li> <code>com::sun::star::beans::XPropertyContainer</code></li> +* <li> <code>com::sun::star::beans::XPropertySet</code></li> +* <li> <code>com::sun::star::beans::XFastPropertySet</code></li> +* <li> <code>com::sun::star::beans::XPropertyState</code></li> +* <li> <code>com::sun::star::container::XNamed</code></li> +* <li> <code>com::sun::star::beans::XMultiPropertySet</code></li> +* <li> <code>com::sun::star::awt::UnoControlFixedTextModel</code></li> +* <li> <code>com::sun::star::lang::XComponent</code></li> +* </ul> +* This object test <b> is NOT </b> designed to be run in several +* threads concurently. +* @see com.sun.star.io.XPersistObject +* @see com.sun.star.container.XChild +* @see com.sun.star.form.FormControlModel +* @see com.sun.star.form.FormComponent +* @see com.sun.star.beans.XPropertyAccess +* @see com.sun.star.beans.XPropertyContainer +* @see com.sun.star.beans.XPropertySet +* @see com.sun.star.beans.XFastPropertySet +* @see com.sun.star.beans.XPropertyState +* @see com.sun.star.container.XNamed +* @see com.sun.star.beans.XMultiPropertySet +* @see com.sun.star.awt.UnoControlFixedTextModel +* @see com.sun.star.lang.XComponent +* @see ifc.io._XPersistObject +* @see ifc.container._XChild +* @see ifc.form._FormControlModel +* @see ifc.form._FormComponent +* @see ifc.beans._XPropertySet +* @see ifc.beans._XFastPropertySet +* @see ifc.beans._XPropertyState +* @see ifc.container._XNamed +* @see ifc.beans._XMultiPropertySet +* @see ifc.awt._UnoControlFixedTextModel +* @see ifc.lang._XComponent +*/ + +public class OFixedTextModel extends GenericModelTest { + + /** + * Set some member variable of the super class <CODE>GenericModelTest</CODE>: + * <pre> + * super.m_kindOfControl="CommandButton"; + * super.m_ObjectName = "com.sun.star.form.component.CommandButton"; + * super.m_LCShape_Type = "CommandButton"; + * </pre> + * Then <CODE>super.initialize()</CODE> was called. + * @param tParam the test parameter + * @param log the log writer + */ + + protected void initialize(TestParameters tParam, PrintWriter log) { + + super.initialize(tParam, log); + + super.m_kindOfControl="FixedText"; + + super.m_ObjectName = "stardiv.one.form.component.FixedText"; + + super.m_LCShape_Type = "FixedText"; + + } + /** + * calls <CODE>cleanup()</CODE> from it's super class + * @param tParam the test parameter + * @param log the log writer + */ + protected void cleanup(TestParameters tParam, PrintWriter log) { + super.cleanup(tParam, log); + } + + + /** + * calls <CODE>createTestEnvironment()</CODE> from it's super class + * @param Param the test parameter + * @param log the log writer + * @return lib.TestEnvironment + */ + protected synchronized TestEnvironment createTestEnvironment(TestParameters Param, + PrintWriter log) { + return super.createTestEnvironment(Param, log); + } + +} // finish class OFixedTextModel diff --git a/qadevOOo/tests/java/mod/_forms/OFormattedControl.java b/qadevOOo/tests/java/mod/_forms/OFormattedControl.java new file mode 100644 index 000000000000..4888caba5441 --- /dev/null +++ b/qadevOOo/tests/java/mod/_forms/OFormattedControl.java @@ -0,0 +1,240 @@ +/************************************************************************* + * + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * Copyright 2000, 2010 Oracle and/or its affiliates. + * + * OpenOffice.org - a multi-platform office productivity suite + * + * This file is part of OpenOffice.org. + * + * OpenOffice.org is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License version 3 + * only, as published by the Free Software Foundation. + * + * OpenOffice.org is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License version 3 for more details + * (a copy is included in the LICENSE file that accompanied this code). + * + * You should have received a copy of the GNU Lesser General Public License + * version 3 along with OpenOffice.org. If not, see + * <http://www.openoffice.org/license.html> + * for a copy of the LGPLv3 License. + * + ************************************************************************/ +package mod._forms; + +import java.io.PrintWriter; + +import lib.StatusException; +import lib.TestCase; +import lib.TestEnvironment; +import lib.TestParameters; +import util.FormTools; +import util.SOfficeFactory; +import util.WriterTools; + +import com.sun.star.awt.XControlModel; +import com.sun.star.awt.XDevice; +import com.sun.star.awt.XGraphics; +import com.sun.star.awt.XTextComponent; +import com.sun.star.awt.XToolkit; +import com.sun.star.awt.XWindow; +import com.sun.star.awt.XWindowPeer; +import com.sun.star.drawing.XControlShape; +import com.sun.star.drawing.XShape; +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.XCloseable; +import com.sun.star.view.XControlAccess; + + +/** + * Test for object which is represented by default controller + * of the <code>com.sun.star.form.component.FormattedField</code> + * component. <p> + * + * Object implements the following interfaces : + * <ul> + * <li> <code>com::sun::star::awt::XView</code></li> + * <li> <code>com::sun::star::form::XBoundControl</code></li> + * <li> <code>com::sun::star::awt::XControl</code></li> + * <li> <code>com::sun::star::awt::XTextComponent</code></li> + * <li> <code>com::sun::star::awt::XLayoutConstrains</code></li> + * <li> <code>com::sun::star::awt::XTextListener</code></li> + * <li> <code>com::sun::star::awt::XWindow</code></li> + * <li> <code>com::sun::star::lang::XComponent</code></li> + * <li> <code>com::sun::star::awt::XTextLayoutConstrains</code></li> + * <li> <code>com::sun::star::lang::XEventListener</code></li> + * </ul> <p> + * This object test <b> is NOT </b> designed to be run in several + * threads concurently. + * + * @see com.sun.star.awt.XView + * @see com.sun.star.form.XBoundControl + * @see com.sun.star.awt.XControl + * @see com.sun.star.awt.XTextComponent + * @see com.sun.star.awt.XLayoutConstrains + * @see com.sun.star.awt.XTextListener + * @see com.sun.star.awt.XWindow + * @see com.sun.star.lang.XComponent + * @see com.sun.star.awt.XTextLayoutConstrains + * @see com.sun.star.lang.XEventListener + * @see ifc.awt._XView + * @see ifc.form._XBoundControl + * @see ifc.awt._XControl + * @see ifc.awt._XTextComponent + * @see ifc.awt._XLayoutConstrains + * @see ifc.awt._XTextListener + * @see ifc.awt._XWindow + * @see ifc.lang._XComponent + * @see ifc.awt._XTextLayoutConstrains + * @see ifc.lang._XEventListener + */ +public class OFormattedControl extends TestCase { + XTextDocument xTextDoc; + + /** + * Creates a new text document. + */ + protected void initialize(TestParameters Param, PrintWriter log) { + SOfficeFactory SOF = SOfficeFactory.getFactory(((XMultiServiceFactory) Param.getMSF())); + + try { + log.println("creating a textdocument"); + xTextDoc = SOF.createTextDoc(null); + } catch (com.sun.star.uno.Exception e) { + // Some exception occures.FAILED + e.printStackTrace(log); + throw new StatusException("Couldn't create document", e); + } + } + + /** + * Disposes the text document created before + */ + protected void cleanup(TestParameters tParam, PrintWriter log) { + log.println(" disposing xTextDoc "); + + try { + XCloseable closer = (XCloseable) 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"); + } + } + + /** + * Creates two components and inserts them to the form of + * text document. One component + * (<code>com.sun.star.form.component.FormattedField</code>) is created + * for testing, another to be passed as relation. Using a controller + * of the text document the controller of the first component is + * obtained and returned in environment as a test object. <p> + * + * Object relations created : + * <ul> + * <li> <code>'GRAPHICS'</code> for + * {@link ifc.awt._XView} : a graphics component + * created using screen device of the window peer of + * the controller tested. </li> + * <li> <code>'CONTEXT'</code> for + * {@link ifc.awt._XControl} : the text document + * where the component is inserted. </li> + * <li> <code>'WINPEER'</code> for + * {@link ifc.awt._XControl} : Window peer of the + * controller tested. </li> + * <li> <code>'TOOLKIT'</code> for + * {@link ifc.awt._XControl} : toolkit of the component.</li> + * <li> <code>'MODEL'</code> for + * {@link ifc.awt._XControl} : the model of the controller.</li> + * <li> <code>'XWindow.AnotherWindow'</code> for + * {@link ifc.awt._XWindow} : the controller of another + * component. </li> + * </ul> + */ + protected TestEnvironment createTestEnvironment(TestParameters Param, + PrintWriter log) { + XInterface oObj = null; + Object anotherCtrl = null; + XWindowPeer the_win = null; + XToolkit the_kit = null; + XDevice aDevice = null; + XGraphics aGraphic = null; + + //Insert a ControlShape and get the ControlModel + XControlShape aShape = FormTools.createControlShape(xTextDoc, 3000, + 4500, 15000, 10000, + "FormattedField"); + + WriterTools.getDrawPage(xTextDoc).add((XShape) aShape); + + XControlModel the_Model = aShape.getControl(); + + XControlShape aShape2 = FormTools.createControlShape(xTextDoc, 3000, + 4500, 5000, 10000, + "TextField"); + + WriterTools.getDrawPage(xTextDoc).add((XShape) aShape2); + + XControlModel the_Model2 = aShape2.getControl(); + + //Try to query XControlAccess + XControlAccess the_access = (XControlAccess) UnoRuntime.queryInterface( + XControlAccess.class, + xTextDoc.getCurrentController()); + + //now get the OFormattedControl + try { + oObj = the_access.getControl(the_Model); + anotherCtrl = the_access.getControl(the_Model2); + the_win = the_access.getControl(the_Model).getPeer(); + the_kit = the_win.getToolkit(); + aDevice = the_kit.createScreenCompatibleDevice(200, 200); + aGraphic = aDevice.createGraphics(); + } catch (com.sun.star.container.NoSuchElementException e) { + log.println("Couldn't get OFormattedControl"); + e.printStackTrace(log); + throw new StatusException("Couldn't get OFormattedControl", e); + } + + log.println("creating a new environment for OFormattedControl object"); + + TestEnvironment tEnv = new TestEnvironment(oObj); + + + //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 + XWindow forObjRel = (XWindow) UnoRuntime.queryInterface(XWindow.class, + anotherCtrl); + + tEnv.addObjRelation("XWindow.AnotherWindow", forObjRel); + tEnv.addObjRelation("XWindow.ControlShape", aShape); + + // Adding relation for XTextListener + ifc.awt._XTextListener.TestTextListener listener = + new ifc.awt._XTextListener.TestTextListener(); + XTextComponent textComp = (XTextComponent) UnoRuntime.queryInterface( + XTextComponent.class, oObj); + textComp.addTextListener(listener); + tEnv.addObjRelation("TestTextListener", listener); + + return tEnv; + } // finish method getTestEnvironment +} // finish class OFormattedControl diff --git a/qadevOOo/tests/java/mod/_forms/OFormattedFieldWrapper.java b/qadevOOo/tests/java/mod/_forms/OFormattedFieldWrapper.java new file mode 100644 index 000000000000..b51b4b575932 --- /dev/null +++ b/qadevOOo/tests/java/mod/_forms/OFormattedFieldWrapper.java @@ -0,0 +1,162 @@ +/************************************************************************* + * + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * Copyright 2000, 2010 Oracle and/or its affiliates. + * + * OpenOffice.org - a multi-platform office productivity suite + * + * This file is part of OpenOffice.org. + * + * OpenOffice.org is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License version 3 + * only, as published by the Free Software Foundation. + * + * OpenOffice.org is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License version 3 for more details + * (a copy is included in the LICENSE file that accompanied this code). + * + * You should have received a copy of the GNU Lesser General Public License + * version 3 along with OpenOffice.org. If not, see + * <http://www.openoffice.org/license.html> + * for a copy of the LGPLv3 License. + * + ************************************************************************/ +package mod._forms; + +import com.sun.star.beans.NamedValue; +import java.io.PrintWriter; + +import lib.TestEnvironment; +import lib.TestParameters; + +import util.DBTools; + + +/** + * Test for object which is represented by service + * <code>com.sun.star.form.component.FormattedField</code>. <p> + * Object implements the following interfaces : + * <ul> + * <li> <code>com::sun::star::io::XPersistObject</code></li> + * <li> <code>com::sun::star::form::XReset</code></li> + * <li> <code>com::sun::star::form::XBoundComponent</code></li> + * <li> <code>com::sun::star::form::FormComponent</code></li> + * <li> <code>com::sun::star::beans::XFastPropertySet</code></li> + * <li> <code>com::sun::star::beans::XMultiPropertySet</code></li> + * <li> <code>com::sun::star::form::DataAwareControlModel</code></li> + * <li> <code>com::sun::star::form::XUpdateBroadcaster</code></li> + * <li> <code>com::sun::star::form::component::DatabaseFormattedField</code></li> + * <li> <code>com::sun::star::form::FormControlModel</code></li> + * <li> <code>com::sun::star::beans::XPropertyState</code></li> + * <li> <code>com::sun::star::container::XNamed</code></li> + * <li> <code>com::sun::star::lang::XComponent</code></li> + * <li> <code>com::sun::star::lang::XEventListener</code></li> + * <li> <code>com::sun::star::beans::XPropertyAccess</code></li> + * <li> <code>com::sun::star::beans::XPropertyContainer</code></li> + * <li> <code>com::sun::star::beans::XPropertySet</code></li> + * <li> <code>com::sun::star::form::XLoadListener</code></li> + * <li> <code>com::sun::star::awt::UnoControlFormattedFieldModel</code></li> + * <li> <code>com::sun::star::container::XChild</code></li> + * </ul> <p> + * + * This object test <b> is NOT </b> designed to be run in several + * threads concurently. + * + * @see com.sun.star.io.XPersistObject + * @see com.sun.star.form.XReset + * @see com.sun.star.form.XBoundComponent + * @see com.sun.star.form.FormComponent + * @see com.sun.star.beans.XFastPropertySet + * @see com.sun.star.beans.XMultiPropertySet + * @see com.sun.star.form.DataAwareControlModel + * @see com.sun.star.form.XUpdateBroadcaster + * @see com.sun.star.form.component.DatabaseFormattedField + * @see com.sun.star.form.FormControlModel + * @see com.sun.star.beans.XPropertyState + * @see com.sun.star.container.XNamed + * @see com.sun.star.lang.XComponent + * @see com.sun.star.lang.XEventListener + * @see com.sun.star.beans.XPropertySet + * @see com.sun.star.form.XLoadListener + * @see com.sun.star.awt.UnoControlFormattedFieldModel + * @see com.sun.star.container.XChild + * @see ifc.io._XPersistObject + * @see ifc.form._XReset + * @see ifc.form._XBoundComponent + * @see ifc.form._FormComponent + * @see ifc.beans._XFastPropertySet + * @see ifc.beans._XMultiPropertySet + * @see ifc.form._DataAwareControlModel + * @see ifc.form._XUpdateBroadcaster + * @see ifc.form.component._DatabaseFormattedField + * @see ifc.form._FormControlModel + * @see ifc.beans._XPropertyState + * @see ifc.container._XNamed + * @see ifc.lang._XComponent + * @see ifc.lang._XEventListener + * @see ifc.beans._XPropertyAccess + * @see ifc.beans._XPropertyContainer + * @see ifc.beans._XPropertySet + * @see ifc.form._XLoadListener + * @see ifc.awt._UnoControlFormattedFieldModel + * @see ifc.container._XChild + */ +public class OFormattedFieldWrapper extends GenericModelTest { + /** + * Set some member variable of the super class <CODE>GenericModelTest</CODE>: + * <pre> + ' super.m_ChangePropertyName = "Text"; + * super.m_kindOfControl="DatabaseImageControl"; + * super.m_ObjectName = "stardiv.one.form.component.DatabaseImageControl"; + * NamedValue DataField = new NamedValue(); + * DataField.Name = "DataField"; + * DataField.Value = DBTools.TST_BINARY_STREAM_F; + * super.m_propertiesToSet.add(DataField); + * + * super.m_LCShape_Type = "FixedText"; + * </pre> + * Then <CODE>super.initialize()</CODE> was called. + * @param tParam the test parameter + * @param log the log writer + */ + protected void initialize(TestParameters tParam, PrintWriter log) { + + super.initialize(tParam, log); + + super.m_ChangePropertyName = "Text"; + + super.m_kindOfControl="DatabaseFormattedField"; + + super.m_ObjectName = "stardiv.one.form.component.Edit"; + + NamedValue DataField = new NamedValue(); + DataField.Name = "DataField"; + DataField.Value = DBTools.TST_STRING_F; + super.m_propertiesToSet.add(DataField); + + super.m_LCShape_Type = "FixedText"; + + } /** + * calls <CODE>cleanup()</CODE> from it's super class + * @param tParam the test parameter + * @param log the log writer + */ + protected void cleanup(TestParameters tParam, PrintWriter log) { + super.cleanup(tParam, log); + } + + + /** + * calls <CODE>createTestEnvironment()</CODE> from it's super class + * @param Param the test parameter + * @param log the log writer + * @return lib.TestEnvironment + */ + protected synchronized TestEnvironment createTestEnvironment(TestParameters Param, + PrintWriter log) { + return super.createTestEnvironment(Param, log); + } +} // finish class OFormattedFieldWrapper diff --git a/qadevOOo/tests/java/mod/_forms/OFormsCollection.java b/qadevOOo/tests/java/mod/_forms/OFormsCollection.java new file mode 100644 index 000000000000..af94a546b004 --- /dev/null +++ b/qadevOOo/tests/java/mod/_forms/OFormsCollection.java @@ -0,0 +1,184 @@ +/************************************************************************* + * + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * Copyright 2000, 2010 Oracle and/or its affiliates. + * + * OpenOffice.org - a multi-platform office productivity suite + * + * This file is part of OpenOffice.org. + * + * OpenOffice.org is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License version 3 + * only, as published by the Free Software Foundation. + * + * OpenOffice.org is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License version 3 for more details + * (a copy is included in the LICENSE file that accompanied this code). + * + * You should have received a copy of the GNU Lesser General Public License + * version 3 along with OpenOffice.org. If not, see + * <http://www.openoffice.org/license.html> + * for a copy of the LGPLv3 License. + * + ************************************************************************/ +package mod._forms; + +import java.io.PrintWriter; + +import lib.TestCase; +import lib.TestEnvironment; +import lib.TestParameters; +import util.DrawTools; +import util.FormTools; + +import com.sun.star.container.XNameContainer; +import com.sun.star.drawing.XDrawPage; +import com.sun.star.lang.XComponent; +import com.sun.star.lang.XMultiServiceFactory; +import com.sun.star.uno.UnoRuntime; +import com.sun.star.uno.XInterface; +import com.sun.star.util.XCloseable; + + +/** +* Test for object which is represented by service +* <code>com.sun.star.form.Forms</code>. <p> +* Object implements the following interfaces : +* <ul> +* <li> <code>com::sun::star::container::XNameReplace</code></li> +* <li> <code>com::sun::star::container::XIndexReplace</code></li> +* <li> <code>com::sun::star::container::XNameContainer</code></li> +* <li> <code>com::sun::star::container::XIndexAccess</code></li> +* <li> <code>com::sun::star::container::XElementAccess</code></li> +* <li> <code>com::sun::star::container::XEnumerationAccess</code></li> +* <li> <code>com::sun::star::container::XIndexContainer</code></li> +* <li> <code>com::sun::star::container::XNameAccess</code></li> +* </ul> +* +* This object test <b> is NOT </b> designed to be run in several +* threads concurently. +* +* @see com.sun.star.container.XNameReplace +* @see com.sun.star.container.XIndexReplace +* @see com.sun.star.container.XNameContainer +* @see com.sun.star.container.XIndexAccess +* @see com.sun.star.container.XElementAccess +* @see com.sun.star.container.XEnumerationAccess +* @see com.sun.star.container.XIndexContainer +* @see com.sun.star.container.XNameAccess +* @see ifc.container._XNameReplace +* @see ifc.container._XIndexReplace +* @see ifc.container._XNameContainer +* @see ifc.container._XIndexAccess +* @see ifc.container._XElementAccess +* @see ifc.container._XEnumerationAccess +* @see ifc.container._XIndexContainer +* @see ifc.container._XNameAccess +*/ +public class OFormsCollection extends TestCase { + XComponent xDrawDoc; + + /** + * Creates Drawing document. + */ + protected void initialize(TestParameters tParam, PrintWriter log) { + log.println("creating a draw document"); + xDrawDoc = DrawTools.createDrawDoc(((XMultiServiceFactory) tParam.getMSF())); + } + + /** + * Disposes drawing document. + */ + protected void cleanup(TestParameters tParam, PrintWriter log) { + log.println(" disposing xDrawDoc "); + + try { + XCloseable closer = (XCloseable) UnoRuntime.queryInterface( + XCloseable.class, xDrawDoc); + 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"); + } + } + + /** + * Adds some controls to the 'Standard' form of a draw page, + * then adds an empty form to a collection of forms. Then + * returns the collection as a test object. <p> + * Object relations created : + * <ul> + * <li> <code>'INSTANCE1' ... 'INSTANCEN'</code> for + * <code>XNameReplace, XNameContainer, XIndexReplace, + * XIndexContainer </code> : objects to be inserted + * or replaced with in interface tests. Number of relations + * depends on number of interface test threads. For each + * thread there must be an individual element. </li> + * <li> <code>'XNameContainer.AllowDuplicateNames'</code> : + * if this relation exists then container elements can have duplicate + * names. In case of forms' collection forms can have equal names.</li> + * </ul> + */ + protected synchronized TestEnvironment createTestEnvironment(TestParameters Param, + PrintWriter log) { + XInterface oObj = null; + XDrawPage oDP = null; + + + // creation of testobject here + // first we write what we are intend to do to log file + log.println("creating a test environment"); + + oDP = DrawTools.getDrawPage(xDrawDoc, 0); + + (DrawTools.getShapes(oDP)) + .add(FormTools.createControlShape(xDrawDoc, 2000, 1500, 1000, 1000, + "CheckBox")); + (DrawTools.getShapes(oDP)) + .add(FormTools.createControlShape(xDrawDoc, 3000, 4500, 15000, + 1000, "CommandButton")); + (DrawTools.getShapes(oDP)) + .add(FormTools.createControlShape(xDrawDoc, 5000, 3500, 7500, 5000, + "TextField")); + + oObj = FormTools.getForms(oDP); + FormTools.insertForm(xDrawDoc, (XNameContainer) oObj, "SecondForm"); + + log.println("creating a new environment for drawpage object"); + + TestEnvironment tEnv = new TestEnvironment(oObj); + + + // INSTANCEn : _XNameContainer; _XNameReplace + log.println("adding INSTANCEn as obj relation to environment"); + + XComponent xComp = (XComponent) UnoRuntime.queryInterface( + XComponent.class, xDrawDoc); + int THRCNT = 1; + if (Param.get("THRCNT")!= null) { + THRCNT = Integer.parseInt((String) Param.get("THRCNT")); + } + + for (int n = 1; n < (THRCNT + 1); n++) { + log.println("adding INSTANCE" + n + + " as obj relation to environment"); + tEnv.addObjRelation("INSTANCE" + n, + FormTools.createControl(xComp, "Form")); + } + + + // adding indicator that this collection can have duplicate + // elements with the same names for XNameContainer test. + tEnv.addObjRelation("XNameContainer.AllowDuplicateNames", new Object()); + + tEnv.addObjRelation("INSTANCE", FormTools.createControl(xComp, "Form")); + tEnv.addObjRelation("INSTANCE2", + FormTools.createControl(xComp, "Form")); + + return tEnv; + } // finish method getTestEnvironment +} // finish class OFormsCollection diff --git a/qadevOOo/tests/java/mod/_forms/OGridControlModel.java b/qadevOOo/tests/java/mod/_forms/OGridControlModel.java new file mode 100644 index 000000000000..65131dae1c46 --- /dev/null +++ b/qadevOOo/tests/java/mod/_forms/OGridControlModel.java @@ -0,0 +1,431 @@ +/************************************************************************* + * + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * Copyright 2000, 2010 Oracle and/or its affiliates. + * + * OpenOffice.org - a multi-platform office productivity suite + * + * This file is part of OpenOffice.org. + * + * OpenOffice.org is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License version 3 + * only, as published by the Free Software Foundation. + * + * OpenOffice.org is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License version 3 for more details + * (a copy is included in the LICENSE file that accompanied this code). + * + * You should have received a copy of the GNU Lesser General Public License + * version 3 along with OpenOffice.org. If not, see + * <http://www.openoffice.org/license.html> + * for a copy of the LGPLv3 License. + * + ************************************************************************/ +package mod._forms; + +import java.io.PrintWriter; +import java.util.Comparator; + +import lib.StatusException; +import lib.TestCase; +import lib.TestEnvironment; +import lib.TestParameters; +import util.FormTools; +import util.SOfficeFactory; + +import com.sun.star.beans.XPropertySet; +import com.sun.star.container.XNameContainer; +import com.sun.star.container.XNamed; +import com.sun.star.drawing.XControlShape; +import com.sun.star.form.XGridColumnFactory; +import com.sun.star.lang.XComponent; +import com.sun.star.lang.XMultiServiceFactory; +import com.sun.star.uno.UnoRuntime; +import com.sun.star.uno.XInterface; +import com.sun.star.util.XCloseable; + + +/** +* Test for object which is represented by service +* <code>com.sun.star.form.component.GridControl</code>. <p> +* Object implements the following interfaces : +* <ul> +* <li> <code>com::sun::star::io::XPersistObject</code></li> +* <li> <code>com::sun::star::container::XNameReplace</code></li> +* <li> <code>com::sun::star::form::XReset</code></li> +* <li> <code>com::sun::star::script::XEventAttacherManager</code></li> +* <li> <code>com::sun::star::form::FormComponent</code></li> +* <li> <code>com::sun::star::beans::XFastPropertySet</code></li> +* <li> <code>com::sun::star::beans::XMultiPropertySet</code></li> +* <li> <code>com::sun::star::container::XElementAccess</code></li> +* <li> <code>com::sun::star::form::component::GridControl</code></li> +* <li> <code>com::sun::star::view::XSelectionSupplier</code></li> +* <li> <code>com::sun::star::container::XEnumerationAccess</code></li> +* <li> <code>com::sun::star::beans::XPropertyState</code></li> +* <li> <code>com::sun::star::form::FormControlModel</code></li> +* <li> <code>com::sun::star::container::XIndexReplace</code></li> +* <li> <code>com::sun::star::container::XNamed</code></li> +* <li> <code>com::sun::star::container::XIndexAccess</code></li> +* <li> <code>com::sun::star::container::XNameContainer</code></li> +* <li> <code>com::sun::star::form::XGridColumnFactory</code></li> +* <li> <code>com::sun::star::lang::XComponent</code></li> +* <li> <code>com::sun::star::container::XNameAccess</code></li> +* <li> <code>com::sun::star::beans::XPropertyAccess</code></li> +* <li> <code>com::sun::star::beans::XPropertyContainer</code></li> +* <li> <code>com::sun::star::beans::XPropertySet</code></li> +* <li> <code>com::sun::star::container::XIndexContainer</code></li> +* <li> <code>com::sun::star::container::XChild</code></li> +* <li> <code>com::sun::star::container::XContainer</code></li> +* </ul> <p> +* This object test <b> is NOT </b> designed to be run in several +* threads concurently. +* +* @see com.sun.star.io.XPersistObject +* @see com.sun.star.container.XNameReplace +* @see com.sun.star.form.XReset +* @see com.sun.star.script.XEventAttacherManager +* @see com.sun.star.form.FormComponent +* @see com.sun.star.beans.XFastPropertySet +* @see com.sun.star.beans.XMultiPropertySet +* @see com.sun.star.container.XElementAccess +* @see com.sun.star.form.component.GridControl +* @see com.sun.star.view.XSelectionSupplier +* @see com.sun.star.container.XEnumerationAccess +* @see com.sun.star.beans.XPropertyState +* @see com.sun.star.form.FormControlModel +* @see com.sun.star.container.XIndexReplace +* @see com.sun.star.container.XNamed +* @see com.sun.star.container.XIndexAccess +* @see com.sun.star.container.XNameContainer +* @see com.sun.star.form.XGridColumnFactory +* @see com.sun.star.lang.XComponent +* @see com.sun.star.container.XNameAccess +* @see com.sun.star.beans.XPropertyAccess +* @see com.sun.star.beans.XPropertyContainer +* @see com.sun.star.beans.XPropertySet +* @see com.sun.star.container.XIndexContainer +* @see com.sun.star.container.XChild +* @see com.sun.star.container.XContainer +* @see ifc.io._XPersistObject +* @see ifc.container._XNameReplace +* @see ifc.form._XReset +* @see ifc.script._XEventAttacherManager +* @see ifc.form._FormComponent +* @see ifc.beans._XFastPropertySet +* @see ifc.beans._XMultiPropertySet +* @see ifc.container._XElementAccess +* @see ifc.form.component._GridControl +* @see ifc.view._XSelectionSupplier +* @see ifc.container._XEnumerationAccess +* @see ifc.beans._XPropertyState +* @see ifc.form._FormControlModel +* @see ifc.container._XIndexReplace +* @see ifc.container._XNamed +* @see ifc.container._XIndexAccess +* @see ifc.container._XNameContainer +* @see ifc.form._XGridColumnFactory +* @see ifc.lang._XComponent +* @see ifc.container._XNameAccess +* @see ifc.beans._XPropertySet +* @see ifc.container._XIndexContainer +* @see ifc.container._XChild +* @see ifc.container._XContainer +*/ + +public class OGridControlModel extends GenericModelTest { + + /** + * Set some member variable of the super class <CODE>GenericModelTest</CODE>: + * <pre> + * super.m_kindOfControl="CommandButton"; + * super.m_ObjectName = "com.sun.star.form.component.CommandButton"; + * super.m_LCShape_Type = "CommandButton"; + * </pre> + * Then <CODE>super.initialize()</CODE> was called. + * @param tParam the test parameter + * @param log the log writer + */ + + protected void initialize(TestParameters tParam, PrintWriter log) { + + super.initialize(tParam, log); + + super.m_kindOfControl="GridControl"; + + super.m_ObjectName = "stardiv.one.form.component.Grid"; + + super.m_LCShape_Type = "GridControl"; + + } + /** + * calls <CODE>cleanup()</CODE> from it's super class + * @param tParam the test parameter + * @param log the log writer + */ + protected void cleanup(TestParameters tParam, PrintWriter log) { + super.cleanup(tParam, log); + } + + + /** + * calls <CODE>createTestEnvironment()</CODE> from it's super class + * @param Param the test parameter + * @param log the log writer + * @return lib.TestEnvironment + */ + protected synchronized TestEnvironment createTestEnvironment(TestParameters Param, + PrintWriter log) { + TestEnvironment tEnv = super.createTestEnvironment(Param, log); + + XInterface oObj = tEnv.getTestObject(); + + XPropertySet aControl = null; + XPropertySet aControl2 = null; + XPropertySet aControl3 = null; + XPropertySet aControl4 = null; + XPropertySet aControl5 = null; + + try { + XGridColumnFactory columns = (XGridColumnFactory) UnoRuntime.queryInterface( + XGridColumnFactory.class, oObj); + aControl = columns.createColumn("TextField"); + aControl2 = columns.createColumn("DateField"); + aControl3 = columns.createColumn("TextField"); + aControl4 = columns.createColumn("TextField"); + aControl5 = columns.createColumn("TextField"); + } catch (com.sun.star.lang.IllegalArgumentException e) { + // Some exception occures.FAILED + log.println("!!! Couldn't create instance : " + e); + throw new StatusException("Can't create column instances.", e); + } + + XNameContainer aContainer = (XNameContainer) UnoRuntime.queryInterface( + XNameContainer.class, oObj); + + try { + aContainer.insertByName("First", aControl); + aContainer.insertByName("Second", aControl2); + } catch (com.sun.star.lang.WrappedTargetException e) { + log.println("!!! Could't insert column Instance"); + e.printStackTrace(log); + throw new StatusException("Can't insert columns", e); + } catch (com.sun.star.lang.IllegalArgumentException e) { + log.println("!!! Could't insert column Instance"); + e.printStackTrace(log); + throw new StatusException("Can't insert columns", e); + } catch (com.sun.star.container.ElementExistException e) { + log.println("!!! Could't insert column Instance"); + e.printStackTrace(log); + throw new StatusException("Can't insert columns", e); + } + + //Relations for XSelectionSupplier + tEnv.addObjRelation("Selections", new Object[] { aControl, aControl2 }); + + // adding relation for XNameContainer + tEnv.addObjRelation("XNameContainer.AllowDuplicateNames", new Object()); + + + // adding relation for XContainer + tEnv.addObjRelation("INSTANCE", aControl3); + tEnv.addObjRelation("INSTANCE1", aControl4); + tEnv.addObjRelation("INSTANCE2", aControl5); + + + tEnv.addObjRelation("Comparer", + new Comparator() { + public int compare(Object o1, Object o2) { + XNamed named1 = (XNamed) UnoRuntime.queryInterface( + XNamed.class, o1); + XNamed named2 = (XNamed) UnoRuntime.queryInterface( + XNamed.class, o2); + + if (named1.getName().equals(named2.getName())) { + return 0; + } + + return -1; + } + + public boolean equals(Object obj) { + return compare(this, obj) == 0; + } + }); + + +// HashSet exclude = new HashSet(); +// +// exclude.add("FormatKey"); +// +// tEnv.addObjRelation("XUpdateBroadcaster.Checker", +// new Checker(m_XFormLoader, m_XPS, m_XCtrl, m_ChangePropertyName, m_ChangePropertyValue)); + return tEnv; + } + +} // finish class OButtonModelold + + +class OGridControlModelold extends TestCase { + XComponent xDrawDoc = null; + + /** + * Creates Drawing document. + */ + protected void initialize(TestParameters tParam, PrintWriter log) { + SOfficeFactory SOF = SOfficeFactory.getFactory(((XMultiServiceFactory) tParam.getMSF())); + + log.println("creating a draw document"); + + try { + xDrawDoc = SOF.createDrawDoc(null); + } catch (com.sun.star.uno.Exception e) { + throw new StatusException("Can't create Draw document", e); + } + } + + /** + * Disposes drawing document. + */ + protected void cleanup(TestParameters tParam, PrintWriter log) { + log.println(" disposing xDrawDoc "); + + try { + XCloseable closer = (XCloseable) UnoRuntime.queryInterface( + XCloseable.class, xDrawDoc); + 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"); + } + } + + /** + * <code>GridControl</code> component created and added to the draw + * page. Then two columns are created and added to the grid. + * Object relations created : + * <ul> + * <li> <code>'INSTANCE1' ... 'INSTANCEN'</code> for + * <code>XNameReplace, XNameContainer, XIndexReplace, + * XIndexContainer </code> : objects to be inserted + * or replaced with in interface tests. Number of relations + * depends on number of interface test threads. For each + * thread there must be an individual element. </li> + * <li> <code>'XNameContainer.AllowDuplicateNames'</code> : + * if this relation exists then container elements can have duplicate + * names. <code>GridControl</code> can have.</li> + * <li> <code>'OBJNAME'</code> for + * {@link ifc.io._XPersistObject} : name of service which is + * represented by this object. </li> + * <li> <code>'INSTANCE'</code> for + * {@link ifc.container._XContainer} : a column instance. </li> + * </ul> + */ + protected synchronized TestEnvironment createTestEnvironment(TestParameters Param, + PrintWriter log) { + XInterface oObj = null; + XInterface oInstance = null; + XPropertySet aControl = null; + XPropertySet aControl2 = null; + XPropertySet aControl3 = null; + XPropertySet aControl4 = null; + XPropertySet aControl5 = null; + XGridColumnFactory columns = null; + + + // creation of testobject here + // first we write what we are intend to do to log file + log.println("creating a test environment"); + + //get GridControlModel + String objName = "Grid"; + XControlShape shape = FormTools.insertControlShape(xDrawDoc, 5000, + 7000, 2000, 2000, + "GridControl"); + oObj = shape.getControl(); + + log.println("creating a new environment for drawpage object"); + + TestEnvironment tEnv = new TestEnvironment(oObj); + + try { + columns = (XGridColumnFactory) UnoRuntime.queryInterface( + XGridColumnFactory.class, oObj); + aControl = columns.createColumn("TextField"); + aControl2 = columns.createColumn("DateField"); + aControl3 = columns.createColumn("TextField"); + aControl4 = columns.createColumn("TextField"); + aControl5 = columns.createColumn("TextField"); + } catch (com.sun.star.lang.IllegalArgumentException e) { + // Some exception occures.FAILED + log.println("!!! Couldn't create instance : " + e); + throw new StatusException("Can't create column instances.", e); + } + + XNameContainer aContainer = (XNameContainer) UnoRuntime.queryInterface( + XNameContainer.class, oObj); + + try { + aContainer.insertByName("First", aControl); + aContainer.insertByName("Second", aControl2); + } catch (com.sun.star.lang.WrappedTargetException e) { + log.println("!!! Could't insert column Instance"); + e.printStackTrace(log); + throw new StatusException("Can't insert columns", e); + } catch (com.sun.star.lang.IllegalArgumentException e) { + log.println("!!! Could't insert column Instance"); + e.printStackTrace(log); + throw new StatusException("Can't insert columns", e); + } catch (com.sun.star.container.ElementExistException e) { + log.println("!!! Could't insert column Instance"); + e.printStackTrace(log); + throw new StatusException("Can't insert columns", e); + } + + //Relations for XSelectionSupplier + tEnv.addObjRelation("Selections", new Object[] { aControl, aControl2 }); + + // COMPARER + + int THRCNT = 1; + String count = (String)Param.get("THRCNT"); + if (count != null) + THRCNT = Integer.parseInt(count); + + + // INSTANCEn : _XNameContainer; _XNameReplace + log.println("adding INSTANCEn as obj relation to environment"); + + try { + for (int n = 1; n < (3 * THRCNT + 1); n++) { + log.println("adding INSTANCE" + n + + " as obj relation to environment"); + oInstance = columns.createColumn("TextField"); + tEnv.addObjRelation("INSTANCE" + n, oInstance); + } + } catch (com.sun.star.lang.IllegalArgumentException e) { + e.printStackTrace(log); + throw new StatusException("Can't create 'INSTANCEn' relations", e); + } + + + // adding relation for XNameContainer + tEnv.addObjRelation("XNameContainer.AllowDuplicateNames", new Object()); + + // OK tEnv.addObjRelation("OBJNAME", "stardiv.one.form.component." + objName); + + + // adding relation for XContainer + tEnv.addObjRelation("INSTANCE", aControl3); + tEnv.addObjRelation("INSTANCE2", aControl4); + + + //adding ObjRelation for XPersistObject + // OK tEnv.addObjRelation("PSEUDOPERSISTENT", new Boolean(true)); // OK + + return tEnv; + } // finish method getTestEnvironment +} // finish class OGridControlModel diff --git a/qadevOOo/tests/java/mod/_forms/OGroupBoxControl.java b/qadevOOo/tests/java/mod/_forms/OGroupBoxControl.java new file mode 100644 index 000000000000..7b4a6adea8be --- /dev/null +++ b/qadevOOo/tests/java/mod/_forms/OGroupBoxControl.java @@ -0,0 +1,214 @@ +/************************************************************************* + * + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * Copyright 2000, 2010 Oracle and/or its affiliates. + * + * OpenOffice.org - a multi-platform office productivity suite + * + * This file is part of OpenOffice.org. + * + * OpenOffice.org is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License version 3 + * only, as published by the Free Software Foundation. + * + * OpenOffice.org is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License version 3 for more details + * (a copy is included in the LICENSE file that accompanied this code). + * + * You should have received a copy of the GNU Lesser General Public License + * version 3 along with OpenOffice.org. If not, see + * <http://www.openoffice.org/license.html> + * for a copy of the LGPLv3 License. + * + ************************************************************************/ +package mod._forms; + +import java.io.PrintWriter; + +import lib.StatusException; +import lib.TestCase; +import lib.TestEnvironment; +import lib.TestParameters; +import util.FormTools; +import util.SOfficeFactory; +import util.WriterTools; +import util.utils; + +import com.sun.star.awt.XControlModel; +import com.sun.star.awt.XDevice; +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.drawing.XControlShape; +import com.sun.star.drawing.XShape; +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.XCloseable; +import com.sun.star.view.XControlAccess; + + +/** + * Test for object which is represented by default controller + * of the <code>com.sun.star.form.component.GroupBox</code> + * component. <p> + * + * Object implements the following interfaces : + * <ul> + * <li> <code>com::sun::star::lang::XComponent</code></li> + * <li> <code>com::sun::star::awt::XWindow</code></li> + * <li> <code>com::sun::star::awt::XControl</code></li> + * <li> <code>com::sun::star::awt::XView</code></li> + * </ul> <p> + * This object test <b> is NOT </b> designed to be run in several + * threads concurently. + * + * @see com.sun.star.lang.XComponent + * @see com.sun.star.awt.XWindow + * @see com.sun.star.awt.XControl + * @see com.sun.star.awt.XView + * @see ifc.lang._XComponent + * @see ifc.awt._XWindow + * @see ifc.awt._XControl + * @see ifc.awt._XView + */ +public class OGroupBoxControl extends TestCase { + XTextDocument xTextDoc; + + /** + * Creates a new text document. + */ + protected void initialize(TestParameters Param, PrintWriter log) { + SOfficeFactory SOF = SOfficeFactory.getFactory(((XMultiServiceFactory) Param.getMSF())); + + try { + log.println("creating a textdocument"); + xTextDoc = SOF.createTextDoc(null); + } catch (com.sun.star.uno.Exception e) { + // Some exception occures.FAILED + e.printStackTrace(log); + throw new StatusException("Couldn't create document", e); + } + } + + /** + * Disposes the text document created before + */ + protected void cleanup(TestParameters tParam, PrintWriter log) { + log.println(" disposing xTextDoc "); + + try { + XCloseable closer = (XCloseable) 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"); + } + } + + /** + * Creates two components and inserts them to the form of + * text document. One component + * (<code>com.sun.star.form.component.GroupBox</code>) is created + * for testing, another to be passed as relation. Using a controller + * of the text document the controller of the first component is + * obtained and returned in environment as a test object. <p> + * + * Object relations created : + * <ul> + * <li> <code>'GRAPHICS'</code> for + * {@link ifc.awt._XView} : a graphics component + * created using screen device of the window peer of + * the controller tested. </li> + * <li> <code>'CONTEXT'</code> for + * {@link ifc.awt._XControl} : the text document + * where the component is inserted. </li> + * <li> <code>'WINPEER'</code> for + * {@link ifc.awt._XControl} : Window peer of the + * controller tested. </li> + * <li> <code>'TOOLKIT'</code> for + * {@link ifc.awt._XControl} : toolkit of the component.</li> + * <li> <code>'MODEL'</code> for + * {@link ifc.awt._XControl} : the model of the controller.</li> + * <li> <code>'XWindow.AnotherWindow'</code> for + * {@link ifc.awt._XWindow} : the controller of another + * component. </li> + * </ul> + */ + protected TestEnvironment createTestEnvironment(TestParameters Param, + PrintWriter log) { + XInterface oObj = null; + Object anotherCtrl = null; + XWindowPeer the_win = null; + XToolkit the_kit = null; + XDevice aDevice = null; + XGraphics aGraphic = null; + + //Insert a ControlShape and get the ControlModel + XControlShape aShape = FormTools.createControlShape(xTextDoc, 5000, + 7000, 2000, 2000, + "GroupBox"); + + WriterTools.getDrawPage(xTextDoc).add((XShape) aShape); + + XControlModel the_Model = aShape.getControl(); + + XControlShape aShape2 = FormTools.createControlShape(xTextDoc, 3000, + 4500, 5000, 10000, + "TextField"); + + WriterTools.getDrawPage(xTextDoc).add((XShape) aShape2); + + XControlModel the_Model2 = aShape2.getControl(); + + //Try to query XControlAccess + XControlAccess the_access = (XControlAccess) UnoRuntime.queryInterface( + XControlAccess.class, + xTextDoc.getCurrentController()); + + //now get the OGroupBoxControl + try { + oObj = the_access.getControl(the_Model); + anotherCtrl = the_access.getControl(the_Model2); + the_win = the_access.getControl(the_Model).getPeer(); + the_kit = the_win.getToolkit(); + aDevice = the_kit.createScreenCompatibleDevice(200, 200); + aGraphic = aDevice.createGraphics(); + } catch (com.sun.star.container.NoSuchElementException e) { + log.println("Couldn't get OGroupBoxControl"); + e.printStackTrace(log); + throw new StatusException("Couldn't get OGroupBoxControl", e); + } + + log.println("creating a new environment for OGroupBoxControl object"); + + TestEnvironment tEnv = new TestEnvironment(oObj); + + + //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); + log.println("ImplementationName: " + utils.getImplName(oObj)); + + + // Adding relation for XWindow + tEnv.addObjRelation("XWindow.AnotherWindow", + UnoRuntime.queryInterface(XWindow.class, + anotherCtrl)); + + return tEnv; + } // finish method getTestEnvironment +} // finish class OGroupBoxControl diff --git a/qadevOOo/tests/java/mod/_forms/OGroupBoxModel.java b/qadevOOo/tests/java/mod/_forms/OGroupBoxModel.java new file mode 100644 index 000000000000..8f8f227457c6 --- /dev/null +++ b/qadevOOo/tests/java/mod/_forms/OGroupBoxModel.java @@ -0,0 +1,128 @@ +/************************************************************************* + * + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * Copyright 2000, 2010 Oracle and/or its affiliates. + * + * OpenOffice.org - a multi-platform office productivity suite + * + * This file is part of OpenOffice.org. + * + * OpenOffice.org is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License version 3 + * only, as published by the Free Software Foundation. + * + * OpenOffice.org is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License version 3 for more details + * (a copy is included in the LICENSE file that accompanied this code). + * + * You should have received a copy of the GNU Lesser General Public License + * version 3 along with OpenOffice.org. If not, see + * <http://www.openoffice.org/license.html> + * for a copy of the LGPLv3 License. + * + ************************************************************************/ +package mod._forms; + +import java.io.PrintWriter; + +import lib.TestEnvironment; +import lib.TestParameters; + + +/** + * Test for object which is represented by service + * <code>com.sun.star.form.component.GroupBox</code>. <p> + * Object implements the following interfaces : + * <ul> + * <li> <code>com::sun::star::awt::UnoControlGroupBoxModel</code></li> + * <li> <code>com::sun::star::io::XPersistObject</code></li> + * <li> <code>com::sun::star::container::XChild</code></li> + * <li> <code>com::sun::star::form::FormControlModel</code></li> + * <li> <code>com::sun::star::form::FormComponent</code></li> + * <li> <code>com::sun::star::beans::XPropertyAccess</code></li> + * <li> <code>com::sun::star::beans::XPropertyContainer</code></li> + * <li> <code>com::sun::star::beans::XPropertySet</code></li> + * <li> <code>com::sun::star::beans::XFastPropertySet</code></li> + * <li> <code>com::sun::star::beans::XPropertyState</code></li> + * <li> <code>com::sun::star::container::XNamed</code></li> + * <li> <code>com::sun::star::beans::XMultiPropertySet</code></li> + * <li> <code>com::sun::star::lang::XComponent</code></li> + * </ul> + * This object test <b> is NOT </b> designed to be run in several + * threads concurently. + * @see com.sun.star.awt.UnoControlGroupBoxModel + * @see com.sun.star.io.XPersistObject + * @see com.sun.star.container.XChild + * @see com.sun.star.form.FormControlModel + * @see com.sun.star.form.FormComponent + * @see com.sun.star.beans.XPropertyAccess + * @see com.sun.star.beans.XPropertyContainer + * @see com.sun.star.beans.XPropertySet + * @see com.sun.star.beans.XFastPropertySet + * @see com.sun.star.beans.XPropertyState + * @see com.sun.star.container.XNamed + * @see com.sun.star.beans.XMultiPropertySet + * @see com.sun.star.lang.XComponent + * @see ifc.awt._UnoControlGroupBoxModel + * @see ifc.io._XPersistObject + * @see ifc.container._XChild + * @see ifc.form._FormControlModel + * @see ifc.form._FormComponent + * @see ifc.beans._XPropertySet + * @see ifc.beans._XFastPropertySet + * @see ifc.beans._XPropertyState + * @see ifc.container._XNamed + * @see ifc.beans._XMultiPropertySet + * @see ifc.lang._XComponent + */ +public class OGroupBoxModel extends GenericModelTest { + + /** + * Set some member variable of the super class <CODE>GenericModelTest</CODE>: + * <pre> + * <super.m_ChangePropertyName</CODE> = "Text"; + * super.m_kindOfControl</CODE>="GroupBox"; + * super.m_ObjectName</CODE> = "GroupBox"; + * </pre> + * Then <CODE>super.initialize()</CODE> was called. + * @param tParam the test parameter + * @param log the log writer + */ + + protected void initialize(TestParameters tParam, PrintWriter log) { + + super.initialize(tParam, log); + + super.m_kindOfControl="GroupBox"; + + super.m_ObjectName = "stardiv.one.form.component.GroupBox"; + + super.m_LCShape_Type = "FixedText"; + + super.m_ChangePropertyName = "Text"; + } + /** + * calls <CODE>cleanup()</CODE> from it's super class + * @param tParam the test parameter + * @param log the log writer + */ + protected void cleanup(TestParameters tParam, PrintWriter log) { + super.cleanup(tParam, log); + } + + + /** + * calls <CODE>createTestEnvironment()</CODE> from it's super class + * @param Param the test parameter + * @param log the log writer + * @return lib.TestEnvironment + */ + protected synchronized TestEnvironment createTestEnvironment(TestParameters Param, + PrintWriter log) { + return super.createTestEnvironment(Param, log); + } + +} // finish class OGroupBoxModel diff --git a/qadevOOo/tests/java/mod/_forms/OHiddenModel.java b/qadevOOo/tests/java/mod/_forms/OHiddenModel.java new file mode 100644 index 000000000000..de2f93bc494c --- /dev/null +++ b/qadevOOo/tests/java/mod/_forms/OHiddenModel.java @@ -0,0 +1,203 @@ +/************************************************************************* + * + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * Copyright 2000, 2010 Oracle and/or its affiliates. + * + * OpenOffice.org - a multi-platform office productivity suite + * + * This file is part of OpenOffice.org. + * + * OpenOffice.org is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License version 3 + * only, as published by the Free Software Foundation. + * + * OpenOffice.org is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License version 3 for more details + * (a copy is included in the LICENSE file that accompanied this code). + * + * You should have received a copy of the GNU Lesser General Public License + * version 3 along with OpenOffice.org. If not, see + * <http://www.openoffice.org/license.html> + * for a copy of the LGPLv3 License. + * + ************************************************************************/ +package mod._forms; + +import com.sun.star.beans.PropertyValue; +import java.io.PrintWriter; + +import lib.StatusException; +import lib.TestCase; +import lib.TestEnvironment; +import lib.TestParameters; +import util.DrawTools; +import util.FormTools; +import util.SOfficeFactory; + +import com.sun.star.container.XNameContainer; +import com.sun.star.drawing.XDrawPage; +import com.sun.star.lang.XComponent; +import com.sun.star.lang.XMultiServiceFactory; +import com.sun.star.uno.AnyConverter; +import com.sun.star.uno.Type; +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.form.component.HiddenControl</code>. <p> + * Object implements the following interfaces : + * <ul> + * <li> <code>com::sun::star::io::XPersistObject</code></li> + * <li> <code>com::sun::star::container::XChild</code></li> + * <li> <code>com::sun::star::form::FormControlModel</code></li> + * <li> <code>com::sun::star::form::component::HiddenControl</code></li> + * <li> <code>com::sun::star::form::FormComponent</code></li> + * <li> <code>com::sun::star::beans::XPropertyAccess</code></li> +* <li> <code>com::sun::star::beans::XPropertyContainer</code></li> +* <li> <code>com::sun::star::beans::XPropertySet</code></li> + * <li> <code>com::sun::star::beans::XFastPropertySet</code></li> + * <li> <code>com::sun::star::beans::XPropertyState</code></li> + * <li> <code>com::sun::star::container::XNamed</code></li> + * <li> <code>com::sun::star::beans::XMultiPropertySet</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 concurently. + * @see com.sun.star.io.XPersistObject + * @see com.sun.star.container.XChild + * @see com.sun.star.form.FormControlModel + * @see com.sun.star.form.component.HiddenControl + * @see com.sun.star.form.FormComponent + * @see com.sun.star.beans.XPropertyAccess +* @see com.sun.star.beans.XPropertyContainer +* @see com.sun.star.beans.XPropertySet + * @see com.sun.star.beans.XFastPropertySet + * @see com.sun.star.beans.XPropertyState + * @see com.sun.star.container.XNamed + * @see com.sun.star.beans.XMultiPropertySet + * @see com.sun.star.lang.XComponent + * @see ifc.io._XPersistObject + * @see ifc.container._XChild + * @see ifc.form._FormControlModel + * @see ifc.form.component._HiddenControl + * @see ifc.form._FormComponent + * @see ifc.beans._XPropertySet + * @see ifc.beans._XFastPropertySet + * @see ifc.beans._XPropertyState + * @see ifc.container._XNamed + * @see ifc.beans._XMultiPropertySet + * @see ifc.lang._XComponent + */ +public class OHiddenModel extends TestCase { + XComponent xDrawDoc; + + /** + * Creates Drawing document. + */ + protected void initialize(TestParameters tParam, PrintWriter log) { + SOfficeFactory SOF = SOfficeFactory.getFactory(((XMultiServiceFactory) tParam.getMSF())); + + try { + log.println("creating a draw document"); + xDrawDoc = SOF.createDrawDoc(null); + } catch (com.sun.star.uno.Exception e) { + // Some exception occures.FAILED + e.printStackTrace(log); + throw new StatusException("Couldn't create document", e); + } + } + + /** + * Disposes drawing document. + */ + protected void cleanup(TestParameters tParam, PrintWriter log) { + log.println(" disposing xDrawDoc "); + + try { + XCloseable closer = (XCloseable) UnoRuntime.queryInterface( + XCloseable.class, xDrawDoc); + 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"); + } + } + + /** + * Creates hidden component, then adds Form into draw page, + * and inserts the component into Form components' collection. + * Object relations created : + * <ul> + * <li> <code>'OBJNAME'</code> for + * {@link ifc.io._XPersistObject} : name of service which is + * represented by this object. </li> + * </ul> + */ + protected synchronized TestEnvironment createTestEnvironment(TestParameters Param, + PrintWriter log) { + XInterface oObj = null; + + + // creation of testobject here + // first we write what we are intend to do to log file + log.println("creating a test environment"); + + // get a soffice factory object + SOfficeFactory SOF = SOfficeFactory.getFactory(((XMultiServiceFactory) Param.getMSF())); + String objName = "HiddenControl"; + XInterface ctrl = SOF.createControl(xDrawDoc, objName); + + try { + XDrawPage oDP = DrawTools.getDrawPage(xDrawDoc, 0); + + XNameContainer nc = FormTools.getForms(oDP); + FormTools.insertForm(xDrawDoc, nc, "OHiddenModelForm"); + + Object frm = nc.getByName("OHiddenModelForm"); + + XNameContainer frmNC = (XNameContainer) UnoRuntime.queryInterface( + XNameContainer.class, frm); + + frmNC.insertByName("OHiddenModel", ctrl); + oObj = (XInterface) AnyConverter.toObject( + new Type(XInterface.class), + frmNC.getByName("OHiddenModel")); + } catch (com.sun.star.lang.WrappedTargetException e) { + e.printStackTrace(log); + throw new StatusException("Can't create and add control", e); + } catch (com.sun.star.lang.IllegalArgumentException e) { + e.printStackTrace(log); + throw new StatusException("Can't create and add control", e); + } catch (com.sun.star.container.NoSuchElementException e) { + e.printStackTrace(log); + throw new StatusException("Can't create and add control", e); + } catch (com.sun.star.container.ElementExistException e) { + e.printStackTrace(log); + throw new StatusException("Can't create and add control", e); + } + + log.println("creating a new environment for drawpage object"); + + TestEnvironment tEnv = new TestEnvironment(oObj); + + util.dbg.getSuppServices(oObj); + + log.println("adding DrawDocument as obj relation to environment"); + tEnv.addObjRelation("OBJNAME", "stardiv.one.form.component.Hidden"); + + PropertyValue prop = new PropertyValue(); + prop.Name = "Name"; + prop.Value = "new Text since XPropertyAccess"; + tEnv.addObjRelation("XPropertyAccess.propertyToChange", prop); + tEnv.addObjRelation("XPropertyContainer.propertyNotRemovable", "Name"); + + return tEnv; + } // finish method getTestEnvironment +} // finish class OHiddenModel diff --git a/qadevOOo/tests/java/mod/_forms/OImageButtonControl.java b/qadevOOo/tests/java/mod/_forms/OImageButtonControl.java new file mode 100644 index 000000000000..8d8744ed7377 --- /dev/null +++ b/qadevOOo/tests/java/mod/_forms/OImageButtonControl.java @@ -0,0 +1,219 @@ +/************************************************************************* + * + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * Copyright 2000, 2010 Oracle and/or its affiliates. + * + * OpenOffice.org - a multi-platform office productivity suite + * + * This file is part of OpenOffice.org. + * + * OpenOffice.org is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License version 3 + * only, as published by the Free Software Foundation. + * + * OpenOffice.org is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License version 3 for more details + * (a copy is included in the LICENSE file that accompanied this code). + * + * You should have received a copy of the GNU Lesser General Public License + * version 3 along with OpenOffice.org. If not, see + * <http://www.openoffice.org/license.html> + * for a copy of the LGPLv3 License. + * + ************************************************************************/ +package mod._forms; + +import java.io.PrintWriter; + +import lib.StatusException; +import lib.TestCase; +import lib.TestEnvironment; +import lib.TestParameters; +import util.FormTools; +import util.SOfficeFactory; +import util.WriterTools; + +import com.sun.star.awt.XControlModel; +import com.sun.star.awt.XDevice; +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.drawing.XControlShape; +import com.sun.star.drawing.XShape; +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.XCloseable; +import com.sun.star.view.XControlAccess; + + +/** + * Test for object which is represented by default controller + * of the <code>com.sun.star.form.component.ImageButton</code> + * component. <p> + * + * Object implements the following interfaces : + * <ul> + * <li> <code>com::sun::star::lang::XComponent</code></li> + * <li> <code>com::sun::star::awt::XWindow</code></li> + * <li> <code>com::sun::star::form::XApproveActionBroadcaster</code></li> + * <li> <code>com::sun::star::awt::XControl</code></li> + * <li> <code>com::sun::star::awt::XLayoutConstrains</code></li> + * <li> <code>com::sun::star::awt::XView</code></li> + * </ul> <p> + * This object test <b> is NOT </b> designed to be run in several + * threads concurently. + * + * @see com.sun.star.lang.XComponent + * @see com.sun.star.awt.XWindow + * @see com.sun.star.form.XApproveActionBroadcaster + * @see com.sun.star.awt.XControl + * @see com.sun.star.awt.XLayoutConstrains + * @see com.sun.star.awt.XView + * @see ifc.lang._XComponent + * @see ifc.awt._XWindow + * @see ifc.form._XApproveActionBroadcaster + * @see ifc.awt._XControl + * @see ifc.awt._XLayoutConstrains + * @see ifc.awt._XView + */ +public class OImageButtonControl extends TestCase { + XTextDocument xTextDoc; + + /** + * Creates a new text document. + */ + protected void initialize(TestParameters Param, PrintWriter log) { + SOfficeFactory SOF = SOfficeFactory.getFactory(((XMultiServiceFactory) Param.getMSF())); + + try { + log.println("creating a textdocument"); + xTextDoc = SOF.createTextDoc(null); + } catch (com.sun.star.uno.Exception e) { + // Some exception occures.FAILED + e.printStackTrace(log); + throw new StatusException("Couldn't create document", e); + } + } + + /** + * Disposes the text document created before + */ + protected void cleanup(TestParameters tParam, PrintWriter log) { + log.println(" disposing xTextDoc "); + + try { + XCloseable closer = (XCloseable) 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"); + } + } + + /** + * Creates two components and inserts them to the form of + * text document. One component + * (<code>com.sun.star.form.component.ImageButton</code>) is created + * for testing, another to be passed as relation. Using a controller + * of the text document the controller of the first component is + * obtained and returned in environment as a test object. <p> + * + * Object relations created : + * <ul> + * <li> <code>'GRAPHICS'</code> for + * {@link ifc.awt._XView} : a graphics component + * created using screen device of the window peer of + * the controller tested. </li> + * <li> <code>'CONTEXT'</code> for + * {@link ifc.awt._XControl} : the text document + * where the component is inserted. </li> + * <li> <code>'WINPEER'</code> for + * {@link ifc.awt._XControl} : Window peer of the + * controller tested. </li> + * <li> <code>'TOOLKIT'</code> for + * {@link ifc.awt._XControl} : toolkit of the component.</li> + * <li> <code>'MODEL'</code> for + * {@link ifc.awt._XControl} : the model of the controller.</li> + * <li> <code>'XWindow.AnotherWindow'</code> for + * {@link ifc.awt._XWindow} : the controller of another + * component. </li> + * </ul> + */ + protected TestEnvironment createTestEnvironment(TestParameters Param, + PrintWriter log) { + XInterface oObj = null; + Object anotherCtrl = null; + XWindowPeer the_win = null; + XToolkit the_kit = null; + XDevice aDevice = null; + XGraphics aGraphic = null; + + //Insert a ControlShape and get the ControlModel + XControlShape aShape = FormTools.createControlShape(xTextDoc, 3000, + 4500, 15000, 10000, + "ImageButton"); + + WriterTools.getDrawPage(xTextDoc).add((XShape) aShape); + + XControlModel the_Model = aShape.getControl(); + + XControlShape aShape2 = FormTools.createControlShape(xTextDoc, 3000, + 4500, 5000, 10000, + "TextField"); + + WriterTools.getDrawPage(xTextDoc).add((XShape) aShape2); + + XControlModel the_Model2 = aShape2.getControl(); + + //Try to query XControlAccess + XControlAccess the_access = (XControlAccess) UnoRuntime.queryInterface( + XControlAccess.class, + xTextDoc.getCurrentController()); + + //now get the OImageButtonControl + try { + oObj = the_access.getControl(the_Model); + anotherCtrl = the_access.getControl(the_Model2); + the_win = the_access.getControl(the_Model).getPeer(); + the_kit = the_win.getToolkit(); + aDevice = the_kit.createScreenCompatibleDevice(200, 200); + aGraphic = aDevice.createGraphics(); + } catch (com.sun.star.container.NoSuchElementException e) { + log.println("Couldn't get OImageButtonControl"); + e.printStackTrace(log); + throw new StatusException("Couldn't get OImageButtonControl", e); + } + + log.println( + "creating a new environment for OImageButtonControl object"); + + TestEnvironment tEnv = new TestEnvironment(oObj); + + + //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 + XWindow forObjRel = (XWindow) UnoRuntime.queryInterface(XWindow.class, + anotherCtrl); + + tEnv.addObjRelation("XWindow.AnotherWindow", forObjRel); + + return tEnv; + } // finish method getTestEnvironment +} // finish class OImageButtonControl diff --git a/qadevOOo/tests/java/mod/_forms/OImageButtonModel.java b/qadevOOo/tests/java/mod/_forms/OImageButtonModel.java new file mode 100644 index 000000000000..9920e26feea9 --- /dev/null +++ b/qadevOOo/tests/java/mod/_forms/OImageButtonModel.java @@ -0,0 +1,132 @@ +/************************************************************************* + * + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * Copyright 2000, 2010 Oracle and/or its affiliates. + * + * OpenOffice.org - a multi-platform office productivity suite + * + * This file is part of OpenOffice.org. + * + * OpenOffice.org is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License version 3 + * only, as published by the Free Software Foundation. + * + * OpenOffice.org is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License version 3 for more details + * (a copy is included in the LICENSE file that accompanied this code). + * + * You should have received a copy of the GNU Lesser General Public License + * version 3 along with OpenOffice.org. If not, see + * <http://www.openoffice.org/license.html> + * for a copy of the LGPLv3 License. + * + ************************************************************************/ +package mod._forms; + +import java.io.PrintWriter; +import lib.TestEnvironment; +import lib.TestParameters; + +/** +* Test for object which is represented by service +* <code>com.sun.star.form.component.ImageButton</code>. <p> +* Object implements the following interfaces : +* <ul> +* <li> <code>com::sun::star::io::XPersistObject</code></li> +* <li> <code>com::sun::star::container::XChild</code></li> +* <li> <code>com::sun::star::awt::UnoControlImageControlModel</code></li> +* <li> <code>com::sun::star::form::FormControlModel</code></li> +* <li> <code>com::sun::star::form::FormComponent</code></li> +* <li> <code>com::sun::star::form::XImageProducerSupplier</code></li> +* <li> <code>com::sun::star::beans::XPropertyAccess</code></li> +* <li> <code>com::sun::star::beans::XPropertyContainer</code></li> +* <li> <code>com::sun::star::beans::XPropertySet</code></li> +* <li> <code>com::sun::star::beans::XFastPropertySet</code></li> +* <li> <code>com::sun::star::beans::XPropertyState</code></li> +* <li> <code>com::sun::star::form::component::ImageButton</code></li> +* <li> <code>com::sun::star::container::XNamed</code></li> +* <li> <code>com::sun::star::beans::XMultiPropertySet</code></li> +* <li> <code>com::sun::star::lang::XComponent</code></li> +* </ul> +* This object test <b> is NOT </b> designed to be run in several +* threads concurently. +* @see com.sun.star.io.XPersistObject +* @see com.sun.star.container.XChild +* @see com.sun.star.awt.UnoControlImageControlModel +* @see com.sun.star.form.FormControlModel +* @see com.sun.star.form.FormComponent +* @see com.sun.star.form.XImageProducerSupplier +* @see com.sun.star.beans.XPropertyAccess +* @see com.sun.star.beans.XPropertyContainer +* @see com.sun.star.beans.XPropertySet +* @see com.sun.star.beans.XFastPropertySet +* @see com.sun.star.beans.XPropertyState +* @see com.sun.star.form.component.ImageButton +* @see com.sun.star.container.XNamed +* @see com.sun.star.beans.XMultiPropertySet +* @see com.sun.star.lang.XComponent +* @see ifc.io._XPersistObject +* @see ifc.container._XChild +* @see ifc.awt._UnoControlImageControlModel +* @see ifc.form._FormControlModel +* @see ifc.form._FormComponent +* @see ifc.form._XImageProducerSupplier +* @see ifc.beans._XPropertySet +* @see ifc.beans._XFastPropertySet +* @see ifc.beans._XPropertyState +* @see ifc.form.component._ImageButton +* @see ifc.container._XNamed +* @see ifc.beans._XMultiPropertySet +* @see ifc.lang._XComponent +*/ + +public class OImageButtonModel extends GenericModelTest { + + /** + * Set some member variable of the super class <CODE>GenericModelTest</CODE>: + * <pre> + * super.m_kindOfControl="ImageButton"; + * super.m_ObjectName = "stardiv.one.form.component.ImageButton"; + * super.m_LCShape_Type = "ImageButton"; + * </pre> + * Then <CODE>super.initialize()</CODE> was called. + * @param tParam the test parameter + * @param log the log writer + */ + + protected void initialize(TestParameters tParam, PrintWriter log) { + + super.initialize(tParam, log); + + super.m_kindOfControl="ImageButton"; + + super.m_ObjectName = "stardiv.one.form.component.ImageButton"; + + super.m_LCShape_Type = "ImageButton"; + + } + /** + * calls <CODE>cleanup()</CODE> from it's super class + * @param tParam the test parameter + * @param log the log writer + */ + protected void cleanup(TestParameters tParam, PrintWriter log) { + super.cleanup(tParam, log); + } + + + /** + * calls <CODE>createTestEnvironment()</CODE> from it's super class + * @param Param the test parameter + * @param log the log writer + * @return lib.TestEnvironment + */ + protected synchronized TestEnvironment createTestEnvironment(TestParameters Param, + PrintWriter log) { + return super.createTestEnvironment(Param, log); + } + +} // finish class OImageButtonModel diff --git a/qadevOOo/tests/java/mod/_forms/OImageControlControl.java b/qadevOOo/tests/java/mod/_forms/OImageControlControl.java new file mode 100644 index 000000000000..f8771e086ec2 --- /dev/null +++ b/qadevOOo/tests/java/mod/_forms/OImageControlControl.java @@ -0,0 +1,220 @@ +/************************************************************************* + * + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * Copyright 2000, 2010 Oracle and/or its affiliates. + * + * OpenOffice.org - a multi-platform office productivity suite + * + * This file is part of OpenOffice.org. + * + * OpenOffice.org is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License version 3 + * only, as published by the Free Software Foundation. + * + * OpenOffice.org is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License version 3 for more details + * (a copy is included in the LICENSE file that accompanied this code). + * + * You should have received a copy of the GNU Lesser General Public License + * version 3 along with OpenOffice.org. If not, see + * <http://www.openoffice.org/license.html> + * for a copy of the LGPLv3 License. + * + ************************************************************************/ +package mod._forms; + +import java.io.PrintWriter; + +import lib.StatusException; +import lib.TestCase; +import lib.TestEnvironment; +import lib.TestParameters; +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.XDevice; +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.drawing.XControlShape; +import com.sun.star.drawing.XShape; +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.XCloseable; +import com.sun.star.view.XControlAccess; + + +/** + * Test for object which is represented by default controller + * of the <code>com.sun.star.form.component.DatabaseImageControl</code> + * component. <p> + * + * Object implements the following interfaces : + * <ul> + * <li> <code>com::sun::star::lang::XComponent</code></li> + * <li> <code>com::sun::star::awt::XWindow</code></li> + * <li> <code>com::sun::star::form::XBoundControl</code></li> + * <li> <code>com::sun::star::awt::XControl</code></li> + * <li> <code>com::sun::star::awt::XLayoutConstrains</code></li> + * <li> <code>com::sun::star::awt::XView</code></li> + * </ul> <p> + * This object test <b> is NOT </b> designed to be run in several + * threads concurently. + * + * @see com.sun.star.lang.XComponent + * @see com.sun.star.awt.XWindow + * @see com.sun.star.form.XBoundControl + * @see com.sun.star.awt.XControl + * @see com.sun.star.awt.XLayoutConstrains + * @see com.sun.star.awt.XView + * @see ifc.lang._XComponent + * @see ifc.awt._XWindow + * @see ifc.form._XBoundControl + * @see ifc.awt._XControl + * @see ifc.awt._XLayoutConstrains + * @see ifc.awt._XView + */ +public class OImageControlControl extends TestCase { + XTextDocument xTextDoc; + + /** + * Creates a new text document. + */ + protected void initialize(TestParameters Param, PrintWriter log) { + SOfficeFactory SOF = SOfficeFactory.getFactory(((XMultiServiceFactory) Param.getMSF())); + + try { + log.println("creating a textdocument"); + xTextDoc = SOF.createTextDoc(null); + } catch (com.sun.star.uno.Exception e) { + // Some exception occures.FAILED + e.printStackTrace(log); + throw new StatusException("Couldn't create document", e); + } + } + + /** + * Disposes the text document created before + */ + protected void cleanup(TestParameters tParam, PrintWriter log) { + log.println(" disposing xTextDoc "); + + try { + XCloseable closer = (XCloseable) 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"); + } + } + + /** + * Creates two components and inserts them to the form of + * text document. One component + * (<code>com.sun.star.form.component.DatabaseImageControl</code>) is created + * for testing, another to be passed as relation. Using a controller + * of the text document the controller of the first component is + * obtained and returned in environment as a test object. <p> + * + * Object relations created : + * <ul> + * <li> <code>'GRAPHICS'</code> for + * {@link ifc.awt._XView} : a graphics component + * created using screen device of the window peer of + * the controller tested. </li> + * <li> <code>'CONTEXT'</code> for + * {@link ifc.awt._XControl} : the text document + * where the component is inserted. </li> + * <li> <code>'WINPEER'</code> for + * {@link ifc.awt._XControl} : Window peer of the + * controller tested. </li> + * <li> <code>'TOOLKIT'</code> for + * {@link ifc.awt._XControl} : toolkit of the component.</li> + * <li> <code>'MODEL'</code> for + * {@link ifc.awt._XControl} : the model of the controller.</li> + * <li> <code>'XWindow.AnotherWindow'</code> for + * {@link ifc.awt._XWindow} : the controller of another + * component. </li> + * </ul> + */ + protected TestEnvironment createTestEnvironment(TestParameters Param, + PrintWriter log) { + XInterface oObj = null; + XWindowPeer the_win = null; + XToolkit the_kit = null; + XDevice aDevice = null; + XGraphics aGraphic = null; + XControl aControl = null; + + //Insert a ControlShape and get the ControlModel + XControlShape aShape = FormTools.createControlShapeWithDefaultControl( + xTextDoc, 3000, 4500, 15000, 10000, + "DatabaseImageControl"); + + WriterTools.getDrawPage(xTextDoc).add((XShape) aShape); + + XControlModel the_Model = aShape.getControl(); + + XControlShape aShape2 = FormTools.createControlShape(xTextDoc, 3000, + 4500, 5000, 10000, + "TextField"); + + WriterTools.getDrawPage(xTextDoc).add((XShape) aShape2); + + XControlModel the_Model2 = aShape2.getControl(); + + //Try to query XControlAccess + XControlAccess the_access = (XControlAccess) UnoRuntime.queryInterface( + XControlAccess.class, + xTextDoc.getCurrentController()); + + //now get the OImageControlControl + try { + oObj = the_access.getControl(the_Model); + the_win = the_access.getControl(the_Model).getPeer(); + aControl = the_access.getControl(the_Model2); + the_kit = the_win.getToolkit(); + aDevice = the_kit.createScreenCompatibleDevice(200, 200); + aGraphic = aDevice.createGraphics(); + } catch (com.sun.star.container.NoSuchElementException e) { + log.println("Couldn't get OImageControlControl"); + e.printStackTrace(log); + throw new StatusException("Couldn't get OImageControlControl", e); + } + + log.println( + "creating a new environment for OImageControlControl object"); + + TestEnvironment tEnv = new TestEnvironment(oObj); + + + //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 + XWindow forObjRel = (XWindow) UnoRuntime.queryInterface(XWindow.class, + aControl); + + tEnv.addObjRelation("XWindow.AnotherWindow", forObjRel); + + return tEnv; + } // finish method getTestEnvironment +} // finish class OImageControlControl diff --git a/qadevOOo/tests/java/mod/_forms/OImageControlModel.java b/qadevOOo/tests/java/mod/_forms/OImageControlModel.java new file mode 100644 index 000000000000..461b60fa52cd --- /dev/null +++ b/qadevOOo/tests/java/mod/_forms/OImageControlModel.java @@ -0,0 +1,161 @@ +/************************************************************************* + * + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * Copyright 2000, 2010 Oracle and/or its affiliates. + * + * OpenOffice.org - a multi-platform office productivity suite + * + * This file is part of OpenOffice.org. + * + * OpenOffice.org is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License version 3 + * only, as published by the Free Software Foundation. + * + * OpenOffice.org is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License version 3 for more details + * (a copy is included in the LICENSE file that accompanied this code). + * + * You should have received a copy of the GNU Lesser General Public License + * version 3 along with OpenOffice.org. If not, see + * <http://www.openoffice.org/license.html> + * for a copy of the LGPLv3 License. + * + ************************************************************************/ +package mod._forms; + +import com.sun.star.beans.NamedValue; +import java.io.PrintWriter; + +import lib.TestEnvironment; +import lib.TestParameters; +import util.DBTools; + + +/** +* Test for object which is represented by service +* <code>com.sun.star.form.component.DatabaseImageControl</code>. <p> +* Object implements the following interfaces : +* <ul> +* <li> <code>com::sun::star::form::XImageProducerSupplier</code></li> +* <li> <code>com::sun::star::io::XPersistObject</code></li> +* <li> <code>com::sun::star::form::XReset</code></li> +* <li> <code>com::sun::star::form::XBoundComponent</code></li> +* <li> <code>com::sun::star::form::FormComponent</code></li> +* <li> <code>com::sun::star::beans::XFastPropertySet</code></li> +* <li> <code>com::sun::star::awt::UnoControlImageControlModel</code></li> +* <li> <code>com::sun::star::beans::XMultiPropertySet</code></li> +* <li> <code>com::sun::star::form::XUpdateBroadcaster</code> +* <b>(currently nonavailable)</b></li> +* <li> <code>com::sun::star::form::DataAwareControlModel</code></li> +* <li> <code>com::sun::star::beans::XPropertyState</code></li> +* <li> <code>com::sun::star::form::FormControlModel</code></li> +* <li> <code>com::sun::star::form::component::DatabaseImageControl</code></li> +* <li> <code>com::sun::star::container::XNamed</code></li> +* <li> <code>com::sun::star::lang::XComponent</code></li> +* <li> <code>com::sun::star::lang::XEventListener</code></li> +* <li> <code>com::sun::star::beans::XPropertyAccess</code></li> +* <li> <code>com::sun::star::beans::XPropertyContainer</code></li> +* <li> <code>com::sun::star::beans::XPropertySet</code></li> +* <li> <code>com::sun::star::form::XLoadListener</code></li> +* <li> <code>com::sun::star::container::XChild</code></li> +* </ul> <p> +* This object test <b> is NOT </b> designed to be run in several +* threads concurently. +* +* @see com.sun.star.form.XImageProducerSupplier +* @see com.sun.star.io.XPersistObject +* @see com.sun.star.form.XReset +* @see com.sun.star.form.XBoundComponent +* @see com.sun.star.form.FormComponent +* @see com.sun.star.beans.XFastPropertySet +* @see com.sun.star.awt.UnoControlImageControlModel +* @see com.sun.star.beans.XMultiPropertySet +* @see com.sun.star.form.XUpdateBroadcaster +* @see com.sun.star.form.DataAwareControlModel +* @see com.sun.star.beans.XPropertyState +* @see com.sun.star.form.FormControlModel +* @see com.sun.star.form.component.DatabaseImageControl +* @see com.sun.star.container.XNamed +* @see com.sun.star.lang.XComponent +* @see com.sun.star.lang.XEventListener +* @see com.sun.star.beans.XPropertyAccess +* @see com.sun.star.beans.XPropertyContainer +* @see com.sun.star.beans.XPropertySet +* @see com.sun.star.form.XLoadListener +* @see com.sun.star.container.XChild +* @see ifc.form._XImageProducerSupplier +* @see ifc.io._XPersistObject +* @see ifc.form._XReset +* @see ifc.form._XBoundComponent +* @see ifc.form._FormComponent +* @see ifc.beans._XFastPropertySet +* @see ifc.awt._UnoControlImageControlModel +* @see ifc.beans._XMultiPropertySet +* @see ifc.form._XUpdateBroadcaster +* @see ifc.form._DataAwareControlModel +* @see ifc.beans._XPropertyState +* @see ifc.form._FormControlModel +* @see ifc.form.component._DatabaseImageControl +* @see ifc.container._XNamed +* @see ifc.lang._XComponent +* @see ifc.lang._XEventListener +* @see ifc.beans._XPropertySet +* @see ifc.form._XLoadListener +* @see ifc.container._XChild +*/ +public class OImageControlModel extends GenericModelTest { + /** + * Set some member variable of the super class <CODE>GenericModelTest</CODE>: + * <pre> + * super.m_kindOfControl="DatabaseImageControl"; + * super.m_ObjectName = "stardiv.one.form.component.DatabaseImageControl"; + * NamedValue DataField = new NamedValue(); + * DataField.Name = "DataField"; + * DataField.Value = DBTools.TST_BINARY_STREAM_F; + * super.m_propertiesToSet.add(DataField); + * + * super.m_LCShape_Type = "FixedText"; + * </pre> + * Then <CODE>super.initialize()</CODE> was called. + * @param tParam the test parameter + * @param log the log writer + */ + protected void initialize(TestParameters tParam, PrintWriter log) { + + super.initialize(tParam, log); + + super.m_kindOfControl= "DatabaseImageControl"; + + super.m_ObjectName = "stardiv.one.form.component.ImageControl"; + + NamedValue DataField = new NamedValue(); + DataField.Name = "DataField"; + DataField.Value = DBTools.TST_BINARY_STREAM_F; + super.m_propertiesToSet.add(DataField); + + super.m_LCShape_Type = "FixedText"; + + } /** + * calls <CODE>cleanup()</CODE> from it's super class + * @param tParam the test parameter + * @param log the log writer + */ + protected void cleanup(TestParameters tParam, PrintWriter log) { + super.cleanup(tParam, log); + } + + + /** + * calls <CODE>createTestEnvironment()</CODE> from it's super class + * @param Param the test parameter + * @param log the log writer + * @return lib.TestEnvironment + */ + protected synchronized TestEnvironment createTestEnvironment(TestParameters Param, + PrintWriter log) { + return super.createTestEnvironment(Param, log); + } +} // finish class OImageControlModel diff --git a/qadevOOo/tests/java/mod/_forms/OListBoxControl.java b/qadevOOo/tests/java/mod/_forms/OListBoxControl.java new file mode 100644 index 000000000000..66dfaa38d777 --- /dev/null +++ b/qadevOOo/tests/java/mod/_forms/OListBoxControl.java @@ -0,0 +1,180 @@ +/************************************************************************* + * + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * Copyright 2000, 2010 Oracle and/or its affiliates. + * + * OpenOffice.org - a multi-platform office productivity suite + * + * This file is part of OpenOffice.org. + * + * OpenOffice.org is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License version 3 + * only, as published by the Free Software Foundation. + * + * OpenOffice.org is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License version 3 for more details + * (a copy is included in the LICENSE file that accompanied this code). + * + * You should have received a copy of the GNU Lesser General Public License + * version 3 along with OpenOffice.org. If not, see + * <http://www.openoffice.org/license.html> + * for a copy of the LGPLv3 License. + * + ************************************************************************/ + +package mod._forms; + +import java.io.PrintWriter; + +import lib.StatusException; +import lib.TestCase; +import lib.TestEnvironment; +import lib.TestParameters; +import util.FormTools; +import util.SOfficeFactory; +import util.WriterTools; + +import com.sun.star.awt.XControlModel; +import com.sun.star.awt.XDevice; +import com.sun.star.awt.XGraphics; +import com.sun.star.awt.XListBox; +import com.sun.star.awt.XToolkit; +import com.sun.star.awt.XWindow; +import com.sun.star.awt.XWindowPeer; +import com.sun.star.drawing.XControlShape; +import com.sun.star.drawing.XShape; +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.XCloseable; +import com.sun.star.view.XControlAccess; + +public class OListBoxControl extends TestCase { + + XTextDocument xTextDoc; + + protected void initialize ( TestParameters Param, PrintWriter log) { + SOfficeFactory SOF = SOfficeFactory.getFactory( ((XMultiServiceFactory) Param.getMSF()) ); + + try { + log.println( "creating a textdocument" ); + xTextDoc = SOF.createTextDoc( null ); + } catch ( com.sun.star.uno.Exception e ) { + // Some exception occures.FAILED + e.printStackTrace( log ); + throw new StatusException( "Couldn't create document", e ); + } + } + + protected void cleanup(TestParameters tParam, PrintWriter log) { + log.println(" disposing xTextDoc "); + + try { + XCloseable closer = (XCloseable) 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"); + } + } + + protected TestEnvironment createTestEnvironment(TestParameters Param, PrintWriter log) { + XInterface oObj = null; + Object anotherCtrl = null ; + XWindowPeer the_win = null; + XToolkit the_kit = null; + XDevice aDevice = null; + XGraphics aGraphic = null; + //Insert a ControlShape and get the ControlModel + XControlShape aShape = FormTools.createControlShape( + xTextDoc,3000,4500,15000,10000,"ListBox"); + + WriterTools.getDrawPage(xTextDoc).add((XShape) aShape); + + XControlModel the_Model = aShape.getControl(); + + XControlShape aShape2 = FormTools.createControlShape( + xTextDoc,3000,4500,5000,10000,"TextField"); + + WriterTools.getDrawPage(xTextDoc).add((XShape) aShape2); + + XControlModel the_Model2 = aShape2.getControl(); + + //Try to query XControlAccess + XControlAccess the_access = (XControlAccess) UnoRuntime.queryInterface( + XControlAccess.class,xTextDoc.getCurrentController()); + + //now get the OListBoxControl + try { + oObj = the_access.getControl(the_Model); + anotherCtrl = the_access.getControl(the_Model2); + the_win = the_access.getControl(the_Model).getPeer(); + the_kit = the_win.getToolkit(); + aDevice = the_kit.createScreenCompatibleDevice(200,200); + aGraphic = aDevice.createGraphics(); + } catch (Exception e) { + log.println("Couldn't get OListBoxControl"); + e.printStackTrace(log); + throw new StatusException("Couldn't get OListBoxControl", e ); + } + + log.println( "creating a new environment for OListBoxControl object" ); + TestEnvironment tEnv = new TestEnvironment( oObj ); + + //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 XItemListener + ifc.awt._XItemListener.TestItemListener listener = + new ifc.awt._XItemListener.TestItemListener() ; + final XListBox box = (XListBox) UnoRuntime.queryInterface(XListBox.class, oObj) ; + box.addItemListener(listener) ; + tEnv.addObjRelation("TestItemListener", listener) ; + + // Adding relation for XWindow + XWindow forObjRel = (XWindow) + UnoRuntime.queryInterface(XWindow.class, anotherCtrl); + + XWindow objWin = (XWindow) + UnoRuntime.queryInterface(XWindow.class, oObj); + + tEnv.addObjRelation("XWindow.AnotherWindow",forObjRel); + tEnv.addObjRelation("XWindow.ControlShape",aShape); + + tEnv.addObjRelation("Win1",objWin); + tEnv.addObjRelation("Win2",forObjRel); + + tEnv.addObjRelation("CONTROL",anotherCtrl); + + // adding relation for XChangeBroadcaster + box.addItem("Item1", (short) 0); + box.addItem("Item2", (short) 1); + + tEnv.addObjRelation("XChangeBroadcaster.Changer", + new ifc.form._XChangeBroadcaster.Changer() { + public void change(){ + box.addItem("Item1", (short) 0); + box.addItem("Item2", (short) 1); + box.selectItemPos((short) 0, true); + box.selectItemPos((short) 1, true); + } + } + ); + + return tEnv; + } // finish method getTestEnvironment + +} // finish class OListBoxControl + diff --git a/qadevOOo/tests/java/mod/_forms/OListBoxModel.java b/qadevOOo/tests/java/mod/_forms/OListBoxModel.java new file mode 100644 index 000000000000..ebfe3bf5a47f --- /dev/null +++ b/qadevOOo/tests/java/mod/_forms/OListBoxModel.java @@ -0,0 +1,236 @@ +/************************************************************************* + * + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * Copyright 2000, 2010 Oracle and/or its affiliates. + * + * OpenOffice.org - a multi-platform office productivity suite + * + * This file is part of OpenOffice.org. + * + * OpenOffice.org is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License version 3 + * only, as published by the Free Software Foundation. + * + * OpenOffice.org is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License version 3 for more details + * (a copy is included in the LICENSE file that accompanied this code). + * + * You should have received a copy of the GNU Lesser General Public License + * version 3 along with OpenOffice.org. If not, see + * <http://www.openoffice.org/license.html> + * for a copy of the LGPLv3 License. + * + ************************************************************************/ +package mod._forms; + +import com.sun.star.beans.NamedValue; +import com.sun.star.beans.XPropertySet; +import com.sun.star.form.XBoundComponent; +import com.sun.star.form.XLoadable; + + +import com.sun.star.sdbc.SQLException; +import com.sun.star.sdbc.XResultSetUpdate; +import com.sun.star.uno.Exception; +import com.sun.star.uno.UnoRuntime; +import com.sun.star.uno.XInterface; +import ifc.form._XUpdateBroadcaster.UpdateChecker; +import java.io.PrintWriter; +import lib.TestEnvironment; +import lib.TestParameters; +import util.DBTools; + + +/** +* Test for object which is represented by service +* <code>com.sun.star.form.component.DatabaseListBox</code>. <p> +* Object implements the following interfaces : +* <ul> +* <li> <code>com::sun::star::io::XPersistObject</code></li> +* <li> <code>com::sun::star::awt::UnoControlListBoxModel</code></li> +* <li> <code>com::sun::star::form::XReset</code></li> +* <li> <code>com::sun::star::form::XBoundComponent</code></li> +* <li> <code>com::sun::star::form::FormComponent</code></li> +* <li> <code>com::sun::star::form::component::ListBox</code></li> +* <li> <code>com::sun::star::beans::XFastPropertySet</code></li> +* <li> <code>com::sun::star::beans::XMultiPropertySet</code></li> +* <li> <code>com::sun::star::form::XUpdateBroadcaster</code></li> +* <li> <code>com::sun::star::form::DataAwareControlModel</code></li> +* <li> <code>com::sun::star::beans::XPropertyState</code></li> +* <li> <code>com::sun::star::form::FormControlModel</code></li> +* <li> <code>com::sun::star::container::XNamed</code></li> +* <li> <code>com::sun::star::lang::XComponent</code></li> +* <li> <code>com::sun::star::lang::XEventListener</code></li> +* <li> <code>com::sun::star::beans::XPropertyAccess</code></li> +* <li> <code>com::sun::star::beans::XPropertyContainer</code></li> +* <li> <code>com::sun::star::beans::XPropertySet</code></li> +* <li> <code>com::sun::star::form::XLoadListener</code></li> +* <li> <code>com::sun::star::form::component::DatabaseListBox</code></li> +* <li> <code>com::sun::star::container::XChild</code></li> +* </ul> <p> +* This object test <b> is NOT </b> designed to be run in several +* threads concurently. +* @see com.sun.star.io.XPersistObject +* @see com.sun.star.awt.UnoControlListBoxModel +* @see com.sun.star.form.XReset +* @see com.sun.star.form.XBoundComponent +* @see com.sun.star.form.FormComponent +* @see com.sun.star.form.component.ListBox +* @see com.sun.star.beans.XFastPropertySet +* @see com.sun.star.beans.XMultiPropertySet +* @see com.sun.star.form.XUpdateBroadcaster +* @see com.sun.star.form.DataAwareControlModel +* @see com.sun.star.beans.XPropertyState +* @see com.sun.star.form.FormControlModel +* @see com.sun.star.container.XNamed +* @see com.sun.star.lang.XComponent +* @see com.sun.star.lang.XEventListener +* @see com.sun.star.beans.XPropertyAccess +* @see com.sun.star.beans.XPropertyContainer +* @see com.sun.star.beans.XPropertySet +* @see com.sun.star.form.XLoadListener +* @see com.sun.star.form.component.DatabaseListBox +* @see com.sun.star.container.XChild +* @see ifc.io._XPersistObject +* @see ifc.awt._UnoControlListBoxModel +* @see ifc.form._XReset +* @see ifc.form._XBoundComponent +* @see ifc.form._FormComponent +* @see ifc.form.component._ListBox +* @see ifc.beans._XFastPropertySet +* @see ifc.beans._XMultiPropertySet +* @see ifc.form._XUpdateBroadcaster +* @see ifc.form._DataAwareControlModel +* @see ifc.beans._XPropertyState +* @see ifc.form._FormControlModel +* @see ifc.container._XNamed +* @see ifc.lang._XComponent +* @see ifc.lang._XEventListener +* @see ifc.beans._XPropertySet +* @see ifc.form._XLoadListener +* @see ifc.form.component._DatabaseListBox +* @see ifc.container._XChild +*/ +public class OListBoxModel extends GenericModelTest { + /** + * Set some member variable of the super class <CODE>GenericModelTest</CODE>: + * <pre> + * super.m_ChangePropertyName = "Date"; + * super.m_kindOfControl="DateField"; + * super.m_ObjectName = "stardiv.one.form.component.DateField"; + * NamedValue DataField = new NamedValue(); + * DataField.Name = "DataField"; + * DataField.Value = DBTools.TST_DATE_F; + * super.m_propertiesToSet.add(DataField); + * + * NamedValue ListSource = new NamedValue(); + * ListSource.Name = "ListSource"; + * ListSource.Value = new String[] { + * "OListBoxModel1", "OListBoxModel2", "OListBoxModel3"}; + * super.m_propertiesToSet.add(ListSource); + * super.m_LCShape_Type = "FixedText"; + * </pre> + * Then <CODE>super.initialize()</CODE> was called. + * @param tParam the test parameter + * @param log the log writer + */ + protected void initialize(TestParameters tParam, PrintWriter log) { + + super.initialize(tParam, log); + + super.m_ChangePropertyName = "SelectedItems"; + + super.m_kindOfControl="ListBox"; + + super.m_ObjectName = "stardiv.one.form.component.ListBox"; + + NamedValue DataField = new NamedValue(); + DataField.Name = "DataField"; + DataField.Value = DBTools.TST_STRING_F; + super.m_propertiesToSet.add(DataField); + + NamedValue ListSource = new NamedValue(); + ListSource.Name = "ListSource"; + ListSource.Value = new String[] { + "OListBoxModel1", "OListBoxModel2", "OListBoxModel3"}; + super.m_propertiesToSet.add(ListSource); + + super.m_LCShape_Type = "FixedText"; + + } + /** + * calls <CODE>cleanup()</CODE> from it's super class + * @param tParam the test parameter + * @param log the log writer + */ + protected void cleanup(TestParameters tParam, PrintWriter log) { + super.cleanup(tParam, log); + } + + + /** + * calls <CODE>createTestEnvironment()</CODE> from it's super class + * This test uses not the generic implementaion of <CODE>cecker()</CODE> of its + * super class. This tests uses its own implementation of <CODE>checker()</CODE> + * to test <CODE>com::sun::star::form::XUpdateBroadcaster</CODE> + * @param Param the test parameter + * @param log the log writer + * @return lib.TestEnvironment + */ + protected synchronized TestEnvironment createTestEnvironment(TestParameters Param, + PrintWriter log) { + TestEnvironment tEnv = super.createTestEnvironment(Param, log); + + tEnv.addObjRelation("XUpdateBroadcaster.Checker", + new Checker(m_XFormLoader, m_XPS, m_XCtrl, m_ChangePropertyName, m_ChangePropertyValue)); + return tEnv; + } + + static class Checker implements UpdateChecker { + private short lastItem = (short) 0; + XLoadable formLoaderF = null; + XPropertySet ps = null; + XInterface ctrl = null; + String ChangePropertyName = null; + Object ChangePropertyValue = null; + + public Checker(XLoadable xl, XPropertySet ps, XInterface ctrl, String ChangePropertyName, Object ChangePropertyValue) { + formLoaderF = xl; + this.ps = ps; + this.ctrl = ctrl; + this.ChangePropertyName=ChangePropertyName; + this.ChangePropertyValue=ChangePropertyValue; + } + + public void update() throws Exception { + if (!formLoaderF.isLoaded()) { + formLoaderF.load(); + } + lastItem = (short) (1 - lastItem); + ps.setPropertyValue(ChangePropertyName, new short[] { lastItem }); + } + + public void commit() throws SQLException { + XBoundComponent bound = (XBoundComponent) UnoRuntime.queryInterface( + XBoundComponent.class, ctrl); + XResultSetUpdate update = (XResultSetUpdate) UnoRuntime.queryInterface( + XResultSetUpdate.class, + formLoaderF); + + bound.commit(); + update.updateRow(); + } + + public boolean wasCommited() throws Exception { + formLoaderF.reload(); + + short[] getS = (short[]) ps.getPropertyValue(ChangePropertyName); + + return (getS.length > 0) && (lastItem == getS[0]); + } + } + +} // finish class OListBoxModel diff --git a/qadevOOo/tests/java/mod/_forms/ONavigationBarControl.java b/qadevOOo/tests/java/mod/_forms/ONavigationBarControl.java new file mode 100644 index 000000000000..f965a9c8af3f --- /dev/null +++ b/qadevOOo/tests/java/mod/_forms/ONavigationBarControl.java @@ -0,0 +1,180 @@ +/************************************************************************* + * + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * Copyright 2000, 2010 Oracle and/or its affiliates. + * + * OpenOffice.org - a multi-platform office productivity suite + * + * This file is part of OpenOffice.org. + * + * OpenOffice.org is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License version 3 + * only, as published by the Free Software Foundation. + * + * OpenOffice.org is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License version 3 for more details + * (a copy is included in the LICENSE file that accompanied this code). + * + * You should have received a copy of the GNU Lesser General Public License + * version 3 along with OpenOffice.org. If not, see + * <http://www.openoffice.org/license.html> + * for a copy of the LGPLv3 License. + * + ************************************************************************/ +package mod._forms; + +import java.io.PrintWriter; + +import lib.StatusException; +import lib.TestCase; +import lib.TestEnvironment; +import lib.TestParameters; +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.XDevice; +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.drawing.XControlShape; +import com.sun.star.drawing.XShape; +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.view.XControlAccess; +import util.DesktopTools; + +public class ONavigationBarControl extends TestCase { + XTextDocument xTextDoc; + + /** + * Creates a text document. + */ + protected void initialize(TestParameters Param, PrintWriter log) { + SOfficeFactory SOF = SOfficeFactory.getFactory((XMultiServiceFactory) Param.getMSF()); + + try { + log.println("creating a textdocument"); + xTextDoc = SOF.createTextDoc(null); + } catch (com.sun.star.uno.Exception e) { + // Some exception occures.FAILED + e.printStackTrace(log); + throw new StatusException("Couldn't create document", e); + } + } + + /** + * Disposes the text document created before + */ + protected void cleanup(TestParameters tParam, PrintWriter log) { + log.println(" disposing xTextDoc "); + + DesktopTools.closeDoc(xTextDoc); + } + + /** + * Creates two components and inserts them to the form of + * text document. One component + * (<code>com.sun.star.form.component.CommandButton</code>) is created + * for testing, another to be passed as relation. Using a controller + * of the text document the controller of the first component is + * obtained and returned in environment as a test object. <p> + * + * Object relations created : + * <ul> + * <li> <code>'GRAPHICS'</code> for + * {@link ifc.awt._XView} : a graphics component + * created using screen device of the window peer of + * the controller tested. </li> + * <li> <code>'CONTEXT'</code> for + * {@link ifc.awt._XControl} : the text document + * where the component is inserted. </li> + * <li> <code>'WINPEER'</code> for + * {@link ifc.awt._XControl} : Window peer of the + * controller tested. </li> + * <li> <code>'TOOLKIT'</code> for + * {@link ifc.awt._XControl} : toolkit of the component.</li> + * <li> <code>'MODEL'</code> for + * {@link ifc.awt._XControl} : the model of the controller.</li> + * <li> <code>'XWindow.AnotherWindow'</code> for + * {@link ifc.awt._XWindow} : the controller of another + * component. </li> + * </ul> + */ + protected TestEnvironment createTestEnvironment(TestParameters Param, + PrintWriter log) { + XInterface oObj = null; + XWindowPeer the_win = null; + XToolkit the_kit = null; + XDevice aDevice = null; + XGraphics aGraphic = null; + XControl aControl = null; + + //Insert a ControlShape and get the ControlModel + XControlShape aShape = FormTools.createControlShape(xTextDoc, 3000, + 4500, 15000, 10000, + "NavigationToolBar"); + + WriterTools.getDrawPage(xTextDoc).add((XShape) aShape); + + XControlModel the_Model = aShape.getControl(); + + XControlShape aShape2 = FormTools.createControlShape(xTextDoc, 3000, + 4500, 5000, 10000, + "TextField"); + + WriterTools.getDrawPage(xTextDoc).add((XShape) aShape2); + + XControlModel the_Model2 = aShape2.getControl(); + + //Try to query XControlAccess + XControlAccess the_access = (XControlAccess) UnoRuntime.queryInterface( + XControlAccess.class, + xTextDoc.getCurrentController()); + + //now get the OButtonControl + try { + oObj = the_access.getControl(the_Model); + aControl = the_access.getControl(the_Model2); + the_win = the_access.getControl(the_Model).getPeer(); + the_kit = the_win.getToolkit(); + aDevice = the_kit.createScreenCompatibleDevice(200, 200); + aGraphic = aDevice.createGraphics(); + } catch (com.sun.star.container.NoSuchElementException e) { + log.println("Couldn't get ONavigationBarControl"); + e.printStackTrace(log); + throw new StatusException("Couldn't get ONavigationBarControl", e); + } + + log.println("creating a new environment for ONavigationBarControl object"); + + TestEnvironment tEnv = new TestEnvironment(oObj); + + + //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); + + XWindow forObjRel = (XWindow) UnoRuntime.queryInterface(XWindow.class, + aControl); + + tEnv.addObjRelation("XWindow.AnotherWindow", forObjRel); + tEnv.addObjRelation("XWindow.ControlShape", aShape); + + return tEnv; + } // finish method getTestEnvironment +} // finish class ONavigationBarControl diff --git a/qadevOOo/tests/java/mod/_forms/ONavigationBarModel.java b/qadevOOo/tests/java/mod/_forms/ONavigationBarModel.java new file mode 100644 index 000000000000..ffe624ed8f5d --- /dev/null +++ b/qadevOOo/tests/java/mod/_forms/ONavigationBarModel.java @@ -0,0 +1,81 @@ +/************************************************************************* + * + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * Copyright 2000, 2010 Oracle and/or its affiliates. + * + * OpenOffice.org - a multi-platform office productivity suite + * + * This file is part of OpenOffice.org. + * + * OpenOffice.org is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License version 3 + * only, as published by the Free Software Foundation. + * + * OpenOffice.org is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License version 3 for more details + * (a copy is included in the LICENSE file that accompanied this code). + * + * You should have received a copy of the GNU Lesser General Public License + * version 3 along with OpenOffice.org. If not, see + * <http://www.openoffice.org/license.html> + * for a copy of the LGPLv3 License. + * + ************************************************************************/ + +package mod._forms; + +import java.io.PrintWriter; +import lib.TestEnvironment; +import lib.TestParameters; + +public class ONavigationBarModel extends GenericModelTest { + + /** + * Set some member variable of the super class <CODE>GenericModelTest</CODE>: + * <pre> + * super.m_kindOfControl="NavigationToolBar"; + * super.m_ObjectName = "om.sun.star.form.component.NavigationToolBar"; + * super.m_LCShape_Type = "NavigationToolBar"; + * </pre> + * Then <CODE>super.initialize()</CODE> was called. + * @param tParam the test parameter + * @param log the log writer + */ + + protected void initialize(TestParameters tParam, PrintWriter log) { + + super.initialize(tParam, log); + + super.m_kindOfControl="NavigationToolBar"; + + super.m_ObjectName = "com.sun.star.form.component.NavigationToolBar"; + + super.m_LCShape_Type = "NavigationToolBar"; + + } + /** + * calls <CODE>cleanup()</CODE> from it's super class + * @param tParam the test parameter + * @param log the log writer + */ + protected void cleanup(TestParameters tParam, PrintWriter log) { + super.cleanup(tParam, log); + } + + + /** + * calls <CODE>createTestEnvironment()</CODE> from it's super class + * @param Param the test parameter + * @param log the log writer + * @return lib.TestEnvironment + */ + protected synchronized TestEnvironment createTestEnvironment(TestParameters Param, + PrintWriter log) { + return super.createTestEnvironment(Param, log); + } + +} // finish class ONavigationBarModel + diff --git a/qadevOOo/tests/java/mod/_forms/ONumericControl.java b/qadevOOo/tests/java/mod/_forms/ONumericControl.java new file mode 100644 index 000000000000..ce03616582b0 --- /dev/null +++ b/qadevOOo/tests/java/mod/_forms/ONumericControl.java @@ -0,0 +1,245 @@ +/************************************************************************* + * + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * Copyright 2000, 2010 Oracle and/or its affiliates. + * + * OpenOffice.org - a multi-platform office productivity suite + * + * This file is part of OpenOffice.org. + * + * OpenOffice.org is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License version 3 + * only, as published by the Free Software Foundation. + * + * OpenOffice.org is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License version 3 for more details + * (a copy is included in the LICENSE file that accompanied this code). + * + * You should have received a copy of the GNU Lesser General Public License + * version 3 along with OpenOffice.org. If not, see + * <http://www.openoffice.org/license.html> + * for a copy of the LGPLv3 License. + * + ************************************************************************/ +package mod._forms; + +import java.io.PrintWriter; + +import lib.StatusException; +import lib.TestCase; +import lib.TestEnvironment; +import lib.TestParameters; +import util.FormTools; +import util.SOfficeFactory; +import util.WriterTools; + +import com.sun.star.awt.XControlModel; +import com.sun.star.awt.XDevice; +import com.sun.star.awt.XGraphics; +import com.sun.star.awt.XTextComponent; +import com.sun.star.awt.XToolkit; +import com.sun.star.awt.XWindow; +import com.sun.star.awt.XWindowPeer; +import com.sun.star.drawing.XControlShape; +import com.sun.star.drawing.XShape; +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.XCloseable; +import com.sun.star.view.XControlAccess; + + +/** + * Test for object which is represented by default controller + * of the <code>com.sun.star.form.component.NumericField</code> + * component. <p> + * + * Object implements the following interfaces : + * <ul> + * <li> <code>com::sun::star::awt::XView</code></li> + * <li> <code>com::sun::star::form::XBoundControl</code></li> + * <li> <code>com::sun::star::awt::XControl</code></li> + * <li> <code>com::sun::star::awt::XTextComponent</code></li> + * <li> <code>com::sun::star::awt::XLayoutConstrains</code></li> + * <li> <code>com::sun::star::awt::XNumericField</code></li> + * <li> <code>com::sun::star::awt::XTextListener</code></li> + * <li> <code>com::sun::star::awt::XWindow</code></li> + * <li> <code>com::sun::star::lang::XComponent</code></li> + * <li> <code>com::sun::star::awt::XTextLayoutConstrains</code></li> + * <li> <code>com::sun::star::lang::XEventListener</code></li> + * </ul> <p> + * This object test <b> is NOT </b> designed to be run in several + * threads concurently. + * + * @see com.sun.star.awt.XView + * @see com.sun.star.form.XBoundControl + * @see com.sun.star.awt.XControl + * @see com.sun.star.awt.XTextComponent + * @see com.sun.star.awt.XLayoutConstrains + * @see com.sun.star.awt.XNumericField + * @see com.sun.star.awt.XTextListener + * @see com.sun.star.awt.XWindow + * @see com.sun.star.lang.XComponent + * @see com.sun.star.awt.XTextLayoutConstrains + * @see com.sun.star.lang.XEventListener + * @see ifc.awt._XView + * @see ifc.form._XBoundControl + * @see ifc.awt._XControl + * @see ifc.awt._XTextComponent + * @see ifc.awt._XLayoutConstrains + * @see ifc.awt._XNumericField + * @see ifc.awt._XTextListener + * @see ifc.awt._XWindow + * @see ifc.lang._XComponent + * @see ifc.awt._XTextLayoutConstrains + * @see ifc.lang._XEventListener + */ +public class ONumericControl extends TestCase { + XTextDocument xTextDoc; + + /** + * Creates a new text document. + */ + protected void initialize(TestParameters Param, PrintWriter log) { + SOfficeFactory SOF = SOfficeFactory.getFactory(((XMultiServiceFactory) Param.getMSF())); + + try { + log.println("creating a textdocument"); + xTextDoc = SOF.createTextDoc(null); + } catch (com.sun.star.uno.Exception e) { + // Some exception occures.FAILED + e.printStackTrace(log); + throw new StatusException("Couldn't create document", e); + } + } + + /** + * Disposes the text document created before + */ + protected void cleanup(TestParameters tParam, PrintWriter log) { + log.println(" disposing xTextDoc "); + + try { + XCloseable closer = (XCloseable) 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"); + } + } + + /** + * Creates two components and inserts them to the form of + * text document. One component + * (<code>com.sun.star.form.component.NumericField</code>) is created + * for testing, another to be passed as relation. Using a controller + * of the text document the controller of the first component is + * obtained and returned in environment as a test object. <p> + * + * Object relations created : + * <ul> + * <li> <code>'GRAPHICS'</code> for + * {@link ifc.awt._XView} : a graphics component + * created using screen device of the window peer of + * the controller tested. </li> + * <li> <code>'CONTEXT'</code> for + * {@link ifc.awt._XControl} : the text document + * where the component is inserted. </li> + * <li> <code>'WINPEER'</code> for + * {@link ifc.awt._XControl} : Window peer of the + * controller tested. </li> + * <li> <code>'TOOLKIT'</code> for + * {@link ifc.awt._XControl} : toolkit of the component.</li> + * <li> <code>'MODEL'</code> for + * {@link ifc.awt._XControl} : the model of the controller.</li> + * <li> <code>'XWindow.AnotherWindow'</code> for + * {@link ifc.awt._XWindow} : the controller of another + * component. </li> + * </ul> + */ + protected TestEnvironment createTestEnvironment(TestParameters Param, + PrintWriter log) { + XInterface oObj = null; + Object anotherCtrl = null; + XWindowPeer the_win = null; + XToolkit the_kit = null; + XDevice aDevice = null; + XGraphics aGraphic = null; + + //Insert a ControlShape and get the ControlModel + XControlShape aShape = FormTools.createControlShape(xTextDoc, 3000, + 4500, 15000, 10000, + "NumericField"); + + WriterTools.getDrawPage(xTextDoc).add((XShape) aShape); + + XControlModel the_Model = aShape.getControl(); + + XControlShape aShape2 = FormTools.createControlShape(xTextDoc, 3000, + 4500, 5000, 10000, + "TextField"); + + WriterTools.getDrawPage(xTextDoc).add((XShape) aShape2); + + XControlModel the_Model2 = aShape2.getControl(); + + //Try to query XControlAccess + XControlAccess the_access = (XControlAccess) UnoRuntime.queryInterface( + XControlAccess.class, + xTextDoc.getCurrentController()); + + //now get the ONumericControl + try { + oObj = the_access.getControl(the_Model); + anotherCtrl = the_access.getControl(the_Model2); + the_win = the_access.getControl(the_Model).getPeer(); + the_kit = the_win.getToolkit(); + aDevice = the_kit.createScreenCompatibleDevice(200, 200); + aGraphic = aDevice.createGraphics(); + } catch (com.sun.star.container.NoSuchElementException e) { + log.println("Couldn't get ONumericControl"); + e.printStackTrace(log); + throw new StatusException("Couldn't get ONumericControl", e); + } + + log.println("creating a new environment for ONumericControl object"); + + TestEnvironment tEnv = new TestEnvironment(oObj); + + + //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 + XWindow forObjRel = (XWindow) UnoRuntime.queryInterface(XWindow.class, + anotherCtrl); + + tEnv.addObjRelation("XWindow.AnotherWindow", forObjRel); + tEnv.addObjRelation("XWindow.ControlShape", aShape); + + // Adding relation for XTextListener + ifc.awt._XTextListener.TestTextListener listener = + new ifc.awt._XTextListener.TestTextListener(); + XTextComponent textComp = (XTextComponent) UnoRuntime.queryInterface( + XTextComponent.class, oObj); + textComp.addTextListener(listener); + tEnv.addObjRelation("TestTextListener", listener); + + tEnv.addObjRelation("XTextComponent.onlyNumbers", new Boolean(true)); + + return tEnv; + } // finish method getTestEnvironment +} // finish class ONumericControl diff --git a/qadevOOo/tests/java/mod/_forms/ONumericModel.java b/qadevOOo/tests/java/mod/_forms/ONumericModel.java new file mode 100644 index 000000000000..8a2ba304283f --- /dev/null +++ b/qadevOOo/tests/java/mod/_forms/ONumericModel.java @@ -0,0 +1,160 @@ +/************************************************************************* + * + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * Copyright 2000, 2010 Oracle and/or its affiliates. + * + * OpenOffice.org - a multi-platform office productivity suite + * + * This file is part of OpenOffice.org. + * + * OpenOffice.org is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License version 3 + * only, as published by the Free Software Foundation. + * + * OpenOffice.org is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License version 3 for more details + * (a copy is included in the LICENSE file that accompanied this code). + * + * You should have received a copy of the GNU Lesser General Public License + * version 3 along with OpenOffice.org. If not, see + * <http://www.openoffice.org/license.html> + * for a copy of the LGPLv3 License. + * + ************************************************************************/ +package mod._forms; + +import com.sun.star.beans.NamedValue; +import java.io.PrintWriter; + +import lib.TestEnvironment; +import lib.TestParameters; +import util.DBTools; + + + +/** +* Test for object which is represented by service +* <code>com.sun.star.for.component.NumericField</code>. <p> +* Object implements the following interfaces : +* <ul> +* <li> <code>com::sun::star::io::XPersistObject</code></li> +* <li> <code>com::sun::star::form::XReset</code></li> +* <li> <code>com::sun::star::form::XBoundComponent</code></li> +* <li> <code>com::sun::star::form::FormComponent</code></li> +* <li> <code>com::sun::star::beans::XFastPropertySet</code></li> +* <li> <code>com::sun::star::beans::XMultiPropertySet</code></li> +* <li> <code>com::sun::star::form::XUpdateBroadcaster</code></li> +* <li> <code>com::sun::star::form::DataAwareControlModel</code></li> +* <li> <code>com::sun::star::beans::XPropertyState</code></li> +* <li> <code>com::sun::star::form::component::NumericField</code></li> +* <li> <code>com::sun::star::form::FormControlModel</code></li> +* <li> <code>com::sun::star::container::XNamed</code></li> +* <li> <code>com::sun::star::lang::XComponent</code></li> +* <li> <code>com::sun::star::lang::XEventListener</code></li> +* <li> <code>com::sun::star::beans::XPropertyAccess</code></li> +* <li> <code>com::sun::star::beans::XPropertyContainer</code></li> +* <li> <code>com::sun::star::beans::XPropertySet</code></li> +* <li> <code>com::sun::star::awt::UnoControlNumericFieldModel</code></li> +* <li> <code>com::sun::star::form::XLoadListener</code></li> +* <li> <code>com::sun::star::container::XChild</code></li> +* </ul> <p> +* This object test <b> is NOT </b> designed to be run in several +* threads concurently. +* @see com.sun.star.io.XPersistObject +* @see com.sun.star.form.XReset +* @see com.sun.star.form.XBoundComponent +* @see com.sun.star.form.FormComponent +* @see com.sun.star.beans.XFastPropertySet +* @see com.sun.star.beans.XMultiPropertySet +* @see com.sun.star.form.XUpdateBroadcaster +* @see com.sun.star.form.DataAwareControlModel +* @see com.sun.star.beans.XPropertyState +* @see com.sun.star.form.component.NumericField +* @see com.sun.star.form.FormControlModel +* @see com.sun.star.container.XNamed +* @see com.sun.star.lang.XComponent +* @see com.sun.star.lang.XEventListener +* @see com.sun.star.beans.XPropertyAccess +* @see com.sun.star.beans.XPropertyContainer +* @see com.sun.star.beans.XPropertySet +* @see com.sun.star.awt.UnoControlNumericFieldModel +* @see com.sun.star.form.XLoadListener +* @see com.sun.star.container.XChild +* @see ifc.io._XPersistObject +* @see ifc.form._XReset +* @see ifc.form._XBoundComponent +* @see ifc.form._FormComponent +* @see ifc.beans._XFastPropertySet +* @see ifc.beans._XMultiPropertySet +* @see ifc.form._XUpdateBroadcaster +* @see ifc.form._DataAwareControlModel +* @see ifc.beans._XPropertyState +* @see ifc.form.component._NumericField +* @see ifc.form._FormControlModel +* @see ifc.container._XNamed +* @see ifc.lang._XComponent +* @see ifc.lang._XEventListener +* @see ifc.beans._XPropertySet +* @see ifc.awt._UnoControlNumericFieldModel +* @see ifc.form._XLoadListener +* @see ifc.container._XChild +*/ +public class ONumericModel extends GenericModelTest { + /** + * Set some member variable of the super class <CODE>GenericModelTest</CODE>: + * <pre> + * super.m_ChangePropertyName = "Time"; + * super.m_kindOfControl="TimeField"; + * super.m_ObjectName = "stardiv.one.form.component.TimeField"; + * NamedValue DataField = new NamedValue(); + * DataField.Name = "DataField"; + * DataField.Value = DBTools.TST_INT_F; + * super.m_propertiesToSet.add(DataField); + * + * super.m_LCShape_Type = "FixedText"; + * </pre> + * Then <CODE>super.initialize()</CODE> was called. + * @param tParam the test parameter + * @param log the log writer + */ + protected void initialize(TestParameters tParam, PrintWriter log) { + + super.initialize(tParam, log); + + super.m_ChangePropertyName = "Value"; + + super.m_kindOfControl="NumericField"; + + super.m_ObjectName = "stardiv.one.form.component.NumericField"; + + NamedValue DataField = new NamedValue(); + DataField.Name = "DataField"; + DataField.Value = DBTools.TST_DOUBLE_F; + super.m_propertiesToSet.add(DataField); + + super.m_LCShape_Type = "FixedText"; + + } /** + * calls <CODE>cleanup()</CODE> from it's super class + * @param tParam the test parameter + * @param log the log writer + */ + protected void cleanup(TestParameters tParam, PrintWriter log) { + super.cleanup(tParam, log); + } + + + /** + * calls <CODE>createTestEnvironment()</CODE> from it's super class + * @param Param the test parameter + * @param log the log writer + * @return lib.TestEnvironment + */ + protected synchronized TestEnvironment createTestEnvironment(TestParameters Param, + PrintWriter log) { + return super.createTestEnvironment(Param, log); + } +} // finish class ONumericModel diff --git a/qadevOOo/tests/java/mod/_forms/OPatternControl.java b/qadevOOo/tests/java/mod/_forms/OPatternControl.java new file mode 100644 index 000000000000..34d325498c79 --- /dev/null +++ b/qadevOOo/tests/java/mod/_forms/OPatternControl.java @@ -0,0 +1,243 @@ +/************************************************************************* + * + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * Copyright 2000, 2010 Oracle and/or its affiliates. + * + * OpenOffice.org - a multi-platform office productivity suite + * + * This file is part of OpenOffice.org. + * + * OpenOffice.org is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License version 3 + * only, as published by the Free Software Foundation. + * + * OpenOffice.org is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License version 3 for more details + * (a copy is included in the LICENSE file that accompanied this code). + * + * You should have received a copy of the GNU Lesser General Public License + * version 3 along with OpenOffice.org. If not, see + * <http://www.openoffice.org/license.html> + * for a copy of the LGPLv3 License. + * + ************************************************************************/ +package mod._forms; + +import java.io.PrintWriter; + +import lib.StatusException; +import lib.TestCase; +import lib.TestEnvironment; +import lib.TestParameters; +import util.FormTools; +import util.SOfficeFactory; +import util.WriterTools; + +import com.sun.star.awt.XControlModel; +import com.sun.star.awt.XDevice; +import com.sun.star.awt.XGraphics; +import com.sun.star.awt.XTextComponent; +import com.sun.star.awt.XToolkit; +import com.sun.star.awt.XWindow; +import com.sun.star.awt.XWindowPeer; +import com.sun.star.drawing.XControlShape; +import com.sun.star.drawing.XShape; +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.XCloseable; +import com.sun.star.view.XControlAccess; + + +/** + * Test for object which is represented by default controller + * of the <code>com.sun.star.form.component.PatternField</code> + * component. <p> + * + * Object implements the following interfaces : + * <ul> + * <li> <code>com::sun::star::awt::XView</code></li> + * <li> <code>com::sun::star::form::XBoundControl</code></li> + * <li> <code>com::sun::star::awt::XControl</code></li> + * <li> <code>com::sun::star::awt::XTextComponent</code></li> + * <li> <code>com::sun::star::awt::XLayoutConstrains</code></li> + * <li> <code>com::sun::star::awt::XTextListener</code></li> + * <li> <code>com::sun::star::awt::XWindow</code></li> + * <li> <code>com::sun::star::awt::XPatternField</code></li> + * <li> <code>com::sun::star::lang::XComponent</code></li> + * <li> <code>com::sun::star::awt::XTextLayoutConstrains</code></li> + * <li> <code>com::sun::star::lang::XEventListener</code></li> + * </ul> <p> + * This object test <b> is NOT </b> designed to be run in several + * threads concurently. + * + * @see com.sun.star.awt.XView + * @see com.sun.star.form.XBoundControl + * @see com.sun.star.awt.XControl + * @see com.sun.star.awt.XTextComponent + * @see com.sun.star.awt.XLayoutConstrains + * @see com.sun.star.awt.XTextListener + * @see com.sun.star.awt.XWindow + * @see com.sun.star.awt.XPatternField + * @see com.sun.star.lang.XComponent + * @see com.sun.star.awt.XTextLayoutConstrains + * @see com.sun.star.lang.XEventListener + * @see ifc.awt._XView + * @see ifc.form._XBoundControl + * @see ifc.awt._XControl + * @see ifc.awt._XTextComponent + * @see ifc.awt._XLayoutConstrains + * @see ifc.awt._XTextListener + * @see ifc.awt._XWindow + * @see ifc.awt._XPatternField + * @see ifc.lang._XComponent + * @see ifc.awt._XTextLayoutConstrains + * @see ifc.lang._XEventListener + */ +public class OPatternControl extends TestCase { + XTextDocument xTextDoc; + + /** + * Creates a new text document. + */ + protected void initialize(TestParameters Param, PrintWriter log) { + SOfficeFactory SOF = SOfficeFactory.getFactory(((XMultiServiceFactory) Param.getMSF())); + + try { + log.println("creating a textdocument"); + xTextDoc = SOF.createTextDoc(null); + } catch (com.sun.star.uno.Exception e) { + // Some exception occures.FAILED + e.printStackTrace(log); + throw new StatusException("Couldn't create document", e); + } + } + + /** + * Disposes the text document created before + */ + protected void cleanup(TestParameters tParam, PrintWriter log) { + log.println(" disposing xTextDoc "); + + try { + XCloseable closer = (XCloseable) 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"); + } + } + + /** + * Creates two components and inserts them to the form of + * text document. One component + * (<code>com.sun.star.form.component.PatternField</code>) is created + * for testing, another to be passed as relation. Using a controller + * of the text document the controller of the first component is + * obtained and returned in environment as a test object. <p> + * + * Object relations created : + * <ul> + * <li> <code>'GRAPHICS'</code> for + * {@link ifc.awt._XView} : a graphics component + * created using screen device of the window peer of + * the controller tested. </li> + * <li> <code>'CONTEXT'</code> for + * {@link ifc.awt._XControl} : the text document + * where the component is inserted. </li> + * <li> <code>'WINPEER'</code> for + * {@link ifc.awt._XControl} : Window peer of the + * controller tested. </li> + * <li> <code>'TOOLKIT'</code> for + * {@link ifc.awt._XControl} : toolkit of the component.</li> + * <li> <code>'MODEL'</code> for + * {@link ifc.awt._XControl} : the model of the controller.</li> + * <li> <code>'XWindow.AnotherWindow'</code> for + * {@link ifc.awt._XWindow} : the controller of another + * component. </li> + * </ul> + */ + protected TestEnvironment createTestEnvironment(TestParameters Param, + PrintWriter log) { + XInterface oObj = null; + Object anotherCtrl = null; + XWindowPeer the_win = null; + XToolkit the_kit = null; + XDevice aDevice = null; + XGraphics aGraphic = null; + + //Insert a ControlShape and get the ControlModel + XControlShape aShape = FormTools.createControlShape(xTextDoc, 3000, + 4500, 15000, 10000, + "PatternField"); + + WriterTools.getDrawPage(xTextDoc).add((XShape) aShape); + + XControlModel the_Model = aShape.getControl(); + + XControlShape aShape2 = FormTools.createControlShape(xTextDoc, 3000, + 4500, 5000, 10000, + "TextField"); + + WriterTools.getDrawPage(xTextDoc).add((XShape) aShape2); + + XControlModel the_Model2 = aShape2.getControl(); + + //Try to query XControlAccess + XControlAccess the_access = (XControlAccess) UnoRuntime.queryInterface( + XControlAccess.class, + xTextDoc.getCurrentController()); + + //now get the OPatternControl + try { + oObj = the_access.getControl(the_Model); + anotherCtrl = the_access.getControl(the_Model2); + the_win = the_access.getControl(the_Model).getPeer(); + the_kit = the_win.getToolkit(); + aDevice = the_kit.createScreenCompatibleDevice(200, 200); + aGraphic = aDevice.createGraphics(); + } catch (com.sun.star.container.NoSuchElementException e) { + log.println("Couldn't get OPatternControl"); + e.printStackTrace(log); + throw new StatusException("Couldn't get OPatternControl", e); + } + + log.println("creating a new environment for OPatternControl object"); + + TestEnvironment tEnv = new TestEnvironment(oObj); + + + //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 + XWindow forObjRel = (XWindow) UnoRuntime.queryInterface(XWindow.class, + anotherCtrl); + + tEnv.addObjRelation("XWindow.AnotherWindow", forObjRel); + tEnv.addObjRelation("XWindow.ControlShape", aShape); + + // Adding relation for XTextListener + ifc.awt._XTextListener.TestTextListener listener = + new ifc.awt._XTextListener.TestTextListener(); + XTextComponent textComp = (XTextComponent) UnoRuntime.queryInterface( + XTextComponent.class, oObj); + textComp.addTextListener(listener); + tEnv.addObjRelation("TestTextListener", listener); + + return tEnv; + } // finish method getTestEnvironment +} // finish class OPatternControl diff --git a/qadevOOo/tests/java/mod/_forms/OPatternModel.java b/qadevOOo/tests/java/mod/_forms/OPatternModel.java new file mode 100644 index 000000000000..cc80327ff20d --- /dev/null +++ b/qadevOOo/tests/java/mod/_forms/OPatternModel.java @@ -0,0 +1,166 @@ +/************************************************************************* + * + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * Copyright 2000, 2010 Oracle and/or its affiliates. + * + * OpenOffice.org - a multi-platform office productivity suite + * + * This file is part of OpenOffice.org. + * + * OpenOffice.org is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License version 3 + * only, as published by the Free Software Foundation. + * + * OpenOffice.org is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License version 3 for more details + * (a copy is included in the LICENSE file that accompanied this code). + * + * You should have received a copy of the GNU Lesser General Public License + * version 3 along with OpenOffice.org. If not, see + * <http://www.openoffice.org/license.html> + * for a copy of the LGPLv3 License. + * + ************************************************************************/ +package mod._forms; + +import com.sun.star.beans.NamedValue; +import java.io.PrintWriter; + +import lib.TestEnvironment; +import lib.TestParameters; +import util.DBTools; + + + +/** + * Test for object which is represented by service + * <code>com.sun.star.form.component.PatternField</code>. <p> + * Object implements the following interfaces : + * <ul> + * <li> <code>com::sun::star::io::XPersistObject</code></li> + * <li> <code>com::sun::star::form::XReset</code></li> + * <li> <code>com::sun::star::form::XBoundComponent</code></li> + * <li> <code>com::sun::star::form::FormComponent</code></li> + * <li> <code>com::sun::star::beans::XFastPropertySet</code></li> + * <li> <code>com::sun::star::beans::XMultiPropertySet</code></li> + * <li> <code>com::sun::star::form::component::PatternField</code></li> + * <li> <code>com::sun::star::form::DataAwareControlModel</code></li> + * <li> <code>com::sun::star::form::XUpdateBroadcaster</code></li> + * <li> <code>com::sun::star::awt::UnoControlPatternFieldModel</code></li> + * <li> <code>com::sun::star::form::component::DatabasePatternField</code></li> + * <li> <code>com::sun::star::form::FormControlModel</code></li> + * <li> <code>com::sun::star::beans::XPropertyState</code></li> + * <li> <code>com::sun::star::container::XNamed</code></li> + * <li> <code>com::sun::star::lang::XComponent</code></li> + * <li> <code>com::sun::star::lang::XEventListener</code></li> + * <li> <code>com::sun::star::beans::XPropertyAccess</code></li> +* <li> <code>com::sun::star::beans::XPropertyContainer</code></li> +* <li> <code>com::sun::star::beans::XPropertySet</code></li> + * <li> <code>com::sun::star::form::XLoadListener</code></li> + * <li> <code>com::sun::star::container::XChild</code></li> + * </ul> <p> + * + * This object test <b> is NOT </b> designed to be run in several + * threads concurently. + * + * @see com.sun.star.io.XPersistObject + * @see com.sun.star.form.XReset + * @see com.sun.star.form.XBoundComponent + * @see com.sun.star.form.FormComponent + * @see com.sun.star.beans.XFastPropertySet + * @see com.sun.star.beans.XMultiPropertySet + * @see com.sun.star.form.component.PatternField + * @see com.sun.star.form.DataAwareControlModel + * @see com.sun.star.form.XUpdateBroadcaster + * @see com.sun.star.awt.UnoControlPatternFieldModel + * @see com.sun.star.form.component.DatabasePatternField + * @see com.sun.star.form.FormControlModel + * @see com.sun.star.beans.XPropertyState + * @see com.sun.star.container.XNamed + * @see com.sun.star.lang.XComponent + * @see com.sun.star.lang.XEventListener + * @see com.sun.star.beans.XPropertyAccess +* @see com.sun.star.beans.XPropertyContainer +* @see com.sun.star.beans.XPropertySet + * @see com.sun.star.form.XLoadListener + * @see com.sun.star.container.XChild + * @see ifc.io._XPersistObject + * @see ifc.form._XReset + * @see ifc.form._XBoundComponent + * @see ifc.form._FormComponent + * @see ifc.beans._XFastPropertySet + * @see ifc.beans._XMultiPropertySet + * @see ifc.form.component._PatternField + * @see ifc.form._DataAwareControlModel + * @see ifc.form._XUpdateBroadcaster + * @see ifc.awt._UnoControlPatternFieldModel + * @see ifc.form.component._DatabasePatternField + * @see ifc.form._FormControlModel + * @see ifc.beans._XPropertyState + * @see ifc.container._XNamed + * @see ifc.lang._XComponent + * @see ifc.lang._XEventListener + * @see ifc.beans._XPropertySet + * @see ifc.form._XLoadListener + * @see ifc.container._XChild + */ +public class OPatternModel extends GenericModelTest { + /** + * Set some member variable of the super class <CODE>GenericModelTest</CODE>: + * <pre> + * super.m_ChangePropertyName = "Text"; + * super.m_kindOfControl="PatternField"; + * super.m_ObjectName = "stardiv.one.form.component.PatternField"; + * NamedValue DataField = new NamedValue(); + * DataField.Name = "DataField"; + * DataField.Value = DBTools.TST_STRING_F; + * super.m_propertiesToSet.add(DataField); + * + * super.m_LCShape_Type = "FixedText"; + * </pre> + * Then <CODE>super.initialize()</CODE> was called. + * @param tParam the test parameter + * @param log the log writer + */ + protected void initialize(TestParameters tParam, PrintWriter log) { + + super.initialize(tParam, log); + + super.m_ChangePropertyName = "Text"; + + super.m_kindOfControl="PatternField"; + + super.m_ObjectName = "stardiv.one.form.component.PatternField"; + + NamedValue DataField = new NamedValue(); + DataField.Name = "DataField"; + DataField.Value = DBTools.TST_STRING_F; + super.m_propertiesToSet.add(DataField); + + super.m_LCShape_Type = "FixedText"; + + } /** + * calls <CODE>cleanup()</CODE> from it's super class + * @param tParam the test parameter + * @param log the log writer + */ + protected void cleanup(TestParameters tParam, PrintWriter log) { + super.cleanup(tParam, log); + } + + + /** + * calls <CODE>createTestEnvironment()</CODE> from it's super class + * @param Param the test parameter + * @param log the log writer + * @return lib.TestEnvironment + */ + protected synchronized TestEnvironment createTestEnvironment(TestParameters Param, + PrintWriter log) { + return super.createTestEnvironment(Param, log); + } + +} // finish class OPatternModel diff --git a/qadevOOo/tests/java/mod/_forms/ORadioButtonControl.java b/qadevOOo/tests/java/mod/_forms/ORadioButtonControl.java new file mode 100644 index 000000000000..e013cb29cff8 --- /dev/null +++ b/qadevOOo/tests/java/mod/_forms/ORadioButtonControl.java @@ -0,0 +1,222 @@ +/************************************************************************* + * + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * Copyright 2000, 2010 Oracle and/or its affiliates. + * + * OpenOffice.org - a multi-platform office productivity suite + * + * This file is part of OpenOffice.org. + * + * OpenOffice.org is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License version 3 + * only, as published by the Free Software Foundation. + * + * OpenOffice.org is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License version 3 for more details + * (a copy is included in the LICENSE file that accompanied this code). + * + * You should have received a copy of the GNU Lesser General Public License + * version 3 along with OpenOffice.org. If not, see + * <http://www.openoffice.org/license.html> + * for a copy of the LGPLv3 License. + * + ************************************************************************/ +package mod._forms; + +import java.io.PrintWriter; + +import lib.StatusException; +import lib.TestCase; +import lib.TestEnvironment; +import lib.TestParameters; +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.XDevice; +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.drawing.XControlShape; +import com.sun.star.drawing.XShape; +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.XCloseable; +import com.sun.star.view.XControlAccess; + + +/** + * Test for object which is represented by default controller + * of the <code>com.sun.star.form.component.RadioButton</code> + * component. <p> + * + * Object implements the following interfaces : + * <ul> + * <li> <code>com::sun::star::lang::XComponent</code></li> + * <li> <code>com::sun::star::awt::XWindow</code></li> + * <li> <code>com::sun::star::form::XBoundControl</code></li> + * <li> <code>com::sun::star::awt::XRadioButton</code></li> + * <li> <code>com::sun::star::awt::XControl</code></li> + * <li> <code>com::sun::star::awt::XLayoutConstrains</code></li> + * <li> <code>com::sun::star::awt::XView</code></li> + * </ul> <p> + * This object test <b> is NOT </b> designed to be run in several + * threads concurently. + * + * @see com.sun.star.lang.XComponent + * @see com.sun.star.awt.XWindow + * @see com.sun.star.form.XBoundControl + * @see com.sun.star.awt.XRadioButton + * @see com.sun.star.awt.XControl + * @see com.sun.star.awt.XLayoutConstrains + * @see com.sun.star.awt.XView + * @see ifc.lang._XComponent + * @see ifc.awt._XWindow + * @see ifc.form._XBoundControl + * @see ifc.awt._XRadioButton + * @see ifc.awt._XControl + * @see ifc.awt._XLayoutConstrains + * @see ifc.awt._XView + */ +public class ORadioButtonControl extends TestCase { + XTextDocument xTextDoc; + + /** + * Creates a new text document. + */ + protected void initialize(TestParameters Param, PrintWriter log) { + SOfficeFactory SOF = SOfficeFactory.getFactory(((XMultiServiceFactory) Param.getMSF())); + + try { + log.println("creating a textdocument"); + xTextDoc = SOF.createTextDoc(null); + } catch (com.sun.star.uno.Exception e) { + // Some exception occures.FAILED + e.printStackTrace(log); + throw new StatusException("Couldn't create document", e); + } + } + + /** + * Disposes the text document created before + */ + protected void cleanup(TestParameters tParam, PrintWriter log) { + log.println(" disposing xTextDoc "); + + try { + XCloseable closer = (XCloseable) 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"); + } + } + + /** + * Creates two components and inserts them to the form of + * text document. One component + * (<code>com.sun.star.form.component.RadioButton</code>) is created + * for testing, another to be passed as relation. Using a controller + * of the text document the controller of the first component is + * obtained and returned in environment as a test object. <p> + * + * Object relations created : + * <ul> + * <li> <code>'GRAPHICS'</code> for + * {@link ifc.awt._XView} : a graphics component + * created using screen device of the window peer of + * the controller tested. </li> + * <li> <code>'CONTEXT'</code> for + * {@link ifc.awt._XControl} : the text document + * where the component is inserted. </li> + * <li> <code>'WINPEER'</code> for + * {@link ifc.awt._XControl} : Window peer of the + * controller tested. </li> + * <li> <code>'TOOLKIT'</code> for + * {@link ifc.awt._XControl} : toolkit of the component.</li> + * <li> <code>'MODEL'</code> for + * {@link ifc.awt._XControl} : the model of the controller.</li> + * <li> <code>'XWindow.AnotherWindow'</code> for + * {@link ifc.awt._XWindow} : the controller of another + * component. </li> + * </ul> + */ + protected TestEnvironment createTestEnvironment(TestParameters Param, + PrintWriter log) { + XInterface oObj = null; + XWindowPeer the_win = null; + XToolkit the_kit = null; + XDevice aDevice = null; + XGraphics aGraphic = null; + XControl aControl = null; + + //Insert a ControlShape and get the ControlModel + XControlShape aShape = FormTools.createControlShape(xTextDoc, 3000, + 4500, 15000, 10000, + "RadioButton"); + + WriterTools.getDrawPage(xTextDoc).add((XShape) aShape); + + XControlModel the_Model = aShape.getControl(); + + XControlShape aShape2 = FormTools.createControlShape(xTextDoc, 3000, + 4500, 5000, 10000, + "TextField"); + + WriterTools.getDrawPage(xTextDoc).add((XShape) aShape2); + + XControlModel the_Model2 = aShape2.getControl(); + + //Try to query XControlAccess + XControlAccess the_access = (XControlAccess) UnoRuntime.queryInterface( + XControlAccess.class, + xTextDoc.getCurrentController()); + + //now get the ORadioButtonControl + try { + oObj = the_access.getControl(the_Model); + aControl = the_access.getControl(the_Model2); + the_win = the_access.getControl(the_Model).getPeer(); + the_kit = the_win.getToolkit(); + aDevice = the_kit.createScreenCompatibleDevice(200, 200); + aGraphic = aDevice.createGraphics(); + } catch (com.sun.star.container.NoSuchElementException e) { + log.println("Couldn't get ORadioButtonControl"); + e.printStackTrace(log); + throw new StatusException("Couldn't get ORadioButtonControl", e); + } + + log.println( + "creating a new environment for ORadioButtonControl object"); + + TestEnvironment tEnv = new TestEnvironment(oObj); + + + //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); + + XWindow forObjRel = (XWindow) UnoRuntime.queryInterface(XWindow.class, + aControl); + + tEnv.addObjRelation("XWindow.AnotherWindow", forObjRel); + + return tEnv; + } // finish method getTestEnvironment +} // finish class ORadioButtonControl diff --git a/qadevOOo/tests/java/mod/_forms/ORadioButtonModel.java b/qadevOOo/tests/java/mod/_forms/ORadioButtonModel.java new file mode 100644 index 000000000000..36e3927f46af --- /dev/null +++ b/qadevOOo/tests/java/mod/_forms/ORadioButtonModel.java @@ -0,0 +1,173 @@ +/************************************************************************* + * + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * Copyright 2000, 2010 Oracle and/or its affiliates. + * + * OpenOffice.org - a multi-platform office productivity suite + * + * This file is part of OpenOffice.org. + * + * OpenOffice.org is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License version 3 + * only, as published by the Free Software Foundation. + * + * OpenOffice.org is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License version 3 for more details + * (a copy is included in the LICENSE file that accompanied this code). + * + * You should have received a copy of the GNU Lesser General Public License + * version 3 along with OpenOffice.org. If not, see + * <http://www.openoffice.org/license.html> + * for a copy of the LGPLv3 License. + * + ************************************************************************/ +package mod._forms; + +import com.sun.star.beans.NamedValue; +import com.sun.star.beans.PropertyValue; +import java.io.PrintWriter; + +import lib.TestEnvironment; +import lib.TestParameters; +import util.DBTools; + + + +/** +* Test for object which is represented by service +* <code>com.sun.star.form.component.RadioButton</code>. <p> +* +* Object implements the following interfaces : +* <ul> +* <li> <code>com::sun::star::io::XPersistObject</code></li> +* <li> <code>com::sun::star::form::component::RadioButton</code></li> +* <li> <code>com::sun::star::form::XReset</code></li> +* <li> <code>com::sun::star::form::XBoundComponent</code></li> +* <li> <code>com::sun::star::form::FormComponent</code></li> +* <li> <code>com::sun::star::beans::XFastPropertySet</code></li> +* <li> <code>com::sun::star::beans::XMultiPropertySet</code></li> +* <li> <code>com::sun::star::form::XUpdateBroadcaster</code></li> +* <li> <code>com::sun::star::form::DataAwareControlModel</code></li> +* <li> <code>com::sun::star::awt::UnoControlRadioButtonModel</code></li> +* <li> <code>com::sun::star::beans::XPropertyState</code></li> +* <li> <code>com::sun::star::form::FormControlModel</code></li> +* <li> <code>com::sun::star::container::XNamed</code></li> +* <li> <code>com::sun::star::lang::XComponent</code></li> +* <li> <code>com::sun::star::lang::XEventListener</code></li> +* <li> <code>com::sun::star::beans::XPropertyAccess</code></li> +* <li> <code>com::sun::star::beans::XPropertyContainer</code></li> +* <li> <code>com::sun::star::beans::XPropertySet</code></li> +* <li> <code>com::sun::star::form::XLoadListener</code></li> +* <li> <code>com::sun::star::container::XChild</code></li> +* </ul> <p> +* This object test <b> is NOT </b> designed to be run in several +* threads concurently. +* @see com.sun.star.io.XPersistObject +* @see com.sun.star.form.component.RadioButton +* @see com.sun.star.form.XReset +* @see com.sun.star.form.XBoundComponent +* @see com.sun.star.form.FormComponent +* @see com.sun.star.beans.XFastPropertySet +* @see com.sun.star.beans.XMultiPropertySet +* @see com.sun.star.form.XUpdateBroadcaster +* @see com.sun.star.form.DataAwareControlModel +* @see com.sun.star.awt.UnoControlRadioButtonModel +* @see com.sun.star.beans.XPropertyState +* @see com.sun.star.form.FormControlModel +* @see com.sun.star.container.XNamed +* @see com.sun.star.lang.XComponent +* @see com.sun.star.lang.XEventListener +* @see com.sun.star.beans.XPropertyAccess +* @see com.sun.star.beans.XPropertyContainer +* @see com.sun.star.beans.XPropertySet +* @see com.sun.star.form.XLoadListener +* @see com.sun.star.container.XChild +* @see ifc.io._XPersistObject +* @see ifc.form.component._RadioButton +* @see ifc.form._XReset +* @see ifc.form._XBoundComponent +* @see ifc.form._FormComponent +* @see ifc.beans._XFastPropertySet +* @see ifc.beans._XMultiPropertySet +* @see ifc.form._XUpdateBroadcaster +* @see ifc.form._DataAwareControlModel +* @see ifc.awt._UnoControlRadioButtonModel +* @see ifc.beans._XPropertyState +* @see ifc.form._FormControlModel +* @see ifc.container._XNamed +* @see ifc.lang._XComponent +* @see ifc.lang._XEventListener +* @see ifc.beans._XPropertySet +* @see ifc.form._XLoadListener +* @see ifc.container._XChild +*/ +public class ORadioButtonModel extends GenericModelTest { + + /** + * Set some member variable of the super class <CODE>GenericModelTest</CODE>: + * <pre> + * super.m_ChangePropertyName</CODE> = "State"; + * super.m_kindOfControl</CODE>="RadioButton"; + * super.m_ObjectName</CODE> = "RadioButton"; + * NamedValue myProp = new NamedValue(); + * myProp.Name = "DataField"; + * myProp.Value = DBTools.TST_STRING_F; + * super.m_propertiesToSet.add(myProp); + * super.m_LCShape_Type = "GroupBox"; + * </pre> + * Then <CODE>super.initialize()</CODE> was called. + * @param tParam the test parameter + * @param log the log writer + */ + + protected void initialize(TestParameters tParam, PrintWriter log) { + + super.initialize(tParam, log); + super.m_ChangePropertyName = "State"; + + super.m_kindOfControl="RadioButton"; + + super.m_ObjectName = "stardiv.one.form.component.RadioButton"; + + NamedValue myProp = new NamedValue(); + myProp.Name = "DataField"; + myProp.Value = DBTools.TST_STRING_F; + super.m_propertiesToSet.add(myProp); + + super.m_LCShape_Type = "GroupBox"; + + } + /** + * calls <CODE>cleanup()</CODE> from it's super class + * @param tParam the test parameter + * @param log the log writer + */ + protected void cleanup(TestParameters tParam, PrintWriter log) { + super.cleanup(tParam, log); + } + + + /** + * calls <CODE>createTestEnvironment()</CODE> from it's super class + * @param Param the test parameter + * @param log the log writer + * @return lib.TestEnvironment + */ + protected synchronized TestEnvironment createTestEnvironment(TestParameters Param, + PrintWriter log) { + TestEnvironment tEnv = super.createTestEnvironment(Param, log); + tEnv.addObjRelation("DataAwareControlModel.NewFieldName", + DBTools.TST_INT_F); + PropertyValue prop = new PropertyValue(); + prop.Name = "HelpText"; + prop.Value = "new Help Text since XPropertyAccess"; + tEnv.addObjRelation("XPropertyAccess.propertyToChange", prop); + tEnv.addObjRelation("XPropertyContainer.propertyNotRemovable", "HelpText"); + + return tEnv; + } + +} // finish class ORadioButtonModel diff --git a/qadevOOo/tests/java/mod/_forms/OScrollBarModel.java b/qadevOOo/tests/java/mod/_forms/OScrollBarModel.java new file mode 100644 index 000000000000..a847bfff055d --- /dev/null +++ b/qadevOOo/tests/java/mod/_forms/OScrollBarModel.java @@ -0,0 +1,99 @@ +/************************************************************************* + * + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * Copyright 2000, 2010 Oracle and/or its affiliates. + * + * OpenOffice.org - a multi-platform office productivity suite + * + * This file is part of OpenOffice.org. + * + * OpenOffice.org is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License version 3 + * only, as published by the Free Software Foundation. + * + * OpenOffice.org is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License version 3 for more details + * (a copy is included in the LICENSE file that accompanied this code). + * + * You should have received a copy of the GNU Lesser General Public License + * version 3 along with OpenOffice.org. If not, see + * <http://www.openoffice.org/license.html> + * for a copy of the LGPLv3 License. + * + ************************************************************************/ + +package mod._forms; + +import com.sun.star.beans.PropertyValue; +import com.sun.star.drawing.XControlShape; +import com.sun.star.drawing.XShape; +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.XCloseable; +import java.io.PrintWriter; +import lib.TestCase; +import lib.TestEnvironment; +import lib.TestParameters; +import util.FormTools; +import util.WriterTools; + +public class OScrollBarModel extends TestCase { + + XTextDocument xTextDoc; + + /** + * Creates Writer document. + */ + protected void initialize( TestParameters tParam, PrintWriter log ) { + + log.println( "creating a textdocument" ); + xTextDoc = WriterTools.createTextDoc(((XMultiServiceFactory) tParam.getMSF())); + } + + /** + * Disposes the Writer document. + */ + protected void cleanup(TestParameters tParam, PrintWriter log) { + log.println(" disposing xTextDoc "); + + try { + XCloseable closer = (XCloseable) 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"); + } + } + + protected synchronized TestEnvironment createTestEnvironment(TestParameters Param, PrintWriter log) { + + XInterface oObj = null; + + XControlShape aShape = FormTools.createControlShape( + xTextDoc,3000,4500,15000,10000,"ScrollBar"); + + WriterTools.getDrawPage(xTextDoc).add((XShape) aShape); + oObj = aShape.getControl(); + log.println( "creating a new environment for OScrollBarModel object" ); + TestEnvironment tEnv = new TestEnvironment( oObj ); + + System.out.println("Implementation Name: "+util.utils.getImplName(oObj)); + + String objName = "ScrollBar"; + tEnv.addObjRelation("OBJNAME", "com.sun.star.form.component." + objName); + PropertyValue prop = new PropertyValue(); + prop.Name = "HelpText"; + prop.Value = "new Help Text since XPropertyAccess"; + tEnv.addObjRelation("XPropertyAccess.propertyToChange", prop); + tEnv.addObjRelation("XPropertyContainer.propertyNotRemovable", "HelpText"); + return tEnv; + } + +} diff --git a/qadevOOo/tests/java/mod/_forms/OSpinButtonModel.java b/qadevOOo/tests/java/mod/_forms/OSpinButtonModel.java new file mode 100644 index 000000000000..bde3fd640e52 --- /dev/null +++ b/qadevOOo/tests/java/mod/_forms/OSpinButtonModel.java @@ -0,0 +1,102 @@ +/************************************************************************* + * + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * Copyright 2000, 2010 Oracle and/or its affiliates. + * + * OpenOffice.org - a multi-platform office productivity suite + * + * This file is part of OpenOffice.org. + * + * OpenOffice.org is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License version 3 + * only, as published by the Free Software Foundation. + * + * OpenOffice.org is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License version 3 for more details + * (a copy is included in the LICENSE file that accompanied this code). + * + * You should have received a copy of the GNU Lesser General Public License + * version 3 along with OpenOffice.org. If not, see + * <http://www.openoffice.org/license.html> + * for a copy of the LGPLv3 License. + * + ************************************************************************/ + +package mod._forms; + +import com.sun.star.beans.PropertyValue; +import com.sun.star.drawing.XControlShape; +import com.sun.star.drawing.XShape; +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.XCloseable; +import java.io.PrintWriter; +import lib.TestCase; +import lib.TestEnvironment; +import lib.TestParameters; +import util.FormTools; +import util.WriterTools; + +public class OSpinButtonModel extends TestCase { + + XTextDocument xTextDoc; + + /** + * Creates a Writer document. + */ + protected void initialize( TestParameters tParam, PrintWriter log ) { + + log.println( "creating a textdocument" ); + xTextDoc = WriterTools.createTextDoc(((XMultiServiceFactory) tParam.getMSF())); + } + + /** + * Disposes the Writer document. + */ + protected void cleanup(TestParameters tParam, PrintWriter log) { + log.println(" disposing xTextDoc "); + + try { + XCloseable closer = (XCloseable) 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. + * Adds spin button into text and retrieves it's control model. + */ + protected synchronized TestEnvironment createTestEnvironment(TestParameters Param, PrintWriter log) { + + XInterface oObj = null; + + XControlShape aShape = FormTools.createControlShape( + xTextDoc,3000,4500,15000,10000,"SpinButton"); + + WriterTools.getDrawPage(xTextDoc).add((XShape) aShape); + oObj = aShape.getControl(); + log.println( "creating a new environment for OButtonModel object" ); + TestEnvironment tEnv = new TestEnvironment( oObj ); + tEnv.addObjRelation("OBJNAME", "com.sun.star.form.component.SpinButton"); + PropertyValue prop = new PropertyValue(); + prop.Name = "HelpText"; + prop.Value = "new Help Text since XPropertyAccess"; + tEnv.addObjRelation("XPropertyAccess.propertyToChange", prop); + tEnv.addObjRelation("XPropertyContainer.propertyNotRemovable", "HelpText"); + + System.out.println("Implementation name: "+util.utils.getImplName(oObj)); + return tEnv; + } // finish method getTestEnvironment + +} diff --git a/qadevOOo/tests/java/mod/_forms/OTimeControl.java b/qadevOOo/tests/java/mod/_forms/OTimeControl.java new file mode 100644 index 000000000000..f23d635de7df --- /dev/null +++ b/qadevOOo/tests/java/mod/_forms/OTimeControl.java @@ -0,0 +1,258 @@ +/************************************************************************* + * + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * Copyright 2000, 2010 Oracle and/or its affiliates. + * + * OpenOffice.org - a multi-platform office productivity suite + * + * This file is part of OpenOffice.org. + * + * OpenOffice.org is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License version 3 + * only, as published by the Free Software Foundation. + * + * OpenOffice.org is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License version 3 for more details + * (a copy is included in the LICENSE file that accompanied this code). + * + * You should have received a copy of the GNU Lesser General Public License + * version 3 along with OpenOffice.org. If not, see + * <http://www.openoffice.org/license.html> + * for a copy of the LGPLv3 License. + * + ************************************************************************/ +package mod._forms; + +import java.io.PrintWriter; + +import lib.StatusException; +import lib.TestCase; +import lib.TestEnvironment; +import lib.TestParameters; +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.XDevice; +import com.sun.star.awt.XGraphics; +import com.sun.star.awt.XTextComponent; +import com.sun.star.awt.XToolkit; +import com.sun.star.awt.XWindow; +import com.sun.star.awt.XWindowPeer; +import com.sun.star.drawing.XControlShape; +import com.sun.star.drawing.XShape; +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.XCloseable; +import com.sun.star.view.XControlAccess; + + +/** + * Test for object which is represented by default controller + * of the <code>com.sun.star.form.component.TimeField</code> + * component. <p> + * + * Object implements the following interfaces : + * <ul> + * <li> <code>com::sun::star::awt::XView</code></li> + * <li> <code>com::sun::star::form::XBoundControl</code></li> + * <li> <code>com::sun::star::awt::XControl</code></li> + * <li> <code>com::sun::star::awt::XTextComponent</code></li> + * <li> <code>com::sun::star::awt::XLayoutConstrains</code></li> + * <li> <code>com::sun::star::awt::XTimeField</code></li> + * <li> <code>com::sun::star::awt::XTextListener</code></li> + * <li> <code>com::sun::star::awt::XWindow</code></li> + * <li> <code>com::sun::star::lang::XComponent</code></li> + * <li> <code>com::sun::star::awt::XTextLayoutConstrains</code></li> + * <li> <code>com::sun::star::lang::XEventListener</code></li> + * </ul> <p> + * This object test <b> is NOT </b> designed to be run in several + * threads concurently. + * + * @see com.sun.star.awt.XView + * @see com.sun.star.form.XBoundControl + * @see com.sun.star.awt.XControl + * @see com.sun.star.awt.XTextComponent + * @see com.sun.star.awt.XLayoutConstrains + * @see com.sun.star.awt.XTimeField + * @see com.sun.star.awt.XTextListener + * @see com.sun.star.awt.XWindow + * @see com.sun.star.lang.XComponent + * @see com.sun.star.awt.XTextLayoutConstrains + * @see com.sun.star.lang.XEventListener + * @see ifc.awt._XView + * @see ifc.form._XBoundControl + * @see ifc.awt._XControl + * @see ifc.awt._XTextComponent + * @see ifc.awt._XLayoutConstrains + * @see ifc.awt._XTimeField + * @see ifc.awt._XTextListener + * @see ifc.awt._XWindow + * @see ifc.lang._XComponent + * @see ifc.awt._XTextLayoutConstrains + * @see ifc.lang._XEventListener + */ +public class OTimeControl extends TestCase { + XTextDocument xTextDoc; + + /** + * Creates a new text document. + */ + protected void initialize(TestParameters Param, PrintWriter log) { + SOfficeFactory SOF = SOfficeFactory.getFactory(((XMultiServiceFactory) Param.getMSF())); + + try { + log.println("creating a textdocument"); + xTextDoc = SOF.createTextDoc(null); + } catch (com.sun.star.uno.Exception e) { + // Some exception occures.FAILED + e.printStackTrace(log); + throw new StatusException("Couldn't create document", e); + } + } + + /** + * Disposes the text document created before + */ + protected void cleanup(TestParameters tParam, PrintWriter log) { + log.println(" disposing xTextDoc "); + + try { + XCloseable closer = (XCloseable) 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"); + } + } + + /** + * Creates two components and inserts them to the form of + * text document. One component + * (<code>com.sun.star.form.component.TimeField</code>) is created + * for testing, another to be passed as relation. Using a controller + * of the text document the controller of the first component is + * obtained and returned in environment as a test object. <p> + * + * Object relations created : + * <ul> + * <li> <code>'GRAPHICS'</code> for + * {@link ifc.awt._XView} : a graphics component + * created using screen device of the window peer of + * the controller tested. </li> + * <li> <code>'CONTEXT'</code> for + * {@link ifc.awt._XControl} : the text document + * where the component is inserted. </li> + * <li> <code>'WINPEER'</code> for + * {@link ifc.awt._XControl} : Window peer of the + * controller tested. </li> + * <li> <code>'TOOLKIT'</code> for + * {@link ifc.awt._XControl} : toolkit of the component.</li> + * <li> <code>'MODEL'</code> for + * {@link ifc.awt._XControl} : the model of the controller.</li> + * <li> <code>'XWindow.AnotherWindow'</code> for + * {@link ifc.awt._XWindow} : the controller of another + * component. </li> + * </ul> + */ + protected TestEnvironment createTestEnvironment(TestParameters Param, + PrintWriter log) { + XInterface oObj = null; + XWindowPeer the_win = null; + XToolkit the_kit = null; + XDevice aDevice = null; + XGraphics aGraphic = null; + XControl aControl = null; + + //Insert a ControlShape and get the ControlModel + XControlShape aShape = FormTools.createControlShape(xTextDoc, 3000, + 4500, 15000, 10000, + "TimeField"); + + WriterTools.getDrawPage(xTextDoc).add((XShape) aShape); + + XControlModel the_Model = aShape.getControl(); + + XControlShape aShape2 = FormTools.createControlShape(xTextDoc, 3000, + 4500, 5000, 10000, + "TextField"); + + WriterTools.getDrawPage(xTextDoc).add((XShape) aShape2); + + XControlModel the_Model2 = aShape2.getControl(); + + //Try to query XControlAccess + XControlAccess the_access = (XControlAccess) UnoRuntime.queryInterface( + XControlAccess.class, + xTextDoc.getCurrentController()); + + //now get the OTimeControl + try { + oObj = the_access.getControl(the_Model); + aControl = the_access.getControl(the_Model2); + the_win = the_access.getControl(the_Model).getPeer(); + the_kit = the_win.getToolkit(); + aDevice = the_kit.createScreenCompatibleDevice(200, 200); + aGraphic = aDevice.createGraphics(); + } catch (com.sun.star.container.NoSuchElementException e) { + log.println("Couldn't get OTimeControl"); + e.printStackTrace(log); + throw new StatusException("Couldn't get OTimeControl", e); + } + + log.println("creating a new environment for OTimeControl object"); + + TestEnvironment tEnv = new TestEnvironment(oObj); + + + //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); + + XWindow forObjRel = (XWindow) UnoRuntime.queryInterface(XWindow.class, + aControl); + + tEnv.addObjRelation("XWindow.AnotherWindow", forObjRel); + tEnv.addObjRelation("XWindow.ControlShape", aShape); + + // Adding relation for XTextListener + ifc.awt._XTextListener.TestTextListener listener = + new ifc.awt._XTextListener.TestTextListener(); + XTextComponent textComp = (XTextComponent) UnoRuntime.queryInterface( + XTextComponent.class, oObj); + textComp.addTextListener(listener); + tEnv.addObjRelation("TestTextListener", listener); + + FormTools.switchDesignOf(((XMultiServiceFactory) Param.getMSF()), xTextDoc); + shortWait(); + + return tEnv; + } // finish method getTestEnvironment + + /** + * Sleeps for 0.2 sec. to allow StarOffice to react on <code> + * reset</code> call. + */ + private void shortWait() { + try { + Thread.sleep(200); + } catch (InterruptedException e) { + System.out.println("While waiting :" + e); + } + } +} // finish class OTimeControl diff --git a/qadevOOo/tests/java/mod/_forms/OTimeModel.java b/qadevOOo/tests/java/mod/_forms/OTimeModel.java new file mode 100644 index 000000000000..de1e17332d7f --- /dev/null +++ b/qadevOOo/tests/java/mod/_forms/OTimeModel.java @@ -0,0 +1,237 @@ +/************************************************************************* + * + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * Copyright 2000, 2010 Oracle and/or its affiliates. + * + * OpenOffice.org - a multi-platform office productivity suite + * + * This file is part of OpenOffice.org. + * + * OpenOffice.org is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License version 3 + * only, as published by the Free Software Foundation. + * + * OpenOffice.org is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License version 3 for more details + * (a copy is included in the LICENSE file that accompanied this code). + * + * You should have received a copy of the GNU Lesser General Public License + * version 3 along with OpenOffice.org. If not, see + * <http://www.openoffice.org/license.html> + * for a copy of the LGPLv3 License. + * + ************************************************************************/ +package mod._forms; + +import com.sun.star.beans.NamedValue; +import com.sun.star.beans.XPropertySet; +import com.sun.star.form.XBoundComponent; +import com.sun.star.form.XLoadable; +import com.sun.star.sdbc.XResultSetUpdate; +import com.sun.star.uno.UnoRuntime; +import com.sun.star.uno.XInterface; +import java.io.PrintWriter; +import java.util.HashSet; +import ifc.form._XUpdateBroadcaster.UpdateChecker; + +import lib.TestEnvironment; +import lib.TestParameters; +import util.DBTools; + + + +/** +* Test for object which is represented by service +* <code>com.sun.star.form.component.TimeField</code>. <p> +* Object implements the following interfaces : +* <ul> +* <li> <code>com::sun::star::awt::UnoControlTimeFieldModel</code></li> +* <li> <code>com::sun::star::io::XPersistObject</code></li> +* <li> <code>com::sun::star::form::component::TimeField</code></li> +* <li> <code>com::sun::star::form::XReset</code></li> +* <li> <code>com::sun::star::form::XBoundComponent</code></li> +* <li> <code>com::sun::star::form::FormComponent</code></li> +* <li> <code>com::sun::star::beans::XFastPropertySet</code></li> +* <li> <code>com::sun::star::beans::XMultiPropertySet</code></li> +* <li> <code>com::sun::star::form::XUpdateBroadcaster</code></li> +* <li> <code>com::sun::star::form::DataAwareControlModel</code></li> +* <li> <code>com::sun::star::beans::XPropertyState</code></li> +* <li> <code>com::sun::star::form::FormControlModel</code></li> +* <li> <code>com::sun::star::container::XNamed</code></li> +* <li> <code>com::sun::star::lang::XComponent</code></li> +* <li> <code>com::sun::star::lang::XEventListener</code></li> +* <li> <code>com::sun::star::beans::XPropertyAccess</code></li> +* <li> <code>com::sun::star::beans::XPropertyContainer</code></li> +* <li> <code>com::sun::star::beans::XPropertySet</code></li> +* <li> <code>com::sun::star::form::XLoadListener</code></li> +* <li> <code>com::sun::star::container::XChild</code></li> +* </ul> +* The following files used by this test : +* <ul> +* <li><b> TestDB </b> (directory) : directory with test database </li> +* <li><b> TestDB/TestDB.dbf </b> : table file. See +* {@link util.DBTools DBTools} class for more information.</li> +* </ul> <p> +* This object test <b> is NOT </b> designed to be run in several +* threads concurently. +* @see com.sun.star.awt.UnoControlTimeFieldModel +* @see com.sun.star.io.XPersistObject +* @see com.sun.star.form.component.TimeField +* @see com.sun.star.form.XReset +* @see com.sun.star.form.XBoundComponent +* @see com.sun.star.form.FormComponent +* @see com.sun.star.beans.XFastPropertySet +* @see com.sun.star.beans.XMultiPropertySet +* @see com.sun.star.form.XUpdateBroadcaster +* @see com.sun.star.form.DataAwareControlModel +* @see com.sun.star.beans.XPropertyState +* @see com.sun.star.form.FormControlModel +* @see com.sun.star.container.XNamed +* @see com.sun.star.lang.XComponent +* @see com.sun.star.lang.XEventListener +* @see com.sun.star.beans.XPropertyAccess +* @see com.sun.star.beans.XPropertyContainer +* @see com.sun.star.beans.XPropertySet +* @see com.sun.star.form.XLoadListener +* @see com.sun.star.container.XChild +* @see ifc.awt._UnoControlTimeFieldModel +* @see ifc.io._XPersistObject +* @see ifc.form.component._TimeField +* @see ifc.form._XReset +* @see ifc.form._XBoundComponent +* @see ifc.form._FormComponent +* @see ifc.beans._XFastPropertySet +* @see ifc.beans._XMultiPropertySet +* @see ifc.form._XUpdateBroadcaster +* @see ifc.form._DataAwareControlModel +* @see ifc.beans._XPropertyState +* @see ifc.form._FormControlModel +* @see ifc.container._XNamed +* @see ifc.lang._XComponent +* @see ifc.lang._XEventListener +* @see ifc.beans._XPropertySet +* @see ifc.form._XLoadListener +* @see ifc.container._XChild +*/ +public class OTimeModel extends GenericModelTest { + /** + * Set some member variable of the super class <CODE>GenericModelTest</CODE>: + * <pre> + * super.m_ChangePropertyName = "Time"; + * super.m_kindOfControl="TimeField"; + * super.m_ObjectName = "stardiv.one.form.component.TimeField"; + * NamedValue DataField = new NamedValue(); + * DataField.Name = "DataField"; + * DataField.Value = DBTools.TST_INT_F; + * super.m_propertiesToSet.add(DataField); + * + * super.m_LCShape_Type = "FixedText"; + * </pre> + * Then <CODE>super.initialize()</CODE> was called. + * @param tParam the test parameter + * @param log the log writer + */ + protected void initialize(TestParameters tParam, PrintWriter log) { + + super.initialize(tParam, log); + + super.m_ChangePropertyName = "Time"; + + super.m_kindOfControl="TimeField"; + + super.m_ObjectName = "stardiv.one.form.component.TimeField"; + + NamedValue DataField = new NamedValue(); + DataField.Name = "DataField"; + DataField.Value = DBTools.TST_INT_F; + super.m_propertiesToSet.add(DataField); + + super.m_LCShape_Type = "FixedText"; + + } /** + * calls <CODE>cleanup()</CODE> from it's super class + * @param tParam the test parameter + * @param log the log writer + */ + protected void cleanup(TestParameters tParam, PrintWriter log) { + super.cleanup(tParam, log); + } + + /** + * calls <CODE>createTestEnvironment()</CODE> from it's super class + * This test uses not the generic implementaion of <CODE>cecker()</CODE> of its + * super class. This tests uses its own implementation of <CODE>checker()</CODE> + * to test <CODE>com::sun::star::form::XUpdateBroadcaster</CODE> + * @param Param the test parameter + * @param log the log writer + * @return lib.TestEnvironment + */ + protected synchronized TestEnvironment createTestEnvironment(TestParameters Param, + PrintWriter log) { + TestEnvironment tEnv = super.createTestEnvironment(Param, log); + + HashSet exclude = new HashSet(); + + exclude.add("FormatKey"); + + tEnv.addObjRelation("XUpdateBroadcaster.Checker", + new Checker(m_XFormLoader, m_XPS, m_XCtrl, m_ChangePropertyName, m_ChangePropertyValue)); + return tEnv; + } + + static class Checker implements UpdateChecker { + private short lastItem = (short) 0; + XLoadable formLoaderF = null; + XPropertySet ps = null; + XInterface ctrl = null; + String ChangePropertyName = null; + Object ChangePropertyValue = null; + + public Checker(XLoadable xl, XPropertySet ps, XInterface ctrl, String ChangePropertyName, Object ChangePropertyValue) { + formLoaderF = xl; + this.ps = ps; + this.ctrl = ctrl; + this.ChangePropertyName=ChangePropertyName; + this.ChangePropertyValue=ChangePropertyValue; + } + + private int lastTime = 0; + + public void update() throws com.sun.star.uno.Exception { + if (!formLoaderF.isLoaded()) { + formLoaderF.load(); + } + + Integer time = (Integer) ps.getPropertyValue("Time"); + + if (time != null) { + lastTime = time.intValue() + 150000; + } + + ps.setPropertyValue("Time", new Integer(lastTime)); + } + + public void commit() throws com.sun.star.sdbc.SQLException { + XBoundComponent bound = (XBoundComponent) UnoRuntime.queryInterface( + XBoundComponent.class, ctrl); + XResultSetUpdate update = (XResultSetUpdate) UnoRuntime.queryInterface( + XResultSetUpdate.class, + formLoaderF); + + bound.commit(); + update.updateRow(); + } + + public boolean wasCommited() throws com.sun.star.uno.Exception { + formLoaderF.reload(); + + Integer getT = (Integer) ps.getPropertyValue("Time"); + + return (getT != null) && + (Math.abs(getT.intValue() - lastTime) < 100); + } + } +} // finish class OTimeModel diff --git a/qadevOOo/tests/java/mod/_forms/package.html b/qadevOOo/tests/java/mod/_forms/package.html new file mode 100644 index 000000000000..15ed2ca3a131 --- /dev/null +++ b/qadevOOo/tests/java/mod/_forms/package.html @@ -0,0 +1,6 @@ +<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 3.2//EN"> +<HTML> +<BODY> +<P>Containes all test cases for the module 'forms'.</P> +</BODY> +</HTML>
\ No newline at end of file |