mirror of
https://github.com/NationalSecurityAgency/ghidra.git
synced 2024-11-23 12:42:30 +00:00
Merge remote-tracking branch 'origin/GP-0-dragonmacher-test-fixes-6-11-24-patch' into patch
This commit is contained in:
commit
51c7994114
@ -197,9 +197,8 @@ public class DecompilerNavigationTest extends AbstractDecompilerTest {
|
|||||||
public void testFunctionNavigation_WithAViewThatCachesTheLastValidFunction() throws Exception {
|
public void testFunctionNavigation_WithAViewThatCachesTheLastValidFunction() throws Exception {
|
||||||
|
|
||||||
//
|
//
|
||||||
// This is testing the case where the user starts on a function foo(). Ancillary windows
|
// This is testing the case where the user starts on a function foo(). When the user clicks
|
||||||
// will display tool, such as a decompiled view. Now, if the user clicks to a
|
// away to a non-function location, such as data, the window may still show foo(), even
|
||||||
// non-function location, such as data, the ancillary window may still show foo(), even
|
|
||||||
// though the user is no longer in foo. At this point, if the user wishes to go to the
|
// though the user is no longer in foo. At this point, if the user wishes to go to the
|
||||||
// previous function, then from the ancillary window's perspective, it is the function
|
// previous function, then from the ancillary window's perspective, it is the function
|
||||||
// that came before foo().
|
// that came before foo().
|
||||||
@ -212,12 +211,13 @@ public class DecompilerNavigationTest extends AbstractDecompilerTest {
|
|||||||
goTo(f1);
|
goTo(f1);
|
||||||
goTo(f2);
|
goTo(f2);
|
||||||
goTo(nonFunctionAddress);
|
goTo(nonFunctionAddress);
|
||||||
|
waitForDecompiler();
|
||||||
|
|
||||||
String title = provider.getTitle();
|
String title = provider.getTitle();
|
||||||
assertTrue("Decompiler did not retain last function visited", title.contains("sscanf"));
|
assertTrue("Decompiler did not retain last function visited. " +
|
||||||
|
"Expected sscanf, but was '%s'".formatted(title), title.contains("sscanf"));
|
||||||
|
|
||||||
provider.requestFocus();
|
focusDecompiler();
|
||||||
waitForSwing();
|
|
||||||
|
|
||||||
//
|
//
|
||||||
// The Decompiler is focused, showing 'entry'. Going back while it is focused should go
|
// The Decompiler is focused, showing 'entry'. Going back while it is focused should go
|
||||||
@ -227,22 +227,6 @@ public class DecompilerNavigationTest extends AbstractDecompilerTest {
|
|||||||
assertCurrentAddress(f1);
|
assertCurrentAddress(f1);
|
||||||
}
|
}
|
||||||
|
|
||||||
private void previousFunction() {
|
|
||||||
NextPrevAddressPlugin plugin = env.getPlugin(NextPrevAddressPlugin.class);
|
|
||||||
DockingAction previousFunctionAction =
|
|
||||||
(DockingAction) getInstanceField("previousFunctionAction", plugin);
|
|
||||||
|
|
||||||
ActionContext context = provider.getActionContext(null);
|
|
||||||
assertTrue(previousFunctionAction.isEnabledForContext(context));
|
|
||||||
performAction(previousFunctionAction, context, true);
|
|
||||||
waitForSwing();
|
|
||||||
}
|
|
||||||
|
|
||||||
private void assertListingAddress(Address expected) {
|
|
||||||
waitForCondition(() -> expected.equals(codeBrowser.getCurrentLocation().getAddress()),
|
|
||||||
"The Listing is not at the expected address");
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void assertCurrentAddress(Address expected) {
|
public void assertCurrentAddress(Address expected) {
|
||||||
codeBrowser.updateNow();
|
codeBrowser.updateNow();
|
||||||
@ -255,6 +239,27 @@ public class DecompilerNavigationTest extends AbstractDecompilerTest {
|
|||||||
}, "Listing is not at the expected address");
|
}, "Listing is not at the expected address");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private void focusDecompiler() {
|
||||||
|
runSwing(() -> provider.requestFocus());
|
||||||
|
waitForSwing();
|
||||||
|
}
|
||||||
|
|
||||||
|
private void previousFunction() {
|
||||||
|
NextPrevAddressPlugin plugin = env.getPlugin(NextPrevAddressPlugin.class);
|
||||||
|
DockingAction previousFunctionAction =
|
||||||
|
(DockingAction) getInstanceField("previousFunctionAction", plugin);
|
||||||
|
|
||||||
|
ActionContext context = runSwing(() -> provider.getActionContext(null));
|
||||||
|
assertTrue(previousFunctionAction.isEnabledForContext(context));
|
||||||
|
performAction(previousFunctionAction, context, true);
|
||||||
|
waitForSwing();
|
||||||
|
}
|
||||||
|
|
||||||
|
private void assertListingAddress(Address expected) {
|
||||||
|
waitForCondition(() -> expected.equals(codeBrowser.getCurrentLocation().getAddress()),
|
||||||
|
"The Listing is not at the expected address");
|
||||||
|
}
|
||||||
|
|
||||||
private void assertExternalNavigationPerformed() {
|
private void assertExternalNavigationPerformed() {
|
||||||
// going to the 'external linkage' means we went to the thunk function and not the
|
// going to the 'external linkage' means we went to the thunk function and not the
|
||||||
// external program
|
// external program
|
||||||
@ -269,9 +274,7 @@ public class DecompilerNavigationTest extends AbstractDecompilerTest {
|
|||||||
|
|
||||||
private void createThunkToExternal(String addressString) throws Exception {
|
private void createThunkToExternal(String addressString) throws Exception {
|
||||||
|
|
||||||
int txId = program.startTransaction("Set External Location");
|
tx(program, () -> {
|
||||||
try {
|
|
||||||
|
|
||||||
program.getExternalManager().setExternalPath("ADVAPI32.dll", "/FILE1", true);
|
program.getExternalManager().setExternalPath("ADVAPI32.dll", "/FILE1", true);
|
||||||
|
|
||||||
Address address = addr(addressString);
|
Address address = addr(addressString);
|
||||||
@ -289,12 +292,6 @@ public class DecompilerNavigationTest extends AbstractDecompilerTest {
|
|||||||
|
|
||||||
Function function = program.getFunctionManager().getFunctionAt(addr(addressString));
|
Function function = program.getFunctionManager().getFunctionAt(addr(addressString));
|
||||||
function.setThunkedFunction(externalLocation.getFunction());
|
function.setThunkedFunction(externalLocation.getFunction());
|
||||||
}
|
});
|
||||||
finally {
|
|
||||||
program.endTransaction(txId, true);
|
|
||||||
}
|
|
||||||
|
|
||||||
program.flushEvents();
|
|
||||||
waitForSwing();
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user