summaryrefslogtreecommitdiff
path: root/framework/qa
diff options
context:
space:
mode:
authorNoel Grandin <noel@peralex.com>2014-12-22 10:02:49 +0200
committerNoel Grandin <noel@peralex.com>2015-01-12 08:36:17 +0200
commit09330056a01a4b5c3d16e3ffb6c1bff36099eb83 (patch)
treeefa793bee83eed4081edd52737e73216a3048b89 /framework/qa
parent4bf4e3d40778051f1f886c47dd2b2bef82acf1e5 (diff)
java: simplify sleeping and waiting in tests
- remove the SHORT_WAIT test parameter, no-one is using it - inline the various independent shortWait() methods - use the util.utils.shortWait() utility method everywhere Change-Id: I93cd4a2580172a1441d2ff3d390f52b9505e2721
Diffstat (limited to 'framework/qa')
-rw-r--r--framework/qa/complex/XUserInputInterception/EventTest.java4
-rw-r--r--framework/qa/complex/api_internal/CheckAPI.java5
-rw-r--r--framework/qa/complex/contextMenuInterceptor/CheckContextMenuInterceptor.java2
-rw-r--r--framework/qa/complex/desktop/DesktopTerminate.java16
-rw-r--r--framework/qa/complex/framework/recovery/RecoveryTest.java16
-rw-r--r--framework/qa/complex/framework/recovery/RecoveryTools.java36
-rw-r--r--framework/qa/complex/imageManager/_XComponent.java4
7 files changed, 23 insertions, 60 deletions
diff --git a/framework/qa/complex/XUserInputInterception/EventTest.java b/framework/qa/complex/XUserInputInterception/EventTest.java
index e8462b4ee74d..f337495b6718 100644
--- a/framework/qa/complex/XUserInputInterception/EventTest.java
+++ b/framework/qa/complex/XUserInputInterception/EventTest.java
@@ -267,7 +267,7 @@ public class EventTest {
et.run();
- util.utils.shortWait(m_threadWait);
+ util.utils.pause(m_threadWait);
System.out.println("key listener thread should be finished.");
assertTrue("key event does not work!", m_keyPressed && m_keyReleased);
@@ -300,7 +300,7 @@ public class EventTest {
et.run();
- util.utils.shortWait(m_threadWait);
+ util.utils.pause(m_threadWait);
System.out.println("mouse listener thread should be finished.");
assertTrue("mouse event does not work!", m_mousePressed && m_mouseReleased);
diff --git a/framework/qa/complex/api_internal/CheckAPI.java b/framework/qa/complex/api_internal/CheckAPI.java
index dfc77543bde7..0480191294a7 100644
--- a/framework/qa/complex/api_internal/CheckAPI.java
+++ b/framework/qa/complex/api_internal/CheckAPI.java
@@ -145,10 +145,7 @@ public class CheckAPI {
xMSF = null;
ProcessHandler handler = (ProcessHandler)param.get("AppProvider");
handler.kill();
- try {
- Thread.sleep(10000);
- }
- catch(InterruptedException e) {}
+ util.utils.pause(10000);
OfficeProvider op = new OfficeProvider();
xMSF = (XMultiServiceFactory)op.getManager(param);
param.put("ServiceFactory",xMSF);
diff --git a/framework/qa/complex/contextMenuInterceptor/CheckContextMenuInterceptor.java b/framework/qa/complex/contextMenuInterceptor/CheckContextMenuInterceptor.java
index 189a1e81cfb4..532dc9da5cd1 100644
--- a/framework/qa/complex/contextMenuInterceptor/CheckContextMenuInterceptor.java
+++ b/framework/qa/complex/contextMenuInterceptor/CheckContextMenuInterceptor.java
@@ -316,7 +316,7 @@ public class CheckContextMenuInterceptor
System.out.println("couldn't press mouse button");
}
- utils.shortWait(3000);
+ utils.pause(3000);
}
diff --git a/framework/qa/complex/desktop/DesktopTerminate.java b/framework/qa/complex/desktop/DesktopTerminate.java
index e7bd0421753e..ee862bd116a6 100644
--- a/framework/qa/complex/desktop/DesktopTerminate.java
+++ b/framework/qa/complex/desktop/DesktopTerminate.java
@@ -89,13 +89,7 @@ public class DesktopTerminate
try
{
xMSF = getMSF();
- try
- {
- Thread.sleep(10000);
- }
- catch (InterruptedException e)
- {
- }
+ util.utils.pause(10000);
}
catch (java.lang.Exception e)
{
@@ -115,13 +109,7 @@ public class DesktopTerminate
desk = UnoRuntime.queryInterface(XDesktop.class, xMSF.createInstance("com.sun.star.frame.Desktop"));
desk.terminate();
System.out.println("Waiting " + iOfficeCloseTime + " milliseconds for the Office to close down");
- try
- {
- Thread.sleep(iOfficeCloseTime);
- }
- catch (InterruptedException e)
- {
- }
+ util.utils.pause(iOfficeCloseTime);
xMSF = null;
}
catch (java.lang.Exception e)
diff --git a/framework/qa/complex/framework/recovery/RecoveryTest.java b/framework/qa/complex/framework/recovery/RecoveryTest.java
index 187b336d1b17..42f61c331fe2 100644
--- a/framework/qa/complex/framework/recovery/RecoveryTest.java
+++ b/framework/qa/complex/framework/recovery/RecoveryTest.java
@@ -204,8 +204,8 @@ public class RecoveryTest extends ComplexTestCase {
CrashThread crash = new CrashThread(xDoc, xMSF);
crash.start();
- rt.pause();
- rt.pause();
+ util.utils.shortWait();
+ util.utils.shortWait();
}
/**
@@ -221,13 +221,13 @@ public class RecoveryTest extends ComplexTestCase {
log.println("wating for recovery dialog...");
int counter = 0;
- int maximum = param.getInt(PropertyName.THREAD_TIME_OUT) / param.getInt(PropertyName.SHORT_WAIT);
+ int maximum = param.getInt(PropertyName.THREAD_TIME_OUT) / PropertyName.DEFAULT_SHORT_WAIT_MS;
XDialog oDialog = rt.getActiveDialog(xMSF);
while ( oDialog == null && (counter < maximum))
{
- rt.pause();
+ util.utils.shortWait();
oDialog = rt.getActiveDialog(xMSF);
counter ++;
}
@@ -349,10 +349,10 @@ public class RecoveryTest extends ComplexTestCase {
log.println("clicking 'Start Recovery' button...");
oUITools.clickButton("Start Recovery >");
- rt.pause();
+ util.utils.shortWait();
int counter = 0;
- int maximum = param.getInt(PropertyName.THREAD_TIME_OUT) / param.getInt(PropertyName.SHORT_WAIT);
+ int maximum = param.getInt(PropertyName.THREAD_TIME_OUT) / PropertyName.DEFAULT_SHORT_WAIT_MS;
XAccessibleContext oButton = null;
while ((oButton == null) && (counter < maximum)){
@@ -364,7 +364,7 @@ public class RecoveryTest extends ComplexTestCase {
// no fault: The title "Start Recovery" switches to "Next"
// while all documents are recoverd
}
- rt.pause();
+ util.utils.shortWait();
counter++;
}
@@ -379,7 +379,7 @@ public class RecoveryTest extends ComplexTestCase {
oUITools.clickButton("Next >");
}
- rt.pause();
+ util.utils.shortWait();
} else {
log.println("do not recover: clicking 'Cancel' button...");
diff --git a/framework/qa/complex/framework/recovery/RecoveryTools.java b/framework/qa/complex/framework/recovery/RecoveryTools.java
index 36f3c018cf4d..70374518f6ce 100644
--- a/framework/qa/complex/framework/recovery/RecoveryTools.java
+++ b/framework/qa/complex/framework/recovery/RecoveryTools.java
@@ -93,15 +93,15 @@ public class RecoveryTools {
// This could consumes more time then the TimeOut allow.
int counter = 0;
int multi = 5;
- int pause = param.getInt(PropertyName.SHORT_WAIT)*10;
+ int pause = PropertyName.DEFAULT_SHORT_WAIT_MS * 10;
int timeOut = param.getInt(PropertyName.THREAD_TIME_OUT)*5;
int maximum = (timeOut / pause) * multi;
XDialog oDialog = getActiveDialog(xMSF);
while (oDialog == null && (counter < maximum)){
- log.println("waiting until the office has recoverd... remaining " + (timeOut * multi - pause * counter)/1000 + " seconds");
- pause(pause);
+ log.println("waiting until the office has recovered... remaining " + (timeOut * multi - pause * counter)/1000 + " seconds");
+ util.utils.pause(pause);
oDialog = getActiveDialog(xMSF);
counter ++;
}
@@ -109,26 +109,6 @@ public class RecoveryTools {
}
/**
- * halt the thread for some time
- */
- public void pause(){
- pause(param.getInt(PropertyName.SHORT_WAIT));
- }
-
- /**
- * halt the thread for some time
- */
- private void pause(int sleepTime){
- sleep(sleepTime);
- }
-
- private void sleep(long millis){
- try{
- Thread.sleep(millis);
- }catch (InterruptedException e){}
- }
-
- /**
* remove the content of the user backup folder and removes the Recovery.xcu. This
* was done from the Office via XSimpleFileAccess
* @throws com.sun.star.io.IOException the exception was thrown if something goes wrong.
@@ -204,11 +184,11 @@ public class RecoveryTools {
helper.ProcessHandler ph = (helper.ProcessHandler) param.get("AppProvider");
int timeOut = param.getInt(PropertyName.THREAD_TIME_OUT)*5;
- int pause = param.getInt(PropertyName.SHORT_WAIT)*20;
+ int pause = PropertyName.DEFAULT_SHORT_WAIT_MS * 20;
int multi = 0;
while ((ph != null) && (ph.getExitCode()<0) && (pause*multi < timeOut)) {
log.println("waiting until the office is closed... remaining " + (timeOut - pause * multi)/1000 + " seconds");
- pause(pause);
+ util.utils.pause(pause);
multi ++;
}
@@ -254,7 +234,7 @@ public class RecoveryTools {
log.println("try to get modal Dialog...");
- pause();
+ util.utils.shortWait();
XWindow oDialog = getActiveWindow(xMSF);
@@ -270,14 +250,14 @@ public class RecoveryTools {
} catch ( java.lang.Exception e){
throw new com.sun.star.accessibility.IllegalAccessibleComponentStateException("Could not click '"+buttonName +"' at modal dialog", e);
}
- pause();
+ util.utils.shortWait();
}
public void clickThreadButton(XWindow xWindow, String buttonName)
{
KlickButtonThread kbt = new KlickButtonThread(xWindow, buttonName);
kbt.start();
- pause(param.getInt(PropertyName.SHORT_WAIT) * 10);
+ util.utils.pause(PropertyName.DEFAULT_SHORT_WAIT_MS * 10);
}
public void copyRecoveryData(boolean backup)
diff --git a/framework/qa/complex/imageManager/_XComponent.java b/framework/qa/complex/imageManager/_XComponent.java
index e5a3ea90e918..c8c94d7c86e0 100644
--- a/framework/qa/complex/imageManager/_XComponent.java
+++ b/framework/qa/complex/imageManager/_XComponent.java
@@ -147,9 +147,7 @@ public class _XComponent {
}
}
- try {
- Thread.sleep(500) ;
- } catch (InterruptedException e) {}
+ util.utils.shortWait();
if (Loutput[0]!=null){
System.out.println(Loutput[0]);
}