Merge remote-tracking branch 'origin/GP-3848-dragonmacher-task-launcher-headless'

This commit is contained in:
Ryan Kurtz 2023-09-20 09:23:41 -04:00
commit 4f867c099e
2 changed files with 24 additions and 0 deletions

View File

@ -113,6 +113,10 @@ class TaskRunner {
private void showTaskDialog(WrappingTaskMonitor monitor) {
if (SystemUtilities.isInHeadlessMode()) {
return;
}
Swing.runIfSwingOrRunLater(() -> {
taskDialog = buildTaskDialog();
monitor.setDelegate(taskDialog); // initialize the dialog to the current monitor state

View File

@ -22,6 +22,8 @@ import java.util.concurrent.TimeUnit;
import org.junit.*;
import ghidra.util.SystemUtilities;
public class TaskLauncherTest extends AbstractTaskTest {
private Thread swingThread;
@ -114,6 +116,24 @@ public class TaskLauncherTest extends AbstractTaskTest {
totalTime < dialogDelay);
}
@Test
public void testHeadless() throws Exception {
System.setProperty(SystemUtilities.HEADLESS_PROPERTY, Boolean.TRUE.toString());
SwingBlocker blocker = new SwingBlocker();
runSwing(blocker, false);
blocker.waitForStart();
// 4 - 2 per task
threadsFinished = new CountDownLatch(4);
launchTaskFromTask();
waitForTask();
assertDidNotRunInSwing();
assertNull(taskDialog);
}
//==================================================================================================
// Private Methods
//==================================================================================================