mirror of
https://github.com/nasa/trick.git
synced 2025-04-19 00:27:00 +00:00
DataProducts Test Reimplemented
This commit is contained in:
parent
f0af15ee2d
commit
acdf2420e8
@ -0,0 +1,101 @@
|
||||
package trick.dataproducts.trickdp;
|
||||
|
||||
import static org.junit.Assert.assertTrue;
|
||||
|
||||
import org.jdesktop.application.Application;
|
||||
import org.junit.After;
|
||||
import org.junit.AfterClass;
|
||||
import org.junit.Before;
|
||||
import org.junit.BeforeClass;
|
||||
import org.junit.Test;
|
||||
|
||||
import trick.common.CheckApplicationProperties;
|
||||
|
||||
/**
|
||||
*
|
||||
* Test TrickDPApplication life cycle.
|
||||
*
|
||||
* @author hchen
|
||||
* @intern mrockwell2
|
||||
*
|
||||
*/
|
||||
public class TrickDPApplicationTest {
|
||||
|
||||
@BeforeClass
|
||||
public static void setUpBeforeClass() throws Exception {
|
||||
WaitForTrickDPApplication.launchAndWait(WaitForTrickDPApplication.class);
|
||||
}
|
||||
|
||||
@AfterClass
|
||||
public static void tearDownAfterClass() throws Exception {
|
||||
}
|
||||
|
||||
@Before
|
||||
public void setUp() throws Exception {
|
||||
}
|
||||
|
||||
@After
|
||||
public void tearDown() throws Exception {
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testReady() {
|
||||
assertTrue("TrickDPApplicationTest 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 = {"newSession", "openSession", "saveSession", "refreshSession", "importSimDir", "addRunDir",
|
||||
"addDP", "editSelectedDP", "editRightClickedDP", "filterDP", "gnuSinglePlot", "gnuComparisonPlot",
|
||||
"gnuErrorPlot", "quickPlot", "createPDF", "addRuns", "readDPList", "openSelected",
|
||||
"closeSelected", "removeSelectedNodes", "addDPs", "removeSelectedItems", "removeAllItems", "runSim",
|
||||
"refreshSelected"};
|
||||
String[] actionTexts = {"New...", "Open...", "Save...", "Refresh...", "Import Sim Dir...", "Add Run Dir...", "Add DP...",
|
||||
"Edit DP...", "Edit DP...", "Filter...", "GNUplot Postscript Single Plot...",
|
||||
"GNUplot Postscript Comparison Plot...", "GNUplot Postscript Error Plot...",
|
||||
"Quickplot...", "Create PDF Booklet...", "Add run(s)", "Read DP List", "Opentree",
|
||||
"Closetree", "Remove", "Add DPs", "Remove", "Remove All", "Run Sim", "Refresh"};
|
||||
String[] actionShortDescriptions = {"Start a New Session", "Open an Existing Session", "Save Current Session",
|
||||
"Refresh Current Session", "Import Sim Directory to Current Session",
|
||||
"Add a Run Directory to Current Session", "Add a Data Product file to Current Session",
|
||||
"Open Quickplot to edit the Selected Data Product from DP Selections", "Open Quickplot to edit the Selected Data Product file",
|
||||
"Filter the Displayed Data Product files",
|
||||
"Show GNU Postscript Single Plot", "Show GNU Postscript Comparison Plot",
|
||||
"Show GNU Postscript Error Plot", "Quick Plot", "Create PDF Booklet...", "Selects run(s)",
|
||||
"Add DP List in Selected SIM Directory", "Open Selected Tree Nodes", "Close Selected Tree Nodes",
|
||||
"Remove Selected Node(s)", "Add Selected to DP List", "Remove Selected List Item(s)",
|
||||
"Remove All List Items", "Run Selected Sim", "Refresh the Selected Nodes of the Tree"};
|
||||
|
||||
for (int i = 0; i < actionNames.length; i++) {
|
||||
CheckApplicationProperties.checkAction(application().actionMap, actionNames[i]);
|
||||
CheckApplicationProperties.checkActionText(application().actionMap, actionNames[i], actionTexts[i]);
|
||||
CheckApplicationProperties.checkActionShortDescription(application().actionMap, actionNames[i], actionShortDescriptions[i]);
|
||||
}
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testDefinedKeyText() {
|
||||
String[] keyNames = {"fileMenu.text", "sessionMenu.text", "simsRunsMenu.text", "dataProductMenu.text",
|
||||
"settingsMenu.text", "actionsMenu.text", "helpMenu.text"};
|
||||
String[] keyTexts = {"&File", "&Session", "Sims/&Runs", "&Data Product", "Se&ttings", "&Actions", "&Help"};
|
||||
|
||||
for (int i = 0; i < keyNames.length; i++) {
|
||||
CheckApplicationProperties.checkKeyText(application().resourceMap, keyNames[i], keyTexts[i]);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testExit() {
|
||||
application().removeExitListener(application().exitListener);
|
||||
application().exit();
|
||||
assertTrue(application().isEnded);
|
||||
}
|
||||
|
||||
private static WaitForTrickDPApplication application() {
|
||||
return Application.getInstance(WaitForTrickDPApplication.class);
|
||||
}
|
||||
}
|
@ -0,0 +1,50 @@
|
||||
package trick.dataproducts.trickdp;
|
||||
|
||||
|
||||
import org.jdesktop.application.Application;
|
||||
|
||||
|
||||
public class WaitForTrickDPApplication extends TrickDPApplication {
|
||||
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 subclass of TrickDPApplication and block
|
||||
* (wait) until it's startup() method has run.
|
||||
*/
|
||||
public static void launchAndWait(Class<? extends WaitForTrickDPApplication> applicationClass) {
|
||||
synchronized(lock) {
|
||||
Application.launch(applicationClass, new String[]{});
|
||||
while(true) {
|
||||
try {
|
||||
lock.wait();
|
||||
}
|
||||
catch (InterruptedException e) {
|
||||
System.err.println("launchAndWait interrupted!");
|
||||
break;
|
||||
}
|
||||
Application app = Application.getInstance(WaitForTrickDPApplication.class);
|
||||
if (app instanceof WaitForTrickDPApplication) {
|
||||
if (((WaitForTrickDPApplication)app).isReady()) {
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
@ -0,0 +1,95 @@
|
||||
package trick.dataproducts.trickqp;
|
||||
|
||||
import static org.junit.Assert.assertTrue;
|
||||
|
||||
import org.jdesktop.application.Application;
|
||||
import org.junit.After;
|
||||
import org.junit.AfterClass;
|
||||
import org.junit.Before;
|
||||
import org.junit.BeforeClass;
|
||||
import org.junit.Test;
|
||||
|
||||
import trick.common.CheckApplicationProperties;
|
||||
|
||||
/**
|
||||
*
|
||||
* Test TrickQPApplication life cycle.
|
||||
*
|
||||
* @author hchen
|
||||
* @intern mrockwell2
|
||||
*
|
||||
*/
|
||||
public class TrickQPApplicationTest {
|
||||
|
||||
@BeforeClass
|
||||
public static void setUpBeforeClass() throws Exception {
|
||||
WaitForTrickQPApplication.launchAndWait(WaitForTrickQPApplication.class);
|
||||
}
|
||||
|
||||
@AfterClass
|
||||
public static void tearDownAfterClass() throws Exception {
|
||||
}
|
||||
|
||||
@Before
|
||||
public void setUp() throws Exception {
|
||||
}
|
||||
|
||||
@After
|
||||
public void tearDown() throws Exception {
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testReady() {
|
||||
assertTrue("TrickQPApplicationTest 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 = {"searchVar", "newDP", "openDP", "refreshDP", "saveDP", "saveAsDP",
|
||||
"addVar", "expandVar", "contractVar", "changeUnits", "addRun", "removeRun",
|
||||
"newPage", "removeAllPages", "newPlot", "newCurve", "newVarcase",
|
||||
"newTable", "newColumn", "removeTable"};
|
||||
String[] actionTexts = {"Search", "New DP...", "Open DP...", "Refresh...", "Save...", "Save As...", "Add Var",
|
||||
"Expand Var", "Contract Var", "Change Units...", "Add Run...", "Remove Run",
|
||||
"New Page", "Remove All Pages", "New Plot", "New Curve", "New Varcase",
|
||||
"New Table", "New Column", "Remove All Tables"};
|
||||
String[] actionShortDescriptions = {"Search Variables (all variables return if leave it blank)",
|
||||
"Start a New DP", "Open an Existing DP File", "Refresh DP",
|
||||
"Save Current DP", "Save Current DP As", "Add Selected Variables",
|
||||
"Expand Selected Variables / All", "Contract Selected Variables / All",
|
||||
"Change Units", "Add Run Directories", "Remove Selected Run Directories",
|
||||
"Add a New Page", "Remove All Pages", "Add a New Plot", "Add a New Curve",
|
||||
"Add One Variable Group Option for the Curve", "Add a New Table",
|
||||
"Add a New Column to Table", "Remove All Tables"};
|
||||
for (int i = 0; i < actionNames.length; i++) {
|
||||
CheckApplicationProperties.checkAction(application().actionMap, actionNames[i]);
|
||||
CheckApplicationProperties.checkActionText(application().actionMap, actionNames[i], actionTexts[i]);
|
||||
CheckApplicationProperties.checkActionShortDescription(application().actionMap, actionNames[i], actionShortDescriptions[i]);
|
||||
}
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testDefinedKeyText() {
|
||||
String[] keyNames = {"varsMenu.text", "runsMenu.text", "plotsMenu.text", "tablesMenu.text",
|
||||
"programsMenu.text", "settingsMenu.text", "actionsMenu.text", "helpMenu.text"};
|
||||
String[] keyTexts = {"&Vars", "&Runs", "&Plots", "&Tables", "Pro&grams", "&Settings", "&Actions", "&Help"};
|
||||
|
||||
for (int i = 0; i < keyNames.length; i++) {
|
||||
CheckApplicationProperties.checkKeyText(application().resourceMap, keyNames[i], keyTexts[i]);
|
||||
}
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testExit() {
|
||||
application().removeExitListener(application().exitListener);
|
||||
application().exit();
|
||||
assertTrue(application().isEnded);
|
||||
}
|
||||
|
||||
private static WaitForTrickQPApplication application() {
|
||||
return Application.getInstance(WaitForTrickQPApplication.class);
|
||||
}
|
||||
}
|
@ -0,0 +1,50 @@
|
||||
package trick.dataproducts.trickqp;
|
||||
|
||||
|
||||
import org.jdesktop.application.Application;
|
||||
|
||||
|
||||
public class WaitForTrickQPApplication extends TrickQPApplication {
|
||||
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 subclass of TrickDPApplication and block
|
||||
* (wait) until it's startup() method has run.
|
||||
*/
|
||||
public static void launchAndWait(Class<? extends WaitForTrickQPApplication> applicationClass) {
|
||||
synchronized(lock) {
|
||||
Application.launch(applicationClass, new String[]{});
|
||||
while(true) {
|
||||
try {
|
||||
lock.wait();
|
||||
}
|
||||
catch (InterruptedException e) {
|
||||
System.err.println("launchAndWait interrupted!");
|
||||
break;
|
||||
}
|
||||
Application app = Application.getInstance(WaitForTrickQPApplication.class);
|
||||
if (app instanceof WaitForTrickQPApplication) {
|
||||
if (((WaitForTrickQPApplication)app).isReady()) {
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
Loading…
x
Reference in New Issue
Block a user