updated status message pane tests

This commit is contained in:
Marcus Rockwell 2024-09-04 10:22:06 -04:00
parent e78884c81d
commit 8db6fa4b37

View File

@ -44,6 +44,7 @@ import static org.assertj.swing.launcher.ApplicationLauncher.application;
public class StubbedSimControlTests extends AssertJSwingJUnitTestCase { public class StubbedSimControlTests extends AssertJSwingJUnitTestCase {
private FrameFixture mainFrame; private FrameFixture mainFrame;
private JPanelFixture findPanel; private JPanelFixture findPanel;
private JTextComponentFixture editorFixture;
private StubbedSimControlApplication app = null; private StubbedSimControlApplication app = null;
@BeforeClass @BeforeClass
@ -55,7 +56,9 @@ public class StubbedSimControlTests extends AssertJSwingJUnitTestCase {
protected void onSetUp() { protected void onSetUp() {
application(StubbedSimControlApplication.class).start(); application(StubbedSimControlApplication.class).start();
app = StubbedSimControlApplication.getInstance(); app = StubbedSimControlApplication.getInstance();
mainFrame = getFrameByTitle("Sim Control"); mainFrame = getFrameByTitle("Sim Control");
findPanel = mainFrame.panel( findPanel = mainFrame.panel(
new GenericTypeMatcher<JXFindBar>(JXFindBar.class) { new GenericTypeMatcher<JXFindBar>(JXFindBar.class) {
@Override @Override
@ -65,6 +68,15 @@ public class StubbedSimControlTests extends AssertJSwingJUnitTestCase {
} }
); );
editorFixture = mainFrame.textBox(
new GenericTypeMatcher<JXEditorPane>(JXEditorPane.class) {
@Override
protected boolean isMatching(JXEditorPane pane) {
return true;
}
}
);
sleep(500); sleep(500);
updateState(); updateState();
} }
@ -148,15 +160,6 @@ public class StubbedSimControlTests extends AssertJSwingJUnitTestCase {
@Test @Test
public void testStatusMsgPane() { public void testStatusMsgPane() {
// ARRANGE // ARRANGE
JTextComponentFixture editorFixture = mainFrame.textBox(
new GenericTypeMatcher<JXEditorPane>(JXEditorPane.class) {
@Override
protected boolean isMatching(JXEditorPane pane) {
return true;
}
}
);
final String msg = "How much wood can a woodchuck chuck if a woodchuck could chuck wood?"; final String msg = "How much wood can a woodchuck chuck if a woodchuck could chuck wood?";
assumeThat(editorFixture).isNotNull(); assumeThat(editorFixture).isNotNull();
@ -172,7 +175,7 @@ public class StubbedSimControlTests extends AssertJSwingJUnitTestCase {
@Test @Test
public void testFindPanelButtons() { public void testFindPanelButtons() {
// ARRANGE // ARRANGE
String message = "I must not fear.\n" + // final String message = "I must not fear.\n" + //
"Fear is the mind-killer.\n" + // "Fear is the mind-killer.\n" + //
"Fear is the little-death that brings total obliteration.\n" + // "Fear is the little-death that brings total obliteration.\n" + //
"I will face my fear.\n" + // "I will face my fear.\n" + //
@ -188,13 +191,14 @@ public class StubbedSimControlTests extends AssertJSwingJUnitTestCase {
String[] queryResults = new String[10]; String[] queryResults = new String[10];
JTextComponentFixture editorFixture = setStatusMessage(message);
JXEditorPane editorPane = (JXEditorPane) editorFixture.target(); JXEditorPane editorPane = (JXEditorPane) editorFixture.target();
JButtonFixture findNextButton = getButtonByText(findPanel, "Find Next"), JButtonFixture findNextButton = getButtonByText(findPanel, "Find Next"),
findPrevButton = getButtonByText(findPanel, "Find Previous"); findPrevButton = getButtonByText(findPanel, "Find Previous");
assumeThat(findNextButton).isNotNull(); assumeThat(findNextButton).isNotNull();
assumeThat(findPrevButton).isNotNull(); assumeThat(findPrevButton).isNotNull();
setStatusMessage(message);
// ACT // ACT
setFindText("Hello"); setFindText("Hello");