add android properties box tests
This commit is contained in:
committed by
Yan Zhulanow
parent
f2ab424c41
commit
08245ffe1c
@@ -18,7 +18,6 @@ package org.jetbrains.jet.lang.resolve.android
|
||||
|
||||
import org.jetbrains.jet.codegen.generated.AbstractBlackBoxCodegenTest
|
||||
import org.jetbrains.jet.ConfigurationKind
|
||||
import com.intellij.compiler.CompilerConfiguration
|
||||
import org.jetbrains.jet.TestJdkKind
|
||||
import org.jetbrains.jet.cli.jvm.JVMConfigurationKeys
|
||||
import org.jetbrains.jet.cli.jvm.compiler.JetCoreEnvironment
|
||||
@@ -30,30 +29,62 @@ import java.io.File
|
||||
import java.util.ArrayList
|
||||
import com.intellij.util.Processor
|
||||
import org.jetbrains.jet.codegen.CodegenTestFiles
|
||||
import java.util.regex.Pattern
|
||||
import org.jetbrains.jet.config.CompilerConfiguration
|
||||
|
||||
public abstract class AbstractAndroidBoxTest : AbstractBlackBoxCodegenTest() {
|
||||
|
||||
fun createEnvironment(path: String) {
|
||||
val configuration = JetTestUtils.compilerConfigurationForTests(ConfigurationKind.ALL, TestJdkKind.ANDROID_API);
|
||||
private fun createAndroidAPIEnvironment(path: String) {
|
||||
return createEnvironmentForConfiguration(JetTestUtils.compilerConfigurationForTests(ConfigurationKind.ALL, TestJdkKind.ANDROID_API), path)
|
||||
}
|
||||
|
||||
private fun createFakeAndroidEnvironment(path: String) {
|
||||
return createEnvironmentForConfiguration(JetTestUtils.compilerConfigurationForTests(ConfigurationKind.ALL, TestJdkKind.MOCK_JDK), path)
|
||||
}
|
||||
|
||||
private fun createEnvironmentForConfiguration(configuration: CompilerConfiguration, path: String) {
|
||||
configuration.put(JVMConfigurationKeys.ANDROID_RES_PATH, path + "layout/");
|
||||
configuration.put(JVMConfigurationKeys.ANDROID_MANIFEST, path + "AndroidManifest.xml");
|
||||
myEnvironment = JetCoreEnvironment.createForTests(getTestRootDisposable()!!, configuration);
|
||||
}
|
||||
|
||||
override fun doTest(path: String) {
|
||||
createEnvironment(path)
|
||||
public fun doCompileAgainstAndroidSdkTest(path: String) {
|
||||
createAndroidAPIEnvironment(path)
|
||||
doMultiFileTest(path)
|
||||
}
|
||||
|
||||
public fun doFakeInvocationTest(path: String) {
|
||||
if (needsInvocationTest(path)) {
|
||||
createFakeAndroidEnvironment(path)
|
||||
doMultiFileTest(path, getFakeFiles(path))
|
||||
}
|
||||
}
|
||||
|
||||
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)).empty
|
||||
}
|
||||
|
||||
private fun doMultiFileTest(path: String, additionalFiles: Collection<String>? = null) {
|
||||
val files = ArrayList<String>(2)
|
||||
FileUtil.processFilesRecursively(File(path), object : Processor<File> {
|
||||
override fun process(file: File?): Boolean {
|
||||
if (file!!.getName().endsWith(".kt")) {
|
||||
files.add(relativePath(file))
|
||||
when (file!!.getName()) {
|
||||
"1.kt" -> { if (additionalFiles == null) files.add(relativePath(file)) }
|
||||
"0.kt" -> { if (additionalFiles != null) files.add(relativePath(file)) }
|
||||
else -> { if (file.getName().endsWith(".kt")) files.add(relativePath(file)) }
|
||||
}
|
||||
return true
|
||||
}
|
||||
})
|
||||
Collections.sort(files);
|
||||
if (additionalFiles != null) {
|
||||
files.addAll(additionalFiles)
|
||||
}
|
||||
myFiles = CodegenTestFiles.create(myEnvironment!!.getProject(), ArrayUtil.toStringArray(files))
|
||||
blackBox();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
+68
-25
@@ -30,35 +30,78 @@ import org.jetbrains.jet.lang.resolve.android.AbstractAndroidBoxTest;
|
||||
|
||||
/** This class is generated by {@link org.jetbrains.jet.generators.tests.TestsPackage}. DO NOT MODIFY MANUALLY */
|
||||
@SuppressWarnings("all")
|
||||
@TestMetadata("compiler/testData/codegen/android")
|
||||
@InnerTestClasses({AndroidBoxTestGenerated.Android.class, AndroidBoxTestGenerated.Invoke.class})
|
||||
public class AndroidBoxTestGenerated extends AbstractAndroidBoxTest {
|
||||
public void testAllFilesPresentInAndroid() throws Exception {
|
||||
JetTestUtils.assertAllTestsPresentByMetadata(this.getClass(), "org.jetbrains.jet.generators.tests.TestsPackage", new File("compiler/testData/codegen/android"), Pattern.compile("^([^\\.]+)$"), false);
|
||||
@TestMetadata("compiler/testData/codegen/android")
|
||||
public static class Android extends AbstractAndroidBoxTest {
|
||||
public void testAllFilesPresentInAndroid() throws Exception {
|
||||
JetTestUtils.assertAllTestsPresentByMetadata(this.getClass(), "org.jetbrains.jet.generators.tests.TestsPackage", new File("compiler/testData/codegen/android"), Pattern.compile("^([^\\.]+)$"), false);
|
||||
}
|
||||
|
||||
@TestMetadata("fqNameInAttr")
|
||||
public void testFqNameInAttr() throws Exception {
|
||||
doCompileAgainstAndroidSdkTest("compiler/testData/codegen/android/fqNameInAttr/");
|
||||
}
|
||||
|
||||
@TestMetadata("fqNameInTag")
|
||||
public void testFqNameInTag() throws Exception {
|
||||
doCompileAgainstAndroidSdkTest("compiler/testData/codegen/android/fqNameInTag/");
|
||||
}
|
||||
|
||||
@TestMetadata("manyWidgets")
|
||||
public void testManyWidgets() throws Exception {
|
||||
doCompileAgainstAndroidSdkTest("compiler/testData/codegen/android/manyWidgets/");
|
||||
}
|
||||
|
||||
@TestMetadata("multiFile")
|
||||
public void testMultiFile() throws Exception {
|
||||
doCompileAgainstAndroidSdkTest("compiler/testData/codegen/android/multiFile/");
|
||||
}
|
||||
|
||||
@TestMetadata("singleFile")
|
||||
public void testSingleFile() throws Exception {
|
||||
doCompileAgainstAndroidSdkTest("compiler/testData/codegen/android/singleFile/");
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@TestMetadata("fqNameInAttr")
|
||||
public void testFqNameInAttr() throws Exception {
|
||||
doTest("compiler/testData/codegen/android/fqNameInAttr/");
|
||||
@TestMetadata("compiler/testData/codegen/android")
|
||||
public static class Invoke extends AbstractAndroidBoxTest {
|
||||
public void testAllFilesPresentInInvoke() throws Exception {
|
||||
JetTestUtils.assertAllTestsPresentByMetadata(this.getClass(), "org.jetbrains.jet.generators.tests.TestsPackage", new File("compiler/testData/codegen/android"), Pattern.compile("^([^\\.]+)$"), false);
|
||||
}
|
||||
|
||||
@TestMetadata("fqNameInAttr")
|
||||
public void testFqNameInAttr() throws Exception {
|
||||
doFakeInvocationTest("compiler/testData/codegen/android/fqNameInAttr/");
|
||||
}
|
||||
|
||||
@TestMetadata("fqNameInTag")
|
||||
public void testFqNameInTag() throws Exception {
|
||||
doFakeInvocationTest("compiler/testData/codegen/android/fqNameInTag/");
|
||||
}
|
||||
|
||||
@TestMetadata("manyWidgets")
|
||||
public void testManyWidgets() throws Exception {
|
||||
doFakeInvocationTest("compiler/testData/codegen/android/manyWidgets/");
|
||||
}
|
||||
|
||||
@TestMetadata("multiFile")
|
||||
public void testMultiFile() throws Exception {
|
||||
doFakeInvocationTest("compiler/testData/codegen/android/multiFile/");
|
||||
}
|
||||
|
||||
@TestMetadata("singleFile")
|
||||
public void testSingleFile() throws Exception {
|
||||
doFakeInvocationTest("compiler/testData/codegen/android/singleFile/");
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@TestMetadata("fqNameInTag")
|
||||
public void testFqNameInTag() throws Exception {
|
||||
doTest("compiler/testData/codegen/android/fqNameInTag/");
|
||||
public static Test suite() {
|
||||
TestSuite suite = new TestSuite("AndroidBoxTestGenerated");
|
||||
suite.addTestSuite(Android.class);
|
||||
suite.addTestSuite(Invoke.class);
|
||||
return suite;
|
||||
}
|
||||
|
||||
@TestMetadata("manyWidgets")
|
||||
public void testManyWidgets() throws Exception {
|
||||
doTest("compiler/testData/codegen/android/manyWidgets/");
|
||||
}
|
||||
|
||||
@TestMetadata("multiFile")
|
||||
public void testMultiFile() throws Exception {
|
||||
doTest("compiler/testData/codegen/android/multiFile/");
|
||||
}
|
||||
|
||||
@TestMetadata("singleFile")
|
||||
public void testSingleFile() throws Exception {
|
||||
doTest("compiler/testData/codegen/android/singleFile/");
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user