mirror of
https://github.com/nasa/trick.git
synced 2025-01-28 15:14:36 +00:00
Merge branch 'AssertJ_Swing_Tests' of https://github.com/Mrockwell2/trick into AssertJ_Swing_Tests
This commit is contained in:
commit
17fb0f447d
@ -324,14 +324,14 @@
|
||||
<printSummary>true</printSummary>
|
||||
<excludes>
|
||||
<exclude> **/SimControlApplicationTest.java </exclude>
|
||||
<!-- <exclude> **/DreApplicationTest.java </exclude> -->
|
||||
<exclude> **/DreApplicationTest.java </exclude>
|
||||
<exclude> **/TrickDPApplicationTest.java </exclude>
|
||||
<exclude> **/TrickQPApplicationTest.java </exclude>
|
||||
<exclude> **/MonteMonitorApplicationTest.java </exclude>
|
||||
<exclude> **/MtvApplicationTest.java </exclude>
|
||||
<exclude> **/SieApplicationTest.java </exclude>
|
||||
<exclude> **/SnifferApplicationTest.java </exclude>
|
||||
<exclude> **/TVApplicationTest.java </exclude>
|
||||
<!-- <exclude> **/TVApplicationTest.java </exclude> -->
|
||||
</excludes>
|
||||
</configuration>
|
||||
</plugin>
|
||||
|
2
trick_source/java/src/test/.gitignore
vendored
Normal file
2
trick_source/java/src/test/.gitignore
vendored
Normal file
@ -0,0 +1,2 @@
|
||||
resources/RUN_gui_test/*
|
||||
!resources/RUN_gui_test/input.py
|
@ -0,0 +1,18 @@
|
||||
package trick.tv;
|
||||
|
||||
|
||||
import org.jdesktop.application.Application;
|
||||
|
||||
|
||||
public class MockTVApplication extends TVApplication {
|
||||
|
||||
@Override
|
||||
protected void initialize(String[] args) {
|
||||
for(int i = 0; i < args.length; i++)
|
||||
System.out.println((i+1) + ": " + args[i]);
|
||||
super.initialize(args);
|
||||
}
|
||||
public static void main(String[] args) {
|
||||
Application.launch(MockTVApplication.class, args);
|
||||
}
|
||||
}
|
@ -1,6 +1,7 @@
|
||||
package trick.tv;
|
||||
|
||||
import static org.junit.Assert.assertTrue;
|
||||
import java.io.IOException;
|
||||
import java.net.ServerSocket;
|
||||
|
||||
import org.jdesktop.application.Application;
|
||||
import org.junit.After;
|
||||
@ -9,7 +10,15 @@ import org.junit.Before;
|
||||
import org.junit.BeforeClass;
|
||||
import org.junit.Test;
|
||||
|
||||
import trick.common.ApplicationTest;
|
||||
import trick.common.CheckApplicationProperties;
|
||||
import trick.dre.MockDreApplication;
|
||||
import trick.dre.fixtures.DreFixture;
|
||||
|
||||
import static org.assertj.core.api.Assertions.assertThat;
|
||||
import static org.assertj.core.api.Assumptions.assumeThat;
|
||||
import static org.assertj.swing.launcher.ApplicationLauncher.application;
|
||||
import static org.junit.Assert.assertTrue;
|
||||
|
||||
/**
|
||||
*
|
||||
@ -18,75 +27,38 @@ import trick.common.CheckApplicationProperties;
|
||||
* @author hchen
|
||||
*
|
||||
*/
|
||||
public class TVApplicationTest {
|
||||
|
||||
@BeforeClass
|
||||
public static void setUpBeforeClass() throws Exception {
|
||||
WaitForTVApplication.launchAndWait(WaitForTVApplication.class);
|
||||
}
|
||||
public class TVApplicationTest extends ApplicationTest {
|
||||
private static final int PORT = getOpenPort();
|
||||
|
||||
@AfterClass
|
||||
public static void tearDownAfterClass() throws Exception {
|
||||
}
|
||||
@BeforeClass
|
||||
public static void onSetUpBeforeClass() {
|
||||
System.out.println("Port: " + PORT);
|
||||
|
||||
@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);
|
||||
|
||||
public static int getOpenPort() {
|
||||
int port = -1;
|
||||
try {
|
||||
ServerSocket temp = new ServerSocket(0);
|
||||
port = temp.getLocalPort();
|
||||
temp.close();
|
||||
} catch(IOException e) {
|
||||
System.out.println("Free Port Not Found");
|
||||
}
|
||||
|
||||
return port;
|
||||
}
|
||||
|
||||
private static WaitForTVApplication application() {
|
||||
return Application.getInstance(WaitForTVApplication.class);
|
||||
|
||||
@Override
|
||||
protected void onSetUp() {
|
||||
application(MockTVApplication.class).start();
|
||||
|
||||
sleep(1500);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testGeneric() {
|
||||
sleep(5000);
|
||||
assertThat(true).isTrue();
|
||||
}
|
||||
}
|
@ -1,50 +0,0 @@
|
||||
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;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
32
trick_source/java/src/test/resources/RUN_gui_test/input.py
Normal file
32
trick_source/java/src/test/resources/RUN_gui_test/input.py
Normal file
@ -0,0 +1,32 @@
|
||||
|
||||
def get_port():
|
||||
from os import remove
|
||||
from os.path import dirname, abspath
|
||||
|
||||
port_info = dirname(abspath(__file__)) + "/port.info"
|
||||
|
||||
try:
|
||||
f = open(port_info, "r")
|
||||
port_num = int(f.read())
|
||||
|
||||
f.close()
|
||||
remove(port_info)
|
||||
|
||||
print(f"Using Port '{port_num}'")
|
||||
return port_num
|
||||
|
||||
except:
|
||||
print("Port Not Parsed. Using '39595'")
|
||||
return 39595
|
||||
|
||||
trick.frame_log_on()
|
||||
trick.real_time_enable()
|
||||
trick.exec_set_software_frame(0.1)
|
||||
trick.itimer_enable()
|
||||
|
||||
trick.exec_set_enable_freeze(True)
|
||||
trick.exec_set_freeze_command(True)
|
||||
|
||||
portnum = get_port()
|
||||
|
||||
trick.var_server_set_port(portnum)
|
Loading…
x
Reference in New Issue
Block a user