mirror of
https://github.com/nasa/trick.git
synced 2025-03-23 04:25:28 +00:00
Reimplemented the Trick View Test Suite
This commit is contained in:
parent
69dc3d4110
commit
dbd04beee4
@ -0,0 +1,92 @@
|
||||
package trick.tv;
|
||||
|
||||
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 TVApplication life cycle.
|
||||
*
|
||||
* @author hchen
|
||||
*
|
||||
*/
|
||||
public class TVApplicationTest {
|
||||
|
||||
@BeforeClass
|
||||
public static void setUpBeforeClass() throws Exception {
|
||||
WaitForTVApplication.launchAndWait(WaitForTVApplication.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("TVApplicationTest 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", "openAndSet", "set", "saveSession", "startMonitoring",
|
||||
"stopMonitoring", "stripchartSelection", "removeSelection", "addVariablesFromTree",
|
||||
"addVariablesFromList", "purgeBadRefs", "commitVariableAddition"};
|
||||
String[] actionTexts = {"New", "Open", "Open & Set", "Set", "Save", "Start the Monitor", "Stop the Monitor",
|
||||
"Stripchart Selection", "Remove Selection", "Add Selection", "Add Selection",
|
||||
"Purge BAD_REFs", "Ok"};
|
||||
String[] actionShortDescriptions = {"Clear the variable table.", "Replace the variable table with a TV input file without setting the values.",
|
||||
"Replace the variable table with a TV input file and set each value.",
|
||||
"Set the variable values from a TV input file without changing the variable table.",
|
||||
"Save the variable table to a TV input file.",
|
||||
"Start updating variable values.", "Stop updating variable values.",
|
||||
"Stripchart the selected variables.", "Delete the selected rows.",
|
||||
"Begin watching the selected variables.", "Begin watching the selected variables.",
|
||||
"Remove all variables that failed to resolve.", "Commit the variable additions."};
|
||||
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() {
|
||||
CheckApplicationProperties.checkKeyText(application().resourceMap, "fileMenu.text", "&File");
|
||||
/*CheckApplicationProperties.checkKeyText(application().resourceMap, "actionsMenu.text", "&Actions");
|
||||
CheckApplicationProperties.checkKeyText(application().resourceMap, "preferencesMenu.text", "&Preferences");
|
||||
CheckApplicationProperties.checkKeyText(application().resourceMap, "notifyOnDisconnectCheckBoxMenuItem.text", "Not&ify on Disconnect");
|
||||
CheckApplicationProperties.checkKeyText(application().resourceMap, "caseInsensitiveCheckBox.text", "Case Insensitive");
|
||||
CheckApplicationProperties.checkKeyText(application().resourceMap, "containsRadioButton.text", "Contains");
|
||||
CheckApplicationProperties.checkKeyText(application().resourceMap, "regularExpressionRadioButton.text", "RegEx");*/
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testExit() {
|
||||
application().removeExitListener(application().exitListener);
|
||||
application().exit();
|
||||
assertTrue(application().isEnded);
|
||||
}
|
||||
|
||||
private static WaitForTVApplication application() {
|
||||
return Application.getInstance(WaitForTVApplication.class);
|
||||
}
|
||||
}
|
@ -0,0 +1,50 @@
|
||||
package trick.tv;
|
||||
|
||||
|
||||
import org.jdesktop.application.Application;
|
||||
|
||||
|
||||
public class WaitForTVApplication extends TVApplication {
|
||||
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 TVApplication and block
|
||||
* (wait) until it's startup() method has run.
|
||||
*/
|
||||
public static void launchAndWait(Class<? extends WaitForTVApplication> 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(WaitForTVApplication.class);
|
||||
if (app instanceof WaitForTVApplication) {
|
||||
if (((WaitForTVApplication)app).isReady()) {
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
Loading…
x
Reference in New Issue
Block a user