Skip to content

Commit

Permalink
HittingEscapeOnCloseConfirmationDialogTest: Match dialog by title
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
matthijskooijman authored and cmaglie committed May 11, 2020
1 parent af8e1e6 commit 7bc6efa
Showing 1 changed file with 4 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -39,6 +40,7 @@
import java.awt.event.KeyEvent;

import static org.junit.Assert.assertEquals;
import static processing.app.I18n.tr;

public class HittingEscapeOnCloseConfirmationDialogTest extends AbstractGUITest {

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

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();
Expand Down

0 comments on commit 7bc6efa

Please sign in to comment.