diff --git a/platform/testGuiFramework/src/com/intellij/testGuiFramework/framework/GuiTestUtil.java b/platform/testGuiFramework/src/com/intellij/testGuiFramework/framework/GuiTestUtil.java index d728092e977f..6ef8cd39c93c 100644 --- a/platform/testGuiFramework/src/com/intellij/testGuiFramework/framework/GuiTestUtil.java +++ b/platform/testGuiFramework/src/com/intellij/testGuiFramework/framework/GuiTestUtil.java @@ -17,7 +17,6 @@ package com.intellij.testGuiFramework.framework; import com.intellij.diagnostic.AbstractMessage; import com.intellij.diagnostic.MessagePool; -import com.intellij.ide.GeneralSettings; import com.intellij.ide.PrivacyPolicy; import com.intellij.ide.RecentProjectsManager; import com.intellij.openapi.actionSystem.ActionManager; @@ -159,12 +158,8 @@ public final class GuiTestUtil { // Called by IdeTestApplication via reflection. @SuppressWarnings("unused") public static void setUpDefaultGeneralSettings() { - //setGuiTestingMode(true); - GeneralSettings.getInstance().setShowTipsOnStartup(false); - setUpDefaultProjectCreationLocationPath(); - setUpSdks(); } public static String getSystemJdk() { @@ -179,11 +174,6 @@ public final class GuiTestUtil { return jdkHome; } - public static void setupGitPath() { - //GitVcsApplicationSettings settings = GitVcsApplicationSettings.getInstance(); - //settings.setPathToGit(GitExecutor.PathHolder.GIT_EXECUTABLE); - } - public static void setUpSdks() { String jdkHome = getSystemPropertyOrEnvironmentVariable(JDK_HOME_FOR_TESTS); @@ -224,6 +214,9 @@ public final class GuiTestUtil { JavaSdk javaSdk = JavaSdk.getInstance(); + //in case of running different from IntelliJ or Android Studio IDE (PyCharm for example) + if (javaSdk == null) return; + String jdk_name = "JDK"; final Sdk newJdk = javaSdk.createJdk(jdk_name, path.toString(), false); final Sdk foundJdk = ProjectJdkTable.getInstance().findJdk(newJdk.getName(), newJdk.getSdkType().getName()); diff --git a/platform/testGuiFramework/src/com/intellij/testGuiFramework/framework/IdeTestApplication.java b/platform/testGuiFramework/src/com/intellij/testGuiFramework/framework/IdeTestApplication.java index 3c7ed45ae234..f592c76d3556 100644 --- a/platform/testGuiFramework/src/com/intellij/testGuiFramework/framework/IdeTestApplication.java +++ b/platform/testGuiFramework/src/com/intellij/testGuiFramework/framework/IdeTestApplication.java @@ -109,7 +109,6 @@ public class IdeTestApplication { ClassLoader ideClassLoader = ourInstance.getIdeClassLoader(); Class clazz = ideClassLoader.loadClass(GuiTestUtil.class.getCanonicalName()); method("waitForIdeToStart").in(clazz).invoke(); - method("setUpDefaultGeneralSettings").in(clazz).invoke(); } return ourInstance; diff --git a/platform/testGuiFramework/src/com/intellij/testGuiFramework/impl/GuiTestCase.java b/platform/testGuiFramework/src/com/intellij/testGuiFramework/impl/GuiTestCase.java index d4026a072d1e..82c9d25af17f 100644 --- a/platform/testGuiFramework/src/com/intellij/testGuiFramework/impl/GuiTestCase.java +++ b/platform/testGuiFramework/src/com/intellij/testGuiFramework/impl/GuiTestCase.java @@ -15,13 +15,14 @@ */ package com.intellij.testGuiFramework.impl; +import com.intellij.ide.GeneralSettings; import com.intellij.testGuiFramework.framework.GuiTestBase; +import com.intellij.testGuiFramework.framework.GuiTestUtil; import com.intellij.util.net.HttpConfigurable; import org.fest.swing.core.FastRobot; import java.lang.reflect.InvocationTargetException; -import static com.intellij.testGuiFramework.framework.GuiTestUtil.setUpDefaultProjectCreationLocationPath; /** * @author Sergey Karashevich @@ -34,30 +35,43 @@ public class GuiTestCase extends GuiTestBase { super(); } - @Override - public void setUp() throws Exception { - super.setUp(); + public static class GuiSettings { - setUpDefaultProjectCreationLocationPath(); - myRobot = new FastRobot(); + private static final Object lock = new Object(); + + private static GuiSettings SETTINGS; + + public static GuiSettings setUp() { + synchronized (lock) { + if (SETTINGS == null) SETTINGS = new GuiSettings(); + return SETTINGS; + } + } + + GuiSettings(){ + GeneralSettings.getInstance().setShowTipsOnStartup(false); + GuiTestUtil.setUpDefaultProjectCreationLocationPath(); + GuiTestUtil.setUpSdks(); + HttpConfigurable ideSettings = HttpConfigurable.getInstance(); + ideSettings.USE_HTTP_PROXY = false; + ideSettings.PROXY_HOST = ""; + ideSettings.PROXY_PORT = 80; + if (IS_UNDER_TEAMCITY) GitSettings.INSTANCE.setup(); + } - setIdeSettings(); - if (IS_UNDER_TEAMCITY) GitSettings.INSTANCE.setup(); } - @Override - public void tearDown() throws InvocationTargetException, InterruptedException { - GitSettings.INSTANCE.restore(); - super.tearDown(); + @Override + public void setUp() throws Exception { + super.setUp(); + myRobot = new FastRobot(); + GuiSettings.setUp(); + } + + @Override + public void tearDown() throws InvocationTargetException, InterruptedException { + GitSettings.INSTANCE.restore(); + super.tearDown(); + } + } - - private static void setIdeSettings() { - // Clear HTTP proxy settings, in case a test changed them. - HttpConfigurable ideSettings = HttpConfigurable.getInstance(); - ideSettings.USE_HTTP_PROXY = false; - ideSettings.PROXY_HOST = ""; - ideSettings.PROXY_PORT = 80; - } - - -}