diff --git a/idea/idea-live-templates/idea-live-templates.iml b/idea/idea-live-templates/idea-live-templates.iml
index c04eb50c696..8c86e23f7ee 100644
--- a/idea/idea-live-templates/idea-live-templates.iml
+++ b/idea/idea-live-templates/idea-live-templates.iml
@@ -17,5 +17,6 @@
+
\ No newline at end of file
diff --git a/idea/testData/templates/anonymous_1.exp.kt b/idea/idea-live-templates/testData/anonymous_1.exp.kt
similarity index 100%
rename from idea/testData/templates/anonymous_1.exp.kt
rename to idea/idea-live-templates/testData/anonymous_1.exp.kt
diff --git a/idea/testData/templates/anonymous_1.kt b/idea/idea-live-templates/testData/anonymous_1.kt
similarity index 100%
rename from idea/testData/templates/anonymous_1.kt
rename to idea/idea-live-templates/testData/anonymous_1.kt
diff --git a/idea/testData/templates/anonymous_2.exp.kt b/idea/idea-live-templates/testData/anonymous_2.exp.kt
similarity index 100%
rename from idea/testData/templates/anonymous_2.exp.kt
rename to idea/idea-live-templates/testData/anonymous_2.exp.kt
diff --git a/idea/testData/templates/anonymous_2.kt b/idea/idea-live-templates/testData/anonymous_2.kt
similarity index 100%
rename from idea/testData/templates/anonymous_2.kt
rename to idea/idea-live-templates/testData/anonymous_2.kt
diff --git a/idea/testData/templates/closure.exp.kt b/idea/idea-live-templates/testData/closure.exp.kt
similarity index 100%
rename from idea/testData/templates/closure.exp.kt
rename to idea/idea-live-templates/testData/closure.exp.kt
diff --git a/idea/testData/templates/closure.kt b/idea/idea-live-templates/testData/closure.kt
similarity index 100%
rename from idea/testData/templates/closure.kt
rename to idea/idea-live-templates/testData/closure.kt
diff --git a/idea/testData/templates/context/InDocComment.kt b/idea/idea-live-templates/testData/context/InDocComment.kt
similarity index 100%
rename from idea/testData/templates/context/InDocComment.kt
rename to idea/idea-live-templates/testData/context/InDocComment.kt
diff --git a/idea/testData/templates/context/InExpression.kt b/idea/idea-live-templates/testData/context/InExpression.kt
similarity index 100%
rename from idea/testData/templates/context/InExpression.kt
rename to idea/idea-live-templates/testData/context/InExpression.kt
diff --git a/idea/testData/templates/context/TopLevel.kt b/idea/idea-live-templates/testData/context/TopLevel.kt
similarity index 100%
rename from idea/testData/templates/context/TopLevel.kt
rename to idea/idea-live-templates/testData/context/TopLevel.kt
diff --git a/idea/testData/templates/exfun.exp.kt b/idea/idea-live-templates/testData/exfun.exp.kt
similarity index 100%
rename from idea/testData/templates/exfun.exp.kt
rename to idea/idea-live-templates/testData/exfun.exp.kt
diff --git a/idea/testData/templates/exfun.kt b/idea/idea-live-templates/testData/exfun.kt
similarity index 100%
rename from idea/testData/templates/exfun.kt
rename to idea/idea-live-templates/testData/exfun.kt
diff --git a/idea/testData/templates/exval.exp.kt b/idea/idea-live-templates/testData/exval.exp.kt
similarity index 100%
rename from idea/testData/templates/exval.exp.kt
rename to idea/idea-live-templates/testData/exval.exp.kt
diff --git a/idea/testData/templates/exval.kt b/idea/idea-live-templates/testData/exval.kt
similarity index 100%
rename from idea/testData/templates/exval.kt
rename to idea/idea-live-templates/testData/exval.kt
diff --git a/idea/testData/templates/exvar.exp.kt b/idea/idea-live-templates/testData/exvar.exp.kt
similarity index 100%
rename from idea/testData/templates/exvar.exp.kt
rename to idea/idea-live-templates/testData/exvar.exp.kt
diff --git a/idea/testData/templates/exvar.kt b/idea/idea-live-templates/testData/exvar.kt
similarity index 100%
rename from idea/testData/templates/exvar.kt
rename to idea/idea-live-templates/testData/exvar.kt
diff --git a/idea/testData/templates/fun0.exp.kt b/idea/idea-live-templates/testData/fun0.exp.kt
similarity index 100%
rename from idea/testData/templates/fun0.exp.kt
rename to idea/idea-live-templates/testData/fun0.exp.kt
diff --git a/idea/testData/templates/fun0.kt b/idea/idea-live-templates/testData/fun0.kt
similarity index 100%
rename from idea/testData/templates/fun0.kt
rename to idea/idea-live-templates/testData/fun0.kt
diff --git a/idea/testData/templates/fun1.exp.kt b/idea/idea-live-templates/testData/fun1.exp.kt
similarity index 100%
rename from idea/testData/templates/fun1.exp.kt
rename to idea/idea-live-templates/testData/fun1.exp.kt
diff --git a/idea/testData/templates/fun1.kt b/idea/idea-live-templates/testData/fun1.kt
similarity index 100%
rename from idea/testData/templates/fun1.kt
rename to idea/idea-live-templates/testData/fun1.kt
diff --git a/idea/testData/templates/fun2.exp.kt b/idea/idea-live-templates/testData/fun2.exp.kt
similarity index 100%
rename from idea/testData/templates/fun2.exp.kt
rename to idea/idea-live-templates/testData/fun2.exp.kt
diff --git a/idea/testData/templates/fun2.kt b/idea/idea-live-templates/testData/fun2.kt
similarity index 100%
rename from idea/testData/templates/fun2.kt
rename to idea/idea-live-templates/testData/fun2.kt
diff --git a/idea/testData/templates/ifn.exp.kt b/idea/idea-live-templates/testData/ifn.exp.kt
similarity index 100%
rename from idea/testData/templates/ifn.exp.kt
rename to idea/idea-live-templates/testData/ifn.exp.kt
diff --git a/idea/testData/templates/ifn.kt b/idea/idea-live-templates/testData/ifn.kt
similarity index 100%
rename from idea/testData/templates/ifn.kt
rename to idea/idea-live-templates/testData/ifn.kt
diff --git a/idea/testData/templates/inn.exp.kt b/idea/idea-live-templates/testData/inn.exp.kt
similarity index 100%
rename from idea/testData/templates/inn.exp.kt
rename to idea/idea-live-templates/testData/inn.exp.kt
diff --git a/idea/testData/templates/inn.kt b/idea/idea-live-templates/testData/inn.kt
similarity index 100%
rename from idea/testData/templates/inn.kt
rename to idea/idea-live-templates/testData/inn.kt
diff --git a/idea/testData/templates/interface.exp.kt b/idea/idea-live-templates/testData/interface.exp.kt
similarity index 100%
rename from idea/testData/templates/interface.exp.kt
rename to idea/idea-live-templates/testData/interface.exp.kt
diff --git a/idea/testData/templates/interface.kt b/idea/idea-live-templates/testData/interface.kt
similarity index 100%
rename from idea/testData/templates/interface.kt
rename to idea/idea-live-templates/testData/interface.kt
diff --git a/idea/testData/templates/iter.exp.kt b/idea/idea-live-templates/testData/iter.exp.kt
similarity index 100%
rename from idea/testData/templates/iter.exp.kt
rename to idea/idea-live-templates/testData/iter.exp.kt
diff --git a/idea/testData/templates/iter.kt b/idea/idea-live-templates/testData/iter.kt
similarity index 100%
rename from idea/testData/templates/iter.kt
rename to idea/idea-live-templates/testData/iter.kt
diff --git a/idea/testData/templates/main.exp.kt b/idea/idea-live-templates/testData/main.exp.kt
similarity index 100%
rename from idea/testData/templates/main.exp.kt
rename to idea/idea-live-templates/testData/main.exp.kt
diff --git a/idea/testData/templates/main.kt b/idea/idea-live-templates/testData/main.kt
similarity index 100%
rename from idea/testData/templates/main.kt
rename to idea/idea-live-templates/testData/main.kt
diff --git a/idea/testData/templates/serr.exp.kt b/idea/idea-live-templates/testData/serr.exp.kt
similarity index 100%
rename from idea/testData/templates/serr.exp.kt
rename to idea/idea-live-templates/testData/serr.exp.kt
diff --git a/idea/testData/templates/serr.kt b/idea/idea-live-templates/testData/serr.kt
similarity index 100%
rename from idea/testData/templates/serr.kt
rename to idea/idea-live-templates/testData/serr.kt
diff --git a/idea/testData/templates/singleton.exp.kt b/idea/idea-live-templates/testData/singleton.exp.kt
similarity index 100%
rename from idea/testData/templates/singleton.exp.kt
rename to idea/idea-live-templates/testData/singleton.exp.kt
diff --git a/idea/testData/templates/singleton.kt b/idea/idea-live-templates/testData/singleton.kt
similarity index 100%
rename from idea/testData/templates/singleton.kt
rename to idea/idea-live-templates/testData/singleton.kt
diff --git a/idea/testData/templates/sout.exp.kt b/idea/idea-live-templates/testData/sout.exp.kt
similarity index 100%
rename from idea/testData/templates/sout.exp.kt
rename to idea/idea-live-templates/testData/sout.exp.kt
diff --git a/idea/testData/templates/sout.kt b/idea/idea-live-templates/testData/sout.kt
similarity index 100%
rename from idea/testData/templates/sout.kt
rename to idea/idea-live-templates/testData/sout.kt
diff --git a/idea/testData/templates/sout_AfterSemicolon.exp.kt b/idea/idea-live-templates/testData/sout_AfterSemicolon.exp.kt
similarity index 100%
rename from idea/testData/templates/sout_AfterSemicolon.exp.kt
rename to idea/idea-live-templates/testData/sout_AfterSemicolon.exp.kt
diff --git a/idea/testData/templates/sout_AfterSemicolon.kt b/idea/idea-live-templates/testData/sout_AfterSemicolon.kt
similarity index 100%
rename from idea/testData/templates/sout_AfterSemicolon.kt
rename to idea/idea-live-templates/testData/sout_AfterSemicolon.kt
diff --git a/idea/testData/templates/sout_BeforeBinary.exp.kt b/idea/idea-live-templates/testData/sout_BeforeBinary.exp.kt
similarity index 100%
rename from idea/testData/templates/sout_BeforeBinary.exp.kt
rename to idea/idea-live-templates/testData/sout_BeforeBinary.exp.kt
diff --git a/idea/testData/templates/sout_BeforeBinary.kt b/idea/idea-live-templates/testData/sout_BeforeBinary.kt
similarity index 100%
rename from idea/testData/templates/sout_BeforeBinary.kt
rename to idea/idea-live-templates/testData/sout_BeforeBinary.kt
diff --git a/idea/testData/templates/sout_BeforeCall.exp.kt b/idea/idea-live-templates/testData/sout_BeforeCall.exp.kt
similarity index 100%
rename from idea/testData/templates/sout_BeforeCall.exp.kt
rename to idea/idea-live-templates/testData/sout_BeforeCall.exp.kt
diff --git a/idea/testData/templates/sout_BeforeCall.kt b/idea/idea-live-templates/testData/sout_BeforeCall.kt
similarity index 100%
rename from idea/testData/templates/sout_BeforeCall.kt
rename to idea/idea-live-templates/testData/sout_BeforeCall.kt
diff --git a/idea/testData/templates/sout_BeforeCallSpace.exp.kt b/idea/idea-live-templates/testData/sout_BeforeCallSpace.exp.kt
similarity index 100%
rename from idea/testData/templates/sout_BeforeCallSpace.exp.kt
rename to idea/idea-live-templates/testData/sout_BeforeCallSpace.exp.kt
diff --git a/idea/testData/templates/sout_BeforeCallSpace.kt b/idea/idea-live-templates/testData/sout_BeforeCallSpace.kt
similarity index 100%
rename from idea/testData/templates/sout_BeforeCallSpace.kt
rename to idea/idea-live-templates/testData/sout_BeforeCallSpace.kt
diff --git a/idea/testData/templates/sout_BeforeQualifiedCall.exp.kt b/idea/idea-live-templates/testData/sout_BeforeQualifiedCall.exp.kt
similarity index 100%
rename from idea/testData/templates/sout_BeforeQualifiedCall.exp.kt
rename to idea/idea-live-templates/testData/sout_BeforeQualifiedCall.exp.kt
diff --git a/idea/testData/templates/sout_BeforeQualifiedCall.kt b/idea/idea-live-templates/testData/sout_BeforeQualifiedCall.kt
similarity index 100%
rename from idea/testData/templates/sout_BeforeQualifiedCall.kt
rename to idea/idea-live-templates/testData/sout_BeforeQualifiedCall.kt
diff --git a/idea/testData/templates/sout_InCallArguments.exp.kt b/idea/idea-live-templates/testData/sout_InCallArguments.exp.kt
similarity index 100%
rename from idea/testData/templates/sout_InCallArguments.exp.kt
rename to idea/idea-live-templates/testData/sout_InCallArguments.exp.kt
diff --git a/idea/testData/templates/sout_InCallArguments.kt b/idea/idea-live-templates/testData/sout_InCallArguments.kt
similarity index 100%
rename from idea/testData/templates/sout_InCallArguments.kt
rename to idea/idea-live-templates/testData/sout_InCallArguments.kt
diff --git a/idea/testData/templates/soutp.exp.kt b/idea/idea-live-templates/testData/soutp.exp.kt
similarity index 100%
rename from idea/testData/templates/soutp.exp.kt
rename to idea/idea-live-templates/testData/soutp.exp.kt
diff --git a/idea/testData/templates/soutp.kt b/idea/idea-live-templates/testData/soutp.kt
similarity index 100%
rename from idea/testData/templates/soutp.kt
rename to idea/idea-live-templates/testData/soutp.kt
diff --git a/idea/testData/templates/soutv.exp.kt b/idea/idea-live-templates/testData/soutv.exp.kt
similarity index 100%
rename from idea/testData/templates/soutv.exp.kt
rename to idea/idea-live-templates/testData/soutv.exp.kt
diff --git a/idea/testData/templates/soutv.kt b/idea/idea-live-templates/testData/soutv.kt
similarity index 100%
rename from idea/testData/templates/soutv.kt
rename to idea/idea-live-templates/testData/soutv.kt
diff --git a/idea/testData/templates/void.exp.kt b/idea/idea-live-templates/testData/void.exp.kt
similarity index 100%
rename from idea/testData/templates/void.exp.kt
rename to idea/idea-live-templates/testData/void.exp.kt
diff --git a/idea/testData/templates/void.kt b/idea/idea-live-templates/testData/void.kt
similarity index 100%
rename from idea/testData/templates/void.kt
rename to idea/idea-live-templates/testData/void.kt
diff --git a/idea/idea-live-templates/tests/org/jetbrains/kotlin/idea/liveTemplates/LiveTemplatesContextTest.kt b/idea/idea-live-templates/tests/org/jetbrains/kotlin/idea/liveTemplates/LiveTemplatesContextTest.kt
index cedd09a8341..379e847364d 100644
--- a/idea/idea-live-templates/tests/org/jetbrains/kotlin/idea/liveTemplates/LiveTemplatesContextTest.kt
+++ b/idea/idea-live-templates/tests/org/jetbrains/kotlin/idea/liveTemplates/LiveTemplatesContextTest.kt
@@ -19,12 +19,11 @@ package org.jetbrains.kotlin.idea.liveTemplates
import com.intellij.codeInsight.template.TemplateContextType
import com.intellij.testFramework.UsefulTestCase
import org.jetbrains.kotlin.idea.test.KotlinLightCodeInsightFixtureTestCase
-import org.jetbrains.kotlin.idea.test.PluginTestCaseBase
import java.io.File
public class LiveTemplatesContextTest : KotlinLightCodeInsightFixtureTestCase() {
override fun getTestDataPath(): String =
- File(PluginTestCaseBase.getTestDataPathBase(), "/templates/context").getPath() + File.separator
+ File(TEST_DATA_BASE_PATH, "/context").path + File.separator
public fun testInDocComment() {
myFixture.configureByFile(getTestName(false) + ".kt")
diff --git a/idea/idea-live-templates/tests/org/jetbrains/kotlin/idea/liveTemplates/LiveTemplatesTest.java b/idea/idea-live-templates/tests/org/jetbrains/kotlin/idea/liveTemplates/LiveTemplatesTest.java
deleted file mode 100644
index f5e4a22f032..00000000000
--- a/idea/idea-live-templates/tests/org/jetbrains/kotlin/idea/liveTemplates/LiveTemplatesTest.java
+++ /dev/null
@@ -1,337 +0,0 @@
-/*
- * Copyright 2010-2015 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 org.jetbrains.kotlin.idea.liveTemplates;
-
-import com.intellij.codeInsight.lookup.LookupElement;
-import com.intellij.codeInsight.lookup.LookupEx;
-import com.intellij.codeInsight.lookup.LookupManager;
-import com.intellij.codeInsight.template.TemplateManager;
-import com.intellij.codeInsight.template.impl.TemplateManagerImpl;
-import com.intellij.codeInsight.template.impl.TemplateState;
-import com.intellij.ide.DataManager;
-import com.intellij.openapi.application.ApplicationManager;
-import com.intellij.openapi.command.CommandProcessor;
-import com.intellij.openapi.editor.actionSystem.EditorActionHandler;
-import com.intellij.openapi.editor.actionSystem.EditorActionManager;
-import com.intellij.testFramework.LightProjectDescriptor;
-import com.intellij.util.ArrayUtil;
-import com.intellij.util.ui.UIUtil;
-import junit.framework.TestCase;
-import org.jetbrains.annotations.NonNls;
-import org.jetbrains.annotations.NotNull;
-import org.jetbrains.kotlin.idea.test.KotlinLightCodeInsightFixtureTestCase;
-import org.jetbrains.kotlin.idea.test.KotlinWithJdkAndRuntimeLightProjectDescriptor;
-import org.jetbrains.kotlin.idea.test.PluginTestCaseBase;
-
-import java.io.File;
-import java.util.ArrayList;
-import java.util.Arrays;
-
-public class LiveTemplatesTest extends KotlinLightCodeInsightFixtureTestCase {
- @Override
- protected void setUp() {
- super.setUp();
- myFixture.setTestDataPath(new File(PluginTestCaseBase.getTestDataPathBase(), "/templates").getPath() + File.separator);
- ((TemplateManagerImpl) TemplateManager.getInstance(getProject())).setTemplateTesting(true);
- }
-
- @Override
- protected void tearDown() {
- ((TemplateManagerImpl) TemplateManager.getInstance(getProject())).setTemplateTesting(false);
- super.tearDown();
- }
-
- public void testSout() {
- paremeterless();
- }
-
- public void testSout_BeforeCall() {
- paremeterless();
- }
-
- public void testSout_BeforeCallSpace() {
- paremeterless();
- }
-
- public void testSout_BeforeBinary() {
- paremeterless();
- }
-
- public void testSout_InCallArguments() {
- paremeterless();
- }
-
- public void testSout_BeforeQualifiedCall() {
- paremeterless();
- }
-
- public void testSout_AfterSemicolon() {
- paremeterless();
- }
-
- public void testSerr() {
- paremeterless();
- }
-
- public void testMain() {
- paremeterless();
- }
-
- public void testSoutv() {
- start();
-
- assertStringItems("args", "x", "y");
- typeAndNextTab("y");
-
- checkAfter();
- }
-
- public void testSoutp() {
- paremeterless();
- }
-
- public void testFun0() {
- start();
-
- type("foo");
- nextTab(2);
-
- checkAfter();
- }
-
- public void testFun1() {
- start();
-
- type("foo");
- nextTab(4);
-
- checkAfter();
- }
-
- public void testFun2() {
- start();
-
- type("foo");
- nextTab(6);
-
- checkAfter();
- }
-
- public void testExfun() {
- start();
-
- typeAndNextTab("Int");
- typeAndNextTab("foo");
- typeAndNextTab("arg : Int");
- nextTab();
-
- checkAfter();
- }
-
- public void testExval() {
- start();
-
- typeAndNextTab("Int");
- nextTab();
- typeAndNextTab("Int");
-
- checkAfter();
- }
-
- public void testExvar() {
- start();
-
- typeAndNextTab("Int");
- nextTab();
- typeAndNextTab("Int");
-
- checkAfter();
- }
-
- public void testClosure() {
- start();
-
- typeAndNextTab("param");
- nextTab();
-
- checkAfter();
- }
-
- public void testInterface() {
- start();
-
- typeAndNextTab("SomeTrait");
-
- checkAfter();
- }
-
- public void testSingleton() {
- start();
-
- typeAndNextTab("MySingleton");
-
- checkAfter();
- }
-
- public void testVoid() {
- start();
-
- typeAndNextTab("foo");
- typeAndNextTab("x : Int");
-
- checkAfter();
- }
-
- public void testIter() {
- start();
-
- assertStringItems("args", "myList", "o", "str", "stream");
- type("args");
- nextTab(2);
-
- checkAfter();
- }
-
- public void testAnonymous_1() {
- start();
-
- typeAndNextTab("Runnable");
-
- checkAfter();
- }
-
- public void testAnonymous_2() {
- start();
-
- typeAndNextTab("Thread");
-
- checkAfter();
- }
-
- private void doTestIfnInn() {
- start();
-
- assertStringItems("b", "t", "y");
- typeAndNextTab("b");
-
- checkAfter();
- }
-
- public void testIfn() {
- doTestIfnInn();
- }
-
- public void testInn() {
- doTestIfnInn();
- }
-
- private void paremeterless() {
- start();
-
- checkAfter();
- }
-
- private void start() {
- myFixture.configureByFile(getTestName(true) + ".kt");
- myFixture.type(getTemplateName());
-
- doAction("ExpandLiveTemplateByTab");
- }
-
- private String getTemplateName() {
- String testName = getTestName(true);
- if (testName.contains("_")) {
- return testName.substring(0, testName.indexOf("_"));
- }
- return testName;
- }
-
- private void checkAfter() {
- TestCase.assertNull(getTemplateState());
- myFixture.checkResultByFile(getTestName(true) + ".exp.kt", true);
- }
-
- private void typeAndNextTab(String s) {
- type(s);
- nextTab();
- }
-
- private void type(String s) {
- myFixture.type(s);
- }
-
- private void nextTab() {
- UIUtil.invokeAndWaitIfNeeded(new Runnable() {
- @Override
- public void run() {
- CommandProcessor.getInstance().executeCommand(getProject(), new Runnable() {
- @Override
- public void run() {
- ApplicationManager.getApplication().runWriteAction(new Runnable() {
- @Override
- public void run() {
- getTemplateState().nextTab();
- }
- });
- }
- }, "nextTab", null);
- }
- });
- }
-
- private void nextTab(int times) {
- for (int i = 0; i < times; i++) {
- nextTab();
- }
- }
-
- private TemplateState getTemplateState() {
- return TemplateManagerImpl.getTemplateState(myFixture.getEditor());
- }
-
- @NotNull
- @Override
- protected LightProjectDescriptor getProjectDescriptor() {
- return KotlinWithJdkAndRuntimeLightProjectDescriptor.INSTANCE;
- }
-
- private void doAction(@NotNull String actionId) {
- EditorActionManager actionManager = EditorActionManager.getInstance();
- EditorActionHandler actionHandler = actionManager.getActionHandler(actionId);
- actionHandler.execute(myFixture.getEditor(), DataManager.getInstance().getDataContext(myFixture.getEditor().getComponent()));
- }
-
- private void assertStringItems(@NonNls String... items) {
- TestCase.assertEquals(Arrays.asList(items), Arrays.asList(getItemStringsSorted()));
- }
-
- private String[] getItemStrings() {
- LookupEx lookup = LookupManager.getActiveLookup(myFixture.getEditor());
- TestCase.assertNotNull(lookup);
- ArrayList result = new ArrayList();
- for (LookupElement element : lookup.getItems()) {
- result.add(element.getLookupString());
- }
- return ArrayUtil.toStringArray(result);
- }
-
- private String[] getItemStringsSorted() {
- String[] items = getItemStrings();
- Arrays.sort(items);
- return items;
- }
-}
diff --git a/idea/idea-live-templates/tests/org/jetbrains/kotlin/idea/liveTemplates/LiveTemplatesTest.kt b/idea/idea-live-templates/tests/org/jetbrains/kotlin/idea/liveTemplates/LiveTemplatesTest.kt
new file mode 100644
index 00000000000..dfc5b924305
--- /dev/null
+++ b/idea/idea-live-templates/tests/org/jetbrains/kotlin/idea/liveTemplates/LiveTemplatesTest.kt
@@ -0,0 +1,321 @@
+/*
+ * Copyright 2010-2015 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 org.jetbrains.kotlin.idea.liveTemplates
+
+import com.intellij.codeInsight.lookup.LookupManager
+import com.intellij.codeInsight.template.TemplateManager
+import com.intellij.codeInsight.template.impl.TemplateManagerImpl
+import com.intellij.codeInsight.template.impl.TemplateState
+import com.intellij.ide.DataManager
+import com.intellij.openapi.application.ApplicationManager
+import com.intellij.openapi.command.CommandProcessor
+import com.intellij.openapi.editor.actionSystem.EditorActionManager
+import com.intellij.testFramework.LightProjectDescriptor
+import com.intellij.util.ArrayUtil
+import com.intellij.util.ui.UIUtil
+import junit.framework.TestCase
+import org.jetbrains.annotations.NonNls
+import org.jetbrains.kotlin.idea.test.KotlinLightCodeInsightFixtureTestCase
+import org.jetbrains.kotlin.idea.test.KotlinWithJdkAndRuntimeLightProjectDescriptor
+import java.io.File
+import java.util.*
+
+class LiveTemplatesTest : KotlinLightCodeInsightFixtureTestCase() {
+ override fun setUp() {
+ super.setUp()
+ myFixture.testDataPath = File(TEST_DATA_BASE_PATH).getPath() + File.separator
+ (TemplateManager.getInstance(project) as TemplateManagerImpl).setTemplateTesting(true)
+ }
+
+ override fun tearDown() {
+ (TemplateManager.getInstance(project) as TemplateManagerImpl).setTemplateTesting(false)
+ super.tearDown()
+ }
+
+ fun testSout() {
+ paremeterless()
+ }
+
+ fun testSout_BeforeCall() {
+ paremeterless()
+ }
+
+ fun testSout_BeforeCallSpace() {
+ paremeterless()
+ }
+
+ fun testSout_BeforeBinary() {
+ paremeterless()
+ }
+
+ fun testSout_InCallArguments() {
+ paremeterless()
+ }
+
+ fun testSout_BeforeQualifiedCall() {
+ paremeterless()
+ }
+
+ fun testSout_AfterSemicolon() {
+ paremeterless()
+ }
+
+ fun testSerr() {
+ paremeterless()
+ }
+
+ fun testMain() {
+ paremeterless()
+ }
+
+ fun testSoutv() {
+ start()
+
+ assertStringItems("args", "x", "y")
+ typeAndNextTab("y")
+
+ checkAfter()
+ }
+
+ fun testSoutp() {
+ paremeterless()
+ }
+
+ fun testFun0() {
+ start()
+
+ type("foo")
+ nextTab(2)
+
+ checkAfter()
+ }
+
+ fun testFun1() {
+ start()
+
+ type("foo")
+ nextTab(4)
+
+ checkAfter()
+ }
+
+ fun testFun2() {
+ start()
+
+ type("foo")
+ nextTab(6)
+
+ checkAfter()
+ }
+
+ fun testExfun() {
+ start()
+
+ typeAndNextTab("Int")
+ typeAndNextTab("foo")
+ typeAndNextTab("arg : Int")
+ nextTab()
+
+ checkAfter()
+ }
+
+ fun testExval() {
+ start()
+
+ typeAndNextTab("Int")
+ nextTab()
+ typeAndNextTab("Int")
+
+ checkAfter()
+ }
+
+ fun testExvar() {
+ start()
+
+ typeAndNextTab("Int")
+ nextTab()
+ typeAndNextTab("Int")
+
+ checkAfter()
+ }
+
+ fun testClosure() {
+ start()
+
+ typeAndNextTab("param")
+ nextTab()
+
+ checkAfter()
+ }
+
+ fun testInterface() {
+ start()
+
+ typeAndNextTab("SomeTrait")
+
+ checkAfter()
+ }
+
+ fun testSingleton() {
+ start()
+
+ typeAndNextTab("MySingleton")
+
+ checkAfter()
+ }
+
+ fun testVoid() {
+ start()
+
+ typeAndNextTab("foo")
+ typeAndNextTab("x : Int")
+
+ checkAfter()
+ }
+
+ fun testIter() {
+ start()
+
+ assertStringItems("args", "myList", "o", "str", "stream")
+ type("args")
+ nextTab(2)
+
+ checkAfter()
+ }
+
+ fun testAnonymous_1() {
+ start()
+
+ typeAndNextTab("Runnable")
+
+ checkAfter()
+ }
+
+ fun testAnonymous_2() {
+ start()
+
+ typeAndNextTab("Thread")
+
+ checkAfter()
+ }
+
+ private fun doTestIfnInn() {
+ start()
+
+ assertStringItems("b", "t", "y")
+ typeAndNextTab("b")
+
+ checkAfter()
+ }
+
+ fun testIfn() {
+ doTestIfnInn()
+ }
+
+ fun testInn() {
+ doTestIfnInn()
+ }
+
+ private fun paremeterless() {
+ start()
+
+ checkAfter()
+ }
+
+ private fun start() {
+ myFixture.configureByFile(getTestName(true) + ".kt")
+ myFixture.type(templateName)
+
+ doAction("ExpandLiveTemplateByTab")
+ }
+
+ private val templateName: String
+ get() {
+ val testName = getTestName(true)
+ if (testName.contains("_")) {
+ return testName.substring(0, testName.indexOf("_"))
+ }
+ return testName
+ }
+
+ private fun checkAfter() {
+ TestCase.assertNull(templateState)
+ myFixture.checkResultByFile(getTestName(true) + ".exp.kt", true)
+ }
+
+ private fun typeAndNextTab(s: String) {
+ type(s)
+ nextTab()
+ }
+
+ private fun type(s: String) {
+ myFixture.type(s)
+ }
+
+ private fun nextTab() {
+ val project = project
+ UIUtil.invokeAndWaitIfNeeded(Runnable {
+ CommandProcessor.getInstance().executeCommand(
+ project,
+ {
+ ApplicationManager.getApplication().runWriteAction { templateState!!.nextTab() }
+ },
+ "nextTab",
+ null)
+ })
+ }
+
+ private fun nextTab(times: Int) {
+ for (i in 0..times - 1) {
+ nextTab()
+ }
+ }
+
+ private val templateState: TemplateState?
+ get() = TemplateManagerImpl.getTemplateState(myFixture.editor)
+
+ override fun getProjectDescriptor(): LightProjectDescriptor {
+ return KotlinWithJdkAndRuntimeLightProjectDescriptor.INSTANCE
+ }
+
+ private fun doAction(actionId: String) {
+ val actionManager = EditorActionManager.getInstance()
+ val actionHandler = actionManager.getActionHandler(actionId)
+ actionHandler.execute(myFixture.editor, DataManager.getInstance().getDataContext(myFixture.editor.component))
+ }
+
+ private fun assertStringItems(@NonNls vararg items: String) {
+ TestCase.assertEquals(Arrays.asList(*items), Arrays.asList(*itemStringsSorted))
+ }
+
+ private val itemStrings: Array
+ get() {
+ val lookup = LookupManager.getActiveLookup(myFixture.editor)!!
+ val result = ArrayList()
+ for (element in lookup.items) {
+ result.add(element.lookupString)
+ }
+ return ArrayUtil.toStringArray(result)
+ }
+
+ private val itemStringsSorted: Array
+ get() {
+ val items = itemStrings
+ Arrays.sort(items)
+ return items
+ }
+}
diff --git a/idea/idea-live-templates/tests/org/jetbrains/kotlin/idea/liveTemplates/paths.kt b/idea/idea-live-templates/tests/org/jetbrains/kotlin/idea/liveTemplates/paths.kt
new file mode 100644
index 00000000000..2ce035cc1d0
--- /dev/null
+++ b/idea/idea-live-templates/tests/org/jetbrains/kotlin/idea/liveTemplates/paths.kt
@@ -0,0 +1,23 @@
+/*
+ * Copyright 2010-2015 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 org.jetbrains.kotlin.idea.liveTemplates
+
+import org.jetbrains.kotlin.test.KotlinTestUtils
+
+internal val RELATIVE_TEST_DATA_BASE_PATH = "idea/idea-live-templates/testData"
+
+internal val TEST_DATA_BASE_PATH = KotlinTestUtils.getHomeDirectory() + "/" + RELATIVE_TEST_DATA_BASE_PATH