Files
JIMRI/java/test/jmri/jmrit/logix/OpSessionLogTest.java
2026-06-17 14:00:51 +02:00

71 lines
1.9 KiB
Java

package jmri.jmrit.logix;
import jmri.util.JUnitUtil;
import org.junit.jupiter.api.*;
import org.netbeans.jemmy.operators.JDialogOperator;
/**
*
* @author Paul Bender Copyright (C) 2017
*/
public class OpSessionLogTest {
private jmri.util.JmriJFrame f;
private boolean retval;
@Test
@jmri.util.junit.annotations.DisabledIfHeadless
public void openAndClose() {
// create a thread that waits to close the dialog box opened later
Thread t = new Thread(() -> {
// constructor for jdo will wait until the dialog is visible
JDialogOperator jdo = new JDialogOperator(Bundle.getMessage("logSession"));
jdo.requestClose();
jdo.waitClosed();
});
t.setName("OpSessionLog File Chooser Dialog Close Thread");
t.start();
// create the window and make the log file on Swing thread
jmri.util.ThreadingUtil.runOnGUI(() -> {
f = new jmri.util.JmriJFrame("OpSessionLog Chooser Test");
// get the result of closing
retval = OpSessionLog.makeLogFile(f);
});
JUnitUtil.waitFor( () -> !t.isAlive(), "OpSessionLog File Chooser Dialog Close Thread complete");
// check results
Assertions.assertFalse(retval);
// done
f.dispose();
}
@Test
@Disabled("needs more thought")
@jmri.util.junit.annotations.DisabledIfHeadless
public void makeLogFileCheck() {
// This is going to be a graphical check.
// make sure the log file is correctly chosen and created.
}
@BeforeEach
public void setUp() {
JUnitUtil.setUp();
JUnitUtil.resetProfileManager();
}
@AfterEach
public void tearDown() {
f = null;
JUnitUtil.tearDown();
}
// private static final Logger log = LoggerFactory.getLogger(OpSessionLogTest.class);
}