add android bytecode persistence test

This commit is contained in:
Mikhail Mutcianko
2014-09-18 16:25:14 +04:00
committed by Yan Zhulanow
parent 2643866e31
commit bf25dffb85
13 changed files with 277 additions and 0 deletions
@@ -0,0 +1,49 @@
/*
* Copyright 2010-2014 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.jet.lang.resolve.android
import org.jetbrains.jet.codegen.AbstractBytecodeTextTest
import org.jetbrains.jet.JetTestUtils
import org.jetbrains.jet.ConfigurationKind
import org.jetbrains.jet.TestJdkKind
import org.jetbrains.jet.config.CompilerConfiguration
import org.jetbrains.jet.cli.jvm.JVMConfigurationKeys
import org.jetbrains.jet.cli.jvm.compiler.JetCoreEnvironment
public abstract class AbstractAndroidBytecodePersistenceTest : AbstractBytecodeTextTest() {
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 + "res/layout/");
configuration.put(JVMConfigurationKeys.ANDROID_MANIFEST, path + "../AndroidManifest.xml");
myEnvironment = JetCoreEnvironment.createForTests(getTestRootDisposable()!!, configuration);
}
public override fun doTest(path: String) {
val fileName = path + getTestName(true) + ".kt"
createAndroidAPIEnvironment(path)
loadFileByFullPath(fileName)
val expected = readExpectedOccurrences(fileName)
countAndCompareActualOccurrences(expected)
}
}
@@ -0,0 +1,62 @@
/*
* Copyright 2010-2014 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.jet.lang.resolve.android;
import com.intellij.testFramework.TestDataPath;
import junit.framework.Test;
import junit.framework.TestSuite;
import org.jetbrains.jet.JetTestUtils;
import org.jetbrains.jet.test.InnerTestClasses;
import org.jetbrains.jet.test.TestMetadata;
import java.io.File;
import java.util.regex.Pattern;
/** This class is generated by {@link org.jetbrains.jet.generators.tests.TestsPackage}. DO NOT MODIFY MANUALLY */
@SuppressWarnings("all")
@TestMetadata("compiler/testData/codegen/androidPersistence")
@TestDataPath("$PROJECT_ROOT")
public class AndroidBytecodePersistenceTestGenerated extends AbstractAndroidBytecodePersistenceTest {
public void testAllFilesPresentInAndroidPersistence() throws Exception {
JetTestUtils.assertAllTestsPresentByMetadata(this.getClass(), new File("compiler/testData/codegen/androidPersistence"), Pattern.compile("^([^\\.]+)$"), false);
}
@TestMetadata("fqNameInAttr")
public void testFqNameInAttr() throws Exception {
String fileName = JetTestUtils.navigationMetadata("compiler/testData/codegen/androidPersistence/fqNameInAttr/");
doTest(fileName);
}
@TestMetadata("fqNameInTag")
public void testFqNameInTag() throws Exception {
String fileName = JetTestUtils.navigationMetadata("compiler/testData/codegen/androidPersistence/fqNameInTag/");
doTest(fileName);
}
@TestMetadata("multiFile")
public void testMultiFile() throws Exception {
String fileName = JetTestUtils.navigationMetadata("compiler/testData/codegen/androidPersistence/multiFile/");
doTest(fileName);
}
@TestMetadata("simple")
public void testSimple() throws Exception {
String fileName = JetTestUtils.navigationMetadata("compiler/testData/codegen/androidPersistence/simple/");
doTest(fileName);
}
}