assertj / assertj/assertj-swing

Testing issues with org.openide.DialogDisplayer

Open
#49 1 comment 0 reactions 0 assignees View on GitHub
bug import from fest-swing Major
Dominant language
Java
Stars
121
Forks
52
PR merge metrics
No merged PRs in 30d

Description

_Issue by **[Mark Corkery](http://jira.codehaus.org/secure/ViewProfile.jspa?name=kramkroc)** from Thu, 24 Sep 2009 04:53:11 -0500_
_Originally opened as http://jira.codehaus.org/browse/FEST-226_

---

I'm having issues testing NetBeans Platforms DialogDescriptor. If I am testing the behavior in more than one test case the robot will not find the dialog panel in any test subsequent to the first test case which means that only the first test will pass. Netbeans Platform is

included as part of the standard netbeans IDE download. See the following page for more: http://platform.netbeans.org/

Testcase:


shouldDisplayDialog2(com.login.view.LoginFormTest):

Caused an ERROR
Timed out waiting for dialog to be found using matcher
org.fest.swing.core.matcher.DialogMatcher[name=<Any>, title='Hello',
requireShowing=false]
org.fest.swing.exception.WaitTimedOutError: Timed out waiting for
dialog to be found using matcher
org.fest.swing.core.matcher.DialogMatcher[name=<Any>, title='Hello',
requireShowing=false]
at org.fest.swing.timing.Pause.pause(Pause.java:74)
at org.fest.swing.timing.Pause.pause(Pause.java:58)
at org.fest.swing.fixture.ContainerFixture.findDialog
(ContainerFixture.java:165)
at org.fest.swing.fixture.ContainerFixture.dialog
(ContainerFixture.java:148)
at org.fest.swing.fixture.ContainerFixture.dialog
(ContainerFixture.java:143)
at com.login.view.LoginFormTest.shouldDisplayDialog2
(LoginFormTest.java:85)

I've created a cut down version of what my test looks like below (LoginForm could be replaced with any default JPanel object) :


package com.login.view;

import org.fest.swing.driver.ComponentStateValidator;
import org.fest.swing.edt.FailOnThreadViolationRepaintManager;
import org.fest.swing.edt.GuiTask;
import org.fest.swing.fixture.Containers;
import org.fest.swing.fixture.DialogFixture;
import org.fest.swing.fixture.FrameFixture;
import org.fest.swing.core.matcher.DialogMatcher;
import org.junit.After;
import org.junit.Before;
import org.junit.BeforeClass;
import org.junit.Test;
import org.openide.DialogDescriptor;
import org.openide.DialogDisplayer;
import static org.fest.swing.edt.GuiActionRunner.*;

public class LoginFormTest {

private LoginForm loginForm;
private FrameFixture testPanelFixture = null;

@BeforeClass
public static void setUpOnce() {
FailOnThreadViolationRepaintManager.install();
}

@Before
public void setUp() {

execute(new GuiTask() {
@Override
protected void executeInEDT() throws Throwable {
loginForm = new LoginForm();
}
});
testPanelFixture = Containers.frameFixtureFor(loginForm);
//Aways call wait for idle after using the GuiActionRunner.
testPanelFixture.robot.waitForIdle();
}

@After
public void cleanUp() {
testPanelFixture.robot.cleanUp();
}

@Test
public void shouldDisplayDialog() throws Exception {
final DialogDescriptor dd = new DialogDescriptor("Hello", "Hello");
DialogDisplayer.getDefault().notifyLater(dd);
final DialogFixture loginDialog = testPanelFixture.dialog(DialogMatcher.withTitle("Hello"));
ComponentStateValidator.validateIsShowing(loginDialog.component());
loginDialog.focus();
}

@Test
public void shouldDisplayDialog2() throws Exception {
final DialogDescriptor dd = new DialogDescriptor("Hello", "Hello");
DialogDisplayer.getDefault().notifyLater(dd);
final DialogFixture loginDialog = testPanelFixture.dialog(DialogMatcher.withTitle("Hello"));
ComponentStateValidator.validateIsShowing(loginDialog.component());
loginDialog.focus();
}
}


---

votes (original issue): 0
watches (original issue): 0

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.