From 32afcf75e97b3d1abb591b4123e9ece1726da76a Mon Sep 17 00:00:00 2001 From: peter Date: Fri, 15 Sep 2017 18:29:40 +0200 Subject: [PATCH] fix LaterInvocatorTest --- .../application/impl/LaterInvocatorTest.java | 44 ++++--------------- 1 file changed, 9 insertions(+), 35 deletions(-) diff --git a/platform/platform-tests/testSrc/com/intellij/openapi/application/impl/LaterInvocatorTest.java b/platform/platform-tests/testSrc/com/intellij/openapi/application/impl/LaterInvocatorTest.java index 5ae6dbd18949..0500b7d12373 100644 --- a/platform/platform-tests/testSrc/com/intellij/openapi/application/impl/LaterInvocatorTest.java +++ b/platform/platform-tests/testSrc/com/intellij/openapi/application/impl/LaterInvocatorTest.java @@ -21,10 +21,7 @@ import com.intellij.openapi.application.ModalityState; import com.intellij.openapi.diagnostic.Logger; import com.intellij.openapi.util.Conditions; import com.intellij.openapi.util.EmptyRunnable; -import com.intellij.testFramework.LoggedErrorProcessor; -import com.intellij.testFramework.PlatformTestCase; -import com.intellij.testFramework.SkipInHeadlessEnvironment; -import com.intellij.testFramework.UsefulTestCase; +import com.intellij.testFramework.*; import com.intellij.util.ThrowableRunnable; import com.intellij.util.ui.UIUtil; import junit.framework.TestCase; @@ -80,22 +77,15 @@ public class LaterInvocatorTest extends PlatformTestCase { return "Window2"; } }; - final Exception[] exception = {null}; - UIUtil.invokeAndWaitIfNeeded((Runnable)() -> { - try { - super.setUp(); - final Object[] modalEntities = LaterInvocator.getCurrentModalEntities(); - if (modalEntities.length > 0) { - LOG.error( - "Expect no modal entries. Probably some of the previous tests didn't left their entries. Top entry is: " + modalEntities[0]); - } - } - catch (Exception e) { - exception[0] = e; + EdtTestUtil.runInEdtAndWait(() -> { + super.setUp(); + final Object[] modalEntities = LaterInvocator.getCurrentModalEntities(); + if (modalEntities.length > 0) { + LOG.error( + "Expect no modal entries. Probably some of the previous tests didn't left their entries. Top entry is: " + modalEntities[0]); } }); - if (exception[0] != null) throw exception[0]; - UIUtil.invokeAndWaitIfNeeded((Runnable)() -> TestCase.assertFalse("Can't run test " + ModalityState.current(), LaterInvocator.isInModalContext())); + EdtTestUtil.runInEdtAndWait(() -> TestCase.assertFalse("Can't run test " + ModalityState.current(), LaterInvocator.isInModalContext())); flushSwingQueue(); } @@ -128,23 +118,7 @@ public class LaterInvocatorTest extends PlatformTestCase { } }); - final Exception[] exception = {null}; - UIUtil.invokeAndWaitIfNeeded(new Runnable() { - @Override - public void run() { - try { - LaterInvocatorTest.super.tearDown(); - } - catch (Exception e) { - exception[0] = e; - } - } - - public String toString() { - return "super teardown"; - } - }); - if (exception[0] != null) throw exception[0]; + EdtTestUtil.runInEdtAndWait(() -> super.tearDown()); } public void testReorder() {