mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-04-19 13:02:30 +07:00
fixture-based CopyReferenceTest in community
This commit is contained in:
@@ -0,0 +1,4 @@
|
||||
class C2 {
|
||||
public <caret>C2(int i) {
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,9 @@
|
||||
class XXX {
|
||||
void f() {
|
||||
new C2(<caret>)
|
||||
}
|
||||
}
|
||||
class C2 {
|
||||
public C2(int i) {
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,9 @@
|
||||
class XXX {
|
||||
void f() {
|
||||
new <caret>
|
||||
}
|
||||
}
|
||||
class C2 {
|
||||
public C2(int i) {
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,3 @@
|
||||
class X {
|
||||
String s = "/x/x.txt<caret>";
|
||||
}
|
||||
@@ -0,0 +1,3 @@
|
||||
class X {
|
||||
String s = "<caret>";
|
||||
}
|
||||
@@ -0,0 +1,7 @@
|
||||
class XXX {
|
||||
void f() {
|
||||
new <caret>C2();
|
||||
}
|
||||
}
|
||||
class C2 {
|
||||
}
|
||||
@@ -0,0 +1,8 @@
|
||||
class XXX {
|
||||
void f() {
|
||||
new C2();
|
||||
new C2()<caret>
|
||||
}
|
||||
}
|
||||
class C2 {
|
||||
}
|
||||
@@ -0,0 +1,8 @@
|
||||
class XXX {
|
||||
void f() {
|
||||
new C2();
|
||||
new <caret>
|
||||
}
|
||||
}
|
||||
class C2 {
|
||||
}
|
||||
@@ -0,0 +1,2 @@
|
||||
class <caret>C {
|
||||
}
|
||||
@@ -0,0 +1,5 @@
|
||||
class X {
|
||||
void f(C <caret>X x) {}
|
||||
}
|
||||
class C {
|
||||
}
|
||||
@@ -0,0 +1,5 @@
|
||||
class X {
|
||||
void f(<caret>X x) {}
|
||||
}
|
||||
class C {
|
||||
}
|
||||
@@ -0,0 +1,9 @@
|
||||
class Test {
|
||||
public void m() {
|
||||
new Runnable() {
|
||||
public void <caret>run() {
|
||||
|
||||
}
|
||||
};
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,9 @@
|
||||
class Test {
|
||||
public void m() {
|
||||
new Runnable() {
|
||||
public void run() {
|
||||
run()<caret>
|
||||
}
|
||||
};
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,9 @@
|
||||
class Test {
|
||||
public void m() {
|
||||
new Runnable() {
|
||||
public void run() {
|
||||
<caret>
|
||||
}
|
||||
};
|
||||
}
|
||||
}
|
||||
@@ -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);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user