From 1a75fce084b03e07cee13bdc0f37b40c1c10e1ec Mon Sep 17 00:00:00 2001 From: Marcus Rockwell Date: Wed, 13 Nov 2024 17:19:42 -0500 Subject: [PATCH] Updated fixture --- .../test/java/trick/tv/MockTVApplication.java | 20 ------- .../test/java/trick/tv/TVApplicationTest.java | 30 ++++++++--- .../java/trick/tv/fixtures/TVFixture.java | 52 +++++++++++++------ 3 files changed, 60 insertions(+), 42 deletions(-) diff --git a/trick_source/java/src/test/java/trick/tv/MockTVApplication.java b/trick_source/java/src/test/java/trick/tv/MockTVApplication.java index c2c019ac..de98c3e6 100644 --- a/trick_source/java/src/test/java/trick/tv/MockTVApplication.java +++ b/trick_source/java/src/test/java/trick/tv/MockTVApplication.java @@ -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) { diff --git a/trick_source/java/src/test/java/trick/tv/TVApplicationTest.java b/trick_source/java/src/test/java/trick/tv/TVApplicationTest.java index fd4b6e90..6605467a 100644 --- a/trick_source/java/src/test/java/trick/tv/TVApplicationTest.java +++ b/trick_source/java/src/test/java/trick/tv/TVApplicationTest.java @@ -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() { diff --git a/trick_source/java/src/test/java/trick/tv/fixtures/TVFixture.java b/trick_source/java/src/test/java/trick/tv/fixtures/TVFixture.java index 1d5ccaf6..44f238a7 100644 --- a/trick_source/java/src/test/java/trick/tv/fixtures/TVFixture.java +++ b/trick_source/java/src/test/java/trick/tv/fixtures/TVFixture.java @@ -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.class) { - // @Override - // protected boolean isMatching(SearchPanel panel) { - // return true; - // } - // }); + varSelectedPanel = table(); + varSearchPanel = panel( + new GenericTypeMatcher(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; } \ No newline at end of file