mirror of
https://github.com/nasa/trick.git
synced 2025-02-06 02:49:20 +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 {
|
public class MockTVApplication extends TVApplication {
|
||||||
private boolean connected = false;
|
|
||||||
private static String hostname;
|
|
||||||
private static int port;
|
|
||||||
private static Object lock = new Object();
|
private static Object lock = new Object();
|
||||||
|
|
||||||
boolean isEnded;
|
boolean isEnded;
|
||||||
@ -25,24 +22,7 @@ public class MockTVApplication extends TVApplication {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public final boolean isConnected() { return connected; }
|
|
||||||
|
|
||||||
public void connectSimulation() {
|
|
||||||
setTargetSimulation(hostname, port);
|
|
||||||
}
|
|
||||||
|
|
||||||
public static void main(String[] args) {
|
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) {
|
synchronized(lock) {
|
||||||
Application.launch(MockTVApplication.class, args);
|
Application.launch(MockTVApplication.class, args);
|
||||||
while(true) {
|
while(true) {
|
||||||
|
@ -15,6 +15,8 @@ import trick.common.ApplicationTest;
|
|||||||
import trick.common.TestUtils;
|
import trick.common.TestUtils;
|
||||||
import trick.tv.fixtures.TVFixture;
|
import trick.tv.fixtures.TVFixture;
|
||||||
|
|
||||||
|
import static trick.tv.fixtures.TVFixture.*;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
*
|
*
|
||||||
* Test TVApplication life cycle.
|
* Test TVApplication life cycle.
|
||||||
@ -63,19 +65,33 @@ public class TVApplicationTest extends ApplicationTest {
|
|||||||
|
|
||||||
tv_app = MockTVApplication.getInstance(MockTVApplication.class);
|
tv_app = MockTVApplication.getInstance(MockTVApplication.class);
|
||||||
tv_fix = new TVFixture(robot(), tv_app);
|
tv_fix = new TVFixture(robot(), tv_app);
|
||||||
tv_fix.getErrorPopupFixture()
|
|
||||||
.okButton().click();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testGeneric() {
|
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);
|
sleep(5000);
|
||||||
|
|
||||||
// tv_app.connectSimulation();
|
|
||||||
if(tv_app.isConnected()) System.out.println("CONNECTED");
|
|
||||||
else System.out.println("NOT CONNECTED");
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public static int getOpenPort() {
|
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.JOptionPaneFixture;
|
||||||
import org.assertj.swing.fixture.JPanelFixture;
|
import org.assertj.swing.fixture.JPanelFixture;
|
||||||
import org.assertj.swing.fixture.JScrollPaneFixture;
|
import org.assertj.swing.fixture.JScrollPaneFixture;
|
||||||
|
import org.assertj.swing.fixture.JTableFixture;
|
||||||
import org.assertj.swing.fixture.JTextComponentFixture;
|
import org.assertj.swing.fixture.JTextComponentFixture;
|
||||||
import org.assertj.swing.fixture.JTreeFixture;
|
import org.assertj.swing.fixture.JTreeFixture;
|
||||||
import static org.assertj.swing.timing.Timeout.timeout;
|
import static org.assertj.swing.timing.Timeout.timeout;
|
||||||
import org.jdesktop.swingx.JXTitledPanel;
|
import org.jdesktop.swingx.JXTitledPanel;
|
||||||
|
|
||||||
|
import trick.sie.utils.SearchPanel;
|
||||||
import trick.tv.TVApplication;
|
import trick.tv.TVApplication;
|
||||||
|
|
||||||
public class TVFixture extends FrameFixture {
|
public class TVFixture extends FrameFixture {
|
||||||
private JPanelFixture varSelectedPanel,
|
private JPanelFixture varSearchPanel;
|
||||||
varSearchPanel;
|
private JTableFixture varSelectedPanel;
|
||||||
|
|
||||||
private JTextComponentFixture searchBar;
|
private JTextComponentFixture searchBar;
|
||||||
|
|
||||||
private JCheckBoxFixture caseSCheckBox,
|
private JCheckBoxFixture caseSCheckBox,
|
||||||
regexCheckBox;
|
regexCheckBox,
|
||||||
|
greedCheckBox;
|
||||||
|
|
||||||
private JScrollPaneFixture searchResults;
|
private JScrollPaneFixture searchResults;
|
||||||
private JTreeFixture varTree;
|
private JTreeFixture varTree;
|
||||||
@ -32,21 +35,22 @@ public class TVFixture extends FrameFixture {
|
|||||||
super(robot, target.getMainFrame());
|
super(robot, target.getMainFrame());
|
||||||
|
|
||||||
// varTreePanel = panel(new JXTitledPanelMatcher("Variables"));
|
// varTreePanel = panel(new JXTitledPanelMatcher("Variables"));
|
||||||
// varSelectedPanel = panel(new JXTitledPanelMatcher("Selected Variables"));
|
varSelectedPanel = table();
|
||||||
// varSearchPanel = panel(
|
varSearchPanel = panel(
|
||||||
// new GenericTypeMatcher<SearchPanel>(SearchPanel.class) {
|
new GenericTypeMatcher<SearchPanel>(SearchPanel.class) {
|
||||||
// @Override
|
@Override
|
||||||
// protected boolean isMatching(SearchPanel panel) {
|
protected boolean isMatching(SearchPanel panel) {
|
||||||
// return true;
|
return true;
|
||||||
// }
|
}
|
||||||
// });
|
});
|
||||||
|
|
||||||
varTree = tree();
|
varTree = tree();
|
||||||
|
|
||||||
// searchBar = varSearchPanel.textBox();
|
// searchBar = varSearchPanel.textBox();
|
||||||
// searchResults = varSearchPanel.scrollPane();
|
// searchResults = varSearchPanel.scrollPane();
|
||||||
// caseSCheckBox = varSearchPanel.checkBox("caseSensitiveCheckBox");
|
caseSCheckBox = varSearchPanel.checkBox("caseSensitiveCheckBox");
|
||||||
// regexCheckBox = varSearchPanel.checkBox("regularExpressionCheckBox");
|
regexCheckBox = varSearchPanel.checkBox("regularExpressionCheckBox");
|
||||||
|
greedCheckBox = varSearchPanel.checkBox("greedySearchCheckBox");
|
||||||
}
|
}
|
||||||
|
|
||||||
//---------------------------
|
//---------------------------
|
||||||
@ -72,6 +76,16 @@ public class TVFixture extends FrameFixture {
|
|||||||
.enterText(query);
|
.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() {
|
public JOptionPaneFixture getErrorPopupFixture() {
|
||||||
JOptionPaneFixture opt = optionPane(timeout(1500));
|
JOptionPaneFixture opt = optionPane(timeout(1500));
|
||||||
if(opt.target().getMessageType() == JOptionPane.ERROR_MESSAGE)
|
if(opt.target().getMessageType() == JOptionPane.ERROR_MESSAGE)
|
||||||
@ -80,8 +94,8 @@ public class TVFixture extends FrameFixture {
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public String[] getSelectedVars() {
|
public String[][] getSelectedVars() {
|
||||||
return varSelectedPanel.list().contents();
|
return varSelectedPanel.contents();
|
||||||
}
|
}
|
||||||
|
|
||||||
public String[] getSearchResults() {
|
public String[] getSearchResults() {
|
||||||
@ -107,4 +121,12 @@ public class TVFixture extends FrameFixture {
|
|||||||
return pane.getTitle().equals(title);
|
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