GP-2875 Split Generic module into two modules to remove Gui related code from the generic module

This commit is contained in:
ghidragon 2022-11-30 12:33:04 -05:00
parent 522bda39e8
commit 56fcce1456
228 changed files with 1652 additions and 1572 deletions

View file

@ -38,13 +38,7 @@ configurations {
} }
dependencies { dependencies {
api project(':Utility')
api project(':Generic')
api project(':Docking')
api project(':Graph')
api project(':SoftwareModeling') api project(':SoftwareModeling')
api project(':DB')
api project(':Help')
api 'org.apache.felix:org.apache.felix.framework:7.0.3' api 'org.apache.felix:org.apache.felix.framework:7.0.3'
api 'com.github.rotty3000:phidias:0.3.7' api 'com.github.rotty3000:phidias:0.3.7'

View file

@ -22,6 +22,7 @@ import java.util.*;
import generic.jar.ResourceFile; import generic.jar.ResourceFile;
import generic.test.AbstractGenericTest; import generic.test.AbstractGenericTest;
import generic.test.AbstractGuiTest;
import ghidra.app.cmd.data.CreateDataCmd; import ghidra.app.cmd.data.CreateDataCmd;
import ghidra.app.cmd.disassemble.ArmDisassembleCommand; import ghidra.app.cmd.disassemble.ArmDisassembleCommand;
import ghidra.app.cmd.disassemble.DisassembleCommand; import ghidra.app.cmd.disassemble.DisassembleCommand;
@ -216,7 +217,7 @@ public class ProgramBuilder {
private void flushEvents() { private void flushEvents() {
program.flushEvents(); program.flushEvents();
if (!SystemUtilities.isInHeadlessMode()) { if (!SystemUtilities.isInHeadlessMode()) {
AbstractGenericTest.waitForSwing(); AbstractGuiTest.waitForSwing();
} }
} }

View file

@ -20,7 +20,7 @@ import java.io.IOException;
import java.net.MalformedURLException; import java.net.MalformedURLException;
import java.util.*; import java.util.*;
import generic.test.AbstractGenericTest; import generic.test.AbstractGuiTest;
import ghidra.framework.model.*; import ghidra.framework.model.*;
import ghidra.framework.plugintool.PluginTool; import ghidra.framework.plugintool.PluginTool;
import ghidra.framework.store.LockException; import ghidra.framework.store.LockException;
@ -131,7 +131,7 @@ public class ProjectTestUtils {
Msg.warn(ProjectTestUtils.class, "deleteLockFile(): " + "unable to delete file " + Msg.warn(ProjectTestUtils.class, "deleteLockFile(): " + "unable to delete file " +
lockFile.getAbsolutePath() + "- trying again."); lockFile.getAbsolutePath() + "- trying again.");
for (int i = 0; i < 6; i++) { for (int i = 0; i < 6; i++) {
AbstractGenericTest.waitForPostedSwingRunnables(); AbstractGuiTest.waitForPostedSwingRunnables();
try { try {
Thread.sleep(1000); Thread.sleep(1000);
} }

View file

@ -189,12 +189,12 @@ public class TestEnv {
closeAllProgramsFor(tool); closeAllProgramsFor(tool);
// don't want to prompt for saving // don't want to prompt for saving
AbstractGenericTest.runSwing(() -> { AbstractGuiTest.runSwing(() -> {
tool.setConfigChanged(false); tool.setConfigChanged(false);
}); });
AbstractGenericTest.runSwing(() -> tool.close(), false); AbstractGuiTest.runSwing(() -> tool.close(), false);
AbstractGenericTest.waitForSwing(); AbstractGuiTest.waitForSwing();
tool = null; tool = null;
} }
@ -231,7 +231,7 @@ public class TestEnv {
} }
extraTools.remove(toolToClose); extraTools.remove(toolToClose);
AbstractGenericTest.executeOnSwingWithoutBlocking(() -> { AbstractGuiTest.executeOnSwingWithoutBlocking(() -> {
if (ignoreChanges) { if (ignoreChanges) {
toolToClose.setConfigChanged(false); toolToClose.setConfigChanged(false);
} }
@ -244,13 +244,13 @@ public class TestEnv {
return; return;
} }
AbstractGenericTest.runSwing(() -> frontEndTool.close()); AbstractGuiTest.runSwing(() -> frontEndTool.close());
frontEndTool = null; frontEndTool = null;
removeFrontEndFromSystem(); removeFrontEndFromSystem();
} }
private void dipsoseTestTools() { private void dipsoseTestTools() {
AbstractGenericTest.runSwing(() -> { AbstractGuiTest.runSwing(() -> {
disposeSingleTool(tool); disposeSingleTool(tool);
Iterator<PluginTool> it = extraTools.iterator(); Iterator<PluginTool> it = extraTools.iterator();
@ -279,7 +279,7 @@ public class TestEnv {
} }
public void saveRestoreToolState() { public void saveRestoreToolState() {
AbstractGenericTest.runSwing(() -> { AbstractGuiTest.runSwing(() -> {
Element element = lazyTool().saveDataStateToXml(true); Element element = lazyTool().saveDataStateToXml(true);
lazyTool().restoreDataStateFromXml(element); lazyTool().restoreDataStateFromXml(element);
}); });
@ -413,7 +413,7 @@ public class TestEnv {
ToolChest toolChest = project.getLocalToolChest(); ToolChest toolChest = project.getLocalToolChest();
ToolTemplate template = getToolTemplate(AbstractGenericTest.DEFAULT_TEST_TOOL_NAME); ToolTemplate template = getToolTemplate(AbstractGenericTest.DEFAULT_TEST_TOOL_NAME);
template.setName(AbstractGenericTest.DEFAULT_TOOL_NAME); template.setName(AbstractGenericTest.DEFAULT_TOOL_NAME);
AbstractGenericTest.runSwing(() -> toolChest.replaceToolTemplate(template)); AbstractGuiTest.runSwing(() -> toolChest.replaceToolTemplate(template));
} }
private void initializeSimpleTool() { private void initializeSimpleTool() {
@ -422,7 +422,7 @@ public class TestEnv {
throw new AssertException("Tool already exists--you are doing something wrong!"); throw new AssertException("Tool already exists--you are doing something wrong!");
} }
AbstractGenericTest.runSwing(() -> { AbstractGuiTest.runSwing(() -> {
Project project = gp.getProject(); Project project = gp.getProject();
tool = new TestTool(project); tool = new TestTool(project);
@ -452,7 +452,7 @@ public class TestEnv {
return frontEndTool; return frontEndTool;
} }
AbstractGenericTest.runSwing(() -> { AbstractGuiTest.runSwing(() -> {
frontEndTool = new TestFrontEndTool(gp.getProjectManager()); frontEndTool = new TestFrontEndTool(gp.getProjectManager());
frontEndTool.setActiveProject(getProject()); frontEndTool.setActiveProject(getProject());
@ -517,7 +517,7 @@ public class TestEnv {
protected PluginTool launchDefaultToolByName(String toolName) { protected PluginTool launchDefaultToolByName(String toolName) {
return AbstractGenericTest.runSwing(() -> { return AbstractGuiTest.runSwing(() -> {
ToolTemplate toolTemplate = getToolTemplate(toolName); ToolTemplate toolTemplate = getToolTemplate(toolName);
if (toolTemplate == null) { if (toolTemplate == null) {
@ -540,7 +540,7 @@ public class TestEnv {
private static ToolTemplate getToolTemplate(String toolName) { private static ToolTemplate getToolTemplate(String toolName) {
return AbstractGenericTest.runSwing(() -> { return AbstractGuiTest.runSwing(() -> {
ToolTemplate toolTemplate = ToolTemplate toolTemplate =
ToolUtils.readToolTemplate("defaultTools/" + toolName + ToolUtils.TOOL_EXTENSION); ToolUtils.readToolTemplate("defaultTools/" + toolName + ToolUtils.TOOL_EXTENSION);
if (toolTemplate == null) { if (toolTemplate == null) {
@ -620,7 +620,7 @@ public class TestEnv {
public PluginTool restartTool() { public PluginTool restartTool() {
closeTool(); closeTool();
AbstractGenericTest.waitForSwing(); AbstractGuiTest.waitForSwing();
tool = null; tool = null;
initializeSimpleTool(); initializeSimpleTool();
@ -634,7 +634,7 @@ public class TestEnv {
*/ */
public PluginTool launchAnotherDefaultTool() { public PluginTool launchAnotherDefaultTool() {
PluginTool newTool = createDefaultTool(); PluginTool newTool = createDefaultTool();
AbstractGenericTest.runSwing(() -> newTool.setToolName(newTool.getToolName() + toolID++)); AbstractGuiTest.runSwing(() -> newTool.setToolName(newTool.getToolName() + toolID++));
extraTools.add(newTool); extraTools.add(newTool);
return newTool; return newTool;
@ -833,7 +833,7 @@ public class TestEnv {
throw new AssertException("Tool already exists--you are doing something wrong!"); throw new AssertException("Tool already exists--you are doing something wrong!");
} }
AbstractGenericTest.runSwing(() -> { AbstractGuiTest.runSwing(() -> {
tool = launchDefaultTool(); tool = launchDefaultTool();
ProgramManager pm = tool.getService(ProgramManager.class); ProgramManager pm = tool.getService(ProgramManager.class);
pm.openProgram(program.getDomainFile()); pm.openProgram(program.getDomainFile());
@ -844,7 +844,7 @@ public class TestEnv {
"Unable to launch the default tool: " + ToolServices.DEFAULT_TOOLNAME); "Unable to launch the default tool: " + ToolServices.DEFAULT_TOOLNAME);
} }
AbstractGenericTest.waitForSwing(); AbstractGuiTest.waitForSwing();
removeAllConsumersExceptTool(program, tool); removeAllConsumersExceptTool(program, tool);
@ -879,7 +879,7 @@ public class TestEnv {
public PluginTool launchTool(String toolName, DomainFile domainFile) { public PluginTool launchTool(String toolName, DomainFile domainFile) {
AtomicReference<PluginTool> ref = new AtomicReference<>(); AtomicReference<PluginTool> ref = new AtomicReference<>();
AbstractGenericTest.runSwing(() -> { AbstractGuiTest.runSwing(() -> {
PluginTool newTool = doLaunchTool(toolName); PluginTool newTool = doLaunchTool(toolName);
ref.set(newTool); ref.set(newTool);
if (newTool != null) { if (newTool != null) {
@ -909,7 +909,7 @@ public class TestEnv {
public PluginTool launchToolWithURL(String toolName, URL ghidraUrl) { public PluginTool launchToolWithURL(String toolName, URL ghidraUrl) {
AtomicReference<PluginTool> ref = new AtomicReference<>(); AtomicReference<PluginTool> ref = new AtomicReference<>();
AbstractGenericTest.runSwing(() -> { AbstractGuiTest.runSwing(() -> {
PluginTool newTool = doLaunchTool(toolName); PluginTool newTool = doLaunchTool(toolName);
ref.set(newTool); ref.set(newTool);
if (newTool != null) { if (newTool != null) {
@ -956,7 +956,7 @@ public class TestEnv {
protected void setAutoSaveEnabled(final FrontEndTool frontEndToolInstance, protected void setAutoSaveEnabled(final FrontEndTool frontEndToolInstance,
final boolean enabled) { final boolean enabled) {
AbstractGenericTest.runSwing(() -> { AbstractGuiTest.runSwing(() -> {
Options options = frontEndToolInstance.getOptions(ToolConstants.TOOL_OPTIONS); Options options = frontEndToolInstance.getOptions(ToolConstants.TOOL_OPTIONS);
options.setBoolean(FrontEndTool.AUTOMATICALLY_SAVE_TOOLS, enabled); options.setBoolean(FrontEndTool.AUTOMATICALLY_SAVE_TOOLS, enabled);
}); });
@ -1085,7 +1085,7 @@ public class TestEnv {
Project project = gp.getProject(); Project project = gp.getProject();
String projectName = project.getName(); String projectName = project.getName();
try { try {
AbstractGenericTest.runSwing(() -> gp.close()); AbstractGuiTest.runSwing(() -> gp.close());
} }
catch (Throwable t) { catch (Throwable t) {
Msg.error(TestEnv.class, "Problem disposing the test project", t); Msg.error(TestEnv.class, "Problem disposing the test project", t);
@ -1146,7 +1146,7 @@ public class TestEnv {
private void printOpenModalDialogs() { private void printOpenModalDialogs() {
boolean hasModal = false; boolean hasModal = false;
Set<Window> windows = AbstractGenericTest.getAllWindows(); Set<Window> windows = AbstractGuiTest.getAllWindows();
for (Window window : windows) { for (Window window : windows) {
if (window instanceof Dialog) { if (window instanceof Dialog) {
if (((Dialog) window).isModal() && window.isShowing()) { if (((Dialog) window).isModal() && window.isShowing()) {
@ -1168,7 +1168,7 @@ public class TestEnv {
} }
private void disposeTestTools() { private void disposeTestTools() {
AbstractGenericTest.runSwing(() -> { AbstractGuiTest.runSwing(() -> {
try { try {
dipsoseTestTools(); dipsoseTestTools();
} }
@ -1183,7 +1183,7 @@ public class TestEnv {
// the deprecation is OK--we are a framework method and we know we can use it // the deprecation is OK--we are a framework method and we know we can use it
@SuppressWarnings("deprecation") @SuppressWarnings("deprecation")
private void privateWaitForSwingRunnables() { private void privateWaitForSwingRunnables() {
AbstractGenericTest.privateWaitForPostedSwingRunnables_SwingSafe(); AbstractGuiTest.privateWaitForPostedSwingRunnables_SwingSafe();
} }
private void disposeAllSwingUpdateManagers() { private void disposeAllSwingUpdateManagers() {
@ -1207,7 +1207,7 @@ public class TestEnv {
Msg.out(StringUtils.join(list, ",\n")); Msg.out(StringUtils.join(list, ",\n"));
*/ */
AbstractGenericTest.runSwing(() -> s.clear()); AbstractGuiTest.runSwing(() -> s.clear());
} }
private void markAllProgramsAsUnchanged() { private void markAllProgramsAsUnchanged() {

View file

@ -21,8 +21,7 @@ import java.util.*;
import db.DBConstants; import db.DBConstants;
import db.DBHandle; import db.DBHandle;
import db.buffers.BufferFile; import db.buffers.BufferFile;
import generic.test.AbstractGTest; import generic.test.*;
import generic.test.AbstractGenericTest;
import ghidra.app.util.xml.*; import ghidra.app.util.xml.*;
import ghidra.framework.data.DomainObjectAdapterDB; import ghidra.framework.data.DomainObjectAdapterDB;
import ghidra.framework.model.*; import ghidra.framework.model.*;
@ -243,7 +242,7 @@ public class TestProgramManager {
while (true) { while (true) {
try { try {
DomainFile df = folder.createFile(name, gzf, TaskMonitor.DUMMY); DomainFile df = folder.createFile(name, gzf, TaskMonitor.DUMMY);
AbstractGenericTest.waitForPostedSwingRunnables(); AbstractGuiTest.waitForPostedSwingRunnables();
DomainObject dobj = df.getDomainObject(this, true, false, null); DomainObject dobj = df.getDomainObject(this, true, false, null);
try { try {
if (dobj.isChanged()) { if (dobj.isChanged()) {

View file

@ -25,6 +25,7 @@ import docking.action.DockingActionIf;
import docking.widgets.tree.GTree; import docking.widgets.tree.GTree;
import docking.widgets.tree.GTreeNode; import docking.widgets.tree.GTreeNode;
import generic.test.AbstractGenericTest; import generic.test.AbstractGenericTest;
import generic.test.AbstractGuiTest;
import ghidra.app.plugin.core.datamgr.archive.*; import ghidra.app.plugin.core.datamgr.archive.*;
import ghidra.app.plugin.core.datamgr.tree.ArchiveNode; import ghidra.app.plugin.core.datamgr.tree.ArchiveNode;
import ghidra.app.plugin.core.datamgr.tree.DataTypeArchiveGTree; import ghidra.app.plugin.core.datamgr.tree.DataTypeArchiveGTree;
@ -125,7 +126,7 @@ public class DataTypeTestUtils {
// who cares? // who cares?
} }
} }
AbstractGenericTest.waitForPostedSwingRunnables(); AbstractGuiTest.waitForPostedSwingRunnables();
} }
public static ArchiveNode openArchive(String archiveName, boolean checkout, public static ArchiveNode openArchive(String archiveName, boolean checkout,
@ -239,14 +240,14 @@ public class DataTypeTestUtils {
public static void performAction(DockingActionIf action, Program program, GTree tree, public static void performAction(DockingActionIf action, Program program, GTree tree,
boolean wait) { boolean wait) {
AbstractGenericTest.runSwing(() -> { AbstractGuiTest.runSwing(() -> {
ActionContext context = ActionContext context =
new DataTypesActionContext(null, program, (DataTypeArchiveGTree) tree, null, true); new DataTypesActionContext(null, program, (DataTypeArchiveGTree) tree, null, true);
action.actionPerformed(context); action.actionPerformed(context);
}, wait); }, wait);
if (!SwingUtilities.isEventDispatchThread()) { if (!SwingUtilities.isEventDispatchThread()) {
AbstractGenericTest.waitForSwing(); AbstractGuiTest.waitForSwing();
} }
} }
@ -255,14 +256,14 @@ public class DataTypeTestUtils {
} }
public static void performAction(DockingActionIf action, GTree tree, boolean wait) { public static void performAction(DockingActionIf action, GTree tree, boolean wait) {
AbstractGenericTest.runSwing(() -> { AbstractGuiTest.runSwing(() -> {
ActionContext context = ActionContext context =
new DataTypesActionContext(null, null, (DataTypeArchiveGTree) tree, null, true); new DataTypesActionContext(null, null, (DataTypeArchiveGTree) tree, null, true);
action.actionPerformed(context); action.actionPerformed(context);
}, wait); }, wait);
if (!SwingUtilities.isEventDispatchThread()) { if (!SwingUtilities.isEventDispatchThread()) {
AbstractGenericTest.waitForSwing(); AbstractGuiTest.waitForSwing();
} }
} }

View file

@ -22,12 +22,12 @@ import java.util.*;
import org.junit.*; import org.junit.*;
import generic.test.AbstractGenericTest; import generic.test.AbstractGuiTest;
import ghidra.framework.model.*; import ghidra.framework.model.*;
import ghidra.framework.options.Options; import ghidra.framework.options.Options;
import ghidra.framework.store.LockException; import ghidra.framework.store.LockException;
public class PairedTransactionTest extends AbstractGenericTest { public class PairedTransactionTest extends AbstractGuiTest {
DummyDomainObject obj1; DummyDomainObject obj1;
DummyDomainObject obj2; DummyDomainObject obj2;

View file

@ -25,7 +25,7 @@ import javax.swing.text.Document;
import org.junit.Test; import org.junit.Test;
import generic.test.AbstractGenericTest; import generic.test.AbstractGuiTest;
import ghidra.framework.plugintool.DummyPluginTool; import ghidra.framework.plugintool.DummyPluginTool;
public class ConsoleTextPaneTest { public class ConsoleTextPaneTest {
@ -110,28 +110,28 @@ public class ConsoleTextPaneTest {
private void assertCaretAtTop(ConsoleTextPane text) { private void assertCaretAtTop(ConsoleTextPane text) {
AbstractGenericTest.waitForSwing(); AbstractGuiTest.waitForSwing();
int expectedPosition = 0; int expectedPosition = 0;
assertCaretPosition(text, expectedPosition); assertCaretPosition(text, expectedPosition);
} }
private void assertCaretAtBottom(ConsoleTextPane text) { private void assertCaretAtBottom(ConsoleTextPane text) {
AbstractGenericTest.waitForSwing(); AbstractGuiTest.waitForSwing();
int expectedPosition = text.getDocument().getLength(); int expectedPosition = text.getDocument().getLength();
assertCaretPosition(text, expectedPosition); assertCaretPosition(text, expectedPosition);
} }
private void assertCaretPosition(ConsoleTextPane text, int expectedPosition) { private void assertCaretPosition(ConsoleTextPane text, int expectedPosition) {
AbstractGenericTest.waitForSwing(); AbstractGuiTest.waitForSwing();
Document doc = text.getDocument(); Document doc = text.getDocument();
int actualPosition = swing(() -> text.getCaretPosition()); int actualPosition = swing(() -> text.getCaretPosition());
assertEquals(expectedPosition, actualPosition); assertEquals(expectedPosition, actualPosition);
} }
private void printEnoughLinesToOverflowTheMaxCharCount(ConsoleTextPane text) { private void printEnoughLinesToOverflowTheMaxCharCount(ConsoleTextPane text) {
AbstractGenericTest.runSwing(() -> { AbstractGuiTest.runSwing(() -> {
int charsWritten = 0; int charsWritten = 0;
for (int i = 0; charsWritten < text.getMaximumCharacterLimit(); i++) { for (int i = 0; charsWritten < text.getMaximumCharacterLimit(); i++) {
@ -145,10 +145,10 @@ public class ConsoleTextPaneTest {
} }
private void swing(Runnable r) { private void swing(Runnable r) {
AbstractGenericTest.runSwing(r); AbstractGuiTest.runSwing(r);
} }
private <T> T swing(Supplier<T> s) { private <T> T swing(Supplier<T> s) {
return AbstractGenericTest.runSwing(s); return AbstractGuiTest.runSwing(s);
} }
} }

View file

@ -18,7 +18,7 @@ package ghidra.app;
import java.lang.reflect.InvocationTargetException; import java.lang.reflect.InvocationTargetException;
import java.lang.reflect.Method; import java.lang.reflect.Method;
import generic.test.AbstractGenericTest; import generic.test.AbstractGuiTest;
import ghidra.app.plugin.core.codebrowser.CodeBrowserPlugin; import ghidra.app.plugin.core.codebrowser.CodeBrowserPlugin;
import ghidra.program.model.address.Address; import ghidra.program.model.address.Address;
import ghidra.program.model.address.AddressSpace; import ghidra.program.model.address.AddressSpace;
@ -56,7 +56,7 @@ public class SampleLocationGenerator implements GhidraLocationGenerator {
* @param cb * @param cb
*/ */
public void toggleOpenComposites(final CodeBrowserPlugin cb) { public void toggleOpenComposites(final CodeBrowserPlugin cb) {
AbstractGenericTest.runSwing(() -> { AbstractGuiTest.runSwing(() -> {
Data data = program.getListing().getDataAt(addr(0x100d0f3)); Data data = program.getListing().getDataAt(addr(0x100d0f3));
if (data.getDataType() instanceof Composite) { if (data.getDataType() instanceof Composite) {
cb.toggleOpen(data); cb.toggleOpen(data);

View file

@ -23,7 +23,7 @@ import javax.swing.JTextField;
import docking.test.AbstractDockingTest; import docking.test.AbstractDockingTest;
import generic.test.AbstractGTest; import generic.test.AbstractGTest;
import generic.test.AbstractGenericTest; import generic.test.AbstractGuiTest;
import ghidra.app.plugin.core.assembler.AssemblyDualTextField.AssemblyCompletion; import ghidra.app.plugin.core.assembler.AssemblyDualTextField.AssemblyCompletion;
import ghidra.app.plugin.core.assembler.AssemblyDualTextField.AssemblyInstruction; import ghidra.app.plugin.core.assembler.AssemblyDualTextField.AssemblyInstruction;
import ghidra.app.plugin.core.codebrowser.CodeViewerProvider; import ghidra.app.plugin.core.codebrowser.CodeViewerProvider;
@ -78,14 +78,14 @@ public class AssemblerPluginTestHelper {
} }
public List<AssemblyCompletion> inputAndGetCompletions(String text) { public List<AssemblyCompletion> inputAndGetCompletions(String text) {
AbstractGenericTest.runSwing(() -> { AbstractGuiTest.runSwing(() -> {
instructionInput.setText(text); instructionInput.setText(text);
JTextField field = instructionInput.getOperandsField(); JTextField field = instructionInput.getOperandsField();
instructionInput.auto.fakeFocusGained(field); instructionInput.auto.fakeFocusGained(field);
instructionInput.auto.startCompletion(field); instructionInput.auto.startCompletion(field);
instructionInput.auto.updateNow(); instructionInput.auto.updateNow();
}); });
return AbstractGenericTest.waitForValue(() -> AbstractGenericTest.runSwing(() -> { return AbstractGuiTest.waitForValue(() -> AbstractGuiTest.runSwing(() -> {
List<AssemblyCompletion> suggestions = instructionInput.auto.getSuggestions(); List<AssemblyCompletion> suggestions = instructionInput.auto.getSuggestions();
if (suggestions.isEmpty()) { if (suggestions.isEmpty()) {
return null; return null;
@ -98,7 +98,7 @@ public class AssemblerPluginTestHelper {
ListingPanel listingPanel = provider.getListingPanel(); ListingPanel listingPanel = provider.getListingPanel();
ProgramLocation location = new ProgramLocation(program, address); ProgramLocation location = new ProgramLocation(program, address);
AbstractGTest.waitForCondition(() -> { AbstractGTest.waitForCondition(() -> {
AbstractGenericTest.runSwing(() -> listingPanel.goTo(location)); AbstractGuiTest.runSwing(() -> listingPanel.goTo(location));
ProgramLocation confirm = listingPanel.getCursorLocation(); ProgramLocation confirm = listingPanel.getCursorLocation();
if (confirm == null) { if (confirm == null) {
return false; return false;
@ -126,7 +126,7 @@ public class AssemblerPluginTestHelper {
assertTrue(first instanceof AssemblyInstruction); assertTrue(first instanceof AssemblyInstruction);
AssemblyInstruction ai = (AssemblyInstruction) first; AssemblyInstruction ai = (AssemblyInstruction) first;
AbstractGenericTest.runSwing(() -> patchInstructionAction.accept(ai)); AbstractGuiTest.runSwing(() -> patchInstructionAction.accept(ai));
AbstractGhidraHeadedIntegrationTest.waitForProgram(program); AbstractGhidraHeadedIntegrationTest.waitForProgram(program);
return AbstractGTest.waitForValue(() -> listing.getInstructionAt(address)); return AbstractGTest.waitForValue(() -> listing.getInstructionAt(address));
@ -140,7 +140,7 @@ public class AssemblerPluginTestHelper {
assertEquals(expText, dataInput.getText()); assertEquals(expText, dataInput.getText());
assertEquals(address, patchDataAction.getAddress()); assertEquals(address, patchDataAction.getAddress());
AbstractGenericTest.runSwing(() -> { AbstractGuiTest.runSwing(() -> {
dataInput.setText(newText); dataInput.setText(newText);
patchDataAction.accept(); patchDataAction.accept();
}); });

View file

@ -21,7 +21,7 @@ import java.util.List;
import org.junit.*; import org.junit.*;
import generic.test.AbstractGenericTest; import generic.test.AbstractGuiTest;
import ghidra.app.services.DataTypeManagerService; import ghidra.app.services.DataTypeManagerService;
import ghidra.app.util.cparser.C.ParseException; import ghidra.app.util.cparser.C.ParseException;
import ghidra.program.database.ProgramBuilder; import ghidra.program.database.ProgramBuilder;
@ -34,7 +34,7 @@ import ghidra.program.model.listing.*;
import ghidra.program.model.pcode.Varnode; import ghidra.program.model.pcode.Varnode;
import ghidra.util.exception.InvalidInputException; import ghidra.util.exception.InvalidInputException;
public class FunctionEditorModelTest extends AbstractGenericTest { public class FunctionEditorModelTest extends AbstractGuiTest {
private FunctionEditorModel model; private FunctionEditorModel model;
private volatile boolean dataChangeCalled; private volatile boolean dataChangeCalled;

View file

@ -22,7 +22,7 @@ import java.util.List;
import org.junit.Before; import org.junit.Before;
import org.junit.Test; import org.junit.Test;
import generic.test.AbstractGenericTest; import generic.test.AbstractGuiTest;
import ghidra.program.database.ProgramBuilder; import ghidra.program.database.ProgramBuilder;
import ghidra.program.database.ProgramDB; import ghidra.program.database.ProgramDB;
import ghidra.program.model.address.Address; import ghidra.program.model.address.Address;
@ -32,7 +32,7 @@ import ghidra.program.model.listing.Function;
import ghidra.program.model.listing.VariableStorage; import ghidra.program.model.listing.VariableStorage;
import ghidra.util.exception.InvalidInputException; import ghidra.util.exception.InvalidInputException;
public class StorageEditorModelTest extends AbstractGenericTest { public class StorageEditorModelTest extends AbstractGuiTest {
protected static final int REQUIRE_SIZE = 8; protected static final int REQUIRE_SIZE = 8;
protected StorageAddressModel model; protected StorageAddressModel model;

View file

@ -30,13 +30,13 @@ import javax.swing.KeyStroke;
import org.jdom.Element; import org.jdom.Element;
import org.junit.*; import org.junit.*;
import generic.test.AbstractGenericTest; import generic.test.AbstractGuiTest;
import generic.theme.GThemeDefaults.Colors.Palette; import generic.theme.GThemeDefaults.Colors.Palette;
import ghidra.util.HelpLocation; import ghidra.util.HelpLocation;
import ghidra.util.bean.opteditor.OptionsVetoException; import ghidra.util.bean.opteditor.OptionsVetoException;
import ghidra.util.exception.InvalidInputException; import ghidra.util.exception.InvalidInputException;
public class OptionsTest extends AbstractGenericTest { public class OptionsTest extends AbstractGuiTest {
public enum FRUIT { public enum FRUIT {
Apple, Orange, Pear Apple, Orange, Pear

View file

@ -20,6 +20,7 @@ import java.io.IOException;
import db.*; import db.*;
import db.buffers.BufferFile; import db.buffers.BufferFile;
import generic.test.AbstractGenericTest; import generic.test.AbstractGenericTest;
import generic.test.AbstractGuiTest;
import ghidra.app.plugin.core.analysis.AutoAnalysisManager; import ghidra.app.plugin.core.analysis.AutoAnalysisManager;
import ghidra.framework.data.GhidraFolder; import ghidra.framework.data.GhidraFolder;
import ghidra.framework.model.DomainFile; import ghidra.framework.model.DomainFile;
@ -158,7 +159,7 @@ public abstract class AbstractMTFModel {
} }
if (resultProgram != null) { if (resultProgram != null) {
resultProgram.flushEvents(); resultProgram.flushEvents();
AbstractGenericTest.waitForSwing(); AbstractGuiTest.waitForSwing();
resultProgram.release(this); resultProgram.release(this);
resultProgram = null; resultProgram = null;
} }

View file

@ -44,7 +44,6 @@ import edu.uci.ics.jung.graph.Graph;
import edu.uci.ics.jung.visualization.VisualizationModel; import edu.uci.ics.jung.visualization.VisualizationModel;
import edu.uci.ics.jung.visualization.VisualizationViewer; import edu.uci.ics.jung.visualization.VisualizationViewer;
import edu.uci.ics.jung.visualization.picking.PickedState; import edu.uci.ics.jung.visualization.picking.PickedState;
import generic.test.AbstractGenericTest;
import generic.test.TestUtils; import generic.test.TestUtils;
import ghidra.app.cmd.label.AddLabelCmd; import ghidra.app.cmd.label.AddLabelCmd;
import ghidra.app.cmd.label.SetLabelPrimaryCmd; import ghidra.app.cmd.label.SetLabelPrimaryCmd;
@ -2312,11 +2311,11 @@ public abstract class AbstractFunctionGraphTest extends AbstractGhidraHeadedInte
} }
protected void swing(Runnable r) { protected void swing(Runnable r) {
AbstractGenericTest.runSwing(r); runSwing(r);
} }
protected <T> T swing(Supplier<T> s) { protected <T> T swing(Supplier<T> s) {
return AbstractGenericTest.runSwing(s); return runSwing(s);
} }
static class DummyTransferable implements Transferable { static class DummyTransferable implements Transferable {

View file

@ -22,7 +22,7 @@ import javax.swing.tree.TreeModel;
import javax.swing.tree.TreePath; import javax.swing.tree.TreePath;
import docking.widgets.tree.GTreeNode; import docking.widgets.tree.GTreeNode;
import generic.test.AbstractGenericTest; import generic.test.AbstractGuiTest;
public class TreeTestUtils { public class TreeTestUtils {
public static TreePath findTreePathToText(JTree tree, String text) { public static TreePath findTreePathToText(JTree tree, String text) {
@ -57,7 +57,7 @@ public class TreeTestUtils {
*/ */
public static void selectTreeNodeByText(final JTree tree, final String text) { public static void selectTreeNodeByText(final JTree tree, final String text) {
AbstractGenericTest.runSwing(new Runnable() { AbstractGuiTest.runSwing(new Runnable() {
@Override @Override
public void run() { public void run() {
TreePath path = findTreePathToText(tree, text); TreePath path = findTreePathToText(tree, text);
@ -68,9 +68,9 @@ public class TreeTestUtils {
} }
}); });
AbstractGenericTest.waitForSwing(); AbstractGuiTest.waitForSwing();
AbstractGenericTest.runSwing(new Runnable() { AbstractGuiTest.runSwing(new Runnable() {
@Override @Override
public void run() { public void run() {
TreePath path = findTreePathToText(tree, text); TreePath path = findTreePathToText(tree, text);

View file

@ -24,7 +24,6 @@ apply plugin: 'eclipse'
eclipse.project.name = 'Framework Docking' eclipse.project.name = 'Framework Docking'
dependencies { dependencies {
api project(':Generic')
api project(':Help') api project(':Help')
// include code from src/test in Generic // include code from src/test in Generic

View file

@ -21,7 +21,7 @@ import java.util.Set;
import java.util.concurrent.atomic.AtomicReference; import java.util.concurrent.atomic.AtomicReference;
import generic.test.AbstractGTest; import generic.test.AbstractGTest;
import generic.test.AbstractGenericTest; import generic.test.AbstractGuiTest;
/** /**
* This class mainly serves as a conduit through which testing code can access some of the * This class mainly serves as a conduit through which testing code can access some of the
@ -44,7 +44,7 @@ public class DockingWindowManagerTestUtils {
public static Window moveProviderToWindow(final DockingWindowManager dwm, public static Window moveProviderToWindow(final DockingWindowManager dwm,
final ComponentProvider provider) { final ComponentProvider provider) {
AbstractGenericTest.runSwing(() -> { AbstractGuiTest.runSwing(() -> {
if (!dwm.containsProvider(provider)) { if (!dwm.containsProvider(provider)) {
return; return;
} }
@ -65,7 +65,7 @@ public class DockingWindowManagerTestUtils {
public static void moveProvider(final DockingWindowManager dwm, final ComponentProvider movee, public static void moveProvider(final DockingWindowManager dwm, final ComponentProvider movee,
final ComponentProvider relativeTo, final WindowPosition position) { final ComponentProvider relativeTo, final WindowPosition position) {
AbstractGenericTest.runSwing(() -> { AbstractGuiTest.runSwing(() -> {
ComponentPlaceholder moveePlaceholder = dwm.getPlaceholder(movee); ComponentPlaceholder moveePlaceholder = dwm.getPlaceholder(movee);
ComponentPlaceholder relativeToPlaceholder = dwm.getPlaceholder(relativeTo); ComponentPlaceholder relativeToPlaceholder = dwm.getPlaceholder(relativeTo);
dwm.movePlaceholder(moveePlaceholder, relativeToPlaceholder, position); dwm.movePlaceholder(moveePlaceholder, relativeToPlaceholder, position);
@ -76,7 +76,7 @@ public class DockingWindowManagerTestUtils {
final ComponentProvider provider) { final ComponentProvider provider) {
final AtomicReference<DockableComponent> ref = new AtomicReference<>(); final AtomicReference<DockableComponent> ref = new AtomicReference<>();
AbstractGenericTest.runSwing(() -> ref.set(dwm.getDockableComponent(provider))); AbstractGuiTest.runSwing(() -> ref.set(dwm.getDockableComponent(provider)));
return ref.get(); return ref.get();
} }

View file

@ -23,6 +23,7 @@ import java.awt.event.*;
import java.awt.image.BufferedImage; import java.awt.image.BufferedImage;
import java.io.File; import java.io.File;
import java.io.IOException; import java.io.IOException;
import java.net.URL;
import java.util.*; import java.util.*;
import java.util.List; import java.util.List;
import java.util.concurrent.atomic.AtomicBoolean; import java.util.concurrent.atomic.AtomicBoolean;
@ -48,8 +49,9 @@ import docking.widgets.filechooser.GhidraFileChooser;
import docking.widgets.table.threaded.ThreadedTableModel; import docking.widgets.table.threaded.ThreadedTableModel;
import docking.widgets.tree.GTree; import docking.widgets.tree.GTree;
import docking.widgets.tree.GTreeNode; import docking.widgets.tree.GTreeNode;
import generic.test.AbstractGenericTest; import generic.test.AbstractGuiTest;
import generic.test.ConcurrentTestExceptionHandler; import generic.test.ConcurrentTestExceptionHandler;
import generic.theme.GIcon;
import generic.util.image.ImageUtils; import generic.util.image.ImageUtils;
import ghidra.GhidraTestApplicationLayout; import ghidra.GhidraTestApplicationLayout;
import ghidra.framework.ApplicationConfiguration; import ghidra.framework.ApplicationConfiguration;
@ -58,11 +60,12 @@ import ghidra.util.exception.AssertException;
import ghidra.util.task.SwingUpdateManager; import ghidra.util.task.SwingUpdateManager;
import ghidra.util.worker.Worker; import ghidra.util.worker.Worker;
import junit.framework.AssertionFailedError; import junit.framework.AssertionFailedError;
import resources.icons.UrlImageIcon;
import sun.awt.AppContext; import sun.awt.AppContext;
import util.CollectionUtils; import util.CollectionUtils;
import utility.application.ApplicationLayout; import utility.application.ApplicationLayout;
public abstract class AbstractDockingTest extends AbstractGenericTest { public abstract class AbstractDockingTest extends AbstractGuiTest {
static { static {
ConcurrentTestExceptionHandler.registerHandler(); ConcurrentTestExceptionHandler.registerHandler();
@ -2265,4 +2268,39 @@ public abstract class AbstractDockingTest extends AbstractGenericTest {
ImageUtils.writeFile(image, imageFile); ImageUtils.writeFile(image, imageFile);
Msg.info(AbstractDockingTest.class, "Wrote image to " + imageFile.getCanonicalPath()); Msg.info(AbstractDockingTest.class, "Wrote image to " + imageFile.getCanonicalPath());
} }
/**
* Asserts that the two icons are or refer to the same icon (handles GIcon)
* @param expected the expected icon
* @param actual the actual icon
*/
public void assertIconsEqual(Icon expected, Icon actual) {
if (expected.equals(actual)) {
return;
}
URL url1 = getURL(expected);
URL url2 = getURL(actual);
if (url1 != null && url1.equals(url2)) {
return;
}
fail("Expected icon [" + expected.getClass().getSimpleName() + "]" + expected.toString() +
", but got: [" + actual.getClass().getSimpleName() + "]" + actual.toString());
}
/**
* Gets the URL for the given icon
* @param icon the icon to get a URL for
* @return the URL for the given icon
*/
public URL getURL(Icon icon) {
if (icon instanceof UrlImageIcon urlIcon) {
return urlIcon.getUrl();
}
if (icon instanceof GIcon gIcon) {
return gIcon.getUrl();
}
return null;
}
} }

View file

@ -17,7 +17,7 @@ package docking.widgets.filter;
import static docking.test.AbstractDockingTest.*; import static docking.test.AbstractDockingTest.*;
import static generic.test.AbstractGTest.*; import static generic.test.AbstractGTest.*;
import static generic.test.AbstractGenericTest.*; import static generic.test.AbstractGuiTest.*;
import static org.junit.Assert.*; import static org.junit.Assert.*;
import java.awt.BorderLayout; import java.awt.BorderLayout;
@ -32,7 +32,7 @@ import org.junit.Before;
import org.junit.Test; import org.junit.Test;
import generic.test.AbstractGTest; import generic.test.AbstractGTest;
import generic.test.AbstractGenericTest; import generic.test.AbstractGuiTest;
import utility.function.Callback; import utility.function.Callback;
public class FilterTextFieldTest { public class FilterTextFieldTest {
@ -276,7 +276,7 @@ public class FilterTextFieldTest {
private void clickClearFilterIcon() { private void clickClearFilterIcon() {
JLabel clearLabel = filter.getClearLabel(); JLabel clearLabel = filter.getClearLabel();
AbstractGenericTest.clickMouse(clearLabel, MouseEvent.BUTTON1, 0, 0, 1, 0); AbstractGuiTest.clickMouse(clearLabel, MouseEvent.BUTTON1, 0, 0, 1, 0);
} }
private void setFilter(String text) { private void setFilter(String text) {

View file

@ -18,13 +18,10 @@ package docking.widgets.fieldpanel;
import org.junit.Test; import org.junit.Test;
import docking.widgets.fieldpanel.internal.ColorRangeMap; import docking.widgets.fieldpanel.internal.ColorRangeMap;
import generic.test.AbstractGenericTest; import generic.test.AbstractGuiTest;
import generic.theme.GThemeDefaults.Colors.Palette; import generic.theme.GThemeDefaults.Colors.Palette;
public class ColorRangeMapTest extends AbstractGenericTest { public class ColorRangeMapTest extends AbstractGuiTest {
public ColorRangeMapTest() {
super();
}
@Test @Test
public void testPaint1() { public void testPaint1() {

View file

@ -23,7 +23,7 @@ import org.junit.Before;
import org.junit.Test; import org.junit.Test;
import docking.widgets.tree.*; import docking.widgets.tree.*;
import generic.test.AbstractGenericTest; import generic.test.AbstractGuiTest;
/** /**
* Class to test the {@link DepthFirstIterator} and {@link BreadthFirstIterator} classes for * Class to test the {@link DepthFirstIterator} and {@link BreadthFirstIterator} classes for
@ -48,7 +48,7 @@ public class TreeIteratorTest {
node0_1 = new GTestNode("Node0_1"); node0_1 = new GTestNode("Node0_1");
node1_0 = new GTestNode("Node1_0"); node1_0 = new GTestNode("Node1_0");
AbstractGenericTest.runSwing(() -> { AbstractGuiTest.runSwing(() -> {
root.addNode(node0); root.addNode(node0);
root.addNode(node1); root.addNode(node1);
root.addNode(node2); root.addNode(node2);

View file

@ -23,7 +23,6 @@ apply plugin: 'eclipse'
eclipse.project.name = 'Framework FileSystem' eclipse.project.name = 'Framework FileSystem'
dependencies { dependencies {
api project(':Generic')
api project(':DB') api project(':DB')
api project(':Docking') api project(':Docking')
} }

View file

@ -38,13 +38,9 @@ dependencies {
api 'org.bouncycastle:bcpkix-jdk15on:1.69' // requires bcutil and bcprov api 'org.bouncycastle:bcpkix-jdk15on:1.69' // requires bcutil and bcprov
api 'org.bouncycastle:bcprov-jdk15on:1.69' api 'org.bouncycastle:bcprov-jdk15on:1.69'
api 'org.bouncycastle:bcutil-jdk15on:1.69' api 'org.bouncycastle:bcutil-jdk15on:1.69'
api 'com.formdev:flatlaf:2.6'
compileOnly "junit:junit:4.12" compileOnly "junit:junit:4.12"
} }
ext.addExports([
'java.desktop/sun.awt=ALL-UNNAMED'
])

View file

@ -22,8 +22,6 @@ import java.text.DateFormat;
import java.text.SimpleDateFormat; import java.text.SimpleDateFormat;
import java.util.*; import java.util.*;
import ghidra.util.HTMLUtilities;
public class FileLocker { public class FileLocker {
private static final String META_TAG = "<META> "; private static final String META_TAG = "<META> ";
@ -111,10 +109,10 @@ public class FileLocker {
for (String name : PROPERTY_KEYS) { for (String name : PROPERTY_KEYS) {
buf.append("<tr><td>"); buf.append("<tr><td>");
buf.append("&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;"); buf.append("&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;");
buf.append(HTMLUtilities.escapeHTML(name)); buf.append(name);
buf.append(": "); buf.append(": ");
buf.append("</td><td>"); buf.append("</td><td>");
buf.append(HTMLUtilities.escapeHTML(existingLockProperties.get(name).toString())); buf.append(existingLockProperties.get(name).toString());
buf.append("</td></tr>"); buf.append("</td></tr>");
} }
buf.append("</table>"); buf.append("</table>");

View file

@ -24,7 +24,6 @@ import org.apache.logging.log4j.core.LoggerContext;
import ghidra.util.Msg; import ghidra.util.Msg;
import ghidra.util.SystemUtilities; import ghidra.util.SystemUtilities;
import ghidra.util.exception.AssertException; import ghidra.util.exception.AssertException;
import resources.ResourceManager;
public class LoggingInitialization { public class LoggingInitialization {
@ -90,7 +89,7 @@ public class LoggingInitialization {
loggingConfigFilename = DEVELOPMENT_LOGGING_CONFIGURATION_FILE; loggingConfigFilename = DEVELOPMENT_LOGGING_CONFIGURATION_FILE;
} }
return ResourceManager.getResource(loggingConfigFilename); return LoggingInitialization.class.getClassLoader().getResource(loggingConfigFilename);
} }
private static URL getLogFileFromSystemProperty() { private static URL getLogFileFromSystemProperty() {
@ -100,7 +99,7 @@ public class LoggingInitialization {
} }
// first see if the given filename is something that is in our classpath // first see if the given filename is something that is in our classpath
URL resource = ResourceManager.getResource(configString); URL resource = LoggingInitialization.class.getClassLoader().getResource(configString);
if (resource != null) { if (resource != null) {
return resource; return resource;
} }

View file

@ -33,8 +33,6 @@ import ghidra.security.KeyStorePasswordProvider;
import ghidra.util.Msg; import ghidra.util.Msg;
import ghidra.util.SystemUtilities; import ghidra.util.SystemUtilities;
import ghidra.util.exception.CancelledException; import ghidra.util.exception.CancelledException;
import ghidra.util.filechooser.ExtensionFileFilter;
import ghidra.util.filechooser.GhidraFileFilter;
/** /**
* <code>ApplicationKeyManagerFactory</code> provides application keystore management * <code>ApplicationKeyManagerFactory</code> provides application keystore management
@ -58,12 +56,6 @@ public class ApplicationKeyManagerFactory {
*/ */
public static final String KEYSTORE_PASSWORD_PROPERTY = "ghidra.password"; public static final String KEYSTORE_PASSWORD_PROPERTY = "ghidra.password";
/**
* PKCS Private Key/Certificate File Filter
*/
public static final GhidraFileFilter CERTIFICATE_FILE_FILTER =
new ExtensionFileFilter(ApplicationKeyStore.PKCS_FILE_EXTENSIONS, "PKCS Key File");
public static final String DEFAULT_PASSWORD = "changeme"; public static final String DEFAULT_PASSWORD = "changeme";
private static final int SELF_SIGNED_DURATION_DAYS = 2 * 365; // 2-years private static final int SELF_SIGNED_DURATION_DAYS = 2 * 365; // 2-years

View file

@ -26,6 +26,7 @@ import java.util.*;
import javax.net.ssl.*; import javax.net.ssl.*;
import javax.security.auth.DestroyFailedException; import javax.security.auth.DestroyFailedException;
import javax.security.auth.x500.X500Principal; import javax.security.auth.x500.X500Principal;
import javax.swing.filechooser.FileNameExtensionFilter;
import org.bouncycastle.asn1.x500.X500Name; import org.bouncycastle.asn1.x500.X500Name;
import org.bouncycastle.asn1.x500.style.RFC4519Style; import org.bouncycastle.asn1.x500.style.RFC4519Style;
@ -61,6 +62,10 @@ public class ApplicationKeyManagerUtils {
public static final String BEGIN_CERT = "-----BEGIN CERTIFICATE-----"; public static final String BEGIN_CERT = "-----BEGIN CERTIFICATE-----";
public static final String END_CERT = "-----END CERTIFICATE-----"; public static final String END_CERT = "-----END CERTIFICATE-----";
public static final String[] PKCS_FILE_EXTENSIONS = new String[] { "p12", "pks", "pfx" };
public static final FileNameExtensionFilter PKCS_FILENAME_FILTER =
new FileNameExtensionFilter("PKCS Key File", PKCS_FILE_EXTENSIONS);
static { static {
/** /**
* Bouncy Castle uses its BCStyle for X500Names which reverses Distingushed Name ordering. * Bouncy Castle uses its BCStyle for X500Names which reverses Distingushed Name ordering.
@ -356,21 +361,21 @@ public class ApplicationKeyManagerUtils {
long durationMs = (long) durationDays * MILLISECONDS_PER_DAY; long durationMs = (long) durationDays * MILLISECONDS_PER_DAY;
Date notAfter = new Date(notBefore.getTime() + durationMs); Date notAfter = new Date(notBefore.getTime() + durationMs);
BigInteger serialNumber = new BigInteger(128, random); BigInteger serialNumber = new BigInteger(128, random);
// JcaX509ExtensionUtils x509Utils = new JcaX509ExtensionUtils(); // JcaX509ExtensionUtils x509Utils = new JcaX509ExtensionUtils();
X509v3CertificateBuilder certificateBuilder = new X509v3CertificateBuilder(caX500Name, X509v3CertificateBuilder certificateBuilder = new X509v3CertificateBuilder(caX500Name,
serialNumber, notBefore, notAfter, x500Name, bcPk); serialNumber, notBefore, notAfter, x500Name, bcPk);
certificateBuilder certificateBuilder
// .addExtension(Extension.subjectKeyIdentifier, true, x509Utils.createSubjectKeyIdentifier(bcPk)) // .addExtension(Extension.subjectKeyIdentifier, true, x509Utils.createSubjectKeyIdentifier(bcPk))
.addExtension(Extension.keyUsage, true, keyUsage); .addExtension(Extension.keyUsage, true, keyUsage);
if (caEntry == null) { if (caEntry == null) {
certificateBuilder certificateBuilder
.addExtension(Extension.basicConstraints, true, new BasicConstraints(1)); .addExtension(Extension.basicConstraints, true, new BasicConstraints(1));
// .addExtension(Extension.authorityKeyIdentifier, true, x509Utils.createAuthorityKeyIdentifier(bcPk)); // .addExtension(Extension.authorityKeyIdentifier, true, x509Utils.createAuthorityKeyIdentifier(bcPk));
} }
ContentSigner contentSigner = ContentSigner contentSigner =
new JcaContentSignerBuilder(SIGNING_ALGORITHM).build(issuerKey); new JcaContentSignerBuilder(SIGNING_ALGORITHM).build(issuerKey);

View file

@ -23,7 +23,6 @@ import java.util.Date;
import java.util.Enumeration; import java.util.Enumeration;
import javax.security.auth.x500.X500Principal; import javax.security.auth.x500.X500Principal;
import javax.swing.filechooser.FileNameExtensionFilter;
import ghidra.util.Msg; import ghidra.util.Msg;
@ -35,11 +34,6 @@ import ghidra.util.Msg;
*/ */
class ApplicationKeyStore { class ApplicationKeyStore {
static final String[] PKCS_FILE_EXTENSIONS = new String[] { "p12", "pks", "pfx" };
private static final FileNameExtensionFilter PKCS_FILENAME_FILTER =
new FileNameExtensionFilter("PKCS Key File", PKCS_FILE_EXTENSIONS);
private ApplicationKeyStore() { private ApplicationKeyStore() {
// no instantiation - static methods only // no instantiation - static methods only
} }
@ -113,7 +107,7 @@ class ApplicationKeyStore {
throws IOException, KeyStoreException, NoSuchAlgorithmException, CertificateException { throws IOException, KeyStoreException, NoSuchAlgorithmException, CertificateException {
File keystoreFile = new File(keystorePath); File keystoreFile = new File(keystorePath);
boolean isPKCS12 = PKCS_FILENAME_FILTER.accept(keystoreFile); boolean isPKCS12 = ApplicationKeyManagerUtils.PKCS_FILENAME_FILTER.accept(keystoreFile);
String type = isPKCS12 ? "PKCS12" : "JKS"; // JKS assumed if not PKCS String type = isPKCS12 ? "PKCS12" : "JKS"; // JKS assumed if not PKCS
KeyStore ks = KeyStore.getInstance(type); KeyStore ks = KeyStore.getInstance(type);

View file

@ -1,6 +1,5 @@
/* ### /* ###
* IP: GHIDRA * IP: GHIDRA
* REVIEWED: YES
* *
* Licensed under the Apache License, Version 2.0 (the "License"); * Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License. * you may not use this file except in compliance with the License.
@ -16,15 +15,8 @@
*/ */
package ghidra.util.xml; package ghidra.util.xml;
import java.io.*; import java.io.*;
import resources.ResourceManager;
/** /**
* A class for creating XML files. * A class for creating XML files.
*/ */
@ -42,68 +34,75 @@ public class XmlWriter {
* @throws IOException if an i/o error occurs * @throws IOException if an i/o error occurs
*/ */
public XmlWriter(File file, String dtdName) throws IOException { public XmlWriter(File file, String dtdName) throws IOException {
this(new FileOutputStream(file), dtdName); this(new FileOutputStream(file), dtdName);
} }
/** /**
* Constructs a new XML writer. * Constructs a new XML writer.
* @param out the output stream * @param out the output stream
* @param dtdName the name of the DTD * @param dtdName the name of the DTD
* @throws IOException if an i/o error occurs * @throws IOException if an i/o error occurs
*/ */
public XmlWriter(OutputStream out, String dtdName) throws IOException { public XmlWriter(OutputStream out, String dtdName) throws IOException {
writer = new PrintWriter(out); writer = new PrintWriter(out);
counter = new Counter(); counter = new Counter();
if (dtdName != null) { if (dtdName != null) {
writeDTD(dtdName); writeDTD(dtdName);
} }
} }
/**
* Returns the XML summary string. /**
* @return the XML summary string * Returns the XML summary string.
*/ * @return the XML summary string
*/
public Counter getCounter() { public Counter getCounter() {
return counter; return counter;
} }
/** /**
* Closes this XML writer. * Closes this XML writer.
*/ */
public void close() { public void close() {
writer.close(); writer.close();
} }
/** /**
* Writes the specified DTD into the file. * Writes the specified DTD into the file.
* @param dtdName the name of the DTD * @param dtdName the name of the DTD
* @throws IOException if an i/o error occurs * @throws IOException if an i/o error occurs
*/ */
public void writeDTD(String dtdName) throws IOException { public void writeDTD(String dtdName) throws IOException {
InputStream is = ResourceManager.getResourceAsStream(dtdName); InputStream is = getClass().getClassLoader().getResourceAsStream(dtdName);
BufferedReader reader = new BufferedReader(new InputStreamReader(is)); BufferedReader reader = new BufferedReader(new InputStreamReader(is));
String line; String line;
while((line = reader.readLine()) != null) { while ((line = reader.readLine()) != null) {
writer.println(line); writer.println(line);
} }
reader.close(); reader.close();
} }
/**
* Writes the specified start element. /**
* @param name the name of the start element * Writes the specified start element.
*/ * @param name the name of the start element
*/
public void startElement(String name) { public void startElement(String name) {
startElement(name, null, null); startElement(name, null, null);
} }
/**
* Writes the specified start element with the attributes. /**
* @param name the name of the start element * Writes the specified start element with the attributes.
* @param attrs the attributes of the start element * @param name the name of the start element
*/ * @param attrs the attributes of the start element
*/
public void startElement(String name, XmlAttributes attrs) { public void startElement(String name, XmlAttributes attrs) {
startElement(name, attrs, null); startElement(name, attrs, null);
} }
private void startElement(String name, XmlAttributes attrs, String text) { private void startElement(String name, XmlAttributes attrs, String text) {
if (addedText) { if (addedText) {
throw new IllegalStateException("Cannot have child elements in parent elements with text!"); throw new IllegalStateException(
} "Cannot have child elements in parent elements with text!");
}
counter.increment(name); counter.increment(name);
@ -111,54 +110,56 @@ public class XmlWriter {
writer.println(">"); writer.println(">");
incompleteLine = false; incompleteLine = false;
} }
indent(); indent();
indentLevel++; indentLevel++;
writer.print("<"); writer.print("<");
writer.print(name); writer.print(name);
incompleteLine = true; incompleteLine = true;
if (attrs != null) { if (attrs != null) {
writer.print(attrs.toString()); writer.print(attrs.toString());
} }
if (text != null) { if (text != null) {
writer.print(">"); writer.print(">");
writer.print(XmlUtilities.escapeElementEntities(text)); writer.print(XmlUtilities.escapeElementEntities(text));
incompleteLine = false; incompleteLine = false;
addedText = true; addedText = true;
} }
} }
/** /**
* Writes the specified end element. * Writes the specified end element.
* @param name the name of the end element * @param name the name of the end element
*/ */
public void endElement(String name) { public void endElement(String name) {
indentLevel--; indentLevel--;
if (incompleteLine) { if (incompleteLine) {
writer.println(" />"); writer.println(" />");
} }
else { else {
if (!addedText) { if (!addedText) {
indent(); indent();
} }
writer.println("</"+name+">"); writer.println("</" + name + ">");
} }
incompleteLine = false; incompleteLine = false;
addedText = false; addedText = false;
} }
/**
* Writes the specified element with the attributes. /**
* @param name the name of the start element * Writes the specified element with the attributes.
* @param attrs the attributes of the start element * @param name the name of the start element
*/ * @param attrs the attributes of the start element
*/
public void writeElement(String name, XmlAttributes attrs) { public void writeElement(String name, XmlAttributes attrs) {
writeElement(name, attrs, null); writeElement(name, attrs, null);
} }
/**
* Writes the specified element with the attributes and text. /**
* @param name the name of the element * Writes the specified element with the attributes and text.
* @param attrs the attributes of the element * @param name the name of the element
* @param text the text of the element * @param attrs the attributes of the element
*/ * @param text the text of the element
*/
public void writeElement(String name, XmlAttributes attrs, String text) { public void writeElement(String name, XmlAttributes attrs, String text) {
startElement(name, attrs, text); startElement(name, attrs, text);
endElement(name); endElement(name);
@ -170,5 +171,3 @@ public class XmlWriter {
} }
} }
} }

View file

@ -25,7 +25,7 @@ import org.junit.*;
import edu.uci.ics.jung.algorithms.layout.DAGLayout; import edu.uci.ics.jung.algorithms.layout.DAGLayout;
import edu.uci.ics.jung.algorithms.layout.Layout; import edu.uci.ics.jung.algorithms.layout.Layout;
import generic.test.AbstractGenericTest; import generic.test.AbstractGuiTest;
import ghidra.graph.graphs.*; import ghidra.graph.graphs.*;
import ghidra.graph.support.*; import ghidra.graph.support.*;
import ghidra.graph.viewer.GraphViewerUtils; import ghidra.graph.viewer.GraphViewerUtils;
@ -60,7 +60,7 @@ public class GraphViewerTransformationsTest {
} }
protected void swing(Runnable r) { protected void swing(Runnable r) {
AbstractGenericTest.runSwing(r); AbstractGuiTest.runSwing(r);
} }
private TestVisualGraph buildGraph() { private TestVisualGraph buildGraph() {
@ -196,7 +196,7 @@ public class GraphViewerTransformationsTest {
// TODO move up the Swing methods? ...to reduce dependencies on slow startup stuff? // TODO move up the Swing methods? ...to reduce dependencies on slow startup stuff?
AbstractGenericTest.runSwing(() -> GraphViewerUtils.setGraphScale(viewer, d)); AbstractGuiTest.runSwing(() -> GraphViewerUtils.setGraphScale(viewer, d));
AbstractGenericTest.waitForSwing(); AbstractGuiTest.waitForSwing();
} }
} }

View file

@ -27,7 +27,7 @@ import org.apache.logging.log4j.Logger;
import org.junit.*; import org.junit.*;
import generic.test.AbstractGTest; import generic.test.AbstractGTest;
import generic.test.AbstractGenericTest; import generic.test.AbstractGuiTest;
import ghidra.framework.LoggingInitialization; import ghidra.framework.LoggingInitialization;
import ghidra.util.Msg; import ghidra.util.Msg;
import ghidra.util.SystemUtilities; import ghidra.util.SystemUtilities;
@ -35,7 +35,7 @@ import ghidra.util.datastruct.WeakDataStructureFactory;
import ghidra.util.datastruct.WeakSet; import ghidra.util.datastruct.WeakSet;
import ghidra.util.exception.AssertException; import ghidra.util.exception.AssertException;
public class VisualGraphJobRunnerTest extends AbstractGenericTest { public class VisualGraphJobRunnerTest extends AbstractGuiTest {
// something reasonable: too large makes the test slower; too small, then the test can timeout // something reasonable: too large makes the test slower; too small, then the test can timeout
private static final int RUN_TIME_MILLIS_JOB_THREAD_MAX = 1000; private static final int RUN_TIME_MILLIS_JOB_THREAD_MAX = 1000;

View file

@ -32,7 +32,6 @@ import org.junit.Before;
import docking.test.AbstractDockingTest; import docking.test.AbstractDockingTest;
import edu.uci.ics.jung.algorithms.layout.Layout; import edu.uci.ics.jung.algorithms.layout.Layout;
import generic.test.AbstractGenericTest;
import ghidra.graph.graphs.AbstractTestVertex; import ghidra.graph.graphs.AbstractTestVertex;
import ghidra.graph.graphs.TestEdge; import ghidra.graph.graphs.TestEdge;
import ghidra.graph.support.*; import ghidra.graph.support.*;
@ -123,11 +122,11 @@ public abstract class AbstractVisualGraphTest extends AbstractDockingTest {
} }
protected void swing(Runnable r) { protected void swing(Runnable r) {
AbstractGenericTest.runSwing(r); runSwing(r);
} }
protected <T> T swing(Supplier<T> s) { protected <T> T swing(Supplier<T> s) {
return AbstractGenericTest.runSwing(s); return runSwing(s);
} }
protected void waitForAnimation() { protected void waitForAnimation() {
@ -258,7 +257,7 @@ public abstract class AbstractVisualGraphTest extends AbstractDockingTest {
protected void clickViewer(int x, int y) { protected void clickViewer(int x, int y) {
GraphViewer<AbstractTestVertex, TestEdge> viewer = graphComponent.getPrimaryViewer(); GraphViewer<AbstractTestVertex, TestEdge> viewer = graphComponent.getPrimaryViewer();
AbstractGenericTest.clickMouse(viewer, MouseEvent.BUTTON1, x, y, 1, 0); clickMouse(viewer, MouseEvent.BUTTON1, x, y, 1, 0);
waitForSwing(); waitForSwing();
} }
@ -276,7 +275,7 @@ public abstract class AbstractVisualGraphTest extends AbstractDockingTest {
Point p = getViewLocation(v); Point p = getViewLocation(v);
int x = p.x + xOffset; int x = p.x + xOffset;
int y = p.y + yOffset; int y = p.y + yOffset;
AbstractGenericTest.clickMouse(viewer, MouseEvent.BUTTON1, x, y, clickCount, 0); clickMouse(viewer, MouseEvent.BUTTON1, x, y, clickCount, 0);
waitForSwing(); waitForSwing();
AbstractTestVertex focused = swing(() -> graph.getFocusedVertex()); AbstractTestVertex focused = swing(() -> graph.getFocusedVertex());
@ -318,12 +317,12 @@ public abstract class AbstractVisualGraphTest extends AbstractDockingTest {
int x = (int) p.getX(); int x = (int) p.getX();
int y = (int) p.getY(); int y = (int) p.getY();
AbstractGenericTest.moveMouse(viewer, x, y); moveMouse(viewer, x, y);
} }
protected void drag(int x1, int y1, int x2, int y2) { protected void drag(int x1, int y1, int x2, int y2) {
GraphViewer<AbstractTestVertex, TestEdge> viewer = graphComponent.getPrimaryViewer(); GraphViewer<AbstractTestVertex, TestEdge> viewer = graphComponent.getPrimaryViewer();
AbstractGenericTest.dragMouse(viewer, MouseEvent.BUTTON1, x1, y1, x2, y2, 0); dragMouse(viewer, MouseEvent.BUTTON1, x1, y1, x2, y2, 0);
waitForAnimation(); waitForAnimation();
} }

View file

@ -33,7 +33,6 @@ import org.junit.Test;
import docking.test.AbstractDockingTest; import docking.test.AbstractDockingTest;
import edu.uci.ics.jung.visualization.RenderContext; import edu.uci.ics.jung.visualization.RenderContext;
import generic.test.AbstractGenericTest;
import generic.test.TestUtils; import generic.test.TestUtils;
import generic.util.WindowUtilities; import generic.util.WindowUtilities;
import ghidra.graph.graphs.*; import ghidra.graph.graphs.*;
@ -481,7 +480,7 @@ public class GraphComponentTest extends AbstractVisualGraphTest {
} }
private void press(String name) { private void press(String name) {
AbstractGenericTest.pressButtonByName(graphComponent.getComponent(), name, true); pressButtonByName(graphComponent.getComponent(), name, true);
} }
private AbstractTestVertex pickNonEditableVertex() { private AbstractTestVertex pickNonEditableVertex() {

View file

@ -15,8 +15,7 @@
*/ */
package ghidra.graph; package ghidra.graph;
import static org.junit.Assert.assertTrue; import static org.junit.Assert.*;
import static org.junit.Assert.fail;
import java.util.*; import java.util.*;
@ -24,6 +23,7 @@ import org.junit.Assert;
import org.junit.Before; import org.junit.Before;
import generic.test.AbstractGenericTest; import generic.test.AbstractGenericTest;
import generic.test.AbstractGuiTest;
import ghidra.graph.algo.ChkDominanceAlgorithm; import ghidra.graph.algo.ChkDominanceAlgorithm;
import ghidra.graph.algo.ChkPostDominanceAlgorithm; import ghidra.graph.algo.ChkPostDominanceAlgorithm;
import ghidra.util.exception.CancelledException; import ghidra.util.exception.CancelledException;
@ -65,7 +65,7 @@ public abstract class AbstractGraphAlgorithmsTest extends AbstractGenericTest {
while (true) { while (true) {
sleep(1000); sleep(1000);
printMemory(); AbstractGuiTest.printMemory();
} }
}, "Memory Monitor"); }, "Memory Monitor");

View file

@ -0,0 +1 @@
MODULE FILE LICENSE: lib/flatlaf-2.6.jar Apache License 2.0

View file

@ -0,0 +1,39 @@
/* ###
* IP: GHIDRA
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
import org.gradle.plugins.ide.eclipse.model.Container;
apply from: "$rootProject.projectDir/gradle/distributableGhidraModule.gradle"
apply from: "$rootProject.projectDir/gradle/javaProject.gradle"
apply from: "$rootProject.projectDir/gradle/jacocoProject.gradle"
apply from: "$rootProject.projectDir/gradle/javaTestProject.gradle"
apply from: "$rootProject.projectDir/gradle/javadoc.gradle"
apply plugin: 'eclipse'
eclipse.project.name = 'Framework Gui'
dependencies {
api project(':Generic')
api 'com.formdev:flatlaf:2.6'
compileOnly "junit:junit:4.12"
testImplementation project(path: ':Generic', configuration: 'testArtifacts')
}
ext.addExports([
'java.desktop/sun.awt=ALL-UNNAMED'
])

View file

@ -0,0 +1,9 @@
##VERSION: 2.0
##MODULE IP: Modified Nuvola Icons - LGPL 2.1
##MODULE IP: Nuvola Icons - LGPL 2.1
##MODULE IP: Oxygen Icons - LGPL 3.0
##MODULE IP: Tango Icons - Public Domain
.classpath||GHIDRA||||END|
Module.manifest||GHIDRA||||END|
src/main/java/ghidra/framework/options/package.html||GHIDRA||||END|
src/main/java/ghidra/util/layout/package.html||GHIDRA||||END|

File diff suppressed because it is too large Load diff

Some files were not shown because too many files have changed in this diff Show more