diff options
Diffstat (limited to 'qadevOOo/tests/java/mod/_forms')
42 files changed, 8081 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 000000000..b24a951c3 --- /dev/null +++ b/qadevOOo/tests/java/mod/_forms/GenericModelTest.java @@ -0,0 +1,526 @@ +/* + * This file is part of the LibreOffice project. + * + * This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. + * + * This file incorporates work covered by the following license notice: + * + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed + * with this work for additional information regarding copyright + * ownership. The ASF licenses this file to you under the Apache + * License, Version 2.0 (the "License"); you may not use this file + * except in compliance with the License. You may obtain a copy of + * the License at http://www.apache.org/licenses/LICENSE-2.0 . + */ +package mod._forms; +import com.sun.star.beans.NamedValue; +import com.sun.star.beans.PropertyValue; +import com.sun.star.container.XIndexAccess; +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.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 concurrently. +* @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 +* @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 XTextDocument m_xTextDoc; + private Object m_dbSrc = null; + /** + * This is the name of the Data Base which the test uses: "APITestDatabase" + */ + private static final String m_dbSourceName = "APITestDatabase"; + private static final String m_TestDB = "TestDB"; + private DBTools m_dbTools = null; + + private boolean m_ConnectionColsed = false; + + /** + * describes the kind of the shape which should be created. + * Example: m_kindOfshape=DateFilled + */ + protected String m_kindOfControl = null; + + /** + * If your object needs some special property 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); + */ + protected ArrayList<NamedValue> m_propertiesToSet = new ArrayList<NamedValue>(); + + /** + * 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 + */ + protected 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>. + * Normally 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. + */ + protected Object m_ChangePropertyValue = null; + + /** + * This variable contains the implementation name of the object. + */ + protected String m_ObjectName = null; + + /** + * For local implementations of <CODE>Checker</CODE> this variable contains the + * <CODE>FormLoader</CODE> + */ + protected XLoadable m_XFormLoader = null; + /** + * For local implementations of <CODE>Checker</CODE> this variable contains the + * <CODE>XPropertySet</CODE> + */ + protected XPropertySet m_XPS = null; + /** + * For local implementations of <CODE>Checker</CODE> this variable contains the + * <CODE>Control</CODE> + */ + protected XInterface m_XCtrl = null; + /** + * The interface 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 String m_LCShape_Type = null; + + /** + * If this variable is true some more debug info was logged. It was set by the parameter variable + * <code>debug_is_active</code> + */ + private boolean debug = false; + + /** + * Creates Writer document where controls are placed. + * @param tParam the test parameter + * @param log the log writer + */ + @Override + protected void initialize(TestParameters tParam, PrintWriter log) throws Exception { + log.println("creating a textdocument"); + m_xTextDoc = WriterTools.createTextDoc(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 + */ + @Override + 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 { + XIndexAccess forms = UnoRuntime.queryInterface( XIndexAccess.class, + FormTools.getForms( WriterTools.getDrawPage( m_xTextDoc ) ) ); + XForm myForm = (XForm) AnyConverter.toObject(new Type(XForm.class), + forms.getByIndex(0)); + + if (debug){ + if (myForm == null){ + log.println("ERROR: could not get 'Standard' from drawpage!"); + } + log.println("the draw page contains following elements:"); + 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 = UnoRuntime.queryInterface( XPropertySet.class, myForm ); + XConnection connection = UnoRuntime.queryInterface( XConnection.class, xSetProp.getPropertyValue( "ActiveConnection" ) ); + if ( connection == null ) + { + if ( debug ) + log.println("ERROR: could not get property 'ActiveConnection' from the XForm"); + } + else + { + connection.close(); + } + } catch (Exception e) { + log.println("ERROR: Can't close the connection: " + e.toString()); + e.printStackTrace( log ); + } + + log.println("closing data source..."); + try { + XCloseable closer = UnoRuntime.queryInterface( + XCloseable.class, m_dbSrc); + if ( closer == null ) + { + XDocumentDataSource dataSource = UnoRuntime.queryInterface( + XDocumentDataSource.class, m_dbSrc); + if ( dataSource != null ) + closer = 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 = 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 = 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 + * committed.</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 + */ + @Override + protected TestEnvironment createTestEnvironment(TestParameters Param, + PrintWriter log) throws Exception { + XInterface oObj = null; + XControlShape aShape = null; + XMultiServiceFactory xMSF = Param.getMSF(); + + log.println("adding control shape '" + m_kindOfControl + "'"); + aShape = FormTools.createControlShape(m_xTextDoc, 3000, + 4500, 15000, 10000, + m_kindOfControl); + + WriterTools.getDrawPage(m_xTextDoc).add(aShape); + oObj = aShape.getControl(); + + log.println("Implementation name: " + util.utils.getImplName(oObj)); + + 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 ); + String tmpDir = utils.getOfficeTemp(xMSF); + + DBTools.DataSourceInfo srcInf = m_dbTools.newDataSourceInfo(); + srcInf.URL = "sdbc:dbase:" + DBTools.dirToUrl(tmpDir); + log.println("data source: " + srcInf.URL); + + m_dbSrc = srcInf.getDataSourceService(); + m_dbTools.reRegisterDB(m_dbSourceName, m_dbSrc); + + m_XFormLoader = FormTools.bindForm(m_xTextDoc, m_dbSourceName, + m_TestDB); + + 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(aShape); + + m_XPS = UnoRuntime.queryInterface( + XPropertySet.class, oObj); + + int i = 0; + NamedValue prop = null; + for (i = 0; i < m_propertiesToSet.size(); i++){ + prop = m_propertiesToSet.get(i); + + log.println("setting property: '"+prop.Name+"' to value '"+prop.Value.toString()+"'"); + + m_XPS.setPropertyValue(prop.Name, prop.Value); + } + + // 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", Boolean.TRUE); + + // adding relation for XFastPropertySet + java.util.HashSet<String> exclude = new java.util.HashSet<String>(); + exclude.add("FormatKey"); + tEnv.addObjRelation("XFastPropertySet.ExcludeProps", exclude); + + PropertyValue propVal = new PropertyValue(); + propVal.Name = "HelpText"; + propVal.Value = "Text since XPropertyAccess"; + tEnv.addObjRelation("XPropertyAccess.propertyToChange", propVal); + tEnv.addObjRelation("XPropertyContainer.propertyNotRemovable", "HelpText"); + + + return tEnv; + } // finish method getTestEnvironment + + + private static class Checker implements ifc.form._XUpdateBroadcaster.UpdateChecker { + private Object lastValue = null; + private XLoadable formLoaderF = null; + private XPropertySet ps = null; + private XInterface ctrl = null; + private 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 = UnoRuntime.queryInterface( + XBoundComponent.class, ctrl); + XResultSetUpdate update = UnoRuntime.queryInterface( + XResultSetUpdate.class, + formLoaderF); + + bound.commit(); + update.updateRow(); + } + + public boolean wasCommited() throws com.sun.star.uno.Exception { + 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 000000000..82f905931 --- /dev/null +++ b/qadevOOo/tests/java/mod/_forms/OButtonControl.java @@ -0,0 +1,202 @@ +/* + * This file is part of the LibreOffice project. + * + * This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. + * + * This file incorporates work covered by the following license notice: + * + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed + * with this work for additional information regarding copyright + * ownership. The ASF licenses this file to you under the Apache + * License, Version 2.0 (the "License"); you may not use this file + * except in compliance with the License. You may obtain a copy of + * the License at http://www.apache.org/licenses/LICENSE-2.0 . + */ +package mod._forms; + +import java.io.PrintWriter; + +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.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 concurrently. + * + * @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. + */ + @Override + protected void initialize(TestParameters Param, PrintWriter log) throws Exception { + SOfficeFactory SOF = SOfficeFactory.getFactory(Param.getMSF()); + + log.println("creating a textdocument"); + xTextDoc = SOF.createTextDoc(null); + } + + /** + * Disposes the text document created before + */ + @Override + protected void cleanup(TestParameters tParam, PrintWriter log) { + log.println(" disposing xTextDoc "); + + try { + XCloseable closer = UnoRuntime.queryInterface( + XCloseable.class, xTextDoc); + closer.close(true); + } catch (com.sun.star.util.CloseVetoException e) { + log.println("couldn't close document"); + } catch (com.sun.star.lang.DisposedException e) { + log.println("couldn't close document"); + } + } + + /** + * 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> + */ + @Override + protected TestEnvironment createTestEnvironment(TestParameters Param, + PrintWriter log) throws Exception { + XInterface oObj = null; + XWindowPeer the_win = null; + XToolkit the_kit = null; + XDevice aDevice = null; + XGraphics aGraphic = null; + XControl aControl = null; + + //Insert a ControlShape and get the ControlModel + XControlShape aShape = FormTools.createControlShape(xTextDoc, 3000, + 4500, 15000, 10000, + "CommandButton"); + + WriterTools.getDrawPage(xTextDoc).add(aShape); + + XControlModel the_Model = aShape.getControl(); + + XControlShape aShape2 = FormTools.createControlShape(xTextDoc, 3000, + 4500, 5000, 10000, + "TextField"); + + WriterTools.getDrawPage(xTextDoc).add(aShape2); + + XControlModel the_Model2 = aShape2.getControl(); + + //Try to query XControlAccess + XControlAccess the_access = UnoRuntime.queryInterface( + XControlAccess.class, + xTextDoc.getCurrentController()); + + //now get the OButtonControl + 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(); + + 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 = 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 000000000..c54b24184 --- /dev/null +++ b/qadevOOo/tests/java/mod/_forms/OButtonModel.java @@ -0,0 +1,106 @@ +/* + * This file is part of the LibreOffice project. + * + * This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. + * + * This file incorporates work covered by the following license notice: + * + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed + * with this work for additional information regarding copyright + * ownership. The ASF licenses this file to you under the Apache + * License, Version 2.0 (the "License"); you may not use this file + * except in compliance with the License. You may obtain a copy of + * the License at http://www.apache.org/licenses/LICENSE-2.0 . + */ + +package mod._forms; + +import java.io.PrintWriter; +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 concurrently. + * + * @see com.sun.star.io.XPersistObject + * @see com.sun.star.container.XChild + * @see com.sun.star.form + * @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 + */ + + @Override + protected void initialize(TestParameters tParam, PrintWriter log) throws Exception { + + super.initialize(tParam, log); + + super.m_kindOfControl="CommandButton"; + + super.m_ObjectName = "stardiv.one.form.component.CommandButton"; + + super.m_LCShape_Type = "CommandButton"; + + } + + +} // 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 000000000..f95a2340d --- /dev/null +++ b/qadevOOo/tests/java/mod/_forms/OCheckBoxControl.java @@ -0,0 +1,214 @@ +/* + * This file is part of the LibreOffice project. + * + * This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. + * + * This file incorporates work covered by the following license notice: + * + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed + * with this work for additional information regarding copyright + * ownership. The ASF licenses this file to you under the Apache + * License, Version 2.0 (the "License"); you may not use this file + * except in compliance with the License. You may obtain a copy of + * the License at http://www.apache.org/licenses/LICENSE-2.0 . + */ + +package mod._forms; + +import java.io.PrintWriter; + +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.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 concurrently. + * + * @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. + */ + @Override + protected void initialize ( TestParameters Param, PrintWriter log) throws Exception { + SOfficeFactory SOF = SOfficeFactory.getFactory( Param.getMSF() ); + log.println( "creating a textdocument" ); + xTextDoc = SOF.createTextDoc( null ); + } + + /** + * Disposes the text document created before + */ + @Override + protected void cleanup(TestParameters tParam, PrintWriter log) { + log.println(" disposing xTextDoc "); + + try { + XCloseable closer = UnoRuntime.queryInterface( + XCloseable.class, xTextDoc); + closer.close(true); + } catch (com.sun.star.util.CloseVetoException e) { + log.println("couldn't close document"); + } catch (com.sun.star.lang.DisposedException e) { + log.println("couldn't close document"); + } + } + + /** + * 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> + */ + @Override + protected TestEnvironment createTestEnvironment(TestParameters Param, PrintWriter log) throws Exception { + XInterface oObj = null; + XWindowPeer the_win = null; + XToolkit the_kit = null; + XDevice aDevice = null; + XGraphics aGraphic = null; + XControl aControl = null; + //Insert a ControlShape and get the ControlModel + XControlShape aShape = FormTools.createControlShape( + xTextDoc,3000,4500,15000,10000,"CheckBox"); + + WriterTools.getDrawPage(xTextDoc).add(aShape); + + XControlModel the_Model = aShape.getControl(); + + XControlShape aShape2 = FormTools.createControlShape( + xTextDoc,3000,4500,5000,10000,"TextField"); + + WriterTools.getDrawPage(xTextDoc).add(aShape2); + + XControlModel the_Model2 = aShape2.getControl(); + + //Try to query XControlAccess + XControlAccess the_access = UnoRuntime.queryInterface( + XControlAccess.class,xTextDoc.getCurrentController()); + + //now get the OButtonControl + 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(); + + 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 = UnoRuntime.queryInterface + (XCheckBox.class, oObj) ; + box.addItemListener(listener) ; + tEnv.addObjRelation("TestItemListener", listener) ; + + // Adding relation for XWindow + XWindow forObjRel = 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 000000000..edec240f9 --- /dev/null +++ b/qadevOOo/tests/java/mod/_forms/OCheckBoxModel.java @@ -0,0 +1,121 @@ +/* + * This file is part of the LibreOffice project. + * + * This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. + * + * This file incorporates work covered by the following license notice: + * + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed + * with this work for additional information regarding copyright + * ownership. The ASF licenses this file to you under the Apache + * License, Version 2.0 (the "License"); you may not use this file + * except in compliance with the License. You may obtain a copy of + * the License at http://www.apache.org/licenses/LICENSE-2.0 . + */ +package mod._forms; + +import java.io.PrintWriter; + +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 concurrently. +* +* @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 +* @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 + */ + @Override + protected void initialize(TestParameters tParam, PrintWriter log) throws Exception { + + super.initialize(tParam, log); + + super.m_kindOfControl= "CheckBox"; + + super.m_ObjectName = "stardiv.one.form.component.CheckBox"; + + super.m_LCShape_Type = "FixedText"; + + } + +} // 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 000000000..1b5fe16d6 --- /dev/null +++ b/qadevOOo/tests/java/mod/_forms/OComboBoxControl.java @@ -0,0 +1,223 @@ +/* + * This file is part of the LibreOffice project. + * + * This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. + * + * This file incorporates work covered by the following license notice: + * + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed + * with this work for additional information regarding copyright + * ownership. The ASF licenses this file to you under the Apache + * License, Version 2.0 (the "License"); you may not use this file + * except in compliance with the License. You may obtain a copy of + * the License at http://www.apache.org/licenses/LICENSE-2.0 . + */ +package mod._forms; + +import java.io.PrintWriter; + +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.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 concurrently. + * + * @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. + */ + @Override + protected void initialize(TestParameters Param, PrintWriter log) throws Exception { + SOfficeFactory SOF = SOfficeFactory.getFactory(Param.getMSF()); + + log.println("creating a textdocument"); + xTextDoc = SOF.createTextDoc(null); + } + + /** + * Disposes the text document created before + */ + @Override + protected void cleanup(TestParameters tParam, PrintWriter log) { + log.println(" disposing xTextDoc "); + + try { + XCloseable closer = UnoRuntime.queryInterface( + XCloseable.class, xTextDoc); + closer.close(true); + } catch (com.sun.star.util.CloseVetoException e) { + log.println("couldn't close document"); + } catch (com.sun.star.lang.DisposedException e) { + log.println("couldn't close document"); + } + } + + /** + * 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> + */ + @Override + protected TestEnvironment createTestEnvironment(TestParameters Param, + PrintWriter log) throws Exception { + XInterface oObj = null; + XWindowPeer the_win = null; + XToolkit the_kit = null; + XDevice aDevice = null; + XGraphics aGraphic = null; + XControl aControl = null; + + //Insert a ControlShape and get the ControlModel + XControlShape aShape = FormTools.createControlShape(xTextDoc, 3000, + 4500, 15000, 10000, + "ComboBox"); + + WriterTools.getDrawPage(xTextDoc).add(aShape); + + XControlModel the_Model = aShape.getControl(); + + XControlShape aShape2 = FormTools.createControlShape(xTextDoc, 3000, + 4500, 5000, 10000, + "TextField"); + + WriterTools.getDrawPage(xTextDoc).add(aShape2); + + XControlModel the_Model2 = aShape2.getControl(); + + //Try to query XControlAccess + XControlAccess the_access = UnoRuntime.queryInterface( + XControlAccess.class, + xTextDoc.getCurrentController()); + + //now get the OButtonControl + 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(); + + 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 = 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 = 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 000000000..963e996ed --- /dev/null +++ b/qadevOOo/tests/java/mod/_forms/OComboBoxModel.java @@ -0,0 +1,135 @@ +/* + * This file is part of the LibreOffice project. + * + * This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. + * + * This file incorporates work covered by the following license notice: + * + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed + * with this work for additional information regarding copyright + * ownership. The ASF licenses this file to you under the Apache + * License, Version 2.0 (the "License"); you may not use this file + * except in compliance with the License. You may obtain a copy of + * the License at http://www.apache.org/licenses/LICENSE-2.0 . + */ +package mod._forms; +import com.sun.star.beans.NamedValue; +import java.io.PrintWriter; + +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 concurrently. +* @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 +* @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 + */ + @Override + protected void initialize(TestParameters tParam, PrintWriter log) throws Exception { + + 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"; + + } + +} // 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 000000000..571401aba --- /dev/null +++ b/qadevOOo/tests/java/mod/_forms/OCurrencyControl.java @@ -0,0 +1,230 @@ +/* + * This file is part of the LibreOffice project. + * + * This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. + * + * This file incorporates work covered by the following license notice: + * + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed + * with this work for additional information regarding copyright + * ownership. The ASF licenses this file to you under the Apache + * License, Version 2.0 (the "License"); you may not use this file + * except in compliance with the License. You may obtain a copy of + * the License at http://www.apache.org/licenses/LICENSE-2.0 . + */ +package mod._forms; + +import java.io.PrintWriter; + +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.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 concurrently. + * + * @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. + */ + @Override + protected void initialize(TestParameters Param, PrintWriter log) throws Exception { + SOfficeFactory SOF = SOfficeFactory.getFactory(Param.getMSF()); + + log.println("creating a textdocument"); + xTextDoc = SOF.createTextDoc(null); + } + + /** + * Disposes the text document created before + */ + @Override + protected void cleanup(TestParameters tParam, PrintWriter log) { + log.println(" disposing xTextDoc "); + + try { + XCloseable closer = UnoRuntime.queryInterface( + XCloseable.class, xTextDoc); + closer.close(true); + } catch (com.sun.star.util.CloseVetoException e) { + log.println("couldn't close document"); + } catch (com.sun.star.lang.DisposedException e) { + log.println("couldn't close document"); + } + } + + /** + * 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> + */ + @Override + protected TestEnvironment createTestEnvironment(TestParameters Param, + PrintWriter log) throws Exception { + XInterface oObj = null; + XWindowPeer the_win = null; + XToolkit the_kit = null; + XDevice aDevice = null; + XGraphics aGraphic = null; + XControl aControl = null; + + //Insert a ControlShape and get the ControlModel + XControlShape aShape = FormTools.createControlShape(xTextDoc, 3000, + 4500, 15000, 10000, + "CurrencyField"); + + WriterTools.getDrawPage(xTextDoc).add(aShape); + + XControlModel the_Model = aShape.getControl(); + + XControlShape aShape2 = FormTools.createControlShape(xTextDoc, 3000, + 4500, 5000, 10000, + "TextField"); + + WriterTools.getDrawPage(xTextDoc).add(aShape2); + + XControlModel the_Model2 = aShape2.getControl(); + + //Try to query XControlAccess + XControlAccess the_access = UnoRuntime.queryInterface( + XControlAccess.class, + xTextDoc.getCurrentController()); + + //now get the OCurrencyControl + 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(); + + 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 = 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 = 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 000000000..fed0b5d57 --- /dev/null +++ b/qadevOOo/tests/java/mod/_forms/OCurrencyModel.java @@ -0,0 +1,131 @@ +/* + * This file is part of the LibreOffice project. + * + * This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. + * + * This file incorporates work covered by the following license notice: + * + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed + * with this work for additional information regarding copyright + * ownership. The ASF licenses this file to you under the Apache + * License, Version 2.0 (the "License"); you may not use this file + * except in compliance with the License. You may obtain a copy of + * the License at http://www.apache.org/licenses/LICENSE-2.0 . + */ +package mod._forms; +import com.sun.star.beans.NamedValue; +import java.io.PrintWriter; + +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 concurrently. +* @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 +* @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 + */ + @Override + protected void initialize(TestParameters tParam, PrintWriter log) throws Exception { + + 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"; + + } + +} // 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 000000000..0683ab01c --- /dev/null +++ b/qadevOOo/tests/java/mod/_forms/ODatabaseForm.java @@ -0,0 +1,863 @@ +/* + * This file is part of the LibreOffice project. + * + * This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. + * + * This file incorporates work covered by the following license notice: + * + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed + * with this work for additional information regarding copyright + * ownership. The ASF licenses this file to you under the Apache + * License, Version 2.0 (the "License"); you may not use this file + * except in compliance with the License. You may obtain a copy of + * the License at http://www.apache.org/licenses/LICENSE-2.0 . + */ +package mod._forms; + +import ifc.form._XDatabaseParameterBroadcaster; +import ifc.sdb._XCompletedExecution; + +import java.io.OutputStreamWriter; +import java.io.PrintWriter; +import java.io.UnsupportedEncodingException; +import java.util.ArrayList; +import lib.StatusException; +import lib.TestCase; +import lib.TestEnvironment; +import lib.TestParameters; +import util.DBTools; +import util.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.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.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.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; + + +/** + * 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 concurrently. + * 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 static final 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; + + @Override + protected void initialize(TestParameters tParam, PrintWriter log) throws Exception { + tmpDir = utils.getOfficeTemp(tParam.getMSF()); + + origDB = util.utils.getFullTestDocName("TestDB/testDB.dbf"); + + dbTools = new DBTools( tParam.getMSF() ); + + // 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 = Boolean.TRUE; + srcInf.Password = dbPassword; + srcInf.User = dbUser; + + PropertyValue[] propInfo = new PropertyValue[1]; + propInfo[0] = new PropertyValue(); + propInfo[0].Name = "JavaDriverClass"; + 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(tParam.getMSF()) + tableName + + ".dbf"; + } while (!utils.tryOverwriteFile(tParam.getMSF(), oldF, newF) && + (uniqueSuffix++ < 50)); + } + } + + /** + * creating a TestEnvironment for the interfaces to be tested + */ + @Override + protected TestEnvironment createTestEnvironment(TestParameters Param, + PrintWriter log) throws Exception { + if (xTextDoc != null) { + try { + XCloseable closer = UnoRuntime.queryInterface( + XCloseable.class, xTextDoc); + closer.close(true); + } catch (com.sun.star.util.CloseVetoException e) { + log.println("couldn't close document"); + } catch (com.sun.star.lang.DisposedException e) { + log.println("couldn't close document"); + } + + log.println("Existing document disposed"); + } + + log.println("creating a text document"); + xTextDoc = WriterTools.createTextDoc(Param.getMSF()); + + //initialize test table + if (isMySQLDB) { + dbTools.initTestTableUsingJDBC(tableName, srcInf); + } + + 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; + + formLoader = FormTools.bindForm(xTextDoc, "MyForm", dbSourceName, + tableName); + + + // 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 = UnoRuntime.queryInterface( + XIndexAccess.class, + forms.getByName("MyForm")); + + for (int i = 0; i < formElements1.getCount(); i++) { + XNamed elemName = 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(shape1); + oShapes.add(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 = UnoRuntime.queryInterface( + XIndexAccess.class, + forms.getByName("MyForm")); + + for (int i = 0; i < formElements1.getCount(); i++) { + XNamed elemName = UnoRuntime.queryInterface( + XNamed.class, + formElements1.getByIndex(i)); + log.println(" '" + elemName.getName() + "'"); + } + } catch (Exception e) { + e.printStackTrace(log); + } + + formLoader.load(); + + try { + Object temp1 = FormTools.getForms( WriterTools.getDrawPage(xTextDoc) ).getByName("MyForm"); + oObj = (XForm) AnyConverter.toObject(new Type(XForm.class), temp1); + + XPropertySet xSetProp = 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 = UnoRuntime.queryInterface( + XControlAccess.class, + xTextDoc.getCurrentController()); + XControl cntrl = null; + + //now get the OEditControl + cntrl = the_access.getControl(the_Model); + log.println(cntrl.getClass().getName()); + + XResultSet the_set = UnoRuntime.queryInterface( + XResultSet.class, oObj); + + the_set.first(); + + tEnv.addObjRelation("Model1", shape1.getControl()); + tEnv.addObjRelation("Model2", shape2.getControl()); + + + // adding an object for XNameReplace testing + log.println("adding oInstance 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"); + + 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"); + + // Adding obj relation for XRowSetApproveBroadcaster test + final XResultSet xResSet = UnoRuntime.queryInterface( + XResultSet.class, oObj); + final XResultSetUpdate xResSetUpdate = UnoRuntime.queryInterface( + XResultSetUpdate.class, + oObj); + final 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 = 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 + ArrayList<Object> params = new ArrayList<Object>(); + + + /***** statement parameter types and their initial + values must be added here as relation. */ + params.add("SAU99") ; + params.add(Boolean.FALSE) ; + params.add(Byte.valueOf((byte) 123)) ; + params.add(Short.valueOf((short) 234)) ; + params.add(Integer.valueOf(12345)) ; + params.add(Long.valueOf(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.NanoSeconds = 123456789; 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.NanoSeconds = 123456789; 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", Boolean.valueOf(isMySQLDB)); + + // Adding relation for XDatabaseParameterBroadcaster + tEnv.addObjRelation("ParameterListenerChecker", new ODatabaseForm.ParameterListenerImpl()); + XPropertySet xSetProp = 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", + Integer.valueOf(CommandType.COMMAND)) ; + } + catch(Exception e) { + } + + // Adding relation for XResultSetUpdate + final XRowUpdate xRowUpdate = UnoRuntime.queryInterface( + XRowUpdate.class, oObj); + final 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. + + ArrayList<Object> rowData = new ArrayList<Object>(); + + for (int i = 0; i < DBTools.TST_TABLE_VALUES[0].length; i++) { + rowData.add(DBTools.TST_TABLE_VALUES[0][i]); + } + + tEnv.addObjRelation("CurrentRowData", rowData); + + // Adding relation for XRowUpdate + XRow row = 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. + */ + @Override + 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 = 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 = 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 + */ + private static class ParameterListenerImpl implements _XDatabaseParameterBroadcaster.CheckParameterListener { + private boolean listenerWasCalled = false; + + private PrintWriter log; + + ParameterListenerImpl() throws UnsupportedEncodingException { + log = new PrintWriter(new OutputStreamWriter(System.out, "UTF-8")); + } + + /** + * 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 = UnoRuntime.queryInterface(XPropertySet.class, params.getByIndex(i)); + log.println("### _XDatabaseParameterBroadcaster.ParameterListenerImpl: Parameter Name: '"+xProp.getPropertyValue("Name") + "' is set to Value '1'"); + xProp.setPropertyValue("Value", Integer.valueOf(1)); + listenerWasCalled = true; + } + } + catch(Exception eI) { + log.println("### _XDatabaseParameterBroadcaster.ParameterListenerImpl: Exception!"); + eI.printStackTrace(log); + return false; + } + return true; + } + + /** + * Dummy implementation. 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 + */ + private static class InteractionHandlerImpl implements _XCompletedExecution.CheckInteractionHandler { + private boolean handlerWasUsed = false; + private PrintWriter log; + + InteractionHandlerImpl() throws UnsupportedEncodingException { + log = new PrintWriter(new OutputStreamWriter(System.out, "UTF-8")); + } + + public boolean checkInteractionHandler() { + return handlerWasUsed; + } + + public void handle(XInteractionRequest xInteractionRequest) { + log.println("### _XCompletedExecution.InteractionHandlerImpl: handle called."); + 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++) { + params.getByIndex(i); + log.println("### _XCompletedExecution.InteractionHandlerImpl: Parameter "+i+": "+params.getByIndex(i)); + XPropertySet xProp = UnoRuntime.queryInterface(XPropertySet.class, params.getByIndex(i)); + log.println("### _XCompletedExecution.InteractionHandlerImpl: Parameter Name: '"+xProp.getPropertyValue("Name") + "' is set to Value '1'"); + xProp.setPropertyValue("Value", Integer.valueOf(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 000000000..7d4dfc9e4 --- /dev/null +++ b/qadevOOo/tests/java/mod/_forms/ODateControl.java @@ -0,0 +1,222 @@ +/* + * This file is part of the LibreOffice project. + * + * This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. + * + * This file incorporates work covered by the following license notice: + * + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed + * with this work for additional information regarding copyright + * ownership. The ASF licenses this file to you under the Apache + * License, Version 2.0 (the "License"); you may not use this file + * except in compliance with the License. You may obtain a copy of + * the License at http://www.apache.org/licenses/LICENSE-2.0 . + */ +package mod._forms; + +import java.io.PrintWriter; + +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.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 concurrently. + * + * @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. + */ + @Override + protected void initialize(TestParameters Param, PrintWriter log) throws Exception { + SOfficeFactory SOF = SOfficeFactory.getFactory(Param.getMSF()); + + log.println("creating a textdocument"); + xTextDoc = SOF.createTextDoc(null); + } + + /** + * Disposes the text document created before + */ + @Override + protected void cleanup(TestParameters tParam, PrintWriter log) { + log.println(" disposing xTextDoc "); + + try { + XCloseable closer = UnoRuntime.queryInterface( + XCloseable.class, xTextDoc); + closer.close(true); + } catch (com.sun.star.util.CloseVetoException e) { + log.println("couldn't close document"); + } catch (com.sun.star.lang.DisposedException e) { + log.println("couldn't close document"); + } + } + + /** + * 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> + */ + @Override + protected TestEnvironment createTestEnvironment(TestParameters Param, + PrintWriter log) throws Exception { + 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(aShape); + + XControlModel the_Model = aShape.getControl(); + + XControlShape aShape2 = FormTools.createControlShape(xTextDoc, 3000, + 4500, 5000, 10000, + "TextField"); + + WriterTools.getDrawPage(xTextDoc).add(aShape2); + + XControlModel the_Model2 = aShape2.getControl(); + + //Try to query XControlAccess + XControlAccess the_access = UnoRuntime.queryInterface( + XControlAccess.class, + xTextDoc.getCurrentController()); + + //now get the ODateControl + 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(); + + 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 = 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 = 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 000000000..0d4c75800 --- /dev/null +++ b/qadevOOo/tests/java/mod/_forms/ODateModel.java @@ -0,0 +1,150 @@ +/* + * This file is part of the LibreOffice project. + * + * This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. + * + * This file incorporates work covered by the following license notice: + * + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed + * with this work for additional information regarding copyright + * ownership. The ASF licenses this file to you under the Apache + * License, Version 2.0 (the "License"); you may not use this file + * except in compliance with the License. You may obtain a copy of + * the License at http://www.apache.org/licenses/LICENSE-2.0 . + */ +package mod._forms; + +import com.sun.star.beans.NamedValue; +import java.io.PrintWriter; + +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 concurrently. +* @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 +* @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 = Integer.valueOf(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 + */ + @Override + protected void initialize(TestParameters tParam, PrintWriter log) throws Exception { + + 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 com.sun.star.util.Date(); + super.m_propertiesToSet.add(Date); + + super.m_LCShape_Type = "FixedText"; + + } + +} // 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 000000000..ae231ace5 --- /dev/null +++ b/qadevOOo/tests/java/mod/_forms/OEditControl.java @@ -0,0 +1,240 @@ +/* + * This file is part of the LibreOffice project. + * + * This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. + * + * This file incorporates work covered by the following license notice: + * + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed + * with this work for additional information regarding copyright + * ownership. The ASF licenses this file to you under the Apache + * License, Version 2.0 (the "License"); you may not use this file + * except in compliance with the License. You may obtain a copy of + * the License at http://www.apache.org/licenses/LICENSE-2.0 . + */ +package mod._forms; + +import java.io.PrintWriter; + +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.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 concurrently. + * + * @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. + */ + @Override + protected void initialize(TestParameters Param, PrintWriter log) throws Exception { + SOfficeFactory SOF = SOfficeFactory.getFactory(Param.getMSF()); + + log.println("creating a textdocument"); + xTextDoc = SOF.createTextDoc(null); + } + + /** + * Disposes the text document created before + */ + @Override + protected void cleanup(TestParameters tParam, PrintWriter log) { + log.println(" disposing xTextDoc "); + + try { + XCloseable closer = UnoRuntime.queryInterface( + XCloseable.class, xTextDoc); + closer.close(true); + } catch (com.sun.star.util.CloseVetoException e) { + log.println("couldn't close document"); + } catch (com.sun.star.lang.DisposedException e) { + log.println("couldn't close document"); + } + } + + /** + * 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> + */ + @Override + protected TestEnvironment createTestEnvironment(TestParameters Param, + PrintWriter log) throws Exception { + 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(aShape); + + XControlModel the_Model = aShape.getControl(); + + XControlShape aShape2 = FormTools.createControlShape(xTextDoc, 3000, + 4500, 5000, 10000, + "TextField"); + + WriterTools.getDrawPage(xTextDoc).add(aShape2); + + XControlModel the_Model2 = aShape2.getControl(); + + //Try to query XControlAccess + XControlAccess the_access = UnoRuntime.queryInterface( + XControlAccess.class, + xTextDoc.getCurrentController()); + + //now get the OEditControl + 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(); + + 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 = UnoRuntime.queryInterface(XWindow.class, + aControl); + + tEnv.addObjRelation("Win1", + 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 = 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 000000000..b672cbd9c --- /dev/null +++ b/qadevOOo/tests/java/mod/_forms/OEditModel.java @@ -0,0 +1,142 @@ +/* + * This file is part of the LibreOffice project. + * + * This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. + * + * This file incorporates work covered by the following license notice: + * + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed + * with this work for additional information regarding copyright + * ownership. The ASF licenses this file to you under the Apache + * License, Version 2.0 (the "License"); you may not use this file + * except in compliance with the License. You may obtain a copy of + * the License at http://www.apache.org/licenses/LICENSE-2.0 . + */ +package mod._forms; + +import com.sun.star.beans.NamedValue; +import java.io.PrintWriter; + +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 concurrently. +* @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 +* @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 + */ + + @Override + protected void initialize(TestParameters tParam, PrintWriter log) throws Exception { + + 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"; + } + +} // 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 000000000..994e62123 --- /dev/null +++ b/qadevOOo/tests/java/mod/_forms/OFileControlModel.java @@ -0,0 +1,188 @@ +/* + * This file is part of the LibreOffice project. + * + * This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. + * + * This file incorporates work covered by the following license notice: + * + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed + * with this work for additional information regarding copyright + * ownership. The ASF licenses this file to you under the Apache + * License, Version 2.0 (the "License"); you may not use this file + * except in compliance with the License. You may obtain a copy of + * the License at http://www.apache.org/licenses/LICENSE-2.0 . + */ +package mod._forms; + +import java.io.PrintWriter; + +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.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 concurrently. + * @see com.sun.star.io.XPersistObject + * @see com.sun.star.container.XChild + * @see com.sun.star.form + * @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. + */ + @Override + protected void initialize(TestParameters tParam, PrintWriter log) throws Exception { + SOfficeFactory SOF = SOfficeFactory.getFactory(tParam.getMSF()); + log.println("creating a draw document"); + xDrawDoc = SOF.createDrawDoc(null); + } + + /** + * Disposes Draw document. + */ + @Override + protected void cleanup(TestParameters tParam, PrintWriter log) { + log.println(" disposing xDrawDoc "); + + try { + XCloseable closer = 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> + */ + @Override + protected TestEnvironment createTestEnvironment(TestParameters Param, + PrintWriter log) throws Exception { + 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 = UnoRuntime.queryInterface( + XMultiServiceFactory.class, + xDrawDoc); + + Object oInt = oDocMSF.createInstance( + "com.sun.star.drawing.ControlShape"); + Object aCon = oDocMSF.createInstance( + "com.sun.star.form.component." + objName); + aControl = UnoRuntime.queryInterface( + XControlModel.class, aCon); + aShape = UnoRuntime.queryInterface( + XControlShape.class, oInt); + size.Height = 1500; + size.Width = 3000; + position.X = 1000; + position.Y = 1000; + aShape.setSize(size); + aShape.setPosition(position); + + aShape.setControl(aControl); + + DrawTools.getDrawPage(xDrawDoc, 0).add(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 000000000..2b8469144 --- /dev/null +++ b/qadevOOo/tests/java/mod/_forms/OFixedTextModel.java @@ -0,0 +1,99 @@ +/* + * This file is part of the LibreOffice project. + * + * This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. + * + * This file incorporates work covered by the following license notice: + * + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed + * with this work for additional information regarding copyright + * ownership. The ASF licenses this file to you under the Apache + * License, Version 2.0 (the "License"); you may not use this file + * except in compliance with the License. You may obtain a copy of + * the License at http://www.apache.org/licenses/LICENSE-2.0 . + */ +package mod._forms; + +import java.io.PrintWriter; + +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 concurrently. +* @see com.sun.star.io.XPersistObject +* @see com.sun.star.container.XChild +* @see com.sun.star.form +* @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 + */ + + @Override + protected void initialize(TestParameters tParam, PrintWriter log) throws Exception { + + super.initialize(tParam, log); + + super.m_kindOfControl="FixedText"; + + super.m_ObjectName = "stardiv.one.form.component.FixedText"; + + super.m_LCShape_Type = "FixedText"; + + } + +} // 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 000000000..11793b31d --- /dev/null +++ b/qadevOOo/tests/java/mod/_forms/OFormattedControl.java @@ -0,0 +1,219 @@ +/* + * This file is part of the LibreOffice project. + * + * This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. + * + * This file incorporates work covered by the following license notice: + * + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed + * with this work for additional information regarding copyright + * ownership. The ASF licenses this file to you under the Apache + * License, Version 2.0 (the "License"); you may not use this file + * except in compliance with the License. You may obtain a copy of + * the License at http://www.apache.org/licenses/LICENSE-2.0 . + */ +package mod._forms; + +import java.io.PrintWriter; + +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.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 concurrently. + * + * @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. + */ + @Override + protected void initialize(TestParameters Param, PrintWriter log) throws Exception { + SOfficeFactory SOF = SOfficeFactory.getFactory(Param.getMSF()); + + log.println("creating a textdocument"); + xTextDoc = SOF.createTextDoc(null); + } + + /** + * Disposes the text document created before + */ + @Override + protected void cleanup(TestParameters tParam, PrintWriter log) { + log.println(" disposing xTextDoc "); + + try { + XCloseable closer = UnoRuntime.queryInterface( + XCloseable.class, xTextDoc); + closer.close(true); + } catch (com.sun.star.util.CloseVetoException e) { + log.println("couldn't close document"); + } catch (com.sun.star.lang.DisposedException e) { + log.println("couldn't close document"); + } + } + + /** + * 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> + */ + @Override + protected TestEnvironment createTestEnvironment(TestParameters Param, + PrintWriter log) throws Exception { + 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(aShape); + + XControlModel the_Model = aShape.getControl(); + + XControlShape aShape2 = FormTools.createControlShape(xTextDoc, 3000, + 4500, 5000, 10000, + "TextField"); + + WriterTools.getDrawPage(xTextDoc).add(aShape2); + + XControlModel the_Model2 = aShape2.getControl(); + + //Try to query XControlAccess + XControlAccess the_access = UnoRuntime.queryInterface( + XControlAccess.class, + xTextDoc.getCurrentController()); + + //now get the OFormattedControl + 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(); + + 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 = 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 = 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 000000000..4a5334044 --- /dev/null +++ b/qadevOOo/tests/java/mod/_forms/OFormattedFieldWrapper.java @@ -0,0 +1,135 @@ +/* + * This file is part of the LibreOffice project. + * + * This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. + * + * This file incorporates work covered by the following license notice: + * + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed + * with this work for additional information regarding copyright + * ownership. The ASF licenses this file to you under the Apache + * License, Version 2.0 (the "License"); you may not use this file + * except in compliance with the License. You may obtain a copy of + * the License at http://www.apache.org/licenses/LICENSE-2.0 . + */ +package mod._forms; + +import com.sun.star.beans.NamedValue; +import java.io.PrintWriter; + +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 concurrently. + * + * @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 + * @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 + */ + @Override + protected void initialize(TestParameters tParam, PrintWriter log) throws Exception { + + 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"; + + } + +} // 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 000000000..00bc2e21b --- /dev/null +++ b/qadevOOo/tests/java/mod/_forms/OFormsCollection.java @@ -0,0 +1,179 @@ +/* + * This file is part of the LibreOffice project. + * + * This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. + * + * This file incorporates work covered by the following license notice: + * + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed + * with this work for additional information regarding copyright + * ownership. The ASF licenses this file to you under the Apache + * License, Version 2.0 (the "License"); you may not use this file + * except in compliance with the License. You may obtain a copy of + * the License at http://www.apache.org/licenses/LICENSE-2.0 . + */ +package mod._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.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 concurrently. +* +* @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. + */ + @Override + protected void initialize(TestParameters tParam, PrintWriter log) throws Exception { + log.println("creating a draw document"); + xDrawDoc = DrawTools.createDrawDoc(tParam.getMSF()); + } + + /** + * Disposes drawing document. + */ + @Override + protected void cleanup(TestParameters tParam, PrintWriter log) { + log.println(" disposing xDrawDoc "); + + try { + XCloseable closer = 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> + */ + @Override + protected TestEnvironment createTestEnvironment(TestParameters Param, + PrintWriter log) + throws com.sun.star.uno.Exception + { + 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 = 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 000000000..b440f24ce --- /dev/null +++ b/qadevOOo/tests/java/mod/_forms/OGridControlModel.java @@ -0,0 +1,347 @@ +/* + * This file is part of the LibreOffice project. + * + * This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. + * + * This file incorporates work covered by the following license notice: + * + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed + * with this work for additional information regarding copyright + * ownership. The ASF licenses this file to you under the Apache + * License, Version 2.0 (the "License"); you may not use this file + * except in compliance with the License. You may obtain a copy of + * the License at http://www.apache.org/licenses/LICENSE-2.0 . + */ +package mod._forms; + +import java.io.PrintWriter; +import java.util.Comparator; + +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.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 concurrently. +* +* @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 +* @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 + */ + + @Override + protected void initialize(TestParameters tParam, PrintWriter log) throws Exception { + + super.initialize(tParam, log); + + super.m_kindOfControl="GridControl"; + + super.m_ObjectName = "stardiv.one.form.component.Grid"; + + super.m_LCShape_Type = "GridControl"; + + } + + + /** + * calls <CODE>createTestEnvironment()</CODE> from its super class + * @param Param the test parameter + * @param log the log writer + * @return lib.TestEnvironment + */ + @Override + protected TestEnvironment createTestEnvironment(TestParameters Param, + PrintWriter log) throws Exception { + 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; + + XGridColumnFactory columns = 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"); + + XNameContainer aContainer = UnoRuntime.queryInterface( + XNameContainer.class, oObj); + + aContainer.insertByName("First", aControl); + aContainer.insertByName("Second", aControl2); + + //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<Object>() { + public int compare(Object o1, Object o2) { + XNamed named1 = UnoRuntime.queryInterface( + XNamed.class, o1); + XNamed named2 = UnoRuntime.queryInterface( + XNamed.class, o2); + + if (named1.getName().equals(named2.getName())) { + return 0; + } + + return -1; + } + }); + + + return tEnv; + } + +} // finish class OButtonModelold + + +class OGridControlModelold extends TestCase { + XComponent xDrawDoc = null; + + /** + * Creates Drawing document. + */ + @Override + protected void initialize(TestParameters tParam, PrintWriter log) throws Exception { + SOfficeFactory SOF = SOfficeFactory.getFactory(tParam.getMSF()); + log.println("creating a draw document"); + xDrawDoc = SOF.createDrawDoc(null); + } + + /** + * Disposes drawing document. + */ + @Override + protected void cleanup(TestParameters tParam, PrintWriter log) { + log.println(" disposing xDrawDoc "); + + try { + XCloseable closer = 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> + */ + @Override + protected TestEnvironment createTestEnvironment(TestParameters Param, + PrintWriter log) throws Exception { + XInterface oObj = null; + XInterface oInstance = null; + XPropertySet aControl = null; + XPropertySet aControl2 = null; + XPropertySet aControl3 = null; + XPropertySet aControl4 = 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"); + + 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); + + columns = UnoRuntime.queryInterface( + XGridColumnFactory.class, oObj); + aControl = columns.createColumn("TextField"); + aControl2 = columns.createColumn("DateField"); + aControl3 = columns.createColumn("TextField"); + aControl4 = columns.createColumn("TextField"); + columns.createColumn("TextField"); + + XNameContainer aContainer = UnoRuntime.queryInterface( + XNameContainer.class, oObj); + + aContainer.insertByName("First", aControl); + aContainer.insertByName("Second", aControl2); + + //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"); + + 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); + } + + + // adding relation for XNameContainer + tEnv.addObjRelation("XNameContainer.AllowDuplicateNames", new Object()); + + // adding relation for XContainer + tEnv.addObjRelation("INSTANCE", aControl3); + tEnv.addObjRelation("INSTANCE2", aControl4); + + + 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 000000000..dea7c0058 --- /dev/null +++ b/qadevOOo/tests/java/mod/_forms/OGroupBoxControl.java @@ -0,0 +1,193 @@ +/* + * This file is part of the LibreOffice project. + * + * This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. + * + * This file incorporates work covered by the following license notice: + * + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed + * with this work for additional information regarding copyright + * ownership. The ASF licenses this file to you under the Apache + * License, Version 2.0 (the "License"); you may not use this file + * except in compliance with the License. You may obtain a copy of + * the License at http://www.apache.org/licenses/LICENSE-2.0 . + */ +package mod._forms; + +import java.io.PrintWriter; + +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.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 concurrently. + * + * @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. + */ + @Override + protected void initialize(TestParameters Param, PrintWriter log) throws Exception { + SOfficeFactory SOF = SOfficeFactory.getFactory(Param.getMSF()); + + log.println("creating a textdocument"); + xTextDoc = SOF.createTextDoc(null); + } + + /** + * Disposes the text document created before + */ + @Override + protected void cleanup(TestParameters tParam, PrintWriter log) { + log.println(" disposing xTextDoc "); + + try { + XCloseable closer = UnoRuntime.queryInterface( + XCloseable.class, xTextDoc); + closer.close(true); + } catch (com.sun.star.util.CloseVetoException e) { + log.println("couldn't close document"); + } catch (com.sun.star.lang.DisposedException e) { + log.println("couldn't close document"); + } + } + + /** + * 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> + */ + @Override + protected TestEnvironment createTestEnvironment(TestParameters Param, + PrintWriter log) throws Exception { + 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(aShape); + + XControlModel the_Model = aShape.getControl(); + + XControlShape aShape2 = FormTools.createControlShape(xTextDoc, 3000, + 4500, 5000, 10000, + "TextField"); + + WriterTools.getDrawPage(xTextDoc).add(aShape2); + + XControlModel the_Model2 = aShape2.getControl(); + + //Try to query XControlAccess + XControlAccess the_access = UnoRuntime.queryInterface( + XControlAccess.class, + xTextDoc.getCurrentController()); + + //now get the OGroupBoxControl + 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(); + + 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 000000000..dcc810bd6 --- /dev/null +++ b/qadevOOo/tests/java/mod/_forms/OGroupBoxModel.java @@ -0,0 +1,99 @@ +/* + * This file is part of the LibreOffice project. + * + * This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. + * + * This file incorporates work covered by the following license notice: + * + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed + * with this work for additional information regarding copyright + * ownership. The ASF licenses this file to you under the Apache + * License, Version 2.0 (the "License"); you may not use this file + * except in compliance with the License. You may obtain a copy of + * the License at http://www.apache.org/licenses/LICENSE-2.0 . + */ +package mod._forms; + +import java.io.PrintWriter; + +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 concurrently. + * @see com.sun.star.awt.UnoControlGroupBoxModel + * @see com.sun.star.io.XPersistObject + * @see com.sun.star.container.XChild + * @see com.sun.star.form + * @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 + */ + + @Override + protected void initialize(TestParameters tParam, PrintWriter log) throws Exception { + + 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"; + } + +} // 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 000000000..388447f50 --- /dev/null +++ b/qadevOOo/tests/java/mod/_forms/OHiddenModel.java @@ -0,0 +1,175 @@ +/* + * This file is part of the LibreOffice project. + * + * This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. + * + * This file incorporates work covered by the following license notice: + * + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed + * with this work for additional information regarding copyright + * ownership. The ASF licenses this file to you under the Apache + * License, Version 2.0 (the "License"); you may not use this file + * except in compliance with the License. You may obtain a copy of + * the License at http://www.apache.org/licenses/LICENSE-2.0 . + */ +package mod._forms; + +import com.sun.star.beans.PropertyValue; +import java.io.PrintWriter; + +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.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 concurrently. + * @see com.sun.star.io.XPersistObject + * @see com.sun.star.container.XChild + * @see com.sun.star.form + * @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. + */ + @Override + protected void initialize(TestParameters tParam, PrintWriter log) throws Exception { + SOfficeFactory SOF = SOfficeFactory.getFactory(tParam.getMSF()); + + log.println("creating a draw document"); + xDrawDoc = SOF.createDrawDoc(null); + } + + /** + * Disposes drawing document. + */ + @Override + protected void cleanup(TestParameters tParam, PrintWriter log) { + log.println(" disposing xDrawDoc "); + + try { + XCloseable closer = 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> + */ + @Override + protected TestEnvironment createTestEnvironment(TestParameters Param, + PrintWriter log) throws Exception { + 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(Param.getMSF()); + String objName = "HiddenControl"; + XInterface ctrl = SOF.createControl(xDrawDoc, objName); + + XDrawPage oDP = DrawTools.getDrawPage(xDrawDoc, 0); + + XNameContainer nc = FormTools.getForms(oDP); + FormTools.insertForm(xDrawDoc, nc, "OHiddenModelForm"); + + Object frm = nc.getByName("OHiddenModelForm"); + + XNameContainer frmNC = UnoRuntime.queryInterface( + XNameContainer.class, frm); + + frmNC.insertByName("OHiddenModel", ctrl); + oObj = (XInterface) AnyConverter.toObject( + new Type(XInterface.class), + frmNC.getByName("OHiddenModel")); + + 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 000000000..1f55ac59e --- /dev/null +++ b/qadevOOo/tests/java/mod/_forms/OImageButtonControl.java @@ -0,0 +1,198 @@ +/* + * This file is part of the LibreOffice project. + * + * This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. + * + * This file incorporates work covered by the following license notice: + * + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed + * with this work for additional information regarding copyright + * ownership. The ASF licenses this file to you under the Apache + * License, Version 2.0 (the "License"); you may not use this file + * except in compliance with the License. You may obtain a copy of + * the License at http://www.apache.org/licenses/LICENSE-2.0 . + */ +package mod._forms; + +import java.io.PrintWriter; + +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.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 concurrently. + * + * @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. + */ + @Override + protected void initialize(TestParameters Param, PrintWriter log) throws Exception { + SOfficeFactory SOF = SOfficeFactory.getFactory(Param.getMSF()); + + log.println("creating a textdocument"); + xTextDoc = SOF.createTextDoc(null); + } + + /** + * Disposes the text document created before + */ + @Override + protected void cleanup(TestParameters tParam, PrintWriter log) { + log.println(" disposing xTextDoc "); + + try { + XCloseable closer = UnoRuntime.queryInterface( + XCloseable.class, xTextDoc); + closer.close(true); + } catch (com.sun.star.util.CloseVetoException e) { + log.println("couldn't close document"); + } catch (com.sun.star.lang.DisposedException e) { + log.println("couldn't close document"); + } + } + + /** + * 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> + */ + @Override + protected TestEnvironment createTestEnvironment(TestParameters Param, + PrintWriter log) throws Exception { + 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(aShape); + + XControlModel the_Model = aShape.getControl(); + + XControlShape aShape2 = FormTools.createControlShape(xTextDoc, 3000, + 4500, 5000, 10000, + "TextField"); + + WriterTools.getDrawPage(xTextDoc).add(aShape2); + + XControlModel the_Model2 = aShape2.getControl(); + + //Try to query XControlAccess + XControlAccess the_access = UnoRuntime.queryInterface( + XControlAccess.class, + xTextDoc.getCurrentController()); + + //now get the OImageButtonControl + 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(); + + 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 = 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 000000000..0c93ba70f --- /dev/null +++ b/qadevOOo/tests/java/mod/_forms/OImageButtonModel.java @@ -0,0 +1,103 @@ +/* + * This file is part of the LibreOffice project. + * + * This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. + * + * This file incorporates work covered by the following license notice: + * + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed + * with this work for additional information regarding copyright + * ownership. The ASF licenses this file to you under the Apache + * License, Version 2.0 (the "License"); you may not use this file + * except in compliance with the License. You may obtain a copy of + * the License at http://www.apache.org/licenses/LICENSE-2.0 . + */ +package mod._forms; + +import java.io.PrintWriter; +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 concurrently. +* @see com.sun.star.io.XPersistObject +* @see com.sun.star.container.XChild +* @see com.sun.star.awt.UnoControlImageControlModel +* @see com.sun.star.form +* @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 + */ + + @Override + protected void initialize(TestParameters tParam, PrintWriter log) throws Exception { + + super.initialize(tParam, log); + + super.m_kindOfControl="ImageButton"; + + super.m_ObjectName = "stardiv.one.form.component.ImageButton"; + + super.m_LCShape_Type = "ImageButton"; + + } + +} // 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 000000000..d859264e1 --- /dev/null +++ b/qadevOOo/tests/java/mod/_forms/OImageControlControl.java @@ -0,0 +1,199 @@ +/* + * This file is part of the LibreOffice project. + * + * This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. + * + * This file incorporates work covered by the following license notice: + * + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed + * with this work for additional information regarding copyright + * ownership. The ASF licenses this file to you under the Apache + * License, Version 2.0 (the "License"); you may not use this file + * except in compliance with the License. You may obtain a copy of + * the License at http://www.apache.org/licenses/LICENSE-2.0 . + */ +package mod._forms; + +import java.io.PrintWriter; + +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.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 concurrently. + * + * @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. + */ + @Override + protected void initialize(TestParameters Param, PrintWriter log) throws Exception { + SOfficeFactory SOF = SOfficeFactory.getFactory(Param.getMSF()); + + log.println("creating a textdocument"); + xTextDoc = SOF.createTextDoc(null); + } + + /** + * Disposes the text document created before + */ + @Override + protected void cleanup(TestParameters tParam, PrintWriter log) { + log.println(" disposing xTextDoc "); + + try { + XCloseable closer = UnoRuntime.queryInterface( + XCloseable.class, xTextDoc); + closer.close(true); + } catch (com.sun.star.util.CloseVetoException e) { + log.println("couldn't close document"); + } catch (com.sun.star.lang.DisposedException e) { + log.println("couldn't close document"); + } + } + + /** + * 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> + */ + @Override + protected TestEnvironment createTestEnvironment(TestParameters Param, + PrintWriter log) throws Exception { + XInterface oObj = null; + XWindowPeer the_win = null; + XToolkit the_kit = null; + XDevice aDevice = null; + XGraphics aGraphic = null; + XControl aControl = null; + + //Insert a ControlShape and get the ControlModel + XControlShape aShape = FormTools.createControlShapeWithDefaultControl( + xTextDoc, 3000, 4500, 15000, 10000, + "DatabaseImageControl"); + + WriterTools.getDrawPage(xTextDoc).add(aShape); + + XControlModel the_Model = aShape.getControl(); + + XControlShape aShape2 = FormTools.createControlShape(xTextDoc, 3000, + 4500, 5000, 10000, + "TextField"); + + WriterTools.getDrawPage(xTextDoc).add(aShape2); + + XControlModel the_Model2 = aShape2.getControl(); + + //Try to query XControlAccess + XControlAccess the_access = UnoRuntime.queryInterface( + XControlAccess.class, + xTextDoc.getCurrentController()); + + //now get the OImageControlControl + 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(); + + 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 = 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 000000000..174bcd54d --- /dev/null +++ b/qadevOOo/tests/java/mod/_forms/OImageControlModel.java @@ -0,0 +1,134 @@ +/* + * This file is part of the LibreOffice project. + * + * This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. + * + * This file incorporates work covered by the following license notice: + * + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed + * with this work for additional information regarding copyright + * ownership. The ASF licenses this file to you under the Apache + * License, Version 2.0 (the "License"); you may not use this file + * except in compliance with the License. You may obtain a copy of + * the License at http://www.apache.org/licenses/LICENSE-2.0 . + */ +package mod._forms; + +import com.sun.star.beans.NamedValue; +import java.io.PrintWriter; + +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 concurrently. +* +* @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 +* @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 + */ + @Override + protected void initialize(TestParameters tParam, PrintWriter log) throws Exception { + + 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"; + + } + +} // 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 000000000..03dac5b1a --- /dev/null +++ b/qadevOOo/tests/java/mod/_forms/OListBoxControl.java @@ -0,0 +1,156 @@ +/* + * This file is part of the LibreOffice project. + * + * This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. + * + * This file incorporates work covered by the following license notice: + * + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed + * with this work for additional information regarding copyright + * ownership. The ASF licenses this file to you under the Apache + * License, Version 2.0 (the "License"); you may not use this file + * except in compliance with the License. You may obtain a copy of + * the License at http://www.apache.org/licenses/LICENSE-2.0 . + */ + +package mod._forms; + +import java.io.PrintWriter; + +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.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; + + @Override + protected void initialize ( TestParameters Param, PrintWriter log) throws Exception { + SOfficeFactory SOF = SOfficeFactory.getFactory( Param.getMSF() ); + log.println( "creating a textdocument" ); + xTextDoc = SOF.createTextDoc( null ); + } + + @Override + protected void cleanup(TestParameters tParam, PrintWriter log) { + log.println(" disposing xTextDoc "); + + try { + XCloseable closer = UnoRuntime.queryInterface( + XCloseable.class, xTextDoc); + closer.close(true); + } catch (com.sun.star.util.CloseVetoException e) { + log.println("couldn't close document"); + } catch (com.sun.star.lang.DisposedException e) { + log.println("couldn't close document"); + } + } + + @Override + protected TestEnvironment createTestEnvironment(TestParameters Param, PrintWriter log) throws Exception { + 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(aShape); + + XControlModel the_Model = aShape.getControl(); + + XControlShape aShape2 = FormTools.createControlShape( + xTextDoc,3000,4500,5000,10000,"TextField"); + + WriterTools.getDrawPage(xTextDoc).add(aShape2); + + XControlModel the_Model2 = aShape2.getControl(); + + //Try to query XControlAccess + XControlAccess the_access = UnoRuntime.queryInterface( + XControlAccess.class,xTextDoc.getCurrentController()); + + //now get the OListBoxControl + 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(); + + 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 = UnoRuntime.queryInterface(XListBox.class, oObj) ; + box.addItemListener(listener) ; + tEnv.addObjRelation("TestItemListener", listener) ; + + // Adding relation for XWindow + XWindow forObjRel = UnoRuntime.queryInterface(XWindow.class, anotherCtrl); + + XWindow objWin = 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 000000000..f829da701 --- /dev/null +++ b/qadevOOo/tests/java/mod/_forms/OListBoxModel.java @@ -0,0 +1,217 @@ +/* + * This file is part of the LibreOffice project. + * + * This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. + * + * This file incorporates work covered by the following license notice: + * + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed + * with this work for additional information regarding copyright + * ownership. The ASF licenses this file to you under the Apache + * License, Version 2.0 (the "License"); you may not use this file + * except in compliance with the License. You may obtain a copy of + * the License at http://www.apache.org/licenses/LICENSE-2.0 . + */ +package mod._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.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 concurrently. +* @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 +* @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 + */ + @Override + protected void initialize(TestParameters tParam, PrintWriter log) throws Exception { + + 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>createTestEnvironment()</CODE> from its super class + * This test uses not the generic implementation of <CODE>checker()</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 + */ + @Override + protected TestEnvironment createTestEnvironment(TestParameters Param, + PrintWriter log) throws Exception { + TestEnvironment tEnv = super.createTestEnvironment(Param, log); + + tEnv.addObjRelation("XUpdateBroadcaster.Checker", + new Checker(m_XFormLoader, m_XPS, m_XCtrl, m_ChangePropertyName)); + return tEnv; + } + + private static class Checker implements UpdateChecker { + private short lastItem = (short) 0; + private XLoadable formLoaderF = null; + private XPropertySet ps = null; + private XInterface ctrl = null; + private String ChangePropertyName = null; + + public Checker(XLoadable xl, XPropertySet ps, XInterface ctrl, String ChangePropertyName) { + formLoaderF = xl; + this.ps = ps; + this.ctrl = ctrl; + this.ChangePropertyName=ChangePropertyName; + } + + public void update() throws com.sun.star.uno.Exception { + if (!formLoaderF.isLoaded()) { + formLoaderF.load(); + } + lastItem = (short) (1 - lastItem); + ps.setPropertyValue(ChangePropertyName, new short[] { lastItem }); + } + + public void commit() throws SQLException { + XBoundComponent bound = UnoRuntime.queryInterface( + XBoundComponent.class, ctrl); + XResultSetUpdate update = UnoRuntime.queryInterface( + XResultSetUpdate.class, + formLoaderF); + + bound.commit(); + update.updateRow(); + } + + public boolean wasCommited() throws com.sun.star.uno.Exception { + 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 000000000..cec4696cd --- /dev/null +++ b/qadevOOo/tests/java/mod/_forms/ONavigationBarControl.java @@ -0,0 +1,159 @@ +/* + * This file is part of the LibreOffice project. + * + * This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. + * + * This file incorporates work covered by the following license notice: + * + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed + * with this work for additional information regarding copyright + * ownership. The ASF licenses this file to you under the Apache + * License, Version 2.0 (the "License"); you may not use this file + * except in compliance with the License. You may obtain a copy of + * the License at http://www.apache.org/licenses/LICENSE-2.0 . + */ +package mod._forms; + +import java.io.PrintWriter; + +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.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. + */ + @Override + protected void initialize(TestParameters Param, PrintWriter log) throws Exception { + SOfficeFactory SOF = SOfficeFactory.getFactory(Param.getMSF()); + + log.println("creating a textdocument"); + xTextDoc = SOF.createTextDoc(null); + } + + /** + * Disposes the text document created before + */ + @Override + 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> + */ + @Override + protected TestEnvironment createTestEnvironment(TestParameters Param, + PrintWriter log) throws Exception { + XInterface oObj = null; + XWindowPeer the_win = null; + XToolkit the_kit = null; + XDevice aDevice = null; + XGraphics aGraphic = null; + XControl aControl = null; + + //Insert a ControlShape and get the ControlModel + XControlShape aShape = FormTools.createControlShape(xTextDoc, 3000, + 4500, 15000, 10000, + "NavigationToolBar"); + + WriterTools.getDrawPage(xTextDoc).add(aShape); + + XControlModel the_Model = aShape.getControl(); + + XControlShape aShape2 = FormTools.createControlShape(xTextDoc, 3000, + 4500, 5000, 10000, + "TextField"); + + WriterTools.getDrawPage(xTextDoc).add(aShape2); + + XControlModel the_Model2 = aShape2.getControl(); + + //Try to query XControlAccess + XControlAccess the_access = UnoRuntime.queryInterface( + XControlAccess.class, + xTextDoc.getCurrentController()); + + //now get the OButtonControl + 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(); + + 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 = 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 000000000..030a9b011 --- /dev/null +++ b/qadevOOo/tests/java/mod/_forms/ONavigationBarModel.java @@ -0,0 +1,52 @@ +/* + * This file is part of the LibreOffice project. + * + * This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. + * + * This file incorporates work covered by the following license notice: + * + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed + * with this work for additional information regarding copyright + * ownership. The ASF licenses this file to you under the Apache + * License, Version 2.0 (the "License"); you may not use this file + * except in compliance with the License. You may obtain a copy of + * the License at http://www.apache.org/licenses/LICENSE-2.0 . + */ + +package mod._forms; + +import java.io.PrintWriter; +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 + */ + + @Override + protected void initialize(TestParameters tParam, PrintWriter log) throws Exception { + + super.initialize(tParam, log); + + super.m_kindOfControl="NavigationToolBar"; + + super.m_ObjectName = "com.sun.star.form.component.NavigationToolBar"; + + super.m_LCShape_Type = "NavigationToolBar"; + + } + +} // 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 000000000..843e5c8a9 --- /dev/null +++ b/qadevOOo/tests/java/mod/_forms/ONumericControl.java @@ -0,0 +1,224 @@ +/* + * This file is part of the LibreOffice project. + * + * This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. + * + * This file incorporates work covered by the following license notice: + * + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed + * with this work for additional information regarding copyright + * ownership. The ASF licenses this file to you under the Apache + * License, Version 2.0 (the "License"); you may not use this file + * except in compliance with the License. You may obtain a copy of + * the License at http://www.apache.org/licenses/LICENSE-2.0 . + */ +package mod._forms; + +import java.io.PrintWriter; + +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.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 concurrently. + * + * @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. + */ + @Override + protected void initialize(TestParameters Param, PrintWriter log) throws Exception { + SOfficeFactory SOF = SOfficeFactory.getFactory(Param.getMSF()); + + log.println("creating a textdocument"); + xTextDoc = SOF.createTextDoc(null); + } + + /** + * Disposes the text document created before + */ + @Override + protected void cleanup(TestParameters tParam, PrintWriter log) { + log.println(" disposing xTextDoc "); + + try { + XCloseable closer = UnoRuntime.queryInterface( + XCloseable.class, xTextDoc); + closer.close(true); + } catch (com.sun.star.util.CloseVetoException e) { + log.println("couldn't close document"); + } catch (com.sun.star.lang.DisposedException e) { + log.println("couldn't close document"); + } + } + + /** + * 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> + */ + @Override + protected TestEnvironment createTestEnvironment(TestParameters Param, + PrintWriter log) throws Exception { + 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(aShape); + + XControlModel the_Model = aShape.getControl(); + + XControlShape aShape2 = FormTools.createControlShape(xTextDoc, 3000, + 4500, 5000, 10000, + "TextField"); + + WriterTools.getDrawPage(xTextDoc).add(aShape2); + + XControlModel the_Model2 = aShape2.getControl(); + + //Try to query XControlAccess + XControlAccess the_access = UnoRuntime.queryInterface( + XControlAccess.class, + xTextDoc.getCurrentController()); + + //now get the ONumericControl + 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(); + + 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 = 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 = UnoRuntime.queryInterface( + XTextComponent.class, oObj); + textComp.addTextListener(listener); + tEnv.addObjRelation("TestTextListener", listener); + + tEnv.addObjRelation("XTextComponent.onlyNumbers", 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 000000000..23f26b0e5 --- /dev/null +++ b/qadevOOo/tests/java/mod/_forms/ONumericModel.java @@ -0,0 +1,133 @@ +/* + * This file is part of the LibreOffice project. + * + * This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. + * + * This file incorporates work covered by the following license notice: + * + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed + * with this work for additional information regarding copyright + * ownership. The ASF licenses this file to you under the Apache + * License, Version 2.0 (the "License"); you may not use this file + * except in compliance with the License. You may obtain a copy of + * the License at http://www.apache.org/licenses/LICENSE-2.0 . + */ +package mod._forms; + +import com.sun.star.beans.NamedValue; +import java.io.PrintWriter; + +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 concurrently. +* @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 +* @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 + */ + @Override + protected void initialize(TestParameters tParam, PrintWriter log) throws Exception { + + 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"; + + } + +} // 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 000000000..4c67dabd9 --- /dev/null +++ b/qadevOOo/tests/java/mod/_forms/OPatternControl.java @@ -0,0 +1,222 @@ +/* + * This file is part of the LibreOffice project. + * + * This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. + * + * This file incorporates work covered by the following license notice: + * + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed + * with this work for additional information regarding copyright + * ownership. The ASF licenses this file to you under the Apache + * License, Version 2.0 (the "License"); you may not use this file + * except in compliance with the License. You may obtain a copy of + * the License at http://www.apache.org/licenses/LICENSE-2.0 . + */ +package mod._forms; + +import java.io.PrintWriter; + +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.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 concurrently. + * + * @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. + */ + @Override + protected void initialize(TestParameters Param, PrintWriter log) throws Exception { + SOfficeFactory SOF = SOfficeFactory.getFactory(Param.getMSF()); + + log.println("creating a textdocument"); + xTextDoc = SOF.createTextDoc(null); + } + + /** + * Disposes the text document created before + */ + @Override + protected void cleanup(TestParameters tParam, PrintWriter log) { + log.println(" disposing xTextDoc "); + + try { + XCloseable closer = UnoRuntime.queryInterface( + XCloseable.class, xTextDoc); + closer.close(true); + } catch (com.sun.star.util.CloseVetoException e) { + log.println("couldn't close document"); + } catch (com.sun.star.lang.DisposedException e) { + log.println("couldn't close document"); + } + } + + /** + * 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> + */ + @Override + protected TestEnvironment createTestEnvironment(TestParameters Param, + PrintWriter log) throws Exception { + 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(aShape); + + XControlModel the_Model = aShape.getControl(); + + XControlShape aShape2 = FormTools.createControlShape(xTextDoc, 3000, + 4500, 5000, 10000, + "TextField"); + + WriterTools.getDrawPage(xTextDoc).add(aShape2); + + XControlModel the_Model2 = aShape2.getControl(); + + //Try to query XControlAccess + XControlAccess the_access = UnoRuntime.queryInterface( + XControlAccess.class, + xTextDoc.getCurrentController()); + + //now get the OPatternControl + 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(); + + 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 = 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 = 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 000000000..0bec8f499 --- /dev/null +++ b/qadevOOo/tests/java/mod/_forms/OPatternModel.java @@ -0,0 +1,138 @@ +/* + * This file is part of the LibreOffice project. + * + * This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. + * + * This file incorporates work covered by the following license notice: + * + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed + * with this work for additional information regarding copyright + * ownership. The ASF licenses this file to you under the Apache + * License, Version 2.0 (the "License"); you may not use this file + * except in compliance with the License. You may obtain a copy of + * the License at http://www.apache.org/licenses/LICENSE-2.0 . + */ +package mod._forms; + +import com.sun.star.beans.NamedValue; +import java.io.PrintWriter; + +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 concurrently. + * + * @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 + * @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 + */ + @Override + protected void initialize(TestParameters tParam, PrintWriter log) throws Exception { + + 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"; + + } + +} // 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 000000000..0fd3ce626 --- /dev/null +++ b/qadevOOo/tests/java/mod/_forms/ORadioButtonControl.java @@ -0,0 +1,201 @@ +/* + * This file is part of the LibreOffice project. + * + * This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. + * + * This file incorporates work covered by the following license notice: + * + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed + * with this work for additional information regarding copyright + * ownership. The ASF licenses this file to you under the Apache + * License, Version 2.0 (the "License"); you may not use this file + * except in compliance with the License. You may obtain a copy of + * the License at http://www.apache.org/licenses/LICENSE-2.0 . + */ +package mod._forms; + +import java.io.PrintWriter; + +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.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 concurrently. + * + * @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. + */ + @Override + protected void initialize(TestParameters Param, PrintWriter log) throws Exception { + SOfficeFactory SOF = SOfficeFactory.getFactory(Param.getMSF()); + + log.println("creating a textdocument"); + xTextDoc = SOF.createTextDoc(null); + } + + /** + * Disposes the text document created before + */ + @Override + protected void cleanup(TestParameters tParam, PrintWriter log) { + log.println(" disposing xTextDoc "); + + try { + XCloseable closer = UnoRuntime.queryInterface( + XCloseable.class, xTextDoc); + closer.close(true); + } catch (com.sun.star.util.CloseVetoException e) { + log.println("couldn't close document"); + } catch (com.sun.star.lang.DisposedException e) { + log.println("couldn't close document"); + } + } + + /** + * 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> + */ + @Override + protected TestEnvironment createTestEnvironment(TestParameters Param, + PrintWriter log) throws Exception { + XInterface oObj = null; + XWindowPeer the_win = null; + XToolkit the_kit = null; + XDevice aDevice = null; + XGraphics aGraphic = null; + XControl aControl = null; + + //Insert a ControlShape and get the ControlModel + XControlShape aShape = FormTools.createControlShape(xTextDoc, 3000, + 4500, 15000, 10000, + "RadioButton"); + + WriterTools.getDrawPage(xTextDoc).add(aShape); + + XControlModel the_Model = aShape.getControl(); + + XControlShape aShape2 = FormTools.createControlShape(xTextDoc, 3000, + 4500, 5000, 10000, + "TextField"); + + WriterTools.getDrawPage(xTextDoc).add(aShape2); + + XControlModel the_Model2 = aShape2.getControl(); + + //Try to query XControlAccess + XControlAccess the_access = UnoRuntime.queryInterface( + XControlAccess.class, + xTextDoc.getCurrentController()); + + //now get the ORadioButtonControl + 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(); + + 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 = 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 000000000..d65c07064 --- /dev/null +++ b/qadevOOo/tests/java/mod/_forms/ORadioButtonModel.java @@ -0,0 +1,157 @@ +/* + * This file is part of the LibreOffice project. + * + * This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. + * + * This file incorporates work covered by the following license notice: + * + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed + * with this work for additional information regarding copyright + * ownership. The ASF licenses this file to you under the Apache + * License, Version 2.0 (the "License"); you may not use this file + * except in compliance with the License. You may obtain a copy of + * the License at http://www.apache.org/licenses/LICENSE-2.0 . + */ +package mod._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 concurrently. +* @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 +* @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 + */ + + @Override + protected void initialize(TestParameters tParam, PrintWriter log) throws Exception { + + 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>createTestEnvironment()</CODE> from its super class + * @param Param the test parameter + * @param log the log writer + * @return lib.TestEnvironment + */ + @Override + protected TestEnvironment createTestEnvironment(TestParameters Param, + PrintWriter log) throws Exception { + 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 000000000..cd6c24161 --- /dev/null +++ b/qadevOOo/tests/java/mod/_forms/OScrollBarModel.java @@ -0,0 +1,93 @@ +/* + * This file is part of the LibreOffice project. + * + * This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. + * + * This file incorporates work covered by the following license notice: + * + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed + * with this work for additional information regarding copyright + * ownership. The ASF licenses this file to you under the Apache + * License, Version 2.0 (the "License"); you may not use this file + * except in compliance with the License. You may obtain a copy of + * the License at http://www.apache.org/licenses/LICENSE-2.0 . + */ + +package mod._forms; + +import com.sun.star.beans.PropertyValue; +import com.sun.star.drawing.XControlShape; +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. + */ + @Override + protected void initialize( TestParameters tParam, PrintWriter log ) throws Exception { + + log.println( "creating a textdocument" ); + xTextDoc = WriterTools.createTextDoc(tParam.getMSF()); + } + + /** + * Disposes the Writer document. + */ + @Override + protected void cleanup(TestParameters tParam, PrintWriter log) { + log.println(" disposing xTextDoc "); + + try { + XCloseable closer = UnoRuntime.queryInterface( + XCloseable.class, xTextDoc); + closer.close(true); + } catch (com.sun.star.util.CloseVetoException e) { + log.println("couldn't close document"); + } catch (com.sun.star.lang.DisposedException e) { + log.println("couldn't close document"); + } + } + + @Override + protected TestEnvironment createTestEnvironment(TestParameters Param, PrintWriter log) + throws com.sun.star.uno.Exception + { + + XInterface oObj = null; + + XControlShape aShape = FormTools.createControlShape( + xTextDoc,3000,4500,15000,10000,"ScrollBar"); + + WriterTools.getDrawPage(xTextDoc).add(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 000000000..d4864f285 --- /dev/null +++ b/qadevOOo/tests/java/mod/_forms/OSpinButtonModel.java @@ -0,0 +1,95 @@ +/* + * This file is part of the LibreOffice project. + * + * This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. + * + * This file incorporates work covered by the following license notice: + * + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed + * with this work for additional information regarding copyright + * ownership. The ASF licenses this file to you under the Apache + * License, Version 2.0 (the "License"); you may not use this file + * except in compliance with the License. You may obtain a copy of + * the License at http://www.apache.org/licenses/LICENSE-2.0 . + */ + +package mod._forms; + +import com.sun.star.beans.PropertyValue; +import com.sun.star.drawing.XControlShape; +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. + */ + @Override + protected void initialize( TestParameters tParam, PrintWriter log ) throws Exception { + + log.println( "creating a textdocument" ); + xTextDoc = WriterTools.createTextDoc(tParam.getMSF()); + } + + /** + * Disposes the Writer document. + */ + @Override + protected void cleanup(TestParameters tParam, PrintWriter log) { + log.println(" disposing xTextDoc "); + + try { + XCloseable closer = UnoRuntime.queryInterface( + XCloseable.class, xTextDoc); + closer.close(true); + } catch (com.sun.star.util.CloseVetoException e) { + log.println("couldn't close document"); + } catch (com.sun.star.lang.DisposedException e) { + log.println("couldn't close document"); + } + } + + + /** + * Creating a TestEnvironment for the interfaces to be tested. + * Adds spin button into text and retrieves it's control model. + */ + @Override + protected TestEnvironment createTestEnvironment(TestParameters Param, PrintWriter log) + throws com.sun.star.uno.Exception + { + XInterface oObj = null; + + XControlShape aShape = FormTools.createControlShape( + xTextDoc,3000,4500,15000,10000,"SpinButton"); + + WriterTools.getDrawPage(xTextDoc).add(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 000000000..01c8f17b4 --- /dev/null +++ b/qadevOOo/tests/java/mod/_forms/OTimeControl.java @@ -0,0 +1,224 @@ +/* + * This file is part of the LibreOffice project. + * + * This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. + * + * This file incorporates work covered by the following license notice: + * + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed + * with this work for additional information regarding copyright + * ownership. The ASF licenses this file to you under the Apache + * License, Version 2.0 (the "License"); you may not use this file + * except in compliance with the License. You may obtain a copy of + * the License at http://www.apache.org/licenses/LICENSE-2.0 . + */ +package mod._forms; + +import java.io.PrintWriter; + +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.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 concurrently. + * + * @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. + */ + @Override + protected void initialize(TestParameters Param, PrintWriter log) throws Exception { + SOfficeFactory SOF = SOfficeFactory.getFactory(Param.getMSF()); + + log.println("creating a textdocument"); + xTextDoc = SOF.createTextDoc(null); + } + + /** + * Disposes the text document created before + */ + @Override + protected void cleanup(TestParameters tParam, PrintWriter log) { + log.println(" disposing xTextDoc "); + + try { + XCloseable closer = UnoRuntime.queryInterface( + XCloseable.class, xTextDoc); + closer.close(true); + } catch (com.sun.star.util.CloseVetoException e) { + log.println("couldn't close document"); + } catch (com.sun.star.lang.DisposedException e) { + log.println("couldn't close document"); + } + } + + /** + * 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> + */ + @Override + protected TestEnvironment createTestEnvironment(TestParameters Param, + PrintWriter log) throws Exception { + XInterface oObj = null; + XWindowPeer the_win = null; + XToolkit the_kit = null; + XDevice aDevice = null; + XGraphics aGraphic = null; + XControl aControl = null; + + //Insert a ControlShape and get the ControlModel + XControlShape aShape = FormTools.createControlShape(xTextDoc, 3000, + 4500, 15000, 10000, + "TimeField"); + + WriterTools.getDrawPage(xTextDoc).add(aShape); + + XControlModel the_Model = aShape.getControl(); + + XControlShape aShape2 = FormTools.createControlShape(xTextDoc, 3000, + 4500, 5000, 10000, + "TextField"); + + WriterTools.getDrawPage(xTextDoc).add(aShape2); + + XControlModel the_Model2 = aShape2.getControl(); + + //Try to query XControlAccess + XControlAccess the_access = UnoRuntime.queryInterface( + XControlAccess.class, + xTextDoc.getCurrentController()); + + //now get the OTimeControl + 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(); + + 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 = 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 = UnoRuntime.queryInterface( + XTextComponent.class, oObj); + textComp.addTextListener(listener); + tEnv.addObjRelation("TestTextListener", listener); + + FormTools.switchDesignOf(Param.getMSF(), xTextDoc); + + return tEnv; + } // finish method getTestEnvironment +} // 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 000000000..8dda139e5 --- /dev/null +++ b/qadevOOo/tests/java/mod/_forms/OTimeModel.java @@ -0,0 +1,214 @@ +/* + * This file is part of the LibreOffice project. + * + * This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. + * + * This file incorporates work covered by the following license notice: + * + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed + * with this work for additional information regarding copyright + * ownership. The ASF licenses this file to you under the Apache + * License, Version 2.0 (the "License"); you may not use this file + * except in compliance with the License. You may obtain a copy of + * the License at http://www.apache.org/licenses/LICENSE-2.0 . + */ +package mod._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 concurrently. +* @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 +* @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 + */ + @Override + protected void initialize(TestParameters tParam, PrintWriter log) throws Exception { + + 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>createTestEnvironment()</CODE> from its super class + * This test uses not the generic implementation of <CODE>checker()</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 + */ + @Override + protected TestEnvironment createTestEnvironment(TestParameters Param, + PrintWriter log) throws Exception { + TestEnvironment tEnv = super.createTestEnvironment(Param, log); + + tEnv.addObjRelation("XUpdateBroadcaster.Checker", + new Checker(m_XFormLoader, m_XPS, m_XCtrl)); + return tEnv; + } + + private static class Checker implements UpdateChecker { + private XLoadable formLoaderF = null; + private XPropertySet ps = null; + private XInterface ctrl = null; + + public Checker(XLoadable xl, XPropertySet ps, XInterface ctrl) { + formLoaderF = xl; + this.ps = ps; + this.ctrl = ctrl; + } + + 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", Integer.valueOf(lastTime)); + } + + public void commit() throws com.sun.star.sdbc.SQLException { + XBoundComponent bound = UnoRuntime.queryInterface( + XBoundComponent.class, ctrl); + XResultSetUpdate update = UnoRuntime.queryInterface( + XResultSetUpdate.class, + formLoaderF); + + bound.commit(); + update.updateRow(); + } + + public boolean wasCommited() throws com.sun.star.uno.Exception { + 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 000000000..895d60e46 --- /dev/null +++ b/qadevOOo/tests/java/mod/_forms/package.html @@ -0,0 +1,23 @@ +<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 3.2//EN"> +<!-- + * This file is part of the LibreOffice project. + * + * This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. + * + * This file incorporates work covered by the following license notice: + * + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed + * with this work for additional information regarding copyright + * ownership. The ASF licenses this file to you under the Apache + * License, Version 2.0 (the "License"); you may not use this file + * except in compliance with the License. You may obtain a copy of + * the License at http://www.apache.org/licenses/LICENSE-2.0 . +--> +<HTML> +<BODY> +<P>Contains all test cases for the module 'forms'.</P> +</BODY> +</HTML> |