Search in sources :

Example 1 with FileTemplateManagerImpl

use of com.intellij.ide.fileTemplates.impl.FileTemplateManagerImpl in project intellij-community by JetBrains.

the class JavaFileTemplatesTest method testManyTemplates.

public void testManyTemplates() {
    FileTemplateManagerImpl templateManager = (FileTemplateManagerImpl) FileTemplateManager.getInstance(getProject());
    templateManager.getState().RECENT_TEMPLATES.clear();
    FileTemplate[] before = templateManager.getAllTemplates();
    try {
        for (int i = 0; i < 30; i++) {
            templateManager.addTemplate("foo" + i, "java");
        }
        AnAction[] children = new CreateFromTemplateGroup().getChildren(new TestActionEvent(new TestDataProvider(getProject())));
        assertEquals(3, children.length);
        assertTrue(IdeBundle.message("action.from.file.template").equals(children[0].getTemplatePresentation().getText()));
    } finally {
        templateManager.setTemplates(FileTemplateManager.DEFAULT_TEMPLATES_CATEGORY, Arrays.asList(before));
        templateManager.getState().RECENT_TEMPLATES.clear();
    }
}
Also used : TestDataProvider(com.intellij.testFramework.TestDataProvider) FileTemplateManagerImpl(com.intellij.ide.fileTemplates.impl.FileTemplateManagerImpl) AnAction(com.intellij.openapi.actionSystem.AnAction) TestActionEvent(com.intellij.testFramework.TestActionEvent) CreateFromTemplateGroup(com.intellij.ide.fileTemplates.actions.CreateFromTemplateGroup)

Aggregations

CreateFromTemplateGroup (com.intellij.ide.fileTemplates.actions.CreateFromTemplateGroup)1 FileTemplateManagerImpl (com.intellij.ide.fileTemplates.impl.FileTemplateManagerImpl)1 AnAction (com.intellij.openapi.actionSystem.AnAction)1 TestActionEvent (com.intellij.testFramework.TestActionEvent)1 TestDataProvider (com.intellij.testFramework.TestDataProvider)1