mirror of
https://github.com/nasa/trick.git
synced 2025-01-30 16:13:55 +00:00
Implemented the skeleton of the DataRecording test suite
This commit is contained in:
parent
90feb68a5f
commit
d5dcc315ac
@ -325,7 +325,6 @@
|
|||||||
<excludes>
|
<excludes>
|
||||||
<exclude> **/TrickDPApplicationTest.java </exclude>
|
<exclude> **/TrickDPApplicationTest.java </exclude>
|
||||||
<exclude> **/TrickQPApplicationTest.java </exclude>
|
<exclude> **/TrickQPApplicationTest.java </exclude>
|
||||||
<exclude> **/DreApplicationTest.java </exclude>
|
|
||||||
<exclude> **/MonteMonitorApplicationTest.java </exclude>
|
<exclude> **/MonteMonitorApplicationTest.java </exclude>
|
||||||
<exclude> **/MtvApplicationTest.java </exclude>
|
<exclude> **/MtvApplicationTest.java </exclude>
|
||||||
<exclude> **/SieApplicationTest.java </exclude>
|
<exclude> **/SieApplicationTest.java </exclude>
|
||||||
|
19
trick_source/java/src/test/java/trick/common/TestUtils.java
Normal file
19
trick_source/java/src/test/java/trick/common/TestUtils.java
Normal file
@ -0,0 +1,19 @@
|
|||||||
|
package trick.common;
|
||||||
|
|
||||||
|
import trick.common.SimulationInterface;
|
||||||
|
|
||||||
|
public class TestUtils {
|
||||||
|
public static String getTrickHome() {
|
||||||
|
String cwd = System.getProperty("user.dir");
|
||||||
|
int trick_index = cwd.indexOf("/trick/trick_source/java");
|
||||||
|
|
||||||
|
return cwd.substring(0, trick_index + 6);
|
||||||
|
}
|
||||||
|
|
||||||
|
public static boolean compileTestSim(String sim_name) {
|
||||||
|
String sim_path = getTrickHome() + "/test/" + sim_name;
|
||||||
|
|
||||||
|
SimulationInterface.cleanSim(sim_path);
|
||||||
|
return SimulationInterface.compileSim(sim_path);
|
||||||
|
}
|
||||||
|
}
|
@ -1,5 +1,7 @@
|
|||||||
package trick.dre;
|
package trick.dre;
|
||||||
|
|
||||||
|
import static org.assertj.swing.launcher.ApplicationLauncher.application;
|
||||||
|
|
||||||
import static org.junit.Assert.assertTrue;
|
import static org.junit.Assert.assertTrue;
|
||||||
|
|
||||||
import org.jdesktop.application.Application;
|
import org.jdesktop.application.Application;
|
||||||
@ -9,7 +11,11 @@ import org.junit.Before;
|
|||||||
import org.junit.BeforeClass;
|
import org.junit.BeforeClass;
|
||||||
import org.junit.Test;
|
import org.junit.Test;
|
||||||
|
|
||||||
|
import trick.common.ApplicationTest;
|
||||||
import trick.common.CheckApplicationProperties;
|
import trick.common.CheckApplicationProperties;
|
||||||
|
import trick.dre.MockDreApplication;
|
||||||
|
|
||||||
|
import static org.assertj.core.api.Assertions.assertThat;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
*
|
*
|
||||||
@ -19,63 +25,22 @@ import trick.common.CheckApplicationProperties;
|
|||||||
* @intern mrockwell2
|
* @intern mrockwell2
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
public class DreApplicationTest {
|
public class DreApplicationTest extends ApplicationTest {
|
||||||
|
|
||||||
@BeforeClass
|
@BeforeClass
|
||||||
public static void setUpBeforeClass() throws Exception {
|
public static void onSetUpBeforeClass() {
|
||||||
WaitForDreApplication.launchAndWait(WaitForDreApplication.class);
|
|
||||||
}
|
|
||||||
|
|
||||||
@AfterClass
|
}
|
||||||
public static void tearDownAfterClass() throws Exception {
|
|
||||||
}
|
|
||||||
|
|
||||||
@Before
|
@Override
|
||||||
public void setUp() throws Exception {
|
protected void onSetUp() {
|
||||||
}
|
application(MockDreApplication.class).start();
|
||||||
|
|
||||||
@After
|
|
||||||
public void tearDown() throws Exception {
|
|
||||||
}
|
|
||||||
|
|
||||||
@Test
|
|
||||||
public void testReady() {
|
|
||||||
assertTrue("DreApplicationTest is not ready yet!", application().isReady());
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Verify that all implemented actions exist as well as their text, shortDescription properties.
|
|
||||||
*/
|
|
||||||
@Test
|
|
||||||
public void testDefinedActions() {
|
|
||||||
String[] actionNames = {"openDR", "saveDR", "selectDRBinary", "selectDRAscii", "selectDRHDF5",
|
|
||||||
"selectDRAlways", "selectDRChanges", "selectDRStepChanges", "toggleSinglePrecision",
|
|
||||||
"selectDRBuffer", "selectDRNoBuffer", "selectDRRingBuffer", "selectDRThreadBuffer",
|
|
||||||
"addVariables", "removeSelected", "removeAll"};
|
|
||||||
String[] actionTexts = {"Open...", "Save...", "DR Binary", "DR Ascii", "DR HDF5", "DR Always", "DR Changes",
|
|
||||||
"DR Step Changes", "Single Precision", "DR Buffer", "DR No Buffer", "DR Ring Buffer",
|
|
||||||
"DR Thread Buffer", "Add", "Remove Selected", "Remove All"};
|
|
||||||
|
|
||||||
for (int i = 0; i < actionNames.length; i++) {
|
|
||||||
CheckApplicationProperties.checkAction(application().actionMap, actionNames[i]);
|
|
||||||
CheckApplicationProperties.checkActionText(application().actionMap, actionNames[i], actionTexts[i]);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testDefinedKeyText() {
|
public void testGeneric() {
|
||||||
CheckApplicationProperties.checkKeyText(application().resourceMap, "fileMenu.text", "&File");
|
boolean bool = true;
|
||||||
CheckApplicationProperties.checkKeyText(application().resourceMap, "optionsMenu.text", "&Options");
|
sleep(5000);
|
||||||
}
|
assertThat(bool).isTrue();
|
||||||
|
|
||||||
@Test
|
|
||||||
public void testExit() {
|
|
||||||
application().removeExitListener(application().exitListener);
|
|
||||||
application().exit();
|
|
||||||
assertTrue(application().isEnded);
|
|
||||||
}
|
|
||||||
|
|
||||||
private static WaitForDreApplication application() {
|
|
||||||
return Application.getInstance(WaitForDreApplication.class);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
@ -0,0 +1,26 @@
|
|||||||
|
package trick.dre;
|
||||||
|
|
||||||
|
|
||||||
|
import java.io.File;
|
||||||
|
|
||||||
|
import org.jdesktop.application.Application;
|
||||||
|
|
||||||
|
import trick.common.ApplicationTest;
|
||||||
|
import trick.common.TestUtils;
|
||||||
|
|
||||||
|
|
||||||
|
public class MockDreApplication extends DreApplication {
|
||||||
|
|
||||||
|
public static void main(String[] args) {
|
||||||
|
File sie;
|
||||||
|
|
||||||
|
sieResourcePath = TestUtils.getTrickHome() + "/test/SIM_test_dr/S_sie.resource";
|
||||||
|
sie = new File(sieResourcePath);
|
||||||
|
|
||||||
|
if (!sie.exists()) {
|
||||||
|
boolean success = TestUtils.compileTestSim("SIM_test_dr");
|
||||||
|
}
|
||||||
|
|
||||||
|
Application.launch(MockDreApplication.class, args);
|
||||||
|
}
|
||||||
|
}
|
@ -1,54 +0,0 @@
|
|||||||
package trick.dre;
|
|
||||||
|
|
||||||
|
|
||||||
import org.jdesktop.application.Application;
|
|
||||||
|
|
||||||
|
|
||||||
public class WaitForDreApplication extends DreApplication {
|
|
||||||
static Object lock = new Object();
|
|
||||||
|
|
||||||
boolean isEnded;
|
|
||||||
|
|
||||||
@Override
|
|
||||||
protected void end() {
|
|
||||||
isEnded = true;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
protected void ready() {
|
|
||||||
super.ready();
|
|
||||||
synchronized(lock) {
|
|
||||||
lock.notifyAll();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Launch the specified subclsas of DreApplication and block
|
|
||||||
* (wait) until it's startup() method has run.
|
|
||||||
*/
|
|
||||||
public static void launchAndWait(Class<? extends WaitForDreApplication> applicationClass) {
|
|
||||||
synchronized(lock) {
|
|
||||||
// Set path to S_sie.resource (src/test/resources/S_sie.resource)
|
|
||||||
final String sep = java.io.File.separator;
|
|
||||||
sieResourcePath = String.format("src%1$stest%1$sresources%1$sS_sie.resource", sep);
|
|
||||||
|
|
||||||
Application.launch(applicationClass, new String[]{});
|
|
||||||
while(true) {
|
|
||||||
try {
|
|
||||||
lock.wait();
|
|
||||||
}
|
|
||||||
catch (InterruptedException e) {
|
|
||||||
System.err.println("launchAndWait interrupted!");
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
Application app = Application.getInstance(WaitForDreApplication.class);
|
|
||||||
if (app instanceof WaitForDreApplication) {
|
|
||||||
if (((WaitForDreApplication)app).isReady()) {
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
@ -0,0 +1,29 @@
|
|||||||
|
package trick.simcontrol.fixtures;
|
||||||
|
|
||||||
|
import java.awt.Font;
|
||||||
|
import java.awt.GraphicsEnvironment;
|
||||||
|
|
||||||
|
import org.assertj.swing.core.Robot;
|
||||||
|
import org.assertj.swing.fixture.ComponentContainerFixture;
|
||||||
|
import org.assertj.swing.fixture.DialogFixture;
|
||||||
|
import org.assertj.swing.fixture.FrameFixture;
|
||||||
|
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 trick.dre.fixtures.DreFixtureExtension;
|
||||||
|
import trick.dre.DreApplication;
|
||||||
|
import trick.common.ui.components.FontChooser;
|
||||||
|
|
||||||
|
public class DreFixture extends FrameFixture {
|
||||||
|
|
||||||
|
public DreFixture(Robot robot, DreApplication target) {
|
||||||
|
super(robot, target.getMainFrame());
|
||||||
|
}
|
||||||
|
|
||||||
|
public static DreFixtureExtension getExtension() {
|
||||||
|
return new DreFixtureExtension();
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
@ -0,0 +1,16 @@
|
|||||||
|
package trick.dre.fixtures;
|
||||||
|
|
||||||
|
import java.awt.Container;
|
||||||
|
|
||||||
|
import org.assertj.swing.core.Robot;
|
||||||
|
import org.assertj.swing.fixture.ComponentFixtureExtension;
|
||||||
|
|
||||||
|
import trick.simcontrol.fixtures.DreFixture;
|
||||||
|
|
||||||
|
public class DreFixtureExtension extends ComponentFixtureExtension {
|
||||||
|
@Override
|
||||||
|
public DreFixture createFixture(Robot robot, Container root) {
|
||||||
|
DreApplication dreFrame = robot.finder().findByType(root, DreApplication.class, true);
|
||||||
|
return new DreFixture(robot, dreFrame);
|
||||||
|
}
|
||||||
|
}
|
Loading…
x
Reference in New Issue
Block a user