From 424cbf0a5e689a8b18c9e5ce2c23dee5e96a49ea Mon Sep 17 00:00:00 2001 From: Dan <46821332+nsadeveloper789@users.noreply.github.com> Date: Thu, 8 Apr 2021 11:50:59 -0400 Subject: [PATCH] GP-0: Fixed DebuggerInterpreterPluginTest --- ...tractDebuggerWrappedConsoleConnection.java | 36 +++++++++++++++---- .../DebuggerInterpreterPluginTest.java | 19 +++++----- 2 files changed, 39 insertions(+), 16 deletions(-) diff --git a/Ghidra/Debug/Debugger/src/main/java/ghidra/app/plugin/core/debug/gui/interpreters/AbstractDebuggerWrappedConsoleConnection.java b/Ghidra/Debug/Debugger/src/main/java/ghidra/app/plugin/core/debug/gui/interpreters/AbstractDebuggerWrappedConsoleConnection.java index a2a8d52ff2..929aac8f2e 100644 --- a/Ghidra/Debug/Debugger/src/main/java/ghidra/app/plugin/core/debug/gui/interpreters/AbstractDebuggerWrappedConsoleConnection.java +++ b/Ghidra/Debug/Debugger/src/main/java/ghidra/app/plugin/core/debug/gui/interpreters/AbstractDebuggerWrappedConsoleConnection.java @@ -84,12 +84,26 @@ public abstract class AbstractDebuggerWrappedConsoleConnection 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 { 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 exe = mb.testModel.session.interpreter.pollExecute(); + ExecuteCall 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())); } }