mirror of
https://github.com/nasa/trick.git
synced 2025-01-28 15:14:36 +00:00
Updated fixture
This commit is contained in:
parent
de668a7c2e
commit
1a75fce084
@ -5,9 +5,6 @@ import org.jdesktop.application.Application;
|
||||
|
||||
|
||||
public class MockTVApplication extends TVApplication {
|
||||
private boolean connected = false;
|
||||
private static String hostname;
|
||||
private static int port;
|
||||
private static Object lock = new Object();
|
||||
|
||||
boolean isEnded;
|
||||
@ -24,25 +21,8 @@ public class MockTVApplication extends TVApplication {
|
||||
lock.notifyAll();
|
||||
}
|
||||
}
|
||||
|
||||
public final boolean isConnected() { return connected; }
|
||||
|
||||
public void connectSimulation() {
|
||||
setTargetSimulation(hostname, port);
|
||||
}
|
||||
|
||||
public static void main(String[] args) {
|
||||
for(int i = 0; i < args.length; i++) {
|
||||
String arg = args[i];
|
||||
if((i+1) < args.length) {
|
||||
if(arg.equals("--host")) {
|
||||
hostname = args[++i];
|
||||
} else if(arg.equals("--port")) {
|
||||
port = Integer.parseInt(args[++i]);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
synchronized(lock) {
|
||||
Application.launch(MockTVApplication.class, args);
|
||||
while(true) {
|
||||
|
@ -15,6 +15,8 @@ import trick.common.ApplicationTest;
|
||||
import trick.common.TestUtils;
|
||||
import trick.tv.fixtures.TVFixture;
|
||||
|
||||
import static trick.tv.fixtures.TVFixture.*;
|
||||
|
||||
/**
|
||||
*
|
||||
* Test TVApplication life cycle.
|
||||
@ -63,19 +65,33 @@ public class TVApplicationTest extends ApplicationTest {
|
||||
|
||||
tv_app = MockTVApplication.getInstance(MockTVApplication.class);
|
||||
tv_fix = new TVFixture(robot(), tv_app);
|
||||
tv_fix.getErrorPopupFixture()
|
||||
.okButton().click();
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testGeneric() {
|
||||
// tv_fix.selectVar("drx.drt.uintB.var1");
|
||||
tv_fix.selectVar("drx.drt.uintB.var1");
|
||||
tv_fix.setSearchOptions(CASE_SENSITIVE_ON | REG_EXPRESSION_ON | GREEDY_SEARCH_ON);
|
||||
tv_fix.enterQuery("var1\n");
|
||||
sleep(500);
|
||||
|
||||
System.out.println("SEARCH RESULTS");;
|
||||
String[] results = tv_fix.getSearchResults();
|
||||
for (String string : results) {
|
||||
System.out.println(string);
|
||||
tv_fix.selectVar(string);
|
||||
sleep(250);
|
||||
}
|
||||
|
||||
System.out.println("\nSEL VARS");
|
||||
String[][] table = tv_fix.getSelectedVars();
|
||||
for (String[] strings : table) {
|
||||
for (String string : strings) {
|
||||
System.out.print(string + "\t");
|
||||
}
|
||||
System.out.println();
|
||||
}
|
||||
|
||||
sleep(5000);
|
||||
|
||||
// tv_app.connectSimulation();
|
||||
if(tv_app.isConnected()) System.out.println("CONNECTED");
|
||||
else System.out.println("NOT CONNECTED");
|
||||
}
|
||||
|
||||
public static int getOpenPort() {
|
||||
|
@ -9,21 +9,24 @@ import org.assertj.swing.fixture.JCheckBoxFixture;
|
||||
import org.assertj.swing.fixture.JOptionPaneFixture;
|
||||
import org.assertj.swing.fixture.JPanelFixture;
|
||||
import org.assertj.swing.fixture.JScrollPaneFixture;
|
||||
import org.assertj.swing.fixture.JTableFixture;
|
||||
import org.assertj.swing.fixture.JTextComponentFixture;
|
||||
import org.assertj.swing.fixture.JTreeFixture;
|
||||
import static org.assertj.swing.timing.Timeout.timeout;
|
||||
import org.jdesktop.swingx.JXTitledPanel;
|
||||
|
||||
import trick.sie.utils.SearchPanel;
|
||||
import trick.tv.TVApplication;
|
||||
|
||||
public class TVFixture extends FrameFixture {
|
||||
private JPanelFixture varSelectedPanel,
|
||||
varSearchPanel;
|
||||
private JPanelFixture varSearchPanel;
|
||||
private JTableFixture varSelectedPanel;
|
||||
|
||||
private JTextComponentFixture searchBar;
|
||||
|
||||
private JCheckBoxFixture caseSCheckBox,
|
||||
regexCheckBox;
|
||||
regexCheckBox,
|
||||
greedCheckBox;
|
||||
|
||||
private JScrollPaneFixture searchResults;
|
||||
private JTreeFixture varTree;
|
||||
@ -32,21 +35,22 @@ public class TVFixture extends FrameFixture {
|
||||
super(robot, target.getMainFrame());
|
||||
|
||||
// varTreePanel = panel(new JXTitledPanelMatcher("Variables"));
|
||||
// varSelectedPanel = panel(new JXTitledPanelMatcher("Selected Variables"));
|
||||
// varSearchPanel = panel(
|
||||
// new GenericTypeMatcher<SearchPanel>(SearchPanel.class) {
|
||||
// @Override
|
||||
// protected boolean isMatching(SearchPanel panel) {
|
||||
// return true;
|
||||
// }
|
||||
// });
|
||||
varSelectedPanel = table();
|
||||
varSearchPanel = panel(
|
||||
new GenericTypeMatcher<SearchPanel>(SearchPanel.class) {
|
||||
@Override
|
||||
protected boolean isMatching(SearchPanel panel) {
|
||||
return true;
|
||||
}
|
||||
});
|
||||
|
||||
varTree = tree();
|
||||
|
||||
// searchBar = varSearchPanel.textBox();
|
||||
// searchResults = varSearchPanel.scrollPane();
|
||||
// caseSCheckBox = varSearchPanel.checkBox("caseSensitiveCheckBox");
|
||||
// regexCheckBox = varSearchPanel.checkBox("regularExpressionCheckBox");
|
||||
caseSCheckBox = varSearchPanel.checkBox("caseSensitiveCheckBox");
|
||||
regexCheckBox = varSearchPanel.checkBox("regularExpressionCheckBox");
|
||||
greedCheckBox = varSearchPanel.checkBox("greedySearchCheckBox");
|
||||
}
|
||||
|
||||
//---------------------------
|
||||
@ -72,6 +76,16 @@ public class TVFixture extends FrameFixture {
|
||||
.enterText(query);
|
||||
}
|
||||
|
||||
public void setSearchOptions(int opts) {
|
||||
boolean senseSel = (opts & CASE_SENSITIVE_ON) == CASE_SENSITIVE_ON,
|
||||
regexSel = (opts & REG_EXPRESSION_ON) == REG_EXPRESSION_ON,
|
||||
greedSel = (opts & GREEDY_SEARCH_ON ) == GREEDY_SEARCH_ON ;
|
||||
|
||||
caseSCheckBox.check(senseSel);
|
||||
regexCheckBox.check(regexSel);
|
||||
greedCheckBox.check(greedSel);
|
||||
}
|
||||
|
||||
public JOptionPaneFixture getErrorPopupFixture() {
|
||||
JOptionPaneFixture opt = optionPane(timeout(1500));
|
||||
if(opt.target().getMessageType() == JOptionPane.ERROR_MESSAGE)
|
||||
@ -80,8 +94,8 @@ public class TVFixture extends FrameFixture {
|
||||
|
||||
}
|
||||
|
||||
public String[] getSelectedVars() {
|
||||
return varSelectedPanel.list().contents();
|
||||
public String[][] getSelectedVars() {
|
||||
return varSelectedPanel.contents();
|
||||
}
|
||||
|
||||
public String[] getSearchResults() {
|
||||
@ -107,4 +121,12 @@ public class TVFixture extends FrameFixture {
|
||||
return pane.getTitle().equals(title);
|
||||
}
|
||||
}
|
||||
|
||||
public static final int CASE_SENSITIVE_ON = 0b100,
|
||||
REG_EXPRESSION_ON = 0b010,
|
||||
GREEDY_SEARCH_ON = 0b001;
|
||||
|
||||
public static final int CASE_SENSITIVE_OFF = 0b000,
|
||||
REG_EXPRESSION_OFF = 0b000,
|
||||
GREEDY_SEARCH_OFF = 0b000;
|
||||
}
|
Loading…
x
Reference in New Issue
Block a user