Package docking.test

Class AbstractDockingTest

Direct Known Subclasses:
AbstractGhidraHeadlessIntegrationTest

public abstract class AbstractDockingTest extends AbstractGuiTest
  • Constructor Details

    • AbstractDockingTest

      public AbstractDockingTest()
  • Method Details

    • dockingSetUp

      public void dockingSetUp()
    • dockingTearDown

      public void dockingTearDown()
    • createApplicationLayout

      protected ApplicationLayout createApplicationLayout() throws IOException
      Overrides:
      createApplicationLayout in class AbstractGenericTest
      Throws:
      IOException
    • createApplicationConfiguration

      protected ApplicationConfiguration createApplicationConfiguration()
      Overrides:
      createApplicationConfiguration in class AbstractGuiTest
    • waitForUpdateOnChooser

      public static void waitForUpdateOnChooser(GhidraFileChooser chooser) throws Exception
      Throws:
      Exception
    • getWindowByTitleContaining

      public static Window getWindowByTitleContaining(Window parentWindow, String text)
    • getWindow

      protected static Window getWindow(String title)
    • getWindowByTitle

      protected static Window getWindowByTitle(Window parentWindow, String title)
    • waitForErrorDialog

      public static AbstractErrDialog waitForErrorDialog()
      Waits for the system error dialog to appear
      Returns:
      the dialog
    • waitForInfoDialog

      public static OkDialog waitForInfoDialog()
      Waits for the system info dialog to appear
      Returns:
      the dialog
    • waitForWindow

      public static Window waitForWindow(Class<?> windowClass)
    • waitForWindowByTitleContaining

      public static Window waitForWindowByTitleContaining(String text)
    • waitForWindow

      @Deprecated public static Window waitForWindow(String title, int timeoutMS)
      Deprecated.
      Instead call one of the methods that does not take a timeout (we are standardizing timeouts). The timeouts passed to this method will be ignored in favor of the standard value.
      Waits for a window with the given name.
      Parameters:
      title - The title of the window for which to search
      timeoutMS - The timeout after which this method will wait no more
      Returns:
      The window, if found, null otherwise.
    • waitForWindow

      public static Window waitForWindow(String title)
      Waits for a window with the given name
      Parameters:
      title - The title of the window for which to search
      Returns:
      The window, if found, null otherwise.
    • waitForWindowByName

      public static Window waitForWindowByName(String name)
      Waits for a window with the given name.
      Parameters:
      name - The name of the window for which to search
      Returns:
      The window, if found, null otherwise
    • getMessageText

      public static String getMessageText(Window w)
      Check for and display message component text associated with OptionDialog windows
      Parameters:
      w - any window
      Returns:
      the message string if one can be found; null otherwise
    • getStatusText

      public static String getStatusText(DialogComponentProvider provider)
      Get the dialog provider's status text
      Parameters:
      provider - dialog component provider
      Returns:
      status text
    • closeSaveChangesDialog

      public static void closeSaveChangesDialog()
      Will try to close dialogs prompting for changes to be saved, whether from program changes or from tool config changes.
    • close

      public void close(DialogComponentProvider dialog)
    • close

      public void close(Window w)
    • closeAllWindows

      public static void closeAllWindows(boolean showError)
    • closeAllWindowsAndFrames

      @Deprecated public static void closeAllWindowsAndFrames()
      Deprecated.
      instead call the new closeAllWindows()
      A convenience method to close all of the windows and frames that the current Java windowing environment knows about
    • closeAllWindows

      public static void closeAllWindows()
      A convenience method to close all of the windows and frames that the current Java windowing environment knows about
    • getTitleForWindow

      public static String getTitleForWindow(Window window)
    • waitForJDialog

      public static JDialog waitForJDialog(String title)
      Waits for the JDialog with the given title

      Note: Sometimes the task dialog might have the same title as the dialog you pop up and you want to get yours instead of the one for the task monitor.

      Parameters:
      title - the title of the dialog
      Returns:
      the dialog
    • waitForJDialog

      @Deprecated public static JDialog waitForJDialog(Window window, String title, int timeoutMS)
      Deprecated.
      Waits for the JDialog with the indicated title and that is parented to the indicated window

      Note: Sometimes the task dialog might have the same title as the dialog you pop up and you want to get yours instead of the one for the task monitor.

      Parameters:
      window - the parent window
      title - the title of the dialog
      timeoutMS - Maximum time to wait for the dialog
      Returns:
      the dialog
    • findComponent

      public static <T extends Component> T findComponent(DialogComponentProvider provider, Class<T> desiredClass)
      Returns the first Component of the given type inside of the given dialog
      Parameters:
      provider - the dialog
      desiredClass - the class of the component
      Returns:
      the component; null if none was found
    • waitForDialogComponent

      public static DialogComponentProvider waitForDialogComponent(String title)
      Returns the DialogComponentProvider with the given title. This method is not preferred, but instead you should use a waitForDialogComponent(Class) that takes a class so that you can get the correct return type. This method is meant for clients that need a dialog, but that type is private of package restricted and thus cannot be referenced by a test. Also, code that relies on a title is more subject to breaking when code is refactored; code that relies on class types will get refactored along side the referenced code.

      This method will fail if no dialog can be found

      Parameters:
      title - the title of the desired dialog
      Returns:
      the dialog
    • waitForDialogComponent

      public static <T extends DialogComponentProvider> T waitForDialogComponent(Class<T> ghidraClass)
      Waits for the first window of the given class.
      Parameters:
      ghidraClass - The class of the dialog the user desires
      Returns:
      The first occurrence of a dialog that extends the given ghirdraClass
      See Also:
    • waitForDialogComponent

      @Deprecated public static <T extends DialogComponentProvider> T waitForDialogComponent(Window parentWindow, Class<T> clazz, int timeoutMS)
      Deprecated.
      Instead call one of the methods that does not take a timeout (we are standardizing timeouts). The timeouts passed to this method will be ignored in favor of the standard value.
      Waits for the first window of the given class. This method assumes that the desired dialog is parented by parentWindow.
      Parameters:
      parentWindow - The parent of the desired dialog; may be null
      clazz - The class of the dialog the user desires
      timeoutMS - The max amount of time in milliseconds to wait for the requested dialog to appear.
      Returns:
      The first occurrence of a dialog that extends the given ghirdraClass
    • getDialogComponent

      public static <T extends DialogComponentProvider> T getDialogComponent(Class<T> ghidraClass)
      Gets a dialog component provider of the given type
      Parameters:
      ghidraClass - the class of the desired DialogComponentProvider.
      Returns:
      the dialog or null if it cannot be found
    • getDialogComponentProvider

      protected static <T extends DialogComponentProvider> T getDialogComponentProvider(Window window, Class<T> ghidraClass)
      Gets the dialog component provider that is inside the given window or null if a provider of the given class type is not in the window.
      Parameters:
      window - the window that contains the desired provider.
      ghidraClass - the class of the desired provider
      Returns:
      the desired provider or null if the window does not contain a provider of the given type.
    • getComponentProvider

      public static <T extends ComponentProvider> T getComponentProvider(Class<T> clazz)
      Searches for the first occurrence of a ComponentProvider that is an instance of the given providerClass.
      Parameters:
      clazz - The class of the ComponentProvider to locate
      Returns:
      The component provider, or null if one cannot be found
    • waitForComponentProvider

      public static <T extends ComponentProvider> T waitForComponentProvider(Class<T> clazz)
      Searches for the first occurrence of a ComponentProvider that is an instance of the given providerClass. This method will repeat the search every AbstractGTest.DEFAULT_WAIT_DELAY milliseconds until the provider is found, or the maximum number of searches has been reached, where maximum number of searches = MaxTimeMS / AbstractGTest.DEFAULT_WAIT_DELAY
      Parameters:
      clazz - The class of the ComponentProvider to locate
      Returns:
      The component provider, or null if one cannot be found
    • waitForComponentProvider

      public static <T extends ComponentProvider> T waitForComponentProvider(Class<T> clazz, String title)
      Allows you to find a component provider with the given title. Most plugins will only ever have a single provider. In those cases, use waitForComponentProvider(Class). This version of that method is to allow you to differentiate between multiple instances of a given provider that have different titles.
      Parameters:
      clazz - The class of the ComponentProvider to locate
      title - the title of the component provider
      Returns:
      The component provider, or null if one cannot be found
    • waitForComponentProvider

      @Deprecated public static <T extends ComponentProvider> T waitForComponentProvider(Window parentWindow, Class<T> providerClass, int maxTimeMS)
      Deprecated.
      Instead call one of the methods that does not take a timeout (we are standardizing timeouts). The timeouts passed to this method will be ignored in favor of the standard value.
      Searches for the first occurrence of a ComponentProvider that is an instance of the given providerClass. This method will repeat the search every AbstractGTest.DEFAULT_WAIT_DELAY milliseconds until the provider is found, or the maximum number of searches has been reached, where maximum number of searches = MaxTimeMS / AbstractGTest.DEFAULT_WAIT_DELAY
      Parameters:
      parentWindow - The window that will become the parent window of the provider (this is typically the tool's frame).
      providerClass - The class of the ComponentProvider to locate.
      maxTimeMS - The maximum amount of time to wait. This is an approximation (see above).
      Returns:
      The component provider, or null if one cannot be found
    • getWindows

      protected static Set<Window> getWindows(Window parentWindow)
    • pressButtonByText

      public static void pressButtonByText(DialogComponentProvider provider, String buttonText)
      Finds the button with the indicated TEXT that is a sub-component of the indicated container, and then programmatically presses the button.
      The following is a sample JUnit test use:
              env.showTool();
              OptionDialog dialog = (OptionDialog)env.waitForDialog(OptionDialog.class, 1000);
              assertNotNull(dialog);
              pressButtonByText(dialog, "OK");
       
      Parameters:
      provider - the DialogComponentProvider containing the button.
      buttonText - the text on the desired JButton.
    • pressButtonByText

      public static void pressButtonByText(DialogComponentProvider provider, String buttonText, boolean waitForCompletion)
      Finds the button with the indicated TEXT that is a sub-component of the indicated container, and then programmatically presses the button.
      Parameters:
      provider - the DialogComponentProvider containing the button.
      buttonText - the text on the desired JButton.
      waitForCompletion - if true wait for action to complete before returning, otherwise schedule action to be performed and return immediately.
    • setToggleButtonSelected

      public static void setToggleButtonSelected(Container container, String buttonName, boolean selected)
      Finds the toggle button with the given name inside of the given container and then ensures that the selected state of the button matches selected.

      Note: this works for any instanceof JToggleButton, such as:

      as well as EmptyBorderToggleButtons.
      Parameters:
      container - a container that has the desired button as a descendant
      buttonName - the name of the button (you must set this on the button when it is constructed; if there is no button with the given name found, then this method will search for a button with the given text
      selected - true to toggle the button to selected; false for de-selected
    • setToggleButtonSelected

      public static void setToggleButtonSelected(AbstractButton button, boolean selected)
      Ensures that the selected state of the button matches selected.

      Note: this works for most toggle button implementations which are derived from AbstractButton and relay on AbstractButton.isSelected() and AbstractButton.doClick() for toggling, such as:

      Parameters:
      button - the button to select
      selected - true to toggle the button to selected; false for de-selected
    • assertToggleButtonSelected

      public static void assertToggleButtonSelected(JToggleButton button, boolean selected)
      Checks the selected state of a JToggleButton in a thread safe way.
      Parameters:
      button - the toggle button for which to check the selected state.
      selected - the expected state of the toggle button.
    • assertEnabled

      public static void assertEnabled(JComponent component, boolean enabled)
      Checks the enablement state of a JComponent in a thread safe way.
      Parameters:
      component - the component for which to check the enablement state.
      enabled - the expected enablement state for the component.
    • getActionsByName

      public static Set<DockingActionIf> getActionsByName(Tool tool, String name)
      A helper method to find all actions with the given name
      Parameters:
      tool - the tool containing all system actions
      name - the name to match
      Returns:
      the matching actions; empty list if no matches
    • getActionsByOwner

      public static Set<DockingActionIf> getActionsByOwner(Tool tool, String name)
      A helper method to find all actions with the given owner's name (this will not include reserved system actions)
      Parameters:
      tool - the tool containing all system actions
      name - the owner's name to match
      Returns:
      the matching actions; empty list if no matches
    • getActionsByOwnerAndName

      public static Set<DockingActionIf> getActionsByOwnerAndName(Tool tool, String owner, String name)
      A helper method to find all actions by name, with the given owner's name (this will not include reserved system actions)
      Parameters:
      tool - the tool containing all system actions
      owner - the owner's name
      name - the owner's name to match
      Returns:
      the matching actions; empty list if no matches
    • getAction

      public static DockingActionIf getAction(Tool tool, String name)
      Finds the singular tool action by the given name. If more than one action exists with that name, then an exception is thrown. If you want more than one matching action, the call getActionsByName(Tool, String) instead.

      Note: more specific test case subclasses provide other methods for finding actions when you have an owner name (which is usually the plugin name).

      Parameters:
      tool - the tool containing all system actions
      name - the name to match
      Returns:
      the matching action; null if no matching action can be found
    • getAction

      public static DockingActionIf getAction(Tool tool, String owner, String name)
      Finds the action by the given owner name and action name. If you do not know the owner name, then use the call getActionsByName(Tool, String) instead (this will not include reserved system actions).

      Note: more specific test case subclasses provide other methods for finding actions when you have an owner name (which is usually the plugin name).

      Parameters:
      tool - the tool containing all system actions
      owner - the owner of the action
      name - the name to match
      Returns:
      the matching action; null if no matching action can be found
    • getLocalAction

      public static DockingActionIf getLocalAction(ComponentProvider provider, String actionName)
      Returns the action by the given name that belongs to the given provider
      Parameters:
      provider - the provider
      actionName - the action name
      Returns:
      the action
    • getAction

      public static DockingActionIf getAction(DialogComponentProvider provider, String actionName)
      Returns the given dialog's action that has the given name
      Parameters:
      provider - the dialog provider
      actionName - the name of the action
      Returns:
      the action
    • performAction

      public static void performAction(DockingActionIf action)
      Performs the specified action within the Swing Thread. This method will block until the action completes. Do not use this method if the given actions triggers a modal dialog. Instead, call performAction(DockingActionIf, boolean) with a false value.

      If the action results in a modal dialog, then call performAction(DockingActionIf, boolean) with a value of false.

      Parameters:
      action - action to be performed (event will be null)
    • performAction

      public static void performAction(DockingActionIf action, boolean waitForCompletion)
      Performs the specified action within the Swing Thread. If the action results in a modal dialog, waitForCompletion must be false.
      Parameters:
      action - action to be performed
      waitForCompletion - if true wait for action to complete before returning, otherwise schedule action to be performed and return immediately.
    • performAction

      public static void performAction(DockingActionIf action, ComponentProvider provider, boolean wait)
      Performs the specified action with context within the Swing Thread. If the action results in a modal dialog, waitForCompletion must be false.
      Parameters:
      action - action to be performed
      provider - the component provider from which to get action context; if null, then an empty context will used
      wait - if true wait for action to complete before returning, otherwise schedule action to be performed and return immediately.
    • performDialogAction

      public static void performDialogAction(DockingActionIf action, DialogComponentProvider provider, boolean wait)
      Performs the specified action with context within the Swing Thread. If the action results in a modal dialog, waitForCompletion must be false.
      Parameters:
      action - action to be performed
      provider - the component provider from which to get action context
      wait - if true wait for action to complete before returning, otherwise schedule action to be performed and return immediately.
    • performAction

      public static void performAction(DockingActionIf action, ActionContext context, boolean wait)
      Performs the specified action with context within the Swing Thread. If the action results in a modal dialog, waitForCompletion must be false.
      Parameters:
      action - action to be performed
      context - the context to use with the action
      wait - if true wait for action to complete before returning, otherwise schedule action to be performed and return immediately.
    • setToggleActionSelected

      public static void setToggleActionSelected(ToggleDockingActionIf toggleAction, ActionContext context, boolean selected)
      Ensures the given toggle action is in the given selected state. If it is not, then the action will be performed. This call will wait for the action to finish.
      Parameters:
      toggleAction - the action
      context - the context for the action
      selected - true if the action is be be selected; false for not selected
    • setToggleActionSelected

      public static void setToggleActionSelected(ToggleDockingActionIf toggleAction, ActionContext context, boolean selected, boolean wait)
      Ensures the given toggle action is in the given selected state. If it is not, then the action will be performed. This call will wait for the action to finish.
      Parameters:
      toggleAction - the action
      context - the context for the action
      selected - true if the action is be be selected; false for not selected
      wait - true to wait for the action to finish; false to invoke later
    • findComponentByName

      public static Component findComponentByName(DialogComponentProvider provider, String componentName)
      Searches the component and subcomponents of the indicated provider and returns the component with the specified name.
      Parameters:
      provider - the provider of the component to search
      componentName - the name of the desired component
      Returns:
      the component, or null if not found
    • findButtonByText

      public static JButton findButtonByText(DialogComponentProvider provider, String text)
    • findButtonByIcon

      public static JButton findButtonByIcon(DialogComponentProvider provider, Icon icon)
    • findButtonByActionName

      public static JButton findButtonByActionName(Container container, String name)
    • triggerActionKey

      public static void triggerActionKey(Component c, int modifiers, int keyCode)
      Simulates a user typing a single key. This method should used for the special keyboard keys (ARROW, F1, END, etc) and alpha keys when associated with actions.
      Parameters:
      c - the component that should be the receiver of the key event; the event source
      modifiers - the modifier keys down during event (shift, ctrl, alt, meta) Either extended _DOWN_MASK or old _MASK modifiers should be used, but both models should not be mixed in one event. Use of the extended modifiers is preferred.
      keyCode - the integer code for an actual key.
    • triggerActionKey

      public static void triggerActionKey(Component destination, DockingActionIf action)
      Simulates a user initiated keystroke using the keybinding of the given action
      Parameters:
      destination - the component for the action being executed
      action - The action to simulate pressing
    • triggerEscapeKey

      public static void triggerEscapeKey(Component c)
    • triggerBackspaceKey

      public static void triggerBackspaceKey(Component c)
    • triggerEnter

      public static void triggerEnter(Component c)
      Simulates the user pressing the 'Enter' key on the given text field
      Parameters:
      c - the component
    • triggerText

      public static void triggerText(Component destination, String string)
      Types the indicated string using the triggerKey(Component, int, int, char) method. This method should be used when typing into text components. For example, JTextFields and JTextAreas. All three events are fired, KEY_PRESSED, KEY_TYPED, and KEY_RELEASED.
      Note: Handles the following characters:

      ABCDEFGHIJKLMNOPQRSTUVWXYZ
      abcdefghijklmnopqrstuvwxyz
      `1234567890-=[]\;',./
      ~!@#$%^&*()_+{}|:"<>?

      It also handles '\n', '\t', and '\b'.
      Parameters:
      destination - the component to receive the events
      string - the string to be typed.
    • triggerText

      public static void triggerText(Component destination, String string, BiConsumer<Component,KeyEvent> consumer)
      Types the indicated string using the triggerKey(Component, int, int, char) method. This method should be used when typing into text components. For example, JTextFields and JTextAreas. All three events are fired, KEY_PRESSED, KEY_TYPED, and KEY_RELEASED.
      Note: Handles the following characters:

      ABCDEFGHIJKLMNOPQRSTUVWXYZ
      abcdefghijklmnopqrstuvwxyz
      `1234567890-=[]\;',./
      ~!@#$%^&*()_+{}|:"<>?

      It also handles '\n', '\t', and '\b'.
      Parameters:
      destination - the component to receive the events
      string - the string to be typed.
      consumer - the consumer of the text to be generated
    • triggerKey

      public static void triggerKey(Component c, KeyStroke ks)
      Parameters:
      c - the destination component
      ks - the key stroke
    • triggerKey

      public static void triggerKey(Component c, int modifiers, int keyCode, char keyChar)
      Fires a KeyListener.keyPressed(KeyEvent), KeyListener.keyTyped(KeyEvent) and KeyListener.keyReleased(KeyEvent) for the given key code and char.

      If the key you need is not a character, but is an action, pass KeyEvent.CHAR_UNDEFINED for the keyChar parameter.

      Parameters:
      c - the destination component
      modifiers - any modifiers, like Control
      keyCode - the key code (see KeyEvent's VK_xyz values)
      keyChar - the key char or KeyEvent.CHAR_UNDEFINED
    • triggerKey

      public static void triggerKey(Component c, int modifiers, int keyCode, char keyChar, BiConsumer<Component,KeyEvent> consumer)
    • getClipboardText

      public String getClipboardText() throws Exception
      Gets any current text on the clipboard
      Returns:
      the text on the clipboard; null if no text is on the clipboard
      Throws:
      Exception - if there are any issues copying from the clipboard
    • isUseErrorGUI

      public static boolean isUseErrorGUI()
    • setErrorGUIEnabled

      public static void setErrorGUIEnabled(boolean enable)
      By default Ghidra will use a modal error dialog to display errors when running tests. This method should be used to disable this feature, as opposed to calling:
            Err.setErrorDisplay( new ConsoleErrorDisplay() );
       
      Parameters:
      enable - true to use the GUI; false to use the error console
    • disposeErrorGUI

      public static void disposeErrorGUI()
      Turns off the gui displays for errors. This does not change the "isUseErrorGUI()" value for other tests in the TestCase.
    • showProvider

      public ComponentProvider showProvider(Tool tool, String name)
      Shows the provider by the given name.
      Parameters:
      tool - the tool in which the provider lives
      name - the name of the provider to show
      Returns:
      the newly shown provider
    • closeProvider

      public void closeProvider(ComponentProvider p)
      Closes the given provider. You could just call Tool.removeComponentProvider(ComponentProvider), but some providers have extra logic that happens when ComponentProvider.closeComponent() is called. This will likely change in the future.
      Parameters:
      p - the provider to close
    • clickComponentProvider

      public static Component clickComponentProvider(ComponentProvider provider)
      Performs a single left mouse click in the center of the given provider. This is useful when trying to make a provider the active provider, while making sure that one of the provider's components has focus.
      Parameters:
      provider - The provider to click
      Returns:
      the actual Java JComponent that was clicked.
      See Also:
    • selectTabIfAvailable

      protected static void selectTabIfAvailable(DockableComponent dockableComponent)
      If this dockable component is in a tabbed pane then select the associated tab.
      Parameters:
      dockableComponent - the dockable component of interest
    • getDockableComponent

      protected static DockableComponent getDockableComponent(JComponent component)
      Get the dockable component that contains this component if there is one.
      Parameters:
      component - the component that may be within a dockable component.
      Returns:
      the dockable component or null
    • clickComponentProvider

      public static Component clickComponentProvider(ComponentProvider provider, int button, int x, int y, int clickCount, int modifiers, boolean popupTrigger)
      Clicks the JComponent at the given point from within the given provider.
      Parameters:
      provider - The provider to be clicked.
      button - The mouse button to use (left, center, right)
      x - the x location of the click
      y - the y location of the click
      clickCount - the number of times to click
      modifiers - the modifiers to apply (Ctrl, Alt, etc; 0 is none)
      popupTrigger - true if this click should show a popup menu
      Returns:
      the actual Java JComponent that was clicked
    • printOpenWindows

      public static void printOpenWindows()
      Prints all found windows that are showing, nesting by parent-child relationship.
    • getOpenWindowsAsString

      public static String getOpenWindowsAsString()
      Returns a pretty-print string of all found windows that are showing, nesting by parent-child relationship.
      Returns:
      the result string
    • waitForTableModel

      public static <T> void waitForTableModel(ThreadedTableModel<T,?> model)
    • getNode

      public static GTreeNode getNode(GTree tree, String... path)
    • expandPath

      public static void expandPath(GTree tree, String... path)
    • expandTree

      public static void expandTree(GTree tree, String... path)
    • selectPath

      public static void selectPath(GTree tree, String... path)
    • waitForTree

      public static void waitForTree(GTree gTree)
    • isEnabled

      public static boolean isEnabled(DockingActionIf action)
    • isEnabled

      public static boolean isEnabled(DockingActionIf action, ActionContextProvider contextProvider)
    • isEnabled

      public static boolean isEnabled(AbstractButton button)
    • isSelected

      public static boolean isSelected(AbstractButton button)
    • createContext

      public ActionContext createContext(Object contextObject)
      Creates a generic action context with no provider, with the given context object
      Parameters:
      contextObject - the generic object to put in the context
      Returns:
      the new context
    • createContext

      public ActionContext createContext(ComponentProvider provider, Object contextObject)
      Creates a generic action context with the given provider, with the given context object
      Parameters:
      provider - the provider
      contextObject - the generic object to put in the context
      Returns:
      the new context
    • capture

      public void capture(Component c, String name) throws Exception
      Creates and writes to file an image of the given component. The file will be written to the reports directory (this differs depending upon how the test was run), nested inside a directory structure of the form {test class name}/{test name}. A console statement will be written indicating the location of the written file.
      Parameters:
      c - the component to capture
      name - the file name suffix
      Throws:
      Exception - if there is any issue capturing the component
    • writeImage

      protected void writeImage(Image image, String name) throws IOException
      Throws:
      IOException
    • createScreenImage

      public static Image createScreenImage(Component c) throws AWTException
      Creates a png of the given component by capturing a screenshot of the image. This differs from creating the image by rendering it via a Graphics object.
      Parameters:
      c - the component
      Returns:
      the new image
      Throws:
      AWTException - if there is a problem creating the image
    • createRenderedImage

      public static Image createRenderedImage(Component c)
    • writeImage

      public static void writeImage(Image image, File imageFile) throws IOException
      Writes the given image to the given file
      Parameters:
      image - the image
      imageFile - the file
      Throws:
      IOException - if there is any issue writing the image
    • assertIconsEqual

      public void assertIconsEqual(Icon expected, Icon actual)
      Asserts that the two icons are or refer to the same icon (handles GIcon)
      Parameters:
      expected - the expected icon
      actual - the actual icon
    • getURL

      public URL getURL(Icon icon)
      Gets the URL for the given icon
      Parameters:
      icon - the icon to get a URL for
      Returns:
      the URL for the given icon