GitOrigin-RevId: 1ae83bfca90fb89e405b40a8eeeebe56050616ae
This commit is contained in:
Alexey Kudravtsev
2022-07-01 16:18:20 +00:00
committed by intellij-monorepo-bot
parent 35a33a9b83
commit 20f34d84c3
@@ -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++) {