From fcfdb4b83e67f0fc9b151a26d865495f8a84177a Mon Sep 17 00:00:00 2001 From: "Maxim.Kolmakov" Date: Fri, 12 Jan 2018 16:35:25 +0100 Subject: [PATCH] GUI-67 Can't record actions in mocha run tool window Fix access allowed only from AWT --- .../testGuiFramework/fixtures/EditorFixture.java | 7 ++++++- .../testGuiFramework/fixtures/FileEditorFixture.java | 9 ++++++++- 2 files changed, 14 insertions(+), 2 deletions(-) diff --git a/platform/testGuiFramework/src/com/intellij/testGuiFramework/fixtures/EditorFixture.java b/platform/testGuiFramework/src/com/intellij/testGuiFramework/fixtures/EditorFixture.java index 9a1cd5cf7d1e..b9c6d7b76c22 100644 --- a/platform/testGuiFramework/src/com/intellij/testGuiFramework/fixtures/EditorFixture.java +++ b/platform/testGuiFramework/src/com/intellij/testGuiFramework/fixtures/EditorFixture.java @@ -73,7 +73,7 @@ public class EditorFixture { public final Robot robot; private final IdeFrameFixture myFrame; private final EditorTabsFixture tabs; - private final Editor myEditor; + private Editor myEditor; /** * Constructs a new editor fixture, tied to the given project @@ -210,6 +210,11 @@ public class EditorFixture { return myEditor; } + public void setEditor(Editor editor) { + myEditor = editor; + } + + /** * Returns the contents of the current file, or null if there is no * file open. The caret position is indicated by {@code ^}, and diff --git a/platform/testGuiFramework/src/com/intellij/testGuiFramework/fixtures/FileEditorFixture.java b/platform/testGuiFramework/src/com/intellij/testGuiFramework/fixtures/FileEditorFixture.java index 39fac68b4ef6..97f8d3ac43e5 100644 --- a/platform/testGuiFramework/src/com/intellij/testGuiFramework/fixtures/FileEditorFixture.java +++ b/platform/testGuiFramework/src/com/intellij/testGuiFramework/fixtures/FileEditorFixture.java @@ -12,6 +12,7 @@ import com.intellij.openapi.project.Project; import com.intellij.openapi.util.Ref; import com.intellij.openapi.vfs.VirtualFile; import org.fest.swing.core.Robot; +import org.fest.swing.edt.GuiActionRunner; import org.fest.swing.edt.GuiQuery; import org.fest.swing.edt.GuiTask; import org.fest.swing.timing.Condition; @@ -38,8 +39,14 @@ public class FileEditorFixture extends EditorFixture { private final IdeFrameFixture myFrame; public FileEditorFixture(Robot robot, IdeFrameFixture frame) { - super(robot, FileEditorManager.getInstance(frame.getProject()).getSelectedTextEditor()); + super(robot, null); myManager = FileEditorManager.getInstance(frame.getProject()); + execute(new GuiTask() { + @Override + protected void executeInEDT() { + FileEditorFixture.this.setEditor(myManager.getSelectedTextEditor()); + } + }); myFrame = frame; }