From fcb3f807553ca14344b6026d56180ddcfe90cac6 Mon Sep 17 00:00:00 2001 From: Aleksey Pivovarov Date: Fri, 3 Apr 2015 15:28:43 +0300 Subject: [PATCH] fix tests after b02da0a --- .../LightPlatformCodeInsightTestCase.java | 36 +++++++++++++++---- 1 file changed, 30 insertions(+), 6 deletions(-) diff --git a/platform/testFramework/src/com/intellij/testFramework/LightPlatformCodeInsightTestCase.java b/platform/testFramework/src/com/intellij/testFramework/LightPlatformCodeInsightTestCase.java index e184530ad771..1caaee7a1c99 100644 --- a/platform/testFramework/src/com/intellij/testFramework/LightPlatformCodeInsightTestCase.java +++ b/platform/testFramework/src/com/intellij/testFramework/LightPlatformCodeInsightTestCase.java @@ -344,14 +344,38 @@ public abstract class LightPlatformCodeInsightTestCase extends LightPlatformTest protected void checkResultByText(final String message, @NotNull final String fileText, final boolean ignoreTrailingSpaces, final String filePath) { bringRealEditorBack(); PsiDocumentManager.getInstance(getProject()).commitAllDocuments(); - checkResultByText(message, myEditor, fileText, ignoreTrailingSpaces, filePath); + ApplicationManager.getApplication().runWriteAction(new Runnable() { + @Override + public void run() { + final Document document = EditorFactory.getInstance().createDocument(fileText); + + if (ignoreTrailingSpaces) { + ((DocumentImpl)document).stripTrailingSpaces(getProject()); + } + + EditorTestUtil.CaretAndSelectionState carets = EditorTestUtil.extractCaretAndSelectionMarkers(document); + + PostprocessReformattingAspect.getInstance(getProject()).doPostponedFormatting(); + String newFileText = document.getText(); + + PsiDocumentManager.getInstance(getProject()).commitAllDocuments(); + String fileText = myFile.getText(); + String failMessage = getMessage("Text mismatch", message); + if (filePath != null && !newFileText.equals(fileText)) { + throw new FileComparisonFailure(failMessage, newFileText, fileText, filePath); + } + assertEquals(failMessage, newFileText, fileText); + + EditorTestUtil.verifyCaretAndSelectionState(myEditor, carets, message); + } + }); } - protected static void checkResultByText(final String message, - @NotNull final Editor editor, - @NotNull final String fileText, - final boolean ignoreTrailingSpaces, - final String filePath) { + protected static void checkResultByTextWithoutPSI(final String message, + @NotNull final Editor editor, + @NotNull final String fileText, + final boolean ignoreTrailingSpaces, + final String filePath) { ApplicationManager.getApplication().runWriteAction(new Runnable() { @Override public void run() {