From 22358bdb2c7bcb98a3abf01f605e681ca80268f2 Mon Sep 17 00:00:00 2001 From: Sergey Karashevich Date: Mon, 26 Dec 2016 22:02:37 +0300 Subject: [PATCH] [gui-test] fix jList() --- .../intellij/testGuiFramework/impl/GuiTestCase.kt | 12 +++++++++++- .../tests/samples/AddActionToolbarInKotlinTest.kt | 1 - 2 files changed, 11 insertions(+), 2 deletions(-) diff --git a/platform/testGuiFramework/src/com/intellij/testGuiFramework/impl/GuiTestCase.kt b/platform/testGuiFramework/src/com/intellij/testGuiFramework/impl/GuiTestCase.kt index 184d5eacc7a1..64990d8c1690 100644 --- a/platform/testGuiFramework/src/com/intellij/testGuiFramework/impl/GuiTestCase.kt +++ b/platform/testGuiFramework/src/com/intellij/testGuiFramework/impl/GuiTestCase.kt @@ -144,6 +144,11 @@ open class GuiTestCase : GuiTestBase() { else throw UnsupportedOperationException( "Sorry, unable to find JTree component \"${if (path != null) "by path ${path}" else ""}\" with ${target().toString()} as a Container") + fun ComponentFixture.popupClick(itemName: String) = if (target() is Container) popupClick( + target() as Container, itemName) + else throw UnsupportedOperationException( + "Sorry, unable to find Popup component with ${target().toString()} as a Container") + //*********COMMON FUNCTIONS WITHOUT CONTEXT fun typeText(text: String) = GuiTestUtil.typeText(text, myRobot, 10) @@ -179,7 +184,7 @@ open class GuiTestCase : GuiTestBase() { return JListFixture(myRobot, lists.first() as JList<*>) else { if (containingItem == null) throw ComponentLookupException("Found more than one JList, please specify item") - val filterJList: (JList<*>) -> Boolean = { myList -> (0..(myList.model.size)).any { it.toString() == containingItem } } + val filterJList: (JList<*>) -> Boolean = { myList -> (0..(myList.model.size - 1)).any { myList.model.getElementAt(it).toString() == containingItem } } return JListFixture(myRobot, lists.filter { filterJList(it as JList<*>) }.first() as JList<*>) } } @@ -223,6 +228,11 @@ open class GuiTestCase : GuiTestBase() { return JTextComponentFixture(myRobot, myRobot.finder().findByLabel(labelText, JTextComponent::class.java)) } + private fun popupClick(container: Container, itemName: String) { + GuiTestUtil.clickPopupMenuItem(itemName, false, container, myRobot) + } + + private fun jTree(container: Container, path: String? = null): JTreeFixture { val myTree: JTree? if (path == null) { diff --git a/platform/testGuiFramework/testSrc/com/intellij/testGuiFramework/tests/samples/AddActionToolbarInKotlinTest.kt b/platform/testGuiFramework/testSrc/com/intellij/testGuiFramework/tests/samples/AddActionToolbarInKotlinTest.kt index d3950eebc178..5c5d75e55749 100644 --- a/platform/testGuiFramework/testSrc/com/intellij/testGuiFramework/tests/samples/AddActionToolbarInKotlinTest.kt +++ b/platform/testGuiFramework/testSrc/com/intellij/testGuiFramework/tests/samples/AddActionToolbarInKotlinTest.kt @@ -28,7 +28,6 @@ class AddActionToolbarInKotlinTestTest : GuiTestCase() { simpleProject { - waitForBackgroundTasksToFinish() if (!UISettings.getInstance().SHOW_MAIN_TOOLBAR) invokeMenuPath("View", "Toolbar") invokeAction(keyStroke = "meta comma")