mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-09-27 10:03:11 +07:00
[gui-test] check process is running modal dialog when close IDE
Signed-off-by: Sergey Karashevich <sergey.karashevich@jetbrains.com>
This commit is contained in:
@@ -50,6 +50,7 @@ import java.awt.KeyboardFocusManager
|
||||
import java.io.File
|
||||
import java.util.*
|
||||
import java.util.concurrent.TimeUnit
|
||||
import javax.swing.JButton
|
||||
|
||||
class GuiTestRule : TestRule {
|
||||
|
||||
@@ -196,7 +197,10 @@ class GuiTestRule : TestRule {
|
||||
else {
|
||||
closedModalDialogSet.add(modalDialog)
|
||||
ScreenshotOnFailure.takeScreenshot("$myTestName.checkForModalDialogFail")
|
||||
robot().close(modalDialog)
|
||||
if (isProcessIsRunningDialog(modalDialog))
|
||||
closeProcessIsRunningDialog(modalDialog)
|
||||
else
|
||||
robot().close(modalDialog)
|
||||
errors.add(AssertionError("Modal dialog showing: ${modalDialog.javaClass.name} with title '${modalDialog.title}'"))
|
||||
}
|
||||
return@waitUntil false
|
||||
@@ -208,6 +212,17 @@ class GuiTestRule : TestRule {
|
||||
return errors
|
||||
}
|
||||
|
||||
private fun isProcessIsRunningDialog(modalDialog: Dialog): Boolean {
|
||||
return modalDialog.title.toLowerCase().contains("process")
|
||||
&& modalDialog.title.toLowerCase().contains("is running")
|
||||
}
|
||||
|
||||
private fun closeProcessIsRunningDialog(modalDialog: Dialog) {
|
||||
val terminateButton: JButton = robot().finder().find(modalDialog) { it is JButton && it.text == "Terminate" } as JButton
|
||||
robot().click(terminateButton)
|
||||
robot().waitForIdle()
|
||||
}
|
||||
|
||||
// Note: this works with a cooperating window manager that returns focus properly. It does not work on bare Xvfb.
|
||||
private fun getActiveModalDialog(): Dialog? {
|
||||
val activeWindow = KeyboardFocusManager.getCurrentKeyboardFocusManager().activeWindow
|
||||
|
||||
Reference in New Issue
Block a user