use of com.intellij.testFramework.TestActionEvent in project intellij-community by JetBrains.
the class CCTaskFileActionTest method getActionEvent.
@NotNull
private TestActionEvent getActionEvent(VirtualFile virtualFile, AnAction action) {
MapDataContext context = new MapDataContext();
context.put(CommonDataKeys.VIRTUAL_FILE, virtualFile);
context.put(CommonDataKeys.PROJECT, getProject());
return new TestActionEvent(context, action);
}
use of com.intellij.testFramework.TestActionEvent 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();
}
}
use of com.intellij.testFramework.TestActionEvent in project intellij-community by JetBrains.
the class JavaCallHierarchyTest method testActionAvailableInXml.
public void testActionAvailableInXml() throws Exception {
configureByText(XmlFileType.INSTANCE, "<foo>java.lang.Str<caret>ing</foo>");
BrowseTypeHierarchyAction action = new BrowseTypeHierarchyAction();
TestActionEvent e = new TestActionEvent(action);
action.beforeActionPerformedUpdate(e);
assertTrue(e.getPresentation().isEnabled() && e.getPresentation().isVisible());
}
use of com.intellij.testFramework.TestActionEvent in project intellij-community by JetBrains.
the class RunLineMarkerTest method testTestClassWithMain.
public void testTestClassWithMain() throws Exception {
myFixture.addClass("package junit.framework; public class TestCase {}");
myFixture.configureByText("MainTest.java", "public class <caret>MainTest extends junit.framework.TestCase {\n" + " public static void main(String[] args) {\n" + " }\n" + " public void testFoo() {\n" + " }\n" + "}");
List<GutterMark> marks = myFixture.findGuttersAtCaret();
assertEquals(1, marks.size());
GutterIconRenderer mark = (GutterIconRenderer) marks.get(0);
ActionGroup group = mark.getPopupMenuActions();
assertNotNull(group);
TestActionEvent event = new TestActionEvent();
List<AnAction> list = ContainerUtil.findAll(group.getChildren(event), action -> {
TestActionEvent actionEvent = new TestActionEvent();
action.update(actionEvent);
String text = actionEvent.getPresentation().getText();
return text != null && text.startsWith("Run ") && text.endsWith("'");
});
assertEquals(list.toString(), 2, list.size());
list.get(0).update(event);
assertEquals("Run 'MainTest.main()'", event.getPresentation().getText());
list.get(1).update(event);
assertEquals("Run 'MainTest'", event.getPresentation().getText());
}
use of com.intellij.testFramework.TestActionEvent in project android by JetBrains.
the class AndroidRenameTest method checkAndRenameUsingHandler.
private void checkAndRenameUsingHandler(String newName) {
final RenameElementAction action = new RenameElementAction();
final AnActionEvent e = new TestActionEvent(DataManager.getInstance().getDataContext(myFixture.getEditor().getComponent()), action);
action.update(e);
assertTrue(e.getPresentation().isEnabled() && e.getPresentation().isVisible());
// Note: This fails when trying to rename XML attribute values: Use myFixture.renameElementAtCaretUsingHandler() instead!
myFixture.renameElementAtCaretUsingHandler(newName);
}
Aggregations