Use test path relative to testDataPath in fixture.configureByFile to be complaint with 193, part 2
This commit is contained in:
@@ -19,16 +19,7 @@ package org.jetbrains.kotlin.generators.tests
|
||||
import org.jetbrains.kotlin.AbstractDataFlowValueRenderingTest
|
||||
import org.jetbrains.kotlin.addImport.AbstractAddImportTest
|
||||
import org.jetbrains.kotlin.allopen.AbstractBytecodeListingTestForAllOpen
|
||||
import org.jetbrains.kotlin.android.*
|
||||
import org.jetbrains.kotlin.android.annotator.AbstractAndroidGutterIconTest
|
||||
import org.jetbrains.kotlin.android.configure.AbstractConfigureProjectTest
|
||||
import org.jetbrains.kotlin.android.folding.AbstractAndroidResourceFoldingTest
|
||||
import org.jetbrains.kotlin.android.intention.AbstractAndroidIntentionTest
|
||||
import org.jetbrains.kotlin.android.intention.AbstractAndroidResourceIntentionTest
|
||||
import org.jetbrains.kotlin.android.lint.AbstractKotlinLintTest
|
||||
import org.jetbrains.kotlin.android.parcel.AbstractParcelBytecodeListingTest
|
||||
import org.jetbrains.kotlin.android.quickfix.AbstractAndroidLintQuickfixTest
|
||||
import org.jetbrains.kotlin.android.quickfix.AbstractAndroidQuickFixMultiFileTest
|
||||
import org.jetbrains.kotlin.android.synthetic.test.AbstractAndroidBoxTest
|
||||
import org.jetbrains.kotlin.android.synthetic.test.AbstractAndroidBytecodeShapeTest
|
||||
import org.jetbrains.kotlin.android.synthetic.test.AbstractAndroidSyntheticPropertyDescriptorTest
|
||||
@@ -1333,4 +1324,5 @@ fun main(args: Array<String>) {
|
||||
model("android/gutterIcon")
|
||||
}
|
||||
}
|
||||
*/
|
||||
}
|
||||
|
||||
+10
-7
@@ -29,6 +29,7 @@ import com.intellij.psi.search.FileTypeIndex
|
||||
import com.intellij.psi.search.ProjectScope
|
||||
import com.intellij.testFramework.LightProjectDescriptor
|
||||
import com.intellij.testFramework.LoggedErrorProcessor
|
||||
import com.sun.tools.corba.se.idl.toJavaPortable.Util.fileName
|
||||
import org.apache.log4j.Logger
|
||||
import org.jetbrains.kotlin.cli.common.arguments.K2JVMCompilerArguments
|
||||
import org.jetbrains.kotlin.config.CompilerSettings
|
||||
@@ -62,8 +63,15 @@ abstract class KotlinLightCodeInsightFixtureTestCase : KotlinLightCodeInsightFix
|
||||
|
||||
protected open val captureExceptions = true
|
||||
|
||||
protected fun testPath(): String =
|
||||
File(testDataPath, fileName()).toString()
|
||||
protected fun testDataFile(): File = File(testDataPath, fileName())
|
||||
|
||||
protected fun testPath(): String = testDataFile().toString()
|
||||
|
||||
protected open fun fileName(): String = KotlinTestUtils.getTestDataFileName(this::class.java, this.name) ?: (getTestName(false) + ".kt")
|
||||
|
||||
override fun getTestDataPath(): String {
|
||||
return this::class.findAnnotation<TestMetadata>()?.value ?: super.getTestDataPath()
|
||||
}
|
||||
|
||||
override fun setUp() {
|
||||
super.setUp()
|
||||
@@ -194,8 +202,6 @@ abstract class KotlinLightCodeInsightFixtureTestCase : KotlinLightCodeInsightFix
|
||||
|
||||
protected fun isAllFilesPresentInTest(): Boolean = KotlinTestUtils.isAllFilesPresentTest(getTestName(false))
|
||||
|
||||
protected open fun fileName(): String = KotlinTestUtils.getTestDataFileName(this::class.java, this.name) ?: (getTestName(false) + ".kt")
|
||||
|
||||
protected fun performNotWriteEditorAction(actionId: String): Boolean {
|
||||
val dataContext = (myFixture.editor as EditorEx).dataContext
|
||||
|
||||
@@ -215,9 +221,6 @@ abstract class KotlinLightCodeInsightFixtureTestCase : KotlinLightCodeInsightFix
|
||||
return true
|
||||
}
|
||||
|
||||
override fun getTestDataPath(): String {
|
||||
return this::class.findAnnotation<TestMetadata>()?.value ?: super.getTestDataPath()
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
+6
-8
@@ -12,7 +12,6 @@ import com.intellij.psi.PsiFile
|
||||
import org.jetbrains.kotlin.idea.AbstractCopyPasteTest
|
||||
import org.jetbrains.kotlin.idea.perf.Stats.Companion.WARM_UP
|
||||
import org.jetbrains.kotlin.idea.test.KotlinWithJdkAndRuntimeLightProjectDescriptor
|
||||
import org.jetbrains.kotlin.idea.test.PluginTestCaseBase
|
||||
import org.jetbrains.kotlin.test.KotlinTestUtils
|
||||
import java.io.File
|
||||
|
||||
@@ -22,8 +21,6 @@ import java.io.File
|
||||
abstract class AbstractPerformanceLiteralKotlinToKotlinCopyPasteTest : AbstractCopyPasteTest() {
|
||||
|
||||
companion object {
|
||||
val BASE_PATH = PluginTestCaseBase.getTestDataPathBase() + "/copyPaste/literal"
|
||||
|
||||
@JvmStatic
|
||||
var warmedUp: Boolean = false
|
||||
|
||||
@@ -36,8 +33,6 @@ abstract class AbstractPerformanceLiteralKotlinToKotlinCopyPasteTest : AbstractC
|
||||
}
|
||||
}
|
||||
|
||||
override fun getTestDataPath() = BASE_PATH
|
||||
|
||||
override fun getProjectDescriptor() = KotlinWithJdkAndRuntimeLightProjectDescriptor.INSTANCE
|
||||
|
||||
override fun setUp() {
|
||||
@@ -83,14 +78,17 @@ abstract class AbstractPerformanceLiteralKotlinToKotlinCopyPasteTest : AbstractC
|
||||
)
|
||||
}
|
||||
|
||||
fun doPerfTest(path: String) {
|
||||
fun doPerfTest(unused: String) {
|
||||
val testName = getTestName(false)
|
||||
val fileName = fileName()
|
||||
val testPath = testPath()
|
||||
val expectedPath = File(testPath.replace(".kt", ".expected.kt"))
|
||||
|
||||
val fileEditorManager = FileEditorManagerEx.getInstance(project)
|
||||
stats.perfTest<Array<PsiFile>, Unit>(
|
||||
testName = testName,
|
||||
setUp = {
|
||||
it.setUpValue = myFixture.configureByFiles("$testName.kt", "$testName.to.kt")
|
||||
it.setUpValue = myFixture.configureByFiles(fileName, fileName.replace(".kt", ".to.kt"))
|
||||
},
|
||||
test = {
|
||||
fileEditorManager.setSelectedEditor(it.setUpValue!![0].virtualFile, "")
|
||||
@@ -100,7 +98,7 @@ abstract class AbstractPerformanceLiteralKotlinToKotlinCopyPasteTest : AbstractC
|
||||
myFixture.performEditorAction(IdeActions.ACTION_PASTE)
|
||||
},
|
||||
tearDown = {
|
||||
KotlinTestUtils.assertEqualsToFile(File(path.replace(".kt", ".expected.kt")), it.setUpValue!![1].text)
|
||||
KotlinTestUtils.assertEqualsToFile(expectedPath, it.setUpValue!![1].text)
|
||||
|
||||
// to avoid VFS refresh
|
||||
myFixture.performEditorAction(IdeActions.ACTION_UNDO)
|
||||
|
||||
+17
-1
@@ -5,15 +5,21 @@
|
||||
|
||||
package org.jetbrains.kotlin.idea.testFramework
|
||||
|
||||
import com.intellij.ide.startup.impl.StartupManagerImpl
|
||||
import com.intellij.lang.LanguageAnnotators
|
||||
import com.intellij.lang.LanguageExtensionPoint
|
||||
import com.intellij.lang.annotation.Annotator
|
||||
import com.intellij.openapi.Disposable
|
||||
import com.intellij.openapi.editor.Document
|
||||
import com.intellij.openapi.fileEditor.FileDocumentManager
|
||||
import com.intellij.openapi.fileEditor.FileEditorManager
|
||||
import com.intellij.openapi.project.Project
|
||||
import com.intellij.openapi.project.ex.ProjectManagerEx
|
||||
import com.intellij.openapi.startup.StartupManager
|
||||
import com.intellij.psi.PsiDocumentManager
|
||||
import com.intellij.psi.impl.PsiDocumentManagerBase
|
||||
import com.intellij.testFramework.EdtTestUtil
|
||||
import com.intellij.testFramework.PlatformTestUtil
|
||||
import com.intellij.testFramework.runInEdtAndWait
|
||||
import com.intellij.util.ThrowableRunnable
|
||||
import com.intellij.util.ui.UIUtil
|
||||
@@ -55,13 +61,23 @@ fun dispatchAllInvocationEvents() {
|
||||
}
|
||||
}
|
||||
|
||||
fun loadProjectWithName(path: String, name: String): Project? =
|
||||
ProjectManagerEx.getInstanceEx().loadProject(name, path)
|
||||
|
||||
fun closeProject(project: Project) {
|
||||
dispatchAllInvocationEvents()
|
||||
val projectManagerEx = ProjectManagerEx.getInstanceEx()
|
||||
projectManagerEx.closeAndDispose(project)
|
||||
}
|
||||
|
||||
// BUNCH: 183
|
||||
fun runStartupActivities(project: Project) {
|
||||
with(StartupManager.getInstance(project) as StartupManagerImpl) {
|
||||
scheduleInitialVfsRefresh()
|
||||
runStartupActivities()
|
||||
runPostStartupActivities()
|
||||
}
|
||||
}
|
||||
|
||||
fun waitForAllEditorsFinallyLoaded(project: Project) {
|
||||
// 183 does not have this public api
|
||||
}
|
||||
|
||||
@@ -19,10 +19,10 @@ import org.jetbrains.kotlin.test.KotlinTestUtils
|
||||
import java.io.File
|
||||
|
||||
abstract class AbstractImportsTest : KotlinLightCodeInsightFixtureTestCase() {
|
||||
override fun getTestDataPath() = KotlinTestUtils.getHomeDirectory()
|
||||
override fun getProjectDescriptor(): LightProjectDescriptor = KotlinWithJdkAndRuntimeLightProjectDescriptor.INSTANCE
|
||||
|
||||
protected fun doTest(testPath: String) {
|
||||
protected fun doTest(unused: String) {
|
||||
val testPath = testPath()
|
||||
CodeStyle.setTemporarySettings(project, CodeStyle.getSettings(project).clone())
|
||||
val codeStyleSettings = KotlinCodeStyleSettings.getInstance(project)
|
||||
|
||||
@@ -30,13 +30,13 @@ abstract class AbstractImportsTest : KotlinLightCodeInsightFixtureTestCase() {
|
||||
val fixture = myFixture
|
||||
val dependencySuffixes = listOf(".dependency.kt", ".dependency.java", ".dependency1.kt", ".dependency2.kt")
|
||||
for (suffix in dependencySuffixes) {
|
||||
val dependencyPath = testPath.replace(".kt", suffix)
|
||||
if (File(dependencyPath).exists()) {
|
||||
val dependencyPath = fileName().replace(".kt", suffix)
|
||||
if (File(testDataPath, dependencyPath).exists()) {
|
||||
fixture.configureByFile(dependencyPath)
|
||||
}
|
||||
}
|
||||
|
||||
fixture.configureByFile(testPath)
|
||||
fixture.configureByFile(fileName())
|
||||
|
||||
val file = fixture.file as KtFile
|
||||
|
||||
|
||||
@@ -8,35 +8,36 @@ package org.jetbrains.kotlin.checkers
|
||||
import com.intellij.codeInspection.ex.EntryPointsManagerBase
|
||||
import com.intellij.testFramework.LightProjectDescriptor
|
||||
import org.jetbrains.kotlin.test.JUnit3WithIdeaConfigurationRunner
|
||||
import org.jetbrains.kotlin.test.KotlinTestUtils
|
||||
import org.jetbrains.kotlin.test.TestMetadata
|
||||
import org.junit.runner.RunWith
|
||||
|
||||
@TestMetadata("idea/testData/checker/custom")
|
||||
@RunWith(JUnit3WithIdeaConfigurationRunner::class)
|
||||
class PsiCheckerCustomTest : AbstractPsiCheckerTest() {
|
||||
|
||||
fun testNoUnusedParameterWhenCustom() {
|
||||
val testAnnotation = "MyTestAnnotation"
|
||||
EntryPointsManagerBase.getInstance(project).ADDITIONAL_ANNOTATIONS.add(testAnnotation)
|
||||
try {
|
||||
doTest(getTestDataFile("noUnusedParameterWhenCustom.kt"))
|
||||
}
|
||||
finally {
|
||||
doTest("noUnusedParameterWhenCustom.kt")
|
||||
} finally {
|
||||
EntryPointsManagerBase.getInstance(project).ADDITIONAL_ANNOTATIONS.remove(testAnnotation)
|
||||
}
|
||||
}
|
||||
|
||||
fun testConflictingOverloadsMultifile1() {
|
||||
doTest(getTestDataFile("conflictingOverloadsMultifile1a.kt"),
|
||||
getTestDataFile("conflictingOverloadsMultifile1b.kt"))
|
||||
doTest(
|
||||
"conflictingOverloadsMultifile1a.kt",
|
||||
"conflictingOverloadsMultifile1b.kt"
|
||||
)
|
||||
}
|
||||
|
||||
fun testConflictingOverloadsMultifile2() {
|
||||
doTest(getTestDataFile("conflictingOverloadsMultifile2a.kt"),
|
||||
getTestDataFile("conflictingOverloadsMultifile2b.kt"))
|
||||
doTest(
|
||||
"conflictingOverloadsMultifile2a.kt",
|
||||
"conflictingOverloadsMultifile2b.kt"
|
||||
)
|
||||
}
|
||||
|
||||
private fun getTestDataFile(localName: String) = "idea/testData/checker/custom/$localName"
|
||||
|
||||
override fun getTestDataPath(): String = KotlinTestUtils.getHomeDirectory()
|
||||
|
||||
override fun getProjectDescriptor(): LightProjectDescriptor = getProjectDescriptorFromTestName()
|
||||
}
|
||||
@@ -44,34 +44,39 @@ import kotlin.test.assertNotNull
|
||||
import kotlin.test.assertTrue
|
||||
|
||||
abstract class AbstractIdeLightClassTest : KotlinLightCodeInsightFixtureTestCase() {
|
||||
fun doTest(testDataPath: String) {
|
||||
fun doTest(unused: String) {
|
||||
forceUsingOldLightClassesForTest()
|
||||
val fileName = fileName()
|
||||
val extraFilePath = when {
|
||||
testDataPath.endsWith(fileExtension) -> testDataPath.replace(fileExtension, ".extra" + fileExtension)
|
||||
fileName.endsWith(fileExtension) -> fileName.replace(fileExtension, ".extra" + fileExtension)
|
||||
else -> error("Invalid test data extension")
|
||||
}
|
||||
|
||||
val testFiles = if (File(extraFilePath).isFile) listOf(testDataPath, extraFilePath) else listOf(testDataPath)
|
||||
val testFiles = if (File(testDataPath, extraFilePath).isFile) listOf(fileName, extraFilePath) else listOf(fileName)
|
||||
|
||||
val lazinessMode = lazinessModeByFileText(testDataPath)
|
||||
val lazinessMode = lazinessModeByFileText()
|
||||
myFixture.configureByFiles(*testFiles.toTypedArray())
|
||||
|
||||
val ktFile = myFixture.file as KtFile
|
||||
val testData = File(testDataPath)
|
||||
testLightClass(KotlinTestUtils.replaceExtension(testData, "java"), testData, { LightClassTestCommon.removeEmptyDefaultImpls(it) }, { fqName ->
|
||||
val tracker = LightClassLazinessChecker.Tracker(fqName)
|
||||
project.withServiceRegistered<StubComputationTracker, PsiClass?>(tracker) {
|
||||
findClass(fqName, ktFile, project)?.apply {
|
||||
LightClassLazinessChecker.check(this as KtLightClass, tracker, lazinessMode)
|
||||
tracker.allowLevel(EXACT)
|
||||
PsiElementChecker.checkPsiElementStructure(this)
|
||||
val testData = testDataFile()
|
||||
testLightClass(
|
||||
KotlinTestUtils.replaceExtension(testData, "java"),
|
||||
testData,
|
||||
{ LightClassTestCommon.removeEmptyDefaultImpls(it) },
|
||||
{ fqName ->
|
||||
val tracker = LightClassLazinessChecker.Tracker(fqName)
|
||||
project.withServiceRegistered<StubComputationTracker, PsiClass?>(tracker) {
|
||||
findClass(fqName, ktFile, project)?.apply {
|
||||
LightClassLazinessChecker.check(this as KtLightClass, tracker, lazinessMode)
|
||||
tracker.allowLevel(EXACT)
|
||||
PsiElementChecker.checkPsiElementStructure(this)
|
||||
}
|
||||
}
|
||||
}
|
||||
})
|
||||
})
|
||||
}
|
||||
|
||||
private fun lazinessModeByFileText(testDataPath: String): LightClassLazinessChecker.Mode {
|
||||
return File(testDataPath).readText().run {
|
||||
private fun lazinessModeByFileText(): LightClassLazinessChecker.Mode {
|
||||
return testDataFile().readText().run {
|
||||
val argument = substringAfter("LAZINESS:", "").substringBefore(" ")
|
||||
LightClassLazinessChecker.Mode.values().firstOrNull { it.name == argument } ?: LightClassLazinessChecker.Mode.AllChecks
|
||||
}
|
||||
|
||||
+8
-10
@@ -9,21 +9,18 @@ import com.intellij.openapi.actionSystem.IdeActions
|
||||
import org.jetbrains.kotlin.idea.AbstractCopyPasteTest
|
||||
import org.jetbrains.kotlin.idea.caches.resolve.forceResolveInWriteActionCheckInTests
|
||||
import org.jetbrains.kotlin.idea.test.KotlinWithJdkAndRuntimeLightProjectDescriptor
|
||||
import org.jetbrains.kotlin.idea.test.PluginTestCaseBase
|
||||
import org.jetbrains.kotlin.test.KotlinTestUtils
|
||||
import java.io.File
|
||||
|
||||
abstract class AbstractLiteralTextToKotlinCopyPasteTest : AbstractCopyPasteTest() {
|
||||
private val _basePath = PluginTestCaseBase.getTestDataPathBase() + "/copyPaste/plainTextLiteral"
|
||||
|
||||
override fun getTestDataPath() = _basePath
|
||||
|
||||
override fun getProjectDescriptor() = KotlinWithJdkAndRuntimeLightProjectDescriptor.INSTANCE
|
||||
|
||||
fun doTest(path: String) {
|
||||
myFixture.testDataPath = _basePath
|
||||
val testName = getTestName(false)
|
||||
myFixture.configureByFiles("$testName.txt")
|
||||
fun doTest(unused: String) {
|
||||
val fileName = fileName()
|
||||
val targetFileName = fileName.replace(".txt", ".kt")
|
||||
|
||||
myFixture.configureByFile(fileName)
|
||||
val fileText = myFixture.editor.document.text
|
||||
|
||||
if (!myFixture.editor.selectionModel.hasSelection())
|
||||
@@ -33,12 +30,13 @@ abstract class AbstractLiteralTextToKotlinCopyPasteTest : AbstractCopyPasteTest(
|
||||
myFixture.performEditorAction(IdeActions.ACTION_COPY)
|
||||
}
|
||||
|
||||
configureTargetFile("$testName.kt")
|
||||
configureTargetFile(targetFileName)
|
||||
|
||||
forceResolveInWriteActionCheckInTests {
|
||||
myFixture.performEditorAction(IdeActions.ACTION_PASTE)
|
||||
}
|
||||
|
||||
KotlinTestUtils.assertEqualsToFile(File(path.replace(".txt", ".expected.kt")), myFixture.file.text)
|
||||
val expectedFile = File(testPath().replace(".txt", ".expected.kt"))
|
||||
KotlinTestUtils.assertEqualsToFile(expectedFile, myFixture.file.text)
|
||||
}
|
||||
}
|
||||
+12
-16
@@ -6,21 +6,15 @@
|
||||
package org.jetbrains.kotlin.idea.conversion.copy
|
||||
|
||||
import com.intellij.openapi.actionSystem.IdeActions
|
||||
import org.jetbrains.kotlin.idea.AbstractCopyPasteTest
|
||||
import org.jetbrains.kotlin.idea.editor.KotlinEditorOptions
|
||||
import org.jetbrains.kotlin.idea.test.KotlinWithJdkAndRuntimeLightProjectDescriptor
|
||||
import org.jetbrains.kotlin.idea.test.PluginTestCaseBase
|
||||
import org.jetbrains.kotlin.test.InTextDirectivesUtils
|
||||
import org.jetbrains.kotlin.test.KotlinTestUtils
|
||||
import java.io.File
|
||||
|
||||
abstract class AbstractTextJavaToKotlinCopyPasteConversionTest : AbstractJ2kCopyPasteTest() {
|
||||
protected open val BASE_PATH = PluginTestCaseBase.getTestDataPathBase() + "/copyPaste/plainTextConversion"
|
||||
|
||||
private var oldEditorOptions: KotlinEditorOptions? = null
|
||||
|
||||
override fun getTestDataPath() = BASE_PATH
|
||||
|
||||
override fun getProjectDescriptor() = KotlinWithJdkAndRuntimeLightProjectDescriptor.INSTANCE
|
||||
|
||||
override fun setUp() {
|
||||
@@ -35,10 +29,9 @@ abstract class AbstractTextJavaToKotlinCopyPasteConversionTest : AbstractJ2kCopy
|
||||
super.tearDown()
|
||||
}
|
||||
|
||||
fun doTest(path: String) {
|
||||
myFixture.testDataPath = BASE_PATH
|
||||
val testName = getTestName(false)
|
||||
myFixture.configureByFiles(testName + ".txt")
|
||||
fun doTest(unused: String) {
|
||||
val fileName = fileName()
|
||||
myFixture.configureByFile(fileName)
|
||||
|
||||
val fileText = myFixture.editor.document.text
|
||||
val noConversionExpected = InTextDirectivesUtils.findListWithPrefixes(fileText, "// NO_CONVERSION_EXPECTED").isNotEmpty()
|
||||
@@ -46,18 +39,21 @@ abstract class AbstractTextJavaToKotlinCopyPasteConversionTest : AbstractJ2kCopy
|
||||
myFixture.editor.selectionModel.setSelection(0, fileText.length)
|
||||
myFixture.performEditorAction(IdeActions.ACTION_COPY)
|
||||
|
||||
configureByDependencyIfExists(testName + ".dependency.kt")
|
||||
configureByDependencyIfExists(testName + ".dependency.java")
|
||||
configureByDependencyIfExists(fileName.replace(".txt", ".dependency.kt"))
|
||||
configureByDependencyIfExists(fileName.replace(".txt", ".dependency.java"))
|
||||
|
||||
configureTargetFile(testName + ".to.kt")
|
||||
configureTargetFile(fileName.replace(".txt", ".to.kt"))
|
||||
|
||||
ConvertTextJavaCopyPasteProcessor.conversionPerformed = false
|
||||
|
||||
myFixture.performEditorAction(IdeActions.ACTION_PASTE)
|
||||
|
||||
kotlin.test.assertEquals(noConversionExpected, !ConvertTextJavaCopyPasteProcessor.conversionPerformed,
|
||||
if (noConversionExpected) "Conversion to Kotlin should not be suggested" else "No conversion to Kotlin suggested")
|
||||
kotlin.test.assertEquals(
|
||||
noConversionExpected, !ConvertTextJavaCopyPasteProcessor.conversionPerformed,
|
||||
if (noConversionExpected) "Conversion to Kotlin should not be suggested" else "No conversion to Kotlin suggested"
|
||||
)
|
||||
|
||||
KotlinTestUtils.assertEqualsToFile(File(path.replace(".txt", ".expected.kt")), myFixture.file.text)
|
||||
val expectedFile = File(testPath().replace(".txt", ".expected.kt"))
|
||||
KotlinTestUtils.assertEqualsToFile(expectedFile, myFixture.file.text)
|
||||
}
|
||||
}
|
||||
|
||||
+7
-11
@@ -8,29 +8,25 @@ package org.jetbrains.kotlin.idea.conversion.copy
|
||||
import com.intellij.openapi.actionSystem.IdeActions
|
||||
import org.jetbrains.kotlin.idea.AbstractCopyPasteTest
|
||||
import org.jetbrains.kotlin.idea.test.KotlinWithJdkAndRuntimeLightProjectDescriptor
|
||||
import org.jetbrains.kotlin.idea.test.PluginTestCaseBase
|
||||
import org.jetbrains.kotlin.test.KotlinTestUtils
|
||||
import java.io.File
|
||||
|
||||
abstract class AbstractLiteralKotlinToKotlinCopyPasteTest : AbstractCopyPasteTest() {
|
||||
private val BASE_PATH = PluginTestCaseBase.getTestDataPathBase() + "/copyPaste/literal"
|
||||
|
||||
|
||||
override fun getTestDataPath() = BASE_PATH
|
||||
|
||||
override fun getProjectDescriptor() = KotlinWithJdkAndRuntimeLightProjectDescriptor.INSTANCE
|
||||
|
||||
fun doTest(unused: String) {
|
||||
val fileName = fileName()
|
||||
val testPath = testPath()
|
||||
val expectedPath = File(testPath.replace(".kt", ".expected.kt"))
|
||||
|
||||
fun doTest(path: String) {
|
||||
myFixture.testDataPath = BASE_PATH
|
||||
val testName = getTestName(false)
|
||||
myFixture.configureByFiles(testName + ".kt")
|
||||
myFixture.configureByFile(fileName)
|
||||
|
||||
myFixture.performEditorAction(IdeActions.ACTION_COPY)
|
||||
|
||||
configureTargetFile(testName + ".to.kt")
|
||||
configureTargetFile(fileName.replace(".kt", ".to.kt"))
|
||||
|
||||
myFixture.performEditorAction(IdeActions.ACTION_PASTE)
|
||||
KotlinTestUtils.assertEqualsToFile(File(path.replace(".kt", ".expected.kt")), myFixture.file.text)
|
||||
KotlinTestUtils.assertEqualsToFile(expectedPath, myFixture.file.text)
|
||||
}
|
||||
}
|
||||
|
||||
@@ -8,12 +8,12 @@ package org.jetbrains.kotlin.idea.highlighter
|
||||
import com.intellij.codeInsight.highlighting.HighlightUsagesHandler
|
||||
import com.intellij.openapi.editor.colors.EditorColors
|
||||
import com.intellij.openapi.editor.colors.EditorColorsManager
|
||||
import com.intellij.testFramework.fixtures.LightCodeInsightFixtureTestCase
|
||||
import org.jetbrains.kotlin.idea.test.KotlinLightCodeInsightFixtureTestCase
|
||||
import org.jetbrains.kotlin.test.InTextDirectivesUtils
|
||||
|
||||
abstract class AbstractHighlightExitPointsTest : LightCodeInsightFixtureTestCase() {
|
||||
fun doTest(testDataPath: String) {
|
||||
myFixture.configureByFile(testDataPath)
|
||||
abstract class AbstractHighlightExitPointsTest : KotlinLightCodeInsightFixtureTestCase() {
|
||||
fun doTest(unused: String) {
|
||||
myFixture.configureByFile(fileName())
|
||||
HighlightUsagesHandler.invoke(myFixture.project, myFixture.editor, myFixture.file)
|
||||
|
||||
val text = myFixture.file.text
|
||||
|
||||
@@ -18,14 +18,14 @@ import java.util.List;
|
||||
|
||||
public abstract class AbstractHighlightingTest extends KotlinLightCodeInsightFixtureTestCase {
|
||||
|
||||
protected void doTest(String filePath) throws Exception {
|
||||
String fileText = FileUtil.loadFile(new File(filePath), true);
|
||||
protected void doTest(String unused) throws Exception {
|
||||
String fileText = FileUtil.loadFile(new File(testPath()), true);
|
||||
boolean checkInfos = !InTextDirectivesUtils.isDirectiveDefined(fileText, "// NO_CHECK_INFOS");
|
||||
boolean checkWeakWarnings = !InTextDirectivesUtils.isDirectiveDefined(fileText, "// NO_CHECK_WEAK_WARNINGS");
|
||||
boolean checkWarnings = !InTextDirectivesUtils.isDirectiveDefined(fileText, "// NO_CHECK_WARNINGS");
|
||||
boolean expectedDuplicatedHighlighting = InTextDirectivesUtils.isDirectiveDefined(fileText, "// EXPECTED_DUPLICATED_HIGHLIGHTING");
|
||||
|
||||
myFixture.configureByFile(filePath);
|
||||
myFixture.configureByFile(fileName());
|
||||
|
||||
withExpectedDuplicatedHighlighting(expectedDuplicatedHighlighting, () -> {
|
||||
try {
|
||||
|
||||
+2
-6
@@ -14,20 +14,16 @@ import org.jetbrains.kotlin.idea.util.application.executeWriteCommand
|
||||
import org.jetbrains.kotlin.psi.KtSimpleNameExpression
|
||||
import org.jetbrains.kotlin.psi.psiUtil.parents
|
||||
import org.jetbrains.kotlin.test.JUnit3RunnerWithInners
|
||||
import org.jetbrains.kotlin.test.KotlinTestUtils
|
||||
import org.jetbrains.kotlin.test.TestMetadata
|
||||
import org.jetbrains.kotlin.utils.addToStdlib.firstIsInstance
|
||||
import org.junit.runner.RunWith
|
||||
|
||||
@TestMetadata("idea/testData/quickfix.special")
|
||||
@TestMetadata("idea/testData/quickfix.special/deprecatedSymbolUsage")
|
||||
@TestDataPath("\$PROJECT_ROOT")
|
||||
@RunWith(JUnit3RunnerWithInners::class)
|
||||
class DeprecatedSymbolUsageFixSpecialTest : KotlinLightCodeInsightFixtureTestCase() {
|
||||
override fun getTestDataPath() = KotlinTestUtils.getHomeDirectory()
|
||||
override fun getProjectDescriptor() = ProjectDescriptorWithStdlibSources.INSTANCE
|
||||
|
||||
private val TEST_DATA_DIR = "idea/testData/quickfix.special/deprecatedSymbolUsage"
|
||||
|
||||
fun testMemberInCompiledClass() {
|
||||
doTest("matches(input)")
|
||||
}
|
||||
@@ -37,7 +33,7 @@ class DeprecatedSymbolUsageFixSpecialTest : KotlinLightCodeInsightFixtureTestCas
|
||||
}
|
||||
|
||||
private fun doTest(pattern: String) {
|
||||
val testPath = KotlinTestUtils.navigationMetadata(TEST_DATA_DIR + "/" + getTestName(true) + ".kt")
|
||||
val testPath = getTestName(true) + ".kt"
|
||||
myFixture.configureByFile(testPath)
|
||||
|
||||
val offset = editor.caretModel.offset
|
||||
|
||||
@@ -30,21 +30,20 @@ import java.io.File
|
||||
import java.util.*
|
||||
|
||||
abstract class AbstractPartialBodyResolveTest : KotlinLightCodeInsightFixtureTestCase() {
|
||||
override fun getTestDataPath() = KotlinTestUtils.getHomeDirectory()
|
||||
override fun getProjectDescriptor() = KotlinWithJdkAndRuntimeLightProjectDescriptor.INSTANCE
|
||||
|
||||
fun doTest(testPath: String) {
|
||||
fun doTest(unused: String) {
|
||||
val testPath = testPath()
|
||||
val dumpNormal = dump(testPath, BodyResolveMode.PARTIAL)
|
||||
|
||||
val testPathNoExt = FileUtil.getNameWithoutExtension(testPath)
|
||||
KotlinTestUtils.assertEqualsToFile(File(testPathNoExt + ".dump"), dumpNormal)
|
||||
KotlinTestUtils.assertEqualsToFile(File("$testPathNoExt.dump"), dumpNormal)
|
||||
|
||||
val dumpForCompletion = dump(testPath, BodyResolveMode.PARTIAL_FOR_COMPLETION)
|
||||
val completionDump = File(testPathNoExt + ".completion")
|
||||
val completionDump = File("$testPathNoExt.completion")
|
||||
if (dumpForCompletion != dumpNormal) {
|
||||
KotlinTestUtils.assertEqualsToFile(completionDump, dumpForCompletion)
|
||||
}
|
||||
else {
|
||||
} else {
|
||||
Assert.assertFalse(completionDump.exists())
|
||||
}
|
||||
}
|
||||
@@ -64,11 +63,11 @@ abstract class AbstractPartialBodyResolveTest : KotlinLightCodeInsightFixtureTes
|
||||
selectionModel.selectionEnd,
|
||||
KtExpression::class.java
|
||||
)
|
||||
?: error("No JetExpression at selection range")
|
||||
?: error("No KtExpression at selection range")
|
||||
} else {
|
||||
val offset = editor.caretModel.offset
|
||||
val element = file.findElementAt(offset)!!
|
||||
element.getNonStrictParentOfType<KtSimpleNameExpression>() ?: error("No JetSimpleNameExpression at caret")
|
||||
element.getNonStrictParentOfType<KtSimpleNameExpression>() ?: error("No KtSimpleNameExpression at caret")
|
||||
}
|
||||
|
||||
val resolutionFacade = file.getResolutionFacade()
|
||||
|
||||
@@ -86,8 +86,9 @@ abstract class AbstractScratchRunActionTest : FileEditorManagerTestCase() {
|
||||
}
|
||||
}
|
||||
|
||||
javaFiles.forEach { myFixture.copyFileToProject(it.path, FileUtil.getRelativePath(baseDir, it)!!) }
|
||||
kotlinFiles.forEach { myFixture.copyFileToProject(it.path, FileUtil.getRelativePath(baseDir, it)!!) }
|
||||
val testDataPathFile = File(myFixture.testDataPath)
|
||||
javaFiles.forEach { myFixture.copyFileToProject(FileUtil.getRelativePath(testDataPathFile, it)!!, FileUtil.getRelativePath(baseDir, it)!!) }
|
||||
kotlinFiles.forEach { myFixture.copyFileToProject(FileUtil.getRelativePath(testDataPathFile, it)!!, FileUtil.getRelativePath(baseDir, it)!!) }
|
||||
|
||||
val outputDir = createTempDir(dirName)
|
||||
|
||||
|
||||
-3
@@ -6,10 +6,7 @@
|
||||
package org.jetbrains.kotlin.nj2k
|
||||
|
||||
import org.jetbrains.kotlin.idea.conversion.copy.AbstractTextJavaToKotlinCopyPasteConversionTest
|
||||
import org.jetbrains.kotlin.test.KotlinTestUtils
|
||||
|
||||
abstract class AbstractTextNewJavaToKotlinCopyPasteConversionTest : AbstractTextJavaToKotlinCopyPasteConversionTest() {
|
||||
override val BASE_PATH = KotlinTestUtils.getHomeDirectory() + "/nj2k/testData/copyPastePlainText"
|
||||
|
||||
override fun isNewJ2K(): Boolean = true
|
||||
}
|
||||
Reference in New Issue
Block a user