Added test for update on typing

This commit is contained in:
Valentin Kipyatkov
2015-10-05 21:15:37 +03:00
parent 4865139fb1
commit 9da7f39195
8 changed files with 58 additions and 13 deletions
@@ -0,0 +1,11 @@
fun <T> f(t1: T, t2: T){}
fun test() {
f(<caret>)
}
// TYPE: "1"
/*
Text: (<highlight>t1: Int</highlight>, t2: Int), Disabled: false, Strikeout: false, Green: true
*/
@@ -0,0 +1,9 @@
fun fff(p: String, c: Char) {}
fun foo() {
fff(<caret>)
}
// TYPE: "1, "
//Text: (p: String, <highlight>c: Char</highlight>), Disabled: true, Strikeout: false, Green: true
@@ -16,14 +16,17 @@
package org.jetbrains.kotlin.idea.parameterInfo
import com.intellij.psi.PsiDocumentManager
import com.intellij.psi.PsiWhiteSpace
import com.intellij.testFramework.fixtures.LightCodeInsightFixtureTestCase
import org.jetbrains.kotlin.descriptors.FunctionDescriptor
import org.jetbrains.kotlin.idea.test.JetWithJdkAndRuntimeLightProjectDescriptor
import org.jetbrains.kotlin.idea.test.PluginTestCaseBase
import org.jetbrains.kotlin.idea.util.application.executeWriteCommand
import org.jetbrains.kotlin.lexer.JetTokens
import org.jetbrains.kotlin.psi.JetFile
import org.jetbrains.kotlin.psi.psiUtil.allChildren
import org.jetbrains.kotlin.test.InTextDirectivesUtils
import org.junit.Assert
abstract class AbstractFunctionParameterInfoTest : LightCodeInsightFixtureTestCase() {
@@ -50,9 +53,19 @@ abstract class AbstractFunctionParameterInfoTest : LightCodeInsightFixtureTestCa
val mockCreateParameterInfoContext = MockCreateParameterInfoContext(file, myFixture)
val parameterOwner = parameterInfoHandler.findElementForParameterInfo(mockCreateParameterInfoContext)
val updateContext = MockUpdateParameterInfoContext(file, myFixture)
val textToType = InTextDirectivesUtils.findStringWithPrefixes(file.text, "// TYPE:")
if (textToType != null) {
project.executeWriteCommand("") {
val caretModel = myFixture.editor.caretModel
val offset = caretModel.offset
myFixture.getDocument(file).insertString(offset, textToType)
caretModel.moveToOffset(offset + textToType.length())
}
PsiDocumentManager.getInstance(project).commitAllDocuments()
}
//to update current parameter index
val updateContext = MockUpdateParameterInfoContext(file, myFixture)
val elementForUpdating = parameterInfoHandler.findElementForUpdatingParameterInfo(updateContext)
if (elementForUpdating != null) {
parameterInfoHandler.updateParameterInfo(elementForUpdating, updateContext)
@@ -149,27 +149,33 @@ public class FunctionParameterInfoTestGenerated extends AbstractFunctionParamete
doTest(fileName);
}
@TestMetadata("SubstituteFromParameters1.kt")
public void testSubstituteFromParameters1() throws Exception {
String fileName = JetTestUtils.navigationMetadata("idea/testData/parameterInfo/functionParameterInfo/SubstituteFromParameters1.kt");
@TestMetadata("SubstituteFromArguments1.kt")
public void testSubstituteFromArguments1() throws Exception {
String fileName = JetTestUtils.navigationMetadata("idea/testData/parameterInfo/functionParameterInfo/SubstituteFromArguments1.kt");
doTest(fileName);
}
@TestMetadata("SubstituteFromParameters2.kt")
public void testSubstituteFromParameters2() throws Exception {
String fileName = JetTestUtils.navigationMetadata("idea/testData/parameterInfo/functionParameterInfo/SubstituteFromParameters2.kt");
@TestMetadata("SubstituteFromArguments2.kt")
public void testSubstituteFromArguments2() throws Exception {
String fileName = JetTestUtils.navigationMetadata("idea/testData/parameterInfo/functionParameterInfo/SubstituteFromArguments2.kt");
doTest(fileName);
}
@TestMetadata("SubstituteFromParameters3.kt")
public void testSubstituteFromParameters3() throws Exception {
String fileName = JetTestUtils.navigationMetadata("idea/testData/parameterInfo/functionParameterInfo/SubstituteFromParameters3.kt");
@TestMetadata("SubstituteFromArguments3.kt")
public void testSubstituteFromArguments3() throws Exception {
String fileName = JetTestUtils.navigationMetadata("idea/testData/parameterInfo/functionParameterInfo/SubstituteFromArguments3.kt");
doTest(fileName);
}
@TestMetadata("SubstituteFromParameters4.kt")
public void testSubstituteFromParameters4() throws Exception {
String fileName = JetTestUtils.navigationMetadata("idea/testData/parameterInfo/functionParameterInfo/SubstituteFromParameters4.kt");
@TestMetadata("SubstituteFromArguments4.kt")
public void testSubstituteFromArguments4() throws Exception {
String fileName = JetTestUtils.navigationMetadata("idea/testData/parameterInfo/functionParameterInfo/SubstituteFromArguments4.kt");
doTest(fileName);
}
@TestMetadata("SubstituteFromArgumentsOnTyping.kt")
public void testSubstituteFromArgumentsOnTyping() throws Exception {
String fileName = JetTestUtils.navigationMetadata("idea/testData/parameterInfo/functionParameterInfo/SubstituteFromArgumentsOnTyping.kt");
doTest(fileName);
}
@@ -190,4 +196,10 @@ public class FunctionParameterInfoTestGenerated extends AbstractFunctionParamete
String fileName = JetTestUtils.navigationMetadata("idea/testData/parameterInfo/functionParameterInfo/TwoFunctionsGrey.kt");
doTest(fileName);
}
@TestMetadata("UpdateOnTyping.kt")
public void testUpdateOnTyping() throws Exception {
String fileName = JetTestUtils.navigationMetadata("idea/testData/parameterInfo/functionParameterInfo/UpdateOnTyping.kt");
doTest(fileName);
}
}