Infrastructure: move compiler plugin tests back to their modules

This commit is contained in:
Yan Zhulanow
2017-10-16 20:20:57 +03:00
parent 7248f2568a
commit eccc3447f6
40 changed files with 113 additions and 106 deletions
@@ -11,11 +11,21 @@ dependencies {
compile(project(":compiler:frontend.java"))
compile(project(":compiler:backend"))
compileOnly(project(":kotlin-android-extensions-runtime"))
testCompile(project(":compiler:util"))
testCompile(project(":compiler:backend"))
testCompile(project(":compiler:cli"))
testCompile(project(":compiler:tests-common"))
testCompile(projectTests(":compiler:tests-common"))
testCompile(projectDist(":kotlin-test:kotlin-test-jvm"))
testCompile(commonDep("junit:junit"))
testRuntime(ideaPluginDeps("idea-junit", "resources_en", plugin = "junit"))
testCompile(project(":kotlin-android-extensions-runtime"))
}
sourceSets {
"main" { projectDefault() }
"test" {}
"test" { projectDefault() }
}
runtimeJar {
@@ -25,3 +35,13 @@ runtimeJar {
dist()
ideaPlugin()
testsJar {}
evaluationDependsOn(":kotlin-android-extensions-runtime")
projectTest {
environment("ANDROID_EXTENSIONS_RUNTIME_CLASSES", getSourceSetsFrom(":kotlin-android-extensions-runtime")["main"].output.classesDirs.asPath)
dependsOnTaskIfExistsRec("dist", project = rootProject)
workingDir = rootDir
}
@@ -0,0 +1,197 @@
/*
* Copyright 2010-2017 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.android.parcel
import org.jetbrains.kotlin.codegen.CodegenTestCase
import org.jetbrains.kotlin.codegen.getClassFiles
import org.jetbrains.kotlin.test.KotlinTestUtils
import org.jetbrains.org.objectweb.asm.ClassReader
import org.jetbrains.org.objectweb.asm.Label
import org.jetbrains.org.objectweb.asm.Opcodes.*
import org.jetbrains.org.objectweb.asm.Type
import org.jetbrains.org.objectweb.asm.tree.*
import org.jetbrains.org.objectweb.asm.util.Printer
import java.io.File
private val LINE_SEPARATOR = System.getProperty("line.separator")
abstract class AbstractAsmLikeInstructionListingTest : CodegenTestCase() {
private companion object {
val CURIOUS_ABOUT_DIRECTIVE = "// CURIOUS_ABOUT "
val LOCAL_VARIABLES_TABLE_DIRECTIVE = "// LOCAL_VARIABLES_TABLE"
}
override fun doMultiFileTest(wholeFile: File, files: List<TestFile>, javaFilesDir: File?) {
val txtFile = File(wholeFile.parentFile, wholeFile.nameWithoutExtension + ".txt")
compile(files, javaFilesDir)
val classes = classFileFactory
.getClassFiles()
.sortedBy { it.relativePath }
.map { file -> ClassNode().also { ClassReader(file.asByteArray()).accept(it, ClassReader.EXPAND_FRAMES) } }
val testFileLines = wholeFile.readLines()
val printBytecodeForTheseMethods = testFileLines
.filter { it.startsWith(CURIOUS_ABOUT_DIRECTIVE) }
.map { it.substring(CURIOUS_ABOUT_DIRECTIVE.length) }
.flatMap { it.split(',').map { it.trim() } }
val showLocalVariables = testFileLines.any { it.trim() == LOCAL_VARIABLES_TABLE_DIRECTIVE }
KotlinTestUtils.assertEqualsToFile(txtFile, classes.joinToString(LINE_SEPARATOR.repeat(2)) {
renderClassNode(it, printBytecodeForTheseMethods, showLocalVariables)
})
}
private fun renderClassNode(clazz: ClassNode, printBytecodeForTheseMethods: List<String>, showLocalVariables: Boolean): String {
val fields = (clazz.fields ?: emptyList()).sortedBy { it.name }
val methods = (clazz.methods ?: emptyList()).sortedBy { it.name }
val superTypes = (listOf(clazz.superName) + clazz.interfaces).filterNotNull()
return buildString {
renderVisibilityModifiers(clazz.access)
renderModalityModifiers(clazz.access)
append(if ((clazz.access and ACC_INTERFACE) != 0) "interface " else "class ")
append(clazz.name)
if (superTypes.isNotEmpty()) {
append(" : " + superTypes.joinToString())
}
appendln(" {")
fields.joinTo(this, LINE_SEPARATOR.repeat(2)) { renderField(it).withMargin() }
if (fields.isNotEmpty()) {
appendln().appendln()
}
methods.joinTo(this, LINE_SEPARATOR.repeat(2)) {
val printBytecode = printBytecodeForTheseMethods.contains(it.name)
renderMethod(it, printBytecode, showLocalVariables).withMargin()
}
appendln().append("}")
}
}
private fun renderField(field: FieldNode) = buildString {
renderVisibilityModifiers(field.access)
renderModalityModifiers(field.access)
append(Type.getType(field.desc).className).append(' ')
append(field.name)
}
private fun renderMethod(method: MethodNode, printBytecode: Boolean, showLocalVariables: Boolean) = buildString {
renderVisibilityModifiers(method.access)
renderModalityModifiers(method.access)
val (returnType, parameterTypes) = with(Type.getMethodType(method.desc)) { returnType to argumentTypes }
append(returnType.className).append(' ')
append(method.name)
parameterTypes.mapIndexed { index, type -> "${type.className} p$index" }.joinTo(this, prefix = "(", postfix = ")")
if (printBytecode && (method.access and ACC_ABSTRACT) == 0) {
appendln(" {")
append(renderBytecodeInstructions(method.instructions).trimEnd().withMargin())
if (showLocalVariables) {
val localVariableTable = buildLocalVariableTable(method)
if (localVariableTable.isNotEmpty()) {
appendln().appendln()
append(localVariableTable.withMargin())
}
}
appendln().append("}")
}
}
private fun buildLocalVariableTable(method: MethodNode): String {
val localVariables = method.localVariables?.takeIf { it.isNotEmpty() } ?: return ""
return buildString {
append("Local variables:")
for (variable in localVariables) {
appendln().append((variable.name + ": " + variable.desc).withMargin())
}
}
}
private fun renderBytecodeInstructions(instructions: InsnList) = buildString {
val labelMappings = LabelMappings()
var currentInsn = instructions.first
while (currentInsn != null) {
renderInstruction(currentInsn, labelMappings)
currentInsn = currentInsn.next
}
}
private fun StringBuilder.renderInstruction(node: AbstractInsnNode, labelMappings: LabelMappings) {
if (node is LabelNode) {
appendln("LABEL (L" + labelMappings[node.label] + ")")
return
}
if (node is LineNumberNode) {
appendln("LINENUMBER (" + node.line + ")")
return
}
if (node is FrameNode) return
append(" ").append(Printer.OPCODES[node.opcode] ?: error("Invalid opcode ${node.opcode}"))
when (node) {
is FieldInsnNode -> append(" (" + node.name + ", " + node.desc + ")")
is JumpInsnNode -> append(" (L" + labelMappings[node.label.label] + ")")
is IntInsnNode -> append(" (" + node.operand + ")")
is MethodInsnNode -> append(" (" + node.owner + ", "+ node.name + ", " + node.desc + ")")
is VarInsnNode -> append(" (" + node.`var` + ")")
is LdcInsnNode -> append(" (" + node.cst + ")")
}
appendln()
}
private fun String.withMargin(margin: String = " "): String {
return lineSequence().map { margin + it }.joinToString(LINE_SEPARATOR)
}
private fun StringBuilder.renderVisibilityModifiers(access: Int) {
if ((access and ACC_PUBLIC) != 0) append("public ")
if ((access and ACC_PRIVATE) != 0) append("private ")
if ((access and ACC_PROTECTED) != 0) append("protected ")
}
private fun StringBuilder.renderModalityModifiers(access: Int) {
if ((access and ACC_FINAL) != 0) append("final ")
if ((access and ACC_ABSTRACT) != 0) append("abstract ")
if ((access and ACC_STATIC) != 0) append("static ")
}
private class LabelMappings {
private var mappings = hashMapOf<Int, Int>()
private var currentIndex = 0
operator fun get(label: Label): Int {
val hashCode = System.identityHashCode(label)
return mappings.getOrPut(hashCode) { currentIndex++ }
}
}
}
@@ -0,0 +1,172 @@
/*
* Copyright 2010-2017 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.android.parcel
import org.jetbrains.kotlin.android.synthetic.AndroidComponentRegistrar
import org.jetbrains.kotlin.android.synthetic.test.addAndroidExtensionsRuntimeLibrary
import org.jetbrains.kotlin.cli.jvm.compiler.KotlinCoreEnvironment
import org.jetbrains.kotlin.cli.jvm.config.JvmClasspathRoot
import org.jetbrains.kotlin.codegen.CodegenTestCase
import org.jetbrains.kotlin.codegen.getClassFiles
import org.jetbrains.kotlin.utils.PathUtil
import org.jetbrains.org.objectweb.asm.ClassWriter
import org.jetbrains.org.objectweb.asm.ClassWriter.COMPUTE_FRAMES
import org.jetbrains.org.objectweb.asm.ClassWriter.COMPUTE_MAXS
import org.jetbrains.org.objectweb.asm.Label
import org.jetbrains.org.objectweb.asm.Opcodes.*
import org.jetbrains.org.objectweb.asm.Type
import org.jetbrains.org.objectweb.asm.commons.InstructionAdapter
import org.junit.runner.JUnitCore
import java.io.File
import java.nio.file.Files
import java.util.concurrent.TimeUnit
abstract class AbstractParcelBoxTest : CodegenTestCase() {
protected companion object {
val BASE_DIR = "plugins/android-extensions/android-extensions-compiler/testData/parcel/box"
val LIBRARY_KT = File(File(BASE_DIR).parentFile, "boxLib.kt")
private val JUNIT_GENERATED_TEST_CLASS_BYTES by lazy { constructSyntheticTestClass() }
private val JUNIT_GENERATED_TEST_CLASS_FQNAME = "test.JunitTest"
private fun constructSyntheticTestClass(): ByteArray {
return with(ClassWriter(COMPUTE_MAXS or COMPUTE_FRAMES)) {
visit(49, ACC_PUBLIC, JUNIT_GENERATED_TEST_CLASS_FQNAME.replace('.', '/'), null, "java/lang/Object", emptyArray())
visitSource(null, null)
with(visitAnnotation("Lorg/junit/runner/RunWith;", true)) {
visit("value", Type.getType("Lorg/robolectric/RobolectricTestRunner;"))
visitEnd()
}
with(visitAnnotation("Lorg/robolectric/annotation/Config;", true)) {
visit("manifest", "--none")
visitEnd()
}
with(visitMethod(ACC_PUBLIC, "<init>", "()V", null, null)) {
visitVarInsn(ALOAD, 0)
visitMethodInsn(INVOKESPECIAL, "java/lang/Object", "<init>", "()V", false)
visitInsn(RETURN)
visitMaxs(-1, -1)
visitEnd()
}
with(visitMethod(ACC_PUBLIC, "test", "()V", null, null)) {
visitAnnotation("Lorg/junit/Test;", true).visitEnd()
val v = InstructionAdapter(this)
val assertionOk = Label()
v.invokestatic("test/TestKt", "box", "()Ljava/lang/String;", false) // -> ret
v.dup() // -> ret, ret
v.aconst("OK") // -> ret, ret, ok
v.invokevirtual("java/lang/String", "equals", "(Ljava/lang/Object;)Z", false) // -> ret, eq
v.ifne(assertionOk) // -> ret
val assertionErrorType = Type.getObjectType("java/lang/AssertionError")
v.anew(assertionErrorType) // -> ret, ae
v.dupX1() // -> ae, ret, ae
v.swap() // -> ae, ae, ret
v.invokespecial(assertionErrorType.internalName, "<init>", "(Ljava/lang/Object;)V", false) // -> ae
v.athrow()
v.visitLabel(assertionOk)
v.pop() // -> [empty]
v.areturn(Type.VOID_TYPE)
visitMaxs(-1, -1)
visitEnd()
}
visitEnd()
toByteArray()
}
}
}
override fun doTest(filePath: String) {
super.doTest(File(BASE_DIR, filePath + ".kt").absolutePath)
}
private fun getClasspathForTest(): List<File> {
val kotlinRuntimeJar = PathUtil.kotlinPathsForIdeaPlugin.stdlibPath
val layoutLibJars = listOf(File("ideaSDK/plugins/android/lib/layoutlib.jar"), File("ideaSDK/plugins/android/lib/layoutlib-api.jar"))
val robolectricJars = File("dependencies/robolectric")
.listFiles { f: File -> f.extension == "jar" }
.sortedBy { it.nameWithoutExtension }
val junitCoreResourceName = JUnitCore::class.java.name.replace('.', '/') + ".class"
val junitJar = File(JUnitCore::class.java.classLoader.getResource(junitCoreResourceName).file.substringBeforeLast('!'))
val androidExtensionsRuntimeCP =
(System.getenv("ANDROID_EXTENSIONS_RUNTIME_CLASSES")?.split(File.pathSeparator)
?: listOf("out/production/android-extensions-runtime")
).map { File(it) }
return listOf(kotlinRuntimeJar) + layoutLibJars + robolectricJars + junitJar + androidExtensionsRuntimeCP
}
override fun doMultiFileTest(wholeFile: File, files: List<TestFile>, javaFilesDir: File?) {
compile(files + TestFile(LIBRARY_KT.name, LIBRARY_KT.readText()), javaFilesDir)
val javaBin = File(System.getProperty("java.home").takeIf { it.isNotEmpty() } ?: error("JAVA_HOME is not set"), "bin")
val javaExe = File(javaBin, "java.exe").takeIf { it.exists() } ?: File(javaBin, "java")
assert(javaExe.exists()) { "Can't find 'java' executable in $javaBin" }
val libraryClasspath = getClasspathForTest()
val dirForTestClasses = Files.createTempDirectory("parcel").toFile()
fun writeClass(fqNameOrPath: String, bytes: ByteArray) {
val path = if (fqNameOrPath.endsWith(".class")) fqNameOrPath else (fqNameOrPath.replace('.', '/') + ".class")
File(dirForTestClasses, path).also { it.parentFile.mkdirs() }.writeBytes(bytes)
}
try {
writeClass(JUNIT_GENERATED_TEST_CLASS_FQNAME, JUNIT_GENERATED_TEST_CLASS_BYTES)
classFileFactory.getClassFiles().forEach { writeClass(it.relativePath, it.asByteArray()) }
val process = ProcessBuilder(
javaExe.absolutePath,
"-ea",
"-classpath",
(libraryClasspath + dirForTestClasses).joinToString(File.pathSeparator),
JUnitCore::class.java.name,
JUNIT_GENERATED_TEST_CLASS_FQNAME
).inheritIO().start()
process.waitFor(3, TimeUnit.MINUTES)
if (process.exitValue() != 0) {
throw AssertionError(classFileFactory.createText())
}
} finally {
if (!dirForTestClasses.deleteRecursively()) {
throw AssertionError("Unable to delete $dirForTestClasses")
}
}
}
override fun setupEnvironment(environment: KotlinCoreEnvironment) {
AndroidComponentRegistrar.registerParcelExtensions(environment.project)
addAndroidExtensionsRuntimeLibrary(environment)
environment.updateClasspath(listOf(JvmClasspathRoot(File("ideaSDK/plugins/android/lib/layoutlib.jar"))))
}
}
@@ -0,0 +1,32 @@
/*
* Copyright 2010-2017 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.android.parcel
import org.jetbrains.kotlin.android.synthetic.AndroidComponentRegistrar
import org.jetbrains.kotlin.android.synthetic.test.addAndroidExtensionsRuntimeLibrary
import org.jetbrains.kotlin.cli.jvm.compiler.KotlinCoreEnvironment
import org.jetbrains.kotlin.cli.jvm.config.JvmClasspathRoot
import org.jetbrains.kotlin.codegen.extensions.ExpressionCodegenExtension
import java.io.File
abstract class AbstractParcelBytecodeListingTest : AbstractAsmLikeInstructionListingTest() {
override fun setupEnvironment(environment: KotlinCoreEnvironment) {
AndroidComponentRegistrar.registerParcelExtensions(environment.project)
addAndroidExtensionsRuntimeLibrary(environment)
environment.updateClasspath(listOf(JvmClasspathRoot(File("ideaSDK/plugins/android/lib/layoutlib.jar"))))
}
}
@@ -0,0 +1,49 @@
/*
* Copyright 2010-2017 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.android.parcel
class ParcelBoxTest : AbstractParcelBoxTest() {
fun testSimple() = doTest("simple")
fun testPrimitiveTypes() = doTest("primitiveTypes")
fun testBoxedTypes() = doTest("boxedTypes")
fun testNullableTypesSimple() = doTest("nullableTypesSimple")
fun testNullableTypes() = doTest("nullableTypes")
fun testListSimple() = doTest("listSimple")
fun testLists() = doTest("lists")
fun testListKinds() = doTest("listKinds")
fun testArraySimple() = doTest("arraySimple")
fun testArrays() = doTest("arrays")
fun testMapSimple() = doTest("mapSimple")
fun testMaps() = doTest("maps")
fun testMapKinds() = doTest("mapKinds")
fun testSparseBooleanArray() = doTest("sparseBooleanArray")
fun testBundle() = doTest("bundle")
fun testSparseArrays() = doTest("sparseArrays")
fun testCustomSimple() = doTest("customSimple")
fun testCharSequence() = doTest("charSequence")
fun testEnums() = doTest("enums")
fun testObjects() = doTest("objects")
fun testNestedParcelable() = doTest("nestedParcelable")
fun testKt19749() = doTest("kt19749")
fun testKt19747() = doTest("kt19747")
fun testKt19747_2() = doTest("kt19747_2")
fun test20002() = doTest("kt20002")
fun test20021() = doTest("kt20021")
fun testCustomSerializerSimple() = doTest("customSerializerSimple")
fun testCustomSerializerWriteWith() = doTest("customSerializerWriteWith")
fun testCustomSerializerBoxing() = doTest("customSerializerBoxing")
}
@@ -0,0 +1,111 @@
/*
* Copyright 2010-2017 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.android.synthetic.test
import com.intellij.openapi.util.io.FileUtil
import com.intellij.util.ArrayUtil
import com.intellij.util.Processor
import org.jetbrains.kotlin.cli.jvm.config.jvmClasspathRoots
import org.jetbrains.kotlin.codegen.AbstractBlackBoxCodegenTest
import org.jetbrains.kotlin.codegen.CodegenTestFiles
import org.jetbrains.kotlin.config.CompilerConfiguration
import org.jetbrains.kotlin.test.ConfigurationKind
import org.jetbrains.kotlin.test.KotlinTestUtils
import org.jetbrains.kotlin.test.TestJdkKind
import java.io.File
import java.net.URL
import java.util.*
import java.util.regex.Pattern
abstract class AbstractAndroidBoxTest : AbstractBlackBoxCodegenTest() {
private fun createAndroidAPIEnvironment(path: String) {
return createEnvironmentForConfiguration(KotlinTestUtils.newConfiguration(ConfigurationKind.ALL, TestJdkKind.ANDROID_API), path)
}
private fun createFakeAndroidEnvironment(path: String) {
return createEnvironmentForConfiguration(KotlinTestUtils.newConfiguration(ConfigurationKind.ALL, TestJdkKind.MOCK_JDK), path)
}
private fun createEnvironmentForConfiguration(configuration: CompilerConfiguration, path: String) {
val layoutPaths = File(path).listFiles { it -> it.name.startsWith("layout") && it.isDirectory }!!.map { "$path${it.name}/" }
myEnvironment = createTestEnvironment(configuration, layoutPaths)
}
fun doCompileAgainstAndroidSdkTest(path: String) {
createAndroidAPIEnvironment(path)
doMultiFileTest(path)
}
fun doFakeInvocationTest(path: String) {
if (needsInvocationTest(path)) {
createFakeAndroidEnvironment(path)
doMultiFileTest(path, getFakeFiles(path))
}
}
override fun getClassPathURLs(): Array<URL> {
return myEnvironment.configuration.jvmClasspathRoots.map { it.toURI().toURL() }.toTypedArray()
}
private fun getFakeFiles(path: String): Collection<String> {
return FileUtil.findFilesByMask(Pattern.compile("^Fake.*\\.kt$"), File(path.replace(getTestName(true), ""))).map { relativePath(it) }
}
private fun needsInvocationTest(path: String): Boolean {
return !FileUtil.findFilesByMask(Pattern.compile("^0.kt$"), File(path)).isEmpty()
}
override fun codegenTestBasePath(): String {
return "plugins/android-extensions/android-extensions-compiler/testData/codegen/"
}
private fun doMultiFileTest(path: String, additionalFiles: Collection<String>? = null) {
val files = mutableListOf<String>()
FileUtil.processFilesRecursively(File(path), object : Processor<File> {
override fun process(file: File?): Boolean {
when (file!!.name) {
"1.kt" -> {
if (additionalFiles == null) files.add(relativePath(file))
}
"0.kt" -> {
if (additionalFiles != null) files.add(relativePath(file))
}
else -> {
if (file.name.endsWith(".kt")) files.add(relativePath(file))
}
}
return true
}
})
for (file in File("plugins/android-extensions/android-extensions-runtime/src").walk()) {
if (file.extension == "kt") files += relativePath(file.absoluteFile)
}
Collections.sort(files)
if (additionalFiles != null) {
files.addAll(additionalFiles)
}
myFiles = CodegenTestFiles.create(
myEnvironment!!.project,
ArrayUtil.toStringArray(files),
KotlinTestUtils.getHomeDirectory() + "/plugins/android-extensions/android-extensions-compiler/testData"
)
blackBox()
}
}
@@ -0,0 +1,44 @@
/*
* Copyright 2010-2017 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.android.synthetic.test
import org.jetbrains.kotlin.codegen.AbstractBytecodeTextTest
import org.jetbrains.kotlin.config.CompilerConfiguration
import org.jetbrains.kotlin.test.ConfigurationKind
import org.jetbrains.kotlin.test.KotlinTestUtils
import org.jetbrains.kotlin.test.TestJdkKind
abstract class AbstractAndroidBytecodeShapeTest : AbstractBytecodeTextTest() {
private fun createAndroidAPIEnvironment(path: String) {
return createEnvironmentForConfiguration(KotlinTestUtils.newConfiguration(ConfigurationKind.ALL, TestJdkKind.ANDROID_API), path)
}
private fun createEnvironmentForConfiguration(configuration: CompilerConfiguration, path: String) {
val layoutPaths = getResPaths(path)
myEnvironment = createTestEnvironment(configuration, layoutPaths)
addAndroidExtensionsRuntimeLibrary(myEnvironment)
}
override fun doTest(path: String) {
val fileName = path + getTestName(true) + ".kt"
createAndroidAPIEnvironment(path)
loadFileByFullPath(fileName)
val expected = readExpectedOccurrences(fileName)
val actual = generateToText()
checkGeneratedTextAgainstExpectedOccurrences(actual, expected)
}
}
@@ -0,0 +1,55 @@
/*
* Copyright 2010-2017 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.android.synthetic.test
import org.jetbrains.kotlin.android.synthetic.res.AndroidPackageFragmentProviderExtension
import org.jetbrains.kotlin.android.synthetic.res.AndroidSyntheticPackageFragmentProvider
import org.jetbrains.kotlin.renderer.DescriptorRenderer
import org.jetbrains.kotlin.resolve.MemberComparator
import org.jetbrains.kotlin.resolve.jvm.extensions.PackageFragmentProviderExtension
import org.jetbrains.kotlin.resolve.lazy.JvmResolveUtil
import org.jetbrains.kotlin.storage.LockBasedStorageManager
import org.jetbrains.kotlin.test.ConfigurationKind
import org.jetbrains.kotlin.test.KotlinTestUtils
import org.jetbrains.kotlin.test.TestJdkKind
import org.jetbrains.kotlin.test.testFramework.KtUsefulTestCase
import java.io.File
abstract class AbstractAndroidSyntheticPropertyDescriptorTest : KtUsefulTestCase() {
fun doTest(path: String) {
val config = KotlinTestUtils.newConfiguration(ConfigurationKind.ALL, TestJdkKind.ANDROID_API)
val env = createTestEnvironment(config, getResPaths(path))
val project = env.project
val ext = PackageFragmentProviderExtension.getInstances(project).first { it is AndroidPackageFragmentProviderExtension }
val analysisResult = JvmResolveUtil.analyzeAndCheckForErrors(listOf(), env)
val fragmentProvider = ext.getPackageFragmentProvider(project, analysisResult.moduleDescriptor, LockBasedStorageManager.NO_LOCKS,
KotlinTestUtils.DUMMY_EXCEPTION_ON_ERROR_TRACE, null) as AndroidSyntheticPackageFragmentProvider
val renderer = DescriptorRenderer.COMPACT_WITH_MODIFIERS
val expected = fragmentProvider.packageFragments.sortedBy { it.fqName.asString() }.map {
val descriptors = it.getMemberScope().getContributedDescriptors()
.sortedWith(MemberComparator.INSTANCE)
.map { " " + renderer.render(it) }.joinToString("\n")
it.fqName.asString() + (if (descriptors.isNotEmpty()) "\n\n" + descriptors else "")
}.joinToString("\n\n\n")
KotlinTestUtils.assertEqualsToFile(File(path, "result.txt"), expected)
}
}
@@ -0,0 +1,72 @@
/*
* Copyright 2010-2017 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.android.synthetic.test
import com.intellij.testFramework.registerServiceInstance
import kotlinx.android.extensions.CacheImplementation
import org.jetbrains.kotlin.android.synthetic.AndroidConfigurationKeys
import org.jetbrains.kotlin.android.synthetic.AndroidExtensionPropertiesComponentContainerContributor
import org.jetbrains.kotlin.android.synthetic.codegen.CliAndroidExtensionsExpressionCodegenExtension
import org.jetbrains.kotlin.android.synthetic.codegen.CliAndroidOnDestroyClassBuilderInterceptorExtension
import org.jetbrains.kotlin.android.synthetic.res.AndroidLayoutXmlFileManager
import org.jetbrains.kotlin.android.synthetic.res.AndroidVariant
import org.jetbrains.kotlin.android.synthetic.res.CliAndroidLayoutXmlFileManager
import org.jetbrains.kotlin.android.synthetic.res.CliAndroidPackageFragmentProviderExtension
import org.jetbrains.kotlin.cli.jvm.compiler.EnvironmentConfigFiles
import org.jetbrains.kotlin.cli.jvm.compiler.KotlinCoreEnvironment
import org.jetbrains.kotlin.cli.jvm.config.JvmClasspathRoot
import org.jetbrains.kotlin.codegen.extensions.ClassBuilderInterceptorExtension
import org.jetbrains.kotlin.codegen.extensions.ExpressionCodegenExtension
import org.jetbrains.kotlin.config.CompilerConfiguration
import org.jetbrains.kotlin.extensions.StorageComponentContainerContributor
import org.jetbrains.kotlin.resolve.jvm.extensions.PackageFragmentProviderExtension
import org.jetbrains.kotlin.test.testFramework.KtUsefulTestCase
import org.jetbrains.kotlin.utils.KotlinPaths
import org.jetbrains.kotlin.utils.KotlinPathsFromHomeDir
import org.jetbrains.kotlin.utils.PathUtil
import java.io.File
fun KtUsefulTestCase.createTestEnvironment(configuration: CompilerConfiguration, resDirectories: List<String>): KotlinCoreEnvironment {
configuration.put(AndroidConfigurationKeys.VARIANT, resDirectories)
configuration.put(AndroidConfigurationKeys.PACKAGE, "test")
val myEnvironment = KotlinCoreEnvironment.createForTests(testRootDisposable, configuration, EnvironmentConfigFiles.JVM_CONFIG_FILES)
val project = myEnvironment.project
val variants = listOf(AndroidVariant.createMainVariant(resDirectories))
project.registerServiceInstance(AndroidLayoutXmlFileManager::class.java, CliAndroidLayoutXmlFileManager(project, "test", variants))
ExpressionCodegenExtension.registerExtension(project, CliAndroidExtensionsExpressionCodegenExtension(true, CacheImplementation.DEFAULT))
StorageComponentContainerContributor.registerExtension(project, AndroidExtensionPropertiesComponentContainerContributor())
ClassBuilderInterceptorExtension.registerExtension(project, CliAndroidOnDestroyClassBuilderInterceptorExtension(CacheImplementation.DEFAULT))
PackageFragmentProviderExtension.registerExtension(project, CliAndroidPackageFragmentProviderExtension(true))
addAndroidExtensionsRuntimeLibrary(myEnvironment)
return myEnvironment
}
fun addAndroidExtensionsRuntimeLibrary(environment: KotlinCoreEnvironment) {
environment.apply {
val runtimeLibrary = File(PathUtil.kotlinPathsForCompiler.libPath, "android-extensions-compiler.jar")
updateClasspath(listOf(JvmClasspathRoot(runtimeLibrary)))
}
}
fun getResPaths(path: String): List<String> {
return File(path).listFiles { it -> it.name.startsWith("res") && it.isDirectory }!!.map { "$path${it.name}/" }
}
@@ -0,0 +1,128 @@
/*
* Copyright 2010-2017 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.android.parcel;
import com.intellij.testFramework.TestDataPath;
import org.jetbrains.kotlin.test.JUnit3RunnerWithInners;
import org.jetbrains.kotlin.test.KotlinTestUtils;
import org.jetbrains.kotlin.test.TargetBackend;
import org.jetbrains.kotlin.test.TestMetadata;
import org.junit.runner.RunWith;
import java.io.File;
import java.util.regex.Pattern;
/** This class is generated by {@link org.jetbrains.kotlin.generators.tests.TestsPackage}. DO NOT MODIFY MANUALLY */
@SuppressWarnings("all")
@TestMetadata("plugins/android-extensions/android-extensions-compiler/testData/parcel/codegen")
@TestDataPath("$PROJECT_ROOT")
@RunWith(JUnit3RunnerWithInners.class)
public class ParcelBytecodeListingTestGenerated extends AbstractParcelBytecodeListingTest {
public void testAllFilesPresentInCodegen() throws Exception {
KotlinTestUtils.assertAllTestsPresentByMetadata(this.getClass(), new File("plugins/android-extensions/android-extensions-compiler/testData/parcel/codegen"), Pattern.compile("^(.+)\\.kt$"), TargetBackend.ANY, true);
}
@TestMetadata("customDescribeContents.kt")
public void testCustomDescribeContents() throws Exception {
String fileName = KotlinTestUtils.navigationMetadata("plugins/android-extensions/android-extensions-compiler/testData/parcel/codegen/customDescribeContents.kt");
doTest(fileName);
}
@TestMetadata("customParcelablesDifferentModule.kt")
public void testCustomParcelablesDifferentModule() throws Exception {
String fileName = KotlinTestUtils.navigationMetadata("plugins/android-extensions/android-extensions-compiler/testData/parcel/codegen/customParcelablesDifferentModule.kt");
doTest(fileName);
}
@TestMetadata("customParcelablesSameModule.kt")
public void testCustomParcelablesSameModule() throws Exception {
String fileName = KotlinTestUtils.navigationMetadata("plugins/android-extensions/android-extensions-compiler/testData/parcel/codegen/customParcelablesSameModule.kt");
doTest(fileName);
}
@TestMetadata("customSimple.kt")
public void testCustomSimple() throws Exception {
String fileName = KotlinTestUtils.navigationMetadata("plugins/android-extensions/android-extensions-compiler/testData/parcel/codegen/customSimple.kt");
doTest(fileName);
}
@TestMetadata("customSimpleWithNewArray.kt")
public void testCustomSimpleWithNewArray() throws Exception {
String fileName = KotlinTestUtils.navigationMetadata("plugins/android-extensions/android-extensions-compiler/testData/parcel/codegen/customSimpleWithNewArray.kt");
doTest(fileName);
}
@TestMetadata("describeContentsFromSuperType.kt")
public void testDescribeContentsFromSuperType() throws Exception {
String fileName = KotlinTestUtils.navigationMetadata("plugins/android-extensions/android-extensions-compiler/testData/parcel/codegen/describeContentsFromSuperType.kt");
doTest(fileName);
}
@TestMetadata("duplicatingClinit.kt")
public void testDuplicatingClinit() throws Exception {
String fileName = KotlinTestUtils.navigationMetadata("plugins/android-extensions/android-extensions-compiler/testData/parcel/codegen/duplicatingClinit.kt");
doTest(fileName);
}
@TestMetadata("IBinderIInterface.kt")
public void testIBinderIInterface() throws Exception {
String fileName = KotlinTestUtils.navigationMetadata("plugins/android-extensions/android-extensions-compiler/testData/parcel/codegen/IBinderIInterface.kt");
doTest(fileName);
}
@TestMetadata("listInsideList.kt")
public void testListInsideList() throws Exception {
String fileName = KotlinTestUtils.navigationMetadata("plugins/android-extensions/android-extensions-compiler/testData/parcel/codegen/listInsideList.kt");
doTest(fileName);
}
@TestMetadata("nullableNotNullSize.kt")
public void testNullableNotNullSize() throws Exception {
String fileName = KotlinTestUtils.navigationMetadata("plugins/android-extensions/android-extensions-compiler/testData/parcel/codegen/nullableNotNullSize.kt");
doTest(fileName);
}
@TestMetadata("parcelable.kt")
public void testParcelable() throws Exception {
String fileName = KotlinTestUtils.navigationMetadata("plugins/android-extensions/android-extensions-compiler/testData/parcel/codegen/parcelable.kt");
doTest(fileName);
}
@TestMetadata("serializable.kt")
public void testSerializable() throws Exception {
String fileName = KotlinTestUtils.navigationMetadata("plugins/android-extensions/android-extensions-compiler/testData/parcel/codegen/serializable.kt");
doTest(fileName);
}
@TestMetadata("simple.kt")
public void testSimple() throws Exception {
String fileName = KotlinTestUtils.navigationMetadata("plugins/android-extensions/android-extensions-compiler/testData/parcel/codegen/simple.kt");
doTest(fileName);
}
@TestMetadata("simpleList.kt")
public void testSimpleList() throws Exception {
String fileName = KotlinTestUtils.navigationMetadata("plugins/android-extensions/android-extensions-compiler/testData/parcel/codegen/simpleList.kt");
doTest(fileName);
}
@TestMetadata("size.kt")
public void testSize() throws Exception {
String fileName = KotlinTestUtils.navigationMetadata("plugins/android-extensions/android-extensions-compiler/testData/parcel/codegen/size.kt");
doTest(fileName);
}
}
@@ -0,0 +1,170 @@
/*
* Copyright 2010-2017 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.android.synthetic.test;
import com.intellij.testFramework.TestDataPath;
import org.jetbrains.kotlin.test.JUnit3RunnerWithInners;
import org.jetbrains.kotlin.test.KotlinTestUtils;
import org.jetbrains.kotlin.test.TargetBackend;
import org.jetbrains.kotlin.test.TestMetadata;
import org.junit.runner.RunWith;
import java.io.File;
import java.util.regex.Pattern;
/** This class is generated by {@link org.jetbrains.kotlin.generators.tests.TestsPackage}. DO NOT MODIFY MANUALLY */
@SuppressWarnings("all")
@RunWith(JUnit3RunnerWithInners.class)
public class AndroidBoxTestGenerated extends AbstractAndroidBoxTest {
@TestMetadata("plugins/android-extensions/android-extensions-compiler/testData/codegen/android")
@TestDataPath("$PROJECT_ROOT")
@RunWith(JUnit3RunnerWithInners.class)
public static class Android extends AbstractAndroidBoxTest {
public void testAllFilesPresentInAndroid() throws Exception {
KotlinTestUtils.assertAllTestsPresentByMetadata(this.getClass(), new File("plugins/android-extensions/android-extensions-compiler/testData/codegen/android"), Pattern.compile("^([^\\.]+)$"), TargetBackend.ANY, false);
}
@TestMetadata("androidEntity")
public void testAndroidEntity() throws Exception {
String fileName = KotlinTestUtils.navigationMetadata("plugins/android-extensions/android-extensions-compiler/testData/codegen/android/androidEntity/");
doCompileAgainstAndroidSdkTest(fileName);
}
@TestMetadata("androidEntityInnerClass")
public void testAndroidEntityInnerClass() throws Exception {
String fileName = KotlinTestUtils.navigationMetadata("plugins/android-extensions/android-extensions-compiler/testData/codegen/android/androidEntityInnerClass/");
doCompileAgainstAndroidSdkTest(fileName);
}
@TestMetadata("fqNameInAttr")
public void testFqNameInAttr() throws Exception {
String fileName = KotlinTestUtils.navigationMetadata("plugins/android-extensions/android-extensions-compiler/testData/codegen/android/fqNameInAttr/");
doCompileAgainstAndroidSdkTest(fileName);
}
@TestMetadata("fqNameInTag")
public void testFqNameInTag() throws Exception {
String fileName = KotlinTestUtils.navigationMetadata("plugins/android-extensions/android-extensions-compiler/testData/codegen/android/fqNameInTag/");
doCompileAgainstAndroidSdkTest(fileName);
}
@TestMetadata("fragment")
public void testFragment() throws Exception {
String fileName = KotlinTestUtils.navigationMetadata("plugins/android-extensions/android-extensions-compiler/testData/codegen/android/fragment/");
doCompileAgainstAndroidSdkTest(fileName);
}
@TestMetadata("fragmentNoGetView")
public void testFragmentNoGetView() throws Exception {
String fileName = KotlinTestUtils.navigationMetadata("plugins/android-extensions/android-extensions-compiler/testData/codegen/android/fragmentNoGetView/");
doCompileAgainstAndroidSdkTest(fileName);
}
@TestMetadata("manyWidgets")
public void testManyWidgets() throws Exception {
String fileName = KotlinTestUtils.navigationMetadata("plugins/android-extensions/android-extensions-compiler/testData/codegen/android/manyWidgets/");
doCompileAgainstAndroidSdkTest(fileName);
}
@TestMetadata("multiFile")
public void testMultiFile() throws Exception {
String fileName = KotlinTestUtils.navigationMetadata("plugins/android-extensions/android-extensions-compiler/testData/codegen/android/multiFile/");
doCompileAgainstAndroidSdkTest(fileName);
}
@TestMetadata("singleFile")
public void testSingleFile() throws Exception {
String fileName = KotlinTestUtils.navigationMetadata("plugins/android-extensions/android-extensions-compiler/testData/codegen/android/singleFile/");
doCompileAgainstAndroidSdkTest(fileName);
}
@TestMetadata("view")
public void testView() throws Exception {
String fileName = KotlinTestUtils.navigationMetadata("plugins/android-extensions/android-extensions-compiler/testData/codegen/android/view/");
doCompileAgainstAndroidSdkTest(fileName);
}
}
@TestMetadata("plugins/android-extensions/android-extensions-compiler/testData/codegen/android")
@TestDataPath("$PROJECT_ROOT")
@RunWith(JUnit3RunnerWithInners.class)
public static class Invoke extends AbstractAndroidBoxTest {
public void testAllFilesPresentInInvoke() throws Exception {
KotlinTestUtils.assertAllTestsPresentByMetadata(this.getClass(), new File("plugins/android-extensions/android-extensions-compiler/testData/codegen/android"), Pattern.compile("^([^\\.]+)$"), TargetBackend.ANY, false);
}
@TestMetadata("androidEntity")
public void testAndroidEntity() throws Exception {
String fileName = KotlinTestUtils.navigationMetadata("plugins/android-extensions/android-extensions-compiler/testData/codegen/android/androidEntity/");
doFakeInvocationTest(fileName);
}
@TestMetadata("androidEntityInnerClass")
public void testAndroidEntityInnerClass() throws Exception {
String fileName = KotlinTestUtils.navigationMetadata("plugins/android-extensions/android-extensions-compiler/testData/codegen/android/androidEntityInnerClass/");
doFakeInvocationTest(fileName);
}
@TestMetadata("fqNameInAttr")
public void testFqNameInAttr() throws Exception {
String fileName = KotlinTestUtils.navigationMetadata("plugins/android-extensions/android-extensions-compiler/testData/codegen/android/fqNameInAttr/");
doFakeInvocationTest(fileName);
}
@TestMetadata("fqNameInTag")
public void testFqNameInTag() throws Exception {
String fileName = KotlinTestUtils.navigationMetadata("plugins/android-extensions/android-extensions-compiler/testData/codegen/android/fqNameInTag/");
doFakeInvocationTest(fileName);
}
@TestMetadata("fragment")
public void testFragment() throws Exception {
String fileName = KotlinTestUtils.navigationMetadata("plugins/android-extensions/android-extensions-compiler/testData/codegen/android/fragment/");
doFakeInvocationTest(fileName);
}
@TestMetadata("fragmentNoGetView")
public void testFragmentNoGetView() throws Exception {
String fileName = KotlinTestUtils.navigationMetadata("plugins/android-extensions/android-extensions-compiler/testData/codegen/android/fragmentNoGetView/");
doFakeInvocationTest(fileName);
}
@TestMetadata("manyWidgets")
public void testManyWidgets() throws Exception {
String fileName = KotlinTestUtils.navigationMetadata("plugins/android-extensions/android-extensions-compiler/testData/codegen/android/manyWidgets/");
doFakeInvocationTest(fileName);
}
@TestMetadata("multiFile")
public void testMultiFile() throws Exception {
String fileName = KotlinTestUtils.navigationMetadata("plugins/android-extensions/android-extensions-compiler/testData/codegen/android/multiFile/");
doFakeInvocationTest(fileName);
}
@TestMetadata("singleFile")
public void testSingleFile() throws Exception {
String fileName = KotlinTestUtils.navigationMetadata("plugins/android-extensions/android-extensions-compiler/testData/codegen/android/singleFile/");
doFakeInvocationTest(fileName);
}
@TestMetadata("view")
public void testView() throws Exception {
String fileName = KotlinTestUtils.navigationMetadata("plugins/android-extensions/android-extensions-compiler/testData/codegen/android/view/");
doFakeInvocationTest(fileName);
}
}
}
@@ -0,0 +1,218 @@
/*
* Copyright 2010-2017 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.android.synthetic.test;
import com.intellij.testFramework.TestDataPath;
import org.jetbrains.kotlin.test.JUnit3RunnerWithInners;
import org.jetbrains.kotlin.test.KotlinTestUtils;
import org.jetbrains.kotlin.test.TargetBackend;
import org.jetbrains.kotlin.test.TestMetadata;
import org.junit.runner.RunWith;
import java.io.File;
import java.util.regex.Pattern;
/** This class is generated by {@link org.jetbrains.kotlin.generators.tests.TestsPackage}. DO NOT MODIFY MANUALLY */
@SuppressWarnings("all")
@TestMetadata("plugins/android-extensions/android-extensions-compiler/testData/codegen/bytecodeShape")
@TestDataPath("$PROJECT_ROOT")
@RunWith(JUnit3RunnerWithInners.class)
public class AndroidBytecodeShapeTestGenerated extends AbstractAndroidBytecodeShapeTest {
@TestMetadata("activityWithEntityOptionsNoCache")
public void testActivityWithEntityOptionsNoCache() throws Exception {
String fileName = KotlinTestUtils.navigationMetadata("plugins/android-extensions/android-extensions-compiler/testData/codegen/bytecodeShape/activityWithEntityOptionsNoCache/");
doTest(fileName);
}
public void testAllFilesPresentInBytecodeShape() throws Exception {
KotlinTestUtils.assertAllTestsPresentByMetadata(this.getClass(), new File("plugins/android-extensions/android-extensions-compiler/testData/codegen/bytecodeShape"), Pattern.compile("^([^\\.]+)$"), TargetBackend.ANY, false);
}
@TestMetadata("baseClass")
public void testBaseClass() throws Exception {
String fileName = KotlinTestUtils.navigationMetadata("plugins/android-extensions/android-extensions-compiler/testData/codegen/bytecodeShape/baseClass/");
doTest(fileName);
}
@TestMetadata("baseClassFragment")
public void testBaseClassFragment() throws Exception {
String fileName = KotlinTestUtils.navigationMetadata("plugins/android-extensions/android-extensions-compiler/testData/codegen/bytecodeShape/baseClassFragment/");
doTest(fileName);
}
@TestMetadata("clearCache")
public void testClearCache() throws Exception {
String fileName = KotlinTestUtils.navigationMetadata("plugins/android-extensions/android-extensions-compiler/testData/codegen/bytecodeShape/clearCache/");
doTest(fileName);
}
@TestMetadata("clearCacheBaseClass")
public void testClearCacheBaseClass() throws Exception {
String fileName = KotlinTestUtils.navigationMetadata("plugins/android-extensions/android-extensions-compiler/testData/codegen/bytecodeShape/clearCacheBaseClass/");
doTest(fileName);
}
@TestMetadata("dialog")
public void testDialog() throws Exception {
String fileName = KotlinTestUtils.navigationMetadata("plugins/android-extensions/android-extensions-compiler/testData/codegen/bytecodeShape/dialog/");
doTest(fileName);
}
@TestMetadata("extensionFunctions")
public void testExtensionFunctions() throws Exception {
String fileName = KotlinTestUtils.navigationMetadata("plugins/android-extensions/android-extensions-compiler/testData/codegen/bytecodeShape/extensionFunctions/");
doTest(fileName);
}
@TestMetadata("extensionFunctionsFragment")
public void testExtensionFunctionsFragment() throws Exception {
String fileName = KotlinTestUtils.navigationMetadata("plugins/android-extensions/android-extensions-compiler/testData/codegen/bytecodeShape/extensionFunctionsFragment/");
doTest(fileName);
}
@TestMetadata("extensionFunctionsView")
public void testExtensionFunctionsView() throws Exception {
String fileName = KotlinTestUtils.navigationMetadata("plugins/android-extensions/android-extensions-compiler/testData/codegen/bytecodeShape/extensionFunctionsView/");
doTest(fileName);
}
@TestMetadata("fqNameInAttr")
public void testFqNameInAttr() throws Exception {
String fileName = KotlinTestUtils.navigationMetadata("plugins/android-extensions/android-extensions-compiler/testData/codegen/bytecodeShape/fqNameInAttr/");
doTest(fileName);
}
@TestMetadata("fqNameInAttrFragment")
public void testFqNameInAttrFragment() throws Exception {
String fileName = KotlinTestUtils.navigationMetadata("plugins/android-extensions/android-extensions-compiler/testData/codegen/bytecodeShape/fqNameInAttrFragment/");
doTest(fileName);
}
@TestMetadata("fqNameInTag")
public void testFqNameInTag() throws Exception {
String fileName = KotlinTestUtils.navigationMetadata("plugins/android-extensions/android-extensions-compiler/testData/codegen/bytecodeShape/fqNameInTag/");
doTest(fileName);
}
@TestMetadata("fqNameInTagFragment")
public void testFqNameInTagFragment() throws Exception {
String fileName = KotlinTestUtils.navigationMetadata("plugins/android-extensions/android-extensions-compiler/testData/codegen/bytecodeShape/fqNameInTagFragment/");
doTest(fileName);
}
@TestMetadata("fragmentWithEntityOptionsNoCache")
public void testFragmentWithEntityOptionsNoCache() throws Exception {
String fileName = KotlinTestUtils.navigationMetadata("plugins/android-extensions/android-extensions-compiler/testData/codegen/bytecodeShape/fragmentWithEntityOptionsNoCache/");
doTest(fileName);
}
@TestMetadata("kt18545")
public void testKt18545() throws Exception {
String fileName = KotlinTestUtils.navigationMetadata("plugins/android-extensions/android-extensions-compiler/testData/codegen/bytecodeShape/kt18545/");
doTest(fileName);
}
@TestMetadata("multiFile")
public void testMultiFile() throws Exception {
String fileName = KotlinTestUtils.navigationMetadata("plugins/android-extensions/android-extensions-compiler/testData/codegen/bytecodeShape/multiFile/");
doTest(fileName);
}
@TestMetadata("multiFileFragment")
public void testMultiFileFragment() throws Exception {
String fileName = KotlinTestUtils.navigationMetadata("plugins/android-extensions/android-extensions-compiler/testData/codegen/bytecodeShape/multiFileFragment/");
doTest(fileName);
}
@TestMetadata("onDestroyFragment")
public void testOnDestroyFragment() throws Exception {
String fileName = KotlinTestUtils.navigationMetadata("plugins/android-extensions/android-extensions-compiler/testData/codegen/bytecodeShape/onDestroyFragment/");
doTest(fileName);
}
@TestMetadata("simple")
public void testSimple() throws Exception {
String fileName = KotlinTestUtils.navigationMetadata("plugins/android-extensions/android-extensions-compiler/testData/codegen/bytecodeShape/simple/");
doTest(fileName);
}
@TestMetadata("simpleFragment")
public void testSimpleFragment() throws Exception {
String fileName = KotlinTestUtils.navigationMetadata("plugins/android-extensions/android-extensions-compiler/testData/codegen/bytecodeShape/simpleFragment/");
doTest(fileName);
}
@TestMetadata("simpleFragmentProperty")
public void testSimpleFragmentProperty() throws Exception {
String fileName = KotlinTestUtils.navigationMetadata("plugins/android-extensions/android-extensions-compiler/testData/codegen/bytecodeShape/simpleFragmentProperty/");
doTest(fileName);
}
@TestMetadata("simpleHashMapCacheImplementation")
public void testSimpleHashMapCacheImplementation() throws Exception {
String fileName = KotlinTestUtils.navigationMetadata("plugins/android-extensions/android-extensions-compiler/testData/codegen/bytecodeShape/simpleHashMapCacheImplementation/");
doTest(fileName);
}
@TestMetadata("simpleView")
public void testSimpleView() throws Exception {
String fileName = KotlinTestUtils.navigationMetadata("plugins/android-extensions/android-extensions-compiler/testData/codegen/bytecodeShape/simpleView/");
doTest(fileName);
}
@TestMetadata("supportExtensionFunctionsFragment")
public void testSupportExtensionFunctionsFragment() throws Exception {
String fileName = KotlinTestUtils.navigationMetadata("plugins/android-extensions/android-extensions-compiler/testData/codegen/bytecodeShape/supportExtensionFunctionsFragment/");
doTest(fileName);
}
@TestMetadata("supportSimpleFragment")
public void testSupportSimpleFragment() throws Exception {
String fileName = KotlinTestUtils.navigationMetadata("plugins/android-extensions/android-extensions-compiler/testData/codegen/bytecodeShape/supportSimpleFragment/");
doTest(fileName);
}
@TestMetadata("supportSimpleFragmentProperty")
public void testSupportSimpleFragmentProperty() throws Exception {
String fileName = KotlinTestUtils.navigationMetadata("plugins/android-extensions/android-extensions-compiler/testData/codegen/bytecodeShape/supportSimpleFragmentProperty/");
doTest(fileName);
}
@TestMetadata("viewStub")
public void testViewStub() throws Exception {
String fileName = KotlinTestUtils.navigationMetadata("plugins/android-extensions/android-extensions-compiler/testData/codegen/bytecodeShape/viewStub/");
doTest(fileName);
}
@TestMetadata("viewWithCache")
public void testViewWithCache() throws Exception {
String fileName = KotlinTestUtils.navigationMetadata("plugins/android-extensions/android-extensions-compiler/testData/codegen/bytecodeShape/viewWithCache/");
doTest(fileName);
}
@TestMetadata("viewWithDefaultNoCache")
public void testViewWithDefaultNoCache() throws Exception {
String fileName = KotlinTestUtils.navigationMetadata("plugins/android-extensions/android-extensions-compiler/testData/codegen/bytecodeShape/viewWithDefaultNoCache/");
doTest(fileName);
}
@TestMetadata("viewWithEntityOptionsNoCache")
public void testViewWithEntityOptionsNoCache() throws Exception {
String fileName = KotlinTestUtils.navigationMetadata("plugins/android-extensions/android-extensions-compiler/testData/codegen/bytecodeShape/viewWithEntityOptionsNoCache/");
doTest(fileName);
}
}
@@ -0,0 +1,134 @@
/*
* Copyright 2010-2017 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.android.synthetic.test;
import com.intellij.testFramework.TestDataPath;
import org.jetbrains.kotlin.test.JUnit3RunnerWithInners;
import org.jetbrains.kotlin.test.KotlinTestUtils;
import org.jetbrains.kotlin.test.TargetBackend;
import org.jetbrains.kotlin.test.TestMetadata;
import org.junit.runner.RunWith;
import java.io.File;
import java.util.regex.Pattern;
/** This class is generated by {@link org.jetbrains.kotlin.generators.tests.TestsPackage}. DO NOT MODIFY MANUALLY */
@SuppressWarnings("all")
@TestMetadata("plugins/android-extensions/android-extensions-compiler/testData/descriptors")
@TestDataPath("$PROJECT_ROOT")
@RunWith(JUnit3RunnerWithInners.class)
public class AndroidSyntheticPropertyDescriptorTestGenerated extends AbstractAndroidSyntheticPropertyDescriptorTest {
public void testAllFilesPresentInDescriptors() throws Exception {
KotlinTestUtils.assertAllTestsPresentByMetadata(this.getClass(), new File("plugins/android-extensions/android-extensions-compiler/testData/descriptors"), Pattern.compile("^([^\\.]+)$"), TargetBackend.ANY, false);
}
@TestMetadata("escapedLayoutName")
public void testEscapedLayoutName() throws Exception {
String fileName = KotlinTestUtils.navigationMetadata("plugins/android-extensions/android-extensions-compiler/testData/descriptors/escapedLayoutName/");
doTest(fileName);
}
@TestMetadata("fqNameInAttr")
public void testFqNameInAttr() throws Exception {
String fileName = KotlinTestUtils.navigationMetadata("plugins/android-extensions/android-extensions-compiler/testData/descriptors/fqNameInAttr/");
doTest(fileName);
}
@TestMetadata("fqNameInTag")
public void testFqNameInTag() throws Exception {
String fileName = KotlinTestUtils.navigationMetadata("plugins/android-extensions/android-extensions-compiler/testData/descriptors/fqNameInTag/");
doTest(fileName);
}
@TestMetadata("layoutVariants")
public void testLayoutVariants() throws Exception {
String fileName = KotlinTestUtils.navigationMetadata("plugins/android-extensions/android-extensions-compiler/testData/descriptors/layoutVariants/");
doTest(fileName);
}
@TestMetadata("multiFile")
public void testMultiFile() throws Exception {
String fileName = KotlinTestUtils.navigationMetadata("plugins/android-extensions/android-extensions-compiler/testData/descriptors/multiFile/");
doTest(fileName);
}
@TestMetadata("noIds")
public void testNoIds() throws Exception {
String fileName = KotlinTestUtils.navigationMetadata("plugins/android-extensions/android-extensions-compiler/testData/descriptors/noIds/");
doTest(fileName);
}
@TestMetadata("nonLatinNames")
public void testNonLatinNames() throws Exception {
String fileName = KotlinTestUtils.navigationMetadata("plugins/android-extensions/android-extensions-compiler/testData/descriptors/nonLatinNames/");
doTest(fileName);
}
@TestMetadata("sameIds")
public void testSameIds() throws Exception {
String fileName = KotlinTestUtils.navigationMetadata("plugins/android-extensions/android-extensions-compiler/testData/descriptors/sameIds/");
doTest(fileName);
}
@TestMetadata("severalResDirs")
public void testSeveralResDirs() throws Exception {
String fileName = KotlinTestUtils.navigationMetadata("plugins/android-extensions/android-extensions-compiler/testData/descriptors/severalResDirs/");
doTest(fileName);
}
@TestMetadata("singleFile")
public void testSingleFile() throws Exception {
String fileName = KotlinTestUtils.navigationMetadata("plugins/android-extensions/android-extensions-compiler/testData/descriptors/singleFile/");
doTest(fileName);
}
@TestMetadata("specialTags")
public void testSpecialTags() throws Exception {
String fileName = KotlinTestUtils.navigationMetadata("plugins/android-extensions/android-extensions-compiler/testData/descriptors/specialTags/");
doTest(fileName);
}
@TestMetadata("supportSingleFile")
public void testSupportSingleFile() throws Exception {
String fileName = KotlinTestUtils.navigationMetadata("plugins/android-extensions/android-extensions-compiler/testData/descriptors/supportSingleFile/");
doTest(fileName);
}
@TestMetadata("supportSpecialTags")
public void testSupportSpecialTags() throws Exception {
String fileName = KotlinTestUtils.navigationMetadata("plugins/android-extensions/android-extensions-compiler/testData/descriptors/supportSpecialTags/");
doTest(fileName);
}
@TestMetadata("unresolvedFqName")
public void testUnresolvedFqName() throws Exception {
String fileName = KotlinTestUtils.navigationMetadata("plugins/android-extensions/android-extensions-compiler/testData/descriptors/unresolvedFqName/");
doTest(fileName);
}
@TestMetadata("unresolvedWidget")
public void testUnresolvedWidget() throws Exception {
String fileName = KotlinTestUtils.navigationMetadata("plugins/android-extensions/android-extensions-compiler/testData/descriptors/unresolvedWidget/");
doTest(fileName);
}
@TestMetadata("viewStub")
public void testViewStub() throws Exception {
String fileName = KotlinTestUtils.navigationMetadata("plugins/android-extensions/android-extensions-compiler/testData/descriptors/viewStub/");
doTest(fileName);
}
}