From 1234ca249509a024ef5d3f489c62b02ca437d01c Mon Sep 17 00:00:00 2001 From: peter Date: Mon, 11 Jul 2011 19:32:13 +0200 Subject: [PATCH] fire action listeners when executing editor actions in tests --- .../codeInsight/completion/JavaAutoPopupTest.groovy | 2 +- .../fixtures/impl/CodeInsightTestFixtureImpl.java | 13 +++++++++---- 2 files changed, 10 insertions(+), 5 deletions(-) diff --git a/java/java-tests/testSrc/com/intellij/codeInsight/completion/JavaAutoPopupTest.groovy b/java/java-tests/testSrc/com/intellij/codeInsight/completion/JavaAutoPopupTest.groovy index 9b1e2583814d..70289990d756 100644 --- a/java/java-tests/testSrc/com/intellij/codeInsight/completion/JavaAutoPopupTest.groovy +++ b/java/java-tests/testSrc/com/intellij/codeInsight/completion/JavaAutoPopupTest.groovy @@ -109,7 +109,7 @@ class JavaAutoPopupTest extends CompletionAutoPopupTestCase { assertOrderedEquals myFixture.lookupElementStrings, "iterable", "iterable2" assertEquals 'iterable', lookup.currentItem.lookupString - myFixture.performEditorAction IdeActions.ACTION_EDITOR_MOVE_CARET_DOWN + edt { myFixture.performEditorAction IdeActions.ACTION_EDITOR_MOVE_CARET_DOWN } assertEquals 'iterable2', lookup.currentItem.lookupString type "r" diff --git a/platform/testFramework/src/com/intellij/testFramework/fixtures/impl/CodeInsightTestFixtureImpl.java b/platform/testFramework/src/com/intellij/testFramework/fixtures/impl/CodeInsightTestFixtureImpl.java index 9e86607efa36..388643056c49 100644 --- a/platform/testFramework/src/com/intellij/testFramework/fixtures/impl/CodeInsightTestFixtureImpl.java +++ b/platform/testFramework/src/com/intellij/testFramework/fixtures/impl/CodeInsightTestFixtureImpl.java @@ -52,10 +52,8 @@ import com.intellij.ide.structureView.newStructureView.StructureViewComponent; import com.intellij.lang.LanguageStructureViewBuilder; import com.intellij.lang.annotation.HighlightSeverity; import com.intellij.openapi.Disposable; -import com.intellij.openapi.actionSystem.AnAction; -import com.intellij.openapi.actionSystem.DataContext; -import com.intellij.openapi.actionSystem.IdeActions; -import com.intellij.openapi.actionSystem.Presentation; +import com.intellij.openapi.actionSystem.*; +import com.intellij.openapi.actionSystem.ex.ActionManagerEx; import com.intellij.openapi.application.ApplicationManager; import com.intellij.openapi.application.ModalityState; import com.intellij.openapi.application.Result; @@ -710,7 +708,14 @@ public class CodeInsightTestFixtureImpl extends BaseFixture implements CodeInsig return false; } + ActionManagerEx managerEx = ActionManagerEx.getInstanceEx(); + AnAction action = managerEx.getAction(actionId); + AnActionEvent event = new AnActionEvent(null, dataContext, ActionPlaces.UNKNOWN, new Presentation(), managerEx, 0); + managerEx.fireBeforeActionPerformed(action, dataContext, event); + handler.execute(getEditor(), dataContext); + + managerEx.fireAfterActionPerformed(action, dataContext, event); return true; }