Hacktoberfest 2026: die Issues, die Maintainer für den Oktober markiert haben – offen und einsteigerfreundlich. Hacktoberfest-Issues durchsuchen

Stuck waiting for event queue when DialogWrapper is created dynamically

Offen
#239 0 Kommentare 0 Reaktionen 0 zugewiesene Personen Auf GitHub ansehen

Dieses Issue hat noch niemand übernommen.

Bewertung

Schwierigkeit
4/5
Geschätzter Aufwand
3-5 Tage
Anfängerfreundlichkeit
35/100
Issue-Typ
Bug
Klarheit
Größtenteils klar
Aktivitätsstatus
Veraltet
Tech-Stack
java
Bereich
desktop, testing

Rechercherichtung

Beginne mit dem minimalen Projekt im Issue, insbesondere mit DialogTest und dem Erstellungspfad von DialogWrapper, und führe ./gradlew test (oder unter Windows gradlew test) aus. Vergleiche die gemeldeten Verzögerungen mit dem JDialog-Workaround; abgeschlossen bedeutet, dass Interaktionen mit dynamisch erstellten DialogWrapper-Instanzen nicht mehr durch die gemeldeten Verzögerungen blockiert werden und der Reproduktionstest erfolgreich ist.

Vom Indexierungsmodell aus dem Issue-Text verfasst.

Beschreibung

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 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.
Vorherrschende Sprache
Java
Sterne
121
Forks
52
PR-Merge-Kennzahlen
Keine gemergten PRs in 30 T.

Entwicklungsumgebung

Erste Schritte

  1. Lesen Sie das ganze Issue und danach den Beitragsleitfaden des Projekts.
  2. Schreiben Sie ins Issue, dass Sie es übernehmen — das erspart doppelte Arbeit.
  3. Forken Sie das Repository und arbeiten Sie in einem Branch.
  4. Öffnen Sie einen Pull Request, der die Issue-Nummer nennt.

Mehr aus assertj/assertj-swing

Alle Issues in assertj/assertj-swing

Ähnliche Issues

Weitere Issues zu Java

Neue Issues direkt in Ihr Postfach

Eine kurze Übersicht über anfängerfreundliche GitHub-Issues.