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

INTEGRATION: CWS qadev11 (1.2.14); FILE MERGED

2003/09/03 15:33:11 sw 1.2.14.1: #112049#
üst 45020445
...@@ -2,9 +2,9 @@ ...@@ -2,9 +2,9 @@
* *
* $RCSfile: OTimeControl.java,v $ * $RCSfile: OTimeControl.java,v $
* *
* $Revision: 1.2 $ * $Revision: 1.3 $
* *
* last change:$Date: 2003-05-27 12:46:11 $ * last change:$Date: 2003-09-08 11:51:33 $
* *
* 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
...@@ -58,11 +58,19 @@ ...@@ -58,11 +58,19 @@
* *
* *
************************************************************************/ ************************************************************************/
package mod._forms; package mod._forms;
import java.io.PrintWriter;
import lib.StatusException;
import lib.TestCase;
import lib.TestEnvironment;
import lib.TestParameters;
import util.FormTools;
import util.SOfficeFactory;
import util.WriterTools;
import com.sun.star.awt.XControl; import com.sun.star.awt.XControl;
import com.sun.star.lang.XMultiServiceFactory;
import com.sun.star.awt.XControlModel; import com.sun.star.awt.XControlModel;
import com.sun.star.awt.XDevice; import com.sun.star.awt.XDevice;
import com.sun.star.awt.XGraphics; import com.sun.star.awt.XGraphics;
...@@ -72,18 +80,13 @@ import com.sun.star.awt.XWindow; ...@@ -72,18 +80,13 @@ import com.sun.star.awt.XWindow;
import com.sun.star.awt.XWindowPeer; import com.sun.star.awt.XWindowPeer;
import com.sun.star.drawing.XControlShape; import com.sun.star.drawing.XControlShape;
import com.sun.star.drawing.XShape; import com.sun.star.drawing.XShape;
import com.sun.star.lang.XMultiServiceFactory;
import com.sun.star.text.XTextDocument; import com.sun.star.text.XTextDocument;
import com.sun.star.uno.UnoRuntime; import com.sun.star.uno.UnoRuntime;
import com.sun.star.uno.XInterface; import com.sun.star.uno.XInterface;
import com.sun.star.util.XCloseable;
import com.sun.star.view.XControlAccess; import com.sun.star.view.XControlAccess;
import java.io.PrintWriter;
import lib.StatusException;
import lib.TestCase;
import lib.TestEnvironment;
import lib.TestParameters;
import util.FormTools;
import util.SOfficeFactory;
import util.WriterTools;
/** /**
* Test for object which is represented by default controller * Test for object which is represented by default controller
...@@ -131,31 +134,39 @@ import util.WriterTools; ...@@ -131,31 +134,39 @@ import util.WriterTools;
* @see ifc.lang._XEventListener * @see ifc.lang._XEventListener
*/ */
public class OTimeControl extends TestCase { public class OTimeControl extends TestCase {
XTextDocument xTextDoc; XTextDocument xTextDoc;
/** /**
* Creates a new text document. * Creates a new text document.
*/ */
protected void initialize ( TestParameters Param, PrintWriter log) { protected void initialize(TestParameters Param, PrintWriter log) {
SOfficeFactory SOF = SOfficeFactory.getFactory( (XMultiServiceFactory)Param.getMSF() ); SOfficeFactory SOF = SOfficeFactory.getFactory(((XMultiServiceFactory) Param.getMSF()));
try { try {
log.println( "creating a textdocument" ); log.println("creating a textdocument");
xTextDoc = SOF.createTextDoc( null ); xTextDoc = SOF.createTextDoc(null);
} catch ( com.sun.star.uno.Exception e ) { } catch (com.sun.star.uno.Exception e) {
// Some exception occures.FAILED // Some exception occures.FAILED
e.printStackTrace( log ); e.printStackTrace(log);
throw new StatusException( "Couldn't create document", e ); throw new StatusException("Couldn't create document", e);
} }
} }
/** /**
* Disposes the text document created before * Disposes the text document created before
*/ */
protected void cleanup( TestParameters tParam, PrintWriter log ) { protected void cleanup(TestParameters tParam, PrintWriter log) {
log.println( " disposing xTextDoc " ); log.println(" disposing xTextDoc ");
xTextDoc.dispose();
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");
}
} }
/** /**
...@@ -187,25 +198,27 @@ public class OTimeControl extends TestCase { ...@@ -187,25 +198,27 @@ public class OTimeControl extends TestCase {
* component. </li> * component. </li>
* </ul> * </ul>
*/ */
public TestEnvironment createTestEnvironment( TestParameters Param, protected TestEnvironment createTestEnvironment(TestParameters Param,
PrintWriter log ) PrintWriter log) {
throws StatusException {
XInterface oObj = null; XInterface oObj = null;
XWindowPeer the_win = null; XWindowPeer the_win = null;
XToolkit the_kit = null; XToolkit the_kit = null;
XDevice aDevice = null; XDevice aDevice = null;
XGraphics aGraphic = null; XGraphics aGraphic = null;
XControl aControl = null; XControl aControl = null;
//Insert a ControlShape and get the ControlModel //Insert a ControlShape and get the ControlModel
XControlShape aShape = FormTools.createControlShape( XControlShape aShape = FormTools.createControlShape(xTextDoc, 3000,
xTextDoc,3000,4500,15000,10000,"TimeField"); 4500, 15000, 10000,
"TimeField");
WriterTools.getDrawPage(xTextDoc).add((XShape) aShape); WriterTools.getDrawPage(xTextDoc).add((XShape) aShape);
XControlModel the_Model = aShape.getControl(); XControlModel the_Model = aShape.getControl();
XControlShape aShape2 = FormTools.createControlShape( XControlShape aShape2 = FormTools.createControlShape(xTextDoc, 3000,
xTextDoc,3000,4500,5000,10000,"TextField"); 4500, 5000, 10000,
"TextField");
WriterTools.getDrawPage(xTextDoc).add((XShape) aShape2); WriterTools.getDrawPage(xTextDoc).add((XShape) aShape2);
...@@ -213,7 +226,8 @@ public class OTimeControl extends TestCase { ...@@ -213,7 +226,8 @@ public class OTimeControl extends TestCase {
//Try to query XControlAccess //Try to query XControlAccess
XControlAccess the_access = (XControlAccess) UnoRuntime.queryInterface( XControlAccess the_access = (XControlAccess) UnoRuntime.queryInterface(
XControlAccess.class,xTextDoc.getCurrentController()); XControlAccess.class,
xTextDoc.getCurrentController());
//now get the OTimeControl //now get the OTimeControl
try { try {
...@@ -221,42 +235,46 @@ public class OTimeControl extends TestCase { ...@@ -221,42 +235,46 @@ public class OTimeControl extends TestCase {
aControl = the_access.getControl(the_Model2); aControl = the_access.getControl(the_Model2);
the_win = the_access.getControl(the_Model).getPeer(); the_win = the_access.getControl(the_Model).getPeer();
the_kit = the_win.getToolkit(); the_kit = the_win.getToolkit();
aDevice = the_kit.createScreenCompatibleDevice(200,200); aDevice = the_kit.createScreenCompatibleDevice(200, 200);
aGraphic = aDevice.createGraphics(); aGraphic = aDevice.createGraphics();
} catch (com.sun.star.container.NoSuchElementException e) { } catch (com.sun.star.container.NoSuchElementException e) {
log.println("Couldn't get OTimeControl"); log.println("Couldn't get OTimeControl");
e.printStackTrace(log); e.printStackTrace(log);
throw new StatusException("Couldn't get OTimeControl", e ); throw new StatusException("Couldn't get OTimeControl", e);
} }
log.println( "creating a new environment for OTimeControl object" ); log.println("creating a new environment for OTimeControl object");
TestEnvironment tEnv = new TestEnvironment( oObj );
TestEnvironment tEnv = new TestEnvironment(oObj);
//Adding ObjRelation for XView //Adding ObjRelation for XView
tEnv.addObjRelation("GRAPHICS",aGraphic); tEnv.addObjRelation("GRAPHICS", aGraphic);
//Adding ObjRelation for XControl //Adding ObjRelation for XControl
tEnv.addObjRelation("CONTEXT",xTextDoc); tEnv.addObjRelation("CONTEXT", xTextDoc);
tEnv.addObjRelation("WINPEER",the_win); tEnv.addObjRelation("WINPEER", the_win);
tEnv.addObjRelation("TOOLKIT",the_kit); tEnv.addObjRelation("TOOLKIT", the_kit);
tEnv.addObjRelation("MODEL",the_Model); tEnv.addObjRelation("MODEL", the_Model);
XWindow forObjRel = (XWindow) XWindow forObjRel = (XWindow) UnoRuntime.queryInterface(XWindow.class,
UnoRuntime.queryInterface(XWindow.class,aControl); aControl);
tEnv.addObjRelation("XWindow.AnotherWindow",forObjRel); tEnv.addObjRelation("XWindow.AnotherWindow", forObjRel);
tEnv.addObjRelation("XWindow.ControlShape",aShape); tEnv.addObjRelation("XWindow.ControlShape", aShape);
// Adding relation for XTextListener // Adding relation for XTextListener
ifc.awt._XTextListener.TestTextListener listener = ifc.awt._XTextListener.TestTextListener listener =
new ifc.awt._XTextListener.TestTextListener() ; new ifc.awt._XTextListener.TestTextListener();
XTextComponent textComp = (XTextComponent) XTextComponent textComp = (XTextComponent) UnoRuntime.queryInterface(
UnoRuntime.queryInterface(XTextComponent.class, oObj); XTextComponent.class, oObj);
textComp.addTextListener(listener); textComp.addTextListener(listener);
tEnv.addObjRelation("TestTextListener", listener); tEnv.addObjRelation("TestTextListener", listener);
FormTools.switchDesignOf((XMultiServiceFactory)Param.getMSF(),xTextDoc); FormTools.switchDesignOf(((XMultiServiceFactory) Param.getMSF()), xTextDoc);
shortWait(); shortWait();
return tEnv; return tEnv;
} // finish method getTestEnvironment } // finish method getTestEnvironment
...@@ -266,13 +284,9 @@ public class OTimeControl extends TestCase { ...@@ -266,13 +284,9 @@ public class OTimeControl extends TestCase {
*/ */
private void shortWait() { private void shortWait() {
try { try {
Thread.sleep(200) ; Thread.sleep(200);
} catch (InterruptedException e) { } catch (InterruptedException e) {
System.out.println("While waiting :" + e) ; System.out.println("While waiting :" + e);
} }
} }
} // finish class OTimeControl
} // finish class OTimeControl
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