You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I use IntelliJ's DialogWrapper to show dialogs in an IntelliJ plugin. This dialog is opened by a different window. When trying to simulate input events using AssertJ Swing, however, simply changing the text of an input box easily takes 30 seconds. Clicking a button takes 11 seconds.
The issue seems to be that, once the sub-dialog has been opened, the robot gets stuck in waitForIdle(EventQueue). This makes this issue related to #13 and #201. The difference is that I do not use a custom event queue.
Reproducible example
I have created a minimal reproducible example. The code can be found below.
Java code
packagecom.fwdekker.assertjswingtest;
importcom.intellij.openapi.ui.DialogWrapper;
importorg.assertj.swing.edt.GuiActionRunner;
importorg.assertj.swing.fixture.FrameFixture;
importorg.junit.jupiter.api.AfterEach;
importorg.junit.jupiter.api.BeforeEach;
importorg.junit.jupiter.api.Test;
importjavax.swing.JButton;
importjavax.swing.JDialog;
importjavax.swing.JPanel;
importstaticorg.assertj.swing.fixture.Containers.showInFrame;
// Uses AssertJ Swing to test the interaction between the dialogs.classDialogTest {
privateFrameFixtureframe;
@BeforeEachvoidbeforeEach() {
frame = showInFrame(GuiActionRunner.execute(MainDialog::new).getRootPane());
}
@AfterEachvoidafterEach() {
frame.cleanUp();
}
@TestvoidmyTest() {
// This action takes 10 secondsframe.button("mainButton").click();
}
}
// The main dialog that opens the sub-dialog.classMainDialogextendsJDialog {
MainDialog() {
JPanelcontentPane = newJPanel();
JButtonmainButton = newJButton("Open");
mainButton.setName("mainButton");
mainButton.addActionListener(e -> newSubDialog().showAndGet());
contentPane.add(mainButton);
setContentPane(contentPane);
setModal(true);
pack();
}
}
// The sub-dialog using IntelliJ's `DialogWrapper`.classSubDialogextendsDialogWrapper {
privateJPanelcontentPane = newJPanel();
SubDialog() {
super(null);
init();
}
@OverrideprotectedJPanelcreateCenterPanel() {
returncontentPane;
}
}
Alternatively, download a .zip of the minimal project. You can run the test from the command line with ./gradlew test (Unix-like) or gradlew test (Windows).
Workarounds
I was able to find two workarounds for this issue. They are suboptimal solutions, but may be useful for others who have this issue:
Replacing the DialogWrapper with a conventional JDialog fixes the issue, but is not feasible for my use case.
Moving the creation of the sub-dialog outside of the button's action listener fixes the issue, but I do not think this is the idiomatic way of creating dialogs.
The text was updated successfully, but these errors were encountered:
Issue
I use IntelliJ's
DialogWrapper
to show dialogs in an IntelliJ plugin. This dialog is opened by a different window. When trying to simulate input events using AssertJ Swing, however, simply changing the text of an input box easily takes 30 seconds. Clicking a button takes 11 seconds.The issue seems to be that, once the sub-dialog has been opened, the robot gets stuck in
waitForIdle(EventQueue)
. This makes this issue related to #13 and #201. The difference is that I do not use a custom event queue.Reproducible example
I have created a minimal reproducible example. The code can be found below.
Java code
Gradle build file
Alternatively, download a .zip of the minimal project. You can run the test from the command line with
./gradlew test
(Unix-like) orgradlew test
(Windows).Workarounds
I was able to find two workarounds for this issue. They are suboptimal solutions, but may be useful for others who have this issue:
DialogWrapper
with a conventionalJDialog
fixes the issue, but is not feasible for my use case.The text was updated successfully, but these errors were encountered: