Stuck waiting for event queue when DialogWrapper is created dynamically
Ninguém assumiu esta issue ainda.
Avaliação
- Dificuldade
- 4/5
- Tempo estimado
- 3-5 dias
- Facilidade para iniciantes
- 35/100
Direção de pesquisa
Comece pelo projeto mínimo na issue, especialmente pelo DialogTest e pelo caminho de criação de DialogWrapper, e execute ./gradlew test (ou gradlew test no Windows). Compare os atrasos relatados com a solução alternativa de JDialog; considera-se concluído quando as interações com DialogWrapper criados dinamicamente não forem mais bloqueadas pelos atrasos relatados e o teste de reprodução passar.
Escrita pelo modelo de indexação a partir do texto da issue.
Descrição
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.
- Linguagem predominante
- Java
- Estrelas
- 121
- Forks
- 52
- Métricas de merge de PRs
- Nenhum PR com merge em 30d
Preparar o ambiente
Primeiros passos
- Leia a issue inteira e depois o guia de contribuição do projeto.
- Comente na issue dizendo que vai assumir — evita que duas pessoas façam o mesmo trabalho.
- Faça um fork do repositório e trabalhe em uma branch.
- Abra um pull request que referencie o número da issue.
Mais de assertj/assertj-swing
-
Dificuldade 5/5 Mais de uma semana Facilidade para iniciantes 25/100
assertj/assertj-swing#279 ·
-
Dificuldade 2/5 1-3 horas Facilidade para iniciantes 48/100
assertj/assertj-swing#278 · 1 comentário ·
-
Dificuldade 4/5 3-5 dias Facilidade para iniciantes 30/100
assertj/assertj-swing#276 · 1 comentário ·
-
Update unit test to avoid deprecated `ExpectedException.none()` by using `Assert.assertThrows()`Aberta
Dificuldade 4/5 3-5 dias Facilidade para iniciantes 35/100
assertj/assertj-swing#275 ·
-
how to test when headless?Aberta
Dificuldade 3/5 1-2 dias Facilidade para iniciantes 35/100
assertj/assertj-swing#277 · 1 comentário ·
Todas as issues de assertj/assertj-swing
Issues semelhantes
-
Dificuldade 2/5 1-3 horas Facilidade para iniciantes 88/100
checkstyle/checkstyle#21755 · 1 comentário ·
Mantenedores costumam responder em até 1 dia
-
Dificuldade 2/5 1-3 horas Facilidade para iniciantes 84/100
Mantenedores costumam responder em até 1 dia
-
agentic-workflows
Dificuldade 2/5 1-3 horas Facilidade para iniciantes 68/100
github/copilot-sdk#2782 ·
Mantenedores costumam responder em até 1 dia
-
documentation Good for newcomer quick win
Dificuldade 2/5 1-3 horas Facilidade para iniciantes 68/100
CodeForPhilly/benefit-decision-toolkit#519 ·
Mantenedores costumam responder em até 1 dia
-
area-deployment triage:bot-seen triage:needs-human
Dificuldade 2/5 1-3 horas Facilidade para iniciantes 68/100
microsoft/aspire#20533 · 1 comentário ·
Mantenedores costumam responder em até 1 dia