Package ghidra.test
Class AbstractProgramBasedTest
- java.lang.Object
-
public abstract class AbstractProgramBasedTest extends AbstractGhidraHeadedIntegrationTest
A convenience base class for creating tests that use the default tool and open a program. This class will create for you a tool, aTestEnv
and will open the program specified bygetProgramName()
.To use this class, you must call
initialize()
from your test or setUp method.Note: if you are loading a pre-existing program, then simply override
getProgramName()
. Alternatively, if you are building a program, then overridegetProgram()
and return it there.
-
-
Nested Class Summary
-
Nested classes/interfaces inherited from class generic.test.AbstractGenericTest
AbstractGenericTest.ExceptionHandlingRunner
-
-
Field Summary
Fields Modifier and Type Field Description protected ghidra.app.plugin.core.codebrowser.CodeBrowserPlugin
codeBrowser
protected TestEnv
env
protected Program
program
protected PluginTool
tool
-
Fields inherited from class ghidra.test.AbstractGhidraHeadlessIntegrationTest
PROJECT_NAME
-
Fields inherited from class generic.test.AbstractGenericTest
concurrentTestExceptionRule, DEFAULT_TEST_TOOL_NAME, DEFAULT_TOOL_NAME, ruleChain, TESTDATA_DIRECTORY_NAME, watchman
-
Fields inherited from class generic.test.AbstractGTest
BATCH_MODE, DEFAULT_WAIT_DELAY, DEFAULT_WAIT_TIMEOUT, DEFAULT_WINDOW_TIMEOUT, PARALLEL_MODE, PRIVATE_LONG_WAIT_TIMEOUT, testName
-
-
Constructor Summary
Constructors Constructor Description AbstractProgramBasedTest()
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description Address
addr(long offset)
Address
addr(Program p, long offset)
Address
addr(Program p, java.lang.String offset)
Address
addr(java.lang.String offset)
java.util.List<Address>
addrs(long... offsets)
java.util.List<Address>
addrs(Address... addrs)
void
assertCurrentAddress(Address expected)
<R,E extends java.lang.Exception>
RcreateInProgram(ExceptionalFunction<Program,R,E> f)
Provides a convenient method for modifying the current program, handling the transaction logic and returning a new item as a result.Function
function(Address addr)
protected Program
getProgram()
Override this method if you need to build your own program.protected java.lang.String
getProgramName()
void
goTo(long offset)
void
goTo(Address a)
void
goTo(java.lang.String offset)
protected void
initialize()
<E extends java.lang.Exception>
voidmodifyProgram(ExceptionalConsumer<Program,E> callback)
Provides a convenient method for modifying the current program, handling the transaction logic.AddressRange
range(long from, long to)
void
showProvider(java.lang.String name)
void
tearDown()
AddressSet
toAddressSet(long... offsets)
-
Methods inherited from class ghidra.test.AbstractGhidraHeadedIntegrationTest
addPlugin, click, click, click, createApplicationConfiguration, createApplicationLayout, getAction, getPluginByName, saveTool, showDialogWithoutBlocking, showTool, waitForBusyTool, waitForProgram
-
Methods inherited from class ghidra.test.AbstractGhidraHeadlessIntegrationTest
applyCmd, createDefaultProgram, createDefaultProgram, createInProgram, debugProgramInTool, deleteProject, getLanguageCompilerSpecPair, getLanguageService, getPlugin, getSLEIGH_8051_LANGUAGE, getSLEIGH_X86_64_LANGUAGE, getSLEIGH_X86_LANGUAGE, getUniqueSymbol, getUniqueSymbol, getZ80_LANGUAGE, goTo, goTo, initializeSystemProperties, makeSelection, makeSelection, makeSelection, makeSelection, makeSelection, modifyProgram, redo, redo, redo, replaceService, toAddressSet, toAddressSet, toAddressSet, tx, undo, undo, undo, waitForScriptCompletion
-
Methods inherited from class docking.test.AbstractDockingTest
assertEnabled, assertToggleButtonSelected, capture, checkMessageDisplay, clickComponentProvider, clickComponentProvider, close, close, closeAllWindows, closeAllWindows, closeAllWindowsAndFrames, closeProvider, closeSaveChangesDialog, createContext, createContext, createRenderedImage, createScreenImage, disposeErrorGUI, dockingSetUp, dockingTearDown, expandPath, expandTree, findButtonByActionName, findButtonByIcon, findButtonByText, findComponent, findComponentByName, getAction, getAction, getAction, getActionsByName, getActionsByOwner, getActionsByOwnerAndName, getClipboardText, getComponentProvider, getDialogComponent, getDialogComponentProvider, getDockableComponent, getLocalAction, getNode, getOpenWindowsAsString, getStatusText, getTitleForWindow, getWindow, getWindowByTitle, getWindowByTitleContaining, getWindows, isEnabled, isEnabled, isSelected, isUseErrorGUI, performAction, performAction, performAction, performAction, performDialogAction, pressButtonByText, pressButtonByText, printOpenWindows, selectPath, selectTabIfAvailable, setErrorGUIEnabled, setErrorsExpected, setToggleActionSelected, setToggleActionSelected, setToggleButtonSelected, setToggleButtonSelected, showProvider, triggerActionKey, triggerActionKey, triggerBackspaceKey, triggerEnter, triggerEscapeKey, triggerKey, triggerKey, triggerText, triggerText, waitForComponentProvider, waitForComponentProvider, waitForDialogComponent, waitForDialogComponent, waitForDialogComponent, waitForJDialog, waitForJDialog, waitForTableModel, waitForTree, waitForUpdateOnChooser, waitForWindow, waitForWindow, waitForWindow, waitForWindow, waitForWindowByName, waitForWindowByTitleContaining, waitForWindowByTitleContaining, writeImage, writeImage
-
Methods inherited from class generic.test.AbstractGenericTest
clickMouse, clickMouse, clickTableCell, createStackTraceForAllThreads, createTempDirectory, createTempFile, createTempFile, createTempFileForTest, createTempFileForTest, createTempFilePath, createTempFilePath, deleteMatchingTempFiles, deleteSimilarTempFiles, doubleClick, dragMouse, editCell, executeOnSwingWithoutBlocking, findAbstractButtonByName, findAbstractButtonByText, findButtonByIcon, findButtonByText, findComponent, findComponent, findComponentByName, findComponentByName, findComponentsByName, findOwnedWindows, findPathToText, findTestDataFile, findTreePathToText, fixupGUI, getAllWindows, getDebugFileDirectory, getInstanceField, getInstanceFieldByClassType, getLocalResourceFile, getRenderedTableCellValue, getTestDataDir, getTestDataDirectory, getTestDataFile, getText, hasTestFailed, initializeLayout, invokeConstructor, invokeInstanceMethod, invokeInstanceMethod, leftClick, loadTextResource, loadTextResource, middleClick, moveMouse, postEvent, pressButton, pressButton, pressButtonByName, pressButtonByName, pressButtonByText, pressButtonByText, printMemory, privateWaitForPostedSwingRunnables_SwingSafe, rightClick, runSwing, runSwing, runSwing, runSwingWithExceptions, setComboBoxSelection, setInstanceField, setText, testFailed, toString, waitForPostedSwingRunnables, waitForSwing, waitForTasks, windowForComponent, yieldToSwing
-
Methods inherited from class generic.test.AbstractGTest
assertArraysEqualOrdered, assertArraysEqualUnordered, assertArraysEqualUnordered, assertContainsExactly, assertContainsExactly, assertListEqualOrdered, assertListEqualOrdered, assertListEqualsArrayOrdered, assertListEqualsArrayUnordered, assertListEqualUnordered, failWithException, getName, getRandomInt, getRandomInt, getRandomString, getRandomString, getTestDirectoryPath, sleep, waitFor, waitFor, waitFor, waitFor, waitForCondition, waitForCondition, waitForCondition, waitForConditionWithoutFailing, waitForValue, waitForValueWithoutFailing
-
-
-
-
Field Detail
-
env
protected TestEnv env
-
tool
protected PluginTool tool
-
program
protected Program program
-
codeBrowser
protected ghidra.app.plugin.core.codebrowser.CodeBrowserPlugin codeBrowser
-
-
Method Detail
-
getProgramName
protected java.lang.String getProgramName()
-
initialize
protected void initialize() throws java.lang.Exception
- Throws:
java.lang.Exception
-
getProgram
protected Program getProgram() throws java.lang.Exception
Override this method if you need to build your own program.- Returns:
- the program to use for this test.
- Throws:
java.lang.Exception
- if an exception is thrown opening the program
-
tearDown
public void tearDown() throws java.lang.Exception
- Throws:
java.lang.Exception
-
assertCurrentAddress
public void assertCurrentAddress(Address expected)
-
addr
public Address addr(long offset)
-
addr
public Address addr(java.lang.String offset)
-
goTo
public void goTo(long offset)
-
goTo
public void goTo(java.lang.String offset)
-
range
public AddressRange range(long from, long to)
-
showProvider
public void showProvider(java.lang.String name)
-
addrs
public java.util.List<Address> addrs(long... offsets)
-
toAddressSet
public AddressSet toAddressSet(long... offsets)
-
goTo
public void goTo(Address a)
-
modifyProgram
public <E extends java.lang.Exception> void modifyProgram(ExceptionalConsumer<Program,E> callback)
Provides a convenient method for modifying the current program, handling the transaction logic.- Parameters:
callback
- the code to execute
-
createInProgram
public <R,E extends java.lang.Exception> R createInProgram(ExceptionalFunction<Program,R,E> f)
Provides a convenient method for modifying the current program, handling the transaction logic and returning a new item as a result.- Parameters:
f
- the function for modifying the program and creating the desired result- Returns:
- the result
-
-