diff --git a/trick_source/java/src/test/java/trick/dre/DreApplicationTest.java b/trick_source/java/src/test/java/trick/dre/DreApplicationTest.java index 862daa69..f631932b 100644 --- a/trick_source/java/src/test/java/trick/dre/DreApplicationTest.java +++ b/trick_source/java/src/test/java/trick/dre/DreApplicationTest.java @@ -14,9 +14,12 @@ import org.junit.Test; import trick.common.ApplicationTest; import trick.common.CheckApplicationProperties; import trick.dre.MockDreApplication; +import trick.dre.fixtures.DreFixture; import static org.assertj.core.api.Assertions.assertThat; +import static trick.dre.fixtures.DreFixture.*; + /** * * Test DreApplication life cycle. @@ -27,6 +30,8 @@ import static org.assertj.core.api.Assertions.assertThat; */ public class DreApplicationTest extends ApplicationTest { + private DreFixture dre_fix; + @BeforeClass public static void onSetUpBeforeClass() { @@ -35,11 +40,17 @@ public class DreApplicationTest extends ApplicationTest { @Override protected void onSetUp() { application(MockDreApplication.class).start(); + + sleep(500); + + dre_fix = new DreFixture(robot(), MockDreApplication.getInstance()); } @Test public void testGeneric() { boolean bool = true; + dre_fix.selectVar("drx/name"); + dre_fix.setOptions(HDF5 | STEP | RING_BUFFER); sleep(5000); assertThat(bool).isTrue(); } diff --git a/trick_source/java/src/test/java/trick/dre/MockDreApplication.java b/trick_source/java/src/test/java/trick/dre/MockDreApplication.java index a388d16d..678380a2 100644 --- a/trick_source/java/src/test/java/trick/dre/MockDreApplication.java +++ b/trick_source/java/src/test/java/trick/dre/MockDreApplication.java @@ -3,6 +3,8 @@ package trick.dre; import java.io.File; +import org.assertj.swing.core.GenericTypeMatcher; + import org.jdesktop.application.Application; import trick.common.ApplicationTest; @@ -11,6 +13,14 @@ import trick.common.TestUtils; import static org.assertj.core.api.Assumptions.assumeThat; public class MockDreApplication extends DreApplication { + private static MockDreApplication the_dre; + + public MockDreApplication() { + super(); + the_dre = this; + } + + public static MockDreApplication getInstance() { return the_dre; } public static void main(String[] args) { File sie; diff --git a/trick_source/java/src/test/java/trick/dre/fixtures/DreFixture.java b/trick_source/java/src/test/java/trick/dre/fixtures/DreFixture.java index 69ee338c..70c0445b 100644 --- a/trick_source/java/src/test/java/trick/dre/fixtures/DreFixture.java +++ b/trick_source/java/src/test/java/trick/dre/fixtures/DreFixture.java @@ -3,6 +3,7 @@ package trick.dre.fixtures; import java.awt.Font; import java.awt.GraphicsEnvironment; +import org.assertj.swing.core.GenericTypeMatcher; import org.assertj.swing.core.Robot; import org.assertj.swing.fixture.ComponentContainerFixture; import org.assertj.swing.fixture.DialogFixture; @@ -11,6 +12,7 @@ import org.assertj.swing.fixture.JCheckBoxFixture; import org.assertj.swing.fixture.JLabelFixture; import org.assertj.swing.fixture.JListFixture; import org.assertj.swing.fixture.JPanelFixture; +import org.assertj.swing.fixture.JTreeFixture; import org.jdesktop.swingx.JXTitledPanel; @@ -21,18 +23,100 @@ public class DreFixture extends FrameFixture { private JPanelFixture varTreePanel, varSelectedPanel, varSearchPanel; + + private JTreeFixture varTree; public DreFixture(Robot robot, DreApplication target) { super(robot, target.getMainFrame()); - varTreePanel = panel( - new GenericTypeMatcher<JXTitledPanel>(JXTitledPanel.class) { - @Override - protected boolean isMatching(JXTitledPanel pane) { - return pane.getTitle().equals("Variables"); - } - } - ); + varTreePanel = panel(new JXTitledPanelMatcher("Variables")); + varSelectedPanel = panel(new JXTitledPanelMatcher("Selected Variables")); + + varTree = varTreePanel.tree(); } + //--------------------------- + // Fixture Methods + //--------------------------- + + public void selectVar(String varPath) { + varTree.doubleClickPath(varPath); + } + + public void setOptions(int opts) { + switch (opts & 0b1110000000) { + case BINARY: selectFormat(0); break; + case ASCII: selectFormat(1); break; + case HDF5: selectFormat(2); break; + default: break; + } + + switch (opts & 0b0001110000) { + case ALWAYS: selectFrequency(0); break; + case CHANGES: selectFrequency(1); break; + case STEP: selectFrequency(2); break; + default: break; + } + + switch (opts & 0b0000001110) { + case BUFFER: selectBuffer(0); break; + case NO_BUFFER: selectBuffer(1); break; + case RING_BUFFER: selectBuffer(2); break; + default: break; + } + } + + private void selectFormat(int index) { + String menuItemName = "DR" + FORMATS[index]; + menuItem(menuItemName).click(); + } + + private void selectFrequency(int index) { + String menuItemName = "DR_" + FREQUENCIES[index]; + menuItem(menuItemName).click(); + } + + private void selectBuffer(int index) { + String menuItemName = "DR_" + BUFFERS[index]; + menuItem(menuItemName).click(); + } + + //--------------------------- + // Inner Classes + //--------------------------- + + private class JXTitledPanelMatcher extends GenericTypeMatcher<JXTitledPanel> { + private final String title; + + public JXTitledPanelMatcher(String title) { + super(JXTitledPanel.class); + + this.title = title; + } + + @Override + protected boolean isMatching(JXTitledPanel pane) { + return pane.getTitle().equals(title); + } + } + + //---------------------------- + // Constant Variables + //---------------------------- + // 0x000 000 000 0 + + public final static int BINARY = 0b1000000000, + ASCII = 0b0100000000, + HDF5 = 0b0010000000, + ALWAYS = 0b0001000000, + CHANGES = 0b0000100000, + STEP = 0b0000010000, + BUFFER = 0b0000001000, + NO_BUFFER = 0b0000000100, + RING_BUFFER = 0b0000000010, + SINGLE_PREC = 0b0000000001; + + private final String[] FORMATS = {"Binary", "Ascii", "HJDF5"}, + BUFFERS = {"Buffer", "No_Buffer", "Ring_Buffer", "Thread_Buffer"}, + FREQUENCIES = {"Always", "Changes", "Step_Changes"}; } \ No newline at end of file