Package ghidra.test
Class AbstractGhidraHeadlessIntegrationTest
- java.lang.Object
-
- generic.test.AbstractGTest
-
- generic.test.AbstractGenericTest
-
- docking.test.AbstractDockingTest
-
- ghidra.test.AbstractGhidraHeadlessIntegrationTest
-
- Direct Known Subclasses:
AbstractGhidraHeadedIntegrationTest
public abstract class AbstractGhidraHeadlessIntegrationTest extends AbstractDockingTest
-
-
Nested Class Summary
-
Nested classes/interfaces inherited from class generic.test.AbstractGenericTest
AbstractGenericTest.ExceptionHandlingRunner
-
-
Field Summary
Fields Modifier and Type Field Description static java.lang.StringPROJECT_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 AbstractGhidraHeadlessIntegrationTest()
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description static booleanapplyCmd(Program program, Command cmd)Run a command against the specified program within a transaction.protected ApplicationConfigurationcreateApplicationConfiguration()protected ApplicationLayoutcreateApplicationLayout()static ProgramDBcreateDefaultProgram(java.lang.String name, java.lang.String languageString, java.lang.Object consumer)Creates an in-memory program with the given languagestatic ProgramDBcreateDefaultProgram(java.lang.String name, java.lang.String languageString, java.lang.String compilerSpecID, java.lang.Object consumer)Creates an in-memory program with the given language<R,E extends java.lang.Exception>
RcreateInProgram(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 resultvoiddebugProgramInTool(Program p, java.lang.String address)A convenience method that allows you to open the given program in a default tool, navigating to the given address.static booleandeleteProject(java.lang.String directory, java.lang.String name)static LanguageCompilerSpecPairgetLanguageCompilerSpecPair(java.lang.String oldLanguageName)Get the language and compiler spec associated with an old language name string.static LanguageServicegetLanguageService()Get language service used for testing.static <T extends Plugin>
TgetPlugin(PluginTool tool, java.lang.Class<T> c)static LanguagegetSLEIGH_8051_LANGUAGE()static LanguagegetSLEIGH_X86_64_LANGUAGE()static LanguagegetSLEIGH_X86_LANGUAGE()SymbolgetUniqueSymbol(Program program, java.lang.String name)Returns the global symbol with the given name if and only if it is the only global symbol with that name.SymbolgetUniqueSymbol(Program program, java.lang.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 LanguagegetZ80_LANGUAGE()voidgoTo(PluginTool tool, Program p, Address addr)voidgoTo(PluginTool tool, Program p, java.lang.String addrString)protected voidinitializeSystemProperties()A place to initialize and needed static propertiesvoidmakeSelection(PluginTool tool, Program p, Address... addrs)voidmakeSelection(PluginTool tool, Program p, AddressRange... ranges)voidmakeSelection(PluginTool tool, Program p, Address from, Address to)voidmakeSelection(PluginTool tool, Program p, AddressSetView addresses)voidmakeSelection(PluginTool tool, Program p, java.util.List<Address> addrs)<E extends java.lang.Exception>
voidmodifyProgram(Program program, ExceptionalConsumer<Program,E> callback)Provides a convenient method for modifying the current program, handling the transaction logicstatic voidredo(UndoableDomainObject dobj)Redo the last undone transaction on domain object and wait for all events to be flushed.static voidredo(UndoableDomainObject dobj, boolean wait)Redo the last undone transaction on the domain object and wait for all events to be flushed.static voidredo(UndoableDomainObject dobj, int count)Redo the last 'count' undone transactions on the domain object and wait for all events to be flushed.static <T> voidreplaceService(PluginTool tool, java.lang.Class<? extends T> service, T replacement)Replaces the given implementations of the provided service class with the given class.AddressSettoAddressSet(AddressRange... ranges)AddressSettoAddressSet(Address start, Address end)AddressSettoAddressSet(java.util.List<Address> addrs)static <E extends java.lang.Exception>
voidtx(Program p, ExceptionalCallback<E> c)static voidundo(UndoableDomainObject dobj)Undo the last transaction on the domain object and wait for all events to be flushed.static voidundo(UndoableDomainObject dobj, boolean wait)Undo the last transaction on the domain object and wait for all events to be flushed.static voidundo(UndoableDomainObject dobj, int count)Undo the last 'count' transactions on the domain object and wait for all events to be flushed.voidwaitForScriptCompletion(ScriptTaskListener listener, long timeoutMS)Waits for a launched script to complete by using the given listener.-
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
-
-
-
-
Method Detail
-
createApplicationLayout
protected ApplicationLayout createApplicationLayout()
- Overrides:
createApplicationLayoutin classAbstractDockingTest
-
createApplicationConfiguration
protected ApplicationConfiguration createApplicationConfiguration()
- Overrides:
createApplicationConfigurationin classAbstractDockingTest
-
initializeSystemProperties
protected void initializeSystemProperties()
Description copied from class:AbstractGenericTestA place to initialize and needed static properties- Overrides:
initializeSystemPropertiesin classAbstractGenericTest
-
deleteProject
public static boolean deleteProject(java.lang.String directory, java.lang.String name)
-
getLanguageCompilerSpecPair
public static LanguageCompilerSpecPair getLanguageCompilerSpecPair(java.lang.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
-
createDefaultProgram
public static ProgramDB createDefaultProgram(java.lang.String name, java.lang.String languageString, java.lang.Object consumer) throws java.lang.Exception
Creates an in-memory program with the given language- Parameters:
name- the program namelanguageString- a language string of the format x86:LE:32:defaultconsumer- a consumer for the program- Returns:
- a new program
- Throws:
java.lang.Exception- if there is any issue creating the language
-
createDefaultProgram
public static ProgramDB createDefaultProgram(java.lang.String name, java.lang.String languageString, java.lang.String compilerSpecID, java.lang.Object consumer) throws java.lang.Exception
Creates an in-memory program with the given language- Parameters:
name- the program namelanguageString- a language string of the format x86:LE:32:defaultcompilerSpecID- the IDconsumer- a consumer for the program- Returns:
- a new program
- Throws:
java.lang.Exception- if there is any issue creating the language
-
applyCmd
public static boolean applyCmd(Program program, Command cmd) throws RollbackException
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
public static <E extends java.lang.Exception> void tx(Program p, ExceptionalCallback<E> c) throws E extends java.lang.Exception
- Throws:
E extends java.lang.Exception
-
modifyProgram
public <E extends java.lang.Exception> void modifyProgram(Program program, ExceptionalConsumer<Program,E> callback)
Provides a convenient method for modifying the current program, handling the transaction logic- Parameters:
program- the programcallback- the code to execute
-
createInProgram
public <R,E extends java.lang.Exception> R createInProgram(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
-
undo
public static void undo(UndoableDomainObject dobj, boolean wait)
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
public static void redo(UndoableDomainObject dobj, boolean wait)
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
public static void undo(UndoableDomainObject dobj)
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
public static void redo(UndoableDomainObject dobj)
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
public static void undo(UndoableDomainObject dobj, int count)
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
public static void redo(UndoableDomainObject dobj, int count)
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
public static <T extends Plugin> T getPlugin(PluginTool tool, java.lang.Class<T> c)
-
toAddressSet
public AddressSet toAddressSet(java.util.List<Address> addrs)
-
toAddressSet
public AddressSet toAddressSet(Address start, Address end)
-
toAddressSet
public AddressSet toAddressSet(AddressRange... ranges)
-
goTo
public void goTo(PluginTool tool, Program p, Address addr)
-
goTo
public void goTo(PluginTool tool, Program p, java.lang.String addrString)
-
makeSelection
public void makeSelection(PluginTool tool, Program p, java.util.List<Address> addrs)
-
makeSelection
public void makeSelection(PluginTool tool, Program p, Address from, Address to)
-
makeSelection
public void makeSelection(PluginTool tool, Program p, Address... addrs)
-
makeSelection
public void makeSelection(PluginTool tool, Program p, AddressRange... ranges)
-
makeSelection
public void makeSelection(PluginTool tool, Program p, AddressSetView addresses)
-
getUniqueSymbol
public Symbol getUniqueSymbol(Program program, java.lang.String name)
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
public Symbol getUniqueSymbol(Program program, java.lang.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.- 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
public void debugProgramInTool(Program p, java.lang.String address) throws java.lang.Exception
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.
- Parameters:
p- the programaddress- the address- Throws:
java.lang.Exception- if there is an issue create aTestEnv
-
waitForScriptCompletion
public void waitForScriptCompletion(ScriptTaskListener listener, long timeoutMS)
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
public static <T> void replaceService(PluginTool tool, java.lang.Class<? extends T> service, T replacement)
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
public static LanguageService getLanguageService()
Get language service used for testing.- Returns:
- language service.
-
getSLEIGH_X86_LANGUAGE
public static Language getSLEIGH_X86_LANGUAGE()
-
getSLEIGH_X86_64_LANGUAGE
public static Language getSLEIGH_X86_64_LANGUAGE()
-
getSLEIGH_8051_LANGUAGE
public static Language getSLEIGH_8051_LANGUAGE()
-
getZ80_LANGUAGE
public static Language getZ80_LANGUAGE()
-
-