mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-10-01 23:06:24 +07:00
test++
This commit is contained in:
@@ -0,0 +1,104 @@
|
||||
/*
|
||||
* User: anna
|
||||
* Date: 06-May-2008
|
||||
*/
|
||||
package com.intellij.refactoring;
|
||||
|
||||
import com.intellij.codeInsight.CodeInsightTestCase;
|
||||
import com.intellij.codeInsight.TargetElementUtilBase;
|
||||
import com.intellij.psi.PsiElement;
|
||||
import com.intellij.psi.PsiMethod;
|
||||
import com.intellij.refactoring.extractMethodObject.ExtractMethodObjectProcessor;
|
||||
import com.intellij.refactoring.util.duplicates.DuplicatesImpl;
|
||||
import com.intellij.JavaTestUtil;
|
||||
|
||||
public class ExtractMethodObjectTest extends CodeInsightTestCase {
|
||||
@Override
|
||||
protected String getTestDataPath() {
|
||||
return JavaTestUtil.getJavaTestDataPath();
|
||||
}
|
||||
|
||||
private void doTest() throws Exception {
|
||||
doTest(true);
|
||||
}
|
||||
|
||||
private void doTest(boolean createInnerClass) throws Exception {
|
||||
final String testName = getTestName(true);
|
||||
configureByFile("/refactoring/extractMethodObject/" + testName + ".java");
|
||||
PsiElement element = TargetElementUtilBase.findTargetElement(myEditor, TargetElementUtilBase.ELEMENT_NAME_ACCEPTED);
|
||||
assertTrue(element instanceof PsiMethod);
|
||||
PsiMethod method = (PsiMethod) element;
|
||||
|
||||
final ExtractMethodObjectProcessor processor =
|
||||
new ExtractMethodObjectProcessor(getProject(), getEditor(), method.getBody().getStatements(), "InnerClass");
|
||||
final ExtractMethodObjectProcessor.MyExtractMethodProcessor extractProcessor = processor.getExtractProcessor();
|
||||
extractProcessor.setShowErrorDialogs(false);
|
||||
extractProcessor.prepare();
|
||||
extractProcessor.testRun();
|
||||
processor.setCreateInnerClass(createInnerClass);
|
||||
processor.run();
|
||||
DuplicatesImpl.processDuplicates(extractProcessor, getProject(), getEditor());
|
||||
processor.getMethod().delete();
|
||||
checkResultByFile("/refactoring/extractMethodObject/" + testName + ".java" + ".after");
|
||||
}
|
||||
|
||||
public void testStatic() throws Exception {
|
||||
doTest();
|
||||
}
|
||||
|
||||
public void testStaticTypeParams() throws Exception {
|
||||
doTest();
|
||||
}
|
||||
|
||||
public void testStaticTypeParamsReturn() throws Exception {
|
||||
doTest();
|
||||
}
|
||||
|
||||
public void testTypeParamsReturn() throws Exception {
|
||||
doTest();
|
||||
}
|
||||
|
||||
public void testTypeParams() throws Exception {
|
||||
doTest();
|
||||
}
|
||||
|
||||
public void testMethodInHierarchy() throws Exception {
|
||||
doTest();
|
||||
}
|
||||
|
||||
public void testQualifier() throws Exception {
|
||||
doTest();
|
||||
}
|
||||
|
||||
public void testVarargs() throws Exception {
|
||||
doTest();
|
||||
}
|
||||
|
||||
public void testFieldUsage() throws Exception {
|
||||
doTest();
|
||||
}
|
||||
|
||||
public void testMethodInHierarchyReturn() throws Exception {
|
||||
doTest();
|
||||
}
|
||||
|
||||
public void testStaticTypeParamsReturnNoDelete() throws Exception {
|
||||
doTest();
|
||||
}
|
||||
|
||||
public void testStaticTypeParamsRecursive() throws Exception {
|
||||
doTest();
|
||||
}
|
||||
|
||||
public void testRecursion() throws Exception {
|
||||
doTest();
|
||||
}
|
||||
|
||||
public void testWrapWithObject() throws Exception {
|
||||
doTest(false);
|
||||
}
|
||||
|
||||
public void testWrapWithObjectRecursive() throws Exception {
|
||||
doTest(false);
|
||||
}
|
||||
}
|
||||
+69
@@ -0,0 +1,69 @@
|
||||
/*
|
||||
* User: anna
|
||||
* Date: 06-May-2008
|
||||
*/
|
||||
package com.intellij.refactoring;
|
||||
|
||||
import com.intellij.codeInsight.CodeInsightTestCase;
|
||||
import com.intellij.codeInsight.CodeInsightUtil;
|
||||
import com.intellij.psi.PsiElement;
|
||||
import com.intellij.psi.PsiExpression;
|
||||
import com.intellij.refactoring.extractMethodObject.ExtractMethodObjectProcessor;
|
||||
import com.intellij.refactoring.util.duplicates.DuplicatesImpl;
|
||||
import com.intellij.JavaTestUtil;
|
||||
|
||||
public class ExtractMethodObjectWithMultipleExitPointsTest extends CodeInsightTestCase {
|
||||
@Override
|
||||
protected String getTestDataPath() {
|
||||
return JavaTestUtil.getJavaTestDataPath();
|
||||
}
|
||||
|
||||
private void doTest() throws Exception {
|
||||
doTest(true);
|
||||
}
|
||||
|
||||
private void doTest(boolean createInnerClass) throws Exception {
|
||||
final String testName = getTestName(true);
|
||||
configureByFile("/refactoring/extractMethodObject/multipleExitPoints/" + testName + ".java");
|
||||
int startOffset = myEditor.getSelectionModel().getSelectionStart();
|
||||
int endOffset = myEditor.getSelectionModel().getSelectionEnd();
|
||||
|
||||
PsiElement[] elements;
|
||||
PsiExpression expr = CodeInsightUtil.findExpressionInRange(myFile, startOffset, endOffset);
|
||||
if (expr != null) {
|
||||
elements = new PsiElement[]{expr};
|
||||
}
|
||||
else {
|
||||
elements = CodeInsightUtil.findStatementsInRange(myFile, startOffset, endOffset);
|
||||
}
|
||||
|
||||
final ExtractMethodObjectProcessor processor =
|
||||
new ExtractMethodObjectProcessor(getProject(), getEditor(), elements, "Inner");
|
||||
final ExtractMethodObjectProcessor.MyExtractMethodProcessor extractProcessor = processor.getExtractProcessor();
|
||||
extractProcessor.setShowErrorDialogs(false);
|
||||
extractProcessor.prepare();
|
||||
extractProcessor.testRun();
|
||||
processor.setCreateInnerClass(createInnerClass);
|
||||
processor.run();
|
||||
DuplicatesImpl.processDuplicates(extractProcessor, getProject(), getEditor());
|
||||
processor.getMethod().delete();
|
||||
checkResultByFile("/refactoring/extractMethodObject/multipleExitPoints/" + testName + ".java" + ".after");
|
||||
}
|
||||
|
||||
public void testStaticInner() throws Exception {
|
||||
doTest();
|
||||
}
|
||||
|
||||
public void testInputOutput() throws Exception {
|
||||
doTest();
|
||||
}
|
||||
|
||||
public void testOutputVarsReferences() throws Exception {
|
||||
doTest();
|
||||
}
|
||||
|
||||
public void testMultilineDeclarations() throws Exception {
|
||||
doTest();
|
||||
}
|
||||
|
||||
}
|
||||
Reference in New Issue
Block a user