diff --git a/platform/testGuiFramework/src/com/intellij/testGuiFramework/launcher/GuiTestLocalLauncher.kt b/platform/testGuiFramework/src/com/intellij/testGuiFramework/launcher/GuiTestLocalLauncher.kt index d5ccca99547c..4d12b75573d1 100644 --- a/platform/testGuiFramework/src/com/intellij/testGuiFramework/launcher/GuiTestLocalLauncher.kt +++ b/platform/testGuiFramework/src/com/intellij/testGuiFramework/launcher/GuiTestLocalLauncher.kt @@ -169,31 +169,30 @@ object GuiTestLocalLauncher { return resultingArgs } - - private fun getDefaultVmOptions(ide: Ide, - configPath: String = "../config", - systemPath: String = "../system", - bootClasspath: String = "../out/classes/production/boot", - encoding: String = "UTF-8", - isInternal: Boolean = true, - useMenuScreenBar: Boolean = true, - debugPort: Int = 5009, - suspendDebug: String = "n"): List = - listOf() - .plus("-ea") - .plus("-Xbootclasspath/p:$bootClasspath") - .plus("-Dsun.awt.disablegrab=true") - .plus("-Dsun.io.useCanonCaches=false") - .plus("-Djava.net.preferIPv4Stack=true") - .plus("-Dapple.laf.useScreenMenuBar=${useMenuScreenBar.toString()}") - .plus("-Didea.is.internal=${isInternal.toString()}") - .plus("-Didea.config.path=$configPath") - .plus("-Didea.system.path=$systemPath") - .plus("-Dfile.encoding=$encoding") - .plus("-Didea.platform.prefix=${ide.ideType.platformPrefix}") - .plus("-Xdebug") - .plus( - "-Xrunjdwp:transport=dt_socket,server=y,suspend=$suspendDebug,address=$debugPort") //todo: add System.getProperty(...) to customize debug port + /** + * Default VM options to start IntelliJ IDEA (or IDEA-based IDE). To customize options use com.intellij.testGuiFramework.launcher.GuiTestOptions + */ + private fun getDefaultVmOptions(ide: Ide) : List { + return listOf() + .plus("-Xmx${GuiTestOptions.getXmxSize()}m") + .plus("-XX:ReservedCodeCacheSize=150m") + .plus("-XX:+UseConcMarkSweepGC") + .plus("-XX:SoftRefLRUPolicyMSPerMB=50") + .plus("-XX:MaxJavaStackTraceDepth=10000") + .plus("-ea") + .plus("-Xbootclasspath/p:${GuiTestOptions.getBootClasspath()}") + .plus("-Dsun.awt.disablegrab=true") + .plus("-Dsun.io.useCanonCaches=false") + .plus("-Djava.net.preferIPv4Stack=true") + .plus("-Dapple.laf.useScreenMenuBar=${GuiTestOptions.useAppleScreenMenuBar().toString()}") + .plus("-Didea.is.internal=${GuiTestOptions.isInternal().toString()}") + .plus("-Didea.config.path=${GuiTestOptions.getConfigPath()}") + .plus("-Didea.system.path=${GuiTestOptions.getSystemPath()}") + .plus("-Dfile.encoding=${GuiTestOptions.getEncoding()}") + .plus("-Didea.platform.prefix=${ide.ideType.platformPrefix}") + .plus("-Xdebug") + .plus("-Xrunjdwp:transport=dt_socket,server=y,suspend=${GuiTestOptions.suspendDebug()},address=${GuiTestOptions.getDebugPort()}") + } private fun getCurrentJavaExec(): String { return PathUtils.getJreBinPath() diff --git a/platform/testGuiFramework/src/com/intellij/testGuiFramework/launcher/GuiTestOptions.kt b/platform/testGuiFramework/src/com/intellij/testGuiFramework/launcher/GuiTestOptions.kt new file mode 100644 index 000000000000..3c100c703ef4 --- /dev/null +++ b/platform/testGuiFramework/src/com/intellij/testGuiFramework/launcher/GuiTestOptions.kt @@ -0,0 +1,61 @@ +/* + * Copyright 2000-2017 JetBrains s.r.o. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package com.intellij.testGuiFramework.launcher + +import com.intellij.openapi.application.PathManager + +object GuiTestOptions { + + fun getConfigPath(): String = getSystemProperty("idea.config.path", getConfigDefaultPath()) + fun getSystemPath(): String = getSystemProperty("idea.system.path", getSystemDefaultPath()) + fun isDebug(): Boolean = getSystemProperty("idea.debug.mode", false) + fun suspendDebug(): String = if (isDebug()) "y" else "n" + fun isInternal(): Boolean = getSystemProperty("idea.is.internal", true) + fun useAppleScreenMenuBar(): Boolean = getSystemProperty("apple.laf.useScreenMenuBar", false) + + fun getDebugPort(): Int = getSystemProperty("idea.gui.test.debug.port", 5009) + fun getBootClasspath(): String = getSystemProperty("idea.gui.test.bootclasspath", "../out/classes/production/boot") + fun getEncoding(): String = getSystemProperty("idea.gui.test.encoding", "UTF-8") + fun getXmxSize(): Int = getSystemProperty("idea.gui.test.xmx", 512) + + fun getConfigDefaultPath(): String { + try { + return "${PathManager.getHomePath()}/config" + } + catch(e: RuntimeException) { + return "../config" + } + } + + fun getSystemDefaultPath(): String { + try { + return "${PathManager.getHomePath()}/system" + } + catch(e: RuntimeException) { + return "../system" + } + } + + inline fun getSystemProperty(key: String, defaultValue: ReturnType): ReturnType { + val value = System.getProperty(key) ?: return defaultValue + return when (defaultValue) { + is Int -> value.toInt() as ReturnType + is Boolean -> value.toBoolean() as ReturnType + is String -> value as ReturnType + else -> throw Exception("Unable to get returning type of default value (not integer, boolean or string) for key: $key") + } + } +} \ No newline at end of file diff --git a/platform/testGuiFramework/testGuiFramework.iml b/platform/testGuiFramework/testGuiFramework.iml index c9d525589302..e74aa83ddb91 100644 --- a/platform/testGuiFramework/testGuiFramework.iml +++ b/platform/testGuiFramework/testGuiFramework.iml @@ -23,5 +23,6 @@ + \ No newline at end of file diff --git a/platform/testGuiFramework/testSrc/com/intellij/testGuiFramework/tests/community/CommandLineProjectTest.kt b/platform/testGuiFramework/testSrc/com/intellij/testGuiFramework/tests/community/CommandLineProjectTest.kt index 00029b781477..08220f1bd35e 100644 --- a/platform/testGuiFramework/testSrc/com/intellij/testGuiFramework/tests/community/CommandLineProjectTest.kt +++ b/platform/testGuiFramework/testSrc/com/intellij/testGuiFramework/tests/community/CommandLineProjectTest.kt @@ -15,6 +15,9 @@ */ package com.intellij.testGuiFramework.tests.community +import com.intellij.diff.comparison.ComparisonPolicy +import com.intellij.diff.comparison.ComparisonUtil +import com.intellij.openapi.ui.MultiLineLabelUI import com.intellij.openapi.util.text.StringUtil import com.intellij.testGuiFramework.framework.RunWithIde import com.intellij.testGuiFramework.impl.GuiTestCase @@ -33,7 +36,8 @@ public class Main { public static void main(String[] args) { // write your code here } -}""" +} +""" @Test fun testProjectCreate() { @@ -62,8 +66,14 @@ public class Main { moveTo(1) } val editorCode = editor.getCurrentFileContents(false) - assertTrue(StringUtil.convertLineSeparators(codeText) == StringUtil.convertLineSeparators(editorCode!!)) + assertTrue(ComparisonUtil.isEquals(codeText.unifyCode(), + editorCode!!.unifyCode(), + ComparisonPolicy.TRIM_WHITESPACES)) closeProject() } } + + fun String.unifyCode(): String = + MultiLineLabelUI.convertTabs(StringUtil.convertLineSeparators(this), 2) + } \ No newline at end of file