diff options
author | Martin Fluegge | 2010-08-27 08:01:15 +0000 |
---|---|---|
committer | Martin Fluegge | 2010-08-27 08:01:15 +0000 |
commit | df56ab7de6df1a105b99c35cf2f65691044e4317 (patch) | |
tree | e892e75420f1d81165878b12c6ef2d992f8b75fb /plugins/org.eclipse.emf.cdo.tests.ui/src | |
parent | 98dbde127282df1127ee7d6cfe35fdd99d802cf3 (diff) | |
download | cdo-df56ab7de6df1a105b99c35cf2f65691044e4317.tar.gz cdo-df56ab7de6df1a105b99c35cf2f65691044e4317.tar.xz cdo-df56ab7de6df1a105b99c35cf2f65691044e4317.zip |
[320193] [Dawn] Provide a flexible testing environment for UI tests
https://bugs.eclipse.org/bugs/show_bug.cgi?id=320193
Diffstat (limited to 'plugins/org.eclipse.emf.cdo.tests.ui/src')
-rw-r--r-- | plugins/org.eclipse.emf.cdo.tests.ui/src/org/eclipse/emf/cdo/tests/ui/AbstractCDOUITest.java | 42 |
1 files changed, 40 insertions, 2 deletions
diff --git a/plugins/org.eclipse.emf.cdo.tests.ui/src/org/eclipse/emf/cdo/tests/ui/AbstractCDOUITest.java b/plugins/org.eclipse.emf.cdo.tests.ui/src/org/eclipse/emf/cdo/tests/ui/AbstractCDOUITest.java index ac6e666cc3..1d257ef1e9 100644 --- a/plugins/org.eclipse.emf.cdo.tests.ui/src/org/eclipse/emf/cdo/tests/ui/AbstractCDOUITest.java +++ b/plugins/org.eclipse.emf.cdo.tests.ui/src/org/eclipse/emf/cdo/tests/ui/AbstractCDOUITest.java @@ -28,6 +28,9 @@ import org.eclipse.ui.IWorkbenchWindow; import org.eclipse.ui.PlatformUI; import org.eclipse.ui.WorkbenchException; +import java.util.concurrent.CountDownLatch; +import java.util.concurrent.TimeUnit; + /** * @author Martin Fluegge */ @@ -44,6 +47,28 @@ public abstract class AbstractCDOUITest extends AbstractCDOTest protected void closeAllEditors() { + final CountDownLatch countDownLatch = new CountDownLatch(1); + Display.getDefault().asyncExec(new Runnable() + { + + public void run() + { + PlatformUI.getWorkbench().getActiveWorkbenchWindow().getActivePage().closeAllEditors(false); + countDownLatch.countDown(); + } + }); + try + { + countDownLatch.await(5000, TimeUnit.MILLISECONDS); + } + catch (InterruptedException ex) + { + throw new RuntimeException(ex); + } + } + + protected void closeAllEditorsSync() + { UIThreadRunnable.syncExec(new VoidResult() { public void run() @@ -55,7 +80,8 @@ public abstract class AbstractCDOUITest extends AbstractCDOTest protected void resetWorkbench() { - UIThreadRunnable.syncExec(new VoidResult() + final CountDownLatch countDownLatch = new CountDownLatch(1); + UIThreadRunnable.asyncExec(new VoidResult() { public void run() { @@ -66,7 +92,7 @@ public abstract class AbstractCDOUITest extends AbstractCDOTest IWorkbenchPage page = workbenchWindow.getActivePage(); Shell activeShell = Display.getCurrent().getActiveShell(); - if (activeShell != workbenchWindow.getShell()) + if (activeShell != workbenchWindow.getShell() && activeShell != null) { activeShell.close(); } @@ -83,8 +109,20 @@ public abstract class AbstractCDOUITest extends AbstractCDOTest { throw new RuntimeException(e); } + finally + { + countDownLatch.countDown(); + } } }); + try + { + countDownLatch.await(DEFAULT_TIMEOUT, TimeUnit.MILLISECONDS); + } + catch (InterruptedException ex) + { + throw new RuntimeException(ex); + } } /** |