change initial expectations for light extract object

This commit is contained in:
Anna Kozlova
2014-09-05 13:17:10 +04:00
parent 8dbc10140a
commit 4225b2e93f
5 changed files with 108 additions and 57 deletions
@@ -1,7 +1,5 @@
class Sample {
void foo() {
<selection>int i = 0;
int j = 0;</selection>
System.out.println(i + j);
System.out.println("hello <caret>world");
}
}
@@ -21,10 +21,9 @@
package com.intellij.refactoring;
import com.intellij.JavaTestUtil;
import com.intellij.codeInsight.CodeInsightUtil;
import com.intellij.openapi.application.ApplicationManager;
import com.intellij.openapi.projectRoots.Sdk;
import com.intellij.psi.PsiClass;
import com.intellij.psi.PsiElement;
import com.intellij.psi.*;
import com.intellij.refactoring.extractMethodObject.ExtractLightMethodObjectHandler;
import com.intellij.testFramework.IdeaTestUtil;
import org.jetbrains.annotations.NotNull;
@@ -36,16 +35,14 @@ public class ExtractMethodObject4DebuggerTest extends LightRefactoringTestCase {
return JavaTestUtil.getJavaTestDataPath();
}
private void doTest(String expectedCallSite, String expectedClass) throws Exception {
private void doTest(String evaluatedText, String expectedCallSite, String expectedClass) throws Exception {
final String testName = getTestName(false);
configureByFile("/refactoring/extractMethodObject4Debugger/" + testName + ".java");
int startOffset = getEditor().getSelectionModel().getSelectionStart();
int endOffset = getEditor().getSelectionModel().getSelectionEnd();
PsiElement[] elements = CodeInsightUtil.findStatementsInRange(getFile(), startOffset, endOffset);
assertTrue(elements.length > 0);
final int offset = getEditor().getCaretModel().getOffset();
final PsiElement context = getFile().findElementAt(offset);
final JavaCodeFragment fragment = JavaCodeFragmentFactory.getInstance(getProject()).createCodeBlockCodeFragment(evaluatedText, context, false);
final ExtractLightMethodObjectHandler.ExtractedData extractedData =
ExtractLightMethodObjectHandler.extractLightMethodObject(getProject(), getEditor(), getFile(), elements, "test");
ExtractLightMethodObjectHandler.extractLightMethodObject(getProject(), getFile(), fragment, "test");
assertNotNull(extractedData);
assertEquals(expectedCallSite, extractedData.getGeneratedCallText());
final PsiClass innerClass = extractedData.getGeneratedInnerClass();
@@ -53,7 +50,7 @@ public class ExtractMethodObject4DebuggerTest extends LightRefactoringTestCase {
}
public void testSimpleGeneration() throws Exception {
doTest(" Test test = new Test().invoke();\n" +
doTest("int i = 0; int j = 0;", "Test test = new Test().invoke();\n" +
" int i = test.getI();\n" +
" int j = test.getJ();",