Stuck waiting for event queue when DialogWrapper is created dynamically
Personne n'a encore pris cette issue.
Évaluation
- Difficulté
- 4/5
- Temps estimé
- 3-5 jours
- Accessibilité débutants
- 35/100
Piste de recherche
Commencez par le projet minimal de l’issue, en particulier DialogTest et le chemin de création de DialogWrapper, puis exécutez ./gradlew test (ou gradlew test sous Windows). Comparez les délais signalés avec le contournement JDialog ; le travail est terminé lorsque les interactions avec des DialogWrapper créés dynamiquement ne sont plus bloquées pendant les délais signalés et que le test de reproduction réussit.
Rédigé par le modèle d'indexation à partir du texte de l'issue.
Description
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
package com.fwdekker.assertjswingtest;
import com.intellij.openapi.ui.DialogWrapper;
import org.assertj.swing.edt.GuiActionRunner;
import org.assertj.swing.fixture.FrameFixture;
import org.junit.jupiter.api.AfterEach;
import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.Test;
import javax.swing.JButton;
import javax.swing.JDialog;
import javax.swing.JPanel;
import static org.assertj.swing.fixture.Containers.showInFrame;
// Uses AssertJ Swing to test the interaction between the dialogs.
class DialogTest {
private FrameFixture frame;
@BeforeEach
void beforeEach() {
frame = showInFrame(GuiActionRunner.execute(MainDialog::new).getRootPane());
}
@AfterEach
void afterEach() {
frame.cleanUp();
}
@Test
void myTest() {
// This action takes 10 seconds
frame.button("mainButton").click();
}
}
// The main dialog that opens the sub-dialog.
class MainDialog extends JDialog {
MainDialog() {
JPanel contentPane = new JPanel();
JButton mainButton = new JButton("Open");
mainButton.setName("mainButton");
mainButton.addActionListener(e -> new SubDialog().showAndGet());
contentPane.add(mainButton);
setContentPane(contentPane);
setModal(true);
pack();
}
}
// The sub-dialog using IntelliJ's `DialogWrapper`.
class SubDialog extends DialogWrapper {
private JPanel contentPane = new JPanel();
SubDialog() {
super(null);
init();
}
@Override
protected JPanel createCenterPanel() {
return contentPane;
}
}
Gradle build file
plugins {
id "java"
id "org.jetbrains.intellij" version "0.4.9"
}
repositories {
mavenCentral()
}
dependencies {
testCompile group: "org.assertj", name: "assertj-core", version: "3.8.0"
testCompile group: "org.assertj", name: "assertj-swing-junit", version: "3.8.0"
testCompile group: "org.junit.jupiter", name: "junit-jupiter-api", version: "5.5.0"
testCompile group: "org.junit.jupiter", name: "junit-jupiter-engine", version: "5.5.0"
}
intellij {
version = "2019.1.1"
}
test {
useJUnitPlatform()
}
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
DialogWrapperwith a conventionalJDialogfixes 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.
- Langage dominant
- Java
- Étoiles
- 121
- Forks
- 52
- Métriques de merge des PR
- Aucune PR mergée en 30 j
Préparer son environnement
Par où commencer
- Lisez l'issue en entier, puis le guide de contribution du projet.
- Signalez en commentaire que vous la prenez — cela évite que deux personnes fassent le même travail.
- Forkez le dépôt et travaillez sur une branche.
- Ouvrez une pull request qui référence le numéro de l'issue.
Autres issues de assertj/assertj-swing
-
Difficulté 5/5 Plus d'une semaine Accessibilité débutants 25/100
assertj/assertj-swing#279 ·
-
Difficulté 2/5 1-3 heures Accessibilité débutants 48/100
assertj/assertj-swing#278 · 1 commentaire ·
-
Difficulté 4/5 3-5 jours Accessibilité débutants 30/100
assertj/assertj-swing#276 · 1 commentaire ·
-
Update unit test to avoid deprecated `ExpectedException.none()` by using `Assert.assertThrows()`Ouverte
Difficulté 4/5 3-5 jours Accessibilité débutants 35/100
assertj/assertj-swing#275 ·
-
how to test when headless?Ouverte
Difficulté 3/5 1-2 jours Accessibilité débutants 35/100
assertj/assertj-swing#277 · 1 commentaire ·
Toutes les issues de assertj/assertj-swing
Issues similaires
-
bug
Difficulté 2/5 1-3 heures Accessibilité débutants 78/100
openhab/openhab-core#5847 ·
Les mainteneurs répondent en général sous 1 jour
-
Difficulté 2/5 1-3 heures Accessibilité débutants 75/100
-
bug
Difficulté 2/5 1-3 heures Accessibilité débutants 76/100
-
Difficulté 2/5 1-3 heures Accessibilité débutants 88/100
apache/parquet-java#3820 ·
Les mainteneurs répondent en général sous 1 jour
-
Difficulté 2/5 1-3 heures Accessibilité débutants 78/100
beehive-lab/jllm#187 ·