Rewrite SmartCompletionMultifileHandlerTest to KotlinFixtureCompletionBaseTestCase
Use light projects as an attempt to fight leaking project errors
This commit is contained in:
+17
-14
@@ -6,16 +6,20 @@
|
||||
package org.jetbrains.kotlin.idea.completion.test.handlers
|
||||
|
||||
import com.intellij.codeInsight.completion.CompletionType
|
||||
import com.intellij.codeInsight.lookup.Lookup
|
||||
import com.intellij.codeInsight.lookup.LookupElement
|
||||
import com.intellij.codeInsight.lookup.LookupElementPresentation
|
||||
import com.intellij.testFramework.fixtures.LightJavaCodeInsightFixtureTestCase
|
||||
import org.jetbrains.kotlin.idea.completion.test.COMPLETION_TEST_DATA_BASE_PATH
|
||||
import org.jetbrains.kotlin.idea.completion.test.KotlinCompletionTestCase
|
||||
import org.jetbrains.kotlin.idea.completion.test.KotlinFixtureCompletionBaseTestCase
|
||||
import org.jetbrains.kotlin.platform.TargetPlatform
|
||||
import org.jetbrains.kotlin.platform.jvm.JvmPlatforms
|
||||
import org.jetbrains.kotlin.test.JUnit3WithIdeaConfigurationRunner
|
||||
import org.junit.runner.RunWith
|
||||
import java.io.File
|
||||
|
||||
@RunWith(JUnit3WithIdeaConfigurationRunner::class)
|
||||
class SmartCompletionMultifileHandlerTest : KotlinCompletionTestCase() {
|
||||
class SmartCompletionMultifileHandlerTest : KotlinFixtureCompletionBaseTestCase() {
|
||||
fun testImportExtensionFunction() {
|
||||
doTest()
|
||||
}
|
||||
@@ -36,20 +40,15 @@ class SmartCompletionMultifileHandlerTest : KotlinCompletionTestCase() {
|
||||
doTest(lookupString = "Nested")
|
||||
}
|
||||
|
||||
override fun setUp() {
|
||||
setType(CompletionType.SMART)
|
||||
super.setUp()
|
||||
}
|
||||
|
||||
private fun doTest(lookupString: String? = null, itemText: String? = null) {
|
||||
val fileName = getTestName(false)
|
||||
|
||||
val fileNames = listOf("$fileName-1.kt", "$fileName-2.kt", "$fileName.java")
|
||||
|
||||
configureByFiles(null, *fileNames.filter { File(testDataPath + it).exists() }.toTypedArray())
|
||||
myFixture.configureByFiles(*fileNames.filter { File(testDataPath + it).exists() }.toTypedArray())
|
||||
|
||||
complete(1)
|
||||
if (myItems != null) {
|
||||
val items = complete(CompletionType.SMART, 1)
|
||||
if (items != null) {
|
||||
fun isMatching(lookupElement: LookupElement): Boolean {
|
||||
if (lookupString != null && lookupElement.lookupString != lookupString) return false
|
||||
|
||||
@@ -60,16 +59,20 @@ class SmartCompletionMultifileHandlerTest : KotlinCompletionTestCase() {
|
||||
return true
|
||||
}
|
||||
|
||||
val items = myItems.filter(::isMatching)
|
||||
when (items.size) {
|
||||
val matchedItems = items.filter(::isMatching)
|
||||
when (matchedItems.size) {
|
||||
0 -> fail("No matching items found")
|
||||
1 -> selectItem(myItems[0])
|
||||
1 -> CompletionHandlerTestBase.selectItem(myFixture, items[0], Lookup.NORMAL_SELECT_CHAR)
|
||||
else -> fail("Multiple matching items found")
|
||||
}
|
||||
}
|
||||
|
||||
checkResultByFile("$fileName.kt.after")
|
||||
myFixture.checkResultByFile("$fileName.kt.after")
|
||||
}
|
||||
|
||||
override fun getTestDataPath() = File(COMPLETION_TEST_DATA_BASE_PATH, "/handlers/multifile/smart/").path + File.separator
|
||||
|
||||
override fun defaultCompletionType(): CompletionType = CompletionType.BASIC
|
||||
override fun getPlatform(): TargetPlatform = JvmPlatforms.unspecifiedJvmPlatform
|
||||
override fun getProjectDescriptor() = LightJavaCodeInsightFixtureTestCase.JAVA_LATEST
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user