From 2dc7f4be73347af0706bfca9abe05eda791e0159 Mon Sep 17 00:00:00 2001 From: Alexey Kudravtsev Date: Tue, 1 Jul 2014 14:06:21 +0400 Subject: [PATCH] detect performance test in more cases --- .../testFramework/PlatformTestCase.java | 2 -- .../testFramework/UsefulTestCase.java | 25 ++++++------------- 2 files changed, 7 insertions(+), 20 deletions(-) diff --git a/platform/testFramework/src/com/intellij/testFramework/PlatformTestCase.java b/platform/testFramework/src/com/intellij/testFramework/PlatformTestCase.java index 49be3c789f74..e731c6371d92 100644 --- a/platform/testFramework/src/com/intellij/testFramework/PlatformTestCase.java +++ b/platform/testFramework/src/com/intellij/testFramework/PlatformTestCase.java @@ -27,7 +27,6 @@ import com.intellij.openapi.application.ApplicationManager; import com.intellij.openapi.application.ModalityState; import com.intellij.openapi.application.Result; import com.intellij.openapi.application.WriteAction; -import com.intellij.openapi.application.impl.ApplicationInfoImpl; import com.intellij.openapi.command.CommandProcessor; import com.intellij.openapi.command.WriteCommandAction; import com.intellij.openapi.command.impl.UndoManagerImpl; @@ -135,7 +134,6 @@ public abstract class PlatformTestCase extends UsefulTestCase implements DataPro autodetectPlatformPrefix(); ourApplication = IdeaTestApplication.getInstance(getApplicationConfigDirPath()); ourApplication.setDataProvider(this); - ApplicationInfoImpl.setInPerformanceTest(isPerformanceTest()); if (firstTime) { cleanPersistedVFSContent(); diff --git a/platform/testFramework/src/com/intellij/testFramework/UsefulTestCase.java b/platform/testFramework/src/com/intellij/testFramework/UsefulTestCase.java index 306d7f76fd93..fa752b4643b0 100644 --- a/platform/testFramework/src/com/intellij/testFramework/UsefulTestCase.java +++ b/platform/testFramework/src/com/intellij/testFramework/UsefulTestCase.java @@ -22,8 +22,8 @@ import com.intellij.openapi.Disposable; import com.intellij.openapi.application.Application; import com.intellij.openapi.application.ApplicationManager; import com.intellij.openapi.application.PathManager; +import com.intellij.openapi.application.impl.ApplicationInfoImpl; import com.intellij.openapi.command.impl.StartMarkAction; -import com.intellij.openapi.editor.impl.DocumentImpl; import com.intellij.openapi.fileTypes.StdFileTypes; import com.intellij.openapi.project.Project; import com.intellij.openapi.util.*; @@ -138,6 +138,7 @@ public abstract class UsefulTestCase extends TestCase { myTempDir = FileUtil.toSystemDependentName(ORIGINAL_TEMP_DIR + "/" + TEMP_DIR_MARKER + testName + "_"+ RNG.nextInt(1000)); FileUtil.resetCanonicalTempPathCache(myTempDir); } + ApplicationInfoImpl.setInPerformanceTest(isPerformanceTest()); } @Override @@ -203,23 +204,11 @@ public abstract class UsefulTestCase extends TestCase { } private static void cleanupSwingDataStructures() throws Exception { - Class aClass = Class.forName("javax.swing.KeyboardManager"); - - Method get = aClass.getMethod("getCurrentManager"); - get.setAccessible(true); - Object manager = get.invoke(null); - { - Field mapF = aClass.getDeclaredField("componentKeyStrokeMap"); - mapF.setAccessible(true); - Object map = mapF.get(manager); - ((Map)map).clear(); - } - { - Field mapF = aClass.getDeclaredField("containerMap"); - mapF.setAccessible(true); - Object map = mapF.get(manager); - ((Map)map).clear(); - } + Object manager = ReflectionUtil.getDeclaredMethod(Class.forName("javax.swing.KeyboardManager"), "getCurrentManager").invoke(null); + Map componentKeyStrokeMap = ReflectionUtil.getField(manager.getClass(), manager, Hashtable.class, "componentKeyStrokeMap"); + componentKeyStrokeMap.clear(); + Map containerMap = ReflectionUtil.getField(manager.getClass(), manager, Hashtable.class, "containerMap"); + containerMap.clear(); } protected CompositeException checkForSettingsDamage() throws Exception {