GP-0: Fixed DebuggerInterpreterPluginTest

This commit is contained in:
Dan 2021-04-08 11:50:59 -04:00
parent 13fcd3f20d
commit 424cbf0a5e
2 changed files with 39 additions and 16 deletions

View File

@ -84,12 +84,26 @@ public abstract class AbstractDebuggerWrappedConsoleConnection<T extends TargetO
@AttributeCallback(TargetObject.DISPLAY_ATTRIBUTE_NAME)
public void displayChanged(TargetObject object, String display) {
// TODO: Add setSubTitle(String) to InterpreterConsole
if (guiConsole == null) {
/**
* Can happen during init. setSubTitle will get called immediately after guiConsole
* is initialized.
*/
return;
}
InterpreterComponentProvider provider = (InterpreterComponentProvider) guiConsole;
Swing.runLater(() -> provider.setSubTitle(display));
}
@AttributeCallback(TargetInterpreter.PROMPT_ATTRIBUTE_NAME)
public void promptChanged(TargetObject interpreter, String prompt) {
if (guiConsole == null) {
/**
* Can happen during init. setPrompt will get called immediately after guiConsole is
* initialized. NB. It happens in DebuggerWrappedInterpreterConnection
*/
return;
}
Swing.runLater(() -> guiConsole.setPrompt(prompt));
}
@ -97,13 +111,7 @@ public abstract class AbstractDebuggerWrappedConsoleConnection<T extends TargetO
public void invalidated(TargetObject object, TargetObject branch, String reason) {
Swing.runLater(() -> {
if (object == targetConsole) { // Redundant
if (pinned) {
running.set(false);
plugin.disableConsole(targetConsole, guiConsole);
}
else {
plugin.destroyConsole(targetConsole, guiConsole);
}
consoleInvalidated();
}
});
}
@ -161,6 +169,20 @@ public abstract class AbstractDebuggerWrappedConsoleConnection<T extends TargetO
setStdIn(guiConsole.getStdin());
createActions();
if (!targetConsole.isValid()) {
consoleInvalidated();
}
}
protected void consoleInvalidated() {
if (pinned) {
running.set(false);
plugin.disableConsole(targetConsole, guiConsole);
}
else {
plugin.destroyConsole(targetConsole, guiConsole);
}
}
protected void createActions() {

View File

@ -63,13 +63,14 @@ public class DebuggerInterpreterPluginTest extends AbstractGhidraHeadedDebuggerG
// Can't get at the component, so send keystrokes?
Robot robot = new Robot();
robot.keyPress(KeyEvent.VK_A);
robot.keyRelease(KeyEvent.VK_A);
robot.keyPress(KeyEvent.VK_ENTER);
robot.keyRelease(KeyEvent.VK_ENTER);
waitForSwing();
ExecuteCall<Void> exe = mb.testModel.session.interpreter.pollExecute();
ExecuteCall<Void> exe = waitForValue(() -> {
robot.keyPress(KeyEvent.VK_A);
robot.keyRelease(KeyEvent.VK_A);
robot.keyPress(KeyEvent.VK_ENTER);
robot.keyRelease(KeyEvent.VK_ENTER);
waitForSwing();
return mb.testModel.session.interpreter.pollExecute();
});
assertEquals("a", exe.cmd);
exe.complete(null); // Not necessary, but cleaner
}
@ -128,7 +129,7 @@ public class DebuggerInterpreterPluginTest extends AbstractGhidraHeadedDebuggerG
), Map.of(), "Invalidate interpreter");
waitForSwing();
assertFalse(interpreter.isVisible());
waitForPass(() -> assertFalse(interpreter.isVisible()));
assertFalse(interpreter.isInTool());
}
@ -146,6 +147,6 @@ public class DebuggerInterpreterPluginTest extends AbstractGhidraHeadedDebuggerG
), Map.of(), "Invalidate interpreter");
waitForSwing();
assertFalse(interpreter.isInputPermitted());
waitForPass(() -> assertFalse(interpreter.isInputPermitted()));
}
}