Test fixes for Swing access from a script thread

This commit is contained in:
dragonmacher 2021-09-07 15:40:31 -04:00
parent 5e0c5ee3fc
commit 1623f0a069
2 changed files with 12 additions and 16 deletions

View file

@ -36,6 +36,7 @@ import ghidra.framework.model.DomainObjectListener;
import ghidra.framework.plugintool.*;
import ghidra.framework.plugintool.util.PluginStatus;
import ghidra.program.model.listing.Program;
import ghidra.util.Swing;
import ghidra.util.table.GhidraProgramTableModel;
import ghidra.util.table.actions.DeleteTableRowAction;
import ghidra.util.task.SwingUpdateManager;
@ -73,7 +74,7 @@ public class TableServicePlugin extends ProgramPlugin
// Unusual Code: We, as a plugin, don't have any actions. Our transient tables do have
// actions. We need a way to have keybindings shared for all the different
// actions. Further, we need to register them now, not when the transient
// providers are created, as they would only appear in the options at
// providers are created, as they would only appear in the options at
// that point.
//
DeleteTableRowAction.registerDummy(tool, getName());
@ -265,16 +266,13 @@ public class TableServicePlugin extends ProgramPlugin
navigatable = gotoService.getDefaultNavigatable();
}
TableChooserDialog dialog =
new MyTableChooserDialog(this, executor, program, title, navigatable, isModal);
Navigatable nav = navigatable;
TableChooserDialog dialog = Swing.runNow(
() -> new MyTableChooserDialog(this, executor, program, title, nav, isModal));
List<TableChooserDialog> list = programToDialogMap.get(program);
if (list == null) {
list = new ArrayList<>();
programToDialogMap.put(program, list);
}
List<TableChooserDialog> list =
programToDialogMap.computeIfAbsent(program, p -> new ArrayList<>());
list.add(dialog);
return dialog;
}
}

View file

@ -52,10 +52,6 @@ public class GhidraScriptTest extends AbstractGhidraHeadedIntegrationTest {
private Program program;
private GhidraState state;
public GhidraScriptTest() {
super();
}
@Before
public void setUp() throws Exception {
@ -522,8 +518,10 @@ public class GhidraScriptTest extends AbstractGhidraHeadedIntegrationTest {
// Try to set a valid option to an invalid value and verify that the invalid value was not stored.
String invalidValue = "d";
script.setAnalysisOption(program, validOptionName, invalidValue);
assertFalse(script.getCurrentAnalysisOptionsAndValues(program).get(validOptionName).equals(
invalidValue));
assertFalse(script.getCurrentAnalysisOptionsAndValues(program)
.get(validOptionName)
.equals(
invalidValue));
// Try to set an invalid option and verify that the option is not successfully set.
String invalidOption = "invalidOption";
@ -826,7 +824,7 @@ public class GhidraScriptTest extends AbstractGhidraHeadedIntegrationTest {
//==================================================================================================
// Inner Classes
//==================================================================================================
//==================================================================================================
public enum TestEnum {
a, b, c