Ghidra is a software reverse engineering (SRE) framework
Tests - fixed tests failing to bad test mouse clicking and focus
dragonmacher881dca75bfce
diff --git a/Ghidra/Features/Base/src/main/java/ghidra/test/AbstractGhidraHeadedIntegrationTest.java b/Ghidra/Features/Base/src/main/java/ghidra/test/AbstractGhidraHeadedIntegrationTest.javaindex b8b06dd029..c5bafe1aa7 100644--- a/Ghidra/Features/Base/src/main/java/ghidra/test/AbstractGhidraHeadedIntegrationTest.java+++ b/Ghidra/Features/Base/src/main/java/ghidra/test/AbstractGhidraHeadedIntegrationTest.java@@ -215,10 +215,14 @@ public abstract class AbstractGhidraHeadedIntegrationTest}protected void click(FieldPanel fp, int clickCount, boolean wait) {-Point cursor = fp.getCursorPoint();- int x = cursor.x;- int y = cursor.y;+ click(fp, cursor, clickCount, wait);+ }++ protected void click(FieldPanel fp, Point p, int clickCount, boolean wait) {++ int x = p.x;+ int y = p.y;MouseEvent ev = new MouseEvent(fp, 0, System.currentTimeMillis(), 0, x, y, clickCount,false, MouseEvent.BUTTON1);diff --git a/Ghidra/Features/Decompiler/src/test.slow/java/ghidra/app/plugin/core/decompile/AbstractDecompilerTest.java b/Ghidra/Features/Decompiler/src/test.slow/java/ghidra/app/plugin/core/decompile/AbstractDecompilerTest.javaindex ccdf8caea0..ffa51a1d6a 100644--- a/Ghidra/Features/Decompiler/src/test.slow/java/ghidra/app/plugin/core/decompile/AbstractDecompilerTest.java+++ b/Ghidra/Features/Decompiler/src/test.slow/java/ghidra/app/plugin/core/decompile/AbstractDecompilerTest.java@@ -17,6 +17,7 @@ package ghidra.app.plugin.core.decompile;import static org.junit.Assert.*;+import java.awt.Point;import java.util.List;import org.junit.After;@@ -76,10 +77,15 @@ public abstract class AbstractDecompilerTest extends AbstractProgramBasedTest {protected void setDecompilerLocation(int line, int charPosition) {- runSwing(() -> provider.setCursorLocation(line, charPosition));DecompilerPanel panel = provider.getDecompilerPanel();FieldPanel fp = panel.getFieldPanel();- click(fp, 1, true);+ FieldLocation loc = loc(line, charPosition);++ // scroll to the field to make sure it has been built so that we can get its point+ fp.scrollTo(loc);+ Point p = fp.getPointForLocation(loc);++ click(fp, p, 1, true);waitForSwing();}diff --git a/Ghidra/Features/Decompiler/src/test.slow/java/ghidra/app/plugin/core/decompile/DecompilerNavigationTest.java b/Ghidra/Features/Decompiler/src/test.slow/java/ghidra/app/plugin/core/decompile/DecompilerNavigationTest.javaindex 558a87bb6f..5e2ebfba7a 100644--- a/Ghidra/Features/Decompiler/src/test.slow/java/ghidra/app/plugin/core/decompile/DecompilerNavigationTest.java+++ b/Ghidra/Features/Decompiler/src/test.slow/java/ghidra/app/plugin/core/decompile/DecompilerNavigationTest.java@@ -173,6 +173,7 @@ public class DecompilerNavigationTest extends AbstractDecompilerTest {assertToken("FUN_01002c93", line, character);setDecompilerLocation(line, character);+ // this is the address within the function of the call to the function we clickedassertListingAddress(addr("01002d32"));}@@ -223,9 +224,8 @@ public class DecompilerNavigationTest extends AbstractDecompilerTest {}private void assertListingAddress(Address expected) {- ProgramLocation cbLocation = codeBrowser.getCurrentLocation();- assertEquals("The Listing is not at the expected address", expected,- cbLocation.getAddress());+ waitForCondition(() -> expected.equals(codeBrowser.getCurrentLocation().getAddress()),+ "The Listing is not at the expected address");}private void assertExternalNavigationPerformed() {diff --git a/Ghidra/Framework/Docking/src/main/java/docking/widgets/fieldpanel/FieldPanel.java b/Ghidra/Framework/Docking/src/main/java/docking/widgets/fieldpanel/FieldPanel.javaindex 31784d943a..e51125d69b 100644--- a/Ghidra/Framework/Docking/src/main/java/docking/widgets/fieldpanel/FieldPanel.java+++ b/Ghidra/Framework/Docking/src/main/java/docking/widgets/fieldpanel/FieldPanel.java@@ -1193,7 +1193,18 @@ public class FieldPanel extends JPanelcursorHandler.doCursorEnd(trigger);}- private FieldLocation getLocationForPoint(int x, int y) {+ public Point getPointForLocation(FieldLocation location) {++ AnchoredLayout layout = findLayoutOnScreen(location.getIndex());+ if (layout == null) {+ return null;+ }+ Rectangle r =+ layout.getCursorRect(location.fieldNum, location.row, location.col);+ return r.getLocation();+ }++ public FieldLocation getLocationForPoint(int x, int y) {FieldLocation location = new FieldLocation();// delegate to the appropriate layout to do the workLayout layout = findLayoutAt(y);diff --git a/Ghidra/Framework/Docking/src/test.slow/java/docking/widgets/filechooser/GhidraFileChooserTest.java b/Ghidra/Framework/Docking/src/test.slow/java/docking/widgets/filechooser/GhidraFileChooserTest.javaindex 17a14bb5bc..a1158054c7 100644--- a/Ghidra/Framework/Docking/src/test.slow/java/docking/widgets/filechooser/GhidraFileChooserTest.java+++ b/Ghidra/Framework/Docking/src/test.slow/java/docking/widgets/filechooser/GhidraFileChooserTest.java@@ -1724,6 +1724,12 @@ public class GhidraFileChooserTest extends AbstractDockingTest {@Testpublic void testFocus_FilesViewStaysFocusedAfterRefresh() throws Exception {+ if (BATCH_MODE) {+ // I don't like this, but these seem to have a focus sensitivity that+ // does not work correctly in headless+ return;+ }+DirectoryList list = getListView();focus(list);