mirror of
https://github.com/NationalSecurityAgency/ghidra.git
synced 2025-10-05 10:49:34 +02:00
Tests - fix for timing issue; fixed potential deadlock in TaskDialog
This commit is contained in:
parent
42748eb47e
commit
ff7759166b
4 changed files with 21 additions and 12 deletions
|
@ -429,13 +429,15 @@ public class ImporterUtilities {
|
|||
|
||||
if (importedObject instanceof Program) {
|
||||
Program program = (Program) importedObject;
|
||||
|
||||
setProgramProperties(program, fsrl, monitor);
|
||||
ProgramMappingService.createAssociation(fsrl, program);
|
||||
|
||||
if (programManager != null) {
|
||||
int openState =
|
||||
firstProgram ? ProgramManager.OPEN_CURRENT : ProgramManager.OPEN_VISIBLE;
|
||||
programManager.openProgram(program, openState);
|
||||
}
|
||||
setProgramProperties(program, fsrl, monitor);
|
||||
ProgramMappingService.createAssociation(fsrl, program);
|
||||
importedFilesSet.add(program.getDomainFile());
|
||||
}
|
||||
if (firstProgram) {
|
||||
|
|
|
@ -25,8 +25,7 @@ import javax.swing.*;
|
|||
import docking.DialogComponentProvider;
|
||||
import docking.DockingWindowManager;
|
||||
import docking.widgets.OptionDialog;
|
||||
import ghidra.util.HelpLocation;
|
||||
import ghidra.util.SystemUtilities;
|
||||
import ghidra.util.*;
|
||||
import ghidra.util.exception.CancelledException;
|
||||
import ghidra.util.timer.GTimer;
|
||||
|
||||
|
@ -205,12 +204,12 @@ public class TaskDialog extends DialogComponentProvider implements TaskMonitor {
|
|||
@Override
|
||||
public void setCancelEnabled(boolean enable) {
|
||||
monitorComponent.setCancelEnabled(enable);
|
||||
super.setCancelEnabled(enable);
|
||||
Swing.runLater(() -> super.setCancelEnabled(enable));
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isCancelEnabled() {
|
||||
return super.isCancelEnabled();
|
||||
return monitorComponent.isCancelEnabled();
|
||||
}
|
||||
|
||||
public synchronized void taskProcessed() {
|
||||
|
@ -317,7 +316,7 @@ public class TaskDialog extends DialogComponentProvider implements TaskMonitor {
|
|||
|
||||
@Override
|
||||
public String getMessage() {
|
||||
return monitorComponent.getMessage();
|
||||
return getStatusText();
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
|
@ -23,11 +23,13 @@ import java.util.concurrent.*;
|
|||
import java.util.concurrent.atomic.AtomicBoolean;
|
||||
|
||||
import docking.test.AbstractDockingTest;
|
||||
import ghidra.util.Swing;
|
||||
|
||||
public class AbstractTaskTest extends AbstractDockingTest {
|
||||
|
||||
protected static final int DELAY_FAST = 10;
|
||||
protected static final int DELAY_SLOW = 100;
|
||||
protected static final int DELAY_SLOW = TaskLauncher.INITIAL_MODAL_DELAY_MS + 100; // + some fudge
|
||||
protected static final int DELAY_NONMODAL_SLOW = TaskLauncher.INITIAL_DELAY_MS + 100; // + some fudge
|
||||
protected static final int DELAY_LAUNCHER = DELAY_FAST * 2;
|
||||
|
||||
// 2 - 1 for the task itself; 1 for the launcher
|
||||
|
@ -69,7 +71,12 @@ public class AbstractTaskTest extends AbstractDockingTest {
|
|||
return; // not shown
|
||||
}
|
||||
|
||||
assertFalse(dialogSpy.wasShown());
|
||||
assertFalse("Dialog should not have been shown.\nEvents: " + eventQueue,
|
||||
dialogSpy.wasShown());
|
||||
}
|
||||
|
||||
protected void assertDialogShown() {
|
||||
assertTrue("Dialog should have been shown.\nEvents: " + eventQueue, dialogSpy.wasShown());
|
||||
}
|
||||
|
||||
protected void waitForTask() throws Exception {
|
||||
|
@ -186,7 +193,8 @@ public class AbstractTaskTest extends AbstractDockingTest {
|
|||
@Override
|
||||
public void run(TaskMonitor monitor) {
|
||||
postEvent(getName() + " started...");
|
||||
sleep(DELAY_SLOW);
|
||||
sleep(DELAY_NONMODAL_SLOW);
|
||||
Swing.runNow(() -> null);
|
||||
threadsFinished.countDown();
|
||||
postEvent(getName() + " finished.");
|
||||
}
|
||||
|
|
|
@ -63,7 +63,7 @@ public class TaskDialogTest extends AbstractTaskTest {
|
|||
|
||||
waitForTask();
|
||||
|
||||
assertTrue(dialogSpy.wasShown());
|
||||
assertDialogShown();
|
||||
assertSwingThreadBlockedForTask();
|
||||
}
|
||||
|
||||
|
@ -89,7 +89,7 @@ public class TaskDialogTest extends AbstractTaskTest {
|
|||
|
||||
waitForTask();
|
||||
|
||||
assertTrue(dialogSpy.wasShown());
|
||||
assertDialogShown();
|
||||
assertSwingThreadFinishedBeforeTask();
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue