Skip to content

Commit 8b240c9

Browse files
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.
1 parent 82fd88c commit 8b240c9

File tree

1 file changed

+4
-1
lines changed

1 file changed

+4
-1
lines changed

Diff for: app/test/processing/app/HittingEscapeOnCloseConfirmationDialogTest.java

+4-1
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,7 @@
3030
package processing.app;
3131

3232
import org.fest.swing.core.KeyPressInfo;
33+
import org.fest.swing.core.matcher.DialogMatcher;
3334
import org.fest.swing.finder.WindowFinder;
3435
import org.fest.swing.fixture.DialogFixture;
3536
import org.junit.Test;
@@ -39,6 +40,7 @@
3940
import java.awt.event.KeyEvent;
4041

4142
import static org.junit.Assert.assertEquals;
43+
import static processing.app.I18n.tr;
4244

4345
public class HittingEscapeOnCloseConfirmationDialogTest extends AbstractGUITest {
4446

@@ -49,7 +51,8 @@ public void shouldJustCloseTheDialog() throws Exception {
4951

5052
window.close();
5153

52-
DialogFixture dialog = WindowFinder.findDialog(JDialog.class).using(window.robot);
54+
DialogMatcher matcher = DialogMatcher.withTitle(tr("Close")).andShowing();
55+
DialogFixture dialog = WindowFinder.findDialog(matcher).using(window.robot);
5356
dialog.pressAndReleaseKey(KeyPressInfo.keyCode(KeyEvent.VK_ESCAPE));
5457

5558
EditorConsole console = (EditorConsole) window.scrollPane("console").component();

0 commit comments

Comments
 (0)