From d923b3b0bb983d53f10270e4b7da922dd208a337 Mon Sep 17 00:00:00 2001 From: Artem Gainanov Date: Sun, 17 Jun 2018 19:53:49 +0700 Subject: [PATCH] [gui-test] fix a couple of tests We should use JBTerminalPanel instead of EditorComponentImpl when waiting for the text in the run tool window --- .../testGuiFramework/fixtures/TerminalFixture.kt | 14 +++++++++++--- .../fixtures/ToolWindowFixture.java | 2 +- 2 files changed, 12 insertions(+), 4 deletions(-) diff --git a/platform/testGuiFramework/src/com/intellij/testGuiFramework/fixtures/TerminalFixture.kt b/platform/testGuiFramework/src/com/intellij/testGuiFramework/fixtures/TerminalFixture.kt index eeeb3d6e502b..7dbe8d467f7c 100644 --- a/platform/testGuiFramework/src/com/intellij/testGuiFramework/fixtures/TerminalFixture.kt +++ b/platform/testGuiFramework/src/com/intellij/testGuiFramework/fixtures/TerminalFixture.kt @@ -25,18 +25,19 @@ import org.fest.swing.core.Robot import org.fest.swing.exception.ComponentLookupException import org.fest.swing.exception.WaitTimedOutError -class TerminalFixture(project: Project, robot: Robot): ToolWindowFixture("Terminal", project, robot) { +class TerminalFixture(project: Project, robot: Robot, toolWindowId: String) : ToolWindowFixture(toolWindowId, project, robot) { private val myJBTerminalPanel: JBTerminalPanel private val terminalTextBuffer: TerminalTextBuffer init { - val content = this.getContent("") ?: throw Exception("Unable to get content of terminal tool window") + val content: Content = this.getContent(getActiveTabName()) ?: throw Exception("Unable to get content of terminal tool window") try { myJBTerminalPanel = GuiTestUtilKt.withPauseWhenNull { getJBTerminalPanel(content) } - } catch (e: WaitTimedOutError) { + } + catch (e: WaitTimedOutError) { throw ComponentLookupException("Unable to find JBTerminalPanel") } terminalTextBuffer = myJBTerminalPanel.terminalTextBuffer @@ -63,6 +64,13 @@ class TerminalFixture(project: Project, robot: Robot): ToolWindowFixture("Termin } } + private fun getActiveTabName(): String { + for (c in this.contents) { + if (c.isSelected) return c.tabName + } + return "" + } + private fun getJBTerminalPanel(content: Content): JBTerminalPanel? { return try { myRobot.finder().find(content.component) { component -> component is JBTerminalPanel } as JBTerminalPanel diff --git a/platform/testGuiFramework/src/com/intellij/testGuiFramework/fixtures/ToolWindowFixture.java b/platform/testGuiFramework/src/com/intellij/testGuiFramework/fixtures/ToolWindowFixture.java index f0a1fce6b103..d2839143ff11 100644 --- a/platform/testGuiFramework/src/com/intellij/testGuiFramework/fixtures/ToolWindowFixture.java +++ b/platform/testGuiFramework/src/com/intellij/testGuiFramework/fixtures/ToolWindowFixture.java @@ -164,7 +164,7 @@ public abstract class ToolWindowFixture { } @NotNull - private Content[] getContents() { + public Content[] getContents() { return myToolWindow.getContentManager().getContents(); }