mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-09-27 10:03:11 +07:00
[gui-test] fix search popup for the focus issues tests
Signed-off-by: Sergey Karashevich <sergey.karashevich@jetbrains.com>
This commit is contained in:
+41
-5
@@ -2,27 +2,63 @@
|
||||
package com.intellij.testGuiFramework.tests.community.focus
|
||||
|
||||
import com.intellij.ide.actions.searcheverywhere.SearchEverywhereUI
|
||||
import com.intellij.testGuiFramework.framework.GuiTestUtil.defaultTimeout
|
||||
import com.intellij.testGuiFramework.framework.GuiTestUtil.textfield
|
||||
import com.intellij.testGuiFramework.impl.GuiRobotHolder
|
||||
import com.intellij.testGuiFramework.impl.GuiTestUtilKt
|
||||
import com.intellij.ui.components.fields.ExtendableTextField
|
||||
import org.fest.swing.exception.ComponentLookupException
|
||||
import org.junit.Assert
|
||||
import java.awt.Container
|
||||
import java.awt.Window
|
||||
import javax.swing.JLabel
|
||||
|
||||
object FocusIssuesUtil {
|
||||
|
||||
fun checkSearchEverywhereUI(expectedString: String) {
|
||||
val searchEverywhereUI = try {
|
||||
findSearchEverywhereUI()
|
||||
fun checkSearchEnteredText(expectedString: String) {
|
||||
val actualString = try {
|
||||
val searchEverywhereUI = findSearchUiWithWaitingIdle()
|
||||
val extendableTextField: ExtendableTextField = GuiRobotHolder.robot.finder().find(
|
||||
searchEverywhereUI) { it is ExtendableTextField } as ExtendableTextField
|
||||
extendableTextField.text
|
||||
} catch (cle: ComponentLookupException) {
|
||||
//if search dialog appeared as a HeavyWeightWindow
|
||||
textfield("", findSearchEverywhereWindowWithWaitingIdle(), defaultTimeout).text()
|
||||
}
|
||||
Assert.assertEquals(expectedString, actualString)
|
||||
}
|
||||
|
||||
private fun findSearchEverywhereWindowWithWaitingIdle(): Container {
|
||||
return try {
|
||||
findSearchEverywhereWindow()
|
||||
}
|
||||
catch (cle: ComponentLookupException) {
|
||||
GuiRobotHolder.robot.waitForIdle()
|
||||
findSearchEverywhereWindow()
|
||||
}
|
||||
}
|
||||
|
||||
private fun findSearchEverywhereWindow(): Container {
|
||||
fun checkWindowContainsEnterClassName(it: Window)
|
||||
= GuiTestUtilKt.findAllWithBFS(it, JLabel::class.java)
|
||||
.firstOrNull { it.text?.contains("Search Everywhere:") == true || it.text?.contains("Enter class name:") == true} != null
|
||||
return Window.getWindows()
|
||||
.filterNotNull()
|
||||
.firstOrNull { checkWindowContainsEnterClassName(it) } ?: throw ComponentLookupException(
|
||||
"Unable to find search window")
|
||||
}
|
||||
|
||||
private fun findSearchUiWithWaitingIdle(): Container {
|
||||
return try {
|
||||
findSearchEverywhereUI()
|
||||
} catch (cle: ComponentLookupException) {
|
||||
GuiRobotHolder.robot.waitForIdle()
|
||||
findSearchEverywhereUI()
|
||||
}
|
||||
val extendableTextField: ExtendableTextField = GuiRobotHolder.robot.finder().find(searchEverywhereUI) { it is ExtendableTextField } as ExtendableTextField
|
||||
Assert.assertEquals(expectedString, extendableTextField.text)
|
||||
}
|
||||
|
||||
private fun findSearchEverywhereUI(): Container {
|
||||
return GuiRobotHolder.robot.finder().find { it is SearchEverywhereUI } as SearchEverywhereUI
|
||||
}
|
||||
|
||||
}
|
||||
+2
-2
@@ -7,7 +7,7 @@ import com.intellij.testGuiFramework.fixtures.IdeFrameFixture
|
||||
import com.intellij.testGuiFramework.impl.GuiRobotHolder
|
||||
import com.intellij.testGuiFramework.impl.GuiTestCase
|
||||
import com.intellij.testGuiFramework.tests.community.CommunityProjectCreator
|
||||
import com.intellij.testGuiFramework.tests.community.focus.FocusIssuesUtil.checkSearchEverywhereUI
|
||||
import com.intellij.testGuiFramework.tests.community.focus.FocusIssuesUtil.checkSearchEnteredText
|
||||
import com.intellij.testGuiFramework.util.Key.ESCAPE
|
||||
import org.fest.swing.core.SmartWaitRobot
|
||||
import org.fest.swing.timing.Pause
|
||||
@@ -68,7 +68,7 @@ class GoToClassFocusTest : GuiTestCase() {
|
||||
val smartRobot = GuiRobotHolder.robot as SmartWaitRobot
|
||||
smartRobot.shortcutAndTypeString(actionKeyStroke, typedString, 100)
|
||||
Pause.pause(500)
|
||||
checkSearchEverywhereUI(typedString)
|
||||
checkSearchEnteredText(typedString)
|
||||
shortcut(ESCAPE)
|
||||
}
|
||||
|
||||
|
||||
+1
-1
@@ -82,7 +82,7 @@ class GoToClassTwiceFocusTest : GuiTestCase() {
|
||||
smartRobot.shortcut(actionKeyStroke)
|
||||
smartRobot.shortcutAndTypeString(actionKeyStroke, typedString, 100)
|
||||
Pause.pause(500)
|
||||
FocusIssuesUtil.checkSearchEverywhereUI(typedString)
|
||||
FocusIssuesUtil.checkSearchEnteredText(typedString)
|
||||
shortcut(ESCAPE)
|
||||
}
|
||||
|
||||
|
||||
+1
-1
@@ -23,7 +23,7 @@ class SearchEverywhereFocusTest : GuiTestCase() {
|
||||
doubleShift(50)
|
||||
fastType(typedString)
|
||||
Pause.pause(500)
|
||||
FocusIssuesUtil.checkSearchEverywhereUI(typedString)
|
||||
FocusIssuesUtil.checkSearchEnteredText(typedString)
|
||||
shortcut(ESCAPE)
|
||||
focusOnEditor()
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user