public void testAutoImportWorks() throws Throwable {
    @NonNls final String text = "class S { JFrame x; <caret> }";
    configureByText(StdFileTypes.JAVA, text);
    ((UndoManagerImpl) UndoManager.getInstance(getProject())).flushCurrentCommandMerger();
    ((UndoManagerImpl) UndoManager.getInstance(getProject()))
        .clearUndoRedoQueueInTests(getFile().getVirtualFile());
    assertFalse(
        ((DaemonCodeAnalyzerImpl) DaemonCodeAnalyzer.getInstance(getProject()))
            .canChangeFileSilently(getFile()));

    doHighlighting();
    assertFalse(
        ((DaemonCodeAnalyzerImpl) DaemonCodeAnalyzer.getInstance(getProject()))
            .canChangeFileSilently(getFile()));

    type(" ");
    assertTrue(
        ((DaemonCodeAnalyzerImpl) DaemonCodeAnalyzer.getInstance(getProject()))
            .canChangeFileSilently(getFile()));

    undo();

    assertFalse(
        ((DaemonCodeAnalyzerImpl) DaemonCodeAnalyzer.getInstance(getProject()))
            .canChangeFileSilently(
                getFile())); // CodeInsightSettings.getInstance().ADD_UNAMBIGIOUS_IMPORTS_ON_THE_FLY
                             // = old;
  }
 @Override
 protected void setUp() throws Exception {
   super.setUp();
   CodeStyleSettings settings = CodeStyleSettingsManager.getSettings(getProject()).clone();
   settings.CLASS_COUNT_TO_USE_IMPORT_ON_DEMAND = 100;
   CodeStyleSettingsManager.getInstance(getProject()).setTemporarySettings(settings);
   DaemonCodeAnalyzer.getInstance(getProject()).setUpdateByTimerEnabled(false);
 }