Class AbstractScreenShotGenerator

Direct Known Subclasses:
GhidraScreenShotGenerator, TutorialScreenShotGenerator

public abstract class AbstractScreenShotGenerator extends AbstractGhidraHeadedIntegrationTest
  • Field Details

    • SAVE_CREATED_IMAGE_FILE_KEY

      protected static final String SAVE_CREATED_IMAGE_FILE_KEY
      See Also:
    • SAVE_CREATED_IMAGE_FILE

      protected static final boolean SAVE_CREATED_IMAGE_FILE
    • NEW_FILENAME_SUFFIX_KEY

      protected static final String NEW_FILENAME_SUFFIX_KEY
      See Also:
    • DEFAULT_FILENAME_SUFFIX

      protected static final String DEFAULT_FILENAME_SUFFIX
      See Also:
    • NEW_FILENAME_SUFFIX

      protected static final String NEW_FILENAME_SUFFIX
    • DIALOG_HEADER_HEIGHT

      protected static final int DIALOG_HEADER_HEIGHT
      See Also:
    • tool

      public PluginTool tool
    • env

      public TestEnv env
    • program

      public Program program
    • image

      public Image image
  • Constructor Details

    • AbstractScreenShotGenerator

      public AbstractScreenShotGenerator()
  • Method Details

    • newTestEnv

      protected TestEnv newTestEnv() throws Exception
      Throws:
      Exception
    • setUp

      public void setUp() throws Exception
      Throws:
      Exception
    • tearDown

      public void tearDown() throws Exception
      Throws:
      Exception
    • prepareTool

      public void prepareTool()
    • loadProgram

      public void loadProgram() throws Exception
      Throws:
      Exception
    • closeNonProgramArchives

      public void closeNonProgramArchives()
    • loadProgram

      public Program loadProgram(String programName)
    • exit

      public void exit()
    • setUser

      public void setUser(String userName)
    • setDockIcon

      protected void setDockIcon()
    • addr

      public Address addr(long value)
    • setToolSize

      public void setToolSize(int width, int height)
    • setWindowSize

      public void setWindowSize(Window window, int width, int height)
    • performAction

      public void performAction(String actionName, String owner, boolean wait)
    • performDialogAction

      public void performDialogAction(String actionName, boolean wait)
    • performAction

      public void performAction(String actionName, String owner, ComponentProvider contextProvider, boolean wait)
    • showOptions

      public void showOptions(String optionsCategoryName)
    • showProgramOptions

      public void showProgramOptions(String optionsCategoryName)
    • getCursorBounds

      public Rectangle getCursorBounds()
    • pressOkOnDialog

      public void pressOkOnDialog()
    • pressButtonOnDialog

      public void pressButtonOnDialog(String buttonText)
    • captureIsolatedComponent

      public void captureIsolatedComponent(JComponent component, int width, int height)
    • captureComponent

      public Image captureComponent(Component component)
    • captureIsolatedProviderWindow

      public void captureIsolatedProviderWindow(Class<? extends ComponentProvider> clazz, int width, int height)
      The same as captureIsolatedProvider(Class, int, int) except this method will also capture the containing window.
      Parameters:
      clazz - the provider class
      width - the width of the capture
      height - the height of the capture
    • captureIsolatedProvider

      public void captureIsolatedProvider(Class<? extends ComponentProvider> clazz, int width, int height)
    • captureIsolatedProvider

      public void captureIsolatedProvider(ComponentProvider provider, int width, int height)
    • moveProviderToFront

      public void moveProviderToFront(ComponentProvider provider, int width, int height)
    • moveProviderToFront

      public void moveProviderToFront(ComponentProvider provider)
    • moveWindowUp

      public void moveWindowUp(Window window, int yOffset)
    • moveProviderToItsOwnWindow

      public Window moveProviderToItsOwnWindow(ComponentProvider provider)
    • moveProviderToItsOwnWindow

      public Window moveProviderToItsOwnWindow(ComponentProvider provider, int width, int height)
    • getDockableComponent

      public DockableComponent getDockableComponent(ComponentProvider provider)
    • moveProvider

      public void moveProvider(ComponentProvider movee, ComponentProvider relativeTo, WindowPosition position)
    • captureMenu

      public void captureMenu()
    • getPopupMenu

      public JPopupMenu getPopupMenu()
    • captureProvider

      public void captureProvider(Class<? extends ComponentProvider> clazz)
    • captureProvider

      public void captureProvider(ComponentProvider provider)
    • captureProvider

      public void captureProvider(String name)
    • captureProviderWithScreenShot

      public void captureProviderWithScreenShot(ComponentProvider provider)
      Captures the provider by using a screen shot and not by painting the provider directly (as does captureProvider(ComponentProvider)). Use this method if you need to capture the provider along with any popup windows.
      Parameters:
      provider - the provider
    • captureProviderWindow

      public void captureProviderWindow(String name)
      Captures the window, including decorations. This will use a Robot to create a screen capture, which has the effect of getting all items within the window bounds. This method is needed if you wish to capture child windows, like popups/hovers.

      Other capture methods will not use the screen capture mechanism, but rather will directly render the given component. In this case, subordinate windows will not be captured. For example, see captureProvider(Class).

      Parameters:
      name - the provider's name
    • captureProviderWindow

      public void captureProviderWindow(Class<? extends ComponentProvider> clazz)
      Captures the window, including decorations. This will use a Robot to create a screen capture, which has the effect of getting all items within the window bounds. This method is needed if you wish to capture child windows, like popups/hovers.

      Other capture methods will not use the screen capture mechanism, but rather will directly render the given component. In this case, subordinate windows will not be captured. For example, see captureProvider(Class).

      Parameters:
      clazz - the provider's class
    • captureProviderWindow

      public void captureProviderWindow(ComponentProvider provider)
      Captures the window, including decorations. This will use a Robot to create a screen capture, which has the effect of getting all items within the window bounds. This method is needed if you wish to capture child windows, like popups/hovers.

      Other capture methods will not use the screen capture mechanism, but rather will directly render the given component. In this case, subordinate windows will not be captured. For example, see captureProvider(Class).

      Parameters:
      provider - the provider
    • captureProviderWindow

      public void captureProviderWindow(String name, int width, int height)
      Captures the window, including decorations. This will use a Robot to create a screen capture, which has the effect of getting all items within the window bounds. This method is needed if you wish to capture child windows, like popups/hovers.

      Other capture methods will not use the screen capture mechanism, but rather will directly render the given component. In this case, subordinate windows will not be captured. For example, see captureProvider(Class).

      Parameters:
      name - the provider's name
      width - the desired width
      height - the desired height
    • captureProviderWindow

      public void captureProviderWindow(ComponentProvider provider, int width, int height)
      Captures the window, including decorations. This will use a Robot to create a screen capture, which has the effect of getting all items within the window bounds. This method is needed if you wish to capture child windows, like popups/hovers.

      Other capture methods will not use the screen capture mechanism, but rather will directly render the given component. In this case, subordinate windows will not be captured. For example, see captureProvider(Class).

      Parameters:
      provider - the provider's name
      width - the desired width
      height - the desired height
    • showProvider

      public <T extends ComponentProvider> T showProvider(Class<T> clazz)
    • closeProvider

      public void closeProvider(Class<? extends ComponentProvider> clazz)
    • captureActionIcon

      public void captureActionIcon(String actionName)
    • captureIcon

      public void captureIcon(Icon icon)
    • captureDialog

      public void captureDialog()
    • getDialog

      public DialogComponentProvider getDialog()
    • getDialog

      public DialogComponentProvider getDialog(Class<? extends DialogComponentProvider> clazz)
    • captureDialog

      public void captureDialog(int width, int height)
    • paintFix

      protected void paintFix(Window window)
    • captureDialog

      public void captureDialog(String title)
    • captureDialog

      public void captureDialog(Class<? extends DialogComponentProvider> clazz)
    • captureDialog

      public void captureDialog(DialogComponentProvider provider)
    • captureDialog

      public void captureDialog(Class<? extends DialogComponentProvider> clazz, int width, int height)
    • captureWindow

      public void captureWindow()
    • captureWindow

      public void captureWindow(Window window)
    • captureWindow

      public void captureWindow(Window window, int width, int height)
    • captureToolWindow

      public void captureToolWindow(int width, int height)
    • captureDialog

      public void captureDialog(Dialog dialog)
    • captureDialog

      public void captureDialog(Dialog dialog, int width, int height)
    • captureListingField

      public void captureListingField(long address, String fieldName, int padding)
    • generateImage

      public void generateImage(Component c)
    • captureComponents

      public void captureComponents(List<Component> comps)
    • captureMenuBarMenu

      public void captureMenuBarMenu(String menuName, String... subMenuNames)
    • captureMenuBarMenuHierachy

      public void captureMenuBarMenuHierachy(String menuName, String... subMenuNames)
    • captureListingRange

      public void captureListingRange(long start, long end, int width)
    • error

      public void error(Exception e)
    • setListingFieldWidth

      public void setListingFieldWidth(String fieldName, int width)
    • getField

      public Field getField(Point point)
    • leftClickCursor

      public void leftClickCursor()
    • rightClickCursor

      public void rightClickCursor()
    • middleClickCursor

      public void middleClickCursor()
    • doubleClickCursor

      public void doubleClickCursor()
    • selectRow

      public void selectRow(JTable table, int rowIndex)
    • setSelected

      public void setSelected(JToggleButton button, boolean select)
    • hideTableColumn

      public void hideTableColumn(GTable table, String columnName)
    • showMenuBarMenu

      public List<Component> showMenuBarMenu(String menuName, String... submenuNames)
    • showColumnSettings

      public void showColumnSettings(GTable table, String colName)
    • showTableColumn

      public void showTableColumn(GTable table, String columnName)
    • setSelectedAnayzer

      public void setSelectedAnayzer(Object analysisPanel, String analyzerName)
    • showCommentDialog

      public void showCommentDialog(String text)
    • prepareCommentsDialog

      public void prepareCommentsDialog(ghidra.app.plugin.core.comments.CommentsDialog dialog, String annotationText)
    • createBookmark

      public void createBookmark(long address)
    • selectRow

      public void selectRow(JTable table, String searchString)
    • scrollToRow

      public void scrollToRow(JTable table, int row)
    • findRowByPartialText

      public int findRowByPartialText(JTable table, String searchString)
    • performMemorySearch

      public void performMemorySearch(String searchString)
    • removeField

      public void removeField(String fieldName)
    • showAnalysisOptions

      public void showAnalysisOptions(String selectedAnalyzerName)
    • removeFlowArrows

      public void removeFlowArrows()
    • makeSelection

      public void makeSelection(AddressSet addrSet)
    • addSelection

      public void addSelection(long start, long end)
    • makeSelection

      public void makeSelection(long start, long end)
    • go

      public void go(long address)
    • goToListing

      public void goToListing(long address)
    • goToListing

      public void goToListing(long address, boolean scrollToMiddle)
    • goToListing

      public void goToListing(long address, String fieldName, boolean scrollToMiddle)
    • positionCursor

      public void positionCursor(long address)
    • positionCursor

      public void positionCursor(long address, String fieldName)
    • positionListingTop

      public void positionListingTop(long address)
    • positionListingCenter

      public void positionListingCenter(long address)
    • topOfListing

      @Deprecated public void topOfListing(long address)
      Deprecated.
    • loadPlugin

      public Plugin loadPlugin(Class<? extends Plugin> clazz)
    • loadPlugin

      public Plugin loadPlugin(String className)
    • getProvider

      public ComponentProvider getProvider(String name)
    • getProvider

      public <T extends ComponentProvider> T getProvider(Class<T> clazz)
    • getDockableComponent

      public DockableComponent getDockableComponent(Class<? extends ComponentProvider> clazz)
    • findProviderToolBarButton

      public JButton findProviderToolBarButton(ComponentProvider provider, String actionName)
    • address

      @Deprecated public Address address(long value)
      Deprecated.
      use addr(long) instead
      Parameters:
      value - the address's long value
      Returns:
      the new address
    • getBounds

      public Rectangle getBounds(JComponent component)
    • drawRectangleWithDropShadowAround

      public void drawRectangleWithDropShadowAround(JComponent component, Color color, int padding)
    • drawRectangleAround

      public Rectangle drawRectangleAround(JComponent component, Color color, int padding)
    • drawRectangleAround

      public Rectangle drawRectangleAround(JComponent component, JComponent root, Color color, int padding)
      Draws a rectangle around the given component. The root parameter is used to calculate screen coordinates. This allows you to capture a sub-component of a UI, drawing rectangles around children of said sub-component.

      If you are unsure of what to pass for root, the call drawRectangleAround(JComponent, Color, int) instead.

      Parameters:
      component - the component to be en-rectangled
      root - the outermost container widget being displayed; null implies a top-level parent
      color - the rectangle color
      padding - the space between the rectangle and the component; more space makes the component more visible
      Returns:
      the bounds of the drawn rectangle
    • drawRectangle

      public Rectangle drawRectangle(Color c, Rectangle r, int padding, int thickness)
    • drawBorder

      public void drawBorder(Color c)
    • drawRectangle

      public void drawRectangle(Color c, Rectangle rect, int thickness)
    • fillRectangle

      public void fillRectangle(Color c, Rectangle rect)
    • drawOval

      public void drawOval(Color c, Rectangle rect, int thickness)
    • drawText

      public void drawText(String text, Color color, Point start, float size)
    • drawText

      public void drawText(String text, Color color, Point start, Font font)
    • drawLine

      public void drawLine(Color c, int thickness, Point start, Point end)
    • drawArrow

      public void drawArrow(Color c, Point start, Point end)
    • drawArrow

      public void drawArrow(Color c, int thickness, Point start, Point end, int arrowSize)
    • writeFile

      protected void writeFile(File imageFile)
    • readImage

      protected BufferedImage readImage(File imageFile)
    • crop

      public Image crop(Rectangle bounds)
    • padImage

      public Image padImage(Color c, int top, int left, int right, int bottom)
    • placeImagesSideBySide

      public Image placeImagesSideBySide(Image left, Image right)
    • createEmptyImage

      public BufferedImage createEmptyImage(int width, int height)
    • takeSnippet

      public Image takeSnippet(Rectangle bounds)
      Crops a part of the current image, keeping what is inside the given bounds. This method creates a shape such that the top and bottom of the cropped image have a jagged line, looking somewhat like a sideways lightening bolt.
      Parameters:
      bounds - the bounds to keep
      Returns:
      the snippet
    • setDividerPercentage

      public void setDividerPercentage(Class<? extends ComponentProvider> provider1, Class<? extends ComponentProvider> provider2, float percentage)
    • showTab

      public Component showTab(String title)