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

INTEGRATION: CWS qadev26 (1.5.4); FILE MERGED

2006/03/15 15:50:15 sw 1.5.4.1: #115058#
üst a8c05807
...@@ -4,9 +4,9 @@ ...@@ -4,9 +4,9 @@
* *
* $RCSfile: _XExecutableDialog.java,v $ * $RCSfile: _XExecutableDialog.java,v $
* *
* $Revision: 1.5 $ * $Revision: 1.6 $
* *
* last change: $Author: kz $ $Date: 2005-11-02 17:49:20 $ * last change: $Author: vg $ $Date: 2006-05-17 13:33:55 $
* *
* The Contents of this file are made available subject to * The Contents of this file are made available subject to
* the terms of GNU Lesser General Public License Version 2.1. * the terms of GNU Lesser General Public License Version 2.1.
...@@ -59,6 +59,7 @@ import com.sun.star.util.XCancellable; ...@@ -59,6 +59,7 @@ import com.sun.star.util.XCancellable;
public class _XExecutableDialog extends MultiMethodTest { public class _XExecutableDialog extends MultiMethodTest {
public XExecutableDialog oObj = null; public XExecutableDialog oObj = null;
private ExecThread eThread = null;
/** /**
* Test calls the method. <p> * Test calls the method. <p>
...@@ -84,16 +85,14 @@ public class _XExecutableDialog extends MultiMethodTest { ...@@ -84,16 +85,14 @@ public class _XExecutableDialog extends MultiMethodTest {
log.println("and the result is set to true"); log.println("and the result is set to true");
result = true; result = true;
} else { } else {
ExecThread eThread = new ExecThread(oObj); eThread = new ExecThread(oObj);
log.println("Starting Dialog"); log.println("Starting Dialog");
eThread.start(); eThread.start();
XCancellable canc = (XCancellable)UnoRuntime.queryInterface XCancellable canc = (XCancellable)UnoRuntime.queryInterface
(XCancellable.class, tEnv.getTestObject()); (XCancellable.class, tEnv.getTestObject());
shortWait(); shortWait();
if (canc != null) { if (canc != null) {
log.println("Cancelling Dialog"); closeDialog();
canc.cancel();
shortWait();
short res = eThread.execRes; short res = eThread.execRes;
log.println("result: "+res); log.println("result: "+res);
result = (res == 0); result = (res == 0);
...@@ -101,7 +100,7 @@ public class _XExecutableDialog extends MultiMethodTest { ...@@ -101,7 +100,7 @@ public class _XExecutableDialog extends MultiMethodTest {
this.disposeEnvironment(); this.disposeEnvironment();
result=true; result=true;
log.println("XCancellable isn't supported and the "+ log.println("XCancellable isn't supported and the "+
"environment is killed hard"); "environment is killed hard");
} }
...@@ -110,9 +109,9 @@ public class _XExecutableDialog extends MultiMethodTest { ...@@ -110,9 +109,9 @@ public class _XExecutableDialog extends MultiMethodTest {
} }
/** /**
* Calls <code>execute()</code> method in a separate thread. * Calls <code>execute()</code> method in a separate thread.
* Necessary to check if this method works * Necessary to check if this method works
*/ */
protected class ExecThread extends Thread { protected class ExecThread extends Thread {
public short execRes = (short) 17 ; public short execRes = (short) 17 ;
...@@ -123,23 +122,81 @@ public class _XExecutableDialog extends MultiMethodTest { ...@@ -123,23 +122,81 @@ public class _XExecutableDialog extends MultiMethodTest {
} }
public void run() { public void run() {
execRes = Diag.execute(); try {
System.out.println("HERE: "+execRes); execRes = Diag.execute();
System.out.println("HERE: "+execRes);
} catch(Exception e) {
log.println("Thread has been interrupted ... ");
}
} }
} }
/** /**
* Sleeps for 5 sec. to allow StarOffice to react on <code> * Sleeps for 5 sec. to allow StarOffice to react on <code>
* reset</code> call. * reset</code> call.
*/ */
private void shortWait() { private void shortWait() {
try { try {
Thread.sleep(5000) ; Thread.sleep(2000) ;
} catch (InterruptedException e) { } catch (InterruptedException e) {
log.println("While waiting :" + e) ; log.println("While waiting :" + e) ;
} }
} }
public void after() {
if (eThread.isAlive()) {
log.println("Thread didn't die ... cleaning up");
disposeEnvironment();
}
}
private void closeDialog() {
XCancellable canc = (XCancellable) UnoRuntime.queryInterface(
XCancellable.class, tEnv.getTestObject());
if (canc != null) {
log.println("Cancelling Dialog");
canc.cancel();
} else {
this.disposeEnvironment();
}
long st = System.currentTimeMillis();
boolean toLong = false;
log.println("waiting for dialog to close");
while (eThread.isAlive() && !toLong) {
//wait for dialog to close
toLong = (System.currentTimeMillis()-st > 10000);
}
log.println("done");
try {
if (eThread.isAlive()) {
log.println("Interrupting Thread");
eThread.interrupt();
eThread.yield();
}
} catch (Exception e) {
// who cares ;-)
}
st = System.currentTimeMillis();
toLong = false;
log.println("waiting for interruption to work");
while (eThread.isAlive() && !toLong) {
//wait for dialog to close
toLong = (System.currentTimeMillis()-st > 10000);
}
log.println("DialogThread alive: "+eThread.isAlive());
log.println("done");
}
} }
......
...@@ -4,9 +4,9 @@ ...@@ -4,9 +4,9 @@
* *
* $RCSfile: _XFilePickerNotifier.java,v $ * $RCSfile: _XFilePickerNotifier.java,v $
* *
* $Revision: 1.5 $ * $Revision: 1.6 $
* *
* last change: $Author: kz $ $Date: 2005-11-02 17:49:31 $ * last change: $Author: vg $ $Date: 2006-05-17 13:34:16 $
* *
* The Contents of this file are made available subject to * The Contents of this file are made available subject to
* the terms of GNU Lesser General Public License Version 2.1. * the terms of GNU Lesser General Public License Version 2.1.
...@@ -51,42 +51,30 @@ import com.sun.star.util.XCancellable; ...@@ -51,42 +51,30 @@ import com.sun.star.util.XCancellable;
/** /**
* Testing <code>com.sun.star.ui.XFilePickerNotifier</code> * Testing <code>com.sun.star.ui.XFilePickerNotifier</code>
* interface methods : * interface methods :
* <ul> * <ul>
* <li><code> addFilePickerListener()</code></li> * <li><code> addFilePickerListener()</code></li>
* <li><code> removeFilePickerListener()</code></li> * <li><code> removeFilePickerListener()</code></li>
* </ul> <p> * </ul> <p>
* The object must implement <code>XFilePicker</code> * The object must implement <code>XFilePicker</code>
* interface to check if a listener was called. <p> * interface to check if a listener was called. <p>
* Test is <b> NOT </b> multithread compilant. <p> * Test is <b> NOT </b> multithread compilant. <p>
* @see com.sun.star.ui.XFilePickerNotifier * @see com.sun.star.ui.XFilePickerNotifier
*/ */
public class _XFilePickerNotifier extends MultiMethodTest { public class _XFilePickerNotifier extends MultiMethodTest {
public XFilePickerNotifier oObj = null; public XFilePickerNotifier oObj = null;
private XFilePicker fps = null ; private XFilePicker fps = null ;
private String dir1 = null, private String dir1 = null,
dir2 = null ; dir2 = null ;
ExecThread eThread = null; ExecThread eThread = null;
public void after() {
XCancellable canc = (XCancellable) UnoRuntime.queryInterface(
XCancellable.class, tEnv.getTestObject());
shortWait();
if (canc != null) {
log.println("Cancelling Dialog");
canc.cancel();
} else {
this.disposeEnvironment();
}
}
/** /**
* Listener implementation which sets a flag if some of its * Listener implementation which sets a flag if some of its
* methods was called. * methods was called.
*/ */
protected class TestListener implements XFilePickerListener { protected class TestListener implements XFilePickerListener {
public boolean called = false ; public boolean called = false ;
...@@ -118,36 +106,34 @@ public class _XFilePickerNotifier extends MultiMethodTest { ...@@ -118,36 +106,34 @@ public class _XFilePickerNotifier extends MultiMethodTest {
TestListener listener = new TestListener() ; TestListener listener = new TestListener() ;
/** /**
* Tries to query object for <code>XFilePicker</code> interface, and * Tries to query object for <code>XFilePicker</code> interface, and
* initializes two different URLs for changing file picker directory. <p> * initializes two different URLs for changing file picker directory. <p>
* @throw StatusException If object doesn't support <code>XFilePicker</code> * @throw StatusException If object doesn't support <code>XFilePicker</code>
* interface. * interface.
*/ */
public void before() { public void before() {
fps = (XFilePicker) UnoRuntime.queryInterface fps = (XFilePicker) UnoRuntime.queryInterface
(XFilePicker.class, oObj) ; (XFilePicker.class, oObj) ;
if (fps == null) { if (fps == null) {
log.println("The object doesnt implement XFilePicker") ; log.println("The object doesnt implement XFilePicker") ;
throw new StatusException(Status.failed throw new StatusException(Status.failed
("The object doesnt implement XFilePicker")); ("The object doesnt implement XFilePicker"));
} }
XExecutableDialog exD = (XExecutableDialog) UnoRuntime.queryInterface(
XExecutableDialog.class, tEnv.getTestObject());
dir1 = util.utils.getOfficeTemp((XMultiServiceFactory)tParam.getMSF()); dir1 = util.utils.getOfficeTemp((XMultiServiceFactory)tParam.getMSF());
dir2 = util.utils.getFullTestURL(""); dir2 = util.utils.getFullTestURL("");
XExecutableDialog exD = (XExecutableDialog) UnoRuntime.queryInterface(
XExecutableDialog.class, tEnv.getTestObject());
eThread = new ExecThread(exD); eThread = new ExecThread(exD);
log.println("Starting Dialog");
eThread.start();
} }
/** /**
* Adds a listener, then tries to change display directory and * Adds a listener, then tries to change display directory and
* checks if the listener was called. <p> * checks if the listener was called. <p>
* Has <b>OK</b> status if a listener method was called. * Has <b>OK</b> status if a listener method was called.
*/ */
public void _addFilePickerListener() { public void _addFilePickerListener() {
oObj.addFilePickerListener(listener) ; oObj.addFilePickerListener(listener) ;
...@@ -155,6 +141,7 @@ public class _XFilePickerNotifier extends MultiMethodTest { ...@@ -155,6 +141,7 @@ public class _XFilePickerNotifier extends MultiMethodTest {
log.println("***** Setting DisplayDirectory to " + dir1); log.println("***** Setting DisplayDirectory to " + dir1);
fps.setDisplayDirectory(dir1) ; fps.setDisplayDirectory(dir1) ;
log.println("***** Getting: " + fps.getDisplayDirectory()); log.println("***** Getting: " + fps.getDisplayDirectory());
openDialog();
log.println("***** Setting DisplayDirectory to " + dir2); log.println("***** Setting DisplayDirectory to " + dir2);
fps.setDisplayDirectory(dir2) ; fps.setDisplayDirectory(dir2) ;
log.println("***** Getting: " + fps.getDisplayDirectory()); log.println("***** Getting: " + fps.getDisplayDirectory());
...@@ -164,25 +151,25 @@ public class _XFilePickerNotifier extends MultiMethodTest { ...@@ -164,25 +151,25 @@ public class _XFilePickerNotifier extends MultiMethodTest {
e.printStackTrace(log) ; e.printStackTrace(log) ;
} }
try { shortWait();
Thread.sleep(5000) ;
} catch(InterruptedException e) {}
if (!listener.called) { if (!listener.called) {
log.println("Listener wasn't called :-("); log.println("Listener wasn't called :-(");
} }
closeDialog();
tRes.tested("addFilePickerListener()", listener.called) ; tRes.tested("addFilePickerListener()", listener.called) ;
} }
/** /**
* Removes the listener and changes display directory. <p> * Removes the listener and changes display directory. <p>
* Has <b>OK</b> status if the listener wasn't called. <p> * Has <b>OK</b> status if the listener wasn't called. <p>
* The following method tests are to be completed successfully before : * The following method tests are to be completed successfully before :
* <ul> * <ul>
* <li> <code> addFilePickerListener </code> </li> * <li> <code> addFilePickerListener </code> </li>
* </ul> * </ul>
*/ */
public void _removeFilePickerListener() { public void _removeFilePickerListener() {
requiredMethod("addFilePickerListener()") ; requiredMethod("addFilePickerListener()") ;
...@@ -192,23 +179,24 @@ public class _XFilePickerNotifier extends MultiMethodTest { ...@@ -192,23 +179,24 @@ public class _XFilePickerNotifier extends MultiMethodTest {
try { try {
fps.setDisplayDirectory(dir1) ; fps.setDisplayDirectory(dir1) ;
openDialog();
fps.setDisplayDirectory(dir2) ; fps.setDisplayDirectory(dir2) ;
} catch(com.sun.star.lang.IllegalArgumentException e) { } catch(com.sun.star.lang.IllegalArgumentException e) {
log.println("!!! Exception changing dir !!!") ; log.println("!!! Exception changing dir !!!") ;
e.printStackTrace(log) ; e.printStackTrace(log) ;
} }
try { shortWait();
Thread.sleep(2000) ;
} catch(InterruptedException e) {} closeDialog();
tRes.tested("removeFilePickerListener()", !listener.called) ; tRes.tested("removeFilePickerListener()", !listener.called) ;
} }
/** /**
* Calls <code>execute()</code> method in a separate thread. * Calls <code>execute()</code> method in a separate thread.
* Necessary to check if this method works * Necessary to check if this method works
*/ */
protected class ExecThread extends Thread { protected class ExecThread extends Thread {
public short execRes = (short) 17 ; public short execRes = (short) 17 ;
...@@ -219,23 +207,92 @@ public class _XFilePickerNotifier extends MultiMethodTest { ...@@ -219,23 +207,92 @@ public class _XFilePickerNotifier extends MultiMethodTest {
} }
public void run() { public void run() {
execRes = Diag.execute(); try {
System.out.println("HERE: "+execRes); execRes = Diag.execute();
shortWait(); System.out.println("HERE: "+execRes);
} catch (Exception e) {
log.println("Thread has been interrupted ...");
}
} }
} }
/** /**
* Sleeps for 0.5 sec. to allow StarOffice to react on <code> * Sleeps for 0.5 sec. to allow StarOffice to react on <code>
* reset</code> call. * reset</code> call.
*/ */
private void shortWait() { private void shortWait() {
try { try {
Thread.sleep(500) ; Thread.sleep(2000) ;
} catch (InterruptedException e) { } catch (InterruptedException e) {
log.println("While waiting :" + e) ; log.println("While waiting :" + e) ;
} }
} }
private void closeDialog() {
XCancellable canc = (XCancellable) UnoRuntime.queryInterface(
XCancellable.class, tEnv.getTestObject());
if (canc != null) {
log.println("Cancelling Dialog");
canc.cancel();
} else {
this.disposeEnvironment();
}
long st = System.currentTimeMillis();
boolean toLong = false;
log.println("waiting for dialog to close");
while (eThread.isAlive() && !toLong) {
//wait for dialog to close
toLong = (System.currentTimeMillis()-st > 10000);
}
log.println("done");
try {
if (eThread.isAlive()) {
log.println("Interrupting Thread");
eThread.interrupt();
eThread.yield();
}
} catch (Exception e) {
// who cares ;-)
}
st = System.currentTimeMillis();
toLong = false;
log.println("waiting for interruption to work");
while (eThread.isAlive() && !toLong) {
//wait for dialog to close
toLong = (System.currentTimeMillis()-st > 10000);
}
log.println("DialogThread alive: "+eThread.isAlive());
log.println("done");
}
private void openDialog() {
log.println("Starting Dialog");
if (eThread.isAlive()) {
log.println("second interrupt");
eThread.interrupt();
eThread.yield();
}
XExecutableDialog exD = (XExecutableDialog) UnoRuntime.queryInterface(
XExecutableDialog.class, tEnv.getTestObject());
dir1 = util.utils.getOfficeTemp((XMultiServiceFactory)tParam.getMSF());
dir2 = util.utils.getFullTestURL("");
eThread = new ExecThread(exD);
eThread.start();
}
} }
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