diff options
Diffstat (limited to 'org.eclipse.debug.tests/src/org/eclipse/debug/tests/AbstractDebugTest.java')
-rw-r--r-- | org.eclipse.debug.tests/src/org/eclipse/debug/tests/AbstractDebugTest.java | 42 |
1 files changed, 42 insertions, 0 deletions
diff --git a/org.eclipse.debug.tests/src/org/eclipse/debug/tests/AbstractDebugTest.java b/org.eclipse.debug.tests/src/org/eclipse/debug/tests/AbstractDebugTest.java index 39e3134d3..6c4a54706 100644 --- a/org.eclipse.debug.tests/src/org/eclipse/debug/tests/AbstractDebugTest.java +++ b/org.eclipse.debug.tests/src/org/eclipse/debug/tests/AbstractDebugTest.java @@ -10,6 +10,7 @@ *******************************************************************************/ package org.eclipse.debug.tests; +import java.util.function.Function; import org.eclipse.core.runtime.IProgressMonitor; import org.eclipse.core.runtime.IStatus; import org.eclipse.core.runtime.Status; @@ -28,6 +29,11 @@ public class AbstractDebugTest extends TestCase { private static boolean welcomeClosed; + /** + * Default timeout in milliseconds to wait on some events + */ + protected long testTimeout = 30000; + public AbstractDebugTest() { super(); } @@ -82,6 +88,42 @@ public class AbstractDebugTest extends TestCase { } } + /** + * Waits while given condition is {@code true} for a given amount of + * milliseconds. If the actual wait time exceeds given timeout and condition + * will be still {@code true}, throws {@link AssertionFailedError} with + * given message. + * <p> + * Will process UI events while waiting in UI thread, if called from + * background thread, just waits. + * + * @param condition function which will be evaluated while waiting + * @param timeout max wait time in milliseconds to wait on given condition + * @param errorMessage message which will be used to construct the failure + * exception in case the condition will still return {@code true} + * after given timeout + */ + public void waitWhile(Function<AbstractDebugTest, Boolean> condition, long timeout, Function<AbstractDebugTest, String> errorMessage) throws Exception { + TestUtil.waitWhile(condition, this, timeout, errorMessage); + } + + /** + * Waits while given condition is {@code true} for some time. If the actual + * wait time exceeds {@link #testTimeout} and condition will be still + * {@code true}, throws {@link AssertionFailedError} with given message. + * <p> + * Will process UI events while waiting in UI thread, if called from + * background thread, just waits. + * + * @param condition function which will be evaluated while waiting + * @param errorMessage message which will be used to construct the failure + * exception in case the condition will still return {@code true} + * after given timeout + */ + public void waitWhile(Function<AbstractDebugTest, Boolean> condition, Function<AbstractDebugTest, String> errorMessage) throws Exception { + TestUtil.waitWhile(condition, this, testTimeout, errorMessage); + } + private static void closeIntro(final IWorkbench wb) { IWorkbenchWindow window = wb.getActiveWorkbenchWindow(); if (window != null) { |