Kaydet (Commit) 8f2b7e47 authored tarafından Vladimir Glazounov's avatar Vladimir Glazounov

INTEGRATION: CWS qadev12 (1.2.2); FILE MERGED

2003/09/25 14:24:30 cn 1.2.2.1: CHG: #i19654# checkXDispatchWithNotification() added
üst 36e6706c
...@@ -2,9 +2,9 @@ ...@@ -2,9 +2,9 @@
* *
* $RCSfile: _XDispatch.java,v $ * $RCSfile: _XDispatch.java,v $
* *
* $Revision: 1.2 $ * $Revision: 1.3 $
* *
* last change:$Date: 2003-09-08 10:38:20 $ * last change:$Date: 2003-10-06 13:30:04 $
* *
* 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
...@@ -62,13 +62,15 @@ ...@@ -62,13 +62,15 @@
package ifc.frame; package ifc.frame;
import lib.MultiMethodTest;
import lib.Status;
import lib.StatusException;
import com.sun.star.beans.PropertyValue; import com.sun.star.beans.PropertyValue;
import com.sun.star.frame.XDispatch; import com.sun.star.frame.XDispatch;
import com.sun.star.util.URL; import com.sun.star.util.URL;
import lib.MultiMethodTest;
import lib.Status;
import lib.StatusException;
import com.sun.star.frame.XNotifyingDispatch;
import com.sun.star.uno.UnoRuntime;
import com.sun.star.frame.DispatchResultEvent;
/** /**
* Testing <code>com.sun.star.frame.XDispatch</code> * Testing <code>com.sun.star.frame.XDispatch</code>
...@@ -84,7 +86,11 @@ import com.sun.star.util.URL; ...@@ -84,7 +86,11 @@ import com.sun.star.util.URL;
* </code>): URL for passing to <code>dispatch()</code> method. </li> * </code>): URL for passing to <code>dispatch()</code> method. </li>
* <ul> <p> * <ul> <p>
* @see com.sun.star.frame.XDispatch * @see com.sun.star.frame.XDispatch
* @see com.sun.star.frame.XNotifyingDispatch
* @see ifc.frame._XDispatch
* @see ifc.frame._XNotifyingDispatch
*/ */
public class _XDispatch extends MultiMethodTest { public class _XDispatch extends MultiMethodTest {
public XDispatch oObj = null; public XDispatch oObj = null;
...@@ -119,9 +125,68 @@ public class _XDispatch extends MultiMethodTest { ...@@ -119,9 +125,68 @@ public class _XDispatch extends MultiMethodTest {
} }
/**
* Listener implementation which sets flags on appropriate method calls
*/
protected class TestNotificationListener implements
com.sun.star.frame.XDispatchResultListener {
public boolean disposingCalled = false ;
public boolean finishedDispatch = false ;
private java.io.PrintWriter log = null ;
public TestNotificationListener(java.io.PrintWriter log) {
this.log = log ;
}
public void disposing(com.sun.star.lang.EventObject e) {
disposingCalled = true ;
log.println(" disposing was called.") ;
}
public void dispatchFinished( DispatchResultEvent e) {
finishedDispatch = true ;
log.println(" dispatchFinished was called.") ;
}
}
TestStatusListener listener = null ; TestStatusListener listener = null ;
TestNotificationListener notificationListener = null;
URL url = null ; URL url = null ;
/**
* Not all implementations could call the
* <code>com.sun.star.frame.XStatusListener</code>. For this purposes the
* <code>com.sun.star.frame.XDispatchWithNotification</code> was designed.
* If <code>com.sun.star.frame.XStatusListener</code> was not called and
* <code>com.sun.star.frame.XStatusListener</code> is present, it was used
* to check listeners.
*/
private boolean checkXDispatchWithNotification()
{
XNotifyingDispatch xND = (XNotifyingDispatch)
UnoRuntime.queryInterface(XNotifyingDispatch.class, oObj);
if ( xND != null) {
log.println(" XNotifyingDispatch found:");
PropertyValue[] arguments = (PropertyValue[])
tEnv.getObjRelation("XNotifyingDispatchArgument");
notificationListener = new TestNotificationListener(log) ;
xND.dispatchWithNotification(url, arguments, notificationListener);
try {
Thread.sleep(200);
}
catch(java.lang.InterruptedException e) {}
log.println(" Listener called: "+ notificationListener.finishedDispatch);
return notificationListener.finishedDispatch;
} else {
return false;
}
}
/** /**
* Retrieves object relations and creates new listeners. * Retrieves object relations and creates new listeners.
* @throws StatusException If one of relations not found. * @throws StatusException If one of relations not found.
...@@ -157,10 +222,14 @@ public class _XDispatch extends MultiMethodTest { ...@@ -157,10 +222,14 @@ public class _XDispatch extends MultiMethodTest {
} }
catch(java.lang.InterruptedException e) {} catch(java.lang.InterruptedException e) {}
System.out.println("Listener called: "+ listener.statusChangedCalled); log.println("Listener called: "+ listener.statusChangedCalled);
result = listener.statusChangedCalled; result = listener.statusChangedCalled;
if (result == false) {
result = checkXDispatchWithNotification();
}
tRes.tested("dispatch()", result) ; tRes.tested("dispatch()", result) ;
} }
......
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