mirror of
https://github.com/NationalSecurityAgency/ghidra.git
synced 2025-10-03 17:59:46 +02:00
Merge remote-tracking branch 'origin/patch'
Conflicts: Ghidra/Features/Base/src/test.slow/java/ghidra/app/plugin/core/disassembler/ClearTest.java Ghidra/Features/Base/src/test.slow/java/ghidra/app/plugin/core/select/qualified/QualifiedSelectionPluginTest.java
This commit is contained in:
commit
2d7c8d5055
8 changed files with 105 additions and 81 deletions
|
@ -177,8 +177,9 @@ public class ClearTest extends AbstractGhidraHeadedIntegrationTest {
|
||||||
public void testClearActionEnablement() throws Exception {
|
public void testClearActionEnablement() throws Exception {
|
||||||
|
|
||||||
closeProgram();
|
closeProgram();
|
||||||
ActionContext context = cb.getProvider().getActionContext(null);
|
|
||||||
assertFalse(clearAction.isEnabledForContext(context));
|
assertFalse(isEnabled(clearAction, cb.getProvider()));
|
||||||
|
assertFalse(clearAction.isEnabledForContext(new ActionContext()));
|
||||||
|
|
||||||
showTool(tool);
|
showTool(tool);
|
||||||
loadProgram("notepad");
|
loadProgram("notepad");
|
||||||
|
@ -186,12 +187,10 @@ public class ClearTest extends AbstractGhidraHeadedIntegrationTest {
|
||||||
waitForSwing();
|
waitForSwing();
|
||||||
assertTrue(cb.goToField(addr("0x10026f0"), "Address", 0, 0));
|
assertTrue(cb.goToField(addr("0x10026f0"), "Address", 0, 0));
|
||||||
|
|
||||||
context = cb.getProvider().getActionContext(null);
|
assertTrue(isEnabled(clearAction, cb.getProvider()));
|
||||||
assertTrue(clearAction.isEnabledForContext(context));
|
|
||||||
closeProgram();
|
closeProgram();
|
||||||
|
|
||||||
context = cb.getProvider().getActionContext(null);
|
assertFalse(isEnabled(clearAction, cb.getProvider()));
|
||||||
assertFalse(clearAction.isEnabledForContext(context));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
|
@ -204,7 +203,6 @@ public class ClearTest extends AbstractGhidraHeadedIntegrationTest {
|
||||||
doClearAction(true);
|
doClearAction(true);
|
||||||
|
|
||||||
assertEquals(numInstructions, program.getListing().getNumInstructions());
|
assertEquals(numInstructions, program.getListing().getNumInstructions());
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
|
@ -287,7 +285,7 @@ public class ClearTest extends AbstractGhidraHeadedIntegrationTest {
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* This tests that a selection that includes the outermost header of does not change the
|
* This tests that a selection that includes the outermost header of does not change the
|
||||||
* selection, but instead removes the structure from the listing at that address.
|
* selection, but instead removes the structure from the listing at that address.
|
||||||
*/
|
*/
|
||||||
@Test
|
@Test
|
||||||
|
|
|
@ -97,7 +97,8 @@ public class TableChooserDialogTest extends AbstractGhidraHeadedIntegrationTest
|
||||||
|
|
||||||
Program program = builder.getProgram();
|
Program program = builder.getProgram();
|
||||||
Navigatable navigatable = null;
|
Navigatable navigatable = null;
|
||||||
dialog = new TableChooserDialog(tool, executor, program, "Dialog Title", navigatable);
|
runSwing(() -> dialog =
|
||||||
|
new TableChooserDialog(tool, executor, program, "Dialog Title", navigatable));
|
||||||
|
|
||||||
testAction = new TestAction();
|
testAction = new TestAction();
|
||||||
dialog.addAction(testAction);
|
dialog.addAction(testAction);
|
||||||
|
|
|
@ -43,7 +43,6 @@ public class CloseToolTest extends AbstractGhidraHeadedIntegrationTest {
|
||||||
|
|
||||||
@Before
|
@Before
|
||||||
public void setUp() throws Exception {
|
public void setUp() throws Exception {
|
||||||
|
|
||||||
env = new TestEnv();
|
env = new TestEnv();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -62,7 +61,6 @@ public class CloseToolTest extends AbstractGhidraHeadedIntegrationTest {
|
||||||
assertNotNull(tool.getToolFrame());
|
assertNotNull(tool.getToolFrame());
|
||||||
closeTool(tool);
|
closeTool(tool);
|
||||||
assertNull("Tool did not close after task", tool.getToolFrame());
|
assertNull("Tool did not close after task", tool.getToolFrame());
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
|
@ -185,8 +183,8 @@ public class CloseToolTest extends AbstractGhidraHeadedIntegrationTest {
|
||||||
}
|
}
|
||||||
|
|
||||||
//==================================================================================================
|
//==================================================================================================
|
||||||
// Inner Classes
|
// Inner Classes
|
||||||
//==================================================================================================
|
//==================================================================================================
|
||||||
|
|
||||||
private class ControllableBackgroundCommand extends BackgroundCommand {
|
private class ControllableBackgroundCommand extends BackgroundCommand {
|
||||||
|
|
||||||
|
|
|
@ -60,10 +60,11 @@ public class DefaultGraphDisplayProvider implements GraphDisplayProvider {
|
||||||
return visibleGraph;
|
return visibleGraph;
|
||||||
}
|
}
|
||||||
|
|
||||||
DefaultGraphDisplay display =
|
return Swing.runNow(() -> {
|
||||||
Swing.runNow(() -> new DefaultGraphDisplay(this, displayCounter++));
|
DefaultGraphDisplay display = new DefaultGraphDisplay(this, displayCounter++);
|
||||||
displays.add(display);
|
displays.add(display);
|
||||||
return display;
|
return display;
|
||||||
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -76,10 +77,11 @@ public class DefaultGraphDisplayProvider implements GraphDisplayProvider {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public List<GraphDisplay> getAllGraphDisplays() {
|
public List<GraphDisplay> getAllGraphDisplays() {
|
||||||
return displays.stream()
|
return Swing.runNow(() -> {
|
||||||
.filter(d -> d.getComponent().isShowing())
|
return displays.stream()
|
||||||
.sorted((d1, d2) -> -(d1.getId() - d2.getId())) // largest/newest IDs come first
|
.sorted((d1, d2) -> -(d1.getId() - d2.getId())) // largest/newest IDs come first
|
||||||
.collect(Collectors.toList());
|
.collect(Collectors.toList());
|
||||||
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|
|
@ -38,8 +38,7 @@ import org.apache.commons.lang3.StringUtils;
|
||||||
import org.junit.*;
|
import org.junit.*;
|
||||||
|
|
||||||
import docking.*;
|
import docking.*;
|
||||||
import docking.action.DockingActionIf;
|
import docking.action.*;
|
||||||
import docking.action.ToggleDockingActionIf;
|
|
||||||
import docking.actions.DockingToolActions;
|
import docking.actions.DockingToolActions;
|
||||||
import docking.dnd.GClipboard;
|
import docking.dnd.GClipboard;
|
||||||
import docking.framework.DockingApplicationConfiguration;
|
import docking.framework.DockingApplicationConfiguration;
|
||||||
|
@ -105,7 +104,7 @@ public abstract class AbstractDockingTest extends AbstractGenericTest {
|
||||||
// timing issues.
|
// timing issues.
|
||||||
|
|
||||||
// Note: this doesn't quite work as intended. This should be run before each other
|
// Note: this doesn't quite work as intended. This should be run before each other
|
||||||
// tearDown() method, but junit offers no way to do that. If you can figure
|
// tearDown() method, but junit offers no way to do that. If you can figure
|
||||||
// out how to make that work, then update this code.
|
// out how to make that work, then update this code.
|
||||||
ConcurrentTestExceptionHandler.disable();
|
ConcurrentTestExceptionHandler.disable();
|
||||||
}
|
}
|
||||||
|
@ -322,7 +321,7 @@ public abstract class AbstractDockingTest extends AbstractGenericTest {
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Check for and display message component text associated with OptionDialog windows
|
* Check for and display message component text associated with OptionDialog windows
|
||||||
* @param w any window
|
* @param w any window
|
||||||
* @return the message string if one can be found; <code>null</code> otherwise
|
* @return the message string if one can be found; <code>null</code> otherwise
|
||||||
*/
|
*/
|
||||||
|
@ -756,7 +755,7 @@ public abstract class AbstractDockingTest extends AbstractGenericTest {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Allows you to find a component provider <b>with the given title</b>. Most plugins will
|
* Allows you to find a component provider <b>with the given title</b>. Most plugins will
|
||||||
* only ever have a single provider. In those cases, use
|
* only ever have a single provider. In those cases, use
|
||||||
* {@link #waitForComponentProvider(Class)}. This version of that method is to allow you to
|
* {@link #waitForComponentProvider(Class)}. This version of that method is to allow you to
|
||||||
* differentiate between multiple instances of a given provider that have different titles.
|
* differentiate between multiple instances of a given provider that have different titles.
|
||||||
*
|
*
|
||||||
|
@ -1121,7 +1120,7 @@ public abstract class AbstractDockingTest extends AbstractGenericTest {
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* A helper method to find all actions by name, with the given owner's name (this will not
|
* A helper method to find all actions by name, with the given owner's name (this will not
|
||||||
* include reserved system actions)
|
* include reserved system actions)
|
||||||
*
|
*
|
||||||
* @param tool the tool containing all system actions
|
* @param tool the tool containing all system actions
|
||||||
|
@ -1164,12 +1163,12 @@ public abstract class AbstractDockingTest extends AbstractGenericTest {
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Finds the action by the given owner name and action name.
|
* Finds the action by the given owner name and action name.
|
||||||
* If you do not know the owner name, then use
|
* If you do not know the owner name, then use
|
||||||
* the call {@link #getActionsByName(Tool, String)} instead (this will not include
|
* the call {@link #getActionsByName(Tool, String)} instead (this will not include
|
||||||
* reserved system actions).
|
* reserved system actions).
|
||||||
*
|
*
|
||||||
* <P>Note: more specific test case subclasses provide other methods for finding actions
|
* <P>Note: more specific test case subclasses provide other methods for finding actions
|
||||||
* when you have an owner name (which is usually the plugin name).
|
* when you have an owner name (which is usually the plugin name).
|
||||||
*
|
*
|
||||||
* @param tool the tool containing all system actions
|
* @param tool the tool containing all system actions
|
||||||
|
@ -1522,8 +1521,8 @@ public abstract class AbstractDockingTest extends AbstractGenericTest {
|
||||||
triggerText(c, "\010");
|
triggerText(c, "\010");
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Simulates the user pressing the 'Enter' key on the given text field
|
* Simulates the user pressing the 'Enter' key on the given text field
|
||||||
* @param c the component
|
* @param c the component
|
||||||
*/
|
*/
|
||||||
public static void triggerEnter(Component c) {
|
public static void triggerEnter(Component c) {
|
||||||
|
@ -1715,7 +1714,7 @@ public abstract class AbstractDockingTest extends AbstractGenericTest {
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Fires a {@link KeyListener#keyPressed(KeyEvent)},
|
* Fires a {@link KeyListener#keyPressed(KeyEvent)},
|
||||||
* {@link KeyListener#keyTyped(KeyEvent)}
|
* {@link KeyListener#keyTyped(KeyEvent)}
|
||||||
* and {@link KeyListener#keyReleased(KeyEvent)} for the given key stroke
|
* and {@link KeyListener#keyReleased(KeyEvent)} for the given key stroke
|
||||||
*
|
*
|
||||||
|
@ -2020,7 +2019,7 @@ public abstract class AbstractDockingTest extends AbstractGenericTest {
|
||||||
|
|
||||||
private static <T> void doWaitForTableModel(ThreadedTableModel<T, ?> model) {
|
private static <T> void doWaitForTableModel(ThreadedTableModel<T, ?> model) {
|
||||||
|
|
||||||
// Always wait for Swing at least once. There seems to be a race condition for
|
// Always wait for Swing at least once. There seems to be a race condition for
|
||||||
// incremental threaded models where the table is not busy at the time this method
|
// incremental threaded models where the table is not busy at the time this method
|
||||||
// is called, but there is an update pending via an invokeLater().
|
// is called, but there is an update pending via an invokeLater().
|
||||||
waitForSwing();
|
waitForSwing();
|
||||||
|
@ -2142,6 +2141,11 @@ public abstract class AbstractDockingTest extends AbstractGenericTest {
|
||||||
return runSwing(() -> action.isEnabledForContext(new ActionContext()));
|
return runSwing(() -> action.isEnabledForContext(new ActionContext()));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public static boolean isEnabled(DockingActionIf action,
|
||||||
|
ActionContextProvider contextProvider) {
|
||||||
|
return runSwing(() -> action.isEnabledForContext(contextProvider.getActionContext(null)));
|
||||||
|
}
|
||||||
|
|
||||||
public static boolean isEnabled(AbstractButton button) {
|
public static boolean isEnabled(AbstractButton button) {
|
||||||
return runSwing(() -> button.isEnabled());
|
return runSwing(() -> button.isEnabled());
|
||||||
}
|
}
|
||||||
|
|
|
@ -27,7 +27,7 @@ import resources.icons.EmptyIcon;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Creates a panel that displays an {@link Image}. Users may pan the image as desired and zoom the
|
* Creates a panel that displays an {@link Image}. Users may pan the image as desired and zoom the
|
||||||
* image according to specific zoom levels.
|
* image according to specific zoom levels.
|
||||||
*/
|
*/
|
||||||
public class ImagePanel extends JPanel {
|
public class ImagePanel extends JPanel {
|
||||||
|
|
||||||
|
@ -40,7 +40,7 @@ public class ImagePanel extends JPanel {
|
||||||
// neutral
|
// neutral
|
||||||
1.0f,
|
1.0f,
|
||||||
// expanding scales
|
// expanding scales
|
||||||
1.5f, 2f, 2.5f, 3f, 4f, 5f, 6f, 7f, 8f, 9f, 10f
|
1.5f, 2f, 2.5f, 3f, 4f, 5f, 6f, 7f, 8f, 9f, 10f
|
||||||
|
|
||||||
// @formatter:on
|
// @formatter:on
|
||||||
};
|
};
|
||||||
|
@ -127,6 +127,7 @@ public class ImagePanel extends JPanel {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Create an NavigableImagePanel with the specified image
|
* Create an NavigableImagePanel with the specified image
|
||||||
|
* @param image the image
|
||||||
*/
|
*/
|
||||||
public ImagePanel(Image image) {
|
public ImagePanel(Image image) {
|
||||||
initUI();
|
initUI();
|
||||||
|
@ -174,7 +175,7 @@ public class ImagePanel extends JPanel {
|
||||||
firePropertyChange(IMAGE_PROPERTY, oldImage, this.image);
|
firePropertyChange(IMAGE_PROPERTY, oldImage, this.image);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Get the currently-displayed image
|
* Get the currently-displayed image
|
||||||
* @return the current image
|
* @return the current image
|
||||||
*/
|
*/
|
||||||
|
@ -183,7 +184,7 @@ public class ImagePanel extends JPanel {
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Set the background color of the panel. If the specified color is null, the
|
* Set the background color of the panel. If the specified color is null, the
|
||||||
* default color for panel backgrounds is used.
|
* default color for panel backgrounds is used.
|
||||||
* @param color the new background color
|
* @param color the new background color
|
||||||
*/
|
*/
|
||||||
|
@ -202,12 +203,24 @@ public class ImagePanel extends JPanel {
|
||||||
return imagePanel.getBackground();
|
return imagePanel.getBackground();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Unused
|
||||||
|
* @param text unused
|
||||||
|
* @deprecated unused
|
||||||
|
*/
|
||||||
|
@Deprecated(since = "10.2", forRemoval = true) // unused
|
||||||
public void setText(String text) {
|
public void setText(String text) {
|
||||||
label.setText(text);
|
// unused
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Unused
|
||||||
|
* @return unused
|
||||||
|
* @deprecated unused
|
||||||
|
*/
|
||||||
|
@Deprecated(since = "10.2", forRemoval = true) // unused
|
||||||
public String getText() {
|
public String getText() {
|
||||||
return label.getText();
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -219,11 +232,11 @@ public class ImagePanel extends JPanel {
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Set the magnification factor of the image. The zoom parameter is aligned to the
|
* Set the magnification factor of the image. The zoom parameter is aligned to the
|
||||||
* nearest pre-configured magnification factor, rounding down for zoom factors less than
|
* nearest pre-configured magnification factor, rounding down for zoom factors less than
|
||||||
* 1.0, and up for factors greater than 1.0. Zoom factors outside the pre-configured range
|
* 1.0, and up for factors greater than 1.0. Zoom factors outside the pre-configured range
|
||||||
* are limited to the nearest range extent.
|
* are limited to the nearest range extent.
|
||||||
* @param zoom
|
* @param zoom the zoom
|
||||||
*/
|
*/
|
||||||
public void setZoomFactor(float zoom) {
|
public void setZoomFactor(float zoom) {
|
||||||
|
|
||||||
|
@ -250,7 +263,7 @@ public class ImagePanel extends JPanel {
|
||||||
// idx is now the index for where zoom should be inserted into levels...
|
// idx is now the index for where zoom should be inserted into levels...
|
||||||
|
|
||||||
if (idx == 0) {
|
if (idx == 0) {
|
||||||
// Smaller zoom factor than our minimum-supported; just provide
|
// Smaller zoom factor than our minimum-supported; just provide
|
||||||
// our minimum-supported
|
// our minimum-supported
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
@ -269,17 +282,17 @@ public class ImagePanel extends JPanel {
|
||||||
return idx;
|
return idx;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Get the default zoom level
|
* Get the default zoom factory
|
||||||
* @return
|
* @return the zoom factor
|
||||||
*/
|
*/
|
||||||
public float getDefaultZoomFactor() {
|
public float getDefaultZoomFactor() {
|
||||||
return defaultZoomFactor;
|
return defaultZoomFactor;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Set the default zoom level, adhering to the same set of constrains as {@link #setZoomFactor(float)}
|
* Set the default zoom level, adhering to the same set of constrains as {@link #setZoomFactor(float)}
|
||||||
* @param zoom
|
* @param zoom the zoom
|
||||||
* @see #setZoomFactor(float)
|
* @see #setZoomFactor(float)
|
||||||
* @see #resetZoom()
|
* @see #resetZoom()
|
||||||
*/
|
*/
|
||||||
|
@ -309,14 +322,14 @@ public class ImagePanel extends JPanel {
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Determine if the image can zoom in further based on current magnification levels
|
* Determine if the image can zoom in further based on current magnification levels
|
||||||
* @return True if magnification steps are available, false otherwise
|
* @return True if magnification steps are available, false otherwise
|
||||||
*/
|
*/
|
||||||
public boolean canZoomIn() {
|
public boolean canZoomIn() {
|
||||||
return image != null && zoomLevelIndex < ZOOM_LEVELS.length - 1;
|
return image != null && zoomLevelIndex < ZOOM_LEVELS.length - 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Enlarge the image about the image center
|
* Enlarge the image about the image center
|
||||||
*/
|
*/
|
||||||
public void zoomIn() {
|
public void zoomIn() {
|
||||||
|
@ -354,7 +367,7 @@ public class ImagePanel extends JPanel {
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Determine if the image can zoom out further based on current magnification levels
|
* Determine if the image can zoom out further based on current magnification levels
|
||||||
* @return True if (de-)magnification steps are available, false otherwise
|
* @return True if (de-)magnification steps are available, false otherwise
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
@ -452,7 +465,7 @@ public class ImagePanel extends JPanel {
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Move the image back to the center. Zoom factor is unmodified.
|
* Move the image back to the center. Zoom factor is unmodified.
|
||||||
*/
|
*/
|
||||||
public void resetImageTranslation() {
|
public void resetImageTranslation() {
|
||||||
label.resetTranslation();
|
label.resetTranslation();
|
||||||
|
|
|
@ -15,7 +15,7 @@
|
||||||
*/
|
*/
|
||||||
package docking.widgets.imagepanel;
|
package docking.widgets.imagepanel;
|
||||||
|
|
||||||
import static org.junit.Assert.assertTrue;
|
import static org.junit.Assert.*;
|
||||||
|
|
||||||
import java.awt.Image;
|
import java.awt.Image;
|
||||||
|
|
||||||
|
@ -39,84 +39,92 @@ public class ImagePanelTest extends AbstractDockingTest {
|
||||||
Image emptyImage = ResourceManager.getImageIcon(emptyIcon).getImage();
|
Image emptyImage = ResourceManager.getImageIcon(emptyIcon).getImage();
|
||||||
imagePanel = new ImagePanel(emptyImage);
|
imagePanel = new ImagePanel(emptyImage);
|
||||||
|
|
||||||
frame = new JFrame("ImagePanel Test");
|
runSwing(() -> {
|
||||||
frame.getContentPane().add(imagePanel);
|
frame = new JFrame("ImagePanel Test");
|
||||||
frame.setSize(400, 400);
|
frame.getContentPane().add(imagePanel);
|
||||||
|
frame.setSize(400, 400);
|
||||||
|
|
||||||
frame.setVisible(true);
|
frame.setVisible(true);
|
||||||
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
@After
|
@After
|
||||||
public void tearDown() throws Exception {
|
public void tearDown() throws Exception {
|
||||||
frame.dispose();
|
runSwing(() -> frame.dispose());
|
||||||
}
|
}
|
||||||
|
|
||||||
private void reset() {
|
private void reset() {
|
||||||
imagePanel.setZoomFactor(1.0f);
|
setZoom(1.0f);
|
||||||
|
|
||||||
assertTrue("Unable to reset zoom factor",
|
assertTrue("Unable to reset zoom factor",
|
||||||
Float.compare(imagePanel.getZoomFactor(), 1.0f) == 0);
|
Float.compare(getZoom(), 1.0f) == 0);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testZoom_Neutral() {
|
public void testZoom_Neutral() {
|
||||||
reset();
|
reset();
|
||||||
|
|
||||||
imagePanel.setZoomFactor(1.0f);
|
setZoom(1.0f);
|
||||||
|
|
||||||
assertTrue("Zoom factor not set to 1.0x",
|
assertTrue("Zoom factor not set to 1.0x",
|
||||||
Float.compare(imagePanel.getZoomFactor(), 1.0f) == 0);
|
Float.compare(getZoom(), 1.0f) == 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testZoom_10Point0f() {
|
public void testZoom_10Point0f() {
|
||||||
reset();
|
reset();
|
||||||
|
|
||||||
imagePanel.setZoomFactor(10.0f);
|
setZoom(10.0f);
|
||||||
|
|
||||||
assertTrue("Zoom factor not set to 10.0x",
|
assertTrue("Zoom factor not set to 10.0x",
|
||||||
Float.compare(imagePanel.getZoomFactor(), 10.0f) == 0);
|
Float.compare(getZoom(), 10.0f) == 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testZoom_0Point05() {
|
public void testZoom_0Point05() {
|
||||||
reset();
|
reset();
|
||||||
|
|
||||||
imagePanel.setZoomFactor(0.05f);
|
setZoom(0.05f);
|
||||||
|
|
||||||
assertTrue("Zoom factor not set to 0.05x",
|
assertTrue("Zoom factor not set to 0.05x",
|
||||||
Float.compare(imagePanel.getZoomFactor(), 0.05f) == 0);
|
Float.compare(getZoom(), 0.05f) == 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testZoom_20Point0() {
|
public void testZoom_20Point0() {
|
||||||
reset();
|
reset();
|
||||||
|
|
||||||
imagePanel.setZoomFactor(20.0f);
|
setZoom(20.0f);
|
||||||
|
|
||||||
assertTrue("Zoom factor not set to 20.0x; should be 10.0x",
|
assertTrue("Zoom factor not set to 20.0x; should be 10.0x",
|
||||||
Float.compare(imagePanel.getZoomFactor(), 10.0f) == 0);
|
Float.compare(getZoom(), 10.0f) == 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testZoom_0Point001() {
|
public void testZoom_0Point001() {
|
||||||
reset();
|
reset();
|
||||||
|
|
||||||
imagePanel.setZoomFactor(0.001f);
|
setZoom(0.001f);
|
||||||
|
|
||||||
assertTrue("Zoom factor not set to 0.001x; should be 0.05x",
|
assertTrue("Zoom factor not set to 0.001x; should be 0.05x",
|
||||||
Float.compare(imagePanel.getZoomFactor(), 0.05f) == 0);
|
Float.compare(getZoom(), 0.05f) == 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testZoom_3Point75() {
|
public void testZoom_3Point75() {
|
||||||
reset();
|
reset();
|
||||||
|
|
||||||
imagePanel.setZoomFactor(3.75f);
|
setZoom(3.75f);
|
||||||
|
|
||||||
assertTrue("Zoom factor not set to 3.75x; should be 4.0x",
|
assertTrue("Zoom factor not set to 3.75x; should be 4.0x",
|
||||||
Float.compare(imagePanel.getZoomFactor(), 4.0f) == 0);
|
Float.compare(getZoom(), 4.0f) == 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private void setZoom(float zoom) {
|
||||||
|
runSwing(() -> imagePanel.setZoomFactor(zoom));
|
||||||
|
}
|
||||||
|
|
||||||
|
private float getZoom() {
|
||||||
|
return runSwing(() -> imagePanel.getZoomFactor());
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -416,30 +416,30 @@ public class GraphActionsTest extends AbstractGhidraHeadedIntegrationTest {
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testGetActiveGraph() throws Exception {
|
public void testGetActiveGraph() throws Exception {
|
||||||
|
|
||||||
GraphDisplayBroker broker = tool.getService(GraphDisplayBroker.class);
|
GraphDisplayBroker broker = tool.getService(GraphDisplayBroker.class);
|
||||||
GraphDisplayProvider service = broker.getGraphDisplayProvider("Default Graph Display");
|
GraphDisplayProvider service = broker.getGraphDisplayProvider("Default Graph Display");
|
||||||
GraphDisplay firstDisplay = service.getActiveGraphDisplay();
|
GraphDisplay firstDisplay = service.getActiveGraphDisplay();
|
||||||
assertNotNull(firstDisplay);
|
assertNotNull(firstDisplay);
|
||||||
|
|
||||||
showGraph();
|
showGraph();
|
||||||
GraphDisplay secondDisplay = service.getActiveGraphDisplay();
|
GraphDisplay secondDisplay = service.getActiveGraphDisplay();
|
||||||
assertNotNull(secondDisplay);
|
assertNotNull(secondDisplay);
|
||||||
assertNotSame(firstDisplay, secondDisplay);
|
assertNotSame(firstDisplay, secondDisplay);
|
||||||
|
|
||||||
showGraph();
|
showGraph();
|
||||||
GraphDisplay thirdDisplay = service.getActiveGraphDisplay();
|
GraphDisplay thirdDisplay = service.getActiveGraphDisplay();
|
||||||
assertNotNull(thirdDisplay);
|
assertNotNull(thirdDisplay);
|
||||||
assertNotSame(firstDisplay, thirdDisplay);
|
assertNotSame(firstDisplay, thirdDisplay);
|
||||||
assertNotSame(secondDisplay, thirdDisplay);
|
assertNotSame(secondDisplay, thirdDisplay);
|
||||||
|
|
||||||
close(thirdDisplay);
|
close(thirdDisplay);
|
||||||
close(firstDisplay);
|
close(firstDisplay);
|
||||||
|
|
||||||
GraphDisplay activeDisplay = service.getActiveGraphDisplay();
|
GraphDisplay activeDisplay = service.getActiveGraphDisplay();
|
||||||
assertNotNull(activeDisplay);
|
assertNotNull(activeDisplay);
|
||||||
assertSame(secondDisplay, activeDisplay);
|
assertSame(secondDisplay, activeDisplay);
|
||||||
|
|
||||||
close(secondDisplay);
|
close(secondDisplay);
|
||||||
activeDisplay = service.getActiveGraphDisplay();
|
activeDisplay = service.getActiveGraphDisplay();
|
||||||
assertNull(activeDisplay);
|
assertNull(activeDisplay);
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue