mirror of
https://github.com/nasa/trick.git
synced 2025-04-04 17:59:16 +00:00
Created test case for status message pane
This commit is contained in:
parent
158c1787f2
commit
16a39d55da
@ -4,19 +4,34 @@ import trick.simcontrol.SimControlApplication;
|
||||
import trick.simcontrol.StubbedSimControlApplication;
|
||||
|
||||
import java.awt.Frame;
|
||||
import java.awt.Toolkit;
|
||||
import java.awt.datatransfer.Clipboard;
|
||||
import java.awt.datatransfer.DataFlavor;
|
||||
import java.awt.datatransfer.UnsupportedFlavorException;
|
||||
import java.awt.event.KeyEvent;
|
||||
import java.beans.Transient;
|
||||
import java.util.ArrayList;
|
||||
|
||||
import javax.swing.JButton;
|
||||
import javax.swing.JTextField;
|
||||
import javax.swing.JToggleButton;
|
||||
import javax.swing.text.JTextComponent;
|
||||
|
||||
import org.assertj.swing.core.GenericTypeMatcher;
|
||||
import org.assertj.swing.core.KeyPressInfo;
|
||||
import org.assertj.swing.exception.ComponentLookupException;
|
||||
import org.assertj.swing.fixture.ComponentContainerFixture;
|
||||
import org.assertj.swing.fixture.MouseInputSimulationFixture;
|
||||
import org.assertj.swing.fixture.JButtonFixture;
|
||||
import org.assertj.swing.fixture.JPanelFixture;
|
||||
import org.assertj.swing.fixture.JTextComponentFixture;
|
||||
import org.assertj.swing.fixture.JToggleButtonFixture;
|
||||
import org.assertj.swing.fixture.FrameFixture;
|
||||
import org.assertj.swing.fixture.MouseInputSimulationFixture;
|
||||
import org.assertj.swing.junit.testcase.AssertJSwingJUnitTestCase;
|
||||
|
||||
import org.jdesktop.swingx.JXFindBar;
|
||||
import org.jdesktop.swingx.JXEditorPane;
|
||||
|
||||
import org.junit.BeforeClass;
|
||||
import org.junit.Test;
|
||||
|
||||
@ -97,6 +112,103 @@ public class StubbedSimControlTests extends AssertJSwingJUnitTestCase {
|
||||
testJToggleButton("Load Chkpnt", ActionID.LOAD_CHKPNT);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testStatusMsgPane() {
|
||||
// ARRANGE
|
||||
JTextComponentFixture editorFixture = mainFrame.textBox(
|
||||
new GenericTypeMatcher<JXEditorPane>(JXEditorPane.class) {
|
||||
@Override
|
||||
protected boolean isMatching(JXEditorPane pane) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
);
|
||||
JXEditorPane editorPane = (JXEditorPane) editorFixture.target();
|
||||
|
||||
JPanelFixture findPanel = mainFrame.panel(
|
||||
new GenericTypeMatcher<JXFindBar>(JXFindBar.class) {
|
||||
@Override
|
||||
protected boolean isMatching(JXFindBar pane) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
);
|
||||
|
||||
JTextComponentFixture findTextField = findPanel.textBox(
|
||||
new GenericTypeMatcher<JTextField>(JTextField.class) {
|
||||
@Override
|
||||
protected boolean isMatching(JTextField pane) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
);
|
||||
|
||||
JButtonFixture findNextButton = findPanel.button(
|
||||
new GenericTypeMatcher<JButton>(JButton.class) {
|
||||
@Override
|
||||
protected boolean isMatching(JButton button) {
|
||||
return "Find Next".equals(button.getText());
|
||||
}
|
||||
}
|
||||
);
|
||||
|
||||
JButtonFixture findPrevButton = findPanel.button(
|
||||
new GenericTypeMatcher<JButton>(JButton.class) {
|
||||
@Override
|
||||
protected boolean isMatching(JButton button) {
|
||||
return "Find Previous".equals(button.getText());
|
||||
}
|
||||
}
|
||||
);
|
||||
|
||||
final String outStencil = "%s@%d";
|
||||
final String[] expOutput = {"null@304", "fear@11",
|
||||
"Fear@17" , "Fear@42",
|
||||
"fear@114", "fear@249",
|
||||
"fear@114", "Fear@42",
|
||||
"Fear@17" , "fear@11"};
|
||||
String[] queryResults = new String[10];
|
||||
|
||||
editorFixture.deleteText()
|
||||
.setText("I must not fear.\n" + //
|
||||
"Fear is the mind-killer.\n" + //
|
||||
"Fear is the little-death that brings total obliteration.\n" + //
|
||||
"I will face my fear.\n" + //
|
||||
"I will permit it to pass over me and through me.\n" + //
|
||||
"And when it has gone past, I will turn the inner eye to see its path.\n" + //
|
||||
"Where the fear has gone there will be nothing. Only I will remain");
|
||||
|
||||
// ACT
|
||||
findTextField.setText("Hello");
|
||||
queryResults[0] = String.format(outStencil,
|
||||
editorPane.getSelectedText(),
|
||||
editorPane.getSelectionStart());
|
||||
|
||||
findTextField.setText("fear");
|
||||
queryResults[1] = String.format(outStencil,
|
||||
editorPane.getSelectedText(),
|
||||
editorPane.getSelectionStart());
|
||||
|
||||
for(int i = 2; i < 6; i++) {
|
||||
findNextButton.click();
|
||||
queryResults[i] = String.format(outStencil,
|
||||
editorPane.getSelectedText(),
|
||||
editorPane.getSelectionStart());
|
||||
}
|
||||
|
||||
for(int i = 6; i < 10; i++) {
|
||||
findPrevButton.click();
|
||||
queryResults[i] = String.format(outStencil,
|
||||
editorPane.getSelectedText(),
|
||||
editorPane.getSelectionStart());
|
||||
}
|
||||
|
||||
// ASSERT
|
||||
for(int i = 0; i < 10; i++) {
|
||||
assertThat(queryResults[i]).isEqualTo(expOutput[i]);
|
||||
}
|
||||
}
|
||||
|
||||
public static void sleep(long ms) {
|
||||
try {Thread.sleep(ms);} catch(Exception ignored) {}
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user