Package ghidra.test
Class AbstractProgramBasedTest
A convenience base class for creating tests that use the default tool and open a program.
This class will create for you a tool, a
TestEnv and will open the program
specified by getProgramName().
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 override
getProgram() and return it there.
-
Nested Class Summary
Nested classes/interfaces inherited from class generic.test.AbstractGuiTest
AbstractGuiTest.ExceptionHandlingRunner -
Field Summary
FieldsModifier and TypeFieldDescriptionprotected ghidra.app.plugin.core.codebrowser.CodeBrowserPluginprotected TestEnvprotected Programprotected PluginToolFields inherited from class ghidra.test.AbstractGhidraHeadlessIntegrationTest
PROJECT_NAMEFields inherited from class generic.test.AbstractGenericTest
concurrentTestExceptionRule, DEFAULT_TEST_TOOL_NAME, DEFAULT_TOOL_NAME, ruleChain, TESTDATA_DIRECTORY_NAME, watchmanFields inherited from class generic.test.AbstractGTest
BATCH_MODE, DEFAULT_WAIT_DELAY, DEFAULT_WAIT_TIMEOUT, DEFAULT_WINDOW_TIMEOUT, ignoreUnfinishedRule, PARALLEL_MODE, PRIVATE_LONG_WAIT_TIMEOUT, repeatedRule, testName -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionaddr(long offset) addrs(long... offsets) voidassertCurrentAddress(Address expected) <R,E extends Exception>
RProvides a convenient method for modifying the current program, handling the transaction logic and returning a new item as a result.protected ListingFieldReturns a field by the given name at the given address.protected ListingFieldgetField(String fieldName, int occurrence, BigInteger index, FieldPanel fieldPanel) protected ProgramOverride this method if you need to build your own program.protected StringvoidgoTo(long offset) voidvoidprotected void<E extends Exception>
voidmodifyProgram(ExceptionalConsumer<Program, E> callback) Provides a convenient method for modifying the current program, handling the transaction logic.range(long from, long to) voidshowProvider(String name) voidtearDown()toAddressSet(long... offsets) Methods inherited from class ghidra.test.AbstractGhidraHeadedIntegrationTest
addPlugin, click, click, click, click, createApplicationConfiguration, createApplicationLayout, getAction, getPluginByName, saveTool, showDialogWithoutBlocking, showTool, waitForBusyTool, waitForProgramMethods inherited from class ghidra.test.AbstractGhidraHeadlessIntegrationTest
applyCmd, cleanDbTestDir, clearSelection, createDefaultProgram, createDefaultProgram, 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, modifyProgram, modifyProgram, redo, redo, redo, replaceService, toAddressSet, toAddressSet, toAddressSet, toAddressSet, tx, tx, tx, undo, undo, undo, undo, waitForScriptCompletionMethods inherited from class docking.test.AbstractDockingTest
assertEnabled, assertIconsEqual, assertToggleButtonSelected, capture, clickComponentProvider, clickComponentProvider, close, close, closeAllWindows, closeAllWindows, closeAllWindowsAndFrames, closeProvider, closeSaveChangesDialog, createContext, createContext, createRenderedImage, createScreenImage, disposeErrorGUI, dockingSetUp, dockingTearDown, expandPath, expandTree, findButtonByActionName, findButtonByIcon, findButtonByName, findButtonByText, findComponent, findComponentByName, getAction, getAction, getAction, getActionsByName, getActionsByOwner, getActionsByOwnerAndName, getClipboardText, getComponentProvider, getDialogComponent, getDialogComponentProvider, getDockableComponent, getLocalAction, getMessageText, getNode, getOpenWindowsAsString, getStatusText, getTitleForWindow, getURL, getWindow, getWindowByTitle, getWindowByTitleContaining, getWindows, isEnabled, isEnabled, isEnabled, isSelected, isToggleButttonSelected, isUseErrorGUI, performAction, performAction, performAction, performAction, performDialogAction, pressButtonByText, pressButtonByText, printOpenWindows, selectPath, selectTabIfAvailable, setErrorGUIEnabled, setToggleActionSelected, setToggleActionSelected, setToggleButtonSelected, setToggleButtonSelected, showProvider, triggerActionKey, triggerActionKey, triggerBackspace, triggerEnter, triggerEscape, triggerKey, triggerKey, triggerKey, triggerText, triggerText, waitForComponentProvider, waitForComponentProvider, waitForComponentProvider, waitForDialogComponent, waitForDialogComponent, waitForDialogComponent, waitForErrorDialog, waitForInfoDialog, waitForJDialog, waitForJDialog, waitForTableModel, waitForTree, waitForUpdateOnChooser, waitForWindow, waitForWindow, waitForWindow, waitForWindowByName, waitForWindowByTitleContaining, writeImage, writeImageMethods inherited from class generic.test.AbstractGuiTest
assertColorsEqual, clickListRange, clickMouse, clickMouse, clickTableCell, clickTableRange, doubleClick, dragMouse, editCell, executeOnSwingWithoutBlocking, findAbstractButtonByName, findAbstractButtonByText, findButtonByIcon, findButtonByName, findButtonByText, findComponent, findComponent, findComponentByName, findComponentByName, findComponents, findComponents, findOwnedWindows, findPathToText, findTreePathToText, fixupGUI, getAllWindows, getRenderedTableCellValue, getSwing, getText, leftClick, middleClick, moveMouse, postEvent, pressButton, pressButton, pressButtonByName, pressButtonByName, pressButtonByText, pressButtonByText, printMemory, privatewaitForSwing_SwingSafe, rightClick, runSwing, runSwing, runSwing, runSwingLater, runSwingWithException, setComboBoxSelection, setText, waitForExpiringSwingTimers, waitForPostedSwingRunnables, waitForSwing, waitForTasks, waitForTasks, yieldToSwingMethods inherited from class generic.test.AbstractGenericTest
createStackTraceForAllThreads, createTempDirectory, createTempFile, createTempFile, createTempFileForTest, createTempFileForTest, createTempFilePath, createTempFilePath, deleteMatchingTempFiles, deleteSimilarTempFiles, findTestDataFile, getDebugFileDirectory, getFontMetrics, getInstanceField, getInstanceFieldByClassType, getTestDataDir, getTestDataDirectory, getTestDataFile, hasTestFailed, initializeLayout, invokeConstructor, invokeInstanceMethod, invokeInstanceMethod, loadTextResource, loadTextResource, resetLogging, setErrorsExpected, setInstanceField, setLogLevel, setLogLevel, testFailed, toString, windowForComponentMethods inherited from class generic.test.AbstractGTest
assertArraysEqualOrdered, assertArraysEqualUnordered, assertArraysEqualUnordered, assertContainsExactly, assertContainsExactly, assertContainsString, assertContainsStringIgnoringCase, assertListEqualOrdered, assertListEqualOrdered, assertListEqualsArrayOrdered, assertListEqualsArrayUnordered, assertListEqualUnordered, bytes, failWithException, getName, getRandomInt, getRandomInt, getRandomString, getRandomString, getTestDirectoryPath, sleep, waitFor, waitFor, waitFor, waitFor, waitFor, waitForCondition, waitForCondition, waitForCondition, waitForConditionWithoutFailing, waitForValue, waitForValueWithoutFailing
-
Field Details
-
env
-
tool
-
program
-
codeBrowser
protected ghidra.app.plugin.core.codebrowser.CodeBrowserPlugin codeBrowser
-
-
Constructor Details
-
AbstractProgramBasedTest
public AbstractProgramBasedTest()
-
-
Method Details
-
getProgramName
-
initialize
- Throws:
Exception
-
getProgram
Override this method if you need to build your own program.- Returns:
- the program to use for this test.
- Throws:
Exception- if an exception is thrown opening the program
-
tearDown
- Throws:
Exception
-
assertCurrentAddress
-
addr
-
addr
-
addr
-
addr
-
goTo
public void goTo(long offset) -
goTo
-
range
-
showProvider
-
function
-
addrs
-
toAddressSet
-
addrs
-
goTo
-
modifyProgram
Provides a convenient method for modifying the current program, handling the transaction logic.- Parameters:
callback- the code to execute
-
createInProgram
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
-
getField
Returns a field by the given name at the given address. Clients can use the convention that field factory classes specify a public static field named 'FIELD_NAME' to choose the desired field name.Note: you will have to perform a
goTo()to trigger the view to load the given field.- Parameters:
a- the addressfieldName- the field name- Returns:
- the field
-
getField
protected ListingField getField(String fieldName, int occurrence, BigInteger index, FieldPanel fieldPanel)
-