From d7f9b8a516f926d72ad8183397726757d5084c91 Mon Sep 17 00:00:00 2001 From: Marcus Rockwell Date: Thu, 10 Oct 2024 12:14:21 -0400 Subject: [PATCH] Added getters to dre fixture --- .../main/java/trick/dre/DreApplication.java | 28 +++++++++-- .../java/trick/dre/fixtures/DreFixture.java | 48 +++++++++++++++++-- 2 files changed, 70 insertions(+), 6 deletions(-) diff --git a/trick_source/java/src/main/java/trick/dre/DreApplication.java b/trick_source/java/src/main/java/trick/dre/DreApplication.java index 57ea7051..e6b42c41 100644 --- a/trick_source/java/src/main/java/trick/dre/DreApplication.java +++ b/trick_source/java/src/main/java/trick/dre/DreApplication.java @@ -182,31 +182,37 @@ public class DreApplication extends TrickApplication { @Action public void selectDRBinary() { format = "DRBinary"; + DRBinary_item.setSelected(true); } @Action public void selectDRAscii() { format = "DRAscii"; + DRAscii_item.setSelected(true); } @Action public void selectDRHDF5() { format = "DRHDF5"; + DRHDF5_item.setSelected(true); } @Action public void selectDRAlways() { frequency = "DR_Always"; + DRAlways_item.setSelected(true); } @Action public void selectDRChanges() { frequency = "DR_Changes"; + DRChanges_item.setSelected(true); } @Action public void selectDRStepChanges() { frequency = "DR_Step_Changes"; + DRStepChanges_item.setSelected(true); } @Action @@ -222,16 +228,19 @@ public class DreApplication extends TrickApplication { @Action public void selectDRBuffer() { buffering = "DR_Buffer"; + DRBuffer_item.setSelected(true); } @Action public void selectDRNoBuffer() { buffering = "DR_No_Buffer"; + DRNoBuffer_item.setSelected(true); } @Action public void selectDRRingBuffer() { buffering = "DR_Ring_Buffer"; + DRRingBuffer_item.setSelected(true); } @Action @@ -400,6 +409,7 @@ public class DreApplication extends TrickApplication { */ private JMenu createOptionsMenu() { JMenu optionsMenu = new JMenu(); + JRadioButtonMenuItem[] rbuttons; String[] formats = {"selectDRBinary", "selectDRAscii", "selectDRHDF5"}, frequencies = {"selectDRAlways", "selectDRChanges", "selectDRStepChanges"}, buffers = {"selectDRBuffer", "selectDRNoBuffer", "selectDRRingBuffer"}; @@ -407,12 +417,20 @@ public class DreApplication extends TrickApplication { optionsMenu.setName("optionsMenu"); optionsMenu.add(new JLabel("Format ")); - addRadioButtonMenuItems(optionsMenu, formats); + rbuttons = addRadioButtonMenuItems(optionsMenu, formats); + + DRBinary_item = rbuttons[0]; + DRAscii_item = rbuttons[1]; + DRHDF5_item = rbuttons[2]; optionsMenu.addSeparator(); optionsMenu.add(new JLabel("Freq")); - addRadioButtonMenuItems(optionsMenu, frequencies); + rbuttons = addRadioButtonMenuItems(optionsMenu, frequencies); + + DRAlways_item = rbuttons[0]; + DRChanges_item = rbuttons[1]; + DRStepChanges_item = rbuttons[2]; optionsMenu.addSeparator(); @@ -423,7 +441,11 @@ public class DreApplication extends TrickApplication { optionsMenu.addSeparator(); optionsMenu.add(new JXLabel("Buffering")); - addRadioButtonMenuItems(optionsMenu, buffers); + rbuttons = addRadioButtonMenuItems(optionsMenu, buffers); + + DRBuffer_item = rbuttons[0]; + DRNoBuffer_item = rbuttons[1]; + DRRingBuffer_item = rbuttons[2]; selectDRBinary(); // by default, DR_Binary 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 82cdb2b7..9ffd4396 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 @@ -139,7 +139,7 @@ public class DreFixture extends FrameFixture { .enterText(cycle); } - public JOptionPaneFixture getErrorPopup() { + public JOptionPaneFixture getErrorPopupFixture() { JOptionPaneFixture opt = optionPane(timeout(1500)); if(opt.target().getMessageType() == JOptionPane.ERROR_MESSAGE) return opt; @@ -147,11 +147,53 @@ public class DreFixture extends FrameFixture { } - private void selectOption(String term) { - String menuItemName = "selectDR" + term + "MenuItem"; + public int getSelectedOptions() { + int opts = 0b11111111111; + + if (getOptionState("Binary")) + opts &= BINARY; + else if(getOptionState("Ascii")) + opts &= ASCII; + else if (getOptionState("HDF5")) + opts &= HDF5; + + if (getOptionState("Always")) + opts &= ALWAYS; + else if(getOptionState("Changes")) + opts &= CHANGES; + else if (getOptionState("StepChanges")) + opts &= STEP; + + if (getOptionState("Buffer")) + opts &= BUFFER; + else if(getOptionState("NoBuffer")) + opts &= NO_BUFFER; + else if (getOptionState("RingBuffer")) + opts &= RING_BUFFER; + + if(isSinglePrec()) + opts &= SINGLE_PREC_ON; + else + opts &= SINGLE_PREC_OFF; + + return opts; + } + + private boolean getOptionState(String ID) { + String menuItemName = "selectDR" + ID + "MenuItem"; + return menuItem(menuItemName).target().isSelected(); + } + + private void selectOption(String ID) { + String menuItemName = "selectDR" + ID + "MenuItem"; menuItem(menuItemName).click(); } + private boolean isSinglePrec() { + String singlePrecName = "toggleSinglePrecisionCheckBoxMenuItem"; + return menuItem(singlePrecName).target().isSelected(); + } + private void setSinglePrec(boolean state) { String singlePrecName = "toggleSinglePrecisionCheckBoxMenuItem"; JMenuItemFixture singlePrecCB = menuItem(singlePrecName);