Search in sources :

Example 11 with TestActionEvent

use of com.intellij.testFramework.TestActionEvent in project intellij-community by JetBrains.

the class CCShowPreviewTest method doTest.

private void doTest(String name) {
    VirtualFile file = configureByTaskFile(name + CCTestsUtil.BEFORE_POSTFIX);
    CCShowPreview action = new CCShowPreview();
    TestActionEvent e = getActionEvent(action, PsiManager.getInstance(getProject()).findFile(file));
    action.beforeActionPerformedUpdate(e);
    assertTrue(e.getPresentation().isEnabled() && e.getPresentation().isVisible());
    action.actionPerformed(e);
    Editor editor = EditorFactory.getInstance().getAllEditors()[1];
    Pair<Document, List<AnswerPlaceholder>> pair = getPlaceholders(name + CCTestsUtil.AFTER_POSTFIX);
    assertEquals("Files don't match", editor.getDocument().getText(), pair.getFirst().getText());
    for (AnswerPlaceholder placeholder : pair.getSecond()) {
        assertNotNull("No highlighter for placeholder:" + CCTestsUtil.getPlaceholderPresentation(placeholder), getHighlighter(editor.getMarkupModel(), placeholder));
    }
}
Also used : VirtualFile(com.intellij.openapi.vfs.VirtualFile) AnswerPlaceholder(com.jetbrains.edu.learning.courseFormat.AnswerPlaceholder) List(java.util.List) Editor(com.intellij.openapi.editor.Editor) Document(com.intellij.openapi.editor.Document) TestActionEvent(com.intellij.testFramework.TestActionEvent)

Example 12 with TestActionEvent

use of com.intellij.testFramework.TestActionEvent in project intellij-community by JetBrains.

the class CCTaskFileActionTest method launchAction.

private void launchAction(VirtualFile virtualFile, AnAction action) {
    TestActionEvent e = getActionEvent(virtualFile, action);
    action.beforeActionPerformedUpdate(e);
    assertTrue(e.getPresentation().isEnabled() && e.getPresentation().isVisible());
    action.actionPerformed(e);
}
Also used : TestActionEvent(com.intellij.testFramework.TestActionEvent)

Example 13 with TestActionEvent

use of com.intellij.testFramework.TestActionEvent in project android by JetBrains.

the class AndroidGotoRelatedTest method doGotoRelatedFile.

private List<GotoRelatedItem> doGotoRelatedFile(VirtualFile file) {
    myFixture.configureFromExistingVirtualFile(file);
    final GotoRelatedSymbolAction action = new GotoRelatedSymbolAction();
    final TestActionEvent e = new TestActionEvent(action);
    action.beforeActionPerformedUpdate(e);
    final Presentation presentation = e.getPresentation();
    assertTrue(presentation.isEnabled() && presentation.isVisible());
    return GotoRelatedSymbolAction.getItems(myFixture.getFile(), myFixture.getEditor(), null);
}
Also used : GotoRelatedSymbolAction(com.intellij.ide.actions.GotoRelatedSymbolAction) Presentation(com.intellij.openapi.actionSystem.Presentation) TestActionEvent(com.intellij.testFramework.TestActionEvent)

Example 14 with TestActionEvent

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);
}
Also used : AnActionEvent(com.intellij.openapi.actionSystem.AnActionEvent) TestActionEvent(com.intellij.testFramework.TestActionEvent) RenameElementAction(com.intellij.refactoring.actions.RenameElementAction)

Example 15 with TestActionEvent

use of com.intellij.testFramework.TestActionEvent in project android by JetBrains.

the class AndroidRenameTest method checkAndRename.

private void checkAndRename(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.renameElementAtCaret(newName);
}
Also used : AnActionEvent(com.intellij.openapi.actionSystem.AnActionEvent) TestActionEvent(com.intellij.testFramework.TestActionEvent) RenameElementAction(com.intellij.refactoring.actions.RenameElementAction)

Aggregations

TestActionEvent (com.intellij.testFramework.TestActionEvent)16 AnAction (com.intellij.openapi.actionSystem.AnAction)4 AnActionEvent (com.intellij.openapi.actionSystem.AnActionEvent)3 CreateFromTemplateGroup (com.intellij.ide.fileTemplates.actions.CreateFromTemplateGroup)2 FileTemplateManagerImpl (com.intellij.ide.fileTemplates.impl.FileTemplateManagerImpl)2 VirtualFile (com.intellij.openapi.vfs.VirtualFile)2 RenameElementAction (com.intellij.refactoring.actions.RenameElementAction)2 MapDataContext (com.intellij.testFramework.MapDataContext)2 TestDataProvider (com.intellij.testFramework.TestDataProvider)2 Arrays (java.util.Arrays)2 List (java.util.List)2 GutterMark (com.intellij.codeInsight.daemon.GutterMark)1 IdeBundle (com.intellij.ide.IdeBundle)1 GotoRelatedSymbolAction (com.intellij.ide.actions.GotoRelatedSymbolAction)1 CreateFromTemplateAction (com.intellij.ide.fileTemplates.actions.CreateFromTemplateAction)1 BrowseTypeHierarchyAction (com.intellij.ide.hierarchy.actions.BrowseTypeHierarchyAction)1 LanguageFormatting (com.intellij.lang.LanguageFormatting)1 LanguageImportStatements (com.intellij.lang.LanguageImportStatements)1 com.intellij.openapi.actionSystem (com.intellij.openapi.actionSystem)1 ActionGroup (com.intellij.openapi.actionSystem.ActionGroup)1