Skip to main content
summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMarcel Hein2016-09-14 10:48:59 -0400
committerMarvin Mueller2016-10-31 08:54:53 -0400
commit1345c2ca3f798cbb9665c93343251f48e0812b63 (patch)
tree93797721f40bee082f336b331773ee6834576afb
parent2168686061df2930dc93ecab10f66b69aabef55a (diff)
downloadorg.eclipse.jubula.core-1345c2ca3f798cbb9665c93343251f48e0812b63.tar.gz
org.eclipse.jubula.core-1345c2ca3f798cbb9665c93343251f48e0812b63.tar.xz
org.eclipse.jubula.core-1345c2ca3f798cbb9665c93343251f48e0812b63.zip
Fix for Bug 486790 - wait for window to close
-rw-r--r--org.eclipse.jubula.rc.javafx/src/org/eclipse/jubula/rc/javafx/tester/JavaFXApplicationTester.java101
1 files changed, 54 insertions, 47 deletions
diff --git a/org.eclipse.jubula.rc.javafx/src/org/eclipse/jubula/rc/javafx/tester/JavaFXApplicationTester.java b/org.eclipse.jubula.rc.javafx/src/org/eclipse/jubula/rc/javafx/tester/JavaFXApplicationTester.java
index 3a5832765..05b90e672 100644
--- a/org.eclipse.jubula.rc.javafx/src/org/eclipse/jubula/rc/javafx/tester/JavaFXApplicationTester.java
+++ b/org.eclipse.jubula.rc.javafx/src/org/eclipse/jubula/rc/javafx/tester/JavaFXApplicationTester.java
@@ -352,21 +352,21 @@ public class JavaFXApplicationTester extends AbstractApplicationTester {
} finally {
stage.removeEventFilter(WindowEvent.WINDOW_SHOWN, showHandler);
}
- boolean result = EventThreadQueuerJavaFXImpl.invokeAndWait(
- "rcWaitForWindowConfirm", new Callable<Boolean>() { //$NON-NLS-1$
+ }
+ boolean result = EventThreadQueuerJavaFXImpl.invokeAndWait(
+ "rcWaitForWindowConfirm", new Callable<Boolean>() { //$NON-NLS-1$
- @Override
- public Boolean call() throws Exception {
- return stage.isShowing();
- }
- });
- if (!result) {
- throw new StepExecutionException("window did not open", //$NON-NLS-1$
- EventFactory
- .createActionError(
- TestErrorEvent.TIMEOUT_EXPIRED));
- }
+ @Override
+ public Boolean call() throws Exception {
+ return stage.isShowing();
+ }
+ });
+ if (!result) {
+ throw new StepExecutionException("window did not open", //$NON-NLS-1$
+ EventFactory
+ .createActionError(TestErrorEvent.TIMEOUT_EXPIRED));
}
+
TimeUtil.delay(delay);
}
@@ -431,7 +431,7 @@ public class JavaFXApplicationTester extends AbstractApplicationTester {
return true;
}
});
- if (isFocused) {
+ if (!isFocused) {
try {
signal.await(pTimeout, TimeUnit.MILLISECONDS);
} catch (InterruptedException e) {
@@ -442,21 +442,21 @@ public class JavaFXApplicationTester extends AbstractApplicationTester {
} finally {
stage.focusedProperty().removeListener(focusListener);
}
- boolean result = EventThreadQueuerJavaFXImpl
- .invokeAndWait(
- "rcWaitForWindowActivationConfirm", new Callable<Boolean>() { //$NON-NLS-1$
-
- @Override
- public Boolean call() throws Exception {
- return stage.isFocused();
- }
- });
- if (!result) {
- throw new StepExecutionException("window was not activated", //$NON-NLS-1$
- EventFactory.createActionError(
- TestErrorEvent.TIMEOUT_EXPIRED));
- }
}
+ boolean result = EventThreadQueuerJavaFXImpl.invokeAndWait(
+ "rcWaitForWindowActivationConfirm", new Callable<Boolean>() { //$NON-NLS-1$
+
+ @Override
+ public Boolean call() throws Exception {
+ return stage.isFocused();
+ }
+ });
+ if (!result) {
+ throw new StepExecutionException("window was not activated", //$NON-NLS-1$
+ EventFactory
+ .createActionError(TestErrorEvent.TIMEOUT_EXPIRED));
+ }
+
TimeUtil.delay(delay);
}
@@ -498,12 +498,16 @@ public class JavaFXApplicationTester extends AbstractApplicationTester {
@Override
public Boolean call() throws Exception {
- s.addEventFilter(WindowEvent.WINDOW_CLOSE_REQUEST,
- closeHandler);
- return false;
+ if (s.isShowing()) {
+ s.addEventFilter(WindowEvent.WINDOW_CLOSE_REQUEST,
+ closeHandler);
+ return false;
+ } else {
+ return true;
+ }
}
});
- if (isClosing) {
+ if (!isClosing) {
try {
signal.await(pTimeout, TimeUnit.MILLISECONDS);
} catch (InterruptedException e) {
@@ -516,22 +520,25 @@ public class JavaFXApplicationTester extends AbstractApplicationTester {
s.removeEventFilter(WindowEvent.WINDOW_CLOSE_REQUEST,
closeHandler);
}
- boolean result = EventThreadQueuerJavaFXImpl.invokeAndWait(
- "rcWaitForWindowToCloseConfirm", new Callable<Boolean>() { //$NON-NLS-1$
-
- @Override
- public Boolean call() throws Exception {
- final Stage tmpS = getStageByTitle(title, operator);
+ }
+ boolean result = EventThreadQueuerJavaFXImpl.invokeAndWait(
+ "rcWaitForWindowToCloseConfirm", new Callable<Boolean>() { //$NON-NLS-1$
- return tmpS == null;
- }
- });
- if (!result) {
- throw new StepExecutionException("window was not closed", //$NON-NLS-1$
- EventFactory
- .createActionError(
- TestErrorEvent.TIMEOUT_EXPIRED));
- }
+ @Override
+ public Boolean call() throws Exception {
+ final Stage tmpS = getStageByTitle(title, operator);
+ // the stage might be still in the list be cause the fx
+ // thread was not fast enough to remove it, thus
+ // checking if showing == false which also means that
+ // the stage is not rendered
+ return tmpS == null || !tmpS.isShowing();
+ }
+ });
+ if (!result) {
+ throw new StepExecutionException("window was not closed", //$NON-NLS-1$
+ EventFactory
+ .createActionError(
+ TestErrorEvent.TIMEOUT_EXPIRED));
}
TimeUtil.delay(delay);
}

Back to the top