factor base android test case
- move common initialization code to base class
This commit is contained in:
committed by
Yan Zhulanow
parent
65ef880dd3
commit
bc7fe3405e
@@ -38,16 +38,10 @@ public abstract class AbstractAndroidCompletionTest : KotlinAndroidTestCase() {
|
|||||||
private var kotlinInternalModeOriginalValue: Boolean = false
|
private var kotlinInternalModeOriginalValue: Boolean = false
|
||||||
|
|
||||||
override fun setUp() {
|
override fun setUp() {
|
||||||
System.setProperty(KotlinAndroidTestCaseBase.SDK_PATH_PROPERTY, PathManager.getHomePath() + "/androidSDK/")
|
|
||||||
System.setProperty(KotlinAndroidTestCaseBase.PLATFORM_DIR_PROPERTY, "android-17")
|
|
||||||
super.setUp()
|
super.setUp()
|
||||||
setAutoCompleteSetting(false)
|
setAutoCompleteSetting(false)
|
||||||
}
|
}
|
||||||
|
|
||||||
override fun createManifest() {
|
|
||||||
myFixture!!.copyFileToProject("idea/testData/android/AndroidManifest.xml", SdkConstants.FN_ANDROID_MANIFEST_XML)
|
|
||||||
}
|
|
||||||
|
|
||||||
private fun setAutoCompleteSetting(value: Boolean): Boolean {
|
private fun setAutoCompleteSetting(value: Boolean): Boolean {
|
||||||
val settings = CodeInsightSettings.getInstance()
|
val settings = CodeInsightSettings.getInstance()
|
||||||
val oldValue: Boolean
|
val oldValue: Boolean
|
||||||
@@ -78,6 +72,4 @@ public abstract class AbstractAndroidCompletionTest : KotlinAndroidTestCase() {
|
|||||||
return PluginTestCaseBase.getTestDataPathBase() + "/android/completion/" + getTestName(true) + "/"
|
return PluginTestCaseBase.getTestDataPathBase() + "/android/completion/" + getTestName(true) + "/"
|
||||||
}
|
}
|
||||||
|
|
||||||
override fun requireRecentSdk() = true
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -26,29 +26,17 @@ import org.jetbrains.jet.lang.psi.JetProperty
|
|||||||
|
|
||||||
public abstract class AbstractAndroidGotoTest : KotlinAndroidTestCase() {
|
public abstract class AbstractAndroidGotoTest : KotlinAndroidTestCase() {
|
||||||
|
|
||||||
override fun setUp() {
|
|
||||||
System.setProperty(KotlinAndroidTestCaseBase.SDK_PATH_PROPERTY, PathManager.getHomePath() + "/androidSDK/")
|
|
||||||
System.setProperty(KotlinAndroidTestCaseBase.PLATFORM_DIR_PROPERTY, "android-17")
|
|
||||||
super.setUp()
|
|
||||||
}
|
|
||||||
|
|
||||||
override fun getTestDataPath(): String {
|
override fun getTestDataPath(): String {
|
||||||
return PluginTestCaseBase.getTestDataPathBase() + "/android/goto/" + getTestName(true) + "/"
|
return PluginTestCaseBase.getTestDataPathBase() + "/android/goto/" + getTestName(true) + "/"
|
||||||
}
|
}
|
||||||
|
|
||||||
override fun createManifest() {
|
|
||||||
myFixture!!.copyFileToProject("idea/testData/android/AndroidManifest.xml", SdkConstants.FN_ANDROID_MANIFEST_XML)
|
|
||||||
}
|
|
||||||
|
|
||||||
override fun requireRecentSdk() = true
|
|
||||||
|
|
||||||
public fun doTest(path: String) {
|
public fun doTest(path: String) {
|
||||||
val f = myFixture!!
|
val f = myFixture!!
|
||||||
f.copyDirectoryToProject(getResDir()!!, "res")
|
f.copyDirectoryToProject(getResDir()!!, "res")
|
||||||
f.configureByFile(path + getTestName(true) + ".kt");
|
f.configureByFile(path + getTestName(true) + ".kt");
|
||||||
|
|
||||||
val resolved = GotoDeclarationAction.findTargetElement(f.getProject(), f.getEditor(), f.getCaretOffset())
|
val resolved = GotoDeclarationAction.findTargetElement(f.getProject(), f.getEditor(), f.getCaretOffset())
|
||||||
if (f.getElementAtCaret() !is JetProperty) fail("resolved element must be a property, not a ${f.getElementAtCaret().javaClass}")
|
if (f.getElementAtCaret() !is JetProperty) fail("element at caret must be a property, not a ${f.getElementAtCaret().javaClass}")
|
||||||
assertEquals("\"@+id/${(f.getElementAtCaret() as JetProperty).getName()}\"", resolved?.getText())
|
assertEquals("\"@+id/${(f.getElementAtCaret() as JetProperty).getName()}\"", resolved?.getText())
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -52,11 +52,6 @@ public abstract class AbstractCrossParserTest : KotlinAndroidTestCase() {
|
|||||||
|
|
||||||
assertEquals(cliResult, ideResult)
|
assertEquals(cliResult, ideResult)
|
||||||
}
|
}
|
||||||
override fun setUp() {
|
|
||||||
System.setProperty(KotlinAndroidTestCaseBase.SDK_PATH_PROPERTY, PathManager.getHomePath() + "/androidSDK/")
|
|
||||||
System.setProperty(KotlinAndroidTestCaseBase.PLATFORM_DIR_PROPERTY, "android-17")
|
|
||||||
super.setUp()
|
|
||||||
}
|
|
||||||
|
|
||||||
private fun getEnvironment(testPath: String): JetCoreEnvironment {
|
private fun getEnvironment(testPath: String): JetCoreEnvironment {
|
||||||
val configuration = JetTestUtils.compilerConfigurationForTests(ConfigurationKind.ALL, TestJdkKind.MOCK_JDK)
|
val configuration = JetTestUtils.compilerConfigurationForTests(ConfigurationKind.ALL, TestJdkKind.MOCK_JDK)
|
||||||
@@ -68,10 +63,4 @@ public abstract class AbstractCrossParserTest : KotlinAndroidTestCase() {
|
|||||||
override fun getTestDataPath(): String? {
|
override fun getTestDataPath(): String? {
|
||||||
return PluginTestCaseBase.getTestDataPathBase() + "/android/crossParser/" + getTestName(true) + "/"
|
return PluginTestCaseBase.getTestDataPathBase() + "/android/crossParser/" + getTestName(true) + "/"
|
||||||
}
|
}
|
||||||
|
|
||||||
override fun createManifest() {
|
|
||||||
myFixture!!.copyFileToProject("idea/testData/android/AndroidManifest.xml", SdkConstants.FN_ANDROID_MANIFEST_XML)
|
|
||||||
}
|
|
||||||
|
|
||||||
override fun requireRecentSdk() = true
|
|
||||||
}
|
}
|
||||||
@@ -28,6 +28,7 @@ import com.intellij.facet.FacetManager;
|
|||||||
import com.intellij.facet.ModifiableFacetModel;
|
import com.intellij.facet.ModifiableFacetModel;
|
||||||
import com.intellij.ide.startup.impl.StartupManagerImpl;
|
import com.intellij.ide.startup.impl.StartupManagerImpl;
|
||||||
import com.intellij.openapi.application.ApplicationManager;
|
import com.intellij.openapi.application.ApplicationManager;
|
||||||
|
import com.intellij.openapi.application.PathManager;
|
||||||
import com.intellij.openapi.module.Module;
|
import com.intellij.openapi.module.Module;
|
||||||
import com.intellij.openapi.module.ModuleType;
|
import com.intellij.openapi.module.ModuleType;
|
||||||
import com.intellij.openapi.projectRoots.Sdk;
|
import com.intellij.openapi.projectRoots.Sdk;
|
||||||
@@ -93,6 +94,10 @@ public abstract class KotlinAndroidTestCase extends KotlinAndroidTestCaseBase {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected void setUp() throws Exception {
|
protected void setUp() throws Exception {
|
||||||
|
// sdk path workaround, set real android sdk path and platform for android plugin to work
|
||||||
|
System.setProperty(KotlinAndroidTestCaseBase.SDK_PATH_PROPERTY, PathManager.getHomePath() + "/androidSDK/");
|
||||||
|
System.setProperty(KotlinAndroidTestCaseBase.PLATFORM_DIR_PROPERTY, "android-17");
|
||||||
|
|
||||||
super.setUp();
|
super.setUp();
|
||||||
|
|
||||||
// this will throw an exception if we don't have a full Android SDK, so we need to do this first thing before any other setup
|
// this will throw an exception if we don't have a full Android SDK, so we need to do this first thing before any other setup
|
||||||
@@ -204,7 +209,8 @@ public abstract class KotlinAndroidTestCase extends KotlinAndroidTestCaseBase {
|
|||||||
}
|
}
|
||||||
|
|
||||||
protected void createManifest() throws IOException {
|
protected void createManifest() throws IOException {
|
||||||
myFixture.copyFileToProject(SdkConstants.FN_ANDROID_MANIFEST_XML, SdkConstants.FN_ANDROID_MANIFEST_XML);
|
myFixture.copyFileToProject("idea/testData/android/AndroidManifest.xml", SdkConstants.FN_ANDROID_MANIFEST_XML);
|
||||||
|
// myFixture.copyFileToProject(SdkConstants.FN_ANDROID_MANIFEST_XML, SdkConstants.FN_ANDROID_MANIFEST_XML);
|
||||||
}
|
}
|
||||||
|
|
||||||
protected void createProjectProperties() throws IOException {
|
protected void createProjectProperties() throws IOException {
|
||||||
|
|||||||
@@ -137,7 +137,7 @@ public abstract class KotlinAndroidTestCaseBase extends UsefulTestCase {
|
|||||||
|
|
||||||
/** Is the bundled (incomplete) SDK install adequate or do we need to find a valid install? */
|
/** Is the bundled (incomplete) SDK install adequate or do we need to find a valid install? */
|
||||||
protected boolean requireRecentSdk() {
|
protected boolean requireRecentSdk() {
|
||||||
return false;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
protected void addAndroidSdk(Module module, String sdkPath, String platformDir) {
|
protected void addAndroidSdk(Module module, String sdkPath, String platformDir) {
|
||||||
|
|||||||
Reference in New Issue
Block a user