From 20f34d84c3975d531f8b32e27cacbc4fe8be749e Mon Sep 17 00:00:00 2001 From: Alexey Kudravtsev Date: Fri, 1 Jul 2022 18:04:38 +0200 Subject: [PATCH] cleanup GitOrigin-RevId: 1ae83bfca90fb89e405b40a8eeeebe56050616ae --- .../application/impl/LaterInvocatorTest.java | 43 ++----------------- 1 file changed, 4 insertions(+), 39 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 ecfa78dbc136..2727ce55195c 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 @@ -172,19 +172,7 @@ public class LaterInvocatorTest extends HeavyPlatformTestCase { public void testStress() { UIUtil.invokeAndWaitIfNeeded((Runnable)() -> { int N = 1000; - //long start = System.currentTimeMillis(); for (int i = 0; i < N; i++) { - /* - if (i % 10 == 0) { - long elapsed = System.currentTimeMillis() - start; - System.out.println("i = " + i+"; elapsed="+elapsed); - start = System.currentTimeMillis(); - } - */ - - //assertEquals(null, Toolkit.getDefaultToolkit().getSystemEventQueue().peekEvent()); - //assertEquals(null, LaterInvocator.dumpQueue()); - UsefulTestCase.assertEmpty(LaterInvocator.getCurrentModalEntities()); LaterInvocator.enterModal(myWindow2); //some weird things like MyFireIdleRequest may still sneak in @@ -212,10 +200,7 @@ public class LaterInvocatorTest extends HeavyPlatformTestCase { LaterInvocator.leaveModal(myWindow2); flushSwingQueue(); - if (!LaterInvocator.isInModalContext()) { - //System.out.println("inv queue" + LaterInvocator.dumpQueue()); - TestCase.fail(); - } + assertTrue(LaterInvocator.isInModalContext()); checkOrder(0); @@ -356,32 +341,12 @@ public class LaterInvocatorTest extends HeavyPlatformTestCase { } static void flushSwingQueue() { - - //try { - // Thread.sleep(10); - //} - //catch (InterruptedException e) { - // throw new RuntimeException(e); - //} - if (SwingUtilities.isEventDispatchThread()) { UIUtil.dispatchAllInvocationEvents(); } else { UIUtil.pump(); } - /* - final AtomicBoolean hasEventsInQueue = new AtomicBoolean(true); - while (hasEventsInQueue.get()) { - UIUtil.invokeAndWaitIfNeeded(new Runnable() { - @Override - public void run() { - hasEventsInQueue.set(Toolkit.getDefaultToolkit().getSystemEventQueue().peekEvent() != null); - } - }); - } - */ - //some weird things like MyFireIdleRequest may still sneak in //assertEquals(null, Toolkit.getDefaultToolkit().getSystemEventQueue().peekEvent()); } @@ -622,7 +587,7 @@ public class LaterInvocatorTest extends HeavyPlatformTestCase { AtomicInteger counter = new AtomicInteger(); Runnable r = () -> counter.incrementAndGet(); - PlatformTestUtil.startPerformanceTest("Swing invokeLater", 20_000, () -> { + PlatformTestUtil.startPerformanceTest(getTestName(false), 20_000, () -> { for (int i = 0; i < N; i++) { if (i % 8192 == 0) { // decrease GC pressure, we're not measuring that @@ -639,7 +604,7 @@ public class LaterInvocatorTest extends HeavyPlatformTestCase { int N = 1_000_000; AtomicInteger counter = new AtomicInteger(); Runnable r = () -> counter.incrementAndGet(); - PlatformTestUtil.startPerformanceTest("Application invokeLater", 800, () -> { + PlatformTestUtil.startPerformanceTest(getTestName(false), 800, () -> { Application application = ApplicationManager.getApplication(); for (int i = 0; i < N; i++) { if (i % 8192 == 0) { @@ -659,7 +624,7 @@ public class LaterInvocatorTest extends HeavyPlatformTestCase { Runnable r = () -> counter.incrementAndGet(); Application application = ApplicationManager.getApplication(); application.invokeAndWait(r); - PlatformTestUtil.startPerformanceTest("Application invokeLater in modal context", 800, () -> { + PlatformTestUtil.startPerformanceTest(getTestName(false), 800, () -> { counter.set(0); UIUtil.invokeAndWaitIfNeeded((Runnable)() -> LaterInvocator.enterModal(myWindow1)); for (int i = 0; i < N; i++) {