void () { TodoPattern pattern = new TodoPattern("(x+x+)+y", TodoAttributesUtil.createDefault(), true); TodoPattern[] oldPatterns = TodoConfiguration.getInstance().getTodoPatterns(); TodoPattern[] newPatterns = new TodoPattern[]{pattern}; TodoConfiguration.getInstance().setTodoPatterns(newPatterns); PlatformTestUtil.dispatchAllEventsInIdeEventQueue(); FileBasedIndex.getInstance().ensureUpToDate(IdIndex.NAME, getProject(), GlobalSearchScope.allScope(getProject())); myFixture.addFileToProject("Foo.txt", "xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx"); try { final CountDownLatch progressStarted = new CountDownLatch(1); final ProgressIndicatorBase progressIndicatorBase = new ProgressIndicatorBase(); final AtomicBoolean canceled = new AtomicBoolean(false); ApplicationManager.getApplication().executeOnPooledThread(() -> { try { progressStarted.await(); TimeoutUtil.sleep(1000); progressIndicatorBase.cancel(); TimeoutUtil.sleep(500); assertTrue(canceled.get()); } catch (Exception e) { throw new AssertionError("Should not throw exceptions", e); } }); ProgressManager.getInstance().runProcess(() -> { try { progressStarted.countDown(); FileBasedIndex.getInstance().ensureUpToDate(IdIndex.NAME, getProject(), GlobalSearchScope.allScope(getProject())); } catch (ProcessCanceledException ignore) { canceled.set(true); } }, progressIndicatorBase ); } finally { TodoConfiguration.getInstance().setTodoPatterns(oldPatterns); } }