Refactoring: return injection tests to single test-class

This commit is contained in:
Nikolay Krasko
2016-04-26 22:53:49 +03:00
parent adda3ef69d
commit 62ede15241
3 changed files with 39 additions and 47 deletions
@@ -40,12 +40,18 @@ abstract class AbstractInjectionTest : KotlinLightCodeInsightFixtureTestCase() {
}
}
protected fun doInjectionPresentTest(@Language("kotlin") text: String, languageId: String? = null, unInjectShouldBePresent: Boolean = true) {
protected fun doInjectionPresentTest(
@Language("kotlin") text: String, @Language("Java") javaText: String? = null,
languageId: String? = null, unInjectShouldBePresent: Boolean = true) {
if (javaText != null) {
myFixture.configureByText("${getTestName(true)}.java", javaText.trimIndent())
}
myFixture.configureByText("${getTestName(true)}.kt", text.trimIndent())
assertInjectionPresent(languageId, unInjectShouldBePresent)
}
protected fun assertInjectionPresent(languageId: String?, unInjectShouldBePresent: Boolean) {
TestCase.assertFalse("Injection action is available. There's probably no injection at caret place",
InjectLanguageAction().isAvailable(project, myFixture.editor, myFixture.file))
@@ -379,4 +379,35 @@ class KotlinInjectionTest : AbstractInjectionTest() {
// """,
// languageId = HTMLLanguage.INSTANCE.id, unInjectShouldBePresent = false
// )
fun testInjectionOfCustomParameterInJavaConstructorWithAnnotationWithAnnotation() = doInjectionPresentTest(
"""
fun bar() { Test("<caret>some") }
""",
javaText =
"""
import org.intellij.lang.annotations.Language;
public class Test {
public Test(@Language("HTML") String str) {}
}
""",
languageId = HTMLLanguage.INSTANCE.id, unInjectShouldBePresent = false
)
fun testInjectionOfCustomParameterJavaWithAnnotation() = doInjectionPresentTest(
"""
fun bar() { Test.foo("<caret>some") }
""",
javaText =
"""
import org.intellij.lang.annotations.Language;
public class Test {
public static void foo(@Language("HTML") String str) {}
}
""",
languageId = HTMLLanguage.INSTANCE.id, unInjectShouldBePresent = false
)
}
@@ -1,45 +0,0 @@
/*
* Copyright 2010-2016 JetBrains s.r.o.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.jetbrains.kotlin.psi
import com.intellij.lang.html.HTMLLanguage
import org.jetbrains.kotlin.idea.test.PluginTestCaseBase
class KotlinMultiFileInjectionTest : AbstractInjectionTest() {
public override fun setUp() {
super.setUp()
myFixture.testDataPath = PluginTestCaseBase.getTestDataPathBase() + "/injection"
}
fun testInjectionOfCustomParameterInJavaConstructorWithAnnotation() = doMultiFileInjectionPresentTest(HTMLLanguage.INSTANCE.id, false)
fun testInjectionOfCustomParameterJavaWithAnnotation() = doMultiFileInjectionPresentTest(HTMLLanguage.INSTANCE.id, false)
override fun getTestDataPath(): String? {
return "idea/testData/injection/"
}
private fun doMultiFileInjectionPresentTest(languageId: String? = null, unInjectShouldBePresent: Boolean = true) {
val testName = getTestName(false)
myFixture.configureByFile("$testName.java")
myFixture.configureByFile("$testName.kt")
assertInjectionPresent(languageId, unInjectShouldBePresent)
}
}