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 a7ff416c..5ec63c80 100644 --- a/trick_source/java/src/test/java/trick/dre/DreApplicationTest.java +++ b/trick_source/java/src/test/java/trick/dre/DreApplicationTest.java @@ -53,6 +53,15 @@ public class DreApplicationTest extends ApplicationTest { dre_fix = new DreFixture(robot(), dre_app); } + /** + * Purpose: Test changing the selected format + * Procedures: + * 1) Select ASCII and save the selected options within ascii_sel + * 2) Select HDF5 and save the selected options within hdf5_sel + * 3) Select Binary and save the selected options within binary_sel + * 4) Verify that each of the saved selected options equals the + * expected benchmarks (BINARY_EXP, ASCII_EXP, HDF5_EXP) + */ @Test public void testFormatOptions() { // ARRANGE @@ -82,6 +91,15 @@ public class DreApplicationTest extends ApplicationTest { assertThat(hdf5_sel).isEqualTo(HDF5_EXP); } + /** + * Purpose: Test changing the selected frequency + * Procedures: + * 1) Select Changes and save the selected options within changes_sel + * 2) Select Step and save the selected options within step_sel + * 3) Select Always and save the selected options within always_sel + * 4) Verify that each of the saved selected options equals the + * expected benchmarks (ALWAYS_EXP, CHANGES_EXP, STEP_EXP) + */ @Test public void testFrequencyOptions() { // ARRANGE @@ -111,6 +129,15 @@ public class DreApplicationTest extends ApplicationTest { assertThat(step_sel).isEqualTo(STEP_EXP); } + /** + * Purpose: Test changing the selected buffer type + * Procedures: + * 1) Select No Buffer and save the selected options within no_buff_sel + * 2) Select Ring Buffer and save the selected options within ring_sel + * 3) Select Buffer and save the selected options within buffer_sel + * 4) Verify that each of the saved selected options equals the + * expected benchmarks (BUFFER_EXP, NO_BUFF_EXP, RING_EXP) + */ @Test public void testBufferOptions() { // ARRANGE @@ -140,6 +167,14 @@ public class DreApplicationTest extends ApplicationTest { assertThat(ring_sel).isEqualTo(RING_EXP); } + /** + * Purpose: Test toggling single precision on/off + * Procedures: + * 1) Toggle single precision on and save the selected options within sp_on_sel + * 2) Toggle single precision off and save the selected options within sp_off_sel + * 3) Verify that each of the saved selected options equals the + * expected benchmarks (SP_OFF_EXP, SP_ON_EXP) + */ @Test public void testSinglePrecOptions() { // ARRANGE @@ -164,6 +199,13 @@ public class DreApplicationTest extends ApplicationTest { assertThat(sp_on_sel).isEqualTo(SP_ON_EXP); } + /** + * Purpose: Select variables and verify that the Selected Variable + * Panel shows the expected output + * Procedures: + * 1) Select each contents of the Selected Variables panel to the + * SEL_VARS array + */ @Test public void testSelectVars() { // ARRANGE @@ -191,6 +233,12 @@ public class DreApplicationTest extends ApplicationTest { assertThat(res_vars[i]).isEqualTo(SEL_VARS[i]); } + /** + * Purpose: Do a basic test of the search panel to verify that it is enabled + * Procedure: + * 1) Use the search panel to find any variables that have 'var1' in their name. + * 2) Compare the search results with the benchmark SEARCH_VARS + */ @Test public void testSearchVars() { // ARRANGE @@ -216,6 +264,14 @@ public class DreApplicationTest extends ApplicationTest { assertThat(found_vars[i]).isEqualTo(SEARCH_VARS[i]); } + /** + * Purpose: Test inputing information into the toolbar + * Procedures: + * 1) Enter a group name + * 2) Enter a cycle + * 3) Set the maximum file size and the unit of measurement + * 4) Parse the settings output to verify the correct information was processed + */ @Test public void testToolbar() { // ARRANGE @@ -267,6 +323,23 @@ public class DreApplicationTest extends ApplicationTest { .isTrue(); } + /** + * Purpose: Test the save functionality + * Procedures: + * 1) Enter a group name + * 2) Enter a cycle + * 3) Set the maximum file size and the unit of measurement + * 4) Set the the format as ASCII, the frequency as Changes, + * the buffer as No Buffer, and Single Precision on + * 5) Select the various different variable types (drx.drt.charB, + * drx.drt.intB, drx.drt.shortB, drx.drt.ucharB, drx.drt.uintB, + * drx.drt.ushortB, drx.drt.mixB) + * 6) Make sure there isn't any remaining test result file from + * previous test runs + * 7) Click the Save menu item + * 8) Save the .dr file to test_result.dr + * 9) Compare test_result.dr to the presaved benchmark dre_test_ascii.dr + */ @Test public void testSaveDataRecordGroup() { // ARRANGE @@ -323,6 +396,20 @@ public class DreApplicationTest extends ApplicationTest { } } + /** + * Purpose: Test opening .dr files + * Procedures: + * 1) Click the Open menu item + * 2) Get the selected options and variables and store them in + * sel_opts and sel_vars, respectively + * 3) Get the settings output and store it in the settings array + * 4) Verify that the expected options are selected by comparing + * sel_opts with the benchmark EXP_OPTIONS + * 5) Parse the settings array and ensure that name, cycle, and + * max file size are as expected. + * 6) Verify that the selected variables within sel_vars is equal + * to the expected within SEL_VARS + */ @Test public void testLoadDataRecordGroup() { // ARRANGE @@ -337,12 +424,7 @@ public class DreApplicationTest extends ApplicationTest { final String[] VAR_TYPES = {"charB", "intB", "shortB", "ucharB", "uintB", "ushortB", "mixB"}; int sel_opts; - String name, cycle, size; String[] sel_vars, settings; - Size unit; - boolean setGrpName = false, - setCycle = false, - setSize = false; //ACT dre_fix.openMenuItem(TEST_DR.getAbsolutePath()); @@ -360,13 +442,10 @@ public class DreApplicationTest extends ApplicationTest { for(String line : settings) { if (line.contains("drg.append")) { - setGrpName = true; assertThat(line).contains(EXP_NAME); } else if (line.contains("set_cycle")) { - setCycle = true; assertThat(line).contains(EXP_CYCLE); } else if(line.contains("set_max_file_size")) { - setSize = true; assertThat(line).contains(EXP_SIZE) .contains(EXP_UNIT.TAG); } diff --git a/trick_source/java/src/test/java/trick/simcontrol/SimControlApplicationTest.java b/trick_source/java/src/test/java/trick/simcontrol/SimControlApplicationTest.java index 30c788c0..f14cd8b5 100644 --- a/trick_source/java/src/test/java/trick/simcontrol/SimControlApplicationTest.java +++ b/trick_source/java/src/test/java/trick/simcontrol/SimControlApplicationTest.java @@ -101,31 +101,61 @@ public class SimControlApplicationTest extends ApplicationTest { // JButton Tests //-------------------- + /** + * Purpose: + * Procedures: + * 1) + */ @Test public void testConnectButton() { testJButton("Connect", ActionID.CONNECT); } + /** + * Purpose: + * Procedures: + * 1) + */ @Test public void testStartButton() { testJButton("Start", ActionID.START); } + /** + * Purpose: + * Procedures: + * 1) + */ @Test public void testFreezeButton() { testJButton("Freeze", ActionID.FREEZE); } + /** + * Purpose: + * Procedures: + * 1) + */ @Test public void testStepButton() { testJButton("Step", ActionID.STEP); } + /** + * Purpose: + * Procedures: + * 1) + */ @Test public void testShutdownButton() { testJButton("Shutdown", ActionID.SHUTDOWN); } + /** + * Purpose: + * Procedures: + * 1) + */ @Test public void testExitButton() { testJButton("Exit", ActionID.EXIT); @@ -135,16 +165,31 @@ public class SimControlApplicationTest extends ApplicationTest { // JToggleButton Tests //----------------------- + /** + * Purpose: + * Procedures: + * 1) + */ @Test public void testDumpChkpntButton() { testButtonToggleTwice("Dump Chkpnt", ActionID.DUMP_CHKPNT); } + /** + * Purpose: + * Procedures: + * 1) + */ @Test public void testLoadChkpntButton() { testButtonToggleTwice("Load Chkpnt", ActionID.LOAD_CHKPNT); } + /** + * Purpose: + * Procedures: + * 1) + */ @Test public void testLiteToggle() { Frame frame = mainFrame.target(); @@ -159,11 +204,21 @@ public class SimControlApplicationTest extends ApplicationTest { assertThat(toggle2).isEqualTo(SimControlApplication.FULL_SIZE); } + /** + * Purpose: + * Procedures: + * 1) + */ @Test public void testDataRecToggle() { testButtonToggleTwice("Data Rec On", "Data Rec Off", ActionID.RECORDING); } + /** + * Purpose: + * Procedures: + * 1) + */ @Test public void testRealtimeToggle() { testButtonToggleTwice("RealTime On", ActionID.REALTIME); @@ -173,6 +228,11 @@ public class SimControlApplicationTest extends ApplicationTest { // Status Message Pane Tests //----------------------------- + /** + * Purpose: + * Procedures: + * 1) + */ @Test public void testStatusMsgPane() { // ARRANGE @@ -188,6 +248,11 @@ public class SimControlApplicationTest extends ApplicationTest { assertThat(editorFixture.target().getText()); } + /** + * Purpose: + * Procedures: + * 1) + */ @Test public void testFindPanelButtons() { // ARRANGE @@ -255,6 +320,11 @@ public class SimControlApplicationTest extends ApplicationTest { // File Menu Tests //-------------------- + /** + * Purpose: + * Procedures: + * 1) + */ @Test public void testFontChange() { // ARRANGE @@ -299,6 +369,11 @@ public class SimControlApplicationTest extends ApplicationTest { assertThat(actualFont).isEqualTo(expFont); } + /** + * Purpose: + * Procedures: + * 1) + */ @Test public void testSaveStatusMessage() { // ARRANGE @@ -315,6 +390,11 @@ public class SimControlApplicationTest extends ApplicationTest { assertThat(action).isEqualTo(ActionID.SAVE_STATUS); } + /** + * Purpose: + * Procedures: + * 1) + */ @Test public void testClearStatusMessage() { // ARRANGE @@ -334,8 +414,13 @@ public class SimControlApplicationTest extends ApplicationTest { assertThat(editorFixture.text()).isEqualTo(""); } - @Test + /** + * Purpose: + * Procedures: + * 1) + */ /* Not sure if I should test each of the LookAndFeel buttons */ + @Test public void testLookAndFeel() { // ARRANGE JMenuItemFixture lafItem = mainFrame.menuItem("lookAndFeelMenuItem"); @@ -367,6 +452,11 @@ public class SimControlApplicationTest extends ApplicationTest { // Action Menu Tests //-------------------- + /** + * Purpose: + * Procedures: + * 1) + */ @Test public void testStartTrickViewMenuItem() { // ARRANGE @@ -383,6 +473,11 @@ public class SimControlApplicationTest extends ApplicationTest { assertThat(loggedAction).isEqualTo(TV_ACTION); } + /** + * Purpose: + * Procedures: + * 1) + */ @Test public void testStartMalfunctionTrickViewMenuItem() { // ARRANGE @@ -399,6 +494,11 @@ public class SimControlApplicationTest extends ApplicationTest { assertThat(loggedAction).isEqualTo(MTV_ACTION); } + /** + * Purpose: + * Procedures: + * 1) + */ @Test public void testFreezeAtMenuItem() { // ARRANGE @@ -415,6 +515,11 @@ public class SimControlApplicationTest extends ApplicationTest { assertThat(loggedAction).isEqualTo(FREEZE_AT_ACTION); } + /** + * Purpose: + * Procedures: + * 1) + */ @Test public void testFreezeInMenuItem() { // ARRANGE @@ -432,6 +537,11 @@ public class SimControlApplicationTest extends ApplicationTest { } + /** + * Purpose: + * Procedures: + * 1) + */ @Test public void testCheckpointMenuItem() { // ARRANGE @@ -448,6 +558,11 @@ public class SimControlApplicationTest extends ApplicationTest { assertThat(loggedAction).isEqualTo(CHKPNT_OBJ_ACTION); } + /** + * Purpose: + * Procedures: + * 1) + */ @Test public void testThrottleMenuItem() { // ARRANGE @@ -468,6 +583,11 @@ public class SimControlApplicationTest extends ApplicationTest { // Toolbar Tests //-------------------- + /** + * Purpose: + * Procedures: + * 1) + */ @Test public void testStartTrickViewButton() { final JButtonFixture TV_BUTTON = toolBarFixture.button("startTVButton"); @@ -476,6 +596,11 @@ public class SimControlApplicationTest extends ApplicationTest { testConnectedAction(TV_BUTTON, TV_ACTION); } + /** + * Purpose: + * Procedures: + * 1) + */ @Test public void testStartMalfunctionTrickViewButton() { final JButtonFixture MTV_BUTTON = toolBarFixture.button("startMTVButton"); @@ -484,6 +609,11 @@ public class SimControlApplicationTest extends ApplicationTest { testConnectedAction(MTV_BUTTON, MTV_ACTION); } + /** + * Purpose: + * Procedures: + * 1) + */ @Test public void testThrottleButton() { final JButtonFixture THROTTLE_BUTTON = toolBarFixture.button("throttleButton"); 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 d4888f27..be9f6ae9 100644 --- a/trick_source/java/src/test/java/trick/tv/TVApplicationTest.java +++ b/trick_source/java/src/test/java/trick/tv/TVApplicationTest.java @@ -18,9 +18,6 @@ import org.junit.Test; import trick.common.ApplicationTest; import trick.common.TestUtils; import trick.tv.fixtures.TVFixture; -import static trick.tv.fixtures.TVFixture.CASE_SENSITIVE_ON; -import static trick.tv.fixtures.TVFixture.GREEDY_SEARCH_ON; -import static trick.tv.fixtures.TVFixture.REG_EXPRESSION_ON; /** * @@ -40,6 +37,12 @@ public class TVApplicationTest extends ApplicationTest { private TVFixture tv_fix; private MockTVApplication tv_app; + /** + * Before Running the Test Suite, prior to the constructor being called: + * Compiles and runs SIM_test_dr in the trick/test/ directory. + * - Change String SIM_NAME to compile & run another simulation in the + * trick/test/ folder + */ @BeforeClass public static void onSetUpBeforeClass() { assumeThat(TestUtils.compileTestSim(SIM_NAME)) @@ -52,6 +55,10 @@ public class TVApplicationTest extends ApplicationTest { .isNotNull(); } + /** + * After Running the Test Suite + * Kill the running simulation + */ @AfterClass public static void onCleanUpAfterClass() { if(sim_process != null && sim_process.isAlive()) { @@ -59,6 +66,12 @@ public class TVApplicationTest extends ApplicationTest { } } + /** + * Set Up Before Each Test + * Start the application using the arguments to provide a host name and port number. + * Save the application instance in a variable + * Create a test fixture using the instance + */ @Override protected void onSetUp() { application(MockTVApplication.class) @@ -72,33 +85,12 @@ public class TVApplicationTest extends ApplicationTest { tv_fix = new TVFixture(robot(), tv_app); } - @Test - public void testGeneric() { - 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); - } - + /** + * Purpose: Select variables and verify that the expected values are in the table + * Procedures: + * 1) Select each of the mentioned variables + * 2) Compare the table values to the benchmark matrix SEL_VARS + */ @Test public void testSelectVars() { // ARRANGE @@ -139,6 +131,12 @@ public class TVApplicationTest extends ApplicationTest { } } + /** + * Purpose: Do a basic test of the search panel to verify that it is enabled + * Procedure: + * 1) Use the search panel to find any variables that have 'var1' in their name. + * 2) Compare the search results with the benchmark SEARCH_VARS + */ @Test public void testSearchVars() { // ARRANGE @@ -164,6 +162,14 @@ public class TVApplicationTest extends ApplicationTest { assertThat(found_vars[i]).isEqualTo(SEARCH_VARS[i]); } + /** + * Purpose: Validate that variable values can be changed by editing the table + * Procedures: + * 1) Select each of the variables within SEL_VARS + * 2) Change the values of each of the selected variables + * 3) Verify that the table contains the expected values + * 4) Return the variables back to their original values + */ @Test public void testEditTable() { // ARRANGE @@ -205,6 +211,15 @@ public class TVApplicationTest extends ApplicationTest { } } + /** + * Purpose: Test the save functionality. Specifically that tied to the menu item. + * Procedures: + * 1) Select the list of variables + * 2) Click the Save menu item within the File menu + * 3) Enter the path where the new file will be saved to (see File SAVED_OUTPUT) + * 4) Compare the contents of the saved file to the benchmark file (see File EXPECTED_OUTPUT) + * - If the contents aren't the same, copy the saved file to the FAILED_TEST file for debugging + */ @Test public void testSave() { // ARRANGE @@ -251,6 +266,13 @@ public class TVApplicationTest extends ApplicationTest { .isTrue(); } + /** + * Purpose: Test the Open functionality. It should just add in the variables without overwriting the values + * Procedures: + * 1) Click the Open menu item + * 2) Enter the path where the file will be loaded from (see File SAVED_FILE) + * 3) Compare the table after loading to the expected in SEL_VARS. + */ @Test public void testLoadVariables() { // ARRANGE @@ -279,6 +301,15 @@ public class TVApplicationTest extends ApplicationTest { assertThat2DArraysAreEqual(res_vars, SEL_VARS); } + /** + * Purpose: Test the Open & Set menu item. It should update the selected variables and their values + * Procedures: + * 1) Click the Open & Set menu item + * 2) Open the file specified by SAVED_FILE + * 3) Compare the table after loading to the expected in SEL_VARS. + * - The variable values will be different from the default simulation values + * 4) Use the Open & Set menu item to reload the orignal values using the ORIGINAL_VALS_FILE variable + */ @Test public void testLoadVariables_SetValues() { // ARRANGE @@ -311,6 +342,16 @@ public class TVApplicationTest extends ApplicationTest { sleep(500); } + /** + * Purpose: Test the Set menu item. It should set variable values without changing the selected variables + * Procedures: + * 1) Click the Set menu item + * 2) Use SAVED_FILE to load the values + * 3) Record the state of the variable table immediately after loading the file (res_vars1) + * 4) Select the variables within SEL_VARS + * 5) Verify that res_vars1 is empty + * 6) Verify that the variable values have changed to the expected + */ @Test public void testSetValues() { // ARRANGE @@ -354,6 +395,16 @@ public class TVApplicationTest extends ApplicationTest { sleep(500); } + /** + * Purpose: Test the toggle for turning monitoring on and off + * Procedures: + * 1) Toggle monitoring off + * 2) Select variable "drx.drt.a" + * 3) Save the variable entry in the array var_no_monitor + * 4) Toggle monitoring back on + * 5) Save the updated entry in the array var_monitor + * 6) compare both arrays to their expected benchmarks + */ @Test public void testMonitorToggle() { // ARRANGE @@ -383,6 +434,10 @@ public class TVApplicationTest extends ApplicationTest { } + /** + * Find a free port, write the number to a file called port.info + * within the RUN_gui_test directory. Return the chosen port + */ public static int getOpenPort() { String port = "39595"; File port_info;