Remove state from android tests
This commit is contained in:
+15
-3
@@ -18,6 +18,7 @@ package org.jetbrains.kotlin.android;
|
||||
|
||||
import com.android.SdkConstants;
|
||||
import com.android.ide.common.rendering.RenderSecurityManager;
|
||||
import com.android.tools.idea.rendering.PsiProjectListener;
|
||||
import com.intellij.facet.FacetManager;
|
||||
import com.intellij.facet.ModifiableFacetModel;
|
||||
import com.intellij.ide.startup.impl.StartupManagerImpl;
|
||||
@@ -43,8 +44,10 @@ import org.jetbrains.kotlin.test.JetTestUtils;
|
||||
import java.io.File;
|
||||
import java.io.FileFilter;
|
||||
import java.io.IOException;
|
||||
import java.lang.reflect.Field;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
|
||||
@SuppressWarnings({"JUnitTestCaseWithNonTrivialConstructors"})
|
||||
@@ -80,6 +83,8 @@ public abstract class KotlinAndroidTestCase extends KotlinAndroidTestCaseBase {
|
||||
System.setProperty(KotlinAndroidTestCaseBase.SDK_PATH_PROPERTY, PathManager.getHomePath() + "/../dependencies/androidSDK");
|
||||
System.setProperty(KotlinAndroidTestCaseBase.PLATFORM_DIR_PROPERTY, "android-21");
|
||||
|
||||
VfsRootAccess.allowRootAccess(JetTestUtils.getHomeDirectory());
|
||||
|
||||
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
|
||||
@@ -142,7 +147,6 @@ public abstract class KotlinAndroidTestCase extends KotlinAndroidTestCaseBase {
|
||||
}
|
||||
|
||||
((StartupManagerImpl) StartupManager.getInstance(getProject())).runPostStartupActivities();
|
||||
VfsRootAccess.allowRootAccess(JetTestUtils.getHomeDirectory());
|
||||
|
||||
kotlinInternalModeOriginalValue = KotlinInternalMode.Instance.getEnabled();
|
||||
KotlinInternalMode.Instance.setEnabled(true);
|
||||
@@ -177,7 +181,8 @@ public abstract class KotlinAndroidTestCase extends KotlinAndroidTestCaseBase {
|
||||
}
|
||||
|
||||
protected void createManifest() throws IOException {
|
||||
myFixture.copyFileToProject("plugins/android-idea-plugin/testData/android/AndroidManifest.xml", SdkConstants.FN_ANDROID_MANIFEST_XML);
|
||||
myFixture.copyFileToProject("plugins/android-idea-plugin/testData/android/AndroidManifest.xml",
|
||||
SdkConstants.FN_ANDROID_MANIFEST_XML);
|
||||
}
|
||||
|
||||
protected void deleteManifest() throws IOException {
|
||||
@@ -207,15 +212,22 @@ public abstract class KotlinAndroidTestCase extends KotlinAndroidTestCaseBase {
|
||||
@Override
|
||||
public void tearDown() throws Exception {
|
||||
KotlinInternalMode.Instance.setEnabled(kotlinInternalModeOriginalValue);
|
||||
VfsRootAccess.disallowRootAccess(JetTestUtils.getHomeDirectory());
|
||||
|
||||
super.tearDown();
|
||||
|
||||
Field listenersField = PsiProjectListener.class.getDeclaredField("ourListeners");
|
||||
listenersField.setAccessible(true);
|
||||
Map listeners = (Map)listenersField.get(null);
|
||||
listeners.clear();
|
||||
|
||||
VfsRootAccess.disallowRootAccess(JetTestUtils.getHomeDirectory());
|
||||
|
||||
myModule = null;
|
||||
myAdditionalModules = null;
|
||||
myFixture.tearDown();
|
||||
myFixture = null;
|
||||
myFacet = null;
|
||||
|
||||
if (RenderSecurityManager.RESTRICT_READS) {
|
||||
RenderSecurityManager.sEnabled = true;
|
||||
}
|
||||
|
||||
+2
@@ -76,6 +76,8 @@ public abstract class KotlinAndroidTestCaseBase extends UsefulTestCase {
|
||||
@Override
|
||||
public void run() throws Exception {
|
||||
KotlinAndroidTestCaseBase.super.tearDown();
|
||||
androidJar = null;
|
||||
androidSdk = null;
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user