Kaydet (Commit) 5dfb4800 authored tarafından Vladimir Glazounov's avatar Vladimir Glazounov

INTEGRATION: CWS qadev21 (1.3.106); FILE MERGED

2005/01/19 17:35:48 cn 1.3.106.1: #i40688# redesign of test: uses GenericModelTest
üst e6b03b87
...@@ -2,9 +2,9 @@ ...@@ -2,9 +2,9 @@
* *
* $RCSfile: OImageControlModel.java,v $ * $RCSfile: OImageControlModel.java,v $
* *
* $Revision: 1.3 $ * $Revision: 1.4 $
* *
* last change:$Date: 2003-09-08 11:49:56 $ * last change:$Date: 2005-02-24 17:43:25 $
* *
* The Contents of this file are made available subject to the terms of * The Contents of this file are made available subject to the terms of
* either of the following licenses * either of the following licenses
...@@ -60,6 +60,7 @@ ...@@ -60,6 +60,7 @@
************************************************************************/ ************************************************************************/
package mod._forms; package mod._forms;
import com.sun.star.beans.NamedValue;
import java.io.PrintWriter; import java.io.PrintWriter;
import lib.StatusException; import lib.StatusException;
...@@ -149,130 +150,57 @@ import com.sun.star.util.XCloseable; ...@@ -149,130 +150,57 @@ import com.sun.star.util.XCloseable;
* @see ifc.form._XLoadListener * @see ifc.form._XLoadListener
* @see ifc.container._XChild * @see ifc.container._XChild
*/ */
public class OImageControlModel extends TestCase { public class OImageControlModel extends GenericModelTest {
XTextDocument xTextDoc;
/** /**
* Creates Text document. * Set some member variable of the super class <CODE>GenericModelTest</CODE>:
*/ * <pre>
* super.m_kindOfControl="DatabaseImageControl";
* super.m_ObjectName = "stardiv.one.form.component.DatabaseImageControl";
* NamedValue DataField = new NamedValue();
* DataField.Name = "DataField";
* DataField.Value = DBTools.TST_BINARY_STREAM_F;
* super.m_propertiesToSet.add(DataField);
*
* super.m_LCShape_Type = "FixedText";
* </pre>
* Then <CODE>super.initialize()</CODE> was called.
* @param tParam the test parameter
* @param log the log writer
*/
protected void initialize(TestParameters tParam, PrintWriter log) { protected void initialize(TestParameters tParam, PrintWriter log) {
log.println("creating a text document");
xTextDoc = WriterTools.createTextDoc(((XMultiServiceFactory) tParam.getMSF()));
}
/**
* Disposes Text document.
*/
protected void cleanup(TestParameters tParam, PrintWriter log) {
log.println(" disposing xTextDoc ");
try {
XCloseable closer = (XCloseable) UnoRuntime.queryInterface(
XCloseable.class, xTextDoc);
closer.close(true);
} catch (com.sun.star.util.CloseVetoException e) {
log.println("couldn't close document");
} catch (com.sun.star.lang.DisposedException e) {
log.println("couldn't close document");
}
}
/**
* Creating a Testenvironment for the interfaces to be tested.
* First <code>TestDB</code> database is registered.
* Creates ImageControl in the Form, then binds it to TestDB
* database and returns component'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>'DataAwareControlModel.NewFieldName'</code> : for
* <code>com.sun.star.form.DataAwareControlModel</code> service
* which contains new name of the field to bind control to.
* </li>
* </ul>
*/
protected synchronized TestEnvironment createTestEnvironment(TestParameters Param,
PrintWriter log) {
XInterface oObj = null;
// creation of testobject here
// first we write what we are intend to do to log file
log.println("creating a test environment");
String objName = "DatabaseImageControl";
XControlShape aShape = FormTools.createControlShape(xTextDoc, 3000,
4500, 15000, 10000,
objName);
WriterTools.getDrawPage(xTextDoc).add((XShape) aShape); super.m_kindOfControl="DatabaseImageControl";
oObj = aShape.getControl();
XLoadable formLoader = null; super.m_ObjectName = "stardiv.one.form.component.ImageControl";
try { NamedValue DataField = new NamedValue();
DBTools dbTools = new DBTools(((XMultiServiceFactory) Param.getMSF())); DataField.Name = "DataField";
dbTools.registerTestDB((String) System.getProperty("DOCPTH")); DataField.Value = DBTools.TST_BINARY_STREAM_F;
super.m_propertiesToSet.add(DataField);
formLoader = FormTools.bindForm(xTextDoc, "APITestDatabase", super.m_LCShape_Type = "FixedText";
"TestDB");
} catch (com.sun.star.uno.Exception e) {
log.println("!!! Can't access TestDB !!!");
e.printStackTrace(log);
throw new StatusException("Can't access TestDB", e);
}
final XPropertySet ps = (XPropertySet) UnoRuntime.queryInterface( super.initialize(tParam, log);
XPropertySet.class, oObj);
try {
ps.setPropertyValue("DataField", DBTools.TST_BINARY_STREAM_F);
} catch (com.sun.star.lang.WrappedTargetException e) {
e.printStackTrace(log);
throw new StatusException("Couldn't set Default Date", e);
} catch (com.sun.star.lang.IllegalArgumentException e) {
e.printStackTrace(log);
throw new StatusException("Couldn't set Default Date", e);
} catch (com.sun.star.beans.PropertyVetoException e) {
e.printStackTrace(log);
throw new StatusException("Couldn't set Default Date", e);
} catch (com.sun.star.beans.UnknownPropertyException e) {
e.printStackTrace(log);
throw new StatusException("Couldn't set Default Date", e);
}
aShape = FormTools.createControlShape(xTextDoc, 6000, 4500, 15000,
10000, "FixedText");
WriterTools.getDrawPage(xTextDoc).add((XShape) aShape);
log.println("creating a new environment for drawpage object");
TestEnvironment tEnv = new TestEnvironment(oObj);
tEnv.addObjRelation("OBJNAME",
"stardiv.one.form.component.ImageControl");
// adding relations for DataAwareControlModel service
tEnv.addObjRelation("DataAwareControlModel.NewFieldName",
DBTools.TST_CHARACTER_STREAM_F);
tEnv.addObjRelation("FL", formLoader);
tEnv.addObjRelation("LC", aShape.getControl());
}
/**
* calls <CODE>cleanup()</CODE> from it's super class
* @param tParam the test parameter
* @param log the log writer
*/
protected void cleanup(TestParameters tParam, PrintWriter log) {
super.cleanup(tParam, log);
}
//adding ObjRelation for XPersistObject
tEnv.addObjRelation("PSEUDOPERSISTENT", new Boolean(true));
return tEnv; /**
} // finish method getTestEnvironment * calls <CODE>createTestEnvironment()</CODE> from it's super class
* @param Param the test parameter
* @param log the log writer
* @return lib.TestEnvironment
*/
protected synchronized TestEnvironment createTestEnvironment(TestParameters Param,
PrintWriter log) {
return super.createTestEnvironment(Param, log);
}
} // finish class OImageControlModel } // finish class OImageControlModel
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment