mirror of
https://github.com/NationalSecurityAgency/ghidra.git
synced 2024-11-25 05:32:14 +00:00
Fixed bad palette references; set standard theme for screenshots
This commit is contained in:
parent
9d7809902d
commit
a8328a39f5
@ -15,8 +15,7 @@
|
||||
*/
|
||||
package help.screenshot;
|
||||
|
||||
import static org.junit.Assert.assertNotNull;
|
||||
import static org.junit.Assert.assertTrue;
|
||||
import static org.junit.Assert.*;
|
||||
|
||||
import java.awt.*;
|
||||
import java.awt.geom.GeneralPath;
|
||||
@ -49,6 +48,8 @@ import docking.widgets.tree.GTree;
|
||||
import generic.test.AbstractGenericTest;
|
||||
import generic.theme.GThemeDefaults.Colors;
|
||||
import generic.theme.GThemeDefaults.Colors.Palette;
|
||||
import generic.theme.ThemeManager;
|
||||
import generic.theme.builtin.FlatLightTheme;
|
||||
import generic.util.image.ImageUtils;
|
||||
import ghidra.app.events.ProgramSelectionPluginEvent;
|
||||
import ghidra.app.plugin.core.analysis.AnalysisOptionsDialog;
|
||||
@ -106,11 +107,11 @@ public abstract class AbstractScreenShotGenerator extends AbstractGhidraHeadedIn
|
||||
public Image image;
|
||||
|
||||
public AbstractScreenShotGenerator() {
|
||||
super();
|
||||
|
||||
// this prevents test tool from appearing in the UI
|
||||
setInstanceField("allowTestTools", ToolUtils.class, Boolean.FALSE);
|
||||
setDockIcon();
|
||||
|
||||
ThemeManager.getInstance().setTheme(new FlatLightTheme());
|
||||
}
|
||||
|
||||
protected TestEnv newTestEnv() throws Exception {
|
||||
|
@ -48,11 +48,10 @@ import ghidra.util.exception.AssertException;
|
||||
*/
|
||||
public abstract class GhidraScreenShotGenerator extends AbstractScreenShotGenerator {
|
||||
|
||||
private static final Color FG_COLOR_TEXT = Palette.getColor("color.palette.cornflowerblue");
|
||||
private static final Color FG_COLOR_TEXT = Palette.getColor("cornflowerblue");
|
||||
private static final String CAPTURE = "Capture";
|
||||
|
||||
protected GhidraScreenShotGenerator() {
|
||||
super();
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -1124,8 +1124,8 @@ public abstract class AbstractDockingTest extends AbstractGuiTest {
|
||||
String name) {
|
||||
Set<DockingActionIf> ownerActions = tool.getDockingActionsByOwnerName(owner);
|
||||
return ownerActions.stream()
|
||||
.filter(action -> action.getName().equals(name))
|
||||
.collect(Collectors.toSet());
|
||||
.filter(action -> action.getName().equals(name))
|
||||
.collect(Collectors.toSet());
|
||||
}
|
||||
|
||||
/**
|
||||
@ -2217,7 +2217,9 @@ public abstract class AbstractDockingTest extends AbstractGuiTest {
|
||||
*/
|
||||
public static Image createScreenImage(Component c) throws AWTException {
|
||||
|
||||
yieldToSwing();
|
||||
if (!Swing.isSwingThread()) {
|
||||
yieldToSwing();
|
||||
}
|
||||
|
||||
Rectangle r = c.getBounds();
|
||||
Point p = r.getLocation();
|
||||
@ -2234,7 +2236,9 @@ public abstract class AbstractDockingTest extends AbstractGuiTest {
|
||||
|
||||
public static Image createRenderedImage(Component c) {
|
||||
|
||||
yieldToSwing();
|
||||
if (!Swing.isSwingThread()) {
|
||||
yieldToSwing();
|
||||
}
|
||||
|
||||
Image i = runSwing(() -> {
|
||||
try {
|
||||
|
@ -26,7 +26,7 @@ import generic.util.image.ImageUtils;
|
||||
|
||||
public class Callout {
|
||||
|
||||
private static final Color CALLOUT_SHAPE_COLOR = Palette.getColor("color.palette.palegreen");
|
||||
private static final Color CALLOUT_SHAPE_COLOR = Palette.getColor("palegreen");
|
||||
private static final int CALLOUT_BORDER_PADDING = 20;
|
||||
|
||||
public Image createCallout(CalloutComponentInfo calloutInfo) {
|
||||
|
@ -15,8 +15,7 @@
|
||||
*/
|
||||
package generic.test;
|
||||
|
||||
import static org.junit.Assert.assertNotNull;
|
||||
import static org.junit.Assert.fail;
|
||||
import static org.junit.Assert.*;
|
||||
|
||||
import java.awt.*;
|
||||
import java.awt.event.*;
|
||||
@ -1110,8 +1109,8 @@ public class AbstractGuiTest extends AbstractGenericTest {
|
||||
if (expected.getRGB() == actual.getRGB()) {
|
||||
return;
|
||||
}
|
||||
fail("Expected: [" + expected.getClass().getSimpleName() + "]" + expected +
|
||||
", but got: [" + actual.getClass().getSimpleName() + "]" + actual);
|
||||
fail("Expected: [" + expected.getClass().getSimpleName() + "]" + expected + ", but got: [" +
|
||||
actual.getClass().getSimpleName() + "]" + actual);
|
||||
}
|
||||
|
||||
public static void printMemory() {
|
||||
|
@ -63,10 +63,6 @@ public class RepositoryScreenShots extends AbstractListingMergeManagerTest {
|
||||
protected MergeScreenShotGenerator mtfGenerator;
|
||||
static protected float DESCRIPTION_FONT_SIZE = (float) 14.0;
|
||||
|
||||
public RepositoryScreenShots() {
|
||||
super();
|
||||
}
|
||||
|
||||
@Before
|
||||
@Override
|
||||
public void setUp() throws Exception {
|
||||
@ -81,6 +77,7 @@ public class RepositoryScreenShots extends AbstractListingMergeManagerTest {
|
||||
@Override
|
||||
public void tearDown() throws Exception {
|
||||
mtfGenerator.showResults();
|
||||
closeAllWindows();
|
||||
mtf.dispose();
|
||||
}
|
||||
|
||||
@ -96,13 +93,6 @@ public class RepositoryScreenShots extends AbstractListingMergeManagerTest {
|
||||
mtfGenerator.setTool(mergeTool);
|
||||
}
|
||||
|
||||
// public void testMultiUser() throws Exception {
|
||||
// GhidraScreenShotGenerator gssg = new GhidraScreenShotGenerator(getName());
|
||||
// gssg.setUp();
|
||||
// gssg.captureWindow();
|
||||
//
|
||||
// }
|
||||
|
||||
@Test
|
||||
public void testMemoryConflict() throws Exception {
|
||||
mtf.initialize("WallaceSrc", new ProgramModifierListener() {
|
||||
@ -2412,8 +2402,7 @@ public class RepositoryScreenShots extends AbstractListingMergeManagerTest {
|
||||
boolean commit = false;
|
||||
try {
|
||||
program.getExternalManager()
|
||||
.setExternalPath("ADVAPI32.DLL", "//advapi32.dll",
|
||||
true);
|
||||
.setExternalPath("ADVAPI32.DLL", "//advapi32.dll", true);
|
||||
commit = true;
|
||||
}
|
||||
finally {
|
||||
@ -2469,8 +2458,7 @@ public class RepositoryScreenShots extends AbstractListingMergeManagerTest {
|
||||
boolean commit = false;
|
||||
try {
|
||||
program.getExternalManager()
|
||||
.setExternalPath("ADVAPI32.DLL", "//advapi32.dll",
|
||||
true);
|
||||
.setExternalPath("ADVAPI32.DLL", "//advapi32.dll", true);
|
||||
commit = true;
|
||||
}
|
||||
finally {
|
||||
@ -2572,11 +2560,9 @@ public class RepositoryScreenShots extends AbstractListingMergeManagerTest {
|
||||
FrontEndTool frontEndTool = env.showFrontEndTool();
|
||||
DomainFolder rootFolder = frontEndTool.getProject().getProjectData().getRootFolder();
|
||||
TaskMonitor dummyMonitor = TaskMonitor.DUMMY;
|
||||
DomainFile myTestArchiveDF =
|
||||
env.restoreDataTypeArchive("MyTestArchive.gdt", rootFolder);
|
||||
final DataTypeArchive myTestArchive =
|
||||
(DataTypeArchiveDB) myTestArchiveDF.getDomainObject(this, true, false,
|
||||
TaskMonitor.DUMMY);
|
||||
DomainFile myTestArchiveDF = env.restoreDataTypeArchive("MyTestArchive.gdt", rootFolder);
|
||||
final DataTypeArchive myTestArchive = (DataTypeArchiveDB) myTestArchiveDF
|
||||
.getDomainObject(this, true, false, TaskMonitor.DUMMY);
|
||||
|
||||
final CategoryPath sourceCatPath = new CategoryPath("/Category1/Category2/Category5");
|
||||
final DataType floatStruct =
|
||||
@ -2729,8 +2715,8 @@ public class RepositoryScreenShots extends AbstractListingMergeManagerTest {
|
||||
ExternalLocationIterator iter = extMgr.getExternalLocations(libName);
|
||||
while (iter.hasNext()) {
|
||||
ExternalLocation loc = iter.next();
|
||||
if (!((ExternalManagerDB) extMgr).removeExternalLocation(
|
||||
loc.getExternalSpaceAddress())) {
|
||||
if (!((ExternalManagerDB) extMgr)
|
||||
.removeExternalLocation(loc.getExternalSpaceAddress())) {
|
||||
Assert.fail("Couldn't remove external location for library " + libName);
|
||||
}
|
||||
}
|
||||
@ -2868,9 +2854,9 @@ public class RepositoryScreenShots extends AbstractListingMergeManagerTest {
|
||||
JScrollPane scrollPane =
|
||||
(JScrollPane) TestUtils.getInstanceField("scrollPane", latestScroller);
|
||||
JScrollBar horizontalScrollBar = scrollPane.getHorizontalScrollBar();
|
||||
horizontalScrollBar.setValue(
|
||||
(horizontalScrollBar.getMinimum() + horizontalScrollBar.getMaximum() -
|
||||
horizontalScrollBar.getVisibleAmount()) * percent / 100);
|
||||
horizontalScrollBar
|
||||
.setValue((horizontalScrollBar.getMinimum() + horizontalScrollBar.getMaximum() -
|
||||
horizontalScrollBar.getVisibleAmount()) * percent / 100);
|
||||
});
|
||||
waitForSwing();
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user