mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-02-04 15:06:56 +07:00
Rename to improve clarity: each element in this constant represents a method of Project class, providing a context of Project. It is used to run expressions in tests in different variations of Closure where Project is a delegate. Also, add some more methods of Project providing such context. GitOrigin-RevId: 290ce09e88bff7171e67b3be2abcb8f2c9f3df6d
57 lines
2.6 KiB
Kotlin
57 lines
2.6 KiB
Kotlin
// Copyright 2000-2022 JetBrains s.r.o. and contributors. Use of this source code is governed by the Apache 2.0 license.
|
|
package org.jetbrains.plugins.gradle.dsl
|
|
|
|
import com.intellij.psi.PsiMethod
|
|
import org.gradle.util.GradleVersion
|
|
import org.jetbrains.plugins.gradle.service.resolve.GradleCommonClassNames.GRADLE_API_JAVA_PLUGIN_CONVENTION
|
|
import org.jetbrains.plugins.gradle.testFramework.GradleCodeInsightTestCase
|
|
import org.jetbrains.plugins.gradle.testFramework.annotations.AllGradleVersionsSource
|
|
import org.jetbrains.plugins.gradle.testFramework.util.assumeThatTopLevelJavaConventionsIsSupported
|
|
import org.junit.jupiter.params.ParameterizedTest
|
|
|
|
class GradleConventionsTest : GradleCodeInsightTestCase() {
|
|
|
|
@ParameterizedTest
|
|
@AllGradleVersionsSource(PROJECT_CONTEXTS, """
|
|
"<caret>docsDir",
|
|
"project.<caret>docsDir"
|
|
""")
|
|
fun `test property read`(gradleVersion: GradleVersion, decorator: String, expression: String) {
|
|
assumeThatTopLevelJavaConventionsIsSupported(gradleVersion)
|
|
testJavaProject(gradleVersion) {
|
|
testBuildscript(decorator, expression) {
|
|
methodTest(resolveTest(PsiMethod::class.java), "getDocsDir", GRADLE_API_JAVA_PLUGIN_CONVENTION)
|
|
}
|
|
}
|
|
}
|
|
|
|
@ParameterizedTest
|
|
@AllGradleVersionsSource(PROJECT_CONTEXTS)
|
|
fun `test property write`(gradleVersion: GradleVersion, decorator: String) {
|
|
assumeThatTopLevelJavaConventionsIsSupported(gradleVersion)
|
|
testJavaProject(gradleVersion) {
|
|
testBuildscript(decorator, "<caret>sourceCompatibility = 42") {
|
|
methodTest(resolveTest(PsiMethod::class.java), "setSourceCompatibility", GRADLE_API_JAVA_PLUGIN_CONVENTION)
|
|
}
|
|
}
|
|
}
|
|
|
|
// this test is wrong and exists only to preserve current behaviour and to fail when behaviour changes
|
|
@ParameterizedTest
|
|
@AllGradleVersionsSource(PROJECT_CONTEXTS)
|
|
fun `test setter method`(gradleVersion: GradleVersion, decorator: String) {
|
|
assumeThatTopLevelJavaConventionsIsSupported(gradleVersion)
|
|
testJavaProject(gradleVersion) {
|
|
testBuildscript(decorator, "<caret>targetCompatibility('1.8')") {
|
|
setterMethodTest("targetCompatibility", "setTargetCompatibility", GRADLE_API_JAVA_PLUGIN_CONVENTION)
|
|
//// the correct test is below:
|
|
//val call = elementUnderCaret(GrMethodCall::class.java)
|
|
//val result = call.advancedResolve()
|
|
//assertTrue(result.isInvokedOnProperty)
|
|
//// getTargetCompatibility() should be resolved, just because it exists, but later it's highlighted with warning
|
|
//val method = assertInstanceOf<PsiMethod>(result.element)
|
|
//methodTest(method, "getTargetCompatibility", GRADLE_API_JAVA_PLUGIN_CONVENTION)
|
|
}
|
|
}
|
|
}
|
|
} |