From 51bd32edab15a5b77ca328285ef5cfa3d6b3f7e1 Mon Sep 17 00:00:00 2001 From: Dmitry Jemerov Date: Tue, 23 Mar 2010 21:18:07 +0300 Subject: [PATCH] auto-configure platform prefix in CE tests --- .../intellij/testFramework/IdeaTestCase.java | 42 +++++++++---------- java/testFramework/testFramework-java.iml | 1 + 2 files changed, 21 insertions(+), 22 deletions(-) diff --git a/java/testFramework/src/com/intellij/testFramework/IdeaTestCase.java b/java/testFramework/src/com/intellij/testFramework/IdeaTestCase.java index a6455c69bbb4..340676caaaea 100644 --- a/java/testFramework/src/com/intellij/testFramework/IdeaTestCase.java +++ b/java/testFramework/src/com/intellij/testFramework/IdeaTestCase.java @@ -26,6 +26,12 @@ import org.jetbrains.annotations.NonNls; * @author mike */ @NonNls public abstract class IdeaTestCase extends PlatformTestCase { + private static boolean ourPlatformPrefixInitialized; + + protected IdeaTestCase() { + initPlatformPrefix(); + } + public final JavaPsiFacadeEx getJavaFacade() { return JavaPsiFacadeEx.getInstanceEx(myProject); } @@ -40,27 +46,19 @@ import org.jetbrains.annotations.NonNls; return StdModuleTypes.JAVA; } - //private void cleanTheWorld() throws IllegalAccessException, NoSuchFieldException { - // try { - // ((JobSchedulerImpl)JobScheduler.getInstance()).waitForCompletion(); - // } - // catch (Throwable throwable) { - // LOG.error(throwable); - // } - // UIUtil.dispatchAllInvocationEvents(); - // - // Thread thread = Thread.currentThread(); - // Field locals = Thread.class.getDeclaredField("threadLocals"); - // locals.setAccessible(true); - // locals.set(thread, null); - // - // String path = HeapWalker.findObjectUnder(ourApplication, Project.class); - // if (path != null) { - // throw new RuntimeException(getName() + " " + path); - // } - //} - - static { - System.setProperty("jbdt.test.fixture", "com.intellij.designer.dt.IJTestFixture"); + public static void initPlatformPrefix() { + if (!ourPlatformPrefixInitialized) { + ourPlatformPrefixInitialized = true; + boolean isUltimate = true; + try { + IdeaTestCase.class.getClassLoader().loadClass("com.intellij.idea.IdeaUltimateApplication"); + } + catch (ClassNotFoundException e) { + isUltimate = false; + } + if (!isUltimate) { + System.setProperty("idea.platform.prefix", "Idea"); + } + } } } diff --git a/java/testFramework/testFramework-java.iml b/java/testFramework/testFramework-java.iml index 5e101414c506..b692257cf630 100644 --- a/java/testFramework/testFramework-java.iml +++ b/java/testFramework/testFramework-java.iml @@ -17,6 +17,7 @@ +