mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-09-27 10:03:11 +07:00
yet another attempt to fix blinking test
This commit is contained in:
+9
-6
@@ -2121,15 +2121,18 @@ public class DaemonRespondToChangesTest extends DaemonAnalyzerTestCase {
|
||||
|
||||
private void waitForDaemon() {
|
||||
long deadline = System.currentTimeMillis() + 60_000;
|
||||
while (PsiDocumentManager.getInstance(myProject).isUncommited(myEditor.getDocument())) {
|
||||
if (System.currentTimeMillis() > deadline) fail("Too long waiting for document commit");
|
||||
UIUtil.dispatchAllInvocationEvents();
|
||||
while (!daemonIsWorkingOrPending()) {
|
||||
if (System.currentTimeMillis() > deadline) fail("Too long waiting for daemon to start");
|
||||
UIUtil.dispatchInvocationEvent();
|
||||
}
|
||||
UIUtil.dispatchAllInvocationEvents(); // make sure daemon is started
|
||||
while (myDaemonCodeAnalyzer.isRunning()) {
|
||||
while (daemonIsWorkingOrPending()) {
|
||||
if (System.currentTimeMillis() > deadline) fail("Too long waiting for daemon to finish");
|
||||
UIUtil.dispatchAllInvocationEvents();
|
||||
UIUtil.dispatchInvocationEvent();
|
||||
}
|
||||
}
|
||||
|
||||
private boolean daemonIsWorkingOrPending() {
|
||||
return PsiDocumentManager.getInstance(myProject).isUncommited(myEditor.getDocument()) || myDaemonCodeAnalyzer.isRunningOrPending();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
+5
@@ -591,6 +591,11 @@ public class DaemonCodeAnalyzerImpl extends DaemonCodeAnalyzerEx implements Pers
|
||||
synchronized boolean isRunning() {
|
||||
return myUpdateProgress != null && !myUpdateProgress.isCanceled();
|
||||
}
|
||||
|
||||
@TestOnly
|
||||
boolean isRunningOrPending() {
|
||||
return isRunning() || !myAlarm.isEmpty();
|
||||
}
|
||||
|
||||
synchronized void stopProcess(boolean toRestartAlarm, @NonNls String reason) {
|
||||
if (!allowToInterrupt) throw new RuntimeException("Cannot interrupt daemon");
|
||||
|
||||
@@ -1821,22 +1821,28 @@ public class UIUtil {
|
||||
/** @see #pump() */
|
||||
@TestOnly
|
||||
public static void dispatchAllInvocationEvents() {
|
||||
//noinspection StatementWithEmptyBody
|
||||
while(dispatchInvocationEvent());
|
||||
}
|
||||
|
||||
@TestOnly
|
||||
public static boolean dispatchInvocationEvent() {
|
||||
assert EdtInvocationManager.getInstance().isEventDispatchThread() : Thread.currentThread() + "; EDT: "+getEventQueueThread();
|
||||
final EventQueue eventQueue = Toolkit.getDefaultToolkit().getSystemEventQueue();
|
||||
while (true) {
|
||||
AWTEvent event = eventQueue.peekEvent();
|
||||
if (event == null) break;
|
||||
try {
|
||||
AWTEvent event1 = eventQueue.getNextEvent();
|
||||
if (event1 instanceof InvocationEvent) {
|
||||
((InvocationEvent)event1).dispatch();
|
||||
}
|
||||
}
|
||||
catch (Exception e) {
|
||||
LOG.error(e); //?
|
||||
AWTEvent event = eventQueue.peekEvent();
|
||||
if (event == null) return false;
|
||||
try {
|
||||
AWTEvent event1 = eventQueue.getNextEvent();
|
||||
if (event1 instanceof InvocationEvent) {
|
||||
((InvocationEvent)event1).dispatch();
|
||||
}
|
||||
}
|
||||
catch (Exception e) {
|
||||
LOG.error(e);
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
private static Thread getEventQueueThread() {
|
||||
EventQueue eventQueue = Toolkit.getDefaultToolkit().getSystemEventQueue();
|
||||
try {
|
||||
|
||||
Reference in New Issue
Block a user