From 7bc6efa27ebf8ab2ec26b09854cbaa639c5a5ef7 Mon Sep 17 00:00:00 2001 From: Matthijs Kooijman Date: Wed, 6 May 2020 21:41:41 +0200 Subject: [PATCH] HittingEscapeOnCloseConfirmationDialogTest: Match dialog by title This would match the "Close" dialog, by looking for any JDialog on screen. However, in some cases, there could be a second dialog (I have seen a "Install this package to use your xxx board" popup because I happened to have an Arduino Zero connected, presumably an "Updates are available" popup could cause this as well). By matching not just the type of the dialog, but also the title, only one dialog is matched and the testcase runs more reliably. --- .../app/HittingEscapeOnCloseConfirmationDialogTest.java | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/app/test/processing/app/HittingEscapeOnCloseConfirmationDialogTest.java b/app/test/processing/app/HittingEscapeOnCloseConfirmationDialogTest.java index 83897b196..59dff4c35 100644 --- a/app/test/processing/app/HittingEscapeOnCloseConfirmationDialogTest.java +++ b/app/test/processing/app/HittingEscapeOnCloseConfirmationDialogTest.java @@ -30,6 +30,7 @@ package processing.app; import org.fest.swing.core.KeyPressInfo; +import org.fest.swing.core.matcher.DialogMatcher; import org.fest.swing.finder.WindowFinder; import org.fest.swing.fixture.DialogFixture; import org.junit.Test; @@ -39,6 +40,7 @@ import javax.swing.*; import java.awt.event.KeyEvent; import static org.junit.Assert.assertEquals; +import static processing.app.I18n.tr; public class HittingEscapeOnCloseConfirmationDialogTest extends AbstractGUITest { @@ -49,7 +51,8 @@ public class HittingEscapeOnCloseConfirmationDialogTest extends AbstractGUITest window.close(); - DialogFixture dialog = WindowFinder.findDialog(JDialog.class).using(window.robot); + DialogMatcher matcher = DialogMatcher.withTitle(tr("Close")).andShowing(); + DialogFixture dialog = WindowFinder.findDialog(matcher).using(window.robot); dialog.pressAndReleaseKey(KeyPressInfo.keyCode(KeyEvent.VK_ESCAPE)); EditorConsole console = (EditorConsole) window.scrollPane("console").component();