Refactored LiveTemplatesTest to make adding new tests simpler.

This commit is contained in:
Evgeny Gerashchenko
2012-02-13 20:57:05 +04:00
parent 53e643ca33
commit 468d31b5e8
@@ -27,20 +27,36 @@ import java.util.Arrays;
*/ */
public class LiveTemplatesTest extends LightCodeInsightFixtureTestCase { public class LiveTemplatesTest extends LightCodeInsightFixtureTestCase {
public void testIter() { public void testIter() {
start();
assertStringItems("args", "collection", "myList", "str", "stream");
type("args");
nextTab();
nextTab();
checkAfter();
}
private void start() {
myFixture.configureByFile(getTestName(false) + ".kt"); myFixture.configureByFile(getTestName(false) + ".kt");
myFixture.type("iter"); myFixture.type(getTestName(true));
doAction("ExpandLiveTemplateByTab"); doAction("ExpandLiveTemplateByTab");
assertStringItems("args", "collection", "myList", "str", "stream"); }
myFixture.type("args"); private void checkAfter() {
getTemplateState().nextTab();
getTemplateState().nextTab();
assertNull(getTemplateState()); assertNull(getTemplateState());
myFixture.checkResultByFile(getTestName(false) + ".exp.kt"); myFixture.checkResultByFile(getTestName(false) + ".exp.kt");
} }
private void type(String s) {
myFixture.type(s);
}
private void nextTab() {
getTemplateState().nextTab();
}
private TemplateState getTemplateState() { private TemplateState getTemplateState() {
return TemplateManagerImpl.getTemplateState(myFixture.getEditor()); return TemplateManagerImpl.getTemplateState(myFixture.getEditor());
} }
@@ -71,10 +87,8 @@ public class LiveTemplatesTest extends LightCodeInsightFixtureTestCase {
@Override @Override
protected void setUp() throws Exception { protected void setUp() throws Exception {
super.setUp(); super.setUp();
myFixture.setTestDataPath(new File(PluginTestCaseBase.getTestDataPathBase(), "/templates").getPath() + myFixture.setTestDataPath(new File(PluginTestCaseBase.getTestDataPathBase(), "/templates").getPath() +
File.separator); File.separator);
((TemplateManagerImpl) TemplateManager.getInstance(getProject())).setTemplateTesting(true); ((TemplateManagerImpl) TemplateManager.getInstance(getProject())).setTemplateTesting(true);
} }