void () { registerInspection(new MyVisibleRangeInspection()); String text = "blah blah\n".repeat(1000) + "<caret>" + wordToAnnotate + "\n" + "balh blah\n".repeat(1000); configureByText(PlainTextFileType.INSTANCE, text); EditorImpl editor = (EditorImpl)getEditor(); editor.getScrollPane().getViewport().setSize(1000, 1000); DaemonCodeAnalyzerSettings.getInstance().setImportHintEnabled(true); editor.getScrollingModel().scrollToCaret(ScrollType.MAKE_VISIBLE); Point2D caretVisualPoint = editor.offsetToPoint2D(editor.getCaretModel().getOffset()); editor.getScrollPane().getViewport().setViewPosition(new Point((int)caretVisualPoint.getX(), (int)caretVisualPoint.getY())); editor.getScrollPane().getViewport().setExtentSize(new Dimension(100, editor.getPreferredHeight() - (int)caretVisualPoint.getY())); ProperTextRange visibleRange = editor.calculateVisibleRange(); assertTrue(visibleRange.toString(), visibleRange.getStartOffset() > 0); myDaemonCodeAnalyzer.restart(); expectedVisibleRange = visibleRange; doHighlighting(); assertNull(expectedVisibleRange); // check the inspection was run makeWholeEditorWindowVisible(editor); myDaemonCodeAnalyzer.restart(); expectedVisibleRange = new TextRange(0, editor.getDocument().getTextLength()); doHighlighting(); assertNull(expectedVisibleRange); // check the inspection was run }