From 7d55ac958e23038f1916e0cd604d9829b6505085 Mon Sep 17 00:00:00 2001 From: Alexander Zolotov Date: Mon, 30 May 2016 15:29:59 +0300 Subject: [PATCH] Live Templates: do not wrap tests with write command --- .../template/ClassNameDotInTemplate-out.java | 2 +- .../FinishTemplateVariantWithDot-out.java | 2 +- .../template/LiveTemplateTest.groovy | 32 ++++--------------- 3 files changed, 9 insertions(+), 27 deletions(-) diff --git a/java/java-tests/testData/codeInsight/template/ClassNameDotInTemplate-out.java b/java/java-tests/testData/codeInsight/template/ClassNameDotInTemplate-out.java index 504e438cac54..ecaa70065a1f 100644 --- a/java/java-tests/testData/codeInsight/template/ClassNameDotInTemplate-out.java +++ b/java/java-tests/testData/codeInsight/template/ClassNameDotInTemplate-out.java @@ -3,6 +3,6 @@ import java.io.File; class Foo { { File file = new File("some.txt"); - System.out.println("file = " + File.); + System.out.println("File. = " + File.); } } \ No newline at end of file diff --git a/java/java-tests/testData/codeInsight/template/FinishTemplateVariantWithDot-out.java b/java/java-tests/testData/codeInsight/template/FinishTemplateVariantWithDot-out.java index d89c60000cf6..be828fdb057d 100644 --- a/java/java-tests/testData/codeInsight/template/FinishTemplateVariantWithDot-out.java +++ b/java/java-tests/testData/codeInsight/template/FinishTemplateVariantWithDot-out.java @@ -3,6 +3,6 @@ import java.io.File; class Foo { { File file = new File("some.txt"); - System.out.println("file = " + file.); + System.out.println("file. = " + file.); } } \ No newline at end of file diff --git a/java/java-tests/testSrc/com/intellij/codeInsight/template/LiveTemplateTest.groovy b/java/java-tests/testSrc/com/intellij/codeInsight/template/LiveTemplateTest.groovy index 0b8020a0b1b1..5cf4f3996813 100644 --- a/java/java-tests/testSrc/com/intellij/codeInsight/template/LiveTemplateTest.groovy +++ b/java/java-tests/testSrc/com/intellij/codeInsight/template/LiveTemplateTest.groovy @@ -20,8 +20,6 @@ import com.intellij.codeInsight.CodeInsightSettings import com.intellij.codeInsight.completion.CompletionType import com.intellij.codeInsight.lookup.Lookup import com.intellij.codeInsight.lookup.LookupManager -import com.intellij.codeInsight.lookup.impl.LookupImpl -import com.intellij.codeInsight.lookup.impl.LookupManagerImpl import com.intellij.codeInsight.template.impl.* import com.intellij.codeInsight.template.macro.* import com.intellij.openapi.actionSystem.IdeActions @@ -82,7 +80,7 @@ public class LiveTemplateTest extends LightCodeInsightFixtureTestCase { ((TemplateImpl)template).getTemplateContext().setEnabled(contextType, true); CodeInsightTestUtil.addTemplate(template, testRootDisposable) - manager.startTemplate(editor, (char)'\t'); + writeCommand { manager.startTemplate(editor, (char)'\t') } UIUtil.dispatchAllInvocationEvents() checkResultByText(expected); } @@ -370,8 +368,8 @@ class Outer { public void testIter() throws Throwable { configure(); startTemplate("iter", "iterations") - state.nextTab(); - ((LookupImpl)LookupManagerImpl.getActiveLookup(getEditor())).finishLookup(Lookup.AUTO_INSERT_SELECT_CHAR); + writeCommand { state.nextTab() } + myFixture.finishLookup(Lookup.AUTO_INSERT_SELECT_CHAR) checkResult(); } @@ -422,7 +420,7 @@ class Outer { public void testIter1() throws Throwable { configure(); startTemplate("iter", "iterations") - state.nextTab(); + myFixture.performEditorAction("NextTemplateVariable") checkResult(); } @@ -590,22 +588,6 @@ class Outer { return TemplateManagerImpl.isApplicable(myFixture.getFile(), getEditor().getCaretModel().getOffset(), inst); } - @Override - protected void invokeTestRunnable(@NotNull final Runnable runnable) { - if (name in ["testNavigationActionsDontTerminateTemplate", "testTemplateWithEnd", "testDisappearingVar", - "test do replace macro value with empty result", - "test do not replace macro value with null result", - "test escape string characters in soutv", - "test escape shouldn't move caret to the end marker", - "test finish template on moving caret by completion insert handler", - "test do not replace macro value with empty result"]) { - runnable.run(); - return; - } - - writeCommand(runnable) - } - private static writeCommand(Runnable runnable) { WriteCommandAction.runWriteCommandAction(null, runnable) } @@ -1087,7 +1069,7 @@ class Foo {{ myFixture.type '\n' myFixture.checkResult """ class Foo {{ - System.out.println("true = " + abc); + System.out.println("abc = " + abc); }} """ @@ -1100,11 +1082,11 @@ class Foo {{ }} """ myFixture.type 'soutv\tabc' - myFixture.editor.caretModel.moveCaretRelatively(3, 0, false, false, false) + myFixture.editor.caretModel.moveCaretRelatively(2, 0, false, false, false) myFixture.type '\t' myFixture.checkResult """ class Foo {{ - System.out.println("true = " + abc); + System.out.println("abc = " + abc); }} """ }