diff --git a/compiler/testData/codegen/android/fqNameInAttr/1.kt b/compiler/testData/codegen/android/fqNameInAttr/1.kt
new file mode 100644
index 00000000000..d7202aa8c72
--- /dev/null
+++ b/compiler/testData/codegen/android/fqNameInAttr/1.kt
@@ -0,0 +1,29 @@
+package com.myapp
+
+import android.app.Activity
+import android.view.View
+import android.widget.*
+import org.my.cool.MyButton
+
+class R {
+ class id {
+ class object {
+ val login = 5
+ }
+ }
+}
+
+class MyActivity(): Activity() {
+ val buttonWidget = MyButton(this)
+
+ override fun findViewById(id: Int): View? {
+ return when (id) {
+ R.id.login -> buttonWidget
+ else -> null
+ }
+ }
+}
+
+fun box(): String {
+ return "OK"
+}
diff --git a/compiler/testData/codegen/android/fqNameInAttr/AndroidManifest.xml b/compiler/testData/codegen/android/fqNameInAttr/AndroidManifest.xml
new file mode 100644
index 00000000000..580c474f5de
--- /dev/null
+++ b/compiler/testData/codegen/android/fqNameInAttr/AndroidManifest.xml
@@ -0,0 +1,33 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/compiler/testData/codegen/android/fqNameInAttr/CustomWidgets.kt b/compiler/testData/codegen/android/fqNameInAttr/CustomWidgets.kt
new file mode 100644
index 00000000000..cf15bfe703e
--- /dev/null
+++ b/compiler/testData/codegen/android/fqNameInAttr/CustomWidgets.kt
@@ -0,0 +1,8 @@
+package org.my.cool
+
+import android.widget.Button
+import android.app.Activity
+
+class MyButton(ctx: Activity): Button(ctx) {
+ override fun toString(): String {return "Button"}
+}
diff --git a/compiler/testData/codegen/android/fqNameInAttr/layout/layout.xml b/compiler/testData/codegen/android/fqNameInAttr/layout/layout.xml
new file mode 100644
index 00000000000..101bb490115
--- /dev/null
+++ b/compiler/testData/codegen/android/fqNameInAttr/layout/layout.xml
@@ -0,0 +1,15 @@
+
+
+
+
+
diff --git a/compiler/testData/codegen/android/fqNameInTag/1.kt b/compiler/testData/codegen/android/fqNameInTag/1.kt
new file mode 100644
index 00000000000..9f597fb6c3e
--- /dev/null
+++ b/compiler/testData/codegen/android/fqNameInTag/1.kt
@@ -0,0 +1,29 @@
+package com.myapp
+
+import android.app.Activity
+import android.view.View
+import android.widget.*
+import org.my.cool.MyButton
+
+class R {
+ class id {
+ class object {
+ val login = 5
+ }
+ }
+}
+
+class MyActivity(): Activity() {
+ val buttonWidget = Button(this)
+
+ override fun findViewById(id: Int): View? {
+ return when (id) {
+ R.id.login -> buttonWidget
+ else -> null
+ }
+ }
+}
+
+fun box(): String {
+ return "OK"
+}
diff --git a/compiler/testData/codegen/android/fqNameInTag/AndroidManifest.xml b/compiler/testData/codegen/android/fqNameInTag/AndroidManifest.xml
new file mode 100644
index 00000000000..580c474f5de
--- /dev/null
+++ b/compiler/testData/codegen/android/fqNameInTag/AndroidManifest.xml
@@ -0,0 +1,33 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/compiler/testData/codegen/android/fqNameInTag/CustomWidgets.kt b/compiler/testData/codegen/android/fqNameInTag/CustomWidgets.kt
new file mode 100644
index 00000000000..59c3b9ff5be
--- /dev/null
+++ b/compiler/testData/codegen/android/fqNameInTag/CustomWidgets.kt
@@ -0,0 +1,8 @@
+package org.my.cool
+
+import android.widget.Button
+import android.content.Context
+
+class MyButton(ctx: Context): Button(ctx) {
+ override fun toString(): String {return "Button"}
+}
diff --git a/compiler/testData/codegen/android/fqNameInTag/layout/layout.xml b/compiler/testData/codegen/android/fqNameInTag/layout/layout.xml
new file mode 100644
index 00000000000..27907c09826
--- /dev/null
+++ b/compiler/testData/codegen/android/fqNameInTag/layout/layout.xml
@@ -0,0 +1,14 @@
+
+
+
+
+
diff --git a/compiler/testData/codegen/android/manyWidgets/1.kt b/compiler/testData/codegen/android/manyWidgets/1.kt
new file mode 100644
index 00000000000..bdc79a107c2
--- /dev/null
+++ b/compiler/testData/codegen/android/manyWidgets/1.kt
@@ -0,0 +1 @@
+fun box() = "OK"
diff --git a/compiler/testData/codegen/android/manyWidgets/AndroidManifest.xml b/compiler/testData/codegen/android/manyWidgets/AndroidManifest.xml
new file mode 100644
index 00000000000..580c474f5de
--- /dev/null
+++ b/compiler/testData/codegen/android/manyWidgets/AndroidManifest.xml
@@ -0,0 +1,33 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/compiler/testData/codegen/android/manyWidgets/layout/layout.xml b/compiler/testData/codegen/android/manyWidgets/layout/layout.xml
new file mode 100644
index 00000000000..6ca5e004050
--- /dev/null
+++ b/compiler/testData/codegen/android/manyWidgets/layout/layout.xml
@@ -0,0 +1,67 @@
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/compiler/testData/codegen/android/multiFile/1.kt b/compiler/testData/codegen/android/multiFile/1.kt
new file mode 100644
index 00000000000..246b6dee346
--- /dev/null
+++ b/compiler/testData/codegen/android/multiFile/1.kt
@@ -0,0 +1,37 @@
+package com.myapp
+
+import android.app.Activity
+import android.view.View
+import android.widget.*
+
+class R {
+ class id {
+ class object {
+ val item_detail_container = 0
+ val textView1 = 1
+ val password = 2
+ val textView2 = 3
+ val passwordConfirmation = 4
+ val login = 5
+ }
+ }
+}
+
+class MyActivity(): Activity() {
+ val textViewWidget = TextView(this)
+ val editTextWidget = EditText(this)
+ val buttonWidget = Button(this)
+
+ override fun findViewById(id: Int): View? {
+ return when (id) {
+ R.id.textView1 -> textViewWidget
+ R.id.password -> editTextWidget
+ R.id.login -> buttonWidget
+ else -> null
+ }
+ }
+}
+
+fun box(): String {
+ return "OK"
+}
diff --git a/compiler/testData/codegen/android/multiFile/AndroidManifest.xml b/compiler/testData/codegen/android/multiFile/AndroidManifest.xml
new file mode 100644
index 00000000000..580c474f5de
--- /dev/null
+++ b/compiler/testData/codegen/android/multiFile/AndroidManifest.xml
@@ -0,0 +1,33 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/compiler/testData/codegen/android/multiFile/layout/layout.xml b/compiler/testData/codegen/android/multiFile/layout/layout.xml
new file mode 100644
index 00000000000..f4736f6937b
--- /dev/null
+++ b/compiler/testData/codegen/android/multiFile/layout/layout.xml
@@ -0,0 +1,29 @@
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/compiler/testData/codegen/android/multiFile/layout/layout1.xml b/compiler/testData/codegen/android/multiFile/layout/layout1.xml
new file mode 100644
index 00000000000..7c48f2b615c
--- /dev/null
+++ b/compiler/testData/codegen/android/multiFile/layout/layout1.xml
@@ -0,0 +1,29 @@
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/compiler/testData/codegen/android/singleFile/1.kt b/compiler/testData/codegen/android/singleFile/1.kt
new file mode 100644
index 00000000000..246b6dee346
--- /dev/null
+++ b/compiler/testData/codegen/android/singleFile/1.kt
@@ -0,0 +1,37 @@
+package com.myapp
+
+import android.app.Activity
+import android.view.View
+import android.widget.*
+
+class R {
+ class id {
+ class object {
+ val item_detail_container = 0
+ val textView1 = 1
+ val password = 2
+ val textView2 = 3
+ val passwordConfirmation = 4
+ val login = 5
+ }
+ }
+}
+
+class MyActivity(): Activity() {
+ val textViewWidget = TextView(this)
+ val editTextWidget = EditText(this)
+ val buttonWidget = Button(this)
+
+ override fun findViewById(id: Int): View? {
+ return when (id) {
+ R.id.textView1 -> textViewWidget
+ R.id.password -> editTextWidget
+ R.id.login -> buttonWidget
+ else -> null
+ }
+ }
+}
+
+fun box(): String {
+ return "OK"
+}
diff --git a/compiler/testData/codegen/android/singleFile/AndroidManifest.xml b/compiler/testData/codegen/android/singleFile/AndroidManifest.xml
new file mode 100644
index 00000000000..580c474f5de
--- /dev/null
+++ b/compiler/testData/codegen/android/singleFile/AndroidManifest.xml
@@ -0,0 +1,33 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/compiler/testData/codegen/android/singleFile/layout/layout.xml b/compiler/testData/codegen/android/singleFile/layout/layout.xml
new file mode 100644
index 00000000000..f4736f6937b
--- /dev/null
+++ b/compiler/testData/codegen/android/singleFile/layout/layout.xml
@@ -0,0 +1,29 @@
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/compiler/tests/org/jetbrains/jet/lang/resolve/android/AbstractAndroidBoxTest.kt b/compiler/tests/org/jetbrains/jet/lang/resolve/android/AbstractAndroidBoxTest.kt
new file mode 100644
index 00000000000..e3513cb0f44
--- /dev/null
+++ b/compiler/tests/org/jetbrains/jet/lang/resolve/android/AbstractAndroidBoxTest.kt
@@ -0,0 +1,59 @@
+/*
+ * 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.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
+import org.jetbrains.jet.JetTestUtils
+import java.util.Collections
+import com.intellij.util.ArrayUtil
+import com.intellij.openapi.util.io.FileUtil
+import java.io.File
+import java.util.ArrayList
+import com.intellij.util.Processor
+import org.jetbrains.jet.codegen.CodegenTestFiles
+
+public abstract class AbstractAndroidBoxTest : AbstractBlackBoxCodegenTest() {
+
+ fun createEnvironment(path: String) {
+ val configuration = JetTestUtils.compilerConfigurationForTests(ConfigurationKind.ALL, TestJdkKind.ANDROID_API);
+ 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)
+ val files = ArrayList(2)
+ FileUtil.processFilesRecursively(File(path), object : Processor {
+ override fun process(file: File?): Boolean {
+ if (file!!.getName().endsWith(".kt")) {
+ files.add(relativePath(file))
+ }
+ return true
+ }
+ })
+ Collections.sort(files);
+ myFiles = CodegenTestFiles.create(myEnvironment!!.getProject(), ArrayUtil.toStringArray(files))
+ blackBox();
+ }
+
+}
diff --git a/compiler/tests/org/jetbrains/jet/lang/resolve/android/AndroidBoxTestGenerated.java b/compiler/tests/org/jetbrains/jet/lang/resolve/android/AndroidBoxTestGenerated.java
new file mode 100644
index 00000000000..40545700c9a
--- /dev/null
+++ b/compiler/tests/org/jetbrains/jet/lang/resolve/android/AndroidBoxTestGenerated.java
@@ -0,0 +1,64 @@
+/*
+ * 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 junit.framework.Assert;
+import junit.framework.Test;
+import junit.framework.TestSuite;
+
+import java.io.File;
+import java.util.regex.Pattern;
+import org.jetbrains.jet.JetTestUtils;
+import org.jetbrains.jet.test.InnerTestClasses;
+import org.jetbrains.jet.test.TestMetadata;
+
+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")
+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("fqNameInAttr")
+ public void testFqNameInAttr() throws Exception {
+ doTest("compiler/testData/codegen/android/fqNameInAttr/");
+ }
+
+ @TestMetadata("fqNameInTag")
+ public void testFqNameInTag() throws Exception {
+ doTest("compiler/testData/codegen/android/fqNameInTag/");
+ }
+
+ @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/");
+ }
+
+}
diff --git a/compiler/tests/org/jetbrains/jet/lang/resolve/android/AndroidXmlTest.java b/compiler/tests/org/jetbrains/jet/lang/resolve/android/AndroidXmlTest.java
deleted file mode 100644
index 2d8d725b5d8..00000000000
--- a/compiler/tests/org/jetbrains/jet/lang/resolve/android/AndroidXmlTest.java
+++ /dev/null
@@ -1,141 +0,0 @@
-/*
- * 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.openapi.project.Project;
-import com.intellij.openapi.util.Disposer;
-import com.intellij.testFramework.UsefulTestCase;
-import org.jetbrains.annotations.NotNull;
-import org.jetbrains.jet.*;
-import org.jetbrains.jet.cli.jvm.JVMConfigurationKeys;
-import org.jetbrains.jet.cli.jvm.compiler.JetCoreEnvironment;
-import org.jetbrains.jet.codegen.GenerationUtils;
-import org.jetbrains.jet.codegen.state.GenerationState;
-import org.jetbrains.jet.config.CompilerConfiguration;
-import org.jetbrains.jet.lang.psi.JetFile;
-import org.jetbrains.jet.test.TestCaseWithTmpdir;
-
-import java.io.File;
-import java.io.FileWriter;
-import java.io.IOException;
-import java.net.URL;
-import java.util.*;
-
-public class AndroidXmlTest extends UsefulTestCase {
-
- private static final String singleFilePrefix = getTestDataPath() + "/converter/singleFile/";
- public static final String singleFileManifestPath = singleFilePrefix + "AndroidManifest.xml";
- private final File singleFileDir = new File(singleFilePrefix + "res/layout/");
- private final File fakeActivitySrc = new File(getTestDataPath() + "/fakeHelpers/Activity.kt");
- private final File fakeViewSrc = new File(getTestDataPath() + "/fakeHelpers/View.kt");
- private final File fakeWidgetsSrc = new File(getTestDataPath() + "/fakeHelpers/Widgets.kt");
- private final File fakeMyActivitySrc = new File(singleFilePrefix + "MyActivity.kt");
- private static final String singleFileResPath = singleFilePrefix + "res/layout/";
-
- @Override
- public void setUp() throws Exception {
- super.setUp();
- }
-
- @NotNull
- private static String getTestDataPath() {
- return JetTestCaseBuilder.getTestDataPathBase() + "/android";
- }
-
- @SuppressWarnings({"ResultOfMethodCallIgnored", "IOResourceOpenedButNotSafelyClosed"})
- protected static String loadOrCreate(File file, String data) throws IOException {
- try {
- return new Scanner(file, "UTF-8" ).useDelimiter("\\A").next();
- } catch (IOException e) {
- file.createNewFile();
- FileWriter fileWriter = new FileWriter(file);
- fileWriter.write(data);
- fileWriter.close();
- fail("Empty expected data, creating from actual");
- return data;
- }
- }
-
- private GenerationState compileManyFilesGetGenerationState(List files, String resPath) throws IOException {
- JetCoreEnvironment jetCoreEnvironment = getEnvironment(resPath);
- Project project = jetCoreEnvironment.getProject();
-
- List jetFiles = new ArrayList(files.size());
- for (File file: files) {
- jetFiles.add(JetTestUtils.loadJetFile(project, file));
- }
-
- return GenerationUtils.compileManyFilesGetGenerationStateForTest(project, jetFiles);
- }
-
- private JetCoreEnvironment getEnvironment(String resPath) {
- CompilerConfiguration configuration = JetTestUtils.compilerConfigurationForTests(ConfigurationKind.ALL,
- TestJdkKind.MOCK_JDK);
- configuration.put(JVMConfigurationKeys.ANDROID_RES_PATH, resPath);
- configuration.put(JVMConfigurationKeys.ANDROID_MANIFEST, singleFileManifestPath);
- return JetCoreEnvironment.createForTests(getTestRootDisposable(),
- configuration);
- }
-
- public void testCompileResult() throws Exception {
- List files = addDefaultFiles();
-
- compileManyFilesGetGenerationState(files, singleFileResPath);
- // TODO: why?
- Disposer.dispose(getTestRootDisposable());
- }
-
- private List addDefaultFiles() {
- File fakeRClass = new File(getTestDataPath() + "/converter/singleFile/R.kt");
- List files = new ArrayList();
- files.add(fakeActivitySrc);
- files.add(fakeViewSrc);
- files.add(fakeRClass);
- files.add(fakeWidgetsSrc);
- return files;
- }
-
- // TODO: many tests
- public void testConverterOneFile() throws Exception {
- JetCoreEnvironment jetCoreEnvironment = getEnvironment(singleFileResPath);
- AndroidUIXmlProcessor parser = new CliAndroidUIXmlProcessor(jetCoreEnvironment.getProject(),
- singleFileDir.getAbsolutePath(),
- singleFileManifestPath);
-
- String actual = parser.parseToString();
- String expected = loadOrCreate(new File(getTestDataPath() + "/converter/singleFile/layout.kt"), actual);
-
- assertEquals(expected, actual);
- }
-
- // todo: unify with box tests
- public void testGeneratedByteCode() throws Exception {
-
- String resPath = getTestDataPath() + "/converter/singleFile/res/layout/";
- List files = addDefaultFiles();
-
- files.add(fakeMyActivitySrc);
- GenerationState state = compileManyFilesGetGenerationState(files, resPath);
- ByteArrayClassLoader classLoader = new ByteArrayClassLoader(new URL[] {}, getClass().getClassLoader(), state.getFactory().asList());
- classLoader.loadFiles();
- Class> activity = classLoader.findClass("com.myapp.MyActivity");
- String res =(String) activity.getMethod("test").invoke(activity.newInstance());
- // todo: why?
- Disposer.dispose(getTestRootDisposable());
- assertEquals("OK", res);
- }
-}
diff --git a/compiler/tests/org/jetbrains/jet/lang/resolve/android/ByteArrayClassLoader.java b/compiler/tests/org/jetbrains/jet/lang/resolve/android/ByteArrayClassLoader.java
deleted file mode 100644
index 7d148636040..00000000000
--- a/compiler/tests/org/jetbrains/jet/lang/resolve/android/ByteArrayClassLoader.java
+++ /dev/null
@@ -1,84 +0,0 @@
-/*
- * 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.annotations.NotNull;
-import org.jetbrains.jet.OutputFile;
-
-import java.net.URL;
-import java.net.URLClassLoader;
-import java.util.*;
-
-// todo: get rid of this class
-public class ByteArrayClassLoader extends URLClassLoader {
-
- private final Queue q;
- private final Map extraClassDefs = new HashMap();
-
- @NotNull
- @Override
- protected Class> findClass(@NotNull String name) throws ClassNotFoundException {
- Class aClass = extraClassDefs.get(name);
- if (aClass != null) return aClass;
- else return super.findClass(name);
- }
-
- public ByteArrayClassLoader(URL[] urls, ClassLoader parent, List files) {
- super(urls, parent);
- q = new LinkedList(files);
- }
-
- private void loadBytes(OutputFile f) {
- try {
- byte[] b = f.asByteArray();
- String name = relPathToClassName(f.getRelativePath());
- Class> aClass = defineClass(name, b, 0, b.length);
- extraClassDefs.put(name, aClass);
- q.remove(f);
- } catch (NoClassDefFoundError e) {
- OutputFile found = findByClassName(e.getMessage());
- if (found == null) throw e;
- else {
- loadBytes(found);
- loadBytes(f);
- }
- }
- }
-
- public void loadFiles() {
- OutputFile f = q.peek();
- while (f != null) {
- loadBytes(f);
- f = q.peek();
- }
- }
-
- private OutputFile findByClassName(String name) {
- String path = classNameToRelPath(name);
- for (OutputFile file: q)
- if (file.getRelativePath().equals(path)) return file;
- return null;
- }
-
- private static String relPathToClassName(String path) {
- return path.replace(".class", "").replace("/", ".");
- }
-
- private static String classNameToRelPath(String name) {
- return name.replace(".", "/").concat(".class");
- }
-}
diff --git a/compiler/tests/org/jetbrains/kotlin/codegen/generated/AbstractBlackBoxCodegenTest.java b/compiler/tests/org/jetbrains/kotlin/codegen/generated/AbstractBlackBoxCodegenTest.java
index 0043108f239..398c4e3fffb 100644
--- a/compiler/tests/org/jetbrains/kotlin/codegen/generated/AbstractBlackBoxCodegenTest.java
+++ b/compiler/tests/org/jetbrains/kotlin/codegen/generated/AbstractBlackBoxCodegenTest.java
@@ -164,7 +164,7 @@ public abstract class AbstractBlackBoxCodegenTest extends CodegenTestCase {
blackBox();
}
- private void blackBox() {
+ protected void blackBox() {
// If there are many files, the first of them should contain the 'box(): String' function
JetFile firstFile = myFiles.getPsiFiles().get(0);
String fqName = getPackageClassFqName(firstFile.getPackageFqName()).asString();
diff --git a/generators/src/org/jetbrains/kotlin/generators/tests/GenerateTests.kt b/generators/src/org/jetbrains/kotlin/generators/tests/GenerateTests.kt
index bd48983cf71..19fca3dd8ae 100644
--- a/generators/src/org/jetbrains/kotlin/generators/tests/GenerateTests.kt
+++ b/generators/src/org/jetbrains/kotlin/generators/tests/GenerateTests.kt
@@ -143,6 +143,8 @@ import org.jetbrains.kotlin.idea.kdoc.AbstractKDocHighlightingTest
import org.jetbrains.kotlin.addImport.AbstractAddImportTest
import org.jetbrains.kotlin.idea.highlighter.*
import org.jetbrains.jet.lang.resolve.android.AbstractAndroidXml2KConversionTest
+import org.jetbrains.jet.android.AbstractCrossParserTest
+import org.jetbrains.jet.lang.resolve.android.AbstractAndroidBoxTest
fun main(args: Array) {
System.setProperty("java.awt.headless", "true")
@@ -319,6 +321,10 @@ fun main(args: Array) {
model("android/converter/simple", recursive = false, extension = null)
model("android/converter/exceptions", recursive = false, extension = null, testMethod = "doNoManifestTest")
}
+
+ testClass(javaClass()) {
+ model("codegen/android", recursive = false, extension = null)
+ }
}
testGroup("idea/tests", "idea/testData") {
@@ -691,6 +697,9 @@ fun main(args: Array) {
testClass(javaClass(), "org.jetbrains.kotlin.idea.kdoc.KdocResolveTestGenerated") {
model("kdoc/resolve")
+
+ testClass(javaClass()) {
+ model("android/crossParser", recursive = false, extension = null)
}
testClass(javaClass()) {
diff --git a/idea/src/org/jetbrains/jet/plugin/android/IDEAndroidUIXmlProcessor.kt b/idea/src/org/jetbrains/jet/plugin/android/IDEAndroidUIXmlProcessor.kt
index f357c3a9fbc..c5f7b973ce5 100644
--- a/idea/src/org/jetbrains/jet/plugin/android/IDEAndroidUIXmlProcessor.kt
+++ b/idea/src/org/jetbrains/jet/plugin/android/IDEAndroidUIXmlProcessor.kt
@@ -27,13 +27,13 @@ import org.jetbrains.jet.lang.resolve.android.CliAndroidResourceManager
import org.jetbrains.jet.lang.resolve.android.AndroidResourceManager
class IDEAndroidUIXmlProcessor(project: Project) : AndroidUIXmlProcessor(project) {
- override val searchPath: String? = if (ApplicationManager.getApplication()!!.isUnitTestMode()) project.getUserData(TestConst.TESTDATA_PATH) + "res/layout/"
+ override val searchPath: String? = if (ApplicationManager.getApplication()!!.isUnitTestMode()) project.getUserData(TestConst.TESTDATA_PATH) + "layout/"
else project.getBasePath() + "/res/layout/"
override var androidAppPackage: String = ""
get() = resourceManager.readManifest()._package
override val resourceManager: AndroidResourceManager = if (ApplicationManager.getApplication()!!.isUnitTestMode())
- CliAndroidResourceManager(project, searchPath, searchPath + "AndroidManifest.xml")
+ CliAndroidResourceManager(project, searchPath, project.getUserData(TestConst.TESTDATA_PATH) + "AndroidManifest.xml")
else IDEAndroidResourceManager(project, searchPath)
override fun parseSingleFileImpl(file: PsiFile): String {
diff --git a/idea/testData/android/crossParser/fqNameInAttr/AndroidManifest.xml b/idea/testData/android/crossParser/fqNameInAttr/AndroidManifest.xml
new file mode 100644
index 00000000000..580c474f5de
--- /dev/null
+++ b/idea/testData/android/crossParser/fqNameInAttr/AndroidManifest.xml
@@ -0,0 +1,33 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/idea/testData/android/crossParser/fqNameInAttr/layout.kt b/idea/testData/android/crossParser/fqNameInAttr/layout.kt
new file mode 100644
index 00000000000..5ec16eef328
--- /dev/null
+++ b/idea/testData/android/crossParser/fqNameInAttr/layout.kt
@@ -0,0 +1,9 @@
+package com.myapp
+
+import android.app.Activity
+import android.view.View
+import android.widget.*
+
+val Activity.MyButton: org.my.cool.Button
+ get() = findViewById(0) as org.my.cool.Button
+
diff --git a/idea/testData/android/crossParser/fqNameInAttr/layout/layout.xml b/idea/testData/android/crossParser/fqNameInAttr/layout/layout.xml
new file mode 100644
index 00000000000..a0ef9f3a1ed
--- /dev/null
+++ b/idea/testData/android/crossParser/fqNameInAttr/layout/layout.xml
@@ -0,0 +1,15 @@
+
+
+
+
+
diff --git a/idea/testData/android/crossParser/fqNameInTag/AndroidManifest.xml b/idea/testData/android/crossParser/fqNameInTag/AndroidManifest.xml
new file mode 100644
index 00000000000..580c474f5de
--- /dev/null
+++ b/idea/testData/android/crossParser/fqNameInTag/AndroidManifest.xml
@@ -0,0 +1,33 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/idea/testData/android/crossParser/fqNameInTag/layout.kt b/idea/testData/android/crossParser/fqNameInTag/layout.kt
new file mode 100644
index 00000000000..5ec16eef328
--- /dev/null
+++ b/idea/testData/android/crossParser/fqNameInTag/layout.kt
@@ -0,0 +1,9 @@
+package com.myapp
+
+import android.app.Activity
+import android.view.View
+import android.widget.*
+
+val Activity.MyButton: org.my.cool.Button
+ get() = findViewById(0) as org.my.cool.Button
+
diff --git a/idea/testData/android/crossParser/fqNameInTag/layout/layout.xml b/idea/testData/android/crossParser/fqNameInTag/layout/layout.xml
new file mode 100644
index 00000000000..2ec85364e74
--- /dev/null
+++ b/idea/testData/android/crossParser/fqNameInTag/layout/layout.xml
@@ -0,0 +1,14 @@
+
+
+
+
+
diff --git a/idea/testData/android/crossParser/multiFile/AndroidManifest.xml b/idea/testData/android/crossParser/multiFile/AndroidManifest.xml
new file mode 100644
index 00000000000..580c474f5de
--- /dev/null
+++ b/idea/testData/android/crossParser/multiFile/AndroidManifest.xml
@@ -0,0 +1,33 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/idea/testData/android/crossParser/multiFile/layout.kt b/idea/testData/android/crossParser/multiFile/layout.kt
new file mode 100644
index 00000000000..313d0b13d16
--- /dev/null
+++ b/idea/testData/android/crossParser/multiFile/layout.kt
@@ -0,0 +1,30 @@
+package com.myapp
+
+import android.app.Activity
+import android.view.View
+import android.widget.*
+
+val Activity.item_detail_container: FrameLayout
+ get() = findViewById(0) as FrameLayout
+
+val Activity.textView1: TextView
+ get() = findViewById(0) as TextView
+
+val Activity.password: EditText
+ get() = findViewById(0) as EditText
+
+val Activity.login: Button
+ get() = findViewById(0) as Button
+
+val Activity.frameLayout: FrameLayout
+ get() = findViewById(0) as FrameLayout
+
+val Activity.passwordField: TextView
+ get() = findViewById(0) as TextView
+
+val Activity.passwordCaption: EditText
+ get() = findViewById(0) as EditText
+
+val Activity.loginButton: Button
+ get() = findViewById(0) as Button
+
diff --git a/idea/testData/android/crossParser/multiFile/layout/layout.xml b/idea/testData/android/crossParser/multiFile/layout/layout.xml
new file mode 100644
index 00000000000..f4736f6937b
--- /dev/null
+++ b/idea/testData/android/crossParser/multiFile/layout/layout.xml
@@ -0,0 +1,29 @@
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/idea/testData/android/crossParser/multiFile/layout/layout1.xml b/idea/testData/android/crossParser/multiFile/layout/layout1.xml
new file mode 100644
index 00000000000..7c48f2b615c
--- /dev/null
+++ b/idea/testData/android/crossParser/multiFile/layout/layout1.xml
@@ -0,0 +1,29 @@
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/idea/testData/android/crossParser/noIds/AndroidManifest.xml b/idea/testData/android/crossParser/noIds/AndroidManifest.xml
new file mode 100644
index 00000000000..580c474f5de
--- /dev/null
+++ b/idea/testData/android/crossParser/noIds/AndroidManifest.xml
@@ -0,0 +1,33 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/idea/testData/android/crossParser/noIds/layout.kt b/idea/testData/android/crossParser/noIds/layout.kt
new file mode 100644
index 00000000000..efb6ca1b54b
--- /dev/null
+++ b/idea/testData/android/crossParser/noIds/layout.kt
@@ -0,0 +1,6 @@
+package com.myapp
+
+import android.app.Activity
+import android.view.View
+import android.widget.*
+
diff --git a/idea/testData/android/crossParser/noIds/layout/layout.xml b/idea/testData/android/crossParser/noIds/layout/layout.xml
new file mode 100644
index 00000000000..44ae171ae73
--- /dev/null
+++ b/idea/testData/android/crossParser/noIds/layout/layout.xml
@@ -0,0 +1,25 @@
+
+
+
+
+
+
+
+
+
+
diff --git a/idea/testData/android/crossParser/singleFile/AndroidManifest.xml b/idea/testData/android/crossParser/singleFile/AndroidManifest.xml
new file mode 100644
index 00000000000..580c474f5de
--- /dev/null
+++ b/idea/testData/android/crossParser/singleFile/AndroidManifest.xml
@@ -0,0 +1,33 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/idea/testData/android/crossParser/singleFile/MyActivity.kt b/idea/testData/android/crossParser/singleFile/MyActivity.kt
new file mode 100644
index 00000000000..3d61c9fb897
--- /dev/null
+++ b/idea/testData/android/crossParser/singleFile/MyActivity.kt
@@ -0,0 +1,27 @@
+package com.myapp
+
+import android.app.Activity
+import android.view.View
+import android.widget.*
+
+class MyActivity(): Activity() {
+ val textViewWidget = TextView()
+ val editTextWidget = EditText()
+ val buttonWidget = Button()
+
+ override fun findViewById(id: Int): View? {
+ return when (id) {
+ R.id.textView1 -> textViewWidget
+ R.id.password -> editTextWidget
+ R.id.login -> buttonWidget
+ else -> null
+ }
+ }
+
+ fun test(): String {
+ return if (password.toString() == "EditText" &&
+ textView1.toString() == "TextView" &&
+ login.toString() == "Button" )
+ "OK" else "NOTOK"
+ }
+}
\ No newline at end of file
diff --git a/idea/testData/android/crossParser/singleFile/R.kt b/idea/testData/android/crossParser/singleFile/R.kt
new file mode 100644
index 00000000000..3e9f1eb1b9f
--- /dev/null
+++ b/idea/testData/android/crossParser/singleFile/R.kt
@@ -0,0 +1,14 @@
+package com.myapp
+
+class R {
+ class id {
+ class object {
+ val item_detail_container = 0
+ val textView1 = 1
+ val password = 2
+ val textView2 = 3
+ val passwordConfirmation = 4
+ val login = 5
+ }
+ }
+}
\ No newline at end of file
diff --git a/idea/testData/android/crossParser/singleFile/layout.kt b/idea/testData/android/crossParser/singleFile/layout.kt
new file mode 100644
index 00000000000..c8ebd646620
--- /dev/null
+++ b/idea/testData/android/crossParser/singleFile/layout.kt
@@ -0,0 +1,18 @@
+package com.myapp
+
+import android.app.Activity
+import android.view.View
+import android.widget.*
+
+val Activity.item_detail_container: FrameLayout
+ get() = findViewById(0) as FrameLayout
+
+val Activity.textView1: TextView
+ get() = findViewById(0) as TextView
+
+val Activity.password: EditText
+ get() = findViewById(0) as EditText
+
+val Activity.login: Button
+ get() = findViewById(0) as Button
+
diff --git a/idea/testData/android/crossParser/singleFile/layout/layout.xml b/idea/testData/android/crossParser/singleFile/layout/layout.xml
new file mode 100644
index 00000000000..f4736f6937b
--- /dev/null
+++ b/idea/testData/android/crossParser/singleFile/layout/layout.xml
@@ -0,0 +1,29 @@
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/compiler/tests/org/jetbrains/jet/lang/resolve/android/AbstractCrossParserTest.kt b/idea/tests/org/jetbrains/jet/android/AbstractCrossParserTest.kt
similarity index 56%
rename from compiler/tests/org/jetbrains/jet/lang/resolve/android/AbstractCrossParserTest.kt
rename to idea/tests/org/jetbrains/jet/android/AbstractCrossParserTest.kt
index e8dda6fd47e..9f2b7ab39b9 100644
--- a/compiler/tests/org/jetbrains/jet/lang/resolve/android/AbstractCrossParserTest.kt
+++ b/idea/tests/org/jetbrains/jet/android/AbstractCrossParserTest.kt
@@ -14,26 +14,40 @@
* limitations under the License.
*/
-package org.jetbrains.jet.lang.resolve.android
+package org.jetbrains.jet.android
import com.intellij.testFramework.UsefulTestCase
import org.jetbrains.jet.cli.jvm.compiler.JetCoreEnvironment
+import org.jetbrains.jet.lang.resolve.android.CliAndroidUIXmlProcessor
import org.jetbrains.jet.JetTestUtils
import org.jetbrains.jet.ConfigurationKind
import org.jetbrains.jet.TestJdkKind
import org.jetbrains.jet.plugin.android.IDEAndroidUIXmlProcessor
+import org.jetbrains.jet.cli.jvm.JVMConfigurationKeys
+import junit.framework.TestCase
+import kotlin.test.assertEquals
+import org.jetbrains.jet.plugin.android.TestConst
+import com.intellij.testFramework.LightCodeInsightTestCase
+import com.intellij.testFramework.fixtures.LightCodeInsightFixtureTestCase
-public abstract class AbstractCrossParserTest : UsefulTestCase() {
+public abstract class AbstractCrossParserTest : LightCodeInsightFixtureTestCase() {
public fun doTest(path: String) {
val jetCoreEnvironment = getEnvironment(path)
+ val project = jetCoreEnvironment.getProject()
+ project.putUserData(TestConst.TESTDATA_PATH, path)
val cliParser = CliAndroidUIXmlProcessor(jetCoreEnvironment.getProject(), path + "/layout", path + "AndroidManifest.xml")
-// val ideParser = IDEAndroidUIXmlProcessor(jetCoreEnvironment.getProject(), path + "/layout", path + "AndroidManifest.xml")
+ val ideParser = IDEAndroidUIXmlProcessor(jetCoreEnvironment.getProject())
+
+ val cliResult = cliParser.parseToPsi(project)!!.getText()
+ val ideResult = ideParser.parseToPsi(project)!!.getText()
+
+ assertEquals(cliResult, ideResult)
}
private fun getEnvironment(testPath: String): JetCoreEnvironment {
val configuration = JetTestUtils.compilerConfigurationForTests(ConfigurationKind.ALL, TestJdkKind.MOCK_JDK)
- // configuration.put(JVMConfigurationKeys.ANDROID_RES_PATH, testPath + "/layout")
- // configuration.put(JVMConfigurationKeys.ANDROID_MANIFEST, testPath + "/AndroidManifest.xml")
+ configuration.put(JVMConfigurationKeys.ANDROID_RES_PATH, testPath + "/layout")
+ configuration.put(JVMConfigurationKeys.ANDROID_MANIFEST, testPath + "/AndroidManifest.xml")
return JetCoreEnvironment.createForTests(getTestRootDisposable()!!, configuration)
}
-}
+}
\ No newline at end of file
diff --git a/idea/tests/org/jetbrains/jet/android/CrossParserTestGenerated.java b/idea/tests/org/jetbrains/jet/android/CrossParserTestGenerated.java
new file mode 100644
index 00000000000..913047bd3b2
--- /dev/null
+++ b/idea/tests/org/jetbrains/jet/android/CrossParserTestGenerated.java
@@ -0,0 +1,64 @@
+/*
+ * 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.android;
+
+import junit.framework.Assert;
+import junit.framework.Test;
+import junit.framework.TestSuite;
+
+import java.io.File;
+import java.util.regex.Pattern;
+import org.jetbrains.jet.JetTestUtils;
+import org.jetbrains.jet.test.InnerTestClasses;
+import org.jetbrains.jet.test.TestMetadata;
+
+import org.jetbrains.jet.android.AbstractCrossParserTest;
+
+/** This class is generated by {@link org.jetbrains.jet.generators.tests.TestsPackage}. DO NOT MODIFY MANUALLY */
+@SuppressWarnings("all")
+@TestMetadata("idea/testData/android/crossParser")
+public class CrossParserTestGenerated extends AbstractCrossParserTest {
+ public void testAllFilesPresentInCrossParser() throws Exception {
+ JetTestUtils.assertAllTestsPresentByMetadata(this.getClass(), "org.jetbrains.jet.generators.tests.TestsPackage", new File("idea/testData/android/crossParser"), Pattern.compile("^([^\\.]+)$"), false);
+ }
+
+ @TestMetadata("fqNameInAttr")
+ public void testFqNameInAttr() throws Exception {
+ doTest("idea/testData/android/crossParser/fqNameInAttr/");
+ }
+
+ @TestMetadata("fqNameInTag")
+ public void testFqNameInTag() throws Exception {
+ doTest("idea/testData/android/crossParser/fqNameInTag/");
+ }
+
+ @TestMetadata("multiFile")
+ public void testMultiFile() throws Exception {
+ doTest("idea/testData/android/crossParser/multiFile/");
+ }
+
+ @TestMetadata("noIds")
+ public void testNoIds() throws Exception {
+ doTest("idea/testData/android/crossParser/noIds/");
+ }
+
+ @TestMetadata("singleFile")
+ public void testSingleFile() throws Exception {
+ doTest("idea/testData/android/crossParser/singleFile/");
+ }
+
+}