optimize imports
This commit is contained in:
committed by
Yan Zhulanow
parent
19e6b79cae
commit
a56fa7f192
+59
@@ -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 com.intellij.testFramework.UsefulTestCase
|
||||
import java.io.File
|
||||
import java.io.IOException
|
||||
import java.util.Scanner
|
||||
import java.io.FileWriter
|
||||
import org.jetbrains.jet.cli.jvm.compiler.JetCoreEnvironment
|
||||
import org.jetbrains.jet.config.CompilerConfiguration
|
||||
import org.jetbrains.jet.JetTestUtils
|
||||
import org.jetbrains.jet.ConfigurationKind
|
||||
import org.jetbrains.jet.TestJdkKind
|
||||
import org.jetbrains.jet.cli.jvm.JVMConfigurationKeys
|
||||
import org.junit.Assert
|
||||
import kotlin.test.fail
|
||||
|
||||
public abstract class AbstractAndroidXml2KConversionTest : UsefulTestCase() {
|
||||
|
||||
public fun doTest(path: String) {
|
||||
val jetCoreEnvironment = getEnvironment(path)
|
||||
val parser = CliAndroidUIXmlProcessor(jetCoreEnvironment.getProject(), path + "/layout", path + "AndroidManifest.xml")
|
||||
|
||||
val actual = parser.parseToString()
|
||||
|
||||
JetTestUtils.assertEqualsToFile(File(path + "/layout.kt"), actual!!)
|
||||
}
|
||||
|
||||
public fun doNoManifestTest(path: String) {
|
||||
try {
|
||||
doTest(path)
|
||||
fail("NoAndroidManifestFound not thrown")
|
||||
}
|
||||
catch (e: AndroidUIXmlProcessor.NoAndroidManifestFound) {
|
||||
}
|
||||
}
|
||||
|
||||
private fun getEnvironment(testPath: String): JetCoreEnvironment {
|
||||
val configuration = JetTestUtils.compilerConfigurationForTests(ConfigurationKind.ALL, TestJdkKind.MOCK_JDK)
|
||||
// configuration.put<String>(JVMConfigurationKeys.ANDROID_RES_PATH, testPath + "/layout")
|
||||
// configuration.put<String>(JVMConfigurationKeys.ANDROID_MANIFEST, testPath + "/AndroidManifest.xml")
|
||||
return JetCoreEnvironment.createForTests(getTestRootDisposable()!!, configuration)
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,39 @@
|
||||
/*
|
||||
* 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.UsefulTestCase
|
||||
import org.jetbrains.jet.cli.jvm.compiler.JetCoreEnvironment
|
||||
import org.jetbrains.jet.JetTestUtils
|
||||
import org.jetbrains.jet.ConfigurationKind
|
||||
import org.jetbrains.jet.TestJdkKind
|
||||
import org.jetbrains.jet.plugin.android.IDEAndroidUIXmlProcessor
|
||||
|
||||
public abstract class AbstractCrossParserTest : UsefulTestCase() {
|
||||
public fun doTest(path: String) {
|
||||
val jetCoreEnvironment = getEnvironment(path)
|
||||
val cliParser = CliAndroidUIXmlProcessor(jetCoreEnvironment.getProject(), path + "/layout", path + "AndroidManifest.xml")
|
||||
// val ideParser = IDEAndroidUIXmlProcessor(jetCoreEnvironment.getProject(), path + "/layout", path + "AndroidManifest.xml")
|
||||
}
|
||||
|
||||
private fun getEnvironment(testPath: String): JetCoreEnvironment {
|
||||
val configuration = JetTestUtils.compilerConfigurationForTests(ConfigurationKind.ALL, TestJdkKind.MOCK_JDK)
|
||||
// configuration.put<String>(JVMConfigurationKeys.ANDROID_RES_PATH, testPath + "/layout")
|
||||
// configuration.put<String>(JVMConfigurationKeys.ANDROID_MANIFEST, testPath + "/AndroidManifest.xml")
|
||||
return JetCoreEnvironment.createForTests(getTestRootDisposable()!!, configuration)
|
||||
}
|
||||
}
|
||||
+87
@@ -0,0 +1,87 @@
|
||||
/*
|
||||
* 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.AbstractAndroidXml2KConversionTest;
|
||||
|
||||
/** This class is generated by {@link org.jetbrains.jet.generators.tests.TestsPackage}. DO NOT MODIFY MANUALLY */
|
||||
@SuppressWarnings("all")
|
||||
@InnerTestClasses({AndroidXml2KConversionTestGenerated.Simple.class, AndroidXml2KConversionTestGenerated.Exceptions.class})
|
||||
public class AndroidXml2KConversionTestGenerated extends AbstractAndroidXml2KConversionTest {
|
||||
@TestMetadata("compiler/testData/android/converter/simple")
|
||||
public static class Simple extends AbstractAndroidXml2KConversionTest {
|
||||
public void testAllFilesPresentInSimple() throws Exception {
|
||||
JetTestUtils.assertAllTestsPresentByMetadata(this.getClass(), "org.jetbrains.jet.generators.tests.TestsPackage", new File("compiler/testData/android/converter/simple"), Pattern.compile("^([^\\.]+)$"), false);
|
||||
}
|
||||
|
||||
@TestMetadata("fqNameInAttr")
|
||||
public void testFqNameInAttr() throws Exception {
|
||||
doTest("compiler/testData/android/converter/simple/fqNameInAttr/");
|
||||
}
|
||||
|
||||
@TestMetadata("fqNameInTag")
|
||||
public void testFqNameInTag() throws Exception {
|
||||
doTest("compiler/testData/android/converter/simple/fqNameInTag/");
|
||||
}
|
||||
|
||||
@TestMetadata("multiFile")
|
||||
public void testMultiFile() throws Exception {
|
||||
doTest("compiler/testData/android/converter/simple/multiFile/");
|
||||
}
|
||||
|
||||
@TestMetadata("noIds")
|
||||
public void testNoIds() throws Exception {
|
||||
doTest("compiler/testData/android/converter/simple/noIds/");
|
||||
}
|
||||
|
||||
@TestMetadata("singleFile")
|
||||
public void testSingleFile() throws Exception {
|
||||
doTest("compiler/testData/android/converter/simple/singleFile/");
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@TestMetadata("compiler/testData/android/converter/exceptions")
|
||||
public static class Exceptions extends AbstractAndroidXml2KConversionTest {
|
||||
public void testAllFilesPresentInExceptions() throws Exception {
|
||||
JetTestUtils.assertAllTestsPresentByMetadata(this.getClass(), "org.jetbrains.jet.generators.tests.TestsPackage", new File("compiler/testData/android/converter/exceptions"), Pattern.compile("^([^\\.]+)$"), false);
|
||||
}
|
||||
|
||||
@TestMetadata("noManifest")
|
||||
public void testNoManifest() throws Exception {
|
||||
doNoManifestTest("compiler/testData/android/converter/exceptions/noManifest/");
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
public static Test suite() {
|
||||
TestSuite suite = new TestSuite("AndroidXml2KConversionTestGenerated");
|
||||
suite.addTestSuite(Simple.class);
|
||||
suite.addTestSuite(Exceptions.class);
|
||||
return suite;
|
||||
}
|
||||
}
|
||||
@@ -18,6 +18,7 @@ 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;
|
||||
@@ -34,7 +35,7 @@ import java.io.IOException;
|
||||
import java.net.URL;
|
||||
import java.util.*;
|
||||
|
||||
public class AndroidXmlTest extends TestCaseWithTmpdir {
|
||||
public class AndroidXmlTest extends UsefulTestCase {
|
||||
|
||||
private static final String singleFilePrefix = getTestDataPath() + "/converter/singleFile/";
|
||||
public static final String singleFileManifestPath = singleFilePrefix + "AndroidManifest.xml";
|
||||
@@ -94,6 +95,7 @@ public class AndroidXmlTest extends TestCaseWithTmpdir {
|
||||
List<File> files = addDefaultFiles();
|
||||
|
||||
compileManyFilesGetGenerationState(files, singleFileResPath);
|
||||
// TODO: why?
|
||||
Disposer.dispose(getTestRootDisposable());
|
||||
}
|
||||
|
||||
@@ -107,6 +109,7 @@ public class AndroidXmlTest extends TestCaseWithTmpdir {
|
||||
return files;
|
||||
}
|
||||
|
||||
// TODO: many tests
|
||||
public void testConverterOneFile() throws Exception {
|
||||
JetCoreEnvironment jetCoreEnvironment = getEnvironment(singleFileResPath);
|
||||
AndroidUIXmlProcessor parser = new CliAndroidUIXmlProcessor(jetCoreEnvironment.getProject(),
|
||||
@@ -119,6 +122,7 @@ public class AndroidXmlTest extends TestCaseWithTmpdir {
|
||||
assertEquals(expected, actual);
|
||||
}
|
||||
|
||||
// todo: unify with box tests
|
||||
public void testGeneratedByteCode() throws Exception {
|
||||
|
||||
String resPath = getTestDataPath() + "/converter/singleFile/res/layout/";
|
||||
@@ -130,6 +134,7 @@ public class AndroidXmlTest extends TestCaseWithTmpdir {
|
||||
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);
|
||||
}
|
||||
|
||||
@@ -23,6 +23,7 @@ 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<OutputFile> q;
|
||||
|
||||
Reference in New Issue
Block a user