[gui-test] fix a couple of tests

We should use JBTerminalPanel instead of EditorComponentImpl  when waiting for the text in the run tool window
This commit is contained in:
Artem Gainanov
2018-06-17 19:56:21 +07:00
parent af978558e5
commit d923b3b0bb
2 changed files with 12 additions and 4 deletions
@@ -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
@@ -164,7 +164,7 @@ public abstract class ToolWindowFixture {
}
@NotNull
private Content[] getContents() {
public Content[] getContents() {
return myToolWindow.getContentManager().getContents();
}