INTEGRATION: CWS qadev6 (1.1.8); FILE MERGED
2003/05/21 10:16:00 sg 1.1.8.1: #109368# #109375#: watcher is configurable now; added new method closeExistingOffice() to OfficeProvider
This commit is contained in:
parent
22b8bbe24b
commit
154bb1cdff
2 changed files with 31 additions and 9 deletions
|
@ -2,9 +2,9 @@
|
|||
*
|
||||
* $RCSfile: AppProvider.java,v $
|
||||
*
|
||||
* $Revision: 1.1 $
|
||||
* $Revision: 1.2 $
|
||||
*
|
||||
* last change:$Date: 2003-01-27 16:27:35 $
|
||||
* last change:$Date: 2003-05-27 12:01:55 $
|
||||
*
|
||||
* The Contents of this file are made available subject to the terms of
|
||||
* either of the following licenses
|
||||
|
@ -77,4 +77,13 @@ public interface AppProvider {
|
|||
*/
|
||||
public boolean disposeManager(lib.TestParameters param);
|
||||
|
||||
/**
|
||||
* Close an office.
|
||||
* @param param The test parameters.
|
||||
* @param closeIfPossible If true, close even if
|
||||
* it was running before the test
|
||||
* @return True, if close worked.
|
||||
*/
|
||||
public boolean closeExistingOffice(lib.TestParameters param,
|
||||
boolean closeIfPossible);
|
||||
}
|
||||
|
|
|
@ -2,9 +2,9 @@
|
|||
*
|
||||
* $RCSfile: OfficeWatcher.java,v $
|
||||
*
|
||||
* $Revision: 1.1 $
|
||||
* $Revision: 1.2 $
|
||||
*
|
||||
* last change:$Date: 2003-01-27 16:27:33 $
|
||||
* last change:$Date: 2003-05-27 12:02:53 $
|
||||
*
|
||||
* The Contents of this file are made available subject to the terms of
|
||||
* either of the following licenses
|
||||
|
@ -63,6 +63,7 @@ package helper;
|
|||
|
||||
import java.lang.Thread;
|
||||
import lib.TestParameters;
|
||||
import share.LogWriter;
|
||||
|
||||
import com.sun.star.frame.XComponentLoader;
|
||||
import com.sun.star.uno.UnoRuntime;
|
||||
|
@ -71,11 +72,14 @@ import com.sun.star.beans.PropertyValue;
|
|||
|
||||
public class OfficeWatcher extends Thread implements share.Watcher {
|
||||
|
||||
public boolean finish;
|
||||
|
||||
TestParameters params;
|
||||
String StoredPing = "";
|
||||
|
||||
/** Creates new OfficeWatcher */
|
||||
public OfficeWatcher(TestParameters param) {
|
||||
finish = false;
|
||||
this.params = param;
|
||||
}
|
||||
|
||||
|
@ -89,25 +93,34 @@ public class OfficeWatcher extends Thread implements share.Watcher {
|
|||
public void run() {
|
||||
boolean isDone = false;
|
||||
ProcessHandler ph = (ProcessHandler) params.get("AppProvider");
|
||||
int timeOut = params.getInt("TimeOut");
|
||||
if (ph == null) {
|
||||
isDone = true;
|
||||
}
|
||||
while (!isDone) {
|
||||
timeOut = params.getInt("TimeOut");
|
||||
String previous = StoredPing;
|
||||
shortWait();
|
||||
if (StoredPing.equals(previous)){
|
||||
shortWait(timeOut==0?30000:timeOut);
|
||||
// a timeout with value 0 lets watcher not react.
|
||||
if (StoredPing.equals(previous) && timeOut != 0){
|
||||
isDone = true;
|
||||
}
|
||||
// execute in case the watcher is not needed anymore
|
||||
if (finish) {
|
||||
return;
|
||||
}
|
||||
}
|
||||
if (ph !=null) {
|
||||
System.out.println("OfficeWatcher: the Office is idle for " + timeOut/1000
|
||||
+ " seconds, it probably hangs and is killed NOW.");
|
||||
ph.kill();
|
||||
}
|
||||
shortWait();
|
||||
shortWait(timeOut==0?30000:timeOut);
|
||||
}
|
||||
|
||||
protected void shortWait() {
|
||||
protected void shortWait(int timeOut) {
|
||||
try {
|
||||
this.sleep(params.getInt("TimeOut"));
|
||||
this.sleep(timeOut);
|
||||
} catch (java.lang.InterruptedException ie) {}
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in a new issue