Package ghidra.test
Class AbstractGhidraHeadlessIntegrationTest
java.lang.Object
generic.test.AbstractGTest
generic.test.AbstractGenericTest
generic.test.AbstractGuiTest
docking.test.AbstractDockingTest
ghidra.test.AbstractGhidraHeadlessIntegrationTest
- Direct Known Subclasses:
AbstractGhidraHeadedIntegrationTest
-
Nested Class Summary
Nested classes/interfaces inherited from class generic.test.AbstractGuiTest
AbstractGuiTest.ExceptionHandlingRunner
-
Field Summary
Fields inherited from class generic.test.AbstractGenericTest
concurrentTestExceptionRule, DEFAULT_TEST_TOOL_NAME, DEFAULT_TOOL_NAME, repeatedRule, 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
-
Method Summary
Modifier and TypeMethodDescriptionstatic boolean
Run a command against the specified program within a transaction.static void
void
clearSelection
(PluginTool tool, Program p) protected ApplicationConfiguration
protected ApplicationLayout
static ProgramDB
createDefaultProgram
(String name, String languageString, Object consumer) Creates an in-memory program with the given languagestatic ProgramDB
createDefaultProgram
(String name, String languageString, String compilerSpecID, Object consumer) Creates an in-memory program with the given languagevoid
debugProgramInTool
(Program p, String address) A convenience method that allows you to open the given program in a default tool, navigating to the given address.static boolean
deleteProject
(String directory, String name) static LanguageCompilerSpecPair
getLanguageCompilerSpecPair
(String oldLanguageName) Get the language and compiler spec associated with an old language name string.static LanguageService
Get language service used for testing.static <T extends Plugin>
TgetPlugin
(PluginTool tool, Class<T> c) static Language
static Language
static Language
getUniqueSymbol
(Program program, String name) Returns the global symbol with the given name if and only if it is the only global symbol with that name.getUniqueSymbol
(Program program, String name, Namespace namespace) Returns the symbol in the given namespace with the given name if and only if it is the only symbol in that namespace with that name.static Language
void
goTo
(PluginTool tool, Program p, Address addr) void
goTo
(PluginTool tool, Program p, String addrString) protected void
A place to initialize and needed static propertiesvoid
makeSelection
(PluginTool tool, Program p, AddressRange... ranges) void
makeSelection
(PluginTool tool, Program p, Address from, Address to) void
makeSelection
(PluginTool tool, Program p, AddressSetView addresses) void
makeSelection
(PluginTool tool, Program p, List<Address> addrs) static <E extends Exception>
voidmodifyProgram
(Program p, ExceptionalCallback<E> c) Provides a convenient method for modifying the current program, handling the transaction logic.<R,
E extends Exception>
RmodifyProgram
(Program program, 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 resultstatic void
redo
(DomainObject dobj) Redo the last undone transaction on domain object and wait for all events to be flushed.static void
redo
(DomainObject dobj, boolean wait) Redo the last undone transaction on the domain object and wait for all events to be flushed.static void
redo
(DomainObject dobj, int count) Redo the last 'count' undone transactions on the domain object and wait for all events to be flushed.static <T> void
replaceService
(PluginTool tool, Class<? extends T> service, T replacement) Replaces the given implementations of the provided service class with the given class.toAddressSet
(AddressRange... ranges) toAddressSet
(Address start, Address end) toAddressSet
(Program p, String from, String to) toAddressSet
(List<Address> addrs) static <E extends Exception>
voidtx
(Program p, ExceptionalCallback<E> c) Provides a convenient method for modifying the current program, handling the transaction logic.static <T,
E extends Exception>
Ttx
(Program p, ExceptionalSupplier<T, E> s) Provides a convenient method for modifying the current program, handling the transaction logic and returning a result.static void
undo
(DomainObject dobj) Undo the last transaction on the domain object and wait for all events to be flushed.static void
undo
(DomainObject dobj, boolean wait) Undo the last transaction on the domain object and wait for all events to be flushed.static void
undo
(DomainObject dobj, int count) Undo the last 'count' transactions on the domain object and wait for all events to be flushed.static void
undo
(DomainObject dobj, String name) Undo the last transaction on the domain object and wait for all events to be flushed.void
waitForScriptCompletion
(ScriptTaskListener listener, long timeoutMS) Waits for a launched script to complete by using the given listener.Methods 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, isUseErrorGUI, performAction, performAction, performAction, performAction, performDialogAction, pressButtonByText, pressButtonByText, printOpenWindows, selectPath, selectTabIfAvailable, setErrorGUIEnabled, setToggleActionSelected, setToggleActionSelected, setToggleButtonSelected, setToggleButtonSelected, showProvider, triggerActionKey, triggerActionKey, triggerBackspaceKey, triggerEnter, triggerEscapeKey, triggerKey, triggerKey, triggerKey, triggerText, triggerText, waitForComponentProvider, waitForComponentProvider, waitForComponentProvider, waitForDialogComponent, waitForDialogComponent, waitForDialogComponent, waitForErrorDialog, waitForInfoDialog, waitForJDialog, waitForJDialog, waitForTableModel, waitForTree, waitForUpdateOnChooser, waitForWindow, waitForWindow, waitForWindow, waitForWindowByName, waitForWindowByTitleContaining, writeImage, writeImage
Methods 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, waitForPostedSwingRunnables, waitForSwing, waitForTasks, waitForTasks, yieldToSwing
Methods 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, windowForComponent
Methods 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
-
PROJECT_NAME
-
-
Constructor Details
-
AbstractGhidraHeadlessIntegrationTest
public AbstractGhidraHeadlessIntegrationTest()
-
-
Method Details
-
createApplicationLayout
- Overrides:
createApplicationLayout
in classAbstractDockingTest
- Throws:
IOException
-
createApplicationConfiguration
- Overrides:
createApplicationConfiguration
in classAbstractDockingTest
-
initializeSystemProperties
protected void initializeSystemProperties()Description copied from class:AbstractGenericTest
A place to initialize and needed static properties- Overrides:
initializeSystemProperties
in classAbstractGenericTest
-
cleanDbTestDir
public static void cleanDbTestDir() -
deleteProject
-
getLanguageCompilerSpecPair
public static LanguageCompilerSpecPair getLanguageCompilerSpecPair(String oldLanguageName) throws LanguageNotFoundException Get the language and compiler spec associated with an old language name string. If the language no longer exists, and suitable replacement language will be returned if found. If no language is found, an exception will be thrown.- Parameters:
oldLanguageName
- old language name string- Returns:
- the language compiler and spec
- Throws:
LanguageNotFoundException
- if the language is not found
-
createDefaultProgram
public static ProgramDB createDefaultProgram(String name, String languageString, Object consumer) throws Exception Creates an in-memory program with the given language- Parameters:
name
- the program namelanguageString
- a language string of the formatx86:LE:32:default
consumer
- a consumer for the program- Returns:
- a new program
- Throws:
Exception
- if there is any issue creating the language
-
createDefaultProgram
public static ProgramDB createDefaultProgram(String name, String languageString, String compilerSpecID, Object consumer) throws Exception Creates an in-memory program with the given language- Parameters:
name
- the program namelanguageString
- a language string of the formatx86:LE:32:default
compilerSpecID
- the IDconsumer
- a consumer for the program- Returns:
- a new program
- Throws:
Exception
- if there is any issue creating the language
-
applyCmd
Run a command against the specified program within a transaction. The transaction will be committed unless the command throws a RollbackException.- Parameters:
program
- the programcmd
- the command to apply- Returns:
- result of command applyTo method
- Throws:
RollbackException
- thrown if thrown by command applyTo method
-
tx
Provides a convenient method for modifying the current program, handling the transaction logic.- Parameters:
p
- the programc
- the code to execute- See Also:
-
tx
Provides a convenient method for modifying the current program, handling the transaction logic and returning a result.- Type Parameters:
T
- the return typeE
- the exception type- Parameters:
p
- the programs
- the code to execute- Returns:
- the supplier's return value
- See Also:
-
modifyProgram
Provides a convenient method for modifying the current program, handling the transaction logic. This method is callstx(Program, ExceptionalCallback)
, but helps with semantics.- Parameters:
p
- the programc
- the code to execute- See Also:
-
modifyProgram
public <R,E extends Exception> R modifyProgram(Program program, 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:
program
- the programf
- the function for modifying the program and creating the desired result- Returns:
- the result
- See Also:
-
undo
Undo the last transaction on the domain object and wait for all events to be flushed.- Parameters:
dobj
- The domain object upon which to perform the undo.wait
- if true, wait for undo to fully complete in Swing thread. If a modal dialog may result from this undo, wait should be set false.
-
redo
Redo the last undone transaction on the domain object and wait for all events to be flushed.- Parameters:
dobj
- The domain object upon which to perform the redo.wait
- if true, wait for redo to fully complete in Swing thread. If a modal dialog may result from this redo, wait should be set false.
-
undo
Undo the last transaction on the domain object and wait for all events to be flushed. This method takes the undo item name, which is used to find the undo item. Once found, all items before and including that undo item will be undone.- Parameters:
dobj
- The domain object upon which to perform the undo.name
- the name of the undo item on the stack.
-
undo
Undo the last transaction on the domain object and wait for all events to be flushed.- Parameters:
dobj
- The domain object upon which to perform the undo.
-
redo
Redo the last undone transaction on domain object and wait for all events to be flushed.- Parameters:
dobj
- The domain object upon which to perform the redo.
-
undo
Undo the last 'count' transactions on the domain object and wait for all events to be flushed.- Parameters:
dobj
- The domain object upon which to perform the undo.count
- number of transactions to undo
-
redo
Redo the last 'count' undone transactions on the domain object and wait for all events to be flushed.- Parameters:
dobj
- The domain object upon which to perform the redo.count
- number of transactions to redo
-
getPlugin
-
toAddressSet
-
toAddressSet
-
toAddressSet
-
toAddressSet
-
goTo
-
goTo
-
makeSelection
-
makeSelection
-
makeSelection
-
makeSelection
-
clearSelection
-
getUniqueSymbol
Returns the global symbol with the given name if and only if it is the only global symbol with that name.- Parameters:
program
- the program to search.name
- the name of the global symbol to find.- Returns:
- the global symbol with the given name if and only if it is the only one.
-
getUniqueSymbol
Returns the symbol in the given namespace with the given name if and only if it is the only symbol in that namespace with that name.- Parameters:
program
- the program to search.name
- the name of the symbol to find.namespace
- the parent namespace; may be null- Returns:
- the symbol with the given name if and only if it is the only one in that namespace
-
debugProgramInTool
A convenience method that allows you to open the given program in a default tool, navigating to the given address.Note: this is a blocking operation. Your test will not proceed while this method is sleeping.
Do not leave this call in your test when committing changes.
-
waitForScriptCompletion
Waits for a launched script to complete by using the given listener.- Parameters:
listener
- the listener used to track script progresstimeoutMS
- the max time to wait; failing if exceeded
-
replaceService
Replaces the given implementations of the provided service class with the given class.- Type Parameters:
T
- the service type- Parameters:
tool
- the tool whose services to update (optional)service
- the service to overridereplacement
- the new version of the service
-
getLanguageService
Get language service used for testing.- Returns:
- language service.
-
getSLEIGH_X86_LANGUAGE
-
getSLEIGH_X86_64_LANGUAGE
-
getSLEIGH_8051_LANGUAGE
-
getZ80_LANGUAGE
-