fixture-based CopyReferenceTest in community

This commit is contained in:
peter
2012-07-05 17:26:17 +02:00
parent 3cc055c6ec
commit 116c7fdcd0
15 changed files with 157 additions and 0 deletions

View File

@@ -0,0 +1,4 @@
class C2 {
public <caret>C2(int i) {
}
}

View File

@@ -0,0 +1,9 @@
class XXX {
void f() {
new C2(<caret>)
}
}
class C2 {
public C2(int i) {
}
}

View File

@@ -0,0 +1,9 @@
class XXX {
void f() {
new <caret>
}
}
class C2 {
public C2(int i) {
}
}

View File

@@ -0,0 +1,3 @@
class X {
String s = "/x/x.txt<caret>";
}

View File

@@ -0,0 +1,3 @@
class X {
String s = "<caret>";
}

View File

@@ -0,0 +1,7 @@
class XXX {
void f() {
new <caret>C2();
}
}
class C2 {
}

View File

@@ -0,0 +1,8 @@
class XXX {
void f() {
new C2();
new C2()<caret>
}
}
class C2 {
}

View File

@@ -0,0 +1,8 @@
class XXX {
void f() {
new C2();
new <caret>
}
}
class C2 {
}

View File

@@ -0,0 +1,2 @@
class <caret>C {
}

View File

@@ -0,0 +1,5 @@
class X {
void f(C <caret>X x) {}
}
class C {
}

View File

@@ -0,0 +1,5 @@
class X {
void f(<caret>X x) {}
}
class C {
}

View File

@@ -0,0 +1,9 @@
class Test {
public void m() {
new Runnable() {
public void <caret>run() {
}
};
}
}

View File

@@ -0,0 +1,9 @@
class Test {
public void m() {
new Runnable() {
public void run() {
run()<caret>
}
};
}
}

View File

@@ -0,0 +1,9 @@
class Test {
public void m() {
new Runnable() {
public void run() {
<caret>
}
};
}
}

View File

@@ -0,0 +1,67 @@
package com.intellij.codeInsight;
import com.intellij.JavaTestUtil;
import com.intellij.ide.actions.CopyReferenceAction;
import com.intellij.openapi.actionSystem.ActionManager;
import com.intellij.openapi.actionSystem.IdeActions;
import com.intellij.psi.PsiFile;
import com.intellij.testFramework.fixtures.LightCodeInsightFixtureTestCase;
import org.jetbrains.annotations.NonNls;
public class CopyReferenceTest extends LightCodeInsightFixtureTestCase {
@NonNls private static final String BASE_PATH = "/codeInsight/copyReference";
protected int oldSetting;
@Override
protected String getBasePath() {
return JavaTestUtil.getRelativeJavaTestDataPath() + BASE_PATH;
}
@Override
protected void setUp() throws Exception {
super.setUp();
CodeInsightSettings settings = CodeInsightSettings.getInstance();
oldSetting = settings.ADD_IMPORTS_ON_PASTE;
settings.ADD_IMPORTS_ON_PASTE = CodeInsightSettings.YES;
}
@Override
protected void tearDown() throws Exception {
CodeInsightSettings settings = CodeInsightSettings.getInstance();
settings.ADD_IMPORTS_ON_PASTE = oldSetting;
super.tearDown();
}
public void testConstructor() throws Exception { doTest(); }
public void testDefaultConstructor() throws Exception { doTest(); }
public void testIdentifierSeparator() throws Exception { doTest(); }
public void testMethodFromAnonymousClass() throws Exception { doTest(); }
public void testCopyFile() throws Exception {
PsiFile psiFile = myFixture.addFileToProject("x/x.txt", "");
assertTrue(CopyReferenceAction.doCopy(psiFile, getProject()));
String name = getTestName(false);
myFixture.configureByFile(name + "_dst.java");
performPaste();
myFixture.checkResultByFile(name + "_after.java");
}
private void doTest() throws Exception {
String name = getTestName(false);
myFixture.configureByFile(name + ".java");
performCopy();
myFixture.configureByFile(name + "_dst.java");
performPaste();
myFixture.checkResultByFile(name + "_after.java");
}
private void performCopy() {
myFixture.testAction(ActionManager.getInstance().getAction(IdeActions.ACTION_COPY_REFERENCE));
}
private void performPaste() {
myFixture.performEditorAction(IdeActions.ACTION_EDITOR_PASTE);
}
}