summaryrefslogtreecommitdiff
path: root/platform/testFramework/src/com/intellij/testFramework
diff options
context:
space:
mode:
Diffstat (limited to 'platform/testFramework/src/com/intellij/testFramework')
-rw-r--r--platform/testFramework/src/com/intellij/testFramework/EditorTestUtil.java2
-rw-r--r--platform/testFramework/src/com/intellij/testFramework/FileEditorManagerTestCase.java1
-rw-r--r--platform/testFramework/src/com/intellij/testFramework/LightPlatformCodeInsightTestCase.java4
-rw-r--r--platform/testFramework/src/com/intellij/testFramework/PlatformTestUtil.java2
-rw-r--r--platform/testFramework/src/com/intellij/testFramework/TestDataProvider.java6
-rw-r--r--platform/testFramework/src/com/intellij/testFramework/fixtures/impl/CodeInsightTestFixtureImpl.java10
6 files changed, 16 insertions, 9 deletions
diff --git a/platform/testFramework/src/com/intellij/testFramework/EditorTestUtil.java b/platform/testFramework/src/com/intellij/testFramework/EditorTestUtil.java
index d42e639438c2..870d6d53b998 100644
--- a/platform/testFramework/src/com/intellij/testFramework/EditorTestUtil.java
+++ b/platform/testFramework/src/com/intellij/testFramework/EditorTestUtil.java
@@ -208,7 +208,7 @@ public class EditorTestUtil {
return visibleWidth;
}
});
- applianceManager.setRepresentationHelper(new DefaultEditorTextRepresentationHelper(editor) {
+ model.setEditorTextRepresentationHelper(new DefaultEditorTextRepresentationHelper(editor) {
@Override
public int charWidth(char c, int fontType) {
return charWidthInPixels;
diff --git a/platform/testFramework/src/com/intellij/testFramework/FileEditorManagerTestCase.java b/platform/testFramework/src/com/intellij/testFramework/FileEditorManagerTestCase.java
index 77b93ac6f88f..e3f0d0788cfb 100644
--- a/platform/testFramework/src/com/intellij/testFramework/FileEditorManagerTestCase.java
+++ b/platform/testFramework/src/com/intellij/testFramework/FileEditorManagerTestCase.java
@@ -54,6 +54,7 @@ public abstract class FileEditorManagerTestCase extends LightPlatformCodeInsight
super.setUp();
myManager = new FileEditorManagerImpl(getProject(), DockManager.getInstance(getProject()), EditorHistoryManager.getInstance(getProject()));
myOldManager = ((ComponentManagerImpl)getProject()).registerComponentInstance(FileEditorManager.class, myManager);
+ ((FileEditorProviderManagerImpl)FileEditorProviderManager.getInstance()).clearSelectedProviders();
}
@Override
diff --git a/platform/testFramework/src/com/intellij/testFramework/LightPlatformCodeInsightTestCase.java b/platform/testFramework/src/com/intellij/testFramework/LightPlatformCodeInsightTestCase.java
index 90c2ca11b49a..24e4074ed4ee 100644
--- a/platform/testFramework/src/com/intellij/testFramework/LightPlatformCodeInsightTestCase.java
+++ b/platform/testFramework/src/com/intellij/testFramework/LightPlatformCodeInsightTestCase.java
@@ -15,7 +15,7 @@
*/
package com.intellij.testFramework;
-import com.intellij.codeInsight.generation.CommentByLineCommentHandler;
+import com.intellij.codeInsight.generation.actions.CommentByLineCommentAction;
import com.intellij.ide.DataManager;
import com.intellij.injected.editor.DocumentWindow;
import com.intellij.injected.editor.EditorWindow;
@@ -501,7 +501,7 @@ public abstract class LightPlatformCodeInsightTestCase extends LightPlatformTest
}
protected static void lineComment() {
- new CommentByLineCommentHandler().invoke(getProject(), getEditor(), getFile());
+ new CommentByLineCommentAction().actionPerformedImpl(getProject(), getEditor());
}
protected static void executeAction(@NonNls @NotNull final String actionId) {
diff --git a/platform/testFramework/src/com/intellij/testFramework/PlatformTestUtil.java b/platform/testFramework/src/com/intellij/testFramework/PlatformTestUtil.java
index 37fd23da6741..0c46f14b98e0 100644
--- a/platform/testFramework/src/com/intellij/testFramework/PlatformTestUtil.java
+++ b/platform/testFramework/src/com/intellij/testFramework/PlatformTestUtil.java
@@ -762,7 +762,7 @@ public class PlatformTestUtil {
public static String getCommunityPath() {
final String homePath = PathManager.getHomePath();
- if (new File(homePath, "community").exists()) {
+ if (new File(homePath, "community/.idea").isDirectory()) {
return homePath + File.separatorChar + "community";
}
return homePath;
diff --git a/platform/testFramework/src/com/intellij/testFramework/TestDataProvider.java b/platform/testFramework/src/com/intellij/testFramework/TestDataProvider.java
index b5f84d33c6c4..cc8376832e36 100644
--- a/platform/testFramework/src/com/intellij/testFramework/TestDataProvider.java
+++ b/platform/testFramework/src/com/intellij/testFramework/TestDataProvider.java
@@ -17,11 +17,13 @@ package com.intellij.testFramework;
import com.intellij.openapi.actionSystem.CommonDataKeys;
import com.intellij.openapi.actionSystem.DataProvider;
+import com.intellij.openapi.actionSystem.PlatformDataKeys;
import com.intellij.openapi.editor.Editor;
import com.intellij.openapi.editor.impl.EditorComponentImpl;
import com.intellij.openapi.fileEditor.FileEditorManager;
import com.intellij.openapi.fileEditor.OpenFileDescriptor;
import com.intellij.openapi.fileEditor.ex.FileEditorManagerEx;
+import com.intellij.openapi.fileEditor.impl.text.TextEditorProvider;
import com.intellij.openapi.project.Project;
import org.jetbrains.annotations.NonNls;
import org.jetbrains.annotations.NotNull;
@@ -51,6 +53,10 @@ public class TestDataProvider implements DataProvider {
else if (CommonDataKeys.EDITOR.is(dataId) || OpenFileDescriptor.NAVIGATE_IN_EDITOR.is(dataId)) {
return FileEditorManager.getInstance(myProject).getSelectedTextEditor();
}
+ else if (PlatformDataKeys.FILE_EDITOR.is(dataId)) {
+ Editor editor = FileEditorManager.getInstance(myProject).getSelectedTextEditor();
+ return editor == null ? null : TextEditorProvider.getInstance().getTextEditor(editor);
+ }
else {
Editor editor = (Editor)getData(CommonDataKeys.EDITOR.getName());
if (editor != null) {
diff --git a/platform/testFramework/src/com/intellij/testFramework/fixtures/impl/CodeInsightTestFixtureImpl.java b/platform/testFramework/src/com/intellij/testFramework/fixtures/impl/CodeInsightTestFixtureImpl.java
index ce58f3071581..4857acd2d328 100644
--- a/platform/testFramework/src/com/intellij/testFramework/fixtures/impl/CodeInsightTestFixtureImpl.java
+++ b/platform/testFramework/src/com/intellij/testFramework/fixtures/impl/CodeInsightTestFixtureImpl.java
@@ -1061,19 +1061,19 @@ public class CodeInsightTestFixtureImpl extends BaseFixture implements CodeInsig
final CaretModel caretModel = myEditor.getCaretModel();
final List<Caret> carets = caretModel.getAllCarets();
- final Collection<Integer> originalOffsets = new ArrayList<Integer>(carets.size());
+ final List<Integer> originalOffsets = new ArrayList<Integer>(carets.size());
for (final Caret caret : carets) {
originalOffsets.add(caret.getOffset());
}
caretModel.removeSecondaryCarets();
- int newOffset = 0; // To be incremented each time we complete something
+ // We do it in reverse order because completions would affect offsets
+ // i.e.: when you complete "spa" to "spam", next caret offset increased by 1
+ Collections.reverse(originalOffsets);
for (final int originalOffset : originalOffsets) {
- final int realOffsetBeforeCompletion = originalOffset + newOffset;
- caretModel.moveToOffset(realOffsetBeforeCompletion);
+ caretModel.moveToOffset(originalOffset);
completeBasic();
- newOffset += (getCaretOffset() - realOffsetBeforeCompletion);
}
}